From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v3] net/nfp: add the feature of RSS based on VXLAN inner layer
Date: Sat, 15 Oct 2022 15:22:52 +0800 [thread overview]
Message-ID: <1665818572-38639-1-git-send-email-chaoyong.he@corigine.com> (raw)
In-Reply-To: <1665738548-20974-1-git-send-email-chaoyong.he@corigine.com>
Add the logics to support the feature of RSS packets based on
the inner layer of VXLAN tunnel.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
* Changes since v2
- Still include 'nfp_ctrl.h' in source files that use symbols from it.
* Changes since v1
- Don't expose the dependency relation of header files to source files.
Depends-on: series-24819 ("preparation for the rte_flow offload of nfp PMD")
---
drivers/net/nfp/nfp_common.c | 32 +++++++++++++
drivers/net/nfp/nfp_common.h | 6 +++
drivers/net/nfp/nfp_ethdev.c | 110 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 148 insertions(+)
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 07781a1..9be2e21 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -1370,6 +1370,38 @@
}
}
+int
+nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
+ size_t idx,
+ uint16_t port)
+{
+ int ret;
+ uint32_t i;
+
+ if (idx > NFP_NET_N_VXLAN_PORTS) {
+ PMD_DRV_LOG(ERR, "The idx value is out of range.");
+ return -ERANGE;
+ }
+
+ hw->vxlan_ports[idx] = port;
+
+ for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i += 2) {
+ nn_cfg_writel(hw, NFP_NET_CFG_VXLAN_PORT + i * sizeof(port),
+ (hw->vxlan_ports[i + 1] << 16) | hw->vxlan_ports[i]);
+ }
+
+ rte_spinlock_lock(&hw->reconfig_lock);
+
+ nn_cfg_writel(hw, NFP_NET_CFG_UPDATE, NFP_NET_CFG_UPDATE_VXLAN);
+ rte_wmb();
+
+ ret = __nfp_net_reconfig(hw, NFP_NET_CFG_UPDATE_VXLAN);
+
+ rte_spinlock_unlock(&hw->reconfig_lock);
+
+ return ret;
+}
+
RTE_LOG_REGISTER_SUFFIX(nfp_logtype_init, init, NOTICE);
RTE_LOG_REGISTER_SUFFIX(nfp_logtype_driver, driver, NOTICE);
RTE_LOG_REGISTER_SUFFIX(nfp_logtype_cpp, cpp, NOTICE);
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 27ea9c2..d7861a2 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -14,6 +14,8 @@
#ifndef _NFP_COMMON_H_
#define _NFP_COMMON_H_
+#include "nfp_ctrl.h"
+
#define NFP_NET_PMD_VERSION "0.1"
#define PCI_VENDOR_ID_NETRONOME 0x19ee
#define PCI_VENDOR_ID_CORIGINE 0x1da8
@@ -209,6 +211,9 @@ struct nfp_net_hw {
int stride_rx;
int stride_tx;
+ uint16_t vxlan_ports[NFP_NET_N_VXLAN_PORTS];
+ uint8_t vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
+
uint8_t *qcp_cfg;
rte_spinlock_t reconfig_lock;
@@ -438,6 +443,7 @@ int nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev,
void nfp_net_close_rx_queue(struct rte_eth_dev *dev);
void nfp_net_stop_tx_queue(struct rte_eth_dev *dev);
void nfp_net_close_tx_queue(struct rte_eth_dev *dev);
+int nfp_net_set_vxlan_port(struct nfp_net_hw *hw, size_t idx, uint16_t port);
#define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\
(&((struct nfp_net_adapter *)adapter)->hw)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index e131021..f11a1b6 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -138,6 +138,10 @@
update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
+ /* Enable vxlan */
+ new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
+ update |= NFP_NET_CFG_UPDATE_VXLAN;
+
if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
@@ -319,6 +323,110 @@
return 0;
}
+static int
+nfp_net_find_vxlan_idx(struct nfp_net_hw *hw,
+ uint16_t port,
+ uint32_t *idx)
+{
+ uint32_t i;
+ int free_idx = -1;
+
+ for (i = 0; i < NFP_NET_N_VXLAN_PORTS; i++) {
+ if (hw->vxlan_ports[i] == port) {
+ free_idx = i;
+ break;
+ }
+
+ if (hw->vxlan_usecnt[i] == 0) {
+ free_idx = i;
+ break;
+ }
+ }
+
+ if (free_idx == -1)
+ return -EINVAL;
+
+ *idx = free_idx;
+
+ return 0;
+}
+
+static int
+nfp_udp_tunnel_port_add(struct rte_eth_dev *dev,
+ struct rte_eth_udp_tunnel *tunnel_udp)
+{
+ int ret;
+ uint32_t idx;
+ uint16_t vxlan_port;
+ struct nfp_net_hw *hw;
+ enum rte_eth_tunnel_type tnl_type;
+
+ hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ vxlan_port = tunnel_udp->udp_port;
+ tnl_type = tunnel_udp->prot_type;
+
+ if (tnl_type != RTE_ETH_TUNNEL_TYPE_VXLAN) {
+ PMD_DRV_LOG(ERR, "Not VXLAN tunnel");
+ return -ENOTSUP;
+ }
+
+ ret = nfp_net_find_vxlan_idx(hw, vxlan_port, &idx);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed find valid vxlan idx");
+ return -EINVAL;
+ }
+
+ if (hw->vxlan_usecnt[idx] == 0) {
+ ret = nfp_net_set_vxlan_port(hw, idx, vxlan_port);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed set vxlan port");
+ return -EINVAL;
+ }
+ }
+
+ hw->vxlan_usecnt[idx]++;
+
+ return 0;
+}
+
+static int
+nfp_udp_tunnel_port_del(struct rte_eth_dev *dev,
+ struct rte_eth_udp_tunnel *tunnel_udp)
+{
+ int ret;
+ uint32_t idx;
+ uint16_t vxlan_port;
+ struct nfp_net_hw *hw;
+ enum rte_eth_tunnel_type tnl_type;
+
+ hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ vxlan_port = tunnel_udp->udp_port;
+ tnl_type = tunnel_udp->prot_type;
+
+ if (tnl_type != RTE_ETH_TUNNEL_TYPE_VXLAN) {
+ PMD_DRV_LOG(ERR, "Not VXLAN tunnel");
+ return -ENOTSUP;
+ }
+
+ ret = nfp_net_find_vxlan_idx(hw, vxlan_port, &idx);
+ if (ret != 0 || hw->vxlan_usecnt[idx] == 0) {
+ PMD_DRV_LOG(ERR, "Failed find valid vxlan idx");
+ return -EINVAL;
+ }
+
+ hw->vxlan_usecnt[idx]--;
+
+ if (hw->vxlan_usecnt[idx] == 0) {
+ ret = nfp_net_set_vxlan_port(hw, idx, 0);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed set vxlan port");
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
/* Initialise and register driver with DPDK Application */
static const struct eth_dev_ops nfp_net_eth_dev_ops = {
.dev_configure = nfp_net_configure,
@@ -347,6 +455,8 @@
.tx_queue_release = nfp_net_tx_queue_release,
.rx_queue_intr_enable = nfp_rx_queue_intr_enable,
.rx_queue_intr_disable = nfp_rx_queue_intr_disable,
+ .udp_tunnel_port_add = nfp_udp_tunnel_port_add,
+ .udp_tunnel_port_del = nfp_udp_tunnel_port_del,
};
static inline int
--
1.8.3.1
next prev parent reply other threads:[~2022-10-15 7:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 9:09 [PATCH v2] " Chaoyong He
2022-10-14 9:40 ` Ferruh Yigit
2022-10-14 9:41 ` Ferruh Yigit
2022-10-15 7:22 ` Chaoyong He [this message]
2022-10-17 12:12 ` [PATCH v3] " 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=1665818572-38639-1-git-send-email-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@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).