diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/Kconfig | 14 | ||||
-rw-r--r-- | net/bootp.c | 27 | ||||
-rw-r--r-- | net/eth-uclass.c | 50 | ||||
-rw-r--r-- | net/mdio-mux-uclass.c | 10 | ||||
-rw-r--r-- | net/mdio-uclass.c | 10 | ||||
-rw-r--r-- | net/sntp.c | 10 |
6 files changed, 72 insertions, 49 deletions
diff --git a/net/Kconfig b/net/Kconfig index 1b3e420d0d..c4b4dae064 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -74,4 +74,18 @@ config TFTP_WINDOWSIZE before an ack response is required. The default TFTP implementation implies a window size of 1. +config SERVERIP_FROM_PROXYDHCP + bool "Get serverip value from Proxy DHCP response" + help + Allows bootfile config to be fetched from Proxy DHCP server + while IP is obtained from main DHCP server. + +config SERVERIP_FROM_PROXYDHCP_DELAY_MS + int "# of additional milliseconds to wait for ProxyDHCP response" + default 100 + help + Amount of additional time to wait for ProxyDHCP response after + receiving response from main DHCP server. Has no effect if + SERVERIP_FROM_PROXYDHCP is false. + endif # if NET diff --git a/net/bootp.c b/net/bootp.c index de3dab4114..163af41e92 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -146,10 +146,7 @@ static int check_reply_packet(uchar *pkt, unsigned dest, unsigned src, return retval; } -/* - * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet - */ -static void store_net_params(struct bootp_hdr *bp) +static void store_bootp_params(struct bootp_hdr *bp) { #if !defined(CONFIG_BOOTP_SERVERIP) struct in_addr tmp_ip; @@ -183,6 +180,16 @@ static void store_net_params(struct bootp_hdr *bp) if (*net_boot_file_name) env_set("bootfile", net_boot_file_name); #endif +} + +/* + * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet + */ +static void store_net_params(struct bootp_hdr *bp) +{ +#if !defined(CONFIG_SERVERIP_FROM_PROXYDHCP) + store_bootp_params(bp); +#endif net_copy_ip(&net_ip, &bp->bp_yiaddr); } @@ -1055,8 +1062,12 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip, debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: " "%d\n", src, dest, len, dhcp_state); - if (net_read_ip(&bp->bp_yiaddr).s_addr == 0) + if (net_read_ip(&bp->bp_yiaddr).s_addr == 0) { +#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP) + store_bootp_params(bp); +#endif return; + } switch (dhcp_state) { case SELECTING: @@ -1075,6 +1086,12 @@ static void dhcp_handler(uchar *pkt, unsigned dest, struct in_addr sip, dhcp_packet_process_options(bp); efi_net_set_dhcp_ack(pkt, len); +#if defined(CONFIG_SERVERIP_FROM_PROXYDHCP) + if (!net_server_ip.s_addr) + udelay(CONFIG_SERVERIP_FROM_PROXYDHCP_DELAY_MS * + 1000); +#endif /* CONFIG_SERVERIP_FROM_PROXYDHCP */ + debug("TRANSITIONING TO REQUESTING STATE\n"); dhcp_state = REQUESTING; diff --git a/net/eth-uclass.c b/net/eth-uclass.c index e14695c0f1..0156324032 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -50,7 +50,7 @@ static struct eth_uclass_priv *eth_get_uclass_priv(void) return NULL; assert(uc); - return uc->priv; + return uclass_get_priv(uc); } void eth_set_current_to_next(void) @@ -126,9 +126,6 @@ struct udevice *eth_get_dev_by_name(const char *devname) uclass_foreach_dev(it, uc) { /* - * We need the seq to be valid, so try to probe it. - * If the probe fails, the seq will not match since it will be - * -1 instead of what we are looking for. * We don't care about errors from probe here. Either they won't * match an alias or it will match a literal name and we'll pick * up the error when we try to probe again in eth_set_dev(). @@ -137,7 +134,7 @@ struct udevice *eth_get_dev_by_name(const char *devname) continue; /* Check for the name or the sequence number to match */ if (strcmp(it->name, devname) == 0 || - (endp > startp && it->seq == seq)) + (endp > startp && dev_seq(it) == seq)) return it; } @@ -149,7 +146,7 @@ unsigned char *eth_get_ethaddr(void) struct eth_pdata *pdata; if (eth_get_dev()) { - pdata = eth_get_dev()->platdata; + pdata = dev_get_plat(eth_get_dev()); return pdata->enetaddr; } @@ -166,7 +163,7 @@ int eth_init_state_only(void) if (!current || !device_active(current)) return -EINVAL; - priv = current->uclass_priv; + priv = dev_get_uclass_priv(current); priv->state = ETH_STATE_ACTIVE; return 0; @@ -182,14 +179,14 @@ void eth_halt_state_only(void) if (!current || !device_active(current)) return; - priv = current->uclass_priv; + priv = dev_get_uclass_priv(current); priv->state = ETH_STATE_PASSIVE; } int eth_get_dev_index(void) { if (eth_get_dev()) - return eth_get_dev()->seq; + return dev_seq(eth_get_dev()); return -1; } @@ -202,8 +199,8 @@ static int eth_write_hwaddr(struct udevice *dev) return -EINVAL; /* seq is valid since the device is active */ - if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev->seq)) { - pdata = dev->platdata; + if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev_seq(dev))) { + pdata = dev_get_plat(dev); if (!is_valid_ethaddr(pdata->enetaddr)) { printf("\nError: %s address %pM illegal value\n", dev->name, pdata->enetaddr); @@ -235,9 +232,9 @@ static int on_ethaddr(const char *name, const char *value, enum env_op op, /* look for an index after "eth" */ index = simple_strtoul(name + 3, NULL, 10); - retval = uclass_find_device_by_seq(UCLASS_ETH, index, false, &dev); + retval = uclass_find_device_by_seq(UCLASS_ETH, index, &dev); if (!retval) { - struct eth_pdata *pdata = dev->platdata; + struct eth_pdata *pdata = dev_get_plat(dev); switch (op) { case env_op_create: case env_op_overwrite: @@ -290,7 +287,7 @@ int eth_init(void) ret = eth_get_ops(current)->start(current); if (ret >= 0) { struct eth_device_priv *priv = - current->uclass_priv; + dev_get_uclass_priv(current); priv->state = ETH_STATE_ACTIVE; return 0; @@ -326,7 +323,7 @@ void eth_halt(void) return; eth_get_ops(current)->stop(current); - priv = current->uclass_priv; + priv = dev_get_uclass_priv(current); if (priv) priv->state = ETH_STATE_PASSIVE; } @@ -434,11 +431,11 @@ int eth_initialize(void) bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT); do { - if (dev->seq != -1) { + if (device_active(dev)) { if (num_devices) printf(", "); - printf("eth%d: %s", dev->seq, dev->name); + printf("eth%d: %s", dev_seq(dev), dev->name); if (ethprime && dev == prime_dev) printf(" [PRIME]"); @@ -446,7 +443,7 @@ int eth_initialize(void) eth_write_hwaddr(dev); - if (dev->seq != -1) + if (device_active(dev)) num_devices++; uclass_next_device_check(&dev); } while (dev); @@ -505,8 +502,8 @@ static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN]) static int eth_post_probe(struct udevice *dev) { - struct eth_device_priv *priv = dev->uclass_priv; - struct eth_pdata *pdata = dev->platdata; + struct eth_device_priv *priv = dev_get_uclass_priv(dev); + struct eth_pdata *pdata = dev_get_plat(dev); unsigned char env_enetaddr[ARP_HLEN]; char *source = "DT"; @@ -547,7 +544,7 @@ static int eth_post_probe(struct udevice *dev) eth_get_ops(dev)->read_rom_hwaddr(dev); } - eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr); + eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr); if (!is_zero_ethaddr(env_enetaddr)) { if (!is_zero_ethaddr(pdata->enetaddr) && memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) { @@ -562,13 +559,14 @@ static int eth_post_probe(struct udevice *dev) /* Override the ROM MAC address */ memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN); } else if (is_valid_ethaddr(pdata->enetaddr)) { - eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev), + pdata->enetaddr); } else if (is_zero_ethaddr(pdata->enetaddr) || !is_valid_ethaddr(pdata->enetaddr)) { #ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr(pdata->enetaddr); printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", - dev->name, dev->seq, pdata->enetaddr); + dev->name, dev_seq(dev), pdata->enetaddr); #else printf("\nError: %s address not set.\n", dev->name); @@ -583,7 +581,7 @@ static int eth_post_probe(struct udevice *dev) static int eth_pre_remove(struct udevice *dev) { - struct eth_pdata *pdata = dev->platdata; + struct eth_pdata *pdata = dev_get_plat(dev); eth_get_ops(dev)->stop(dev); @@ -600,7 +598,7 @@ UCLASS_DRIVER(eth) = { .pre_unbind = eth_pre_unbind, .post_probe = eth_post_probe, .pre_remove = eth_pre_remove, - .priv_auto_alloc_size = sizeof(struct eth_uclass_priv), - .per_device_auto_alloc_size = sizeof(struct eth_device_priv), + .priv_auto = sizeof(struct eth_uclass_priv), + .per_device_auto = sizeof(struct eth_device_priv), .flags = DM_UC_FLAG_SEQ_ALIAS, }; diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c index 6674eb6bee..780526c19e 100644 --- a/net/mdio-mux-uclass.c +++ b/net/mdio-mux-uclass.c @@ -65,7 +65,7 @@ static int mmux_change_sel(struct udevice *ch, bool sel) struct udevice *mux = ch->parent; struct mdio_mux_perdev_priv *priv = dev_get_uclass_priv(mux); struct mdio_mux_ops *ops = mdio_mux_get_ops(mux); - struct mdio_mux_ch_data *ch_data = dev_get_parent_platdata(ch); + struct mdio_mux_ch_data *ch_data = dev_get_parent_plat(ch); int err = 0; if (sel) { @@ -147,7 +147,7 @@ static int mmux_reset(struct udevice *ch) /* Picks up the mux selection value for each child */ static int dm_mdio_mux_child_post_bind(struct udevice *ch) { - struct mdio_mux_ch_data *ch_data = dev_get_parent_platdata(ch); + struct mdio_mux_ch_data *ch_data = dev_get_parent_plat(ch); ch_data->sel = dev_read_u32_default(ch, "reg", MDIO_MUX_SELECT_NONE); @@ -163,7 +163,7 @@ static int dm_mdio_mux_post_bind(struct udevice *mux) ofnode ch_node; int err, first_err = 0; - if (!ofnode_valid(mux->node)) { + if (!dev_has_ofnode(mux)) { debug("%s: no mux node found, no child MDIO busses set up\n", __func__); return 0; @@ -228,6 +228,6 @@ UCLASS_DRIVER(mdio_mux) = { .child_post_bind = dm_mdio_mux_child_post_bind, .post_bind = dm_mdio_mux_post_bind, .post_probe = dm_mdio_mux_post_probe, - .per_device_auto_alloc_size = sizeof(struct mdio_mux_perdev_priv), - .per_child_platdata_auto_alloc_size = sizeof(struct mdio_mux_ch_data), + .per_device_auto = sizeof(struct mdio_mux_perdev_priv), + .per_child_plat_auto = sizeof(struct mdio_mux_ch_data), }; diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index b5e8e46512..697e5f838d 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -40,8 +40,8 @@ static int dm_mdio_post_bind(struct udevice *dev) const char *dt_name; /* set a custom name for the MDIO device, if present in DT */ - if (ofnode_valid(dev->node)) { - dt_name = ofnode_read_string(dev->node, "device-name"); + if (dev_has_ofnode(dev)) { + dt_name = dev_read_string(dev, "device-name"); if (dt_name) { debug("renaming dev %s to %s\n", dev->name, dt_name); device_set_name(dev, dt_name); @@ -182,14 +182,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) struct phy_device *phy; int i; - if (!ofnode_valid(ethdev->node)) { + if (!dev_has_ofnode(ethdev)) { debug("%s: supplied eth dev has no DT node!\n", ethdev->name); return NULL; } interface = PHY_INTERFACE_MODE_NONE; for (i = 0; i < PHY_MODE_STR_CNT; i++) { - if_str = ofnode_read_string(ethdev->node, phy_mode_str[i]); + if_str = dev_read_string(ethdev, phy_mode_str[i]); if (if_str) { interface = phy_get_interface_by_name(if_str); break; @@ -216,5 +216,5 @@ UCLASS_DRIVER(mdio) = { .post_bind = dm_mdio_post_bind, .post_probe = dm_mdio_post_probe, .pre_remove = dm_mdio_pre_remove, - .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv), + .per_device_auto = sizeof(struct mdio_perdev_priv), }; diff --git a/net/sntp.c b/net/sntp.c index d5d5671933..dac0f8ceea 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -57,18 +57,15 @@ static void sntp_timeout_handler(void) static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, unsigned src, unsigned len) { -#ifdef CONFIG_TIMESTAMP struct sntp_pkt_t *rpktp = (struct sntp_pkt_t *)pkt; struct rtc_time tm; ulong seconds; -#endif debug("%s\n", __func__); if (dest != sntp_our_port) return; -#ifdef CONFIG_TIMESTAMP /* * As the RTC's used in U-Boot support second resolution only * we simply ignore the sub-second field. @@ -76,8 +73,7 @@ static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, memcpy(&seconds, &rpktp->transmit_timestamp, sizeof(ulong)); rtc_to_tm(ntohl(seconds) - 2208988800UL + net_ntp_time_offset, &tm); -#if defined(CONFIG_CMD_DATE) -# ifdef CONFIG_DM_RTC +#ifdef CONFIG_DM_RTC struct udevice *dev; int ret; @@ -86,14 +82,12 @@ static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, printf("SNTP: cannot find RTC: err=%d\n", ret); else dm_rtc_set(dev, &tm); -# else +#elif defined(CONFIG_CMD_DATE) rtc_set(&tm); -# endif #endif printf("Date: %4d-%02d-%02d Time: %2d:%02d:%02d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); -#endif net_set_state(NETLOOP_SUCCESS); } |