From: Alejandro Lucero Date: Tue, 22 Aug 2017 10:41:26 +0000 (+0100) Subject: net/nfp: handle packets with length 0 as usual ones X-Git-Tag: spdx-start~2108 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f78f0e64f772aa32bdca79a17835db8f2c57c1d9;p=dpdk.git net/nfp: handle packets with length 0 as usual ones A DPDK app could, whatever the reason, send packets with size 0. The PMD is not sending those packets, which does make sense, but the problem is the mbuf is not released either. That leads to mbufs not being available, because the app trusts the PMD will do it. Although this is a problem related to app wrong behavior, we should harden the PMD in this regard. Not sending a packet with size 0 could be problematic, needing special handling inside the PMD xmit function. It could be a burst of those packets, which can be easily handled, but it could also be a single packet in a burst, what is harder to handle. It would be simpler to just send that kind of packets, which will likely be dropped by the hw at some point. The main problem is how the fw/hw handles the DMA, because a dma read to a hypothetical 0x0 address could trigger an IOMMU error. It turns out, it is safe to send a descriptor with packet size 0 to the hardware: the DMA never happens, from the PCIe point of view. Signed-off-by: Alejandro Lucero --- diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index efa18e12b2..a76dbd48fa 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -2110,7 +2110,7 @@ nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) */ pkt_size = pkt->pkt_len; - while (pkt_size) { + while (pkt) { /* Copying TSO, VLAN and cksum info */ *txds = txd; @@ -2142,13 +2142,13 @@ nfp_net_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) txq->wr_p = 0; pkt_size -= dma_size; - if (!pkt_size) { + if (!pkt_size) /* End of packet */ txds->offset_eop |= PCIE_DESC_TX_EOP; - } else { + else txds->offset_eop &= PCIE_DESC_TX_OFFSET_MASK; - pkt = pkt->next; - } + + pkt = pkt->next; /* Referencing next free TX descriptor */ txds = &txq->txds[txq->wr_p]; lmbuf = &txq->txbufs[txq->wr_p].mbuf;