[dpdk-stable] [PATCH] net/nfp: fix packet/data length conversion

Alejandro Lucero alejandro.lucero at netronome.com
Tue May 16 15:53:02 CEST 2017


[ backported from upstream commit 19ac8c75df90ef90ef8100b13ee3fed2da5a5ac7 ]

Chained mbufs hold data_len as the length of that particular mbuf
and pkt_len as the full packet length including all the chained
mbufs. It is not clear from the mbuf definition if pkt_len should
be set for all the mbufs in a chain, but code there for handling
mbufs suggests just the first mbuf requires to have pkt_len set.

NFP PMD was assuming pkt_len is set in all the chained mbufs and
unit tests for gather dma were building mbufs with pkt_len always
set. This patch gets rid of that assumption.

Fixes: b812daadad0d ("nfp: add Rx and Tx")

Signed-off-by: Alejandro Lucero <alejandro.lucero at netronome.com>
---
 drivers/net/nfp/nfp_net.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 099d82b..49c5293 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -1916,7 +1916,7 @@ int nfp_net_txq_full(struct nfp_net_txq *txq)
 	struct nfp_net_tx_desc *txds;
 	struct rte_mbuf *pkt;
 	uint64_t dma_addr;
-	int pkt_size, dma_size;
+	int pkt_size, pkt_len, dma_size;
 	uint16_t free_descs, issued_descs;
 	struct rte_mbuf **lmbuf;
 	int i;
@@ -1964,6 +1964,8 @@ int nfp_net_txq_full(struct nfp_net_txq *txq)
 		 * Checksum and VLAN flags just in the first descriptor for a
 		 * multisegment packet
 		 */
+
+		txds->data_len = pkt->pkt_len;
 		nfp_net_tx_cksum(txq, txds, pkt);
 
 		if ((pkt->ol_flags & PKT_TX_VLAN_PKT) &&
@@ -1981,6 +1983,7 @@ int nfp_net_txq_full(struct nfp_net_txq *txq)
 		 * then data_len = pkt_len
 		 */
 		pkt_size = pkt->pkt_len;
+		pkt_len = pkt->pkt_len;
 
 		/* Releasing mbuf which was prefetched above */
 		if (*lmbuf)
@@ -1999,7 +2002,7 @@ int nfp_net_txq_full(struct nfp_net_txq *txq)
 
 			/* Filling descriptors fields */
 			txds->dma_len = dma_size;
-			txds->data_len = pkt->pkt_len;
+			txds->data_len = pkt_len;
 			txds->dma_addr_hi = (dma_addr >> 32) & 0xff;
 			txds->dma_addr_lo = (dma_addr & 0xffffffff);
 			ASSERT(free_descs > 0);
-- 
1.9.1



More information about the stable mailing list