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.