[1/8] net/nfp: break out function to report device information

Message ID 20221128065359.12737-2-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Add the features for nfp include VLAN strip, QinQ strip, VLAN insert |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Chaoyong He Nov. 28, 2022, 6:53 a.m. UTC
  From: Peng Zhang <peng.zhang@corigine.com>

The method to report device information to the log is the same for both
physical and virtual functions. The implementation is however open coded
in each code path, break out the reporting logic to a helper
function to reduce code duplication.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/nfp_common.c    | 27 +++++++++++++++++++++++++++
 drivers/net/nfp/nfp_common.h    |  1 +
 drivers/net/nfp/nfp_ethdev.c    | 23 +----------------------
 drivers/net/nfp/nfp_ethdev_vf.c | 23 +----------------------
 4 files changed, 30 insertions(+), 44 deletions(-)
  

Comments

Nole Zhang Jan. 16, 2023, 2:24 a.m. UTC | #1
Hi all,

A gentle ping on this patch.

> -----Original Message-----
> From: Chaoyong He <chaoyong.he@corigine.com>
> Sent: 2022年11月28日 14:54
> To: dev@dpdk.org
> Cc: oss-drivers <oss-drivers@corigine.com>; Niklas Soderlund
> <niklas.soderlund@corigine.com>; Nole Zhang <peng.zhang@corigine.com>;
> Chaoyong He <chaoyong.he@corigine.com>
> Subject: [PATCH 1/8] net/nfp: break out function to report device
> information
> 
> From: Peng Zhang <peng.zhang@corigine.com>
> 
> The method to report device information to the log is the same for both
> physical and virtual functions. The implementation is however open coded in
> each code path, break out the reporting logic to a helper function to reduce
> code duplication.
> 
> Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> ---
>  drivers/net/nfp/nfp_common.c    | 27 +++++++++++++++++++++++++++
>  drivers/net/nfp/nfp_common.h    |  1 +
>  drivers/net/nfp/nfp_ethdev.c    | 23 +----------------------
>  drivers/net/nfp/nfp_ethdev_vf.c | 23 +----------------------
>  4 files changed, 30 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
> index 71711bfa22..f112a70980 100644
> --- a/drivers/net/nfp/nfp_common.c
> +++ b/drivers/net/nfp/nfp_common.c
> @@ -188,6 +188,33 @@ nfp_net_configure(struct rte_eth_dev *dev)
>  	return 0;
>  }
> 
> +void
> +nfp_net_log_device_information(const struct nfp_net_hw *hw) {
> +	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
> +			NFD_CFG_MAJOR_VERSION_of(hw->ver),
> +			NFD_CFG_MINOR_VERSION_of(hw->ver), hw-
> >max_mtu);
> +
> +	PMD_INIT_LOG(INFO,
> "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
> +			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ?
> "PROMISC "   : "",
> +			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT
> "  : "",
> +			hw->cap & NFP_NET_CFG_CTRL_L2MC      ?
> "L2MCFILT "  : "",
> +			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ?
> "RXCSUM "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ?
> "TXCSUM "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN
> "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN
> "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ?
> "SCATTER "   : "",
> +			hw->cap & NFP_NET_CFG_CTRL_GATHER    ?
> "GATHER "    : "",
> +			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ?
> "LIVE_ADDR " : "",
> +			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       :
> "",
> +			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2
> "     : "",
> +			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       :
> "",
> +			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     :
> "");
> +
> +	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
> +			hw->max_rx_queues, hw->max_tx_queues); }
> +
>  void
>  nfp_net_enable_queues(struct rte_eth_dev *dev)  { diff --git
> a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h index
> 36c19b47e4..02612dbb58 100644
> --- a/drivers/net/nfp/nfp_common.h
> +++ b/drivers/net/nfp/nfp_common.h
> @@ -404,6 +404,7 @@ nfp_pci_queue(struct rte_pci_device *pdev, uint16_t
> queue)
>  /* Prototypes for common NFP functions */  int nfp_net_reconfig(struct
> nfp_net_hw *hw, uint32_t ctrl, uint32_t update);  int
> nfp_net_configure(struct rte_eth_dev *dev);
> +void nfp_net_log_device_information(const struct nfp_net_hw *hw);
>  void nfp_net_enable_queues(struct rte_eth_dev *dev);  void
> nfp_net_disable_queues(struct rte_eth_dev *dev);  void
> nfp_net_params_setup(struct nfp_net_hw *hw); diff --git
> a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index
> 0956ea81df..f661819fc0 100644
> --- a/drivers/net/nfp/nfp_ethdev.c
> +++ b/drivers/net/nfp/nfp_ethdev.c
> @@ -619,33 +619,12 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
>  	else
>  		hw->rx_offset = nn_cfg_readl(hw,
> NFP_NET_CFG_RX_OFFSET_ADDR);
> 
> -	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
> -			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
> -			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw-
> >max_mtu);
> -
> -	PMD_INIT_LOG(INFO,
> "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
> -		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR
> "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
> -
>  	hw->ctrl = 0;
> 
>  	hw->stride_rx = stride;
>  	hw->stride_tx = stride;
> 
> -	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
> -		     hw->max_rx_queues, hw->max_tx_queues);
> +	nfp_net_log_device_information(hw);
> 
>  	/* Initializing spinlock for reconfigs */
>  	rte_spinlock_init(&hw->reconfig_lock);
> diff --git a/drivers/net/nfp/nfp_ethdev_vf.c
> b/drivers/net/nfp/nfp_ethdev_vf.c index d1427b63bc..170f7eeb93 100644
> --- a/drivers/net/nfp/nfp_ethdev_vf.c
> +++ b/drivers/net/nfp/nfp_ethdev_vf.c
> @@ -376,33 +376,12 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
>  	else
>  		hw->rx_offset = nn_cfg_readl(hw,
> NFP_NET_CFG_RX_OFFSET_ADDR);
> 
> -	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
> -			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
> -			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw-
> >max_mtu);
> -
> -	PMD_INIT_LOG(INFO,
> "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
> -		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  :
> "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR
> "  : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
> -		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
> -
>  	hw->ctrl = 0;
> 
>  	hw->stride_rx = stride;
>  	hw->stride_tx = stride;
> 
> -	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
> -		     hw->max_rx_queues, hw->max_tx_queues);
> +	nfp_net_log_device_information(hw);
> 
>  	/* Initializing spinlock for reconfigs */
>  	rte_spinlock_init(&hw->reconfig_lock);
> --
> 2.29.3
  

Patch

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 71711bfa22..f112a70980 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -188,6 +188,33 @@  nfp_net_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+void
+nfp_net_log_device_information(const struct nfp_net_hw *hw)
+{
+	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
+			NFD_CFG_MAJOR_VERSION_of(hw->ver),
+			NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
+
+	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
+			hw->cap & NFP_NET_CFG_CTRL_PROMISC   ? "PROMISC "   : "",
+			hw->cap & NFP_NET_CFG_CTRL_L2BC      ? "L2BCFILT "  : "",
+			hw->cap & NFP_NET_CFG_CTRL_L2MC      ? "L2MCFILT "  : "",
+			hw->cap & NFP_NET_CFG_CTRL_RXCSUM    ? "RXCSUM "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_TXCSUM    ? "TXCSUM "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_RXVLAN    ? "RXVLAN "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_TXVLAN    ? "TXVLAN "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_SCATTER   ? "SCATTER "   : "",
+			hw->cap & NFP_NET_CFG_CTRL_GATHER    ? "GATHER "    : "",
+			hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR " : "",
+			hw->cap & NFP_NET_CFG_CTRL_LSO       ? "TSO "       : "",
+			hw->cap & NFP_NET_CFG_CTRL_LSO2      ? "TSOv2 "     : "",
+			hw->cap & NFP_NET_CFG_CTRL_RSS       ? "RSS "       : "",
+			hw->cap & NFP_NET_CFG_CTRL_RSS2      ? "RSSv2 "     : "");
+
+	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
+			hw->max_rx_queues, hw->max_tx_queues);
+}
+
 void
 nfp_net_enable_queues(struct rte_eth_dev *dev)
 {
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 36c19b47e4..02612dbb58 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -404,6 +404,7 @@  nfp_pci_queue(struct rte_pci_device *pdev, uint16_t queue)
 /* Prototypes for common NFP functions */
 int nfp_net_reconfig(struct nfp_net_hw *hw, uint32_t ctrl, uint32_t update);
 int nfp_net_configure(struct rte_eth_dev *dev);
+void nfp_net_log_device_information(const struct nfp_net_hw *hw);
 void nfp_net_enable_queues(struct rte_eth_dev *dev);
 void nfp_net_disable_queues(struct rte_eth_dev *dev);
 void nfp_net_params_setup(struct nfp_net_hw *hw);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 0956ea81df..f661819fc0 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -619,33 +619,12 @@  nfp_net_init(struct rte_eth_dev *eth_dev)
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
-			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
-			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
-
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
-
 	hw->ctrl = 0;
 
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
-	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
-		     hw->max_rx_queues, hw->max_tx_queues);
+	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
 	rte_spinlock_init(&hw->reconfig_lock);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index d1427b63bc..170f7eeb93 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -376,33 +376,12 @@  nfp_netvf_init(struct rte_eth_dev *eth_dev)
 	else
 		hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
 
-	PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
-			   NFD_CFG_MAJOR_VERSION_of(hw->ver),
-			   NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
-
-	PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
-		     hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2BC    ? "L2BCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_L2MC    ? "L2MCFILT " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXCSUM  ? "RXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXCSUM  ? "TXCSUM "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RXVLAN  ? "RXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_TXVLAN  ? "TXVLAN "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_SCATTER ? "SCATTER " : "",
-		     hw->cap & NFP_NET_CFG_CTRL_GATHER  ? "GATHER "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR ? "LIVE_ADDR "  : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO     ? "TSO "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_LSO2     ? "TSOv2 "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS     ? "RSS "     : "",
-		     hw->cap & NFP_NET_CFG_CTRL_RSS2     ? "RSSv2 "     : "");
-
 	hw->ctrl = 0;
 
 	hw->stride_rx = stride;
 	hw->stride_tx = stride;
 
-	PMD_INIT_LOG(INFO, "max_rx_queues: %u, max_tx_queues: %u",
-		     hw->max_rx_queues, hw->max_tx_queues);
+	nfp_net_log_device_information(hw);
 
 	/* Initializing spinlock for reconfigs */
 	rte_spinlock_init(&hw->reconfig_lock);