* [PATCH 0/2] net/nfp: use a single struct eth_dev_ops
@ 2022-09-22 13:03 Niklas Söderlund
2022-09-22 13:03 ` [PATCH 1/2] net/nfp: fix return value of nfp card init function Niklas Söderlund
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Niklas Söderlund @ 2022-09-22 13:03 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Jin Liu, Chaoyong He, Niklas Söderlund
Hi all,
This small series aims to reduce code duplication by using a single
shared struct eth_dev_ops for NFDk and NFD3.
Patch 1/2 is a small bug fix that suck in when adding support for
NFP3800 where the error code is not correctly propagated.
Patch 2/2 is do the real work by merging the two existing structs and
adding the small glue in the setup step that differenced them.
Jin Liu (2):
net/nfp: fix return value of nfp card init function
net/nfp: optimize ethdev struct
drivers/net/nfp/nfp_ethdev.c | 38 ++++-----------------------------
drivers/net/nfp/nfp_ethdev_vf.c | 36 +++----------------------------
drivers/net/nfp/nfp_rxtx.c | 33 ++++++++++++++++++++++++++--
drivers/net/nfp/nfp_rxtx.h | 5 +----
4 files changed, 39 insertions(+), 73 deletions(-)
--
2.37.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net/nfp: fix return value of nfp card init function
2022-09-22 13:03 [PATCH 0/2] net/nfp: use a single struct eth_dev_ops Niklas Söderlund
@ 2022-09-22 13:03 ` Niklas Söderlund
2022-09-22 13:03 ` [PATCH 2/2] net/nfp: optimize ethdev struct Niklas Söderlund
2022-10-05 16:51 ` [PATCH 0/2] net/nfp: use a single struct eth_dev_ops Ferruh Yigit
2 siblings, 0 replies; 4+ messages in thread
From: Niklas Söderlund @ 2022-09-22 13:03 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Jin Liu, Chaoyong He, stable, Niklas Söderlund
From: Jin Liu <jin.liu@corigine.com>
The return value of 'nfp_pf_init' function is variable ret, but
there is one statement, if error occurs, assign error num to
variable err, it is incorrect, fixed it.
Fixes: 5c464d6a2771 ("net/nfp: support NFP3800 card")
Cc: stable@dpdk.org
Signed-off-by: Jin Liu <jin.liu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 2e546cfc5ffc..bc69840777eb 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -924,7 +924,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
break;
default:
PMD_INIT_LOG(ERR, "nfp_net: no device ID matching");
- err = -ENODEV;
+ ret = -ENODEV;
goto ctrl_area_cleanup;
}
--
2.37.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] net/nfp: optimize ethdev struct
2022-09-22 13:03 [PATCH 0/2] net/nfp: use a single struct eth_dev_ops Niklas Söderlund
2022-09-22 13:03 ` [PATCH 1/2] net/nfp: fix return value of nfp card init function Niklas Söderlund
@ 2022-09-22 13:03 ` Niklas Söderlund
2022-10-05 16:51 ` [PATCH 0/2] net/nfp: use a single struct eth_dev_ops Ferruh Yigit
2 siblings, 0 replies; 4+ messages in thread
From: Niklas Söderlund @ 2022-09-22 13:03 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, Jin Liu, Chaoyong He, Niklas Söderlund
From: Jin Liu <jin.liu@corigine.com>
Before, use two variables to represent the ethdev structure for
firmware with NFDk and NFD3, but only a few field values differ
between the two variables. Now use one variable only, and to
distinguish different firmware versions in specific functions.
Signed-off-by: Jin Liu <jin.liu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 36 +++------------------------------
drivers/net/nfp/nfp_ethdev_vf.c | 36 +++------------------------------
drivers/net/nfp/nfp_rxtx.c | 33 ++++++++++++++++++++++++++++--
drivers/net/nfp/nfp_rxtx.h | 5 +----
4 files changed, 38 insertions(+), 72 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index bc69840777eb..3cb889bd015f 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -313,7 +313,7 @@ nfp_net_close(struct rte_eth_dev *dev)
}
/* Initialise and register driver with DPDK Application */
-static const struct eth_dev_ops nfp_net_nfd3_eth_dev_ops = {
+static const struct eth_dev_ops nfp_net_eth_dev_ops = {
.dev_configure = nfp_net_configure,
.dev_start = nfp_net_start,
.dev_stop = nfp_net_stop,
@@ -336,36 +336,7 @@ static const struct eth_dev_ops nfp_net_nfd3_eth_dev_ops = {
.rss_hash_conf_get = nfp_net_rss_hash_conf_get,
.rx_queue_setup = nfp_net_rx_queue_setup,
.rx_queue_release = nfp_net_rx_queue_release,
- .tx_queue_setup = nfp_net_nfd3_tx_queue_setup,
- .tx_queue_release = nfp_net_tx_queue_release,
- .rx_queue_intr_enable = nfp_rx_queue_intr_enable,
- .rx_queue_intr_disable = nfp_rx_queue_intr_disable,
-};
-
-static const struct eth_dev_ops nfp_net_nfdk_eth_dev_ops = {
- .dev_configure = nfp_net_configure,
- .dev_start = nfp_net_start,
- .dev_stop = nfp_net_stop,
- .dev_set_link_up = nfp_net_set_link_up,
- .dev_set_link_down = nfp_net_set_link_down,
- .dev_close = nfp_net_close,
- .promiscuous_enable = nfp_net_promisc_enable,
- .promiscuous_disable = nfp_net_promisc_disable,
- .link_update = nfp_net_link_update,
- .stats_get = nfp_net_stats_get,
- .stats_reset = nfp_net_stats_reset,
- .dev_infos_get = nfp_net_infos_get,
- .dev_supported_ptypes_get = nfp_net_supported_ptypes_get,
- .mtu_set = nfp_net_dev_mtu_set,
- .mac_addr_set = nfp_net_set_mac_addr,
- .vlan_offload_set = nfp_net_vlan_offload_set,
- .reta_update = nfp_net_reta_update,
- .reta_query = nfp_net_reta_query,
- .rss_hash_update = nfp_net_rss_hash_update,
- .rss_hash_conf_get = nfp_net_rss_hash_conf_get,
- .rx_queue_setup = nfp_net_rx_queue_setup,
- .rx_queue_release = nfp_net_rx_queue_release,
- .tx_queue_setup = nfp_net_nfdk_tx_queue_setup,
+ .tx_queue_setup = nfp_net_tx_queue_setup,
.tx_queue_release = nfp_net_tx_queue_release,
.rx_queue_intr_enable = nfp_rx_queue_intr_enable,
.rx_queue_intr_disable = nfp_rx_queue_intr_disable,
@@ -376,7 +347,6 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
{
switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
case NFP_NET_CFG_VERSION_DP_NFD3:
- eth_dev->dev_ops = &nfp_net_nfd3_eth_dev_ops;
eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts;
break;
case NFP_NET_CFG_VERSION_DP_NFDK:
@@ -385,7 +355,6 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
NFD_CFG_MAJOR_VERSION_of(hw->ver));
return -EINVAL;
}
- eth_dev->dev_ops = &nfp_net_nfdk_eth_dev_ops;
eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts;
break;
default:
@@ -393,6 +362,7 @@ nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
return -EINVAL;
}
+ eth_dev->dev_ops = &nfp_net_eth_dev_ops;
eth_dev->rx_queue_count = nfp_net_rx_queue_count;
eth_dev->rx_pkt_burst = &nfp_net_recv_pkts;
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index affea9d17cdf..96c4d3cca7bb 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -218,7 +218,7 @@ nfp_netvf_close(struct rte_eth_dev *dev)
}
/* Initialise and register VF driver with DPDK Application */
-static const struct eth_dev_ops nfp_netvf_nfd3_eth_dev_ops = {
+static const struct eth_dev_ops nfp_netvf_eth_dev_ops = {
.dev_configure = nfp_net_configure,
.dev_start = nfp_netvf_start,
.dev_stop = nfp_netvf_stop,
@@ -241,36 +241,7 @@ static const struct eth_dev_ops nfp_netvf_nfd3_eth_dev_ops = {
.rss_hash_conf_get = nfp_net_rss_hash_conf_get,
.rx_queue_setup = nfp_net_rx_queue_setup,
.rx_queue_release = nfp_net_rx_queue_release,
- .tx_queue_setup = nfp_net_nfd3_tx_queue_setup,
- .tx_queue_release = nfp_net_tx_queue_release,
- .rx_queue_intr_enable = nfp_rx_queue_intr_enable,
- .rx_queue_intr_disable = nfp_rx_queue_intr_disable,
-};
-
-static const struct eth_dev_ops nfp_netvf_nfdk_eth_dev_ops = {
- .dev_configure = nfp_net_configure,
- .dev_start = nfp_netvf_start,
- .dev_stop = nfp_netvf_stop,
- .dev_set_link_up = nfp_netvf_set_link_up,
- .dev_set_link_down = nfp_netvf_set_link_down,
- .dev_close = nfp_netvf_close,
- .promiscuous_enable = nfp_net_promisc_enable,
- .promiscuous_disable = nfp_net_promisc_disable,
- .link_update = nfp_net_link_update,
- .stats_get = nfp_net_stats_get,
- .stats_reset = nfp_net_stats_reset,
- .dev_infos_get = nfp_net_infos_get,
- .dev_supported_ptypes_get = nfp_net_supported_ptypes_get,
- .mtu_set = nfp_net_dev_mtu_set,
- .mac_addr_set = nfp_net_set_mac_addr,
- .vlan_offload_set = nfp_net_vlan_offload_set,
- .reta_update = nfp_net_reta_update,
- .reta_query = nfp_net_reta_query,
- .rss_hash_update = nfp_net_rss_hash_update,
- .rss_hash_conf_get = nfp_net_rss_hash_conf_get,
- .rx_queue_setup = nfp_net_rx_queue_setup,
- .rx_queue_release = nfp_net_rx_queue_release,
- .tx_queue_setup = nfp_net_nfdk_tx_queue_setup,
+ .tx_queue_setup = nfp_net_tx_queue_setup,
.tx_queue_release = nfp_net_tx_queue_release,
.rx_queue_intr_enable = nfp_rx_queue_intr_enable,
.rx_queue_intr_disable = nfp_rx_queue_intr_disable,
@@ -281,7 +252,6 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
{
switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
case NFP_NET_CFG_VERSION_DP_NFD3:
- eth_dev->dev_ops = &nfp_netvf_nfd3_eth_dev_ops;
eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts;
break;
case NFP_NET_CFG_VERSION_DP_NFDK:
@@ -290,7 +260,6 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
NFD_CFG_MAJOR_VERSION_of(hw->ver));
return -EINVAL;
}
- eth_dev->dev_ops = &nfp_netvf_nfdk_eth_dev_ops;
eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts;
break;
default:
@@ -298,6 +267,7 @@ nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
return -EINVAL;
}
+ eth_dev->dev_ops = &nfp_netvf_eth_dev_ops;
eth_dev->rx_queue_count = nfp_net_rx_queue_count;
eth_dev->rx_pkt_burst = &nfp_net_recv_pkts;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 8429b44de06d..12db07c276f0 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -657,7 +657,7 @@ nfp_net_reset_tx_queue(struct nfp_net_txq *txq)
txq->rd_p = 0;
}
-int
+static int
nfp_net_nfd3_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)
@@ -991,7 +991,7 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
return i;
}
-int
+static int
nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t queue_idx,
uint16_t nb_desc,
@@ -1108,6 +1108,35 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
return 0;
}
+int
+nfp_net_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;
+
+ hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
+ case NFP_NET_CFG_VERSION_DP_NFD3:
+ return nfp_net_nfd3_tx_queue_setup(dev, queue_idx,
+ nb_desc, socket_id, tx_conf);
+ case NFP_NET_CFG_VERSION_DP_NFDK:
+ if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) {
+ PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d",
+ NFD_CFG_MAJOR_VERSION_of(hw->ver));
+ return -EINVAL;
+ }
+ return nfp_net_nfdk_tx_queue_setup(dev, queue_idx,
+ nb_desc, socket_id, tx_conf);
+ default:
+ PMD_DRV_LOG(ERR, "The version of firmware is not correct.");
+ return -EINVAL;
+ }
+}
+
static inline uint32_t
nfp_net_nfdk_free_tx_desc(struct nfp_net_txq *txq)
{
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 5c005d74e79b..fa90c3e8e751 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -342,12 +342,9 @@ int nfp_net_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
struct rte_mempool *mp);
void nfp_net_tx_queue_release(struct rte_eth_dev *dev, uint16_t queue_idx);
void nfp_net_reset_tx_queue(struct nfp_net_txq *txq);
-int nfp_net_nfd3_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);
uint16_t nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
-int nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
+int nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t queue_idx,
uint16_t nb_desc,
unsigned int socket_id,
--
2.37.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] net/nfp: use a single struct eth_dev_ops
2022-09-22 13:03 [PATCH 0/2] net/nfp: use a single struct eth_dev_ops Niklas Söderlund
2022-09-22 13:03 ` [PATCH 1/2] net/nfp: fix return value of nfp card init function Niklas Söderlund
2022-09-22 13:03 ` [PATCH 2/2] net/nfp: optimize ethdev struct Niklas Söderlund
@ 2022-10-05 16:51 ` Ferruh Yigit
2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2022-10-05 16:51 UTC (permalink / raw)
To: Niklas Söderlund, dev; +Cc: oss-drivers, Jin Liu, Chaoyong He
On 9/22/2022 2:03 PM, Niklas Söderlund wrote:
> Hi all,
>
> This small series aims to reduce code duplication by using a single
> shared struct eth_dev_ops for NFDk and NFD3.
>
> Patch 1/2 is a small bug fix that suck in when adding support for
> NFP3800 where the error code is not correctly propagated.
>
> Patch 2/2 is do the real work by merging the two existing structs and
> adding the small glue in the setup step that differenced them.
>
> Jin Liu (2):
> net/nfp: fix return value of nfp card init function
> net/nfp: optimize ethdev struct
>
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-05 16:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 13:03 [PATCH 0/2] net/nfp: use a single struct eth_dev_ops Niklas Söderlund
2022-09-22 13:03 ` [PATCH 1/2] net/nfp: fix return value of nfp card init function Niklas Söderlund
2022-09-22 13:03 ` [PATCH 2/2] net/nfp: optimize ethdev struct Niklas Söderlund
2022-10-05 16:51 ` [PATCH 0/2] net/nfp: use a single struct eth_dev_ops 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).