66
77struct ixgbe_info_ctx {
88 char buf [128 ];
9+ struct ixgbe_orom_info pending_orom ;
10+ struct ixgbe_nvm_info pending_nvm ;
11+ struct ixgbe_netlist_info pending_netlist ;
12+ struct ixgbe_hw_dev_caps dev_caps ;
13+ };
14+
15+ enum ixgbe_devlink_version_type {
16+ IXGBE_DL_VERSION_RUNNING ,
17+ IXGBE_DL_VERSION_STORED
918};
1019
1120static void ixgbe_info_get_dsn (struct ixgbe_adapter * adapter ,
@@ -20,7 +29,8 @@ static void ixgbe_info_get_dsn(struct ixgbe_adapter *adapter,
2029}
2130
2231static void ixgbe_info_orom_ver (struct ixgbe_adapter * adapter ,
23- struct ixgbe_info_ctx * ctx )
32+ struct ixgbe_info_ctx * ctx ,
33+ enum ixgbe_devlink_version_type type )
2434{
2535 struct ixgbe_hw * hw = & adapter -> hw ;
2636 struct ixgbe_nvm_version nvm_ver ;
@@ -30,6 +40,10 @@ static void ixgbe_info_orom_ver(struct ixgbe_adapter *adapter,
3040 if (hw -> mac .type == ixgbe_mac_e610 ) {
3141 struct ixgbe_orom_info * orom = & adapter -> hw .flash .orom ;
3242
43+ if (type == IXGBE_DL_VERSION_STORED &&
44+ ctx -> dev_caps .common_cap .nvm_update_pending_orom )
45+ orom = & ctx -> pending_orom ;
46+
3347 snprintf (ctx -> buf , sizeof (ctx -> buf ), "%u.%u.%u" ,
3448 orom -> major , orom -> build , orom -> patch );
3549 return ;
@@ -51,14 +65,20 @@ static void ixgbe_info_orom_ver(struct ixgbe_adapter *adapter,
5165}
5266
5367static void ixgbe_info_eetrack (struct ixgbe_adapter * adapter ,
54- struct ixgbe_info_ctx * ctx )
68+ struct ixgbe_info_ctx * ctx ,
69+ enum ixgbe_devlink_version_type type )
5570{
5671 struct ixgbe_hw * hw = & adapter -> hw ;
5772 struct ixgbe_nvm_version nvm_ver ;
5873
5974 if (hw -> mac .type == ixgbe_mac_e610 ) {
60- snprintf (ctx -> buf , sizeof (ctx -> buf ), "0x%08x" ,
61- hw -> flash .nvm .eetrack );
75+ u32 eetrack = hw -> flash .nvm .eetrack ;
76+
77+ if (type == IXGBE_DL_VERSION_STORED &&
78+ ctx -> dev_caps .common_cap .nvm_update_pending_nvm )
79+ eetrack = ctx -> pending_nvm .eetrack ;
80+
81+ snprintf (ctx -> buf , sizeof (ctx -> buf ), "0x%08x" , eetrack );
6282 return ;
6383 }
6484
@@ -92,34 +112,54 @@ static void ixgbe_info_fw_build(struct ixgbe_adapter *adapter,
92112}
93113
94114static void ixgbe_info_fw_srev (struct ixgbe_adapter * adapter ,
95- struct ixgbe_info_ctx * ctx )
115+ struct ixgbe_info_ctx * ctx ,
116+ enum ixgbe_devlink_version_type type )
96117{
97118 struct ixgbe_nvm_info * nvm = & adapter -> hw .flash .nvm ;
98119
120+ if (type == IXGBE_DL_VERSION_STORED &&
121+ ctx -> dev_caps .common_cap .nvm_update_pending_nvm )
122+ nvm = & ctx -> pending_nvm ;
123+
99124 snprintf (ctx -> buf , sizeof (ctx -> buf ), "%u" , nvm -> srev );
100125}
101126
102127static void ixgbe_info_orom_srev (struct ixgbe_adapter * adapter ,
103- struct ixgbe_info_ctx * ctx )
128+ struct ixgbe_info_ctx * ctx ,
129+ enum ixgbe_devlink_version_type type )
104130{
105131 struct ixgbe_orom_info * orom = & adapter -> hw .flash .orom ;
106132
133+ if (type == IXGBE_DL_VERSION_STORED &&
134+ ctx -> dev_caps .common_cap .nvm_update_pending_orom )
135+ orom = & ctx -> pending_orom ;
136+
107137 snprintf (ctx -> buf , sizeof (ctx -> buf ), "%u" , orom -> srev );
108138}
109139
110140static void ixgbe_info_nvm_ver (struct ixgbe_adapter * adapter ,
111- struct ixgbe_info_ctx * ctx )
141+ struct ixgbe_info_ctx * ctx ,
142+ enum ixgbe_devlink_version_type type )
112143{
113144 struct ixgbe_nvm_info * nvm = & adapter -> hw .flash .nvm ;
114145
146+ if (type == IXGBE_DL_VERSION_STORED &&
147+ ctx -> dev_caps .common_cap .nvm_update_pending_nvm )
148+ nvm = & ctx -> pending_nvm ;
149+
115150 snprintf (ctx -> buf , sizeof (ctx -> buf ), "%x.%02x" , nvm -> major , nvm -> minor );
116151}
117152
118153static void ixgbe_info_netlist_ver (struct ixgbe_adapter * adapter ,
119- struct ixgbe_info_ctx * ctx )
154+ struct ixgbe_info_ctx * ctx ,
155+ enum ixgbe_devlink_version_type type )
120156{
121157 struct ixgbe_netlist_info * netlist = & adapter -> hw .flash .netlist ;
122158
159+ if (type == IXGBE_DL_VERSION_STORED &&
160+ ctx -> dev_caps .common_cap .nvm_update_pending_netlist )
161+ netlist = & ctx -> pending_netlist ;
162+
123163 /* The netlist version fields are BCD formatted */
124164 snprintf (ctx -> buf , sizeof (ctx -> buf ), "%x.%x.%x-%x.%x.%x" ,
125165 netlist -> major , netlist -> minor ,
@@ -128,13 +168,57 @@ static void ixgbe_info_netlist_ver(struct ixgbe_adapter *adapter,
128168}
129169
130170static void ixgbe_info_netlist_build (struct ixgbe_adapter * adapter ,
131- struct ixgbe_info_ctx * ctx )
171+ struct ixgbe_info_ctx * ctx ,
172+ enum ixgbe_devlink_version_type type )
132173{
133174 struct ixgbe_netlist_info * netlist = & adapter -> hw .flash .netlist ;
134175
176+ if (type == IXGBE_DL_VERSION_STORED &&
177+ ctx -> dev_caps .common_cap .nvm_update_pending_netlist )
178+ netlist = & ctx -> pending_netlist ;
179+
135180 snprintf (ctx -> buf , sizeof (ctx -> buf ), "0x%08x" , netlist -> hash );
136181}
137182
183+ static int ixgbe_set_ctx_dev_caps (struct ixgbe_hw * hw ,
184+ struct ixgbe_info_ctx * ctx ,
185+ struct netlink_ext_ack * extack )
186+ {
187+ bool * pending_orom , * pending_nvm , * pending_netlist ;
188+ int err ;
189+
190+ err = ixgbe_discover_dev_caps (hw , & ctx -> dev_caps );
191+ if (err ) {
192+ NL_SET_ERR_MSG_MOD (extack ,
193+ "Unable to discover device capabilities" );
194+ return err ;
195+ }
196+
197+ pending_orom = & ctx -> dev_caps .common_cap .nvm_update_pending_orom ;
198+ pending_nvm = & ctx -> dev_caps .common_cap .nvm_update_pending_nvm ;
199+ pending_netlist = & ctx -> dev_caps .common_cap .nvm_update_pending_netlist ;
200+
201+ if (* pending_orom ) {
202+ err = ixgbe_get_inactive_orom_ver (hw , & ctx -> pending_orom );
203+ if (err )
204+ * pending_orom = false;
205+ }
206+
207+ if (* pending_nvm ) {
208+ err = ixgbe_get_inactive_nvm_ver (hw , & ctx -> pending_nvm );
209+ if (err )
210+ * pending_nvm = false;
211+ }
212+
213+ if (* pending_netlist ) {
214+ err = ixgbe_get_inactive_netlist_ver (hw , & ctx -> pending_netlist );
215+ if (err )
216+ * pending_netlist = false;
217+ }
218+
219+ return 0 ;
220+ }
221+
138222static int ixgbe_devlink_info_get_e610 (struct ixgbe_adapter * adapter ,
139223 struct devlink_info_req * req ,
140224 struct ixgbe_info_ctx * ctx )
@@ -153,31 +237,77 @@ static int ixgbe_devlink_info_get_e610(struct ixgbe_adapter *adapter,
153237 if (err )
154238 return err ;
155239
156- ixgbe_info_fw_srev (adapter , ctx );
240+ ixgbe_info_fw_srev (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
157241 err = devlink_info_version_running_put (req , "fw.mgmt.srev" , ctx -> buf );
158242 if (err )
159243 return err ;
160244
161- ixgbe_info_orom_srev (adapter , ctx );
245+ ixgbe_info_orom_srev (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
162246 err = devlink_info_version_running_put (req , "fw.undi.srev" , ctx -> buf );
163247 if (err )
164248 return err ;
165249
166- ixgbe_info_nvm_ver (adapter , ctx );
250+ ixgbe_info_nvm_ver (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
167251 err = devlink_info_version_running_put (req , "fw.psid.api" , ctx -> buf );
168252 if (err )
169253 return err ;
170254
171- ixgbe_info_netlist_ver (adapter , ctx );
255+ ixgbe_info_netlist_ver (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
172256 err = devlink_info_version_running_put (req , "fw.netlist" , ctx -> buf );
173257 if (err )
174258 return err ;
175259
176- ixgbe_info_netlist_build (adapter , ctx );
260+ ixgbe_info_netlist_build (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
177261 return devlink_info_version_running_put (req , "fw.netlist.build" ,
178262 ctx -> buf );
179263}
180264
265+ static int
266+ ixgbe_devlink_pending_info_get_e610 (struct ixgbe_adapter * adapter ,
267+ struct devlink_info_req * req ,
268+ struct ixgbe_info_ctx * ctx )
269+ {
270+ int err ;
271+
272+ ixgbe_info_orom_ver (adapter , ctx , IXGBE_DL_VERSION_STORED );
273+ err = devlink_info_version_stored_put (req ,
274+ DEVLINK_INFO_VERSION_GENERIC_FW_UNDI ,
275+ ctx -> buf );
276+ if (err )
277+ return err ;
278+
279+ ixgbe_info_eetrack (adapter , ctx , IXGBE_DL_VERSION_STORED );
280+ err = devlink_info_version_stored_put (req ,
281+ DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID ,
282+ ctx -> buf );
283+ if (err )
284+ return err ;
285+
286+ ixgbe_info_fw_srev (adapter , ctx , IXGBE_DL_VERSION_STORED );
287+ err = devlink_info_version_stored_put (req , "fw.mgmt.srev" , ctx -> buf );
288+ if (err )
289+ return err ;
290+
291+ ixgbe_info_orom_srev (adapter , ctx , IXGBE_DL_VERSION_STORED );
292+ err = devlink_info_version_stored_put (req , "fw.undi.srev" , ctx -> buf );
293+ if (err )
294+ return err ;
295+
296+ ixgbe_info_nvm_ver (adapter , ctx , IXGBE_DL_VERSION_STORED );
297+ err = devlink_info_version_stored_put (req , "fw.psid.api" , ctx -> buf );
298+ if (err )
299+ return err ;
300+
301+ ixgbe_info_netlist_ver (adapter , ctx , IXGBE_DL_VERSION_STORED );
302+ err = devlink_info_version_stored_put (req , "fw.netlist" , ctx -> buf );
303+ if (err )
304+ return err ;
305+
306+ ixgbe_info_netlist_build (adapter , ctx , IXGBE_DL_VERSION_STORED );
307+ return devlink_info_version_stored_put (req , "fw.netlist.build" ,
308+ ctx -> buf );
309+ }
310+
181311static int ixgbe_devlink_info_get (struct devlink * devlink ,
182312 struct devlink_info_req * req ,
183313 struct netlink_ext_ack * extack )
@@ -206,21 +336,29 @@ static int ixgbe_devlink_info_get(struct devlink *devlink,
206336 if (err )
207337 goto free_ctx ;
208338
209- ixgbe_info_orom_ver (adapter , ctx );
339+ ixgbe_info_orom_ver (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
210340 err = devlink_info_version_running_put (req ,
211341 DEVLINK_INFO_VERSION_GENERIC_FW_UNDI ,
212342 ctx -> buf );
213343 if (err )
214344 goto free_ctx ;
215345
216- ixgbe_info_eetrack (adapter , ctx );
346+ ixgbe_info_eetrack (adapter , ctx , IXGBE_DL_VERSION_RUNNING );
217347 err = devlink_info_version_running_put (req ,
218348 DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID ,
219349 ctx -> buf );
220350 if (err || hw -> mac .type != ixgbe_mac_e610 )
221351 goto free_ctx ;
222352
353+ err = ixgbe_set_ctx_dev_caps (hw , ctx , extack );
354+ if (err )
355+ goto free_ctx ;
356+
223357 err = ixgbe_devlink_info_get_e610 (adapter , req , ctx );
358+ if (err )
359+ goto free_ctx ;
360+
361+ err = ixgbe_devlink_pending_info_get_e610 (adapter , req , ctx );
224362free_ctx :
225363 kfree (ctx );
226364 return err ;
0 commit comments