|
@@ -3149,6 +3149,55 @@ static void devlink_param_unregister_one(struct devlink *devlink,
|
|
kfree(param_item);
|
|
kfree(param_item);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int devlink_nl_region_snapshot_id_put(struct sk_buff *msg,
|
|
|
|
+ struct devlink *devlink,
|
|
|
|
+ struct devlink_snapshot *snapshot)
|
|
|
|
+{
|
|
|
|
+ struct nlattr *snap_attr;
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ snap_attr = nla_nest_start(msg, DEVLINK_ATTR_REGION_SNAPSHOT);
|
|
|
|
+ if (!snap_attr)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ err = nla_put_u32(msg, DEVLINK_ATTR_REGION_SNAPSHOT_ID, snapshot->id);
|
|
|
|
+ if (err)
|
|
|
|
+ goto nla_put_failure;
|
|
|
|
+
|
|
|
|
+ nla_nest_end(msg, snap_attr);
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+nla_put_failure:
|
|
|
|
+ nla_nest_cancel(msg, snap_attr);
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int devlink_nl_region_snapshots_id_put(struct sk_buff *msg,
|
|
|
|
+ struct devlink *devlink,
|
|
|
|
+ struct devlink_region *region)
|
|
|
|
+{
|
|
|
|
+ struct devlink_snapshot *snapshot;
|
|
|
|
+ struct nlattr *snapshots_attr;
|
|
|
|
+ int err;
|
|
|
|
+
|
|
|
|
+ snapshots_attr = nla_nest_start(msg, DEVLINK_ATTR_REGION_SNAPSHOTS);
|
|
|
|
+ if (!snapshots_attr)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ list_for_each_entry(snapshot, ®ion->snapshot_list, list) {
|
|
|
|
+ err = devlink_nl_region_snapshot_id_put(msg, devlink, snapshot);
|
|
|
|
+ if (err)
|
|
|
|
+ goto nla_put_failure;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nla_nest_end(msg, snapshots_attr);
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+nla_put_failure:
|
|
|
|
+ nla_nest_cancel(msg, snapshots_attr);
|
|
|
|
+ return err;
|
|
|
|
+}
|
|
|
|
+
|
|
static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
|
|
static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
|
|
enum devlink_command cmd, u32 portid,
|
|
enum devlink_command cmd, u32 portid,
|
|
u32 seq, int flags,
|
|
u32 seq, int flags,
|
|
@@ -3175,6 +3224,10 @@ static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
|
|
if (err)
|
|
if (err)
|
|
goto nla_put_failure;
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
+ err = devlink_nl_region_snapshots_id_put(msg, devlink, region);
|
|
|
|
+ if (err)
|
|
|
|
+ goto nla_put_failure;
|
|
|
|
+
|
|
genlmsg_end(msg, hdr);
|
|
genlmsg_end(msg, hdr);
|
|
return 0;
|
|
return 0;
|
|
|
|
|