Implement the logic of get RSS algorithm capability, also add the logic of print RSS algorithm capability.
Signed-off-by: Chaoyong He <chaoyong...@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