Skip to content

Commit ee7a70f

Browse files
Jiri Pirkodavem330
Jiri Pirko
authored andcommitted
mlxsw: core_linecards: Implement line card activation process
Allow to process events generated upon line card getting "ready" and "active". When DSDSC event with "ready" bit set is delivered, that means the line card is powered up. Use MDDC register to push the line card to active state. Once FW is done with that, the DSDSC event with "active" bit set is delivered. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b217127 commit ee7a70f

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,9 @@ struct mlxsw_linecard {
564564
char mbct_pl[MLXSW_REG_MBCT_LEN]; /* Too big for stack */
565565
enum mlxsw_linecard_status_event_type status_event_type_to;
566566
struct delayed_work status_event_to_dw;
567-
u8 provisioned:1;
567+
u8 provisioned:1,
568+
ready:1,
569+
active:1;
568570
u16 hw_revision;
569571
u16 ini_version;
570572
};

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

+63
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
9090
static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard)
9191
{
9292
linecard->provisioned = false;
93+
linecard->ready = false;
94+
linecard->active = false;
9395
devlink_linecard_provision_fail(linecard->devlink_linecard);
9496
}
9597

@@ -131,6 +133,46 @@ static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard)
131133
devlink_linecard_provision_clear(linecard->devlink_linecard);
132134
}
133135

136+
static int mlxsw_linecard_ready_set(struct mlxsw_linecard *linecard)
137+
{
138+
struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core;
139+
char mddc_pl[MLXSW_REG_MDDC_LEN];
140+
int err;
141+
142+
mlxsw_reg_mddc_pack(mddc_pl, linecard->slot_index, false, true);
143+
err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddc), mddc_pl);
144+
if (err)
145+
return err;
146+
linecard->ready = true;
147+
return 0;
148+
}
149+
150+
static int mlxsw_linecard_ready_clear(struct mlxsw_linecard *linecard)
151+
{
152+
struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core;
153+
char mddc_pl[MLXSW_REG_MDDC_LEN];
154+
int err;
155+
156+
mlxsw_reg_mddc_pack(mddc_pl, linecard->slot_index, false, false);
157+
err = mlxsw_reg_write(mlxsw_core, MLXSW_REG(mddc), mddc_pl);
158+
if (err)
159+
return err;
160+
linecard->ready = false;
161+
return 0;
162+
}
163+
164+
static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard)
165+
{
166+
linecard->active = true;
167+
devlink_linecard_activate(linecard->devlink_linecard);
168+
}
169+
170+
static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard)
171+
{
172+
linecard->active = false;
173+
devlink_linecard_deactivate(linecard->devlink_linecard);
174+
}
175+
134176
static int mlxsw_linecard_status_process(struct mlxsw_linecards *linecards,
135177
struct mlxsw_linecard *linecard,
136178
const char *mddq_pl)
@@ -164,6 +206,25 @@ static int mlxsw_linecard_status_process(struct mlxsw_linecards *linecards,
164206
goto out;
165207
}
166208

209+
if (ready == MLXSW_REG_MDDQ_SLOT_INFO_READY_READY && !linecard->ready) {
210+
err = mlxsw_linecard_ready_set(linecard);
211+
if (err)
212+
goto out;
213+
}
214+
215+
if (active && linecard->active != active)
216+
mlxsw_linecard_active_set(linecard);
217+
218+
if (!active && linecard->active != active)
219+
mlxsw_linecard_active_clear(linecard);
220+
221+
if (ready != MLXSW_REG_MDDQ_SLOT_INFO_READY_READY &&
222+
linecard->ready) {
223+
err = mlxsw_linecard_ready_clear(linecard);
224+
if (err)
225+
goto out;
226+
}
227+
167228
if (!provisioned && linecard->provisioned != provisioned)
168229
mlxsw_linecard_provision_clear(linecard);
169230

@@ -676,6 +737,8 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,
676737
cancel_delayed_work_sync(&linecard->status_event_to_dw);
677738
/* Make sure all scheduled events are processed */
678739
mlxsw_core_flush_owq();
740+
if (linecard->active)
741+
mlxsw_linecard_active_clear(linecard);
679742
devlink_linecard_destroy(linecard->devlink_linecard);
680743
mutex_destroy(&linecard->lock);
681744
}

0 commit comments

Comments
 (0)