patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] net/nfp: fix the Tx performance issue
@ 2023-10-13  7:46 Chaoyong He
  2023-10-16 12:50 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Chaoyong He @ 2023-10-13  7:46 UTC (permalink / raw)
  To: dev
  Cc: oss-drivers, Zerun Fu, shihong.wang, stable, Long Wu, Peng Zhang,
	Chaoyong He

From: Zerun Fu <zerun.fu@corigine.com>

The former commit imports a register read operation into the data path
logic, which will severely degrade performance.
Fix this bug by moving the register read logic out of the data path.
Read 'cap_extend' only once in the initialisation logic and store it
in the data structure. And all other logics that need this value should
get it from the data structure.

Fixes: 310a1780581e ("net/nfp: support IPsec Rx and Tx offload")
Cc: shihong.wang@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 2 +-
 drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 2 +-
 drivers/net/nfp/nfp_common.c       | 3 ++-
 drivers/net/nfp/nfp_common.h       | 1 +
 drivers/net/nfp/nfp_ethdev.c       | 2 +-
 drivers/net/nfp/nfp_ipsec.c        | 4 ++--
 6 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 64928254d8..8e3199e9b6 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -153,7 +153,7 @@ nfp_net_nfd3_set_meta_data(struct nfp_net_meta_raw *meta_data,
 	uint8_t ipsec_layer = 0;
 
 	hw = txq->hw;
-	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	cap_extend = hw->cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index d4bd5edb0a..80b48a3f16 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -186,7 +186,7 @@ nfp_net_nfdk_set_meta_data(struct rte_mbuf *pkt,
 
 	memset(&meta_data, 0, sizeof(meta_data));
 	hw = txq->hw;
-	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	cap_extend = hw->cap_ext;
 
 	if ((pkt->ol_flags & RTE_MBUF_F_TX_VLAN) != 0 &&
 			(hw->ctrl & NFP_NET_CFG_CTRL_TXVLAN_V2) != 0) {
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 5683afc40a..59da28a182 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -1257,7 +1257,7 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	if (hw->cap & NFP_NET_CFG_CTRL_GATHER)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) != 0) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SECURITY;
 		dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_SECURITY;
@@ -1348,6 +1348,7 @@ nfp_net_common_init(struct rte_pci_device *pci_dev,
 
 	/* Get some of the read-only fields from the config BAR */
 	hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
+	hw->cap_ext = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
 	hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
 	hw->flbufsz = DEFAULT_FLBUF_SIZE;
 
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index bc3a948231..3c89519195 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -120,6 +120,7 @@ struct nfp_net_hw {
 	struct rte_eth_dev *eth_dev;
 
 	/* Info from the firmware */
+	uint32_t cap_ext;
 	struct nfp_net_fw_ver ver;
 	uint32_t cap;
 	uint32_t max_mtu;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index ebc5538291..85fcb08bd9 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -137,7 +137,7 @@ nfp_net_start(struct rte_eth_dev *dev)
 		return -EIO;
 
 	/* Enable packet type offload by extend ctrl word1. */
-	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_PKT_TYPE) != 0)
 		ctrl_extend = NFP_NET_CFG_CTRL_PKT_TYPE;
 
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index 9edb096a58..a76ba2a91d 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -1382,7 +1382,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return 0;
@@ -1429,7 +1429,7 @@ nfp_ipsec_uninit(struct rte_eth_dev *dev)
 
 	hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-	cap_extend = nn_cfg_readl(hw, NFP_NET_CFG_CAP_WORD1);
+	cap_extend = hw->cap_ext;
 	if ((cap_extend & NFP_NET_CFG_CTRL_IPSEC) == 0) {
 		PMD_INIT_LOG(INFO, "Unsupported IPsec extend capability");
 		return;
-- 
2.39.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/nfp: fix the Tx performance issue
  2023-10-13  7:46 [PATCH] net/nfp: fix the Tx performance issue Chaoyong He
@ 2023-10-16 12:50 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2023-10-16 12:50 UTC (permalink / raw)
  To: Chaoyong He, dev
  Cc: oss-drivers, Zerun Fu, shihong.wang, stable, Long Wu, Peng Zhang

On 10/13/2023 8:46 AM, Chaoyong He wrote:
> From: Zerun Fu <zerun.fu@corigine.com>
> 
> The former commit imports a register read operation into the data path
> logic, which will severely degrade performance.
> Fix this bug by moving the register read logic out of the data path.
> Read 'cap_extend' only once in the initialisation logic and store it
> in the data structure. And all other logics that need this value should
> get it from the data structure.
> 
> Fixes: 310a1780581e ("net/nfp: support IPsec Rx and Tx offload")
> Cc: shihong.wang@corigine.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
> Reviewed-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-16 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13  7:46 [PATCH] net/nfp: fix the Tx performance issue Chaoyong He
2023-10-16 12:50 ` 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).