From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by dpdk.org (Postfix) with ESMTP id C0A6D8E63 for ; Wed, 25 Apr 2018 17:56:59 +0200 (CEST) Received: by mail-pg0-f68.google.com with SMTP id e12so13635059pgn.9 for ; Wed, 25 Apr 2018 08:56:59 -0700 (PDT) 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; bh=qDmwztWVnwRPayPUB4x9b/Mw0WMcx/7Q6y9dqOZkDDQ=; b=CyhsGIwgFQns2/vQL4rZ2Prd9Tca1potO7khlnvagmFKpoKHktrQ+RRKCUaJtCGsIi BPG4XfWl9hlFptLoRf4ho0BFKibRo7icNRKpmlNwwjMQFHaUwTI5Ar7+gRZJd5rBvKkV 8VjEmtgAVj3U8DybnGCvX4kZVQbOUeLUrELpF++uMV1pbV9A1MKetOB7EhbvG7BkL0dL /4y5ePvCzOkWQ2WBHXT5bROIqihqD1FJPdq8MQ0ga6sF70k/QwR1Su4iJxz5EfY9A5ia qOC2MYLYIt3MH8mp7YWMvsUcpfJPpMM9HwfUqqNp3y4dIdcMIlpP/EV4ZW6NI1+dkMpa v58g== 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; bh=qDmwztWVnwRPayPUB4x9b/Mw0WMcx/7Q6y9dqOZkDDQ=; b=r0UYB6svNuQp+yxyq0Acsu7YX3lmSyDAdqIqr0epIZ2qkit9S5eLtxAGZgH7EYQMEJ /cNrZeB2/IRv4IMtdwxFizFOWcTi0kY5FogZKHRo5QZFyVEGRohQ0iM2XkUrp/Xbwqde 6K4g7kMLU3N6zOWQBmPDGLqm6mI2lnHKOuOpI34cSKagJtbtsToZsA7DQfSO/9CoCU8V X5NyDI+9exidSrF2KS1JjsyXagMA3+U0dlwpk3AWfyhX6wTR12eqDerPFp3P7PIyElKw l6DHhWDDA/XFtfuWvVDjqLmDqfodr437MRjYdqns044kwFuCDhJmdiJaH5kPPkT5NY8b B+4g== X-Gm-Message-State: ALQs6tDkTbnu8KNLo0kNIDM155g4+Dc1v1uJde/z9gVejRIPOVGsGg1e kcTwnzsjOzR29tj69hzaa/kXPV9FhuQ= X-Google-Smtp-Source: AIpwx4+wTHQrJB9dxkHyDmES82xfMPkrSfq2E8giWDcp9xdLzihBSakz/1HVU4BjtHRBhP+zRac2NA== X-Received: by 10.98.166.92 with SMTP id t89mr28201077pfe.27.1524671818685; Wed, 25 Apr 2018 08:56:58 -0700 (PDT) Received: from xeon-e3.lan (204-195-71-95.wavecable.com. [204.195.71.95]) by smtp.gmail.com with ESMTPSA id y3sm25713924pgc.81.2018.04.25.08.56.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 08:56:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 25 Apr 2018 08:56:43 -0700 Message-Id: <20180425155646.3627-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425155646.3627-1-stephen@networkplumber.org> References: <20180425155646.3627-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH next 07/10] net/kni: support dynamic logging 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: , X-List-Received-Date: Wed, 25 Apr 2018 15:57:00 -0000 Signed-off-by: Stephen Hemminger --- drivers/net/kni/rte_eth_kni.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 35a6d3ef7280..bbb2f00c80d7 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -65,6 +65,11 @@ static const struct rte_eth_link pmd_link = { }; static int is_kni_initialized; +static int eth_kni_logtype; + +#define PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, eth_kni_logtype, \ + "%s(): " fmt "\n", __func__, ##args) static uint16_t eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { @@ -126,8 +131,8 @@ eth_kni_start(struct rte_eth_dev *dev) internals->kni = rte_kni_alloc(mb_pool, &conf, NULL); if (internals->kni == NULL) { - RTE_LOG(ERR, PMD, - "Fail to create kni interface for port: %d\n", + PMD_LOG(ERR, + "Fail to create kni interface for port: %d", port_id); return -1; } @@ -153,8 +158,8 @@ eth_kni_dev_start(struct rte_eth_dev *dev) "kni_handle_req", NULL, kni_handle_request, internals); if (ret) { - RTE_LOG(ERR, PMD, - "Fail to create kni request thread\n"); + PMD_LOG(ERR, + "Fail to create kni request thread"); return -1; } } @@ -175,11 +180,11 @@ eth_kni_dev_stop(struct rte_eth_dev *dev) ret = pthread_cancel(internals->thread); if (ret) - RTE_LOG(ERR, PMD, "Can't cancel the thread\n"); + PMD_LOG(ERR, "Can't cancel the thread"); ret = pthread_join(internals->thread, NULL); if (ret) - RTE_LOG(ERR, PMD, "Can't join the thread\n"); + PMD_LOG(ERR, "Can't join the thread"); internals->stop_thread = 0; } @@ -338,7 +343,7 @@ eth_kni_create(struct rte_vdev_device *vdev, struct rte_eth_dev_data *data; struct rte_eth_dev *eth_dev; - RTE_LOG(INFO, PMD, "Creating kni ethdev on numa socket %u\n", + PMD_LOG(INFO, "Creating kni ethdev on numa socket %u", numa_node); /* reserve an ethdev entry */ @@ -403,13 +408,13 @@ eth_kni_probe(struct rte_vdev_device *vdev) name = rte_vdev_device_name(vdev); params = rte_vdev_device_args(vdev); - RTE_LOG(INFO, PMD, "Initializing eth_kni for %s\n", name); + PMD_LOG(INFO, "Initializing eth_kni for %s", name); if (rte_eal_process_type() == RTE_PROC_SECONDARY && strlen(params) == 0) { eth_dev = rte_eth_dev_attach_secondary(name); if (!eth_dev) { - RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + PMD_LOG(ERR, "Failed to probe %s", name); return -1; } /* TODO: request info from primary to set up Rx and Tx */ @@ -449,7 +454,7 @@ eth_kni_remove(struct rte_vdev_device *vdev) const char *name; name = rte_vdev_device_name(vdev); - RTE_LOG(INFO, PMD, "Un-Initializing eth_kni for %s\n", name); + PMD_LOG(INFO, "Un-Initializing eth_kni for %s", name); /* find the ethdev entry */ eth_dev = rte_eth_dev_allocated(name); @@ -479,3 +484,12 @@ static struct rte_vdev_driver eth_kni_drv = { RTE_PMD_REGISTER_VDEV(net_kni, eth_kni_drv); RTE_PMD_REGISTER_PARAM_STRING(net_kni, ETH_KNI_NO_REQUEST_THREAD_ARG "="); + +RTE_INIT(eth_kni_init_log); +static void +eth_kni_init_log(void) +{ + eth_kni_logtype = rte_log_register("pmd.net.kni"); + if (eth_kni_logtype >= 0) + rte_log_set_level(eth_kni_logtype, RTE_LOG_NOTICE); +} -- 2.17.0