DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 3/5] app/testpmd: generic event handler
Date: Tue, 18 Apr 2017 14:17:40 +0200	[thread overview]
Message-ID: <fd7a257cbfd4ab464d99e99848cd6814e03b972d.1492517222.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1492517222.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1492517222.git.gaetan.rivet@6wind.com>

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 <gaetan.rivet@6wind.com>
---
 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

  parent reply	other threads:[~2017-04-18 12:17 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 15:40 [dpdk-dev] [PATCH 0/5] add device removal event Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 1/5] ethdev: introduce " Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 2/5] net/mlx4: device removal event support Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 3/5] app/testpmd: generic event handler Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 4/5] app/testpmd: request link status interrupt Gaetan Rivet
2017-03-03 15:40 ` [dpdk-dev] [PATCH 5/5] app/testpmd: request device removal interrupt Gaetan Rivet
2017-03-23 10:24 ` [dpdk-dev] [PATCH 0/5] add device removal event Gaetan Rivet
2017-04-18 12:17 ` [dpdk-dev] [PATCH v2 " Gaetan Rivet
2017-04-18 12:17   ` [dpdk-dev] [PATCH v2 1/5] ethdev: introduce " Gaetan Rivet
2017-04-21 14:59     ` Ferruh Yigit
2017-04-25  9:05       ` Gaëtan Rivet
2017-05-02  7:35         ` Jan Blunck
2017-05-02  9:18           ` Thomas Monjalon
2017-05-02 12:20             ` Gaëtan Rivet
2017-04-18 12:17   ` [dpdk-dev] [PATCH v2 2/5] net/mlx4: device removal event support Gaetan Rivet
2017-04-18 12:17   ` Gaetan Rivet [this message]
2017-04-18 12:17   ` [dpdk-dev] [PATCH v2 4/5] app/testpmd: request link status interrupt Gaetan Rivet
2017-04-21 14:55     ` Ferruh Yigit
2017-04-25  9:07       ` Gaëtan Rivet
2017-04-25  9:40         ` Ferruh Yigit
2017-04-25 10:10           ` [dpdk-dev] [PATCH 1/3] doc: fix missing backquotes Gaetan Rivet
2017-04-25 10:10             ` [dpdk-dev] [PATCH 2/3] doc: add device removal event to release note Gaetan Rivet
2017-04-25 10:10             ` [dpdk-dev] [PATCH 3/3] doc: add lsc and rmv interrupt to testpmd user guide Gaetan Rivet
2017-04-25 10:18             ` [dpdk-dev] [PATCH v2 1/4] doc: fix missing backquotes Gaetan Rivet
2017-04-25 10:18               ` [dpdk-dev] [PATCH v2 2/4] doc: add device removal event to release note Gaetan Rivet
2017-04-26 14:59                 ` Mcnamara, John
2017-04-25 10:18               ` [dpdk-dev] [PATCH v2 3/4] doc: add LSC and RMV interrupt to testpmd user guide Gaetan Rivet
2017-04-26 15:00                 ` Mcnamara, John
2017-04-25 10:18               ` [dpdk-dev] [PATCH v2 4/4] devtools: add git log checks for rmv Gaetan Rivet
2017-04-26 15:01                 ` Mcnamara, John
2017-04-30 22:28                 ` Thomas Monjalon
2017-04-26 14:58               ` [dpdk-dev] [PATCH v2 1/4] doc: fix missing backquotes Mcnamara, John
2017-04-30 22:30                 ` Thomas Monjalon
2017-04-18 12:17   ` [dpdk-dev] [PATCH v2 5/5] app/testpmd: request device removal interrupt Gaetan Rivet
2017-04-20 22:45   ` [dpdk-dev] [PATCH v2 0/5] add device removal event Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fd7a257cbfd4ab464d99e99848cd6814e03b972d.1492517222.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).