Skip to content

Commit 508c29b

Browse files
vadimp-nvidiakuba-moo
authored andcommitted
mlxsw: core_linecards: Register a system event handler
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>
1 parent 2ab4e70 commit 508c29b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_linecards.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,21 @@ static int mlxsw_linecard_status_get_and_process(struct mlxsw_core *mlxsw_core,
785785
return mlxsw_linecard_status_process(linecards, linecard, mddq_pl);
786786
}
787787

788+
static void mlxsw_linecards_irq_event_handler(struct mlxsw_core *mlxsw_core)
789+
{
790+
struct mlxsw_linecards *linecards = mlxsw_core_linecards(mlxsw_core);
791+
int i;
792+
793+
/* Handle change of line card active state. */
794+
for (i = 0; i < linecards->count; i++) {
795+
struct mlxsw_linecard *linecard = mlxsw_linecard_get(linecards,
796+
i + 1);
797+
798+
mlxsw_linecard_status_get_and_process(mlxsw_core, linecards,
799+
linecard);
800+
}
801+
}
802+
788803
static const char * const mlxsw_linecard_status_event_type_name[] = {
789804
[MLXSW_LINECARD_STATUS_EVENT_TYPE_PROVISION] = "provision",
790805
[MLXSW_LINECARD_STATUS_EVENT_TYPE_UNPROVISION] = "unprovision",
@@ -1521,6 +1536,11 @@ int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
15211536
if (err)
15221537
goto err_traps_register;
15231538

1539+
err = mlxsw_core_irq_event_handler_register(mlxsw_core,
1540+
mlxsw_linecards_irq_event_handler);
1541+
if (err)
1542+
goto err_irq_event_handler_register;
1543+
15241544
mlxsw_core_linecards_set(mlxsw_core, linecards);
15251545

15261546
for (i = 0; i < linecards->count; i++) {
@@ -1545,6 +1565,9 @@ int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
15451565
err_linecard_init:
15461566
for (i--; i >= 0; i--)
15471567
mlxsw_linecard_fini(mlxsw_core, linecards, i + 1);
1568+
mlxsw_core_irq_event_handler_unregister(mlxsw_core,
1569+
mlxsw_linecards_irq_event_handler);
1570+
err_irq_event_handler_register:
15481571
mlxsw_core_traps_unregister(mlxsw_core, mlxsw_linecard_listener,
15491572
ARRAY_SIZE(mlxsw_linecard_listener),
15501573
mlxsw_core);
@@ -1566,6 +1589,8 @@ void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core)
15661589
mlxsw_linecard_event_delivery_fini(mlxsw_core, linecards, i + 1);
15671590
for (i = 0; i < linecards->count; i++)
15681591
mlxsw_linecard_fini(mlxsw_core, linecards, i + 1);
1592+
mlxsw_core_irq_event_handler_unregister(mlxsw_core,
1593+
mlxsw_linecards_irq_event_handler);
15691594
mlxsw_core_traps_unregister(mlxsw_core, mlxsw_linecard_listener,
15701595
ARRAY_SIZE(mlxsw_linecard_listener),
15711596
mlxsw_core);

0 commit comments

Comments
 (0)