2017-12-19 15:49:03 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2018-07-19 12:21:42 +00:00
|
|
|
* Copyright(c) 2010-2018 Intel Corporation
|
2017-09-22 14:52:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ethdev_profile.h"
|
|
|
|
|
|
|
|
/**
|
2018-07-19 12:21:42 +00:00
|
|
|
* This conditional block enables Ethernet device profiling with
|
|
|
|
* Intel (R) VTune (TM) Amplifier.
|
2017-09-22 14:52:29 +00:00
|
|
|
*/
|
2018-07-19 12:21:42 +00:00
|
|
|
#ifdef RTE_ETHDEV_PROFILE_WITH_VTUNE
|
2017-09-22 14:52:29 +00:00
|
|
|
|
|
|
|
/**
|
2018-07-19 12:21:42 +00:00
|
|
|
* Hook callback to trace rte_eth_rx_burst() calls.
|
2017-09-22 14:52:29 +00:00
|
|
|
*/
|
2018-07-19 12:21:42 +00:00
|
|
|
uint16_t
|
|
|
|
profile_hook_rx_burst_cb(
|
|
|
|
__rte_unused uint16_t port_id, __rte_unused uint16_t queue_id,
|
2017-09-22 14:52:29 +00:00
|
|
|
__rte_unused struct rte_mbuf *pkts[], uint16_t nb_pkts,
|
|
|
|
__rte_unused uint16_t max_pkts, __rte_unused void *user_param)
|
|
|
|
{
|
|
|
|
return nb_pkts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-20 12:47:20 +00:00
|
|
|
* Setting profiling Rx callback for a given Ethernet device.
|
2021-10-20 12:47:21 +00:00
|
|
|
* This function must be invoked when Ethernet device is being configured.
|
2017-09-22 14:52:29 +00:00
|
|
|
*
|
|
|
|
* @param port_id
|
|
|
|
* The port identifier of the Ethernet device.
|
|
|
|
* @param rx_queue_num
|
2021-10-20 12:47:20 +00:00
|
|
|
* The number of Rx queues on specified port.
|
2017-09-22 14:52:29 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* - On success, zero.
|
|
|
|
* - On failure, a negative value.
|
|
|
|
*/
|
|
|
|
static inline int
|
2018-07-19 12:21:42 +00:00
|
|
|
vtune_profile_rx_init(uint16_t port_id, uint8_t rx_queue_num)
|
2017-09-22 14:52:29 +00:00
|
|
|
{
|
|
|
|
uint16_t q_id;
|
|
|
|
|
|
|
|
for (q_id = 0; q_id < rx_queue_num; ++q_id) {
|
|
|
|
if (!rte_eth_add_rx_callback(
|
2018-07-19 12:21:42 +00:00
|
|
|
port_id, q_id, profile_hook_rx_burst_cb, NULL)) {
|
2017-09-22 14:52:29 +00:00
|
|
|
return -rte_errno;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-07-19 12:21:42 +00:00
|
|
|
#endif /* RTE_ETHDEV_PROFILE_WITH_VTUNE */
|
2017-09-22 14:52:29 +00:00
|
|
|
|
|
|
|
int
|
2018-07-19 12:21:42 +00:00
|
|
|
__rte_eth_dev_profile_init(__rte_unused uint16_t port_id,
|
2017-09-22 14:52:29 +00:00
|
|
|
__rte_unused struct rte_eth_dev *dev)
|
|
|
|
{
|
2018-07-19 12:21:42 +00:00
|
|
|
#ifdef RTE_ETHDEV_PROFILE_WITH_VTUNE
|
|
|
|
return vtune_profile_rx_init(port_id, dev->data->nb_rx_queues);
|
2017-09-22 14:52:29 +00:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|