]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
nfp: devlink: include vendor/product info in serial number
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 11 Feb 2019 03:35:31 +0000 (19:35 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Feb 2019 04:39:56 +0000 (20:39 -0800)
The manufacturing team requests we include vendor and product
in the serial number field, as the serial number itself is not
unique across manufacturing facilities and products.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_devlink.c

index bf4e124dbdd284a023c613b349135c8ccb2d01fd..080a301f379e834ff5ab68dfd4fa45361c3cf807 100644 (file)
@@ -258,18 +258,33 @@ nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
                     struct netlink_ext_ack *extack)
 {
        struct nfp_pf *pf = devlink_priv(devlink);
+       const char *sn, *vendor, *part;
        struct nfp_nsp *nsp;
        char *buf = NULL;
-       const char *sn;
        int err;
 
        err = devlink_info_driver_name_put(req, "nfp");
        if (err)
                return err;
 
+       vendor = nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor");
+       part = nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno");
        sn = nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial");
-       if (sn) {
-               err = devlink_info_serial_number_put(req, sn);
+       if (vendor && part && sn) {
+               char *buf;
+
+               buf = kmalloc(strlen(vendor) + strlen(part) + strlen(sn) + 1,
+                             GFP_KERNEL);
+               if (!buf)
+                       return -ENOMEM;
+
+               buf[0] = '\0';
+               strcat(buf, vendor);
+               strcat(buf, part);
+               strcat(buf, sn);
+
+               err = devlink_info_serial_number_put(req, buf);
+               kfree(buf);
                if (err)
                        return err;
        }