From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id 581D52BAE for ; Tue, 18 Apr 2017 14:17:59 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id w64so54803244wma.0 for ; Tue, 18 Apr 2017 05:17:59 -0700 (PDT) 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:in-reply-to :references; bh=/VDH4qGvbgBnxwq//WuoapJfNi/34hkuYmoNvh0aPUg=; b=kwTHz6lSqzFzLRwi5ohLXhV1RD1gzn5o/7Lkl8u0Hqm6kiEyvdU60eIRLEimjrXCW6 B8ScQnSre1HjLtrxLpjnm3XCvTDMqKeqx5k3EWXQQFyZSAXMCZRvNoUy/r43++T9/Zw8 Yp04M+d9C2yr2OuXUR7DGP0389CCcHSPIpoeBS6aeRQyNCaPh8c2WYheGUi1gWC9Ys0Y +FtNIS+TCqedY9yaXOl0IqwTWP1oP2saBkPOfegQgxeWflBoO+J664Ec3NL2Xl91iMon 24rSCG8Y3xYEu/rqAYK5oF622FCeffTEkHiRgbsAkfDb6MNgCdJgnCVQXf48Diu7flRz G1QA== 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:in-reply-to:references; bh=/VDH4qGvbgBnxwq//WuoapJfNi/34hkuYmoNvh0aPUg=; b=STlEO4EFHoe74AnYsgshLZOpSWxnHgT94GUfaJ6Cc3gG/QXpoo9kp9GsgVzisgtP9K EtWOUqh+7wiAcPmtggckRJsgutpkC6lqfNn7HDYkRQzTFOTNhLAfmyHrq7rIresdlYni QVOzXIFZc2banP0KUnMGZISsbZ6v1XV8xK2Mtocj3BowMCsspwTLqjgrtoZfUCwnEvTf K9fiZ8mAnR06vbIRTWfnfhpjSF+c5F+tmNhuIiLpCbieRjMXXgIrNTlqvrsN4Ul1UsiK If917UFR0/sr2pTi0TSQycdlWnPhhDzqGDHVGRiE6X4mA5qAxyMmePoBGj5G0+fXW3Qq vORA== X-Gm-Message-State: AN3rC/6X96zx+qonFawSPMyGjVpXc8YpFJfVjlSbFSXBkxz1Dexv3BoJ 9+yt3ghoL2rko7ZOlDs= X-Received: by 10.28.62.212 with SMTP id l203mr13881309wma.110.1492517878632; Tue, 18 Apr 2017 05:17:58 -0700 (PDT) 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 u23sm4266024wmu.16.2017.04.18.05.17.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Apr 2017 05:17:57 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Date: Tue, 18 Apr 2017 14:17:40 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 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: Tue, 18 Apr 2017 12:17:59 -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 d6bd2b2..221f0e9 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -351,6 +351,9 @@ struct rte_stats_bitrates *bitrate_data; /* 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. @@ -1347,6 +1350,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; @@ -1458,6 +1462,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); @@ -1730,6 +1749,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