Register the Draco PCI IDs now that the common Tx and Rx burst paths handle the Draco extended headers.
Enable half-offload on Draco Rx queues so the hardware writes the 16-byte extension header expected by the Rx burst path. Keep single-segment and multi-segment packet handling in the existing unified burst functions. Restrict software VLAN insertion and stripping to Leonis and leave Draco VLAN offload capabilities disabled until hardware VLAN support is implemented. Fix Rx tail encoding by putting the wrap flag in bit 15 of the 16-bit tail value (bit 31 of the doorbell). ORing the flag into bit 0 could change an even producer index into an odd one. Use the same doorbell format for Leonis and Draco. In addition to the initial Rx notification, issue one MMIO doorbell write after each refill batch on both products. A software test with mocked MMIO verified the Leonis tail encoding and refill notifications, including when the ring wraps. Use the reserved 32-byte Tx header slot stride for the software header pointer and the descriptor DMA address to avoid overlapping Leonis VLAN fallback headers. Check at compile time that the Leonis fallback header fits in the slot. Signed-off-by: Dimon Zhao <[email protected]> --- drivers/net/nbl/nbl_dev/nbl_dev.c | 5 ++-- drivers/net/nbl/nbl_ethdev.c | 9 ++++++ drivers/net/nbl/nbl_hw/nbl_txrx.c | 47 +++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/drivers/net/nbl/nbl_dev/nbl_dev.c b/drivers/net/nbl/nbl_dev/nbl_dev.c index 965da0ad4e..49b0c2b3a1 100644 --- a/drivers/net/nbl/nbl_dev/nbl_dev.c +++ b/drivers/net/nbl/nbl_dev/nbl_dev.c @@ -81,7 +81,8 @@ static int nbl_dev_txrx_start(struct rte_eth_dev *eth_dev) param.local_queue_id = i + ring_mgt->queue_offset; param.intr_en = 0; param.intr_mask = 0; - param.half_offload_en = 0; + /* Enable the 16-byte Rx extension header on Draco. */ + param.half_offload_en = adapter->caps.product_type == NBL_DRACO_TYPE; param.extend_header = 1; param.split = 0; param.rxcsum = 1; @@ -465,7 +466,7 @@ int nbl_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_ dev_info->default_txportconf.nb_queues = ring_mgt->tx_ring_num; dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_MULTI_SEGS; dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_SCATTER; - if (!common->is_vf) { + if (adapter->caps.product_type == NBL_LEONIS_TYPE && !common->is_vf) { dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VLAN_INSERT; dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP; } diff --git a/drivers/net/nbl/nbl_ethdev.c b/drivers/net/nbl/nbl_ethdev.c index 5a7d8266a4..f714fdccbe 100644 --- a/drivers/net/nbl/nbl_ethdev.c +++ b/drivers/net/nbl/nbl_ethdev.c @@ -133,6 +133,15 @@ static const struct rte_pci_id pci_id_nbl_map[] = { { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18120_BASE_T_OCP) }, { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18120_LX_BASE_T_OCP) }, { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18100_VF) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_LX) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_BASE_T) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_LX_BASE_T) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_OCP) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_LX_OCP) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_BASE_T_OCP) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_LX_BASE_T_OCP) }, + { RTE_PCI_DEVICE(NBL_VENDOR_ID, NBL_DEVICE_ID_M18305_VF) }, { .vendor_id = 0, /* sentinel */ }, }; diff --git a/drivers/net/nbl/nbl_hw/nbl_txrx.c b/drivers/net/nbl/nbl_hw/nbl_txrx.c index 3c30364e60..7cc9231bb6 100644 --- a/drivers/net/nbl/nbl_hw/nbl_txrx.c +++ b/drivers/net/nbl/nbl_hw/nbl_txrx.c @@ -6,6 +6,12 @@ #include "nbl_include.h" #include "nbl_txrx_ops.h" +static inline u32 nbl_res_txrx_notify_value(u16 qid, u16 next_to_use, u16 flags) +{ + return qid | ((u32)next_to_use << 16) | + ((u32)!!(flags & NBL_PACKED_DESC_F_AVAIL_BIT) << 31); +} + static int nbl_res_txrx_alloc_rings(void *priv, u16 tx_num, u16 rx_num, u16 queue_offset) { struct nbl_resource_mgt *res_mgt = (struct nbl_resource_mgt *)priv; @@ -465,11 +471,13 @@ static void nbl_res_txrx_update_rx_ring(void *priv, u16 index) struct nbl_resource_mgt *res_mgt = (struct nbl_resource_mgt *)priv; const struct nbl_hw_ops *hw_ops = NBL_RES_MGT_TO_HW_OPS(res_mgt); struct nbl_res_rx_ring *rx_ring = NBL_RES_MGT_TO_RX_RING(res_mgt, index); + u16 tail_ptr; + + tail_ptr = rx_ring->next_to_use | + ((u16)!!(rx_ring->avail_used_flags & NBL_PACKED_DESC_F_AVAIL_BIT) << 15); hw_ops->update_tail_ptr(NBL_RES_MGT_TO_HW_PRIV(res_mgt), - rx_ring->notify_qid, - ((!!(rx_ring->avail_used_flags & NBL_PACKED_DESC_F_AVAIL_BIT)) | - rx_ring->next_to_use)); + rx_ring->notify_qid, tail_ptr); } static inline void nbl_fill_rx_ring(struct nbl_res_rx_ring *rxq, @@ -507,10 +515,17 @@ static inline void nbl_fill_rx_ring(struct nbl_res_rx_ring *rxq, rx_desc->flags = flags; } + rte_write32(nbl_res_txrx_notify_value(rxq->notify_qid, desc_index, + rxq->avail_used_flags), rxq->notify); + rxq->vq_free_cnt -= fill_num; rxq->next_to_use = desc_index; } +static_assert(sizeof(struct nbl_tx_ehdr_leonis) + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_vlan_hdr) <= NBL_TX_HEADER_LEN, + "VLAN fallback header exceeds Tx header slot size"); + static inline void nbl_res_txrx_vlan_insert_out_mbuf(struct rte_mbuf *tx_pkt, union nbl_tx_extend_head *u, u16 vlan_proto, u16 vlan_tci) @@ -532,7 +547,7 @@ static u16 nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u16 extend_set) { struct nbl_res_tx_ring *txq; - union nbl_tx_extend_head *tx_region; + void *tx_region; volatile struct nbl_packed_desc *tx_ring; struct nbl_tx_entry *sw_ring; volatile struct nbl_packed_desc *tx_desc, *head_desc; @@ -540,6 +555,7 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u struct rte_mbuf *tx_pkt; union nbl_tx_extend_head *u; rte_iova_t net_hdr_mem; + size_t hdr_offset; uint64_t dma_addr; u16 nb_xmit_pkts; u16 desc_index, head_index, head_flags; @@ -549,6 +565,7 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u u16 required_headroom; u16 tx_extend_len; u16 addr_offset; + u32 notify_val; txq = tx_queue; tx_ring = txq->desc; @@ -562,13 +579,16 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u nbl_tx_free_bufs(txq); for (nb_xmit_pkts = 0; nb_xmit_pkts < nb_pkts; nb_xmit_pkts++) { + hdr_offset = (size_t)desc_index * NBL_TX_HEADER_LEN; + required_headroom = txq->exthdr_len; tx_extend_len = txq->exthdr_len; addr_offset = 0; tx_pkt = *tx_pkts++; - if (tx_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) { + if (txq->product == NBL_LEONIS_TYPE && + (tx_pkt->ol_flags & RTE_MBUF_F_TX_VLAN)) { required_headroom += sizeof(struct rte_vlan_hdr); /* extend_hdr + ether_hdr + vlan_hdr */ tx_extend_len = required_headroom + sizeof(struct rte_ether_hdr); @@ -583,14 +603,15 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u -required_headroom); } else { can_push = 0; - u = (union nbl_tx_extend_head *)(&tx_region[desc_index]); + u = RTE_PTR_ADD(tx_region, hdr_offset); } - if (tx_pkt->ol_flags & RTE_MBUF_F_TX_VLAN) { + if (txq->product == NBL_LEONIS_TYPE && + (tx_pkt->ol_flags & RTE_MBUF_F_TX_VLAN)) { if (likely(can_push)) { if (rte_vlan_insert(&tx_pkt)) { can_push = 0; - u = (union nbl_tx_extend_head *)(&tx_region[desc_index]); + u = RTE_PTR_ADD(tx_region, hdr_offset); } } if (unlikely(!can_push)) { @@ -627,8 +648,7 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u head_flags |= NBL_VRING_DESC_F_NEXT; txe->mbuf = NULL; /* padding */ - head_desc->addr = net_hdr_mem + - RTE_PTR_DIFF(&tx_region[desc_index], tx_region); + head_desc->addr = net_hdr_mem + hdr_offset; head_desc->len = tx_extend_len; txe->first_id = head_index; desc_index++; @@ -677,7 +697,9 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, u16 nb_pkts, u exit: /* kick hw_notify_addr */ - rte_write32(txq->notify_qid, txq->notify); + notify_val = nbl_res_txrx_notify_value(txq->notify_qid, txq->next_to_use, + txq->avail_used_flags); + rte_write32(notify_val, txq->notify); txq->txq_stats.tx_packets += nb_xmit_pkts; return nb_xmit_pkts; } @@ -754,7 +776,8 @@ nbl_res_txrx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, u16 nb_pkts) if (--num_sg) continue; - if (rxq->eth_dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) + if (rxq->product == NBL_LEONIS_TYPE && + (rxq->eth_dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) rte_vlan_strip(rx_mbuf); if (drop) { -- 2.53.0

