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 B30FF41C58; Fri, 10 Feb 2023 02:09:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C873642D5D; Fri, 10 Feb 2023 02:08:19 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 26D5242D20 for ; Fri, 10 Feb 2023 02:08:14 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso7505452pju.0 for ; Thu, 09 Feb 2023 17:08:14 -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=qnKdfj+fOpVFlnE0xwWcwjQ/fObrrSNzzUnVGCC7FFo=; b=dNbusazKY1CDq/0Ezc2ymddkbE20leMdwUlPoNgtG3hi8BqYKj6WWiSV8HcIqAFpNd Hf+g4LB6vWWy6EtcdfB1P/Y1LX+ONllJdlFEG+Yf1SPMavM4iwlTOvG3/tVi5y4u6K99 jW6Jtnckm5ph9bJH8/8ID7bkYCrIyf5SDPzt9WLVCJyPLXOT7FBLJYXWT3QVjMBvNmgd cqTrKoVb4ipO2AiHy1yE7NvsQneRqmcLBmhq2jobGf9h0fmNomZ6+rcWM9BT5yrqP5WO UdoPAtco3auJlQMR9kj6piXkDQjfl9rzoA1MfbdYY6cFThBgzBPLjteXZAyB0VVRnth3 8N5g== 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=qnKdfj+fOpVFlnE0xwWcwjQ/fObrrSNzzUnVGCC7FFo=; b=Ouvoqlv69yrWCxwlyLLPnWh9P+tzGg/G3pn2tlzIyubWTG9Hz6jLDgTtQPUR8BizLp 750M0b/tMoOn8Whwi2NSwo/a2gfPzwM0M4GFPYxUvOVJ+I/qM65+Wp0AE99Vuy819vUD z6uUgxNvE6ej+NQxEtnGdHuBvd8RSkC4V68SF5CFP5lI/uv+Zbwad3g1CnYfF2K8RlXE JEK2uR3NXQhzGyfoByCd8vD/RHtKb2otoA1FVXKfJKN3btMEx/1aODCSdBRhezlxAPxx Dg7wzS2uZ+f+OmwxnXAx2xOdb5gtADXZTDOmuayjAtqUXJVl+MaISwuQ1DyM1KkAkz+K W+SQ== X-Gm-Message-State: AO0yUKV2rsUYo1hhdxjVVQfOV3aoX5NQ1vdV29P7ZgngWfn+9LsV64gQ B2e6ujlDdkSfAK6bmJa1TeABiuAorSax4McH7k4= X-Google-Smtp-Source: AK7set+Nz+QxXaBfWoHftnpTu+zxdj1XYaK27jFuJkyjlFHd/xWmlsDD4xeuUmIXCYgGjtcejdrilw== X-Received: by 2002:a17:902:d506:b0:196:5bac:e319 with SMTP id b6-20020a170902d50600b001965bace319mr14634340plg.35.1675991293033; Thu, 09 Feb 2023 17:08:13 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jd9-20020a170903260900b0019625428cefsm2103023plb.281.2023.02.09.17.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 17:08:12 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3 10/16] kni: replace RTE_LOGTYPE_KNI with dynamic type Date: Thu, 9 Feb 2023 17:07:18 -0800 Message-Id: <20230210010724.890413-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210010724.890413-1-stephen@networkplumber.org> References: <20230207204151.1503491-1-stephen@networkplumber.org> <20230210010724.890413-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..6645c2a239cb 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_DEFAULT(kni_logtype, 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