trace: add interrupt tracepoints

Add the following interrupt related tracepoints.

- rte_eal_trace_intr_callback_register()
- rte_eal_trace_intr_callback_unregister()
- rte_eal_trace_intr_enable()
- rte_eal_trace_intr_disable()

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: David Marchand <david.marchand@redhat.com>
This commit is contained in:
Jerin Jacob 2020-04-23 00:33:38 +05:30 committed by David Marchand
parent 0baa1e01c3
commit 05c4105738
5 changed files with 170 additions and 49 deletions

View File

@ -38,6 +38,11 @@ RTE_TRACE_POINT_DEFINE(rte_eal_trace_memzone_free);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_thread_remote_launch);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_thread_lcore_ready);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_intr_callback_register);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_intr_callback_unregister);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_intr_enable);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_intr_disable);
RTE_INIT(eal_trace_init)
{
RTE_TRACE_POINT_REGISTER(rte_eal_trace_generic_void,
@ -98,4 +103,13 @@ RTE_INIT(eal_trace_init)
lib.eal.thread.remote.launch);
RTE_TRACE_POINT_REGISTER(rte_eal_trace_thread_lcore_ready,
lib.eal.thread.lcore.ready);
RTE_TRACE_POINT_REGISTER(rte_eal_trace_intr_callback_register,
lib.eal.intr.register);
RTE_TRACE_POINT_REGISTER(rte_eal_trace_intr_callback_unregister,
lib.eal.intr.unregister);
RTE_TRACE_POINT_REGISTER(rte_eal_trace_intr_enable,
lib.eal.intr.enable);
RTE_TRACE_POINT_REGISTER(rte_eal_trace_intr_disable,
lib.eal.intr.disable);
}

View File

@ -13,6 +13,7 @@
#include <rte_spinlock.h>
#include <rte_common.h>
#include <rte_interrupts.h>
#include <rte_eal_trace.h>
#include "eal_private.h"
#include "eal_alarm_private.h"
@ -85,7 +86,7 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
{
struct rte_intr_callback *callback;
struct rte_intr_source *src;
int ret, add_event = 0;
int ret = 0, add_event = 0;
/* first do parameter checking */
if (intr_handle == NULL || intr_handle->fd < 0 || cb == NULL) {
@ -182,6 +183,7 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
goto fail;
}
}
rte_eal_trace_intr_callback_register(intr_handle, cb, cb_arg, ret);
rte_spinlock_unlock(&intr_lock);
return 0;
@ -196,6 +198,7 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
}
}
free(callback);
rte_eal_trace_intr_callback_register(intr_handle, cb, cb_arg, ret);
rte_spinlock_unlock(&intr_lock);
return ret;
}
@ -335,6 +338,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
}
}
out:
rte_eal_trace_intr_callback_unregister(intr_handle, cb_fn, cb_arg,
ret);
rte_spinlock_unlock(&intr_lock);
return ret;
@ -343,55 +348,78 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
int
rte_intr_enable(const struct rte_intr_handle *intr_handle)
{
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)
return 0;
int rc = 0;
if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
return -1;
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
rc = 0;
goto out;
}
if (!intr_handle || intr_handle->fd < 0 ||
intr_handle->uio_cfg_fd < 0) {
rc = -1;
goto out;
}
switch (intr_handle->type) {
/* not used at this moment */
case RTE_INTR_HANDLE_ALARM:
return -1;
rc = -1;
break;
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
return -1;
rc = -1;
break;
/* unknown handle type */
default:
RTE_LOG(ERR, EAL,
"Unknown handle type of fd %d\n",
intr_handle->fd);
return -1;
rc = -1;
break;
}
return 0;
out:
rte_eal_trace_intr_enable(intr_handle, rc);
return rc;
}
int
rte_intr_disable(const struct rte_intr_handle *intr_handle)
{
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)
return 0;
int rc = 0;
if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
return -1;
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
rc = 0;
goto out;
}
if (!intr_handle || intr_handle->fd < 0 ||
intr_handle->uio_cfg_fd < 0) {
rc = -1;
goto out;
}
switch (intr_handle->type) {
/* not used at this moment */
case RTE_INTR_HANDLE_ALARM:
return -1;
rc = -1;
break;
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
return -1;
rc = -1;
break;
/* unknown handle type */
default:
RTE_LOG(ERR, EAL,
"Unknown handle type of fd %d\n",
intr_handle->fd);
return -1;
rc = -1;
break;
}
return 0;
out:
rte_eal_trace_intr_disable(intr_handle, rc);
return rc;
}
int

View File

@ -16,6 +16,7 @@ extern "C" {
#endif
#include <rte_alarm.h>
#include <rte_interrupts.h>
#include <rte_trace_point.h>
/* Generic */
@ -222,6 +223,54 @@ RTE_TRACE_POINT(
rte_trace_point_emit_string(cpuset);
)
/* Interrupt */
RTE_TRACE_POINT(
rte_eal_trace_intr_callback_register,
RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle,
rte_intr_callback_fn cb, void *cb_arg, int rc),
rte_trace_point_emit_int(rc);
rte_trace_point_emit_int(handle->vfio_dev_fd);
rte_trace_point_emit_int(handle->fd);
rte_trace_point_emit_int(handle->type);
rte_trace_point_emit_u32(handle->max_intr);
rte_trace_point_emit_u32(handle->nb_efd);
rte_trace_point_emit_ptr(cb);
rte_trace_point_emit_ptr(cb_arg);
)
RTE_TRACE_POINT(
rte_eal_trace_intr_callback_unregister,
RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle,
rte_intr_callback_fn cb, void *cb_arg, int rc),
rte_trace_point_emit_int(rc);
rte_trace_point_emit_int(handle->vfio_dev_fd);
rte_trace_point_emit_int(handle->fd);
rte_trace_point_emit_int(handle->type);
rte_trace_point_emit_u32(handle->max_intr);
rte_trace_point_emit_u32(handle->nb_efd);
rte_trace_point_emit_ptr(cb);
rte_trace_point_emit_ptr(cb_arg);
)
RTE_TRACE_POINT(
rte_eal_trace_intr_enable,
RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle, int rc),
rte_trace_point_emit_int(rc);
rte_trace_point_emit_int(handle->vfio_dev_fd);
rte_trace_point_emit_int(handle->fd);
rte_trace_point_emit_int(handle->type);
rte_trace_point_emit_u32(handle->max_intr);
rte_trace_point_emit_u32(handle->nb_efd);
)
RTE_TRACE_POINT(
rte_eal_trace_intr_disable,
RTE_TRACE_POINT_ARGS(const struct rte_intr_handle *handle, int rc),
rte_trace_point_emit_int(rc);
rte_trace_point_emit_int(handle->vfio_dev_fd);
rte_trace_point_emit_int(handle->fd);
rte_trace_point_emit_int(handle->type);
rte_trace_point_emit_u32(handle->max_intr);
rte_trace_point_emit_u32(handle->nb_efd);
)
#ifdef __cplusplus
}
#endif

View File

@ -34,6 +34,7 @@
#include <rte_spinlock.h>
#include <rte_pause.h>
#include <rte_vfio.h>
#include <rte_eal_trace.h>
#include "eal_private.h"
#include "eal_vfio.h"
@ -539,8 +540,9 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,
*/
if (wake_thread)
if (write(intr_pipe.writefd, "1", 1) < 0)
return -EPIPE;
ret = -EPIPE;
rte_eal_trace_intr_callback_register(intr_handle, cb, cb_arg, ret);
return ret;
}
@ -656,63 +658,76 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,
ret = -EPIPE;
}
rte_eal_trace_intr_callback_unregister(intr_handle, cb_fn, cb_arg,
ret);
return ret;
}
int
rte_intr_enable(const struct rte_intr_handle *intr_handle)
{
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)
return 0;
int rc = 0;
if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
return -1;
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
rc = 0;
goto out;
}
if (!intr_handle || intr_handle->fd < 0 ||
intr_handle->uio_cfg_fd < 0) {
rc = -1;
goto out;
}
switch (intr_handle->type){
/* write to the uio fd to enable the interrupt */
case RTE_INTR_HANDLE_UIO:
if (uio_intr_enable(intr_handle))
return -1;
rc = -1;
break;
case RTE_INTR_HANDLE_UIO_INTX:
if (uio_intx_intr_enable(intr_handle))
return -1;
rc = -1;
break;
/* not used at this moment */
case RTE_INTR_HANDLE_ALARM:
return -1;
rc = -1;
break;
#ifdef VFIO_PRESENT
case RTE_INTR_HANDLE_VFIO_MSIX:
if (vfio_enable_msix(intr_handle))
return -1;
rc = -1;
break;
case RTE_INTR_HANDLE_VFIO_MSI:
if (vfio_enable_msi(intr_handle))
return -1;
rc = -1;
break;
case RTE_INTR_HANDLE_VFIO_LEGACY:
if (vfio_enable_intx(intr_handle))
return -1;
rc = -1;
break;
#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
case RTE_INTR_HANDLE_VFIO_REQ:
if (vfio_enable_req(intr_handle))
return -1;
rc = -1;
break;
#endif
#endif
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
return -1;
rc = -1;
break;
/* unknown handle type */
default:
RTE_LOG(ERR, EAL,
"Unknown handle type of fd %d\n",
intr_handle->fd);
return -1;
rc = -1;
break;
}
return 0;
out:
rte_eal_trace_intr_enable(intr_handle, rc);
return rc;
}
/**
@ -778,57 +793,68 @@ rte_intr_ack(const struct rte_intr_handle *intr_handle)
int
rte_intr_disable(const struct rte_intr_handle *intr_handle)
{
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)
return 0;
int rc = 0;
if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)
return -1;
if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) {
rc = 0;
goto out;
}
if (!intr_handle || intr_handle->fd < 0 ||
intr_handle->uio_cfg_fd < 0) {
rc = -1;
goto out;
}
switch (intr_handle->type){
/* write to the uio fd to disable the interrupt */
case RTE_INTR_HANDLE_UIO:
if (uio_intr_disable(intr_handle))
return -1;
rc = -1;
break;
case RTE_INTR_HANDLE_UIO_INTX:
if (uio_intx_intr_disable(intr_handle))
return -1;
rc = -1;
break;
/* not used at this moment */
case RTE_INTR_HANDLE_ALARM:
return -1;
rc = -1;
break;
#ifdef VFIO_PRESENT
case RTE_INTR_HANDLE_VFIO_MSIX:
if (vfio_disable_msix(intr_handle))
return -1;
rc = -1;
break;
case RTE_INTR_HANDLE_VFIO_MSI:
if (vfio_disable_msi(intr_handle))
return -1;
rc = -1;
break;
case RTE_INTR_HANDLE_VFIO_LEGACY:
if (vfio_disable_intx(intr_handle))
return -1;
rc = -1;
break;
#ifdef HAVE_VFIO_DEV_REQ_INTERFACE
case RTE_INTR_HANDLE_VFIO_REQ:
if (vfio_disable_req(intr_handle))
return -1;
rc = -1;
break;
#endif
#endif
/* not used at this moment */
case RTE_INTR_HANDLE_DEV_EVENT:
return -1;
rc = -1;
break;
/* unknown handle type */
default:
RTE_LOG(ERR, EAL,
"Unknown handle type of fd %d\n",
intr_handle->fd);
return -1;
rc = -1;
break;
}
return 0;
out:
rte_eal_trace_intr_disable(intr_handle, rc);
return rc;
}
static int

View File

@ -355,6 +355,10 @@ EXPERIMENTAL {
__rte_eal_trace_generic_u64;
__rte_eal_trace_generic_u8;
__rte_eal_trace_generic_void;
__rte_eal_trace_intr_callback_register;
__rte_eal_trace_intr_callback_unregister;
__rte_eal_trace_intr_enable;
__rte_eal_trace_intr_disable;
__rte_eal_trace_mem_free;
__rte_eal_trace_mem_malloc;
__rte_eal_trace_mem_realloc;