From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
Peng Zhang <peng.zhang@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 5/8] net/nfp: add support for VLAN strip V2
Date: Mon, 28 Nov 2022 14:53:56 +0800 [thread overview]
Message-ID: <20221128065359.12737-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20221128065359.12737-1-chaoyong.he@corigine.com>
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
next prev parent reply other threads:[~2022-11-28 6:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Chaoyong He [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221128065359.12737-6-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).