net/nfp: fix the Tx performance issue
Checks
Commit Message
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(-)
Comments
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.
@@ -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) {
@@ -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) {
@@ -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;
@@ -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;
@@ -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;
@@ -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;