All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ethdev: support dynamic logging
@ 2018-03-13 11:07 Ferruh Yigit
  2018-03-13 12:38 ` Shreyansh Jain
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2018-03-13 11:07 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 77628cc05..ef9bf102a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -40,6 +40,11 @@
 #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__)
+
 static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data";
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
 static uint8_t eth_dev_last_created_port;
@@ -276,13 +281,14 @@ rte_eth_dev_allocate(const char *name)
 
 	port_id = rte_eth_dev_find_free_port();
 	if (port_id == RTE_MAX_ETHPORTS) {
-		RTE_LOG(ERR, EAL, "Reached maximum number of Ethernet ports\n");
+		ethdev_log(ERR, "Reached maximum number of Ethernet ports");
 		goto unlock;
 	}
 
 	if (rte_eth_dev_allocated(name) != NULL) {
-		RTE_LOG(ERR, EAL, "Ethernet Device with name %s already allocated!\n",
-				name);
+		ethdev_log(ERR,
+			"Ethernet Device with name %s already allocated!",
+			name);
 		goto unlock;
 	}
 
@@ -614,7 +620,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()) {
-		RTE_LOG(ERR, EAL, "No port found for device (%s)\n", name);
+		ethdev_log(ERR, "No port found for device (%s)", name);
 		ret = -1;
 		goto err;
 	}
@@ -652,8 +658,8 @@ rte_eth_dev_detach(uint16_t port_id, char *name)
 
 	dev_flags = rte_eth_devices[port_id].data->dev_flags;
 	if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {
-		RTE_LOG(ERR, EAL, "Port %" PRIu16 " is bonded, cannot detach\n",
-			port_id);
+		ethdev_log(ERR,
+			"Port %" PRIu16 " is bonded, cannot detach", port_id);
 		ret = -ENOTSUP;
 		goto err;
 	}
@@ -3214,7 +3220,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) {
-		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		ethdev_log(ERR, "Invalid port_id=%d", port_id);
 		return -EINVAL;
 	}
 
@@ -3277,7 +3283,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) {
-		RTE_LOG(ERR, EAL, "Invalid port_id=%d\n", port_id);
+		ethdev_log(ERR, "Invalid port_id=%d", port_id);
 		return -EINVAL;
 	}
 
@@ -4016,3 +4022,12 @@ rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool)
 
 	return (*dev->dev_ops->pool_ops_supported)(dev, pool);
 }
+
+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);
+}
-- 
2.13.6

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

* Re: [PATCH] ethdev: support dynamic logging
  2018-03-13 11:07 [PATCH] ethdev: support dynamic logging Ferruh Yigit
@ 2018-03-13 12:38 ` Shreyansh Jain
  2018-03-27 18:34   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Shreyansh Jain @ 2018-03-13 12:38 UTC (permalink / raw)
  To: Ferruh Yigit, Thomas Monjalon; +Cc: dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
> Sent: Tuesday, March 13, 2018 4:37 PM
> To: Thomas Monjalon <thomas@monjalon.net>
> Cc: dev@dpdk.org; Ferruh Yigit <ferruh.yigit@intel.com>
> Subject: [dpdk-dev] [PATCH] ethdev: support dynamic logging
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---

Reviewed-by: Shreyansh Jain <Shreyansh.jain@nxp.com>

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

* Re: [PATCH] ethdev: support dynamic logging
  2018-03-13 12:38 ` Shreyansh Jain
@ 2018-03-27 18:34   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2018-03-27 18:34 UTC (permalink / raw)
  To: Shreyansh Jain, Thomas Monjalon; +Cc: dev

On 3/13/2018 12:38 PM, Shreyansh Jain wrote:
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
>> Sent: Tuesday, March 13, 2018 4:37 PM
>> To: Thomas Monjalon <thomas@monjalon.net>
>> Cc: dev@dpdk.org; Ferruh Yigit <ferruh.yigit@intel.com>
>> Subject: [dpdk-dev] [PATCH] ethdev: support dynamic logging
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
> 
> Reviewed-by: Shreyansh Jain <Shreyansh.jain@nxp.com>

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

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

end of thread, other threads:[~2018-03-27 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-13 11:07 [PATCH] ethdev: support dynamic logging Ferruh Yigit
2018-03-13 12:38 ` Shreyansh Jain
2018-03-27 18:34   ` Ferruh Yigit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.