From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 5DB16F94A for ; Fri, 3 Mar 2017 16:40:37 +0100 (CET) Received: by mail-wr0-f180.google.com with SMTP id g10so76174671wrg.2 for ; Fri, 03 Mar 2017 07:40:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=/ul2BASX/wg6Rxc8Icm1pBVxoNg+4U4G0BijtBPccKM=; b=ZbdgMfSKoe0b7E/QvKmnV3WgH2x2xDwhoEH5NVGruuANi2ms2l3k2pH3bPvfioXfrk fRzicpBdHKuFu9wUmPELPU/vX4yqrUx++jgaNE3nkbBD8MrAC8hA9JAubeYvfNHR7US9 tWWdJZou0lDWhlugZHOZLQGbwRjrIk7Lek1bGklCbX6zisXek0FfoZXF5RlYPihBdJXH tHQ6cIvvTaEuUVozQAKIRFaKcF66D+JYv7gmV7ciPkxl7gQHLEiVK1lz6W/LRqx+Fj6o gbVZRbi/kyJLBA82M8xoMqTWiyuQRDvTzmDE2DJPl/pum+AOmyJWj669mjKRvZtbG1S3 jY0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=/ul2BASX/wg6Rxc8Icm1pBVxoNg+4U4G0BijtBPccKM=; b=RO/c46hOH2euWqWuT0yZB9faUhLD9vX9osnQqm60lQb3Cl3FvYgHuZWEphcwPlPjPQ Tzjl6nmiA2ooDNO23b4wE31/XuCHmqUgfYvBMWst3FT1Y2YGy5tK578z0kFYUtrC6NVu 57q5IM1S4qN7xkh0EhTbGJk+ge7cDz5Oy0VsuZ7lY1UlaMFMCe7Md6AtWskGfreZne67 xf9/oamUOwqjgWMVA0MIgA7pIXzSglSo1YHt9u+IjRkF2Bnh5wqxjIwSEWPhLDgeG40Y aapccdASzMgWNMjbR4IxbFKnUnx6xwYx+462QOWwXp/LPTfbLx4DEagLU0f/TAkWt8sv NBKg== X-Gm-Message-State: AMke39lh3YLU2HSoNXxmkTtE9lzjTBMZLLR15jDPlMlahN5nGLbmhtncnceMwhSssU7wHALo X-Received: by 10.223.166.7 with SMTP id k7mr3019223wrc.52.1488555636936; Fri, 03 Mar 2017 07:40:36 -0800 (PST) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id i15sm3486899wmf.21.2017.03.03.07.40.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 07:40:36 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Date: Fri, 3 Mar 2017 16:40:21 +0100 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH 3/5] app/testpmd: generic event handler 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: Fri, 03 Mar 2017 15:40:37 -0000 This is a rather simple handler that prints a message with the name of the current event. It can be used to check PMD callback registration and triggers. Signed-off-by: Gaetan Rivet --- app/test-pmd/testpmd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index b8ec1fe..f2b67d5 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -326,6 +326,9 @@ unsigned max_socket = 0; /* Forward function declarations */ static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port); static void check_all_ports_link_status(uint32_t port_mask); +static void eth_event_callback(uint8_t port_id, + enum rte_eth_event_type type, + void *param); /* * Check if all the ports are started. @@ -1299,6 +1302,7 @@ start_port(portid_t pid) queueid_t qi; struct rte_port *port; struct ether_addr mac_addr; + enum rte_eth_event_type event_type; if (port_id_is_invalid(pid, ENABLED_WARN)) return 0; @@ -1410,6 +1414,21 @@ start_port(portid_t pid) return -1; } } + + for (event_type = RTE_ETH_EVENT_UNKNOWN; + event_type < RTE_ETH_EVENT_MAX; + event_type++) { + diag = rte_eth_dev_callback_register(pi, + event_type, + eth_event_callback, + NULL); + if (diag) { + printf("Failed to setup even callback for event %d\n", + event_type); + return -1; + } + } + /* start port */ if (rte_eth_dev_start(pi) < 0) { printf("Fail to start port %d\n", pi); @@ -1682,6 +1701,34 @@ check_all_ports_link_status(uint32_t port_mask) } } +/* This function is used by the interrupt thread */ +static void +eth_event_callback(uint8_t port_id, enum rte_eth_event_type type, void *param) +{ + static const char * const event_desc[] = { + [RTE_ETH_EVENT_UNKNOWN] = "Unknown", + [RTE_ETH_EVENT_INTR_LSC] = "LSC", + [RTE_ETH_EVENT_QUEUE_STATE] = "Queue state", + [RTE_ETH_EVENT_INTR_RESET] = "Interrupt reset", + [RTE_ETH_EVENT_VF_MBOX] = "VF Mbox", + [RTE_ETH_EVENT_MACSEC] = "MACsec", + [RTE_ETH_EVENT_INTR_RMV] = "device removal", + [RTE_ETH_EVENT_MAX] = NULL, + }; + + RTE_SET_USED(param); + + if (type >= RTE_ETH_EVENT_MAX) { + fprintf(stderr, "\nPort %" PRIu8 ": %s called upon invalid event %d\n", + port_id, __func__, type); + fflush(stderr); + } else { + printf("\nPort %" PRIu8 ": %s event\n", port_id, + event_desc[type]); + fflush(stdout); + } +} + static int set_tx_queue_stats_mapping_registers(uint8_t port_id, struct rte_port *port) { -- 2.1.4