summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/lib/librte_ethdev/ethdev_profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/spdk/dpdk/lib/librte_ethdev/ethdev_profile.c')
-rw-r--r--src/spdk/dpdk/lib/librte_ethdev/ethdev_profile.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/spdk/dpdk/lib/librte_ethdev/ethdev_profile.c b/src/spdk/dpdk/lib/librte_ethdev/ethdev_profile.c
new file mode 100644
index 000000000..a3c303f62
--- /dev/null
+++ b/src/spdk/dpdk/lib/librte_ethdev/ethdev_profile.c
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#include "ethdev_profile.h"
+
+/**
+ * This conditional block enables Ethernet device profiling with
+ * Intel (R) VTune (TM) Amplifier.
+ */
+#ifdef RTE_ETHDEV_PROFILE_WITH_VTUNE
+
+/**
+ * Hook callback to trace rte_eth_rx_burst() calls.
+ */
+uint16_t
+profile_hook_rx_burst_cb(
+ __rte_unused uint16_t port_id, __rte_unused uint16_t queue_id,
+ __rte_unused struct rte_mbuf *pkts[], uint16_t nb_pkts,
+ __rte_unused uint16_t max_pkts, __rte_unused void *user_param)
+{
+ return nb_pkts;
+}
+
+/**
+ * Setting profiling rx callback for a given Ethernet device.
+ * This function must be invoked when ethernet device is being configured.
+ *
+ * @param port_id
+ * The port identifier of the Ethernet device.
+ * @param rx_queue_num
+ * The number of RX queues on specified port.
+ *
+ * @return
+ * - On success, zero.
+ * - On failure, a negative value.
+ */
+static inline int
+vtune_profile_rx_init(uint16_t port_id, uint8_t rx_queue_num)
+{
+ uint16_t q_id;
+
+ for (q_id = 0; q_id < rx_queue_num; ++q_id) {
+ if (!rte_eth_add_rx_callback(
+ port_id, q_id, profile_hook_rx_burst_cb, NULL)) {
+ return -rte_errno;
+ }
+ }
+
+ return 0;
+}
+#endif /* RTE_ETHDEV_PROFILE_WITH_VTUNE */
+
+int
+__rte_eth_dev_profile_init(__rte_unused uint16_t port_id,
+ __rte_unused struct rte_eth_dev *dev)
+{
+#ifdef RTE_ETHDEV_PROFILE_WITH_VTUNE
+ return vtune_profile_rx_init(port_id, dev->data->nb_rx_queues);
+#endif
+ return 0;
+}