>
> <snip>
>

@@ -559,51 +587,30 @@ af_xdp_tx_zc(void *queue, struct rte_mbuf **bufs,
> uint16_t nb_pkts)
>                 mbuf = bufs[i];
>
>                 if (mbuf->pool == umem->mb_pool) {
> -                       if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx))
> {
> +                 if (!(desc = reserve_and_fill(txq, mbuf, umem, NULL))) {
>                                 kick_tx(txq, cq);
> -                               if (!xsk_ring_prod__reserve(&txq->tx, 1,
> -                                                           &idx_tx))
> +                               desc = reserve_and_fill(txq, mbuf, umem,
> NULL);
> +                               if (!desc)
>                                         goto out;
>                         }
> -                       desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx);
> -                       desc->len = mbuf->pkt_len;
> -                       addr = (uint64_t)mbuf - (uint64_t)umem->buffer -
> -                                       umem->mb_pool->header_size;
> -                       offset = rte_pktmbuf_mtod(mbuf, uint64_t) -
> -                                       (uint64_t)mbuf +
> -                                       umem->mb_pool->header_size;
> -                       offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT;
> -                       desc->addr = addr | offset;
> +
>                         tx_bytes += desc->len;
>                         count++;
>                 } else {
> -                       struct rte_mbuf *local_mbuf =
> -                                       rte_pktmbuf_alloc(umem->mb_pool);
> -                       void *pkt;
> -
> -                       if (local_mbuf == NULL)
> +                       if (!(local_mbuf =
> rte_pktmbuf_alloc(umem->mb_pool)))
>                                 goto out;
>
> -                       if (!xsk_ring_prod__reserve(&txq->tx, 1, &idx_tx))
> {
> +                       desc = reserve_and_fill(txq, local_mbuf, umem,
> &pkt);
> +                       if (!desc) {
>                                 rte_pktmbuf_free(local_mbuf);
>                                 goto out;
>                         }
>
> -                       desc = xsk_ring_prod__tx_desc(&txq->tx, idx_tx);
> -                       desc->len = mbuf->pkt_len;
> -
> -                       addr = (uint64_t)local_mbuf -
> (uint64_t)umem->buffer -
> -                                       umem->mb_pool->header_size;
> -                       offset = rte_pktmbuf_mtod(local_mbuf, uint64_t) -
> -                                       (uint64_t)local_mbuf +
> -                                       umem->mb_pool->header_size;
> -                       pkt = xsk_umem__get_data(umem->buffer, addr +
> offset);
> -                       offset = offset << XSK_UNALIGNED_BUF_OFFSET_SHIFT;
> -                       desc->addr = addr | offset;
> +                       desc->len = local_mbuf->pkt_len;
>

Sorry if my remarks were confusing, it was just missing from the previous
patch and it needs to be:
desc->len = mbuf->pkt_len;

We need to keep this the same as the original code. This is a scenario
where we need to copy the data from an mbuf that isn't in from the pool of
buffers allocated for the umem. So the desc->len needs to be set to that of
the (non umem) mbuf.

The other changes look good. Nearly there,

Thanks again

<snip>

Reply via email to