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 D364C41CEC; Mon, 20 Feb 2023 17:16:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B29CF43091; Mon, 20 Feb 2023 17:16:45 +0100 (CET) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mails.dpdk.org (Postfix) with ESMTP id B525440395 for ; Mon, 20 Feb 2023 17:16:44 +0100 (CET) Received: by mail-pf1-f174.google.com with SMTP id g12so846178pfi.0 for ; Mon, 20 Feb 2023 08:16:44 -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:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=cetIEqNf2aW+NmC2dmuo5GzyE6wmN+wHZgWA3ttxXPA=; b=q5/QHyR26r+mUz3gd83+i0j8LibTmAObzXHredYkrRJh0HQejxphfblM/0bVrAPH91 QW/rf8T8HDHEPTNt/sy+V+vc1B/FPetvuyVsTA9qAopdze7gOo2woVvmix57ghbLHtyi SRuj9K7VIYANB2zHtIml0IFClfBU9qGoJR7dhXbnnkL4/W7CTolsdy9+E8QXP7kNHQpk 9rcP6yd7AbpAPDcCP0nq7pxUUUNQHzMlWDsftCpTIOpQg4TWxKsNz2TwC1dTLewBTy7X qudmCO6Xm9t2ZjmTGrt8YK7y394m3MvRMnn6watudMNQ9N1axhsYzb6iVjyVSn8VmEWK GHog== 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:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cetIEqNf2aW+NmC2dmuo5GzyE6wmN+wHZgWA3ttxXPA=; b=lJwU+XAhpRl49PzyChQ853nIhMPw982t6+/blB/qDsMqEWCE4kmB+aPdrPc4B1P12F b9AGaEAu5duhQuB+N8mKOVuzSA51AAwIFwghf5dSYgZ6gK5q08EwXAEgceYHeLIfAIJf arlviPxmmmXbcEJ6JQ/Z1lmniX2CB02FZwnhogKHB7V8S/0WYHjFRnf7YubudTj9LaQx CCKX4hAnp5b+uJBkNFB3lGTPzHREECoTOL0y7os6EpJKaTK3Pp2KiO0YRDp//gzRTnrs 9ZlNKG7vJSei7/ce5Y7dMpR4uEwrKwdBH0iiJDF1XD+4it9mWrLRyR8t9Axzhe6N8Er1 p12g== X-Gm-Message-State: AO0yUKWjcJWyV8ghNqDuHnXkzVemny92sK2rsP6Aed7wNOHe5Dkgn9YL iZRX4OHG/NvMC9QJjPenwmi75A== X-Google-Smtp-Source: AK7set8TG8b/WHOrp+P75/zv2uza+ZIzxRMrDyFURYCzSjBiFVPB2QhgoPvBuSdTC/WSMTKjwsdulw== X-Received: by 2002:aa7:8f0b:0:b0:578:ac9f:79a9 with SMTP id x11-20020aa78f0b000000b00578ac9f79a9mr2043942pfr.15.1676909803444; Mon, 20 Feb 2023 08:16:43 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id d2-20020aa78e42000000b005943bd7c72bsm1732749pfr.190.2023.02.20.08.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 08:16:43 -0800 (PST) Date: Mon, 20 Feb 2023 08:16:41 -0800 From: Stephen Hemminger To: Ferruh Yigit Cc: Chaoyong He , "dev@dpdk.org" , oss-drivers , Niklas Soderlund Subject: Re: [PATCH 2/3] net/nfp: get rid of the usage of RTE log level type Message-ID: <20230220081641.623a2a97@hermes.local> In-Reply-To: <357ee243-d0d1-37fb-f7f3-ba4d99a001ed@amd.com> References: <20230217024539.16514-1-chaoyong.he@corigine.com> <20230217024539.16514-3-chaoyong.he@corigine.com> <357ee243-d0d1-37fb-f7f3-ba4d99a001ed@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Mon, 20 Feb 2023 10:09:51 +0000 Ferruh Yigit wrote: > On 2/20/2023 1:36 AM, Chaoyong He wrote: > >> On 2/17/2023 2:45 AM, Chaoyong He wrote: =20 > >>> Register the own RX/TX debug log level type, and get rid of the usage > >>> of RTE_LOGTYPE_*. Then we can control the log by a independent switch. > >>> > >>> Signed-off-by: Chaoyong He > >>> Reviewed-by: Niklas S=C3=B6derlund > >>> --- > >>> drivers/net/nfp/nfp_logs.c | 10 ++++++++++ > >>> drivers/net/nfp/nfp_logs.h | 8 ++++++-- > >>> 2 files changed, 16 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/net/nfp/nfp_logs.c b/drivers/net/nfp/nfp_logs.c > >>> index 48c42fe53f..cd58bcee43 100644 > >>> --- a/drivers/net/nfp/nfp_logs.c > >>> +++ b/drivers/net/nfp/nfp_logs.c > >>> @@ -5,6 +5,16 @@ > >>> > >>> #include "nfp_logs.h" > >>> > >>> +#include > >>> + > >>> RTE_LOG_REGISTER_SUFFIX(nfp_logtype_init, init, NOTICE); > >>> RTE_LOG_REGISTER_SUFFIX(nfp_logtype_driver, driver, NOTICE); > >>> RTE_LOG_REGISTER_SUFFIX(nfp_logtype_cpp, cpp, NOTICE); > >>> + > >>> +#ifdef RTE_ETHDEV_DEBUG_RX > >>> +RTE_LOG_REGISTER_SUFFIX(nfp_logtype_rx, rx, DEBUG) #endif > >>> + > >>> +#ifdef RTE_ETHDEV_DEBUG_TX > >>> +RTE_LOG_REGISTER_SUFFIX(nfp_logtype_tx, tx, DEBUG) #endif > >>> diff --git a/drivers/net/nfp/nfp_logs.h b/drivers/net/nfp/nfp_logs.h > >>> index b7632ee72c..315a57811c 100644 > >>> --- a/drivers/net/nfp/nfp_logs.h > >>> +++ b/drivers/net/nfp/nfp_logs.h > >>> @@ -15,15 +15,19 @@ extern int nfp_logtype_init; #define > >>> PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>") > >>> > >>> #ifdef RTE_ETHDEV_DEBUG_RX > >>> +extern int nfp_logtype_rx; > >>> #define PMD_RX_LOG(level, fmt, args...) \ > >>> - RTE_LOG(level, PMD, "%s() rx: " fmt "\n", __func__, ## args) > >>> + rte_log(RTE_LOG_ ## level, nfp_logtype_rx, \ > >>> + "%s(): " fmt "\n", __func__, ## args) > >>> #else > >>> #define PMD_RX_LOG(level, fmt, args...) do { } while (0) #endif > >>> > >>> #ifdef RTE_ETHDEV_DEBUG_TX > >>> +extern int nfp_logtype_tx; > >>> #define PMD_TX_LOG(level, fmt, args...) \ > >>> - RTE_LOG(level, PMD, "%s() tx: " fmt "\n", __func__, ## args) > >>> + rte_log(RTE_LOG_ ## level, nfp_logtype_tx, \ > >>> + "%s(): " fmt "\n", __func__, ## args) > >>> #else > >>> #define PMD_TX_LOG(level, fmt, args...) do { } while (0) #endif =20 > >> > >> Intention is to replace 'RTE_LOG_DP' with 'PMD_RX_LOG'/'PMD_TX_LOG', > >> but these are not exactly same (although difference is minor). > >> > >> When 'RTE_ETHDEV_DEBUG_RX' is set, ethdev layer also adds some > >> additional load, although I believe that will small comparing to loggi= ng in > >> driver. > >> If 'RTE_LOG_DP' used, the ethdev layer cost can be removed. > >> > >> With 'RTE_LOG_DP', log level more verbose than requested won't cause a= ny > >> performance impact. Like if ERR level requested, INFO, DEBUG etc logs = will > >> be compiled out and won't cause any performance impact. > >> But with 'RTE_ETHDEV_DEBUG_RX', even log level only request ERR, all > >> logging will add cost of at least an if branch (checking log level). > >> > >> > >> For many cases I am not sure these differences matters, and already ma= ny > >> drivers directly uses 'RTE_ETHDEV_DEBUG_RX' as done here. So you may > >> prefer to keep as it is. > >> > >> But if there is a desire for this fine grain approach, it is possible = to add a > >> version of 'RTE_LOG_DP' macro that accepts dynamic log type (instead of > >> static RTE_LOGTYPE_# type), what do you think? > >> =20 > >=20 > > Thanks for the suggestion. > > For now, we prefer to keep as it is. > > If we does need the more refined design in the future, we would follow = your advice here, thanks again. =20 >=20 > ack, I just wanted to double check. I will proceed as it is. As part of my patch series (work in progress) to get rid of RTE_LOGTYPE_PMD needed to add a helper now for RTE_DP_LOG like this. diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h index 6d2b0856a565..f377bc6db79b 100644 --- a/lib/eal/include/rte_log.h +++ b/lib/eal/include/rte_log.h @@ -336,6 +336,37 @@ int rte_vlog(uint32_t level, uint32_t logtype, const c= har *format, va_list ap) rte_log(RTE_LOG_ ## l, \ RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) =20 +/** + * Generates a log message for data path. + * + * Similar to rte_log(), except that it is an inline function that + * can be eliminated at compilation time if RTE_LOG_DP_LEVEL configuration + * option is lower than the log level argument. + * + * @param level + * Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8). + * @param logtype + * The log type, for example, RTE_LOGTYPE_EAL. + * @param format + * The format string, as in printf(3), followed by the variable arguments + * required by the format. + * @return + * - 0: Success. + * - Negative on error. + */ +static inline __rte_format_printf(3, 4) +void rte_log_dp(uint32_t level, uint32_t logtype, const char *format, ...) + +{ + va_list ap; + + if (level <=3D RTE_LOG_DP_LEVEL) { + va_start(ap, format); + rte_vlog(level, logtype, format, ap); + va_end(ap); + } +} + /** * Generates a log message for data path. * @@ -357,10 +388,8 @@ int rte_vlog(uint32_t level, uint32_t logtype, const c= har *format, va_list ap) * - Negative on error. */ #define RTE_LOG_DP(l, t, ...) \ - (void)((RTE_LOG_ ## l <=3D RTE_LOG_DP_LEVEL) ? \ - rte_log(RTE_LOG_ ## l, \ - RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ - 0) + rte_log_dp(RTE_LOG_ ## l, \ + RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) =20 #define RTE_LOG_REGISTER_IMPL(type, name, level) \ int type; \ The NFP part is: diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/n= fp_flower.c index f1424a010dde..15401c0d5ba6 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -330,7 +330,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue, * DPDK just checks the queue is lower than max queues * enabled. But the queue needs to be configured */ - RTE_LOG_DP(ERR, PMD, "RX Bad queue\n"); + PMD_DP_LOG(ERR, "RX Bad queue"); return 0; } =20 @@ -343,7 +343,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue, while (avail + avail_multiplexed < nb_pkts) { rxb =3D &rxq->rxbufs[rxq->rd_p]; if (unlikely(rxb =3D=3D NULL)) { - RTE_LOG_DP(ERR, PMD, "rxb does not exist!\n"); + PMD_DP_LOG(ERR, "rxb does not exist!"); break; } =20 @@ -363,9 +363,9 @@ nfp_flower_pf_recv_pkts(void *rx_queue, */ new_mb =3D rte_pktmbuf_alloc(rxq->mem_pool); if (unlikely(new_mb =3D=3D NULL)) { - RTE_LOG_DP(DEBUG, PMD, - "RX mbuf alloc failed port_id=3D%u queue_id=3D%d\n", - rxq->port_id, rxq->qidx); + PMD_DP_LOG(DEBUG, + "RX mbuf alloc failed port_id=3D%u queue_id=3D%d\n", + rxq->port_id, rxq->qidx); nfp_net_mbuf_alloc_failed(rxq); break; } @@ -378,7 +378,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue, rxb->mbuf =3D new_mb; =20 PMD_RX_LOG(DEBUG, "Packet len: %u, mbuf_size: %u", - rxds->rxd.data_len, rxq->mbuf_size); + rxds->rxd.data_len, rxq->mbuf_size); =20 /* Size of this segment */ mb->data_len =3D rxds->rxd.data_len - NFP_DESC_META_LEN(rxds); @@ -391,15 +391,15 @@ nfp_flower_pf_recv_pkts(void *rx_queue, * responsibility of avoiding it. But we have * to give some info about the error */ - RTE_LOG_DP(ERR, PMD, - "mbuf overflow likely due to the RX offset.\n" - "\t\tYour mbuf size should have extra space for" - " RX offset=3D%u bytes.\n" - "\t\tCurrently you just have %u bytes available" - " but the received packet is %u bytes long", - hw->rx_offset, - rxq->mbuf_size - hw->rx_offset, - mb->data_len); + PMD_DP_LOG(ERR, + "mbuf overflow likely due to the RX offset.\n" + "\t\tYour mbuf size should have extra space for" + " RX offset=3D%u bytes.\n" + "\t\tCurrently you just have %u bytes available" + " but the received packet is %u bytes long", + hw->rx_offset, + rxq->mbuf_size - hw->rx_offset, + mb->data_len); rte_pktmbuf_free(mb); break; } @@ -420,14 +420,14 @@ nfp_flower_pf_recv_pkts(void *rx_queue, /* Checking the RSS flag */ nfp_flower_parse_metadata(rxq, rxds, mb, &meta_portid); PMD_RX_LOG(DEBUG, "Received from port %u type %u", - NFP_FLOWER_CMSG_PORT_VNIC(meta_portid), - NFP_FLOWER_CMSG_PORT_VNIC_TYPE(meta_portid)); + NFP_FLOWER_CMSG_PORT_VNIC(meta_portid), + NFP_FLOWER_CMSG_PORT_VNIC_TYPE(meta_portid)); =20 /* Checking the checksum flag */ nfp_net_rx_cksum(rxq, rxds, mb); =20 if ((rxds->rxd.flags & PCIE_DESC_RX_VLAN) && - (hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN)) { + (hw->ctrl & NFP_NET_CFG_CTRL_RXVLAN)) { mb->vlan_tci =3D rte_cpu_to_le_32(rxds->rxd.vlan); mb->ol_flags |=3D RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; } @@ -439,7 +439,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue, avail_multiplexed++; } else if (repr !=3D NULL) { PMD_RX_LOG(ERR, "[%u] No ring available for repr_port %s\n", - hw->idx, repr->name); + hw->idx, repr->name); PMD_RX_LOG(DEBUG, "Adding the mbuf to the mbuf array passed by the app"= ); rx_pkts[avail++] =3D mb; } else { @@ -465,7 +465,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue, return nb_hold; =20 PMD_RX_LOG(DEBUG, "RX port_id=3D%u queue_id=3D%d, %d packets received", - rxq->port_id, rxq->qidx, nb_hold); + rxq->port_id, rxq->qidx, nb_hold); =20 nb_hold +=3D rxq->nb_rx_hold; =20 @@ -476,7 +476,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue, rte_wmb(); if (nb_hold > rxq->rx_free_thresh) { PMD_RX_LOG(DEBUG, "port=3D%u queue=3D%d nb_hold=3D%u avail=3D%d", - rxq->port_id, rxq->qidx, nb_hold, avail); + rxq->port_id, rxq->qidx, nb_hold, avail); nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, nb_hold); nb_hold =3D 0; } diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flo= wer/nfp_flower_ctrl.c index 03a2e2e6222f..3de3bf1ca2e9 100644 --- a/drivers/net/nfp/flower/nfp_flower_ctrl.c +++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c @@ -91,15 +91,15 @@ nfp_flower_ctrl_vnic_recv(void *rx_queue, * responsibility of avoiding it. But we have * to give some info about the error */ - RTE_LOG_DP(ERR, PMD, - "mbuf overflow likely due to the RX offset.\n" - "\t\tYour mbuf size should have extra space for" - " RX offset=3D%u bytes.\n" - "\t\tCurrently you just have %u bytes available" - " but the received packet is %u bytes long", - hw->rx_offset, - rxq->mbuf_size - hw->rx_offset, - mb->data_len); + PMD_DP_LOG(ERR, + "mbuf overflow likely due to the RX offset.\n" + "\t\tYour mbuf size should have extra space for" + " RX offset=3D%u bytes.\n" + "\t\tCurrently you just have %u bytes available" + " but the received packet is %u bytes long", + hw->rx_offset, + rxq->mbuf_size - hw->rx_offset, + mb->data_len); rte_pktmbuf_free(mb); break; } diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bri= dge.c index 4aa36eb5814f..3c67a8fd419c 100644 --- a/drivers/net/nfp/nfp_cpp_bridge.c +++ b/drivers/net/nfp/nfp_cpp_bridge.c @@ -126,7 +126,7 @@ nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp *= cpp) size_t count, curlen; int err =3D 0; =20 - PMD_CPP_LOG(DEBUG, "%s: offset size %zu, count_size: %zu\n", __func__, + PMD_CPP_LOG(DEBUG, "offset size %zu, count_size: %zu", sizeof(off_t), sizeof(size_t)); =20 /* Reading the count param */ @@ -145,10 +145,9 @@ nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp = *cpp) cpp_id =3D (offset >> 40) << 8; nfp_offset =3D offset & ((1ull << 40) - 1); =20 - PMD_CPP_LOG(DEBUG, "%s: count %zu and offset %jd\n", __func__, count, - offset); - PMD_CPP_LOG(DEBUG, "%s: cpp_id %08x and nfp_offset %jd\n", __func__, - cpp_id, nfp_offset); + PMD_CPP_LOG(DEBUG, "count %zu and offset %jd", count, offset); + PMD_CPP_LOG(DEBUG, "cpp_id %08x and nfp_offset %jd", + cpp_id, nfp_offset); =20 /* Adjust length if not aligned */ if (((nfp_offset + (off_t)count - 1) & ~(NFP_CPP_MEMIO_BOUNDARY - 1)) !=3D @@ -162,14 +161,14 @@ nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp= *cpp) area =3D nfp_cpp_area_alloc_with_name(cpp, cpp_id, "nfp.cdev", nfp_offset, curlen); if (area =3D=3D NULL) { - RTE_LOG(ERR, PMD, "%s: area alloc fail\n", __func__); + PMD_DRV_LOG(ERR, "area alloc fail"); return -EIO; } =20 /* mapping the target */ err =3D nfp_cpp_area_acquire(area); if (err < 0) { - RTE_LOG(ERR, PMD, "area acquire failed\n"); + PMD_DRV_LOG(ERR, "area acquire failed"); nfp_cpp_area_free(area); return -EIO; } @@ -179,20 +178,18 @@ nfp_cpp_bridge_serve_write(int sockfd, struct nfp_cpp= *cpp) if (len > sizeof(tmpbuf)) len =3D sizeof(tmpbuf); =20 - PMD_CPP_LOG(DEBUG, "%s: Receive %u of %zu\n", __func__, - len, count); + PMD_CPP_LOG(DEBUG, "Receive %u of %zu", len, count); err =3D recv(sockfd, tmpbuf, len, MSG_WAITALL); if (err !=3D (int)len) { - RTE_LOG(ERR, PMD, - "%s: error when receiving, %d of %zu\n", - __func__, err, count); + PMD_DRV_LOG(ERR, "error when receiving, %d of %zu", + err, count); nfp_cpp_area_release(area); nfp_cpp_area_free(area); return -EIO; } err =3D nfp_cpp_area_write(area, pos, tmpbuf, len); if (err < 0) { - RTE_LOG(ERR, PMD, "nfp_cpp_area_write error\n"); + PMD_DRV_LOG(ERR, "nfp_cpp_area_write error"); nfp_cpp_area_release(area); nfp_cpp_area_free(area); return -EIO; @@ -227,7 +224,7 @@ nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *c= pp) size_t count, curlen; int err =3D 0; =20 - PMD_CPP_LOG(DEBUG, "%s: offset size %zu, count_size: %zu\n", __func__, + PMD_CPP_LOG(DEBUG, "offset size %zu, count_size: %zu", sizeof(off_t), sizeof(size_t)); =20 /* Reading the count param */ @@ -246,9 +243,8 @@ nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp *c= pp) cpp_id =3D (offset >> 40) << 8; nfp_offset =3D offset & ((1ull << 40) - 1); =20 - PMD_CPP_LOG(DEBUG, "%s: count %zu and offset %jd\n", __func__, count, - offset); - PMD_CPP_LOG(DEBUG, "%s: cpp_id %08x and nfp_offset %jd\n", __func__, + PMD_CPP_LOG(DEBUG, "count %zu and offset %jd", count, offset); + PMD_CPP_LOG(DEBUG, "cpp_id %08x and nfp_offset %jd", cpp_id, nfp_offset); =20 /* Adjust length if not aligned */ @@ -262,13 +258,13 @@ nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp = *cpp) area =3D nfp_cpp_area_alloc_with_name(cpp, cpp_id, "nfp.cdev", nfp_offset, curlen); if (area =3D=3D NULL) { - RTE_LOG(ERR, PMD, "%s: area alloc failed\n", __func__); + PMD_DRV_LOG(ERR, "area alloc failed"); return -EIO; } =20 err =3D nfp_cpp_area_acquire(area); if (err < 0) { - RTE_LOG(ERR, PMD, "area acquire failed\n"); + PMD_DRV_LOG(ERR, "area acquire failed"); nfp_cpp_area_free(area); return -EIO; } @@ -280,19 +276,19 @@ nfp_cpp_bridge_serve_read(int sockfd, struct nfp_cpp = *cpp) =20 err =3D nfp_cpp_area_read(area, pos, tmpbuf, len); if (err < 0) { - RTE_LOG(ERR, PMD, "nfp_cpp_area_read error\n"); + PMD_DRV_LOG(ERR, "nfp_cpp_area_read error"); nfp_cpp_area_release(area); nfp_cpp_area_free(area); return -EIO; } - PMD_CPP_LOG(DEBUG, "%s: sending %u of %zu\n", __func__, + PMD_CPP_LOG(DEBUG, "sending %u of %zu", len, count); =20 err =3D send(sockfd, tmpbuf, len, 0); if (err !=3D (int)len) { - RTE_LOG(ERR, PMD, - "%s: error when sending: %d of %zu\n", - __func__, err, count); + PMD_DRV_LOG(ERR, + "error when sending: %d of %zu", + err, count); nfp_cpp_area_release(area); nfp_cpp_area_free(area); return -EIO; @@ -325,39 +321,39 @@ nfp_cpp_bridge_serve_ioctl(int sockfd, struct nfp_cpp= *cpp) /* Reading now the IOCTL command */ err =3D recv(sockfd, &cmd, 4, 0); if (err !=3D 4) { - RTE_LOG(ERR, PMD, "%s: read error from socket\n", __func__); + PMD_DRV_LOG(ERR, "read error from socket"); return -EIO; } =20 /* Only supporting NFP_IOCTL_CPP_IDENTIFICATION */ if (cmd !=3D NFP_IOCTL_CPP_IDENTIFICATION) { - RTE_LOG(ERR, PMD, "%s: unknown cmd %d\n", __func__, cmd); + PMD_DRV_LOG(ERR, "unknown cmd %d", cmd); return -EINVAL; } =20 err =3D recv(sockfd, &ident_size, 4, 0); if (err !=3D 4) { - RTE_LOG(ERR, PMD, "%s: read error from socket\n", __func__); + PMD_DRV_LOG(ERR, "read error from socket"); return -EIO; } =20 tmp =3D nfp_cpp_model(cpp); =20 - PMD_CPP_LOG(DEBUG, "%s: sending NFP model %08x\n", __func__, tmp); + PMD_CPP_LOG(DEBUG, "sending NFP model %08x", tmp); =20 err =3D send(sockfd, &tmp, 4, 0); if (err !=3D 4) { - RTE_LOG(ERR, PMD, "%s: error writing to socket\n", __func__); + PMD_DRV_LOG(ERR, "error writing to socket"); return -EIO; } =20 tmp =3D cpp->interface; =20 - PMD_CPP_LOG(DEBUG, "%s: sending NFP interface %08x\n", __func__, tmp); + PMD_CPP_LOG(DEBUG, "sending NFP interface %08x", tmp); =20 err =3D send(sockfd, &tmp, 4, 0); if (err !=3D 4) { - RTE_LOG(ERR, PMD, "%s: error writing to socket\n", __func__); + PMD_DRV_LOG(ERR, "error writing to socket"); return -EIO; } =20 @@ -384,8 +380,7 @@ nfp_cpp_bridge_service_func(void *args) unlink("/tmp/nfp_cpp"); sockfd =3D socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) { - RTE_LOG(ERR, PMD, "%s: socket creation error. Service failed\n", - __func__); + PMD_DRV_LOG(ERR, "socket creation error. Service failed"); return -EIO; } =20 @@ -399,16 +394,14 @@ nfp_cpp_bridge_service_func(void *args) ret =3D bind(sockfd, (const struct sockaddr *)&address, sizeof(struct sockaddr)); if (ret < 0) { - RTE_LOG(ERR, PMD, "%s: bind error (%d). Service failed\n", - __func__, errno); + PMD_DRV_LOG(ERR, "bind error (%d). Service failed", errno); close(sockfd); return ret; } =20 ret =3D listen(sockfd, 20); if (ret < 0) { - RTE_LOG(ERR, PMD, "%s: listen error(%d). Service failed\n", - __func__, errno); + PMD_DRV_LOG(ERR, "listen error(%d). Service failed", errno); close(sockfd); return ret; } @@ -421,9 +414,7 @@ nfp_cpp_bridge_service_func(void *args) if (errno =3D=3D EAGAIN || errno =3D=3D EWOULDBLOCK) continue; =20 - RTE_LOG(ERR, PMD, "%s: accept call error (%d)\n", - __func__, errno); - RTE_LOG(ERR, PMD, "%s: service failed\n", __func__); + PMD_DRV_LOG(ERR, "accept call error (%d)", errno); close(sockfd); return -EIO; } @@ -431,12 +422,11 @@ nfp_cpp_bridge_service_func(void *args) while (1) { ret =3D recv(datafd, &op, 4, 0); if (ret <=3D 0) { - PMD_CPP_LOG(DEBUG, "%s: socket close\n", - __func__); + PMD_CPP_LOG(DEBUG, "socket close"); break; } =20 - PMD_CPP_LOG(DEBUG, "%s: getting op %u\n", __func__, op); + PMD_CPP_LOG(DEBUG, "getting op %u", op); =20 if (op =3D=3D NFP_BRIDGE_OP_READ) nfp_cpp_bridge_serve_read(datafd, cpp); diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c index 290e2fcb41a6..3ea07aa923dd 100644 --- a/drivers/net/nfp/nfp_ethdev.c +++ b/drivers/net/nfp/nfp_ethdev.c @@ -521,9 +521,9 @@ nfp_net_init(struct rte_eth_dev *eth_dev) =20 /* NFP can not handle DMA addresses requiring more than 40 bits */ if (rte_mem_check_dma_mask(40)) { - RTE_LOG(ERR, PMD, - "device %s can not be used: restricted dma mask to 40 bits!\n", - pci_dev->device.name); + PMD_DRV_LOG(ERR, + "device %s can not be used: restricted dma mask to 40 bits!", + pci_dev->device.name); return -ENODEV; } =20 diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_v= f.c index 07a2e17ef8e7..6272b4c29466 100644 --- a/drivers/net/nfp/nfp_ethdev_vf.c +++ b/drivers/net/nfp/nfp_ethdev_vf.c @@ -293,9 +293,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev) =20 /* NFP can not handle DMA addresses requiring more than 40 bits */ if (rte_mem_check_dma_mask(40)) { - RTE_LOG(ERR, PMD, - "device %s can not be used: restricted dma mask to 40 bits!\n", - pci_dev->device.name); + PMD_DRV_LOG(ERR, + "device %s can not be used: restricted dma mask to 40 bits!\n", + pci_dev->device.name); return -ENODEV; } =20 diff --git a/drivers/net/nfp/nfp_logs.h b/drivers/net/nfp/nfp_logs.h index b7632ee72ca1..58dd1da12143 100644 --- a/drivers/net/nfp/nfp_logs.h +++ b/drivers/net/nfp/nfp_logs.h @@ -14,16 +14,23 @@ extern int nfp_logtype_init; "%s(): " fmt "\n", __func__, ## args) #define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>") =20 +extern int nfp_logtype_driver; +#define PMD_DRV_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, nfp_logtype_driver, \ + "%s(): " fmt "\n", __func__, ## args) + +#define PMD_DP_LOG(level, fmt, args...) \ + rte_log_dp(RTE_LOG_ ## level, nfp_logtype_driver, \ + "%s(): " fmt "\n", __func__, ## args) + #ifdef RTE_ETHDEV_DEBUG_RX -#define PMD_RX_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s() rx: " fmt "\n", __func__, ## args) +#define PMD_RX_LOG(level, fmt, args...) PMD_DP_LOG(level, "rx: " fmt, ## a= rgs) #else #define PMD_RX_LOG(level, fmt, args...) do { } while (0) #endif =20 #ifdef RTE_ETHDEV_DEBUG_TX -#define PMD_TX_LOG(level, fmt, args...) \ - RTE_LOG(level, PMD, "%s() tx: " fmt "\n", __func__, ## args) +#define PMD_TX_LOG(level, fmt, args...) PMD_DP_LOG(level, "tx: " fmt, ## a= rgs) #else #define PMD_TX_LOG(level, fmt, args...) do { } while (0) #endif @@ -33,9 +40,4 @@ extern int nfp_logtype_cpp; rte_log(RTE_LOG_ ## level, nfp_logtype_cpp, \ "%s(): " fmt "\n", __func__, ## args) =20 -extern int nfp_logtype_driver; -#define PMD_DRV_LOG(level, fmt, args...) \ - rte_log(RTE_LOG_ ## level, nfp_logtype_driver, \ - "%s(): " fmt "\n", __func__, ## args) - #endif /* _NFP_LOGS_H_ */ diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index cfc1a784b185..e5a3dc57ac38 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -353,7 +353,7 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_= pkts, uint16_t nb_pkts) * DPDK just checks the queue is lower than max queues * enabled. But the queue needs to be configured */ - RTE_LOG_DP(ERR, PMD, "RX Bad queue\n"); + PMD_DP_LOG(ERR, "RX Bad queue"); return avail; } =20 @@ -363,7 +363,7 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_= pkts, uint16_t nb_pkts) while (avail < nb_pkts) { rxb =3D &rxq->rxbufs[rxq->rd_p]; if (unlikely(rxb =3D=3D NULL)) { - RTE_LOG_DP(ERR, PMD, "rxb does not exist!\n"); + PMD_DP_LOG(ERR, "rxb does not exist!"); break; } =20 @@ -383,9 +383,9 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_= pkts, uint16_t nb_pkts) */ new_mb =3D rte_pktmbuf_alloc(rxq->mem_pool); if (unlikely(new_mb =3D=3D NULL)) { - RTE_LOG_DP(DEBUG, PMD, - "RX mbuf alloc failed port_id=3D%u queue_id=3D%u\n", - rxq->port_id, (unsigned int)rxq->qidx); + PMD_DP_LOG(DEBUG, + "RX mbuf alloc failed port_id=3D%u queue_id=3D%u\n", + rxq->port_id, (unsigned int)rxq->qidx); nfp_net_mbuf_alloc_failed(rxq); break; } @@ -412,15 +412,15 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **r= x_pkts, uint16_t nb_pkts) * responsibility of avoiding it. But we have * to give some info about the error */ - RTE_LOG_DP(ERR, PMD, - "mbuf overflow likely due to the RX offset.\n" - "\t\tYour mbuf size should have extra space for" - " RX offset=3D%u bytes.\n" - "\t\tCurrently you just have %u bytes available" - " but the received packet is %u bytes long", - hw->rx_offset, - rxq->mbuf_size - hw->rx_offset, - mb->data_len); + PMD_DP_LOG(ERR, + "mbuf overflow likely due to the RX offset.\n" + "\t\tYour mbuf size should have extra space for" + " RX offset=3D%u bytes.\n" + "\t\tCurrently you just have %u bytes available" + " but the received packet is %u bytes long", + hw->rx_offset, + rxq->mbuf_size - hw->rx_offset, + mb->data_len); rte_pktmbuf_free(mb); break; }