* [PATCH 00/11] Clean up NFP PMD @ 2023-10-28 6:15 Chaoyong He 2023-10-28 6:15 ` [PATCH 01/11] net/nfp: use the suitable helper macro Chaoyong He ` (11 more replies) 0 siblings, 12 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He This patch series clean up the NFP PMD, by: - Using the DPDK macro and API to replace the user defined ones. - Remove the unneeded macro and logic. - Remove the duplicated logic. Chaoyong He (11): net/nfp: use the suitable helper macro net/nfp: remove the unneeded call of underlying API net/nfp: remove the unneeded check of process type net/nfp: remove the unneeded data abstraction net/nfp: remove the redundancy macro net/nfp: remove redundancy logic of init control BAR net/nfp: use the DPDK defined function net/nfp: replace hard coded value net/nfp: unify the PMD name with macro net/nfp: extract a helper function net/nfp: remove the redundancy logic of representor port drivers/common/nfp/nfp_common_ctrl.h | 17 -- drivers/net/nfp/flower/nfp_flower.c | 111 +------- drivers/net/nfp/flower/nfp_flower.h | 4 +- drivers/net/nfp/flower/nfp_flower_cmsg.c | 3 +- drivers/net/nfp/flower/nfp_flower_ctrl.c | 6 +- .../net/nfp/flower/nfp_flower_representor.c | 253 +----------------- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 88 +++--- drivers/net/nfp/nfp_ethdev_vf.c | 28 +- drivers/net/nfp/nfp_ipsec.c | 18 +- drivers/net/nfp/nfp_net_common.c | 203 ++++++++------ drivers/net/nfp/nfp_net_common.h | 13 +- drivers/net/nfp/nfp_net_ctrl.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 11 +- drivers/net/nfp/nfp_rxtx.h | 6 - 16 files changed, 203 insertions(+), 564 deletions(-) -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 01/11] net/nfp: use the suitable helper macro 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 02/11] net/nfp: remove the unneeded call of underlying API Chaoyong He ` (10 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Replace the `rte_pktmbuf_mtod()` macro to with the more suitable `rte_pktmbuf_mtod_offset()`. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 2 +- drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++-- drivers/net/nfp/nfp_rxtx.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 2ec9498d22..4013b32fd0 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -13,7 +13,7 @@ static char* nfp_flower_cmsg_get_data(struct rte_mbuf *m) { - return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN; + return rte_pktmbuf_mtod_offset(m, char *, 4 + 4 + NFP_FLOWER_CMSG_HLEN); } static void * diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index b4be28ccdf..d19b60bc69 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -375,7 +375,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv, uint32_t ctx_id; struct nfp_flower_stats_frame *stats; - msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN; + msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN); msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN; count = msg_len / sizeof(struct nfp_flower_stats_frame); @@ -398,7 +398,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv, struct nfp_mtr *mtr; struct nfp_mtr_stats_reply *mtr_stats; - msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN; + msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN); mtr_stats = (struct nfp_mtr_stats_reply *)msg; profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index fc94e5f0b9..644be2700e 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -448,8 +448,7 @@ nfp_net_parse_meta(struct nfp_net_rx_desc *rxds, if (unlikely(NFP_DESC_META_LEN(rxds) == 0)) return; - meta_base = rte_pktmbuf_mtod(mb, uint8_t *); - meta_base -= NFP_DESC_META_LEN(rxds); + meta_base = rte_pktmbuf_mtod_offset(mb, uint8_t *, -NFP_DESC_META_LEN(rxds)); meta_header = *(rte_be32_t *)meta_base; switch (hw->meta_format) { -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 02/11] net/nfp: remove the unneeded call of underlying API 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He 2023-10-28 6:15 ` [PATCH 01/11] net/nfp: use the suitable helper macro Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 03/11] net/nfp: remove the unneeded check of process type Chaoyong He ` (9 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Remove the unneeded call of underlying API in function 'nfp_net_pf_read_mac()`, because we already store the result of it in data structure. Also change the return type of this function to 'void' as there is no abnormal exit logic. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 76317925ec..0fed0ef72d 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -21,7 +21,7 @@ #include "nfp_ipsec.h" #include "nfp_logs.h" -static int +static void nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, uint16_t port) { @@ -31,13 +31,9 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, /* Grab a pointer to the correct physical port */ hw = app_fw_nic->ports[port]; - nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp); + nfp_eth_table = app_fw_nic->pf_dev->nfp_eth_table; rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr); - - free(nfp_eth_table); - - return 0; } static int -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 03/11] net/nfp: remove the unneeded check of process type 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He 2023-10-28 6:15 ` [PATCH 01/11] net/nfp: use the suitable helper macro Chaoyong He 2023-10-28 6:15 ` [PATCH 02/11] net/nfp: remove the unneeded call of underlying API Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He ` (8 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Remove the unneeded secondary call of 'rte_eal_process_type()' in 'nfp_netvf_init()', because the first call of it already make sure only the primary process can continue run the rest logic. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev_vf.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index b9cfb48021..e24fec861d 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -344,15 +344,13 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) pci_dev->id.device_id, RTE_ETHER_ADDR_BYTES(&hw->mac_addr)); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - /* Registering LSC interrupt handler */ - rte_intr_callback_register(pci_dev->intr_handle, - nfp_net_dev_interrupt_handler, (void *)eth_dev); - /* Telling the firmware about the LSC interrupt entry */ - nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX); - /* Recording current stats counters values */ - nfp_net_stats_reset(eth_dev); - } + /* Registering LSC interrupt handler */ + rte_intr_callback_register(pci_dev->intr_handle, + nfp_net_dev_interrupt_handler, (void *)eth_dev); + /* Telling the firmware about the LSC interrupt entry */ + nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX); + /* Recording current stats counters values */ + nfp_net_stats_reset(eth_dev); return 0; -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 04/11] net/nfp: remove the unneeded data abstraction 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (2 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 03/11] net/nfp: remove the unneeded check of process type Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 05/11] net/nfp: remove the redundancy macro Chaoyong He ` (7 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang The data structure 'struct nfp_net_adapter' has only one data field and we won't extend it in the future, which makes this abstraction unneeded, so remove this data structure and the related macro 'NFP_NET_DEV_PRIVATE_TO_HW'. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 2 +- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 18 +++++----- drivers/net/nfp/nfp_ethdev_vf.c | 6 ++-- drivers/net/nfp/nfp_ipsec.c | 18 +++++----- drivers/net/nfp/nfp_net_common.c | 55 ++++++++++++++--------------- drivers/net/nfp/nfp_net_common.h | 3 -- drivers/net/nfp/nfp_net_ctrl.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 4 +-- 10 files changed, 54 insertions(+), 58 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index f3fedbf7e5..246dd2d454 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -848,7 +848,7 @@ nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev, } /* Allocate memory for the PF AND ctrl vNIC here (hence the * 2) */ - pf_hw = rte_zmalloc_socket("nfp_pf_vnic", 2 * sizeof(struct nfp_net_adapter), + pf_hw = rte_zmalloc_socket("nfp_pf_vnic", 2 * sizeof(struct nfp_net_hw), RTE_CACHE_LINE_SIZE, numa_node); if (pf_hw == NULL) { PMD_INIT_LOG(ERR, "Could not malloc nfp pf vnic"); diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index c85fadc80d..3f9909c6e0 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -377,7 +377,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_free_thresh; const struct rte_memzone *tz; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index 10e6982c95..fe87ea3e25 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -454,7 +454,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_txq *txq; const struct rte_memzone *tz; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 0fed0ef72d..8e69fa67b2 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -55,7 +55,7 @@ nfp_net_start(struct rte_eth_dev *dev) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_intr_handle *intr_handle = pci_dev->intr_handle; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); hw = &net_hw->super; @@ -201,7 +201,7 @@ nfp_net_stop(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_disable_queues(dev); @@ -224,7 +224,7 @@ nfp_net_set_link_up(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ @@ -239,7 +239,7 @@ nfp_net_set_link_down(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ @@ -262,7 +262,7 @@ nfp_net_close(struct rte_eth_dev *dev) return 0; pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; pci_dev = RTE_ETH_DEV_TO_PCI(dev); app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); @@ -350,7 +350,7 @@ nfp_udp_tunnel_port_add(struct rte_eth_dev *dev, struct nfp_net_hw *hw; enum rte_eth_tunnel_type tnl_type; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; vxlan_port = tunnel_udp->udp_port; tnl_type = tunnel_udp->prot_type; @@ -388,7 +388,7 @@ nfp_udp_tunnel_port_del(struct rte_eth_dev *dev, struct nfp_net_hw *hw; enum rte_eth_tunnel_type tnl_type; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; vxlan_port = tunnel_udp->udp_port; tnl_type = tunnel_udp->prot_type; @@ -828,7 +828,7 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev, goto port_cleanup; } - hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + hw = eth_dev->data->dev_private; /* Add this device to the PF's array of physical ports */ app_fw_nic->ports[i] = hw; @@ -1067,7 +1067,7 @@ nfp_secondary_init_app_fw_nic(struct rte_pci_device *pci_dev, } eth_dev->process_private = cpp; - hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + hw = eth_dev->data->dev_private; nfp_net_ethdev_ops_mount(hw, eth_dev); rte_eth_dev_probing_finish(eth_dev); diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index e24fec861d..cb8a37bce7 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -66,7 +66,7 @@ nfp_netvf_start(struct rte_eth_dev *dev) new_ctrl = nfp_check_offloads(dev); /* Writing configuration parameters in the device */ - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; nfp_net_params_setup(net_hw); @@ -258,7 +258,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) return -ENODEV; } - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; net_hw->dev_info = dev_info; hw = &net_hw->super; @@ -393,7 +393,7 @@ static int nfp_vf_pci_probe(struct rte_pci_device *pci_dev) { return rte_eth_dev_pci_generic_probe(pci_dev, - sizeof(struct nfp_net_adapter), nfp_netvf_init); + sizeof(struct nfp_net_hw), nfp_netvf_init); } static int diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c index 7e26977dc1..9a0ae89af3 100644 --- a/drivers/net/nfp/nfp_ipsec.c +++ b/drivers/net/nfp/nfp_ipsec.c @@ -579,7 +579,7 @@ nfp_aead_map(struct rte_eth_dev *eth_dev, const uint32_t *key; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; device_id = net_hw->device_id; offset = 0; @@ -667,7 +667,7 @@ nfp_cipher_map(struct rte_eth_dev *eth_dev, const uint32_t *key; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; device_id = net_hw->device_id; switch (cipher->algo) { @@ -808,7 +808,7 @@ nfp_auth_map(struct rte_eth_dev *eth_dev, return -EINVAL; } - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; device_id = net_hw->device_id; digest_length = digest_length << 3; @@ -1082,7 +1082,7 @@ nfp_crypto_create_session(void *device, sa_idx = -1; eth_dev = device; priv_session = SECURITY_GET_SESS_PRIV(session); - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; if (net_hw->ipsec_data->sa_free_cnt == 0) { PMD_DRV_LOG(ERR, "No space in SA table, spi: %d", conf->ipsec.spi); @@ -1163,7 +1163,7 @@ nfp_security_set_pkt_metadata(void *device, sqn = params; eth_dev = device; priv_session = SECURITY_GET_SESS_PRIV(session); - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; if (priv_session->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { struct nfp_tx_ipsec_desc_msg *desc_md; @@ -1236,7 +1236,7 @@ nfp_security_session_get_stats(void *device, memset(&msg, 0, sizeof(msg)); msg.cmd = NFP_IPSEC_CFG_MSG_GET_SA_STATS; msg.sa_idx = priv_session->sa_index; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg); if (ret < 0) { @@ -1288,7 +1288,7 @@ nfp_crypto_remove_sa(struct rte_eth_dev *eth_dev, struct nfp_ipsec_msg cfg; sa_index = priv_session->sa_index; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; cfg.cmd = NFP_IPSEC_CFG_MSG_INV_SA; cfg.sa_idx = sa_index; @@ -1380,7 +1380,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev) struct nfp_net_hw *net_hw; struct nfp_net_ipsec_data *data; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; cap_extend = net_hw->super.cap_ext; if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) { @@ -1427,7 +1427,7 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev) struct nfp_net_hw *net_hw; struct nfp_ipsec_session *priv_session; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; cap_extend = net_hw->super.cap_ext; if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) { diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index ac97e3bed5..1260b9a3b1 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -252,7 +252,7 @@ nfp_net_configure(struct rte_eth_dev *dev) struct rte_eth_rxmode *rxmode; struct rte_eth_txmode *txmode; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; dev_conf = &dev->data->dev_conf; rxmode = &dev_conf->rxmode; txmode = &dev_conf->txmode; @@ -329,7 +329,7 @@ nfp_net_enable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_enable_queues(&hw->super, dev->data->nb_rx_queues, dev->data->nb_tx_queues); @@ -340,7 +340,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; nfp_disable_queues(&net_hw->super); } @@ -367,7 +367,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 && (hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) { @@ -407,7 +407,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev, return -ENOMEM; } - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) { PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO"); @@ -443,7 +443,7 @@ nfp_check_offloads(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_eth_conf *dev_conf; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; cap = hw->super.cap; dev_conf = &dev->data->dev_conf; @@ -516,7 +516,7 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev) repr = dev->data->dev_private; net_hw = repr->app_fw_flower->pf_hw; } else { - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; } hw = &net_hw->super; @@ -551,7 +551,7 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -588,7 +588,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; memset(&link, 0, sizeof(struct rte_eth_link)); @@ -654,7 +654,7 @@ nfp_net_stats_get(struct rte_eth_dev *dev, if (stats == NULL) return -EINVAL; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); @@ -732,7 +732,7 @@ nfp_net_stats_reset(struct rte_eth_dev *dev) uint16_t i; struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; /* Reading per RX ring stats */ for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -794,7 +794,7 @@ nfp_net_xstats_size(const struct rte_eth_dev *dev) const uint32_t size = RTE_DIM(nfp_net_xstats); /* If the device is a VF, then there will be no MAC stats */ - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (hw->mac_stats == NULL) { for (count = 0; count < size; count++) { if (nfp_net_xstats[count].group == NFP_XSTAT_GROUP_MAC) @@ -828,7 +828,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct nfp_xstat xstat; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; xstat = nfp_net_xstats[index]; if (xstat.group == NFP_XSTAT_GROUP_MAC) @@ -967,7 +967,7 @@ nfp_net_xstats_reset(struct rte_eth_dev *dev) uint32_t read_size; struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; read_size = nfp_net_xstats_size(dev); for (id = 0; id < read_size; id++) { @@ -1015,7 +1015,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint16_t max_tx_desc; struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); @@ -1242,7 +1242,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_UNMASKED); return 0; @@ -1263,7 +1263,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX); return 0; @@ -1301,7 +1301,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; pci_dev = RTE_ETH_DEV_TO_PCI(dev); /* Make sure all updates are written before un-masking */ @@ -1376,7 +1376,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; /* MTU setting is forbidden if port is started */ if (dev->data->dev_started) { @@ -1412,9 +1412,8 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t rxvlan_ctrl = 0; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; - rx_offload = dev->data->dev_conf.rxmode.offloads; new_ctrl = hw->ctrl; @@ -1463,7 +1462,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { @@ -1519,7 +1518,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1552,7 +1551,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1602,7 +1601,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t cfg_rss_ctrl = 0; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; /* Writing the key byte by byte */ @@ -1658,7 +1657,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; rss_hf = rss_conf->rss_hf; @@ -1699,7 +1698,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, uint32_t cfg_rss_ctrl; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1987,7 +1986,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, if (fw_size < FW_VER_LEN) return FW_VER_LEN; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 6607175460..a23b5be968 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -238,9 +238,6 @@ int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); -#define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ - (&((struct nfp_net_adapter *)adapter)->hw) - #define NFP_NET_DEV_PRIVATE_TO_PF(dev_priv)\ (((struct nfp_net_hw *)dev_priv)->pf_dev) diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c index 5135a1ad27..ea14b98924 100644 --- a/drivers/net/nfp/nfp_net_ctrl.c +++ b/drivers/net/nfp/nfp_net_ctrl.c @@ -31,7 +31,7 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev) struct nfp_net_hw *net_hw; struct nfp_net_tlv_caps *caps; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; caps = &net_hw->tlv_caps; nfp_net_tlv_caps_reset(caps); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 644be2700e..38ce83aa46 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -840,7 +840,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_rxq *rxq; const struct rte_memzone *tz; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); @@ -1067,7 +1067,7 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 05/11] net/nfp: remove the redundancy macro 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (3 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 06/11] net/nfp: remove redundancy logic of init control BAR Chaoyong He ` (6 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Macro 'NFP_HASH_OFFSET' and 'NFP_HASH_TYPE_OFFSET' are unused, so remove them. Macro 'NFP_MAX_PHYPORTS' and 'MAX_FLOWER_PHYPORTS' are redundancy, so just keep the first one. Macro 'NFP_NET_CFG_SPARE_ADDR', 'NFP_NET_CFG_RX_OFFSET_ADDR' and 'NFP_NET_CFG_RX_OFFSET' are redundancy, we just keep the final one. Remove the unneeded macro 'NFP_NET_DEV_PRIVATE_TO_PF', and adjust the related logic, to make it easier to read. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/common/nfp/nfp_common_ctrl.h | 17 ----------------- drivers/net/nfp/flower/nfp_flower.h | 3 +-- drivers/net/nfp/nfp_ethdev.c | 12 ++++-------- drivers/net/nfp/nfp_net_common.c | 2 +- drivers/net/nfp/nfp_net_common.h | 3 --- drivers/net/nfp/nfp_rxtx.h | 3 --- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h index f92ce50fc0..7033c8ea00 100644 --- a/drivers/common/nfp/nfp_common_ctrl.h +++ b/drivers/common/nfp/nfp_common_ctrl.h @@ -196,11 +196,6 @@ struct nfp_net_fw_ver { #define NFP_NET_CFG_START_TXQ 0x0048 #define NFP_NET_CFG_START_RXQ 0x004c -/* - * NFP-3200 workaround (0x0050 - 0x0058) - * @NFP_NET_CFG_SPARE_ADDR: DMA address for ME code to use (e.g. YDS-155 fix) - */ -#define NFP_NET_CFG_SPARE_ADDR 0x0050 /* * NFP6000/NFP4000 - Prepend configuration */ @@ -210,18 +205,6 @@ struct nfp_net_fw_ver { /* Start anchor of the TLV area */ #define NFP_NET_CFG_TLV_BASE 0x0058 -/** - * Reuse spare address to contain the offset from the start of - * the host buffer where the first byte of the received frame - * will land. Any metadata will come prior to that offset. If the - * value in this field is 0, it means that the metadata will - * always land starting at the first byte of the host buffer and - * packet data will immediately follow the metadata. As always, - * the RX descriptor indicates the presence or absence of metadata - * along with the length thereof. - */ -#define NFP_NET_CFG_RX_OFFSET_ADDR 0x0050 - #define NFP_NET_CFG_VXLAN_PORT 0x0060 #define NFP_NET_CFG_VXLAN_SZ 0x0008 diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index 7d442e3cb2..a989c4a8b8 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -31,7 +31,6 @@ */ #define FLOWER_PKT_DATA_OFFSET (NFP_NET_META_HEADER_SIZE + NFP_NET_META_FIELD_SIZE) -#define MAX_FLOWER_PHYPORTS 8 #define MAX_FLOWER_VFS 64 /* Forward declaration */ @@ -78,7 +77,7 @@ struct nfp_app_fw_flower { uint64_t ctrl_vnic_tx_count; /** Array of phyport representors */ - struct nfp_flower_representor *phy_reprs[MAX_FLOWER_PHYPORTS]; + struct nfp_flower_representor *phy_reprs[NFP_MAX_PHYPORTS]; /** Array of VF representors */ struct nfp_flower_representor *vf_reprs[MAX_FLOWER_VFS]; diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 8e69fa67b2..7c5b780e82 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -56,7 +56,7 @@ nfp_net_start(struct rte_eth_dev *dev) struct rte_intr_handle *intr_handle = pci_dev->intr_handle; net_hw = dev->data->dev_private; - pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); + pf_dev = net_hw->pf_dev; app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); hw = &net_hw->super; @@ -261,8 +261,8 @@ nfp_net_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); hw = dev->data->dev_private; + pf_dev = hw->pf_dev; pci_dev = RTE_ETH_DEV_TO_PCI(dev); app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); @@ -482,9 +482,10 @@ nfp_net_init(struct rte_eth_dev *eth_dev) struct nfp_app_fw_nic *app_fw_nic; pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); + net_hw = eth_dev->data->dev_private; /* Use backpointer here to the PF of this eth_dev */ - pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(eth_dev->data->dev_private); + pf_dev = net_hw->pf_dev; /* Use backpointer to the CoreNIC app struct */ app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); @@ -495,11 +496,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev) return -ENODEV; } - /* - * Use PF array of physical ports to get pointer to - * this specific port. - */ - net_hw = app_fw_nic->ports[port]; hw = &net_hw->super; PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, " diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 1260b9a3b1..e3c3fa9985 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -1172,7 +1172,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev, if (hw->ver.major < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else - hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR); + hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET); hw->super.ctrl = 0; hw->stride_rx = stride; diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index a23b5be968..829e9c5333 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -238,9 +238,6 @@ int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); -#define NFP_NET_DEV_PRIVATE_TO_PF(dev_priv)\ - (((struct nfp_net_hw *)dev_priv)->pf_dev) - #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index 956cc7a0d2..ff1019b690 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -10,9 +10,6 @@ #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK) -#define NFP_HASH_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4) -#define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8) - #define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \ ((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM)) -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 06/11] net/nfp: remove redundancy logic of init control BAR 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (4 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 05/11] net/nfp: remove the redundancy macro Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 07/11] net/nfp: use the DPDK defined function Chaoyong He ` (5 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang There are two initialize statements of control BAR in 'nfp_net_init()' and the first one is unneeded, and what it really use is the check of NULL value of the 'mem_resource'. So we move the check of 'mem_resource' to the start of probe logic. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 7c5b780e82..8057452799 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -503,12 +503,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev) rte_eth_copy_pci_info(eth_dev, pci_dev); - hw->ctrl_bar = pci_dev->mem_resource[0].addr; - if (hw->ctrl_bar == NULL) { - PMD_DRV_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured"); - return -ENODEV; - } - if (port == 0) { uint32_t min_size; @@ -890,6 +884,11 @@ nfp_pf_init(struct rte_pci_device *pci_dev) if (pci_dev == NULL) return -ENODEV; + if (pci_dev->mem_resource[0].addr == NULL) { + PMD_INIT_LOG(ERR, "The address of BAR0 is NULL."); + return -ENODEV; + } + dev_info = nfp_dev_info_get(pci_dev->id.device_id); if (dev_info == NULL) { PMD_INIT_LOG(ERR, "Not supported device ID"); @@ -1089,6 +1088,11 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) if (pci_dev == NULL) return -ENODEV; + if (pci_dev->mem_resource[0].addr == NULL) { + PMD_INIT_LOG(ERR, "The address of BAR0 is NULL."); + return -ENODEV; + } + dev_info = nfp_dev_info_get(pci_dev->id.device_id); if (dev_info == NULL) { PMD_INIT_LOG(ERR, "Not supported device ID"); -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 07/11] net/nfp: use the DPDK defined function 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (5 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 06/11] net/nfp: remove redundancy logic of init control BAR Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 08/11] net/nfp: replace hard coded value Chaoyong He ` (4 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Use the DPDK defined function to replace the user defined macro, to make the logic more standard. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower_ctrl.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 4 ++-- drivers/net/nfp/nfp_rxtx.h | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index d19b60bc69..c25487c277 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -109,7 +109,7 @@ nfp_flower_ctrl_vnic_recv(void *rx_queue, /* Now resetting and updating the descriptor */ rxds->vals[0] = 0; rxds->vals[1] = 0; - dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(new_mb)); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rxds->fld.dd = 0; rxds->fld.dma_addr_hi = (dma_addr >> 32) & 0xffff; rxds->fld.dma_addr_lo = dma_addr & 0xffffffff; diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 38ce83aa46..be1ac32c73 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -184,7 +184,7 @@ nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq) return -ENOMEM; } - dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(mbuf)); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); rxd = &rxq->rxds[i]; rxd->fld.dd = 0; @@ -752,7 +752,7 @@ nfp_net_recv_pkts(void *rx_queue, /* Now resetting and updating the descriptor */ rxds->vals[0] = 0; rxds->vals[1] = 0; - dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(new_mb)); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rxds->fld.dd = 0; rxds->fld.dma_addr_hi = (dma_addr >> 32) & 0xffff; rxds->fld.dma_addr_lo = dma_addr & 0xffffffff; diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index ff1019b690..5695a31636 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -10,9 +10,6 @@ #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK) -#define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \ - ((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM)) - /* Maximum number of NFP packet metadata fields. */ #define NFP_META_MAX_FIELDS 8 -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 08/11] net/nfp: replace hard coded value 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (6 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 07/11] net/nfp: use the DPDK defined function Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 09/11] net/nfp: unify the PMD name with macro Chaoyong He ` (3 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Replace the hard coded value with meaningful macro to make it more readable. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 4013b32fd0..8effe9474d 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -13,7 +13,8 @@ static char* nfp_flower_cmsg_get_data(struct rte_mbuf *m) { - return rte_pktmbuf_mtod_offset(m, char *, 4 + 4 + NFP_FLOWER_CMSG_HLEN); + return rte_pktmbuf_mtod_offset(m, char *, NFP_NET_META_HEADER_SIZE + + NFP_NET_META_FIELD_SIZE + NFP_FLOWER_CMSG_HLEN); } static void * -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 09/11] net/nfp: unify the PMD name with macro 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (7 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 08/11] net/nfp: replace hard coded value Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 10/11] net/nfp: extract a helper function Chaoyong He ` (2 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Unify the PMD name with a string macro, make it more extendable. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 8 +++++--- drivers/net/nfp/nfp_ethdev_vf.c | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 8057452799..c4a36027b9 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -21,6 +21,8 @@ #include "nfp_ipsec.h" #include "nfp_logs.h" +#define NFP_PF_DRIVER_NAME net_nfp_pf + static void nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, uint16_t port) @@ -1233,6 +1235,6 @@ static struct rte_pci_driver rte_nfp_net_pf_pmd = { .remove = eth_nfp_pci_remove, }; -RTE_PMD_REGISTER_PCI(net_nfp_pf, rte_nfp_net_pf_pmd); -RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map); -RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio"); +RTE_PMD_REGISTER_PCI(NFP_PF_DRIVER_NAME, rte_nfp_net_pf_pmd); +RTE_PMD_REGISTER_PCI_TABLE(NFP_PF_DRIVER_NAME, pci_id_nfp_pf_net_map); +RTE_PMD_REGISTER_KMOD_DEP(NFP_PF_DRIVER_NAME, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index cb8a37bce7..d0834ccb3e 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -15,6 +15,8 @@ #include "nfp_logs.h" #include "nfp_net_common.h" +#define NFP_VF_DRIVER_NAME net_nfp_vf + static int nfp_netvf_start(struct rte_eth_dev *dev) { @@ -416,5 +418,5 @@ RTE_INIT(rte_nfp_vf_pmd_init) nfp_class_driver_register(&rte_nfp_net_vf_pmd); } -RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map); -RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio"); +RTE_PMD_REGISTER_PCI_TABLE(NFP_VF_DRIVER_NAME, pci_id_nfp_vf_net_map); +RTE_PMD_REGISTER_KMOD_DEP(NFP_VF_DRIVER_NAME, "* igb_uio | uio_pci_generic | vfio"); -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 10/11] net/nfp: extract a helper function 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (8 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 09/11] net/nfp: unify the PMD name with macro Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:15 ` [PATCH 11/11] net/nfp: remove the redundancy logic of representor port Chaoyong He 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Extract a helper function to get the pointer of 'struct nfp_net_hw' for both normal port and representor pot, this will make the operation function can be used for both type port. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 64 ++----------------------- drivers/net/nfp/nfp_net_common.c | 74 ++++++++++++++++------------- drivers/net/nfp/nfp_net_common.h | 1 + 3 files changed, 47 insertions(+), 92 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 246dd2d454..0727e7fd9f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -21,62 +21,6 @@ #define CTRL_VNIC_NB_DESC 512 -static void -nfp_pf_repr_enable_queues(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_hw *hw; - uint64_t enabled_queues = 0; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = &repr->app_fw_flower->pf_hw->super; - - /* Enabling the required TX queues in the device */ - for (i = 0; i < dev->data->nb_tx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues); - - enabled_queues = 0; - - /* Enabling the required RX queues in the device */ - for (i = 0; i < dev->data->nb_rx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues); -} - -static void -nfp_pf_repr_disable_queues(struct rte_eth_dev *dev) -{ - uint32_t update; - uint32_t new_ctrl; - struct nfp_hw *hw; - struct nfp_net_hw *net_hw; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - net_hw = repr->app_fw_flower->pf_hw; - hw = &net_hw->super; - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0); - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0); - - new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE; - update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING | - NFP_NET_CFG_UPDATE_MSIX; - - if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG) - new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG; - - /* If an error when reconfig we avoid to change hw state */ - if (nfp_reconfig(hw, new_ctrl, update) < 0) - return; - - hw->ctrl = new_ctrl; -} - int nfp_flower_pf_start(struct rte_eth_dev *dev) { @@ -93,10 +37,10 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) hw = &net_hw->super; /* Disabling queues just in case... */ - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Enabling the required queues in the device */ - nfp_pf_repr_enable_queues(dev); + nfp_net_enable_queues(dev); new_ctrl = nfp_check_offloads(dev); @@ -157,7 +101,7 @@ nfp_flower_pf_stop(struct rte_eth_dev *dev) repr = dev->data->dev_private; hw = repr->app_fw_flower->pf_hw; - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Clear queues */ for (i = 0; i < dev->data->nb_tx_queues; i++) { @@ -207,7 +151,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev) * We assume that the DPDK application is stopping all the * threads/queues before calling the device close function. */ - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Clear queues */ for (i = 0; i < dev->data->nb_tx_queues; i++) { diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index e3c3fa9985..6abd91965c 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -233,6 +233,22 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw, return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET); } +struct nfp_net_hw * +nfp_net_get_hw(const struct rte_eth_dev *dev) +{ + struct nfp_net_hw *hw; + + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + struct nfp_flower_representor *repr; + repr = dev->data->dev_private; + hw = repr->app_fw_flower->pf_hw; + } else { + hw = dev->data->dev_private; + } + + return hw; +} + /* * Configure an Ethernet device. * @@ -252,7 +268,7 @@ nfp_net_configure(struct rte_eth_dev *dev) struct rte_eth_rxmode *rxmode; struct rte_eth_txmode *txmode; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); dev_conf = &dev->data->dev_conf; rxmode = &dev_conf->rxmode; txmode = &dev_conf->txmode; @@ -329,7 +345,7 @@ nfp_net_enable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_enable_queues(&hw->super, dev->data->nb_rx_queues, dev->data->nb_tx_queues); @@ -340,7 +356,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); nfp_disable_queues(&net_hw->super); } @@ -367,7 +383,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 && (hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) { @@ -407,7 +423,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev, return -ENOMEM; } - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) { PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO"); @@ -443,7 +459,7 @@ nfp_check_offloads(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_eth_conf *dev_conf; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); cap = hw->super.cap; dev_conf = &dev->data->dev_conf; @@ -510,14 +526,8 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev) uint32_t new_ctrl; struct nfp_hw *hw; struct nfp_net_hw *net_hw; - struct nfp_flower_representor *repr; - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { - repr = dev->data->dev_private; - net_hw = repr->app_fw_flower->pf_hw; - } else { - net_hw = dev->data->dev_private; - } + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -551,7 +561,7 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -588,7 +598,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); memset(&link, 0, sizeof(struct rte_eth_link)); @@ -654,7 +664,7 @@ nfp_net_stats_get(struct rte_eth_dev *dev, if (stats == NULL) return -EINVAL; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); @@ -732,7 +742,7 @@ nfp_net_stats_reset(struct rte_eth_dev *dev) uint16_t i; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); /* Reading per RX ring stats */ for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -794,7 +804,7 @@ nfp_net_xstats_size(const struct rte_eth_dev *dev) const uint32_t size = RTE_DIM(nfp_net_xstats); /* If the device is a VF, then there will be no MAC stats */ - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (hw->mac_stats == NULL) { for (count = 0; count < size; count++) { if (nfp_net_xstats[count].group == NFP_XSTAT_GROUP_MAC) @@ -828,7 +838,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct nfp_xstat xstat; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); xstat = nfp_net_xstats[index]; if (xstat.group == NFP_XSTAT_GROUP_MAC) @@ -967,7 +977,7 @@ nfp_net_xstats_reset(struct rte_eth_dev *dev) uint32_t read_size; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); read_size = nfp_net_xstats_size(dev); for (id = 0; id < read_size; id++) { @@ -1015,7 +1025,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint16_t max_tx_desc; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); @@ -1242,7 +1252,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_UNMASKED); return 0; @@ -1263,7 +1273,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX); return 0; @@ -1301,7 +1311,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); pci_dev = RTE_ETH_DEV_TO_PCI(dev); /* Make sure all updates are written before un-masking */ @@ -1376,7 +1386,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); /* MTU setting is forbidden if port is started */ if (dev->data->dev_started) { @@ -1412,7 +1422,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t rxvlan_ctrl = 0; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; rx_offload = dev->data->dev_conf.rxmode.offloads; new_ctrl = hw->ctrl; @@ -1462,7 +1472,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { @@ -1518,7 +1528,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1551,7 +1561,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1601,7 +1611,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t cfg_rss_ctrl = 0; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; /* Writing the key byte by byte */ @@ -1657,7 +1667,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; rss_hf = rss_conf->rss_hf; @@ -1698,7 +1708,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, uint32_t cfg_rss_ctrl; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 829e9c5333..e242251bc2 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -237,6 +237,7 @@ void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); +struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 11/11] net/nfp: remove the redundancy logic of representor port 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (9 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 10/11] net/nfp: extract a helper function Chaoyong He @ 2023-10-28 6:15 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:15 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Using the helper function, we can remove some redundancy logic of representor port by reusing the functions in common module. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 47 +--- drivers/net/nfp/flower/nfp_flower.h | 1 - .../net/nfp/flower/nfp_flower_representor.c | 253 +----------------- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 28 +- drivers/net/nfp/nfp_net_common.c | 128 +++++---- drivers/net/nfp/nfp_net_common.h | 6 +- drivers/net/nfp/nfp_rxtx.c | 4 +- 9 files changed, 94 insertions(+), 377 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 0727e7fd9f..f2e6eb6a6f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -48,11 +48,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) nfp_net_params_setup(net_hw); update |= NFP_NET_CFG_UPDATE_RSS; - - if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0) - new_ctrl |= NFP_NET_CFG_CTRL_RSS2; - else - new_ctrl |= NFP_NET_CFG_CTRL_RSS; + new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap); /* Enable device */ new_ctrl |= NFP_NET_CFG_CTRL_ENABLE; @@ -62,8 +58,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0) new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG; - nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl); - /* If an error when reconfig we avoid to change hw state */ ret = nfp_reconfig(hw, new_ctrl, update); if (ret != 0) { @@ -88,43 +82,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) return 0; } -/* Stop device: disable rx and tx functions to allow for reconfiguring. */ -int -nfp_flower_pf_stop(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_hw *hw; - struct nfp_net_txq *this_tx_q; - struct nfp_net_rxq *this_rx_q; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - nfp_net_disable_queues(dev); - - /* Clear queues */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); - else - nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); - - return 0; -} - /* Reset and stop device. The device can not be restarted. */ static int nfp_flower_pf_close(struct rte_eth_dev *dev) @@ -188,7 +145,7 @@ static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_configure = nfp_net_configure, .dev_start = nfp_flower_pf_start, - .dev_stop = nfp_flower_pf_stop, + .dev_stop = nfp_net_stop, .dev_close = nfp_flower_pf_close, }; diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index a989c4a8b8..220b714018 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -113,7 +113,6 @@ bool nfp_flower_pf_dispatch_pkts(struct nfp_net_hw *hw, uint16_t nfp_flower_pf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); int nfp_flower_pf_start(struct rte_eth_dev *dev); -int nfp_flower_pf_stop(struct rte_eth_dev *dev); uint32_t nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower, struct rte_mbuf *mbuf, uint32_t port_id); diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index b52c6f514a..0f0e63aae0 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -18,232 +18,23 @@ enum nfp_repr_type { NFP_REPR_TYPE_MAX, /*<< Number of representor types */ }; -static int -nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev, - uint16_t queue_idx, - uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf, - struct rte_mempool *mp) -{ - struct nfp_net_hw *hw; - struct nfp_net_rxq *rxq; - const struct rte_memzone *tz; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - /* Allocating rx queue data structure */ - rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct nfp_net_rxq), - RTE_CACHE_LINE_SIZE, socket_id); - if (rxq == NULL) - return -ENOMEM; - - dev->data->rx_queues[queue_idx] = rxq; - - /* Hw queues mapping based on firmware configuration */ - rxq->qidx = queue_idx; - rxq->fl_qcidx = queue_idx * hw->stride_rx; - rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx); - - /* - * Tracking mbuf size for detecting a potential mbuf overflow due to - * RX offset. - */ - rxq->mem_pool = mp; - rxq->mbuf_size = rxq->mem_pool->elt_size; - rxq->mbuf_size -= (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM); - hw->flbufsz = rxq->mbuf_size; - - rxq->rx_count = nb_desc; - rxq->port_id = dev->data->port_id; - rxq->rx_free_thresh = rx_conf->rx_free_thresh; - - /* - * Allocate RX ring hardware descriptors. A memzone large enough to - * handle the maximum ring size is allocated in order to allow for - * resizing in later calls to the queue setup function. - */ - tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, - sizeof(struct nfp_net_rx_desc) * - hw->dev_info->max_qc_size, - NFP_MEMZONE_ALIGN, socket_id); - if (tz == NULL) { - PMD_DRV_LOG(ERR, "Error allocating rx dma"); - nfp_net_rx_queue_release(dev, queue_idx); - dev->data->rx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - /* Saving physical and virtual addresses for the RX ring */ - rxq->dma = (uint64_t)tz->iova; - rxq->rxds = tz->addr; - - /* Mbuf pointers array for referencing mbufs linked to RX descriptors */ - rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs", - sizeof(*rxq->rxbufs) * nb_desc, - RTE_CACHE_LINE_SIZE, socket_id); - if (rxq->rxbufs == NULL) { - nfp_net_rx_queue_release(dev, queue_idx); - dev->data->rx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - nfp_net_reset_rx_queue(rxq); - rxq->hw = hw; - - /* - * Telling the HW about the physical address of the RX ring and number - * of descriptors in log2 format. - */ - nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma); - nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc)); - - return 0; -} - -static int -nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev, - uint16_t queue_idx, - uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_txconf *tx_conf) -{ - struct nfp_net_hw *hw; - struct nfp_net_txq *txq; - uint16_t tx_free_thresh; - const struct rte_memzone *tz; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - tx_free_thresh = (tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh : - DEFAULT_TX_FREE_THRESH; - if (tx_free_thresh > nb_desc) - return -EINVAL; - - /* Allocating tx queue data structure */ - txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nfp_net_txq), - RTE_CACHE_LINE_SIZE, socket_id); - if (txq == NULL) { - PMD_DRV_LOG(ERR, "Error allocating tx dma"); - return -ENOMEM; - } - - dev->data->tx_queues[queue_idx] = txq; - - /* - * Allocate TX ring hardware descriptors. A memzone large enough to - * handle the maximum ring size is allocated in order to allow for - * resizing in later calls to the queue setup function. - */ - tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx, - sizeof(struct nfp_net_nfd3_tx_desc) * - hw->dev_info->max_qc_size, - NFP_MEMZONE_ALIGN, socket_id); - if (tz == NULL) { - PMD_DRV_LOG(ERR, "Error allocating tx dma"); - nfp_net_tx_queue_release(dev, queue_idx); - dev->data->tx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - txq->tx_count = nb_desc; - txq->tx_free_thresh = tx_free_thresh; - - /* Queue mapping based on firmware configuration */ - txq->qidx = queue_idx; - txq->tx_qcidx = queue_idx * hw->stride_tx; - txq->qcp_q = hw->tx_bar + NFP_QCP_QUEUE_OFF(txq->tx_qcidx); - - txq->port_id = dev->data->port_id; - - /* Saving physical and virtual addresses for the TX ring */ - txq->dma = (uint64_t)tz->iova; - txq->txds = tz->addr; - - /* Mbuf pointers array for referencing mbufs linked to TX descriptors */ - txq->txbufs = rte_zmalloc_socket("txq->txbufs", - sizeof(*txq->txbufs) * nb_desc, - RTE_CACHE_LINE_SIZE, socket_id); - if (txq->txbufs == NULL) { - nfp_net_tx_queue_release(dev, queue_idx); - dev->data->tx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - nfp_net_reset_tx_queue(txq); - txq->hw = hw; - - /* - * Telling the HW about the physical address of the TX ring and number - * of descriptors in log2 format. - */ - nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma); - nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc)); - - return 0; -} - static int nfp_flower_repr_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { int ret; - uint32_t i; uint32_t nn_link_status; struct nfp_net_hw *pf_hw; struct rte_eth_link *link; - struct nfp_eth_table *nfp_eth_table; struct nfp_flower_representor *repr; - static const uint32_t ls_to_ethtool[] = { - [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_1G] = RTE_ETH_SPEED_NUM_1G, - [NFP_NET_CFG_STS_LINK_RATE_10G] = RTE_ETH_SPEED_NUM_10G, - [NFP_NET_CFG_STS_LINK_RATE_25G] = RTE_ETH_SPEED_NUM_25G, - [NFP_NET_CFG_STS_LINK_RATE_40G] = RTE_ETH_SPEED_NUM_40G, - [NFP_NET_CFG_STS_LINK_RATE_50G] = RTE_ETH_SPEED_NUM_50G, - [NFP_NET_CFG_STS_LINK_RATE_100G] = RTE_ETH_SPEED_NUM_100G, - }; - repr = dev->data->dev_private; link = &repr->link; - link->link_speed = RTE_ETH_SPEED_NUM_NONE; - pf_hw = repr->app_fw_flower->pf_hw; - if (link->link_status == RTE_ETH_LINK_UP) { - if (pf_hw->pf_dev != NULL) { - nfp_eth_table = pf_hw->pf_dev->nfp_eth_table; - if (nfp_eth_table != NULL) { - uint32_t speed = nfp_eth_table->ports[pf_hw->idx].speed; - for (i = 0; i < RTE_DIM(ls_to_ethtool); i++) { - if (ls_to_ethtool[i] == speed) { - link->link_speed = speed; - break; - } - } - } - } else { - nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS); - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & - NFP_NET_CFG_STS_LINK_RATE_MASK; - - if (nn_link_status < RTE_DIM(ls_to_ethtool)) - link->link_speed = ls_to_ethtool[nn_link_status]; - } - } + pf_hw = repr->app_fw_flower->pf_hw; + nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS); - ret = rte_eth_linkstatus_set(dev, link); - if (ret == 0) { - if (link->link_status) - PMD_DRV_LOG(INFO, "NIC Link is Up"); - else - PMD_DRV_LOG(INFO, "NIC Link is Down"); - } + ret = nfp_net_link_update_common(dev, pf_hw, link, nn_link_status); return ret; } @@ -275,30 +66,6 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev, return 0; } -static int -nfp_flower_repr_dev_configure(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *pf_hw; - struct rte_eth_conf *dev_conf; - struct rte_eth_rxmode *rxmode; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - pf_hw = repr->app_fw_flower->pf_hw; - - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - - /* Checking MTU set */ - if (rxmode->mtu > pf_hw->flbufsz) { - PMD_DRV_LOG(INFO, "MTU (%u) larger then current mbufsize (%u) not supported", - rxmode->mtu, pf_hw->flbufsz); - return -ERANGE; - } - - return 0; -} - static int nfp_flower_repr_dev_start(struct rte_eth_dev *dev) { @@ -528,11 +295,11 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_pf_start, - .dev_configure = nfp_flower_repr_dev_configure, - .dev_stop = nfp_flower_pf_stop, + .dev_configure = nfp_net_configure, + .dev_stop = nfp_net_stop, - .rx_queue_setup = nfp_pf_repr_rx_queue_setup, - .tx_queue_setup = nfp_pf_repr_tx_queue_setup, + .rx_queue_setup = nfp_net_rx_queue_setup, + .tx_queue_setup = nfp_net_tx_queue_setup, .link_update = nfp_flower_repr_link_update, @@ -543,14 +310,14 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .promiscuous_disable = nfp_net_promisc_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, - .fw_version_get = nfp_repr_firmware_version_get, + .fw_version_get = nfp_net_firmware_version_get, }; static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_repr_dev_start, - .dev_configure = nfp_flower_repr_dev_configure, + .dev_configure = nfp_net_configure, .dev_stop = nfp_flower_repr_dev_stop, .rx_queue_setup = nfp_flower_repr_rx_queue_setup, @@ -565,7 +332,7 @@ static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .promiscuous_disable = nfp_net_promisc_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, - .fw_version_get = nfp_repr_firmware_version_get, + .fw_version_get = nfp_net_firmware_version_get, .flow_ops_get = nfp_net_flow_ops_get, .mtr_ops_get = nfp_net_mtr_ops_get, diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index 3f9909c6e0..ff9b10f046 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -377,7 +377,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_free_thresh; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index fe87ea3e25..1f330b7bb6 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -454,7 +454,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_txq *txq; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index c4a36027b9..69050e03f5 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -51,7 +51,6 @@ nfp_net_start(struct rte_eth_dev *dev) uint32_t ctrl_extend = 0; struct nfp_net_hw *net_hw; struct nfp_pf_dev *pf_dev; - struct rte_eth_conf *dev_conf; struct rte_eth_rxmode *rxmode; struct nfp_app_fw_nic *app_fw_nic; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); @@ -113,9 +112,7 @@ nfp_net_start(struct rte_eth_dev *dev) /* Writing configuration parameters in the device */ nfp_net_params_setup(net_hw); - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - + rxmode = &dev->data->dev_conf.rxmode; if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) { nfp_net_rss_config_default(dev); update |= NFP_NET_CFG_UPDATE_RSS; @@ -197,29 +194,6 @@ nfp_net_start(struct rte_eth_dev *dev) return ret; } -/* Stop device: disable rx and tx functions to allow for reconfiguring. */ -static int -nfp_net_stop(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - - hw = dev->data->dev_private; - - nfp_net_disable_queues(dev); - - /* Clear queues */ - nfp_net_stop_tx_queue(dev); - nfp_net_stop_rx_queue(dev); - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); - else - nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); - - return 0; -} - /* Set the link up. */ static int nfp_net_set_link_up(struct rte_eth_dev *dev) diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 6abd91965c..13dd952754 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -581,43 +581,27 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) return 0; } -/* - * Return 0 means link status changed, -1 means not changed - * - * Wait to complete is needed as it can take up to 9 seconds to get the Link - * status. - */ int -nfp_net_link_update(struct rte_eth_dev *dev, - __rte_unused int wait_to_complete) +nfp_net_link_update_common(struct rte_eth_dev *dev, + struct nfp_net_hw *hw, + struct rte_eth_link *link, + uint32_t link_status) { int ret; uint32_t i; - struct nfp_net_hw *hw; uint32_t nn_link_status; - struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = nfp_net_get_hw(dev); - - memset(&link, 0, sizeof(struct rte_eth_link)); + link->link_speed = RTE_ETH_SPEED_NUM_NONE; - /* Read link status */ - nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS); - if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) - link.link_status = RTE_ETH_LINK_UP; - - link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - - if (link.link_status == RTE_ETH_LINK_UP) { + if (link->link_status == RTE_ETH_LINK_UP) { if (hw->pf_dev != NULL) { nfp_eth_table = hw->pf_dev->nfp_eth_table; if (nfp_eth_table != NULL) { uint32_t speed = nfp_eth_table->ports[hw->idx].speed; for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) { if (nfp_net_link_speed_nfp2rte[i] == speed) { - link.link_speed = speed; + link->link_speed = speed; break; } } @@ -627,21 +611,52 @@ nfp_net_link_update(struct rte_eth_dev *dev, * Shift and mask nn_link_status so that it is effectively the value * at offset NFP_NET_CFG_STS_NSP_LINK_RATE. */ - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & + nn_link_status = (link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & NFP_NET_CFG_STS_LINK_RATE_MASK; if (nn_link_status < RTE_DIM(nfp_net_link_speed_nfp2rte)) - link.link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; + link->link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; } } - ret = rte_eth_linkstatus_set(dev, &link); + ret = rte_eth_linkstatus_set(dev, link); if (ret == 0) { - if (link.link_status != 0) + if (link->link_status != 0) PMD_DRV_LOG(INFO, "NIC Link is Up"); else PMD_DRV_LOG(INFO, "NIC Link is Down"); } + return ret; +} + +/* + * Return 0 means link status changed, -1 means not changed + * + * Wait to complete is needed as it can take up to 9 seconds to get the Link + * status. + */ +int +nfp_net_link_update(struct rte_eth_dev *dev, + __rte_unused int wait_to_complete) +{ + int ret; + struct nfp_net_hw *hw; + uint32_t nn_link_status; + struct rte_eth_link link; + + hw = nfp_net_get_hw(dev); + + memset(&link, 0, sizeof(struct rte_eth_link)); + + /* Read link status */ + nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS); + if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) + link.link_status = RTE_ETH_LINK_UP; + + link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; + + ret = nfp_net_link_update_common(dev, hw, &link, nn_link_status); + /* * Notify the port to update the speed value in the CTRL BAR from NSP. * Not applicable for VFs as the associated PF is still attached to the @@ -1996,11 +2011,16 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, if (fw_size < FW_VER_LEN) return FW_VER_LEN; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); - snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", + + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, hw->ver.major, hw->ver.minor); + } else { + snprintf(vnic_version, FW_VER_LEN, "*"); + } nfp_net_get_nsp_info(hw, nsp_version); nfp_net_get_mip_name(hw, mip_name); @@ -2012,33 +2032,6 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, return 0; } -int -nfp_repr_firmware_version_get(struct rte_eth_dev *dev, - char *fw_version, - size_t fw_size) -{ - struct nfp_net_hw *hw; - char mip_name[FW_VER_LEN]; - char app_name[FW_VER_LEN]; - char nsp_version[FW_VER_LEN]; - struct nfp_flower_representor *repr; - - if (fw_size < FW_VER_LEN) - return FW_VER_LEN; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - nfp_net_get_nsp_info(hw, nsp_version); - nfp_net_get_mip_name(hw, mip_name); - nfp_net_get_app_name(hw, app_name); - - snprintf(fw_version, FW_VER_LEN, "* %s %s %s", - nsp_version, mip_name, app_name); - - return 0; -} - bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) { @@ -2059,3 +2052,26 @@ nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) return false; } + +/* Disable rx and tx functions to allow for reconfiguring. */ +int +nfp_net_stop(struct rte_eth_dev *dev) +{ + struct nfp_net_hw *hw; + + hw = nfp_net_get_hw(dev); + + nfp_net_disable_queues(dev); + + /* Clear queues */ + nfp_net_stop_tx_queue(dev); + nfp_net_stop_rx_queue(dev); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + /* Configure the physical port down */ + nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); + else + nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); + + return 0; +} diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index e242251bc2..af8f8d15ae 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -178,6 +178,10 @@ int nfp_configure_rx_interrupt(struct rte_eth_dev *dev, uint32_t nfp_check_offloads(struct rte_eth_dev *dev); int nfp_net_promisc_enable(struct rte_eth_dev *dev); int nfp_net_promisc_disable(struct rte_eth_dev *dev); +int nfp_net_link_update_common(struct rte_eth_dev *dev, + struct nfp_net_hw *hw, + struct rte_eth_link *link, + uint32_t link_status); int nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); @@ -235,9 +239,9 @@ int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); void nfp_net_init_metadata_format(struct nfp_net_hw *hw); void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); -int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev); +int nfp_net_stop(struct rte_eth_dev *dev); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index be1ac32c73..b2a9ba6875 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -840,7 +840,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_rxq *rxq; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); @@ -1067,7 +1067,7 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 00/11] Clean up NFP PMD 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He ` (10 preceding siblings ...) 2023-10-28 6:15 ` [PATCH 11/11] net/nfp: remove the redundancy logic of representor port Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 01/11] net/nfp: use the suitable helper macro Chaoyong He ` (11 more replies) 11 siblings, 12 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He This patch series clean up the NFP PMD, by: - Using the DPDK macro and API to replace the user defined ones. - Remove the unneeded macro and logic. - Remove the duplicated logic. --- v2: * Fix the compile error. * Fix one check script warning. --- Chaoyong He (11): net/nfp: use the suitable helper macro net/nfp: remove the unneeded call of underlying API net/nfp: remove the unneeded check of process type net/nfp: remove the unneeded data abstraction net/nfp: remove the redundancy macro net/nfp: remove redundancy logic of init control BAR net/nfp: use the DPDK defined function net/nfp: replace hard coded value net/nfp: unify the PMD name with macro net/nfp: extract a helper function net/nfp: remove the redundancy logic of representor port drivers/common/nfp/nfp_common_ctrl.h | 17 -- drivers/net/nfp/flower/nfp_flower.c | 111 +------- drivers/net/nfp/flower/nfp_flower.h | 4 +- drivers/net/nfp/flower/nfp_flower_cmsg.c | 3 +- drivers/net/nfp/flower/nfp_flower_ctrl.c | 6 +- .../net/nfp/flower/nfp_flower_representor.c | 253 +----------------- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 88 +++--- drivers/net/nfp/nfp_ethdev_vf.c | 28 +- drivers/net/nfp/nfp_ipsec.c | 18 +- drivers/net/nfp/nfp_net_common.c | 204 +++++++------- drivers/net/nfp/nfp_net_common.h | 13 +- drivers/net/nfp/nfp_net_ctrl.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 11 +- drivers/net/nfp/nfp_rxtx.h | 6 - 16 files changed, 203 insertions(+), 565 deletions(-) -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 01/11] net/nfp: use the suitable helper macro 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 02/11] net/nfp: remove the unneeded call of underlying API Chaoyong He ` (10 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Replace the `rte_pktmbuf_mtod()` macro to with the more suitable `rte_pktmbuf_mtod_offset()`. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 2 +- drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++-- drivers/net/nfp/nfp_rxtx.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 2ec9498d22..4013b32fd0 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -13,7 +13,7 @@ static char* nfp_flower_cmsg_get_data(struct rte_mbuf *m) { - return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN; + return rte_pktmbuf_mtod_offset(m, char *, 4 + 4 + NFP_FLOWER_CMSG_HLEN); } static void * diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index b4be28ccdf..d19b60bc69 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -375,7 +375,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv, uint32_t ctx_id; struct nfp_flower_stats_frame *stats; - msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN; + msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN); msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN; count = msg_len / sizeof(struct nfp_flower_stats_frame); @@ -398,7 +398,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv, struct nfp_mtr *mtr; struct nfp_mtr_stats_reply *mtr_stats; - msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN; + msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN); mtr_stats = (struct nfp_mtr_stats_reply *)msg; profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index fc94e5f0b9..644be2700e 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -448,8 +448,7 @@ nfp_net_parse_meta(struct nfp_net_rx_desc *rxds, if (unlikely(NFP_DESC_META_LEN(rxds) == 0)) return; - meta_base = rte_pktmbuf_mtod(mb, uint8_t *); - meta_base -= NFP_DESC_META_LEN(rxds); + meta_base = rte_pktmbuf_mtod_offset(mb, uint8_t *, -NFP_DESC_META_LEN(rxds)); meta_header = *(rte_be32_t *)meta_base; switch (hw->meta_format) { -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 02/11] net/nfp: remove the unneeded call of underlying API 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He 2023-10-28 6:53 ` [PATCH v2 01/11] net/nfp: use the suitable helper macro Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 03/11] net/nfp: remove the unneeded check of process type Chaoyong He ` (9 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Remove the unneeded call of underlying API in function 'nfp_net_pf_read_mac()`, because we already store the result of it in data structure. Also change the return type of this function to 'void' as there is no abnormal exit logic. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 76317925ec..0fed0ef72d 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -21,7 +21,7 @@ #include "nfp_ipsec.h" #include "nfp_logs.h" -static int +static void nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, uint16_t port) { @@ -31,13 +31,9 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, /* Grab a pointer to the correct physical port */ hw = app_fw_nic->ports[port]; - nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp); + nfp_eth_table = app_fw_nic->pf_dev->nfp_eth_table; rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->super.mac_addr); - - free(nfp_eth_table); - - return 0; } static int -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 03/11] net/nfp: remove the unneeded check of process type 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He 2023-10-28 6:53 ` [PATCH v2 01/11] net/nfp: use the suitable helper macro Chaoyong He 2023-10-28 6:53 ` [PATCH v2 02/11] net/nfp: remove the unneeded call of underlying API Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He ` (8 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Remove the unneeded secondary call of 'rte_eal_process_type()' in 'nfp_netvf_init()', because the first call of it already make sure only the primary process can continue run the rest logic. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev_vf.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index b9cfb48021..e24fec861d 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -344,15 +344,13 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) pci_dev->id.device_id, RTE_ETHER_ADDR_BYTES(&hw->mac_addr)); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - /* Registering LSC interrupt handler */ - rte_intr_callback_register(pci_dev->intr_handle, - nfp_net_dev_interrupt_handler, (void *)eth_dev); - /* Telling the firmware about the LSC interrupt entry */ - nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX); - /* Recording current stats counters values */ - nfp_net_stats_reset(eth_dev); - } + /* Registering LSC interrupt handler */ + rte_intr_callback_register(pci_dev->intr_handle, + nfp_net_dev_interrupt_handler, (void *)eth_dev); + /* Telling the firmware about the LSC interrupt entry */ + nn_cfg_writeb(hw, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX); + /* Recording current stats counters values */ + nfp_net_stats_reset(eth_dev); return 0; -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (2 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 03/11] net/nfp: remove the unneeded check of process type Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-11-01 17:57 ` Ferruh Yigit 2023-10-28 6:53 ` [PATCH v2 05/11] net/nfp: remove the redundancy macro Chaoyong He ` (7 subsequent siblings) 11 siblings, 1 reply; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang The data structure 'struct nfp_net_adapter' has only one data field and we won't extend it in the future, which makes this abstraction unneeded, so remove this data structure and the related macro 'NFP_NET_DEV_PRIVATE_TO_HW'. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 2 +- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 18 ++++----- drivers/net/nfp/nfp_ethdev_vf.c | 6 +-- drivers/net/nfp/nfp_ipsec.c | 18 ++++----- drivers/net/nfp/nfp_net_common.c | 57 ++++++++++++++--------------- drivers/net/nfp/nfp_net_common.h | 3 -- drivers/net/nfp/nfp_net_ctrl.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 4 +- 10 files changed, 55 insertions(+), 59 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index f3fedbf7e5..246dd2d454 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -848,7 +848,7 @@ nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev, } /* Allocate memory for the PF AND ctrl vNIC here (hence the * 2) */ - pf_hw = rte_zmalloc_socket("nfp_pf_vnic", 2 * sizeof(struct nfp_net_adapter), + pf_hw = rte_zmalloc_socket("nfp_pf_vnic", 2 * sizeof(struct nfp_net_hw), RTE_CACHE_LINE_SIZE, numa_node); if (pf_hw == NULL) { PMD_INIT_LOG(ERR, "Could not malloc nfp pf vnic"); diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index c85fadc80d..3f9909c6e0 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -377,7 +377,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_free_thresh; const struct rte_memzone *tz; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index 10e6982c95..fe87ea3e25 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -454,7 +454,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_txq *txq; const struct rte_memzone *tz; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 0fed0ef72d..8e69fa67b2 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -55,7 +55,7 @@ nfp_net_start(struct rte_eth_dev *dev) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_intr_handle *intr_handle = pci_dev->intr_handle; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); hw = &net_hw->super; @@ -201,7 +201,7 @@ nfp_net_stop(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_disable_queues(dev); @@ -224,7 +224,7 @@ nfp_net_set_link_up(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ @@ -239,7 +239,7 @@ nfp_net_set_link_down(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (rte_eal_process_type() == RTE_PROC_PRIMARY) /* Configure the physical port down */ @@ -262,7 +262,7 @@ nfp_net_close(struct rte_eth_dev *dev) return 0; pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; pci_dev = RTE_ETH_DEV_TO_PCI(dev); app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); @@ -350,7 +350,7 @@ nfp_udp_tunnel_port_add(struct rte_eth_dev *dev, struct nfp_net_hw *hw; enum rte_eth_tunnel_type tnl_type; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; vxlan_port = tunnel_udp->udp_port; tnl_type = tunnel_udp->prot_type; @@ -388,7 +388,7 @@ nfp_udp_tunnel_port_del(struct rte_eth_dev *dev, struct nfp_net_hw *hw; enum rte_eth_tunnel_type tnl_type; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; vxlan_port = tunnel_udp->udp_port; tnl_type = tunnel_udp->prot_type; @@ -828,7 +828,7 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev, goto port_cleanup; } - hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + hw = eth_dev->data->dev_private; /* Add this device to the PF's array of physical ports */ app_fw_nic->ports[i] = hw; @@ -1067,7 +1067,7 @@ nfp_secondary_init_app_fw_nic(struct rte_pci_device *pci_dev, } eth_dev->process_private = cpp; - hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + hw = eth_dev->data->dev_private; nfp_net_ethdev_ops_mount(hw, eth_dev); rte_eth_dev_probing_finish(eth_dev); diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index e24fec861d..cb8a37bce7 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -66,7 +66,7 @@ nfp_netvf_start(struct rte_eth_dev *dev) new_ctrl = nfp_check_offloads(dev); /* Writing configuration parameters in the device */ - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; nfp_net_params_setup(net_hw); @@ -258,7 +258,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) return -ENODEV; } - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; net_hw->dev_info = dev_info; hw = &net_hw->super; @@ -393,7 +393,7 @@ static int nfp_vf_pci_probe(struct rte_pci_device *pci_dev) { return rte_eth_dev_pci_generic_probe(pci_dev, - sizeof(struct nfp_net_adapter), nfp_netvf_init); + sizeof(struct nfp_net_hw), nfp_netvf_init); } static int diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c index 7e26977dc1..9a0ae89af3 100644 --- a/drivers/net/nfp/nfp_ipsec.c +++ b/drivers/net/nfp/nfp_ipsec.c @@ -579,7 +579,7 @@ nfp_aead_map(struct rte_eth_dev *eth_dev, const uint32_t *key; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; device_id = net_hw->device_id; offset = 0; @@ -667,7 +667,7 @@ nfp_cipher_map(struct rte_eth_dev *eth_dev, const uint32_t *key; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; device_id = net_hw->device_id; switch (cipher->algo) { @@ -808,7 +808,7 @@ nfp_auth_map(struct rte_eth_dev *eth_dev, return -EINVAL; } - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; device_id = net_hw->device_id; digest_length = digest_length << 3; @@ -1082,7 +1082,7 @@ nfp_crypto_create_session(void *device, sa_idx = -1; eth_dev = device; priv_session = SECURITY_GET_SESS_PRIV(session); - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; if (net_hw->ipsec_data->sa_free_cnt == 0) { PMD_DRV_LOG(ERR, "No space in SA table, spi: %d", conf->ipsec.spi); @@ -1163,7 +1163,7 @@ nfp_security_set_pkt_metadata(void *device, sqn = params; eth_dev = device; priv_session = SECURITY_GET_SESS_PRIV(session); - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; if (priv_session->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) { struct nfp_tx_ipsec_desc_msg *desc_md; @@ -1236,7 +1236,7 @@ nfp_security_session_get_stats(void *device, memset(&msg, 0, sizeof(msg)); msg.cmd = NFP_IPSEC_CFG_MSG_GET_SA_STATS; msg.sa_idx = priv_session->sa_index; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; ret = nfp_ipsec_cfg_cmd_issue(net_hw, &msg); if (ret < 0) { @@ -1288,7 +1288,7 @@ nfp_crypto_remove_sa(struct rte_eth_dev *eth_dev, struct nfp_ipsec_msg cfg; sa_index = priv_session->sa_index; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); + net_hw = eth_dev->data->dev_private; cfg.cmd = NFP_IPSEC_CFG_MSG_INV_SA; cfg.sa_idx = sa_index; @@ -1380,7 +1380,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev) struct nfp_net_hw *net_hw; struct nfp_net_ipsec_data *data; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; cap_extend = net_hw->super.cap_ext; if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) { @@ -1427,7 +1427,7 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev) struct nfp_net_hw *net_hw; struct nfp_ipsec_session *priv_session; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; cap_extend = net_hw->super.cap_ext; if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) { diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index ac97e3bed5..10f6298f74 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -252,7 +252,7 @@ nfp_net_configure(struct rte_eth_dev *dev) struct rte_eth_rxmode *rxmode; struct rte_eth_txmode *txmode; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; dev_conf = &dev->data->dev_conf; rxmode = &dev_conf->rxmode; txmode = &dev_conf->txmode; @@ -329,7 +329,7 @@ nfp_net_enable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_enable_queues(&hw->super, dev->data->nb_rx_queues, dev->data->nb_tx_queues); @@ -340,7 +340,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; nfp_disable_queues(&net_hw->super); } @@ -367,7 +367,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 && (hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) { @@ -407,7 +407,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev, return -ENOMEM; } - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) { PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO"); @@ -443,7 +443,7 @@ nfp_check_offloads(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_eth_conf *dev_conf; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; cap = hw->super.cap; dev_conf = &dev->data->dev_conf; @@ -516,7 +516,7 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev) repr = dev->data->dev_private; net_hw = repr->app_fw_flower->pf_hw; } else { - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; } hw = &net_hw->super; @@ -551,7 +551,7 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -588,7 +588,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; memset(&link, 0, sizeof(struct rte_eth_link)); @@ -654,7 +654,7 @@ nfp_net_stats_get(struct rte_eth_dev *dev, if (stats == NULL) return -EINVAL; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); @@ -732,7 +732,7 @@ nfp_net_stats_reset(struct rte_eth_dev *dev) uint16_t i; struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; /* Reading per RX ring stats */ for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -794,7 +794,7 @@ nfp_net_xstats_size(const struct rte_eth_dev *dev) const uint32_t size = RTE_DIM(nfp_net_xstats); /* If the device is a VF, then there will be no MAC stats */ - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (hw->mac_stats == NULL) { for (count = 0; count < size; count++) { if (nfp_net_xstats[count].group == NFP_XSTAT_GROUP_MAC) @@ -828,7 +828,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct nfp_xstat xstat; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; xstat = nfp_net_xstats[index]; if (xstat.group == NFP_XSTAT_GROUP_MAC) @@ -967,7 +967,7 @@ nfp_net_xstats_reset(struct rte_eth_dev *dev) uint32_t read_size; struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; read_size = nfp_net_xstats_size(dev); for (id = 0; id < read_size; id++) { @@ -1015,7 +1015,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint16_t max_tx_desc; struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); @@ -1220,7 +1220,7 @@ nfp_net_supported_ptypes_get(struct rte_eth_dev *dev) if (dev->rx_pkt_burst != nfp_net_recv_pkts) return NULL; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; if ((net_hw->super.cap_ext & NFP_NET_CFG_CTRL_PKT_TYPE) == 0) return NULL; @@ -1242,7 +1242,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_UNMASKED); return 0; @@ -1263,7 +1263,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX); return 0; @@ -1301,7 +1301,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; pci_dev = RTE_ETH_DEV_TO_PCI(dev); /* Make sure all updates are written before un-masking */ @@ -1376,7 +1376,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; /* MTU setting is forbidden if port is started */ if (dev->data->dev_started) { @@ -1412,9 +1412,8 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t rxvlan_ctrl = 0; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; - rx_offload = dev->data->dev_conf.rxmode.offloads; new_ctrl = hw->ctrl; @@ -1463,7 +1462,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { @@ -1519,7 +1518,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1552,7 +1551,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1602,7 +1601,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t cfg_rss_ctrl = 0; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; /* Writing the key byte by byte */ @@ -1658,7 +1657,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; rss_hf = rss_conf->rss_hf; @@ -1699,7 +1698,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, uint32_t cfg_rss_ctrl; struct nfp_net_hw *net_hw; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1987,7 +1986,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, if (fw_size < FW_VER_LEN) return FW_VER_LEN; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 6607175460..a23b5be968 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -238,9 +238,6 @@ int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); -#define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\ - (&((struct nfp_net_adapter *)adapter)->hw) - #define NFP_NET_DEV_PRIVATE_TO_PF(dev_priv)\ (((struct nfp_net_hw *)dev_priv)->pf_dev) diff --git a/drivers/net/nfp/nfp_net_ctrl.c b/drivers/net/nfp/nfp_net_ctrl.c index 5135a1ad27..ea14b98924 100644 --- a/drivers/net/nfp/nfp_net_ctrl.c +++ b/drivers/net/nfp/nfp_net_ctrl.c @@ -31,7 +31,7 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev) struct nfp_net_hw *net_hw; struct nfp_net_tlv_caps *caps; - net_hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + net_hw = dev->data->dev_private; caps = &net_hw->tlv_caps; nfp_net_tlv_caps_reset(caps); diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 644be2700e..38ce83aa46 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -840,7 +840,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_rxq *rxq; const struct rte_memzone *tz; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); @@ -1067,7 +1067,7 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); + hw = dev->data->dev_private; if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction 2023-10-28 6:53 ` [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He @ 2023-11-01 17:57 ` Ferruh Yigit 2023-11-02 1:25 ` Chaoyong He 0 siblings, 1 reply; 27+ messages in thread From: Ferruh Yigit @ 2023-11-01 17:57 UTC (permalink / raw) To: Chaoyong He, dev; +Cc: oss-drivers, Peng Zhang On 10/28/2023 7:53 AM, Chaoyong He wrote: > The data structure 'struct nfp_net_adapter' has only one data field and > we won't extend it in the future, which makes this abstraction unneeded, > so remove this data structure and the related macro > 'NFP_NET_DEV_PRIVATE_TO_HW'. > Mentioned abstract struct, 'struct nfp_net_adapter', is not removed in this patch, although mentioned macro removed. Since there is not user of the struct after this patch, I guess intention was to remove the struct, so if there is no other issue I can remove the struct while merging. > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> > Reviewed-by: Peng Zhang <peng.zhang@corigine.com> ^ permalink raw reply [flat|nested] 27+ messages in thread
* RE: [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction 2023-11-01 17:57 ` Ferruh Yigit @ 2023-11-02 1:25 ` Chaoyong He 0 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-11-02 1:25 UTC (permalink / raw) To: Ferruh Yigit, dev; +Cc: oss-drivers, Nole Zhang > On 10/28/2023 7:53 AM, Chaoyong He wrote: > > The data structure 'struct nfp_net_adapter' has only one data field > > and we won't extend it in the future, which makes this abstraction > > unneeded, so remove this data structure and the related macro > > 'NFP_NET_DEV_PRIVATE_TO_HW'. > > > > Mentioned abstract struct, 'struct nfp_net_adapter', is not removed in this > patch, although mentioned macro removed. Oh, It should be missed when I do rebase, sorry about it. > > Since there is not user of the struct after this patch, I guess intention was to > remove the struct, so if there is no other issue I can remove the struct while > merging. It's nice, thank you very much! > > > > Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> > > Reviewed-by: Peng Zhang <peng.zhang@corigine.com> ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 05/11] net/nfp: remove the redundancy macro 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (3 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 06/11] net/nfp: remove redundancy logic of init control BAR Chaoyong He ` (6 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Macro 'NFP_HASH_OFFSET' and 'NFP_HASH_TYPE_OFFSET' are unused, so remove them. Macro 'NFP_MAX_PHYPORTS' and 'MAX_FLOWER_PHYPORTS' are redundancy, so just keep the first one. Macro 'NFP_NET_CFG_SPARE_ADDR', 'NFP_NET_CFG_RX_OFFSET_ADDR' and 'NFP_NET_CFG_RX_OFFSET' are redundancy, we just keep the final one. Remove the unneeded macro 'NFP_NET_DEV_PRIVATE_TO_PF', and adjust the related logic, to make it easier to read. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/common/nfp/nfp_common_ctrl.h | 17 ----------------- drivers/net/nfp/flower/nfp_flower.h | 3 +-- drivers/net/nfp/nfp_ethdev.c | 12 ++++-------- drivers/net/nfp/nfp_net_common.c | 2 +- drivers/net/nfp/nfp_net_common.h | 3 --- drivers/net/nfp/nfp_rxtx.h | 3 --- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/drivers/common/nfp/nfp_common_ctrl.h b/drivers/common/nfp/nfp_common_ctrl.h index f92ce50fc0..7033c8ea00 100644 --- a/drivers/common/nfp/nfp_common_ctrl.h +++ b/drivers/common/nfp/nfp_common_ctrl.h @@ -196,11 +196,6 @@ struct nfp_net_fw_ver { #define NFP_NET_CFG_START_TXQ 0x0048 #define NFP_NET_CFG_START_RXQ 0x004c -/* - * NFP-3200 workaround (0x0050 - 0x0058) - * @NFP_NET_CFG_SPARE_ADDR: DMA address for ME code to use (e.g. YDS-155 fix) - */ -#define NFP_NET_CFG_SPARE_ADDR 0x0050 /* * NFP6000/NFP4000 - Prepend configuration */ @@ -210,18 +205,6 @@ struct nfp_net_fw_ver { /* Start anchor of the TLV area */ #define NFP_NET_CFG_TLV_BASE 0x0058 -/** - * Reuse spare address to contain the offset from the start of - * the host buffer where the first byte of the received frame - * will land. Any metadata will come prior to that offset. If the - * value in this field is 0, it means that the metadata will - * always land starting at the first byte of the host buffer and - * packet data will immediately follow the metadata. As always, - * the RX descriptor indicates the presence or absence of metadata - * along with the length thereof. - */ -#define NFP_NET_CFG_RX_OFFSET_ADDR 0x0050 - #define NFP_NET_CFG_VXLAN_PORT 0x0060 #define NFP_NET_CFG_VXLAN_SZ 0x0008 diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index 7d442e3cb2..a989c4a8b8 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -31,7 +31,6 @@ */ #define FLOWER_PKT_DATA_OFFSET (NFP_NET_META_HEADER_SIZE + NFP_NET_META_FIELD_SIZE) -#define MAX_FLOWER_PHYPORTS 8 #define MAX_FLOWER_VFS 64 /* Forward declaration */ @@ -78,7 +77,7 @@ struct nfp_app_fw_flower { uint64_t ctrl_vnic_tx_count; /** Array of phyport representors */ - struct nfp_flower_representor *phy_reprs[MAX_FLOWER_PHYPORTS]; + struct nfp_flower_representor *phy_reprs[NFP_MAX_PHYPORTS]; /** Array of VF representors */ struct nfp_flower_representor *vf_reprs[MAX_FLOWER_VFS]; diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 8e69fa67b2..7c5b780e82 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -56,7 +56,7 @@ nfp_net_start(struct rte_eth_dev *dev) struct rte_intr_handle *intr_handle = pci_dev->intr_handle; net_hw = dev->data->dev_private; - pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); + pf_dev = net_hw->pf_dev; app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); hw = &net_hw->super; @@ -261,8 +261,8 @@ nfp_net_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(dev->data->dev_private); hw = dev->data->dev_private; + pf_dev = hw->pf_dev; pci_dev = RTE_ETH_DEV_TO_PCI(dev); app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); @@ -482,9 +482,10 @@ nfp_net_init(struct rte_eth_dev *eth_dev) struct nfp_app_fw_nic *app_fw_nic; pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); + net_hw = eth_dev->data->dev_private; /* Use backpointer here to the PF of this eth_dev */ - pf_dev = NFP_NET_DEV_PRIVATE_TO_PF(eth_dev->data->dev_private); + pf_dev = net_hw->pf_dev; /* Use backpointer to the CoreNIC app struct */ app_fw_nic = NFP_PRIV_TO_APP_FW_NIC(pf_dev->app_fw_priv); @@ -495,11 +496,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev) return -ENODEV; } - /* - * Use PF array of physical ports to get pointer to - * this specific port. - */ - net_hw = app_fw_nic->ports[port]; hw = &net_hw->super; PMD_INIT_LOG(DEBUG, "Working with physical port number: %hu, " diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 10f6298f74..d43a071a42 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -1172,7 +1172,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev, if (hw->ver.major < 2) hw->rx_offset = NFP_NET_RX_OFFSET; else - hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET_ADDR); + hw->rx_offset = nn_cfg_readl(&hw->super, NFP_NET_CFG_RX_OFFSET); hw->super.ctrl = 0; hw->stride_rx = stride; diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index a23b5be968..829e9c5333 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -238,9 +238,6 @@ int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); -#define NFP_NET_DEV_PRIVATE_TO_PF(dev_priv)\ - (((struct nfp_net_hw *)dev_priv)->pf_dev) - #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index 956cc7a0d2..ff1019b690 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -10,9 +10,6 @@ #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK) -#define NFP_HASH_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 4) -#define NFP_HASH_TYPE_OFFSET ((uint8_t *)mbuf->buf_addr + mbuf->data_off - 8) - #define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \ ((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM)) -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 06/11] net/nfp: remove redundancy logic of init control BAR 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (4 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 05/11] net/nfp: remove the redundancy macro Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 07/11] net/nfp: use the DPDK defined function Chaoyong He ` (5 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang There are two initialize statements of control BAR in 'nfp_net_init()' and the first one is unneeded, and what it really use is the check of NULL value of the 'mem_resource'. So we move the check of 'mem_resource' to the start of probe logic. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 7c5b780e82..8057452799 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -503,12 +503,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev) rte_eth_copy_pci_info(eth_dev, pci_dev); - hw->ctrl_bar = pci_dev->mem_resource[0].addr; - if (hw->ctrl_bar == NULL) { - PMD_DRV_LOG(ERR, "hw->ctrl_bar is NULL. BAR0 not configured"); - return -ENODEV; - } - if (port == 0) { uint32_t min_size; @@ -890,6 +884,11 @@ nfp_pf_init(struct rte_pci_device *pci_dev) if (pci_dev == NULL) return -ENODEV; + if (pci_dev->mem_resource[0].addr == NULL) { + PMD_INIT_LOG(ERR, "The address of BAR0 is NULL."); + return -ENODEV; + } + dev_info = nfp_dev_info_get(pci_dev->id.device_id); if (dev_info == NULL) { PMD_INIT_LOG(ERR, "Not supported device ID"); @@ -1089,6 +1088,11 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev) if (pci_dev == NULL) return -ENODEV; + if (pci_dev->mem_resource[0].addr == NULL) { + PMD_INIT_LOG(ERR, "The address of BAR0 is NULL."); + return -ENODEV; + } + dev_info = nfp_dev_info_get(pci_dev->id.device_id); if (dev_info == NULL) { PMD_INIT_LOG(ERR, "Not supported device ID"); -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 07/11] net/nfp: use the DPDK defined function 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (5 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 06/11] net/nfp: remove redundancy logic of init control BAR Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 08/11] net/nfp: replace hard coded value Chaoyong He ` (4 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Use the DPDK defined function to replace the user defined macro, to make the logic more standard. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower_ctrl.c | 2 +- drivers/net/nfp/nfp_rxtx.c | 4 ++-- drivers/net/nfp/nfp_rxtx.h | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c index d19b60bc69..c25487c277 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -109,7 +109,7 @@ nfp_flower_ctrl_vnic_recv(void *rx_queue, /* Now resetting and updating the descriptor */ rxds->vals[0] = 0; rxds->vals[1] = 0; - dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(new_mb)); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rxds->fld.dd = 0; rxds->fld.dma_addr_hi = (dma_addr >> 32) & 0xffff; rxds->fld.dma_addr_lo = dma_addr & 0xffffffff; diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 38ce83aa46..be1ac32c73 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -184,7 +184,7 @@ nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq) return -ENOMEM; } - dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(mbuf)); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); rxd = &rxq->rxds[i]; rxd->fld.dd = 0; @@ -752,7 +752,7 @@ nfp_net_recv_pkts(void *rx_queue, /* Now resetting and updating the descriptor */ rxds->vals[0] = 0; rxds->vals[1] = 0; - dma_addr = rte_cpu_to_le_64(RTE_MBUF_DMA_ADDR_DEFAULT(new_mb)); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(new_mb)); rxds->fld.dd = 0; rxds->fld.dma_addr_hi = (dma_addr >> 32) & 0xffff; rxds->fld.dma_addr_lo = dma_addr & 0xffffffff; diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h index ff1019b690..5695a31636 100644 --- a/drivers/net/nfp/nfp_rxtx.h +++ b/drivers/net/nfp/nfp_rxtx.h @@ -10,9 +10,6 @@ #define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK) -#define RTE_MBUF_DMA_ADDR_DEFAULT(mb) \ - ((uint64_t)((mb)->buf_iova + RTE_PKTMBUF_HEADROOM)) - /* Maximum number of NFP packet metadata fields. */ #define NFP_META_MAX_FIELDS 8 -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 08/11] net/nfp: replace hard coded value 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (6 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 07/11] net/nfp: use the DPDK defined function Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 09/11] net/nfp: unify the PMD name with macro Chaoyong He ` (3 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Replace the hard coded value with meaningful macro to make it more readable. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 4013b32fd0..8effe9474d 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -13,7 +13,8 @@ static char* nfp_flower_cmsg_get_data(struct rte_mbuf *m) { - return rte_pktmbuf_mtod_offset(m, char *, 4 + 4 + NFP_FLOWER_CMSG_HLEN); + return rte_pktmbuf_mtod_offset(m, char *, NFP_NET_META_HEADER_SIZE + + NFP_NET_META_FIELD_SIZE + NFP_FLOWER_CMSG_HLEN); } static void * -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 09/11] net/nfp: unify the PMD name with macro 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (7 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 08/11] net/nfp: replace hard coded value Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 10/11] net/nfp: extract a helper function Chaoyong He ` (2 subsequent siblings) 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Unify the PMD name with a string macro, make it more extendable. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/nfp_ethdev.c | 8 +++++--- drivers/net/nfp/nfp_ethdev_vf.c | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 8057452799..c4a36027b9 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -21,6 +21,8 @@ #include "nfp_ipsec.h" #include "nfp_logs.h" +#define NFP_PF_DRIVER_NAME net_nfp_pf + static void nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, uint16_t port) @@ -1233,6 +1235,6 @@ static struct rte_pci_driver rte_nfp_net_pf_pmd = { .remove = eth_nfp_pci_remove, }; -RTE_PMD_REGISTER_PCI(net_nfp_pf, rte_nfp_net_pf_pmd); -RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map); -RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio"); +RTE_PMD_REGISTER_PCI(NFP_PF_DRIVER_NAME, rte_nfp_net_pf_pmd); +RTE_PMD_REGISTER_PCI_TABLE(NFP_PF_DRIVER_NAME, pci_id_nfp_pf_net_map); +RTE_PMD_REGISTER_KMOD_DEP(NFP_PF_DRIVER_NAME, "* igb_uio | uio_pci_generic | vfio"); diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c index cb8a37bce7..d0834ccb3e 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -15,6 +15,8 @@ #include "nfp_logs.h" #include "nfp_net_common.h" +#define NFP_VF_DRIVER_NAME net_nfp_vf + static int nfp_netvf_start(struct rte_eth_dev *dev) { @@ -416,5 +418,5 @@ RTE_INIT(rte_nfp_vf_pmd_init) nfp_class_driver_register(&rte_nfp_net_vf_pmd); } -RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map); -RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio"); +RTE_PMD_REGISTER_PCI_TABLE(NFP_VF_DRIVER_NAME, pci_id_nfp_vf_net_map); +RTE_PMD_REGISTER_KMOD_DEP(NFP_VF_DRIVER_NAME, "* igb_uio | uio_pci_generic | vfio"); -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 10/11] net/nfp: extract a helper function 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (8 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 09/11] net/nfp: unify the PMD name with macro Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 11/11] net/nfp: remove the redundancy logic of representor port Chaoyong He 2023-11-01 18:33 ` [PATCH v2 00/11] Clean up NFP PMD Ferruh Yigit 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Extract a helper function to get the pointer of 'struct nfp_net_hw' for both normal port and representor pot, this will make the operation function can be used for both type port. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 64 ++----------------------- drivers/net/nfp/nfp_net_common.c | 74 ++++++++++++++++------------- drivers/net/nfp/nfp_net_common.h | 1 + 3 files changed, 47 insertions(+), 92 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 246dd2d454..0727e7fd9f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -21,62 +21,6 @@ #define CTRL_VNIC_NB_DESC 512 -static void -nfp_pf_repr_enable_queues(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_hw *hw; - uint64_t enabled_queues = 0; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = &repr->app_fw_flower->pf_hw->super; - - /* Enabling the required TX queues in the device */ - for (i = 0; i < dev->data->nb_tx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, enabled_queues); - - enabled_queues = 0; - - /* Enabling the required RX queues in the device */ - for (i = 0; i < dev->data->nb_rx_queues; i++) - enabled_queues |= (1 << i); - - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, enabled_queues); -} - -static void -nfp_pf_repr_disable_queues(struct rte_eth_dev *dev) -{ - uint32_t update; - uint32_t new_ctrl; - struct nfp_hw *hw; - struct nfp_net_hw *net_hw; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - net_hw = repr->app_fw_flower->pf_hw; - hw = &net_hw->super; - - nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0); - nn_cfg_writeq(hw, NFP_NET_CFG_RXRS_ENABLE, 0); - - new_ctrl = hw->ctrl & ~NFP_NET_CFG_CTRL_ENABLE; - update = NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING | - NFP_NET_CFG_UPDATE_MSIX; - - if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG) - new_ctrl &= ~NFP_NET_CFG_CTRL_RINGCFG; - - /* If an error when reconfig we avoid to change hw state */ - if (nfp_reconfig(hw, new_ctrl, update) < 0) - return; - - hw->ctrl = new_ctrl; -} - int nfp_flower_pf_start(struct rte_eth_dev *dev) { @@ -93,10 +37,10 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) hw = &net_hw->super; /* Disabling queues just in case... */ - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Enabling the required queues in the device */ - nfp_pf_repr_enable_queues(dev); + nfp_net_enable_queues(dev); new_ctrl = nfp_check_offloads(dev); @@ -157,7 +101,7 @@ nfp_flower_pf_stop(struct rte_eth_dev *dev) repr = dev->data->dev_private; hw = repr->app_fw_flower->pf_hw; - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Clear queues */ for (i = 0; i < dev->data->nb_tx_queues; i++) { @@ -207,7 +151,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev) * We assume that the DPDK application is stopping all the * threads/queues before calling the device close function. */ - nfp_pf_repr_disable_queues(dev); + nfp_net_disable_queues(dev); /* Clear queues */ for (i = 0; i < dev->data->nb_tx_queues; i++) { diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index d43a071a42..1be0d7d060 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -233,6 +233,22 @@ nfp_net_mbox_reconfig(struct nfp_net_hw *net_hw, return nn_cfg_readl(&net_hw->super, mbox + NFP_NET_CFG_MBOX_SIMPLE_RET); } +struct nfp_net_hw * +nfp_net_get_hw(const struct rte_eth_dev *dev) +{ + struct nfp_net_hw *hw; + + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + struct nfp_flower_representor *repr; + repr = dev->data->dev_private; + hw = repr->app_fw_flower->pf_hw; + } else { + hw = dev->data->dev_private; + } + + return hw; +} + /* * Configure an Ethernet device. * @@ -252,7 +268,7 @@ nfp_net_configure(struct rte_eth_dev *dev) struct rte_eth_rxmode *rxmode; struct rte_eth_txmode *txmode; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); dev_conf = &dev->data->dev_conf; rxmode = &dev_conf->rxmode; txmode = &dev_conf->txmode; @@ -329,7 +345,7 @@ nfp_net_enable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_enable_queues(&hw->super, dev->data->nb_rx_queues, dev->data->nb_tx_queues); @@ -340,7 +356,7 @@ nfp_net_disable_queues(struct rte_eth_dev *dev) { struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); nfp_disable_queues(&net_hw->super); } @@ -367,7 +383,7 @@ nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_ENABLE) != 0 && (hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0) { @@ -407,7 +423,7 @@ nfp_configure_rx_interrupt(struct rte_eth_dev *dev, return -ENOMEM; } - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_UIO) { PMD_DRV_LOG(INFO, "VF: enabling RX interrupt with UIO"); @@ -443,7 +459,7 @@ nfp_check_offloads(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_eth_conf *dev_conf; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); cap = hw->super.cap; dev_conf = &dev->data->dev_conf; @@ -510,14 +526,8 @@ nfp_net_promisc_enable(struct rte_eth_dev *dev) uint32_t new_ctrl; struct nfp_hw *hw; struct nfp_net_hw *net_hw; - struct nfp_flower_representor *repr; - if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { - repr = dev->data->dev_private; - net_hw = repr->app_fw_flower->pf_hw; - } else { - net_hw = dev->data->dev_private; - } + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->cap & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -551,7 +561,7 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_PROMISC) == 0) { @@ -588,7 +598,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); memset(&link, 0, sizeof(struct rte_eth_link)); @@ -654,7 +664,7 @@ nfp_net_stats_get(struct rte_eth_dev *dev, if (stats == NULL) return -EINVAL; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); memset(&nfp_dev_stats, 0, sizeof(nfp_dev_stats)); @@ -732,7 +742,7 @@ nfp_net_stats_reset(struct rte_eth_dev *dev) uint16_t i; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); /* Reading per RX ring stats */ for (i = 0; i < dev->data->nb_rx_queues; i++) { @@ -794,7 +804,7 @@ nfp_net_xstats_size(const struct rte_eth_dev *dev) const uint32_t size = RTE_DIM(nfp_net_xstats); /* If the device is a VF, then there will be no MAC stats */ - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (hw->mac_stats == NULL) { for (count = 0; count < size; count++) { if (nfp_net_xstats[count].group == NFP_XSTAT_GROUP_MAC) @@ -828,7 +838,7 @@ nfp_net_xstats_value(const struct rte_eth_dev *dev, struct nfp_net_hw *hw; struct nfp_xstat xstat; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); xstat = nfp_net_xstats[index]; if (xstat.group == NFP_XSTAT_GROUP_MAC) @@ -967,7 +977,7 @@ nfp_net_xstats_reset(struct rte_eth_dev *dev) uint32_t read_size; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); read_size = nfp_net_xstats_size(dev); for (id = 0; id < read_size; id++) { @@ -1015,7 +1025,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) uint16_t max_tx_desc; struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); @@ -1242,7 +1252,7 @@ nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_UNMASKED); return 0; @@ -1263,7 +1273,7 @@ nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, /* Make sure all updates are written before un-masking */ rte_wmb(); - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nn_cfg_writeb(&hw->super, NFP_NET_CFG_ICR(base + queue_id), NFP_NET_CFG_ICR_RXTX); return 0; @@ -1301,7 +1311,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev) struct nfp_net_hw *hw; struct rte_pci_device *pci_dev; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); pci_dev = RTE_ETH_DEV_TO_PCI(dev); /* Make sure all updates are written before un-masking */ @@ -1376,7 +1386,7 @@ nfp_net_dev_mtu_set(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); /* MTU setting is forbidden if port is started */ if (dev->data->dev_started) { @@ -1412,7 +1422,7 @@ nfp_net_vlan_offload_set(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t rxvlan_ctrl = 0; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; rx_offload = dev->data->dev_conf.rxmode.offloads; new_ctrl = hw->ctrl; @@ -1462,7 +1472,7 @@ nfp_net_rss_reta_write(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if (reta_size != NFP_NET_CFG_RSS_ITBL_SZ) { @@ -1518,7 +1528,7 @@ nfp_net_reta_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1551,7 +1561,7 @@ nfp_net_reta_query(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) @@ -1601,7 +1611,7 @@ nfp_net_rss_hash_write(struct rte_eth_dev *dev, struct nfp_net_hw *net_hw; uint32_t cfg_rss_ctrl = 0; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; /* Writing the key byte by byte */ @@ -1657,7 +1667,7 @@ nfp_net_rss_hash_update(struct rte_eth_dev *dev, struct nfp_hw *hw; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; rss_hf = rss_conf->rss_hf; @@ -1698,7 +1708,7 @@ nfp_net_rss_hash_conf_get(struct rte_eth_dev *dev, uint32_t cfg_rss_ctrl; struct nfp_net_hw *net_hw; - net_hw = dev->data->dev_private; + net_hw = nfp_net_get_hw(dev); hw = &net_hw->super; if ((hw->ctrl & NFP_NET_CFG_CTRL_RSS_ANY) == 0) diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index 829e9c5333..e242251bc2 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -237,6 +237,7 @@ void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); +struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 11/11] net/nfp: remove the redundancy logic of representor port 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (9 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 10/11] net/nfp: extract a helper function Chaoyong He @ 2023-10-28 6:53 ` Chaoyong He 2023-11-01 18:33 ` [PATCH v2 00/11] Clean up NFP PMD Ferruh Yigit 11 siblings, 0 replies; 27+ messages in thread From: Chaoyong He @ 2023-10-28 6:53 UTC (permalink / raw) To: dev; +Cc: oss-drivers, Chaoyong He, Peng Zhang Using the helper function, we can remove some redundancy logic of representor port by reusing the functions in common module. Signed-off-by: Chaoyong He <chaoyong.he@corigine.com> Reviewed-by: Peng Zhang <peng.zhang@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 47 +--- drivers/net/nfp/flower/nfp_flower.h | 1 - .../net/nfp/flower/nfp_flower_representor.c | 253 +----------------- drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +- drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +- drivers/net/nfp/nfp_ethdev.c | 28 +- drivers/net/nfp/nfp_net_common.c | 127 +++++---- drivers/net/nfp/nfp_net_common.h | 6 +- drivers/net/nfp/nfp_rxtx.c | 4 +- 9 files changed, 93 insertions(+), 377 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 0727e7fd9f..f2e6eb6a6f 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -48,11 +48,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) nfp_net_params_setup(net_hw); update |= NFP_NET_CFG_UPDATE_RSS; - - if ((hw->cap & NFP_NET_CFG_CTRL_RSS2) != 0) - new_ctrl |= NFP_NET_CFG_CTRL_RSS2; - else - new_ctrl |= NFP_NET_CFG_CTRL_RSS; + new_ctrl |= nfp_net_cfg_ctrl_rss(hw->cap); /* Enable device */ new_ctrl |= NFP_NET_CFG_CTRL_ENABLE; @@ -62,8 +58,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) if ((hw->cap & NFP_NET_CFG_CTRL_RINGCFG) != 0) new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG; - nn_cfg_writel(hw, NFP_NET_CFG_CTRL, new_ctrl); - /* If an error when reconfig we avoid to change hw state */ ret = nfp_reconfig(hw, new_ctrl, update); if (ret != 0) { @@ -88,43 +82,6 @@ nfp_flower_pf_start(struct rte_eth_dev *dev) return 0; } -/* Stop device: disable rx and tx functions to allow for reconfiguring. */ -int -nfp_flower_pf_stop(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_hw *hw; - struct nfp_net_txq *this_tx_q; - struct nfp_net_rxq *this_rx_q; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - nfp_net_disable_queues(dev); - - /* Clear queues */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; - } - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); - else - nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); - - return 0; -} - /* Reset and stop device. The device can not be restarted. */ static int nfp_flower_pf_close(struct rte_eth_dev *dev) @@ -188,7 +145,7 @@ static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_configure = nfp_net_configure, .dev_start = nfp_flower_pf_start, - .dev_stop = nfp_flower_pf_stop, + .dev_stop = nfp_net_stop, .dev_close = nfp_flower_pf_close, }; diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index a989c4a8b8..220b714018 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -113,7 +113,6 @@ bool nfp_flower_pf_dispatch_pkts(struct nfp_net_hw *hw, uint16_t nfp_flower_pf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); int nfp_flower_pf_start(struct rte_eth_dev *dev); -int nfp_flower_pf_stop(struct rte_eth_dev *dev); uint32_t nfp_flower_pkt_add_metadata(struct nfp_app_fw_flower *app_fw_flower, struct rte_mbuf *mbuf, uint32_t port_id); diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index b52c6f514a..0f0e63aae0 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -18,232 +18,23 @@ enum nfp_repr_type { NFP_REPR_TYPE_MAX, /*<< Number of representor types */ }; -static int -nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev, - uint16_t queue_idx, - uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_rxconf *rx_conf, - struct rte_mempool *mp) -{ - struct nfp_net_hw *hw; - struct nfp_net_rxq *rxq; - const struct rte_memzone *tz; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - /* Allocating rx queue data structure */ - rxq = rte_zmalloc_socket("ethdev RX queue", sizeof(struct nfp_net_rxq), - RTE_CACHE_LINE_SIZE, socket_id); - if (rxq == NULL) - return -ENOMEM; - - dev->data->rx_queues[queue_idx] = rxq; - - /* Hw queues mapping based on firmware configuration */ - rxq->qidx = queue_idx; - rxq->fl_qcidx = queue_idx * hw->stride_rx; - rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx); - - /* - * Tracking mbuf size for detecting a potential mbuf overflow due to - * RX offset. - */ - rxq->mem_pool = mp; - rxq->mbuf_size = rxq->mem_pool->elt_size; - rxq->mbuf_size -= (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM); - hw->flbufsz = rxq->mbuf_size; - - rxq->rx_count = nb_desc; - rxq->port_id = dev->data->port_id; - rxq->rx_free_thresh = rx_conf->rx_free_thresh; - - /* - * Allocate RX ring hardware descriptors. A memzone large enough to - * handle the maximum ring size is allocated in order to allow for - * resizing in later calls to the queue setup function. - */ - tz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, - sizeof(struct nfp_net_rx_desc) * - hw->dev_info->max_qc_size, - NFP_MEMZONE_ALIGN, socket_id); - if (tz == NULL) { - PMD_DRV_LOG(ERR, "Error allocating rx dma"); - nfp_net_rx_queue_release(dev, queue_idx); - dev->data->rx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - /* Saving physical and virtual addresses for the RX ring */ - rxq->dma = (uint64_t)tz->iova; - rxq->rxds = tz->addr; - - /* Mbuf pointers array for referencing mbufs linked to RX descriptors */ - rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs", - sizeof(*rxq->rxbufs) * nb_desc, - RTE_CACHE_LINE_SIZE, socket_id); - if (rxq->rxbufs == NULL) { - nfp_net_rx_queue_release(dev, queue_idx); - dev->data->rx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - nfp_net_reset_rx_queue(rxq); - rxq->hw = hw; - - /* - * Telling the HW about the physical address of the RX ring and number - * of descriptors in log2 format. - */ - nn_cfg_writeq(&hw->super, NFP_NET_CFG_RXR_ADDR(queue_idx), rxq->dma); - nn_cfg_writeb(&hw->super, NFP_NET_CFG_RXR_SZ(queue_idx), rte_log2_u32(nb_desc)); - - return 0; -} - -static int -nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev, - uint16_t queue_idx, - uint16_t nb_desc, - unsigned int socket_id, - const struct rte_eth_txconf *tx_conf) -{ - struct nfp_net_hw *hw; - struct nfp_net_txq *txq; - uint16_t tx_free_thresh; - const struct rte_memzone *tz; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - tx_free_thresh = (tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh : - DEFAULT_TX_FREE_THRESH; - if (tx_free_thresh > nb_desc) - return -EINVAL; - - /* Allocating tx queue data structure */ - txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nfp_net_txq), - RTE_CACHE_LINE_SIZE, socket_id); - if (txq == NULL) { - PMD_DRV_LOG(ERR, "Error allocating tx dma"); - return -ENOMEM; - } - - dev->data->tx_queues[queue_idx] = txq; - - /* - * Allocate TX ring hardware descriptors. A memzone large enough to - * handle the maximum ring size is allocated in order to allow for - * resizing in later calls to the queue setup function. - */ - tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx, - sizeof(struct nfp_net_nfd3_tx_desc) * - hw->dev_info->max_qc_size, - NFP_MEMZONE_ALIGN, socket_id); - if (tz == NULL) { - PMD_DRV_LOG(ERR, "Error allocating tx dma"); - nfp_net_tx_queue_release(dev, queue_idx); - dev->data->tx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - txq->tx_count = nb_desc; - txq->tx_free_thresh = tx_free_thresh; - - /* Queue mapping based on firmware configuration */ - txq->qidx = queue_idx; - txq->tx_qcidx = queue_idx * hw->stride_tx; - txq->qcp_q = hw->tx_bar + NFP_QCP_QUEUE_OFF(txq->tx_qcidx); - - txq->port_id = dev->data->port_id; - - /* Saving physical and virtual addresses for the TX ring */ - txq->dma = (uint64_t)tz->iova; - txq->txds = tz->addr; - - /* Mbuf pointers array for referencing mbufs linked to TX descriptors */ - txq->txbufs = rte_zmalloc_socket("txq->txbufs", - sizeof(*txq->txbufs) * nb_desc, - RTE_CACHE_LINE_SIZE, socket_id); - if (txq->txbufs == NULL) { - nfp_net_tx_queue_release(dev, queue_idx); - dev->data->tx_queues[queue_idx] = NULL; - return -ENOMEM; - } - - nfp_net_reset_tx_queue(txq); - txq->hw = hw; - - /* - * Telling the HW about the physical address of the TX ring and number - * of descriptors in log2 format. - */ - nn_cfg_writeq(&hw->super, NFP_NET_CFG_TXR_ADDR(queue_idx), txq->dma); - nn_cfg_writeb(&hw->super, NFP_NET_CFG_TXR_SZ(queue_idx), rte_log2_u32(nb_desc)); - - return 0; -} - static int nfp_flower_repr_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { int ret; - uint32_t i; uint32_t nn_link_status; struct nfp_net_hw *pf_hw; struct rte_eth_link *link; - struct nfp_eth_table *nfp_eth_table; struct nfp_flower_representor *repr; - static const uint32_t ls_to_ethtool[] = { - [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] = RTE_ETH_SPEED_NUM_NONE, - [NFP_NET_CFG_STS_LINK_RATE_1G] = RTE_ETH_SPEED_NUM_1G, - [NFP_NET_CFG_STS_LINK_RATE_10G] = RTE_ETH_SPEED_NUM_10G, - [NFP_NET_CFG_STS_LINK_RATE_25G] = RTE_ETH_SPEED_NUM_25G, - [NFP_NET_CFG_STS_LINK_RATE_40G] = RTE_ETH_SPEED_NUM_40G, - [NFP_NET_CFG_STS_LINK_RATE_50G] = RTE_ETH_SPEED_NUM_50G, - [NFP_NET_CFG_STS_LINK_RATE_100G] = RTE_ETH_SPEED_NUM_100G, - }; - repr = dev->data->dev_private; link = &repr->link; - link->link_speed = RTE_ETH_SPEED_NUM_NONE; - pf_hw = repr->app_fw_flower->pf_hw; - if (link->link_status == RTE_ETH_LINK_UP) { - if (pf_hw->pf_dev != NULL) { - nfp_eth_table = pf_hw->pf_dev->nfp_eth_table; - if (nfp_eth_table != NULL) { - uint32_t speed = nfp_eth_table->ports[pf_hw->idx].speed; - for (i = 0; i < RTE_DIM(ls_to_ethtool); i++) { - if (ls_to_ethtool[i] == speed) { - link->link_speed = speed; - break; - } - } - } - } else { - nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS); - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & - NFP_NET_CFG_STS_LINK_RATE_MASK; - - if (nn_link_status < RTE_DIM(ls_to_ethtool)) - link->link_speed = ls_to_ethtool[nn_link_status]; - } - } + pf_hw = repr->app_fw_flower->pf_hw; + nn_link_status = nn_cfg_readw(&pf_hw->super, NFP_NET_CFG_STS); - ret = rte_eth_linkstatus_set(dev, link); - if (ret == 0) { - if (link->link_status) - PMD_DRV_LOG(INFO, "NIC Link is Up"); - else - PMD_DRV_LOG(INFO, "NIC Link is Down"); - } + ret = nfp_net_link_update_common(dev, pf_hw, link, nn_link_status); return ret; } @@ -275,30 +66,6 @@ nfp_flower_repr_dev_infos_get(__rte_unused struct rte_eth_dev *dev, return 0; } -static int -nfp_flower_repr_dev_configure(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *pf_hw; - struct rte_eth_conf *dev_conf; - struct rte_eth_rxmode *rxmode; - struct nfp_flower_representor *repr; - - repr = dev->data->dev_private; - pf_hw = repr->app_fw_flower->pf_hw; - - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - - /* Checking MTU set */ - if (rxmode->mtu > pf_hw->flbufsz) { - PMD_DRV_LOG(INFO, "MTU (%u) larger then current mbufsize (%u) not supported", - rxmode->mtu, pf_hw->flbufsz); - return -ERANGE; - } - - return 0; -} - static int nfp_flower_repr_dev_start(struct rte_eth_dev *dev) { @@ -528,11 +295,11 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_pf_start, - .dev_configure = nfp_flower_repr_dev_configure, - .dev_stop = nfp_flower_pf_stop, + .dev_configure = nfp_net_configure, + .dev_stop = nfp_net_stop, - .rx_queue_setup = nfp_pf_repr_rx_queue_setup, - .tx_queue_setup = nfp_pf_repr_tx_queue_setup, + .rx_queue_setup = nfp_net_rx_queue_setup, + .tx_queue_setup = nfp_net_tx_queue_setup, .link_update = nfp_flower_repr_link_update, @@ -543,14 +310,14 @@ static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .promiscuous_disable = nfp_net_promisc_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, - .fw_version_get = nfp_repr_firmware_version_get, + .fw_version_get = nfp_net_firmware_version_get, }; static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_repr_dev_start, - .dev_configure = nfp_flower_repr_dev_configure, + .dev_configure = nfp_net_configure, .dev_stop = nfp_flower_repr_dev_stop, .rx_queue_setup = nfp_flower_repr_rx_queue_setup, @@ -565,7 +332,7 @@ static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .promiscuous_disable = nfp_net_promisc_disable, .mac_addr_set = nfp_flower_repr_mac_addr_set, - .fw_version_get = nfp_repr_firmware_version_get, + .fw_version_get = nfp_net_firmware_version_get, .flow_ops_get = nfp_net_flow_ops_get, .mtr_ops_get = nfp_net_mtr_ops_get, diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c index 3f9909c6e0..ff9b10f046 100644 --- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c +++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c @@ -377,7 +377,7 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_free_thresh; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c index fe87ea3e25..1f330b7bb6 100644 --- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c +++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c @@ -454,7 +454,7 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_txq *txq; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_tx_desc_limits(hw, &min_tx_desc, &max_tx_desc); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index c4a36027b9..69050e03f5 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -51,7 +51,6 @@ nfp_net_start(struct rte_eth_dev *dev) uint32_t ctrl_extend = 0; struct nfp_net_hw *net_hw; struct nfp_pf_dev *pf_dev; - struct rte_eth_conf *dev_conf; struct rte_eth_rxmode *rxmode; struct nfp_app_fw_nic *app_fw_nic; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); @@ -113,9 +112,7 @@ nfp_net_start(struct rte_eth_dev *dev) /* Writing configuration parameters in the device */ nfp_net_params_setup(net_hw); - dev_conf = &dev->data->dev_conf; - rxmode = &dev_conf->rxmode; - + rxmode = &dev->data->dev_conf.rxmode; if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS) != 0) { nfp_net_rss_config_default(dev); update |= NFP_NET_CFG_UPDATE_RSS; @@ -197,29 +194,6 @@ nfp_net_start(struct rte_eth_dev *dev) return ret; } -/* Stop device: disable rx and tx functions to allow for reconfiguring. */ -static int -nfp_net_stop(struct rte_eth_dev *dev) -{ - struct nfp_net_hw *hw; - - hw = dev->data->dev_private; - - nfp_net_disable_queues(dev); - - /* Clear queues */ - nfp_net_stop_tx_queue(dev); - nfp_net_stop_rx_queue(dev); - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) - /* Configure the physical port down */ - nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); - else - nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); - - return 0; -} - /* Set the link up. */ static int nfp_net_set_link_up(struct rte_eth_dev *dev) diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c index 1be0d7d060..76b1de0e49 100644 --- a/drivers/net/nfp/nfp_net_common.c +++ b/drivers/net/nfp/nfp_net_common.c @@ -581,43 +581,27 @@ nfp_net_promisc_disable(struct rte_eth_dev *dev) return 0; } -/* - * Return 0 means link status changed, -1 means not changed - * - * Wait to complete is needed as it can take up to 9 seconds to get the Link - * status. - */ int -nfp_net_link_update(struct rte_eth_dev *dev, - __rte_unused int wait_to_complete) +nfp_net_link_update_common(struct rte_eth_dev *dev, + struct nfp_net_hw *hw, + struct rte_eth_link *link, + uint32_t link_status) { int ret; uint32_t i; - struct nfp_net_hw *hw; uint32_t nn_link_status; - struct rte_eth_link link; struct nfp_eth_table *nfp_eth_table; - hw = nfp_net_get_hw(dev); - - memset(&link, 0, sizeof(struct rte_eth_link)); + link->link_speed = RTE_ETH_SPEED_NUM_NONE; - /* Read link status */ - nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS); - if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) - link.link_status = RTE_ETH_LINK_UP; - - link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; - link.link_speed = RTE_ETH_SPEED_NUM_NONE; - - if (link.link_status == RTE_ETH_LINK_UP) { + if (link->link_status == RTE_ETH_LINK_UP) { if (hw->pf_dev != NULL) { nfp_eth_table = hw->pf_dev->nfp_eth_table; if (nfp_eth_table != NULL) { uint32_t speed = nfp_eth_table->ports[hw->idx].speed; for (i = 0; i < RTE_DIM(nfp_net_link_speed_nfp2rte); i++) { if (nfp_net_link_speed_nfp2rte[i] == speed) { - link.link_speed = speed; + link->link_speed = speed; break; } } @@ -627,21 +611,52 @@ nfp_net_link_update(struct rte_eth_dev *dev, * Shift and mask nn_link_status so that it is effectively the value * at offset NFP_NET_CFG_STS_NSP_LINK_RATE. */ - nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & + nn_link_status = (link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) & NFP_NET_CFG_STS_LINK_RATE_MASK; if (nn_link_status < RTE_DIM(nfp_net_link_speed_nfp2rte)) - link.link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; + link->link_speed = nfp_net_link_speed_nfp2rte[nn_link_status]; } } - ret = rte_eth_linkstatus_set(dev, &link); + ret = rte_eth_linkstatus_set(dev, link); if (ret == 0) { - if (link.link_status != 0) + if (link->link_status != 0) PMD_DRV_LOG(INFO, "NIC Link is Up"); else PMD_DRV_LOG(INFO, "NIC Link is Down"); } + return ret; +} + +/* + * Return 0 means link status changed, -1 means not changed + * + * Wait to complete is needed as it can take up to 9 seconds to get the Link + * status. + */ +int +nfp_net_link_update(struct rte_eth_dev *dev, + __rte_unused int wait_to_complete) +{ + int ret; + struct nfp_net_hw *hw; + uint32_t nn_link_status; + struct rte_eth_link link; + + hw = nfp_net_get_hw(dev); + + memset(&link, 0, sizeof(struct rte_eth_link)); + + /* Read link status */ + nn_link_status = nn_cfg_readw(&hw->super, NFP_NET_CFG_STS); + if ((nn_link_status & NFP_NET_CFG_STS_LINK) != 0) + link.link_status = RTE_ETH_LINK_UP; + + link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX; + + ret = nfp_net_link_update_common(dev, hw, &link, nn_link_status); + /* * Notify the port to update the speed value in the CTRL BAR from NSP. * Not applicable for VFs as the associated PF is still attached to the @@ -1996,11 +2011,15 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, if (fw_size < FW_VER_LEN) return FW_VER_LEN; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); - snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", + if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) { + snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d", hw->ver.extend, hw->ver.class, hw->ver.major, hw->ver.minor); + } else { + snprintf(vnic_version, FW_VER_LEN, "*"); + } nfp_net_get_nsp_info(hw, nsp_version); nfp_net_get_mip_name(hw, mip_name); @@ -2012,33 +2031,6 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev, return 0; } -int -nfp_repr_firmware_version_get(struct rte_eth_dev *dev, - char *fw_version, - size_t fw_size) -{ - struct nfp_net_hw *hw; - char mip_name[FW_VER_LEN]; - char app_name[FW_VER_LEN]; - char nsp_version[FW_VER_LEN]; - struct nfp_flower_representor *repr; - - if (fw_size < FW_VER_LEN) - return FW_VER_LEN; - - repr = dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - - nfp_net_get_nsp_info(hw, nsp_version); - nfp_net_get_mip_name(hw, mip_name); - nfp_net_get_app_name(hw, app_name); - - snprintf(fw_version, FW_VER_LEN, "* %s %s %s", - nsp_version, mip_name, app_name); - - return 0; -} - bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) { @@ -2059,3 +2051,26 @@ nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version) return false; } + +/* Disable rx and tx functions to allow for reconfiguring. */ +int +nfp_net_stop(struct rte_eth_dev *dev) +{ + struct nfp_net_hw *hw; + + hw = nfp_net_get_hw(dev); + + nfp_net_disable_queues(dev); + + /* Clear queues */ + nfp_net_stop_tx_queue(dev); + nfp_net_stop_rx_queue(dev); + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + /* Configure the physical port down */ + nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0); + else + nfp_eth_set_configured(dev->process_private, hw->nfp_idx, 0); + + return 0; +} diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h index e242251bc2..af8f8d15ae 100644 --- a/drivers/net/nfp/nfp_net_common.h +++ b/drivers/net/nfp/nfp_net_common.h @@ -178,6 +178,10 @@ int nfp_configure_rx_interrupt(struct rte_eth_dev *dev, uint32_t nfp_check_offloads(struct rte_eth_dev *dev); int nfp_net_promisc_enable(struct rte_eth_dev *dev); int nfp_net_promisc_disable(struct rte_eth_dev *dev); +int nfp_net_link_update_common(struct rte_eth_dev *dev, + struct nfp_net_hw *hw, + struct rte_eth_link *link, + uint32_t link_status); int nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); int nfp_net_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); @@ -235,9 +239,9 @@ int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name); void nfp_net_init_metadata_format(struct nfp_net_hw *hw); void nfp_net_cfg_read_version(struct nfp_net_hw *hw); int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); -int nfp_repr_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version); struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev); +int nfp_net_stop(struct rte_eth_dev *dev); #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\ ((struct nfp_app_fw_nic *)app_fw_priv) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index be1ac32c73..b2a9ba6875 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -840,7 +840,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev, struct nfp_net_rxq *rxq; const struct rte_memzone *tz; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); nfp_net_rx_desc_limits(hw, &min_rx_desc, &max_rx_desc); @@ -1067,7 +1067,7 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev, { struct nfp_net_hw *hw; - hw = dev->data->dev_private; + hw = nfp_net_get_hw(dev); if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3) return nfp_net_nfd3_tx_queue_setup(dev, queue_idx, -- 2.39.1 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 00/11] Clean up NFP PMD 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He ` (10 preceding siblings ...) 2023-10-28 6:53 ` [PATCH v2 11/11] net/nfp: remove the redundancy logic of representor port Chaoyong He @ 2023-11-01 18:33 ` Ferruh Yigit 11 siblings, 0 replies; 27+ messages in thread From: Ferruh Yigit @ 2023-11-01 18:33 UTC (permalink / raw) To: Chaoyong He, dev; +Cc: oss-drivers On 10/28/2023 7:53 AM, Chaoyong He wrote: > This patch series clean up the NFP PMD, by: > - Using the DPDK macro and API to replace the user defined ones. > - Remove the unneeded macro and logic. > - Remove the duplicated logic. > > --- > v2: > * Fix the compile error. > * Fix one check script warning. > --- > > Chaoyong He (11): > net/nfp: use the suitable helper macro > net/nfp: remove the unneeded call of underlying API > net/nfp: remove the unneeded check of process type > net/nfp: remove the unneeded data abstraction > net/nfp: remove the redundancy macro > net/nfp: remove redundancy logic of init control BAR > net/nfp: use the DPDK defined function > net/nfp: replace hard coded value > net/nfp: unify the PMD name with macro > net/nfp: extract a helper function > net/nfp: remove the redundancy logic of representor port > 'struct nfp_net_adapter' removed in 4/11. Series applied to dpdk-next-net/main, thanks. ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2023-11-02 1:25 UTC | newest] Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-10-28 6:15 [PATCH 00/11] Clean up NFP PMD Chaoyong He 2023-10-28 6:15 ` [PATCH 01/11] net/nfp: use the suitable helper macro Chaoyong He 2023-10-28 6:15 ` [PATCH 02/11] net/nfp: remove the unneeded call of underlying API Chaoyong He 2023-10-28 6:15 ` [PATCH 03/11] net/nfp: remove the unneeded check of process type Chaoyong He 2023-10-28 6:15 ` [PATCH 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He 2023-10-28 6:15 ` [PATCH 05/11] net/nfp: remove the redundancy macro Chaoyong He 2023-10-28 6:15 ` [PATCH 06/11] net/nfp: remove redundancy logic of init control BAR Chaoyong He 2023-10-28 6:15 ` [PATCH 07/11] net/nfp: use the DPDK defined function Chaoyong He 2023-10-28 6:15 ` [PATCH 08/11] net/nfp: replace hard coded value Chaoyong He 2023-10-28 6:15 ` [PATCH 09/11] net/nfp: unify the PMD name with macro Chaoyong He 2023-10-28 6:15 ` [PATCH 10/11] net/nfp: extract a helper function Chaoyong He 2023-10-28 6:15 ` [PATCH 11/11] net/nfp: remove the redundancy logic of representor port Chaoyong He 2023-10-28 6:53 ` [PATCH v2 00/11] Clean up NFP PMD Chaoyong He 2023-10-28 6:53 ` [PATCH v2 01/11] net/nfp: use the suitable helper macro Chaoyong He 2023-10-28 6:53 ` [PATCH v2 02/11] net/nfp: remove the unneeded call of underlying API Chaoyong He 2023-10-28 6:53 ` [PATCH v2 03/11] net/nfp: remove the unneeded check of process type Chaoyong He 2023-10-28 6:53 ` [PATCH v2 04/11] net/nfp: remove the unneeded data abstraction Chaoyong He 2023-11-01 17:57 ` Ferruh Yigit 2023-11-02 1:25 ` Chaoyong He 2023-10-28 6:53 ` [PATCH v2 05/11] net/nfp: remove the redundancy macro Chaoyong He 2023-10-28 6:53 ` [PATCH v2 06/11] net/nfp: remove redundancy logic of init control BAR Chaoyong He 2023-10-28 6:53 ` [PATCH v2 07/11] net/nfp: use the DPDK defined function Chaoyong He 2023-10-28 6:53 ` [PATCH v2 08/11] net/nfp: replace hard coded value Chaoyong He 2023-10-28 6:53 ` [PATCH v2 09/11] net/nfp: unify the PMD name with macro Chaoyong He 2023-10-28 6:53 ` [PATCH v2 10/11] net/nfp: extract a helper function Chaoyong He 2023-10-28 6:53 ` [PATCH v2 11/11] net/nfp: remove the redundancy logic of representor port Chaoyong He 2023-11-01 18:33 ` [PATCH v2 00/11] Clean up NFP PMD Ferruh Yigit
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).