diff mbox series

[v3,iproute2-next] devlink: Add board.serial_number to info subcommand.

Message ID 20200731104643.35726-1-vasundhara-v.volam@broadcom.com
State Accepted
Delegated to: David Ahern
Headers show
Series [v3,iproute2-next] devlink: Add board.serial_number to info subcommand. | expand

Commit Message

Vasundhara Volam July 31, 2020, 10:46 a.m. UTC
Add support for reading board serial_number to devlink info
subcommand. Example:

$ devlink dev info pci/0000:af:00.0 -jp
{
    "info": {
        "pci/0000:af:00.0": {
            "driver": "bnxt_en",
            "serial_number": "00-10-18-FF-FE-AD-1A-00",
            "board.serial_number": "433551F+172300000",
            "versions": {
                "fixed": {
                    "board.id": "7339763 Rev 0.",
                    "asic.id": "16D7",
                    "asic.rev": "1"
                },
                "running": {
                    "fw": "216.1.216.0",
                    "fw.psid": "0.0.0",
                    "fw.mgmt": "216.1.192.0",
                    "fw.mgmt.api": "1.10.1",
                    "fw.ncsi": "0.0.0.0",
                    "fw.roce": "216.1.16.0"
                }
            }
        }
    }
}

Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
---
v2: Rebase. Resending the patch as I see this patch didn't make it to
mailing list.
v3: Rebase the patch and remove the line from commit message
"This patch has dependency on updated include/uapi/linux/devlink.h file."
as the headers are updated.
---
 devlink/devlink.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jiri Pirko Aug. 3, 2020, 11:22 a.m. UTC | #1
Fri, Jul 31, 2020 at 12:46:43PM CEST, vasundhara-v.volam@broadcom.com wrote:
>Add support for reading board serial_number to devlink info
>subcommand. Example:
>
>$ devlink dev info pci/0000:af:00.0 -jp
>{
>    "info": {
>        "pci/0000:af:00.0": {
>            "driver": "bnxt_en",
>            "serial_number": "00-10-18-FF-FE-AD-1A-00",
>            "board.serial_number": "433551F+172300000",
>            "versions": {
>                "fixed": {
>                    "board.id": "7339763 Rev 0.",
>                    "asic.id": "16D7",
>                    "asic.rev": "1"
>                },
>                "running": {
>                    "fw": "216.1.216.0",
>                    "fw.psid": "0.0.0",
>                    "fw.mgmt": "216.1.192.0",
>                    "fw.mgmt.api": "1.10.1",
>                    "fw.ncsi": "0.0.0.0",
>                    "fw.roce": "216.1.16.0"
>                }
>            }
>        }
>    }
>}
>
>Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>

Looks fine.

Reviewed-by: Jiri Pirko <jiri@mellanox.com>
David Ahern Aug. 3, 2020, 3:37 p.m. UTC | #2
On 7/31/20 4:46 AM, Vasundhara Volam wrote:
> Add support for reading board serial_number to devlink info
> subcommand. Example:
> 
> $ devlink dev info pci/0000:af:00.0 -jp
> {
>     "info": {
>         "pci/0000:af:00.0": {
>             "driver": "bnxt_en",
>             "serial_number": "00-10-18-FF-FE-AD-1A-00",
>             "board.serial_number": "433551F+172300000",
>             "versions": {
>                 "fixed": {
>                     "board.id": "7339763 Rev 0.",
>                     "asic.id": "16D7",
>                     "asic.rev": "1"
>                 },
>                 "running": {
>                     "fw": "216.1.216.0",
>                     "fw.psid": "0.0.0",
>                     "fw.mgmt": "216.1.192.0",
>                     "fw.mgmt.api": "1.10.1",
>                     "fw.ncsi": "0.0.0.0",
>                     "fw.roce": "216.1.16.0"
>                 }
>             }
>         }
>     }
> }
> 
> Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
> ---
> v2: Rebase. Resending the patch as I see this patch didn't make it to
> mailing list.
> v3: Rebase the patch and remove the line from commit message
> "This patch has dependency on updated include/uapi/linux/devlink.h file."
> as the headers are updated.
> ---
>  devlink/devlink.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

applied to iproute2-next
diff mbox series

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 7dbe9c7e..f4230dac 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -648,6 +648,7 @@  static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_REGION_CHUNK_LEN] = MNL_TYPE_U64,
 	[DEVLINK_ATTR_INFO_DRIVER_NAME] = MNL_TYPE_STRING,
 	[DEVLINK_ATTR_INFO_SERIAL_NUMBER] = MNL_TYPE_STRING,
+	[DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER] = MNL_TYPE_STRING,
 	[DEVLINK_ATTR_INFO_VERSION_FIXED] = MNL_TYPE_NESTED,
 	[DEVLINK_ATTR_INFO_VERSION_RUNNING] = MNL_TYPE_NESTED,
 	[DEVLINK_ATTR_INFO_VERSION_STORED] = MNL_TYPE_NESTED,
@@ -2979,6 +2980,16 @@  static void pr_out_info(struct dl *dl, const struct nlmsghdr *nlh,
 		print_string(PRINT_ANY, "serial_number", "serial_number %s",
 			     mnl_attr_get_str(nla_sn));
 	}
+
+	if (tb[DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER]) {
+		struct nlattr *nla_bsn = tb[DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER];
+
+		if (!dl->json_output)
+			__pr_out_newline();
+		check_indent_newline(dl);
+		print_string(PRINT_ANY, "board.serial_number", "board.serial_number %s",
+			     mnl_attr_get_str(nla_bsn));
+	}
 	__pr_out_indent_dec();
 
 	if (has_versions) {
@@ -3014,6 +3025,7 @@  static int cmd_versions_show_cb(const struct nlmsghdr *nlh, void *data)
 		tb[DEVLINK_ATTR_INFO_VERSION_STORED];
 	has_info = tb[DEVLINK_ATTR_INFO_DRIVER_NAME] ||
 		tb[DEVLINK_ATTR_INFO_SERIAL_NUMBER] ||
+		tb[DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER] ||
 		has_versions;
 
 	if (has_info)