From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id 1E1958E7A for ; Wed, 25 Apr 2018 17:57:02 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id f15so15602083pfn.0 for ; Wed, 25 Apr 2018 08:57:02 -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=RsczD2/4ClQ1OXq5a+cIhOyKKuJtIf5U3MA/E7eqwKI=; b=xe+E50bXywtfUX7V5RXkNnjTUgeaZSuYjeevzfUuyS6L7qcg/WqjIEo5ulZ4aTCuMo 71lCVi0a2R90ExWnHAnH3A+8sBtnfi9qEnlARp8Ri1vvcsPPzFkKtxruITQkassUorvq YqqIGtHgoiZanONeTiLaxp4dkKGg/5QX9ghAk5PCXFESgKIHnVXdW6X5dxQdnB3qHH/5 JbGCdN6WlwC02D9JLvKXMssIebGyO8wVDzxa/3Tbye4FzpF5vFnzgnkg1qESYuoK4AXn K2YxxU+/aqO9j1QHxwvpOLFgQMk6byLST5dX5/7KkGgiCGJmB/7qG8tQGkxrO82cj60C KKew== 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=RsczD2/4ClQ1OXq5a+cIhOyKKuJtIf5U3MA/E7eqwKI=; b=YqcErwqVF2QrSkhAcEr9A6TM/xeI4AZKCPyyYRPkWrYq2m+SvO1Auc4yJbhLKmenKm H11H0a7R6kzz+0AyGr0GilmqFX2yMvWk4XPZYK+yNSz0+vOCnTJCL6J6/4W4S0Zvt+Y7 lGXGlPaLxlj6fqs/MQlFLckBaEaRVkEM5NzN50w6hMoGsSj9ObKuLU+O0DBIkxHj5tJg 4aWN0wSdVU6XotVK2qYs1wSamAEoVv/uceBpMpkdpiNZVLnMAuyvvZcirAqTLCyVg57i 7cbZ6Vb5wRdD2pMfjssZbX3kmSRQy+owEloZuBE7y8OTVk5Uf2JwO5JmCRn5vCL5gOlU DcTw== X-Gm-Message-State: ALQs6tDU5ai2cmmHqdtiPRiDSnnTWworb/PdKlanoVP+8zm/ZlMSW+YS 6NXpOxMMXN1NUDpTlxbiTRH1o34jAUc= X-Google-Smtp-Source: AIpwx49nsrwvERNyqVR7R19N5r4bfg4C9p10elH2ozTS0eLS5GE8FdRAfCUW6MTvs8C0UdlnOu93JA== X-Received: by 10.99.115.78 with SMTP id d14mr12386359pgn.1.1524671820869; Wed, 25 Apr 2018 08:57:00 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 08:56:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 25 Apr 2018 08:56:44 -0700 Message-Id: <20180425155646.3627-9-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 08/10] net/pcap: 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:02 -0000 Signed-off-by: Stephen Hemminger --- drivers/net/pcap/rte_eth_pcap.c | 41 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 570c9e984d32..4ef28a4995d2 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -99,6 +99,12 @@ static struct rte_eth_link pmd_link = { .link_autoneg = ETH_LINK_AUTONEG, }; +static int eth_pcap_logtype; + +#define PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, eth_pcap_logtype, \ + "%s(): " fmt "\n", __func__, ##args) + static int eth_pcap_rx_jumbo(struct rte_mempool *mb_pool, struct rte_mbuf *mbuf, const u_char *data, uint16_t data_len) @@ -256,8 +262,8 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) pcap_dump((u_char *)dumper_q->dumper, &header, tx_pcap_data); } else { - RTE_LOG(ERR, PMD, - "Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n", + PMD_LOG(ERR, + "Dropping PCAP packet. Size (%d) > max jumbo size (%d).", mbuf->pkt_len, ETHER_MAX_JUMBO_FRAME_LEN); @@ -313,8 +319,8 @@ eth_pcap_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) ret = pcap_sendpacket(tx_queue->pcap, tx_pcap_data, mbuf->pkt_len); } else { - RTE_LOG(ERR, PMD, - "Dropping PCAP packet. Size (%d) > max jumbo size (%d).\n", + PMD_LOG(ERR, + "Dropping PCAP packet. Size (%d) > max jumbo size (%d).", mbuf->pkt_len, ETHER_MAX_JUMBO_FRAME_LEN); @@ -346,7 +352,7 @@ open_iface_live(const char *iface, pcap_t **pcap) { RTE_ETH_PCAP_PROMISC, RTE_ETH_PCAP_TIMEOUT, errbuf); if (*pcap == NULL) { - RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", iface, errbuf); + PMD_LOG(ERR, "Couldn't open %s: %s", iface, errbuf); return -1; } @@ -357,7 +363,7 @@ static int open_single_iface(const char *iface, pcap_t **pcap) { if (open_iface_live(iface, pcap) < 0) { - RTE_LOG(ERR, PMD, "Couldn't open interface %s\n", iface); + PMD_LOG(ERR, "Couldn't open interface %s", iface); return -1; } @@ -376,7 +382,7 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper) */ tx_pcap = pcap_open_dead(DLT_EN10MB, RTE_ETH_PCAP_SNAPSHOT_LEN); if (tx_pcap == NULL) { - RTE_LOG(ERR, PMD, "Couldn't create dead pcap\n"); + PMD_LOG(ERR, "Couldn't create dead pcap"); return -1; } @@ -384,7 +390,7 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper) *dumper = pcap_dump_open(tx_pcap, pcap_filename); if (*dumper == NULL) { pcap_close(tx_pcap); - RTE_LOG(ERR, PMD, "Couldn't open %s for writing.\n", + PMD_LOG(ERR, "Couldn't open %s for writing.", pcap_filename); return -1; } @@ -398,7 +404,7 @@ open_single_rx_pcap(const char *pcap_filename, pcap_t **pcap) { *pcap = pcap_open_offline(pcap_filename, errbuf); if (*pcap == NULL) { - RTE_LOG(ERR, PMD, "Couldn't open %s: %s\n", pcap_filename, + PMD_LOG(ERR, "Couldn't open %s: %s", pcap_filename, errbuf); return -1; } @@ -776,7 +782,7 @@ pmd_init_internals(struct rte_vdev_device *vdev, struct rte_eth_dev_data *data; unsigned int numa_node = vdev->device.numa_node; - RTE_LOG(INFO, PMD, "Creating pcap-backed ethdev on numa socket %d\n", + PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d", numa_node); /* reserve an ethdev entry */ @@ -903,7 +909,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) int ret; name = rte_vdev_device_name(dev); - RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name); + PMD_LOG(INFO, "Initializing pmd_pcap for %s", name); gettimeofday(&start_time, NULL); start_cycles = rte_get_timer_cycles(); @@ -913,7 +919,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) strlen(rte_vdev_device_args(dev)) == 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 */ @@ -1009,7 +1015,7 @@ pmd_pcap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; - RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %d\n", + PMD_LOG(INFO, "Closing pcap ethdev on numa socket %d", rte_socket_id()); if (!dev) @@ -1040,3 +1046,12 @@ RTE_PMD_REGISTER_PARAM_STRING(net_pcap, ETH_PCAP_RX_IFACE_ARG "= " ETH_PCAP_TX_IFACE_ARG "= " ETH_PCAP_IFACE_ARG "="); + +RTE_INIT(eth_pcap_init_log); +static void +eth_pcap_init_log(void) +{ + eth_pcap_logtype = rte_log_register("pmd.net.pcap"); + if (eth_pcap_logtype >= 0) + rte_log_set_level(eth_pcap_logtype, RTE_LOG_NOTICE); +} -- 2.17.0