From patchwork Fri Mar 8 18:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138130 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0ACE43C27; Fri, 8 Mar 2024 19:11:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7061842FBD; Fri, 8 Mar 2024 19:11:51 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 0A2A140274 for ; Fri, 8 Mar 2024 19:11:49 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e64647af39so2259122b3a.1 for ; Fri, 08 Mar 2024 10:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709921508; x=1710526308; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ouf2tLM2rmIfd8fhlG+D3i1UvTfrSWV6CufHtPdxR6M=; b=Q8Up4MUB7FhfKPN6MazMOAgG+PKZZCiDf0WYDpxZvLggTBpvJ5gtVwtyqe+rftCNKn rJ7w0phV0VGguCkn+QDeAnO7VxPPqMKXXM7Y9Ik7EZSBqg/cAB+Rapm/yl0RgAwu5f10 Y4fMjd3e712i3Yrm8w9TTsDcvpeaSfAACgleaBNuMTZqvQYuUZwXeLWbFvq7EyJtWFsv ITeVaY5Jl6yDW64y4opkSir8mVpXz2Wg1zLiZTKBb7KY0XhKPU2qDHde+qcDeSda+QoN Cjpatey/XZyj4pnd9U61BYApeAoSK/57WS/1h2AU3lpp6z6ZHunqBFNQ16488ogYe4iu FLTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921508; x=1710526308; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ouf2tLM2rmIfd8fhlG+D3i1UvTfrSWV6CufHtPdxR6M=; b=A5/DsJ3if8Qi27TZMs2KmEI4Rqks9Q0aRnKocx22nVjlOPOcbnhlvjjTQA16Vqbizn ypwlcyC1hwhjX9dI8OlDE2jtIC3+Uxq7icEy8vCETQ6NRbKRq45QM4bQRZgMIRZONiV3 iM5mhm7Su0x2YELGg+aqJalEVcXnXwMDlDQpyMhurTwVxXpMMinYbuTGu8T2vs32Smhe Nk8jOd0y2USuFxkc4G3NUTJ3uc6VGv6bfFDGkx5spIHtPBdOTR98CSx2bSIqGkSaG9Wo rQT4AKDfLg5mFN1Lqj/VZe5jQsTJGIBrArByCpqy/3wvn0gJRkVye4R8ZF3YfR0Dqu8I gC5w== X-Gm-Message-State: AOJu0YxDRu3921mXJow5FKHehLUUmvi9vO1esAKPwHqA3RfgHb4Gc8H+ sr/a2ipizolRBcXpZvX8ohkZD6wGcMHvstywkOBRyYIGgw8lazmv0pVTTEEuLVzuOYk4NvjYu/D TsNU= X-Google-Smtp-Source: AGHT+IEt7ANOS8QssI+ISTmoj5zLtLVcd/GEtw6wUjCUz4lUGBYJ8zxVccknOdZp4Yh6Kn2E1iHHTA== X-Received: by 2002:a05:6a20:431e:b0:1a1:6d5e:3293 with SMTP id h30-20020a056a20431e00b001a16d5e3293mr8401158pzk.47.1709921508254; Fri, 08 Mar 2024 10:11:48 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id fn17-20020a056a002fd100b006e2301e702fsm14376020pfb.125.2024.03.08.10.11.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:11:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Huisong Li , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH v3 1/3] examples/l2fwd-keepalive: don't use EAL logtype Date: Fri, 8 Mar 2024 10:10:24 -0800 Message-ID: <20240308181137.69855-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308181137.69855-1-stephen@networkplumber.org> References: <20231211172437.61958-1-stephen@networkplumber.org> <20240308181137.69855-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org EAL logtype should be reserved for EAL library. This example is already has a log wrapper so use it. Signed-off-by: Stephen Hemminger Acked-by: Huisong Li Acked-by: Morten Brørup --- 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 #include -#include #include #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 #include #include #include #include #include + #include +#include + +#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 /** * Keepalive SHM structure. From patchwork Fri Mar 8 18:10:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138131 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 523E443C27; Fri, 8 Mar 2024 19:12:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8AC2142F9D; Fri, 8 Mar 2024 19:11:52 +0100 (CET) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id E0BA1402BB for ; Fri, 8 Mar 2024 19:11:49 +0100 (CET) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6da9c834646so2152546b3a.3 for ; Fri, 08 Mar 2024 10:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709921509; x=1710526309; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EStD9EvR6OoecugU86AyTaCTLdlfFyksP+Y5mTQTQRU=; b=GyQieI0V70EnOPu/n4jX7rkV1If5tpwrUdHi14Fx8Sqx8qq+ylKbUqQP0q2qumWOT7 yK7Fu2KS/i77djt9fjQYc7RTnedl0+UpH08szZtSHUIpAV0s/zcFoGOo6CNQnfaJSW/i /zvNiodnUtIlmng0MqpOwQj4kmiNPHePGF2CeQhElmcT/eH+w4MOQdDX0BE6eQGISzax kfBFjvfYpFfsTqA5JuwzJnTOP6rpIVcZPzdx8uhlYtZP6wLGyDVD+EoZiZCjedccwHKh OJSkOiAD7WEksa+BStvAR464wcGCydl8W2MXnYjqDkVztsXFKXQODKGqCNo566eNPdEI hRlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921509; x=1710526309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EStD9EvR6OoecugU86AyTaCTLdlfFyksP+Y5mTQTQRU=; b=PQAeMGcvcRzS/aCHVhbiWCWrp0tDECy/3evsTZqGBruKOWCIrCNt7c55+c90dgLB71 aefOvA7UWGTHboT78vI78xqn3WEBpeoIP7FaZTywhA73kr67NKKPpp4w34r1x8VGaTA+ whJbL4ASoejBQZNBm7c7FT/Yb5Tg1COwajPcntYcPZD0VkLhAoTsnd8ybKQhfbhnROBy ToA3kGQ8MQ1TbbK9IfcGCwUDUM3jIraLKn0yDKO29IDhfRfU8JLD7ZeOljSNGvGSBETO 631+at5A94xcoOWeTuKWGJBTAaNDt6PjC/YWVyzFdEc18hvQhIBLNs+chzGbnwBKl8wL C6gQ== X-Gm-Message-State: AOJu0Yx0YWO11RInPUlNmy4Lu17OaVEbrdalnIzh/52+PdJ30WgVMjRM X/q6zelGeHuOMkMdaBZGer+ySfH4zu32/YlHMbKCu38w0L7BE5GLE/9Ezy8gp9Zffq0MipDgjYL R//Y= X-Google-Smtp-Source: AGHT+IH9XBnF9oKQJKCl6lK5U2cQVnVg2upVkH78spGNoXUdXYr/Vwmv7FNR7/O/yThSWdvhD984MQ== X-Received: by 2002:a05:6a20:3941:b0:1a1:2f17:b13c with SMTP id r1-20020a056a20394100b001a12f17b13cmr13129856pzg.3.1709921509192; Fri, 08 Mar 2024 10:11:49 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id fn17-20020a056a002fd100b006e2301e702fsm14376020pfb.125.2024.03.08.10.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:11:48 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , David Hunt , Huisong Li , Anatoly Burakov , Sivaprasad Tummala Subject: [PATCH v3 2/3] examples/vm_power_manager: do not use EAL logtype Date: Fri, 8 Mar 2024 10:10:25 -0800 Message-ID: <20240308181137.69855-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308181137.69855-1-stephen@networkplumber.org> References: <20231211172437.61958-1-stephen@networkplumber.org> <20240308181137.69855-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: David Hunt Acked-by: Huisong Li --- 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 #include #include -#include #include #include #include @@ -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; } From patchwork Fri Mar 8 18:10:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138132 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19B0643C27; Fri, 8 Mar 2024 19:12:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D4FD42FF3; Fri, 8 Mar 2024 19:11:54 +0100 (CET) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTP id 0974342FA7 for ; Fri, 8 Mar 2024 19:11:51 +0100 (CET) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6d9f94b9186so2232988b3a.0 for ; Fri, 08 Mar 2024 10:11:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709921510; x=1710526310; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hIVJamTW7xfgVF58Q7co4lJ3iGXFp9BbTu7AvhTsXRU=; b=OduOnq3flGv6c+24Tib+Xhf70E8+jmW2PVAKEcFXit7nJ+Q18ZET3iRe/FfWMnDvNi tG8U4R9bHzX1LRoqnqFzAi58N0GAKJ6y3sdCorCG8ZCOfs5XyTKXnh1n9SIFEXhp795O 1eBAY0a0P8LyxybtdweM9MxIRSKgeU38bIc8z2XrwUuzXoP0tqRO6GupwBvezUMm8gUg MqrjrcYZ+Gfx7ksYO0uhv6pzFPjgDWLWNSjgDoRVem99xW9BLpgl8QI3QYh5/vP4NbM5 jG+6APwCKU0uUfNmWDfkCXBisi+Ele4ICDLyyYCaRXlqLKkZlDGyGs/9RSmrrgK9gOxb 2ahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921510; x=1710526310; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hIVJamTW7xfgVF58Q7co4lJ3iGXFp9BbTu7AvhTsXRU=; b=k8lLK4jTcVOzC191VCXqYIwl/2bDv8qihuzsmtR0vsJ91FujIZaC/pVchsh6ewts5z a3Qbanz8otHMIPVfSePYoS2/DB1RY30/0o81civwl/+FmxCiaq2TqEShuIB++icNOZ2b Xj0t9FeKbP0nABEZdCJxT0aFiD1oxebMEDDw1bL4FQn/epQutTQEAi45J/novTmVKgmI R77VluPaSv5Blzz5iDTFF3zRuWJpqzz333UJOKNu3fomXvNKKFYwo2Ut5Rnop/sjWmcm W2b5AibVnorn4+sJSFONxuBmSMkYaKDvXGB3E2+avttiG3pnBiaBny4bE7vWxiSQ5/UF 66Xg== X-Gm-Message-State: AOJu0Yyl7GdyTmDkc9PP7tWdmVfWLhjv1FRJKP9VUlKAQY9cKsGe6NEq RHz6LAFrqdB2Nw0oiFZ3Tw/pCMQFaOOhM2ccVUEmmv1i4OoDPFrqxXIwBs/4+PBDIDYGzyo45IN RJDY= X-Google-Smtp-Source: AGHT+IGuNbgpefWxk7dZS2ewLHwVvTFEQPdhz4N49fKSTBNN6WXRZ4u1VSFIqJ+vz5Q01EJh5lnQTA== X-Received: by 2002:a05:6a20:6704:b0:1a1:3cb:e1f0 with SMTP id q4-20020a056a20670400b001a103cbe1f0mr10814406pzh.52.1709921510121; Fri, 08 Mar 2024 10:11:50 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id fn17-20020a056a002fd100b006e2301e702fsm14376020pfb.125.2024.03.08.10.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:11:49 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Huisong Li , Aman Singh , Yuying Zhang Subject: [PATCH v3 3/3] testpmd: replace EAL logtype TESTPMD_LOG Date: Fri, 8 Mar 2024 10:10:26 -0800 Message-ID: <20240308181137.69855-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308181137.69855-1-stephen@networkplumber.org> References: <20231211172437.61958-1-stephen@networkplumber.org> <20240308181137.69855-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Huisong Li 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