From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=20Br=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. -- 2.43.0