0
votes

I set header room of 256bytes, and I want to use this for hold private data, but bnx2x_recv_pkts method set mbuf data_off to cqe_fp->placement_offset in dpdk? Why?

len = cqe_fp->pkt_len_or_gro_seg_len;
**pad = cqe_fp->placement_offset;**

new_mb = rte_mbuf_raw_alloc(rxq->mb_pool);
if (unlikely(!new_mb)) {
    PMD_RX_LOG(ERR, "mbuf alloc fail fp[%02d]", fp->index);
    rte_eth_devices[rxq->port_id].data->
            rx_mbuf_alloc_failed++;
    goto next_rx;
}

rx_mb = rxq->sw_ring[bd_cons];
rxq->sw_ring[bd_cons] = new_mb;
rxq->rx_ring[bd_prod] = new_mb->buf_physaddr;

rx_pref = NEXT_RX_BD(bd_cons) & MAX_RX_BD(rxq);
rte_prefetch0(rxq->sw_ring[rx_pref]);
if ((rx_pref & 0x3) == 0) {
    rte_prefetch0(&rxq->rx_ring[rx_pref]);
    rte_prefetch0(&rxq->sw_ring[rx_pref]);
}

**rx_mb->data_off = pad;**
rx_mb->nb_segs = 1;
rx_mb->next = NULL;
rx_mb->pkt_len = rx_mb->data_len = len;
rx_mb->port = rxq->port_id;
rte_prefetch1(rte_pktmbuf_mtod(rx_mb, void *));
2
I comment the line of rx_mb->data_off = pad, make a new lib, but it not works when run. now i want to know how this value of cqe_fp->placement_offset set to 2 ? I look over the source of dpdk-stable-17.11, but not found.eason

2 Answers

0
votes

While it does not resolve your issue, you might want to look into using mbuf private area, which is placed between mbuf header and data buffer instead.

It could be any size and it is completely transparent for the PMDs. Please refer the rte_pktmbuf_pool_create() for more details:

http://dpdk.org/doc/api/rte__mbuf_8h.html#a593921f13307803b94bbb4e0932db962

0
votes

I think this is a bug. I modify the code looks like that.

    new_mb = rte_mbuf_raw_alloc(rxq->mb_pool);
    if (unlikely(!new_mb)) {
        PMD_RX_LOG(ERR, "mbuf alloc fail fp[%02d]", fp->index);
        rte_eth_devices[rxq->port_id].data->
                rx_mbuf_alloc_failed++;
        goto next_rx;
    }   
    new_mb->data_off = RTE_PKTMBUF_HEADROOM;

    rx_mb = rxq->sw_ring[bd_cons];
    rxq->sw_ring[bd_cons] = new_mb;
    //rxq->rx_ring[bd_prod] = new_mb->buf_physaddr;
    rxq->rx_ring[bd_prod] = rte_cpu_to_le_64(rte_mbuf_data_dma_addr_default(new_mb));

edit new_mb->buf_physaddr to rte_cpu_to_le_64(rte_mbuf_data_dma_addr_default(new_mb)), this will skip the headroom.

when setup queue of nic. bnx2x_dev_rx_queue_setup will call.
    for (idx = 0; idx < rxq->nb_rx_desc; idx = NEXT_RX_BD(idx)) {
    mbuf = rte_mbuf_raw_alloc(mp);
    if (NULL == mbuf) {
        PMD_RX_LOG(ERR, "RX mbuf alloc failed queue_id=%u, idx=%d",
               (unsigned)rxq->queue_id, idx);
        bnx2x_rx_queue_release(rxq);
        return -ENOMEM;
    }
    rxq->sw_ring[idx] = mbuf;
    //rxq->rx_ring[idx] = mbuf->buf_physaddr;
    rxq->rx_ring[idx] = rte_cpu_to_le_64(rte_mbuf_data_dma_addr_default(mbuf));  
}