[OpenWrt-Devel] [PATCH 1/3] swconfig: add SWITCH_TYPE_LINK and support sending link info to user space

Florian Fainelli florian at openwrt.org
Sun Dec 20 16:51:20 EST 2015


Le 16 déc. 2015 09:19, "Rafał Miłecki" <zajec5 at gmail.com> a écrit :
>
> So far we were sending link data as a string. It got some drawbacks:
> 1) Didn't allow writing clean user space apps reading link state. It was
>    needed to do some screen scraping.
> 2) Forced whole PORT_LINK communication to be string based. Adding
>    support for *setting* port link required passing string and parting
>    it in the kernel space.
>
> Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
> ---

[snip]

(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 (nla_put_u32(msg, SWITCH_LINK_LINK, link->link))

Boolean?

> +               goto nla_put_failure;
> +       if (nla_put_u32(msg, SWITCH_LINK_DUPLEX, link->duplex))

Same here

> +               goto nla_put_failure;
> +       if (nla_put_u32(msg, SWITCH_LINK_ANEG, link->aneg))

And here

> +               goto nla_put_failure;
> +       if (nla_put_u32(msg, SWITCH_LINK_TX_FLOW, link->tx_flow))

And here

> +               goto nla_put_failure;
> +       if (nla_put_u32(msg, SWITCH_LINK_RX_FLOW, link->rx_flow))

And here too

> +               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_ADVERTISED_100BASET_FULL))
> +                       goto nla_put_failure;
> +       }
> +       if (link->eee & ADVERTISED_1000baseT_Full) {
> +               if (nla_put_flag(msg,
SWITCH_LINK_FLAG_ADVERTISED_1000BASET_FULL))
> +                       goto nla_put_failure;
> +       }

As mentioned by Stefan, these should reflect that is is EEE-related.
--
Florian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20151220/9f9d2030/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list