devlink: Add support for board.serial_number to info_get cb.

Board serial number is a serial number, often available in PCI
*Vital Product Data*.

Also, update devlink-info.rst documentation file.

Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vasundhara Volam 2020-06-20 22:01:56 +05:30 committed by David S. Miller
parent 406fcb5bae
commit b5872cd0e8
4 changed files with 17 additions and 7 deletions

View File

@ -44,9 +44,11 @@ versions is generally discouraged - here, and via any other Linux API.
reported for two ports of the same device or on two hosts of reported for two ports of the same device or on two hosts of
a multi-host device should be identical. a multi-host device should be identical.
.. note:: ``devlink-info`` API should be extended with a new field * - ``board.serial_number``
if devices want to report board/product serial number (often - Board serial number of the device.
reported in PCI *Vital Product Data* capability).
This is usually the serial number of the board, often available in
PCI *Vital Product Data*.
* - ``fixed`` * - ``fixed``
- Group for hardware identifiers, and versions of components - Group for hardware identifiers, and versions of components
@ -201,10 +203,6 @@ Future work
The following extensions could be useful: The following extensions could be useful:
- product serial number - NIC boards often get labeled with a board serial
number rather than ASIC serial number; it'd be useful to add board serial
numbers to the API if they can be retrieved from the device;
- on-disk firmware file names - drivers list the file names of firmware they - on-disk firmware file names - drivers list the file names of firmware they
may need to load onto devices via the ``MODULE_FIRMWARE()`` macro. These, may need to load onto devices via the ``MODULE_FIRMWARE()`` macro. These,
however, are per module, rather than per device. It'd be useful to list however, are per module, rather than per device. It'd be useful to list

View File

@ -1284,6 +1284,8 @@ int devlink_info_serial_number_put(struct devlink_info_req *req,
const char *sn); const char *sn);
int devlink_info_driver_name_put(struct devlink_info_req *req, int devlink_info_driver_name_put(struct devlink_info_req *req,
const char *name); const char *name);
int devlink_info_board_serial_number_put(struct devlink_info_req *req,
const char *bsn);
int devlink_info_version_fixed_put(struct devlink_info_req *req, int devlink_info_version_fixed_put(struct devlink_info_req *req,
const char *version_name, const char *version_name,
const char *version_value); const char *version_value);

View File

@ -453,6 +453,8 @@ enum devlink_attr {
DEVLINK_ATTR_PORT_FUNCTION, /* nested */ DEVLINK_ATTR_PORT_FUNCTION, /* nested */
DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, /* string */
/* add new attributes above here, update the policy in devlink.c */ /* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX, __DEVLINK_ATTR_MAX,

View File

@ -4502,6 +4502,14 @@ int devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn)
} }
EXPORT_SYMBOL_GPL(devlink_info_serial_number_put); EXPORT_SYMBOL_GPL(devlink_info_serial_number_put);
int devlink_info_board_serial_number_put(struct devlink_info_req *req,
const char *bsn)
{
return nla_put_string(req->msg, DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER,
bsn);
}
EXPORT_SYMBOL_GPL(devlink_info_board_serial_number_put);
static int devlink_info_version_put(struct devlink_info_req *req, int attr, static int devlink_info_version_put(struct devlink_info_req *req, int attr,
const char *version_name, const char *version_name,
const char *version_value) const char *version_value)