* [PATCH 0/5] add new meta data module
@ 2024-03-05 2:29 Chaoyong He
2024-03-05 2:29 ` [PATCH 1/5] net/nfp: create " Chaoyong He
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Chaoyong He @ 2024-03-05 2:29 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Chaoyong He
Extract the related code into a new meta data module, uniform
the name format and data endian.
Which makes the logic more clear and easier to extend in the future.
Long Wu (5):
net/nfp: create new meta data module
net/nfp: uniform variable name format
net/nfp: uniform function name format
net/nfp: use flag bits to control parsing meta data
net/nfp: use big-endian meta data for packet
drivers/common/nfp/nfp_common_ctrl.h | 41 ---
drivers/net/nfp/flower/nfp_flower.c | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.c | 3 +-
drivers/net/nfp/flower/nfp_flower_ctrl.c | 3 +-
drivers/net/nfp/meson.build | 1 +
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 11 +-
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 11 +-
drivers/net/nfp/nfp_ipsec.c | 1 +
drivers/net/nfp/nfp_ipsec.h | 6 -
drivers/net/nfp/nfp_net_common.c | 26 +-
drivers/net/nfp/nfp_net_common.h | 7 +-
drivers/net/nfp/nfp_net_meta.c | 334 +++++++++++++++++++++++
drivers/net/nfp/nfp_net_meta.h | 107 ++++++++
drivers/net/nfp/nfp_rxtx.c | 309 +--------------------
drivers/net/nfp/nfp_rxtx.h | 20 --
15 files changed, 464 insertions(+), 417 deletions(-)
create mode 100644 drivers/net/nfp/nfp_net_meta.c
create mode 100644 drivers/net/nfp/nfp_net_meta.h
--
2.39.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] net/nfp: create new meta data module
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
@ 2024-03-05 2:29 ` Chaoyong He
2024-03-05 2:29 ` [PATCH 2/5] net/nfp: uniform variable name format Chaoyong He
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Chaoyong He @ 2024-03-05 2:29 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Move the Rx meta data code to new 'nfp_net_meta' module, which
makes related logic more clean and the code architecture more
reasonable.
There is no functional change, just moving verbatim code around.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/common/nfp/nfp_common_ctrl.h | 41 ---
drivers/net/nfp/flower/nfp_flower.c | 1 +
drivers/net/nfp/flower/nfp_flower_cmsg.c | 1 +
drivers/net/nfp/flower/nfp_flower_ctrl.c | 1 +
drivers/net/nfp/meson.build | 1 +
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 1 +
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 1 +
drivers/net/nfp/nfp_ipsec.c | 1 +
drivers/net/nfp/nfp_ipsec.h | 6 -
drivers/net/nfp/nfp_net_common.c | 24 +-
drivers/net/nfp/nfp_net_common.h | 7 +-
drivers/net/nfp/nfp_net_meta.c | 320 +++++++++++++++++++++++
drivers/net/nfp/nfp_net_meta.h | 108 ++++++++
drivers/net/nfp/nfp_rxtx.c | 305 +--------------------
drivers/net/nfp/nfp_rxtx.h | 20 --
15 files changed, 438 insertions(+), 400 deletions(-)
create mode 100644 drivers/net/nfp/nfp_net_meta.c
create mode 100644 drivers/net/nfp/nfp_net_meta.h
diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 7749ba6459..6badf769fc 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -13,47 +13,6 @@
*/
#define NFP_NET_CFG_BAR_SZ (32 * 1024)
-/* Offset in Freelist buffer where packet starts on RX */
-#define NFP_NET_RX_OFFSET 32
-
-/* 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
-#define NFP_NET_META_NFDK_LENGTH 8
-
-/* 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_MARK 2
-#define NFP_NET_META_VLAN 4
-#define NFP_NET_META_PORTID 5
-#define NFP_NET_META_IPSEC 9
-
-#define NFP_META_PORT_ID_CTRL ~0U
-
-/* Hash type prepended when a RSS hash was computed */
-#define NFP_NET_RSS_NONE 0
-#define NFP_NET_RSS_IPV4 1
-#define NFP_NET_RSS_IPV6 2
-#define NFP_NET_RSS_IPV6_EX 3
-#define NFP_NET_RSS_IPV4_TCP 4
-#define NFP_NET_RSS_IPV6_TCP 5
-#define NFP_NET_RSS_IPV6_EX_TCP 6
-#define NFP_NET_RSS_IPV4_UDP 7
-#define NFP_NET_RSS_IPV6_UDP 8
-#define NFP_NET_RSS_IPV6_EX_UDP 9
-#define NFP_NET_RSS_IPV4_SCTP 10
-#define NFP_NET_RSS_IPV6_SCTP 11
-
/*
* @NFP_NET_TXR_MAX: Maximum number of TX rings
* @NFP_NET_TXR_MASK: Mask for TX rings
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index c6a744e868..97219ff379 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -16,6 +16,7 @@
#include "../nfp_cpp_bridge.h"
#include "../nfp_logs.h"
#include "../nfp_mtr.h"
+#include "../nfp_net_meta.h"
#include "nfp_flower_ctrl.h"
#include "nfp_flower_representor.h"
#include "nfp_flower_service.h"
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index 8effe9474d..f78bfba332 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -7,6 +7,7 @@
#include "../nfpcore/nfp_nsp.h"
#include "../nfp_logs.h"
+#include "../nfp_net_meta.h"
#include "nfp_flower_ctrl.h"
#include "nfp_flower_representor.h"
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index bcb325d475..720a0d9495 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -10,6 +10,7 @@
#include "../nfd3/nfp_nfd3.h"
#include "../nfdk/nfp_nfdk.h"
#include "../nfp_logs.h"
+#include "../nfp_net_meta.h"
#include "nfp_flower_representor.h"
#include "nfp_mtr.h"
#include "nfp_flower_service.h"
diff --git a/drivers/net/nfp/meson.build b/drivers/net/nfp/meson.build
index 959ca01844..d805644ec5 100644
--- a/drivers/net/nfp/meson.build
+++ b/drivers/net/nfp/meson.build
@@ -41,6 +41,7 @@ sources = files(
'nfp_net_common.c',
'nfp_net_ctrl.c',
'nfp_net_flow.c',
+ 'nfp_net_meta.c',
'nfp_rxtx.c',
'nfp_service.c',
)
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index be31f4ac33..5fb76ae9d7 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -10,6 +10,7 @@
#include "../flower/nfp_flower.h"
#include "../nfp_logs.h"
+#include "../nfp_net_meta.h"
/* Flags in the host TX descriptor */
#define NFD3_DESC_TX_CSUM RTE_BIT32(7)
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index daf5ac5b30..8bdab5d463 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -11,6 +11,7 @@
#include "../flower/nfp_flower.h"
#include "../nfp_logs.h"
+#include "../nfp_net_meta.h"
#define NFDK_TX_DESC_GATHER_MAX 17
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index 0b815fa983..0bf146b9be 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -18,6 +18,7 @@
#include "nfp_net_common.h"
#include "nfp_net_ctrl.h"
#include "nfp_rxtx.h"
+#include "nfp_net_meta.h"
#define NFP_UDP_ESP_PORT 4500
diff --git a/drivers/net/nfp/nfp_ipsec.h b/drivers/net/nfp/nfp_ipsec.h
index d7a729398a..4ef0e196be 100644
--- a/drivers/net/nfp/nfp_ipsec.h
+++ b/drivers/net/nfp/nfp_ipsec.h
@@ -168,12 +168,6 @@ struct nfp_net_ipsec_data {
struct nfp_ipsec_session *sa_entries[NFP_NET_IPSEC_MAX_SA_CNT];
};
-enum nfp_ipsec_meta_layer {
- NFP_IPSEC_META_SAIDX, /**< Order of SA index in metadata */
- NFP_IPSEC_META_SEQLOW, /**< Order of Sequence Number (low 32bits) in metadata */
- NFP_IPSEC_META_SEQHI, /**< Order of Sequence Number (high 32bits) in metadata */
-};
-
int nfp_ipsec_init(struct rte_eth_dev *dev);
void nfp_ipsec_uninit(struct rte_eth_dev *dev);
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 20e628bfd1..384e042dfd 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -15,6 +15,7 @@
#include "nfpcore/nfp_mip.h"
#include "nfpcore/nfp_nsp.h"
#include "nfp_logs.h"
+#include "nfp_net_meta.h"
#define NFP_TX_MAX_SEG UINT8_MAX
#define NFP_TX_MAX_MTU_SEG 8
@@ -2038,29 +2039,6 @@ nfp_net_check_dma_mask(struct nfp_net_hw *hw,
return 0;
}
-void
-nfp_net_init_metadata_format(struct nfp_net_hw *hw)
-{
- /*
- * ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of
- * single metadata if only RSS(v1) is supported by hw capability, and RSS(v2)
- * also indicate that we are using chained metadata.
- */
- if (hw->ver.major == 4) {
- hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
- } else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
- hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
- /*
- * RSS is incompatible with chained metadata. hw->super.cap just represents
- * firmware's ability rather than the firmware's configuration. We decide
- * to reduce the confusion to allow us can use hw->super.cap to identify RSS later.
- */
- hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS;
- } else {
- hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
- }
-}
-
void
nfp_net_cfg_read_version(struct nfp_net_hw *hw)
{
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 628c0d3491..49a5a84044 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -16,6 +16,7 @@
#include "nfpcore/nfp_sync.h"
#include "nfp_net_ctrl.h"
#include "nfp_service.h"
+#include "nfp_net_meta.h"
/* Interrupt definitions */
#define NFP_NET_IRQ_LSC_IDX 0
@@ -67,11 +68,6 @@ enum nfp_app_fw_id {
NFP_APP_FW_FLOWER_NIC = 0x3,
};
-enum nfp_net_meta_format {
- NFP_NET_METAFORMAT_SINGLE,
- NFP_NET_METAFORMAT_CHAINED,
-};
-
/* Parsed control BAR TLV capabilities */
struct nfp_net_tlv_caps {
uint32_t mbox_off; /**< VNIC mailbox area offset */
@@ -306,7 +302,6 @@ void nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
uint16_t *min_tx_desc,
uint16_t *max_tx_desc);
int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name);
-void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
void nfp_net_cfg_read_version(struct nfp_net_hw *hw);
int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size);
bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
new file mode 100644
index 0000000000..0bc22b2f88
--- /dev/null
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -0,0 +1,320 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2023 Corigine, Inc.
+ * All rights reserved.
+ */
+
+#include "nfp_net_meta.h"
+
+#include "nfp_net_common.h"
+#include "nfp_ipsec.h"
+#include "nfp_logs.h"
+
+enum nfp_ipsec_meta_layer {
+ NFP_IPSEC_META_SAIDX, /**< Order of SA index in metadata */
+ NFP_IPSEC_META_SEQLOW, /**< Order of Sequence Number (low 32bits) in metadata */
+ NFP_IPSEC_META_SEQHI, /**< Order of Sequence Number (high 32bits) in metadata */
+};
+
+/* Parse the chained metadata from packet */
+static bool
+nfp_net_parse_chained_meta(uint8_t *meta_base,
+ rte_be32_t meta_header,
+ struct nfp_meta_parsed *meta)
+{
+ uint32_t meta_info;
+ uint32_t vlan_info;
+ uint8_t *meta_offset;
+
+ meta_info = rte_be_to_cpu_32(meta_header);
+ meta_offset = meta_base + 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_PORTID:
+ meta->port_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
+ break;
+ case NFP_NET_META_HASH:
+ /* Next field type is about the hash type */
+ meta_info >>= NFP_NET_META_FIELD_SIZE;
+ /* 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;
+ 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;
+ case NFP_NET_META_IPSEC:
+ meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
+ meta->ipsec_type = meta_info & NFP_NET_META_FIELD_MASK;
+ break;
+ case NFP_NET_META_MARK:
+ meta->flags |= (1 << NFP_NET_META_MARK);
+ meta->mark_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
+ break;
+ default:
+ /* Unsupported metadata can be a performance issue */
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/*
+ * Parse the single metadata
+ *
+ * The RSS hash and hash-type are prepended to the packet data.
+ * Get it from metadata area.
+ */
+static inline void
+nfp_net_parse_single_meta(uint8_t *meta_base,
+ rte_be32_t meta_header,
+ struct nfp_meta_parsed *meta)
+{
+ meta->hash_type = rte_be_to_cpu_32(meta_header);
+ meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4));
+}
+
+/* Set mbuf hash data based on the metadata info */
+static void
+nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
+ struct nfp_net_rxq *rxq,
+ struct rte_mbuf *mbuf)
+{
+ struct nfp_net_hw *hw = rxq->hw;
+
+ if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
+ return;
+
+ mbuf->hash.rss = meta->hash;
+ mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
+}
+
+/* Set mbuf vlan_strip data based on metadata info */
+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)
+{
+ uint32_t ctrl = rxq->hw->super.ctrl;
+
+ /* Skip if hardware don't support setting vlan. */
+ if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
+ return;
+
+ /*
+ * The firmware support two ways to send the VLAN info (with priority) :
+ * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
+ * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
+ */
+ if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
+ if (meta->vlan_layer > 0 && 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 ((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.offload_info);
+ mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+ }
+ }
+}
+
+/*
+ * 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_hw *hw = &rxq->hw->super;
+
+ 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 TCI is %u inner vlan TCI is %u",
+ mb->vlan_tci_outer, mb->vlan_tci);
+ mb->ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED;
+}
+
+/*
+ * Set mbuf IPsec Offload features based on metadata info.
+ *
+ * The IPsec Offload features is prepended to the mbuf ol_flags.
+ * Extract and decode metadata info and set the mbuf ol_flags.
+ */
+static void
+nfp_net_parse_meta_ipsec(struct nfp_meta_parsed *meta,
+ struct nfp_net_rxq *rxq,
+ struct rte_mbuf *mbuf)
+{
+ int offset;
+ uint32_t sa_idx;
+ struct nfp_net_hw *hw;
+ struct nfp_tx_ipsec_desc_msg *desc_md;
+
+ hw = rxq->hw;
+ sa_idx = meta->sa_idx;
+
+ if (meta->ipsec_type != NFP_NET_META_IPSEC)
+ return;
+
+ if (sa_idx >= NFP_NET_IPSEC_MAX_SA_CNT) {
+ mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
+ } else {
+ mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD;
+ offset = hw->ipsec_data->pkt_dynfield_offset;
+ desc_md = RTE_MBUF_DYNFIELD(mbuf, offset, struct nfp_tx_ipsec_desc_msg *);
+ desc_md->sa_idx = sa_idx;
+ desc_md->enc = 0;
+ }
+}
+
+static void
+nfp_net_parse_meta_mark(const struct nfp_meta_parsed *meta,
+ struct rte_mbuf *mbuf)
+{
+ if (((meta->flags >> NFP_NET_META_MARK) & 0x1) == 0)
+ return;
+
+ mbuf->hash.fdir.hi = meta->mark_id;
+ mbuf->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
+}
+
+/* Parse the metadata from packet */
+void
+nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
+ struct nfp_net_rxq *rxq,
+ struct nfp_net_hw *hw,
+ struct rte_mbuf *mb,
+ struct nfp_meta_parsed *meta)
+{
+ uint8_t *meta_base;
+ rte_be32_t meta_header;
+
+ if (unlikely(NFP_DESC_META_LEN(rxds) == 0))
+ return;
+
+ meta_base = rte_pktmbuf_mtod_offset(mb, uint8_t *, -NFP_DESC_META_LEN(rxds));
+ meta_header = *(rte_be32_t *)meta_base;
+
+ switch (hw->meta_format) {
+ case NFP_NET_METAFORMAT_CHAINED:
+ if (nfp_net_parse_chained_meta(meta_base, meta_header, meta)) {
+ nfp_net_parse_meta_hash(meta, rxq, mb);
+ nfp_net_parse_meta_vlan(meta, rxds, rxq, mb);
+ nfp_net_parse_meta_qinq(meta, rxq, mb);
+ nfp_net_parse_meta_ipsec(meta, rxq, mb);
+ nfp_net_parse_meta_mark(meta, mb);
+ } else {
+ PMD_RX_LOG(DEBUG, "RX chained metadata format is wrong!");
+ }
+ break;
+ case NFP_NET_METAFORMAT_SINGLE:
+ if ((rxds->rxd.flags & PCIE_DESC_RX_RSS) != 0) {
+ nfp_net_parse_single_meta(meta_base, meta_header, meta);
+ nfp_net_parse_meta_hash(meta, rxq, mb);
+ }
+ break;
+ default:
+ PMD_RX_LOG(DEBUG, "RX metadata do not exist.");
+ }
+}
+
+void
+nfp_net_init_metadata_format(struct nfp_net_hw *hw)
+{
+ /*
+ * ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of
+ * single metadata if only RSS(v1) is supported by hw capability, and RSS(v2)
+ * also indicate that we are using chained metadata.
+ */
+ if (hw->ver.major == 4) {
+ hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
+ } else if ((hw->super.cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
+ hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
+ /*
+ * RSS is incompatible with chained metadata. hw->super.cap just represents
+ * firmware's ability rather than the firmware's configuration. We decide
+ * to reduce the confusion to allow us can use hw->super.cap to identify RSS later.
+ */
+ hw->super.cap &= ~NFP_NET_CFG_CTRL_RSS;
+ } else {
+ hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
+ }
+}
+
+void
+nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
+ struct rte_mbuf *pkt,
+ uint8_t layer)
+{
+ uint16_t tpid;
+ uint16_t vlan_tci;
+
+ tpid = RTE_ETHER_TYPE_VLAN;
+ vlan_tci = pkt->vlan_tci;
+
+ meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci);
+}
+
+void
+nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
+ struct nfp_net_txq *txq,
+ struct rte_mbuf *pkt,
+ uint8_t layer,
+ uint8_t ipsec_layer)
+{
+ int offset;
+ struct nfp_net_hw *hw;
+ struct nfp_tx_ipsec_desc_msg *desc_md;
+
+ hw = txq->hw;
+ offset = hw->ipsec_data->pkt_dynfield_offset;
+ desc_md = RTE_MBUF_DYNFIELD(pkt, offset, struct nfp_tx_ipsec_desc_msg *);
+
+ switch (ipsec_layer) {
+ case NFP_IPSEC_META_SAIDX:
+ meta_data->data[layer] = desc_md->sa_idx;
+ break;
+ case NFP_IPSEC_META_SEQLOW:
+ meta_data->data[layer] = desc_md->esn.low;
+ break;
+ case NFP_IPSEC_META_SEQHI:
+ meta_data->data[layer] = desc_md->esn.hi;
+ break;
+ default:
+ break;
+ }
+}
diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h
new file mode 100644
index 0000000000..da2091ce9f
--- /dev/null
+++ b/drivers/net/nfp/nfp_net_meta.h
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2014, 2015 Netronome Systems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef __NFP_NET_META_H__
+#define __NFP_NET_META_H__
+
+#include "nfp_rxtx.h"
+
+/* Hash type prepended when a RSS hash was computed */
+#define NFP_NET_RSS_NONE 0
+#define NFP_NET_RSS_IPV4 1
+#define NFP_NET_RSS_IPV6 2
+#define NFP_NET_RSS_IPV6_EX 3
+#define NFP_NET_RSS_IPV4_TCP 4
+#define NFP_NET_RSS_IPV6_TCP 5
+#define NFP_NET_RSS_IPV6_EX_TCP 6
+#define NFP_NET_RSS_IPV4_UDP 7
+#define NFP_NET_RSS_IPV6_UDP 8
+#define NFP_NET_RSS_IPV6_EX_UDP 9
+#define NFP_NET_RSS_IPV4_SCTP 10
+#define NFP_NET_RSS_IPV6_SCTP 11
+
+/* Offset in Freelist buffer where packet starts on RX */
+#define NFP_NET_RX_OFFSET 32
+
+/* 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
+#define NFP_NET_META_NFDK_LENGTH 8
+
+/* 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_MARK 2
+#define NFP_NET_META_VLAN 4
+#define NFP_NET_META_PORTID 5
+#define NFP_NET_META_IPSEC 9
+
+#define NFP_META_PORT_ID_CTRL ~0U
+
+#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
+
+/* Maximum number of NFP packet metadata fields. */
+#define NFP_META_MAX_FIELDS 8
+
+/* Maximum number of supported VLANs in parsed form packet metadata. */
+#define NFP_META_MAX_VLANS 2
+
+enum nfp_net_meta_format {
+ NFP_NET_METAFORMAT_SINGLE,
+ NFP_NET_METAFORMAT_CHAINED,
+};
+
+/* Describe the raw metadata format. */
+struct nfp_net_meta_raw {
+ uint32_t header; /**< Field type header (see format in nfp.rst) */
+ uint32_t data[NFP_META_MAX_FIELDS]; /**< Array of each fields data member */
+ uint8_t length; /**< Number of valid fields in @header */
+};
+
+/* Record metadata parsed from packet */
+struct nfp_meta_parsed {
+ uint32_t port_id; /**< Port id value */
+ uint32_t sa_idx; /**< IPsec SA index */
+ uint32_t hash; /**< RSS hash value */
+ uint32_t mark_id; /**< Mark id value */
+ uint16_t flags; /**< Bitmap to indicate if meta exist */
+ uint8_t hash_type; /**< RSS hash type */
+ uint8_t ipsec_type; /**< IPsec type */
+ uint8_t vlan_layer; /**< The valid number of value in @vlan[] */
+ /**
+ * Holds information parses from NFP_NET_META_VLAN.
+ * The inner most vlan starts at position 0
+ */
+ struct {
+ uint8_t offload; /**< Flag indicates whether VLAN is offloaded */
+ uint8_t tpid; /**< Vlan TPID */
+ uint16_t tci; /**< Vlan TCI (PCP + Priority + VID) */
+ } vlan[NFP_META_MAX_VLANS];
+};
+
+void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
+void nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
+ struct nfp_net_rxq *rxq,
+ struct nfp_net_hw *hw,
+ struct rte_mbuf *mb,
+ struct nfp_meta_parsed *meta);
+void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
+ struct rte_mbuf *pkt,
+ uint8_t layer);
+void nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
+ struct nfp_net_txq *txq,
+ struct rte_mbuf *pkt,
+ uint8_t layer,
+ uint8_t ipsec_layer);
+
+#endif /* __NFP_NET_META_H__ */
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index cbcf57d769..0256eba456 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -16,30 +16,7 @@
#include "nfp_ipsec.h"
#include "nfp_logs.h"
-
-/* Maximum number of supported VLANs in parsed form packet metadata. */
-#define NFP_META_MAX_VLANS 2
-
-/* Record metadata parsed from packet */
-struct nfp_meta_parsed {
- uint32_t port_id; /**< Port id value */
- uint32_t sa_idx; /**< IPsec SA index */
- uint32_t hash; /**< RSS hash value */
- uint32_t mark_id; /**< Mark id value */
- uint16_t flags; /**< Bitmap to indicate if meta exist */
- uint8_t hash_type; /**< RSS hash type */
- uint8_t ipsec_type; /**< IPsec type */
- uint8_t vlan_layer; /**< The valid number of value in @vlan[] */
- /**
- * Holds information parses from NFP_NET_META_VLAN.
- * The inner most vlan starts at position 0
- */
- struct {
- uint8_t offload; /**< Flag indicates whether VLAN is offloaded */
- uint8_t tpid; /**< Vlan TPID */
- uint16_t tci; /**< Vlan TCI (PCP + Priority + VID) */
- } vlan[NFP_META_MAX_VLANS];
-};
+#include "nfp_net_meta.h"
/*
* The bit format and map of nfp packet type for rxd.offload_info in Rx descriptor.
@@ -254,242 +231,6 @@ nfp_net_rx_queue_count(void *rx_queue)
return count;
}
-/* Parse the chained metadata from packet */
-static bool
-nfp_net_parse_chained_meta(uint8_t *meta_base,
- rte_be32_t meta_header,
- struct nfp_meta_parsed *meta)
-{
- uint32_t meta_info;
- uint32_t vlan_info;
- uint8_t *meta_offset;
-
- meta_info = rte_be_to_cpu_32(meta_header);
- meta_offset = meta_base + 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_PORTID:
- meta->port_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
- break;
- case NFP_NET_META_HASH:
- /* Next field type is about the hash type */
- meta_info >>= NFP_NET_META_FIELD_SIZE;
- /* 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;
- 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;
- case NFP_NET_META_IPSEC:
- meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
- meta->ipsec_type = meta_info & NFP_NET_META_FIELD_MASK;
- break;
- case NFP_NET_META_MARK:
- meta->flags |= (1 << NFP_NET_META_MARK);
- meta->mark_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
- break;
- default:
- /* Unsupported metadata can be a performance issue */
- return false;
- }
- }
-
- return true;
-}
-
-/* Set mbuf hash data based on the metadata info */
-static void
-nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
- struct nfp_net_rxq *rxq,
- struct rte_mbuf *mbuf)
-{
- struct nfp_net_hw *hw = rxq->hw;
-
- if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
- return;
-
- mbuf->hash.rss = meta->hash;
- mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
-}
-
-/*
- * Parse the single metadata
- *
- * The RSS hash and hash-type are prepended to the packet data.
- * Get it from metadata area.
- */
-static inline void
-nfp_net_parse_single_meta(uint8_t *meta_base,
- rte_be32_t meta_header,
- struct nfp_meta_parsed *meta)
-{
- meta->hash_type = rte_be_to_cpu_32(meta_header);
- meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4));
-}
-
-/* Set mbuf vlan_strip data based on metadata info */
-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)
-{
- uint32_t ctrl = rxq->hw->super.ctrl;
-
- /* Skip if hardware don't support setting vlan. */
- if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
- return;
-
- /*
- * The firmware support two ways to send the VLAN info (with priority) :
- * 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
- * 2. Using the descriptor when NFP_NET_CFG_CTRL_RXVLAN is set.
- */
- if ((ctrl & NFP_NET_CFG_CTRL_RXVLAN_V2) != 0) {
- if (meta->vlan_layer > 0 && 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 ((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.offload_info);
- mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
- }
- }
-}
-
-/*
- * 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_hw *hw = &rxq->hw->super;
-
- if ((hw->ctrl & 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 TCI is %u inner vlan TCI is %u",
- mb->vlan_tci_outer, mb->vlan_tci);
- mb->ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED;
-}
-
-/*
- * Set mbuf IPsec Offload features based on metadata info.
- *
- * The IPsec Offload features is prepended to the mbuf ol_flags.
- * Extract and decode metadata info and set the mbuf ol_flags.
- */
-static void
-nfp_net_parse_meta_ipsec(struct nfp_meta_parsed *meta,
- struct nfp_net_rxq *rxq,
- struct rte_mbuf *mbuf)
-{
- int offset;
- uint32_t sa_idx;
- struct nfp_net_hw *hw;
- struct nfp_tx_ipsec_desc_msg *desc_md;
-
- hw = rxq->hw;
- sa_idx = meta->sa_idx;
-
- if (meta->ipsec_type != NFP_NET_META_IPSEC)
- return;
-
- if (sa_idx >= NFP_NET_IPSEC_MAX_SA_CNT) {
- mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
- } else {
- mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD;
- offset = hw->ipsec_data->pkt_dynfield_offset;
- desc_md = RTE_MBUF_DYNFIELD(mbuf, offset, struct nfp_tx_ipsec_desc_msg *);
- desc_md->sa_idx = sa_idx;
- desc_md->enc = 0;
- }
-}
-
-static void
-nfp_net_parse_meta_mark(const struct nfp_meta_parsed *meta,
- struct rte_mbuf *mbuf)
-{
- if (((meta->flags >> NFP_NET_META_MARK) & 0x1) == 0)
- return;
-
- mbuf->hash.fdir.hi = meta->mark_id;
- mbuf->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
-}
-
-/* Parse the metadata from packet */
-static void
-nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
- struct nfp_net_rxq *rxq,
- struct nfp_net_hw *hw,
- struct rte_mbuf *mb,
- struct nfp_meta_parsed *meta)
-{
- uint8_t *meta_base;
- rte_be32_t meta_header;
-
- if (unlikely(NFP_DESC_META_LEN(rxds) == 0))
- return;
-
- meta_base = rte_pktmbuf_mtod_offset(mb, uint8_t *, -NFP_DESC_META_LEN(rxds));
- meta_header = *(rte_be32_t *)meta_base;
-
- switch (hw->meta_format) {
- case NFP_NET_METAFORMAT_CHAINED:
- if (nfp_net_parse_chained_meta(meta_base, meta_header, meta)) {
- nfp_net_parse_meta_hash(meta, rxq, mb);
- nfp_net_parse_meta_vlan(meta, rxds, rxq, mb);
- nfp_net_parse_meta_qinq(meta, rxq, mb);
- nfp_net_parse_meta_ipsec(meta, rxq, mb);
- nfp_net_parse_meta_mark(meta, mb);
- } else {
- PMD_RX_LOG(DEBUG, "RX chained metadata format is wrong!");
- }
- break;
- case NFP_NET_METAFORMAT_SINGLE:
- if ((rxds->rxd.flags & PCIE_DESC_RX_RSS) != 0) {
- nfp_net_parse_single_meta(meta_base, meta_header, meta);
- nfp_net_parse_meta_hash(meta, rxq, mb);
- }
- break;
- default:
- PMD_RX_LOG(DEBUG, "RX metadata do not exist.");
- }
-}
-
/**
* Set packet type to mbuf based on parsed structure.
*
@@ -1038,50 +779,6 @@ nfp_net_reset_tx_queue(struct nfp_net_txq *txq)
txq->rd_p = 0;
}
-void
-nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
- struct rte_mbuf *pkt,
- uint8_t layer)
-{
- uint16_t tpid;
- uint16_t vlan_tci;
-
- tpid = RTE_ETHER_TYPE_VLAN;
- vlan_tci = pkt->vlan_tci;
-
- meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci);
-}
-
-void
-nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
- struct nfp_net_txq *txq,
- struct rte_mbuf *pkt,
- uint8_t layer,
- uint8_t ipsec_layer)
-{
- int offset;
- struct nfp_net_hw *hw;
- struct nfp_tx_ipsec_desc_msg *desc_md;
-
- hw = txq->hw;
- offset = hw->ipsec_data->pkt_dynfield_offset;
- desc_md = RTE_MBUF_DYNFIELD(pkt, offset, struct nfp_tx_ipsec_desc_msg *);
-
- switch (ipsec_layer) {
- case NFP_IPSEC_META_SAIDX:
- meta_data->data[layer] = desc_md->sa_idx;
- break;
- case NFP_IPSEC_META_SEQLOW:
- meta_data->data[layer] = desc_md->esn.low;
- break;
- case NFP_IPSEC_META_SEQHI:
- meta_data->data[layer] = desc_md->esn.hi;
- break;
- default:
- break;
- }
-}
-
int
nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t queue_idx,
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 5695a31636..6ecabc232c 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -8,18 +8,6 @@
#include <ethdev_driver.h>
-#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
-
-/* Maximum number of NFP packet metadata fields. */
-#define NFP_META_MAX_FIELDS 8
-
-/* Describe the raw metadata format. */
-struct nfp_net_meta_raw {
- uint32_t header; /**< Field type header (see format in nfp.rst) */
- uint32_t data[NFP_META_MAX_FIELDS]; /**< Array of each fields data member */
- uint8_t length; /**< Number of valid fields in @header */
-};
-
/* Descriptor alignment */
#define NFP_ALIGN_RING_DESC 128
@@ -238,13 +226,5 @@ int nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
unsigned int socket_id,
const struct rte_eth_txconf *tx_conf);
uint32_t nfp_net_tx_free_bufs(struct nfp_net_txq *txq);
-void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
- struct rte_mbuf *pkt,
- uint8_t layer);
-void nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
- struct nfp_net_txq *txq,
- struct rte_mbuf *pkt,
- uint8_t layer,
- uint8_t ipsec_layer);
#endif /* __NFP_RXTX_H__ */
--
2.39.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] net/nfp: uniform variable name format
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
2024-03-05 2:29 ` [PATCH 1/5] net/nfp: create " Chaoyong He
@ 2024-03-05 2:29 ` Chaoyong He
2024-03-05 2:29 ` [PATCH 3/5] net/nfp: uniform function " Chaoyong He
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Chaoyong He @ 2024-03-05 2:29 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Uniform variable name format by add the same prefix.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower_cmsg.c | 2 +-
drivers/net/nfp/flower/nfp_flower_ctrl.c | 2 +-
drivers/net/nfp/nfp_net_meta.c | 32 ++++++++++----------
drivers/net/nfp/nfp_net_meta.h | 38 ++++++++++++------------
drivers/net/nfp/nfp_rxtx.c | 2 +-
5 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index f78bfba332..eefeb0d887 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -31,7 +31,7 @@ nfp_flower_cmsg_init(struct nfp_app_fw_flower *app_fw_flower,
pkt = rte_pktmbuf_mtod(m, char *);
PMD_DRV_LOG(DEBUG, "flower_cmsg_init using pkt at %p", pkt);
- new_size += nfp_flower_pkt_add_metadata(app_fw_flower, m, NFP_META_PORT_ID_CTRL);
+ new_size += nfp_flower_pkt_add_metadata(app_fw_flower, m, NFP_NET_META_PORT_ID_CTRL);
/* Now the ctrl header */
hdr = (struct nfp_flower_cmsg_hdr *)pkt;
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 720a0d9495..4c2aeb9849 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -475,7 +475,7 @@ nfp_flower_cmsg_rx(struct nfp_app_fw_flower *app_fw_flower,
meta_type = rte_be_to_cpu_32(*(uint32_t *)(meta - 8));
meta_info = rte_be_to_cpu_32(*(uint32_t *)(meta - 4));
if (meta_type != NFP_NET_META_PORTID ||
- meta_info != NFP_META_PORT_ID_CTRL) {
+ meta_info != NFP_NET_META_PORT_ID_CTRL) {
PMD_DRV_LOG(ERR, "Incorrect metadata for ctrl packet!");
rte_pktmbuf_free(pkts_burst[i]);
continue;
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index 0bc22b2f88..0fd5ba17a0 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -9,17 +9,17 @@
#include "nfp_ipsec.h"
#include "nfp_logs.h"
-enum nfp_ipsec_meta_layer {
- NFP_IPSEC_META_SAIDX, /**< Order of SA index in metadata */
- NFP_IPSEC_META_SEQLOW, /**< Order of Sequence Number (low 32bits) in metadata */
- NFP_IPSEC_META_SEQHI, /**< Order of Sequence Number (high 32bits) in metadata */
+enum nfp_net_meta_ipsec_layer {
+ NFP_NET_META_IPSEC_SAIDX, /**< Order of SA index in metadata */
+ NFP_NET_META_IPSEC_SEQLOW, /**< Order of Sequence Number (low 32bits) in metadata */
+ NFP_NET_META_IPSEC_SEQHI, /**< Order of Sequence Number (high 32bits) in metadata */
};
/* Parse the chained metadata from packet */
static bool
nfp_net_parse_chained_meta(uint8_t *meta_base,
rte_be32_t meta_header,
- struct nfp_meta_parsed *meta)
+ struct nfp_net_meta_parsed *meta)
{
uint32_t meta_info;
uint32_t vlan_info;
@@ -75,7 +75,7 @@ nfp_net_parse_chained_meta(uint8_t *meta_base,
static inline void
nfp_net_parse_single_meta(uint8_t *meta_base,
rte_be32_t meta_header,
- struct nfp_meta_parsed *meta)
+ struct nfp_net_meta_parsed *meta)
{
meta->hash_type = rte_be_to_cpu_32(meta_header);
meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4));
@@ -83,7 +83,7 @@ nfp_net_parse_single_meta(uint8_t *meta_base,
/* Set mbuf hash data based on the metadata info */
static void
-nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
+nfp_net_parse_meta_hash(const struct nfp_net_meta_parsed *meta,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mbuf)
{
@@ -98,7 +98,7 @@ nfp_net_parse_meta_hash(const struct nfp_meta_parsed *meta,
/* Set mbuf vlan_strip data based on metadata info */
static void
-nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
+nfp_net_parse_meta_vlan(const struct nfp_net_meta_parsed *meta,
struct nfp_net_rx_desc *rxd,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mb)
@@ -146,7 +146,7 @@ nfp_net_parse_meta_vlan(const struct nfp_meta_parsed *meta,
* qinq not set & vlan not set: meta->vlan_layer=0
*/
static void
-nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
+nfp_net_parse_meta_qinq(const struct nfp_net_meta_parsed *meta,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mb)
{
@@ -156,7 +156,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
return;
- if (meta->vlan_layer < NFP_META_MAX_VLANS)
+ if (meta->vlan_layer < NFP_NET_META_MAX_VLANS)
return;
if (meta->vlan[0].offload == 0)
@@ -175,7 +175,7 @@ nfp_net_parse_meta_qinq(const struct nfp_meta_parsed *meta,
* Extract and decode metadata info and set the mbuf ol_flags.
*/
static void
-nfp_net_parse_meta_ipsec(struct nfp_meta_parsed *meta,
+nfp_net_parse_meta_ipsec(struct nfp_net_meta_parsed *meta,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mbuf)
{
@@ -202,7 +202,7 @@ nfp_net_parse_meta_ipsec(struct nfp_meta_parsed *meta,
}
static void
-nfp_net_parse_meta_mark(const struct nfp_meta_parsed *meta,
+nfp_net_parse_meta_mark(const struct nfp_net_meta_parsed *meta,
struct rte_mbuf *mbuf)
{
if (((meta->flags >> NFP_NET_META_MARK) & 0x1) == 0)
@@ -218,7 +218,7 @@ nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
struct nfp_net_rxq *rxq,
struct nfp_net_hw *hw,
struct rte_mbuf *mb,
- struct nfp_meta_parsed *meta)
+ struct nfp_net_meta_parsed *meta)
{
uint8_t *meta_base;
rte_be32_t meta_header;
@@ -305,13 +305,13 @@ nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
desc_md = RTE_MBUF_DYNFIELD(pkt, offset, struct nfp_tx_ipsec_desc_msg *);
switch (ipsec_layer) {
- case NFP_IPSEC_META_SAIDX:
+ case NFP_NET_META_IPSEC_SAIDX:
meta_data->data[layer] = desc_md->sa_idx;
break;
- case NFP_IPSEC_META_SEQLOW:
+ case NFP_NET_META_IPSEC_SEQLOW:
meta_data->data[layer] = desc_md->esn.low;
break;
- case NFP_IPSEC_META_SEQHI:
+ case NFP_NET_META_IPSEC_SEQHI:
meta_data->data[layer] = desc_md->esn.hi;
break;
default:
diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h
index da2091ce9f..46caa777da 100644
--- a/drivers/net/nfp/nfp_net_meta.h
+++ b/drivers/net/nfp/nfp_net_meta.h
@@ -9,18 +9,18 @@
#include "nfp_rxtx.h"
/* Hash type prepended when a RSS hash was computed */
-#define NFP_NET_RSS_NONE 0
-#define NFP_NET_RSS_IPV4 1
-#define NFP_NET_RSS_IPV6 2
-#define NFP_NET_RSS_IPV6_EX 3
-#define NFP_NET_RSS_IPV4_TCP 4
-#define NFP_NET_RSS_IPV6_TCP 5
-#define NFP_NET_RSS_IPV6_EX_TCP 6
-#define NFP_NET_RSS_IPV4_UDP 7
-#define NFP_NET_RSS_IPV6_UDP 8
-#define NFP_NET_RSS_IPV6_EX_UDP 9
-#define NFP_NET_RSS_IPV4_SCTP 10
-#define NFP_NET_RSS_IPV6_SCTP 11
+#define NFP_NET_META_RSS_NONE 0
+#define NFP_NET_META_RSS_IPV4 1
+#define NFP_NET_META_RSS_IPV6 2
+#define NFP_NET_META_RSS_IPV6_EX 3
+#define NFP_NET_META_RSS_IPV4_TCP 4
+#define NFP_NET_META_RSS_IPV6_TCP 5
+#define NFP_NET_META_RSS_IPV6_EX_TCP 6
+#define NFP_NET_META_RSS_IPV4_UDP 7
+#define NFP_NET_META_RSS_IPV6_UDP 8
+#define NFP_NET_META_RSS_IPV6_EX_UDP 9
+#define NFP_NET_META_RSS_IPV4_SCTP 10
+#define NFP_NET_META_RSS_IPV6_SCTP 11
/* Offset in Freelist buffer where packet starts on RX */
#define NFP_NET_RX_OFFSET 32
@@ -47,15 +47,15 @@
#define NFP_NET_META_PORTID 5
#define NFP_NET_META_IPSEC 9
-#define NFP_META_PORT_ID_CTRL ~0U
+#define NFP_NET_META_PORT_ID_CTRL ~0U
#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
/* Maximum number of NFP packet metadata fields. */
-#define NFP_META_MAX_FIELDS 8
+#define NFP_NET_META_MAX_FIELDS 8
/* Maximum number of supported VLANs in parsed form packet metadata. */
-#define NFP_META_MAX_VLANS 2
+#define NFP_NET_META_MAX_VLANS 2
enum nfp_net_meta_format {
NFP_NET_METAFORMAT_SINGLE,
@@ -65,12 +65,12 @@ enum nfp_net_meta_format {
/* Describe the raw metadata format. */
struct nfp_net_meta_raw {
uint32_t header; /**< Field type header (see format in nfp.rst) */
- uint32_t data[NFP_META_MAX_FIELDS]; /**< Array of each fields data member */
+ uint32_t data[NFP_NET_META_MAX_FIELDS]; /**< Array of each fields data member */
uint8_t length; /**< Number of valid fields in @header */
};
/* Record metadata parsed from packet */
-struct nfp_meta_parsed {
+struct nfp_net_meta_parsed {
uint32_t port_id; /**< Port id value */
uint32_t sa_idx; /**< IPsec SA index */
uint32_t hash; /**< RSS hash value */
@@ -87,7 +87,7 @@ struct nfp_meta_parsed {
uint8_t offload; /**< Flag indicates whether VLAN is offloaded */
uint8_t tpid; /**< Vlan TPID */
uint16_t tci; /**< Vlan TCI (PCP + Priority + VID) */
- } vlan[NFP_META_MAX_VLANS];
+ } vlan[NFP_NET_META_MAX_VLANS];
};
void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
@@ -95,7 +95,7 @@ void nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
struct nfp_net_rxq *rxq,
struct nfp_net_hw *hw,
struct rte_mbuf *mb,
- struct nfp_meta_parsed *meta);
+ struct nfp_net_meta_parsed *meta);
void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
struct rte_mbuf *pkt,
uint8_t layer);
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 0256eba456..e863c42039 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -497,7 +497,7 @@ nfp_net_recv_pkts(void *rx_queue,
mb->next = NULL;
mb->port = rxq->port_id;
- struct nfp_meta_parsed meta = {};
+ struct nfp_net_meta_parsed meta = {};
nfp_net_parse_meta(rxds, rxq, hw, mb, &meta);
nfp_net_parse_ptype(rxq, rxds, mb);
--
2.39.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] net/nfp: uniform function name format
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
2024-03-05 2:29 ` [PATCH 1/5] net/nfp: create " Chaoyong He
2024-03-05 2:29 ` [PATCH 2/5] net/nfp: uniform variable name format Chaoyong He
@ 2024-03-05 2:29 ` Chaoyong He
2024-03-05 2:29 ` [PATCH 4/5] net/nfp: use flag bits to control parsing meta data Chaoyong He
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Chaoyong He @ 2024-03-05 2:29 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Uniform function name format and add the same prefix.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 5 ++--
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 5 ++--
drivers/net/nfp/nfp_net_common.c | 2 +-
drivers/net/nfp/nfp_net_meta.c | 38 +++++++++++++++---------------
drivers/net/nfp/nfp_net_meta.h | 8 +++----
drivers/net/nfp/nfp_rxtx.c | 2 +-
6 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 5fb76ae9d7..7e281ae498 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -194,8 +194,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
PMD_DRV_LOG(ERR, "At most 1 layers of vlan is supported");
return -EINVAL;
}
-
- nfp_net_set_meta_vlan(meta_data, pkt, layer);
+ nfp_net_meta_set_vlan(meta_data, pkt, layer);
vlan_layer++;
break;
case NFP_NET_META_IPSEC:
@@ -204,7 +203,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
return -EINVAL;
}
- nfp_net_set_meta_ipsec(meta_data, txq, pkt, layer, ipsec_layer);
+ nfp_net_meta_set_ipsec(meta_data, txq, pkt, layer, ipsec_layer);
ipsec_layer++;
break;
default:
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 8bdab5d463..b8592b1767 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -228,8 +228,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
PMD_DRV_LOG(ERR, "At most 1 layers of vlan is supported");
return -EINVAL;
}
-
- nfp_net_set_meta_vlan(&meta_data, pkt, layer);
+ nfp_net_meta_set_vlan(&meta_data, pkt, layer);
vlan_layer++;
break;
case NFP_NET_META_IPSEC:
@@ -238,7 +237,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
return -EINVAL;
}
- nfp_net_set_meta_ipsec(&meta_data, txq, pkt, layer, ipsec_layer);
+ nfp_net_meta_set_ipsec(&meta_data, txq, pkt, layer, ipsec_layer);
ipsec_layer++;
break;
default:
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 384e042dfd..71038d6be9 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1312,7 +1312,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
hw->max_mtu = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_MTU);
hw->flbufsz = DEFAULT_FLBUF_SIZE;
- nfp_net_init_metadata_format(hw);
+ nfp_net_meta_init_format(hw);
/* Read the Rx offset configured from firmware */
if (hw->ver.major < 2)
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index 0fd5ba17a0..2ec20aba7d 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -17,7 +17,7 @@ enum nfp_net_meta_ipsec_layer {
/* Parse the chained metadata from packet */
static bool
-nfp_net_parse_chained_meta(uint8_t *meta_base,
+nfp_net_meta_parse_chained(uint8_t *meta_base,
rte_be32_t meta_header,
struct nfp_net_meta_parsed *meta)
{
@@ -73,7 +73,7 @@ nfp_net_parse_chained_meta(uint8_t *meta_base,
* Get it from metadata area.
*/
static inline void
-nfp_net_parse_single_meta(uint8_t *meta_base,
+nfp_net_meta_parse_single(uint8_t *meta_base,
rte_be32_t meta_header,
struct nfp_net_meta_parsed *meta)
{
@@ -83,7 +83,7 @@ nfp_net_parse_single_meta(uint8_t *meta_base,
/* Set mbuf hash data based on the metadata info */
static void
-nfp_net_parse_meta_hash(const struct nfp_net_meta_parsed *meta,
+nfp_net_meta_parse_hash(const struct nfp_net_meta_parsed *meta,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mbuf)
{
@@ -98,7 +98,7 @@ nfp_net_parse_meta_hash(const struct nfp_net_meta_parsed *meta,
/* Set mbuf vlan_strip data based on metadata info */
static void
-nfp_net_parse_meta_vlan(const struct nfp_net_meta_parsed *meta,
+nfp_net_meta_parse_vlan(const struct nfp_net_meta_parsed *meta,
struct nfp_net_rx_desc *rxd,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mb)
@@ -146,7 +146,7 @@ nfp_net_parse_meta_vlan(const struct nfp_net_meta_parsed *meta,
* qinq not set & vlan not set: meta->vlan_layer=0
*/
static void
-nfp_net_parse_meta_qinq(const struct nfp_net_meta_parsed *meta,
+nfp_net_meta_parse_qinq(const struct nfp_net_meta_parsed *meta,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mb)
{
@@ -175,7 +175,7 @@ nfp_net_parse_meta_qinq(const struct nfp_net_meta_parsed *meta,
* Extract and decode metadata info and set the mbuf ol_flags.
*/
static void
-nfp_net_parse_meta_ipsec(struct nfp_net_meta_parsed *meta,
+nfp_net_meta_parse_ipsec(struct nfp_net_meta_parsed *meta,
struct nfp_net_rxq *rxq,
struct rte_mbuf *mbuf)
{
@@ -202,7 +202,7 @@ nfp_net_parse_meta_ipsec(struct nfp_net_meta_parsed *meta,
}
static void
-nfp_net_parse_meta_mark(const struct nfp_net_meta_parsed *meta,
+nfp_net_meta_parse_mark(const struct nfp_net_meta_parsed *meta,
struct rte_mbuf *mbuf)
{
if (((meta->flags >> NFP_NET_META_MARK) & 0x1) == 0)
@@ -214,7 +214,7 @@ nfp_net_parse_meta_mark(const struct nfp_net_meta_parsed *meta,
/* Parse the metadata from packet */
void
-nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
+nfp_net_meta_parse(struct nfp_net_rx_desc *rxds,
struct nfp_net_rxq *rxq,
struct nfp_net_hw *hw,
struct rte_mbuf *mb,
@@ -231,20 +231,20 @@ nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
switch (hw->meta_format) {
case NFP_NET_METAFORMAT_CHAINED:
- if (nfp_net_parse_chained_meta(meta_base, meta_header, meta)) {
- nfp_net_parse_meta_hash(meta, rxq, mb);
- nfp_net_parse_meta_vlan(meta, rxds, rxq, mb);
- nfp_net_parse_meta_qinq(meta, rxq, mb);
- nfp_net_parse_meta_ipsec(meta, rxq, mb);
- nfp_net_parse_meta_mark(meta, mb);
+ if (nfp_net_meta_parse_chained(meta_base, meta_header, meta)) {
+ nfp_net_meta_parse_hash(meta, rxq, mb);
+ nfp_net_meta_parse_vlan(meta, rxds, rxq, mb);
+ nfp_net_meta_parse_qinq(meta, rxq, mb);
+ nfp_net_meta_parse_ipsec(meta, rxq, mb);
+ nfp_net_meta_parse_mark(meta, mb);
} else {
PMD_RX_LOG(DEBUG, "RX chained metadata format is wrong!");
}
break;
case NFP_NET_METAFORMAT_SINGLE:
if ((rxds->rxd.flags & PCIE_DESC_RX_RSS) != 0) {
- nfp_net_parse_single_meta(meta_base, meta_header, meta);
- nfp_net_parse_meta_hash(meta, rxq, mb);
+ nfp_net_meta_parse_single(meta_base, meta_header, meta);
+ nfp_net_meta_parse_hash(meta, rxq, mb);
}
break;
default:
@@ -253,7 +253,7 @@ nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
}
void
-nfp_net_init_metadata_format(struct nfp_net_hw *hw)
+nfp_net_meta_init_format(struct nfp_net_hw *hw)
{
/*
* ABI 4.x and ctrl vNIC always use chained metadata, in other cases we allow use of
@@ -276,7 +276,7 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
}
void
-nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
+nfp_net_meta_set_vlan(struct nfp_net_meta_raw *meta_data,
struct rte_mbuf *pkt,
uint8_t layer)
{
@@ -290,7 +290,7 @@ nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
}
void
-nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
+nfp_net_meta_set_ipsec(struct nfp_net_meta_raw *meta_data,
struct nfp_net_txq *txq,
struct rte_mbuf *pkt,
uint8_t layer,
diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h
index 46caa777da..1d26b089d5 100644
--- a/drivers/net/nfp/nfp_net_meta.h
+++ b/drivers/net/nfp/nfp_net_meta.h
@@ -90,16 +90,16 @@ struct nfp_net_meta_parsed {
} vlan[NFP_NET_META_MAX_VLANS];
};
-void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
-void nfp_net_parse_meta(struct nfp_net_rx_desc *rxds,
+void nfp_net_meta_init_format(struct nfp_net_hw *hw);
+void nfp_net_meta_parse(struct nfp_net_rx_desc *rxds,
struct nfp_net_rxq *rxq,
struct nfp_net_hw *hw,
struct rte_mbuf *mb,
struct nfp_net_meta_parsed *meta);
-void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
+void nfp_net_meta_set_vlan(struct nfp_net_meta_raw *meta_data,
struct rte_mbuf *pkt,
uint8_t layer);
-void nfp_net_set_meta_ipsec(struct nfp_net_meta_raw *meta_data,
+void nfp_net_meta_set_ipsec(struct nfp_net_meta_raw *meta_data,
struct nfp_net_txq *txq,
struct rte_mbuf *pkt,
uint8_t layer,
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index e863c42039..716a6af34f 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -498,7 +498,7 @@ nfp_net_recv_pkts(void *rx_queue,
mb->port = rxq->port_id;
struct nfp_net_meta_parsed meta = {};
- nfp_net_parse_meta(rxds, rxq, hw, mb, &meta);
+ nfp_net_meta_parse(rxds, rxq, hw, mb, &meta);
nfp_net_parse_ptype(rxq, rxds, mb);
--
2.39.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] net/nfp: use flag bits to control parsing meta data
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
` (2 preceding siblings ...)
2024-03-05 2:29 ` [PATCH 3/5] net/nfp: uniform function " Chaoyong He
@ 2024-03-05 2:29 ` Chaoyong He
2024-03-05 2:29 ` [PATCH 5/5] net/nfp: use big-endian meta data for packet Chaoyong He
2024-03-12 12:05 ` [PATCH 0/5] add new meta data module Ferruh Yigit
5 siblings, 0 replies; 7+ messages in thread
From: Chaoyong He @ 2024-03-05 2:29 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Use flag bits to indicate whether meta data exists and determine
whether it needs to be parsed.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfp_net_meta.c | 22 ++++++++++++++++++----
drivers/net/nfp/nfp_net_meta.h | 1 -
drivers/net/nfp/nfp_rxtx.c | 2 +-
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index 2ec20aba7d..b39c55a868 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -27,13 +27,16 @@ nfp_net_meta_parse_chained(uint8_t *meta_base,
meta_info = rte_be_to_cpu_32(meta_header);
meta_offset = meta_base + 4;
+ meta->flags = 0;
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_PORTID:
+ meta->flags |= (1 << NFP_NET_META_PORTID);
meta->port_id = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
break;
case NFP_NET_META_HASH:
+ meta->flags |= (1 << NFP_NET_META_HASH);
/* Next field type is about the hash type */
meta_info >>= NFP_NET_META_FIELD_SIZE;
/* Hash value is in the data field */
@@ -41,6 +44,7 @@ nfp_net_meta_parse_chained(uint8_t *meta_base,
meta->hash_type = meta_info & NFP_NET_META_FIELD_MASK;
break;
case NFP_NET_META_VLAN:
+ meta->flags |= (1 << 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;
@@ -50,8 +54,8 @@ nfp_net_meta_parse_chained(uint8_t *meta_base,
meta->vlan_layer++;
break;
case NFP_NET_META_IPSEC:
+ meta->flags |= (1 << NFP_NET_META_IPSEC);
meta->sa_idx = rte_be_to_cpu_32(*(rte_be32_t *)meta_offset);
- meta->ipsec_type = meta_info & NFP_NET_META_FIELD_MASK;
break;
case NFP_NET_META_MARK:
meta->flags |= (1 << NFP_NET_META_MARK);
@@ -77,6 +81,7 @@ nfp_net_meta_parse_single(uint8_t *meta_base,
rte_be32_t meta_header,
struct nfp_net_meta_parsed *meta)
{
+ meta->flags |= (1 << NFP_NET_META_HASH);
meta->hash_type = rte_be_to_cpu_32(meta_header);
meta->hash = rte_be_to_cpu_32(*(rte_be32_t *)(meta_base + 4));
}
@@ -92,6 +97,9 @@ nfp_net_meta_parse_hash(const struct nfp_net_meta_parsed *meta,
if ((hw->super.ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0)
return;
+ if (((meta->flags >> NFP_NET_META_HASH) & 0x1) == 0)
+ return;
+
mbuf->hash.rss = meta->hash;
mbuf->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
}
@@ -109,6 +117,9 @@ nfp_net_meta_parse_vlan(const struct nfp_net_meta_parsed *meta,
if ((ctrl & (NFP_NET_CFG_CTRL_RXVLAN | NFP_NET_CFG_CTRL_RXVLAN_V2)) == 0)
return;
+ if (((meta->flags >> NFP_NET_META_VLAN) & 0x1) == 0)
+ return;
+
/*
* The firmware support two ways to send the VLAN info (with priority) :
* 1. Using the metadata when NFP_NET_CFG_CTRL_RXVLAN_V2 is set,
@@ -156,6 +167,9 @@ nfp_net_meta_parse_qinq(const struct nfp_net_meta_parsed *meta,
(hw->cap & NFP_NET_CFG_CTRL_RXQINQ) == 0)
return;
+ if (((meta->flags >> NFP_NET_META_VLAN) & 0x1) == 0)
+ return;
+
if (meta->vlan_layer < NFP_NET_META_MAX_VLANS)
return;
@@ -184,12 +198,12 @@ nfp_net_meta_parse_ipsec(struct nfp_net_meta_parsed *meta,
struct nfp_net_hw *hw;
struct nfp_tx_ipsec_desc_msg *desc_md;
+ if (((meta->flags >> NFP_NET_META_IPSEC) & 0x1) == 0)
+ return;
+
hw = rxq->hw;
sa_idx = meta->sa_idx;
- if (meta->ipsec_type != NFP_NET_META_IPSEC)
- return;
-
if (sa_idx >= NFP_NET_IPSEC_MAX_SA_CNT) {
mbuf->ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
} else {
diff --git a/drivers/net/nfp/nfp_net_meta.h b/drivers/net/nfp/nfp_net_meta.h
index 1d26b089d5..69d08cf3a7 100644
--- a/drivers/net/nfp/nfp_net_meta.h
+++ b/drivers/net/nfp/nfp_net_meta.h
@@ -77,7 +77,6 @@ struct nfp_net_meta_parsed {
uint32_t mark_id; /**< Mark id value */
uint16_t flags; /**< Bitmap to indicate if meta exist */
uint8_t hash_type; /**< RSS hash type */
- uint8_t ipsec_type; /**< IPsec type */
uint8_t vlan_layer; /**< The valid number of value in @vlan[] */
/**
* Holds information parses from NFP_NET_META_VLAN.
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 716a6af34f..65ae19212d 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -497,7 +497,7 @@ nfp_net_recv_pkts(void *rx_queue,
mb->next = NULL;
mb->port = rxq->port_id;
- struct nfp_net_meta_parsed meta = {};
+ struct nfp_net_meta_parsed meta;
nfp_net_meta_parse(rxds, rxq, hw, mb, &meta);
nfp_net_parse_ptype(rxq, rxds, mb);
--
2.39.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] net/nfp: use big-endian meta data for packet
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
` (3 preceding siblings ...)
2024-03-05 2:29 ` [PATCH 4/5] net/nfp: use flag bits to control parsing meta data Chaoyong He
@ 2024-03-05 2:29 ` Chaoyong He
2024-03-12 12:05 ` [PATCH 0/5] add new meta data module Ferruh Yigit
5 siblings, 0 replies; 7+ messages in thread
From: Chaoyong He @ 2024-03-05 2:29 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He
From: Long Wu <long.wu@corigine.com>
Make sure all kinds of meta data are CPU-endian in process logic and
transform them to big-endian when prepend into packet.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 5 ++---
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 5 ++---
drivers/net/nfp/nfp_net_meta.c | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 7e281ae498..253872f4a1 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -181,9 +181,8 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
return 0;
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));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data->header);
meta += NFP_NET_META_HEADER_SIZE;
for (; meta_info != 0; meta_info >>= NFP_NET_META_FIELD_SIZE, layer++,
@@ -211,7 +210,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
return -ENOTSUP;
}
- memcpy(meta, &meta_data->data[layer], sizeof(meta_data->data[layer]));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data->data[layer]);
}
return 0;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index b8592b1767..1911736e2b 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -215,9 +215,8 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
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));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data.header);
meta += NFP_NET_META_HEADER_SIZE;
for (; meta_type != 0; meta_type >>= NFP_NET_META_FIELD_SIZE, layer++,
@@ -245,7 +244,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
return -ENOTSUP;
}
- memcpy(meta, &meta_data.data[layer], sizeof(meta_data.data[layer]));
+ *(rte_be32_t *)meta = rte_cpu_to_be_32(meta_data.data[layer]);
}
*metadata = NFDK_DESC_TX_CHAIN_META;
diff --git a/drivers/net/nfp/nfp_net_meta.c b/drivers/net/nfp/nfp_net_meta.c
index b39c55a868..fa7e0d3d00 100644
--- a/drivers/net/nfp/nfp_net_meta.c
+++ b/drivers/net/nfp/nfp_net_meta.c
@@ -300,7 +300,7 @@ nfp_net_meta_set_vlan(struct nfp_net_meta_raw *meta_data,
tpid = RTE_ETHER_TYPE_VLAN;
vlan_tci = pkt->vlan_tci;
- meta_data->data[layer] = rte_cpu_to_be_32(tpid << 16 | vlan_tci);
+ meta_data->data[layer] = tpid << 16 | vlan_tci;
}
void
--
2.39.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] add new meta data module
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
` (4 preceding siblings ...)
2024-03-05 2:29 ` [PATCH 5/5] net/nfp: use big-endian meta data for packet Chaoyong He
@ 2024-03-12 12:05 ` Ferruh Yigit
5 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2024-03-12 12:05 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers
On 3/5/2024 2:29 AM, Chaoyong He wrote:
> Extract the related code into a new meta data module, uniform
> the name format and data endian.
> Which makes the logic more clear and easier to extend in the future.
>
> Long Wu (5):
> net/nfp: create new meta data module
> net/nfp: uniform variable name format
> net/nfp: uniform function name format
> net/nfp: use flag bits to control parsing meta data
> net/nfp: use big-endian meta data for packet
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-12 12:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 2:29 [PATCH 0/5] add new meta data module Chaoyong He
2024-03-05 2:29 ` [PATCH 1/5] net/nfp: create " Chaoyong He
2024-03-05 2:29 ` [PATCH 2/5] net/nfp: uniform variable name format Chaoyong He
2024-03-05 2:29 ` [PATCH 3/5] net/nfp: uniform function " Chaoyong He
2024-03-05 2:29 ` [PATCH 4/5] net/nfp: use flag bits to control parsing meta data Chaoyong He
2024-03-05 2:29 ` [PATCH 5/5] net/nfp: use big-endian meta data for packet Chaoyong He
2024-03-12 12:05 ` [PATCH 0/5] add new meta data module 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).