[3/4] net/nfp: representor adds RSS configuration

Message ID 20240210104214.1248772-4-chaoyong.he@corigine.com (mailing list archive)
State Under Review
Delegated to: Ferruh Yigit
Headers
Series add support of partial offload |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Feb. 10, 2024, 10:42 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

Add RSS configuration in representor initializaion.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/common/nfp/nfp_common_ctrl.h            |  1 +
 drivers/net/nfp/flower/nfp_flower.c             | 12 ++++++++++--
 drivers/net/nfp/flower/nfp_flower_representor.c | 13 +++++++++++++
 drivers/net/nfp/nfp_net_common.c                | 17 ++++++-----------
 drivers/net/nfp/nfp_net_common.h                |  9 +++++++++
 5 files changed, 39 insertions(+), 13 deletions(-)
  

Patch

diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index d65fcd17cb..d0a3fc696c 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -253,6 +253,7 @@  struct nfp_net_fw_ver {
 #define   NFP_NET_CFG_RSS_IPV4_SCTP       (1 << 14) /* RSS for IPv4/SCTP */
 #define   NFP_NET_CFG_RSS_IPV6_SCTP       (1 << 15) /* RSS for IPv6/SCTP */
 #define   NFP_NET_CFG_RSS_TOEPLITZ        (1 << 24) /* Use Toeplitz hash */
+#define   NFP_NET_CFG_RSS_CRC32           (1 << 26) /* Use CRC32 hash */
 #define NFP_NET_CFG_RSS_KEY             (NFP_NET_CFG_RSS_BASE + 0x4)
 #define NFP_NET_CFG_RSS_KEY_SZ          0x28
 #define NFP_NET_CFG_RSS_ITBL            (NFP_NET_CFG_RSS_BASE + 0x4 + \
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index e84e6ebbff..c6a744e868 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -31,6 +31,8 @@  nfp_flower_pf_start(struct rte_eth_dev *dev)
 	uint32_t new_ctrl;
 	uint32_t update = 0;
 	struct nfp_net_hw *net_hw;
+	struct rte_eth_conf *dev_conf;
+	struct rte_eth_rxmode *rxmode;
 	struct nfp_flower_representor *repr;
 
 	repr = dev->data->dev_private;
@@ -48,8 +50,14 @@  nfp_flower_pf_start(struct rte_eth_dev *dev)
 	/* Writing configuration parameters in the device */
 	nfp_net_params_setup(net_hw);
 
-	update |= NFP_NET_CFG_UPDATE_RSS;
-	new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	dev_conf = &dev->data->dev_conf;
+	rxmode = &dev_conf->rxmode;
+
+	if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) != 0) {
+		nfp_net_rss_config_default(dev);
+		update |= NFP_NET_CFG_UPDATE_RSS;
+		new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap);
+	}
 
 	/* Enable device */
 	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 4f4df0cd2e..7284a1e84d 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -44,6 +44,12 @@  static int
 nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info)
 {
+	struct nfp_net_hw *pf_hw;
+	struct nfp_flower_representor *repr;
+
+	repr = dev->data->dev_private;
+	pf_hw = repr->app_fw_flower->pf_hw;
+
 	/* Hardcoded pktlen and queues for now */
 	dev_info->max_rx_queues = 1;
 	dev_info->max_tx_queues = 1;
@@ -64,6 +70,13 @@  nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 
 	dev_info->max_mac_addrs = 1;
 
+	if ((pf_hw->super.cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
+		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
+		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
+		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 7a0b0c9973..66aaf7ab09 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -1269,16 +1269,7 @@  nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	if ((cap & NFP_NET_CFG_CTRL_RSS_ANY) != 0) {
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
-
-		dev_info->flow_type_rss_offloads = RTE_ETH_RSS_IPV4 |
-				RTE_ETH_RSS_NONFRAG_IPV4_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV4_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
-				RTE_ETH_RSS_IPV6 |
-				RTE_ETH_RSS_NONFRAG_IPV6_TCP |
-				RTE_ETH_RSS_NONFRAG_IPV6_UDP |
-				RTE_ETH_RSS_NONFRAG_IPV6_SCTP;
-
+		dev_info->flow_type_rss_offloads = NFP_NET_RSS_CAP;
 		dev_info->reta_size = NFP_NET_CFG_RSS_ITBL_SZ;
 		dev_info->hash_key_size = NFP_NET_CFG_RSS_KEY_SZ;
 	}
@@ -1794,7 +1785,11 @@  nfp_net_rss_hash_write(struct rte_eth_dev *dev,
 		cfg_rss_ctrl |= NFP_NET_CFG_RSS_IPV6_SCTP;
 
 	cfg_rss_ctrl |= NFP_NET_CFG_RSS_MASK;
-	cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
+
+	if (nfp_net_dev_is_repr(dev))
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_CRC32;
+	else
+		cfg_rss_ctrl |= NFP_NET_CFG_RSS_TOEPLITZ;
 
 	/* Configuring where to apply the RSS hash */
 	nn_cfg_writel(hw, NFP_NET_CFG_RSS_CTRL, cfg_rss_ctrl);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 1d96b0e9d1..04482455d2 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -41,6 +41,15 @@ 
 
 #define NFP_BEAT_LENGTH         8
 
+/* RSS capability*/
+#define NFP_NET_RSS_CAP (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
+				RTE_ETH_RSS_NONFRAG_IPV6_TCP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_UDP  | \
+				RTE_ETH_RSS_NONFRAG_IPV6_SCTP)
+
 /*
  * Each PF has corresponding word to beat:
  * Offset | Usage