Commit f3cc0030 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'devlink-introduce-selective-dumps'

Jiri Pirko says:

====================
devlink: introduce selective dumps

Motivation:

For SFs, one devlink instance per SF is created. There might be
thousands of these on a single host. When a user needs to know port
handle for specific SF, he needs to dump all devlink ports on the host
which does not scale good.

Solution:

Allow user to pass devlink handle (and possibly other attributes)
alongside the dump command and dump only objects which are matching
the selection.

Use split ops to generate policies for dump callbacks acccording to
the attributes used for selection.

The userspace can use ctrl genetlink GET_POLICY command to find out if
the selective dumps are supported by kernel for particular command.

Example:
$ devlink port show
auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false
auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false

$ devlink port show auxiliary/mlx5_core.eth.0
auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false

$ devlink port show auxiliary/mlx5_core.eth.1
auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false

Extension:

patches #12 and #13 extends selection attributes by port index
for health reporter dumping.
====================

Link: https://lore.kernel.org/r/20230811155714.1736405-1-jiri@resnulli.usSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 83b5f025 0149bca1
......@@ -6,6 +6,16 @@ protocol: genetlink-legacy
doc: Partial family for Devlink.
definitions:
-
type: enum
name: sb-pool-type
entries:
-
name: ingress
-
name: egress
attribute-sets:
-
name: devlink
......@@ -24,6 +34,46 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: sb-index
type: u32
value: 11
# TODO: fill in the attributes in between
-
name: sb-pool-index
type: u16
value: 17
-
name: sb-pool-type
type: u8
enum: sb-pool-type
# TODO: fill in the attributes in between
-
name: sb-tc-index
type: u16
value: 22
# TODO: fill in the attributes in between
-
name: param-name
type: string
value: 81
# TODO: fill in the attributes in between
-
name: region-name
type: string
value: 88
# TODO: fill in the attributes in between
-
name: info-driver-name
type: string
......@@ -55,10 +105,35 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: health-reporter-name
type: string
value: 115
# TODO: fill in the attributes in between
-
name: trap-name
type: string
value: 130
# TODO: fill in the attributes in between
-
name: trap-group-name
type: string
value: 135
-
name: reload-failed
type: u8
value: 136
# TODO: fill in the attributes in between
-
name: trap-policer-id
type: u32
value: 142
# TODO: fill in the attributes in between
......@@ -103,6 +178,21 @@ attribute-sets:
type: nest
multi-attr: true
nested-attributes: dl-reload-act-stats
# TODO: fill in the attributes in between
-
name: rate-node-name
type: string
value: 168
# TODO: fill in the attributes in between
-
name: linecard-index
type: u32
value: 171
-
name: dl-dev-stats
subset-of: devlink
......@@ -188,6 +278,195 @@ operations:
dump:
reply: *get-reply
-
name: port-get
doc: Get devlink port instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
value: 5
attributes: &port-id-attrs
- bus-name
- dev-name
- port-index
reply:
value: 7
attributes: *port-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply:
value: 3 # due to a bug, port dump returns DEVLINK_CMD_NEW
attributes: *port-id-attrs
# TODO: fill in the operations in between
-
name: sb-get
doc: Get shared buffer instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 11
attributes: &sb-id-attrs
- bus-name
- dev-name
- sb-index
reply: &sb-get-reply
value: 11
attributes: *sb-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-get-reply
# TODO: fill in the operations in between
-
name: sb-pool-get
doc: Get shared buffer pool instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 15
attributes: &sb-pool-id-attrs
- bus-name
- dev-name
- sb-index
- sb-pool-index
reply: &sb-pool-get-reply
value: 15
attributes: *sb-pool-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-pool-get-reply
# TODO: fill in the operations in between
-
name: sb-port-pool-get
doc: Get shared buffer port-pool combinations and threshold.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
value: 19
attributes: &sb-port-pool-id-attrs
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-index
reply: &sb-port-pool-get-reply
value: 19
attributes: *sb-port-pool-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-port-pool-get-reply
# TODO: fill in the operations in between
-
name: sb-tc-pool-bind-get
doc: Get shared buffer port-TC to pool bindings and threshold.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
value: 23
attributes: &sb-tc-pool-bind-id-attrs
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-type
- sb-tc-index
reply: &sb-tc-pool-bind-get-reply
value: 23
attributes: *sb-tc-pool-bind-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-tc-pool-bind-get-reply
# TODO: fill in the operations in between
-
name: param-get
doc: Get param instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 38
attributes: &param-id-attrs
- bus-name
- dev-name
- param-name
reply: &param-get-reply
value: 38
attributes: *param-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *param-get-reply
# TODO: fill in the operations in between
-
name: region-get
doc: Get region instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
value: 42
attributes: &region-id-attrs
- bus-name
- dev-name
- port-index
- region-name
reply: &region-get-reply
value: 42
attributes: *region-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *region-get-reply
# TODO: fill in the operations in between
-
......@@ -216,3 +495,179 @@ operations:
- info-version-stored
dump:
reply: *info-get-reply
-
name: health-reporter-get
doc: Get health reporter instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
attributes: &health-reporter-id-attrs
- bus-name
- dev-name
- port-index
- health-reporter-name
reply: &health-reporter-get-reply
attributes: *health-reporter-id-attrs
dump:
request:
attributes: *port-id-attrs
reply: *health-reporter-get-reply
# TODO: fill in the operations in between
-
name: trap-get
doc: Get trap instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 61
attributes: &trap-id-attrs
- bus-name
- dev-name
- trap-name
reply: &trap-get-reply
value: 61
attributes: *trap-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *trap-get-reply
# TODO: fill in the operations in between
-
name: trap-group-get
doc: Get trap group instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 65
attributes: &trap-group-id-attrs
- bus-name
- dev-name
- trap-group-name
reply: &trap-group-get-reply
value: 65
attributes: *trap-group-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *trap-group-get-reply
# TODO: fill in the operations in between
-
name: trap-policer-get
doc: Get trap policer instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 69
attributes: &trap-policer-id-attrs
- bus-name
- dev-name
- trap-policer-id
reply: &trap-policer-get-reply
value: 69
attributes: *trap-policer-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *trap-policer-get-reply
# TODO: fill in the operations in between
-
name: rate-get
doc: Get rate instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 74
attributes: &rate-id-attrs
- bus-name
- dev-name
- port-index
- rate-node-name
reply: &rate-get-reply
value: 74
attributes: *rate-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *rate-get-reply
# TODO: fill in the operations in between
-
name: linecard-get
doc: Get line card instances.
attribute-set: devlink
dont-validate:
- strict
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 78
attributes: &linecard-id-attrs
- bus-name
- dev-name
- linecard-index
reply: &linecard-get-reply
value: 78
attributes: *linecard-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *linecard-get-reply
# TODO: fill in the operations in between
-
name: selftests-get
doc: Get device selftest instances.
attribute-set: devlink
dont-validate:
- strict
- dump
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 82
attributes: *dev-id-attrs
reply: &selftests-get-reply
value: 82
attributes: *dev-id-attrs
dump:
reply: *selftests-get-reply
......@@ -218,11 +218,11 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
static int
devlink_nl_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
struct netlink_callback *cb, int flags)
{
return devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI);
cb->nlh->nlmsg_seq, flags);
}
int devlink_nl_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
......@@ -828,13 +828,13 @@ int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info)
static int
devlink_nl_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
struct netlink_callback *cb, int flags)
{
int err;
err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
cb->nlh->nlmsg_seq, flags,
cb->extack);
if (err == -EOPNOTSUPP)
err = 0;
......@@ -1206,8 +1206,7 @@ devlink_nl_selftests_fill(struct sk_buff *msg, struct devlink *devlink,
return err;
}
int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct sk_buff *msg;
......@@ -1230,23 +1229,25 @@ int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb,
return genlmsg_reply(msg, info);
}
static int
devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_selftests_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
if (!devlink->ops->selftest_check)
return 0;
return devlink_nl_selftests_fill(msg, devlink,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
cb->nlh->nlmsg_seq, flags,
cb->extack);
}
const struct devlink_cmd devl_cmd_selftests_get = {
.dump_one = devlink_nl_cmd_selftests_get_dump_one,
};
int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_selftests_get_dump_one);
}
static int devlink_selftest_result_put(struct sk_buff *skb, unsigned int id,
enum devlink_selftest_status test_status)
......
......@@ -92,9 +92,6 @@ static inline bool devl_is_registered(struct devlink *devlink)
/* Netlink */
#define DEVLINK_NL_FLAG_NEED_PORT BIT(0)
#define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT BIT(1)
#define DEVLINK_NL_FLAG_NEED_RATE BIT(2)
#define DEVLINK_NL_FLAG_NEED_RATE_NODE BIT(3)
#define DEVLINK_NL_FLAG_NEED_LINECARD BIT(4)
enum devlink_multicast_groups {
DEVLINK_MCGRP_CONFIG,
......@@ -118,13 +115,10 @@ struct devlink_nl_dump_state {
typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb);
struct netlink_callback *cb,
int flags);
struct devlink_cmd {
devlink_nl_dump_one_func_t *dump_one;
};
extern const struct genl_small_ops devlink_nl_small_ops[54];
extern const struct genl_small_ops devlink_nl_small_ops[40];
struct devlink *
devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs);
......@@ -134,7 +128,6 @@ void devlink_notify_register(struct devlink *devlink);
int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
devlink_nl_dump_one_func_t *dump_one);
int devlink_nl_instance_iter_dumpit(struct sk_buff *msg, struct netlink_callback *cb);
static inline struct devlink_nl_dump_state *
devlink_dump_state(struct netlink_callback *cb)
......@@ -154,22 +147,6 @@ devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink)
return 0;
}
/* Commands */
extern const struct devlink_cmd devl_cmd_port_get;
extern const struct devlink_cmd devl_cmd_sb_get;
extern const struct devlink_cmd devl_cmd_sb_pool_get;
extern const struct devlink_cmd devl_cmd_sb_port_pool_get;
extern const struct devlink_cmd devl_cmd_sb_tc_pool_bind_get;
extern const struct devlink_cmd devl_cmd_param_get;
extern const struct devlink_cmd devl_cmd_region_get;
extern const struct devlink_cmd devl_cmd_health_reporter_get;
extern const struct devlink_cmd devl_cmd_trap_get;
extern const struct devlink_cmd devl_cmd_trap_group_get;
extern const struct devlink_cmd devl_cmd_trap_policer_get;
extern const struct devlink_cmd devl_cmd_rate_get;
extern const struct devlink_cmd devl_cmd_linecard_get;
extern const struct devlink_cmd devl_cmd_selftests_get;
/* Notify */
void devlink_notify(struct devlink *devlink, enum devlink_command cmd);
......@@ -203,29 +180,16 @@ int devlink_resources_validate(struct devlink *devlink,
struct devlink_resource *resource,
struct genl_info *info);
/* Line cards */
struct devlink_linecard;
struct devlink_linecard *
devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info);
/* Rates */
int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
struct netlink_ext_ack *extack);
struct devlink_rate *
devlink_rate_get_from_info(struct devlink *devlink, struct genl_info *info);
struct devlink_rate *
devlink_rate_node_get_from_info(struct devlink *devlink,
struct genl_info *info);
/* Devlink nl cmds */
int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
......
......@@ -356,8 +356,8 @@ devlink_health_reporter_get_from_info(struct devlink *devlink,
return devlink_health_reporter_get_from_attrs(devlink, info->attrs);
}
int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -384,18 +384,29 @@ int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,
return genlmsg_reply(msg, info);
}
static int
devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
struct devlink_health_reporter *reporter;
unsigned long port_index_end = ULONG_MAX;
struct nlattr **attrs = info->attrs;
unsigned long port_index_start = 0;
struct devlink_port *port;
unsigned long port_index;
int idx = 0;
int err;
if (attrs && attrs[DEVLINK_ATTR_PORT_INDEX]) {
port_index_start = nla_get_u32(attrs[DEVLINK_ATTR_PORT_INDEX]);
port_index_end = port_index_start;
flags |= NLM_F_DUMP_FILTERED;
goto per_port_dump;
}
list_for_each_entry(reporter, &devlink->reporter_list, list) {
if (idx < state->idx) {
idx++;
......@@ -405,14 +416,16 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
DEVLINK_CMD_HEALTH_REPORTER_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
flags);
if (err) {
state->idx = idx;
return err;
}
idx++;
}
xa_for_each(&devlink->ports, port_index, port) {
per_port_dump:
xa_for_each_range(&devlink->ports, port_index, port,
port_index_start, port_index_end) {
list_for_each_entry(reporter, &port->reporter_list, list) {
if (idx < state->idx) {
idx++;
......@@ -422,7 +435,7 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
DEVLINK_CMD_HEALTH_REPORTER_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
flags);
if (err) {
state->idx = idx;
return err;
......@@ -434,9 +447,12 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
return 0;
}
const struct devlink_cmd devl_cmd_health_reporter_get = {
.dump_one = devlink_nl_cmd_health_reporter_get_dump_one,
};
int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb,
devlink_nl_health_reporter_get_dump_one);
}
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info)
......
......@@ -232,13 +232,13 @@ devlink_rate_node_get_from_attrs(struct devlink *devlink, struct nlattr **attrs)
return devlink_rate_node_get_by_name(devlink, rate_node_name);
}
struct devlink_rate *
static struct devlink_rate *
devlink_rate_node_get_from_info(struct devlink *devlink, struct genl_info *info)
{
return devlink_rate_node_get_from_attrs(devlink, info->attrs);
}
struct devlink_rate *
static struct devlink_rate *
devlink_rate_get_from_info(struct devlink *devlink, struct genl_info *info)
{
struct nlattr **attrs = info->attrs;
......@@ -285,7 +285,7 @@ devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs)
return ERR_PTR(-EINVAL);
}
struct devlink_linecard *
static struct devlink_linecard *
devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info)
{
return devlink_linecard_get_from_attrs(devlink, info->attrs);
......@@ -1005,8 +1005,8 @@ static void devlink_rate_notify(struct devlink_rate *devlink_rate,
}
static int
devlink_nl_cmd_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
devlink_nl_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_rate *devlink_rate;
......@@ -1022,8 +1022,7 @@ devlink_nl_cmd_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
continue;
}
err = devlink_nl_rate_fill(msg, devlink_rate, cmd, id,
cb->nlh->nlmsg_seq,
NLM_F_MULTI, NULL);
cb->nlh->nlmsg_seq, flags, NULL);
if (err) {
state->idx = idx;
break;
......@@ -1034,17 +1033,22 @@ devlink_nl_cmd_rate_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
return err;
}
const struct devlink_cmd devl_cmd_rate_get = {
.dump_one = devlink_nl_cmd_rate_get_dump_one,
};
int devlink_nl_rate_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_rate_get_dump_one);
}
static int devlink_nl_cmd_rate_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_rate *devlink_rate = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *devlink_rate;
struct sk_buff *msg;
int err;
devlink_rate = devlink_rate_get_from_info(devlink, info);
if (IS_ERR(devlink_rate))
return PTR_ERR(devlink_rate);
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
......@@ -1072,8 +1076,7 @@ devlink_rate_is_parent_node(struct devlink_rate *devlink_rate,
return false;
}
static int devlink_nl_cmd_port_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct sk_buff *msg;
......@@ -1095,8 +1098,8 @@ static int devlink_nl_cmd_port_get_doit(struct sk_buff *skb,
}
static int
devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
devlink_nl_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_port *devlink_port;
......@@ -1107,8 +1110,8 @@ devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
err = devlink_nl_port_fill(msg, devlink_port,
DEVLINK_CMD_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI, cb->extack);
cb->nlh->nlmsg_seq, flags,
cb->extack);
if (err) {
state->idx = port_index;
break;
......@@ -1118,9 +1121,10 @@ devlink_nl_cmd_port_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
return err;
}
const struct devlink_cmd devl_cmd_port_get = {
.dump_one = devlink_nl_cmd_port_get_dump_one,
};
int devlink_nl_port_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_port_get_dump_one);
}
static int devlink_port_type_set(struct devlink_port *devlink_port,
enum devlink_port_type port_type)
......@@ -1629,11 +1633,16 @@ static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
static int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_rate *devlink_rate = info->user_ptr[1];
struct devlink *devlink = devlink_rate->devlink;
const struct devlink_ops *ops = devlink->ops;
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *devlink_rate;
const struct devlink_ops *ops;
int err;
devlink_rate = devlink_rate_get_from_info(devlink, info);
if (IS_ERR(devlink_rate))
return PTR_ERR(devlink_rate);
ops = devlink->ops;
if (!ops || !devlink_rate_set_ops_supported(ops, info, devlink_rate->type))
return -EOPNOTSUPP;
......@@ -1704,18 +1713,22 @@ static int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb,
static int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_rate *rate_node = info->user_ptr[1];
struct devlink *devlink = rate_node->devlink;
const struct devlink_ops *ops = devlink->ops;
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *rate_node;
int err;
rate_node = devlink_rate_node_get_from_info(devlink, info);
if (IS_ERR(rate_node))
return PTR_ERR(rate_node);
if (refcount_read(&rate_node->refcnt) > 1) {
NL_SET_ERR_MSG(info->extack, "Node has children. Cannot delete node.");
return -EBUSY;
}
devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL);
err = ops->rate_node_del(rate_node, rate_node->priv, info->extack);
err = devlink->ops->rate_node_del(rate_node, rate_node->priv,
info->extack);
if (rate_node->parent)
refcount_dec(&rate_node->parent->refcnt);
list_del(&rate_node->list);
......@@ -1811,14 +1824,17 @@ static void devlink_linecard_notify(struct devlink_linecard *linecard,
msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
}
static int devlink_nl_cmd_linecard_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_linecard *linecard = info->user_ptr[1];
struct devlink *devlink = linecard->devlink;
struct devlink *devlink = info->user_ptr[0];
struct devlink_linecard *linecard;
struct sk_buff *msg;
int err;
linecard = devlink_linecard_get_from_info(devlink, info);
if (IS_ERR(linecard))
return PTR_ERR(linecard);
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
......@@ -1837,9 +1853,10 @@ static int devlink_nl_cmd_linecard_get_doit(struct sk_buff *skb,
return genlmsg_reply(msg, info);
}
static int devlink_nl_cmd_linecard_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_linecard_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_linecard *linecard;
......@@ -1855,8 +1872,7 @@ static int devlink_nl_cmd_linecard_get_dump_one(struct sk_buff *msg,
err = devlink_nl_linecard_fill(msg, devlink, linecard,
DEVLINK_CMD_LINECARD_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI,
cb->nlh->nlmsg_seq, flags,
cb->extack);
mutex_unlock(&linecard->state_lock);
if (err) {
......@@ -1869,9 +1885,11 @@ static int devlink_nl_cmd_linecard_get_dump_one(struct sk_buff *msg,
return err;
}
const struct devlink_cmd devl_cmd_linecard_get = {
.dump_one = devlink_nl_cmd_linecard_get_dump_one,
};
int devlink_nl_linecard_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_linecard_get_dump_one);
}
static struct devlink_linecard_type *
devlink_linecard_type_lookup(struct devlink_linecard *linecard,
......@@ -2008,10 +2026,15 @@ static int devlink_linecard_type_unset(struct devlink_linecard *linecard,
static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_linecard *linecard = info->user_ptr[1];
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
struct devlink_linecard *linecard;
int err;
linecard = devlink_linecard_get_from_info(devlink, info);
if (IS_ERR(linecard))
return PTR_ERR(linecard);
if (info->attrs[DEVLINK_ATTR_LINECARD_TYPE]) {
const char *type;
......@@ -2068,8 +2091,7 @@ static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
static int devlink_nl_cmd_sb_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_sb *devlink_sb;
......@@ -2096,8 +2118,8 @@ static int devlink_nl_cmd_sb_get_doit(struct sk_buff *skb,
}
static int
devlink_nl_cmd_sb_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
devlink_nl_sb_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_sb *devlink_sb;
......@@ -2112,8 +2134,7 @@ devlink_nl_cmd_sb_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
err = devlink_nl_sb_fill(msg, devlink, devlink_sb,
DEVLINK_CMD_SB_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
cb->nlh->nlmsg_seq, flags);
if (err) {
state->idx = idx;
break;
......@@ -2124,9 +2145,10 @@ devlink_nl_cmd_sb_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
return err;
}
const struct devlink_cmd devl_cmd_sb_get = {
.dump_one = devlink_nl_cmd_sb_get_dump_one,
};
int devlink_nl_sb_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_sb_get_dump_one);
}
static int devlink_nl_sb_pool_fill(struct sk_buff *msg, struct devlink *devlink,
struct devlink_sb *devlink_sb,
......@@ -2171,8 +2193,7 @@ static int devlink_nl_sb_pool_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
static int devlink_nl_cmd_sb_pool_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_sb *devlink_sb;
......@@ -2210,7 +2231,7 @@ static int devlink_nl_cmd_sb_pool_get_doit(struct sk_buff *skb,
static int __sb_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
struct devlink *devlink,
struct devlink_sb *devlink_sb,
u32 portid, u32 seq)
u32 portid, u32 seq, int flags)
{
u16 pool_count = devlink_sb_pool_count(devlink_sb);
u16 pool_index;
......@@ -2225,7 +2246,7 @@ static int __sb_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
devlink_sb,
pool_index,
DEVLINK_CMD_SB_POOL_NEW,
portid, seq, NLM_F_MULTI);
portid, seq, flags);
if (err)
return err;
(*p_idx)++;
......@@ -2234,9 +2255,8 @@ static int __sb_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
}
static int
devlink_nl_cmd_sb_pool_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
devlink_nl_sb_pool_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_sb *devlink_sb;
......@@ -2250,7 +2270,7 @@ devlink_nl_cmd_sb_pool_get_dump_one(struct sk_buff *msg,
err = __sb_pool_get_dumpit(msg, state->idx, &idx,
devlink, devlink_sb,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq);
cb->nlh->nlmsg_seq, flags);
if (err == -EOPNOTSUPP) {
err = 0;
} else if (err) {
......@@ -2262,9 +2282,11 @@ devlink_nl_cmd_sb_pool_get_dump_one(struct sk_buff *msg,
return err;
}
const struct devlink_cmd devl_cmd_sb_pool_get = {
.dump_one = devlink_nl_cmd_sb_pool_get_dump_one,
};
int devlink_nl_sb_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_sb_pool_get_dump_one);
}
static int devlink_sb_pool_set(struct devlink *devlink, unsigned int sb_index,
u16 pool_index, u32 size,
......@@ -2371,8 +2393,8 @@ static int devlink_nl_sb_port_pool_fill(struct sk_buff *msg,
return err;
}
static int devlink_nl_cmd_sb_port_pool_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = devlink_port->devlink;
......@@ -2412,7 +2434,7 @@ static int devlink_nl_cmd_sb_port_pool_get_doit(struct sk_buff *skb,
static int __sb_port_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
struct devlink *devlink,
struct devlink_sb *devlink_sb,
u32 portid, u32 seq)
u32 portid, u32 seq, int flags)
{
struct devlink_port *devlink_port;
u16 pool_count = devlink_sb_pool_count(devlink_sb);
......@@ -2431,8 +2453,7 @@ static int __sb_port_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
devlink_sb,
pool_index,
DEVLINK_CMD_SB_PORT_POOL_NEW,
portid, seq,
NLM_F_MULTI);
portid, seq, flags);
if (err)
return err;
(*p_idx)++;
......@@ -2442,9 +2463,9 @@ static int __sb_port_pool_get_dumpit(struct sk_buff *msg, int start, int *p_idx,
}
static int
devlink_nl_cmd_sb_port_pool_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
devlink_nl_sb_port_pool_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_sb *devlink_sb;
......@@ -2458,7 +2479,7 @@ devlink_nl_cmd_sb_port_pool_get_dump_one(struct sk_buff *msg,
err = __sb_port_pool_get_dumpit(msg, state->idx, &idx,
devlink, devlink_sb,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq);
cb->nlh->nlmsg_seq, flags);
if (err == -EOPNOTSUPP) {
err = 0;
} else if (err) {
......@@ -2470,9 +2491,11 @@ devlink_nl_cmd_sb_port_pool_get_dump_one(struct sk_buff *msg,
return err;
}
const struct devlink_cmd devl_cmd_sb_port_pool_get = {
.dump_one = devlink_nl_cmd_sb_port_pool_get_dump_one,
};
int devlink_nl_sb_port_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_sb_port_pool_get_dump_one);
}
static int devlink_sb_port_pool_set(struct devlink_port *devlink_port,
unsigned int sb_index, u16 pool_index,
......@@ -2580,8 +2603,8 @@ devlink_nl_sb_tc_pool_bind_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
static int devlink_nl_cmd_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = devlink_port->devlink;
......@@ -2628,7 +2651,7 @@ static int __sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
int start, int *p_idx,
struct devlink *devlink,
struct devlink_sb *devlink_sb,
u32 portid, u32 seq)
u32 portid, u32 seq, int flags)
{
struct devlink_port *devlink_port;
unsigned long port_index;
......@@ -2649,7 +2672,7 @@ static int __sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
DEVLINK_SB_POOL_TYPE_INGRESS,
DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
portid, seq,
NLM_F_MULTI);
flags);
if (err)
return err;
(*p_idx)++;
......@@ -2667,7 +2690,7 @@ static int __sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
DEVLINK_SB_POOL_TYPE_EGRESS,
DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
portid, seq,
NLM_F_MULTI);
flags);
if (err)
return err;
(*p_idx)++;
......@@ -2676,10 +2699,10 @@ static int __sb_tc_pool_bind_get_dumpit(struct sk_buff *msg,
return 0;
}
static int
devlink_nl_cmd_sb_tc_pool_bind_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_sb_tc_pool_bind_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_sb *devlink_sb;
......@@ -2693,7 +2716,7 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dump_one(struct sk_buff *msg,
err = __sb_tc_pool_bind_get_dumpit(msg, state->idx, &idx,
devlink, devlink_sb,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq);
cb->nlh->nlmsg_seq, flags);
if (err == -EOPNOTSUPP) {
err = 0;
} else if (err) {
......@@ -2705,9 +2728,12 @@ devlink_nl_cmd_sb_tc_pool_bind_get_dump_one(struct sk_buff *msg,
return err;
}
const struct devlink_cmd devl_cmd_sb_tc_pool_bind_get = {
.dump_one = devlink_nl_cmd_sb_tc_pool_bind_get_dump_one,
};
int devlink_nl_sb_tc_pool_bind_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb,
devlink_nl_sb_tc_pool_bind_get_dump_one);
}
static int devlink_sb_tc_pool_bind_set(struct devlink_port *devlink_port,
unsigned int sb_index, u16 tc_index,
......@@ -4155,9 +4181,10 @@ static void devlink_param_notify(struct devlink *devlink,
msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
}
static int
devlink_nl_cmd_param_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_param_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_param_item *param_item;
......@@ -4168,8 +4195,7 @@ devlink_nl_cmd_param_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
err = devlink_nl_param_fill(msg, devlink, 0, param_item,
DEVLINK_CMD_PARAM_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
cb->nlh->nlmsg_seq, flags);
if (err == -EOPNOTSUPP) {
err = 0;
} else if (err) {
......@@ -4181,9 +4207,11 @@ devlink_nl_cmd_param_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
return err;
}
const struct devlink_cmd devl_cmd_param_get = {
.dump_one = devlink_nl_cmd_param_get_dump_one,
};
int devlink_nl_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_param_get_dump_one);
}
static int
devlink_param_type_get_from_info(struct genl_info *info,
......@@ -4272,8 +4300,8 @@ devlink_param_get_from_info(struct xarray *params, struct genl_info *info)
return devlink_param_find_by_name(params, param_name);
}
static int devlink_nl_cmd_param_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_param_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_param_item *param_item;
......@@ -4770,8 +4798,7 @@ static void devlink_region_snapshot_del(struct devlink_region *region,
kfree(snapshot);
}
static int devlink_nl_cmd_region_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_port *port = NULL;
......@@ -4819,8 +4846,7 @@ static int devlink_nl_cmd_region_get_doit(struct sk_buff *skb,
static int devlink_nl_cmd_region_get_port_dumpit(struct sk_buff *msg,
struct netlink_callback *cb,
struct devlink_port *port,
int *idx,
int start)
int *idx, int start, int flags)
{
struct devlink_region *region;
int err = 0;
......@@ -4834,7 +4860,7 @@ static int devlink_nl_cmd_region_get_port_dumpit(struct sk_buff *msg,
DEVLINK_CMD_REGION_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI, region);
flags, region);
if (err)
goto out;
(*idx)++;
......@@ -4844,9 +4870,10 @@ static int devlink_nl_cmd_region_get_port_dumpit(struct sk_buff *msg,
return err;
}
static int
devlink_nl_cmd_region_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_region_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_region *region;
......@@ -4863,8 +4890,8 @@ devlink_nl_cmd_region_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
err = devlink_nl_region_fill(msg, devlink,
DEVLINK_CMD_REGION_GET,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI, region);
cb->nlh->nlmsg_seq, flags,
region);
if (err) {
state->idx = idx;
return err;
......@@ -4874,7 +4901,7 @@ devlink_nl_cmd_region_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
xa_for_each(&devlink->ports, port_index, port) {
err = devlink_nl_cmd_region_get_port_dumpit(msg, cb, port, &idx,
state->idx);
state->idx, flags);
if (err) {
state->idx = idx;
return err;
......@@ -4884,9 +4911,11 @@ devlink_nl_cmd_region_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
return 0;
}
const struct devlink_cmd devl_cmd_region_get = {
.dump_one = devlink_nl_cmd_region_get_dump_one,
};
int devlink_nl_region_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_region_get_dump_one);
}
static int devlink_nl_cmd_region_del(struct sk_buff *skb,
struct genl_info *info)
......@@ -5632,8 +5661,7 @@ static int devlink_nl_trap_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
static int devlink_nl_cmd_trap_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......@@ -5667,9 +5695,9 @@ static int devlink_nl_cmd_trap_get_doit(struct sk_buff *skb,
return err;
}
static int
devlink_nl_cmd_trap_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_trap_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_trap_item *trap_item;
......@@ -5684,8 +5712,7 @@ devlink_nl_cmd_trap_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
err = devlink_nl_trap_fill(msg, devlink, trap_item,
DEVLINK_CMD_TRAP_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
cb->nlh->nlmsg_seq, flags);
if (err) {
state->idx = idx;
break;
......@@ -5696,9 +5723,10 @@ devlink_nl_cmd_trap_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
return err;
}
const struct devlink_cmd devl_cmd_trap_get = {
.dump_one = devlink_nl_cmd_trap_get_dump_one,
};
int devlink_nl_trap_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_trap_get_dump_one);
}
static int __devlink_trap_action_set(struct devlink *devlink,
struct devlink_trap_item *trap_item,
......@@ -5843,8 +5871,7 @@ devlink_nl_trap_group_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
static int devlink_nl_cmd_trap_group_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......@@ -5878,10 +5905,10 @@ static int devlink_nl_cmd_trap_group_get_doit(struct sk_buff *skb,
return err;
}
static int
devlink_nl_cmd_trap_group_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_trap_group_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_trap_group_item *group_item;
......@@ -5897,8 +5924,7 @@ devlink_nl_cmd_trap_group_get_dump_one(struct sk_buff *msg,
err = devlink_nl_trap_group_fill(msg, devlink, group_item,
DEVLINK_CMD_TRAP_GROUP_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
cb->nlh->nlmsg_seq, flags);
if (err) {
state->idx = idx;
break;
......@@ -5909,9 +5935,11 @@ devlink_nl_cmd_trap_group_get_dump_one(struct sk_buff *msg,
return err;
}
const struct devlink_cmd devl_cmd_trap_group_get = {
.dump_one = devlink_nl_cmd_trap_group_get_dump_one,
};
int devlink_nl_trap_group_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_trap_group_get_dump_one);
}
static int
__devlink_trap_group_action_set(struct devlink *devlink,
......@@ -6137,8 +6165,8 @@ devlink_nl_trap_policer_fill(struct sk_buff *msg, struct devlink *devlink,
return -EMSGSIZE;
}
static int devlink_nl_cmd_trap_policer_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_trap_policer_item *policer_item;
struct netlink_ext_ack *extack = info->extack;
......@@ -6172,10 +6200,10 @@ static int devlink_nl_cmd_trap_policer_get_doit(struct sk_buff *skb,
return err;
}
static int
devlink_nl_cmd_trap_policer_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb)
static int devlink_nl_trap_policer_get_dump_one(struct sk_buff *msg,
struct devlink *devlink,
struct netlink_callback *cb,
int flags)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_trap_policer_item *policer_item;
......@@ -6190,8 +6218,7 @@ devlink_nl_cmd_trap_policer_get_dump_one(struct sk_buff *msg,
err = devlink_nl_trap_policer_fill(msg, devlink, policer_item,
DEVLINK_CMD_TRAP_POLICER_NEW,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq,
NLM_F_MULTI);
cb->nlh->nlmsg_seq, flags);
if (err) {
state->idx = idx;
break;
......@@ -6202,9 +6229,11 @@ devlink_nl_cmd_trap_policer_get_dump_one(struct sk_buff *msg,
return err;
}
const struct devlink_cmd devl_cmd_trap_policer_get = {
.dump_one = devlink_nl_cmd_trap_policer_get_dump_one,
};
int devlink_nl_trap_policer_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
return devlink_nl_dumpit(skb, cb, devlink_nl_trap_policer_get_dump_one);
}
static int
devlink_trap_policer_set(struct devlink *devlink,
......@@ -6278,15 +6307,7 @@ static int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
return devlink_trap_policer_set(devlink, policer_item, info);
}
const struct genl_small_ops devlink_nl_small_ops[54] = {
{
.cmd = DEVLINK_CMD_PORT_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_port_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
/* can be retrieved by unprivileged users */
},
const struct genl_small_ops devlink_nl_small_ops[40] = {
{
.cmd = DEVLINK_CMD_PORT_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
......@@ -6294,18 +6315,10 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_RATE_GET,
.doit = devlink_nl_cmd_rate_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_RATE,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_RATE_SET,
.doit = devlink_nl_cmd_rate_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_RATE,
},
{
.cmd = DEVLINK_CMD_RATE_NEW,
......@@ -6316,7 +6329,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.cmd = DEVLINK_CMD_RATE_DEL,
.doit = devlink_nl_cmd_rate_del_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_RATE_NODE,
},
{
.cmd = DEVLINK_CMD_PORT_SPLIT,
......@@ -6343,32 +6355,11 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_LINECARD_GET,
.doit = devlink_nl_cmd_linecard_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_LINECARD_SET,
.doit = devlink_nl_cmd_linecard_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD,
},
{
.cmd = DEVLINK_CMD_SB_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_SB_POOL_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_pool_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_SB_POOL_SET,
......@@ -6376,14 +6367,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.doit = devlink_nl_cmd_sb_pool_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_port_pool_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
......@@ -6391,14 +6374,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_tc_pool_bind_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
......@@ -6472,13 +6447,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.doit = devlink_nl_cmd_reload,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_PARAM_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_param_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_PARAM_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
......@@ -6500,13 +6468,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_REGION_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_region_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_REGION_NEW,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
......@@ -6526,14 +6487,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.dumpit = devlink_nl_cmd_region_read_dumpit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
......@@ -6582,45 +6535,21 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
.doit = devlink_nl_cmd_flash_update,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_TRAP_GET,
.doit = devlink_nl_cmd_trap_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_TRAP_SET,
.doit = devlink_nl_cmd_trap_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_GET,
.doit = devlink_nl_cmd_trap_group_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_SET,
.doit = devlink_nl_cmd_trap_group_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_GET,
.doit = devlink_nl_cmd_trap_policer_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_SET,
.doit = devlink_nl_cmd_trap_policer_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_SELFTESTS_GET,
.doit = devlink_nl_cmd_selftests_get_doit,
.dumpit = devlink_nl_instance_iter_dumpit,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_SELFTESTS_RUN,
.doit = devlink_nl_cmd_selftests_run,
......
......@@ -109,10 +109,9 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs)
return ERR_PTR(-ENODEV);
}
int devlink_nl_pre_doit(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info)
static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info,
u8 flags)
{
struct devlink_linecard *linecard;
struct devlink_port *devlink_port;
struct devlink *devlink;
int err;
......@@ -122,42 +121,17 @@ int devlink_nl_pre_doit(const struct genl_split_ops *ops,
return PTR_ERR(devlink);
info->user_ptr[0] = devlink;
if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) {
if (flags & DEVLINK_NL_FLAG_NEED_PORT) {
devlink_port = devlink_port_get_from_info(devlink, info);
if (IS_ERR(devlink_port)) {
err = PTR_ERR(devlink_port);
goto unlock;
}
info->user_ptr[1] = devlink_port;
} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT) {
} else if (flags & DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT) {
devlink_port = devlink_port_get_from_info(devlink, info);
if (!IS_ERR(devlink_port))
info->user_ptr[1] = devlink_port;
} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_RATE) {
struct devlink_rate *devlink_rate;
devlink_rate = devlink_rate_get_from_info(devlink, info);
if (IS_ERR(devlink_rate)) {
err = PTR_ERR(devlink_rate);
goto unlock;
}
info->user_ptr[1] = devlink_rate;
} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_RATE_NODE) {
struct devlink_rate *rate_node;
rate_node = devlink_rate_node_get_from_info(devlink, info);
if (IS_ERR(rate_node)) {
err = PTR_ERR(rate_node);
goto unlock;
}
info->user_ptr[1] = rate_node;
} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) {
linecard = devlink_linecard_get_from_info(devlink, info);
if (IS_ERR(linecard)) {
err = PTR_ERR(linecard);
goto unlock;
}
info->user_ptr[1] = linecard;
}
return 0;
......@@ -167,6 +141,25 @@ int devlink_nl_pre_doit(const struct genl_split_ops *ops,
return err;
}
int devlink_nl_pre_doit(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info)
{
return __devlink_nl_pre_doit(skb, info, ops->internal_flags);
}
int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info)
{
return __devlink_nl_pre_doit(skb, info, DEVLINK_NL_FLAG_NEED_PORT);
}
int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,
struct sk_buff *skb,
struct genl_info *info)
{
return __devlink_nl_pre_doit(skb, info, DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT);
}
void devlink_nl_post_doit(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info)
{
......@@ -177,25 +170,30 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops,
devlink_put(devlink);
}
static const struct devlink_cmd *devl_cmds[] = {
[DEVLINK_CMD_PORT_GET] = &devl_cmd_port_get,
[DEVLINK_CMD_SB_GET] = &devl_cmd_sb_get,
[DEVLINK_CMD_SB_POOL_GET] = &devl_cmd_sb_pool_get,
[DEVLINK_CMD_SB_PORT_POOL_GET] = &devl_cmd_sb_port_pool_get,
[DEVLINK_CMD_SB_TC_POOL_BIND_GET] = &devl_cmd_sb_tc_pool_bind_get,
[DEVLINK_CMD_PARAM_GET] = &devl_cmd_param_get,
[DEVLINK_CMD_REGION_GET] = &devl_cmd_region_get,
[DEVLINK_CMD_HEALTH_REPORTER_GET] = &devl_cmd_health_reporter_get,
[DEVLINK_CMD_TRAP_GET] = &devl_cmd_trap_get,
[DEVLINK_CMD_TRAP_GROUP_GET] = &devl_cmd_trap_group_get,
[DEVLINK_CMD_TRAP_POLICER_GET] = &devl_cmd_trap_policer_get,
[DEVLINK_CMD_RATE_GET] = &devl_cmd_rate_get,
[DEVLINK_CMD_LINECARD_GET] = &devl_cmd_linecard_get,
[DEVLINK_CMD_SELFTESTS_GET] = &devl_cmd_selftests_get,
};
static int devlink_nl_inst_single_dumpit(struct sk_buff *msg,
struct netlink_callback *cb, int flags,
devlink_nl_dump_one_func_t *dump_one,
struct nlattr **attrs)
{
struct devlink *devlink;
int err;
int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
devlink_nl_dump_one_func_t *dump_one)
devlink = devlink_get_from_attrs_lock(sock_net(msg->sk), attrs);
if (IS_ERR(devlink))
return PTR_ERR(devlink);
err = dump_one(msg, devlink, cb, flags | NLM_F_DUMP_FILTERED);
devl_unlock(devlink);
devlink_put(devlink);
if (err != -EMSGSIZE)
return err;
return msg->len;
}
static int devlink_nl_inst_iter_dumpit(struct sk_buff *msg,
struct netlink_callback *cb, int flags,
devlink_nl_dump_one_func_t *dump_one)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink *devlink;
......@@ -206,7 +204,7 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
devl_lock(devlink);
if (devl_is_registered(devlink))
err = dump_one(msg, devlink, cb);
err = dump_one(msg, devlink, cb, flags);
else
err = 0;
......@@ -227,13 +225,19 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
return msg->len;
}
int devlink_nl_instance_iter_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
devlink_nl_dump_one_func_t *dump_one)
{
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
const struct devlink_cmd *cmd = devl_cmds[info->op.cmd];
struct nlattr **attrs = info->attrs;
int flags = NLM_F_MULTI;
return devlink_nl_dumpit(msg, cb, cmd->dump_one);
if (attrs &&
(attrs[DEVLINK_ATTR_BUS_NAME] || attrs[DEVLINK_ATTR_DEV_NAME]))
return devlink_nl_inst_single_dumpit(msg, cb, flags, dump_one,
attrs);
else
return devlink_nl_inst_iter_dumpit(msg, cb, flags, dump_one);
}
struct genl_family devlink_nl_family __ro_after_init = {
......
......@@ -16,14 +16,199 @@ static const struct nla_policy devlink_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1]
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_PORT_GET - do */
static const struct nla_policy devlink_port_get_do_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_PORT_GET - dump */
static const struct nla_policy devlink_port_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_GET - do */
static const struct nla_policy devlink_sb_get_do_nl_policy[DEVLINK_ATTR_SB_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_SB_GET - dump */
static const struct nla_policy devlink_sb_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_POOL_GET - do */
static const struct nla_policy devlink_sb_pool_get_do_nl_policy[DEVLINK_ATTR_SB_POOL_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16, },
};
/* DEVLINK_CMD_SB_POOL_GET - dump */
static const struct nla_policy devlink_sb_pool_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_PORT_POOL_GET - do */
static const struct nla_policy devlink_sb_port_pool_get_do_nl_policy[DEVLINK_ATTR_SB_POOL_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16, },
};
/* DEVLINK_CMD_SB_PORT_POOL_GET - dump */
static const struct nla_policy devlink_sb_port_pool_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - do */
static const struct nla_policy devlink_sb_tc_pool_bind_get_do_nl_policy[DEVLINK_ATTR_SB_TC_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_POOL_TYPE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_ATTR_SB_TC_INDEX] = { .type = NLA_U16, },
};
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - dump */
static const struct nla_policy devlink_sb_tc_pool_bind_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_PARAM_GET - do */
static const struct nla_policy devlink_param_get_do_nl_policy[DEVLINK_ATTR_PARAM_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PARAM_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_PARAM_GET - dump */
static const struct nla_policy devlink_param_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_REGION_GET - do */
static const struct nla_policy devlink_region_get_do_nl_policy[DEVLINK_ATTR_REGION_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_REGION_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_REGION_GET - dump */
static const struct nla_policy devlink_region_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_INFO_GET - do */
static const struct nla_policy devlink_info_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_GET - do */
static const struct nla_policy devlink_health_reporter_get_do_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_GET - dump */
static const struct nla_policy devlink_health_reporter_get_dump_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_TRAP_GET - do */
static const struct nla_policy devlink_trap_get_do_nl_policy[DEVLINK_ATTR_TRAP_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_GET - dump */
static const struct nla_policy devlink_trap_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_GROUP_GET - do */
static const struct nla_policy devlink_trap_group_get_do_nl_policy[DEVLINK_ATTR_TRAP_GROUP_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_GROUP_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_GROUP_GET - dump */
static const struct nla_policy devlink_trap_group_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_POLICER_GET - do */
static const struct nla_policy devlink_trap_policer_get_do_nl_policy[DEVLINK_ATTR_TRAP_POLICER_ID + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_POLICER_ID] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_TRAP_POLICER_GET - dump */
static const struct nla_policy devlink_trap_policer_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RATE_GET - do */
static const struct nla_policy devlink_rate_get_do_nl_policy[DEVLINK_ATTR_RATE_NODE_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RATE_GET - dump */
static const struct nla_policy devlink_rate_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_LINECARD_GET - do */
static const struct nla_policy devlink_linecard_get_do_nl_policy[DEVLINK_ATTR_LINECARD_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_LINECARD_GET - dump */
static const struct nla_policy devlink_linecard_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SELFTESTS_GET - do */
static const struct nla_policy devlink_selftests_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* Ops table for devlink */
const struct genl_split_ops devlink_nl_ops[4] = {
const struct genl_split_ops devlink_nl_ops[32] = {
{
.cmd = DEVLINK_CMD_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -40,6 +225,125 @@ const struct genl_split_ops devlink_nl_ops[4] = {
.dumpit = devlink_nl_get_dumpit,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_PORT_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PORT_GET,
.dumpit = devlink_nl_port_get_dumpit,
.policy = devlink_port_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_sb_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_SB_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_GET,
.dumpit = devlink_nl_sb_get_dumpit,
.policy = devlink_sb_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_POOL_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_sb_pool_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_pool_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_SB_POOL_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_POOL_GET,
.dumpit = devlink_nl_sb_pool_get_dumpit,
.policy = devlink_sb_pool_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_sb_port_pool_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_port_pool_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_SB_POOL_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_GET,
.dumpit = devlink_nl_sb_port_pool_get_dumpit,
.policy = devlink_sb_port_pool_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_sb_tc_pool_bind_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_tc_pool_bind_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_SB_TC_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_GET,
.dumpit = devlink_nl_sb_tc_pool_bind_get_dumpit,
.policy = devlink_sb_tc_pool_bind_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_PARAM_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_param_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_param_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_PARAM_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PARAM_GET,
.dumpit = devlink_nl_param_get_dumpit,
.policy = devlink_param_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_REGION_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_region_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_region_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_REGION_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_REGION_GET,
.dumpit = devlink_nl_region_get_dumpit,
.policy = devlink_region_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_INFO_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -56,4 +360,122 @@ const struct genl_split_ops devlink_nl_ops[4] = {
.dumpit = devlink_nl_info_get_dumpit,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_health_reporter_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_health_reporter_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_GET,
.dumpit = devlink_nl_health_reporter_get_dumpit,
.policy = devlink_health_reporter_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_TRAP_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_trap_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_trap_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_TRAP_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_TRAP_GET,
.dumpit = devlink_nl_trap_get_dumpit,
.policy = devlink_trap_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_trap_group_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_trap_group_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_TRAP_GROUP_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_GET,
.dumpit = devlink_nl_trap_group_get_dumpit,
.policy = devlink_trap_group_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_trap_policer_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_trap_policer_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_TRAP_POLICER_ID,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_GET,
.dumpit = devlink_nl_trap_policer_get_dumpit,
.policy = devlink_trap_policer_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_RATE_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_rate_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_rate_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_RATE_NODE_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RATE_GET,
.dumpit = devlink_nl_rate_get_dumpit,
.policy = devlink_rate_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_LINECARD_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_linecard_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_linecard_get_do_nl_policy,
.maxattr = DEVLINK_ATTR_LINECARD_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_LINECARD_GET,
.dumpit = devlink_nl_linecard_get_dumpit,
.policy = devlink_linecard_get_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SELFTESTS_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_selftests_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_selftests_get_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SELFTESTS_GET,
.validate = GENL_DONT_VALIDATE_DUMP,
.dumpit = devlink_nl_selftests_get_dumpit,
.flags = GENL_CMD_CAP_DUMP,
},
};
......@@ -12,18 +12,68 @@
#include <uapi/linux/devlink.h>
/* Ops table for devlink */
extern const struct genl_split_ops devlink_nl_ops[4];
extern const struct genl_split_ops devlink_nl_ops[32];
int devlink_nl_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info);
int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,
struct sk_buff *skb,
struct genl_info *info);
void
devlink_nl_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_port_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_tc_pool_bind_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_param_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_info_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_group_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_trap_policer_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_linecard_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
#endif /* _LINUX_DEVLINK_GEN_H */
......@@ -15,7 +15,21 @@
/* Enums */
static const char * const devlink_op_strmap[] = {
[3] = "get",
[7] = "port-get",
[DEVLINK_CMD_SB_GET] = "sb-get",
[DEVLINK_CMD_SB_POOL_GET] = "sb-pool-get",
[DEVLINK_CMD_SB_PORT_POOL_GET] = "sb-port-pool-get",
[DEVLINK_CMD_SB_TC_POOL_BIND_GET] = "sb-tc-pool-bind-get",
[DEVLINK_CMD_PARAM_GET] = "param-get",
[DEVLINK_CMD_REGION_GET] = "region-get",
[DEVLINK_CMD_INFO_GET] = "info-get",
[DEVLINK_CMD_HEALTH_REPORTER_GET] = "health-reporter-get",
[DEVLINK_CMD_TRAP_GET] = "trap-get",
[DEVLINK_CMD_TRAP_GROUP_GET] = "trap-group-get",
[DEVLINK_CMD_TRAP_POLICER_GET] = "trap-policer-get",
[DEVLINK_CMD_RATE_GET] = "rate-get",
[DEVLINK_CMD_LINECARD_GET] = "linecard-get",
[DEVLINK_CMD_SELFTESTS_GET] = "selftests-get",
};
const char *devlink_op_str(int op)
......@@ -25,6 +39,18 @@ const char *devlink_op_str(int op)
return devlink_op_strmap[op];
}
static const char * const devlink_sb_pool_type_strmap[] = {
[0] = "ingress",
[1] = "egress",
};
const char *devlink_sb_pool_type_str(enum devlink_sb_pool_type value)
{
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(devlink_sb_pool_type_strmap))
return NULL;
return devlink_sb_pool_type_strmap[value];
}
/* Policies */
struct ynl_policy_attr devlink_dl_info_version_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_INFO_VERSION_NAME] = { .name = "info-version-name", .type = YNL_PT_NUL_STR, },
......@@ -88,6 +114,12 @@ struct ynl_policy_attr devlink_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .name = "bus-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_DEV_NAME] = { .name = "dev-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_PORT_INDEX] = { .name = "port-index", .type = YNL_PT_U32, },
[DEVLINK_ATTR_SB_INDEX] = { .name = "sb-index", .type = YNL_PT_U32, },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .name = "sb-pool-index", .type = YNL_PT_U16, },
[DEVLINK_ATTR_SB_POOL_TYPE] = { .name = "sb-pool-type", .type = YNL_PT_U8, },
[DEVLINK_ATTR_SB_TC_INDEX] = { .name = "sb-tc-index", .type = YNL_PT_U16, },
[DEVLINK_ATTR_PARAM_NAME] = { .name = "param-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_REGION_NAME] = { .name = "region-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_INFO_DRIVER_NAME] = { .name = "info-driver-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_INFO_SERIAL_NUMBER] = { .name = "info-serial-number", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_INFO_VERSION_FIXED] = { .name = "info-version-fixed", .type = YNL_PT_NEST, .nest = &devlink_dl_info_version_nest, },
......@@ -95,7 +127,11 @@ struct ynl_policy_attr devlink_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_INFO_VERSION_STORED] = { .name = "info-version-stored", .type = YNL_PT_NEST, .nest = &devlink_dl_info_version_nest, },
[DEVLINK_ATTR_INFO_VERSION_NAME] = { .name = "info-version-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_INFO_VERSION_VALUE] = { .name = "info-version-value", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .name = "health-reporter-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_TRAP_NAME] = { .name = "trap-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_TRAP_GROUP_NAME] = { .name = "trap-group-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_RELOAD_FAILED] = { .name = "reload-failed", .type = YNL_PT_U8, },
[DEVLINK_ATTR_TRAP_POLICER_ID] = { .name = "trap-policer-id", .type = YNL_PT_U32, },
[DEVLINK_ATTR_RELOAD_ACTION] = { .name = "reload-action", .type = YNL_PT_U8, },
[DEVLINK_ATTR_DEV_STATS] = { .name = "dev-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_dev_stats_nest, },
[DEVLINK_ATTR_RELOAD_STATS] = { .name = "reload-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_nest, },
......@@ -105,6 +141,8 @@ struct ynl_policy_attr devlink_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_REMOTE_RELOAD_STATS] = { .name = "remote-reload-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_stats_nest, },
[DEVLINK_ATTR_RELOAD_ACTION_INFO] = { .name = "reload-action-info", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_act_info_nest, },
[DEVLINK_ATTR_RELOAD_ACTION_STATS] = { .name = "reload-action-stats", .type = YNL_PT_NEST, .nest = &devlink_dl_reload_act_stats_nest, },
[DEVLINK_ATTR_RATE_NODE_NAME] = { .name = "rate-node-name", .type = YNL_PT_NUL_STR, },
[DEVLINK_ATTR_LINECARD_INDEX] = { .name = "linecard-index", .type = YNL_PT_U32, },
};
struct ynl_policy_nest devlink_nest = {
......@@ -531,55 +569,29 @@ struct devlink_get_list *devlink_get_dump(struct ynl_sock *ys)
return NULL;
}
/* ============== DEVLINK_CMD_INFO_GET ============== */
/* DEVLINK_CMD_INFO_GET - do */
void devlink_info_get_req_free(struct devlink_info_get_req *req)
/* ============== DEVLINK_CMD_PORT_GET ============== */
/* DEVLINK_CMD_PORT_GET - do */
void devlink_port_get_req_free(struct devlink_port_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void devlink_info_get_rsp_free(struct devlink_info_get_rsp *rsp)
void devlink_port_get_rsp_free(struct devlink_port_get_rsp *rsp)
{
unsigned int i;
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->info_driver_name);
free(rsp->info_serial_number);
for (i = 0; i < rsp->n_info_version_fixed; i++)
devlink_dl_info_version_free(&rsp->info_version_fixed[i]);
free(rsp->info_version_fixed);
for (i = 0; i < rsp->n_info_version_running; i++)
devlink_dl_info_version_free(&rsp->info_version_running[i]);
free(rsp->info_version_running);
for (i = 0; i < rsp->n_info_version_stored; i++)
devlink_dl_info_version_free(&rsp->info_version_stored[i]);
free(rsp->info_version_stored);
free(rsp);
}
int devlink_info_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
int devlink_port_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
unsigned int n_info_version_running = 0;
unsigned int n_info_version_stored = 0;
unsigned int n_info_version_fixed = 0;
struct ynl_parse_arg *yarg = data;
struct devlink_info_get_rsp *dst;
struct devlink_port_get_rsp *dst;
const struct nlattr *attr;
struct ynl_parse_arg parg;
int i;
dst = yarg->data;
parg.ys = yarg->ys;
if (dst->info_version_fixed)
return ynl_error_parse(yarg, "attribute already present (devlink.info-version-fixed)");
if (dst->info_version_running)
return ynl_error_parse(yarg, "attribute already present (devlink.info-version-running)");
if (dst->info_version_stored)
return ynl_error_parse(yarg, "attribute already present (devlink.info-version-stored)");
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
......@@ -606,92 +618,213 @@ int devlink_info_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_INFO_DRIVER_NAME) {
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct devlink_port_get_rsp *
devlink_port_get(struct ynl_sock *ys, struct devlink_port_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_port_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PORT_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_port_get_rsp_parse;
yrs.rsp_cmd = 7;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_port_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_PORT_GET - dump */
int devlink_port_get_rsp_dump_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_port_get_rsp_dump *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.info_driver_name_len = len;
dst->info_driver_name = malloc(len + 1);
memcpy(dst->info_driver_name, mnl_attr_get_str(attr), len);
dst->info_driver_name[len] = 0;
} else if (type == DEVLINK_ATTR_INFO_SERIAL_NUMBER) {
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.info_serial_number_len = len;
dst->info_serial_number = malloc(len + 1);
memcpy(dst->info_serial_number, mnl_attr_get_str(attr), len);
dst->info_serial_number[len] = 0;
} else if (type == DEVLINK_ATTR_INFO_VERSION_FIXED) {
n_info_version_fixed++;
} else if (type == DEVLINK_ATTR_INFO_VERSION_RUNNING) {
n_info_version_running++;
} else if (type == DEVLINK_ATTR_INFO_VERSION_STORED) {
n_info_version_stored++;
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
}
}
if (n_info_version_fixed) {
dst->info_version_fixed = calloc(n_info_version_fixed, sizeof(*dst->info_version_fixed));
dst->n_info_version_fixed = n_info_version_fixed;
i = 0;
parg.rsp_policy = &devlink_dl_info_version_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_FIXED) {
parg.data = &dst->info_version_fixed[i];
if (devlink_dl_info_version_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
}
if (n_info_version_running) {
dst->info_version_running = calloc(n_info_version_running, sizeof(*dst->info_version_running));
dst->n_info_version_running = n_info_version_running;
i = 0;
parg.rsp_policy = &devlink_dl_info_version_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_RUNNING) {
parg.data = &dst->info_version_running[i];
if (devlink_dl_info_version_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
return MNL_CB_OK;
}
void devlink_port_get_rsp_list_free(struct devlink_port_get_rsp_list *rsp)
{
struct devlink_port_get_rsp_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
if (n_info_version_stored) {
dst->info_version_stored = calloc(n_info_version_stored, sizeof(*dst->info_version_stored));
dst->n_info_version_stored = n_info_version_stored;
i = 0;
parg.rsp_policy = &devlink_dl_info_version_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_STORED) {
parg.data = &dst->info_version_stored[i];
if (devlink_dl_info_version_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
struct devlink_port_get_rsp_list *
devlink_port_get_dump(struct ynl_sock *ys,
struct devlink_port_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_port_get_rsp_list);
yds.cb = devlink_port_get_rsp_dump_parse;
yds.rsp_cmd = 7;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_PORT_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_port_get_rsp_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_SB_GET ============== */
/* DEVLINK_CMD_SB_GET - do */
void devlink_sb_get_req_free(struct devlink_sb_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void devlink_sb_get_rsp_free(struct devlink_sb_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_sb_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct devlink_sb_get_rsp *dst;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_SB_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_index = 1;
dst->sb_index = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct devlink_info_get_rsp *
devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req)
struct devlink_sb_get_rsp *
devlink_sb_get(struct ynl_sock *ys, struct devlink_sb_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_info_get_rsp *rsp;
struct devlink_sb_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1);
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
......@@ -699,11 +832,13 @@ devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.sb_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_info_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_INFO_GET;
yrs.cb = devlink_sb_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_SB_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
......@@ -712,39 +847,1062 @@ devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req)
return rsp;
err_free:
devlink_info_get_rsp_free(rsp);
devlink_sb_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_INFO_GET - dump */
void devlink_info_get_list_free(struct devlink_info_get_list *rsp)
/* DEVLINK_CMD_SB_GET - dump */
void devlink_sb_get_list_free(struct devlink_sb_get_list *rsp)
{
struct devlink_info_get_list *next = rsp;
struct devlink_sb_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
unsigned int i;
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.info_driver_name);
free(rsp->obj.info_serial_number);
for (i = 0; i < rsp->obj.n_info_version_fixed; i++)
devlink_dl_info_version_free(&rsp->obj.info_version_fixed[i]);
free(rsp->obj.info_version_fixed);
for (i = 0; i < rsp->obj.n_info_version_running; i++)
devlink_dl_info_version_free(&rsp->obj.info_version_running[i]);
free(rsp->obj.info_version_running);
for (i = 0; i < rsp->obj.n_info_version_stored; i++)
devlink_dl_info_version_free(&rsp->obj.info_version_stored[i]);
free(rsp->obj.info_version_stored);
free(rsp);
}
}
struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys)
struct devlink_sb_get_list *
devlink_sb_get_dump(struct ynl_sock *ys, struct devlink_sb_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_sb_get_list);
yds.cb = devlink_sb_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_SB_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_sb_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_SB_POOL_GET ============== */
/* DEVLINK_CMD_SB_POOL_GET - do */
void devlink_sb_pool_get_req_free(struct devlink_sb_pool_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void devlink_sb_pool_get_rsp_free(struct devlink_sb_pool_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_sb_pool_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_sb_pool_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_SB_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_index = 1;
dst->sb_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_SB_POOL_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_pool_index = 1;
dst->sb_pool_index = mnl_attr_get_u16(attr);
}
}
return MNL_CB_OK;
}
struct devlink_sb_pool_get_rsp *
devlink_sb_pool_get(struct ynl_sock *ys, struct devlink_sb_pool_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_sb_pool_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_POOL_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.sb_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
if (req->_present.sb_pool_index)
mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_sb_pool_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_SB_POOL_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_sb_pool_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_SB_POOL_GET - dump */
void devlink_sb_pool_get_list_free(struct devlink_sb_pool_get_list *rsp)
{
struct devlink_sb_pool_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
}
struct devlink_sb_pool_get_list *
devlink_sb_pool_get_dump(struct ynl_sock *ys,
struct devlink_sb_pool_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_sb_pool_get_list);
yds.cb = devlink_sb_pool_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_SB_POOL_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_POOL_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_sb_pool_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_SB_PORT_POOL_GET ============== */
/* DEVLINK_CMD_SB_PORT_POOL_GET - do */
void
devlink_sb_port_pool_get_req_free(struct devlink_sb_port_pool_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void
devlink_sb_port_pool_get_rsp_free(struct devlink_sb_port_pool_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_sb_port_pool_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_sb_port_pool_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_SB_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_index = 1;
dst->sb_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_SB_POOL_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_pool_index = 1;
dst->sb_pool_index = mnl_attr_get_u16(attr);
}
}
return MNL_CB_OK;
}
struct devlink_sb_port_pool_get_rsp *
devlink_sb_port_pool_get(struct ynl_sock *ys,
struct devlink_sb_port_pool_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_sb_port_pool_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_PORT_POOL_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
if (req->_present.sb_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
if (req->_present.sb_pool_index)
mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_POOL_INDEX, req->sb_pool_index);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_sb_port_pool_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_SB_PORT_POOL_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_sb_port_pool_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_SB_PORT_POOL_GET - dump */
void
devlink_sb_port_pool_get_list_free(struct devlink_sb_port_pool_get_list *rsp)
{
struct devlink_sb_port_pool_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
}
struct devlink_sb_port_pool_get_list *
devlink_sb_port_pool_get_dump(struct ynl_sock *ys,
struct devlink_sb_port_pool_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_sb_port_pool_get_list);
yds.cb = devlink_sb_port_pool_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_SB_PORT_POOL_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_PORT_POOL_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_sb_port_pool_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_SB_TC_POOL_BIND_GET ============== */
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - do */
void
devlink_sb_tc_pool_bind_get_req_free(struct devlink_sb_tc_pool_bind_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void
devlink_sb_tc_pool_bind_get_rsp_free(struct devlink_sb_tc_pool_bind_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_sb_tc_pool_bind_get_rsp_parse(const struct nlmsghdr *nlh,
void *data)
{
struct devlink_sb_tc_pool_bind_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_SB_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_index = 1;
dst->sb_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_SB_POOL_TYPE) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_pool_type = 1;
dst->sb_pool_type = mnl_attr_get_u8(attr);
} else if (type == DEVLINK_ATTR_SB_TC_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sb_tc_index = 1;
dst->sb_tc_index = mnl_attr_get_u16(attr);
}
}
return MNL_CB_OK;
}
struct devlink_sb_tc_pool_bind_get_rsp *
devlink_sb_tc_pool_bind_get(struct ynl_sock *ys,
struct devlink_sb_tc_pool_bind_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_sb_tc_pool_bind_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SB_TC_POOL_BIND_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
if (req->_present.sb_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_SB_INDEX, req->sb_index);
if (req->_present.sb_pool_type)
mnl_attr_put_u8(nlh, DEVLINK_ATTR_SB_POOL_TYPE, req->sb_pool_type);
if (req->_present.sb_tc_index)
mnl_attr_put_u16(nlh, DEVLINK_ATTR_SB_TC_INDEX, req->sb_tc_index);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_sb_tc_pool_bind_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_SB_TC_POOL_BIND_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_sb_tc_pool_bind_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - dump */
void
devlink_sb_tc_pool_bind_get_list_free(struct devlink_sb_tc_pool_bind_get_list *rsp)
{
struct devlink_sb_tc_pool_bind_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
}
struct devlink_sb_tc_pool_bind_get_list *
devlink_sb_tc_pool_bind_get_dump(struct ynl_sock *ys,
struct devlink_sb_tc_pool_bind_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_sb_tc_pool_bind_get_list);
yds.cb = devlink_sb_tc_pool_bind_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_SB_TC_POOL_BIND_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SB_TC_POOL_BIND_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_sb_tc_pool_bind_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_PARAM_GET ============== */
/* DEVLINK_CMD_PARAM_GET - do */
void devlink_param_get_req_free(struct devlink_param_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req->param_name);
free(req);
}
void devlink_param_get_rsp_free(struct devlink_param_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->param_name);
free(rsp);
}
int devlink_param_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_param_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PARAM_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.param_name_len = len;
dst->param_name = malloc(len + 1);
memcpy(dst->param_name, mnl_attr_get_str(attr), len);
dst->param_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_param_get_rsp *
devlink_param_get(struct ynl_sock *ys, struct devlink_param_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_param_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_PARAM_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.param_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_PARAM_NAME, req->param_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_param_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_PARAM_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_param_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_PARAM_GET - dump */
void devlink_param_get_list_free(struct devlink_param_get_list *rsp)
{
struct devlink_param_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.param_name);
free(rsp);
}
}
struct devlink_param_get_list *
devlink_param_get_dump(struct ynl_sock *ys,
struct devlink_param_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_param_get_list);
yds.cb = devlink_param_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_PARAM_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_PARAM_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_param_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_REGION_GET ============== */
/* DEVLINK_CMD_REGION_GET - do */
void devlink_region_get_req_free(struct devlink_region_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req->region_name);
free(req);
}
void devlink_region_get_rsp_free(struct devlink_region_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->region_name);
free(rsp);
}
int devlink_region_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_region_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_REGION_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.region_name_len = len;
dst->region_name = malloc(len + 1);
memcpy(dst->region_name, mnl_attr_get_str(attr), len);
dst->region_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_region_get_rsp *
devlink_region_get(struct ynl_sock *ys, struct devlink_region_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_region_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_REGION_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
if (req->_present.region_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_REGION_NAME, req->region_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_region_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_REGION_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_region_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_REGION_GET - dump */
void devlink_region_get_list_free(struct devlink_region_get_list *rsp)
{
struct devlink_region_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.region_name);
free(rsp);
}
}
struct devlink_region_get_list *
devlink_region_get_dump(struct ynl_sock *ys,
struct devlink_region_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_region_get_list);
yds.cb = devlink_region_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_REGION_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_REGION_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_region_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_INFO_GET ============== */
/* DEVLINK_CMD_INFO_GET - do */
void devlink_info_get_req_free(struct devlink_info_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void devlink_info_get_rsp_free(struct devlink_info_get_rsp *rsp)
{
unsigned int i;
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->info_driver_name);
free(rsp->info_serial_number);
for (i = 0; i < rsp->n_info_version_fixed; i++)
devlink_dl_info_version_free(&rsp->info_version_fixed[i]);
free(rsp->info_version_fixed);
for (i = 0; i < rsp->n_info_version_running; i++)
devlink_dl_info_version_free(&rsp->info_version_running[i]);
free(rsp->info_version_running);
for (i = 0; i < rsp->n_info_version_stored; i++)
devlink_dl_info_version_free(&rsp->info_version_stored[i]);
free(rsp->info_version_stored);
free(rsp);
}
int devlink_info_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
unsigned int n_info_version_running = 0;
unsigned int n_info_version_stored = 0;
unsigned int n_info_version_fixed = 0;
struct ynl_parse_arg *yarg = data;
struct devlink_info_get_rsp *dst;
const struct nlattr *attr;
struct ynl_parse_arg parg;
int i;
dst = yarg->data;
parg.ys = yarg->ys;
if (dst->info_version_fixed)
return ynl_error_parse(yarg, "attribute already present (devlink.info-version-fixed)");
if (dst->info_version_running)
return ynl_error_parse(yarg, "attribute already present (devlink.info-version-running)");
if (dst->info_version_stored)
return ynl_error_parse(yarg, "attribute already present (devlink.info-version-stored)");
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_INFO_DRIVER_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.info_driver_name_len = len;
dst->info_driver_name = malloc(len + 1);
memcpy(dst->info_driver_name, mnl_attr_get_str(attr), len);
dst->info_driver_name[len] = 0;
} else if (type == DEVLINK_ATTR_INFO_SERIAL_NUMBER) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.info_serial_number_len = len;
dst->info_serial_number = malloc(len + 1);
memcpy(dst->info_serial_number, mnl_attr_get_str(attr), len);
dst->info_serial_number[len] = 0;
} else if (type == DEVLINK_ATTR_INFO_VERSION_FIXED) {
n_info_version_fixed++;
} else if (type == DEVLINK_ATTR_INFO_VERSION_RUNNING) {
n_info_version_running++;
} else if (type == DEVLINK_ATTR_INFO_VERSION_STORED) {
n_info_version_stored++;
}
}
if (n_info_version_fixed) {
dst->info_version_fixed = calloc(n_info_version_fixed, sizeof(*dst->info_version_fixed));
dst->n_info_version_fixed = n_info_version_fixed;
i = 0;
parg.rsp_policy = &devlink_dl_info_version_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_FIXED) {
parg.data = &dst->info_version_fixed[i];
if (devlink_dl_info_version_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
}
if (n_info_version_running) {
dst->info_version_running = calloc(n_info_version_running, sizeof(*dst->info_version_running));
dst->n_info_version_running = n_info_version_running;
i = 0;
parg.rsp_policy = &devlink_dl_info_version_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_RUNNING) {
parg.data = &dst->info_version_running[i];
if (devlink_dl_info_version_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
}
if (n_info_version_stored) {
dst->info_version_stored = calloc(n_info_version_stored, sizeof(*dst->info_version_stored));
dst->n_info_version_stored = n_info_version_stored;
i = 0;
parg.rsp_policy = &devlink_dl_info_version_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == DEVLINK_ATTR_INFO_VERSION_STORED) {
parg.data = &dst->info_version_stored[i];
if (devlink_dl_info_version_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
}
return MNL_CB_OK;
}
struct devlink_info_get_rsp *
devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_info_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_info_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_INFO_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_info_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_INFO_GET - dump */
void devlink_info_get_list_free(struct devlink_info_get_list *rsp)
{
struct devlink_info_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
unsigned int i;
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.info_driver_name);
free(rsp->obj.info_serial_number);
for (i = 0; i < rsp->obj.n_info_version_fixed; i++)
devlink_dl_info_version_free(&rsp->obj.info_version_fixed[i]);
free(rsp->obj.info_version_fixed);
for (i = 0; i < rsp->obj.n_info_version_running; i++)
devlink_dl_info_version_free(&rsp->obj.info_version_running[i]);
free(rsp->obj.info_version_running);
for (i = 0; i < rsp->obj.n_info_version_stored; i++)
devlink_dl_info_version_free(&rsp->obj.info_version_stored[i]);
free(rsp->obj.info_version_stored);
free(rsp);
}
}
struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
......@@ -756,7 +1914,784 @@ struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys)
yds.rsp_cmd = DEVLINK_CMD_INFO_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1);
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_INFO_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_info_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_HEALTH_REPORTER_GET ============== */
/* DEVLINK_CMD_HEALTH_REPORTER_GET - do */
void
devlink_health_reporter_get_req_free(struct devlink_health_reporter_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req->health_reporter_name);
free(req);
}
void
devlink_health_reporter_get_rsp_free(struct devlink_health_reporter_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->health_reporter_name);
free(rsp);
}
int devlink_health_reporter_get_rsp_parse(const struct nlmsghdr *nlh,
void *data)
{
struct devlink_health_reporter_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_HEALTH_REPORTER_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.health_reporter_name_len = len;
dst->health_reporter_name = malloc(len + 1);
memcpy(dst->health_reporter_name, mnl_attr_get_str(attr), len);
dst->health_reporter_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_health_reporter_get_rsp *
devlink_health_reporter_get(struct ynl_sock *ys,
struct devlink_health_reporter_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_health_reporter_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
if (req->_present.health_reporter_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_HEALTH_REPORTER_NAME, req->health_reporter_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_health_reporter_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_HEALTH_REPORTER_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_health_reporter_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_HEALTH_REPORTER_GET - dump */
void
devlink_health_reporter_get_list_free(struct devlink_health_reporter_get_list *rsp)
{
struct devlink_health_reporter_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.health_reporter_name);
free(rsp);
}
}
struct devlink_health_reporter_get_list *
devlink_health_reporter_get_dump(struct ynl_sock *ys,
struct devlink_health_reporter_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_health_reporter_get_list);
yds.cb = devlink_health_reporter_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_HEALTH_REPORTER_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_HEALTH_REPORTER_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_health_reporter_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_TRAP_GET ============== */
/* DEVLINK_CMD_TRAP_GET - do */
void devlink_trap_get_req_free(struct devlink_trap_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req->trap_name);
free(req);
}
void devlink_trap_get_rsp_free(struct devlink_trap_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->trap_name);
free(rsp);
}
int devlink_trap_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct devlink_trap_get_rsp *dst;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_TRAP_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.trap_name_len = len;
dst->trap_name = malloc(len + 1);
memcpy(dst->trap_name, mnl_attr_get_str(attr), len);
dst->trap_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_trap_get_rsp *
devlink_trap_get(struct ynl_sock *ys, struct devlink_trap_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_trap_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.trap_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_TRAP_NAME, req->trap_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_trap_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_TRAP_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_trap_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_TRAP_GET - dump */
void devlink_trap_get_list_free(struct devlink_trap_get_list *rsp)
{
struct devlink_trap_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.trap_name);
free(rsp);
}
}
struct devlink_trap_get_list *
devlink_trap_get_dump(struct ynl_sock *ys,
struct devlink_trap_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_trap_get_list);
yds.cb = devlink_trap_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_TRAP_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_TRAP_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_trap_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_TRAP_GROUP_GET ============== */
/* DEVLINK_CMD_TRAP_GROUP_GET - do */
void devlink_trap_group_get_req_free(struct devlink_trap_group_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req->trap_group_name);
free(req);
}
void devlink_trap_group_get_rsp_free(struct devlink_trap_group_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->trap_group_name);
free(rsp);
}
int devlink_trap_group_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_trap_group_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_TRAP_GROUP_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.trap_group_name_len = len;
dst->trap_group_name = malloc(len + 1);
memcpy(dst->trap_group_name, mnl_attr_get_str(attr), len);
dst->trap_group_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_trap_group_get_rsp *
devlink_trap_group_get(struct ynl_sock *ys,
struct devlink_trap_group_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_trap_group_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_GROUP_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.trap_group_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_TRAP_GROUP_NAME, req->trap_group_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_trap_group_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_TRAP_GROUP_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_trap_group_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_TRAP_GROUP_GET - dump */
void devlink_trap_group_get_list_free(struct devlink_trap_group_get_list *rsp)
{
struct devlink_trap_group_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.trap_group_name);
free(rsp);
}
}
struct devlink_trap_group_get_list *
devlink_trap_group_get_dump(struct ynl_sock *ys,
struct devlink_trap_group_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_trap_group_get_list);
yds.cb = devlink_trap_group_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_TRAP_GROUP_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_TRAP_GROUP_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_trap_group_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_TRAP_POLICER_GET ============== */
/* DEVLINK_CMD_TRAP_POLICER_GET - do */
void
devlink_trap_policer_get_req_free(struct devlink_trap_policer_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void
devlink_trap_policer_get_rsp_free(struct devlink_trap_policer_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_trap_policer_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_trap_policer_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_TRAP_POLICER_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.trap_policer_id = 1;
dst->trap_policer_id = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct devlink_trap_policer_get_rsp *
devlink_trap_policer_get(struct ynl_sock *ys,
struct devlink_trap_policer_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_trap_policer_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_TRAP_POLICER_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.trap_policer_id)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_TRAP_POLICER_ID, req->trap_policer_id);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_trap_policer_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_TRAP_POLICER_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_trap_policer_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_TRAP_POLICER_GET - dump */
void
devlink_trap_policer_get_list_free(struct devlink_trap_policer_get_list *rsp)
{
struct devlink_trap_policer_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
}
struct devlink_trap_policer_get_list *
devlink_trap_policer_get_dump(struct ynl_sock *ys,
struct devlink_trap_policer_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_trap_policer_get_list);
yds.cb = devlink_trap_policer_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_TRAP_POLICER_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_TRAP_POLICER_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_trap_policer_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_RATE_GET ============== */
/* DEVLINK_CMD_RATE_GET - do */
void devlink_rate_get_req_free(struct devlink_rate_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req->rate_node_name);
free(req);
}
void devlink_rate_get_rsp_free(struct devlink_rate_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp->rate_node_name);
free(rsp);
}
int devlink_rate_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct devlink_rate_get_rsp *dst;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_PORT_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port_index = 1;
dst->port_index = mnl_attr_get_u32(attr);
} else if (type == DEVLINK_ATTR_RATE_NODE_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.rate_node_name_len = len;
dst->rate_node_name = malloc(len + 1);
memcpy(dst->rate_node_name, mnl_attr_get_str(attr), len);
dst->rate_node_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_rate_get_rsp *
devlink_rate_get(struct ynl_sock *ys, struct devlink_rate_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_rate_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_RATE_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.port_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
if (req->_present.rate_node_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_RATE_NODE_NAME, req->rate_node_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_rate_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_RATE_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_rate_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_RATE_GET - dump */
void devlink_rate_get_list_free(struct devlink_rate_get_list *rsp)
{
struct devlink_rate_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp->obj.rate_node_name);
free(rsp);
}
}
struct devlink_rate_get_list *
devlink_rate_get_dump(struct ynl_sock *ys,
struct devlink_rate_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_rate_get_list);
yds.cb = devlink_rate_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_RATE_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_RATE_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
......@@ -765,7 +2700,280 @@ struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys)
return yds.first;
free_list:
devlink_info_get_list_free(yds.first);
devlink_rate_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_LINECARD_GET ============== */
/* DEVLINK_CMD_LINECARD_GET - do */
void devlink_linecard_get_req_free(struct devlink_linecard_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void devlink_linecard_get_rsp_free(struct devlink_linecard_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_linecard_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_linecard_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
} else if (type == DEVLINK_ATTR_LINECARD_INDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.linecard_index = 1;
dst->linecard_index = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct devlink_linecard_get_rsp *
devlink_linecard_get(struct ynl_sock *ys, struct devlink_linecard_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_linecard_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_LINECARD_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
if (req->_present.linecard_index)
mnl_attr_put_u32(nlh, DEVLINK_ATTR_LINECARD_INDEX, req->linecard_index);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_linecard_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_LINECARD_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_linecard_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_LINECARD_GET - dump */
void devlink_linecard_get_list_free(struct devlink_linecard_get_list *rsp)
{
struct devlink_linecard_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
}
struct devlink_linecard_get_list *
devlink_linecard_get_dump(struct ynl_sock *ys,
struct devlink_linecard_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_linecard_get_list);
yds.cb = devlink_linecard_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_LINECARD_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_LINECARD_GET, 1);
ys->req_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_linecard_get_list_free(yds.first);
return NULL;
}
/* ============== DEVLINK_CMD_SELFTESTS_GET ============== */
/* DEVLINK_CMD_SELFTESTS_GET - do */
void devlink_selftests_get_req_free(struct devlink_selftests_get_req *req)
{
free(req->bus_name);
free(req->dev_name);
free(req);
}
void devlink_selftests_get_rsp_free(struct devlink_selftests_get_rsp *rsp)
{
free(rsp->bus_name);
free(rsp->dev_name);
free(rsp);
}
int devlink_selftests_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct devlink_selftests_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == DEVLINK_ATTR_BUS_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.bus_name_len = len;
dst->bus_name = malloc(len + 1);
memcpy(dst->bus_name, mnl_attr_get_str(attr), len);
dst->bus_name[len] = 0;
} else if (type == DEVLINK_ATTR_DEV_NAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.dev_name_len = len;
dst->dev_name = malloc(len + 1);
memcpy(dst->dev_name, mnl_attr_get_str(attr), len);
dst->dev_name[len] = 0;
}
}
return MNL_CB_OK;
}
struct devlink_selftests_get_rsp *
devlink_selftests_get(struct ynl_sock *ys,
struct devlink_selftests_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct devlink_selftests_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, DEVLINK_CMD_SELFTESTS_GET, 1);
ys->req_policy = &devlink_nest;
yrs.yarg.rsp_policy = &devlink_nest;
if (req->_present.bus_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
if (req->_present.dev_name_len)
mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = devlink_selftests_get_rsp_parse;
yrs.rsp_cmd = DEVLINK_CMD_SELFTESTS_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
devlink_selftests_get_rsp_free(rsp);
return NULL;
}
/* DEVLINK_CMD_SELFTESTS_GET - dump */
void devlink_selftests_get_list_free(struct devlink_selftests_get_list *rsp)
{
struct devlink_selftests_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.bus_name);
free(rsp->obj.dev_name);
free(rsp);
}
}
struct devlink_selftests_get_list *
devlink_selftests_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct devlink_selftests_get_list);
yds.cb = devlink_selftests_get_rsp_parse;
yds.rsp_cmd = DEVLINK_CMD_SELFTESTS_GET;
yds.rsp_policy = &devlink_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, DEVLINK_CMD_SELFTESTS_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
devlink_selftests_get_list_free(yds.first);
return NULL;
}
......
......@@ -17,6 +17,7 @@ extern const struct ynl_family ynl_devlink_family;
/* Enums */
const char *devlink_op_str(int op);
const char *devlink_sb_pool_type_str(enum devlink_sb_pool_type value);
/* Common nested types */
struct devlink_dl_info_version {
......@@ -140,6 +141,939 @@ void devlink_get_list_free(struct devlink_get_list *rsp);
struct devlink_get_list *devlink_get_dump(struct ynl_sock *ys);
/* ============== DEVLINK_CMD_PORT_GET ============== */
/* DEVLINK_CMD_PORT_GET - do */
struct devlink_port_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
};
static inline struct devlink_port_get_req *devlink_port_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_port_get_req));
}
void devlink_port_get_req_free(struct devlink_port_get_req *req);
static inline void
devlink_port_get_req_set_bus_name(struct devlink_port_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_port_get_req_set_dev_name(struct devlink_port_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_port_get_req_set_port_index(struct devlink_port_get_req *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
struct devlink_port_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
};
void devlink_port_get_rsp_free(struct devlink_port_get_rsp *rsp);
/*
* Get devlink port instances.
*/
struct devlink_port_get_rsp *
devlink_port_get(struct ynl_sock *ys, struct devlink_port_get_req *req);
/* DEVLINK_CMD_PORT_GET - dump */
struct devlink_port_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_port_get_req_dump *
devlink_port_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_port_get_req_dump));
}
void devlink_port_get_req_dump_free(struct devlink_port_get_req_dump *req);
static inline void
devlink_port_get_req_dump_set_bus_name(struct devlink_port_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_port_get_req_dump_set_dev_name(struct devlink_port_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_port_get_rsp_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
};
struct devlink_port_get_rsp_list {
struct devlink_port_get_rsp_list *next;
struct devlink_port_get_rsp_dump obj __attribute__ ((aligned (8)));
};
void devlink_port_get_rsp_list_free(struct devlink_port_get_rsp_list *rsp);
struct devlink_port_get_rsp_list *
devlink_port_get_dump(struct ynl_sock *ys,
struct devlink_port_get_req_dump *req);
/* ============== DEVLINK_CMD_SB_GET ============== */
/* DEVLINK_CMD_SB_GET - do */
struct devlink_sb_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 sb_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 sb_index;
};
static inline struct devlink_sb_get_req *devlink_sb_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_get_req));
}
void devlink_sb_get_req_free(struct devlink_sb_get_req *req);
static inline void
devlink_sb_get_req_set_bus_name(struct devlink_sb_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_get_req_set_dev_name(struct devlink_sb_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_sb_get_req_set_sb_index(struct devlink_sb_get_req *req, __u32 sb_index)
{
req->_present.sb_index = 1;
req->sb_index = sb_index;
}
struct devlink_sb_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 sb_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 sb_index;
};
void devlink_sb_get_rsp_free(struct devlink_sb_get_rsp *rsp);
/*
* Get shared buffer instances.
*/
struct devlink_sb_get_rsp *
devlink_sb_get(struct ynl_sock *ys, struct devlink_sb_get_req *req);
/* DEVLINK_CMD_SB_GET - dump */
struct devlink_sb_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_sb_get_req_dump *
devlink_sb_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_get_req_dump));
}
void devlink_sb_get_req_dump_free(struct devlink_sb_get_req_dump *req);
static inline void
devlink_sb_get_req_dump_set_bus_name(struct devlink_sb_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_get_req_dump_set_dev_name(struct devlink_sb_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_sb_get_list {
struct devlink_sb_get_list *next;
struct devlink_sb_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_sb_get_list_free(struct devlink_sb_get_list *rsp);
struct devlink_sb_get_list *
devlink_sb_get_dump(struct ynl_sock *ys, struct devlink_sb_get_req_dump *req);
/* ============== DEVLINK_CMD_SB_POOL_GET ============== */
/* DEVLINK_CMD_SB_POOL_GET - do */
struct devlink_sb_pool_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 sb_index:1;
__u32 sb_pool_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 sb_index;
__u16 sb_pool_index;
};
static inline struct devlink_sb_pool_get_req *
devlink_sb_pool_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_pool_get_req));
}
void devlink_sb_pool_get_req_free(struct devlink_sb_pool_get_req *req);
static inline void
devlink_sb_pool_get_req_set_bus_name(struct devlink_sb_pool_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_pool_get_req_set_dev_name(struct devlink_sb_pool_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_sb_pool_get_req_set_sb_index(struct devlink_sb_pool_get_req *req,
__u32 sb_index)
{
req->_present.sb_index = 1;
req->sb_index = sb_index;
}
static inline void
devlink_sb_pool_get_req_set_sb_pool_index(struct devlink_sb_pool_get_req *req,
__u16 sb_pool_index)
{
req->_present.sb_pool_index = 1;
req->sb_pool_index = sb_pool_index;
}
struct devlink_sb_pool_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 sb_index:1;
__u32 sb_pool_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 sb_index;
__u16 sb_pool_index;
};
void devlink_sb_pool_get_rsp_free(struct devlink_sb_pool_get_rsp *rsp);
/*
* Get shared buffer pool instances.
*/
struct devlink_sb_pool_get_rsp *
devlink_sb_pool_get(struct ynl_sock *ys, struct devlink_sb_pool_get_req *req);
/* DEVLINK_CMD_SB_POOL_GET - dump */
struct devlink_sb_pool_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_sb_pool_get_req_dump *
devlink_sb_pool_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_pool_get_req_dump));
}
void
devlink_sb_pool_get_req_dump_free(struct devlink_sb_pool_get_req_dump *req);
static inline void
devlink_sb_pool_get_req_dump_set_bus_name(struct devlink_sb_pool_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_pool_get_req_dump_set_dev_name(struct devlink_sb_pool_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_sb_pool_get_list {
struct devlink_sb_pool_get_list *next;
struct devlink_sb_pool_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_sb_pool_get_list_free(struct devlink_sb_pool_get_list *rsp);
struct devlink_sb_pool_get_list *
devlink_sb_pool_get_dump(struct ynl_sock *ys,
struct devlink_sb_pool_get_req_dump *req);
/* ============== DEVLINK_CMD_SB_PORT_POOL_GET ============== */
/* DEVLINK_CMD_SB_PORT_POOL_GET - do */
struct devlink_sb_port_pool_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 sb_index:1;
__u32 sb_pool_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
__u32 sb_index;
__u16 sb_pool_index;
};
static inline struct devlink_sb_port_pool_get_req *
devlink_sb_port_pool_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_port_pool_get_req));
}
void
devlink_sb_port_pool_get_req_free(struct devlink_sb_port_pool_get_req *req);
static inline void
devlink_sb_port_pool_get_req_set_bus_name(struct devlink_sb_port_pool_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_port_pool_get_req_set_dev_name(struct devlink_sb_port_pool_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_sb_port_pool_get_req_set_port_index(struct devlink_sb_port_pool_get_req *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
static inline void
devlink_sb_port_pool_get_req_set_sb_index(struct devlink_sb_port_pool_get_req *req,
__u32 sb_index)
{
req->_present.sb_index = 1;
req->sb_index = sb_index;
}
static inline void
devlink_sb_port_pool_get_req_set_sb_pool_index(struct devlink_sb_port_pool_get_req *req,
__u16 sb_pool_index)
{
req->_present.sb_pool_index = 1;
req->sb_pool_index = sb_pool_index;
}
struct devlink_sb_port_pool_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 sb_index:1;
__u32 sb_pool_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
__u32 sb_index;
__u16 sb_pool_index;
};
void
devlink_sb_port_pool_get_rsp_free(struct devlink_sb_port_pool_get_rsp *rsp);
/*
* Get shared buffer port-pool combinations and threshold.
*/
struct devlink_sb_port_pool_get_rsp *
devlink_sb_port_pool_get(struct ynl_sock *ys,
struct devlink_sb_port_pool_get_req *req);
/* DEVLINK_CMD_SB_PORT_POOL_GET - dump */
struct devlink_sb_port_pool_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_sb_port_pool_get_req_dump *
devlink_sb_port_pool_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_port_pool_get_req_dump));
}
void
devlink_sb_port_pool_get_req_dump_free(struct devlink_sb_port_pool_get_req_dump *req);
static inline void
devlink_sb_port_pool_get_req_dump_set_bus_name(struct devlink_sb_port_pool_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_port_pool_get_req_dump_set_dev_name(struct devlink_sb_port_pool_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_sb_port_pool_get_list {
struct devlink_sb_port_pool_get_list *next;
struct devlink_sb_port_pool_get_rsp obj __attribute__ ((aligned (8)));
};
void
devlink_sb_port_pool_get_list_free(struct devlink_sb_port_pool_get_list *rsp);
struct devlink_sb_port_pool_get_list *
devlink_sb_port_pool_get_dump(struct ynl_sock *ys,
struct devlink_sb_port_pool_get_req_dump *req);
/* ============== DEVLINK_CMD_SB_TC_POOL_BIND_GET ============== */
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - do */
struct devlink_sb_tc_pool_bind_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 sb_index:1;
__u32 sb_pool_type:1;
__u32 sb_tc_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
__u32 sb_index;
enum devlink_sb_pool_type sb_pool_type;
__u16 sb_tc_index;
};
static inline struct devlink_sb_tc_pool_bind_get_req *
devlink_sb_tc_pool_bind_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_tc_pool_bind_get_req));
}
void
devlink_sb_tc_pool_bind_get_req_free(struct devlink_sb_tc_pool_bind_get_req *req);
static inline void
devlink_sb_tc_pool_bind_get_req_set_bus_name(struct devlink_sb_tc_pool_bind_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_tc_pool_bind_get_req_set_dev_name(struct devlink_sb_tc_pool_bind_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_sb_tc_pool_bind_get_req_set_port_index(struct devlink_sb_tc_pool_bind_get_req *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
static inline void
devlink_sb_tc_pool_bind_get_req_set_sb_index(struct devlink_sb_tc_pool_bind_get_req *req,
__u32 sb_index)
{
req->_present.sb_index = 1;
req->sb_index = sb_index;
}
static inline void
devlink_sb_tc_pool_bind_get_req_set_sb_pool_type(struct devlink_sb_tc_pool_bind_get_req *req,
enum devlink_sb_pool_type sb_pool_type)
{
req->_present.sb_pool_type = 1;
req->sb_pool_type = sb_pool_type;
}
static inline void
devlink_sb_tc_pool_bind_get_req_set_sb_tc_index(struct devlink_sb_tc_pool_bind_get_req *req,
__u16 sb_tc_index)
{
req->_present.sb_tc_index = 1;
req->sb_tc_index = sb_tc_index;
}
struct devlink_sb_tc_pool_bind_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 sb_index:1;
__u32 sb_pool_type:1;
__u32 sb_tc_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
__u32 sb_index;
enum devlink_sb_pool_type sb_pool_type;
__u16 sb_tc_index;
};
void
devlink_sb_tc_pool_bind_get_rsp_free(struct devlink_sb_tc_pool_bind_get_rsp *rsp);
/*
* Get shared buffer port-TC to pool bindings and threshold.
*/
struct devlink_sb_tc_pool_bind_get_rsp *
devlink_sb_tc_pool_bind_get(struct ynl_sock *ys,
struct devlink_sb_tc_pool_bind_get_req *req);
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - dump */
struct devlink_sb_tc_pool_bind_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_sb_tc_pool_bind_get_req_dump *
devlink_sb_tc_pool_bind_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_sb_tc_pool_bind_get_req_dump));
}
void
devlink_sb_tc_pool_bind_get_req_dump_free(struct devlink_sb_tc_pool_bind_get_req_dump *req);
static inline void
devlink_sb_tc_pool_bind_get_req_dump_set_bus_name(struct devlink_sb_tc_pool_bind_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_sb_tc_pool_bind_get_req_dump_set_dev_name(struct devlink_sb_tc_pool_bind_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_sb_tc_pool_bind_get_list {
struct devlink_sb_tc_pool_bind_get_list *next;
struct devlink_sb_tc_pool_bind_get_rsp obj __attribute__ ((aligned (8)));
};
void
devlink_sb_tc_pool_bind_get_list_free(struct devlink_sb_tc_pool_bind_get_list *rsp);
struct devlink_sb_tc_pool_bind_get_list *
devlink_sb_tc_pool_bind_get_dump(struct ynl_sock *ys,
struct devlink_sb_tc_pool_bind_get_req_dump *req);
/* ============== DEVLINK_CMD_PARAM_GET ============== */
/* DEVLINK_CMD_PARAM_GET - do */
struct devlink_param_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 param_name_len;
} _present;
char *bus_name;
char *dev_name;
char *param_name;
};
static inline struct devlink_param_get_req *devlink_param_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_param_get_req));
}
void devlink_param_get_req_free(struct devlink_param_get_req *req);
static inline void
devlink_param_get_req_set_bus_name(struct devlink_param_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_param_get_req_set_dev_name(struct devlink_param_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_param_get_req_set_param_name(struct devlink_param_get_req *req,
const char *param_name)
{
free(req->param_name);
req->_present.param_name_len = strlen(param_name);
req->param_name = malloc(req->_present.param_name_len + 1);
memcpy(req->param_name, param_name, req->_present.param_name_len);
req->param_name[req->_present.param_name_len] = 0;
}
struct devlink_param_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 param_name_len;
} _present;
char *bus_name;
char *dev_name;
char *param_name;
};
void devlink_param_get_rsp_free(struct devlink_param_get_rsp *rsp);
/*
* Get param instances.
*/
struct devlink_param_get_rsp *
devlink_param_get(struct ynl_sock *ys, struct devlink_param_get_req *req);
/* DEVLINK_CMD_PARAM_GET - dump */
struct devlink_param_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_param_get_req_dump *
devlink_param_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_param_get_req_dump));
}
void devlink_param_get_req_dump_free(struct devlink_param_get_req_dump *req);
static inline void
devlink_param_get_req_dump_set_bus_name(struct devlink_param_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_param_get_req_dump_set_dev_name(struct devlink_param_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_param_get_list {
struct devlink_param_get_list *next;
struct devlink_param_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_param_get_list_free(struct devlink_param_get_list *rsp);
struct devlink_param_get_list *
devlink_param_get_dump(struct ynl_sock *ys,
struct devlink_param_get_req_dump *req);
/* ============== DEVLINK_CMD_REGION_GET ============== */
/* DEVLINK_CMD_REGION_GET - do */
struct devlink_region_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 region_name_len;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
char *region_name;
};
static inline struct devlink_region_get_req *devlink_region_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_region_get_req));
}
void devlink_region_get_req_free(struct devlink_region_get_req *req);
static inline void
devlink_region_get_req_set_bus_name(struct devlink_region_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_region_get_req_set_dev_name(struct devlink_region_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_region_get_req_set_port_index(struct devlink_region_get_req *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
static inline void
devlink_region_get_req_set_region_name(struct devlink_region_get_req *req,
const char *region_name)
{
free(req->region_name);
req->_present.region_name_len = strlen(region_name);
req->region_name = malloc(req->_present.region_name_len + 1);
memcpy(req->region_name, region_name, req->_present.region_name_len);
req->region_name[req->_present.region_name_len] = 0;
}
struct devlink_region_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 region_name_len;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
char *region_name;
};
void devlink_region_get_rsp_free(struct devlink_region_get_rsp *rsp);
/*
* Get region instances.
*/
struct devlink_region_get_rsp *
devlink_region_get(struct ynl_sock *ys, struct devlink_region_get_req *req);
/* DEVLINK_CMD_REGION_GET - dump */
struct devlink_region_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_region_get_req_dump *
devlink_region_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_region_get_req_dump));
}
void devlink_region_get_req_dump_free(struct devlink_region_get_req_dump *req);
static inline void
devlink_region_get_req_dump_set_bus_name(struct devlink_region_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_region_get_req_dump_set_dev_name(struct devlink_region_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_region_get_list {
struct devlink_region_get_list *next;
struct devlink_region_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_region_get_list_free(struct devlink_region_get_list *rsp);
struct devlink_region_get_list *
devlink_region_get_dump(struct ynl_sock *ys,
struct devlink_region_get_req_dump *req);
/* ============== DEVLINK_CMD_INFO_GET ============== */
/* DEVLINK_CMD_INFO_GET - do */
struct devlink_info_get_req {
......@@ -152,14 +1086,611 @@ struct devlink_info_get_req {
char *dev_name;
};
static inline struct devlink_info_get_req *devlink_info_get_req_alloc(void)
static inline struct devlink_info_get_req *devlink_info_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_info_get_req));
}
void devlink_info_get_req_free(struct devlink_info_get_req *req);
static inline void
devlink_info_get_req_set_bus_name(struct devlink_info_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_info_get_req_set_dev_name(struct devlink_info_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_info_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 info_driver_name_len;
__u32 info_serial_number_len;
} _present;
char *bus_name;
char *dev_name;
char *info_driver_name;
char *info_serial_number;
unsigned int n_info_version_fixed;
struct devlink_dl_info_version *info_version_fixed;
unsigned int n_info_version_running;
struct devlink_dl_info_version *info_version_running;
unsigned int n_info_version_stored;
struct devlink_dl_info_version *info_version_stored;
};
void devlink_info_get_rsp_free(struct devlink_info_get_rsp *rsp);
/*
* Get device information, like driver name, hardware and firmware versions etc.
*/
struct devlink_info_get_rsp *
devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req);
/* DEVLINK_CMD_INFO_GET - dump */
struct devlink_info_get_list {
struct devlink_info_get_list *next;
struct devlink_info_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_info_get_list_free(struct devlink_info_get_list *rsp);
struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys);
/* ============== DEVLINK_CMD_HEALTH_REPORTER_GET ============== */
/* DEVLINK_CMD_HEALTH_REPORTER_GET - do */
struct devlink_health_reporter_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 health_reporter_name_len;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
char *health_reporter_name;
};
static inline struct devlink_health_reporter_get_req *
devlink_health_reporter_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_health_reporter_get_req));
}
void
devlink_health_reporter_get_req_free(struct devlink_health_reporter_get_req *req);
static inline void
devlink_health_reporter_get_req_set_bus_name(struct devlink_health_reporter_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_health_reporter_get_req_set_dev_name(struct devlink_health_reporter_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_health_reporter_get_req_set_port_index(struct devlink_health_reporter_get_req *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
static inline void
devlink_health_reporter_get_req_set_health_reporter_name(struct devlink_health_reporter_get_req *req,
const char *health_reporter_name)
{
free(req->health_reporter_name);
req->_present.health_reporter_name_len = strlen(health_reporter_name);
req->health_reporter_name = malloc(req->_present.health_reporter_name_len + 1);
memcpy(req->health_reporter_name, health_reporter_name, req->_present.health_reporter_name_len);
req->health_reporter_name[req->_present.health_reporter_name_len] = 0;
}
struct devlink_health_reporter_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 health_reporter_name_len;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
char *health_reporter_name;
};
void
devlink_health_reporter_get_rsp_free(struct devlink_health_reporter_get_rsp *rsp);
/*
* Get health reporter instances.
*/
struct devlink_health_reporter_get_rsp *
devlink_health_reporter_get(struct ynl_sock *ys,
struct devlink_health_reporter_get_req *req);
/* DEVLINK_CMD_HEALTH_REPORTER_GET - dump */
struct devlink_health_reporter_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
};
static inline struct devlink_health_reporter_get_req_dump *
devlink_health_reporter_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_health_reporter_get_req_dump));
}
void
devlink_health_reporter_get_req_dump_free(struct devlink_health_reporter_get_req_dump *req);
static inline void
devlink_health_reporter_get_req_dump_set_bus_name(struct devlink_health_reporter_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_health_reporter_get_req_dump_set_dev_name(struct devlink_health_reporter_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_health_reporter_get_req_dump_set_port_index(struct devlink_health_reporter_get_req_dump *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
struct devlink_health_reporter_get_list {
struct devlink_health_reporter_get_list *next;
struct devlink_health_reporter_get_rsp obj __attribute__ ((aligned (8)));
};
void
devlink_health_reporter_get_list_free(struct devlink_health_reporter_get_list *rsp);
struct devlink_health_reporter_get_list *
devlink_health_reporter_get_dump(struct ynl_sock *ys,
struct devlink_health_reporter_get_req_dump *req);
/* ============== DEVLINK_CMD_TRAP_GET ============== */
/* DEVLINK_CMD_TRAP_GET - do */
struct devlink_trap_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 trap_name_len;
} _present;
char *bus_name;
char *dev_name;
char *trap_name;
};
static inline struct devlink_trap_get_req *devlink_trap_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_trap_get_req));
}
void devlink_trap_get_req_free(struct devlink_trap_get_req *req);
static inline void
devlink_trap_get_req_set_bus_name(struct devlink_trap_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_trap_get_req_set_dev_name(struct devlink_trap_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_trap_get_req_set_trap_name(struct devlink_trap_get_req *req,
const char *trap_name)
{
free(req->trap_name);
req->_present.trap_name_len = strlen(trap_name);
req->trap_name = malloc(req->_present.trap_name_len + 1);
memcpy(req->trap_name, trap_name, req->_present.trap_name_len);
req->trap_name[req->_present.trap_name_len] = 0;
}
struct devlink_trap_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 trap_name_len;
} _present;
char *bus_name;
char *dev_name;
char *trap_name;
};
void devlink_trap_get_rsp_free(struct devlink_trap_get_rsp *rsp);
/*
* Get trap instances.
*/
struct devlink_trap_get_rsp *
devlink_trap_get(struct ynl_sock *ys, struct devlink_trap_get_req *req);
/* DEVLINK_CMD_TRAP_GET - dump */
struct devlink_trap_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_trap_get_req_dump *
devlink_trap_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_trap_get_req_dump));
}
void devlink_trap_get_req_dump_free(struct devlink_trap_get_req_dump *req);
static inline void
devlink_trap_get_req_dump_set_bus_name(struct devlink_trap_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_trap_get_req_dump_set_dev_name(struct devlink_trap_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_trap_get_list {
struct devlink_trap_get_list *next;
struct devlink_trap_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_trap_get_list_free(struct devlink_trap_get_list *rsp);
struct devlink_trap_get_list *
devlink_trap_get_dump(struct ynl_sock *ys,
struct devlink_trap_get_req_dump *req);
/* ============== DEVLINK_CMD_TRAP_GROUP_GET ============== */
/* DEVLINK_CMD_TRAP_GROUP_GET - do */
struct devlink_trap_group_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 trap_group_name_len;
} _present;
char *bus_name;
char *dev_name;
char *trap_group_name;
};
static inline struct devlink_trap_group_get_req *
devlink_trap_group_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_trap_group_get_req));
}
void devlink_trap_group_get_req_free(struct devlink_trap_group_get_req *req);
static inline void
devlink_trap_group_get_req_set_bus_name(struct devlink_trap_group_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_trap_group_get_req_set_dev_name(struct devlink_trap_group_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_trap_group_get_req_set_trap_group_name(struct devlink_trap_group_get_req *req,
const char *trap_group_name)
{
free(req->trap_group_name);
req->_present.trap_group_name_len = strlen(trap_group_name);
req->trap_group_name = malloc(req->_present.trap_group_name_len + 1);
memcpy(req->trap_group_name, trap_group_name, req->_present.trap_group_name_len);
req->trap_group_name[req->_present.trap_group_name_len] = 0;
}
struct devlink_trap_group_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 trap_group_name_len;
} _present;
char *bus_name;
char *dev_name;
char *trap_group_name;
};
void devlink_trap_group_get_rsp_free(struct devlink_trap_group_get_rsp *rsp);
/*
* Get trap group instances.
*/
struct devlink_trap_group_get_rsp *
devlink_trap_group_get(struct ynl_sock *ys,
struct devlink_trap_group_get_req *req);
/* DEVLINK_CMD_TRAP_GROUP_GET - dump */
struct devlink_trap_group_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_trap_group_get_req_dump *
devlink_trap_group_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_trap_group_get_req_dump));
}
void
devlink_trap_group_get_req_dump_free(struct devlink_trap_group_get_req_dump *req);
static inline void
devlink_trap_group_get_req_dump_set_bus_name(struct devlink_trap_group_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_trap_group_get_req_dump_set_dev_name(struct devlink_trap_group_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_trap_group_get_list {
struct devlink_trap_group_get_list *next;
struct devlink_trap_group_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_trap_group_get_list_free(struct devlink_trap_group_get_list *rsp);
struct devlink_trap_group_get_list *
devlink_trap_group_get_dump(struct ynl_sock *ys,
struct devlink_trap_group_get_req_dump *req);
/* ============== DEVLINK_CMD_TRAP_POLICER_GET ============== */
/* DEVLINK_CMD_TRAP_POLICER_GET - do */
struct devlink_trap_policer_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 trap_policer_id:1;
} _present;
char *bus_name;
char *dev_name;
__u32 trap_policer_id;
};
static inline struct devlink_trap_policer_get_req *
devlink_trap_policer_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_trap_policer_get_req));
}
void
devlink_trap_policer_get_req_free(struct devlink_trap_policer_get_req *req);
static inline void
devlink_trap_policer_get_req_set_bus_name(struct devlink_trap_policer_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_trap_policer_get_req_set_dev_name(struct devlink_trap_policer_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_trap_policer_get_req_set_trap_policer_id(struct devlink_trap_policer_get_req *req,
__u32 trap_policer_id)
{
req->_present.trap_policer_id = 1;
req->trap_policer_id = trap_policer_id;
}
struct devlink_trap_policer_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 trap_policer_id:1;
} _present;
char *bus_name;
char *dev_name;
__u32 trap_policer_id;
};
void
devlink_trap_policer_get_rsp_free(struct devlink_trap_policer_get_rsp *rsp);
/*
* Get trap policer instances.
*/
struct devlink_trap_policer_get_rsp *
devlink_trap_policer_get(struct ynl_sock *ys,
struct devlink_trap_policer_get_req *req);
/* DEVLINK_CMD_TRAP_POLICER_GET - dump */
struct devlink_trap_policer_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_trap_policer_get_req_dump *
devlink_trap_policer_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_info_get_req));
return calloc(1, sizeof(struct devlink_trap_policer_get_req_dump));
}
void devlink_info_get_req_free(struct devlink_info_get_req *req);
void
devlink_trap_policer_get_req_dump_free(struct devlink_trap_policer_get_req_dump *req);
static inline void
devlink_info_get_req_set_bus_name(struct devlink_info_get_req *req,
devlink_trap_policer_get_req_dump_set_bus_name(struct devlink_trap_policer_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_trap_policer_get_req_dump_set_dev_name(struct devlink_trap_policer_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_trap_policer_get_list {
struct devlink_trap_policer_get_list *next;
struct devlink_trap_policer_get_rsp obj __attribute__ ((aligned (8)));
};
void
devlink_trap_policer_get_list_free(struct devlink_trap_policer_get_list *rsp);
struct devlink_trap_policer_get_list *
devlink_trap_policer_get_dump(struct ynl_sock *ys,
struct devlink_trap_policer_get_req_dump *req);
/* ============== DEVLINK_CMD_RATE_GET ============== */
/* DEVLINK_CMD_RATE_GET - do */
struct devlink_rate_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 port_index:1;
__u32 rate_node_name_len;
} _present;
char *bus_name;
char *dev_name;
__u32 port_index;
char *rate_node_name;
};
static inline struct devlink_rate_get_req *devlink_rate_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_rate_get_req));
}
void devlink_rate_get_req_free(struct devlink_rate_get_req *req);
static inline void
devlink_rate_get_req_set_bus_name(struct devlink_rate_get_req *req,
const char *bus_name)
{
free(req->bus_name);
......@@ -169,7 +1700,7 @@ devlink_info_get_req_set_bus_name(struct devlink_info_get_req *req,
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_info_get_req_set_dev_name(struct devlink_info_get_req *req,
devlink_rate_get_req_set_dev_name(struct devlink_rate_get_req *req,
const char *dev_name)
{
free(req->dev_name);
......@@ -178,43 +1709,284 @@ devlink_info_get_req_set_dev_name(struct devlink_info_get_req *req,
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_rate_get_req_set_port_index(struct devlink_rate_get_req *req,
__u32 port_index)
{
req->_present.port_index = 1;
req->port_index = port_index;
}
static inline void
devlink_rate_get_req_set_rate_node_name(struct devlink_rate_get_req *req,
const char *rate_node_name)
{
free(req->rate_node_name);
req->_present.rate_node_name_len = strlen(rate_node_name);
req->rate_node_name = malloc(req->_present.rate_node_name_len + 1);
memcpy(req->rate_node_name, rate_node_name, req->_present.rate_node_name_len);
req->rate_node_name[req->_present.rate_node_name_len] = 0;
}
struct devlink_info_get_rsp {
struct devlink_rate_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 info_driver_name_len;
__u32 info_serial_number_len;
__u32 port_index:1;
__u32 rate_node_name_len;
} _present;
char *bus_name;
char *dev_name;
char *info_driver_name;
char *info_serial_number;
unsigned int n_info_version_fixed;
struct devlink_dl_info_version *info_version_fixed;
unsigned int n_info_version_running;
struct devlink_dl_info_version *info_version_running;
unsigned int n_info_version_stored;
struct devlink_dl_info_version *info_version_stored;
__u32 port_index;
char *rate_node_name;
};
void devlink_info_get_rsp_free(struct devlink_info_get_rsp *rsp);
void devlink_rate_get_rsp_free(struct devlink_rate_get_rsp *rsp);
/*
* Get device information, like driver name, hardware and firmware versions etc.
* Get rate instances.
*/
struct devlink_info_get_rsp *
devlink_info_get(struct ynl_sock *ys, struct devlink_info_get_req *req);
struct devlink_rate_get_rsp *
devlink_rate_get(struct ynl_sock *ys, struct devlink_rate_get_req *req);
/* DEVLINK_CMD_INFO_GET - dump */
struct devlink_info_get_list {
struct devlink_info_get_list *next;
struct devlink_info_get_rsp obj __attribute__ ((aligned (8)));
/* DEVLINK_CMD_RATE_GET - dump */
struct devlink_rate_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
void devlink_info_get_list_free(struct devlink_info_get_list *rsp);
static inline struct devlink_rate_get_req_dump *
devlink_rate_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_rate_get_req_dump));
}
void devlink_rate_get_req_dump_free(struct devlink_rate_get_req_dump *req);
struct devlink_info_get_list *devlink_info_get_dump(struct ynl_sock *ys);
static inline void
devlink_rate_get_req_dump_set_bus_name(struct devlink_rate_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_rate_get_req_dump_set_dev_name(struct devlink_rate_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_rate_get_list {
struct devlink_rate_get_list *next;
struct devlink_rate_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_rate_get_list_free(struct devlink_rate_get_list *rsp);
struct devlink_rate_get_list *
devlink_rate_get_dump(struct ynl_sock *ys,
struct devlink_rate_get_req_dump *req);
/* ============== DEVLINK_CMD_LINECARD_GET ============== */
/* DEVLINK_CMD_LINECARD_GET - do */
struct devlink_linecard_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 linecard_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 linecard_index;
};
static inline struct devlink_linecard_get_req *
devlink_linecard_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_linecard_get_req));
}
void devlink_linecard_get_req_free(struct devlink_linecard_get_req *req);
static inline void
devlink_linecard_get_req_set_bus_name(struct devlink_linecard_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_linecard_get_req_set_dev_name(struct devlink_linecard_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
static inline void
devlink_linecard_get_req_set_linecard_index(struct devlink_linecard_get_req *req,
__u32 linecard_index)
{
req->_present.linecard_index = 1;
req->linecard_index = linecard_index;
}
struct devlink_linecard_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
__u32 linecard_index:1;
} _present;
char *bus_name;
char *dev_name;
__u32 linecard_index;
};
void devlink_linecard_get_rsp_free(struct devlink_linecard_get_rsp *rsp);
/*
* Get line card instances.
*/
struct devlink_linecard_get_rsp *
devlink_linecard_get(struct ynl_sock *ys, struct devlink_linecard_get_req *req);
/* DEVLINK_CMD_LINECARD_GET - dump */
struct devlink_linecard_get_req_dump {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_linecard_get_req_dump *
devlink_linecard_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct devlink_linecard_get_req_dump));
}
void
devlink_linecard_get_req_dump_free(struct devlink_linecard_get_req_dump *req);
static inline void
devlink_linecard_get_req_dump_set_bus_name(struct devlink_linecard_get_req_dump *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_linecard_get_req_dump_set_dev_name(struct devlink_linecard_get_req_dump *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_linecard_get_list {
struct devlink_linecard_get_list *next;
struct devlink_linecard_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_linecard_get_list_free(struct devlink_linecard_get_list *rsp);
struct devlink_linecard_get_list *
devlink_linecard_get_dump(struct ynl_sock *ys,
struct devlink_linecard_get_req_dump *req);
/* ============== DEVLINK_CMD_SELFTESTS_GET ============== */
/* DEVLINK_CMD_SELFTESTS_GET - do */
struct devlink_selftests_get_req {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
static inline struct devlink_selftests_get_req *
devlink_selftests_get_req_alloc(void)
{
return calloc(1, sizeof(struct devlink_selftests_get_req));
}
void devlink_selftests_get_req_free(struct devlink_selftests_get_req *req);
static inline void
devlink_selftests_get_req_set_bus_name(struct devlink_selftests_get_req *req,
const char *bus_name)
{
free(req->bus_name);
req->_present.bus_name_len = strlen(bus_name);
req->bus_name = malloc(req->_present.bus_name_len + 1);
memcpy(req->bus_name, bus_name, req->_present.bus_name_len);
req->bus_name[req->_present.bus_name_len] = 0;
}
static inline void
devlink_selftests_get_req_set_dev_name(struct devlink_selftests_get_req *req,
const char *dev_name)
{
free(req->dev_name);
req->_present.dev_name_len = strlen(dev_name);
req->dev_name = malloc(req->_present.dev_name_len + 1);
memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
req->dev_name[req->_present.dev_name_len] = 0;
}
struct devlink_selftests_get_rsp {
struct {
__u32 bus_name_len;
__u32 dev_name_len;
} _present;
char *bus_name;
char *dev_name;
};
void devlink_selftests_get_rsp_free(struct devlink_selftests_get_rsp *rsp);
/*
* Get device selftest instances.
*/
struct devlink_selftests_get_rsp *
devlink_selftests_get(struct ynl_sock *ys,
struct devlink_selftests_get_req *req);
/* DEVLINK_CMD_SELFTESTS_GET - dump */
struct devlink_selftests_get_list {
struct devlink_selftests_get_list *next;
struct devlink_selftests_get_rsp obj __attribute__ ((aligned (8)));
};
void devlink_selftests_get_list_free(struct devlink_selftests_get_list *rsp);
struct devlink_selftests_get_list *
devlink_selftests_get_dump(struct ynl_sock *ys);
#endif /* _LINUX_DEVLINK_GEN_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment