From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Zerun Fu <zerun.fu@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 5/7] net/nfp: support getting FEC capability
Date: Mon, 11 Dec 2023 11:08:56 +0800 [thread overview]
Message-ID: <20231211030858.1693240-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231211030858.1693240-1-chaoyong.he@corigine.com>
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(+)
diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini
index df1d403c6e..3494111f86 100644
--- a/doc/guides/nics/features/nfp.ini
+++ b/doc/guides/nics/features/nfp.ini
@@ -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
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 54d018870d..3c24ebeaf3 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -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
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 1658cc7d3c..5aa85aa077 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -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;
+}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index aec3c51bdf..f0fe10b6cd 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -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)
--
2.39.1
next prev parent reply other threads:[~2023-12-11 3:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 3:08 [PATCH 0/7] support link auto negotiation Chaoyong He
2023-12-11 3:08 ` [PATCH 1/7] net/nfp: set a new parameter to hwinfo Chaoyong He
2023-12-11 3:08 ` [PATCH 2/7] net/nfp: support getting speed capability Chaoyong He
2023-12-11 3:08 ` [PATCH 3/7] net/nfp: support setting port speed Chaoyong He
2023-12-11 3:08 ` [PATCH 4/7] net/nfp: modify the link update function Chaoyong He
2023-12-11 3:08 ` Chaoyong He [this message]
2023-12-11 3:08 ` [PATCH 6/7] net/nfp: support getting FEC mode Chaoyong He
2023-12-11 3:08 ` [PATCH 7/7] net/nfp: support setting " Chaoyong He
2023-12-12 15:28 ` [PATCH 0/7] support link auto negotiation 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=20231211030858.1693240-6-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=zerun.fu@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).