From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 53BDD1B6A6 for ; Thu, 9 Nov 2017 14:51:44 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id k61so5664128wrc.4 for ; Thu, 09 Nov 2017 05:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=K8NvWRtROCgSd6/fyIFo9b2XfU0zShi6l4NfWP0tPxA=; b=p+A4HnLoCMbe6PaHZS+uswuRSQCflQPq4Jeg7tWk9vwGtW40iG5xrpnoUPRW6uGyKW VNfW00LzdShht2m96H+3PwvRZQTNN0qHk97/aPvBwPAABKlILqhT4j6z1dvMg7O8kzHJ L3AfhJxYdc28uvLgDNcqTlpHF1pvMasfMpoFA0WeU+iMYc8Tzdl/MVQBTh40T1OeE96C XCA2Y/OYetPOuKN01OcKKqjQDnS6ZLKjwgFL7dGq4m3Pqd690UfmWmUsVyuc7j4IYjFX yJ+buX8G+vUXso+Awn9MnfAmM7kTHMSEjXZ5Ar4823ig04Lqh6RXswag4zlc48nCu/Md 0rBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=K8NvWRtROCgSd6/fyIFo9b2XfU0zShi6l4NfWP0tPxA=; b=eV67lpPTHr+mT6B/ZJk9w890AgEA5U+g34hScv3/n9v6J7zNY1B8yTQbBcXtPj7v/c qvC0p8LDsYj7RiGoSWgVWtRpuKJbRPti/cIFu8FNTJv+LTC6hGgvXrwUF4CY0dgMowGK urDyDs4P8OU6T1PWV7/PZfDjt5YwPqFKTNVXkZ0z+5FfSBL0eFfULdmgHXjFiqZb41XB kVo2PYAxctYqoKlLyiIcqzFiJSPrgBaJtrN4w4EkXyb3JzfTs28cSWK16JSxUUkgOtDU nAwuevqxS+WgWHijR/v3mDDXzhoNgpgIkAujIqYRpS5x4+lsm2/bDTrckagNvhmU+LeG dwRQ== X-Gm-Message-State: AJaThX48Mf3kJjaELFCSDUQDFqAWa2eVVGLWurNUd6j3lD14L7bG9JEo rvRfxJ0h+Sg5ZhcLqErVu1omZuKr X-Google-Smtp-Source: ABhQp+R6PenwZQQiAm7R6qhy8XCWp7HufUxDqNnTJ6lZz1eKO9ZqVLaI+JOrjlzpML99kakmvzsUAQ== X-Received: by 10.223.171.22 with SMTP id q22mr559716wrc.62.1510235503786; Thu, 09 Nov 2017 05:51:43 -0800 (PST) Received: from [10.61.0.167] (bba193485.alshamil.net.ae. [217.165.96.191]) by smtp.gmail.com with ESMTPSA id k69sm8445964wmg.45.2017.11.09.05.51.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 05:51:43 -0800 (PST) From: Ilya Matveychikov Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Message-Id: <04EF52DF-6CE8-4EF4-96AA-711184F8379F@gmail.com> Date: Thu, 9 Nov 2017 17:51:41 +0400 To: dev@dpdk.org X-Mailer: Apple Mail (2.3273) Subject: [dpdk-dev] [PATCH] mbuf: fix for incomplete nb_segs/port types change X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Nov 2017 13:51:44 -0000 Update types of variables to correspond to nb_segs type change from uint8_t to uint16_t. Also, use 0xffff instead of 0xff to specify invalid port value. Fixes: 97cb466d ("mbuf: use 2 bytes for port and nb segments") Signed-off-by: Ilya V. Matveychikov --- lib/librte_mbuf/rte_mbuf.c | 6 +++--- lib/librte_mbuf/rte_mbuf.h | 13 ++++++++----- lib/librte_pdump/rte_pdump.c | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 26a62b8..f2213a4 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -144,7 +144,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, /* init some constant fields */ m->pool =3D mp; m->nb_segs =3D 1; - m->port =3D 0xff; + m->port =3D 0xffff; rte_mbuf_refcnt_set(m, 1); m->next =3D NULL; } @@ -203,7 +203,7 @@ void rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) { const struct rte_mbuf *m_seg; - unsigned nb_segs; + unsigned int nb_segs; if (m =3D=3D NULL) rte_panic("mbuf is NULL\n"); @@ -239,7 +239,7 @@ void rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len) { unsigned int len; - unsigned nb_segs; + unsigned int nb_segs; __rte_mbuf_sanity_check(m, 1); diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 55206d9..e07e916 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -546,6 +546,9 @@ struct rte_mbuf { } __rte_cache_aligned; +/**< Maximum number @nb_segs allowed. */ +#define RTE_MBUF_MAX_NB_SEGS 0xffff + /** * Prefetch the first part of the mbuf * @@ -1095,7 +1098,7 @@ static inline void rte_pktmbuf_reset(struct = rte_mbuf *m) m->vlan_tci =3D 0; m->vlan_tci_outer =3D 0; m->nb_segs =3D 1; - m->port =3D 0xff; + m->port =3D 0xffff; m->ol_flags =3D 0; m->packet_type =3D 0; @@ -1392,7 +1395,7 @@ static inline struct rte_mbuf = *rte_pktmbuf_clone(struct rte_mbuf *md, { struct rte_mbuf *mc, *mi, **prev; uint32_t pktlen; - uint8_t nseg; + uint16_t nseg; if (unlikely ((mc =3D rte_pktmbuf_alloc(mp)) =3D=3D NULL)) return NULL; @@ -1745,14 +1748,14 @@ static inline const void *rte_pktmbuf_read(const = struct rte_mbuf *m, * * @return * - 0, on success. - * - -EOVERFLOW, if the chain is full (256 entries) + * - -EOVERFLOW, if the chain segment limit exceded */ static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct = rte_mbuf *tail) { struct rte_mbuf *cur_tail; /* Check for number-of-segments-overflow */ - if (head->nb_segs + tail->nb_segs >=3D 1 << = (sizeof(head->nb_segs) * 8)) + if (head->nb_segs + tail->nb_segs > RTE_MBUF_MAX_NB_SEGS) return -EOVERFLOW; /* Chain 'tail' onto the old tail */ @@ -1760,7 +1763,7 @@ static inline int rte_pktmbuf_chain(struct = rte_mbuf *head, struct rte_mbuf *tail cur_tail->next =3D tail; /* accumulate number of segments and total length. */ - head->nb_segs =3D (uint8_t)(head->nb_segs + tail->nb_segs); + head->nb_segs +=3D tail->nb_segs; head->pkt_len +=3D tail->pkt_len; /* pkt_len is only set in the head */ diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index 1ca709d..2caf388 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -139,7 +139,7 @@ pdump_pktmbuf_copy(struct rte_mbuf *m, struct = rte_mempool *mp) { struct rte_mbuf *m_dup, *seg, **prev; uint32_t pktlen; - uint8_t nseg; + uint16_t nseg; m_dup =3D rte_pktmbuf_alloc(mp); if (unlikely(m_dup =3D=3D NULL)) -- 2.7.4=