Commit 720a936d authored by Saeed Mahameed's avatar Saeed Mahameed

net/mlx5: FWTrace, Use async events chain

Remove the explicit call to mlx5_fw_tracer_event on
MLX5_EVENT_TYPE_DEVICE_TRACER and let fw tracer to register
its own handler when its ready.
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 0f597ed4
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include "lib/eq.h"
#include "fw_tracer.h" #include "fw_tracer.h"
#include "fw_tracer_tracepoint.h" #include "fw_tracer_tracepoint.h"
...@@ -846,9 +847,9 @@ struct mlx5_fw_tracer *mlx5_fw_tracer_create(struct mlx5_core_dev *dev) ...@@ -846,9 +847,9 @@ struct mlx5_fw_tracer *mlx5_fw_tracer_create(struct mlx5_core_dev *dev)
return ERR_PTR(err); return ERR_PTR(err);
} }
/* Create HW resources + start tracer static int fw_tracer_event(struct notifier_block *nb, unsigned long action, void *data);
* must be called before Async EQ is created
*/ /* Create HW resources + start tracer */
int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer) int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
{ {
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
...@@ -874,6 +875,9 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer) ...@@ -874,6 +875,9 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
goto err_dealloc_pd; goto err_dealloc_pd;
} }
MLX5_NB_INIT(&tracer->nb, fw_tracer_event, DEVICE_TRACER);
mlx5_eq_notifier_register(dev, &tracer->nb);
mlx5_fw_tracer_start(tracer); mlx5_fw_tracer_start(tracer);
return 0; return 0;
...@@ -883,9 +887,7 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer) ...@@ -883,9 +887,7 @@ int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer)
return err; return err;
} }
/* Stop tracer + Cleanup HW resources /* Stop tracer + Cleanup HW resources */
* must be called after Async EQ is destroyed
*/
void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer) void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer)
{ {
if (IS_ERR_OR_NULL(tracer)) if (IS_ERR_OR_NULL(tracer))
...@@ -893,7 +895,7 @@ void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer) ...@@ -893,7 +895,7 @@ void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer)
mlx5_core_dbg(tracer->dev, "FWTracer: Cleanup, is owner ? (%d)\n", mlx5_core_dbg(tracer->dev, "FWTracer: Cleanup, is owner ? (%d)\n",
tracer->owner); tracer->owner);
mlx5_eq_notifier_unregister(tracer->dev, &tracer->nb);
cancel_work_sync(&tracer->ownership_change_work); cancel_work_sync(&tracer->ownership_change_work);
cancel_work_sync(&tracer->handle_traces_work); cancel_work_sync(&tracer->handle_traces_work);
...@@ -922,12 +924,11 @@ void mlx5_fw_tracer_destroy(struct mlx5_fw_tracer *tracer) ...@@ -922,12 +924,11 @@ void mlx5_fw_tracer_destroy(struct mlx5_fw_tracer *tracer)
kfree(tracer); kfree(tracer);
} }
void mlx5_fw_tracer_event(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe) static int fw_tracer_event(struct notifier_block *nb, unsigned long action, void *data)
{ {
struct mlx5_fw_tracer *tracer = dev->tracer; struct mlx5_fw_tracer *tracer = mlx5_nb_cof(nb, struct mlx5_fw_tracer, nb);
struct mlx5_core_dev *dev = tracer->dev;
if (!tracer) struct mlx5_eqe *eqe = data;
return;
switch (eqe->sub_type) { switch (eqe->sub_type) {
case MLX5_TRACER_SUBTYPE_OWNERSHIP_CHANGE: case MLX5_TRACER_SUBTYPE_OWNERSHIP_CHANGE:
...@@ -942,6 +943,8 @@ void mlx5_fw_tracer_event(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe) ...@@ -942,6 +943,8 @@ void mlx5_fw_tracer_event(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe)
mlx5_core_dbg(dev, "FWTracer: Event with unrecognized subtype: sub_type %d\n", mlx5_core_dbg(dev, "FWTracer: Event with unrecognized subtype: sub_type %d\n",
eqe->sub_type); eqe->sub_type);
} }
return NOTIFY_OK;
} }
EXPORT_TRACEPOINT_SYMBOL(mlx5_fw); EXPORT_TRACEPOINT_SYMBOL(mlx5_fw);
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
struct mlx5_fw_tracer { struct mlx5_fw_tracer {
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
struct mlx5_nb nb;
bool owner; bool owner;
u8 trc_ver; u8 trc_ver;
struct workqueue_struct *work_queue; struct workqueue_struct *work_queue;
...@@ -170,6 +171,5 @@ struct mlx5_fw_tracer *mlx5_fw_tracer_create(struct mlx5_core_dev *dev); ...@@ -170,6 +171,5 @@ struct mlx5_fw_tracer *mlx5_fw_tracer_create(struct mlx5_core_dev *dev);
int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer); int mlx5_fw_tracer_init(struct mlx5_fw_tracer *tracer);
void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer); void mlx5_fw_tracer_cleanup(struct mlx5_fw_tracer *tracer);
void mlx5_fw_tracer_destroy(struct mlx5_fw_tracer *tracer); void mlx5_fw_tracer_destroy(struct mlx5_fw_tracer *tracer);
void mlx5_fw_tracer_event(struct mlx5_core_dev *dev, struct mlx5_eqe *eqe);
#endif #endif
...@@ -434,10 +434,6 @@ static irqreturn_t mlx5_eq_async_int(int irq, void *eq_ptr) ...@@ -434,10 +434,6 @@ static irqreturn_t mlx5_eq_async_int(int irq, void *eq_ptr)
general_event_handler(dev, eqe); general_event_handler(dev, eqe);
break; break;
case MLX5_EVENT_TYPE_DEVICE_TRACER:
mlx5_fw_tracer_event(dev, eqe);
break;
default: default:
mlx5_core_warn(dev, "Unhandled event 0x%x on EQ 0x%x\n", mlx5_core_warn(dev, "Unhandled event 0x%x on EQ 0x%x\n",
eqe->type, eq->eqn); eqe->type, eq->eqn);
......
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