Skip to content

Commit f45a645

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
ice: report netlist version in .info_get
The flash memory for the ice hardware contains a block of information used for link management called the Netlist module. As this essentially represents another section of firmware, add its version information to the output of the driver's .info_get handler. This includes both a version and the first few bytes of a hash of the module contents. fw.netlist -> the version information extracted from the netlist module fw.netlist.build-> first 4 bytes of the hash of the contents, similar to fw.mgmt.build Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 2a330b5 commit f45a645

5 files changed

Lines changed: 158 additions & 0 deletions

File tree

‎Documentation/networking/devlink/ice.rst‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ The ``ice`` driver reports the following versions
6969
- The version of the DDP package that is active in the device. Note
7070
that both the name (as reported by ``fw.app.name``) and version are
7171
required to uniquely identify the package.
72+
* - ``fw.netlist``
73+
- running
74+
- 1.1.2000-6.7.0
75+
- The version of the netlist module. This module defines the device's
76+
Ethernet capabilities and default settings, and is used by the
77+
management firmware as part of managing link and device
78+
connectivity.
79+
* - ``fw.netlist.build``
80+
- running
81+
- 0xee16ced7
82+
- The first 4 bytes of the hash of the netlist module contents.
7283

7384
Regions
7485
=======

‎drivers/net/ethernet/intel/ice/ice_adminq_cmd.h‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,33 @@ struct ice_aqc_nvm_checksum {
12641264
u8 rsvd2[12];
12651265
};
12661266

1267+
/* The result of netlist NVM read comes in a TLV format. The actual data
1268+
* (netlist header) starts from word offset 1 (byte 2). The FW strips
1269+
* out the type field from the TLV header so all the netlist fields
1270+
* should adjust their offset value by 1 word (2 bytes) in order to map
1271+
* their correct location.
1272+
*/
1273+
#define ICE_AQC_NVM_LINK_TOPO_NETLIST_MOD_ID 0x11B
1274+
#define ICE_AQC_NVM_LINK_TOPO_NETLIST_LEN_OFFSET 1
1275+
#define ICE_AQC_NVM_LINK_TOPO_NETLIST_LEN 2 /* In bytes */
1276+
#define ICE_AQC_NVM_NETLIST_NODE_COUNT_OFFSET 2
1277+
#define ICE_AQC_NVM_NETLIST_NODE_COUNT_LEN 2 /* In bytes */
1278+
#define ICE_AQC_NVM_NETLIST_NODE_COUNT_M ICE_M(0x3FF, 0)
1279+
#define ICE_AQC_NVM_NETLIST_ID_BLK_START_OFFSET 5
1280+
#define ICE_AQC_NVM_NETLIST_ID_BLK_LEN 0x30 /* In words */
1281+
1282+
/* netlist ID block field offsets (word offsets) */
1283+
#define ICE_AQC_NVM_NETLIST_ID_BLK_MAJOR_VER_LOW 2
1284+
#define ICE_AQC_NVM_NETLIST_ID_BLK_MAJOR_VER_HIGH 3
1285+
#define ICE_AQC_NVM_NETLIST_ID_BLK_MINOR_VER_LOW 4
1286+
#define ICE_AQC_NVM_NETLIST_ID_BLK_MINOR_VER_HIGH 5
1287+
#define ICE_AQC_NVM_NETLIST_ID_BLK_TYPE_LOW 6
1288+
#define ICE_AQC_NVM_NETLIST_ID_BLK_TYPE_HIGH 7
1289+
#define ICE_AQC_NVM_NETLIST_ID_BLK_REV_LOW 8
1290+
#define ICE_AQC_NVM_NETLIST_ID_BLK_REV_HIGH 9
1291+
#define ICE_AQC_NVM_NETLIST_ID_BLK_SHA_HASH 0xA
1292+
#define ICE_AQC_NVM_NETLIST_ID_BLK_CUST_VER 0x2F
1293+
12671294
/**
12681295
* Send to PF command (indirect 0x0801) ID is only used by PF
12691296
*

‎drivers/net/ethernet/intel/ice/ice_devlink.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ static int ice_info_ddp_pkg_version(struct ice_pf *pf, char *buf, size_t len)
105105
return 0;
106106
}
107107

108+
static int ice_info_netlist_ver(struct ice_pf *pf, char *buf, size_t len)
109+
{
110+
struct ice_netlist_ver_info *netlist = &pf->hw.netlist_ver;
111+
112+
/* The netlist version fields are BCD formatted */
113+
snprintf(buf, len, "%x.%x.%x-%x.%x.%x", netlist->major, netlist->minor,
114+
netlist->type >> 16, netlist->type & 0xFFFF, netlist->rev,
115+
netlist->cust_ver);
116+
117+
return 0;
118+
}
119+
120+
static int ice_info_netlist_build(struct ice_pf *pf, char *buf, size_t len)
121+
{
122+
struct ice_netlist_ver_info *netlist = &pf->hw.netlist_ver;
123+
124+
snprintf(buf, len, "0x%08x", netlist->hash);
125+
126+
return 0;
127+
}
128+
108129
#define fixed(key, getter) { ICE_VERSION_FIXED, key, getter }
109130
#define running(key, getter) { ICE_VERSION_RUNNING, key, getter }
110131

@@ -128,6 +149,8 @@ static const struct ice_devlink_version {
128149
running(DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID, ice_info_eetrack),
129150
running("fw.app.name", ice_info_ddp_pkg_name),
130151
running(DEVLINK_INFO_VERSION_GENERIC_FW_APP, ice_info_ddp_pkg_version),
152+
running("fw.netlist", ice_info_netlist_ver),
153+
running("fw.netlist.build", ice_info_netlist_build),
131154
};
132155

133156
/**

‎drivers/net/ethernet/intel/ice/ice_nvm.c‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,87 @@ static enum ice_status ice_get_orom_ver_info(struct ice_hw *hw)
366366
return 0;
367367
}
368368

369+
/**
370+
* ice_get_netlist_ver_info
371+
* @hw: pointer to the HW struct
372+
*
373+
* Get the netlist version information
374+
*/
375+
static enum ice_status ice_get_netlist_ver_info(struct ice_hw *hw)
376+
{
377+
struct ice_netlist_ver_info *ver = &hw->netlist_ver;
378+
enum ice_status ret;
379+
u32 id_blk_start;
380+
__le16 raw_data;
381+
u16 data, i;
382+
u16 *buff;
383+
384+
ret = ice_acquire_nvm(hw, ICE_RES_READ);
385+
if (ret)
386+
return ret;
387+
buff = kcalloc(ICE_AQC_NVM_NETLIST_ID_BLK_LEN, sizeof(*buff),
388+
GFP_KERNEL);
389+
if (!buff) {
390+
ret = ICE_ERR_NO_MEMORY;
391+
goto exit_no_mem;
392+
}
393+
394+
/* read module length */
395+
ret = ice_aq_read_nvm(hw, ICE_AQC_NVM_LINK_TOPO_NETLIST_MOD_ID,
396+
ICE_AQC_NVM_LINK_TOPO_NETLIST_LEN_OFFSET * 2,
397+
ICE_AQC_NVM_LINK_TOPO_NETLIST_LEN, &raw_data,
398+
false, false, NULL);
399+
if (ret)
400+
goto exit_error;
401+
402+
data = le16_to_cpu(raw_data);
403+
/* exit if length is = 0 */
404+
if (!data)
405+
goto exit_error;
406+
407+
/* read node count */
408+
ret = ice_aq_read_nvm(hw, ICE_AQC_NVM_LINK_TOPO_NETLIST_MOD_ID,
409+
ICE_AQC_NVM_NETLIST_NODE_COUNT_OFFSET * 2,
410+
ICE_AQC_NVM_NETLIST_NODE_COUNT_LEN, &raw_data,
411+
false, false, NULL);
412+
if (ret)
413+
goto exit_error;
414+
data = le16_to_cpu(raw_data) & ICE_AQC_NVM_NETLIST_NODE_COUNT_M;
415+
416+
/* netlist ID block starts from offset 4 + node count * 2 */
417+
id_blk_start = ICE_AQC_NVM_NETLIST_ID_BLK_START_OFFSET + data * 2;
418+
419+
/* read the entire netlist ID block */
420+
ret = ice_aq_read_nvm(hw, ICE_AQC_NVM_LINK_TOPO_NETLIST_MOD_ID,
421+
id_blk_start * 2,
422+
ICE_AQC_NVM_NETLIST_ID_BLK_LEN * 2, buff, false,
423+
false, NULL);
424+
if (ret)
425+
goto exit_error;
426+
427+
for (i = 0; i < ICE_AQC_NVM_NETLIST_ID_BLK_LEN; i++)
428+
buff[i] = le16_to_cpu(((__force __le16 *)buff)[i]);
429+
430+
ver->major = (buff[ICE_AQC_NVM_NETLIST_ID_BLK_MAJOR_VER_HIGH] << 16) |
431+
buff[ICE_AQC_NVM_NETLIST_ID_BLK_MAJOR_VER_LOW];
432+
ver->minor = (buff[ICE_AQC_NVM_NETLIST_ID_BLK_MINOR_VER_HIGH] << 16) |
433+
buff[ICE_AQC_NVM_NETLIST_ID_BLK_MINOR_VER_LOW];
434+
ver->type = (buff[ICE_AQC_NVM_NETLIST_ID_BLK_TYPE_HIGH] << 16) |
435+
buff[ICE_AQC_NVM_NETLIST_ID_BLK_TYPE_LOW];
436+
ver->rev = (buff[ICE_AQC_NVM_NETLIST_ID_BLK_REV_HIGH] << 16) |
437+
buff[ICE_AQC_NVM_NETLIST_ID_BLK_REV_LOW];
438+
ver->cust_ver = buff[ICE_AQC_NVM_NETLIST_ID_BLK_CUST_VER];
439+
/* Read the left most 4 bytes of SHA */
440+
ver->hash = buff[ICE_AQC_NVM_NETLIST_ID_BLK_SHA_HASH + 15] << 16 |
441+
buff[ICE_AQC_NVM_NETLIST_ID_BLK_SHA_HASH + 14];
442+
443+
exit_error:
444+
kfree(buff);
445+
exit_no_mem:
446+
ice_release_nvm(hw);
447+
return ret;
448+
}
449+
369450
/**
370451
* ice_discover_flash_size - Discover the available flash size.
371452
* @hw: pointer to the HW struct
@@ -515,6 +596,11 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)
515596
return status;
516597
}
517598

599+
/* read the netlist version information */
600+
status = ice_get_netlist_ver_info(hw);
601+
if (status)
602+
ice_debug(hw, ICE_DBG_INIT, "Failed to read netlist info.\n");
603+
518604
return 0;
519605
}
520606

‎drivers/net/ethernet/intel/ice/ice_type.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ struct ice_nvm_info {
259259

260260
#define ICE_NVM_VER_LEN 32
261261

262+
/* netlist version information */
263+
struct ice_netlist_ver_info {
264+
u32 major; /* major high/low */
265+
u32 minor; /* minor high/low */
266+
u32 type; /* type high/low */
267+
u32 rev; /* revision high/low */
268+
u32 hash; /* SHA-1 hash word */
269+
u16 cust_ver; /* customer version */
270+
};
271+
262272
/* Max number of port to queue branches w.r.t topology */
263273
#define ICE_MAX_TRAFFIC_CLASS 8
264274
#define ICE_TXSCHED_MAX_BRANCHES ICE_MAX_TRAFFIC_CLASS
@@ -506,6 +516,7 @@ struct ice_hw {
506516
struct ice_nvm_info nvm;
507517
struct ice_hw_dev_caps dev_caps; /* device capabilities */
508518
struct ice_hw_func_caps func_caps; /* function capabilities */
519+
struct ice_netlist_ver_info netlist_ver; /* netlist version info */
509520

510521
struct ice_switch_info *switch_info; /* switch filter lists */
511522

0 commit comments

Comments
 (0)