From patchwork Fri Mar 8 22:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138138 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 DA59043C4B; Fri, 8 Mar 2024 23:34:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5826842EF6; Fri, 8 Mar 2024 23:34:53 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 08BD3402BB for ; Fri, 8 Mar 2024 23:34:51 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1dd5df90170so16050915ad.0 for ; Fri, 08 Mar 2024 14:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709937290; x=1710542090; 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=+vH7ElaK8Orbu4gFrHDq5OpmZPBIsMHSYUchKwm0Gmc=; b=TRKHi9ZkY9QL1GvSTA0XyrL9p7TF+j8aHBbNqTR3GV2hfMvTkn7/n8mmtPe9LcW2Ix bF4AQs8DatSLoZQcXpAPeZGcnUznAcLFasC7LAacApoycGD3w6MuBPon4pFin4TiSPRT B78dorReHYrPYRA/S/h7q2iIqI1ETOpQx/F6+hVYw0sJF/GC7SVjWDhHAnqkaZUpHIpF ZPMxjfRp0HEJErC7avSuLU29pZdw4IIdq+aMDcdWIwEIKHKoZwFAtZ+RnMQ1PbemDRp6 lQ55LCyiGHSN+xk4TD1OSy8KlQQAMHoqbJHG3f9aeM+eHSdYcv767rVcN3RA/4yIC1fY VfSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709937290; x=1710542090; 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=+vH7ElaK8Orbu4gFrHDq5OpmZPBIsMHSYUchKwm0Gmc=; b=amtmC/DvGuvWVZs0Plzg+biIctsSlPdghzlNmGnhSXLQPaoeeJT6KB2ujnZcg2kBtu C6Eqdd4Ne9M66tZBxNKOb/GbZfs/sZowG6jzib8UxxMcj5aGH/DkgR9U+2mb/nXQKOMH 66ZglauNBDGIu+2nAi7M/c57h9XZYlepioDxgq9oU/AAkA62rg1S5C84uS4S6J8HMhlD xyUD9+5H369Cde3IPyCMyN1oCGpYjbPgHnxav0PIyX2tj7u19QkI/MpMd87/9jd+n5nY MINNZS6DmCVm56vEZKLDYYy2QWQD/0SixUC3vZBHybpLwWblkn7ig80TdPPFnamUcMcY i6rg== X-Gm-Message-State: AOJu0Yz3FyjjDuTcvcT4cPAEIMluIIeoOdYOeqaS1vgrsFkyRMN/A/OX hCMCttzeValVc3qSDHqCD4n15HfLhrmhMeN7vvFT2qrajq2Q80lZXCziu3rnrXeadsYpci5mXIk akMA= X-Google-Smtp-Source: AGHT+IGYxvP84RLgO9ZltLy4v0wAyL5P51Ahm0r0VltTogQeqoDThz63+h/mE4iQJ4GwRenDmOg7ng== X-Received: by 2002:a17:903:1c9:b0:1dd:6c08:af with SMTP id e9-20020a17090301c900b001dd6c0800afmr99660plh.4.1709937290143; Fri, 08 Mar 2024 14:34:50 -0800 (PST) Received: from hermes.lan (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id c8-20020a170903234800b001dc3c4e7a12sm145517plh.14.2024.03.08.14.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 14:34:49 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Huisong Li , =?utf-8?q?Morten_Br=C3=B8rup?= Subject: [PATCH v4 1/3] examples/l2fwd-keepalive: don't use EAL logtype Date: Fri, 8 Mar 2024 14:33:40 -0800 Message-ID: <20240308223446.215726-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308223446.215726-1-stephen@networkplumber.org> References: <20231211172437.61958-1-stephen@networkplumber.org> <20240308223446.215726-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 | 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 #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..f7644336e543 100644 --- a/examples/l2fwd-keepalive/shm.h +++ b/examples/l2fwd-keepalive/shm.h @@ -14,6 +14,9 @@ #include #include #include +#include + +#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 /** * Keepalive SHM structure. From patchwork Fri Mar 8 22:33:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138139 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 6E6AC43C4B; Fri, 8 Mar 2024 23:35:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A4F8342F00; Fri, 8 Mar 2024 23:34:54 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id D9DCD42DCE for ; Fri, 8 Mar 2024 23:34:51 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1dd5df90170so16051045ad.0 for ; Fri, 08 Mar 2024 14:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709937291; x=1710542091; 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=GRz5CfsxW1wqYSCdwOimV1uXwr9eMKNXBOlYXpZGHg3QWFu64c6Xu8QWYm7W2icoRk nu2mWTyNjzE1N5WC205j6JOKt45TVfJ+drrh/0xa8bU5QkzatJWf8HA7iATNGq0yPpMV e1QfWlA1m2ancNP5zJKwj378/U7B4DqtqUcjifunbuabVHWvm4gbegjsZvB18srbbcoo RkUE0HStYe9vXlPRDEy4tc8lXqKekAC9nF4f/45BMxZMPJUpPoIreEfD81O4aD/TJCcZ fqfYf6+EVASDGrxoLlSvxQut9yCJonq/vBDi5gtrtEolm9XQn9PIUSvvarls4YWs3/Qy 5aAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709937291; x=1710542091; 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=jbEuNZAmq7XaY8XA8zXL5jJx/I/S5YIFYcj2fJ7E4u/uhPnskedKiGCDlrsoLacKWg BMh1L+7Lw4gl1v/jS1X1hgCIWJiC0fhwrqLa2fdhp4dJaCMbTogRfF2jZHO3PNaoIxcL YOugg/9SlBA9dgPkGSruUoMAfBWfW75MLovGbiOp7xbpon4vRFFEHwIq3rf4WkYQ01V0 OSRLBi9ykzP7y92EO4uPeuYrrQbAxB6DTFsbJM0QZr58CjwE1jRnkuf+ZTRxgwciikBJ RS3LuPjtrZm7JfOWqq0s7Su24JUqnAi47VNkh6xEM4GDLI1y9YGiiVDUzV3eO9VION7x qeUA== X-Gm-Message-State: AOJu0Yye5tfno09FZ3jdadstSi0133eOiWHnRs2sxtqQKGqyQKI9eslY Zs2ydqPnz9+PJn3ua6txuKTmjRqoPxfxCXgdP3G2WLRGuuSZO9XEDinyw4wlzSONZyre3ssOu1b DnDU= X-Google-Smtp-Source: AGHT+IECGISYvwmv98yi6R+gW6U9068JNzwv+tFJpQBU4DyIDUCXPEcurJPjBqNpZMC57/9xmizwmA== X-Received: by 2002:a17:903:2291:b0:1dc:6071:60ad with SMTP id b17-20020a170903229100b001dc607160admr56338plh.24.1709937291042; Fri, 08 Mar 2024 14:34:51 -0800 (PST) Received: from hermes.lan (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id c8-20020a170903234800b001dc3c4e7a12sm145517plh.14.2024.03.08.14.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 14:34:50 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , David Hunt , Huisong Li , Anatoly Burakov , Sivaprasad Tummala Subject: [PATCH v4 2/3] examples/vm_power_manager: do not use EAL logtype Date: Fri, 8 Mar 2024 14:33:41 -0800 Message-ID: <20240308223446.215726-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308223446.215726-1-stephen@networkplumber.org> References: <20231211172437.61958-1-stephen@networkplumber.org> <20240308223446.215726-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 22:33:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 138140 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 A3A6843C4B; Fri, 8 Mar 2024 23:35:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CED2642F15; Fri, 8 Mar 2024 23:34:55 +0100 (CET) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 16DE542EB4 for ; Fri, 8 Mar 2024 23:34:53 +0100 (CET) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1dc29f1956cso9352385ad.0 for ; Fri, 08 Mar 2024 14:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1709937292; x=1710542092; 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=3OzhYHxv5OC5PgVusI9JHZzSBs+VxmefVyK61cGuRZX7dmUjHmJZGA823jtKPOLqI1 8AcCea9JxiwkT7/D4d4syrjBBxtLiEW09g1mk0LuibrBdvj1pV0UG9bBoFNga3jb6wRz IXDQZy2xmKYvF7FRzZPSBTOMaTLrSOINvC3KqzBKZKp1SC3+lLa8q5UV0Zj5u+97Cjm7 ko6uZA1KdAjwXe/P3bE8kGLamF7vDQpp3cmAFCFcCdlGKgq4IUeNgYMQ7eAS21Cv1bIr 74RS0Rifeca3j0fpOg5FIJHezv8OkDgGK7fTTRD5zHWzMSkFidvutzT3wL8GczaT5vuy ZfKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709937292; x=1710542092; 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=HW21Me8f2BfkNC9Z40u1GtR4weT6sUOe03dnCXVqHQ590eu24xW1EChN3s7WymESaA iAY9WXd5zddkpcKZtbaT+8Ma0lOGr7ZGku/WmLhRmbN9FHWkiVqw48ZEuRys2AY5RKQk DJI0mW/c2OFvO+qqVNGBYZEsx6cjf2YknpVK0FTi1N/XG8cTji7ikVpuSo89CdIIY45l 8tBNsWFuRwrFH4ZoMiCvUtp/5FneT97kyIN/FT/xmZgaccpgrWJ3vNueelnPsIHN0MuA 6bZBkdymH+P4inv4Rr1C0M+0mE7899+qdf07zqcFW5JgBHkXuo+dA17JtwoV3IGjvz3k J7WQ== X-Gm-Message-State: AOJu0Ywl/XYH2GZgggtGy+s9v9OMtZx7M2jqccNRaIJ7MdOdpaQ9s/Jb JvHl5xE4BQmN1aWOv1KNnzjJbIJp35kMU8FabcbUqI7dP0cYMvs8Wx4MPPkAQcUwsXkygHxvQQT kOIQ= X-Google-Smtp-Source: AGHT+IGTt0gBgLS+C87YavAQXOjE4rPqH7a5wqNLi9/4jWh5uydL1qCEVWFCl6hhcTXkU/ysXjmEZg== X-Received: by 2002:a17:903:a8c:b0:1dd:6356:8dfc with SMTP id mo12-20020a1709030a8c00b001dd63568dfcmr49618plb.15.1709937292067; Fri, 08 Mar 2024 14:34:52 -0800 (PST) Received: from hermes.lan (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id c8-20020a170903234800b001dc3c4e7a12sm145517plh.14.2024.03.08.14.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 14:34:51 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Huisong Li , Aman Singh , Yuying Zhang Subject: [PATCH v4 3/3] testpmd: replace EAL logtype TESTPMD_LOG Date: Fri, 8 Mar 2024 14:33:42 -0800 Message-ID: <20240308223446.215726-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240308223446.215726-1-stephen@networkplumber.org> References: <20231211172437.61958-1-stephen@networkplumber.org> <20240308223446.215726-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 Acked-by: Aman Singh --- 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