From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CE939A04AB; Fri, 8 Nov 2019 05:38:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C55B1BF8E; Fri, 8 Nov 2019 05:38:35 +0100 (CET) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id E775C1BF51 for ; Fri, 8 Nov 2019 05:38:31 +0100 (CET) Received: by mail-pl1-f195.google.com with SMTP id az9so2358576plb.11 for ; Thu, 07 Nov 2019 20:38:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=djMDG35cjCuB045UhyXyogOlbaXDiaLovHY570h01OE=; b=1PyCVKeDdGsB+4kLZwqoNw/LBzUtwTSaGqrPAQF0zQVAhW1z9DI8orh+17LiSsGeWC wrBM+6O+XWipt2R9GpiDaNHEYdud3FhR0f6VTGgvHAoNN+TKNjvK8T52FBOvtl9r23g4 GaktHNJyjvOy/B4zpwIuVN0ahmRQzZJt3mX4Tjb4frz2cw0Efji2r72KekYQ2ERYjXUh 4fYAmBLWil3uNGgNXWtaeknpOvea6WTDkPJSfy0vevjT0+RjiF7LeulzcXQ/hmXOARdJ 7p1FH27lkqTKyULPn2YHQnCG7iiwqgoyocWvqOOWi/0OyvmLMEYrsLpegfXuPyYFQ7KU AgfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=djMDG35cjCuB045UhyXyogOlbaXDiaLovHY570h01OE=; b=ReqgHD0+GJzT7/2H6kXCuAxGiKddcMR8hVeULOjR9NNLzwY5cDKZnzfiYwni9gv2t4 LqI0Yli5XxCZ4GtoE6vLdlwvkbYp1dgHcPK+Z1jPmP4DeW4QP/ilhyYmttm5gFNqIt5c Dl3+btgs63DQ1dd366gsQ6z/SPtoSwkO93Lcj/MtIgFGKqeKCSOCJwHlSK91c2rpI8z1 KFbPX4sQU7a1dHCnXt5qzLVQDfHyhUMUVr4HdkWz/opAQWAKCwdzlTUSM3Ua/2u1aVtS 4Ysa3xcb4tW6VDBYDbL1c8frvaFyOdmRHzPjrOA/HuLnYfKychmq2aOUBZzIQ3awom6r 8fPg== X-Gm-Message-State: APjAAAUeqhxcr2KvIzdXGFRx/itY/mvRAWYrtqOlL6N3czPfuo2wvJGh ZWWIC3KfIJdAb/gvKNrqOdFoDAMxgkcy9A== X-Google-Smtp-Source: APXvYqyo3WTdTpxgO8nUTjp0335DjcEoWyLq7tR+EFFKdoT+LT4p3Mu6hN/17kOVF2jCdrX4Rs8SbQ== X-Received: by 2002:a17:902:6bc1:: with SMTP id m1mr8227976plt.67.1573187910425; Thu, 07 Nov 2019 20:38:30 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id y24sm5291303pfr.116.2019.11.07.20.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2019 20:38:29 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 7 Nov 2019 20:38:18 -0800 Message-Id: <20191108043818.27610-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191108043818.27610-1-stephen@networkplumber.org> References: <20191108043818.27610-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/2] pdump: use dynamic logtype X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The logtype USER1 should not be overloaded for library function. Instead use a dynamic log type. Signed-off-by: Stephen Hemminger --- lib/librte_pdump/rte_pdump.c | 68 ++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index 7816c7254615..ae25e2a064a4 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -13,8 +13,12 @@ #include "rte_pdump.h" #define DEVICE_ID_SIZE 64 -/* Macros for printing using RTE_LOG */ -#define RTE_LOGTYPE_PDUMP RTE_LOGTYPE_USER1 + +/* Macro for printing using RTE_LOG */ +static int pdump_logtype; +#define PDUMP_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, pdump_logtype, "%s(): " fmt, \ + __func__, ## args) /* Used for the multi-process communication */ #define PDUMP_MP "mp_pdump" @@ -88,7 +92,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) ring_enq = rte_ring_enqueue_burst(ring, (void *)dup_bufs, d_pkts, NULL); if (unlikely(ring_enq < d_pkts)) { - RTE_LOG(DEBUG, PDUMP, + PDUMP_LOG(DEBUG, "only %d of packets enqueued to ring\n", ring_enq); do { rte_pktmbuf_free(dup_bufs[ring_enq]); @@ -127,7 +131,7 @@ pdump_register_rx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, cbs = &rx_cbs[port][qid]; if (cbs && operation == ENABLE) { if (cbs->cb) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to add rx callback for port=%d " "and queue=%d, callback already exists\n", port, qid); @@ -138,7 +142,7 @@ pdump_register_rx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, cbs->cb = rte_eth_add_first_rx_callback(port, qid, pdump_rx, cbs); if (cbs->cb == NULL) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to add rx callback, errno=%d\n", rte_errno); return rte_errno; @@ -148,7 +152,7 @@ pdump_register_rx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, int ret; if (cbs->cb == NULL) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to delete non existing rx " "callback for port=%d and queue=%d\n", port, qid); @@ -156,7 +160,7 @@ pdump_register_rx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, } ret = rte_eth_remove_rx_callback(port, qid, cbs->cb); if (ret < 0) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to remove rx callback, errno=%d\n", -ret); return ret; @@ -182,7 +186,7 @@ pdump_register_tx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, cbs = &tx_cbs[port][qid]; if (cbs && operation == ENABLE) { if (cbs->cb) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to add tx callback for port=%d " "and queue=%d, callback already exists\n", port, qid); @@ -193,7 +197,7 @@ pdump_register_tx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, cbs->cb = rte_eth_add_tx_callback(port, qid, pdump_tx, cbs); if (cbs->cb == NULL) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to add tx callback, errno=%d\n", rte_errno); return rte_errno; @@ -203,7 +207,7 @@ pdump_register_tx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, int ret; if (cbs->cb == NULL) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to delete non existing tx " "callback for port=%d and queue=%d\n", port, qid); @@ -211,7 +215,7 @@ pdump_register_tx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, } ret = rte_eth_remove_tx_callback(port, qid, cbs->cb); if (ret < 0) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to remove tx callback, errno=%d\n", -ret); return ret; @@ -240,7 +244,7 @@ set_pdump_rxtx_cbs(const struct pdump_request *p) ret = rte_eth_dev_get_port_by_name(p->data.en_v1.device, &port); if (ret < 0) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to get port id for device id=%s\n", p->data.en_v1.device); return -EINVAL; @@ -252,7 +256,7 @@ set_pdump_rxtx_cbs(const struct pdump_request *p) ret = rte_eth_dev_get_port_by_name(p->data.dis_v1.device, &port); if (ret < 0) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "failed to get port id for device id=%s\n", p->data.dis_v1.device); return -EINVAL; @@ -277,18 +281,18 @@ set_pdump_rxtx_cbs(const struct pdump_request *p) nb_rx_q = dev_info.nb_rx_queues; nb_tx_q = dev_info.nb_tx_queues; if (nb_rx_q == 0 && flags & RTE_PDUMP_FLAG_RX) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "number of rx queues cannot be 0\n"); return -EINVAL; } if (nb_tx_q == 0 && flags & RTE_PDUMP_FLAG_TX) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "number of tx queues cannot be 0\n"); return -EINVAL; } if ((nb_tx_q == 0 || nb_rx_q == 0) && flags == RTE_PDUMP_FLAG_RXTX) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "both tx&rx queues must be non zero\n"); return -EINVAL; } @@ -324,7 +328,7 @@ pdump_server(const struct rte_mp_msg *mp_msg, const void *peer) /* recv client requests */ if (mp_msg->len_param != sizeof(*cli_req)) { - RTE_LOG(ERR, PDUMP, "failed to recv from client\n"); + PDUMP_LOG(ERR, "failed to recv from client\n"); resp->err_value = -EINVAL; } else { cli_req = (const struct pdump_request *)mp_msg->param; @@ -337,8 +341,8 @@ pdump_server(const struct rte_mp_msg *mp_msg, const void *peer) mp_resp.len_param = sizeof(*resp); mp_resp.num_fds = 0; if (rte_mp_reply(&mp_resp, peer) < 0) { - RTE_LOG(ERR, PDUMP, "failed to send to client:%s, %s:%d\n", - strerror(rte_errno), __func__, __LINE__); + PDUMP_LOG(ERR, "failed to send to client:%s\n", + strerror(rte_errno)); return -1; } @@ -366,19 +370,18 @@ static int pdump_validate_ring_mp(struct rte_ring *ring, struct rte_mempool *mp) { if (ring == NULL || mp == NULL) { - RTE_LOG(ERR, PDUMP, "NULL ring or mempool are passed %s:%d\n", - __func__, __LINE__); + PDUMP_LOG(ERR, "NULL ring or mempool\n"); rte_errno = EINVAL; return -1; } if (mp->flags & MEMPOOL_F_SP_PUT || mp->flags & MEMPOOL_F_SC_GET) { - RTE_LOG(ERR, PDUMP, "mempool with either SP or SC settings" + PDUMP_LOG(ERR, "mempool with either SP or SC settings" " is not valid for pdump, should have MP and MC settings\n"); rte_errno = EINVAL; return -1; } if (ring->prod.single || ring->cons.single) { - RTE_LOG(ERR, PDUMP, "ring with either SP or SC settings" + PDUMP_LOG(ERR, "ring with either SP or SC settings" " is not valid for pdump, should have MP and MC settings\n"); rte_errno = EINVAL; return -1; @@ -392,7 +395,7 @@ pdump_validate_flags(uint32_t flags) { if (flags != RTE_PDUMP_FLAG_RX && flags != RTE_PDUMP_FLAG_TX && flags != RTE_PDUMP_FLAG_RXTX) { - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "invalid flags, should be either rx/tx/rxtx\n"); rte_errno = EINVAL; return -1; @@ -407,17 +410,15 @@ pdump_validate_port(uint16_t port, char *name) int ret = 0; if (port >= RTE_MAX_ETHPORTS) { - RTE_LOG(ERR, PDUMP, "Invalid port id %u, %s:%d\n", port, - __func__, __LINE__); + PDUMP_LOG(ERR, "Invalid port id %u\n", port); rte_errno = EINVAL; return -1; } ret = rte_eth_dev_get_name_by_port(port, name); if (ret < 0) { - RTE_LOG(ERR, PDUMP, - "port id to name mapping failed for port id=%u, %s:%d\n", - port, __func__, __LINE__); + PDUMP_LOG(ERR, "port %u to name mapping failed\n", + port); rte_errno = EINVAL; return -1; } @@ -472,7 +473,7 @@ pdump_prepare_client_request(char *device, uint16_t queue, } if (ret < 0) - RTE_LOG(ERR, PDUMP, + PDUMP_LOG(ERR, "client request for pdump enable/disable failed\n"); return ret; } @@ -559,3 +560,10 @@ rte_pdump_disable_by_deviceid(char *device_id, uint16_t queue, return ret; } + +RTE_INIT(pdump_log) +{ + pdump_logtype = rte_log_register("lib.pdump"); + if (pdump_logtype >= 0) + rte_log_set_level(pdump_logtype, RTE_LOG_NOTICE); +} -- 2.20.1