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 1064C41C34; Wed, 8 Feb 2023 00:06:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E901D42DA2; Wed, 8 Feb 2023 00:05:25 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id A192B42BC9 for ; Wed, 8 Feb 2023 00:05:20 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id rm7-20020a17090b3ec700b0022c05558d22so360110pjb.5 for ; Tue, 07 Feb 2023 15:05:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; 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=F63Q3+OzR2yVFeUNq5eBJMBVmfpDBbBM8IfALOhQmPw=; b=FjAAoNpyuqekKYa9VoH6QycZ/evTgYkXLwJ68cNfwJAgwLk9GZJi34y3gxnAL7QEbK ixrN0w/Snk13qDZUCvFQJ3j47BTP7hV0GpnGDE1ytBH4RjXwvtfqMEiQ6l0jEHFZRBds e5h16vjZpCzFLJg/eD67sXHwfJmw7P6Nx30ChNLwA6JT+xTT6tz5H9WiYZiXLO05faui b5C37Mp9SEpRFSIrgh5JPE+NTkrqP9HqbcumtfAwzqDaMEVk+JGYa6fuYQJn3xwycc4l +VB+f5vzVWnXdb+9yOF1ll4O3jlNhzaaiWilyBLhEs1rcDKfheyeLO8TCDVnOHCINuAo HVUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=F63Q3+OzR2yVFeUNq5eBJMBVmfpDBbBM8IfALOhQmPw=; b=A/xNesUa4ieYfdb1cdnPoDgKgKrAfZgJMCIbwvLsRZgExWzhrr6NRkePE4yB00Kz9T syujTk2dwHJWW/hfUyZT5la8CSSDCyWh0IU+xpo0pYMueE/0XP0Kr2aqGWo73UzItN8H S2J5o5r0nhydLrRQKfwhfxQqPm4dtl5yX9zr6IUdiFnQhArbxnXbhUO26GNQy70nBjR7 svluN2+pE/LawecZJaEdK+dY0H827WTTRv4Myl8Rptb/Ny6UD5sc0iMzMVWtBgakmkfQ mUqhil2PRc//SarGM0u3DttK9gb2Wl6l9r6fhg9dEYi+dv1luKSGsulkvTrMrkGPxnWm 7g7Q== X-Gm-Message-State: AO0yUKVCfR9N0/pXM/7I4SoXuDe4uP52js2hMbdj4OcMhAYZp+0+aqRV jQV3PZ0MNGstXbcMV+zkmBOKSbssa5KQix9JYDI= X-Google-Smtp-Source: AK7set94GAae4TNTIiBRXosG88rNhRWBJiWFq5o9KW96U6WVy368SgCBrs09Q705IPe4p0BiQ/bLDg== X-Received: by 2002:a17:90b:3847:b0:22b:f214:a919 with SMTP id nl7-20020a17090b384700b0022bf214a919mr5779093pjb.49.1675811119590; Tue, 07 Feb 2023 15:05:19 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id gq17-20020a17090b105100b0020dc318a43esm71189pjb.25.2023.02.07.15.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 15:05:19 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC v2 14/17] kni: replace RTE_LOGTYPE_KNI with dynamic type Date: Tue, 7 Feb 2023 15:04:35 -0800 Message-Id: <20230207230438.1617331-15-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207230438.1617331-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230207230438.1617331-1-stephen@networkplumber.org> MIME-Version: 1.0 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 Even though KNI will eventually disappear, fix the logtype now. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 1 - lib/eal/include/rte_log.h | 2 +- lib/kni/rte_kni.c | 63 ++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index ff250b9a6d56..b0c625a02cdf 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -351,7 +351,6 @@ static const struct logtype logtype_strings[] = { {RTE_LOGTYPE_EAL, "lib.eal"}, {RTE_LOGTYPE_PMD, "pmd"}, {RTE_LOGTYPE_HASH, "lib.hash"}, - {RTE_LOGTYPE_KNI, "lib.kni"}, {RTE_LOGTYPE_METER, "lib.meter"}, {RTE_LOGTYPE_SCHED, "lib.sched"}, {RTE_LOGTYPE_PORT, "lib.port"}, diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 55067efb0a84..69d3d07252ec 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -34,7 +34,7 @@ extern "C" { #define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */ #define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */ /* was RTE_LOGTYPE_LPM */ -#define RTE_LOGTYPE_KNI 8 /**< Log related to KNI. */ + /* was RTE_LOGTYPE_KNI */ /* was RTE_LOGTYPE_ACL */ /* was RTE_LOGTYPE_POWER */ #define RTE_LOGTYPE_METER 11 /**< Log related to QoS meter. */ diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c index 8ab6c4715314..baf732017a43 100644 --- a/lib/kni/rte_kni.c +++ b/lib/kni/rte_kni.c @@ -92,15 +92,20 @@ static void kni_allocate_mbufs(struct rte_kni *kni); static volatile int kni_fd = -1; +RTE_LOG_REGISTER_SUFFIX(kni_logtype, "kni", INFO); + +#define KNI_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, kni_logtype, fmt, ## args) + /* Shall be called before any allocation happens */ int rte_kni_init(unsigned int max_kni_ifaces __rte_unused) { - RTE_LOG(WARNING, KNI, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); + KNI_LOG(WARNING, "WARNING: KNI is deprecated and will be removed in DPDK 23.11\n"); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) if (rte_eal_iova_mode() != RTE_IOVA_PA) { - RTE_LOG(ERR, KNI, "KNI requires IOVA as PA\n"); + KNI_LOG(ERR, "KNI requires IOVA as PA\n"); return -1; } #endif @@ -109,7 +114,7 @@ rte_kni_init(unsigned int max_kni_ifaces __rte_unused) if (kni_fd < 0) { kni_fd = open("/dev/" KNI_DEVICE, O_RDWR); if (kni_fd < 0) { - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Can not open /dev/%s\n", KNI_DEVICE); return -1; } @@ -225,7 +230,7 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, /* Check if KNI subsystem has been initialized */ if (kni_fd < 0) { - RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); + KNI_LOG(ERR, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n"); return NULL; } @@ -233,19 +238,19 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool, kni = __rte_kni_get(conf->name); if (kni != NULL) { - RTE_LOG(ERR, KNI, "KNI already exists\n"); + KNI_LOG(ERR, "KNI already exists\n"); goto unlock; } te = rte_zmalloc("KNI_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { - RTE_LOG(ERR, KNI, "Failed to allocate tailq entry\n"); + KNI_LOG(ERR, "Failed to allocate tailq entry\n"); goto unlock; } kni = rte_zmalloc("KNI", sizeof(struct rte_kni), RTE_CACHE_LINE_SIZE); if (kni == NULL) { - RTE_LOG(ERR, KNI, "KNI memory allocation failed\n"); + KNI_LOG(ERR, "KNI memory allocation failed\n"); goto kni_fail; } @@ -424,7 +429,7 @@ rte_kni_release(struct rte_kni *kni) strlcpy(dev_info.name, kni->name, sizeof(dev_info.name)); if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) { - RTE_LOG(ERR, KNI, "Fail to release kni device\n"); + KNI_LOG(ERR, "Fail to release kni device\n"); goto unlock; } @@ -439,7 +444,7 @@ rte_kni_release(struct rte_kni *kni) usleep(1000); if (kni_fifo_count(kni->rx_q)) - RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n"); + KNI_LOG(ERR, "Fail to free all Rx-q items\n"); kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q); kni_free_fifo(kni->tx_q); @@ -466,16 +471,16 @@ kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[]) int ret = 0; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id); + KNI_LOG(INFO, "Configure mac address of %d", port_id); ret = rte_eth_dev_default_mac_addr_set(port_id, (struct rte_ether_addr *)mac_addr); if (ret < 0) - RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n", + KNI_LOG(ERR, "Failed to config mac_addr for port %d\n", port_id); return ret; @@ -488,11 +493,11 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) int ret; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure promiscuous mode of %d to %d\n", + KNI_LOG(INFO, "Configure promiscuous mode of %d to %d\n", port_id, to_on); if (to_on) @@ -501,7 +506,7 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) ret = rte_eth_promiscuous_disable(port_id); if (ret != 0) - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Failed to %s promiscuous mode for port %u: %s\n", to_on ? "enable" : "disable", port_id, rte_strerror(-ret)); @@ -516,11 +521,11 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) int ret; if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); + KNI_LOG(ERR, "Invalid port id %d\n", port_id); return -EINVAL; } - RTE_LOG(INFO, KNI, "Configure allmulticast mode of %d to %d\n", + KNI_LOG(INFO, "Configure allmulticast mode of %d to %d\n", port_id, to_on); if (to_on) @@ -528,7 +533,7 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) else ret = rte_eth_allmulticast_disable(port_id); if (ret != 0) - RTE_LOG(ERR, KNI, + KNI_LOG(ERR, "Failed to %s allmulticast mode for port %u: %s\n", to_on ? "enable" : "disable", port_id, rte_strerror(-ret)); @@ -551,7 +556,7 @@ rte_kni_handle_request(struct rte_kni *kni) return 0; /* It is OK of can not getting the request mbuf */ if (req != kni->sync_addr) { - RTE_LOG(ERR, KNI, "Wrong req pointer %p\n", req); + KNI_LOG(ERR, "Wrong req pointer %p\n", req); return -1; } @@ -592,7 +597,7 @@ rte_kni_handle_request(struct rte_kni *kni) kni->ops.port_id, req->allmulti); break; default: - RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id); + KNI_LOG(ERR, "Unknown request id %u\n", req->req_id); req->result = -EINVAL; break; } @@ -603,7 +608,7 @@ rte_kni_handle_request(struct rte_kni *kni) else ret = 1; if (ret != 1) { - RTE_LOG(ERR, KNI, "Fail to put the muf back to resp_q\n"); + KNI_LOG(ERR, "Fail to put the muf back to resp_q\n"); return -1; /* It is an error of can't putting the mbuf back */ } @@ -679,7 +684,7 @@ kni_allocate_mbufs(struct rte_kni *kni) /* Check if pktmbuf pool has been configured */ if (kni->pktmbuf_pool == NULL) { - RTE_LOG(ERR, KNI, "No valid mempool for allocating mbufs\n"); + KNI_LOG(ERR, "No valid mempool for allocating mbufs\n"); return; } @@ -690,7 +695,7 @@ kni_allocate_mbufs(struct rte_kni *kni) pkts[i] = rte_pktmbuf_alloc(kni->pktmbuf_pool); if (unlikely(pkts[i] == NULL)) { /* Out of memory */ - RTE_LOG(ERR, KNI, "Out of memory\n"); + KNI_LOG(ERR, "Out of memory\n"); break; } phys[i] = va2pa(pkts[i]); @@ -757,18 +762,18 @@ rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops) enum kni_ops_status req_status; if (ops == NULL) { - RTE_LOG(ERR, KNI, "Invalid KNI request operation.\n"); + KNI_LOG(ERR, "Invalid KNI request operation.\n"); return -1; } if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); + KNI_LOG(ERR, "Invalid kni info.\n"); return -1; } req_status = kni_check_request_register(&kni->ops); if (req_status == KNI_REQ_REGISTERED) { - RTE_LOG(ERR, KNI, "The KNI request operation has already registered.\n"); + KNI_LOG(ERR, "The KNI request operation has already registered.\n"); return -1; } @@ -780,7 +785,7 @@ int rte_kni_unregister_handlers(struct rte_kni *kni) { if (kni == NULL) { - RTE_LOG(ERR, KNI, "Invalid kni info.\n"); + KNI_LOG(ERR, "Invalid kni info.\n"); return -1; } @@ -806,7 +811,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) fd = open(path, O_RDWR); if (fd == -1) { - RTE_LOG(ERR, KNI, "Failed to open file: %s.\n", path); + KNI_LOG(ERR, "Failed to open file: %s.\n", path); return -1; } @@ -823,7 +828,7 @@ rte_kni_update_link(struct rte_kni *kni, unsigned int linkup) new_carrier = linkup ? "1" : "0"; ret = write(fd, new_carrier, 1); if (ret < 1) { - RTE_LOG(ERR, KNI, "Failed to write file: %s.\n", path); + KNI_LOG(ERR, "Failed to write file: %s.\n", path); close(fd); return -1; } -- 2.39.1