* [PATCH 0/3] replace use of EAL logtype @ 2023-12-11 17:23 Stephen Hemminger 2023-12-11 17:23 ` [PATCH 1/3] testpmd: replace EAL logtype with fprintf Stephen Hemminger ` (7 more replies) 0 siblings, 8 replies; 33+ messages in thread From: Stephen Hemminger @ 2023-12-11 17:23 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger There are some places EAL logtype is being used in testpmd and examples where it should not be. Lets reserve EAL logtype to only be used by DPDK internals. Stephen Hemminger (3): testpmd: replace EAL logtype with fprintf examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype app/test-pmd/testpmd.c | 33 +++++++++++--------------------- examples/l2fwd-keepalive/shm.c | 21 +++++++------------- examples/vm_power_manager/main.c | 11 ++++------- 3 files changed, 22 insertions(+), 43 deletions(-) -- 2.42.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 1/3] testpmd: replace EAL logtype with fprintf 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger @ 2023-12-11 17:23 ` Stephen Hemminger 2023-12-12 11:51 ` lihuisong (C) 2023-12-11 17:23 ` [PATCH 2/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger ` (6 subsequent siblings) 7 siblings, 1 reply; 33+ messages in thread From: Stephen Hemminger @ 2023-12-11 17:23 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Aman Singh, Yuying Zhang Testpmd is misusing EAL logtype for its own errors. Since the code directly calls fprintf in other places, change to use that everywhere. This has the added benefit of not having testpmd output clutter up syslog(). Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- app/test-pmd/testpmd.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 9e4e99e53b9a..aa350d61e451 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3413,8 +3413,7 @@ stop_port(portid_t pid) ret = eth_dev_stop_mp(pi); if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); + fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", pi); /* Allow to retry stopping the port. */ port->port_status = RTE_PORT_STARTED; continue; @@ -3812,23 +3811,20 @@ pmd_test_exit(void) if (hot_plug) { ret = rte_dev_event_monitor_stop(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to stop device event monitor."); + fprintf(stderr, "fail to stop device event monitor."); return; } ret = rte_dev_event_callback_unregister(NULL, dev_event_callback, NULL); if (ret < 0) { - RTE_LOG(ERR, EAL, - "fail to unregister device event callback.\n"); + fprintf(stderr, "fail to unregister device event callback.\n"); return; } ret = rte_dev_hotplug_handle_disable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to disable hotplug handling.\n"); + fprintf(stderr, "fail to disable hotplug handling.\n"); return; } } @@ -4062,12 +4058,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, switch (type) { case RTE_DEV_EVENT_REMOVE: - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", - device_name); + fprintf(stderr, "The device: %s has been removed!\n", device_name); ret = rte_eth_dev_get_port_by_name(device_name, &port_id); if (ret) { - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", - device_name); + fprintf(stderr, "Can not get port by device %s!\n", device_name); return; } /* @@ -4081,12 +4075,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, */ if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - RTE_LOG(ERR, EAL, - "Could not set up deferred device removal\n"); + fprintf(stderr, "Could not set up deferred device removal\n"); break; case RTE_DEV_EVENT_ADD: - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", - device_name); + fprintf(stderr, "The device: %s has been added!\n", device_name); /* TODO: After finish kernel driver binding, * begin to attach port. */ @@ -4632,23 +4624,20 @@ main(int argc, char** argv) if (hot_plug) { ret = rte_dev_hotplug_handle_enable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to enable hotplug handling."); + fprintf(stderr, "fail to enable hotplug handling."); return -1; } ret = rte_dev_event_monitor_start(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to start device event monitoring."); + fprintf(stderr, "fail to start device event monitoring."); return -1; } ret = rte_dev_event_callback_register(NULL, dev_event_callback, NULL); if (ret) { - RTE_LOG(ERR, EAL, - "fail to register device event callback\n"); + fprintf(stderr, "fail to register device event callback\n"); return -1; } } -- 2.42.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 1/3] testpmd: replace EAL logtype with fprintf 2023-12-11 17:23 ` [PATCH 1/3] testpmd: replace EAL logtype with fprintf Stephen Hemminger @ 2023-12-12 11:51 ` lihuisong (C) 0 siblings, 0 replies; 33+ messages in thread From: lihuisong (C) @ 2023-12-12 11:51 UTC (permalink / raw) To: Stephen Hemminger, dev; +Cc: Aman Singh, Yuying Zhang With belows to changes, Acked-by: Huisong Li <lihuisong@huawei.com> 在 2023/12/12 1:23, Stephen Hemminger 写道: > Testpmd is misusing EAL logtype for its own errors. > Since the code directly calls fprintf in other places, > change to use that everywhere. This has the added benefit > of not having testpmd output clutter up syslog(). > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > --- > app/test-pmd/testpmd.c | 33 +++++++++++---------------------- > 1 file changed, 11 insertions(+), 22 deletions(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index 9e4e99e53b9a..aa350d61e451 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -3413,8 +3413,7 @@ stop_port(portid_t pid) > > ret = eth_dev_stop_mp(pi); > if (ret != 0) { > - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", > - pi); > + fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", pi); > /* Allow to retry stopping the port. */ > port->port_status = RTE_PORT_STARTED; > continue; > @@ -3812,23 +3811,20 @@ pmd_test_exit(void) > if (hot_plug) { > ret = rte_dev_event_monitor_stop(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to stop device event monitor."); > + fprintf(stderr, "fail to stop device event monitor."); > return; > } > > ret = rte_dev_event_callback_unregister(NULL, > dev_event_callback, NULL); > if (ret < 0) { > - RTE_LOG(ERR, EAL, > - "fail to unregister device event callback.\n"); > + fprintf(stderr, "fail to unregister device event callback.\n"); > return; > } > > ret = rte_dev_hotplug_handle_disable(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to disable hotplug handling.\n"); > + fprintf(stderr, "fail to disable hotplug handling.\n"); > return; > } > } > @@ -4062,12 +4058,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, > > switch (type) { > case RTE_DEV_EVENT_REMOVE: > - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", > - device_name); > + fprintf(stderr, "The device: %s has been removed!\n", device_name); > ret = rte_eth_dev_get_port_by_name(device_name, &port_id); > if (ret) { > - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", > - device_name); > + fprintf(stderr, "Can not get port by device %s!\n", device_name); > return; > } > /* > @@ -4081,12 +4075,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, > */ > if (rte_eal_alarm_set(100000, > rmv_port_callback, (void *)(intptr_t)port_id)) > - RTE_LOG(ERR, EAL, > - "Could not set up deferred device removal\n"); > + fprintf(stderr, "Could not set up deferred device removal\n"); > break; > case RTE_DEV_EVENT_ADD: > - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", > - device_name); > + fprintf(stderr, "The device: %s has been added!\n", device_name); > /* TODO: After finish kernel driver binding, > * begin to attach port. > */ > @@ -4632,23 +4624,20 @@ main(int argc, char** argv) > if (hot_plug) { > ret = rte_dev_hotplug_handle_enable(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to enable hotplug handling."); > + fprintf(stderr, "fail to enable hotplug handling."); > return -1; > } > > ret = rte_dev_event_monitor_start(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to start device event monitoring."); > + fprintf(stderr, "fail to start device event monitoring."); > return -1; > } > > ret = rte_dev_event_callback_register(NULL, > dev_event_callback, NULL); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to register device event callback\n"); > + fprintf(stderr, "fail to register device event callback\n"); two space is here. Can you fix it by the way? > return -1; > } > } ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 2/3] examples/l2fwd-keepalive: don't use EAL logtype 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger 2023-12-11 17:23 ` [PATCH 1/3] testpmd: replace EAL logtype with fprintf Stephen Hemminger @ 2023-12-11 17:23 ` Stephen Hemminger 2023-12-12 11:53 ` lihuisong (C) 2023-12-11 17:23 ` [PATCH 3/3] examples/vm_power_manager: do not " Stephen Hemminger ` (5 subsequent siblings) 7 siblings, 1 reply; 33+ messages in thread From: Stephen Hemminger @ 2023-12-11 17:23 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger EAL logtype should be reserved for EAL library. This example is already using printf() so just print errors to stderr. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- examples/l2fwd-keepalive/shm.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c index 7c7a9ea8ea3c..cbeeb511ef07 100644 --- a/examples/l2fwd-keepalive/shm.c +++ b/examples/l2fwd-keepalive/shm.c @@ -5,7 +5,6 @@ #include <time.h> #include <rte_common.h> -#include <rte_log.h> #include <rte_keepalive.h> #include "shm.h" @@ -28,28 +27,23 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void) fd = shm_open(RTE_KEEPALIVE_SHM_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666); if (fd < 0) - RTE_LOG(INFO, EAL, - "Failed to open %s as SHM (%s)\n", - RTE_KEEPALIVE_SHM_NAME, - strerror(errno)); + fprintf(stderr, "Failed to open %s as SHM (%s)\n", + RTE_KEEPALIVE_SHM_NAME, strerror(errno)); else if (ftruncate(fd, sizeof(struct rte_keepalive_shm)) != 0) - RTE_LOG(INFO, EAL, - "Failed to resize SHM (%s)\n", strerror(errno)); + fprintf(stderr, "Failed to resize SHM (%s)\n", strerror(errno)); else { ka_shm = (struct rte_keepalive_shm *) mmap( 0, sizeof(struct rte_keepalive_shm), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); if (ka_shm == MAP_FAILED) - RTE_LOG(INFO, EAL, - "Failed to mmap SHM (%s)\n", strerror(errno)); + fprintf(stderr, "Failed to mmap SHM (%s)\n", strerror(errno)); else { memset(ka_shm, 0, sizeof(struct rte_keepalive_shm)); /* Initialize the semaphores for IPC/SHM use */ if (sem_init(&ka_shm->core_died, 1, 0) != 0) { - RTE_LOG(INFO, EAL, - "Failed to setup SHM semaphore (%s)\n", + fprintf(stderr, "Failed to setup SHM semaphore (%s)\n", strerror(errno)); munmap(ka_shm, sizeof(struct rte_keepalive_shm)); @@ -87,7 +81,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, * ka_agent is not active. */ if (sem_getvalue(&shm->core_died, &count) == -1) { - RTE_LOG(INFO, EAL, "Semaphore check failed(%s)\n", + fprintf(stderr, "Semaphore check failed(%s)\n", strerror(errno)); return; } @@ -95,8 +89,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, return; if (sem_post(&shm->core_died) != 0) - RTE_LOG(INFO, EAL, - "Failed to increment semaphore (%s)\n", + fprintf(stderr, "Failed to increment semaphore (%s)\n", strerror(errno)); } } -- 2.42.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 2/3] examples/l2fwd-keepalive: don't use EAL logtype 2023-12-11 17:23 ` [PATCH 2/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2023-12-12 11:53 ` lihuisong (C) 0 siblings, 0 replies; 33+ messages in thread From: lihuisong (C) @ 2023-12-12 11:53 UTC (permalink / raw) To: Stephen Hemminger, dev Acked-by: Huisong Li <lihuisong@huawei.com> 在 2023/12/12 1:23, Stephen Hemminger 写道: > EAL logtype should be reserved for EAL library. > This example is already using printf() so just print > errors to stderr. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > --- > examples/l2fwd-keepalive/shm.c | 21 +++++++-------------- > 1 file changed, 7 insertions(+), 14 deletions(-) > > diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c > index 7c7a9ea8ea3c..cbeeb511ef07 100644 > --- a/examples/l2fwd-keepalive/shm.c > +++ b/examples/l2fwd-keepalive/shm.c > @@ -5,7 +5,6 @@ > #include <time.h> > > #include <rte_common.h> > -#include <rte_log.h> > #include <rte_keepalive.h> > > #include "shm.h" > @@ -28,28 +27,23 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void) > fd = shm_open(RTE_KEEPALIVE_SHM_NAME, > O_CREAT | O_TRUNC | O_RDWR, 0666); > if (fd < 0) > - RTE_LOG(INFO, EAL, > - "Failed to open %s as SHM (%s)\n", > - RTE_KEEPALIVE_SHM_NAME, > - strerror(errno)); > + fprintf(stderr, "Failed to open %s as SHM (%s)\n", > + RTE_KEEPALIVE_SHM_NAME, strerror(errno)); > else if (ftruncate(fd, sizeof(struct rte_keepalive_shm)) != 0) > - RTE_LOG(INFO, EAL, > - "Failed to resize SHM (%s)\n", strerror(errno)); > + fprintf(stderr, "Failed to resize SHM (%s)\n", strerror(errno)); > else { > ka_shm = (struct rte_keepalive_shm *) mmap( > 0, sizeof(struct rte_keepalive_shm), > PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); > close(fd); > if (ka_shm == MAP_FAILED) > - RTE_LOG(INFO, EAL, > - "Failed to mmap SHM (%s)\n", strerror(errno)); > + fprintf(stderr, "Failed to mmap SHM (%s)\n", strerror(errno)); > else { > memset(ka_shm, 0, sizeof(struct rte_keepalive_shm)); > > /* Initialize the semaphores for IPC/SHM use */ > if (sem_init(&ka_shm->core_died, 1, 0) != 0) { > - RTE_LOG(INFO, EAL, > - "Failed to setup SHM semaphore (%s)\n", > + fprintf(stderr, "Failed to setup SHM semaphore (%s)\n", > strerror(errno)); > munmap(ka_shm, > sizeof(struct rte_keepalive_shm)); > @@ -87,7 +81,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, > * ka_agent is not active. > */ > if (sem_getvalue(&shm->core_died, &count) == -1) { > - RTE_LOG(INFO, EAL, "Semaphore check failed(%s)\n", > + fprintf(stderr, "Semaphore check failed(%s)\n", > strerror(errno)); > return; > } > @@ -95,8 +89,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, > return; > > if (sem_post(&shm->core_died) != 0) > - RTE_LOG(INFO, EAL, > - "Failed to increment semaphore (%s)\n", > + fprintf(stderr, "Failed to increment semaphore (%s)\n", > strerror(errno)); > } > } ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH 3/3] examples/vm_power_manager: do not use EAL logtype 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger 2023-12-11 17:23 ` [PATCH 1/3] testpmd: replace EAL logtype with fprintf Stephen Hemminger 2023-12-11 17:23 ` [PATCH 2/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2023-12-11 17:23 ` Stephen Hemminger 2023-12-12 11:24 ` Hunt, David 2023-12-12 11:53 ` lihuisong (C) 2023-12-11 19:19 ` [PATCH 0/3] replace use of " Tyler Retzlaff ` (4 subsequent siblings) 7 siblings, 2 replies; 33+ messages in thread From: Stephen Hemminger @ 2023-12-11 17:23 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Anatoly Burakov, David Hunt, Sivaprasad Tummala Be consistent for all the error printouts and use fprintf(). The EAL logtype is reserved for internal use by EAL. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> --- examples/vm_power_manager/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index b159291d77ce..c14138202004 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -17,7 +17,6 @@ #include <rte_common.h> #include <rte_eal.h> #include <rte_launch.h> -#include <rte_log.h> #include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_ethdev.h> @@ -425,8 +424,7 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(-1, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } printf("Running channel monitor on lcore id %d\n", lcore_id); @@ -434,16 +432,15 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(lcore_id, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } if (power_manager_init() < 0) { - printf("Unable to initialize power manager\n"); + fprintf(stderr, "Unable to initialize power manager\n"); return -1; } if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) { - printf("Unable to initialize channel manager\n"); + fprintf(stderr, "Unable to initialize channel manager\n"); return -1; } -- 2.42.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/3] examples/vm_power_manager: do not use EAL logtype 2023-12-11 17:23 ` [PATCH 3/3] examples/vm_power_manager: do not " Stephen Hemminger @ 2023-12-12 11:24 ` Hunt, David 2023-12-12 11:53 ` lihuisong (C) 1 sibling, 0 replies; 33+ messages in thread From: Hunt, David @ 2023-12-12 11:24 UTC (permalink / raw) To: Stephen Hemminger, dev; +Cc: Anatoly Burakov, Sivaprasad Tummala On 11/12/2023 17:23, Stephen Hemminger wrote: > Be consistent for all the error printouts and use fprintf(). > The EAL logtype is reserved for internal use by EAL. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > --- > examples/vm_power_manager/main.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c > index b159291d77ce..c14138202004 100644 > --- a/examples/vm_power_manager/main.c > +++ b/examples/vm_power_manager/main.c --snip-- Acked-by: David Hunt <david.hunt@intel.com> > ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 3/3] examples/vm_power_manager: do not use EAL logtype 2023-12-11 17:23 ` [PATCH 3/3] examples/vm_power_manager: do not " Stephen Hemminger 2023-12-12 11:24 ` Hunt, David @ 2023-12-12 11:53 ` lihuisong (C) 1 sibling, 0 replies; 33+ messages in thread From: lihuisong (C) @ 2023-12-12 11:53 UTC (permalink / raw) To: Stephen Hemminger, dev; +Cc: Anatoly Burakov, David Hunt, Sivaprasad Tummala Acked-by: Huisong Li <lihuisong@huawei.com> 在 2023/12/12 1:23, Stephen Hemminger 写道: > Be consistent for all the error printouts and use fprintf(). > The EAL logtype is reserved for internal use by EAL. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > --- > examples/vm_power_manager/main.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c > index b159291d77ce..c14138202004 100644 > --- a/examples/vm_power_manager/main.c > +++ b/examples/vm_power_manager/main.c > @@ -17,7 +17,6 @@ > #include <rte_common.h> > #include <rte_eal.h> > #include <rte_launch.h> > -#include <rte_log.h> > #include <rte_per_lcore.h> > #include <rte_lcore.h> > #include <rte_ethdev.h> > @@ -425,8 +424,7 @@ main(int argc, char **argv) > > lcore_id = rte_get_next_lcore(-1, 1, 0); > if (lcore_id == RTE_MAX_LCORE) { > - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " > - "application\n"); > + fprintf(stderr, "A minimum of three cores are required to run application\n"); > return 0; > } > printf("Running channel monitor on lcore id %d\n", lcore_id); > @@ -434,16 +432,15 @@ main(int argc, char **argv) > > lcore_id = rte_get_next_lcore(lcore_id, 1, 0); > if (lcore_id == RTE_MAX_LCORE) { > - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " > - "application\n"); > + fprintf(stderr, "A minimum of three cores are required to run application\n"); > return 0; > } > if (power_manager_init() < 0) { > - printf("Unable to initialize power manager\n"); > + fprintf(stderr, "Unable to initialize power manager\n"); > return -1; > } > if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) { > - printf("Unable to initialize channel manager\n"); > + fprintf(stderr, "Unable to initialize channel manager\n"); > return -1; > } > ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 0/3] replace use of EAL logtype 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger ` (2 preceding siblings ...) 2023-12-11 17:23 ` [PATCH 3/3] examples/vm_power_manager: do not " Stephen Hemminger @ 2023-12-11 19:19 ` Tyler Retzlaff 2023-12-11 20:15 ` Stephen Hemminger 2023-12-12 8:01 ` David Marchand 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger ` (3 subsequent siblings) 7 siblings, 2 replies; 33+ messages in thread From: Tyler Retzlaff @ 2023-12-11 19:19 UTC (permalink / raw) To: Stephen Hemminger; +Cc: dev On Mon, Dec 11, 2023 at 09:23:22AM -0800, Stephen Hemminger wrote: > There are some places EAL logtype is being used in testpmd > and examples where it should not be. Lets reserve EAL > logtype to only be used by DPDK internals. > > Stephen Hemminger (3): > testpmd: replace EAL logtype with fprintf > examples/l2fwd-keepalive: don't use EAL logtype > examples/vm_power_manager: do not use EAL logtype > > app/test-pmd/testpmd.c | 33 +++++++++++--------------------- > examples/l2fwd-keepalive/shm.c | 21 +++++++------------- > examples/vm_power_manager/main.c | 11 ++++------- are the log types under ALLOW_INTERNAL_API? if not should they be? and if they are should examples be defining ALLOW_INTERNAL_API? just curious. ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 0/3] replace use of EAL logtype 2023-12-11 19:19 ` [PATCH 0/3] replace use of " Tyler Retzlaff @ 2023-12-11 20:15 ` Stephen Hemminger 2023-12-12 8:01 ` David Marchand 1 sibling, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2023-12-11 20:15 UTC (permalink / raw) To: Tyler Retzlaff; +Cc: dev On Mon, 11 Dec 2023 11:19:31 -0800 Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > On Mon, Dec 11, 2023 at 09:23:22AM -0800, Stephen Hemminger wrote: > > There are some places EAL logtype is being used in testpmd > > and examples where it should not be. Lets reserve EAL > > logtype to only be used by DPDK internals. > > > > Stephen Hemminger (3): > > testpmd: replace EAL logtype with fprintf > > examples/l2fwd-keepalive: don't use EAL logtype > > examples/vm_power_manager: do not use EAL logtype > > > > app/test-pmd/testpmd.c | 33 +++++++++++--------------------- > > examples/l2fwd-keepalive/shm.c | 21 +++++++------------- > > examples/vm_power_manager/main.c | 11 ++++------- > > are the log types under ALLOW_INTERNAL_API? if not should they be? and > if they are should examples be defining ALLOW_INTERNAL_API? > > just curious. > No they never were under ALLOW_INTERNAL_API. They should have been, but a little late now to change. ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH 0/3] replace use of EAL logtype 2023-12-11 19:19 ` [PATCH 0/3] replace use of " Tyler Retzlaff 2023-12-11 20:15 ` Stephen Hemminger @ 2023-12-12 8:01 ` David Marchand 1 sibling, 0 replies; 33+ messages in thread From: David Marchand @ 2023-12-12 8:01 UTC (permalink / raw) To: Tyler Retzlaff; +Cc: Stephen Hemminger, dev On Mon, Dec 11, 2023 at 8:19 PM Tyler Retzlaff <roretzla@linux.microsoft.com> wrote: > > On Mon, Dec 11, 2023 at 09:23:22AM -0800, Stephen Hemminger wrote: > > There are some places EAL logtype is being used in testpmd > > and examples where it should not be. Lets reserve EAL > > logtype to only be used by DPDK internals. > > > > Stephen Hemminger (3): > > testpmd: replace EAL logtype with fprintf > > examples/l2fwd-keepalive: don't use EAL logtype > > examples/vm_power_manager: do not use EAL logtype > > > > app/test-pmd/testpmd.c | 33 +++++++++++--------------------- > > examples/l2fwd-keepalive/shm.c | 21 +++++++------------- > > examples/vm_power_manager/main.c | 11 ++++------- > > are the log types under ALLOW_INTERNAL_API? if not should they be? and > if they are should examples be defining ALLOW_INTERNAL_API? ALLOW_INTERNAL_API and ALLOW_EXPERIMENTAL_API tags have a transitive aspect. So it would prevent applications from calling inline helpers and macros with such logs in them. Like for example: lib/eal/include/rte_test.h: RTE_LOG(ERR, EAL, "Test assert %s line %d failed: " \ The EAL logtype is "easy" to fix, but others like ETHDEV are more tricky. -- David Marchand ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v2 0/3] replace use of EAL logtype in applications 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger ` (3 preceding siblings ...) 2023-12-11 19:19 ` [PATCH 0/3] replace use of " Tyler Retzlaff @ 2024-02-16 3:36 ` Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger ` (3 more replies) 2024-03-08 18:10 ` [PATCH v3 " Stephen Hemminger ` (2 subsequent siblings) 7 siblings, 4 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-02-16 3:36 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger There are some places EAL logtype is being used in testpmd and examples where it should not be. Lets reserve EAL logtype to only be used by DPDK internals. v2 - use TESTPMD_LOG() in testpmd log changes Stephen Hemminger (3): examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype testpmd: replace EAL logtype TESTPMD_LOG app/test-pmd/testpmd.c | 42 ++++++++++++-------------------- examples/l2fwd-keepalive/shm.c | 21 ++++++---------- examples/vm_power_manager/main.c | 11 +++------ 3 files changed, 26 insertions(+), 48 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger @ 2024-02-16 3:36 ` Stephen Hemminger 2024-02-16 8:04 ` Morten Brørup 2024-02-16 3:36 ` [PATCH v2 2/3] examples/vm_power_manager: do not " Stephen Hemminger ` (2 subsequent siblings) 3 siblings, 1 reply; 33+ messages in thread From: Stephen Hemminger @ 2024-02-16 3:36 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li EAL logtype should be reserved for EAL library. This example is already using printf() so just print errors to stderr. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> --- examples/l2fwd-keepalive/shm.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c index 7c7a9ea8ea3c..cbeeb511ef07 100644 --- a/examples/l2fwd-keepalive/shm.c +++ b/examples/l2fwd-keepalive/shm.c @@ -5,7 +5,6 @@ #include <time.h> #include <rte_common.h> -#include <rte_log.h> #include <rte_keepalive.h> #include "shm.h" @@ -28,28 +27,23 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void) fd = shm_open(RTE_KEEPALIVE_SHM_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666); if (fd < 0) - RTE_LOG(INFO, EAL, - "Failed to open %s as SHM (%s)\n", - RTE_KEEPALIVE_SHM_NAME, - strerror(errno)); + fprintf(stderr, "Failed to open %s as SHM (%s)\n", + RTE_KEEPALIVE_SHM_NAME, strerror(errno)); else if (ftruncate(fd, sizeof(struct rte_keepalive_shm)) != 0) - RTE_LOG(INFO, EAL, - "Failed to resize SHM (%s)\n", strerror(errno)); + fprintf(stderr, "Failed to resize SHM (%s)\n", strerror(errno)); else { ka_shm = (struct rte_keepalive_shm *) mmap( 0, sizeof(struct rte_keepalive_shm), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); if (ka_shm == MAP_FAILED) - RTE_LOG(INFO, EAL, - "Failed to mmap SHM (%s)\n", strerror(errno)); + fprintf(stderr, "Failed to mmap SHM (%s)\n", strerror(errno)); else { memset(ka_shm, 0, sizeof(struct rte_keepalive_shm)); /* Initialize the semaphores for IPC/SHM use */ if (sem_init(&ka_shm->core_died, 1, 0) != 0) { - RTE_LOG(INFO, EAL, - "Failed to setup SHM semaphore (%s)\n", + fprintf(stderr, "Failed to setup SHM semaphore (%s)\n", strerror(errno)); munmap(ka_shm, sizeof(struct rte_keepalive_shm)); @@ -87,7 +81,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, * ka_agent is not active. */ if (sem_getvalue(&shm->core_died, &count) == -1) { - RTE_LOG(INFO, EAL, "Semaphore check failed(%s)\n", + fprintf(stderr, "Semaphore check failed(%s)\n", strerror(errno)); return; } @@ -95,8 +89,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, return; if (sem_post(&shm->core_died) != 0) - RTE_LOG(INFO, EAL, - "Failed to increment semaphore (%s)\n", + fprintf(stderr, "Failed to increment semaphore (%s)\n", strerror(errno)); } } -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* RE: [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype 2024-02-16 3:36 ` [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2024-02-16 8:04 ` Morten Brørup 0 siblings, 0 replies; 33+ messages in thread From: Morten Brørup @ 2024-02-16 8:04 UTC (permalink / raw) To: Stephen Hemminger, dev; +Cc: Huisong Li > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Friday, 16 February 2024 04.36 > > EAL logtype should be reserved for EAL library. > This example is already using printf() so just print > errors to stderr. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > Acked-by: Huisong Li <lihuisong@huawei.com> > --- Optionally, please consider using RTE_LOG(INFO, L2FWD, ...) instead. This would require #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 in the shm.c file too, or defining it in a common header for the two C files. And while you are at it, shm.c also has a couple of printf for warnings; please consider converting those too. Either to RTE_LOG(INFO, L2FWD, ...) or to fprintf(stderr, ...). Anyway... Acked-by: Morten Brørup <mb@smartsharesystems.com> ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v2 2/3] examples/vm_power_manager: do not use EAL logtype 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2024-02-16 3:36 ` Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2024-02-18 3:16 ` [PATCH v2 0/3] replace use of EAL logtype in applications fengchengwen 3 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-02-16 3:36 UTC (permalink / raw) To: dev Cc: Stephen Hemminger, David Hunt, Huisong Li, Anatoly Burakov, Sivaprasad Tummala Be consistent for all the error printouts and use fprintf(). The EAL logtype is reserved for internal use by EAL. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: David Hunt <david.hunt@intel.com> Acked-by: Huisong Li <lihuisong@huawei.com> --- examples/vm_power_manager/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index b159291d77ce..c14138202004 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -17,7 +17,6 @@ #include <rte_common.h> #include <rte_eal.h> #include <rte_launch.h> -#include <rte_log.h> #include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_ethdev.h> @@ -425,8 +424,7 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(-1, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } printf("Running channel monitor on lcore id %d\n", lcore_id); @@ -434,16 +432,15 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(lcore_id, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } if (power_manager_init() < 0) { - printf("Unable to initialize power manager\n"); + fprintf(stderr, "Unable to initialize power manager\n"); return -1; } if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) { - printf("Unable to initialize channel manager\n"); + fprintf(stderr, "Unable to initialize channel manager\n"); return -1; } -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 2/3] examples/vm_power_manager: do not " Stephen Hemminger @ 2024-02-16 3:36 ` Stephen Hemminger 2024-03-08 13:35 ` Singh, Aman Deep 2024-02-18 3:16 ` [PATCH v2 0/3] replace use of EAL logtype in applications fengchengwen 3 siblings, 1 reply; 33+ messages in thread From: Stephen Hemminger @ 2024-02-16 3:36 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Aman Singh, Yuying Zhang Testpmd is misusing EAL logtype for some errors. Since the code directly has a macro for logging, use that. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> fix testpmd --- app/test-pmd/testpmd.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 9e4e99e53b9a..249e934a3013 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3413,8 +3413,8 @@ stop_port(portid_t pid) ret = eth_dev_stop_mp(pi); if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); + TESTPMD_LOG(ERR, + "rte_eth_dev_stop failed for port %u\n", pi); /* Allow to retry stopping the port. */ port->port_status = RTE_PORT_STARTED; continue; @@ -3423,8 +3423,7 @@ stop_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, "Port %d can not be set into stopped\n", - pi); + TESTPMD_LOG(ERR, "Port %d can not be set into stopped\n", pi); need_check_link_status = 1; } if (need_check_link_status && !no_link_check) @@ -3812,23 +3811,20 @@ pmd_test_exit(void) if (hot_plug) { ret = rte_dev_event_monitor_stop(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to stop device event monitor."); + TESTPMD_LOG(ERR, "fail to stop device event monitor."); return; } ret = rte_dev_event_callback_unregister(NULL, dev_event_callback, NULL); if (ret < 0) { - RTE_LOG(ERR, EAL, - "fail to unregister device event callback.\n"); + TESTPMD_LOG(ERR, "fail to unregister device event callback.\n"); return; } ret = rte_dev_hotplug_handle_disable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to disable hotplug handling.\n"); + TESTPMD_LOG(ERR, "fail to disable hotplug handling.\n"); return; } } @@ -4062,12 +4058,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, switch (type) { case RTE_DEV_EVENT_REMOVE: - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been removed!\n", device_name); ret = rte_eth_dev_get_port_by_name(device_name, &port_id); if (ret) { - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", - device_name); + fprintf(stderr, "Can not get port by device %s!\n", device_name); return; } /* @@ -4081,12 +4075,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, */ if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - RTE_LOG(ERR, EAL, - "Could not set up deferred device removal\n"); + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); break; case RTE_DEV_EVENT_ADD: - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been added!\n", device_name); /* TODO: After finish kernel driver binding, * begin to attach port. */ @@ -4632,23 +4624,19 @@ main(int argc, char** argv) if (hot_plug) { ret = rte_dev_hotplug_handle_enable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to enable hotplug handling."); + TESTPMD_LOG(ERR, "fail to enable hotplug handling."); return -1; } ret = rte_dev_event_monitor_start(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to start device event monitoring."); + TESTPMD_LOG(ERR, "fail to start device event monitoring."); return -1; } - ret = rte_dev_event_callback_register(NULL, - dev_event_callback, NULL); + ret = rte_dev_event_callback_register(NULL, dev_event_callback, NULL); if (ret) { - RTE_LOG(ERR, EAL, - "fail to register device event callback\n"); + TESTPMD_LOG(ERR, "fail to register device event callback\n"); return -1; } } @@ -4658,7 +4646,7 @@ main(int argc, char** argv) rte_eal_cleanup(); rte_exit(EXIT_FAILURE, "Start ports failed\n"); } - fprintf(stderr, "Start ports failed\n"); + TESTPMD_LOG(ERR, "Start ports failed\n"); } /* set all ports to promiscuous mode by default */ -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-02-16 3:36 ` [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger @ 2024-03-08 13:35 ` Singh, Aman Deep 2024-03-08 16:26 ` Stephen Hemminger 0 siblings, 1 reply; 33+ messages in thread From: Singh, Aman Deep @ 2024-03-08 13:35 UTC (permalink / raw) To: Stephen Hemminger, dev; +Cc: Huisong Li, Yuying Zhang On 2/16/2024 9:06 AM, Stephen Hemminger wrote: > Testpmd is misusing EAL logtype for some errors. > Since the code directly has a macro for logging, use that. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > Acked-by: Huisong Li <lihuisong@huawei.com> > > fix testpmd > --- > app/test-pmd/testpmd.c | 42 +++++++++++++++--------------------------- > 1 file changed, 15 insertions(+), 27 deletions(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index 9e4e99e53b9a..249e934a3013 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -3413,8 +3413,8 @@ stop_port(portid_t pid) > > ret = eth_dev_stop_mp(pi); > if (ret != 0) { > - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", > - pi); > + TESTPMD_LOG(ERR, > + "rte_eth_dev_stop failed for port %u\n", pi); > /* Allow to retry stopping the port. */ > port->port_status = RTE_PORT_STARTED; > continue; > @@ -3423,8 +3423,7 @@ stop_port(portid_t pid) > if (port->port_status == RTE_PORT_HANDLING) > port->port_status = RTE_PORT_STOPPED; > else > - fprintf(stderr, "Port %d can not be set into stopped\n", > - pi); > + TESTPMD_LOG(ERR, "Port %d can not be set into stopped\n", pi); > need_check_link_status = 1; > } > if (need_check_link_status && !no_link_check) > @@ -3812,23 +3811,20 @@ pmd_test_exit(void) > if (hot_plug) { > ret = rte_dev_event_monitor_stop(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to stop device event monitor."); > + TESTPMD_LOG(ERR, "fail to stop device event monitor."); > return; > } > > ret = rte_dev_event_callback_unregister(NULL, > dev_event_callback, NULL); > if (ret < 0) { > - RTE_LOG(ERR, EAL, > - "fail to unregister device event callback.\n"); > + TESTPMD_LOG(ERR, "fail to unregister device event callback.\n"); > return; > } > > ret = rte_dev_hotplug_handle_disable(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to disable hotplug handling.\n"); > + TESTPMD_LOG(ERR, "fail to disable hotplug handling.\n"); > return; > } > } > @@ -4062,12 +4058,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, > > switch (type) { > case RTE_DEV_EVENT_REMOVE: > - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", > - device_name); > + TESTPMD_LOG(INFO, "The device: %s has been removed!\n", device_name); > ret = rte_eth_dev_get_port_by_name(device_name, &port_id); > if (ret) { > - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", > - device_name); > + fprintf(stderr, "Can not get port by device %s!\n", device_name); Any specific reason to use fprintf() here rather than TESTPMD_LOG > return; > } > /* > @@ -4081,12 +4075,10 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, > */ > if (rte_eal_alarm_set(100000, > rmv_port_callback, (void *)(intptr_t)port_id)) > - RTE_LOG(ERR, EAL, > - "Could not set up deferred device removal\n"); > + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); > break; > case RTE_DEV_EVENT_ADD: > - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", > - device_name); > + TESTPMD_LOG(INFO, "The device: %s has been added!\n", device_name); > /* TODO: After finish kernel driver binding, > * begin to attach port. > */ > @@ -4632,23 +4624,19 @@ main(int argc, char** argv) > if (hot_plug) { > ret = rte_dev_hotplug_handle_enable(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to enable hotplug handling."); > + TESTPMD_LOG(ERR, "fail to enable hotplug handling."); > return -1; > } > > ret = rte_dev_event_monitor_start(); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to start device event monitoring."); > + TESTPMD_LOG(ERR, "fail to start device event monitoring."); > return -1; > } > > - ret = rte_dev_event_callback_register(NULL, > - dev_event_callback, NULL); > + ret = rte_dev_event_callback_register(NULL, dev_event_callback, NULL); > if (ret) { > - RTE_LOG(ERR, EAL, > - "fail to register device event callback\n"); > + TESTPMD_LOG(ERR, "fail to register device event callback\n"); > return -1; > } > } > @@ -4658,7 +4646,7 @@ main(int argc, char** argv) > rte_eal_cleanup(); > rte_exit(EXIT_FAILURE, "Start ports failed\n"); > } > - fprintf(stderr, "Start ports failed\n"); > + TESTPMD_LOG(ERR, "Start ports failed\n"); > } > > /* set all ports to promiscuous mode by default */ ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-03-08 13:35 ` Singh, Aman Deep @ 2024-03-08 16:26 ` Stephen Hemminger 0 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 16:26 UTC (permalink / raw) To: Singh, Aman Deep; +Cc: dev, Huisong Li, Yuying Zhang On Fri, 8 Mar 2024 19:05:32 +0530 "Singh, Aman Deep" <aman.deep.singh@intel.com> wrote: > > if (ret) { > > - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", > > - device_name); > > + fprintf(stderr, "Can not get port by device %s!\n", device_name); > > Any specific reason to use fprintf() here rather than TESTPMD_LOG No. Just that was done in earlier version. ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v2 0/3] replace use of EAL logtype in applications 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger ` (2 preceding siblings ...) 2024-02-16 3:36 ` [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger @ 2024-02-18 3:16 ` fengchengwen 3 siblings, 0 replies; 33+ messages in thread From: fengchengwen @ 2024-02-18 3:16 UTC (permalink / raw) To: Stephen Hemminger, dev Series-acked-by: Chengwen Feng <fengchengwen@huawei.com> On 2024/2/16 11:36, Stephen Hemminger wrote: > There are some places EAL logtype is being used in testpmd > and examples where it should not be. Lets reserve EAL > logtype to only be used by DPDK internals. > > v2 - use TESTPMD_LOG() in testpmd log changes > > Stephen Hemminger (3): > examples/l2fwd-keepalive: don't use EAL logtype > examples/vm_power_manager: do not use EAL logtype > testpmd: replace EAL logtype TESTPMD_LOG > > app/test-pmd/testpmd.c | 42 ++++++++++++-------------------- > examples/l2fwd-keepalive/shm.c | 21 ++++++---------- > examples/vm_power_manager/main.c | 11 +++------ > 3 files changed, 26 insertions(+), 48 deletions(-) > ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v3 0/3] replace use of EAL logtype in applications 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger ` (4 preceding siblings ...) 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger @ 2024-03-08 18:10 ` Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger ` (2 more replies) 2024-03-08 22:33 ` [PATCH v4 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger 7 siblings, 3 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 18:10 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger There are some places EAL logtype is being used in testpmd and examples where it should not be. Lets reserve EAL logtype to only be used by DPDK internals. Stephen Hemminger (3): examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype testpmd: replace EAL logtype TESTPMD_LOG v3 - rebase, review feedback: use RTE_LOG in more places in l2fwd-keepalive replace more fprintf(stderr,...) in testpmd app/test-pmd/testpmd.c | 221 +++++++++++++++---------------- examples/l2fwd-keepalive/main.c | 2 - examples/l2fwd-keepalive/shm.c | 29 ++-- examples/l2fwd-keepalive/shm.h | 5 + examples/vm_power_manager/main.c | 11 +- 5 files changed, 125 insertions(+), 143 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v3 1/3] examples/l2fwd-keepalive: don't use EAL logtype 2024-03-08 18:10 ` [PATCH v3 " Stephen Hemminger @ 2024-03-08 18:10 ` Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 2/3] examples/vm_power_manager: do not " Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 18:10 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Morten Brørup EAL logtype should be reserved for EAL library. This example is already has a log wrapper so use it. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> --- examples/l2fwd-keepalive/main.c | 2 -- examples/l2fwd-keepalive/shm.c | 29 ++++++++++++----------------- examples/l2fwd-keepalive/shm.h | 5 +++++ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 1463cef0fc2e..dca944fc173f 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -41,8 +41,6 @@ #include "shm.h" -#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 - #define NB_MBUF_PER_PORT 3000 #define MAX_PKT_BURST 32 diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c index 7c7a9ea8ea3c..8e8c9c9c4e83 100644 --- a/examples/l2fwd-keepalive/shm.c +++ b/examples/l2fwd-keepalive/shm.c @@ -5,7 +5,6 @@ #include <time.h> #include <rte_common.h> -#include <rte_log.h> #include <rte_keepalive.h> #include "shm.h" @@ -22,34 +21,30 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void) * will get the new block mapped below. */ if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT) - printf("Warning: Error unlinking stale %s (%s)\n", + RTE_LOG(NOTICE, L2FWD, + "Warning: Error unlinking stale %s (%s)\n", RTE_KEEPALIVE_SHM_NAME, strerror(errno)); fd = shm_open(RTE_KEEPALIVE_SHM_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666); if (fd < 0) - RTE_LOG(INFO, EAL, - "Failed to open %s as SHM (%s)\n", - RTE_KEEPALIVE_SHM_NAME, - strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to open %s as SHM (%s)\n", + RTE_KEEPALIVE_SHM_NAME, strerror(errno)); else if (ftruncate(fd, sizeof(struct rte_keepalive_shm)) != 0) - RTE_LOG(INFO, EAL, - "Failed to resize SHM (%s)\n", strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to resize SHM (%s)\n", strerror(errno)); else { ka_shm = (struct rte_keepalive_shm *) mmap( 0, sizeof(struct rte_keepalive_shm), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); if (ka_shm == MAP_FAILED) - RTE_LOG(INFO, EAL, - "Failed to mmap SHM (%s)\n", strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to mmap SHM (%s)\n", strerror(errno)); else { memset(ka_shm, 0, sizeof(struct rte_keepalive_shm)); /* Initialize the semaphores for IPC/SHM use */ if (sem_init(&ka_shm->core_died, 1, 0) != 0) { - RTE_LOG(INFO, EAL, - "Failed to setup SHM semaphore (%s)\n", + RTE_LOG(ERR, L2FWD, "Failed to setup SHM semaphore (%s)\n", strerror(errno)); munmap(ka_shm, sizeof(struct rte_keepalive_shm)); @@ -87,7 +82,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, * ka_agent is not active. */ if (sem_getvalue(&shm->core_died, &count) == -1) { - RTE_LOG(INFO, EAL, "Semaphore check failed(%s)\n", + RTE_LOG(ERR, L2FWD, "Semaphore check failed(%s)\n", strerror(errno)); return; } @@ -95,8 +90,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, return; if (sem_post(&shm->core_died) != 0) - RTE_LOG(INFO, EAL, - "Failed to increment semaphore (%s)\n", + RTE_LOG(ERR, L2FWD, "Failed to increment semaphore (%s)\n", strerror(errno)); } } @@ -104,9 +98,10 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, void rte_keepalive_shm_cleanup(struct rte_keepalive_shm *ka_shm) { if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT) - printf("Warning: Error unlinking %s (%s)\n", + RTE_LOG(NOTICE, L2FWD, "Warning: Error unlinking %s (%s)\n", RTE_KEEPALIVE_SHM_NAME, strerror(errno)); if (ka_shm && munmap(ka_shm, sizeof(struct rte_keepalive_shm)) != 0) - printf("Warning: munmap() failed\n"); + RTE_LOG(ERR, L2FWD, "Warning: munmap() failed: %s \n", + strerror(errno)); } diff --git a/examples/l2fwd-keepalive/shm.h b/examples/l2fwd-keepalive/shm.h index 7a9d597295e0..d6941e25b3d7 100644 --- a/examples/l2fwd-keepalive/shm.h +++ b/examples/l2fwd-keepalive/shm.h @@ -7,13 +7,18 @@ #define RTE_KEEPALIVE_SHM_ALIVE 1 #define RTE_KEEPALIVE_SHM_DEAD 2 + #include <fcntl.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> #include <sys/stat.h> #include <semaphore.h> + #include <rte_keepalive.h> +#include <rte_log.h> + +#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 /** * Keepalive SHM structure. -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v3 2/3] examples/vm_power_manager: do not use EAL logtype 2024-03-08 18:10 ` [PATCH v3 " Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2024-03-08 18:10 ` Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 18:10 UTC (permalink / raw) To: dev Cc: Stephen Hemminger, David Hunt, Huisong Li, Anatoly Burakov, Sivaprasad Tummala Be consistent for all the error printouts and use fprintf(). The EAL logtype is reserved for internal use by EAL. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: David Hunt <david.hunt@intel.com> Acked-by: Huisong Li <lihuisong@huawei.com> --- examples/vm_power_manager/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index b159291d77ce..c14138202004 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -17,7 +17,6 @@ #include <rte_common.h> #include <rte_eal.h> #include <rte_launch.h> -#include <rte_log.h> #include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_ethdev.h> @@ -425,8 +424,7 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(-1, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } printf("Running channel monitor on lcore id %d\n", lcore_id); @@ -434,16 +432,15 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(lcore_id, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } if (power_manager_init() < 0) { - printf("Unable to initialize power manager\n"); + fprintf(stderr, "Unable to initialize power manager\n"); return -1; } if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) { - printf("Unable to initialize channel manager\n"); + fprintf(stderr, "Unable to initialize channel manager\n"); return -1; } -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v3 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-03-08 18:10 ` [PATCH v3 " Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 2/3] examples/vm_power_manager: do not " Stephen Hemminger @ 2024-03-08 18:10 ` Stephen Hemminger 2 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 18:10 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Aman Singh, Yuying Zhang Testpmd is misusing EAL logtype for some errors. Since the code directly has a macro for logging, use that. Also, replace fprintf(stderr, ...) with TESTPMD_LOG where appropriate. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> fix testpmd --- app/test-pmd/testpmd.c | 221 +++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 117 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 9e4e99e53b9a..fd349b85ebe0 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -615,8 +615,8 @@ change_bonding_member_port_status(portid_t bond_pid, bool is_stop) num_members = rte_eth_bond_members_get(bond_pid, member_pids, RTE_MAX_ETHPORTS); if (num_members < 0) { - fprintf(stderr, "Failed to get member list for port = %u\n", - bond_pid); + TESTPMD_LOG(ERR, "Failed to get member list for port = %u\n", + bond_pid); return num_members; } @@ -1289,8 +1289,8 @@ check_socket_id(const unsigned int socket_id) if (new_socket_id(socket_id)) { if (!warning_once && numa_support) - fprintf(stderr, - "Warning: NUMA should be configured manually by using --port-numa-config and --ring-numa-config parameters along with --numa.\n"); + TESTPMD_LOG(WARNING, + "NUMA should be configured manually by using --port-numa-config and --ring-numa-config parameters along with --numa.\n"); warning_once = 1; return -1; } @@ -1337,9 +1337,9 @@ check_nb_rxq(queueid_t rxq) allowed_max_rxq = get_allowed_max_nb_rxq(&pid); if (rxq > allowed_max_rxq) { - fprintf(stderr, - "Fail: input rxq (%u) can't be greater than max_rx_queues (%u) of port %u\n", - rxq, allowed_max_rxq, pid); + TESTPMD_LOG(ERR, + "Fail: input rxq (%u) can't be greater than max_rx_queues (%u) of port %u\n", + rxq, allowed_max_rxq, pid); return -1; } return 0; @@ -1385,7 +1385,7 @@ check_nb_txq(queueid_t txq) allowed_max_txq = get_allowed_max_nb_txq(&pid); if (txq > allowed_max_txq) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input txq (%u) can't be greater than max_tx_queues (%u) of port %u\n", txq, allowed_max_txq, pid); return -1; @@ -1458,7 +1458,7 @@ check_nb_rxd(queueid_t rxd) allowed_max_rxd = get_allowed_max_nb_rxd(&pid); if (rxd > allowed_max_rxd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input rxd (%u) can't be greater than max_rxds (%u) of port %u\n", rxd, allowed_max_rxd, pid); return -1; @@ -1466,7 +1466,7 @@ check_nb_rxd(queueid_t rxd) allowed_min_rxd = get_allowed_min_nb_rxd(&pid); if (rxd < allowed_min_rxd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input rxd (%u) can't be less than min_rxds (%u) of port %u\n", rxd, allowed_min_rxd, pid); return -1; @@ -1539,7 +1539,7 @@ check_nb_txd(queueid_t txd) allowed_max_txd = get_allowed_max_nb_txd(&pid); if (txd > allowed_max_txd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input txd (%u) can't be greater than max_txds (%u) of port %u\n", txd, allowed_max_txd, pid); return -1; @@ -1547,7 +1547,7 @@ check_nb_txd(queueid_t txd) allowed_min_txd = get_allowed_min_nb_txd(&pid); if (txd < allowed_min_txd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input txd (%u) can't be less than min_txds (%u) of port %u\n", txd, allowed_min_txd, pid); return -1; @@ -1595,7 +1595,7 @@ check_nb_hairpinq(queueid_t hairpinq) allowed_max_hairpinq = get_allowed_max_nb_hairpinq(&pid); if (hairpinq > allowed_max_hairpinq) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input hairpin (%u) can't be greater than max_hairpin_queues (%u) of port %u\n", hairpinq, allowed_max_hairpinq, pid); return -1; @@ -1841,13 +1841,13 @@ init_fwd_streams(void) RTE_ETH_FOREACH_DEV(pid) { port = &ports[pid]; if (nb_rxq > port->dev_info.max_rx_queues) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: nb_rxq(%d) is greater than max_rx_queues(%d)\n", nb_rxq, port->dev_info.max_rx_queues); return -1; } if (nb_txq > port->dev_info.max_tx_queues) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: nb_txq(%d) is greater than max_tx_queues(%d)\n", nb_txq, port->dev_info.max_tx_queues); return -1; @@ -1876,7 +1876,7 @@ init_fwd_streams(void) q = RTE_MAX(nb_rxq, nb_txq); if (q == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: Cannot allocate fwd streams as number of queues is 0\n"); return -1; } @@ -2083,7 +2083,7 @@ fwd_stats_display(void) ret = rte_eth_stats_get(pt_id, &stats); if (ret != 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "%s: Error: failed to get stats (port %u): %d", __func__, pt_id, ret); continue; @@ -2190,7 +2190,7 @@ fwd_stats_reset(void) pt_id = fwd_ports_ids[i]; ret = rte_eth_stats_get(pt_id, &ports[pt_id].stats); if (ret != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "%s: Error: failed to clear stats (port %u):%d", __func__, pt_id, ret); } @@ -2395,7 +2395,7 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) diag = rte_eal_remote_launch(pkt_fwd_on_lcore, fwd_lcores[i], lc_id); if (diag != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "launch lcore %u failed - diag=%d\n", lc_id, diag); } @@ -2518,11 +2518,11 @@ start_packet_forwarding(int with_tx_first) cur_fwd_eng->fwd_mode_name); if (all_ports_started() == 0) { - fprintf(stderr, "Not all ports were started\n"); + TESTPMD_LOG(ERR, "Not all ports were started\n"); return; } if (test_done == 0) { - fprintf(stderr, "Packet forwarding already started\n"); + TESTPMD_LOG(ERR, "Packet forwarding already started\n"); return; } @@ -2542,7 +2542,7 @@ start_packet_forwarding(int with_tx_first) if (port_fwd_begin != NULL) { for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { if (port_fwd_begin(fwd_ports_ids[i])) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Packet forwarding is not ready\n"); return; } @@ -2554,7 +2554,7 @@ start_packet_forwarding(int with_tx_first) if (port_fwd_begin != NULL) { for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { if (port_fwd_begin(fwd_ports_ids[i])) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Packet forwarding is not ready\n"); return; } @@ -2594,7 +2594,7 @@ stop_packet_forwarding(void) int i; if (test_done) { - fprintf(stderr, "Packet forwarding not started\n"); + TESTPMD_LOG(ERR, "Packet forwarding not started\n"); return; } printf("Telling cores to stop..."); @@ -2620,14 +2620,14 @@ void dev_set_link_up(portid_t pid) { if (rte_eth_dev_set_link_up(pid) < 0) - fprintf(stderr, "\nSet link up fail.\n"); + TESTPMD_LOG(ERR, "\nSet link up fail.\n"); } void dev_set_link_down(portid_t pid) { if (rte_eth_dev_set_link_down(pid) < 0) - fprintf(stderr, "\nSet link down fail.\n"); + TESTPMD_LOG(ERR, "\nSet link down fail.\n"); } static int @@ -2767,9 +2767,9 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, "Fail to configure port %d hairpin queues\n", + TESTPMD_LOG(ERR, "Fail to configure port %d hairpin queues\n", pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; @@ -2793,9 +2793,9 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, "Fail to configure port %d hairpin queues\n", + TESTPMD_LOG(ERR, "Fail to configure port %d hairpin queues\n", pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; @@ -2855,7 +2855,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, struct rte_eth_dev_info dev_info; if (mbuf_data_size_n <= 1) { - fprintf(stderr, "Invalid number of mempools %u\n", + TESTPMD_LOG(ERR, "Invalid number of mempools %u\n", mbuf_data_size_n); return -EINVAL; } @@ -2863,7 +2863,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, if (ret != 0) return ret; if (dev_info.max_rx_mempools == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %u doesn't support requested multi-rx-mempool configuration.\n", port_id); return -ENOTSUP; @@ -2975,7 +2975,7 @@ fill_xstats_display_info_for_port(portid_t pi) rc = rte_eth_xstats_get_id_by_name(pi, xstat_name, ids_supp + stat_supp); if (rc != 0) { - fprintf(stderr, "No xstat '%s' on port %u - skip it %u\n", + TESTPMD_LOG(ERR, "No xstat '%s' on port %u - skip it %u\n", xstat_name, pi, stat); continue; } @@ -3014,7 +3014,7 @@ update_bonding_port_dev_conf(portid_t bond_pid) ret = eth_dev_info_get_print_err(bond_pid, &port->dev_info); if (ret != 0) { - fprintf(stderr, "Failed to get dev info for port = %u\n", + TESTPMD_LOG(ERR, "Failed to get dev info for port = %u\n", bond_pid); return; } @@ -3059,7 +3059,7 @@ start_port(portid_t pid) continue; if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3072,7 +3072,7 @@ start_port(portid_t pid) port->port_status = RTE_PORT_HANDLING; all_ports_already_started = false; } else { - fprintf(stderr, "Port %d is now not stopped\n", pi); + TESTPMD_LOG(ERR, "Port %d is now not stopped\n", pi); continue; } @@ -3085,7 +3085,7 @@ start_port(portid_t pid) if (flow_isolate_all) { int ret = port_flow_isolate(pi, 1); if (ret) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to apply isolated mode on port %d\n", pi); return -1; @@ -3096,7 +3096,7 @@ start_port(portid_t pid) port->socket_id); if (nb_hairpinq > 0 && rte_eth_dev_hairpin_capability_get(pi, &cap)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d doesn't support hairpin queues\n", pi); return -1; @@ -3115,10 +3115,10 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, "Fail to configure port %d\n", + TESTPMD_LOG(ERR, "Fail to configure port %d\n", pi); /* try to reconfigure port next time */ port->need_reconfig = 1; @@ -3127,7 +3127,7 @@ start_port(portid_t pid) /* get device configuration*/ if (0 != eth_dev_conf_get_print_err(pi, &dev_conf)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "port %d can not get device configuration\n", pi); return -1; @@ -3186,10 +3186,10 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail to configure port %d tx queues\n", pi); /* try to reconfigure queues next time */ @@ -3204,7 +3204,7 @@ start_port(portid_t pid) mbuf_pool_find (rxring_numa[pi], 0); if (mp == NULL) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to setup RX queue: No mempool allocation on the socket %d\n", rxring_numa[pi]); return -1; @@ -3220,7 +3220,7 @@ start_port(portid_t pid) mbuf_pool_find (port->socket_id, 0); if (mp == NULL) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to setup RX queue: No mempool allocation on the socket %d\n", port->socket_id); return -1; @@ -3238,10 +3238,10 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail to configure port %d rx queues\n", pi); /* try to reconfigure queues next time */ @@ -3257,7 +3257,7 @@ start_port(portid_t pid) diag = rte_eth_dev_set_ptypes(pi, RTE_PTYPE_UNKNOWN, NULL, 0); if (diag < 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d: Failed to disable Ptype parsing\n", pi); } @@ -3268,14 +3268,14 @@ start_port(portid_t pid) /* start port */ diag = eth_dev_start_mp(pi); if (diag < 0) { - fprintf(stderr, "Fail to start port %d: %s\n", + TESTPMD_LOG(ERR, "Fail to start port %d: %s\n", pi, rte_strerror(-diag)); /* Fail to setup rx queue, return */ if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); continue; @@ -3284,7 +3284,7 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STARTED; else - fprintf(stderr, "Port %d can not be set into started\n", + TESTPMD_LOG(ERR, "Port %d can not be set into started\n", pi); if (eth_macaddr_get_print_err(pi, &port->eth_addr) == 0) @@ -3301,7 +3301,7 @@ start_port(portid_t pid) if (at_least_one_port_successfully_started && !no_link_check) check_all_ports_link_status(RTE_PORT_ALL); else if (at_least_one_port_exist & all_ports_already_started) - fprintf(stderr, "Please stop the ports first\n"); + TESTPMD_LOG(ERR, "Please stop the ports first\n"); if (hairpin_mode & 0xf) { uint16_t i; @@ -3320,7 +3320,7 @@ start_port(portid_t pid) continue; diag = rte_eth_hairpin_bind(pi, peer_pl[j]); if (diag < 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during binding hairpin Tx port %u to %u: %s\n", pi, peer_pl[j], rte_strerror(-diag)); @@ -3337,7 +3337,7 @@ start_port(portid_t pid) continue; diag = rte_eth_hairpin_bind(peer_pl[j], pi); if (diag < 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during binding hairpin Tx port %u to %u: %s\n", peer_pl[j], pi, rte_strerror(-diag)); @@ -3373,14 +3373,14 @@ stop_port(portid_t pid) continue; if (port_is_forwarding(pi) != 0 && test_done == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from forwarding configuration.\n", pi); continue; } if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3413,8 +3413,8 @@ stop_port(portid_t pid) ret = eth_dev_stop_mp(pi); if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); + TESTPMD_LOG(ERR, + "rte_eth_dev_stop failed for port %u\n", pi); /* Allow to retry stopping the port. */ port->port_status = RTE_PORT_STARTED; continue; @@ -3423,8 +3423,7 @@ stop_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, "Port %d can not be set into stopped\n", - pi); + TESTPMD_LOG(ERR, "Port %d can not be set into stopped\n", pi); need_check_link_status = 1; } if (need_check_link_status && !no_link_check) @@ -3478,7 +3477,7 @@ clear_bonding_member_device(portid_t *member_pids, uint16_t num_members) member_pid = member_pids[i]; if (port_is_started(member_pid) == 1) { if (rte_eth_dev_stop(member_pid) != 0) - fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", + TESTPMD_LOG(ERR, "rte_eth_dev_stop failed for port %u\n", member_pid); port = &ports[member_pid]; @@ -3511,14 +3510,14 @@ close_port(portid_t pid) continue; if (port_is_forwarding(pi) != 0 && test_done == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from forwarding configuration.\n", pi); continue; } if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3526,7 +3525,7 @@ close_port(portid_t pid) port = &ports[pi]; if (port->port_status == RTE_PORT_CLOSED) { - fprintf(stderr, "Port %d is already closed\n", pi); + TESTPMD_LOG(ERR, "Port %d is already closed\n", pi); continue; } @@ -3566,7 +3565,7 @@ reset_port(portid_t pid) if ((pid == (portid_t)RTE_PORT_ALL && !all_ports_stopped()) || (pid != (portid_t)RTE_PORT_ALL && !port_is_stopped(pid))) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Can not reset port(s), please stop port(s) first.\n"); return; } @@ -3578,14 +3577,14 @@ reset_port(portid_t pid) continue; if (port_is_forwarding(pi) != 0 && test_done == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from forwarding configuration.\n", pi); continue; } if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3598,7 +3597,7 @@ reset_port(portid_t pid) port->need_reconfig = 1; port->need_reconfig_queues = 1; } else { - fprintf(stderr, "Failed to reset port %d. diag=%d\n", + TESTPMD_LOG(ERR, "Failed to reset port %d. diag=%d\n", pi, diag); } } @@ -3616,7 +3615,7 @@ attach_port(char *identifier) printf("Attaching a new port...\n"); if (identifier == NULL) { - fprintf(stderr, "Invalid parameters are specified\n"); + TESTPMD_LOG(ERR, "Invalid parameters are specified\n"); return; } @@ -3657,7 +3656,7 @@ setup_attached_port(portid_t pi) reconfig(pi, socket_id); ret = rte_eth_promiscuous_enable(pi); if (ret != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during enabling promiscuous mode for port %u: %s - ignore\n", pi, rte_strerror(-ret)); @@ -3677,7 +3676,7 @@ detach_device(struct rte_device *dev) portid_t sibling; if (dev == NULL) { - fprintf(stderr, "Device already removed\n"); + TESTPMD_LOG(ERR, "Device already removed\n"); return; } @@ -3686,7 +3685,7 @@ detach_device(struct rte_device *dev) RTE_ETH_FOREACH_DEV_OF(sibling, dev) { if (ports[sibling].port_status != RTE_PORT_CLOSED) { if (ports[sibling].port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Port %u not stopped\n", + TESTPMD_LOG(ERR, "Port %u not stopped\n", sibling); return; } @@ -3717,10 +3716,10 @@ detach_port_device(portid_t port_id) if (ports[port_id].port_status != RTE_PORT_CLOSED) { if (ports[port_id].port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Port not stopped\n"); + TESTPMD_LOG(ERR, "Port not stopped\n"); return; } - fprintf(stderr, "Port was not closed\n"); + TESTPMD_LOG(ERR, "Port was not closed\n"); } ret = eth_dev_info_get_print_err(port_id, &dev_info); @@ -3744,14 +3743,14 @@ detach_devargs(char *identifier) memset(&da, 0, sizeof(da)); if (rte_devargs_parsef(&da, "%s", identifier)) { - fprintf(stderr, "cannot parse identifier\n"); + TESTPMD_LOG(ERR, "cannot parse identifier\n"); return; } RTE_ETH_FOREACH_MATCHING_DEV(port_id, identifier, &iterator) { if (ports[port_id].port_status != RTE_PORT_CLOSED) { if (ports[port_id].port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Port %u not stopped\n", + TESTPMD_LOG(ERR, "Port %u not stopped\n", port_id); rte_eth_iterator_cleanup(&iterator); rte_devargs_reset(&da); @@ -3812,23 +3811,20 @@ pmd_test_exit(void) if (hot_plug) { ret = rte_dev_event_monitor_stop(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to stop device event monitor."); + TESTPMD_LOG(ERR, "fail to stop device event monitor."); return; } ret = rte_dev_event_callback_unregister(NULL, dev_event_callback, NULL); if (ret < 0) { - RTE_LOG(ERR, EAL, - "fail to unregister device event callback.\n"); + TESTPMD_LOG(ERR, "fail to unregister device event callback.\n"); return; } ret = rte_dev_hotplug_handle_disable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to disable hotplug handling.\n"); + TESTPMD_LOG(ERR, "fail to disable hotplug handling.\n"); return; } } @@ -3871,7 +3867,7 @@ check_all_ports_link_status(uint32_t port_mask) if (ret < 0) { all_ports_up = 0; if (print_flag == 1) - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %u link get failed: %s\n", portid, rte_strerror(-ret)); continue; @@ -3950,10 +3946,9 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, RTE_SET_USED(ret_param); if (type >= RTE_ETH_EVENT_MAX) { - fprintf(stderr, + TESTPMD_LOG(ERR, "\nPort %" PRIu16 ": %s called upon invalid event %d\n", port_id, __func__, type); - fflush(stderr); } else if (event_print_mask & (UINT32_C(1) << type)) { printf("\nPort %" PRIu16 ": %s event\n", port_id, eth_event_desc[type]); @@ -3970,7 +3965,7 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, break; if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - fprintf(stderr, + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); break; case RTE_ETH_EVENT_DESTROY: @@ -4054,20 +4049,13 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, uint16_t port_id; int ret; - if (type >= RTE_DEV_EVENT_MAX) { - fprintf(stderr, "%s called upon invalid event %d\n", - __func__, type); - fflush(stderr); - } - switch (type) { case RTE_DEV_EVENT_REMOVE: - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been removed!\n", device_name); ret = rte_eth_dev_get_port_by_name(device_name, &port_id); if (ret) { - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", - device_name); + TESTPMD_LOG(ERR, + "Can not get port for device %s!\n", device_name); return; } /* @@ -4081,17 +4069,20 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, */ if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - RTE_LOG(ERR, EAL, - "Could not set up deferred device removal\n"); + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); break; + case RTE_DEV_EVENT_ADD: - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been added!\n", device_name); /* TODO: After finish kernel driver binding, * begin to attach port. */ break; + default: + if (type >= RTE_DEV_EVENT_MAX) + TESTPMD_LOG(ERR, "%s called upon invalid event %d\n", + __func__, type); break; } } @@ -4189,7 +4180,7 @@ update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen) return 0; if (eth_dev_set_mtu_mp(portid, new_mtu) != 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to set MTU to %u for port %u\n", new_mtu, portid); return -1; @@ -4425,7 +4416,7 @@ init_port_dcb_config(portid_t pid, */ if (dcb_mode == DCB_VT_ENABLED && rte_port->dev_info.vmdq_pool_base > 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "VMDQ_DCB multi-queue mode is nonsensical for port %d.\n", pid); return -1; @@ -4613,17 +4604,17 @@ main(int argc, char** argv) "interactive mode.\n"); if (tx_first && lsc_interrupt) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: lsc_interrupt needs to be off when using tx_first. Disabling.\n"); lsc_interrupt = 0; } if (!nb_rxq && !nb_txq) - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: Either rx or tx queues should be non-zero\n"); if (nb_rxq > 1 && nb_rxq > nb_txq) - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: nb_rxq=%d enables RSS configuration, but nb_txq=%d will prevent to fully test it.\n", nb_rxq, nb_txq); @@ -4632,23 +4623,19 @@ main(int argc, char** argv) if (hot_plug) { ret = rte_dev_hotplug_handle_enable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to enable hotplug handling."); + TESTPMD_LOG(ERR, "fail to enable hotplug handling."); return -1; } ret = rte_dev_event_monitor_start(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to start device event monitoring."); + TESTPMD_LOG(ERR, "fail to start device event monitoring."); return -1; } - ret = rte_dev_event_callback_register(NULL, - dev_event_callback, NULL); + ret = rte_dev_event_callback_register(NULL, dev_event_callback, NULL); if (ret) { - RTE_LOG(ERR, EAL, - "fail to register device event callback\n"); + TESTPMD_LOG(ERR, "fail to register device event callback\n"); return -1; } } @@ -4658,14 +4645,14 @@ main(int argc, char** argv) rte_eal_cleanup(); rte_exit(EXIT_FAILURE, "Start ports failed\n"); } - fprintf(stderr, "Start ports failed\n"); + TESTPMD_LOG(ERR, "Start ports failed\n"); } /* set all ports to promiscuous mode by default */ RTE_ETH_FOREACH_DEV(port_id) { ret = rte_eth_promiscuous_enable(port_id); if (ret != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during enabling promiscuous mode for port %u: %s - ignore\n", port_id, rte_strerror(-ret)); } @@ -4679,10 +4666,10 @@ main(int argc, char** argv) if (latencystats_enabled != 0) { int ret = rte_latencystats_init(1, NULL); if (ret) - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: latencystats init() returned error %d\n", ret); - fprintf(stderr, "Latencystats running on lcore %d\n", + TESTPMD_LOG(ERR, "Latencystats running on lcore %d\n", latencystats_lcore_id); } #endif -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v4 0/3] replace use of EAL logtype in applications 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger ` (5 preceding siblings ...) 2024-03-08 18:10 ` [PATCH v3 " Stephen Hemminger @ 2024-03-08 22:33 ` Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger ` (2 more replies) 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger 7 siblings, 3 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 22:33 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger There are some places EAL logtype is being used in testpmd and examples where it should not be. Lets reserve EAL logtype to only be used by DPDK internals. Stephen Hemminger (3): examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype testpmd: replace EAL logtype TESTPMD_LOG v4 - resolve some checkpatch reported pre-existing stuff Stephen Hemminger (3): examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype testpmd: replace EAL logtype TESTPMD_LOG app/test-pmd/testpmd.c | 221 +++++++++++++++---------------- examples/l2fwd-keepalive/main.c | 2 - examples/l2fwd-keepalive/shm.c | 29 ++-- examples/l2fwd-keepalive/shm.h | 3 + examples/vm_power_manager/main.c | 11 +- 5 files changed, 123 insertions(+), 143 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v4 1/3] examples/l2fwd-keepalive: don't use EAL logtype 2024-03-08 22:33 ` [PATCH v4 0/3] replace use of EAL logtype in applications Stephen Hemminger @ 2024-03-08 22:33 ` Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 2/3] examples/vm_power_manager: do not " Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 22:33 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Morten Brørup EAL logtype should be reserved for EAL library. This example is already has a log wrapper so use it. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> --- examples/l2fwd-keepalive/main.c | 2 -- examples/l2fwd-keepalive/shm.c | 29 ++++++++++++----------------- examples/l2fwd-keepalive/shm.h | 3 +++ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 1463cef0fc2e..dca944fc173f 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -41,8 +41,6 @@ #include "shm.h" -#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 - #define NB_MBUF_PER_PORT 3000 #define MAX_PKT_BURST 32 diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c index 7c7a9ea8ea3c..865a19a57f22 100644 --- a/examples/l2fwd-keepalive/shm.c +++ b/examples/l2fwd-keepalive/shm.c @@ -5,7 +5,6 @@ #include <time.h> #include <rte_common.h> -#include <rte_log.h> #include <rte_keepalive.h> #include "shm.h" @@ -22,34 +21,30 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void) * will get the new block mapped below. */ if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT) - printf("Warning: Error unlinking stale %s (%s)\n", + RTE_LOG(NOTICE, L2FWD, + "Warning: Error unlinking stale %s (%s)\n", RTE_KEEPALIVE_SHM_NAME, strerror(errno)); fd = shm_open(RTE_KEEPALIVE_SHM_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666); if (fd < 0) - RTE_LOG(INFO, EAL, - "Failed to open %s as SHM (%s)\n", - RTE_KEEPALIVE_SHM_NAME, - strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to open %s as SHM (%s)\n", + RTE_KEEPALIVE_SHM_NAME, strerror(errno)); else if (ftruncate(fd, sizeof(struct rte_keepalive_shm)) != 0) - RTE_LOG(INFO, EAL, - "Failed to resize SHM (%s)\n", strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to resize SHM (%s)\n", strerror(errno)); else { ka_shm = (struct rte_keepalive_shm *) mmap( 0, sizeof(struct rte_keepalive_shm), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); if (ka_shm == MAP_FAILED) - RTE_LOG(INFO, EAL, - "Failed to mmap SHM (%s)\n", strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to mmap SHM (%s)\n", strerror(errno)); else { memset(ka_shm, 0, sizeof(struct rte_keepalive_shm)); /* Initialize the semaphores for IPC/SHM use */ if (sem_init(&ka_shm->core_died, 1, 0) != 0) { - RTE_LOG(INFO, EAL, - "Failed to setup SHM semaphore (%s)\n", + RTE_LOG(ERR, L2FWD, "Failed to setup SHM semaphore (%s)\n", strerror(errno)); munmap(ka_shm, sizeof(struct rte_keepalive_shm)); @@ -87,7 +82,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, * ka_agent is not active. */ if (sem_getvalue(&shm->core_died, &count) == -1) { - RTE_LOG(INFO, EAL, "Semaphore check failed(%s)\n", + RTE_LOG(ERR, L2FWD, "Semaphore check failed(%s)\n", strerror(errno)); return; } @@ -95,8 +90,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, return; if (sem_post(&shm->core_died) != 0) - RTE_LOG(INFO, EAL, - "Failed to increment semaphore (%s)\n", + RTE_LOG(ERR, L2FWD, "Failed to increment semaphore (%s)\n", strerror(errno)); } } @@ -104,9 +98,10 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, void rte_keepalive_shm_cleanup(struct rte_keepalive_shm *ka_shm) { if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT) - printf("Warning: Error unlinking %s (%s)\n", + RTE_LOG(NOTICE, L2FWD, "Warning: Error unlinking %s (%s)\n", RTE_KEEPALIVE_SHM_NAME, strerror(errno)); if (ka_shm && munmap(ka_shm, sizeof(struct rte_keepalive_shm)) != 0) - printf("Warning: munmap() failed\n"); + RTE_LOG(ERR, L2FWD, "Warning: munmap() failed: %s\n", + strerror(errno)); } diff --git a/examples/l2fwd-keepalive/shm.h b/examples/l2fwd-keepalive/shm.h index 7a9d597295e0..f7644336e543 100644 --- a/examples/l2fwd-keepalive/shm.h +++ b/examples/l2fwd-keepalive/shm.h @@ -14,6 +14,9 @@ #include <sys/stat.h> #include <semaphore.h> #include <rte_keepalive.h> +#include <rte_log.h> + +#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 /** * Keepalive SHM structure. -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v4 2/3] examples/vm_power_manager: do not use EAL logtype 2024-03-08 22:33 ` [PATCH v4 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2024-03-08 22:33 ` Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 22:33 UTC (permalink / raw) To: dev Cc: Stephen Hemminger, David Hunt, Huisong Li, Anatoly Burakov, Sivaprasad Tummala Be consistent for all the error printouts and use fprintf(). The EAL logtype is reserved for internal use by EAL. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: David Hunt <david.hunt@intel.com> Acked-by: Huisong Li <lihuisong@huawei.com> --- examples/vm_power_manager/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index b159291d77ce..c14138202004 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -17,7 +17,6 @@ #include <rte_common.h> #include <rte_eal.h> #include <rte_launch.h> -#include <rte_log.h> #include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_ethdev.h> @@ -425,8 +424,7 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(-1, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } printf("Running channel monitor on lcore id %d\n", lcore_id); @@ -434,16 +432,15 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(lcore_id, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } if (power_manager_init() < 0) { - printf("Unable to initialize power manager\n"); + fprintf(stderr, "Unable to initialize power manager\n"); return -1; } if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) { - printf("Unable to initialize channel manager\n"); + fprintf(stderr, "Unable to initialize channel manager\n"); return -1; } -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-03-08 22:33 ` [PATCH v4 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 2/3] examples/vm_power_manager: do not " Stephen Hemminger @ 2024-03-08 22:33 ` Stephen Hemminger 2024-03-11 10:24 ` Singh, Aman Deep 2 siblings, 1 reply; 33+ messages in thread From: Stephen Hemminger @ 2024-03-08 22:33 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Aman Singh, Yuying Zhang Testpmd is misusing EAL logtype for some errors. Since the code directly has a macro for logging, use that. Also, replace fprintf(stderr, ...) with TESTPMD_LOG where appropriate. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> fix testpmd --- app/test-pmd/testpmd.c | 221 +++++++++++++++++++---------------------- 1 file changed, 104 insertions(+), 117 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 9e4e99e53b9a..fd349b85ebe0 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -615,8 +615,8 @@ change_bonding_member_port_status(portid_t bond_pid, bool is_stop) num_members = rte_eth_bond_members_get(bond_pid, member_pids, RTE_MAX_ETHPORTS); if (num_members < 0) { - fprintf(stderr, "Failed to get member list for port = %u\n", - bond_pid); + TESTPMD_LOG(ERR, "Failed to get member list for port = %u\n", + bond_pid); return num_members; } @@ -1289,8 +1289,8 @@ check_socket_id(const unsigned int socket_id) if (new_socket_id(socket_id)) { if (!warning_once && numa_support) - fprintf(stderr, - "Warning: NUMA should be configured manually by using --port-numa-config and --ring-numa-config parameters along with --numa.\n"); + TESTPMD_LOG(WARNING, + "NUMA should be configured manually by using --port-numa-config and --ring-numa-config parameters along with --numa.\n"); warning_once = 1; return -1; } @@ -1337,9 +1337,9 @@ check_nb_rxq(queueid_t rxq) allowed_max_rxq = get_allowed_max_nb_rxq(&pid); if (rxq > allowed_max_rxq) { - fprintf(stderr, - "Fail: input rxq (%u) can't be greater than max_rx_queues (%u) of port %u\n", - rxq, allowed_max_rxq, pid); + TESTPMD_LOG(ERR, + "Fail: input rxq (%u) can't be greater than max_rx_queues (%u) of port %u\n", + rxq, allowed_max_rxq, pid); return -1; } return 0; @@ -1385,7 +1385,7 @@ check_nb_txq(queueid_t txq) allowed_max_txq = get_allowed_max_nb_txq(&pid); if (txq > allowed_max_txq) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input txq (%u) can't be greater than max_tx_queues (%u) of port %u\n", txq, allowed_max_txq, pid); return -1; @@ -1458,7 +1458,7 @@ check_nb_rxd(queueid_t rxd) allowed_max_rxd = get_allowed_max_nb_rxd(&pid); if (rxd > allowed_max_rxd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input rxd (%u) can't be greater than max_rxds (%u) of port %u\n", rxd, allowed_max_rxd, pid); return -1; @@ -1466,7 +1466,7 @@ check_nb_rxd(queueid_t rxd) allowed_min_rxd = get_allowed_min_nb_rxd(&pid); if (rxd < allowed_min_rxd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input rxd (%u) can't be less than min_rxds (%u) of port %u\n", rxd, allowed_min_rxd, pid); return -1; @@ -1539,7 +1539,7 @@ check_nb_txd(queueid_t txd) allowed_max_txd = get_allowed_max_nb_txd(&pid); if (txd > allowed_max_txd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input txd (%u) can't be greater than max_txds (%u) of port %u\n", txd, allowed_max_txd, pid); return -1; @@ -1547,7 +1547,7 @@ check_nb_txd(queueid_t txd) allowed_min_txd = get_allowed_min_nb_txd(&pid); if (txd < allowed_min_txd) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input txd (%u) can't be less than min_txds (%u) of port %u\n", txd, allowed_min_txd, pid); return -1; @@ -1595,7 +1595,7 @@ check_nb_hairpinq(queueid_t hairpinq) allowed_max_hairpinq = get_allowed_max_nb_hairpinq(&pid); if (hairpinq > allowed_max_hairpinq) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: input hairpin (%u) can't be greater than max_hairpin_queues (%u) of port %u\n", hairpinq, allowed_max_hairpinq, pid); return -1; @@ -1841,13 +1841,13 @@ init_fwd_streams(void) RTE_ETH_FOREACH_DEV(pid) { port = &ports[pid]; if (nb_rxq > port->dev_info.max_rx_queues) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: nb_rxq(%d) is greater than max_rx_queues(%d)\n", nb_rxq, port->dev_info.max_rx_queues); return -1; } if (nb_txq > port->dev_info.max_tx_queues) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: nb_txq(%d) is greater than max_tx_queues(%d)\n", nb_txq, port->dev_info.max_tx_queues); return -1; @@ -1876,7 +1876,7 @@ init_fwd_streams(void) q = RTE_MAX(nb_rxq, nb_txq); if (q == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail: Cannot allocate fwd streams as number of queues is 0\n"); return -1; } @@ -2083,7 +2083,7 @@ fwd_stats_display(void) ret = rte_eth_stats_get(pt_id, &stats); if (ret != 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "%s: Error: failed to get stats (port %u): %d", __func__, pt_id, ret); continue; @@ -2190,7 +2190,7 @@ fwd_stats_reset(void) pt_id = fwd_ports_ids[i]; ret = rte_eth_stats_get(pt_id, &ports[pt_id].stats); if (ret != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "%s: Error: failed to clear stats (port %u):%d", __func__, pt_id, ret); } @@ -2395,7 +2395,7 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore) diag = rte_eal_remote_launch(pkt_fwd_on_lcore, fwd_lcores[i], lc_id); if (diag != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "launch lcore %u failed - diag=%d\n", lc_id, diag); } @@ -2518,11 +2518,11 @@ start_packet_forwarding(int with_tx_first) cur_fwd_eng->fwd_mode_name); if (all_ports_started() == 0) { - fprintf(stderr, "Not all ports were started\n"); + TESTPMD_LOG(ERR, "Not all ports were started\n"); return; } if (test_done == 0) { - fprintf(stderr, "Packet forwarding already started\n"); + TESTPMD_LOG(ERR, "Packet forwarding already started\n"); return; } @@ -2542,7 +2542,7 @@ start_packet_forwarding(int with_tx_first) if (port_fwd_begin != NULL) { for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { if (port_fwd_begin(fwd_ports_ids[i])) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Packet forwarding is not ready\n"); return; } @@ -2554,7 +2554,7 @@ start_packet_forwarding(int with_tx_first) if (port_fwd_begin != NULL) { for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { if (port_fwd_begin(fwd_ports_ids[i])) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Packet forwarding is not ready\n"); return; } @@ -2594,7 +2594,7 @@ stop_packet_forwarding(void) int i; if (test_done) { - fprintf(stderr, "Packet forwarding not started\n"); + TESTPMD_LOG(ERR, "Packet forwarding not started\n"); return; } printf("Telling cores to stop..."); @@ -2620,14 +2620,14 @@ void dev_set_link_up(portid_t pid) { if (rte_eth_dev_set_link_up(pid) < 0) - fprintf(stderr, "\nSet link up fail.\n"); + TESTPMD_LOG(ERR, "\nSet link up fail.\n"); } void dev_set_link_down(portid_t pid) { if (rte_eth_dev_set_link_down(pid) < 0) - fprintf(stderr, "\nSet link down fail.\n"); + TESTPMD_LOG(ERR, "\nSet link down fail.\n"); } static int @@ -2767,9 +2767,9 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, "Fail to configure port %d hairpin queues\n", + TESTPMD_LOG(ERR, "Fail to configure port %d hairpin queues\n", pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; @@ -2793,9 +2793,9 @@ setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, "Fail to configure port %d hairpin queues\n", + TESTPMD_LOG(ERR, "Fail to configure port %d hairpin queues\n", pi); /* try to reconfigure queues next time */ port->need_reconfig_queues = 1; @@ -2855,7 +2855,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, struct rte_eth_dev_info dev_info; if (mbuf_data_size_n <= 1) { - fprintf(stderr, "Invalid number of mempools %u\n", + TESTPMD_LOG(ERR, "Invalid number of mempools %u\n", mbuf_data_size_n); return -EINVAL; } @@ -2863,7 +2863,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, if (ret != 0) return ret; if (dev_info.max_rx_mempools == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %u doesn't support requested multi-rx-mempool configuration.\n", port_id); return -ENOTSUP; @@ -2975,7 +2975,7 @@ fill_xstats_display_info_for_port(portid_t pi) rc = rte_eth_xstats_get_id_by_name(pi, xstat_name, ids_supp + stat_supp); if (rc != 0) { - fprintf(stderr, "No xstat '%s' on port %u - skip it %u\n", + TESTPMD_LOG(ERR, "No xstat '%s' on port %u - skip it %u\n", xstat_name, pi, stat); continue; } @@ -3014,7 +3014,7 @@ update_bonding_port_dev_conf(portid_t bond_pid) ret = eth_dev_info_get_print_err(bond_pid, &port->dev_info); if (ret != 0) { - fprintf(stderr, "Failed to get dev info for port = %u\n", + TESTPMD_LOG(ERR, "Failed to get dev info for port = %u\n", bond_pid); return; } @@ -3059,7 +3059,7 @@ start_port(portid_t pid) continue; if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3072,7 +3072,7 @@ start_port(portid_t pid) port->port_status = RTE_PORT_HANDLING; all_ports_already_started = false; } else { - fprintf(stderr, "Port %d is now not stopped\n", pi); + TESTPMD_LOG(ERR, "Port %d is now not stopped\n", pi); continue; } @@ -3085,7 +3085,7 @@ start_port(portid_t pid) if (flow_isolate_all) { int ret = port_flow_isolate(pi, 1); if (ret) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to apply isolated mode on port %d\n", pi); return -1; @@ -3096,7 +3096,7 @@ start_port(portid_t pid) port->socket_id); if (nb_hairpinq > 0 && rte_eth_dev_hairpin_capability_get(pi, &cap)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d doesn't support hairpin queues\n", pi); return -1; @@ -3115,10 +3115,10 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, "Fail to configure port %d\n", + TESTPMD_LOG(ERR, "Fail to configure port %d\n", pi); /* try to reconfigure port next time */ port->need_reconfig = 1; @@ -3127,7 +3127,7 @@ start_port(portid_t pid) /* get device configuration*/ if (0 != eth_dev_conf_get_print_err(pi, &dev_conf)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "port %d can not get device configuration\n", pi); return -1; @@ -3186,10 +3186,10 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail to configure port %d tx queues\n", pi); /* try to reconfigure queues next time */ @@ -3204,7 +3204,7 @@ start_port(portid_t pid) mbuf_pool_find (rxring_numa[pi], 0); if (mp == NULL) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to setup RX queue: No mempool allocation on the socket %d\n", rxring_numa[pi]); return -1; @@ -3220,7 +3220,7 @@ start_port(portid_t pid) mbuf_pool_find (port->socket_id, 0); if (mp == NULL) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to setup RX queue: No mempool allocation on the socket %d\n", port->socket_id); return -1; @@ -3238,10 +3238,10 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); - fprintf(stderr, + TESTPMD_LOG(ERR, "Fail to configure port %d rx queues\n", pi); /* try to reconfigure queues next time */ @@ -3257,7 +3257,7 @@ start_port(portid_t pid) diag = rte_eth_dev_set_ptypes(pi, RTE_PTYPE_UNKNOWN, NULL, 0); if (diag < 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d: Failed to disable Ptype parsing\n", pi); } @@ -3268,14 +3268,14 @@ start_port(portid_t pid) /* start port */ diag = eth_dev_start_mp(pi); if (diag < 0) { - fprintf(stderr, "Fail to start port %d: %s\n", + TESTPMD_LOG(ERR, "Fail to start port %d: %s\n", pi, rte_strerror(-diag)); /* Fail to setup rx queue, return */ if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %d can not be set back to stopped\n", pi); continue; @@ -3284,7 +3284,7 @@ start_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STARTED; else - fprintf(stderr, "Port %d can not be set into started\n", + TESTPMD_LOG(ERR, "Port %d can not be set into started\n", pi); if (eth_macaddr_get_print_err(pi, &port->eth_addr) == 0) @@ -3301,7 +3301,7 @@ start_port(portid_t pid) if (at_least_one_port_successfully_started && !no_link_check) check_all_ports_link_status(RTE_PORT_ALL); else if (at_least_one_port_exist & all_ports_already_started) - fprintf(stderr, "Please stop the ports first\n"); + TESTPMD_LOG(ERR, "Please stop the ports first\n"); if (hairpin_mode & 0xf) { uint16_t i; @@ -3320,7 +3320,7 @@ start_port(portid_t pid) continue; diag = rte_eth_hairpin_bind(pi, peer_pl[j]); if (diag < 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during binding hairpin Tx port %u to %u: %s\n", pi, peer_pl[j], rte_strerror(-diag)); @@ -3337,7 +3337,7 @@ start_port(portid_t pid) continue; diag = rte_eth_hairpin_bind(peer_pl[j], pi); if (diag < 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during binding hairpin Tx port %u to %u: %s\n", peer_pl[j], pi, rte_strerror(-diag)); @@ -3373,14 +3373,14 @@ stop_port(portid_t pid) continue; if (port_is_forwarding(pi) != 0 && test_done == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from forwarding configuration.\n", pi); continue; } if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3413,8 +3413,8 @@ stop_port(portid_t pid) ret = eth_dev_stop_mp(pi); if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); + TESTPMD_LOG(ERR, + "rte_eth_dev_stop failed for port %u\n", pi); /* Allow to retry stopping the port. */ port->port_status = RTE_PORT_STARTED; continue; @@ -3423,8 +3423,7 @@ stop_port(portid_t pid) if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; else - fprintf(stderr, "Port %d can not be set into stopped\n", - pi); + TESTPMD_LOG(ERR, "Port %d can not be set into stopped\n", pi); need_check_link_status = 1; } if (need_check_link_status && !no_link_check) @@ -3478,7 +3477,7 @@ clear_bonding_member_device(portid_t *member_pids, uint16_t num_members) member_pid = member_pids[i]; if (port_is_started(member_pid) == 1) { if (rte_eth_dev_stop(member_pid) != 0) - fprintf(stderr, "rte_eth_dev_stop failed for port %u\n", + TESTPMD_LOG(ERR, "rte_eth_dev_stop failed for port %u\n", member_pid); port = &ports[member_pid]; @@ -3511,14 +3510,14 @@ close_port(portid_t pid) continue; if (port_is_forwarding(pi) != 0 && test_done == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from forwarding configuration.\n", pi); continue; } if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3526,7 +3525,7 @@ close_port(portid_t pid) port = &ports[pi]; if (port->port_status == RTE_PORT_CLOSED) { - fprintf(stderr, "Port %d is already closed\n", pi); + TESTPMD_LOG(ERR, "Port %d is already closed\n", pi); continue; } @@ -3566,7 +3565,7 @@ reset_port(portid_t pid) if ((pid == (portid_t)RTE_PORT_ALL && !all_ports_stopped()) || (pid != (portid_t)RTE_PORT_ALL && !port_is_stopped(pid))) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Can not reset port(s), please stop port(s) first.\n"); return; } @@ -3578,14 +3577,14 @@ reset_port(portid_t pid) continue; if (port_is_forwarding(pi) != 0 && test_done == 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from forwarding configuration.\n", pi); continue; } if (port_is_bonding_member(pi)) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Please remove port %d from bonding device.\n", pi); continue; @@ -3598,7 +3597,7 @@ reset_port(portid_t pid) port->need_reconfig = 1; port->need_reconfig_queues = 1; } else { - fprintf(stderr, "Failed to reset port %d. diag=%d\n", + TESTPMD_LOG(ERR, "Failed to reset port %d. diag=%d\n", pi, diag); } } @@ -3616,7 +3615,7 @@ attach_port(char *identifier) printf("Attaching a new port...\n"); if (identifier == NULL) { - fprintf(stderr, "Invalid parameters are specified\n"); + TESTPMD_LOG(ERR, "Invalid parameters are specified\n"); return; } @@ -3657,7 +3656,7 @@ setup_attached_port(portid_t pi) reconfig(pi, socket_id); ret = rte_eth_promiscuous_enable(pi); if (ret != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during enabling promiscuous mode for port %u: %s - ignore\n", pi, rte_strerror(-ret)); @@ -3677,7 +3676,7 @@ detach_device(struct rte_device *dev) portid_t sibling; if (dev == NULL) { - fprintf(stderr, "Device already removed\n"); + TESTPMD_LOG(ERR, "Device already removed\n"); return; } @@ -3686,7 +3685,7 @@ detach_device(struct rte_device *dev) RTE_ETH_FOREACH_DEV_OF(sibling, dev) { if (ports[sibling].port_status != RTE_PORT_CLOSED) { if (ports[sibling].port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Port %u not stopped\n", + TESTPMD_LOG(ERR, "Port %u not stopped\n", sibling); return; } @@ -3717,10 +3716,10 @@ detach_port_device(portid_t port_id) if (ports[port_id].port_status != RTE_PORT_CLOSED) { if (ports[port_id].port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Port not stopped\n"); + TESTPMD_LOG(ERR, "Port not stopped\n"); return; } - fprintf(stderr, "Port was not closed\n"); + TESTPMD_LOG(ERR, "Port was not closed\n"); } ret = eth_dev_info_get_print_err(port_id, &dev_info); @@ -3744,14 +3743,14 @@ detach_devargs(char *identifier) memset(&da, 0, sizeof(da)); if (rte_devargs_parsef(&da, "%s", identifier)) { - fprintf(stderr, "cannot parse identifier\n"); + TESTPMD_LOG(ERR, "cannot parse identifier\n"); return; } RTE_ETH_FOREACH_MATCHING_DEV(port_id, identifier, &iterator) { if (ports[port_id].port_status != RTE_PORT_CLOSED) { if (ports[port_id].port_status != RTE_PORT_STOPPED) { - fprintf(stderr, "Port %u not stopped\n", + TESTPMD_LOG(ERR, "Port %u not stopped\n", port_id); rte_eth_iterator_cleanup(&iterator); rte_devargs_reset(&da); @@ -3812,23 +3811,20 @@ pmd_test_exit(void) if (hot_plug) { ret = rte_dev_event_monitor_stop(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to stop device event monitor."); + TESTPMD_LOG(ERR, "fail to stop device event monitor."); return; } ret = rte_dev_event_callback_unregister(NULL, dev_event_callback, NULL); if (ret < 0) { - RTE_LOG(ERR, EAL, - "fail to unregister device event callback.\n"); + TESTPMD_LOG(ERR, "fail to unregister device event callback.\n"); return; } ret = rte_dev_hotplug_handle_disable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to disable hotplug handling.\n"); + TESTPMD_LOG(ERR, "fail to disable hotplug handling.\n"); return; } } @@ -3871,7 +3867,7 @@ check_all_ports_link_status(uint32_t port_mask) if (ret < 0) { all_ports_up = 0; if (print_flag == 1) - fprintf(stderr, + TESTPMD_LOG(ERR, "Port %u link get failed: %s\n", portid, rte_strerror(-ret)); continue; @@ -3950,10 +3946,9 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, RTE_SET_USED(ret_param); if (type >= RTE_ETH_EVENT_MAX) { - fprintf(stderr, + TESTPMD_LOG(ERR, "\nPort %" PRIu16 ": %s called upon invalid event %d\n", port_id, __func__, type); - fflush(stderr); } else if (event_print_mask & (UINT32_C(1) << type)) { printf("\nPort %" PRIu16 ": %s event\n", port_id, eth_event_desc[type]); @@ -3970,7 +3965,7 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, break; if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - fprintf(stderr, + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); break; case RTE_ETH_EVENT_DESTROY: @@ -4054,20 +4049,13 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, uint16_t port_id; int ret; - if (type >= RTE_DEV_EVENT_MAX) { - fprintf(stderr, "%s called upon invalid event %d\n", - __func__, type); - fflush(stderr); - } - switch (type) { case RTE_DEV_EVENT_REMOVE: - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been removed!\n", device_name); ret = rte_eth_dev_get_port_by_name(device_name, &port_id); if (ret) { - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", - device_name); + TESTPMD_LOG(ERR, + "Can not get port for device %s!\n", device_name); return; } /* @@ -4081,17 +4069,20 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, */ if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - RTE_LOG(ERR, EAL, - "Could not set up deferred device removal\n"); + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); break; + case RTE_DEV_EVENT_ADD: - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been added!\n", device_name); /* TODO: After finish kernel driver binding, * begin to attach port. */ break; + default: + if (type >= RTE_DEV_EVENT_MAX) + TESTPMD_LOG(ERR, "%s called upon invalid event %d\n", + __func__, type); break; } } @@ -4189,7 +4180,7 @@ update_mtu_from_frame_size(portid_t portid, uint32_t max_rx_pktlen) return 0; if (eth_dev_set_mtu_mp(portid, new_mtu) != 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Failed to set MTU to %u for port %u\n", new_mtu, portid); return -1; @@ -4425,7 +4416,7 @@ init_port_dcb_config(portid_t pid, */ if (dcb_mode == DCB_VT_ENABLED && rte_port->dev_info.vmdq_pool_base > 0) { - fprintf(stderr, + TESTPMD_LOG(ERR, "VMDQ_DCB multi-queue mode is nonsensical for port %d.\n", pid); return -1; @@ -4613,17 +4604,17 @@ main(int argc, char** argv) "interactive mode.\n"); if (tx_first && lsc_interrupt) { - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: lsc_interrupt needs to be off when using tx_first. Disabling.\n"); lsc_interrupt = 0; } if (!nb_rxq && !nb_txq) - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: Either rx or tx queues should be non-zero\n"); if (nb_rxq > 1 && nb_rxq > nb_txq) - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: nb_rxq=%d enables RSS configuration, but nb_txq=%d will prevent to fully test it.\n", nb_rxq, nb_txq); @@ -4632,23 +4623,19 @@ main(int argc, char** argv) if (hot_plug) { ret = rte_dev_hotplug_handle_enable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to enable hotplug handling."); + TESTPMD_LOG(ERR, "fail to enable hotplug handling."); return -1; } ret = rte_dev_event_monitor_start(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to start device event monitoring."); + TESTPMD_LOG(ERR, "fail to start device event monitoring."); return -1; } - ret = rte_dev_event_callback_register(NULL, - dev_event_callback, NULL); + ret = rte_dev_event_callback_register(NULL, dev_event_callback, NULL); if (ret) { - RTE_LOG(ERR, EAL, - "fail to register device event callback\n"); + TESTPMD_LOG(ERR, "fail to register device event callback\n"); return -1; } } @@ -4658,14 +4645,14 @@ main(int argc, char** argv) rte_eal_cleanup(); rte_exit(EXIT_FAILURE, "Start ports failed\n"); } - fprintf(stderr, "Start ports failed\n"); + TESTPMD_LOG(ERR, "Start ports failed\n"); } /* set all ports to promiscuous mode by default */ RTE_ETH_FOREACH_DEV(port_id) { ret = rte_eth_promiscuous_enable(port_id); if (ret != 0) - fprintf(stderr, + TESTPMD_LOG(ERR, "Error during enabling promiscuous mode for port %u: %s - ignore\n", port_id, rte_strerror(-ret)); } @@ -4679,10 +4666,10 @@ main(int argc, char** argv) if (latencystats_enabled != 0) { int ret = rte_latencystats_init(1, NULL); if (ret) - fprintf(stderr, + TESTPMD_LOG(ERR, "Warning: latencystats init() returned error %d\n", ret); - fprintf(stderr, "Latencystats running on lcore %d\n", + TESTPMD_LOG(ERR, "Latencystats running on lcore %d\n", latencystats_lcore_id); } #endif -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-03-08 22:33 ` [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger @ 2024-03-11 10:24 ` Singh, Aman Deep 0 siblings, 0 replies; 33+ messages in thread From: Singh, Aman Deep @ 2024-03-11 10:24 UTC (permalink / raw) To: Stephen Hemminger, dev; +Cc: Huisong Li, Yuying Zhang On 3/9/2024 4:03 AM, Stephen Hemminger wrote: > Testpmd is misusing EAL logtype for some errors. > Since the code directly has a macro for logging, use that. > > Also, replace fprintf(stderr, ...) with TESTPMD_LOG where > appropriate. > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > Acked-by: Huisong Li <lihuisong@huawei.com> Acked-by: Aman Singh <aman.deep.singh@intel.com> <snip> ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger ` (6 preceding siblings ...) 2024-03-08 22:33 ` [PATCH v4 0/3] replace use of EAL logtype in applications Stephen Hemminger @ 2024-07-03 16:28 ` Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger ` (3 more replies) 7 siblings, 4 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-07-03 16:28 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger There are some places EAL logtype is being used in testpmd and examples where it should not be. Lets reserve EAL logtype to only be used by DPDK internals. Stephen Hemminger (3): examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype testpmd: replace EAL logtype TESTPMD_LOG v5 - rebase and remove some fprintf changes Stephen Hemminger (3): examples/l2fwd-keepalive: don't use EAL logtype examples/vm_power_manager: do not use EAL logtype testpmd: replace EAL logtype TESTPMD_LOG app/test-pmd/testpmd.c | 49 +++++++++++++------------------- examples/l2fwd-keepalive/main.c | 2 -- examples/l2fwd-keepalive/shm.c | 29 ++++++++----------- examples/l2fwd-keepalive/shm.h | 3 ++ examples/vm_power_manager/main.c | 11 +++---- 5 files changed, 38 insertions(+), 56 deletions(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v5 1/3] examples/l2fwd-keepalive: don't use EAL logtype 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger @ 2024-07-03 16:28 ` Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 2/3] examples/vm_power_manager: do not " Stephen Hemminger ` (2 subsequent siblings) 3 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-07-03 16:28 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Morten Brørup EAL logtype should be reserved for EAL library. This example is already has a log wrapper so use it. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> Acked-by: Morten Brørup <mb@smartsharesystems.com> --- examples/l2fwd-keepalive/main.c | 2 -- examples/l2fwd-keepalive/shm.c | 29 ++++++++++++----------------- examples/l2fwd-keepalive/shm.h | 3 +++ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index c3ead9e8b7..bff2b99531 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -41,8 +41,6 @@ #include "shm.h" -#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 - #define NB_MBUF_PER_PORT 3000 #define MAX_PKT_BURST 32 diff --git a/examples/l2fwd-keepalive/shm.c b/examples/l2fwd-keepalive/shm.c index 7c7a9ea8ea..865a19a57f 100644 --- a/examples/l2fwd-keepalive/shm.c +++ b/examples/l2fwd-keepalive/shm.c @@ -5,7 +5,6 @@ #include <time.h> #include <rte_common.h> -#include <rte_log.h> #include <rte_keepalive.h> #include "shm.h" @@ -22,34 +21,30 @@ struct rte_keepalive_shm *rte_keepalive_shm_create(void) * will get the new block mapped below. */ if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT) - printf("Warning: Error unlinking stale %s (%s)\n", + RTE_LOG(NOTICE, L2FWD, + "Warning: Error unlinking stale %s (%s)\n", RTE_KEEPALIVE_SHM_NAME, strerror(errno)); fd = shm_open(RTE_KEEPALIVE_SHM_NAME, O_CREAT | O_TRUNC | O_RDWR, 0666); if (fd < 0) - RTE_LOG(INFO, EAL, - "Failed to open %s as SHM (%s)\n", - RTE_KEEPALIVE_SHM_NAME, - strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to open %s as SHM (%s)\n", + RTE_KEEPALIVE_SHM_NAME, strerror(errno)); else if (ftruncate(fd, sizeof(struct rte_keepalive_shm)) != 0) - RTE_LOG(INFO, EAL, - "Failed to resize SHM (%s)\n", strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to resize SHM (%s)\n", strerror(errno)); else { ka_shm = (struct rte_keepalive_shm *) mmap( 0, sizeof(struct rte_keepalive_shm), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); if (ka_shm == MAP_FAILED) - RTE_LOG(INFO, EAL, - "Failed to mmap SHM (%s)\n", strerror(errno)); + RTE_LOG(ERR, L2FWD, "Failed to mmap SHM (%s)\n", strerror(errno)); else { memset(ka_shm, 0, sizeof(struct rte_keepalive_shm)); /* Initialize the semaphores for IPC/SHM use */ if (sem_init(&ka_shm->core_died, 1, 0) != 0) { - RTE_LOG(INFO, EAL, - "Failed to setup SHM semaphore (%s)\n", + RTE_LOG(ERR, L2FWD, "Failed to setup SHM semaphore (%s)\n", strerror(errno)); munmap(ka_shm, sizeof(struct rte_keepalive_shm)); @@ -87,7 +82,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, * ka_agent is not active. */ if (sem_getvalue(&shm->core_died, &count) == -1) { - RTE_LOG(INFO, EAL, "Semaphore check failed(%s)\n", + RTE_LOG(ERR, L2FWD, "Semaphore check failed(%s)\n", strerror(errno)); return; } @@ -95,8 +90,7 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, return; if (sem_post(&shm->core_died) != 0) - RTE_LOG(INFO, EAL, - "Failed to increment semaphore (%s)\n", + RTE_LOG(ERR, L2FWD, "Failed to increment semaphore (%s)\n", strerror(errno)); } } @@ -104,9 +98,10 @@ void rte_keepalive_relayed_state(struct rte_keepalive_shm *shm, void rte_keepalive_shm_cleanup(struct rte_keepalive_shm *ka_shm) { if (shm_unlink(RTE_KEEPALIVE_SHM_NAME) == -1 && errno != ENOENT) - printf("Warning: Error unlinking %s (%s)\n", + RTE_LOG(NOTICE, L2FWD, "Warning: Error unlinking %s (%s)\n", RTE_KEEPALIVE_SHM_NAME, strerror(errno)); if (ka_shm && munmap(ka_shm, sizeof(struct rte_keepalive_shm)) != 0) - printf("Warning: munmap() failed\n"); + RTE_LOG(ERR, L2FWD, "Warning: munmap() failed: %s\n", + strerror(errno)); } diff --git a/examples/l2fwd-keepalive/shm.h b/examples/l2fwd-keepalive/shm.h index 7a9d597295..f7644336e5 100644 --- a/examples/l2fwd-keepalive/shm.h +++ b/examples/l2fwd-keepalive/shm.h @@ -14,6 +14,9 @@ #include <sys/stat.h> #include <semaphore.h> #include <rte_keepalive.h> +#include <rte_log.h> + +#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 /** * Keepalive SHM structure. -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v5 2/3] examples/vm_power_manager: do not use EAL logtype 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger @ 2024-07-03 16:28 ` Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2024-07-09 12:20 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd David Marchand 3 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-07-03 16:28 UTC (permalink / raw) To: dev Cc: Stephen Hemminger, David Hunt, Huisong Li, Anatoly Burakov, Sivaprasad Tummala Be consistent for all the error printouts and use fprintf(). The EAL logtype is reserved for internal use by EAL. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: David Hunt <david.hunt@intel.com> Acked-by: Huisong Li <lihuisong@huawei.com> --- examples/vm_power_manager/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index b159291d77..c141382020 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -17,7 +17,6 @@ #include <rte_common.h> #include <rte_eal.h> #include <rte_launch.h> -#include <rte_log.h> #include <rte_per_lcore.h> #include <rte_lcore.h> #include <rte_ethdev.h> @@ -425,8 +424,7 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(-1, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } printf("Running channel monitor on lcore id %d\n", lcore_id); @@ -434,16 +432,15 @@ main(int argc, char **argv) lcore_id = rte_get_next_lcore(lcore_id, 1, 0); if (lcore_id == RTE_MAX_LCORE) { - RTE_LOG(ERR, EAL, "A minimum of three cores are required to run " - "application\n"); + fprintf(stderr, "A minimum of three cores are required to run application\n"); return 0; } if (power_manager_init() < 0) { - printf("Unable to initialize power manager\n"); + fprintf(stderr, "Unable to initialize power manager\n"); return -1; } if (channel_manager_init(CHANNEL_MGR_DEFAULT_HV_PATH) < 0) { - printf("Unable to initialize channel manager\n"); + fprintf(stderr, "Unable to initialize channel manager\n"); return -1; } -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v5 3/3] testpmd: replace EAL logtype TESTPMD_LOG 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 2/3] examples/vm_power_manager: do not " Stephen Hemminger @ 2024-07-03 16:28 ` Stephen Hemminger 2024-07-09 12:20 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd David Marchand 3 siblings, 0 replies; 33+ messages in thread From: Stephen Hemminger @ 2024-07-03 16:28 UTC (permalink / raw) To: dev; +Cc: Stephen Hemminger, Huisong Li, Aman Singh Testpmd is misusing EAL logtype for some errors. Since the code directly has a macro for logging, use that. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Huisong Li <lihuisong@huawei.com> Acked-by: Aman Singh <aman.deep.singh@intel.com> --- app/test-pmd/testpmd.c | 49 ++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 70ea257fda..b1401136e4 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3413,8 +3413,8 @@ stop_port(portid_t pid) ret = eth_dev_stop_mp(pi); if (ret != 0) { - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); + TESTPMD_LOG(ERR, + "rte_eth_dev_stop failed for port %u\n", pi); /* Allow to retry stopping the port. */ port->port_status = RTE_PORT_STARTED; continue; @@ -3812,23 +3812,20 @@ pmd_test_exit(void) if (hot_plug) { ret = rte_dev_event_monitor_stop(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to stop device event monitor."); + TESTPMD_LOG(ERR, "fail to stop device event monitor."); return; } ret = rte_dev_event_callback_unregister(NULL, dev_event_callback, NULL); if (ret < 0) { - RTE_LOG(ERR, EAL, - "fail to unregister device event callback.\n"); + TESTPMD_LOG(ERR, "fail to unregister device event callback.\n"); return; } ret = rte_dev_hotplug_handle_disable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to disable hotplug handling.\n"); + TESTPMD_LOG(ERR, "fail to disable hotplug handling.\n"); return; } } @@ -4054,20 +4051,13 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, uint16_t port_id; int ret; - if (type >= RTE_DEV_EVENT_MAX) { - fprintf(stderr, "%s called upon invalid event %d\n", - __func__, type); - fflush(stderr); - } - switch (type) { case RTE_DEV_EVENT_REMOVE: - RTE_LOG(DEBUG, EAL, "The device: %s has been removed!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been removed!\n", device_name); ret = rte_eth_dev_get_port_by_name(device_name, &port_id); if (ret) { - RTE_LOG(ERR, EAL, "can not get port by device %s!\n", - device_name); + TESTPMD_LOG(ERR, + "Can not get port for device %s!\n", device_name); return; } /* @@ -4081,17 +4071,20 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, */ if (rte_eal_alarm_set(100000, rmv_port_callback, (void *)(intptr_t)port_id)) - RTE_LOG(ERR, EAL, - "Could not set up deferred device removal\n"); + TESTPMD_LOG(ERR, "Could not set up deferred device removal\n"); break; + case RTE_DEV_EVENT_ADD: - RTE_LOG(ERR, EAL, "The device: %s has been added!\n", - device_name); + TESTPMD_LOG(INFO, "The device: %s has been added!\n", device_name); /* TODO: After finish kernel driver binding, * begin to attach port. */ break; + default: + if (type >= RTE_DEV_EVENT_MAX) + TESTPMD_LOG(ERR, "%s called upon invalid event %d\n", + __func__, type); break; } } @@ -4631,23 +4624,19 @@ main(int argc, char** argv) if (hot_plug) { ret = rte_dev_hotplug_handle_enable(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to enable hotplug handling."); + TESTPMD_LOG(ERR, "fail to enable hotplug handling."); return -1; } ret = rte_dev_event_monitor_start(); if (ret) { - RTE_LOG(ERR, EAL, - "fail to start device event monitoring."); + TESTPMD_LOG(ERR, "fail to start device event monitoring."); return -1; } - ret = rte_dev_event_callback_register(NULL, - dev_event_callback, NULL); + ret = rte_dev_event_callback_register(NULL, dev_event_callback, NULL); if (ret) { - RTE_LOG(ERR, EAL, - "fail to register device event callback\n"); + TESTPMD_LOG(ERR, "fail to register device event callback\n"); return -1; } } -- 2.43.0 ^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger ` (2 preceding siblings ...) 2024-07-03 16:28 ` [PATCH v5 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger @ 2024-07-09 12:20 ` David Marchand 3 siblings, 0 replies; 33+ messages in thread From: David Marchand @ 2024-07-09 12:20 UTC (permalink / raw) To: Stephen Hemminger; +Cc: dev On Wed, Jul 3, 2024 at 6:30 PM Stephen Hemminger <stephen@networkplumber.org> wrote: > > There are some places EAL logtype is being used in testpmd > and examples where it should not be. Lets reserve EAL > logtype to only be used by DPDK internals. > > Stephen Hemminger (3): > examples/l2fwd-keepalive: don't use EAL logtype > examples/vm_power_manager: do not use EAL logtype > testpmd: replace EAL logtype TESTPMD_LOG > Series applied, thanks. -- David Marchand ^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2024-07-09 12:21 UTC | newest] Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-12-11 17:23 [PATCH 0/3] replace use of EAL logtype Stephen Hemminger 2023-12-11 17:23 ` [PATCH 1/3] testpmd: replace EAL logtype with fprintf Stephen Hemminger 2023-12-12 11:51 ` lihuisong (C) 2023-12-11 17:23 ` [PATCH 2/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2023-12-12 11:53 ` lihuisong (C) 2023-12-11 17:23 ` [PATCH 3/3] examples/vm_power_manager: do not " Stephen Hemminger 2023-12-12 11:24 ` Hunt, David 2023-12-12 11:53 ` lihuisong (C) 2023-12-11 19:19 ` [PATCH 0/3] replace use of " Tyler Retzlaff 2023-12-11 20:15 ` Stephen Hemminger 2023-12-12 8:01 ` David Marchand 2024-02-16 3:36 ` [PATCH v2 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-02-16 8:04 ` Morten Brørup 2024-02-16 3:36 ` [PATCH v2 2/3] examples/vm_power_manager: do not " Stephen Hemminger 2024-02-16 3:36 ` [PATCH v2 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2024-03-08 13:35 ` Singh, Aman Deep 2024-03-08 16:26 ` Stephen Hemminger 2024-02-18 3:16 ` [PATCH v2 0/3] replace use of EAL logtype in applications fengchengwen 2024-03-08 18:10 ` [PATCH v3 " Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 2/3] examples/vm_power_manager: do not " Stephen Hemminger 2024-03-08 18:10 ` [PATCH v3 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 0/3] replace use of EAL logtype in applications Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 2/3] examples/vm_power_manager: do not " Stephen Hemminger 2024-03-08 22:33 ` [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2024-03-11 10:24 ` Singh, Aman Deep 2024-07-03 16:28 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 1/3] examples/l2fwd-keepalive: don't use EAL logtype Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 2/3] examples/vm_power_manager: do not " Stephen Hemminger 2024-07-03 16:28 ` [PATCH v5 3/3] testpmd: replace EAL logtype TESTPMD_LOG Stephen Hemminger 2024-07-09 12:20 ` [PATCH v5 0/3] replace use of EAL logtype in examples and testpmd David Marchand
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).