[3/6] net/ixgbe: use dynamic log type for tx/rx debug

Message ID 20190716154013.6974-4-stephen@networkplumber.org
State New
Delegated to: Ferruh Yigit
Headers show
Series
  • replace usage of LOGTYPE_PMD in Intel drivers
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger July 16, 2019, 3:40 p.m.
The generic RTE_LOGTYPE_PMD is a historical relic and should
not be used. Every driver must dynamic log types.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 27 +++++++++++++++++++++++++++
 drivers/net/ixgbe/ixgbe_logs.h   | 24 +++++++++++++++---------
 drivers/net/ixgbe/ixgbe_pf.c     | 19 ++++++++-----------
 3 files changed, 50 insertions(+), 20 deletions(-)

Comments

Ferruh Yigit Aug. 27, 2019, 8:24 a.m. | #1
On 7/16/2019 4:40 PM, Stephen Hemminger wrote:
> The generic RTE_LOGTYPE_PMD is a historical relic and should
> not be used. Every driver must dynamic log types.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

<...>

> @@ -161,16 +161,14 @@ ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)
>  	struct ixgbe_ethertype_filter ethertype_filter;
>  
>  	if (!hw->mac.ops.set_ethertype_anti_spoofing) {
> -		RTE_LOG(INFO, PMD, "ether type anti-spoofing is not"
> -			" supported.\n");
> +		PMD_DRV_LOG(INFO, "ether type anti-spoofing is not supported.\n");
>  		return;
>  	}
>  
>  	i = ixgbe_ethertype_filter_lookup(filter_info,
>  					  IXGBE_ETHERTYPE_FLOW_CTRL);
>  	if (i >= 0) {
> -		RTE_LOG(ERR, PMD, "A ether type filter"
> -			" entity for flow control already exists!\n");
> +		PMD_DRV_LOG(ERR, "A ether type filter entity for flow control already exists!\n");
>  		return;
>  	}
>  

This patch both adds dynamic log for Rx/Tx and converts log macro 'RTE_LOG' to
'PMD_DRV_LOG', can we separate these into two different patches?

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 22c5b2c5cabd..5c84fd046752 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -419,6 +419,16 @@  static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
 int ixgbe_logtype_init;
 int ixgbe_logtype_driver;
 
+#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
+int ixgbe_logtype_rx;
+#endif
+#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
+int ixgbe_logtype_tx;
+#endif
+#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
+int ixgbe_logtype_tx_free;
+#endif
+
 /*
  * The set of PCI devices this driver supports
  */
@@ -8732,4 +8742,21 @@  RTE_INIT(ixgbe_init_log)
 	ixgbe_logtype_driver = rte_log_register("pmd.net.ixgbe.driver");
 	if (ixgbe_logtype_driver >= 0)
 		rte_log_set_level(ixgbe_logtype_driver, RTE_LOG_NOTICE);
+#ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
+	ixgbe_logtype_rx = rte_log_register("pmd.net.ixgbe.rx");
+	if (ixgbe_logtype_rx >= 0)
+		rte_log_set_level(ixgbe_logtype_rx, RTE_LOG_NOTICE);
+#endif
+
+#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
+	ixgbe_logtype_tx = rte_log_register("pmd.net.ixgbe.tx");
+	if (ixgbe_logtype_tx >= 0)
+		rte_log_set_level(ixgbe_logtype_tx, RTE_LOG_NOTICE);
+#endif
+
+#ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
+	ixgbe_logtype_tx_free = rte_log_register("pmd.net.ixgbe.tx_free");
+	if (ixgbe_logtype_tx_free >= 0)
+		rte_log_set_level(ixgbe_logtype_tx_free, RTE_LOG_NOTICE);
+#endif
 }
diff --git a/drivers/net/ixgbe/ixgbe_logs.h b/drivers/net/ixgbe/ixgbe_logs.h
index dc73e9bded35..2a279d109813 100644
--- a/drivers/net/ixgbe/ixgbe_logs.h
+++ b/drivers/net/ixgbe/ixgbe_logs.h
@@ -13,24 +13,30 @@  extern int ixgbe_logtype_init;
 #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
 
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_RX
-#define PMD_RX_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+extern int ixgbe_logtype_rx;
+#define PMD_RX_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, ixgbe_logtype_rx,	\
+		"%s(): " fmt "\n", __func__, ## args)
 #else
-#define PMD_RX_LOG(level, fmt, args...) do { } while(0)
+#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX
-#define PMD_TX_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+extern int ixgbe_logtype_tx;
+#define PMD_TX_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, ixgbe_logtype_tx,	\
+		"%s(): " fmt "\n", __func__, ## args)
 #else
-#define PMD_TX_LOG(level, fmt, args...) do { } while(0)
+#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
 #endif
 
 #ifdef RTE_LIBRTE_IXGBE_DEBUG_TX_FREE
-#define PMD_TX_FREE_LOG(level, fmt, args...) \
-	RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
+extern int ixgbe_logtype_tx_free;
+#define PMD_TX_FREE_LOG(level, fmt, args...)			\
+	rte_log(RTE_LOG_ ## level, ixgbe_logtype_tx_free,	\
+		"%s(): " fmt "\n", __func__, ## args)
 #else
-#define PMD_TX_FREE_LOG(level, fmt, args...) do { } while(0)
+#define PMD_TX_FREE_LOG(level, fmt, args...) do { } while (0)
 #endif
 
 extern int ixgbe_logtype_driver;
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index c88d56e24564..a9e77f21c0de 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -161,16 +161,14 @@  ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)
 	struct ixgbe_ethertype_filter ethertype_filter;
 
 	if (!hw->mac.ops.set_ethertype_anti_spoofing) {
-		RTE_LOG(INFO, PMD, "ether type anti-spoofing is not"
-			" supported.\n");
+		PMD_DRV_LOG(INFO, "ether type anti-spoofing is not supported.\n");
 		return;
 	}
 
 	i = ixgbe_ethertype_filter_lookup(filter_info,
 					  IXGBE_ETHERTYPE_FLOW_CTRL);
 	if (i >= 0) {
-		RTE_LOG(ERR, PMD, "A ether type filter"
-			" entity for flow control already exists!\n");
+		PMD_DRV_LOG(ERR, "A ether type filter entity for flow control already exists!\n");
 		return;
 	}
 
@@ -183,8 +181,7 @@  ixgbe_add_tx_flow_control_drop_filter(struct rte_eth_dev *eth_dev)
 	i = ixgbe_ethertype_filter_insert(filter_info,
 					  &ethertype_filter);
 	if (i < 0) {
-		RTE_LOG(ERR, PMD, "Cannot find an unused ether type filter"
-			" entity for flow control.\n");
+		PMD_DRV_LOG(ERR, "Cannot find an unused ether type filter entity for flow control.\n");
 		return;
 	}
 
@@ -415,7 +412,7 @@  ixgbe_disable_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf)
 
 	vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
 
-	RTE_LOG(INFO, PMD, "VF %u: disabling multicast promiscuous\n", vf);
+	PMD_DRV_LOG(INFO, "VF %u: disabling multicast promiscuous\n", vf);
 
 	vmolr &= ~IXGBE_VMOLR_MPE;
 
@@ -588,7 +585,7 @@  ixgbe_negotiate_vf_api(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 		break;
 	}
 
-	RTE_LOG(ERR, PMD, "Negotiate invalid api version %u from VF %d\n",
+	PMD_DRV_LOG(ERR, "Negotiate invalid api version %u from VF %d\n",
 		api_version, vf);
 
 	return -1;
@@ -635,7 +632,7 @@  ixgbe_get_vf_queues(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	switch (eth_conf->txmode.mq_mode) {
 	case ETH_MQ_TX_NONE:
 	case ETH_MQ_TX_DCB:
-		RTE_LOG(ERR, PMD, "PF must work with virtualization for VF %u"
+		PMD_DRV_LOG(ERR, "PF must work with virtualization for VF %u"
 			", but its tx mode = %d\n", vf,
 			eth_conf->txmode.mq_mode);
 		return -1;
@@ -670,7 +667,7 @@  ixgbe_get_vf_queues(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 		break;
 
 	default:
-		RTE_LOG(ERR, PMD, "PF work with invalid mode = %d\n",
+		PMD_DRV_LOG(ERR, "PF work with invalid mode = %d\n",
 			eth_conf->txmode.mq_mode);
 		return -1;
 	}
@@ -725,7 +722,7 @@  ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 		fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
 		if (!(fctrl & IXGBE_FCTRL_UPE)) {
 			/* VF promisc requires PF in promisc */
-			RTE_LOG(ERR, PMD,
+			PMD_DRV_LOG(ERR,
 			       "Enabling VF promisc requires PF in promisc\n");
 			return -1;
 		}