devlink: report maximum number of snapshots with regions
authorJacob Keller <jacob.e.keller@intel.com>
Thu, 30 Sep 2021 21:21:04 +0000 (14:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Oct 2021 13:28:55 +0000 (14:28 +0100)
Each region has an independently configurable number of maximum
snapshots. This information is not reported to userspace, making it not
very discoverable. Fix this by adding a new
DEVLINK_ATTR_REGION_MAX_SNAPSHOST attribute which is used to report this
maximum.

Ex:

  $devlink region
  pci/0000:af:00.0/nvm-flash: size 10485760 snapshot [] max 1
  pci/0000:af:00.0/device-caps: size 4096 snapshot [] max 10
  pci/0000:af:00.1/nvm-flash: size 10485760 snapshot [] max 1
  pci/0000:af:00.1/device-caps: size 4096 snapshot [] max 10

This information enables users to understand why a new region command
may fail due to having too many existing snapshots.

Reported-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/networking/devlink/devlink-region.rst
Documentation/networking/devlink/ice.rst
include/uapi/linux/devlink.h
net/core/devlink.c

index 58fe95e..f06dca9 100644 (file)
@@ -44,8 +44,8 @@ example usage
 
     # Show all of the exposed regions with region sizes:
     $ devlink region show
-    pci/0000:00:05.0/cr-space: size 1048576 snapshot [1 2]
-    pci/0000:00:05.0/fw-health: size 64 snapshot [1 2]
+    pci/0000:00:05.0/cr-space: size 1048576 snapshot [1 2] max 8
+    pci/0000:00:05.0/fw-health: size 64 snapshot [1 2] max 8
 
     # Delete a snapshot using:
     $ devlink region del pci/0000:00:05.0/cr-space snapshot 1
index a432dc4..32aea1f 100644 (file)
@@ -141,6 +141,10 @@ Users can request an immediate capture of a snapshot via the
 
 .. code:: shell
 
+    $ devlink region show
+    pci/0000:01:00.0/nvm-flash: size 10485760 snapshot [] max 1
+    pci/0000:01:00.0/device-caps: size 4096 snapshot [] max 10
+
     $ devlink region new pci/0000:01:00.0/nvm-flash snapshot 1
     $ devlink region dump pci/0000:01:00.0/nvm-flash snapshot 1
 
index 32f53a0..b897b80 100644 (file)
@@ -551,6 +551,8 @@ enum devlink_attr {
        DEVLINK_ATTR_RATE_NODE_NAME,            /* string */
        DEVLINK_ATTR_RATE_PARENT_NODE_NAME,     /* string */
 
+       DEVLINK_ATTR_REGION_MAX_SNAPSHOTS,      /* u32 */
+
        /* add new attributes above here, update the policy in devlink.c */
 
        __DEVLINK_ATTR_MAX,
index b643030..4917112 100644 (file)
@@ -5078,6 +5078,11 @@ static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
        if (err)
                goto nla_put_failure;
 
+       err = nla_put_u32(msg, DEVLINK_ATTR_REGION_MAX_SNAPSHOTS,
+                         region->max_snapshots);
+       if (err)
+               goto nla_put_failure;
+
        err = devlink_nl_region_snapshots_id_put(msg, devlink, region);
        if (err)
                goto nla_put_failure;