DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert
@ 2022-11-28  6:53 Chaoyong He
  2022-11-28  6:53 ` [PATCH 1/8] net/nfp: break out function to report device information Chaoyong He
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He

Add support for QinQ strip
Add support for VLAN strip
Add support for VLAN insert with NFD3
Add support for VLAN insert with NFDk

Peng Zhang (8):
  net/nfp: break out function to report device information
  net/nfp: modify the logic of parse metadata
  net/nfp: add new metadata type for achieving VLAN strip
  net/nfp: add support for QinQ strip
  net/nfp: add support for VLAN strip V2
  net/nfp: add support for VLAN insert with NFD3
  net/nfp: add support for VLAN insert V2 with NFD3
  net/nfp: add support for VLAN insert with NFDk

 doc/guides/nics/features/nfp.ini |   1 +
 doc/guides/nics/nfp.rst          | 139 ++++++++++++
 drivers/net/nfp/nfp_common.c     |  84 ++++++--
 drivers/net/nfp/nfp_common.h     |   1 +
 drivers/net/nfp/nfp_ctrl.h       |  16 +-
 drivers/net/nfp/nfp_ethdev.c     |  23 +-
 drivers/net/nfp/nfp_ethdev_vf.c  |  23 +-
 drivers/net/nfp/nfp_rxtx.c       | 356 ++++++++++++++++++++++++++-----
 drivers/net/nfp/nfp_rxtx.h       |  59 ++++-
 9 files changed, 587 insertions(+), 115 deletions(-)

-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/8] net/nfp: break out function to report device information
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2023-01-16  2:24   ` Nole Zhang
  2022-11-28  6:53 ` [PATCH 2/8] net/nfp: modify the logic of parse metadata Chaoyong He
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

The method to report device information to the log is the same for both
physical and virtual functions. The implementation is however open coded
in each code path, break out the reporting logic to a helper
function to reduce code duplication.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_common.c    | 27 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_common.h    |  1 +
 drivers/net/nfp/nfp_ethdev.c    | 23 +----------------------
 drivers/net/nfp/nfp_ethdev_vf.c | 23 +----------------------
 4 files changed, 30 insertions(+), 44 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 71711bfa22..f112a70980 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -188,6 +188,33 @@ nfp_net_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+void
+nfp_net_log_device_information(const struct nfp_net_hw *hw)
+{
+	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
+			NFD_CFG_MAJOR_VERSION_of(hw->ver),
+			NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
+
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
+			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
+			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
+			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
+			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
+			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
+			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
+			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
+			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
+			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
+
+	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
+			hw->max_rx_queues, hw->max_tx_queues);
+}
+
 void
 nfp_net_enable_queues(struct rte_eth_dev *dev)
 {
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 36c19b47e4..02612dbb58 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -404,6 +404,7 @@ nfp_pci_queue(struct rte_pci_device *pdev, uint16_t queue)
 /* Prototypes for common NFP functions */
 int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
 int nfp_net_configure(struct rte_eth_dev *dev);
+void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 0956ea81df..f661819fc0 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -619,33 +619,12 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
-			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
-			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
-
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
-
 	hw->ctrl = 0;
 
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
-	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
-		     hw->max_rx_queues, hw->max_tx_queues);
+	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
 	rte_spinlock_init(&hw->reconfig_lock);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index d1427b63bc..170f7eeb93 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -376,33 +376,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
-			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
-			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
-
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
-
 	hw->ctrl = 0;
 
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
-	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
-		     hw->max_rx_queues, hw->max_tx_queues);
+	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
 	rte_spinlock_init(&hw->reconfig_lock);
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/8] net/nfp: modify the logic of parse metadata
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
  2022-11-28  6:53 ` [PATCH 1/8] net/nfp: break out function to report device information Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2022-11-28  6:53 ` [PATCH 3/8] net/nfp: add new metadata type for achieving VLAN strip Chaoyong He
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

Previously only one metadata type was supported, now we need support many
different types of metadata, in order to achieve portability and
extensibilit, so adding the new struct nfp_meta_parsed to modify the logic
of parse metadata

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 doc/guides/nics/nfp.rst    | 58 +++++++++++++++++++++++
 drivers/net/nfp/nfp_rxtx.c | 94 ++++++++++++++++++++------------------
 drivers/net/nfp/nfp_rxtx.h | 14 ++++++
 3 files changed, 122 insertions(+), 44 deletions(-)

diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst
index b74067c875..8034b2a668 100644
--- a/doc/guides/nics/nfp.rst
+++ b/doc/guides/nics/nfp.rst
@@ -213,3 +213,61 @@ PF vNIC.
 The ctrl vNIC service handling various control message, like the creation and
 configuration of representor port, the pattern and action of flow rules, the
 statistics of flow rules, and so on.
+
+Metadata Format
+---------------
+
+The NFP packet metadata format
+
+The packet metadata starts with a field type header that can contain up-to
+8 4-bit datatype specifiers (32-bits in total). This is followed by up to 8
+32-bit words of data for each field described in the header. And directly
+following the metadata (header and data) comes the packet.
+
+The order of type is correspond with the data, but the nums of data field are
+decided by the corresponding type, if the type need N data field, it need to
+be wrote N times in the heads.
+::
+
+       3                   2                   1                   0
+   2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   | Type7 | Type6 | Type5 | Type4 | Type3 | Type2 | Type1 | Type0 |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 0                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 1                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 2                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 3                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 4                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 5                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 6                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 7                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                          Packet Data                          |
+   |                              ...                              |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+There are two classes of metadata one for ingress and one for egress. In each
+class the supported NFP types are:
+
+RX
+~~
+
+NFP_NET_META_HASH
+The hash type is 4 bit which is next field type after NFP_NET_META_HASH in
+the header. The hash value is 32 bit which need 1 data field.
+::
+
+   -----------------------------------------------------------------
+       3                   2                   1                   0
+   2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                            Hash value                         |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 01cffdfde0..320387eb7c 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -116,60 +116,65 @@ nfp_net_rx_queue_count(void *rx_queue)
 	return count;
 }
 
-/*
- * nfp_net_set_hash - Set mbuf hash data
- *
- * The RSS hash and hash-type are pre-pended to the packet data.
- * Extract and decode it and set the mbuf fields.
- */
-static inline void
-nfp_net_set_hash(struct nfp_net_rxq *rxq, struct nfp_net_rx_desc *rxd,
-		 struct rte_mbuf *mbuf)
+/* nfp_net_parse_meta() - Parse the metadata from packet */
+static void
+nfp_net_parse_meta(struct nfp_meta_parsed *meta,
+		struct nfp_net_rx_desc *rxd,
+		struct nfp_net_rxq *rxq,
+		struct rte_mbuf *mbuf)
 {
-	struct nfp_net_hw *hw = rxq->hw;
-	uint8_t *meta_offset;
 	uint32_t meta_info;
-	uint32_t hash = 0;
-	uint32_t hash_type = 0;
+	uint8_t *meta_offset;
+	struct nfp_net_hw *hw = rxq->hw;
 
-	if (!(hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY))
+	if (unlikely((NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2) ||
+			NFP_DESC_META_LEN(rxd) == 0))
 		return;
 
-	/* this is true for new firmwares */
-	if (likely(((hw->cap & NFP_NET_CFG_CTRL_RSS2) ||
-	    (NFD_CFG_MAJOR_VERSION_of(hw->ver) == 4)) &&
-	     NFP_DESC_META_LEN(rxd))) {
-		/*
-		 * new metadata api:
-		 * <----  32 bit  ----->
-		 * m    field type word
-		 * e     data field #2
-		 * t     data field #1
-		 * a     data field #0
-		 * ====================
-		 *    packet data
-		 *
-		 * Field type word contains up to 8 4bit field types
-		 * A 4bit field type refers to a data field word
-		 * A data field word can have several 4bit field types
-		 */
-		meta_offset = rte_pktmbuf_mtod(mbuf, uint8_t *);
-		meta_offset -= NFP_DESC_META_LEN(rxd);
-		meta_info = rte_be_to_cpu_32(*(uint32_t *)meta_offset);
-		meta_offset += 4;
-		/* NFP PMD just supports metadata for hashing */
+	meta_offset = rte_pktmbuf_mtod(mbuf, uint8_t *);
+	meta_offset -= NFP_DESC_META_LEN(rxd);
+	meta_info = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
+	meta_offset += 4;
+
+	for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, meta_offset += 4) {
 		switch (meta_info & NFP_NET_META_FIELD_MASK) {
 		case NFP_NET_META_HASH:
-			/* next field type is about the hash type */
+			/* Next field type is about the hash type */
 			meta_info >>= NFP_NET_META_FIELD_SIZE;
-			/* hash value is in the data field */
-			hash = rte_be_to_cpu_32(*(uint32_t *)meta_offset);
-			hash_type = meta_info & NFP_NET_META_FIELD_MASK;
+			/* Hash value is in the data field */
+			meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
+			meta->hash_type = meta_info & NFP_NET_META_FIELD_MASK;
 			break;
 		default:
 			/* Unsupported metadata can be a performance issue */
 			return;
 		}
+	}
+}
+
+/*
+ * nfp_net_parse_meta_hash() - Set mbuf hash data based on the metadata info
+ *
+ * The RSS hash and hash-type are prepended to the packet data.
+ * Extract and decode it and set the mbuf fields.
+ */
+static void
+nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
+		struct nfp_net_rx_desc *rxd,
+		struct nfp_net_rxq *rxq,
+		struct rte_mbuf *mbuf)
+{
+	uint32_t hash;
+	uint32_t hash_type;
+	struct nfp_net_hw *hw = rxq->hw;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+		return;
+
+	if (likely((hw->cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0 &&
+			NFP_DESC_META_LEN(rxd) != 0)) {
+		hash = meta->hash;
+		hash_type = meta->hash_type;
 	} else {
 		if (!(rxd->rxd.flags & PCIE_DESC_RX_RSS))
 			return;
@@ -245,6 +250,7 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	struct nfp_net_hw *hw;
 	struct rte_mbuf *mb;
 	struct rte_mbuf *new_mb;
+	struct nfp_meta_parsed meta;
 	uint16_t nb_hold;
 	uint64_t dma_addr;
 	uint16_t avail;
@@ -338,11 +344,11 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		/* No scatter mode supported */
 		mb->nb_segs = 1;
 		mb->next = NULL;
-
 		mb->port = rxq->port_id;
 
-		/* Checking the RSS flag */
-		nfp_net_set_hash(rxq, rxds, mb);
+		memset(&meta, 0, sizeof(meta));
+		nfp_net_parse_meta(&meta, rxds, rxq, mb);
+		nfp_net_parse_meta_hash(&meta, rxds, rxq, mb);
 
 		/* Checking the checksum flag */
 		nfp_net_rx_cksum(rxq, rxds, mb);
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index ced05fde90..4cbf4080c5 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -25,6 +25,20 @@
 #define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \
 	((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM))
 
+/*
+ * struct nfp_meta_parsed - Record metadata parsed from packet
+ *
+ * Parsed NFP packet metadata are recorded in this struct. The content is
+ * read-only after it have been recorded during parsing by nfp_net_parse_meta().
+ *
+ * @hash: RSS hash value
+ * @hash_type: RSS hash type
+ */
+struct nfp_meta_parsed {
+	uint32_t hash;
+	uint8_t hash_type;
+};
+
 /*
  * The maximum number of descriptors is limited by design as
  * DPDK uses uint16_t variables for these values
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/8] net/nfp: add new metadata type for achieving VLAN strip
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
  2022-11-28  6:53 ` [PATCH 1/8] net/nfp: break out function to report device information Chaoyong He
  2022-11-28  6:53 ` [PATCH 2/8] net/nfp: modify the logic of parse metadata Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2022-11-28  6:53 ` [PATCH 4/8] net/nfp: add support for QinQ strip Chaoyong He
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

The firmware supplies VLAN strip information is stroed in
packet metadata. The field of this VLAN metadata includes
VLAN TPID, VLAN TCI and offload flag.

The new metadata type is NFP_NET_META_VLAN.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 doc/guides/nics/nfp.rst    | 22 ++++++++++++++++
 drivers/net/nfp/nfp_ctrl.h | 10 ++++++++
 drivers/net/nfp/nfp_rxtx.c | 51 +++++++++++++++++++++++++++++++++-----
 drivers/net/nfp/nfp_rxtx.h | 22 ++++++++++++++++
 4 files changed, 99 insertions(+), 6 deletions(-)

diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst
index 8034b2a668..fffff00f1e 100644
--- a/doc/guides/nics/nfp.rst
+++ b/doc/guides/nics/nfp.rst
@@ -271,3 +271,25 @@ the header. The hash value is 32 bit which need 1 data field.
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                            Hash value                         |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+NFP_NET_META_VLAN
+Metadata with L2 (1W/4B)
+::
+
+   ----------------------------------------------------------------
+      3                   2                   1                   0
+    1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |f|            reserved   | tpid| PCP |p|   vlan outermost VID  |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+                                   ^                               ^
+                             NOTE: |             TCI               |
+                                   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   f 0 -> not stripping
+   1 -> stripping
+
+   tpid 0 -> RTE_ETHER_TYPE_VLAN 0x8100 IEEE 802.1Q VLAN tagging
+        1 -> RTE_ETHER_TYPE_QINQ 0x88a8 IEEE 802.1ad QINQ tagging
+   Tpid just be stored, now we don't handle it
+
+   The vlan[0] is the innermost VLAN
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index 372d537462..a90846fddf 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -30,8 +30,18 @@
 #define NFP_NET_META_FIELD_SIZE         4
 #define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
 
+/* Working with metadata vlan api (NFD version >= 2.0) */
+#define NFP_NET_META_VLAN_INFO          16
+#define NFP_NET_META_VLAN_OFFLOAD       31
+#define NFP_NET_META_VLAN_TPID          3
+#define NFP_NET_META_VLAN_MASK          ((1 << NFP_NET_META_VLAN_INFO) - 1)
+#define NFP_NET_META_VLAN_TPID_MASK     ((1 << NFP_NET_META_VLAN_TPID) - 1)
+#define NFP_NET_META_TPID(d)            (((d) >> NFP_NET_META_VLAN_INFO) & \
+						NFP_NET_META_VLAN_TPID_MASK)
+
 /* Prepend field types */
 #define NFP_NET_META_HASH               1 /* next field carries hash type */
+#define NFP_NET_META_VLAN               4
 
 /* Hash type pre-pended when a RSS hash was computed */
 #define NFP_NET_RSS_NONE                0
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 320387eb7c..fb271e6d96 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -124,6 +124,7 @@ nfp_net_parse_meta(struct nfp_meta_parsed *meta,
 		struct rte_mbuf *mbuf)
 {
 	uint32_t meta_info;
+	uint32_t vlan_info;
 	uint8_t *meta_offset;
 	struct nfp_net_hw *hw = rxq->hw;
 
@@ -145,6 +146,15 @@ nfp_net_parse_meta(struct nfp_meta_parsed *meta,
 			meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
 			meta->hash_type = meta_info & NFP_NET_META_FIELD_MASK;
 			break;
+		case NFP_NET_META_VLAN:
+			vlan_info = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
+			meta->vlan[meta->vlan_layer].offload =
+					vlan_info >> NFP_NET_META_VLAN_OFFLOAD;
+			meta->vlan[meta->vlan_layer].tci =
+					vlan_info & NFP_NET_META_VLAN_MASK;
+			meta->vlan[meta->vlan_layer].tpid = NFP_NET_META_TPID(vlan_info);
+			++meta->vlan_layer;
+			break;
 		default:
 			/* Unsupported metadata can be a performance issue */
 			return;
@@ -213,6 +223,40 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
 	}
 }
 
+/*
+ * nfp_net_parse_meta_vlan() - Set mbuf vlan_strip data based on metadata info
+ *
+ * The VLAN info TPID and TCI are prepended to the packet data.
+ * Extract and decode it and set the mbuf fields.
+ */
+static void
+nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
+		struct nfp_net_rx_desc *rxd,
+		struct nfp_net_rxq *rxq,
+		struct rte_mbuf *mb)
+{
+	struct nfp_net_hw *hw = rxq->hw;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) == 0)
+		return;
+
+	/*
+	 * The nic support the two way to send the VLAN info,
+	 * 1. According the metadata to send the VLAN info
+	 * 2. According the descriptor to sned the VLAN info
+	 *
+	 * If the nic doesn't send the VLAN info, it is not necessary
+	 * to do anything.
+	 */
+	if (meta->vlan_layer >= 1 && meta->vlan[0].offload != 0) {
+		mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
+		mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+	} else if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
+		mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.vlan);
+		mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+	}
+}
+
 /*
  * RX path design:
  *
@@ -349,16 +393,11 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		memset(&meta, 0, sizeof(meta));
 		nfp_net_parse_meta(&meta, rxds, rxq, mb);
 		nfp_net_parse_meta_hash(&meta, rxds, rxq, mb);
+		nfp_net_parse_meta_vlan(&meta, rxds, rxq, mb);
 
 		/* Checking the checksum flag */
 		nfp_net_rx_cksum(rxq, rxds, mb);
 
-		if ((rxds->rxd.flags & PCIE_DESC_RX_VLAN) &&
-		    (hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN)) {
-			mb->vlan_tci = rte_cpu_to_le_32(rxds->rxd.vlan);
-			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
-		}
-
 		/* Adding the mbuf to the mbuf array passed by the app */
 		rx_pkts[avail++] = mb;
 
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 4cbf4080c5..a24ec9e560 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -25,6 +25,9 @@
 #define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \
 	((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM))
 
+/* Maximum number of supported VLANs in parsed form packet metadata. */
+#define NFP_META_MAX_VLANS       2
+
 /*
  * struct nfp_meta_parsed - Record metadata parsed from packet
  *
@@ -33,10 +36,29 @@
  *
  * @hash: RSS hash value
  * @hash_type: RSS hash type
+ * @vlan_layer: The layers of VLAN info which are passed from nic.
+ *              Only this number of entries of the @vlan array are valid.
+ *
+ * @vlan: Holds information parses from NFP_NET_META_VLAN. The inner most vlan
+ *        starts at position 0 and only @vlan_layer entries contain valid
+ *        information.
+ *
+ *        Currently only 1 layer of vlan is supported,
+ *        vlan[0] - vlan strip info
+ *
+ * @vlan.offload:  Flag indicates whether VLAN is offloaded
+ * @vlan.tpid: Vlan TPID
+ * @vlan.tci: Vlan TCI including PCP + Priority + VID
  */
 struct nfp_meta_parsed {
 	uint32_t hash;
 	uint8_t hash_type;
+	uint8_t vlan_layer;
+	struct {
+		uint8_t offload;
+		uint8_t tpid;
+		uint16_t tci;
+	} vlan[NFP_META_MAX_VLANS];
 };
 
 /*
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/8] net/nfp: add support for QinQ strip
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
                   ` (2 preceding siblings ...)
  2022-11-28  6:53 ` [PATCH 3/8] net/nfp: add new metadata type for achieving VLAN strip Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2022-11-28  6:53 ` [PATCH 5/8] net/nfp: add support for VLAN strip V2 Chaoyong He
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

Control the offload of outer layer VLAN strip in QinQ mode
through the RTE_ETH_QINQ_STRIP_OFFLOAD mask bit.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 doc/guides/nics/features/nfp.ini |  1 +
 doc/guides/nics/nfp.rst          |  1 +
 drivers/net/nfp/nfp_common.c     | 19 ++++++++++++++-
 drivers/net/nfp/nfp_ctrl.h       |  1 +
 drivers/net/nfp/nfp_rxtx.c       | 41 ++++++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_rxtx.h       |  3 ++-
 6 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index 9e075a680b..b15a1ec52c 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -17,6 +17,7 @@ RSS key update       = Y
 RSS reta update      = Y
 Flow control         = Y
 VLAN offload         = Y
+QinQ offload         = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Basic stats          = Y
diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst
index fffff00f1e..2be15b63d3 100644
--- a/doc/guides/nics/nfp.rst
+++ b/doc/guides/nics/nfp.rst
@@ -293,3 +293,4 @@ Metadata with L2 (1W/4B)
    Tpid just be stored, now we don't handle it
 
    The vlan[0] is the innermost VLAN
+   The vlan[1] is the QinQ info
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index f112a70980..d1822f6b71 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -195,7 +195,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			NFD_CFG_MAJOR_VERSION_of(hw->ver),
 			NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
 			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
 			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
 			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
@@ -203,6 +203,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
 			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
@@ -401,6 +402,11 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 			ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
 	}
 
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) {
+		if (hw->cap & NFP_NET_CFG_CTRL_RXQINQ)
+			ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
+	}
+
 	hw->mtu = dev->data->mtu;
 
 	if (txmode->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT)
@@ -751,6 +757,9 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	if (hw->cap & NFP_NET_CFG_CTRL_RXVLAN)
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
+	if (hw->cap & NFP_NET_CFG_CTRL_RXQINQ)
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_QINQ_STRIP;
+
 	if (hw->cap & NFP_NET_CFG_CTRL_RXCSUM)
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
 					     RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
@@ -1042,6 +1051,14 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 			new_ctrl &= ~NFP_NET_CFG_CTRL_RXVLAN;
 	}
 
+	/* QinQ stripping setting */
+	if (mask & RTE_ETH_QINQ_STRIP_MASK) {
+		if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP)
+			new_ctrl |= NFP_NET_CFG_CTRL_RXQINQ;
+		else
+			new_ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
+	}
+
 	if (new_ctrl == hw->ctrl)
 		return 0;
 
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index a90846fddf..106779c080 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -93,6 +93,7 @@
 #define   NFP_NET_CFG_CTRL_SCATTER        (0x1 <<  8) /* Scatter DMA */
 #define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
 #define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
+#define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
 #define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
 #define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
 #define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index fb271e6d96..40f1702bde 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -257,6 +257,46 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 	}
 }
 
+/*
+ * nfp_net_parse_meta_qinq() - Set mbuf qinq_strip data based on metadata info
+ *
+ * The out VLAN tci are prepended to the packet data.
+ * Extract and decode it and set the mbuf fields.
+ *
+ * If both RTE_MBUF_F_RX_VLAN and NFP_NET_CFG_CTRL_RXQINQ are set, the 2 VLANs
+ *   have been stripped by the hardware and their TCIs are saved in
+ *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
+ * If NFP_NET_CFG_CTRL_RXQINQ is set and RTE_MBUF_F_RX_VLAN is unset, only the
+ *   outer VLAN is removed from packet data, but both tci are saved in
+ *   mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
+ *
+ * qinq set & vlan set : meta->vlan_layer>=2, meta->vlan[0].offload=1, meta->vlan[1].offload=1
+ * qinq set & vlan not set: meta->vlan_layer>=2, meta->vlan[1].offload=1,meta->vlan[0].offload=0
+ * qinq not set & vlan set: meta->vlan_layer=1, meta->vlan[0].offload=1
+ * qinq not set & vlan not set: meta->vlan_layer=0
+ */
+static void
+nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
+		struct nfp_net_rxq *rxq,
+		struct rte_mbuf *mb)
+{
+	struct nfp_net_hw *hw = rxq->hw;
+
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXQINQ) == 0 ||
+			(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
+		return;
+
+	if (meta->vlan_layer < NFP_META_MAX_VLANS)
+		return;
+
+	if (meta->vlan[0].offload == 0)
+		mb->vlan_tci = rte_cpu_to_le_16(meta->vlan[0].tci);
+	mb->vlan_tci_outer = rte_cpu_to_le_16(meta->vlan[1].tci);
+	PMD_RX_LOG(DEBUG, "Received outer vlan is %u inter vlan is %u",
+			mb->vlan_tci_outer, mb->vlan_tci);
+	mb->ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED;
+}
+
 /*
  * RX path design:
  *
@@ -394,6 +434,7 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		nfp_net_parse_meta(&meta, rxds, rxq, mb);
 		nfp_net_parse_meta_hash(&meta, rxds, rxq, mb);
 		nfp_net_parse_meta_vlan(&meta, rxds, rxq, mb);
+		nfp_net_parse_meta_qinq(&meta, rxq, mb);
 
 		/* Checking the checksum flag */
 		nfp_net_rx_cksum(rxq, rxds, mb);
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index a24ec9e560..e3e8b00b48 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -43,8 +43,9 @@
  *        starts at position 0 and only @vlan_layer entries contain valid
  *        information.
  *
- *        Currently only 1 layer of vlan is supported,
+ *        Currently only 2 layers of vlan are supported,
  *        vlan[0] - vlan strip info
+ *        vlan[1] - qinq strip info
  *
  * @vlan.offload:  Flag indicates whether VLAN is offloaded
  * @vlan.tpid: Vlan TPID
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 5/8] net/nfp: add support for VLAN strip V2
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
                   ` (3 preceding siblings ...)
  2022-11-28  6:53 ` [PATCH 4/8] net/nfp: add support for QinQ strip Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2022-11-28  6:53 ` [PATCH 6/8] net/nfp: add support for VLAN insert with NFD3 Chaoyong He
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

The VLAN information can be stored in the descriptor or in the metadata.
Add a new VLAN strip V2 bit to distinguish them. When VLAN strip is set,
the vlan information is stored in the descriptor. When VLAN strip V2 is
set, it is stored in the metadata.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_common.c | 33 +++++++++++++++++++++------------
 drivers/net/nfp/nfp_ctrl.h   |  1 +
 drivers/net/nfp/nfp_rxtx.c   | 25 ++++++++++++++++---------
 3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index d1822f6b71..a62a7386ab 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -195,7 +195,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			NFD_CFG_MAJOR_VERSION_of(hw->ver),
 			NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
 			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
 			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
 			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
@@ -203,6 +203,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
 			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
 			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
@@ -216,6 +217,15 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			hw->max_rx_queues, hw->max_tx_queues);
 }
 
+static inline void
+nfp_net_enbable_rxvlan_cap(struct nfp_net_hw *hw, uint32_t *ctrl)
+{
+	if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0)
+		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN_V2;
+	else if ((hw->cap & NFP_NET_CFG_CTRL_RXVLAN) != 0)
+		*ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
+}
+
 void
 nfp_net_enable_queues(struct rte_eth_dev *dev)
 {
@@ -397,10 +407,8 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 			ctrl |= NFP_NET_CFG_CTRL_RXCSUM;
 	}
 
-	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
-		if (hw->cap & NFP_NET_CFG_CTRL_RXVLAN)
-			ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
-	}
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+		nfp_net_enbable_rxvlan_cap(hw, &ctrl);
 
 	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_QINQ_STRIP) {
 		if (hw->cap & NFP_NET_CFG_CTRL_RXQINQ)
@@ -754,7 +762,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* Next should change when PF support is implemented */
 	dev_info->max_mac_addrs = 1;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_RXVLAN)
+	if (hw->cap & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2))
 		dev_info->rx_offload_capa = RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
 
 	if (hw->cap & NFP_NET_CFG_CTRL_RXQINQ)
@@ -1034,21 +1042,22 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	uint32_t new_ctrl, update;
 	struct nfp_net_hw *hw;
 	struct rte_eth_conf *dev_conf;
+	uint32_t rxvlan_ctrl;
 	int ret;
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	dev_conf = &dev->data->dev_conf;
 	new_ctrl = hw->ctrl;
+	rxvlan_ctrl = 0;
 
-	/*
-	 * Vlan stripping setting
-	 * Enable or disable VLAN stripping
-	 */
+	nfp_net_enbable_rxvlan_cap(hw, &rxvlan_ctrl);
+
+	/* VLAN stripping setting */
 	if (mask & RTE_ETH_VLAN_STRIP_MASK) {
 		if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
-			new_ctrl |= NFP_NET_CFG_CTRL_RXVLAN;
+			new_ctrl |= rxvlan_ctrl;
 		else
-			new_ctrl &= ~NFP_NET_CFG_CTRL_RXVLAN;
+			new_ctrl &= ~rxvlan_ctrl;
 	}
 
 	/* QinQ stripping setting */
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index 106779c080..c7ebcf43b3 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -94,6 +94,7 @@
 #define   NFP_NET_CFG_CTRL_GATHER         (0x1 <<  9) /* Gather DMA */
 #define   NFP_NET_CFG_CTRL_LSO            (0x1 << 10) /* LSO/TSO */
 #define   NFP_NET_CFG_CTRL_RXQINQ         (0x1 << 13) /* Enable QINQ strip */
+#define   NFP_NET_CFG_CTRL_RXVLAN_V2      (0x1 << 15) /* Enable VLAN strip with metadata */
 #define   NFP_NET_CFG_CTRL_RINGCFG        (0x1 << 16) /* Ring runtime changes */
 #define   NFP_NET_CFG_CTRL_RSS            (0x1 << 17) /* RSS */
 #define   NFP_NET_CFG_CTRL_IRQMOD         (0x1 << 18) /* Interrupt moderation */
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 40f1702bde..2bc0eb2625 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -237,23 +237,30 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
 {
 	struct nfp_net_hw *hw = rxq->hw;
 
-	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) == 0)
+	/* Skip if hardware don't support setting vlan. */
+	if ((hw->ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
 		return;
 
 	/*
 	 * The nic support the two way to send the VLAN info,
-	 * 1. According the metadata to send the VLAN info
-	 * 2. According the descriptor to sned the VLAN info
+	 * 1. According the metadata to send the VLAN info when NFP_NET_CFG_CTRL_RXVLAN_V2
+	 * is set
+	 * 2. According the descriptor to sned the VLAN info when NFP_NET_CFG_CTRL_RXVLAN
+	 * is set
 	 *
 	 * If the nic doesn't send the VLAN info, it is not necessary
 	 * to do anything.
 	 */
-	if (meta->vlan_layer >= 1 && meta->vlan[0].offload != 0) {
-		mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
-		mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
-	} else if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
-		mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.vlan);
-		mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+	if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+		if (meta->vlan_layer >= 1 && meta->vlan[0].offload != 0) {
+			mb->vlan_tci = rte_cpu_to_le_32(meta->vlan[0].tci);
+			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+		}
+	} else if ((hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN) != 0) {
+		if ((rxd->rxd.flags & PCIE_DESC_RX_VLAN) != 0) {
+			mb->vlan_tci = rte_cpu_to_le_32(rxd->rxd.vlan);
+			mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+		}
 	}
 }
 
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 6/8] net/nfp: add support for VLAN insert with NFD3
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
                   ` (4 preceding siblings ...)
  2022-11-28  6:53 ` [PATCH 5/8] net/nfp: add support for VLAN strip V2 Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2022-11-28  6:53 ` [PATCH 7/8] net/nfp: add support for VLAN insert V2 " Chaoyong He
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

As the firmware with NFD3 change, using the metadata sends
the VLAN info to the nic to achieve the VLAN offload insert.

The VLAN INFO consists of 16bit TPID + 16bit TCI

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 doc/guides/nics/nfp.rst      | 16 ++++++++
 drivers/net/nfp/nfp_common.c |  6 ++-
 drivers/net/nfp/nfp_ctrl.h   |  1 +
 drivers/net/nfp/nfp_rxtx.c   | 77 +++++++++++++++++++++++++++++++++---
 drivers/net/nfp/nfp_rxtx.h   | 21 +++++++++-
 5 files changed, 112 insertions(+), 9 deletions(-)

diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst
index 2be15b63d3..a636fd0fde 100644
--- a/doc/guides/nics/nfp.rst
+++ b/doc/guides/nics/nfp.rst
@@ -294,3 +294,19 @@ Metadata with L2 (1W/4B)
 
    The vlan[0] is the innermost VLAN
    The vlan[1] is the QinQ info
+
+TX
+~~
+
+NFP_NET_META_VLAN
+::
+
+   -----------------------------------------------------------------
+       3                   2                   1                   0
+     1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |               TPID            | PCP |p|   vlan outermost VID  |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+                                   ^                               ^
+                             NOTE: |             TCI               |
+                                   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index a62a7386ab..9c740ee9b5 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -417,8 +417,10 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 
 	hw->mtu = dev->data->mtu;
 
-	if (txmode->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT)
-		ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
+	if (txmode->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) {
+		if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)
+			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
+	}
 
 	/* L2 broadcast */
 	if (hw->cap & NFP_NET_CFG_CTRL_L2BC)
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index c7ebcf43b3..bffdd8345e 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -29,6 +29,7 @@
 /* working with metadata api (NFD version > 3.0) */
 #define NFP_NET_META_FIELD_SIZE         4
 #define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
+#define NFP_NET_META_HEADER_SIZE        4
 
 /* Working with metadata vlan api (NFD version >= 2.0) */
 #define NFP_NET_META_VLAN_INFO          16
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 2bc0eb2625..200886111e 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -833,12 +833,77 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	return 0;
 }
 
+static void
+nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
+		struct rte_mbuf *pkt,
+		uint8_t layer)
+{
+	uint16_t vlan_tci;
+	uint16_t tpid;
+
+	tpid = RTE_ETHER_TYPE_VLAN;
+	vlan_tci = pkt->vlan_tci;
+
+	meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci);
+}
+
+static void
+nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
+		struct nfp_net_txq *txq,
+		struct rte_mbuf *pkt)
+{
+	uint8_t vlan_layer = 0;
+	struct nfp_net_hw *hw;
+	uint32_t meta_info;
+	uint8_t layer = 0;
+	char *meta;
+
+	hw = txq->hw;
+
+	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
+			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN) != 0) {
+		if (meta_data->length == 0)
+			meta_data->length = NFP_NET_META_HEADER_SIZE;
+		meta_data->length += NFP_NET_META_FIELD_SIZE;
+		meta_data->header |= NFP_NET_META_VLAN;
+	}
+
+	if (meta_data->length == 0)
+		return;
+
+	meta_info = meta_data->header;
+	meta_data->header = rte_cpu_to_be_32(meta_data->header);
+	meta = rte_pktmbuf_prepend(pkt, meta_data->length);
+	memcpy(meta, &meta_data->header, sizeof(meta_data->header));
+	meta += NFP_NET_META_HEADER_SIZE;
+
+	for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, layer++,
+			meta += NFP_NET_META_FIELD_SIZE) {
+		switch (meta_info & NFP_NET_META_FIELD_MASK) {
+		case NFP_NET_META_VLAN:
+			if (vlan_layer > 0) {
+				PMD_DRV_LOG(ERR, "At most 1 layers of vlan is supported");
+				return;
+			}
+			nfp_net_set_meta_vlan(meta_data, pkt, layer);
+			vlan_layer++;
+			break;
+		default:
+			PMD_DRV_LOG(ERR, "The metadata type not supported");
+			return;
+		}
+
+		memcpy(meta, &meta_data->data[layer], sizeof(meta_data->data[layer]));
+	}
+}
+
 uint16_t
 nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
 	struct nfp_net_txq *txq;
 	struct nfp_net_hw *hw;
 	struct nfp_net_nfd3_tx_desc *txds, txd;
+	struct nfp_net_meta_raw meta_data;
 	struct rte_mbuf *pkt;
 	uint64_t dma_addr;
 	int pkt_size, dma_size;
@@ -868,6 +933,7 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 		   txq->qidx, nb_pkts);
 	/* Sending packets */
 	while ((i < nb_pkts) && free_descs) {
+		memset(&meta_data, 0, sizeof(meta_data));
 		/* Grabbing the mbuf linked to the current descriptor */
 		lmbuf = &txq->txbufs[txq->wr_p].mbuf;
 		/* Warming the cache for releasing the mbuf later on */
@@ -875,6 +941,8 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 
 		pkt = *(tx_pkts + i);
 
+		nfp_net_nfd3_set_meta_data(&meta_data, txq, pkt);
+
 		if (unlikely(pkt->nb_segs > 1 &&
 			     !(hw->cap & NFP_NET_CFG_CTRL_GATHER))) {
 			PMD_INIT_LOG(INFO, "NFP_NET_CFG_CTRL_GATHER not set");
@@ -893,12 +961,6 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 		nfp_net_nfd3_tx_tso(txq, &txd, pkt);
 		nfp_net_nfd3_tx_cksum(txq, &txd, pkt);
 
-		if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) &&
-		    (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)) {
-			txd.flags |= PCIE_DESC_TX_VLAN;
-			txd.vlan = pkt->vlan_tci;
-		}
-
 		/*
 		 * mbuf data_len is the data in one segment and pkt_len data
 		 * in the whole packet. When the packet is just one segment,
@@ -948,6 +1010,9 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 			else
 				txds->offset_eop = 0;
 
+			/* Set the meta_len */
+			txds->offset_eop |= meta_data.length;
+
 			pkt = pkt->next;
 			/* Referencing next free TX descriptor */
 			txds = &txq->txds[txq->wr_p];
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index e3e8b00b48..d16d557fd3 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -27,6 +27,25 @@
 
 /* Maximum number of supported VLANs in parsed form packet metadata. */
 #define NFP_META_MAX_VLANS       2
+/* Maximum number of NFP packet metadata fields. */
+#define NFP_META_MAX_FIELDS      8
+
+/*
+ * struct nfp_net_meta_raw - Raw memory representation of packet metadata
+ *
+ * Describe the raw metadata format, useful when preparing metadata for a
+ * transmission mbuf.
+ *
+ * @header: NFD3 Contains the 8 4-bit type fields
+ * @data: Array of each fields data member
+ * @length: Keep track of number of valid fields in @header and data. Not part
+ *          of the raw metadata.
+ */
+struct nfp_net_meta_raw {
+	uint32_t header;
+	uint32_t data[NFP_META_MAX_FIELDS];
+	uint8_t length;
+};
 
 /*
  * struct nfp_meta_parsed - Record metadata parsed from packet
@@ -121,7 +140,7 @@ struct nfp_net_nfd3_tx_desc {
 			uint8_t dma_addr_hi; /* High bits of host buf address */
 			__le16 dma_len;     /* Length to DMA for this desc */
 			uint8_t offset_eop; /* Offset in buf where pkt starts +
-					     * highest bit is eop flag.
+					     * highest bit is eop flag, low 7bit is meta_len.
 					     */
 			__le32 dma_addr_lo; /* Low 32bit of host buf addr */
 
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 7/8] net/nfp: add support for VLAN insert V2 with NFD3
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
                   ` (5 preceding siblings ...)
  2022-11-28  6:53 ` [PATCH 6/8] net/nfp: add support for VLAN insert with NFD3 Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2022-11-28  6:53 ` [PATCH 8/8] net/nfp: add support for VLAN insert with NFDk Chaoyong He
  2023-01-24 16:28 ` [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Ferruh Yigit
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

The firmware support VLAN insert with the descriptor or the metadata.
So adding a NFP_NET_CFG_CTRL_RXVLAN_V2 bit to distinguish them. When
VLAN insert is set, sending the vlan information with the descriptor.
When VLAN insert V2 is set, sending it with the metadata.

Now NFP_NET_CFG_CTRL_L2SWITCH_LOCAL isn't used, so 0x1 << 23 is used
by NFP_NET_CFG_CTRL_RXVLAN_V2.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_common.c |  9 ++++++---
 drivers/net/nfp/nfp_ctrl.h   |  2 +-
 drivers/net/nfp/nfp_rxtx.c   | 30 +++++++++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 9c740ee9b5..853eb4a3f7 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -195,7 +195,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			NFD_CFG_MAJOR_VERSION_of(hw->ver),
 			NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
 
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
 			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
 			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
 			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
@@ -204,6 +204,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw)
 			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_RXVLAN_V2 ? "RXVLANv2 "  : "",
+			hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2 ? "TXVLANv2 "  : "",
 			hw->cap & NFP_NET_CFG_CTRL_RXQINQ    ? "RXQINQ "    : "",
 			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
 			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
@@ -418,7 +419,9 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 	hw->mtu = dev->data->mtu;
 
 	if (txmode->offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) {
-		if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)
+		if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2)
+			ctrl |= NFP_NET_CFG_CTRL_TXVLAN_V2;
+		else if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)
 			ctrl |= NFP_NET_CFG_CTRL_TXVLAN;
 	}
 
@@ -775,7 +778,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 					     RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
 					     RTE_ETH_RX_OFFLOAD_TCP_CKSUM;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_TXVLAN)
+	if (hw->cap & (NFP_NET_CFG_CTRL_TXVLAN | NFP_NET_CFG_CTRL_TXVLAN_V2))
 		dev_info->tx_offload_capa = RTE_ETH_TX_OFFLOAD_VLAN_INSERT;
 
 	if (hw->cap & NFP_NET_CFG_CTRL_TXCSUM)
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index bffdd8345e..6e2601d174 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -103,7 +103,7 @@
 #define   NFP_NET_CFG_CTRL_MSIXAUTO       (0x1 << 20) /* MSI-X auto-masking */
 #define   NFP_NET_CFG_CTRL_TXRWB          (0x1 << 21) /* Write-back of TX ring*/
 #define   NFP_NET_CFG_CTRL_L2SWITCH       (0x1 << 22) /* L2 Switch */
-#define   NFP_NET_CFG_CTRL_L2SWITCH_LOCAL (0x1 << 23) /* Switch to local */
+#define   NFP_NET_CFG_CTRL_TXVLAN_V2      (0x1 << 23) /* Enable VLAN insert with metadata */
 #define   NFP_NET_CFG_CTRL_VXLAN          (0x1 << 24) /* Enable VXLAN */
 #define   NFP_NET_CFG_CTRL_NVGRE          (0x1 << 25) /* Enable NVGRE */
 #define   NFP_NET_CFG_CTRL_MSIX_TX_OFF    (0x1 << 26) /* Disable MSIX for TX */
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 200886111e..293769f240 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -833,6 +833,33 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	return 0;
 }
 
+/*
+ * nfp_net_nfd3_tx_vlan() - Set vlan info in the nfd3 tx desc
+ *
+ * If enable NFP_NET_CFG_CTRL_TXVLAN_V2
+ *	Vlan_info is stored in the meta and
+ *	is handled in the nfp_net_nfd3_set_meta_vlan
+ * else if enable NFP_NET_CFG_CTRL_TXVLAN
+ *	Vlan_info is stored in the tx_desc and
+ *	is handled in the nfp_net_nfd3_tx_vlan
+ */
+static void
+nfp_net_nfd3_tx_vlan(struct nfp_net_txq *txq,
+		struct nfp_net_nfd3_tx_desc *txd,
+		struct rte_mbuf *mb)
+{
+	struct nfp_net_hw *hw = txq->hw;
+
+	if ((hw->cap & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0 ||
+		(hw->cap & NFP_NET_CFG_CTRL_TXVLAN) == 0)
+		return;
+
+	if ((mb->ol_flags & RTE_MBUF_F_TX_VLAN) != 0) {
+		txd->flags |= PCIE_DESC_TX_VLAN;
+		txd->vlan = mb->vlan_tci;
+	}
+}
+
 static void
 nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
 		struct rte_mbuf *pkt,
@@ -861,7 +888,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	hw = txq->hw;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
-			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN) != 0) {
+			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
 		if (meta_data->length == 0)
 			meta_data->length = NFP_NET_META_HEADER_SIZE;
 		meta_data->length += NFP_NET_META_FIELD_SIZE;
@@ -960,6 +987,7 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 		txd.data_len = pkt->pkt_len;
 		nfp_net_nfd3_tx_tso(txq, &txd, pkt);
 		nfp_net_nfd3_tx_cksum(txq, &txd, pkt);
+		nfp_net_nfd3_tx_vlan(txq, &txd, pkt);
 
 		/*
 		 * mbuf data_len is the data in one segment and pkt_len data
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 8/8] net/nfp: add support for VLAN insert with NFDk
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
                   ` (6 preceding siblings ...)
  2022-11-28  6:53 ` [PATCH 7/8] net/nfp: add support for VLAN insert V2 " Chaoyong He
@ 2022-11-28  6:53 ` Chaoyong He
  2023-01-24 16:28 ` [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Ferruh Yigit
  8 siblings, 0 replies; 11+ messages in thread
From: Chaoyong He @ 2022-11-28  6:53 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, niklas.soderlund, Peng Zhang, Chaoyong He

From: Peng Zhang <peng.zhang@corigine.com>

The firmware supplies VLAN insert information as packet metadata.
The field of this VLAN metadata includes VLAN TPID and VLAN
TCI.

Configuration control bit NFP_NET_CFG_CTRL_TXVLAN_V2 is to
signal availability of VLAN insert features of the firmware.

This feature already was implemented with NFD3, now it can be
supported with NFDk.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 doc/guides/nics/nfp.rst    | 42 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_ctrl.h |  1 +
 drivers/net/nfp/nfp_rxtx.c | 58 ++++++++++++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_rxtx.h |  3 +-
 4 files changed, 103 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/nfp.rst b/doc/guides/nics/nfp.rst
index a636fd0fde..a085d7d9ae 100644
--- a/doc/guides/nics/nfp.rst
+++ b/doc/guides/nics/nfp.rst
@@ -219,6 +219,9 @@ Metadata Format
 
 The NFP packet metadata format
 
+NFD3
+~~~~
+
 The packet metadata starts with a field type header that can contain up-to
 8 4-bit datatype specifiers (32-bits in total). This is followed by up to 8
 32-bit words of data for each field described in the header. And directly
@@ -254,6 +257,45 @@ be wrote N times in the heads.
    |                              ...                              |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
+NFDk
+~~~~
+
+The packet metadata starts with a field type header that can contain 8 bit
+metadata length and 6 4-bit datatype specifiers (32-bits in total). This is
+followed by up to 6 32-bit words of data for each field described in the
+header. And directly following the metadata (header and data) comes the
+packet.
+
+The order of type is correspond with the data, but the nums of data field are
+decided by the corresponding type, if the type need N data field, it need to
+be wrote N times in the heads. It is the same with NFD3.
+::
+
+       3                   2                   1                   0
+     1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   | Type5 | Type4 | Type3 | Type2 | Type1 | Type0 |metadata length|
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 0                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 1                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 2                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 3                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 4                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 5                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 6                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                        Data for field 7                       |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   |                          Packet Data                          |
+   |                              ...                              |
+   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
 There are two classes of metadata one for ingress and one for egress. In each
 class the supported NFP types are:
 
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index 6e2601d174..1069ff9485 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -30,6 +30,7 @@
 #define NFP_NET_META_FIELD_SIZE         4
 #define NFP_NET_META_FIELD_MASK ((1 << NFP_NET_META_FIELD_SIZE) - 1)
 #define NFP_NET_META_HEADER_SIZE        4
+#define NFP_NET_META_NFDK_LENGTH        8
 
 /* Working with metadata vlan api (NFD version >= 2.0) */
 #define NFP_NET_META_VLAN_INFO          16
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 293769f240..8f5e9a8e82 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -1058,6 +1058,63 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 	return i;
 }
 
+static void
+nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
+		struct nfp_net_txq *txq,
+		uint64_t *metadata)
+{
+	char *meta;
+	uint8_t layer = 0;
+	uint32_t meta_type;
+	struct nfp_net_hw *hw;
+	uint32_t header_offset;
+	uint8_t vlan_layer = 0;
+	struct nfp_net_meta_raw meta_data;
+
+	memset(&meta_data, 0, sizeof(meta_data));
+	hw = txq->hw;
+
+	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
+			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
+		if (meta_data.length == 0)
+			meta_data.length = NFP_NET_META_HEADER_SIZE;
+		meta_data.length += NFP_NET_META_FIELD_SIZE;
+		meta_data.header |= NFP_NET_META_VLAN;
+	}
+
+	if (meta_data.length == 0)
+		return;
+
+	meta_type = meta_data.header;
+	header_offset = meta_type << NFP_NET_META_NFDK_LENGTH;
+	meta_data.header = header_offset | meta_data.length;
+	meta_data.header = rte_cpu_to_be_32(meta_data.header);
+	meta = rte_pktmbuf_prepend(pkt, meta_data.length);
+	memcpy(meta, &meta_data.header, sizeof(meta_data.header));
+	meta += NFP_NET_META_HEADER_SIZE;
+
+	for (; meta_type != 0; meta_type >>= NFP_NET_META_FIELD_SIZE, layer++,
+			meta += NFP_NET_META_FIELD_SIZE) {
+		switch (meta_type & NFP_NET_META_FIELD_MASK) {
+		case NFP_NET_META_VLAN:
+			if (vlan_layer > 0) {
+				PMD_DRV_LOG(ERR, "At most 1 layers of vlan is supported");
+				return;
+			}
+			nfp_net_set_meta_vlan(&meta_data, pkt, layer);
+			vlan_layer++;
+			break;
+		default:
+			PMD_DRV_LOG(ERR, "The metadata type not supported");
+			return;
+		}
+
+		memcpy(meta, &meta_data.data[layer], sizeof(meta_data.data[layer]));
+	}
+
+	*metadata = NFDK_DESC_TX_CHAIN_META;
+}
+
 static int
 nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
 		uint16_t queue_idx,
@@ -1383,6 +1440,7 @@ nfp_net_nfdk_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
 		RTE_MBUF_PREFETCH_TO_FREE(*lmbuf);
 
 		temp_pkt = pkt;
+		nfp_net_nfdk_set_meta_data(pkt, txq, &metadata);
 
 		if (unlikely(pkt->nb_segs > 1 &&
 				!(hw->cap & NFP_NET_CFG_CTRL_GATHER))) {
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index d16d557fd3..4c86b2b775 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -36,7 +36,7 @@
  * Describe the raw metadata format, useful when preparing metadata for a
  * transmission mbuf.
  *
- * @header: NFD3 Contains the 8 4-bit type fields
+ * @header: NFD3 or NFDk field type header (see format in nfp.rst)
  * @data: Array of each fields data member
  * @length: Keep track of number of valid fields in @header and data. Not part
  *          of the raw metadata.
@@ -118,6 +118,7 @@ struct nfp_meta_parsed {
 #define NFDK_DESC_TX_TYPE_SIMPLE        8
 #define NFDK_DESC_TX_TYPE_GATHER        1
 #define NFDK_DESC_TX_EOP                BIT(14)
+#define NFDK_DESC_TX_CHAIN_META         BIT(3)
 #define NFDK_DESC_TX_L4_CSUM            BIT(1)
 #define NFDK_DESC_TX_L3_CSUM            BIT(0)
 
-- 
2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH 1/8] net/nfp: break out function to report device information
  2022-11-28  6:53 ` [PATCH 1/8] net/nfp: break out function to report device information Chaoyong He
@ 2023-01-16  2:24   ` Nole Zhang
  0 siblings, 0 replies; 11+ messages in thread
From: Nole Zhang @ 2023-01-16  2:24 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, Niklas Soderlund

Hi all,

A gentle ping on this patch.

> -----Original Message-----
> From: Chaoyong He <chaoyong.he@corigine.com>
> Sent: 2022年11月28日 14:54
> To: dev@dpdk.org
> Cc: oss-drivers <oss-drivers@corigine.com>; Niklas Soderlund
> <niklas.soderlund@corigine.com>; Nole Zhang <peng.zhang@corigine.com>;
> Chaoyong He <chaoyong.he@corigine.com>
> Subject: [PATCH 1/8] net/nfp: break out function to report device
> information
> 
> From: Peng Zhang <peng.zhang@corigine.com>
> 
> The method to report device information to the log is the same for both
> physical and virtual functions. The implementation is however open coded in
> each code path, break out the reporting logic to a helper function to reduce
> code duplication.
> 
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> ---
>  drivers/net/nfp/nfp_common.c    | 27 +++++++++++++++++++++++++++
>  drivers/net/nfp/nfp_common.h    |  1 +
>  drivers/net/nfp/nfp_ethdev.c    | 23 +----------------------
>  drivers/net/nfp/nfp_ethdev_vf.c | 23 +----------------------
>  4 files changed, 30 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
> index 71711bfa22..f112a70980 100644
> --- a/drivers/net/nfp/nfp_common.c
> +++ b/drivers/net/nfp/nfp_common.c
> @@ -188,6 +188,33 @@ nfp_net_configure(struct rte_eth_dev *dev)
>  	return 0;
>  }
> 
> +void
> +nfp_net_log_device_information(const struct nfp_net_hw *hw) {
> +	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
> +			NFD_CFG_MAJOR_VERSION_of(hw->ver),
> +			NFD_CFG_MINOR_VERSION_of(hw->ver), hw-
> >max_mtu);
> +
> +	PMD_INIT_LOG(INFO,
> "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
> +			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ?
> "PROMISC "   : "",
> +			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT
> "  : "",
> +			hw->cap & NFP_NET_CFG_CTRL_L2MC      ?
> "L2MCFILT "  : "",
> +			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ?
> "RXCSUM "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ?
> "TXCSUM "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN
> "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN
> "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ?
> "SCATTER "   : "",
> +			hw->cap & NFP_NET_CFG_CTRL_GATHER    ?
> "GATHER "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ?
> "LIVE_ADDR " : "",
> +			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       :
> "",
> +			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2
> "     : "",
> +			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       :
> "",
> +			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     :
> "");
> +
> +	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
> +			hw->max_rx_queues, hw->max_tx_queues); }
> +
>  void
>  nfp_net_enable_queues(struct rte_eth_dev *dev)  { diff --git
> a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index
> 36c19b47e4..02612dbb58 100644
> --- a/drivers/net/nfp/nfp_common.h
> +++ b/drivers/net/nfp/nfp_common.h
> @@ -404,6 +404,7 @@ nfp_pci_queue(struct rte_pci_device *pdev, uint16_t
> queue)
>  /* Prototypes for common NFP functions */  int nfp_net_reconfig(struct
> nfp_net_hw *hw, uint32_t ctrl, uint32_t update);  int
> nfp_net_configure(struct rte_eth_dev *dev);
> +void nfp_net_log_device_information(const struct nfp_net_hw *hw);
>  void nfp_net_enable_queues(struct rte_eth_dev *dev);  void
> nfp_net_disable_queues(struct rte_eth_dev *dev);  void
> nfp_net_params_setup(struct nfp_net_hw *hw); diff --git
> a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index
> 0956ea81df..f661819fc0 100644
> --- a/drivers/net/nfp/nfp_ethdev.c
> +++ b/drivers/net/nfp/nfp_ethdev.c
> @@ -619,33 +619,12 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
>  	else
>  		hw->rx_offset = nn_cfg_readl(hw,
> NFP_NET_CFG_RX_OFFSET_ADDR);
> 
> -	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
> -			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
> -			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw-
> >max_mtu);
> -
> -	PMD_INIT_LOG(INFO,
> "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
> -		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR
> "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
> -
>  	hw->ctrl = 0;
> 
>  	hw->stride_rx = stride;
>  	hw->stride_tx = stride;
> 
> -	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
> -		     hw->max_rx_queues, hw->max_tx_queues);
> +	nfp_net_log_device_information(hw);
> 
>  	/* Initializing spinlock for reconfigs */
>  	rte_spinlock_init(&hw->reconfig_lock);
> diff --git a/drivers/net/nfp/nfp_ethdev_vf.c
> b/drivers/net/nfp/nfp_ethdev_vf.c index d1427b63bc..170f7eeb93 100644
> --- a/drivers/net/nfp/nfp_ethdev_vf.c
> +++ b/drivers/net/nfp/nfp_ethdev_vf.c
> @@ -376,33 +376,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
>  	else
>  		hw->rx_offset = nn_cfg_readl(hw,
> NFP_NET_CFG_RX_OFFSET_ADDR);
> 
> -	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
> -			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
> -			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw-
> >max_mtu);
> -
> -	PMD_INIT_LOG(INFO,
> "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
> -		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR
> "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
> -
>  	hw->ctrl = 0;
> 
>  	hw->stride_rx = stride;
>  	hw->stride_tx = stride;
> 
> -	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
> -		     hw->max_rx_queues, hw->max_tx_queues);
> +	nfp_net_log_device_information(hw);
> 
>  	/* Initializing spinlock for reconfigs */
>  	rte_spinlock_init(&hw->reconfig_lock);
> --
> 2.29.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert
  2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
                   ` (7 preceding siblings ...)
  2022-11-28  6:53 ` [PATCH 8/8] net/nfp: add support for VLAN insert with NFDk Chaoyong He
@ 2023-01-24 16:28 ` Ferruh Yigit
  8 siblings, 0 replies; 11+ messages in thread
From: Ferruh Yigit @ 2023-01-24 16:28 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund

On 11/28/2022 6:53 AM, Chaoyong He wrote:
> Add support for QinQ strip
> Add support for VLAN strip
> Add support for VLAN insert with NFD3
> Add support for VLAN insert with NFDk
> 
> Peng Zhang (8):
>   net/nfp: break out function to report device information
>   net/nfp: modify the logic of parse metadata
>   net/nfp: add new metadata type for achieving VLAN strip
>   net/nfp: add support for QinQ strip
>   net/nfp: add support for VLAN strip V2
>   net/nfp: add support for VLAN insert with NFD3
>   net/nfp: add support for VLAN insert V2 with NFD3
>   net/nfp: add support for VLAN insert with NFDk
> 

Series applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-01-24 16:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-28  6:53 [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Chaoyong He
2022-11-28  6:53 ` [PATCH 1/8] net/nfp: break out function to report device information Chaoyong He
2023-01-16  2:24   ` Nole Zhang
2022-11-28  6:53 ` [PATCH 2/8] net/nfp: modify the logic of parse metadata Chaoyong He
2022-11-28  6:53 ` [PATCH 3/8] net/nfp: add new metadata type for achieving VLAN strip Chaoyong He
2022-11-28  6:53 ` [PATCH 4/8] net/nfp: add support for QinQ strip Chaoyong He
2022-11-28  6:53 ` [PATCH 5/8] net/nfp: add support for VLAN strip V2 Chaoyong He
2022-11-28  6:53 ` [PATCH 6/8] net/nfp: add support for VLAN insert with NFD3 Chaoyong He
2022-11-28  6:53 ` [PATCH 7/8] net/nfp: add support for VLAN insert V2 " Chaoyong He
2022-11-28  6:53 ` [PATCH 8/8] net/nfp: add support for VLAN insert with NFDk Chaoyong He
2023-01-24 16:28 ` [PATCH 0/8] Add the features for nfp include VLAN strip, QinQ strip, VLAN insert Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).