From patchwork Fri Jan 27 14:29:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 92660 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp231067obz; Fri, 27 Jan 2017 06:35:43 -0800 (PST) X-Received: by 10.200.53.150 with SMTP id k22mr8341326qtb.19.1485527743461; Fri, 27 Jan 2017 06:35:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e184si3653784qkc.72.2017.01.27.06.35.43; Fri, 27 Jan 2017 06:35:43 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1886360838; Fri, 27 Jan 2017 14:35:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id F3E9262E05; Fri, 27 Jan 2017 14:30:57 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2E6A360E18; Fri, 27 Jan 2017 14:30:49 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 53628609AC for ; Fri, 27 Jan 2017 14:29:55 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id z134so162792203lff.3 for ; Fri, 27 Jan 2017 06:29:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SmHcSRi6tGMUHUzpMu7/Eq/gr8xUWwkKGFv8NvJkCu4=; b=T2+eE9ZaHydEJQZ3LTRZ2LzIQvkK5M9R1xQZ0+e75genSPSSuSZF3V+hkuSH++FqMe Y3hwyRZU5t7eteA7gS/mzIE2dmptkbkXeK7qlIcevothVmr1kpJheTtuR2Bwh32opy87 fIQBsUfbEcE84t0VsXShKHVquASRbyNRlid477/YYe0CiJCesYYPGynYok7LTHci1k74 RF9V1wCt4k/zbsCHceqeQC8pNyDTIOQhcVkboiYx+oA9GMT3TvDonBubn6P+44jYqqvI nFdTUzgjhfEAI86QeQyqZjJPPNLbe8Lw+I6N5tfwLxsoQg01u0NS0miQJ9at02Bey4EI Nzkg== X-Gm-Message-State: AIkVDXI2ExlvyG7M8fcKeW47IUxt8+n800uaXf2DC5GLrYnOwm3OzecMcMUnJFQbnH4gFsVDtug= X-Received: by 10.46.83.93 with SMTP id t29mr3266219ljd.20.1485527393501; Fri, 27 Jan 2017 06:29:53 -0800 (PST) Received: from localhost.localdomain (ppp109-252-7-40.pppoe.spdop.ru. [109.252.7.40]) by smtp.gmail.com with ESMTPSA id t9sm1325479lja.48.2017.01.27.06.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Jan 2017 06:29:52 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 27 Jan 2017 17:29:14 +0300 Message-Id: <20170127142921.29029-9-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce In-Reply-To: <20170127142921.29029-1-maxim.uvarov@linaro.org> References: <20170127142921.29029-1-maxim.uvarov@linaro.org> Subject: [lng-odp] [API-NEXT PATCH 08/15] merge fix: odp_packet.c X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" --- platform/linux-generic/odp_packet.c | 513 ------------------------------------ 1 file changed, 513 deletions(-) -- 2.11.0.295.gd7dffce diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 12981495..170965ac 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -33,7 +33,6 @@ static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->buf_hdr.handle.handle; } -<<<<<<< HEAD static inline uint32_t packet_ref_inc(odp_packet_hdr_t *pkt_hdr) { return odp_atomic_fetch_inc_u32(&pkt_hdr->ref_count); @@ -44,20 +43,14 @@ static inline uint32_t packet_ref_dec(odp_packet_hdr_t *pkt_hdr) return odp_atomic_fetch_dec_u32(&pkt_hdr->ref_count); } -======= ->>>>>>> v1.13.0.0 static inline uint32_t packet_seg_len(odp_packet_hdr_t *pkt_hdr, uint32_t seg_idx) { return pkt_hdr->buf_hdr.seg[seg_idx].len; } -<<<<<<< HEAD static inline uint8_t *packet_seg_data(odp_packet_hdr_t *pkt_hdr, uint32_t seg_idx) -======= -static inline void *packet_seg_data(odp_packet_hdr_t *pkt_hdr, uint32_t seg_idx) ->>>>>>> v1.13.0.0 { return pkt_hdr->buf_hdr.seg[seg_idx].data; } @@ -70,14 +63,11 @@ static inline int packet_last_seg(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->buf_hdr.segcount - 1; } -<<<<<<< HEAD static inline void *packet_data(odp_packet_hdr_t *pkt_hdr) { return pkt_hdr->buf_hdr.seg[0].data; } -======= ->>>>>>> v1.13.0.0 static inline uint32_t packet_first_seg_len(odp_packet_hdr_t *pkt_hdr) { return packet_seg_len(pkt_hdr, 0); @@ -90,14 +80,6 @@ static inline uint32_t packet_last_seg_len(odp_packet_hdr_t *pkt_hdr) return packet_seg_len(pkt_hdr, last); } -<<<<<<< HEAD -======= -static inline void *packet_data(odp_packet_hdr_t *pkt_hdr) -{ - return pkt_hdr->buf_hdr.seg[0].data; -} - ->>>>>>> v1.13.0.0 static inline void *packet_tail(odp_packet_hdr_t *pkt_hdr) { int last = packet_last_seg(pkt_hdr); @@ -128,10 +110,7 @@ static inline void push_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) { pkt_hdr->headroom -= len; pkt_hdr->frame_len += len; -<<<<<<< HEAD pkt_hdr->unshared_len += len; -======= ->>>>>>> v1.13.0.0 pkt_hdr->buf_hdr.seg[0].data -= len; pkt_hdr->buf_hdr.seg[0].len += len; } @@ -140,10 +119,7 @@ static inline void pull_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) { pkt_hdr->headroom += len; pkt_hdr->frame_len -= len; -<<<<<<< HEAD pkt_hdr->unshared_len -= len; -======= ->>>>>>> v1.13.0.0 pkt_hdr->buf_hdr.seg[0].data += len; pkt_hdr->buf_hdr.seg[0].len -= len; } @@ -154,10 +130,7 @@ static inline void push_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len) pkt_hdr->tailroom -= len; pkt_hdr->frame_len += len; -<<<<<<< HEAD pkt_hdr->unshared_len += len; -======= ->>>>>>> v1.13.0.0 pkt_hdr->buf_hdr.seg[last].len += len; } @@ -185,13 +158,10 @@ static inline void packet_seg_copy_md(odp_packet_hdr_t *dst, dst->buf_hdr.uarea_addr = src->buf_hdr.uarea_addr; dst->buf_hdr.uarea_size = src->buf_hdr.uarea_size; -<<<<<<< HEAD /* reference related metadata */ dst->ref_len = src->ref_len; dst->unshared_len = src->unshared_len; -======= ->>>>>>> v1.13.0.0 /* segmentation data is not copied: * buf_hdr.seg[] * buf_hdr.segcount @@ -206,7 +176,6 @@ static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, int seg = 0; int seg_count = pkt_hdr->buf_hdr.segcount; -<<<<<<< HEAD /* Special processing for references */ while (offset >= pkt_hdr->frame_len && pkt_hdr->ref_hdr) { offset -= (pkt_hdr->frame_len - pkt_hdr->ref_offset); @@ -216,9 +185,6 @@ static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, } if (odp_unlikely(offset > pkt_hdr->frame_len)) -======= - if (odp_unlikely(offset >= pkt_hdr->frame_len)) ->>>>>>> v1.13.0.0 return NULL; if (odp_likely(CONFIG_PACKET_MAX_SEGS == 1 || seg_count == 1)) { @@ -331,7 +297,6 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) hdr->buf_hdr.seg[0].data = hdr->buf_hdr.base_data; hdr->buf_hdr.seg[0].len = BASE_LEN; -<<<<<<< HEAD packet_ref_count_set(hdr, 1); /* Link segments */ @@ -358,32 +323,6 @@ static inline int num_segments(uint32_t len) uint32_t max_seg_len; int num; -======= - - /* Link segments */ - if (CONFIG_PACKET_MAX_SEGS != 1) { - hdr->buf_hdr.segcount = num; - - if (odp_unlikely(num > 1)) { - for (i = 1; i < num; i++) { - odp_buffer_hdr_t *buf_hdr; - - buf_hdr = &pkt_hdr[i]->buf_hdr; - hdr->buf_hdr.seg[i].hdr = buf_hdr; - hdr->buf_hdr.seg[i].data = buf_hdr->base_data; - hdr->buf_hdr.seg[i].len = BASE_LEN; - } - } - } -} - -/* Calculate the number of segments */ -static inline int num_segments(uint32_t len) -{ - uint32_t max_seg_len; - int num; - ->>>>>>> v1.13.0.0 if (CONFIG_PACKET_MAX_SEGS == 1) return 1; @@ -414,7 +353,6 @@ static inline void add_all_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from) to->buf_hdr.segcount = n + num; } -<<<<<<< HEAD static inline void copy_num_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from, int first, int num) @@ -425,180 +363,6 @@ static inline void copy_num_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from, to->buf_hdr.seg[i].hdr = from->buf_hdr.seg[first + i].hdr; to->buf_hdr.seg[i].data = from->buf_hdr.seg[first + i].data; to->buf_hdr.seg[i].len = from->buf_hdr.seg[first + i].len; -======= - -static inline void copy_num_segs(odp_packet_hdr_t *to, odp_packet_hdr_t *from, - int first, int num) -{ - int i; - - for (i = 0; i < num; i++) { - to->buf_hdr.seg[i].hdr = from->buf_hdr.seg[first + i].hdr; - to->buf_hdr.seg[i].data = from->buf_hdr.seg[first + i].data; - to->buf_hdr.seg[i].len = from->buf_hdr.seg[first + i].len; - } - - to->buf_hdr.segcount = num; -} - -static inline odp_packet_hdr_t *alloc_segments(pool_t *pool, int num) -{ - odp_buffer_t buf[num]; - odp_packet_hdr_t *pkt_hdr[num]; - int ret; - - ret = buffer_alloc_multi(pool, buf, (odp_buffer_hdr_t **)pkt_hdr, num); - if (odp_unlikely(ret != num)) { - if (ret > 0) - buffer_free_multi(buf, ret); - - return NULL; - } - - init_segments(pkt_hdr, num); - - return pkt_hdr[0]; -} - -static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr, - pool_t *pool, uint32_t len, - int num, int head) -{ - odp_packet_hdr_t *new_hdr; - uint32_t seg_len, offset; - - new_hdr = alloc_segments(pool, num); - - if (new_hdr == NULL) - return NULL; - - seg_len = len - ((num - 1) * pool->max_seg_len); - offset = pool->max_seg_len - seg_len; - - if (head) { - /* add into the head*/ - add_all_segs(new_hdr, pkt_hdr); - - /* adjust first segment length */ - new_hdr->buf_hdr.seg[0].data += offset; - new_hdr->buf_hdr.seg[0].len = seg_len; - - packet_seg_copy_md(new_hdr, pkt_hdr); - new_hdr->frame_len = pkt_hdr->frame_len + len; - new_hdr->headroom = pool->headroom + offset; - new_hdr->tailroom = pkt_hdr->tailroom; - - pkt_hdr = new_hdr; - } else { - int last; - - /* add into the tail */ - add_all_segs(pkt_hdr, new_hdr); - - /* adjust last segment length */ - last = packet_last_seg(pkt_hdr); - pkt_hdr->buf_hdr.seg[last].len = seg_len; - - pkt_hdr->frame_len += len; - pkt_hdr->tailroom = pool->tailroom + offset; - } - - return pkt_hdr; -} - -static inline void free_bufs(odp_packet_hdr_t *pkt_hdr, int first, int num) -{ - int i; - odp_buffer_t buf[num]; - - for (i = 0; i < num; i++) - buf[i] = buffer_handle(pkt_hdr->buf_hdr.seg[first + i].hdr); - - buffer_free_multi(buf, num); -} - -static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, - int num, uint32_t free_len, - uint32_t pull_len, int head) -{ - int num_remain = pkt_hdr->buf_hdr.segcount - num; - - if (head) { - odp_packet_hdr_t *new_hdr; - int i; - odp_buffer_t buf[num]; - - for (i = 0; i < num; i++) - buf[i] = buffer_handle(pkt_hdr->buf_hdr.seg[i].hdr); - - /* First remaining segment is the new packet descriptor */ - new_hdr = pkt_hdr->buf_hdr.seg[num].hdr; - - copy_num_segs(new_hdr, pkt_hdr, num, num_remain); - packet_seg_copy_md(new_hdr, pkt_hdr); - - /* Tailroom not changed */ - new_hdr->tailroom = pkt_hdr->tailroom; - new_hdr->headroom = seg_headroom(new_hdr, 0); - new_hdr->frame_len = pkt_hdr->frame_len - free_len; - - pull_head(new_hdr, pull_len); - - pkt_hdr = new_hdr; - - buffer_free_multi(buf, num); - } else { - /* Free last 'num' bufs */ - free_bufs(pkt_hdr, num_remain, num); - - /* Head segment remains, no need to copy or update majority - * of the metadata. */ - pkt_hdr->buf_hdr.segcount = num_remain; - pkt_hdr->frame_len -= free_len; - pkt_hdr->tailroom = seg_tailroom(pkt_hdr, num_remain - 1); - - pull_tail(pkt_hdr, pull_len); - } - - return pkt_hdr; -} - -static inline int packet_alloc(pool_t *pool, uint32_t len, int max_pkt, - int num_seg, odp_packet_t *pkt, int parse) -{ - int num_buf, i; - int num = max_pkt; - int max_buf = max_pkt * num_seg; - odp_buffer_t buf[max_buf]; - odp_packet_hdr_t *pkt_hdr[max_buf]; - - num_buf = buffer_alloc_multi(pool, buf, (odp_buffer_hdr_t **)pkt_hdr, - max_buf); - - /* Failed to allocate all segments */ - if (odp_unlikely(num_buf != max_buf)) { - int num_free; - - num = num_buf / num_seg; - num_free = num_buf - (num * num_seg); - - if (num_free > 0) - buffer_free_multi(&buf[num_buf - num_free], num_free); - - if (num == 0) - return 0; - } - - for (i = 0; i < num; i++) { - odp_packet_hdr_t *hdr; - - /* First buffer is the packet descriptor */ - pkt[i] = (odp_packet_t)buf[i * num_seg]; - hdr = pkt_hdr[i * num_seg]; - init_segments(&pkt_hdr[i * num_seg], num_seg); - - packet_init(hdr, len, parse); ->>>>>>> v1.13.0.0 } to->buf_hdr.segcount = num; @@ -792,18 +556,6 @@ int packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, return num; } -int packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, - odp_packet_t pkt[], int max_num) -{ - pool_t *pool = pool_entry_from_hdl(pool_hdl); - int num, num_seg; - - num_seg = num_segments(len); - num = packet_alloc(pool, len, max_num, num_seg, pkt, 1); - - return num; -} - odp_packet_t odp_packet_alloc(odp_pool_t pool_hdl, uint32_t len) { pool_t *pool = pool_entry_from_hdl(pool_hdl); @@ -840,7 +592,6 @@ int odp_packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, if (odp_unlikely(len > pool->max_len)) return -1; -<<<<<<< HEAD num_seg = num_segments(len); num = packet_alloc(pool, len, max_num, num_seg, pkt, 0); @@ -863,65 +614,19 @@ static inline void packet_free(odp_packet_hdr_t *pkt_hdr) pkt_hdr = ref_hdr; } while (pkt_hdr); -======= - - num_seg = num_segments(len); - num = packet_alloc(pool, len, max_num, num_seg, pkt, 0); - - return num; ->>>>>>> v1.13.0.0 } void odp_packet_free(odp_packet_t pkt) { -<<<<<<< HEAD packet_free(odp_packet_hdr(pkt)); -======= - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - int num_seg = pkt_hdr->buf_hdr.segcount; - - if (odp_likely(CONFIG_PACKET_MAX_SEGS == 1 || num_seg == 1)) - buffer_free_multi((odp_buffer_t *)&pkt, 1); - else - free_bufs(pkt_hdr, 0, num_seg); ->>>>>>> v1.13.0.0 } void odp_packet_free_multi(const odp_packet_t pkt[], int num) { -<<<<<<< HEAD int i; for (i = 0; i < num; i++) packet_free(odp_packet_hdr(pkt[i])); -======= - if (CONFIG_PACKET_MAX_SEGS == 1) { - buffer_free_multi((const odp_buffer_t * const)pkt, num); - } else { - odp_buffer_t buf[num * CONFIG_PACKET_MAX_SEGS]; - int i, j; - int bufs = 0; - - for (i = 0; i < num; i++) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt[i]); - int num_seg = pkt_hdr->buf_hdr.segcount; - odp_buffer_hdr_t *buf_hdr = &pkt_hdr->buf_hdr; - - buf[bufs] = (odp_buffer_t)pkt[i]; - bufs++; - - if (odp_likely(num_seg == 1)) - continue; - - for (j = 1; j < num_seg; j++) { - buf[bufs] = buffer_handle(buf_hdr->seg[j].hdr); - bufs++; - } - } - - buffer_free_multi(buf, bufs); - } ->>>>>>> v1.13.0.0 } int odp_packet_reset(odp_packet_t pkt, uint32_t len) @@ -932,12 +637,9 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len) if (len > pool->headroom + pool->data_size + pool->tailroom) return -1; -<<<<<<< HEAD if (pkt_hdr->ref_hdr) packet_free(pkt_hdr->ref_hdr); -======= ->>>>>>> v1.13.0.0 packet_init(pkt_hdr, len, 0); return 0; @@ -994,11 +696,7 @@ void *odp_packet_data(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); -<<<<<<< HEAD return packet_map(pkt_hdr, 0, NULL, NULL); -======= - return packet_data(pkt_hdr); ->>>>>>> v1.13.0.0 } uint32_t odp_packet_seg_len(odp_packet_t pkt) @@ -1244,11 +942,7 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); uint32_t frame_len = pkt_hdr->frame_len; -<<<<<<< HEAD uint32_t headroom = pkt_hdr->headroom; -======= - uint32_t headroom = pkt_hdr->headroom; ->>>>>>> v1.13.0.0 int ret = 0; if (len > headroom) { @@ -1258,7 +952,6 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, if (odp_unlikely((frame_len + len) > pool->max_len)) return -1; -<<<<<<< HEAD num = num_segments(len - headroom); segs = pkt_hdr->buf_hdr.segcount; @@ -1391,94 +1084,6 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, if (seg_len) *seg_len = seg_ln; } -======= - - num = num_segments(len - headroom); - segs = pkt_hdr->buf_hdr.segcount; - - if (odp_unlikely((segs + num) > CONFIG_PACKET_MAX_SEGS)) { - /* Cannot directly add new segments */ - odp_packet_hdr_t *new_hdr; - int new_segs = 0; - int free_segs = 0; - uint32_t offset; - - num = num_segments(frame_len + len); - - if (num > segs) { - /* Allocate additional segments */ - new_segs = num - segs; - new_hdr = alloc_segments(pool, new_segs); - - if (new_hdr == NULL) - return -1; - - } else if (num < segs) { - free_segs = segs - num; - } - - /* Pack all data to packet tail */ - move_data_to_tail(pkt_hdr, segs); - reset_seg(pkt_hdr, 0, segs); - - if (new_segs) { - add_all_segs(new_hdr, pkt_hdr); - packet_seg_copy_md(new_hdr, pkt_hdr); - segs += new_segs; - - pkt_hdr = new_hdr; - *pkt = packet_handle(pkt_hdr); - } else if (free_segs) { - new_hdr = pkt_hdr->buf_hdr.seg[free_segs].hdr; - packet_seg_copy_md(new_hdr, pkt_hdr); - - /* Free extra segs */ - free_bufs(pkt_hdr, 0, free_segs); - - segs -= free_segs; - pkt_hdr = new_hdr; - *pkt = packet_handle(pkt_hdr); - } - - frame_len += len; - offset = (segs * BASE_LEN) - frame_len; - - pkt_hdr->buf_hdr.seg[0].data += offset; - pkt_hdr->buf_hdr.seg[0].len -= offset; - - pkt_hdr->buf_hdr.segcount = segs; - pkt_hdr->frame_len = frame_len; - pkt_hdr->headroom = offset + pool->headroom; - pkt_hdr->tailroom = pool->tailroom; - - /* Data was moved */ - ret = 1; - } else { - void *ptr; - - push_head(pkt_hdr, headroom); - ptr = add_segments(pkt_hdr, pool, len - headroom, - num, 1); - - if (ptr == NULL) { - /* segment alloc failed, rollback changes */ - pull_head(pkt_hdr, headroom); - return -1; - } - - *pkt = packet_handle(ptr); - pkt_hdr = ptr; - } - } else { - push_head(pkt_hdr, len); - } - - if (data_ptr) - *data_ptr = packet_data(pkt_hdr); - - if (seg_len) - *seg_len = packet_first_seg_len(pkt_hdr); ->>>>>>> v1.13.0.0 return ret; } @@ -1499,19 +1104,13 @@ void *odp_packet_pull_head(odp_packet_t pkt, uint32_t len) int odp_packet_trunc_head(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len_out) { -<<<<<<< HEAD odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt), *nxt_hdr; uint32_t seg_len = packet_first_seg_len(pkt_hdr); int ret = 0; -======= - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); - uint32_t seg_len = packet_first_seg_len(pkt_hdr); ->>>>>>> v1.13.0.0 if (len > packet_len(pkt_hdr)) return -1; -<<<<<<< HEAD ODP_ASSERT(len <= odp_packet_unshared_len(*pkt)); /* Special processing for references */ @@ -1559,51 +1158,18 @@ int odp_packet_trunc_head(odp_packet_t *pkt, uint32_t len, } return ret; -======= - if (len < seg_len) { - pull_head(pkt_hdr, len); - } else if (CONFIG_PACKET_MAX_SEGS != 1) { - int num = 0; - uint32_t pull_len = 0; - - while (seg_len <= len) { - pull_len = len - seg_len; - num++; - seg_len += packet_seg_len(pkt_hdr, num); - } - - pkt_hdr = free_segments(pkt_hdr, num, len - pull_len, - pull_len, 1); - *pkt = packet_handle(pkt_hdr); - } - - if (data_ptr) - *data_ptr = packet_data(pkt_hdr); - - if (seg_len_out) - *seg_len_out = packet_first_seg_len(pkt_hdr); - - return 0; ->>>>>>> v1.13.0.0 } void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) { -<<<<<<< HEAD odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(pkt, NULL); -======= - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); ->>>>>>> v1.13.0.0 void *old_tail; if (len > pkt_hdr->tailroom) return NULL; -<<<<<<< HEAD ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); -======= ->>>>>>> v1.13.0.0 old_tail = packet_tail(pkt_hdr); push_tail(pkt_hdr, len); @@ -1613,17 +1179,12 @@ void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len_out) { -<<<<<<< HEAD odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(*pkt, NULL); -======= - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); ->>>>>>> v1.13.0.0 uint32_t frame_len = pkt_hdr->frame_len; uint32_t tailroom = pkt_hdr->tailroom; uint32_t tail_off = frame_len; int ret = 0; -<<<<<<< HEAD ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); if (len > tailroom) { @@ -1631,13 +1192,6 @@ int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, int num; int segs; -======= - if (len > tailroom) { - pool_t *pool = pool_entry_from_hdl(pkt_hdr->buf_hdr.pool_hdl); - int num; - int segs; - ->>>>>>> v1.13.0.0 if (odp_unlikely((frame_len + len) > pool->max_len)) return -1; @@ -1734,18 +1288,13 @@ int odp_packet_trunc_tail(odp_packet_t *pkt, uint32_t len, { int last; uint32_t seg_len; -<<<<<<< HEAD uint32_t offset; odp_packet_hdr_t *first_hdr = odp_packet_hdr(*pkt); odp_packet_hdr_t *pkt_hdr, *prev_hdr; -======= - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); ->>>>>>> v1.13.0.0 if (len > packet_len(first_hdr)) return -1; -<<<<<<< HEAD pkt_hdr = odp_packet_last_hdr(*pkt, &offset); /* Special processing for references */ @@ -1767,14 +1316,6 @@ int odp_packet_trunc_tail(odp_packet_t *pkt, uint32_t len, pkt_hdr->buf_hdr.segcount == 1) { pull_tail(pkt_hdr, len); } else { -======= - last = packet_last_seg(pkt_hdr); - seg_len = packet_seg_len(pkt_hdr, last); - - if (len < seg_len) { - pull_tail(pkt_hdr, len); - } else if (CONFIG_PACKET_MAX_SEGS != 1) { ->>>>>>> v1.13.0.0 int num = 0; uint32_t pull_len = 0; @@ -1989,7 +1530,6 @@ int odp_packet_is_segmented(odp_packet_t pkt) int odp_packet_num_segs(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); -<<<<<<< HEAD uint32_t segcount = 0, i; uint32_t seg_offset = 0, offset; @@ -2009,42 +1549,23 @@ int odp_packet_num_segs(odp_packet_t pkt) } while (pkt_hdr); return segcount; -======= - - return pkt_hdr->buf_hdr.segcount; ->>>>>>> v1.13.0.0 } odp_packet_seg_t odp_packet_first_seg(odp_packet_t pkt ODP_UNUSED) { -<<<<<<< HEAD -======= - (void)pkt; - ->>>>>>> v1.13.0.0 return 0; } odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt) { -<<<<<<< HEAD return (odp_packet_seg_t)(odp_packet_num_segs(pkt) - 1); -======= - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return packet_last_seg(pkt_hdr); ->>>>>>> v1.13.0.0 } odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); -<<<<<<< HEAD if (odp_unlikely(seg >= packet_last_seg(pkt_hdr))) -======= - if (odp_unlikely(seg >= (odp_packet_seg_t)packet_last_seg(pkt_hdr))) ->>>>>>> v1.13.0.0 return ODP_PACKET_SEG_INVALID; return seg + 1; @@ -2079,20 +1600,12 @@ void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg) if (odp_unlikely(seg + seg_offset >= pkt_hdr->buf_hdr.segcount)) return NULL; -<<<<<<< HEAD return packet_seg_data(pkt_hdr, seg + seg_offset) + offset; -======= - if (odp_unlikely(seg >= pkt_hdr->buf_hdr.segcount)) - return NULL; - - return packet_seg_data(pkt_hdr, seg); ->>>>>>> v1.13.0.0 } uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); -<<<<<<< HEAD uint32_t seg_offset = 0, offset = 0, i; while (seg >= pkt_hdr->buf_hdr.segcount - seg_offset && @@ -2113,13 +1626,6 @@ uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg) return 0; return packet_seg_len(pkt_hdr, seg + seg_offset) - offset; -======= - - if (odp_unlikely(seg >= pkt_hdr->buf_hdr.segcount)) - return 0; - - return packet_seg_len(pkt_hdr, seg); ->>>>>>> v1.13.0.0 } /* @@ -2244,7 +1750,6 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) uint32_t dst_len = dst_hdr->frame_len; uint32_t src_len = src_hdr->frame_len; -<<<<<<< HEAD ODP_ASSERT(packet_ref_count(dst_hdr) == 1); /* Do a copy if resulting packet would be out of segments or packets @@ -2252,12 +1757,6 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) if (odp_unlikely((dst_segs + src_segs) > CONFIG_PACKET_MAX_SEGS) || odp_unlikely(dst_pool != src_pool) || odp_unlikely(packet_ref_count(src_hdr)) > 1) { -======= - /* Do a copy if resulting packet would be out of segments or packets - * are from different pools. */ - if (odp_unlikely((dst_segs + src_segs) > CONFIG_PACKET_MAX_SEGS) || - odp_unlikely(dst_pool != src_pool)) { ->>>>>>> v1.13.0.0 if (odp_packet_extend_tail(dst, src_len, NULL, NULL) >= 0) { (void)odp_packet_copy_from_pkt(*dst, dst_len, src, 0, src_len); @@ -2272,14 +1771,9 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) add_all_segs(dst_hdr, src_hdr); -<<<<<<< HEAD dst_hdr->frame_len = dst_len + src_len; dst_hdr->unshared_len = dst_len + src_len; dst_hdr->tailroom = src_hdr->tailroom; -======= - dst_hdr->frame_len = dst_len + src_len; - dst_hdr->tailroom = src_hdr->tailroom; ->>>>>>> v1.13.0.0 /* Data was not moved in memory */ return 0; @@ -2628,17 +2122,10 @@ int odp_packet_is_valid(odp_packet_t pkt) { if (odp_buffer_is_valid((odp_buffer_t)pkt) == 0) return 0; -<<<<<<< HEAD if (odp_event_type(odp_packet_to_event(pkt)) != ODP_EVENT_PACKET) return 0; -======= - - if (odp_event_type(odp_packet_to_event(pkt)) != ODP_EVENT_PACKET) - return 0; - ->>>>>>> v1.13.0.0 return 1; }