@@ -90,6 +90,8 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
9090static 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+
134176static 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