Commit d67ab0a8 authored by Parav Pandit's avatar Parav Pandit Committed by Saeed Mahameed

net/mlx5: SF_DEV Add SF device trace points

Add SF device add and delete specific trace points.

echo mlx5:mlx5_sf_dev_add >> /sys/kernel/debug/tracing/set_event
echo mlx5:mlx5_sf_dev_del >> /sys/kernel/debug/tracing/set_event
echo mlx5:mlx5_sf_vhca_event >> /sys/kernel/debug/tracing/set_event
Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent b3ccada6
...@@ -739,3 +739,24 @@ SF tracepoints: ...@@ -739,3 +739,24 @@ SF tracepoints:
$ cat /sys/kernel/debug/tracing/trace $ cat /sys/kernel/debug/tracing/trace
... ...
devlink-9519 [046] ..... 24624.400271: mlx5_sf_hwc_deferred_free: (0000:06:00.0) hw_id=0x8000 devlink-9519 [046] ..... 24624.400271: mlx5_sf_hwc_deferred_free: (0000:06:00.0) hw_id=0x8000
- mlx5_sf_vhca_event: trace SF vhca event and state::
$ echo mlx5:mlx5_sf_vhca_event >> /sys/kernel/debug/tracing/set_event
$ cat /sys/kernel/debug/tracing/trace
...
kworker/u128:3-9093 [046] ..... 24625.365525: mlx5_sf_vhca_event: (0000:06:00.0) hw_id=0x8000 sfnum=88 vhca_state=1
- mlx5_sf_dev_add : trace SF device add event::
$ echo mlx5:mlx5_sf_dev_add>> /sys/kernel/debug/tracing/set_event
$ cat /sys/kernel/debug/tracing/trace
...
kworker/u128:3-9093 [000] ..... 24616.524495: mlx5_sf_dev_add: (0000:06:00.0) sfdev=00000000fc5d96fd aux_id=4 hw_id=0x8000 sfnum=88
- mlx5_sf_dev_del : trace SF device delete event::
$ echo mlx5:mlx5_sf_dev_del >> /sys/kernel/debug/tracing/set_event
$ cat /sys/kernel/debug/tracing/trace
...
kworker/u128:3-9093 [044] ..... 24624.400749: mlx5_sf_dev_del: (0000:06:00.0) sfdev=00000000fc5d96fd aux_id=4 hw_id=0x8000 sfnum=88
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "sf/sf.h" #include "sf/sf.h"
#include "sf/mlx5_ifc_vhca_event.h" #include "sf/mlx5_ifc_vhca_event.h"
#include "ecpf.h" #include "ecpf.h"
#define CREATE_TRACE_POINTS
#include "diag/dev_tracepoint.h"
struct mlx5_sf_dev_table { struct mlx5_sf_dev_table {
struct xarray devices; struct xarray devices;
...@@ -66,13 +68,18 @@ static void mlx5_sf_dev_release(struct device *device) ...@@ -66,13 +68,18 @@ static void mlx5_sf_dev_release(struct device *device)
kfree(sf_dev); kfree(sf_dev);
} }
static void mlx5_sf_dev_remove(struct mlx5_sf_dev *sf_dev) static void mlx5_sf_dev_remove(struct mlx5_core_dev *dev, struct mlx5_sf_dev *sf_dev)
{ {
int id;
id = sf_dev->adev.id;
trace_mlx5_sf_dev_del(dev, sf_dev, id);
auxiliary_device_delete(&sf_dev->adev); auxiliary_device_delete(&sf_dev->adev);
auxiliary_device_uninit(&sf_dev->adev); auxiliary_device_uninit(&sf_dev->adev);
} }
static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum) static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u16 fn_id, u32 sfnum)
{ {
struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table; struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table;
struct mlx5_sf_dev *sf_dev; struct mlx5_sf_dev *sf_dev;
...@@ -100,6 +107,7 @@ static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum) ...@@ -100,6 +107,7 @@ static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum)
sf_dev->adev.dev.groups = sf_attr_groups; sf_dev->adev.dev.groups = sf_attr_groups;
sf_dev->sfnum = sfnum; sf_dev->sfnum = sfnum;
sf_dev->parent_mdev = dev; sf_dev->parent_mdev = dev;
sf_dev->fn_id = fn_id;
if (!table->max_sfs) { if (!table->max_sfs) {
mlx5_adev_idx_free(id); mlx5_adev_idx_free(id);
...@@ -109,6 +117,8 @@ static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum) ...@@ -109,6 +117,8 @@ static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum)
} }
sf_dev->bar_base_addr = table->base_address + (sf_index * table->sf_bar_length); sf_dev->bar_base_addr = table->base_address + (sf_index * table->sf_bar_length);
trace_mlx5_sf_dev_add(dev, sf_dev, id);
err = auxiliary_device_init(&sf_dev->adev); err = auxiliary_device_init(&sf_dev->adev);
if (err) { if (err) {
mlx5_adev_idx_free(id); mlx5_adev_idx_free(id);
...@@ -128,7 +138,7 @@ static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum) ...@@ -128,7 +138,7 @@ static void mlx5_sf_dev_add(struct mlx5_core_dev *dev, u16 sf_index, u32 sfnum)
return; return;
xa_err: xa_err:
mlx5_sf_dev_remove(sf_dev); mlx5_sf_dev_remove(dev, sf_dev);
add_err: add_err:
mlx5_core_err(dev, "SF DEV: fail device add for index=%d sfnum=%d err=%d\n", mlx5_core_err(dev, "SF DEV: fail device add for index=%d sfnum=%d err=%d\n",
sf_index, sfnum, err); sf_index, sfnum, err);
...@@ -139,7 +149,7 @@ static void mlx5_sf_dev_del(struct mlx5_core_dev *dev, struct mlx5_sf_dev *sf_de ...@@ -139,7 +149,7 @@ static void mlx5_sf_dev_del(struct mlx5_core_dev *dev, struct mlx5_sf_dev *sf_de
struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table; struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table;
xa_erase(&table->devices, sf_index); xa_erase(&table->devices, sf_index);
mlx5_sf_dev_remove(sf_dev); mlx5_sf_dev_remove(dev, sf_dev);
} }
static int static int
...@@ -178,7 +188,8 @@ mlx5_sf_dev_state_change_handler(struct notifier_block *nb, unsigned long event_ ...@@ -178,7 +188,8 @@ mlx5_sf_dev_state_change_handler(struct notifier_block *nb, unsigned long event_
break; break;
case MLX5_VHCA_STATE_ACTIVE: case MLX5_VHCA_STATE_ACTIVE:
if (!sf_dev) if (!sf_dev)
mlx5_sf_dev_add(table->dev, sf_index, event->sw_function_id); mlx5_sf_dev_add(table->dev, sf_index, event->function_id,
event->sw_function_id);
break; break;
default: default:
break; break;
...@@ -260,7 +271,7 @@ static void mlx5_sf_dev_destroy_all(struct mlx5_sf_dev_table *table) ...@@ -260,7 +271,7 @@ static void mlx5_sf_dev_destroy_all(struct mlx5_sf_dev_table *table)
xa_for_each(&table->devices, index, sf_dev) { xa_for_each(&table->devices, index, sf_dev) {
xa_erase(&table->devices, index); xa_erase(&table->devices, index);
mlx5_sf_dev_remove(sf_dev); mlx5_sf_dev_remove(table->dev, sf_dev);
} }
} }
......
...@@ -16,6 +16,7 @@ struct mlx5_sf_dev { ...@@ -16,6 +16,7 @@ struct mlx5_sf_dev {
struct mlx5_core_dev *mdev; struct mlx5_core_dev *mdev;
phys_addr_t bar_base_addr; phys_addr_t bar_base_addr;
u32 sfnum; u32 sfnum;
u16 fn_id;
}; };
void mlx5_sf_dev_table_create(struct mlx5_core_dev *dev); void mlx5_sf_dev_table_create(struct mlx5_core_dev *dev);
......
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mlx5
#if !defined(_MLX5_SF_DEV_TP_) || defined(TRACE_HEADER_MULTI_READ)
#define _MLX5_SF_DEV_TP_
#include <linux/tracepoint.h>
#include <linux/mlx5/driver.h>
#include "../../dev/dev.h"
DECLARE_EVENT_CLASS(mlx5_sf_dev_template,
TP_PROTO(const struct mlx5_core_dev *dev,
const struct mlx5_sf_dev *sfdev,
int aux_id),
TP_ARGS(dev, sfdev, aux_id),
TP_STRUCT__entry(__string(devname, dev_name(dev->device))
__field(const struct mlx5_sf_dev*, sfdev)
__field(int, aux_id)
__field(u16, hw_fn_id)
__field(u32, sfnum)
),
TP_fast_assign(__assign_str(devname, dev_name(dev->device));
__entry->sfdev = sfdev;
__entry->aux_id = aux_id;
__entry->hw_fn_id = sfdev->fn_id;
__entry->sfnum = sfdev->sfnum;
),
TP_printk("(%s) sfdev=%pK aux_id=%d hw_id=0x%x sfnum=%u\n",
__get_str(devname), __entry->sfdev,
__entry->aux_id, __entry->hw_fn_id,
__entry->sfnum)
);
DEFINE_EVENT(mlx5_sf_dev_template, mlx5_sf_dev_add,
TP_PROTO(const struct mlx5_core_dev *dev,
const struct mlx5_sf_dev *sfdev,
int aux_id),
TP_ARGS(dev, sfdev, aux_id)
);
DEFINE_EVENT(mlx5_sf_dev_template, mlx5_sf_dev_del,
TP_PROTO(const struct mlx5_core_dev *dev,
const struct mlx5_sf_dev *sfdev,
int aux_id),
TP_ARGS(dev, sfdev, aux_id)
);
#endif /* _MLX5_SF_DEV_TP_ */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH sf/dev/diag
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE dev_tracepoint
#include <trace/define_trace.h>
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mlx5
#if !defined(_MLX5_SF_VHCA_TP_) || defined(TRACE_HEADER_MULTI_READ)
#define _MLX5_SF_VHCA_TP_
#include <linux/tracepoint.h>
#include <linux/mlx5/driver.h>
#include "sf/vhca_event.h"
TRACE_EVENT(mlx5_sf_vhca_event,
TP_PROTO(const struct mlx5_core_dev *dev,
const struct mlx5_vhca_state_event *event),
TP_ARGS(dev, event),
TP_STRUCT__entry(__string(devname, dev_name(dev->device))
__field(u16, hw_fn_id)
__field(u32, sfnum)
__field(u8, vhca_state)
),
TP_fast_assign(__assign_str(devname, dev_name(dev->device));
__entry->hw_fn_id = event->function_id;
__entry->sfnum = event->sw_function_id;
__entry->vhca_state = event->new_vhca_state;
),
TP_printk("(%s) hw_id=0x%x sfnum=%u vhca_state=%d\n",
__get_str(devname), __entry->hw_fn_id,
__entry->sfnum, __entry->vhca_state)
);
#endif /* _MLX5_SF_VHCA_TP_ */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH sf/diag
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE vhca_tracepoint
#include <trace/define_trace.h>
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "mlx5_core.h" #include "mlx5_core.h"
#include "vhca_event.h" #include "vhca_event.h"
#include "ecpf.h" #include "ecpf.h"
#define CREATE_TRACE_POINTS
#include "diag/vhca_tracepoint.h"
struct mlx5_vhca_state_notifier { struct mlx5_vhca_state_notifier {
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
...@@ -82,6 +84,7 @@ mlx5_vhca_event_notify(struct mlx5_core_dev *dev, struct mlx5_vhca_state_event * ...@@ -82,6 +84,7 @@ mlx5_vhca_event_notify(struct mlx5_core_dev *dev, struct mlx5_vhca_state_event *
vhca_state_context.vhca_state); vhca_state_context.vhca_state);
mlx5_vhca_event_arm(dev, event->function_id); mlx5_vhca_event_arm(dev, event->function_id);
trace_mlx5_sf_vhca_event(dev, event);
blocking_notifier_call_chain(&dev->priv.vhca_state_notifier->n_head, 0, event); blocking_notifier_call_chain(&dev->priv.vhca_state_notifier->n_head, 0, event);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment