Skip to content

Commit 6eae2ae

Browse files
jjagielskanguy11
authored andcommitted
ixgbe: extend .info_get() with stored versions
Add functions reading inactive versions from the inactive flash bank. Print stored versions for the content present in the inactive bank. If there's pending update the versions reflect the ones which are going to be loaded after reload. If there's no pending update both running and stored are the same, which means there won't be any NVM change on reload. Co-developed-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com> Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com> Co-developed-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com> Signed-off-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com> Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 4654ec6 commit 6eae2ae

File tree

3 files changed

+218
-16
lines changed

3 files changed

+218
-16
lines changed

drivers/net/ethernet/intel/ixgbe/devlink/devlink.c

Lines changed: 154 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
struct 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

1120
static 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

2231
static 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

5367
static 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

94114
static 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

102127
static 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

110140
static 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

118153
static 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

130170
static 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+
138222
static 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+
181311
static 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);
224362
free_ctx:
225363
kfree(ctx);
226364
return err;

drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,15 @@ static bool ixgbe_parse_e610_caps(struct ixgbe_hw *hw,
588588
break;
589589
case IXGBE_ACI_CAPS_NVM_VER:
590590
break;
591+
case IXGBE_ACI_CAPS_PENDING_NVM_VER:
592+
caps->nvm_update_pending_nvm = true;
593+
break;
594+
case IXGBE_ACI_CAPS_PENDING_OROM_VER:
595+
caps->nvm_update_pending_orom = true;
596+
break;
597+
case IXGBE_ACI_CAPS_PENDING_NET_VER:
598+
caps->nvm_update_pending_netlist = true;
599+
break;
591600
case IXGBE_ACI_CAPS_MAX_MTU:
592601
caps->max_mtu = number;
593602
break;
@@ -2932,6 +2941,23 @@ static int ixgbe_get_orom_ver_info(struct ixgbe_hw *hw,
29322941
return ixgbe_get_orom_srev(hw, bank, &orom->srev);
29332942
}
29342943

2944+
/**
2945+
* ixgbe_get_inactive_orom_ver - Read Option ROM version from the inactive bank
2946+
* @hw: pointer to the HW structure
2947+
* @orom: storage for Option ROM version information
2948+
*
2949+
* Read the Option ROM version and security revision data for the inactive
2950+
* section of flash. Used to access version data for a pending update that has
2951+
* not yet been activated.
2952+
*
2953+
* Return: the exit code of the operation.
2954+
*/
2955+
int ixgbe_get_inactive_orom_ver(struct ixgbe_hw *hw,
2956+
struct ixgbe_orom_info *orom)
2957+
{
2958+
return ixgbe_get_orom_ver_info(hw, IXGBE_INACTIVE_FLASH_BANK, orom);
2959+
}
2960+
29352961
/**
29362962
* ixgbe_get_nvm_ver_info - Read NVM version information
29372963
* @hw: pointer to the HW struct
@@ -2975,6 +3001,22 @@ static int ixgbe_get_nvm_ver_info(struct ixgbe_hw *hw,
29753001
return 0;
29763002
}
29773003

3004+
/**
3005+
* ixgbe_get_inactive_nvm_ver - Read Option ROM version from the inactive bank
3006+
* @hw: pointer to the HW structure
3007+
* @nvm: storage for Option ROM version information
3008+
*
3009+
* Read the NVM EETRACK ID, Map version, and security revision of the
3010+
* inactive NVM bank. Used to access version data for a pending update that
3011+
* has not yet been activated.
3012+
*
3013+
* Return: the exit code of the operation.
3014+
*/
3015+
int ixgbe_get_inactive_nvm_ver(struct ixgbe_hw *hw, struct ixgbe_nvm_info *nvm)
3016+
{
3017+
return ixgbe_get_nvm_ver_info(hw, IXGBE_INACTIVE_FLASH_BANK, nvm);
3018+
}
3019+
29783020
/**
29793021
* ixgbe_get_netlist_info - Read the netlist version information
29803022
* @hw: pointer to the HW struct
@@ -3055,6 +3097,23 @@ static int ixgbe_get_netlist_info(struct ixgbe_hw *hw,
30553097
return err;
30563098
}
30573099

3100+
/**
3101+
* ixgbe_get_inactive_netlist_ver - Read netlist version from the inactive bank
3102+
* @hw: pointer to the HW struct
3103+
* @netlist: pointer to netlist version info structure
3104+
*
3105+
* Read the netlist version data from the inactive netlist bank. Used to
3106+
* extract version data of a pending flash update in order to display the
3107+
* version data.
3108+
*
3109+
* Return: the exit code of the operation.
3110+
*/
3111+
int ixgbe_get_inactive_netlist_ver(struct ixgbe_hw *hw,
3112+
struct ixgbe_netlist_info *netlist)
3113+
{
3114+
return ixgbe_get_netlist_info(hw, IXGBE_INACTIVE_FLASH_BANK, netlist);
3115+
}
3116+
30583117
/**
30593118
* ixgbe_get_flash_data - get flash data
30603119
* @hw: pointer to the HW struct

drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ int ixgbe_aci_read_nvm(struct ixgbe_hw *hw, u16 module_typeid, u32 offset,
6767
u16 length, void *data, bool last_command,
6868
bool read_shadow_ram);
6969
int ixgbe_nvm_validate_checksum(struct ixgbe_hw *hw);
70+
int ixgbe_get_inactive_orom_ver(struct ixgbe_hw *hw,
71+
struct ixgbe_orom_info *orom);
72+
int ixgbe_get_inactive_nvm_ver(struct ixgbe_hw *hw, struct ixgbe_nvm_info *nvm);
73+
int ixgbe_get_inactive_netlist_ver(struct ixgbe_hw *hw,
74+
struct ixgbe_netlist_info *netlist);
7075
int ixgbe_read_sr_word_aci(struct ixgbe_hw *hw, u16 offset, u16 *data);
7176
int ixgbe_read_flat_nvm(struct ixgbe_hw *hw, u32 offset, u32 *length,
7277
u8 *data, bool read_shadow_ram);

0 commit comments

Comments
 (0)