Skip to content

Commit

Permalink
mlxsw: core_linecards: Register a system event handler
Browse files Browse the repository at this point in the history
Add line card system event handler. Register it with core. It is
triggered by system interrupts raised from chassis programmable logic
devices to CPU. The purpose is to handle line card state changes over
I2C bus.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Vadim Pasternak authored and Jakub Kicinski committed Aug 24, 2022
1 parent 2ab4e70 commit 508c29b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,21 @@ static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core,
return mlxsw_linecard_status_process(linecards, linecard, mddq_pl);
}

static void mlxsw_linecards_irq_event_handler(struct mlxsw_core *mlxsw_core)
{
struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core);
int i;

/* Handle change of line card active state. */
for (i = 0; i < linecards->count; i++) {
struct mlxsw_linecard *linecard = mlxsw_linecard_get(linecards,
i + 1);

mlxsw_linecard_status_get_and_process(mlxsw_core, linecards,
linecard);
}
}

static const char * const mlxsw_linecard_status_event_type_name[] = {
[MLXSW_LINECARD_STATUS_EVENT_TYPE_PROVISION] = "provision",
[MLXSW_LINECARD_STATUS_EVENT_TYPE_UNPROVISION] = "unprovision",
Expand Down Expand Up @@ -1521,6 +1536,11 @@ int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
if (err)
goto err_traps_register;

err = mlxsw_core_irq_event_handler_register(mlxsw_core,
mlxsw_linecards_irq_event_handler);
if (err)
goto err_irq_event_handler_register;

mlxsw_core_linecards_set(mlxsw_core, linecards);

for (i = 0; i < linecards->count; i++) {
Expand All @@ -1545,6 +1565,9 @@ int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
err_linecard_init:
for (i--; i >= 0; i--)
mlxsw_linecard_fini(mlxsw_core, linecards, i + 1);
mlxsw_core_irq_event_handler_unregister(mlxsw_core,
mlxsw_linecards_irq_event_handler);
err_irq_event_handler_register:
mlxsw_core_traps_unregister(mlxsw_core, mlxsw_linecard_listener,
ARRAY_SIZE(mlxsw_linecard_listener),
mlxsw_core);
Expand All @@ -1566,6 +1589,8 @@ void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core)
mlxsw_linecard_event_delivery_fini(mlxsw_core, linecards, i + 1);
for (i = 0; i < linecards->count; i++)
mlxsw_linecard_fini(mlxsw_core, linecards, i + 1);
mlxsw_core_irq_event_handler_unregister(mlxsw_core,
mlxsw_linecards_irq_event_handler);
mlxsw_core_traps_unregister(mlxsw_core, mlxsw_linecard_listener,
ARRAY_SIZE(mlxsw_linecard_listener),
mlxsw_core);
Expand Down

0 comments on commit 508c29b

Please sign in to comment.