|
|
@@ -770,6 +770,53 @@ done:
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
+static int
|
|
|
+swconfig_send_link(struct sk_buff *msg, struct genl_info *info, int attr,
|
|
|
+ const struct switch_port_link *link)
|
|
|
+{
|
|
|
+ struct nlattr *p = NULL;
|
|
|
+ int err = 0;
|
|
|
+
|
|
|
+ p = nla_nest_start(msg, attr);
|
|
|
+ if (link->link) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_LINK))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ if (link->duplex) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_DUPLEX))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ if (link->aneg) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_ANEG))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ if (link->tx_flow) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_TX_FLOW))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ if (link->rx_flow) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_RX_FLOW))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ if (nla_put_u32(msg, SWITCH_LINK_SPEED, link->speed))
|
|
|
+ goto nla_put_failure;
|
|
|
+ if (link->eee & ADVERTISED_100baseT_Full) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_EEE_100BASET))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ if (link->eee & ADVERTISED_1000baseT_Full) {
|
|
|
+ if (nla_put_flag(msg, SWITCH_LINK_FLAG_EEE_1000BASET))
|
|
|
+ goto nla_put_failure;
|
|
|
+ }
|
|
|
+ nla_nest_end(msg, p);
|
|
|
+
|
|
|
+ return err;
|
|
|
+
|
|
|
+nla_put_failure:
|
|
|
+ nla_nest_cancel(msg, p);
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
static int
|
|
|
swconfig_get_attr(struct sk_buff *skb, struct genl_info *info)
|
|
|
{
|
|
|
@@ -794,6 +841,9 @@ swconfig_get_attr(struct sk_buff *skb, struct genl_info *info)
|
|
|
val.value.ports = dev->portbuf;
|
|
|
memset(dev->portbuf, 0,
|
|
|
sizeof(struct switch_port) * dev->ports);
|
|
|
+ } else if (attr->type == SWITCH_TYPE_LINK) {
|
|
|
+ val.value.link = &dev->linkbuf;
|
|
|
+ memset(&dev->linkbuf, 0, sizeof(struct switch_port_link));
|
|
|
}
|
|
|
|
|
|
err = attr->get(dev, attr, &val);
|
|
|
@@ -824,6 +874,12 @@ swconfig_get_attr(struct sk_buff *skb, struct genl_info *info)
|
|
|
if (err < 0)
|
|
|
goto nla_put_failure;
|
|
|
break;
|
|
|
+ case SWITCH_TYPE_LINK:
|
|
|
+ err = swconfig_send_link(msg, info,
|
|
|
+ SWITCH_ATTR_OP_VALUE_LINK, val.value.link);
|
|
|
+ if (err < 0)
|
|
|
+ goto nla_put_failure;
|
|
|
+ break;
|
|
|
default:
|
|
|
pr_debug("invalid type in attribute\n");
|
|
|
err = -EINVAL;
|