DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 1/3] net/nfp: support get RSS algorithm capability
Date: Tue,  8 Apr 2025 14:02:01 +0800	[thread overview]
Message-ID: <20250408060203.473733-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20250408060203.473733-1-chaoyong.he@corigine.com>

Implement the logic of get RSS algorithm capability, also add the logic
of print RSS algorithm capability.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/common/nfp/nfp_common.h               |  1 +
 drivers/common/nfp/nfp_common_ctrl.h          |  3 +++
 .../net/nfp/flower/nfp_flower_representor.c   |  1 +
 drivers/net/nfp/nfp_net_common.c              | 26 +++++++++++++++++++
 drivers/net/nfp/nfp_net_common.h              |  3 +++
 5 files changed, 34 insertions(+)

diff --git a/drivers/common/nfp/nfp_common.h b/drivers/common/nfp/nfp_common.h
index 7597d4090b..f0a4c557d6 100644
--- a/drivers/common/nfp/nfp_common.h
+++ b/drivers/common/nfp/nfp_common.h
@@ -39,6 +39,7 @@ struct nfp_hw {
 	uint32_t ctrl_ext;
 	rte_spinlock_t reconfig_lock;
 	struct rte_ether_addr mac_addr;
+	uint32_t cap_rss;
 };
 
 static inline uint8_t
diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h
index 3db3cc90a3..01839c13db 100644
--- a/drivers/common/nfp/nfp_common_ctrl.h
+++ b/drivers/common/nfp/nfp_common_ctrl.h
@@ -191,6 +191,8 @@ struct nfp_net_fw_ver {
 #define NFP_NET_CFG_RX_OFFSET           0x0050
 #define NFP_NET_CFG_RX_OFFSET_DYNAMIC          0    /* Prepend mode */
 
+#define NFP_NET_CFG_RSS_CAP             0x0054
+
 /* Start anchor of the TLV area */
 #define NFP_NET_CFG_TLV_BASE            0x0058
 
@@ -248,6 +250,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_XOR             (1 << 25) /* Use XOR as 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
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index e377d45e53..33fb98ceea 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -181,6 +181,7 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev,
 		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;
+		nfp_net_rss_algo_capa_get(pf_hw, dev_info);
 	}
 
 	return 0;
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index aaa515bac2..6284c54f5b 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -396,6 +396,7 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw,
 {
 	uint32_t cap = hw->super.cap;
 	uint32_t cap_ext = hw->super.cap_ext;
+	uint32_t cap_rss = hw->super.cap_rss;
 
 	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d.",
 			pf_dev->ver.major, pf_dev->ver.minor, hw->max_mtu);
@@ -442,6 +443,12 @@ nfp_net_log_device_information(const struct nfp_net_hw *hw,
 			cap_ext & NFP_NET_CFG_CTRL_FLOW_STEER      ? "FLOW_STEER "      : "",
 			cap_ext & NFP_NET_CFG_CTRL_IN_ORDER        ? "VIRTIO_IN_ORDER " : "");
 
+	PMD_INIT_LOG(INFO, "CAP_RSS: %#x.", cap_rss);
+	PMD_INIT_LOG(INFO, "%s%s%s",
+			cap_rss & NFP_NET_CFG_RSS_TOEPLITZ        ? "RSS_TOEPLITZ "   : "",
+			cap_rss & NFP_NET_CFG_RSS_XOR             ? "RSS_XOR "        : "",
+			cap_rss & NFP_NET_CFG_RSS_CRC32           ? "RSS_CRC32 "      : "");
+
 	PMD_INIT_LOG(INFO, "The max_rx_queues: %u, max_tx_queues: %u.",
 			hw->max_rx_queues, hw->max_tx_queues);
 }
@@ -1406,6 +1413,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 		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;
+		nfp_net_rss_algo_capa_get(hw, dev_info);
 	}
 
 	/* Only PF supports getting speed capability. */
@@ -1430,6 +1438,7 @@ nfp_net_common_init(struct nfp_pf_dev *pf_dev,
 
 	hw->max_rx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_RXRINGS);
 	hw->max_tx_queues = nn_cfg_readl(&hw->super, NFP_NET_CFG_MAX_TXRINGS);
+	hw->super.cap_rss = nn_cfg_readl(&hw->super, NFP_NET_CFG_RSS_CAP);
 	if (hw->max_rx_queues == 0 || hw->max_tx_queues == 0) {
 		PMD_INIT_LOG(ERR, "Device %s can not be used, there are no valid queue "
 				"pairs for use.", pci_dev->name);
@@ -3222,3 +3231,20 @@ nfp_net_led_off(struct rte_eth_dev *dev)
 {
 	return nfp_net_led_control(dev, false);
 }
+
+void
+nfp_net_rss_algo_capa_get(struct nfp_net_hw *hw,
+		struct rte_eth_dev_info *dev_info)
+{
+	uint32_t cap_rss;
+
+	cap_rss = hw->super.cap_rss;
+	if ((cap_rss & NFP_NET_CFG_RSS_TOEPLITZ) != 0)
+		dev_info->rss_algo_capa |= RTE_ETH_HASH_ALGO_CAPA_MASK(TOEPLITZ);
+
+	if ((cap_rss & NFP_NET_CFG_RSS_XOR) != 0)
+		dev_info->rss_algo_capa |= RTE_ETH_HASH_ALGO_CAPA_MASK(SIMPLE_XOR);
+
+	if ((cap_rss & NFP_NET_CFG_RSS_CRC32) != 0)
+		dev_info->rss_algo_capa |= RTE_ETH_HASH_ALGO_CAPA_MASK(DEFAULT);
+}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index d85a00a75e..a6addf8610 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -402,6 +402,9 @@ int nfp_net_get_module_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_inf
 int nfp_net_led_on(struct rte_eth_dev *dev);
 int nfp_net_led_off(struct rte_eth_dev *dev);
 
+void nfp_net_rss_algo_capa_get(struct nfp_net_hw *hw,
+		struct rte_eth_dev_info *dev_info);
+
 #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
 	((struct nfp_app_fw_nic *)app_fw_priv)
 
-- 
2.43.5


  reply	other threads:[~2025-04-08  6:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08  6:02 [PATCH 0/3] Correct RSS algorithm related logic Chaoyong He
2025-04-08  6:02 ` Chaoyong He [this message]
2025-04-08  6:02 ` [PATCH 2/3] net/nfp: support get RSS algorithm configuration Chaoyong He
2025-04-08  6:02 ` [PATCH 3/3] net/nfp: correct RSS algorithm configuration logic Chaoyong He

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=20250408060203.473733-2-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --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).