mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 22:24:09 +08:00
bridge: mrp: Extend MRP netlink interface for configuring MRP interconnect
This patch extends the existing MRP netlink interface with the following attributes: IFLA_BRIDGE_MRP_IN_ROLE, IFLA_BRIDGE_MRP_IN_STATE and IFLA_BRIDGE_MRP_START_IN_TEST. These attributes are similar with their ring attributes but they apply to the interconnect port. Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
537ed5676d
commit
7ab1748e4c
@ -14,6 +14,9 @@ static const struct nla_policy br_mrp_policy[IFLA_BRIDGE_MRP_MAX + 1] = {
|
||||
[IFLA_BRIDGE_MRP_RING_STATE] = { .type = NLA_NESTED },
|
||||
[IFLA_BRIDGE_MRP_RING_ROLE] = { .type = NLA_NESTED },
|
||||
[IFLA_BRIDGE_MRP_START_TEST] = { .type = NLA_NESTED },
|
||||
[IFLA_BRIDGE_MRP_IN_ROLE] = { .type = NLA_NESTED },
|
||||
[IFLA_BRIDGE_MRP_IN_STATE] = { .type = NLA_NESTED },
|
||||
[IFLA_BRIDGE_MRP_START_IN_TEST] = { .type = NLA_NESTED },
|
||||
};
|
||||
|
||||
static const struct nla_policy
|
||||
@ -235,6 +238,121 @@ static int br_mrp_start_test_parse(struct net_bridge *br, struct nlattr *attr,
|
||||
return br_mrp_start_test(br, &test);
|
||||
}
|
||||
|
||||
static const struct nla_policy
|
||||
br_mrp_in_state_policy[IFLA_BRIDGE_MRP_IN_STATE_MAX + 1] = {
|
||||
[IFLA_BRIDGE_MRP_IN_STATE_UNSPEC] = { .type = NLA_REJECT },
|
||||
[IFLA_BRIDGE_MRP_IN_STATE_IN_ID] = { .type = NLA_U32 },
|
||||
[IFLA_BRIDGE_MRP_IN_STATE_STATE] = { .type = NLA_U32 },
|
||||
};
|
||||
|
||||
static int br_mrp_in_state_parse(struct net_bridge *br, struct nlattr *attr,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct nlattr *tb[IFLA_BRIDGE_MRP_IN_STATE_MAX + 1];
|
||||
struct br_mrp_in_state state;
|
||||
int err;
|
||||
|
||||
err = nla_parse_nested(tb, IFLA_BRIDGE_MRP_IN_STATE_MAX, attr,
|
||||
br_mrp_in_state_policy, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!tb[IFLA_BRIDGE_MRP_IN_STATE_IN_ID] ||
|
||||
!tb[IFLA_BRIDGE_MRP_IN_STATE_STATE]) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Missing attribute: IN_ID or STATE");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(&state, 0x0, sizeof(state));
|
||||
|
||||
state.in_id = nla_get_u32(tb[IFLA_BRIDGE_MRP_IN_STATE_IN_ID]);
|
||||
state.in_state = nla_get_u32(tb[IFLA_BRIDGE_MRP_IN_STATE_STATE]);
|
||||
|
||||
return br_mrp_set_in_state(br, &state);
|
||||
}
|
||||
|
||||
static const struct nla_policy
|
||||
br_mrp_in_role_policy[IFLA_BRIDGE_MRP_IN_ROLE_MAX + 1] = {
|
||||
[IFLA_BRIDGE_MRP_IN_ROLE_UNSPEC] = { .type = NLA_REJECT },
|
||||
[IFLA_BRIDGE_MRP_IN_ROLE_RING_ID] = { .type = NLA_U32 },
|
||||
[IFLA_BRIDGE_MRP_IN_ROLE_IN_ID] = { .type = NLA_U16 },
|
||||
[IFLA_BRIDGE_MRP_IN_ROLE_ROLE] = { .type = NLA_U32 },
|
||||
[IFLA_BRIDGE_MRP_IN_ROLE_I_IFINDEX] = { .type = NLA_U32 },
|
||||
};
|
||||
|
||||
static int br_mrp_in_role_parse(struct net_bridge *br, struct nlattr *attr,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct nlattr *tb[IFLA_BRIDGE_MRP_IN_ROLE_MAX + 1];
|
||||
struct br_mrp_in_role role;
|
||||
int err;
|
||||
|
||||
err = nla_parse_nested(tb, IFLA_BRIDGE_MRP_IN_ROLE_MAX, attr,
|
||||
br_mrp_in_role_policy, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!tb[IFLA_BRIDGE_MRP_IN_ROLE_RING_ID] ||
|
||||
!tb[IFLA_BRIDGE_MRP_IN_ROLE_IN_ID] ||
|
||||
!tb[IFLA_BRIDGE_MRP_IN_ROLE_I_IFINDEX] ||
|
||||
!tb[IFLA_BRIDGE_MRP_IN_ROLE_ROLE]) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Missing attribute: RING_ID or ROLE or IN_ID or I_IFINDEX");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(&role, 0x0, sizeof(role));
|
||||
|
||||
role.ring_id = nla_get_u32(tb[IFLA_BRIDGE_MRP_IN_ROLE_RING_ID]);
|
||||
role.in_id = nla_get_u16(tb[IFLA_BRIDGE_MRP_IN_ROLE_IN_ID]);
|
||||
role.i_ifindex = nla_get_u32(tb[IFLA_BRIDGE_MRP_IN_ROLE_I_IFINDEX]);
|
||||
role.in_role = nla_get_u32(tb[IFLA_BRIDGE_MRP_IN_ROLE_ROLE]);
|
||||
|
||||
return br_mrp_set_in_role(br, &role);
|
||||
}
|
||||
|
||||
static const struct nla_policy
|
||||
br_mrp_start_in_test_policy[IFLA_BRIDGE_MRP_START_IN_TEST_MAX + 1] = {
|
||||
[IFLA_BRIDGE_MRP_START_IN_TEST_UNSPEC] = { .type = NLA_REJECT },
|
||||
[IFLA_BRIDGE_MRP_START_IN_TEST_IN_ID] = { .type = NLA_U32 },
|
||||
[IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL] = { .type = NLA_U32 },
|
||||
[IFLA_BRIDGE_MRP_START_IN_TEST_MAX_MISS] = { .type = NLA_U32 },
|
||||
[IFLA_BRIDGE_MRP_START_IN_TEST_PERIOD] = { .type = NLA_U32 },
|
||||
};
|
||||
|
||||
static int br_mrp_start_in_test_parse(struct net_bridge *br,
|
||||
struct nlattr *attr,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct nlattr *tb[IFLA_BRIDGE_MRP_START_IN_TEST_MAX + 1];
|
||||
struct br_mrp_start_in_test test;
|
||||
int err;
|
||||
|
||||
err = nla_parse_nested(tb, IFLA_BRIDGE_MRP_START_IN_TEST_MAX, attr,
|
||||
br_mrp_start_in_test_policy, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (!tb[IFLA_BRIDGE_MRP_START_IN_TEST_IN_ID] ||
|
||||
!tb[IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL] ||
|
||||
!tb[IFLA_BRIDGE_MRP_START_IN_TEST_MAX_MISS] ||
|
||||
!tb[IFLA_BRIDGE_MRP_START_IN_TEST_PERIOD]) {
|
||||
NL_SET_ERR_MSG_MOD(extack,
|
||||
"Missing attribute: RING_ID or INTERVAL or MAX_MISS or PERIOD");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(&test, 0x0, sizeof(test));
|
||||
|
||||
test.in_id = nla_get_u32(tb[IFLA_BRIDGE_MRP_START_IN_TEST_IN_ID]);
|
||||
test.interval = nla_get_u32(tb[IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL]);
|
||||
test.max_miss = nla_get_u32(tb[IFLA_BRIDGE_MRP_START_IN_TEST_MAX_MISS]);
|
||||
test.period = nla_get_u32(tb[IFLA_BRIDGE_MRP_START_IN_TEST_PERIOD]);
|
||||
|
||||
return br_mrp_start_in_test(br, &test);
|
||||
}
|
||||
|
||||
int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
|
||||
struct nlattr *attr, int cmd, struct netlink_ext_ack *extack)
|
||||
{
|
||||
@ -301,6 +419,28 @@ int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
|
||||
return err;
|
||||
}
|
||||
|
||||
if (tb[IFLA_BRIDGE_MRP_IN_STATE]) {
|
||||
err = br_mrp_in_state_parse(br, tb[IFLA_BRIDGE_MRP_IN_STATE],
|
||||
extack);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (tb[IFLA_BRIDGE_MRP_IN_ROLE]) {
|
||||
err = br_mrp_in_role_parse(br, tb[IFLA_BRIDGE_MRP_IN_ROLE],
|
||||
extack);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (tb[IFLA_BRIDGE_MRP_START_IN_TEST]) {
|
||||
err = br_mrp_start_in_test_parse(br,
|
||||
tb[IFLA_BRIDGE_MRP_START_IN_TEST],
|
||||
extack);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user