From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Qin Ke <qin.ke@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 7/8] net/nfp: standardize the use of port index in some functions
Date: Thu, 5 Sep 2024 14:25:10 +0800 [thread overview]
Message-ID: <20240905062511.2710102-8-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240905062511.2710102-1-chaoyong.he@corigine.com>
From: Qin Ke <qin.ke@corigine.com>
Standardize the use of 'idx' in some functions which could be
used for both flower and coreNIC firmware.
Signed-off-by: Qin Ke <qin.ke@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 6 ++++--
drivers/net/nfp/nfp_net_common.c | 26 +++++++++++++-------------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index b35e40a7d0..2ddfdcd048 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -281,6 +281,7 @@ static int
nfp_net_speed_configure(struct rte_eth_dev *dev)
{
int ret;
+ uint8_t idx;
uint32_t speed_capa;
uint32_t link_speeds;
uint32_t configure_speed;
@@ -289,8 +290,9 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
struct nfp_net_hw *net_hw = dev->data->dev_private;
struct nfp_net_hw_priv *hw_priv = dev->process_private;
+ idx = nfp_net_get_idx(dev);
nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
- eth_port = &nfp_eth_table->ports[net_hw->idx];
+ eth_port = &nfp_eth_table->ports[idx];
speed_capa = hw_priv->pf_dev->speed_capa;
if (speed_capa == 0) {
@@ -308,7 +310,7 @@ nfp_net_speed_configure(struct rte_eth_dev *dev)
/* NFP4000 does not allow the port 0 25Gbps and port 1 10Gbps at the same time. */
if (net_hw->device_id == PCI_DEVICE_ID_NFP4000_PF_NIC) {
- ret = nfp_net_nfp4000_speed_configure_check(net_hw->idx,
+ ret = nfp_net_nfp4000_speed_configure_check(idx,
configure_speed, nfp_eth_table);
if (ret != 0) {
PMD_DRV_LOG(ERR, "Failed to configure speed for NFP4000.");
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index daed57e374..f440f31a4d 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -2489,20 +2489,20 @@ nfp_net_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf)
{
int ret;
- struct nfp_net_hw *net_hw;
+ uint8_t idx;
enum rte_eth_fc_mode set_mode;
struct nfp_net_hw_priv *hw_priv;
enum rte_eth_fc_mode original_mode;
struct nfp_eth_table *nfp_eth_table;
struct nfp_eth_table_port *eth_port;
- net_hw = nfp_net_get_hw(dev);
+ idx = nfp_net_get_idx(dev);
hw_priv = dev->process_private;
if (hw_priv == NULL || hw_priv->pf_dev == NULL)
return -EINVAL;
nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
- eth_port = &nfp_eth_table->ports[net_hw->idx];
+ eth_port = &nfp_eth_table->ports[idx];
original_mode = nfp_net_get_pause_mode(eth_port);
set_mode = fc_conf->mode;
@@ -2526,20 +2526,20 @@ nfp_net_fec_get_capability(struct rte_eth_dev *dev,
struct rte_eth_fec_capa *speed_fec_capa,
__rte_unused unsigned int num)
{
+ uint8_t idx;
uint16_t speed;
- struct nfp_net_hw *hw;
uint32_t supported_fec;
struct nfp_net_hw_priv *hw_priv;
struct nfp_eth_table *nfp_eth_table;
struct nfp_eth_table_port *eth_port;
- hw = nfp_net_get_hw(dev);
+ idx = nfp_net_get_idx(dev);
hw_priv = dev->process_private;
if (hw_priv == NULL || hw_priv->pf_dev == NULL)
return -EINVAL;
nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
- eth_port = &nfp_eth_table->ports[hw->idx];
+ eth_port = &nfp_eth_table->ports[idx];
speed = eth_port->speed;
supported_fec = nfp_eth_supported_fec_modes(eth_port);
@@ -2587,24 +2587,24 @@ int
nfp_net_fec_get(struct rte_eth_dev *dev,
uint32_t *fec_capa)
{
- struct nfp_net_hw *hw;
+ uint8_t idx;
struct nfp_net_hw_priv *hw_priv;
struct nfp_eth_table *nfp_eth_table;
struct nfp_eth_table_port *eth_port;
- hw = nfp_net_get_hw(dev);
+ idx = nfp_net_get_idx(dev);
hw_priv = dev->process_private;
if (hw_priv == NULL || hw_priv->pf_dev == NULL)
return -EINVAL;
if (dev->data->dev_link.link_status == RTE_ETH_LINK_DOWN) {
nfp_eth_table = nfp_eth_read_ports(hw_priv->pf_dev->cpp);
- hw_priv->pf_dev->nfp_eth_table->ports[hw->idx] = nfp_eth_table->ports[hw->idx];
+ hw_priv->pf_dev->nfp_eth_table->ports[idx] = nfp_eth_table->ports[idx];
free(nfp_eth_table);
}
nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
- eth_port = &nfp_eth_table->ports[hw->idx];
+ eth_port = &nfp_eth_table->ports[idx];
if (!nfp_eth_can_support_fec(eth_port)) {
PMD_DRV_LOG(ERR, "NFP can not support FEC.");
@@ -2648,20 +2648,20 @@ int
nfp_net_fec_set(struct rte_eth_dev *dev,
uint32_t fec_capa)
{
+ uint8_t idx;
enum nfp_eth_fec fec;
- struct nfp_net_hw *hw;
uint32_t supported_fec;
struct nfp_net_hw_priv *hw_priv;
struct nfp_eth_table *nfp_eth_table;
struct nfp_eth_table_port *eth_port;
- hw = nfp_net_get_hw(dev);
+ idx = nfp_net_get_idx(dev);
hw_priv = dev->process_private;
if (hw_priv == NULL || hw_priv->pf_dev == NULL)
return -EINVAL;
nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
- eth_port = &nfp_eth_table->ports[hw->idx];
+ eth_port = &nfp_eth_table->ports[idx];
supported_fec = nfp_eth_supported_fec_modes(eth_port);
if (supported_fec == 0) {
--
2.39.1
next prev parent reply other threads:[~2024-09-05 6:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 6:25 [PATCH 0/8] fix the representor port link status and speed Chaoyong He
2024-09-05 6:25 ` [PATCH 1/8] net/nfp: fix incorrect type declaration of some variables Chaoyong He
2024-09-05 6:25 ` [PATCH 2/8] net/nfp: add help function to check link speed Chaoyong He
2024-09-05 6:25 ` [PATCH 3/8] net/nfp: add help function to update VF " Chaoyong He
2024-09-05 6:25 ` [PATCH 4/8] net/nfp: rename PF speed update function Chaoyong He
2024-09-05 6:25 ` [PATCH 5/8] net/nfp: add new data field into representor port structure Chaoyong He
2024-09-05 6:25 ` [PATCH 6/8] net/nfp: fix representor port link speed update problem Chaoyong He
2024-09-05 6:25 ` Chaoyong He [this message]
2024-09-05 6:25 ` [PATCH 8/8] net/nfp: fix representor port link status " 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=20240905062511.2710102-8-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=qin.ke@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).