Hello Martin, Martin Schiller wrote onĀ 2015-12-10:
> This patch adds the new 'id' devicetree property, which makes it possible to > renumber the physical mac ports. I think the numbering should be done by the "aliases" node in the devicetree, as this is the recommended way upstream. Please check for "of_alias_get_id" in the kernel sources. > > This change has only cosmetical reasons (e.g. appearance in swconfig, > kernel messages on link change). > > Signed-off-by: Martin Schiller <[email protected]> > --- > .../0025-NET-MIPS-lantiq-adds-xrx200-net.patch | 39 > ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) > diff --git a/target/linux/lantiq/patches-4.1/0025-NET-MIPS-lantiq-adds- > xrx200-net.patch b/target/linux/lantiq/patches-4.1/0025-NET-MIPS-lantiq- > adds-xrx200-net.patch index 48c7395..4ab09e2 100644 --- > a/target/linux/lantiq/patches-4.1/0025-NET-MIPS-lantiq-adds-xrx200- > net.patch +++ > b/target/linux/lantiq/patches-4.1/0025-NET-MIPS-lantiq-adds-xrx200- > net.patch @@ -209,7 +209,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: > adds xrx200-net > +}; > --- /dev/null > +++ b/drivers/net/ethernet/lantiq_xrx200.c > -@@ -0,0 +1,1798 @@ > +@@ -0,0 +1,1815 @@ > +/* > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License version 2 as > published > @@ -404,6 +404,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + +struct xrx200_port { + u8 num; ++ u8 id; + u8 phy_addr; + > u16 flags; > + phy_interface_t phy_if; > @@ -461,6 +462,9 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + struct xrx200_hw *hw; > +}; > + > ++static int id_to_mac[XRX200_MAX_PORT] = {0,1,2,3,4,5,6}; > ++static int mac_to_id[XRX200_MAX_PORT] = {0,1,2,3,4,5,6}; > ++ > +static __iomem void *xrx200_switch_membase; > +static __iomem void *xrx200_mii_membase; > +static __iomem void *xrx200_mdio_membase; > @@ -789,9 +793,9 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + { > + struct switch_port *p = &val->value.ports[i]; > + > -+ portmap |= (1 << p->id); > ++ portmap |= (1 << id_to_mac[p->id]); > + if (p->flags & (1 << SWITCH_PORT_FLAG_TAGGED)) > -+ tagmap |= (1 << p->id); > ++ tagmap |= (1 << id_to_mac[p->id]); > + } > + > + tem.table = XRX200_PCE_VLANMAP_IDX; > @@ -855,7 +859,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + continue; > + > + p = &val->value.ports[val->len++]; > -+ p->id = i; > ++ p->id = mac_to_id[i]; > + if (tags & (1 << i)) > + p->flags = (1 << SWITCH_PORT_FLAG_TAGGED); > + else > @@ -898,8 +902,9 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > +} > + > +// port > -+static int xrx200sw_get_port_pvid(struct switch_dev *dev, int port, > int *val) ++static int xrx200sw_get_port_pvid(struct switch_dev *dev, > int port_id, int *val) > +{ ++ int port = id_to_mac[port_id]; + struct > xrx200_pce_table_entry > tev; + + if (port >= XRX200_MAX_PORT) > @@ -914,9 +919,11 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > +} > + > +static int xrx200sw_get_port_link(struct switch_dev *dev, > -+ int port, > ++ int port_id, > + struct switch_port_link *link) > +{ > ++ int port = id_to_mac[port_id]; > ++ > + if (port >= XRX200_MAX_PORT) > + return -EINVAL; > + > @@ -1432,7 +1439,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + xrx200_gmac_update(&priv->port[i]); > + priv->port[i].link = priv->port[i].phydev->link; > + netdev_info(dev, "port %d %s link\n", > -+ priv->port[i].num, > ++ priv->port[i].id, > + (priv->port[i].link)?("got"):("lost")); > + } > + } > @@ -1633,7 +1640,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + for (i = 0; i < priv->num_port; i++) > + if (xrx200_mdio_probe(dev, &priv->port[i])) > + pr_warn("xrx200-mdio: probing phy of port %d > failed\n", > -+ priv->port[i].num); > ++ priv->port[i].id); > + > + return 0; > + > @@ -1787,19 +1794,25 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + +static void xrx200_of_port(struct xrx200_priv *priv, struct > device_node *port) +{ > -+ const __be32 *addr, *id = of_get_property(port, "reg", NULL); > ++ const __be32 *addr, *id, *mac = of_get_property(port, "reg", NULL); > + struct xrx200_port *p = &priv->port[priv->num_port]; > + > -+ if (!id) > ++ if (!mac) > + return; > + > ++ id = of_get_property(port, "id", NULL); > ++ > ++ if (!id) > ++ id = mac; > ++ > + memset(p, 0, sizeof(struct xrx200_port)); > + p->phy_node = of_parse_phandle(port, "phy-handle", 0); > + addr = of_get_property(p->phy_node, "reg", NULL); > + if (!addr) > + return; > + > -+ p->num = *id; > ++ p->num = *mac; > ++ p->id = *id; > + p->phy_addr = *addr; > + p->phy_if = of_get_phy_mode(port); > + if (p->phy_addr > 0x10) > @@ -1824,6 +1837,10 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds > xrx200-net > + + /* store the port id in the hw struct so we can map ports -> > devices */ + priv->hw->port_map[p->num] = priv->hw->num_devs; > ++ > ++ /* store the id <-> mac (port) mapping */ > ++ id_to_mac[p->id] = p->num; > ++ mac_to_id[p->num] = p->id; > +} > + > +static const struct net_device_ops xrx200_netdev_ops = { Best Regards, Thomas --- There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. --- _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
