From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH v4 11/24] net/nfp: extract MAC address data field
Date: Fri, 27 Oct 2023 10:59:48 +0800 [thread overview]
Message-ID: <20231027030001.602639-12-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231027030001.602639-1-chaoyong.he@corigine.com>
Extract the 'mac_addr' data filed into the super class, prepare for the
upcoming common library.
Signed-off-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 | 14 +++++++-------
drivers/net/nfp/nfp_ethdev_vf.c | 18 +++++++++---------
drivers/net/nfp/nfp_net_common.c | 8 ++++----
drivers/net/nfp/nfp_net_common.h | 5 ++---
4 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 1378545d22..a93742a205 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -33,7 +33,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp);
- rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr);
+ rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr);
free(nfp_eth_table);
@@ -599,18 +599,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
}
nfp_net_pf_read_mac(app_fw_nic, port);
- nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+ nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
- tmp_ether_addr = &hw->mac_addr;
+ tmp_ether_addr = &hw->super.mac_addr;
if (rte_is_valid_assigned_ether_addr(tmp_ether_addr) == 0) {
PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
/* Using random mac addresses for VFs */
- rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
- nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+ rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+ nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
}
/* Copying mac address to DPDK eth_dev struct */
- rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+ rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -621,7 +621,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
"mac=" RTE_ETHER_ADDR_PRT_FMT,
eth_dev->data->port_id, pci_dev->id.vendor_id,
pci_dev->id.device_id,
- RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+ RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
/* Registering LSC interrupt handler */
rte_intr_callback_register(pci_dev->intr_handle,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 6ead7e02b8..dead6ca5ab 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -16,14 +16,14 @@
#include "nfp_net_common.h"
static void
-nfp_netvf_read_mac(struct nfp_net_hw *hw)
+nfp_netvf_read_mac(struct nfp_hw *hw)
{
uint32_t tmp;
- tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR));
+ tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
- tmp = rte_be_to_cpu_32(nn_cfg_readl(&hw->super, NFP_NET_CFG_MACADDR + 4));
+ tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
}
@@ -332,16 +332,16 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
goto dev_err_ctrl_map;
}
- nfp_netvf_read_mac(hw);
- if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
+ nfp_netvf_read_mac(&hw->super);
+ if (rte_is_valid_assigned_ether_addr(&hw->super.mac_addr) == 0) {
PMD_INIT_LOG(INFO, "Using random mac address for port %hu", port);
/* Using random mac addresses for VFs */
- rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
- nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
+ rte_eth_random_addr(&hw->super.mac_addr.addr_bytes[0]);
+ nfp_net_write_mac(&hw->super, &hw->super.mac_addr.addr_bytes[0]);
}
/* Copying mac address to DPDK eth_dev struct */
- rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
+ rte_ether_addr_copy(&hw->super.mac_addr, eth_dev->data->mac_addrs);
if ((hw->super.cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -352,7 +352,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
"mac=" RTE_ETHER_ADDR_PRT_FMT,
port, pci_dev->id.vendor_id,
pci_dev->id.device_id,
- RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
+ RTE_ETHER_ADDR_BYTES(&hw->super.mac_addr));
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
/* Registering LSC interrupt handler */
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 9e6d2fa490..a760fcf0d2 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -532,19 +532,19 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
}
void
-nfp_net_write_mac(struct nfp_net_hw *hw,
+nfp_net_write_mac(struct nfp_hw *hw,
uint8_t *mac)
{
uint32_t mac0;
uint16_t mac1;
mac0 = *(uint32_t *)mac;
- nn_writel(rte_cpu_to_be_32(mac0), hw->super.ctrl_bar + NFP_NET_CFG_MACADDR);
+ nn_writel(rte_cpu_to_be_32(mac0), hw->ctrl_bar + NFP_NET_CFG_MACADDR);
mac += 4;
mac1 = *(uint16_t *)mac;
nn_writew(rte_cpu_to_be_16(mac1),
- hw->super.ctrl_bar + NFP_NET_CFG_MACADDR + 6);
+ hw->ctrl_bar + NFP_NET_CFG_MACADDR + 6);
}
int
@@ -565,7 +565,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev,
}
/* Writing new MAC to the specific port BAR address */
- nfp_net_write_mac(net_hw, (uint8_t *)mac_addr);
+ nfp_net_write_mac(hw, (uint8_t *)mac_addr);
update = NFP_NET_CFG_UPDATE_MACADDR;
ctrl = hw->ctrl;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index d418cd2b99..e997756091 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -120,6 +120,7 @@ struct nfp_hw {
uint32_t ctrl;
uint32_t ctrl_ext;
rte_spinlock_t reconfig_lock;
+ struct rte_ether_addr mac_addr;
};
struct nfp_net_hw {
@@ -159,8 +160,6 @@ struct nfp_net_hw {
uint16_t subsystem_device_id;
uint16_t subsystem_vendor_id;
- struct rte_ether_addr mac_addr;
-
/** Records starting point for counters */
struct rte_eth_stats eth_stats_base;
struct rte_eth_xstat *eth_xstats_base;
@@ -376,7 +375,7 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
void nfp_net_enable_queues(struct rte_eth_dev *dev);
void nfp_net_disable_queues(struct rte_eth_dev *dev);
void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac);
+void nfp_net_write_mac(struct nfp_hw *hw, uint8_t *mac);
int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
struct rte_intr_handle *intr_handle);
--
2.39.1
next prev parent reply other threads:[~2023-10-27 3:02 UTC|newest]
Thread overview: 121+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 5:45 [PATCH 00/25] add the NFP vDPA PMD Chaoyong He
2023-10-17 5:45 ` [PATCH 01/25] drivers: introduce the NFP common library Chaoyong He
2023-10-17 5:45 ` [PATCH 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
2023-10-17 5:45 ` [PATCH 03/25] net/nfp: rename common module name Chaoyong He
2023-10-17 5:45 ` [PATCH 04/25] net/nfp: rename ctrl " Chaoyong He
2023-10-17 5:45 ` [PATCH 05/25] net/nfp: extract the cap data field Chaoyong He
2023-10-17 5:45 ` [PATCH 06/25] net/nfp: extract the qcp " Chaoyong He
2023-10-17 5:45 ` [PATCH 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
2023-10-17 5:45 ` [PATCH 08/25] net/nfp: extract the ctrl " Chaoyong He
2023-10-17 5:45 ` [PATCH 09/25] net/nfp: change the parameter of APIs Chaoyong He
2023-10-17 5:45 ` [PATCH 10/25] net/nfp: change the parameter of reconfig Chaoyong He
2023-10-17 5:45 ` [PATCH 11/25] net/nfp: extract the MAC address data field Chaoyong He
2023-10-17 5:45 ` [PATCH 12/25] net/nfp: rename parameter in related logic Chaoyong He
2023-10-17 5:45 ` [PATCH 13/25] drivers: add the common ctrl module Chaoyong He
2023-10-17 5:45 ` [PATCH 14/25] drivers: add the nfp common module Chaoyong He
2023-10-17 5:45 ` [PATCH 15/25] drivers: move queue logic to " Chaoyong He
2023-10-17 5:45 ` [PATCH 16/25] drivers: move platform module to common library Chaoyong He
2023-10-17 5:45 ` [PATCH 17/25] drivers: move device " Chaoyong He
2023-10-17 5:45 ` [PATCH 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
2023-10-17 5:45 ` [PATCH 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
2023-10-17 5:45 ` [PATCH 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
2023-10-17 5:45 ` [PATCH 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
2023-10-17 5:45 ` [PATCH 22/25] drivers: add the datapath update logic Chaoyong He
2023-10-17 5:45 ` [PATCH 23/25] vdpa/nfp: add the notify related logic Chaoyong He
2023-10-17 5:45 ` [PATCH 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
2023-10-17 5:45 ` [PATCH 25/25] doc: add the common and vDPA document Chaoyong He
2023-10-24 2:28 ` [PATCH v2 00/25] add the NFP vDPA PMD Chaoyong He
2023-10-24 2:28 ` [PATCH v2 01/25] drivers: introduce the NFP common library Chaoyong He
2023-10-24 2:28 ` [PATCH v2 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
2023-10-25 16:09 ` Ferruh Yigit
2023-10-26 1:34 ` Chaoyong He
2023-10-24 2:28 ` [PATCH v2 03/25] net/nfp: rename common module name Chaoyong He
2023-10-24 2:28 ` [PATCH v2 04/25] net/nfp: rename ctrl " Chaoyong He
2023-10-24 2:28 ` [PATCH v2 05/25] net/nfp: extract the cap data field Chaoyong He
2023-10-24 2:28 ` [PATCH v2 06/25] net/nfp: extract the qcp " Chaoyong He
2023-10-24 2:28 ` [PATCH v2 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
2023-10-24 2:28 ` [PATCH v2 08/25] net/nfp: extract the ctrl " Chaoyong He
2023-10-24 2:28 ` [PATCH v2 09/25] net/nfp: change the parameter of APIs Chaoyong He
2023-10-24 2:28 ` [PATCH v2 10/25] net/nfp: change the parameter of reconfig Chaoyong He
2023-10-24 2:28 ` [PATCH v2 11/25] net/nfp: extract the MAC address data field Chaoyong He
2023-10-24 2:28 ` [PATCH v2 12/25] net/nfp: rename parameter in related logic Chaoyong He
2023-10-24 2:28 ` [PATCH v2 13/25] drivers: add the common ctrl module Chaoyong He
2023-10-24 2:28 ` [PATCH v2 14/25] drivers: add the nfp common module Chaoyong He
2023-10-24 2:28 ` [PATCH v2 15/25] drivers: move queue logic to " Chaoyong He
2023-10-24 2:28 ` [PATCH v2 16/25] drivers: move platform module to common library Chaoyong He
2023-10-24 2:28 ` [PATCH v2 17/25] drivers: move device " Chaoyong He
2023-10-24 2:28 ` [PATCH v2 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
2023-10-25 16:09 ` Ferruh Yigit
2023-10-26 1:39 ` Chaoyong He
2023-10-24 2:28 ` [PATCH v2 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
2023-10-25 16:10 ` Ferruh Yigit
2023-10-26 1:39 ` Chaoyong He
2023-10-24 2:28 ` [PATCH v2 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
2023-10-24 2:28 ` [PATCH v2 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
2023-10-24 2:28 ` [PATCH v2 22/25] drivers: add the datapath update logic Chaoyong He
2023-10-24 2:28 ` [PATCH v2 23/25] vdpa/nfp: add the notify related logic Chaoyong He
2023-10-24 2:28 ` [PATCH v2 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
2023-10-24 2:28 ` [PATCH v2 25/25] doc: add the common and vDPA document Chaoyong He
2023-10-25 16:11 ` Ferruh Yigit
2023-10-26 1:41 ` Chaoyong He
2023-10-25 16:09 ` [PATCH v2 00/25] add the NFP vDPA PMD Ferruh Yigit
2023-10-26 1:33 ` Chaoyong He
2023-10-26 2:50 ` Chaoyong He
2023-10-26 11:30 ` Ferruh Yigit
2023-10-26 11:33 ` Chaoyong He
2023-10-26 6:42 ` [PATCH v3 " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 01/25] drivers: introduce the NFP common library Chaoyong He
2023-10-26 6:43 ` [PATCH v3 02/25] net/nfp: make VF PMD using of NFP common module Chaoyong He
2023-10-26 6:43 ` [PATCH v3 03/25] net/nfp: rename common module name Chaoyong He
2023-10-26 6:43 ` [PATCH v3 04/25] net/nfp: rename ctrl " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 05/25] net/nfp: extract the cap data field Chaoyong He
2023-10-26 6:43 ` [PATCH v3 06/25] net/nfp: extract the qcp " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 07/25] net/nfp: extract the ctrl BAR " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 08/25] net/nfp: extract the ctrl " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 09/25] net/nfp: change the parameter of APIs Chaoyong He
2023-10-26 6:43 ` [PATCH v3 10/25] net/nfp: change the parameter of reconfig Chaoyong He
2023-10-26 6:43 ` [PATCH v3 11/25] net/nfp: extract the MAC address data field Chaoyong He
2023-10-26 6:43 ` [PATCH v3 12/25] net/nfp: rename parameter in related logic Chaoyong He
2023-10-26 6:43 ` [PATCH v3 13/25] drivers: add the common ctrl module Chaoyong He
2023-10-26 6:43 ` [PATCH v3 14/25] drivers: add the nfp common module Chaoyong He
2023-10-26 6:43 ` [PATCH v3 15/25] drivers: move queue logic to " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 16/25] drivers: move platform module to common library Chaoyong He
2023-10-26 6:43 ` [PATCH v3 17/25] drivers: move device " Chaoyong He
2023-10-26 6:43 ` [PATCH v3 18/25] drivers/vdpa: introduce the NFP vDPA library Chaoyong He
2023-10-26 6:43 ` [PATCH v3 19/25] drivers: add the basic framework of vDPA PMD Chaoyong He
2023-10-26 6:43 ` [PATCH v3 20/25] vdpa/nfp: add the logic of remap PCI memory Chaoyong He
2023-10-26 6:43 ` [PATCH v3 21/25] vdpa/nfp: add the hardware init logic Chaoyong He
2023-10-26 6:43 ` [PATCH v3 22/25] drivers: add the datapath update logic Chaoyong He
2023-10-26 6:43 ` [PATCH v3 23/25] vdpa/nfp: add the notify related logic Chaoyong He
2023-10-26 6:43 ` [PATCH v3 24/25] vdpa/nfp: add nfp vDPA device operations Chaoyong He
2023-10-26 6:43 ` [PATCH v3 25/25] doc: add a entry in the release notes Chaoyong He
2023-10-26 14:55 ` Ferruh Yigit
2023-10-26 14:47 ` [PATCH v3 00/25] add the NFP vDPA PMD Ferruh Yigit
2023-10-26 14:55 ` Ferruh Yigit
2023-10-27 1:23 ` Chaoyong He
2023-10-27 2:59 ` [PATCH v4 00/24] " Chaoyong He
2023-10-27 2:59 ` [PATCH v4 01/24] common/nfp: introduce driver Chaoyong He
2023-10-27 2:59 ` [PATCH v4 02/24] net/nfp: make VF PMD use NFP common driver Chaoyong He
2023-10-27 2:59 ` [PATCH v4 03/24] net/nfp: rename net common module Chaoyong He
2023-10-27 2:59 ` [PATCH v4 04/24] net/nfp: rename ctrl module Chaoyong He
2023-10-27 2:59 ` [PATCH v4 05/24] net/nfp: extract cap data field Chaoyong He
2023-10-27 2:59 ` [PATCH v4 06/24] net/nfp: extract qcp " Chaoyong He
2023-10-27 2:59 ` [PATCH v4 07/24] net/nfp: extract ctrl BAR " Chaoyong He
2023-10-27 2:59 ` [PATCH v4 08/24] net/nfp: extract ctrl " Chaoyong He
2023-10-27 2:59 ` [PATCH v4 09/24] net/nfp: change parameter of functions Chaoyong He
2023-10-27 2:59 ` [PATCH v4 10/24] net/nfp: change parameter of reconfig Chaoyong He
2023-10-27 2:59 ` Chaoyong He [this message]
2023-10-27 2:59 ` [PATCH v4 12/24] net/nfp: rename parameter in related logic Chaoyong He
2023-10-27 2:59 ` [PATCH v4 13/24] common/nfp: add common ctrl module Chaoyong He
2023-10-27 2:59 ` [PATCH v4 14/24] common/nfp: add common module Chaoyong He
2023-10-27 2:59 ` [PATCH v4 15/24] common/nfp: move queue logic Chaoyong He
2023-10-27 2:59 ` [PATCH v4 16/24] common/nfp: move platform module Chaoyong He
2023-10-27 2:59 ` [PATCH v4 17/24] common/nfp: move device module Chaoyong He
2023-10-27 2:59 ` [PATCH v4 18/24] vdpa/nfp: introduce driver Chaoyong He
2023-10-27 2:59 ` [PATCH v4 19/24] vdpa/nfp: add basic framework Chaoyong He
2023-10-27 2:59 ` [PATCH v4 20/24] vdpa/nfp: add remap PCI memory Chaoyong He
2023-10-27 2:59 ` [PATCH v4 21/24] vdpa/nfp: add hardware init Chaoyong He
2023-10-27 2:59 ` [PATCH v4 22/24] vdpa/nfp: add datapath update Chaoyong He
2023-10-27 3:00 ` [PATCH v4 23/24] vdpa/nfp: add notify related logic Chaoyong He
2023-10-27 3:00 ` [PATCH v4 24/24] vdpa/nfp: add device operations Chaoyong He
2023-10-27 13:38 ` [PATCH v4 00/24] add the NFP vDPA PMD 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=20231027030001.602639-12-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 \
/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).