diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/Kconfig | 1 | ||||
-rw-r--r-- | net/cdp.c | 3 | ||||
-rw-r--r-- | net/dsa-uclass.c | 82 | ||||
-rw-r--r-- | net/eth_common.c | 2 | ||||
-rw-r--r-- | net/mdio-uclass.c | 2 | ||||
-rw-r--r-- | net/tftp.c | 1 |
6 files changed, 45 insertions, 46 deletions
diff --git a/net/Kconfig b/net/Kconfig index ba0ca813ce5..7a2d1450188 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -40,7 +40,6 @@ config NETCONSOLE config IP_DEFRAG bool "Support IP datagram reassembly" - default n help Selecting this will enable IP datagram reassembly according to the algorithm in RFC815. diff --git a/net/cdp.c b/net/cdp.c index fac02046819..a8f890e7522 100644 --- a/net/cdp.c +++ b/net/cdp.c @@ -11,9 +11,6 @@ #include <common.h> #include <net.h> -#if defined(CONFIG_CDP_VERSION) -#include <timestamp.h> -#endif #include "cdp.h" diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c index 694664d81bb..bf762cd2a8c 100644 --- a/net/dsa-uclass.c +++ b/net/dsa-uclass.c @@ -100,7 +100,7 @@ static void dsa_port_stop(struct udevice *pdev) port_pdata = dev_get_parent_plat(pdev); ops->port_disable(dev, port_pdata->index, port_pdata->phy); - ops->port_disable(dev, priv->cpu_port, NULL); + ops->port_disable(dev, priv->cpu_port, priv->cpu_port_fixed_phy); } eth_get_ops(master)->stop(master); @@ -199,9 +199,7 @@ static int dsa_port_free_pkt(struct udevice *pdev, uchar *packet, int length) static int dsa_port_of_to_pdata(struct udevice *pdev) { struct dsa_port_pdata *port_pdata; - struct dsa_pdata *dsa_pdata; struct eth_pdata *eth_pdata; - struct udevice *dev; const char *label; u32 index; int err; @@ -213,15 +211,12 @@ static int dsa_port_of_to_pdata(struct udevice *pdev) if (err) return err; - dev = dev_get_parent(pdev); - dsa_pdata = dev_get_uclass_plat(dev); - port_pdata = dev_get_parent_plat(pdev); port_pdata->index = index; label = ofnode_read_string(dev_ofnode(pdev), "label"); if (label) - strncpy(port_pdata->name, label, DSA_PORT_NAME_LENGTH); + strlcpy(port_pdata->name, label, DSA_PORT_NAME_LENGTH); eth_pdata = dev_get_plat(pdev); eth_pdata->priv_pdata = port_pdata; @@ -240,18 +235,42 @@ static const struct eth_ops dsa_port_ops = { .free_pkt = dsa_port_free_pkt, }; -static int dsa_port_probe(struct udevice *pdev) +/* + * Inherit port's hwaddr from the DSA master, unless the port already has a + * unique MAC address specified in the environment. + */ +static void dsa_port_set_hwaddr(struct udevice *pdev, struct udevice *master) { - struct udevice *dev = dev_get_parent(pdev); struct eth_pdata *eth_pdata, *master_pdata; unsigned char env_enetaddr[ARP_HLEN]; + + eth_env_get_enetaddr_by_index("eth", dev_seq(pdev), env_enetaddr); + if (!is_zero_ethaddr(env_enetaddr)) { + /* individual port mac addrs require master to be promisc */ + struct eth_ops *eth_ops = eth_get_ops(master); + + if (eth_ops->set_promisc) + eth_ops->set_promisc(master, 1); + + return; + } + + master_pdata = dev_get_plat(master); + eth_pdata = dev_get_plat(pdev); + memcpy(eth_pdata->enetaddr, master_pdata->enetaddr, ARP_HLEN); + eth_env_set_enetaddr_by_index("eth", dev_seq(pdev), + master_pdata->enetaddr); +} + +static int dsa_port_probe(struct udevice *pdev) +{ + struct udevice *dev = dev_get_parent(pdev); + struct dsa_ops *ops = dsa_get_ops(dev); struct dsa_port_pdata *port_pdata; - struct dsa_priv *dsa_priv; struct udevice *master; - int ret; + int err; port_pdata = dev_get_parent_plat(pdev); - dsa_priv = dev_get_uclass_priv(dev); port_pdata->phy = dm_eth_phy_connect(pdev); if (!port_pdata->phy) @@ -268,42 +287,25 @@ static int dsa_port_probe(struct udevice *pdev) * TODO: we assume the master device is always there and doesn't get * removed during runtime. */ - ret = device_probe(master); - if (ret) - return ret; - - /* - * Inherit port's hwaddr from the DSA master, unless the port already - * has a unique MAC address specified in the environment. - */ - eth_env_get_enetaddr_by_index("eth", dev_seq(pdev), env_enetaddr); - if (!is_zero_ethaddr(env_enetaddr)) { - /* individual port mac addrs require master to be promisc */ - struct eth_ops *eth_ops = eth_get_ops(master); + err = device_probe(master); + if (err) + return err; - if (eth_ops->set_promisc) - eth_ops->set_promisc(master, 1); + dsa_port_set_hwaddr(pdev, master); - return 0; + if (ops->port_probe) { + err = ops->port_probe(dev, port_pdata->index, + port_pdata->phy); + if (err) + return err; } - master_pdata = dev_get_plat(master); - eth_pdata = dev_get_plat(pdev); - memcpy(eth_pdata->enetaddr, master_pdata->enetaddr, ARP_HLEN); - eth_env_set_enetaddr_by_index("eth", dev_seq(pdev), - master_pdata->enetaddr); - return 0; } static int dsa_port_remove(struct udevice *pdev) { - struct udevice *dev = dev_get_parent(pdev); - struct dsa_port_pdata *port_pdata; - struct dsa_priv *dsa_priv; - - port_pdata = dev_get_parent_plat(pdev); - dsa_priv = dev_get_uclass_priv(dev); + struct dsa_port_pdata *port_pdata = dev_get_parent_plat(pdev); port_pdata->phy = NULL; @@ -419,7 +421,7 @@ static int dsa_post_bind(struct udevice *dev) struct dsa_port_pdata *port_pdata; port_pdata = dev_get_parent_plat(pdev); - strncpy(port_pdata->name, name, DSA_PORT_NAME_LENGTH); + strlcpy(port_pdata->name, name, DSA_PORT_NAME_LENGTH); pdev->name = port_pdata->name; } diff --git a/net/eth_common.c b/net/eth_common.c index 58f899a0240..82d527abba6 100644 --- a/net/eth_common.c +++ b/net/eth_common.c @@ -32,6 +32,7 @@ int eth_env_set_enetaddr_by_index(const char *base_name, int index, void eth_common_init(void) { bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); +#if CONFIG_IS_ENABLED(ETH) #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) miiphy_init(); #endif @@ -39,6 +40,7 @@ void eth_common_init(void) #ifdef CONFIG_PHYLIB phy_init(); #endif +#endif } int eth_mac_skip(int index) diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 1b687765b8c..e74e34f78f9 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -101,7 +101,7 @@ static int dm_mdio_post_probe(struct udevice *dev) pdata->mii_bus->write = mdio_write; pdata->mii_bus->reset = mdio_reset; pdata->mii_bus->priv = dev; - strncpy(pdata->mii_bus->name, dev->name, MDIO_NAME_LEN - 1); + strlcpy(pdata->mii_bus->name, dev->name, MDIO_NAME_LEN); return mdio_register(pdata->mii_bus); } diff --git a/net/tftp.c b/net/tftp.c index 5baf528f4ec..87392014d58 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -925,4 +925,3 @@ void tftp_start_server(void) memset(net_server_ethaddr, 0, 6); } #endif /* CONFIG_CMD_TFTPSRV */ - |