@@ -90,6 +90,8 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
90
90
static void mlxsw_linecard_provision_fail (struct mlxsw_linecard * linecard )
91
91
{
92
92
linecard -> provisioned = false;
93
+ linecard -> ready = false;
94
+ linecard -> active = false;
93
95
devlink_linecard_provision_fail (linecard -> devlink_linecard );
94
96
}
95
97
@@ -131,6 +133,46 @@ static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard)
131
133
devlink_linecard_provision_clear (linecard -> devlink_linecard );
132
134
}
133
135
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
+
134
176
static int mlxsw_linecard_status_process (struct mlxsw_linecards * linecards ,
135
177
struct mlxsw_linecard * linecard ,
136
178
const char * mddq_pl )
@@ -164,6 +206,25 @@ static int mlxsw_linecard_status_process(struct mlxsw_linecards *linecards,
164
206
goto out ;
165
207
}
166
208
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
+
167
228
if (!provisioned && linecard -> provisioned != provisioned )
168
229
mlxsw_linecard_provision_clear (linecard );
169
230
@@ -676,6 +737,8 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,
676
737
cancel_delayed_work_sync (& linecard -> status_event_to_dw );
677
738
/* Make sure all scheduled events are processed */
678
739
mlxsw_core_flush_owq ();
740
+ if (linecard -> active )
741
+ mlxsw_linecard_active_clear (linecard );
679
742
devlink_linecard_destroy (linecard -> devlink_linecard );
680
743
mutex_destroy (& linecard -> lock );
681
744
}
0 commit comments