diff mbox series

[v4,1/3] ethdev: move log macro to header

Message ID 20180619010457.61490-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series [v4,1/3] ethdev: move log macro to header | expand

Checks

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

Commit Message

Ferruh Yigit June 19, 2018, 1:04 a.m. UTC
Macro moved to header to be able to convert logging usage in header.
And since it has been moved to public header changed naming and added
RTE prefix, ethdev_log -> RTE_ETHDEV_LOG

Also need to add logtype variable to map file since logging macro used
from other libraries.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2:
* updated commit log

v3: no update

v4:
* rename logtype variable to rte_eth_dev_logtype
* add logtype variable to .map file
---
 lib/librte_ethdev/rte_ethdev.c           | 37 ++++++++++++------------
 lib/librte_ethdev/rte_ethdev.h           |  5 ++++
 lib/librte_ethdev/rte_ethdev_version.map |  7 +++++
 3 files changed, 30 insertions(+), 19 deletions(-)

Comments

Andrew Rybchenko June 19, 2018, 1:02 p.m. UTC | #1
On 06/19/2018 04:04 AM, Ferruh Yigit wrote:
> Macro moved to header to be able to convert logging usage in header.
> And since it has been moved to public header changed naming and added
> RTE prefix, ethdev_log -> RTE_ETHDEV_LOG
>
> Also need to add logtype variable to map file since logging macro used
> from other libraries.
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Shahaf Shuler June 26, 2018, 11:41 a.m. UTC | #2
Tuesday, June 19, 2018 4:05 AM, Ferruh Yigit:
> Subject: [dpdk-dev] [PATCH v4 1/3] ethdev: move log macro to header
> 
> Macro moved to header to be able to convert logging usage in header.
> And since it has been moved to public header changed naming and added
> RTE prefix, ethdev_log -> RTE_ETHDEV_LOG
> 
> Also need to add logtype variable to map file since logging macro used from
> other libraries.
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

For the series, 
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
Thomas Monjalon June 26, 2018, 12:25 p.m. UTC | #3
26/06/2018 13:41, Shahaf Shuler:
> Tuesday, June 19, 2018 4:05 AM, Ferruh Yigit:
> > Subject: [dpdk-dev] [PATCH v4 1/3] ethdev: move log macro to header
> > 
> > Macro moved to header to be able to convert logging usage in header.
> > And since it has been moved to public header changed naming and added
> > RTE prefix, ethdev_log -> RTE_ETHDEV_LOG
> > 
> > Also need to add logtype variable to map file since logging macro used from
> > other libraries.
> > 
> > Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 
> For the series, 
> Acked-by: Shahaf Shuler <shahafs@mellanox.com>

Series Acked-by: Thomas Monjalon <thomas@monjalon.net>
Ferruh Yigit June 26, 2018, 3:52 p.m. UTC | #4
On 6/26/2018 1:25 PM, Thomas Monjalon wrote:
> 26/06/2018 13:41, Shahaf Shuler:
>> Tuesday, June 19, 2018 4:05 AM, Ferruh Yigit:
>>> Subject: [dpdk-dev] [PATCH v4 1/3] ethdev: move log macro to header
>>>
>>> Macro moved to header to be able to convert logging usage in header.
>>> And since it has been moved to public header changed naming and added
>>> RTE prefix, ethdev_log -> RTE_ETHDEV_LOG
>>>
>>> Also need to add logtype variable to map file since logging macro used from
>>> other libraries.
>>>
>>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>>
>> For the series, 
>> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
> 
> Series Acked-by: Thomas Monjalon <thomas@monjalon.net>

Series applied to dpdk-next-net/master, thanks.
diff mbox series

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index a9977df97..2f696bfa9 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -42,10 +42,7 @@ 
 #include "rte_ethdev_driver.h"
 #include "ethdev_profile.h"
 
-static int ethdev_logtype;
-
-#define ethdev_log(level, fmt, ...) \
-	rte_log(RTE_LOG_ ## level, ethdev_logtype, fmt "\n", ## __VA_ARGS__)
+int rte_eth_dev_logtype;
 
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
@@ -303,14 +300,16 @@  rte_eth_dev_allocate(const char *name)
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
 	if (_rte_eth_dev_allocated(name) != NULL) {
-		ethdev_log(ERR, "Ethernet device with name %s already allocated",
-				name);
+		RTE_ETHDEV_LOG(ERR,
+			"Ethernet device with name %s already allocated\n",
+			name);
 		goto unlock;
 	}
 
 	port_id = rte_eth_dev_find_free_port();
 	if (port_id == RTE_MAX_ETHPORTS) {
-		ethdev_log(ERR, "Reached maximum number of Ethernet ports");
+		RTE_ETHDEV_LOG(ERR,
+			"Reached maximum number of Ethernet ports\n");
 		goto unlock;
 	}
 
@@ -663,7 +662,7 @@  rte_eth_dev_attach(const char *devargs, uint16_t *port_id)
 
 	/* no point looking at the port count if no port exists */
 	if (!rte_eth_dev_count_total()) {
-		ethdev_log(ERR, "No port found for device (%s)", da.name);
+		RTE_ETHDEV_LOG(ERR, "No port found for device (%s)\n", da.name);
 		ret = -1;
 		goto err;
 	}
@@ -698,8 +697,8 @@  rte_eth_dev_detach(uint16_t port_id, char *name __rte_unused)
 
 	dev_flags = rte_eth_devices[port_id].data->dev_flags;
 	if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
-		ethdev_log(ERR,
-			"Port %" PRIu16 " is bonded, cannot detach", port_id);
+		RTE_ETHDEV_LOG(ERR,
+			"Port %" PRIu16 " is bonded, cannot detach\n", port_id);
 		return -ENOTSUP;
 	}
 
@@ -1164,7 +1163,7 @@  rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	/* Any requested offloading must be within its device capabilities */
 	if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) !=
 	     local_conf.rxmode.offloads) {
-		ethdev_log(ERR, "ethdev port_id=%d requested Rx offloads "
+		RTE_ETHDEV_LOG(ERR, "ethdev port_id=%d requested Rx offloads "
 				"0x%" PRIx64 " doesn't match Rx offloads "
 				"capabilities 0x%" PRIx64 " in %s()\n",
 				port_id,
@@ -1175,7 +1174,7 @@  rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	}
 	if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) !=
 	     local_conf.txmode.offloads) {
-		ethdev_log(ERR, "ethdev port_id=%d requested Tx offloads "
+		RTE_ETHDEV_LOG(ERR, "ethdev port_id=%d requested Tx offloads "
 				"0x%" PRIx64 " doesn't match Tx offloads "
 				"capabilities 0x%" PRIx64 " in %s()\n",
 				port_id,
@@ -1572,7 +1571,7 @@  rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	 */
 	if ((local_conf.offloads & dev_info.rx_queue_offload_capa) !=
 	     local_conf.offloads) {
-		ethdev_log(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
+		RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%d rx_queue_id=%d, new "
 				"added offloads 0x%" PRIx64 " must be "
 				"within pre-queue offload capabilities 0x%"
 				PRIx64 " in %s()\n",
@@ -1737,7 +1736,7 @@  rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 	 */
 	if ((local_conf.offloads & dev_info.tx_queue_offload_capa) !=
 	     local_conf.offloads) {
-		ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new "
+		RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%d tx_queue_id=%d, new "
 				"added offloads 0x%" PRIx64 " must be "
 				"within pre-queue offload capabilities 0x%"
 				PRIx64 " in %s()\n",
@@ -3343,7 +3342,7 @@  rte_eth_dev_callback_register(uint16_t port_id,
 		return -EINVAL;
 
 	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
-		ethdev_log(ERR, "Invalid port_id=%d", port_id);
+		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -3406,7 +3405,7 @@  rte_eth_dev_callback_unregister(uint16_t port_id,
 		return -EINVAL;
 
 	if (!rte_eth_dev_is_valid_port(port_id) && port_id != RTE_ETH_ALL) {
-		ethdev_log(ERR, "Invalid port_id=%d", port_id);
+		RTE_ETHDEV_LOG(ERR, "Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -4522,7 +4521,7 @@  RTE_INIT(ethdev_init_log);
 static void
 ethdev_init_log(void)
 {
-	ethdev_logtype = rte_log_register("lib.ethdev");
-	if (ethdev_logtype >= 0)
-		rte_log_set_level(ethdev_logtype, RTE_LOG_INFO);
+	rte_eth_dev_logtype = rte_log_register("lib.ethdev");
+	if (rte_eth_dev_logtype >= 0)
+		rte_log_set_level(rte_eth_dev_logtype, RTE_LOG_INFO);
 }
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 36e3984ea..24f4b93b7 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -159,6 +159,11 @@  extern "C" {
 #include "rte_eth_ctrl.h"
 #include "rte_dev_info.h"
 
+extern int rte_eth_dev_logtype;
+
+#define RTE_ETHDEV_LOG(level, ...) \
+	rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
+
 struct rte_mbuf;
 
 /**
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index 40cf42b8a..9a0d12d41 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -213,6 +213,13 @@  DPDK_18.05 {
 
 } DPDK_18.02;
 
+DPDK_18.08 {
+	global:
+
+	rte_eth_dev_logtype;
+
+} DPDK_18.05;
+
 EXPERIMENTAL {
 	global: