Hi, On 06/11, William Tu wrote: [snip] >> @@ -294,16 +326,26 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, >> uint16_t nb_pkts) >> >> desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx + i); >> mbuf = bufs[i]; >> - >> - desc->addr = (uint64_t)addrs[i]; >> desc->len = mbuf->pkt_len; >> - pkt = xsk_umem__get_data(umem->mz->addr, >> - desc->addr); >> - rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), >> - desc->len); >> - tx_bytes += mbuf->pkt_len; >> >> - rte_pktmbuf_free(mbuf); >> + /* >> + * We need to make sure the external mbuf address is within >> + * current port's umem memzone range >> + */ >> + if (pmd_zc && RTE_MBUF_HAS_EXTBUF(mbuf) && >> + in_umem_range(umem, >> (uint64_t)mbuf->buf_addr)) { >> + desc->addr = (uint64_t)mbuf->buf_addr - >> + umem->mz->addr_64; >> + mbuf->buf_addr = xsk_umem__get_data(umem->mz->addr, >> + (uint64_t)addrs[i]); >> + } else { >> + desc->addr = (uint64_t)addrs[i]; >> + pkt = xsk_umem__get_data(umem->mz->addr, >> + desc->addr); >> + rte_memcpy(pkt, rte_pktmbuf_mtod(mbuf, void *), >> + desc->len); >> + } >> + tx_bytes += mbuf->pkt_len; >> } >> >> xsk_ring_prod__submit(&txq->tx, nb_pkts); >> @@ -313,6 +355,9 @@ eth_af_xdp_tx(void *queue, struct rte_mbuf **bufs, >> uint16_t nb_pkts) >> txq->stats.tx_pkts += nb_pkts; >> txq->stats.tx_bytes += tx_bytes; >> >> + for (i = 0; i < nb_pkts; i++) >> + rte_pktmbuf_free(bufs[i]); >> + > >Is it ok to free the mbuf here? >If the AF_XDP is running pmd_zc=true, the packet mbuf is still in the tx >ring and might not be sent out yet.
For pmd_zc=ture case, here mbuf->buf_addr has been exchanged to available addr dequeued from umem->buf_ring, rte_pktmbuf_free would just call the free callback umem_buf_release_to_fq to enqueue the addr to the buf_ring. Thanks, Xiaolong > >Regards, >William >