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 6/7] net/nfp: support getting FEC mode
Date: Mon, 11 Dec 2023 11:08:57 +0800 [thread overview]
Message-ID: <20231211030858.1693240-7-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 current FEC mode from the device.
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>
---
drivers/net/nfp/nfp_ethdev.c | 1 +
drivers/net/nfp/nfp_net_common.c | 60 ++++++++++++++++++++++++++++++++
drivers/net/nfp/nfp_net_common.h | 2 ++
3 files changed, 63 insertions(+)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3c24ebeaf3..e3f5fe7917 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -760,6 +760,7 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
.flow_ctrl_set = nfp_net_flow_ctrl_set,
.flow_ops_get = nfp_net_flow_ops_get,
.fec_get_capability = nfp_net_fec_get_capability,
+ .fec_get = nfp_net_fec_get,
};
static inline void
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 5aa85aa077..063c048675 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -2326,3 +2326,63 @@ nfp_net_fec_get_capability(struct rte_eth_dev *dev,
return NFP_FEC_CAPA_ENTRY_NUM;
}
+
+static uint32_t
+nfp_net_fec_nfp_to_rte(enum nfp_eth_fec fec)
+{
+ switch (fec) {
+ case NFP_FEC_AUTO_BIT:
+ return RTE_ETH_FEC_MODE_CAPA_MASK(AUTO);
+ case NFP_FEC_BASER_BIT:
+ return RTE_ETH_FEC_MODE_CAPA_MASK(BASER);
+ case NFP_FEC_REED_SOLOMON_BIT:
+ return RTE_ETH_FEC_MODE_CAPA_MASK(RS);
+ case NFP_FEC_DISABLED_BIT:
+ return RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC);
+ default:
+ PMD_DRV_LOG(ERR, "FEC mode is invalid.");
+ return 0;
+ }
+}
+
+int
+nfp_net_fec_get(struct rte_eth_dev *dev,
+ uint32_t *fec_capa)
+{
+ struct nfp_net_hw *hw;
+ 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;
+
+ if (dev->data->dev_link.link_status == RTE_ETH_LINK_DOWN) {
+ nfp_eth_table = nfp_eth_read_ports(hw->cpp);
+ hw->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+ free(nfp_eth_table);
+ }
+
+ nfp_eth_table = hw->pf_dev->nfp_eth_table;
+ eth_port = &nfp_eth_table->ports[hw->idx];
+
+ if (!nfp_eth_can_support_fec(eth_port)) {
+ PMD_DRV_LOG(ERR, "NFP can not support FEC.");
+ return -ENOTSUP;
+ }
+
+ /*
+ * If link is down and AUTO is enabled, AUTO is returned, otherwise,
+ * configured FEC mode is returned.
+ * If link is up, current FEC mode is returned.
+ */
+ if (dev->data->dev_link.link_status == RTE_ETH_LINK_DOWN)
+ *fec_capa = nfp_net_fec_nfp_to_rte(eth_port->fec);
+ else
+ *fec_capa = nfp_net_fec_nfp_to_rte(eth_port->act_fec);
+
+ if (*fec_capa == 0)
+ return -EINVAL;
+
+ return 0;
+}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index f0fe10b6cd..fa88323b7c 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -291,6 +291,8 @@ 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);
+int nfp_net_fec_get(struct rte_eth_dev *dev,
+ uint32_t *fec_capa);
#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 ` [PATCH 5/7] net/nfp: support getting FEC capability Chaoyong He
2023-12-11 3:08 ` Chaoyong He [this message]
2023-12-11 3:08 ` [PATCH 7/7] net/nfp: support setting FEC mode 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-7-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).