Skip to content

Commit ff2e5c7

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
ice: add basic handler for devlink .info_get
The devlink .info_get callback allows the driver to report detailed version information. The following devlink versions are reported with this initial implementation: "fw.mgmt" -> The version of the firmware that controls PHY, link, etc "fw.mgmt.api" -> API version of interface exposed over the AdminQ "fw.mgmt.build" -> Unique build id of the source for the management fw "fw.undi" -> Version of the Option ROM containing the UEFI driver "fw.psid.api" -> Version of the NVM image format. "fw.bundle_id" -> Unique identifier for the combined flash image. "fw.app.name" -> The name of the active DDP package. "fw.app" -> The version of the active DDP package. With this, devlink dev info can report at least as much information as is reported by ETHTOOL_GDRVINFO. Compare the output from ethtool vs from devlink: $ ethtool -i ens785s0 driver: ice version: 0.8.1-k firmware-version: 0.80 0x80002ec0 1.2581.0 expansion-rom-version: bus-info: 0000:3b:00.0 supports-statistics: yes supports-test: yes supports-eeprom-access: yes supports-register-dump: yes supports-priv-flags: yes $ devlink dev info pci/0000:3b:00.0 pci/0000:3b:00.0: driver ice serial number 00-01-ab-ff-ff-ca-05-68 versions: running: fw.mgmt 2.1.7 fw.mgmt.api 1.5 fw.mgmt.build 0x305d955f fw.undi 1.2581.0 fw.psid.api 0.80 fw.bundle_id 0x80002ec0 fw.app.name ICE OS Default Package fw.app 1.3.1.0 More pieces of information can be displayed, each version is kept separate instead of munged together, and each version has an identifier which comes with associated documentation. Signed-off-by: Jacob Keller <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent c90977a commit ff2e5c7

File tree

3 files changed

+257
-0
lines changed

3 files changed

+257
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
===================
4+
ice devlink support
5+
===================
6+
7+
This document describes the devlink features implemented by the ``ice``
8+
device driver.
9+
10+
Info versions
11+
=============
12+
13+
The ``ice`` driver reports the following versions
14+
15+
.. list-table:: devlink info versions implemented
16+
:widths: 5 5 5 90
17+
18+
* - Name
19+
- Type
20+
- Example
21+
- Description
22+
* - ``fw.mgmt``
23+
- running
24+
- 2.1.7
25+
- 3-digit version number of the management firmware that controls the
26+
PHY, link, etc.
27+
* - ``fw.mgmt.api``
28+
- running
29+
- 1.5
30+
- 2-digit version number of the API exported over the AdminQ by the
31+
management firmware. Used by the driver to identify what commands
32+
are supported.
33+
* - ``fw.mgmt.build``
34+
- running
35+
- 0x305d955f
36+
- Unique identifier of the source for the management firmware.
37+
* - ``fw.undi``
38+
- running
39+
- 1.2581.0
40+
- Version of the Option ROM containing the UEFI driver. The version is
41+
reported in ``major.minor.patch`` format. The major version is
42+
incremented whenever a major breaking change occurs, or when the
43+
minor version would overflow. The minor version is incremented for
44+
non-breaking changes and reset to 1 when the major version is
45+
incremented. The patch version is normally 0 but is incremented when
46+
a fix is delivered as a patch against an older base Option ROM.
47+
* - ``fw.psid.api``
48+
- running
49+
- 0.80
50+
- Version defining the format of the flash contents.
51+
* - ``fw.bundle_id``
52+
- running
53+
- 0x80002ec0
54+
- Unique identifier of the firmware image file that was loaded onto
55+
the device. Also referred to as the EETRACK identifier of the NVM.
56+
* - ``fw.app.name``
57+
- running
58+
- ICE OS Default Package
59+
- The name of the DDP package that is active in the device. The DDP
60+
package is loaded by the driver during initialization. Each varation
61+
of DDP package shall have a unique name.
62+
* - ``fw.app``
63+
- running
64+
- 1.3.1.0
65+
- The version of the DDP package that is active in the device. Note
66+
that both the name (as reported by ``fw.app.name``) and version are
67+
required to uniquely identify the package.

Documentation/networking/devlink/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ parameters, info versions, and other features it supports.
3232

3333
bnxt
3434
ionic
35+
ice
3536
mlx4
3637
mlx5
3738
mlxsw

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

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,198 @@
22
/* Copyright (c) 2020, Intel Corporation. */
33

44
#include "ice.h"
5+
#include "ice_lib.h"
56
#include "ice_devlink.h"
67

8+
static int ice_info_get_dsn(struct ice_pf *pf, char *buf, size_t len)
9+
{
10+
u8 dsn[8];
11+
12+
/* Copy the DSN into an array in Big Endian format */
13+
put_unaligned_be64(pci_get_dsn(pf->pdev), dsn);
14+
15+
snprintf(buf, len, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
16+
dsn[0], dsn[1], dsn[2], dsn[3],
17+
dsn[4], dsn[5], dsn[6], dsn[7]);
18+
19+
return 0;
20+
}
21+
22+
static int ice_info_fw_mgmt(struct ice_pf *pf, char *buf, size_t len)
23+
{
24+
struct ice_hw *hw = &pf->hw;
25+
26+
snprintf(buf, len, "%u.%u.%u", hw->fw_maj_ver, hw->fw_min_ver,
27+
hw->fw_patch);
28+
29+
return 0;
30+
}
31+
32+
static int ice_info_fw_api(struct ice_pf *pf, char *buf, size_t len)
33+
{
34+
struct ice_hw *hw = &pf->hw;
35+
36+
snprintf(buf, len, "%u.%u", hw->api_maj_ver, hw->api_min_ver);
37+
38+
return 0;
39+
}
40+
41+
static int ice_info_fw_build(struct ice_pf *pf, char *buf, size_t len)
42+
{
43+
struct ice_hw *hw = &pf->hw;
44+
45+
snprintf(buf, len, "0x%08x", hw->fw_build);
46+
47+
return 0;
48+
}
49+
50+
static int ice_info_orom_ver(struct ice_pf *pf, char *buf, size_t len)
51+
{
52+
struct ice_orom_info *orom = &pf->hw.nvm.orom;
53+
54+
snprintf(buf, len, "%u.%u.%u", orom->major, orom->build, orom->patch);
55+
56+
return 0;
57+
}
58+
59+
static int ice_info_nvm_ver(struct ice_pf *pf, char *buf, size_t len)
60+
{
61+
struct ice_nvm_info *nvm = &pf->hw.nvm;
62+
63+
snprintf(buf, len, "%x.%02x", nvm->major_ver, nvm->minor_ver);
64+
65+
return 0;
66+
}
67+
68+
static int ice_info_eetrack(struct ice_pf *pf, char *buf, size_t len)
69+
{
70+
struct ice_nvm_info *nvm = &pf->hw.nvm;
71+
72+
snprintf(buf, len, "0x%08x", nvm->eetrack);
73+
74+
return 0;
75+
}
76+
77+
static int ice_info_ddp_pkg_name(struct ice_pf *pf, char *buf, size_t len)
78+
{
79+
struct ice_hw *hw = &pf->hw;
80+
81+
snprintf(buf, len, "%s", hw->active_pkg_name);
82+
83+
return 0;
84+
}
85+
86+
static int ice_info_ddp_pkg_version(struct ice_pf *pf, char *buf, size_t len)
87+
{
88+
struct ice_pkg_ver *pkg = &pf->hw.active_pkg_ver;
89+
90+
snprintf(buf, len, "%u.%u.%u.%u", pkg->major, pkg->minor, pkg->update,
91+
pkg->draft);
92+
93+
return 0;
94+
}
95+
96+
#define running(key, getter) { ICE_VERSION_RUNNING, key, getter }
97+
98+
enum ice_version_type {
99+
ICE_VERSION_FIXED,
100+
ICE_VERSION_RUNNING,
101+
ICE_VERSION_STORED,
102+
};
103+
104+
static const struct ice_devlink_version {
105+
enum ice_version_type type;
106+
const char *key;
107+
int (*getter)(struct ice_pf *pf, char *buf, size_t len);
108+
} ice_devlink_versions[] = {
109+
running(DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, ice_info_fw_mgmt),
110+
running("fw.mgmt.api", ice_info_fw_api),
111+
running("fw.mgmt.build", ice_info_fw_build),
112+
running(DEVLINK_INFO_VERSION_GENERIC_FW_UNDI, ice_info_orom_ver),
113+
running("fw.psid.api", ice_info_nvm_ver),
114+
running(DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID, ice_info_eetrack),
115+
running("fw.app.name", ice_info_ddp_pkg_name),
116+
running(DEVLINK_INFO_VERSION_GENERIC_FW_APP, ice_info_ddp_pkg_version),
117+
};
118+
119+
/**
120+
* ice_devlink_info_get - .info_get devlink handler
121+
* @devlink: devlink instance structure
122+
* @req: the devlink info request
123+
* @extack: extended netdev ack structure
124+
*
125+
* Callback for the devlink .info_get operation. Reports information about the
126+
* device.
127+
*
128+
* @returns zero on success or an error code on failure.
129+
*/
130+
static int ice_devlink_info_get(struct devlink *devlink,
131+
struct devlink_info_req *req,
132+
struct netlink_ext_ack *extack)
133+
{
134+
struct ice_pf *pf = devlink_priv(devlink);
135+
char buf[100];
136+
size_t i;
137+
int err;
138+
139+
err = devlink_info_driver_name_put(req, KBUILD_MODNAME);
140+
if (err) {
141+
NL_SET_ERR_MSG_MOD(extack, "Unable to set driver name");
142+
return err;
143+
}
144+
145+
err = ice_info_get_dsn(pf, buf, sizeof(buf));
146+
if (err) {
147+
NL_SET_ERR_MSG_MOD(extack, "Unable to obtain serial number");
148+
return err;
149+
}
150+
151+
err = devlink_info_serial_number_put(req, buf);
152+
if (err) {
153+
NL_SET_ERR_MSG_MOD(extack, "Unable to set serial number");
154+
return err;
155+
}
156+
157+
for (i = 0; i < ARRAY_SIZE(ice_devlink_versions); i++) {
158+
enum ice_version_type type = ice_devlink_versions[i].type;
159+
const char *key = ice_devlink_versions[i].key;
160+
161+
err = ice_devlink_versions[i].getter(pf, buf, sizeof(buf));
162+
if (err) {
163+
NL_SET_ERR_MSG_MOD(extack, "Unable to obtain version info");
164+
return err;
165+
}
166+
167+
switch (type) {
168+
case ICE_VERSION_FIXED:
169+
err = devlink_info_version_fixed_put(req, key, buf);
170+
if (err) {
171+
NL_SET_ERR_MSG_MOD(extack, "Unable to set fixed version");
172+
return err;
173+
}
174+
break;
175+
case ICE_VERSION_RUNNING:
176+
err = devlink_info_version_running_put(req, key, buf);
177+
if (err) {
178+
NL_SET_ERR_MSG_MOD(extack, "Unable to set running version");
179+
return err;
180+
}
181+
break;
182+
case ICE_VERSION_STORED:
183+
err = devlink_info_version_stored_put(req, key, buf);
184+
if (err) {
185+
NL_SET_ERR_MSG_MOD(extack, "Unable to set stored version");
186+
return err;
187+
}
188+
break;
189+
}
190+
}
191+
192+
return 0;
193+
}
194+
7195
static const struct devlink_ops ice_devlink_ops = {
196+
.info_get = ice_devlink_info_get,
8197
};
9198

10199
static void ice_devlink_free(void *devlink_ptr)

0 commit comments

Comments
 (0)