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.

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 | 31 ++++++++++++++++++++++++-------
 3 files changed, 36 insertions(+), 9 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 e0fd84807b..2cf07278a2 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,6 +515,9 @@ 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;
 }
@@ -553,6 +564,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;
@@ -574,7 +586,8 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, u16 nb_pkts, u
 
                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);
@@ -592,7 +605,8 @@ nbl_res_txrx_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts, u16 nb_pkts, u
                        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;
@@ -682,7 +696,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;
 }
@@ -759,7 +775,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

Reply via email to