[5/7] net/nfp: support getting FEC capability
Checks
Commit Message
From: Zerun Fu <zerun.fu@corigine.com>
Add support for querying FEC capabilities from the device. This
feature only shows the current port speed and the supported FEC
modes at that speed.
Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
doc/guides/nics/features/nfp.ini | 1 +
drivers/net/nfp/nfp_ethdev.c | 1 +
drivers/net/nfp/nfp_net_common.c | 45 ++++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_net_common.h | 3 +++
4 files changed, 50 insertions(+)
@@ -19,6 +19,7 @@ RSS reta update = Y
Flow control = Y
VLAN offload = Y
QinQ offload = Y
+FEC = Y
L3 checksum offload = Y
L4 checksum offload = Y
Basic stats = Y
@@ -759,6 +759,7 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
.flow_ctrl_get = nfp_net_flow_ctrl_get,
.flow_ctrl_set = nfp_net_flow_ctrl_set,
.flow_ops_get = nfp_net_flow_ops_get,
+ .fec_get_capability = nfp_net_fec_get_capability,
};
static inline void
@@ -26,6 +26,9 @@
#define NFP_ETH_OVERHEAD \
(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN * 2)
+/* Only show FEC capability supported by the current speed. */
+#define NFP_FEC_CAPA_ENTRY_NUM 1
+
enum nfp_xstat_group {
NFP_XSTAT_GROUP_NET,
NFP_XSTAT_GROUP_MAC
@@ -2281,3 +2284,45 @@ nfp_net_flow_ctrl_set(struct rte_eth_dev *dev,
return 0;
}
+
+int
+nfp_net_fec_get_capability(struct rte_eth_dev *dev,
+ struct rte_eth_fec_capa *speed_fec_capa,
+ __rte_unused unsigned int num)
+{
+ uint16_t speed;
+ struct nfp_net_hw *hw;
+ uint32_t supported_fec;
+ struct nfp_eth_table *nfp_eth_table;
+ struct nfp_eth_table_port *eth_port;
+
+ hw = nfp_net_get_hw(dev);
+ if (hw->pf_dev == NULL)
+ return -EINVAL;
+
+ nfp_eth_table = hw->pf_dev->nfp_eth_table;
+ eth_port = &nfp_eth_table->ports[hw->idx];
+
+ speed = eth_port->speed;
+ supported_fec = nfp_eth_supported_fec_modes(eth_port);
+ if (speed == 0 || supported_fec == 0) {
+ PMD_DRV_LOG(ERR, "FEC modes supported or Speed is invalid.");
+ return -EINVAL;
+ }
+
+ if (speed_fec_capa == NULL)
+ return NFP_FEC_CAPA_ENTRY_NUM;
+
+ speed_fec_capa->speed = speed;
+
+ if ((supported_fec & NFP_FEC_AUTO) != 0)
+ speed_fec_capa->capa |= RTE_ETH_FEC_MODE_CAPA_MASK(AUTO);
+ if ((supported_fec & NFP_FEC_BASER) != 0)
+ speed_fec_capa->capa |= RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
+ if ((supported_fec & NFP_FEC_REED_SOLOMON) != 0)
+ speed_fec_capa->capa |= RTE_ETH_FEC_MODE_CAPA_MASK(RS);
+ if ((supported_fec & NFP_FEC_DISABLED) != 0)
+ speed_fec_capa->capa |= RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
+
+ return NFP_FEC_CAPA_ENTRY_NUM;
+}
@@ -288,6 +288,9 @@ int nfp_net_flow_ctrl_get(struct rte_eth_dev *dev,
int nfp_net_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
void nfp_pf_uninit(struct nfp_pf_dev *pf_dev);
+int nfp_net_fec_get_capability(struct rte_eth_dev *dev,
+ struct rte_eth_fec_capa *speed_fec_capa,
+ unsigned int num);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)