swconfig: Add cpu port index to help output.
authorGabor Juhos <juhosg@openwrt.org>
Fri, 16 Apr 2010 19:32:40 +0000 (19:32 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Fri, 16 Apr 2010 19:32:40 +0000 (19:32 +0000)
Let swconfig provide the cpu port index in its help page. This is
needed as e.g. Atheros switches have their cpu port at port 0, not
port 5.

This could allow e.g. luci to get a rough overview of the layout of
the switch.

Signed-off-by: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
SVN-Revision: 20939

package/swconfig/src/cli.c
package/swconfig/src/swlib.c
package/swconfig/src/swlib.h
target/linux/generic-2.6/files/drivers/net/phy/swconfig.c
target/linux/generic-2.6/files/include/linux/switch.h

index 76593ba14a160751f26bd3a04bd9d900014542da..eea88d812fb87be3c99089b93c67000ec6a06a8b 100644 (file)
@@ -74,7 +74,7 @@ print_attrs(const struct switch_attr *attr)
 static void
 list_attributes(struct switch_dev *dev)
 {
-       printf("Switch %d: %s(%s), ports: %d, vlans: %d\n", dev->id, dev->dev_name, dev->name, dev->ports, dev->vlans);
+       printf("Switch %d: %s(%s), ports: %d (cpu @ %d), vlans: %d\n", dev->id, dev->dev_name, dev->name, dev->ports, dev->cpu_port, dev->vlans);
        printf("     --switch\n");
        print_attrs(dev->ops);
        printf("     --vlan\n");
index 8a9fd7a29ce8b3659d057ab350400321a598b0e4..59456a33d9d5717c38f6abae2a647f6bb3281ef5 100644 (file)
@@ -586,6 +586,8 @@ add_switch(struct nl_msg *msg, void *arg)
                dev->ports = nla_get_u32(tb[SWITCH_ATTR_PORTS]);
        if (tb[SWITCH_ATTR_VLANS])
                dev->vlans = nla_get_u32(tb[SWITCH_ATTR_VLANS]);
+       if (tb[SWITCH_ATTR_CPU_PORT])
+               dev->cpu_port = nla_get_u32(tb[SWITCH_ATTR_CPU_PORT]);
 
        if (!sa->head) {
                sa->head = dev;
index b3c6769de19831711cae92090f8c6aeb64c4b89e..2c2fccd3943f8d87c5d76e49495a26e8e4e9dc32 100644 (file)
@@ -118,6 +118,7 @@ struct switch_dev {
        const char *dev_name;
        int ports;
        int vlans;
+       int cpu_port;
        struct switch_attr *ops;
        struct switch_attr *port_ops;
        struct switch_attr *vlan_ops;
index bb49df83eb875fc8c427d0dfa59dde3024382ce0..376dec16f93aead7944accc562dea90535391363 100644 (file)
@@ -761,6 +761,7 @@ swconfig_send_switch(struct sk_buff *msg, u32 pid, u32 seq, int flags,
        NLA_PUT_STRING(msg, SWITCH_ATTR_DEV_NAME, dev->devname);
        NLA_PUT_U32(msg, SWITCH_ATTR_VLANS, dev->vlans);
        NLA_PUT_U32(msg, SWITCH_ATTR_PORTS, dev->ports);
+       NLA_PUT_U32(msg, SWITCH_ATTR_CPU_PORT, dev->cpu_port);
 
        return genlmsg_end(msg, hdr);
 nla_put_failure:
index 98b86e8514cb4fd981c81a9084659b6cbd9a50b8..25aedb83b07420ade5c1b3097eebf17ae3d3e01a 100644 (file)
@@ -40,6 +40,7 @@ enum {
        SWITCH_ATTR_DEV_NAME,
        SWITCH_ATTR_VLANS,
        SWITCH_ATTR_PORTS,
+       SWITCH_ATTR_CPU_PORT,
        /* attributes */
        SWITCH_ATTR_OP_ID,
        SWITCH_ATTR_OP_TYPE,