[7/8] net/nfp: standardize the use of port index in some functions
Checks
Commit Message
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(-)
@@ -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.");
@@ -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) {