Re: [PATCH v2 06/32] serial: msm: add debug UART
On Tue, Dec 19, 2023 at 6:04 PM Caleb Connolly wrote: > > Introduce support for early debugging. > > Signed-off-by: Caleb Connolly > --- > drivers/serial/Kconfig | 8 > drivers/serial/serial_msm.c | 32 > 2 files changed, 40 insertions(+) > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index 81fdac047824..20713812c839 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -304,6 +304,14 @@ config DEBUG_UART_S5P > will need to provide parameters to make this work. The driver will > be available until the real driver-model serial is running. > > +config DEBUG_UART_MSM > + bool "Qualcomm QUP UART debug" What is QUP ? > + depends on ARCH_SNAPDRAGON > + help > + Select this to enable a debug UART using the serial_msm driver. You > + will need to provide parameters to make this work. The driver will > + be available until the real driver-model serial is running. > + > config DEBUG_UART_MSM_GENI > bool "Qualcomm snapdragon" > depends on ARCH_SNAPDRAGON > diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c > index a22623c316ed..19a5a3a788f7 100644 > --- a/drivers/serial/serial_msm.c > +++ b/drivers/serial/serial_msm.c > @@ -253,3 +253,35 @@ U_BOOT_DRIVER(serial_msm) = { > .probe = msm_serial_probe, > .ops= &msm_serial_ops, > }; > + > +#ifdef CONFIG_DEBUG_UART_MSM > + > +static struct msm_serial_data init_serial_data = { > + .base = CONFIG_VAL(DEBUG_UART_BASE), > + .clk_bit_rate = UART_DM_CLK_RX_TX_BIT_RATE, > +}; > + > +#include > + > +static inline void _debug_uart_init(void) > +{ > + uart_dm_init(&init_serial_data); > +} > + > +static inline void _debug_uart_putc(int ch) > +{ > + struct msm_serial_data *priv = &init_serial_data; > + > + while (!(readl(priv->base + UARTDM_SR) & UARTDM_SR_TX_EMPTY) && > + !(readl(priv->base + UARTDM_ISR) & UARTDM_ISR_TX_READY)) > + ; > + > + writel(UARTDM_CR_CMD_RESET_TX_READY, priv->base + UARTDM_CR); > + > + writel(1, priv->base + UARTDM_NCF_TX); > + writel(ch, priv->base + UARTDM_TF); > +} > + > +DEBUG_UART_FUNCS > + > +#endif > > -- > 2.42.1 >
Re: [PATCH v2 03/32] mmc: msm_sdhci: use modern clock handling
On Tue, Dec 19, 2023 at 6:04 PM Caleb Connolly wrote: > > Use the clk_* helper functions and the correct property name for clocks. > > Signed-off-by: Caleb Connolly > --- > drivers/mmc/msm_sdhci.c | 69 > - > 1 file changed, 46 insertions(+), 23 deletions(-) > > diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c > index 604f9c3ff99c..863e6007a905 100644 > --- a/drivers/mmc/msm_sdhci.c > +++ b/drivers/mmc/msm_sdhci.c > @@ -44,6 +44,7 @@ struct msm_sdhc_plat { > struct msm_sdhc { > struct sdhci_host host; > void *base; > + struct clk_bulk clks; > }; > > struct msm_sdhc_variant_info { > @@ -54,36 +55,56 @@ DECLARE_GLOBAL_DATA_PTR; > > static int msm_sdc_clk_init(struct udevice *dev) > { > - int node = dev_of_offset(dev); > - uint clk_rate = fdtdec_get_uint(gd->fdt_blob, node, "clock-frequency", > - 40); > - uint clkd[2]; /* clk_id and clk_no */ > - int clk_offset; > - struct udevice *clk_dev; > - struct clk clk; > - int ret; > + struct msm_sdhc *prv = dev_get_priv(dev); > + ofnode node = dev_ofnode(dev); > + uint clk_rate; > + int ret, i = 0, n_clks; > + const char *clk_name; > > - ret = fdtdec_get_int_array(gd->fdt_blob, node, "clock", clkd, 2); > + ret = ofnode_read_u32(node, "clock-frequency", &clk_rate); > if (ret) > - return ret; > + clk_rate = 40; > > - clk_offset = fdt_node_offset_by_phandle(gd->fdt_blob, clkd[0]); > - if (clk_offset < 0) > - return clk_offset; > - > - ret = uclass_get_device_by_of_offset(UCLASS_CLK, clk_offset, > &clk_dev); > - if (ret) > + ret = clk_get_bulk(dev, &prv->clks); > + if (ret) { > + debug("Couldn't get mmc clocks: %d\n", ret); > return ret; > + } > > - clk.id = clkd[1]; > - ret = clk_request(clk_dev, &clk); > - if (ret < 0) > + ret = clk_enable_bulk(&prv->clks); > + if (ret) { > + debug("Couldn't enable mmc clocks: %d\n", ret); > return ret; > + } > > - ret = clk_set_rate(&clk, clk_rate); > - clk_free(&clk); > - if (ret < 0) > - return ret; > + /* If clock-names is unspecified, then the first clock is the core > clock */ > + if (!ofnode_get_property(node, "clock-names", &n_clks)) { > + if (!clk_set_rate(&prv->clks.clks[0], clk_rate)) { > + printf("Couldn't set core clock rate: %d\n", ret); > + return -EINVAL; > + } > + } > + > + /* Find the index of the "core" clock */ > + while (i < n_clks) { > + ofnode_read_string_index(node, "clock-names", i, &clk_name); > + if (!strcmp(clk_name, "core")) > + break; > + i++; > + } > + > + if (i >= prv->clks.count) { > + printf("Couldn't find core clock (index %d but only have %d > clocks)\n", i, > + prv->clks.count); > + return -EINVAL; > + } > + > + /* The clock is already enabled by the clk_bulk above */ > + ret = clk_set_rate(&prv->clks.clks[i], clk_rate); > + if (!ret) { > + printf("Couldn't set core clock rate: %d\n", ret); > + return -EINVAL; > + } > > return 0; > } > @@ -188,6 +209,8 @@ static int msm_sdc_remove(struct udevice *dev) > if (!var_info->mci_removed) > writel(0, priv->base + SDCC_MCI_HC_MODE); > > + clk_release_bulk(&priv->clks); > + > return 0; > } > > > -- > 2.42.1 > Reviewed-by: Ramon Fried
Re: [PATCH v2 13/32] board: dragonboard410c: import board code from mach-snapdragon
On Tue, Dec 19, 2023 at 6:04 PM Caleb Connolly wrote: > > Some of the db410c board support code was written to be generic and > placed in mach-snapdragon. However, as the db410c is the only board > using this, move the code out of mach-snapdragon. This makes is more > obvious what code is relevant for which targets and helps tidy things up > a little more. > > Signed-off-by: Caleb Connolly > --- > arch/arm/mach-snapdragon/Makefile | 2 - > arch/arm/mach-snapdragon/include/mach/dram.h | 12 - > arch/arm/mach-snapdragon/misc.c| 55 > -- > board/qualcomm/dragonboard410c/Makefile| 3 +- > board/qualcomm/dragonboard410c/dragonboard410c.c | 4 +- > .../qualcomm/dragonboard410c/misc.c| 51 +++- > .../mach => board/qualcomm/dragonboard410c}/misc.h | 1 + > 7 files changed, 54 insertions(+), 74 deletions(-) > > diff --git a/arch/arm/mach-snapdragon/Makefile > b/arch/arm/mach-snapdragon/Makefile > index 3a3a297c1768..d02432df8b04 100644 > --- a/arch/arm/mach-snapdragon/Makefile > +++ b/arch/arm/mach-snapdragon/Makefile > @@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o > obj-$(CONFIG_SDM845) += init_sdm845.o > obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o > obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o > -obj-y += misc.o > -obj-y += dram.o > obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o > diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h > b/arch/arm/mach-snapdragon/include/mach/dram.h > deleted file mode 100644 > index 0a9eedda414c.. > --- a/arch/arm/mach-snapdragon/include/mach/dram.h > +++ /dev/null > @@ -1,12 +0,0 @@ > -/* SPDX-License-Identifier: GPL-2.0+ */ > -/* > - * Snapdragon DRAM > - * Copyright (C) 2018 Ramon Fried > - */ > - > -#ifndef DRAM_H > -#define DRAM_H > - > -int msm_fixup_memory(void *blob); > - > -#endif > diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c > deleted file mode 100644 > index 7d452f4529b7.. > --- a/arch/arm/mach-snapdragon/misc.c > +++ /dev/null > @@ -1,55 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0+ > -/* > - * Miscellaneous Snapdragon functionality > - * > - * (C) Copyright 2018 Ramon Fried > - * > - */ > - > -#include > -#include > -#include > -#include > - > -/* UNSTUFF_BITS macro taken from Linux Kernel: drivers/mmc/core/sd.c */ > -#define UNSTUFF_BITS(resp, start, size) \ > - ({ \ > - const int __size = size; \ > - const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \ > - const int __off = 3 - ((start) / 32); \ > - const int __shft = (start) & 31; \ > - u32 __res; \ > - \ > - __res = resp[__off] >> __shft; \ > - if (__size + __shft > 32) \ > - __res |= resp[__off - 1] << ((32 - __shft) % 32); \ > - __res & __mask; \ > - }) > - > -u32 msm_board_serial(void) > -{ > - struct mmc *mmc_dev; > - > - mmc_dev = find_mmc_device(0); > - if (!mmc_dev) > - return 0; > - > - if (mmc_init(mmc_dev)) > - return 0; > - > - return UNSTUFF_BITS(mmc_dev->cid, 16, 32); > -} > - > -void msm_generate_mac_addr(u8 *mac) > -{ > - /* use locally adminstrated pool */ > - mac[0] = 0x02; > - mac[1] = 0x00; > - > - /* > -* Put the 32-bit serial number in the last 32-bit of the MAC address. > -* Use big endian order so it is consistent with the serial number > -* written as a hexadecimal string, e.g. 0x1234abcd -> > 02:00:12:34:ab:cd > -*/ > - put_unaligned_be32(msm_board_serial(), &mac[2]); > -} > diff --git a/board/qualcomm/dragonboard410c/Makefile > b/board/qualcomm/dragonboard410c/Makefile > index 1b99c8b0efef..a3ae1a5f9136 100644 > --- a/board/qualcomm/dragonboard410c/Makefile > +++ b/board/qualcomm/dragonboard410c/Makefile > @@ -2,4 +2,5 @@ > # > # (C) Copyright 2015 Mateusz Kulikowski > > -obj-y := dragonboard410c.o > +obj-y += dragonboard410c.o > +obj-y += misc.o > diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c > b/board/qualcomm/dragonboard410c/dragonboard410c.c > index 1adac07569ae..eea603a4148d 100644 > --- a/board/qualcomm/dragonboard410c/dragonboard410c.c > +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c > @@ -18,10 +18,10 @@ > #include > #include > #include > -#include > -#include >
Re: [PATCH v2 00/32] Qualcomm generic board support
on't have access to a QCS404 EVB board > >>>> to test. > >>> > >>> db820c and qcs404 require a similar pinctrl change though. > >>> > >>> -Sumit > >>> > >>>> > >>>> This series is based on the qcom-next branch [1] and depends on my PMIC > >>>> fixes series [2], an integration branch for testing can be found at [3]. > >>>> The non-qualcomm-specific changes (patches 1 and 2) don't have any > >>>> dependencies. > >>>> > >>>> [1]: https://source.denx.de/u-boot/custodians/u-boot-snapdragon > >>>> [2]: > >>>> https://lore.kernel.org/u-boot/20231114-b4-qcom-dt-compat-v3-0-88a92f8f0...@linaro.org/ > >>>> [3]: > >>>> https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/tree/b4/qcom-common-target > >>>> > >>>> --- > >>>> Changes in v2: > >>>> - Split DTS changes to reduce patch size. > >>>> - Import full board DTS files from Linux too, and introduce -u-boot.dtsi > >>>> files where necessary to make any U-Boot specific changes. > >>>> - Add a pinctrl driver for qcom PMIC GPIOs > >>>> - Always enable LINUX_KERNEL_IMAGE_HEADER > >>>> - Link to v1: > >>>> https://lore.kernel.org/r/20231121-b4-qcom-common-target-v1-0-9492198e0...@linaro.org > >>>> > >>>> To: Neil Armstrong > >>>> To: Sumit Garg > >>>> To: Ramon Fried > >>>> Cc: Marek Vasut > >>>> To: Dzmitry Sankouski > >>>> To: Caleb Connolly > >>>> To: Peng Fan > >>>> To: Jaehoon Chung > >>>> To: Rayagonda Kokatanur > >>>> To: Lukasz Majewski > >>>> To: Sean Anderson > >>>> To: Jorge Ramirez-Ortiz > >>>> To: Stephan Gerhold > >>>> Cc: > >>>> > >>>> --- > >>>> Caleb Connolly (32): > >>>> arm: init: export prev_bl_fdt_addr > >>>> usb: dwc3-generic: support external vbus regulator > >>>> mmc: msm_sdhci: use modern clock handling > >>>> dt-bindings: drop msm_sdhci binding > >>>> clk/qcom: use upstream compatible properties > >>>> serial: msm: add debug UART > >>>> serial: msm: fix clock handling > >>>> gpio: qcom_pmic: 1-based GPIOs > >>>> gpio: qcom_pmic: add a quirk to skip GPIO configuration > >>>> gpio: qcom_pmic: add pinctrl driver > >>>> board: dragonboard410c: add chainloaded config fragment > >>>> board: dragonboard410c: upstream DT compat > >>>> board: dragonboard410c: import board code from mach-snapdragon > >>>> board: dragonboard820c: use LINUX_KERNEL_IMAGE_HEADER > >>>> mach-snapdragon: generalise board support > >>>> mach-snapdragon: dynamic load addresses > >>>> mach-snapdragon: generate fdtfile automatically > >>>> doc: board/qualcomm: document generic targets > >>>> dt-bindings: import headers for SDM845 > >>>> dts: sdm845: import supporting dtsi files > >>>> dts: sdm845: replace with upstream DTS > >>>> dt-bindings: import headers for MSM8916 > >>>> dts: msm8916: import PMIC dtsi files > >>>> dts: msm8916: replace with upstream DTS > >>>> dt-bindings: import headers for MSM8996 > >>>> dts: msm8996: import PMIC dtsi files > >>>> dts: dragonboard820c: use correct bindings for clocks > >>>> dts: msm8996: replace with upstream DTS > >>>> dt-bindings: import headers for qcs404 > >>>> dts: qcs404-evb: replace with upstream DT > >>>> board: qcs404-evb: drop board code > >>>> MAINTAINERS: Qualcomm: add some missing paths > >>>> > >>>> MAINTAINERS| 12 +- > >>>> arch/arm/Kconfig |4 + > >>>> arch/arm/dts/Makefile |9 +- > >>>> arch/arm/dts/apq8016-sbc.dts | 729 +++ > >>>> arch/arm/dts/apq8096-db820c-u-boot.dtsi| 10 + > >>>> arch/arm/dts/apq8096-db820c.dts
Re: [PATCH v2] net: wget: Support non-default HTTP port
On Thu, Dec 14, 2023 at 1:06 AM Tom Rini wrote: > > On Wed, Dec 13, 2023 at 10:11:13PM +0100, Marek Vasut wrote: > > > Currently the wget command is hard wired to HTTP port 80. This is > > inconvenient, as it is extremely easy to start trivial HTTP server > > as an unprivileged user using e.g. python http module to serve the > > files, but such a server has to run on one of the higher ports: > > " > > $ python3 -m http.server -d $(pwd) 8080 > > " > > > > Make it possible to configure HTTP server port the same way it is > > possible to configure TFTP server port, using environment variable > > 'httpdstp' (similar to 'tftpdstp'). Retain port 80 as the default > > fallback port. This way, users can start their own trivial server > > and conveniently download whatever files they need into U-Boot. > > > > Signed-off-by: Marek Vasut > > Reviewed-by: Tom Rini > > -- > Tom Reviewed-by: Ramon Fried
Re: [PATCH v3 3/4] net: tftp: remove explicit efi configuration dependency
On Mon, Dec 18, 2023 at 5:17 AM AKASHI Takahiro wrote: > > Now it is clear that the feature actually depends on efi interfaces, > not "bootefi" command. efi_set_bootdev() will automatically be nullified > if necessary efi component is disabled. > > Signed-off-by: AKASHI Takahiro > --- > net/tftp.c | 10 -- > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/net/tftp.c b/net/tftp.c > index 88e71e67de35..2e335413492b 100644 > --- a/net/tftp.c > +++ b/net/tftp.c > @@ -302,12 +302,10 @@ static void tftp_complete(void) > time_start * 1000, "/s"); > } > puts("\ndone\n"); > - if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) { > - if (!tftp_put_active) > - efi_set_bootdev("Net", "", tftp_filename, > - map_sysmem(tftp_load_addr, 0), > - net_boot_file_size); > - } > + if (!tftp_put_active) > + efi_set_bootdev("Net", "", tftp_filename, > + map_sysmem(tftp_load_addr, 0), > + net_boot_file_size); > net_set_state(NETLOOP_SUCCESS); > } > > -- > 2.34.1 > Reviewed-by: Ramon Fried
Re: [PATCH] net: fix NetConsole documentation reference
On Mon, Dec 18, 2023 at 9:37 AM Baruch Siach wrote: > > Fixes: d0253f7e5ca1 ("doc: move README.NetConsole to HTML documentation") > Signed-off-by: Baruch Siach > --- > net/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/Kconfig b/net/Kconfig > index 4215889127c9..92a22ac1ea55 100644 > --- a/net/Kconfig > +++ b/net/Kconfig > @@ -57,7 +57,7 @@ config NETCONSOLE > bool "NetConsole support" > help > Support the 'nc' input/output device for networked console. > - See README.NetConsole for details. > + See doc/usage/netconsole.rst for details. > > config IP_DEFRAG > bool "Support IP datagram reassembly" > -- > 2.43.0 > Reviewed-by: Ramon Fried
Re: [PATCH 18/25] net: Depend on CONFIG_CMDLINE
On Sun, Sep 24, 2023 at 11:40 PM Simon Glass wrote: > > At present it isn't possible to use networking without the command line > enabled. Add this as a condition. > > Signed-off-by: Simon Glass > --- > > cmd/Kconfig | 1 + > net/Kconfig | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/cmd/Kconfig b/cmd/Kconfig > index 5f6834b335dc..c3428d19f31d 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -1687,6 +1687,7 @@ if NET > > menuconfig CMD_NET > bool "Network commands" > + depends on CMDLINE > default y > imply NETDEVICES > > diff --git a/net/Kconfig b/net/Kconfig > index 4215889127c9..25d494e1db46 100644 > --- a/net/Kconfig > +++ b/net/Kconfig > @@ -4,6 +4,7 @@ > > menuconfig NET > bool "Networking support" > + depends on CMDLINE > default y > > if NET > -- > 2.42.0.515.g380fc7ccd1-goog > Reviewed-by: Ramon Fried
Re: [PATCH v5 2/7] net: wget: add wget with dns utility function
On Wed, Sep 27, 2023 at 12:37 PM Masahisa Kojima wrote: > > Current wget takes the target uri in this format: > ":" e.g.) 192.168.1.1:/bar > The http server ip address must be resolved before > calling wget. > > This commit adds the utility function runs wget with dhs. > User can call wget with the uri like "http://foo/bar";. > > Signed-off-by: Masahisa Kojima > Reviewed-by: Ilias Apalodimas > --- > include/net.h | 9 + > net/wget.c| 54 +++ > 2 files changed, 63 insertions(+) > > diff --git a/include/net.h b/include/net.h > index e254df7d7f..57889d8b7a 100644 > --- a/include/net.h > +++ b/include/net.h > @@ -926,4 +926,13 @@ void eth_set_enable_bootdevs(bool enable); > static inline void eth_set_enable_bootdevs(bool enable) {} > #endif > > +/** > + * wget_with_dns() - runs dns host IP address resulution before wget > + * > + * @dst_addr: destination address to download the file > + * @uri: uri string of target file of wget > + * Return: downloaded file size, negative if failed > + */ > +int wget_with_dns(ulong dst_addr, char *uri); > + > #endif /* __NET_H__ */ > diff --git a/net/wget.c b/net/wget.c > index a48a8cb624..4801e28eb9 100644 > --- a/net/wget.c > +++ b/net/wget.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > DECLARE_GLOBAL_DATA_PTR; > > @@ -504,3 +505,56 @@ void wget_start(void) > > wget_send(TCP_SYN, 0, 0, 0); > } > + > +#if (IS_ENABLED(CONFIG_CMD_DNS)) > +int wget_with_dns(ulong dst_addr, char *uri) > +{ > + int ret; > + char *s, *host_name, *file_name, *str_copy; > + > + /* > +* Download file using wget. > +* > +* U-Boot wget takes the target uri in this format. > +* ":" e.g.) 192.168.1.1:/sample/test.iso > +* Need to resolve the http server ip address before starting wget. > +*/ > + str_copy = strdup(uri); > + if (!str_copy) > + return -ENOMEM; > + > + s = str_copy + strlen("http://";); > + host_name = strsep(&s, "/"); > + if (!s) { > + log_err("Error: invalied uri, no file path\n"); > + ret = -EINVAL; > + goto out; > + } > + file_name = s; > + > + /* TODO: If the given uri has ip address for the http server, skip > dns */ > + net_dns_resolve = host_name; > + net_dns_env_var = "httpserverip"; > + if (net_loop(DNS) < 0) { > + log_err("Error: dns lookup of %s failed, check setup\n", > net_dns_resolve); > + ret = -EINVAL; > + goto out; > + } > + s = env_get("httpserverip"); > + if (!s) { > + ret = -EINVAL; > + goto out; > + } > + > + strlcpy(net_boot_file_name, s, sizeof(net_boot_file_name)); > + strlcat(net_boot_file_name, ":/", sizeof(net_boot_file_name)); /* > append '/' which is removed by strsep() */ > + strlcat(net_boot_file_name, file_name, sizeof(net_boot_file_name)); > + image_load_addr = dst_addr; > + ret = net_loop(WGET); > + > +out: > + free(str_copy); > + > + return ret; > +} > +#endif > -- > 2.34.1 > Reviewed-by: Ramon Fried
Re: [PATCH v5 1/7] net: wget: prevent overwriting reserved memory
> unmap_sysmem(ptr1); > debug_cond(DEBUG_WGET, >"wget: Connctd pkt Q %p len %x\n", >pkt_q[i].pkt, pkt_q[i].len); > + if (err) { > + wget_loop_state = NETLOOP_FAIL; > + wget_fail("wget: store error\n", > tcp_seq_num, tcp_ack_num, action); > + net_set_state(NETLOOP_FAIL); > + return; > + } > } > } > } > @@ -330,6 +386,7 @@ static void wget_handler(uchar *pkt, u16 dport, > len) != 0) { > wget_fail("wget: store error\n", > tcp_seq_num, tcp_ack_num, action); > + net_set_state(NETLOOP_FAIL); > return; > } > > @@ -420,6 +477,15 @@ void wget_start(void) > debug_cond(DEBUG_WGET, >"\nwget:Load address: 0x%lx\nLoading: *\b", > image_load_addr); > > + if (IS_ENABLED(CONFIG_LMB)) { > + if (wget_init_load_size()) { > + printf("\nwget error: "); > + printf("trying to overwrite reserved memory...\n"); > + net_set_state(NETLOOP_FAIL); > + return; > + } > + } > + > net_set_timeout_handler(wget_timeout, wget_timeout_handler); > tcp_set_tcp_handler(wget_handler); > > -- > 2.34.1 > Reviewed-by: Ramon Fried
Re: [PATCH v2 5/7] net: dwc_eth_qos_rockchip: Add support for RK3588
t;); > + if (IS_ERR(data->php_grf)) { > + dev_err(dev, "Missing rockchip,php-grf property\n"); > + ret = -EINVAL; > + goto err_free; > + } > + } > + > ret = reset_get_bulk(dev, &data->resets); > if (ret < 0) > goto err_free; > @@ -211,12 +368,20 @@ static int eqos_probe_resources_rk(struct udevice *dev) > goto err_release_resets; > } > > - ret = clk_get_by_name(dev, "clk_mac_speed", &eqos->clk_tx); > - if (ret) { > - dev_dbg(dev, "clk_get_by_name(clk_mac_speed) failed: %d", > ret); > - goto err_free_clk_master_bus; > + if (device_is_compatible(dev, "rockchip,rk3568-gmac")) { > + ret = clk_get_by_name(dev, "clk_mac_speed", &eqos->clk_tx); > + if (ret) { > + dev_dbg(dev, "clk_get_by_name(clk_mac_speed) failed: > %d", ret); > + goto err_free_clk_master_bus; > + } > } > > + clock_in_out = dev_read_string(dev, "clock_in_out"); > + if (clock_in_out && !strcmp(clock_in_out, "input")) > + data->clock_input = true; > + else > + data->clock_input = false; > + > /* snps,reset props are deprecated, do bare minimum to support them */ > if (dev_read_bool(dev, "snps,reset-active-low")) > reset_flags |= GPIOD_ACTIVE_LOW; > @@ -273,6 +438,12 @@ static int eqos_start_resets_rk(struct udevice *dev) > > static int eqos_stop_clks_rk(struct udevice *dev) > { > + struct eth_pdata *pdata = dev_get_plat(dev); > + struct rockchip_platform_data *data = pdata->priv_pdata; > + > + if (data->ops->set_clock_selection) > + data->ops->set_clock_selection(dev, false); > + > return 0; > } > > @@ -293,6 +464,9 @@ static int eqos_start_clks_rk(struct udevice *dev) > udelay(eqos->reset_delays[2]); > } > > + if (data->ops->set_clock_selection) > + data->ops->set_clock_selection(dev, true); > + > tx_delay = dev_read_u32_default(dev, "tx_delay", 0x30); > rx_delay = dev_read_u32_default(dev, "rx_delay", 0x10); > > -- > 2.42.0 > Reviewed-by: Ramon Fried
Re: [PATCH v2 4/7] net: dwc_eth_qos: Add glue driver for GMAC on Rockchip RK3568
struct rockchip_platform_data *data = pdata->priv_pdata; > + int tx_delay, rx_delay, ret; > + > + if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) { > + udelay(eqos->reset_delays[1]); > + > + ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0); > + if (ret < 0) > + return ret; > + > + udelay(eqos->reset_delays[2]); > + } > + > + tx_delay = dev_read_u32_default(dev, "tx_delay", 0x30); > + rx_delay = dev_read_u32_default(dev, "rx_delay", 0x10); > + > + switch (pdata->phy_interface) { > + case PHY_INTERFACE_MODE_RGMII: > + return data->ops->set_to_rgmii(dev, tx_delay, rx_delay); > + case PHY_INTERFACE_MODE_RGMII_ID: > + return data->ops->set_to_rgmii(dev, 0, 0); > + case PHY_INTERFACE_MODE_RGMII_RXID: > + return data->ops->set_to_rgmii(dev, tx_delay, 0); > + case PHY_INTERFACE_MODE_RGMII_TXID: > + return data->ops->set_to_rgmii(dev, 0, rx_delay); > + case PHY_INTERFACE_MODE_RMII: > + return data->ops->set_to_rmii(dev); > + } > + > + return -EINVAL; > +} > + > +static int eqos_set_tx_clk_speed_rk(struct udevice *dev) > +{ > + struct eth_pdata *pdata = dev_get_plat(dev); > + struct rockchip_platform_data *data = pdata->priv_pdata; > + > + return data->ops->set_gmac_speed(dev); > +} > + > +static ulong eqos_get_tick_clk_rate_rk(struct udevice *dev) > +{ > + struct eqos_priv *eqos = dev_get_priv(dev); > + > + return clk_get_rate(&eqos->clk_master_bus); > +} > + > +static struct eqos_ops eqos_rockchip_ops = { > + .eqos_inval_desc = eqos_inval_desc_generic, > + .eqos_flush_desc = eqos_flush_desc_generic, > + .eqos_inval_buffer = eqos_inval_buffer_generic, > + .eqos_flush_buffer = eqos_flush_buffer_generic, > + .eqos_probe_resources = eqos_probe_resources_rk, > + .eqos_remove_resources = eqos_remove_resources_rk, > + .eqos_stop_resets = eqos_stop_resets_rk, > + .eqos_start_resets = eqos_start_resets_rk, > + .eqos_stop_clks = eqos_stop_clks_rk, > + .eqos_start_clks = eqos_start_clks_rk, > + .eqos_calibrate_pads = eqos_null_ops, > + .eqos_disable_calibration = eqos_null_ops, > + .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_rk, > + .eqos_get_enetaddr = eqos_null_ops, > + .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_rk, > +}; > + > +struct eqos_config eqos_rockchip_config = { > + .reg_access_always_ok = false, > + .mdio_wait = 10, > + .swr_wait = 50, > + .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB, > + .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_100_150, > + .axi_bus_width = EQOS_AXI_WIDTH_64, > + .interface = dev_read_phy_mode, > + .ops = &eqos_rockchip_ops, > +}; > -- > 2.42.0 > Reviewed-by: Ramon Fried
Re: [PATCH v2 3/7] net: dwc_eth_qos: Stop spam of RX packet not available message
On Sun, Oct 1, 2023 at 10:17 PM Jonas Karlman wrote: > > Remove spam of RX packet not available debug messages when waiting to > receive a packet. > > Signed-off-by: Jonas Karlman > Reviewed-by: Kever Yang > --- > v2: > - Collect r-b tag > > drivers/net/dwc_eth_qos.c | 8 +++- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c > index 7565e716823a..24fb3fac1f12 100644 > --- a/drivers/net/dwc_eth_qos.c > +++ b/drivers/net/dwc_eth_qos.c > @@ -1193,14 +1193,12 @@ static int eqos_recv(struct udevice *dev, int flags, > uchar **packetp) > struct eqos_desc *rx_desc; > int length; > > - debug("%s(dev=%p, flags=%x):\n", __func__, dev, flags); > - > rx_desc = eqos_get_desc(eqos, eqos->rx_desc_idx, true); > eqos->config->ops->eqos_inval_desc(rx_desc); > - if (rx_desc->des3 & EQOS_DESC3_OWN) { > - debug("%s: RX packet not available\n", __func__); > + if (rx_desc->des3 & EQOS_DESC3_OWN) > return -EAGAIN; > - } > + > + debug("%s(dev=%p, flags=%x):\n", __func__, dev, flags); > > *packetp = eqos->rx_dma_buf + > (eqos->rx_desc_idx * EQOS_MAX_PACKET_SIZE); > -- > 2.42.0 > Reviewed-by: Ramon Fried
Re: [PATCH v2 2/7] net: dwc_eth_qos: Return error code when start fails
On Sun, Oct 1, 2023 at 10:17 PM Jonas Karlman wrote: > > Return error code when phy_connect fails or no link can be established. > > Signed-off-by: Jonas Karlman > Reviewed-by: Kever Yang > --- > v2: > - Collect r-b tag > > drivers/net/dwc_eth_qos.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c > index 555eaee3bbc3..7565e716823a 100644 > --- a/drivers/net/dwc_eth_qos.c > +++ b/drivers/net/dwc_eth_qos.c > @@ -811,6 +811,7 @@ static int eqos_start(struct udevice *dev) > > if (!eqos->phy) { > pr_err("phy_connect() failed"); > + ret = -ENODEV; > goto err_stop_resets; > } > > @@ -838,6 +839,7 @@ static int eqos_start(struct udevice *dev) > > if (!eqos->phy->link) { > pr_err("No link"); > + ret = -EAGAIN; > goto err_shutdown_phy; > } > > -- > 2.42.0 > Reviewed-by: Ramon Fried
Re: [PATCH v2 1/7] net: dwc_eth_qos: Drop unused rx_pkt from eqos_priv
On Sun, Oct 1, 2023 at 10:17 PM Jonas Karlman wrote: > > rx_pkt is allocated and not used for anything, remove it. > > Signed-off-by: Jonas Karlman > Reviewed-by: Kever Yang > --- > v2: > - Collect r-b tag > > drivers/net/dwc_eth_qos.c | 11 --- > drivers/net/dwc_eth_qos.h | 1 - > 2 files changed, 12 deletions(-) > > diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c > index 1e92bd9ca9c0..555eaee3bbc3 100644 > --- a/drivers/net/dwc_eth_qos.c > +++ b/drivers/net/dwc_eth_qos.c > @@ -1314,22 +1314,12 @@ static int eqos_probe_resources_core(struct udevice > *dev) > } > debug("%s: rx_dma_buf=%p\n", __func__, eqos->rx_dma_buf); > > - eqos->rx_pkt = malloc(EQOS_MAX_PACKET_SIZE); > - if (!eqos->rx_pkt) { > - debug("%s: malloc(rx_pkt) failed\n", __func__); > - ret = -ENOMEM; > - goto err_free_rx_dma_buf; > - } > - debug("%s: rx_pkt=%p\n", __func__, eqos->rx_pkt); > - > eqos->config->ops->eqos_inval_buffer(eqos->rx_dma_buf, > EQOS_MAX_PACKET_SIZE * EQOS_DESCRIPTORS_RX); > > debug("%s: OK\n", __func__); > return 0; > > -err_free_rx_dma_buf: > - free(eqos->rx_dma_buf); > err_free_tx_dma_buf: > free(eqos->tx_dma_buf); > err_free_descs: > @@ -1348,7 +1338,6 @@ static int eqos_remove_resources_core(struct udevice > *dev) > > debug("%s(dev=%p):\n", __func__, dev); > > - free(eqos->rx_pkt); > free(eqos->rx_dma_buf); > free(eqos->tx_dma_buf); > eqos_free_descs(eqos->rx_descs); > diff --git a/drivers/net/dwc_eth_qos.h b/drivers/net/dwc_eth_qos.h > index a6b719af809f..06a082da72ef 100644 > --- a/drivers/net/dwc_eth_qos.h > +++ b/drivers/net/dwc_eth_qos.h > @@ -273,7 +273,6 @@ struct eqos_priv { > unsigned int desc_per_cacheline; > void *tx_dma_buf; > void *rx_dma_buf; > - void *rx_pkt; > bool started; > bool reg_access_ok; > bool clk_ck_enabled; > -- > 2.42.0 > Reviewed-by: Ramon Fried
Re: [PATCH] net: ftgmac100: Add reset control
On Thu, Jul 27, 2023 at 4:58 AM Dylan Hung wrote: > > Add optional reset control, especially for the Aspeed SOC. For the > hardware without a reset line, the reset assertion/deassertion will be > skipped. > > Signed-off-by: Dylan Hung > --- > drivers/net/ftgmac100.c | 12 > 1 file changed, 12 insertions(+) > > diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c > index a50cde338a..886b97119d 100644 > --- a/drivers/net/ftgmac100.c > +++ b/drivers/net/ftgmac100.c > @@ -13,6 +13,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -90,6 +91,7 @@ struct ftgmac100_data { > u32 max_speed; > > struct clk_bulk clks; > + struct reset_ctl *reset_ctl; > > /* End of RX/TX ring buffer bits. Depend on model */ > u32 rxdes0_edorr_mask; > @@ -568,6 +570,8 @@ static int ftgmac100_of_to_plat(struct udevice *dev) > priv->txdes0_edotr_mask = BIT(15); > } > > + priv->reset_ctl = devm_reset_control_get_optional(dev, NULL); > + > return clk_get_bulk(dev, &priv->clks); > } > > @@ -593,6 +597,12 @@ static int ftgmac100_probe(struct udevice *dev) > if (ret) > goto out; > > + if (priv->reset_ctl) { > + ret = reset_deassert(priv->reset_ctl); > + if (ret) > + goto out; > + } > + > /* > * If DM MDIO is enabled, the MDIO bus will be initialized later in > * dm_eth_phy_connect > @@ -628,6 +638,8 @@ static int ftgmac100_remove(struct udevice *dev) > free(priv->phydev); > mdio_unregister(priv->bus); > mdio_free(priv->bus); > + if (priv->reset_ctl) > + reset_assert(priv->reset_ctl); > clk_release_bulk(&priv->clks); > > return 0; > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH] net: phy: TI DP83869 fix invalid clock delay configuration
869_CLK_DELAY_STEP; > } > > - /* TX delay *must* be specified if internal delay of RX is used. */ > + /* TX delay *must* be specified if internal delay of TX is used. */ > if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || > phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { > - dp83869->tx_int_delay = ofnode_read_u32_default(node, > "tx-internal-delay-ps", > - > DP83869_CLK_DELAY_DEF); > - if (dp83869->tx_int_delay > delay_entries) { > - dp83869->tx_int_delay = DP83869_CLK_DELAY_DEF; > - pr_debug("tx-internal-delay-ps not set/invalid, > default to %ups\n", > - > dp83869_internal_delay[dp83869->tx_int_delay]); > + dp83869->tx_int_delay = ofnode_read_u32_default(node, > + "tx-internal-delay-ps", DP83869_CLK_DELAY_DEFAULT); > + if (dp83869->tx_int_delay > DP83869_CLK_DELAY_MAX || > + dp83869->tx_int_delay < DP83869_CLK_DELAY_MIN || > + dp83869->tx_int_delay % DP83869_CLK_DELAY_STEP) { > + dp83869->tx_int_delay = DP83869_CLK_DELAY_DEFAULT; > + pr_warn("tx-internal-delay-ps not set/invalid, > default" > + " to %ups\n", DP83869_CLK_DELAY_DEFAULT); > } > > - dp83869->tx_int_delay = > dp83869_internal_delay[dp83869->tx_int_delay]; > + dp83869->tx_int_delay = > + (dp83869->tx_int_delay - DP83869_CLK_DELAY_STEP) > + / DP83869_CLK_DELAY_STEP; > } > > return 0; > -- > 2.30.2 > Reviewed-by: Ramon Fried
Re: [PATCH] test/py: net: Add a test for 'pxe get' command
On Tue, Oct 3, 2023 at 4:12 PM Love Kumar wrote: > > Execute the 'pxe get' command to download a pxe configuration file from > the TFTP server and validate its interpretation. > > Signed-off-by: Love Kumar > --- > test/py/tests/test_net.py | 66 +++ > 1 file changed, 66 insertions(+) > > diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py > index cd4b4dc53cbc..b2241ae6a482 100644 > --- a/test/py/tests/test_net.py > +++ b/test/py/tests/test_net.py > @@ -6,6 +6,7 @@ > > import pytest > import u_boot_utils > +import uuid > > """ > Note: This test relies on boardenv_* containing configuration values to > define > @@ -61,6 +62,16 @@ env__net_nfs_readable_file = { > 'crc32': 'c2244b26', > } > > +# Details regarding a file that may be read from a TFTP server. This variable > +# may be omitted or set to None if PXE testing is not possible or desired. > +env__net_pxe_readable_file = { > +'fn': 'default', > +'addr': 0x200, > +'size': 74, > +'timeout': 5, > +'pattern': 'Linux', > +} > + > # True if a router advertisement service is connected to the network, and > should > # be tested. If router advertisement testing is not possible or desired, this > variable may be omitted or set to False. > @@ -260,3 +271,58 @@ def test_net_nfs(u_boot_console): > > output = u_boot_console.run_command('crc32 %x $filesize' % addr) > assert expected_crc in output > + > +@pytest.mark.buildconfigspec("cmd_net") > +@pytest.mark.buildconfigspec("cmd_pxe") > +def test_net_pxe_get(u_boot_console): > +"""Test the pxe get command. > + > +A pxe configuration file is downloaded from the TFTP server and > interpreted > +to boot the images mentioned in pxe configuration file. > + > +The details of the file to download are provided by the boardenv_* file; > +see the comment at the beginning of this file. > +""" > + > +if not net_set_up: > +pytest.skip("Network not initialized") > + > +test_net_setup_static(u_boot_console) > + > +f = u_boot_console.config.env.get("env__net_pxe_readable_file", None) > +if not f: > +pytest.skip("No PXE readable file to read") > + > +addr = f.get("addr", None) > +timeout = f.get("timeout", u_boot_console.p.timeout) > + > +pxeuuid = uuid.uuid1() > +u_boot_console.run_command(f"setenv pxeuuid {pxeuuid}") > +expected_text_uuid = f"Retrieving file: pxelinux.cfg/{pxeuuid}" > + > +ethaddr = u_boot_console.run_command("echo $ethaddr") > +ethaddr = ethaddr.replace(':', '-') > +expected_text_ethaddr = f"Retrieving file: pxelinux.cfg/01-{ethaddr}" > + > +ip = u_boot_console.run_command("echo $ipaddr") > +ip = ip.split('.') > +ipaddr_file = "".join(['%02x' % int(x) for x in ip]).upper() > +expected_text_ipaddr = f"Retrieving file: pxelinux.cfg/{ipaddr_file}" > +expected_text_default = f"Retrieving file: pxelinux.cfg/default" > + > +with u_boot_console.temporary_timeout(timeout): > +output = u_boot_console.run_command("pxe get") > + > +assert "TIMEOUT" not in output > +assert expected_text_uuid in output > +assert expected_text_ethaddr in output > +assert expected_text_ipaddr in output > + > +i = 1 > +for i in range(0, len(ipaddr_file) - 1): > +expected_text_ip = f"Retrieving file: > pxelinux.cfg/{ipaddr_file[:-i]}" > +assert expected_text_ip in output > +i += 1 > + > +assert expected_text_default in output > +assert "Config file 'default.boot' found" in output > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH] test/py: net: Add dhcp abort test
On Tue, Oct 3, 2023 at 3:46 PM Love Kumar wrote: > > Abort the dhcp request in the middle by pressing ctrl + c on u-boot > prompt and validate the abort status. > > Signed-off-by: Love Kumar > --- > test/py/tests/test_net.py | 44 +++ > 1 file changed, 44 insertions(+) > > diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py > index cd4b4dc53cbc..1e8eb0357eef 100644 > --- a/test/py/tests/test_net.py > +++ b/test/py/tests/test_net.py > @@ -6,6 +6,7 @@ > > import pytest > import u_boot_utils > +import re > > """ > Note: This test relies on boardenv_* containing configuration values to > define > @@ -104,6 +105,49 @@ def test_net_dhcp(u_boot_console): > global net_set_up > net_set_up = True > > +@pytest.mark.buildconfigspec("cmd_dhcp") > +def test_net_dhcp_abort(u_boot_console): > +"""Test the dhcp command by pressing ctrl+c in the middle of dhcp request > + > +The boardenv_* file may be used to enable/disable this test; see the > +comment at the beginning of this file. > +""" > + > +test_dhcp = u_boot_console.config.env.get("env__net_dhcp_server", False) > +if not test_dhcp: > +pytest.skip("No DHCP server available") > + > +u_boot_console.run_command("setenv autoload no") > + > +# Phy reset before running dhcp command > +output = u_boot_console.run_command("mii device") > +eth_num = re.search(r"Current device: '(.+?)'", output).groups()[0] > +u_boot_console.run_command(f"mii device {eth_num}") > +output = u_boot_console.run_command("mii info") > +eth_addr = hex(int(re.search(r"PHY (.+?):", output).groups()[0], 16)) > +u_boot_console.run_command(f"mii modify {eth_addr} 0 0x8000 0x8000") > + > +u_boot_console.run_command("dhcp", wait_for_prompt=False) > +try: > +u_boot_console.wait_for("Waiting for PHY auto negotiation to > complete") > +except: > +pytest.skip("Timeout waiting for PHY auto negotiation to complete") > + > +u_boot_console.wait_for("done") > + > +# Sending Ctrl-C > +output = u_boot_console.run_command( > +chr(3), wait_for_echo=False, send_nl=False > +) > + > +assert "TIMEOUT" not in output > +assert "DHCP client bound to address " not in output > +assert "Abort" in output > + > +# Provide a time to recover from Abort - if it is not performed > +# There is message like: ethernet@ff0e: No link. > +u_boot_console.run_command("sleep 1") > + > @pytest.mark.buildconfigspec('cmd_dhcp6') > def test_net_dhcp6(u_boot_console): > """Test the dhcp6 command. > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH] test/py: net: Add a TFTP put test
On Tue, Oct 3, 2023 at 12:02 PM Love Kumar wrote: > > Execute tftpput command for uploading files to a server and validate its > size & CRC32. > > Signed-off-by: Love Kumar > --- > test/py/tests/test_net.py | 69 +++ > 1 file changed, 69 insertions(+) > > diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py > index cd4b4dc53cbc..f69e3ea2dbba 100644 > --- a/test/py/tests/test_net.py > +++ b/test/py/tests/test_net.py > @@ -6,6 +6,7 @@ > > import pytest > import u_boot_utils > +import datetime > > """ > Note: This test relies on boardenv_* containing configuration values to > define > @@ -50,6 +51,7 @@ env__net_tftp_readable_file = { > 'addr': 0x1000, > 'size': 5058624, > 'crc32': 'c2244b26', > +'timeout': 5, > } > > # Details regarding a file that may be read from a NFS server. This variable > @@ -260,3 +262,70 @@ def test_net_nfs(u_boot_console): > > output = u_boot_console.run_command('crc32 %x $filesize' % addr) > assert expected_crc in output > + > +@pytest.mark.buildconfigspec("cmd_crc32") > +@pytest.mark.buildconfigspec("cmd_net") > +def test_net_tftpput(u_boot_console): > +"""Test the tftpput command. > +A file is downloaded from the TFTP server and then uploaded to the TFTP > +server, its size and its CRC32 are validated. > +The details of the file to download are provided by the boardenv_* file; > +see the comment at the beginning of this file. > +""" > + > +if not net_set_up: > +pytest.skip("Network not initialized") > + > +f = u_boot_console.config.env.get("env__net_tftp_readable_file", None) > +if not f: > +pytest.skip("No TFTP readable file to read") > + > +addr = f.get("addr", None) > +if not addr: > +addr = u_boot_utils.find_ram_base(u_boot_console) > + > +sz = f.get("size", None) > +timeout = f.get("timeout", u_boot_console.p.timeout) > +fn = f["fn"] > +fnu = "_".join([datetime.datetime.now().strftime("%y%m%d%H%M%S"), fn]) > +expected_text = "Bytes transferred = " > +if sz: > +expected_text += "%d" % sz > + > +with u_boot_console.temporary_timeout(timeout): > +output = u_boot_console.run_command("tftpboot %x %s" % (addr, fn)) > + > +assert "TIMEOUT" not in output > +assert expected_text in output > + > +expected_tftpb_crc = f.get("crc32", None) > + > +output = u_boot_console.run_command("crc32 $fileaddr $filesize") > +assert expected_tftpb_crc in output > + > +with u_boot_console.temporary_timeout(timeout): > +output = u_boot_console.run_command( > +"tftpput $fileaddr $filesize $serverip:%s" % (fnu) > +) > + > +expected_text = "Bytes transferred = " > +if sz: > +expected_text += "%d" % sz > +addr = addr + sz > +assert "TIMEOUT" not in output > +assert "Access violation" not in output > +assert expected_text in output > + > +with u_boot_console.temporary_timeout(timeout): > +output = u_boot_console.run_command("tftpboot %x %s" % (addr, fnu)) > + > +expected_text = "Bytes transferred = " > +if sz: > +expected_text += "%d" % sz > +assert "TIMEOUT" not in output > +assert expected_text in output > + > +expected_tftpp_crc = expected_tftpb_crc > + > +output = u_boot_console.run_command("crc32 $fileaddr $filesize") > +assert expected_tftpp_crc in output > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH] net: ksz9477: add support for KSZ9893 GbE switch
data8 |= PORT_MII_NOT_1GBIT; > + ksz9477_set_xmii(priv, 0, &data8); > + ksz9477_set_gbit(priv, false, &data8); > break; > case PHY_INTERFACE_MODE_RMII: > - data8 &= ~PORT_MII_SEL_M; > - data8 |= PORT_RMII_SEL; > - data8 |= PORT_MII_NOT_1GBIT; > + ksz9477_set_xmii(priv, 1, &data8); > + ksz9477_set_gbit(priv, false, &data8); > break; > case PHY_INTERFACE_MODE_GMII: > - data8 &= ~PORT_MII_SEL_M; > - data8 |= PORT_GMII_SEL; > - data8 &= ~PORT_MII_NOT_1GBIT; > + ksz9477_set_xmii(priv, 2, &data8); > + ksz9477_set_gbit(priv, true, &data8); > break; > default: > - data8 &= ~PORT_MII_SEL_M; > - data8 |= PORT_RGMII_SEL; > - data8 &= ~PORT_MII_NOT_1GBIT; > + ksz9477_set_xmii(priv, 3, &data8); > + ksz9477_set_gbit(priv, true, &data8); > data8 &= ~PORT_RGMII_ID_IG_ENABLE; > data8 &= ~PORT_RGMII_ID_EG_ENABLE; > if (interface == PHY_INTERFACE_MODE_RGMII_ID || > @@ -329,6 +394,8 @@ static int ksz_port_setup(struct udevice *dev, int port, > if (interface == PHY_INTERFACE_MODE_RGMII_ID || > interface == PHY_INTERFACE_MODE_RGMII_TXID) > data8 |= PORT_RGMII_ID_EG_ENABLE; > + if (priv->features & IS_9893) > + data8 &= ~PORT_MII_MAC_MODE; > break; > } > ksz_write8(dev, PORT_CTRL_ADDR(port, REG_PORT_XMII_CTRL_1), > data8); > @@ -479,10 +546,17 @@ static int ksz_i2c_probe(struct udevice *dev) > case 0x00989700: > puts("KSZ9897S: "); > break; > + case 0x00989300: > + puts("KSZ9893R: "); > + break; > default: > dev_err(dev, "invalid chip id: 0x%08x\n", id); > return -EINVAL; > } > + if ((id & 0xf00) == 0x300) > + priv->features |= IS_9893; > + else > + priv->features |= NEW_XMII; > > /* probe mdio bus */ > ret = ksz_probe_mdio(dev); > @@ -503,6 +577,7 @@ static const struct udevice_id ksz_i2c_ids[] = { > { .compatible = "microchip,ksz9897" }, > { .compatible = "microchip,ksz9477" }, > { .compatible = "microchip,ksz9567" }, > + { .compatible = "microchip,ksz9893" }, > { } > }; > > -- > 2.25.1 > > Reviewed-by: Ramon Fried
Re: [PATCH v1 3/4] net: rtl8169: Add one more device ID
On Wed, Jun 21, 2023 at 12:05 PM Minda Chen wrote: > > Add the NIC device ID and adjust the PCI bar regions. > > Signed-off-by: Minda Chen > --- > drivers/net/rtl8169.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c > index 34e4cff1e9..963702777c 100644 > --- a/drivers/net/rtl8169.c > +++ b/drivers/net/rtl8169.c > @@ -353,10 +353,11 @@ static const unsigned int rtl8169_rx_config = > (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); > > static struct pci_device_id supported[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8125) }, > + { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161) }, > { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167) }, > { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168) }, > { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169) }, > - { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8125) }, > {} > }; > > @@ -1051,8 +1052,9 @@ static int rtl8169_eth_probe(struct udevice *dev) > int ret; > > switch (pplat->device) { > - case 0x8168: > case 0x8125: > + case 0x8161: > + case 0x8168: > region = 2; > break; > default: > -- > 2.17.1 > Reviewed-by: Ramon Fried
Re: [PATCH v1 2/4] net: rtl8169: Fix DMA min aligned compile warning in riscv
On Wed, Jun 21, 2023 at 12:05 PM Minda Chen wrote: > > Fix rtl8169 descriptor less the DMA min aligned compile warning > for RISC-V SoC platform. > > Signed-off-by: Minda Chen > --- > drivers/net/rtl8169.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c > index dcba51590d..34e4cff1e9 100644 > --- a/drivers/net/rtl8169.c > +++ b/drivers/net/rtl8169.c > @@ -311,10 +311,12 @@ static unsigned char rxdata[RX_BUF_LEN]; > * > * This can be fixed by defining CONFIG_SYS_NONCACHED_MEMORY which will cause > * the driver to allocate descriptors from a pool of non-cached memory. > + * > + * Hardware maintain D-cache coherency in RISC-V architecture. > */ > #if RTL8169_DESC_SIZE < ARCH_DMA_MINALIGN > #if !defined(CONFIG_SYS_NONCACHED_MEMORY) && \ > - !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) && !defined(CONFIG_X86) > + !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) && !defined(CONFIG_X86) && > !defined(CONFIG_RISCV) > #warning cache-line size is larger than descriptor size > #endif > #endif > -- > 2.17.1 > Reviewed-by: Ramon Fried
Re: [PATCH v1 1/4] net: rtl8169: Fix compile warning in rtl8169 network adapter
On Wed, Jun 21, 2023 at 12:05 PM Minda Chen wrote: > > Fix make pointer from integer without a cast compile warning. > > Signed-off-by: Minda Chen > --- > drivers/net/rtl8169.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c > index 2276a465e7..dcba51590d 100644 > --- a/drivers/net/rtl8169.c > +++ b/drivers/net/rtl8169.c > @@ -96,12 +96,12 @@ static int media[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, > -1, -1 }; > #define TX_TIMEOUT (6*HZ) > > /* write/read MMIO register. Notice: {read,write}[wl] do the necessary > swapping */ > -#define RTL_W8(reg, val8) writeb((val8), ioaddr + (reg)) > -#define RTL_W16(reg, val16)writew((val16), ioaddr + (reg)) > -#define RTL_W32(reg, val32)writel((val32), ioaddr + (reg)) > -#define RTL_R8(reg)readb(ioaddr + (reg)) > -#define RTL_R16(reg) readw(ioaddr + (reg)) > -#define RTL_R32(reg) readl(ioaddr + (reg)) > +#define RTL_W8(reg, val8) writeb((val8), (void *)(ioaddr + (reg))) > +#define RTL_W16(reg, val16)writew((val16), (void *)(ioaddr + (reg))) > +#define RTL_W32(reg, val32)writel((val32), (void *)(ioaddr + (reg))) > +#define RTL_R8(reg)readb((void *)(ioaddr + (reg))) > +#define RTL_R16(reg) readw((void *)(ioaddr + (reg))) > +#define RTL_R32(reg) readl((void *)(ioaddr + (reg))) > > #define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)(unsigned long)dev->priv, \ > (pci_addr_t)(unsigned long)a) > -- > 2.17.1 > Reviewed-by: Ramon Fried
Re: [PATCH 2/2] net: phy: Release PHY from GPIO reset if applicable
On Tue, Jun 20, 2023 at 1:46 AM Marek Vasut wrote: > > In case the PHY DT node describes GPIO reset and no other method > of detecting the PHY succeeded, release the PHY from reset using > its reset GPIO before reading out the PHY IDs as a last resort. > This way there is slightly better chance of successful PHY ID > readout. > > Signed-off-by: Marek Vasut > --- > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/phy/phy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 3d69c2c4d28..373006f8206 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -969,7 +969,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int > addr, > phydev = phy_connect_gmii2rgmii(bus, dev); > #endif > > - if (!phydev) > + if (!phydev && !phy_gpio_reset(dev)) > phydev = phy_find_by_mask(bus, mask); > > if (phydev) > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 1/2] net: phy: Factor out PHY GPIO reset code
On Tue, Jun 20, 2023 at 1:46 AM Marek Vasut wrote: > > Pull the PHY GPIO reset code into separate function, since > this is and will be reused multiple times. Set up default > reset assert and deassert timing to generous 20ms and 1ms > for maximum compatibility in case those DT properties are > missing. > > Signed-off-by: Marek Vasut > --- > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/phy/ethernet_id.c | 37 --- > drivers/net/phy/phy.c | 47 +++ > include/phy.h | 9 +++ > 3 files changed, 61 insertions(+), 32 deletions(-) > > diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c > index 877a51c3d00..0beafaae46a 100644 > --- a/drivers/net/phy/ethernet_id.c > +++ b/drivers/net/phy/ethernet_id.c > @@ -18,12 +18,11 @@ struct phy_device *phy_connect_phy_id(struct mii_dev > *bus, struct udevice *dev, > { > struct phy_device *phydev; > struct ofnode_phandle_args phandle_args; > - struct gpio_desc gpio; > const char *node_name; > struct udevice *pdev; > - ofnode node; > - u32 id, assert, deassert; > u16 vendor, device; > + ofnode node; > + u32 id; > int ret; > > if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, > @@ -41,35 +40,9 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, > struct udevice *dev, > return NULL; > } > > - if (!IS_ENABLED(CONFIG_DM_ETH_PHY)) { > - ret = gpio_request_by_name_nodev(node, "reset-gpios", 0, > &gpio, > -GPIOD_IS_OUT | > GPIOD_ACTIVE_LOW); > - if (!ret) { > - assert = ofnode_read_u32_default(node, > -"reset-assert-us", > 0); > - deassert = ofnode_read_u32_default(node, > - > "reset-deassert-us", > - 0); > - ret = dm_gpio_set_value(&gpio, 1); > - if (ret) { > - dev_err(dev, > - "Failed assert gpio, err: %d\n", ret); > - return NULL; > - } > - > - udelay(assert); > - > - ret = dm_gpio_set_value(&gpio, 0); > - if (ret) { > - dev_err(dev, > - "Failed deassert gpio, err: %d\n", > - ret); > - return NULL; > - } > - > - udelay(deassert); > - } > - } > + ret = phy_gpio_reset(dev); > + if (ret) > + return NULL; > > id = vendor << 16 | device; > phydev = phy_device_create(bus, phyaddr, id, false); > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index ae21acb059b..3d69c2c4d28 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -18,6 +18,8 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > @@ -799,6 +801,51 @@ int miiphy_reset(const char *devname, unsigned char addr) > return phy_reset(phydev); > } > > +int phy_gpio_reset(struct udevice *dev) > +{ > + struct ofnode_phandle_args phandle_args; > + struct gpio_desc gpio; > + u32 assert, deassert; > + ofnode node; > + int ret; > + > + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, > +&phandle_args); > + /* No PHY handle is OK */ > + if (ret) > + return 0; > + > + node = phandle_args.node; > + if (!ofnode_valid(node)) > + return -EINVAL; > + > + ret = gpio_request_by_name_nodev(node, "reset-gpios", 0, &gpio, > +GPIOD_IS_OUT | GPIOD_ACTIVE_LOW); > + /* No PHY reset GPIO is OK */ > + if (ret) > + return 0; > + > + assert = ofnode_read_u32_default(node, "reset-assert-us", 2); > + deassert = ofnode_read_u32_default(node, "reset-deassert-us", 1000); >
Re: [PATCH v1] net: sun8i-emac: Add support for fixed-link phy
On Thu, Jun 15, 2023 at 12:51 AM Maxim Kiselev wrote: > > From: Maksim Kiselev > > Based on dt-specs fixed-link doesn't require phy-handle to be used. > Fix driver to only read phy related setting when phy-handle is found. > > Signed-off-by: Maksim Kiselev > --- > drivers/net/sun8i_emac.c | 7 ++- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c > index 04c3274fbe..0e339d69e0 100644 > --- a/drivers/net/sun8i_emac.c > +++ b/drivers/net/sun8i_emac.c > @@ -834,11 +834,8 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev) > priv->use_internal_phy = false; > > offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle"); > - if (offset < 0) { > - debug("%s: Cannot find PHY address\n", __func__); > - return -EINVAL; > - } > - priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1); > + if (offset >= 0) > + priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", > -1); > > pdata->phy_interface = dev_read_phy_mode(dev); > debug("phy interface %d\n", pdata->phy_interface); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH v1 2/2] net: designware: Add bitbang feature for designware driver
On Tue, Jun 13, 2023 at 9:29 AM Jim Liu wrote: > > Hi Ramon > > Thanks for your review. > The udelay timing is defined on our spec . > Does this need to use config to control it or use dts method to set the > timing? dts > > > Best regards, > Jim >
Re: [PATCH v1 2/2] net: designware: Add bitbang feature for designware driver
On Tue, Feb 14, 2023 at 10:20 AM Jim Liu wrote: > > Add bb_miiphy_bus function for designware bitbang feature. > > Signed-off-by: Jim Liu > --- > drivers/net/designware.c | 109 ++- > drivers/net/designware.h | 3 ++ > 2 files changed, 111 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/designware.c b/drivers/net/designware.c > index e09ca3313d..c539afc620 100644 > --- a/drivers/net/designware.c > +++ b/drivers/net/designware.c > @@ -757,6 +757,32 @@ int designware_eth_probe(struct udevice *dev) > } > priv->bus = miiphy_get_dev_by_name(dev->name); > > +#if defined(CONFIG_BITBANGMII) && defined(CONFIG_DM_GPIO) > + if (dev_read_bool(dev, "snps,bitbang-mii")) { > + printf("\n%s: use bitbang mii..\n", dev->name); debug > + ret = gpio_request_by_name(dev, "snps,mdc-gpio", 0, > + &priv->mdc_gpio, GPIOD_IS_OUT); > + if (ret) { > + printf("no mdc-gpio\n"); > + return ret; > + } > + > + ret = gpio_request_by_name(dev, "snps,mdio-gpio", 0, > + &priv->mdio_gpio, GPIOD_IS_OUT); > + > + if (ret) { > + printf("no mdio-gpio\n"); > + return ret; > + } > + dm_gpio_set_value(&priv->mdc_gpio, 1); > + bb_miiphy_buses[0].priv = priv; > + sprintf(bb_miiphy_buses[0].name, dev->name); > + priv->bus->read = bb_miiphy_read; > + priv->bus->write = bb_miiphy_write; > + priv->bus->reset = NULL; > + } > +#endif > + > ret = dw_phy_init(priv, dev); > debug("%s, ret=%d\n", __func__, ret); > if (!ret) > @@ -826,7 +852,7 @@ int designware_eth_of_to_plat(struct udevice *dev) > reset_flags |= GPIOD_ACTIVE_LOW; > > ret = gpio_request_by_name(dev, "snps,reset-gpio", 0, > - &priv->reset_gpio, reset_flags); > + &priv->reset_gpio, reset_flags); What has changed here ? > if (ret == 0) { > ret = dev_read_u32_array(dev, "snps,reset-delays-us", > dw_pdata->reset_delays, 3); > @@ -866,3 +892,84 @@ static struct pci_device_id supported[] = { > }; > > U_BOOT_PCI_DEVICE(eth_designware, supported); > + > +#if defined(CONFIG_BITBANGMII) && CONFIG_IS_ENABLED(DM_GPIO) > +int dw_eth_bb_init(struct bb_miiphy_bus *bus) > +{ > + return 0; > +} > + > +static int dw_eth_bb_mdio_active(struct bb_miiphy_bus *bus) > +{ > + struct dw_eth_dev *priv = bus->priv; > + struct gpio_desc *desc = &priv->mdio_gpio; > + desc->flags = 0; > + dm_gpio_set_dir_flags(&priv->mdio_gpio, GPIOD_IS_OUT); > + > + return 0; > +} > + > +static int dw_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) > +{ > + struct dw_eth_dev *priv = bus->priv; > + struct gpio_desc *desc = &priv->mdio_gpio; > + desc->flags = 0; > + dm_gpio_set_dir_flags(&priv->mdio_gpio, GPIOD_IS_IN); > + > + return 0; > +} > + > +static int dw_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) > +{ > + struct dw_eth_dev *priv = bus->priv; > + > + if (v) > + dm_gpio_set_value(&priv->mdio_gpio, 1); > + else > + dm_gpio_set_value(&priv->mdio_gpio, 0); > + > + return 0; > +} > + > +static int dw_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) > +{ > + struct dw_eth_dev *priv = bus->priv; > + > + *v = dm_gpio_get_value(&priv->mdio_gpio); > + return 0; > +} > + > +static int dw_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) > +{ > + struct dw_eth_dev *priv = bus->priv; > + > + if (v) > + dm_gpio_set_value(&priv->mdc_gpio, 1); > + else > + dm_gpio_set_value(&priv->mdc_gpio, 0); > + > + return 0; > +} > + > +static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) > +{ > + udelay(1); Where is this 1 usec coming from ? should it be configurable ? > + > + return 0; > +} > + > +struct bb_miiphy_bus bb_miiphy_buses[] = { > + { > + .name = "dw_eth_bb", > + .init = dw_eth_bb_init, > + .mdio_active= dw_eth_bb_mdio_active, > + .mdio_tristate = dw_eth_bb_mdio_tristate, > + .set_mdio = dw_eth_bb_set_mdio, > + .get_mdio = dw_eth_bb_get_mdio, > + .set_mdc= dw_eth_bb_set_mdc, > + .delay = dw_eth_bb_delay, > + } > +}; > + > +int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses); > +#endif > diff --git a/drivers/net/designware.h b/drivers/net/designware.h > index 9da4e902cb..68ca5d9cd0 100644 > --- a/drivers/net/designware.h > +++ b/drivers/net/designware.h > @@ -235,6 +235,9 @@ struct dw_eth_de
Re: [PATCH 0/6] Add the 'net stats' command to dump network statistics
On Wed, May 31, 2023 at 4:19 AM Peng Fan wrote: > > Hi Joe, Ramon > > I see this patchset is delegated to me, would you take care this > patchset or let me handle? > > Thanks, > Peng. > > On 5/23/2023 9:47 PM, Ioana Ciornei wrote: > > > > > > > This patch set extends the 'net' command so that it can be used to dump > > network statistics on the available devices. The first user of this new > > API is the ldpaa_eth driver which, in the last patch, implements the 3 > > new callbacks added. > > > > Since the ldpaa_eth driver already had some debug printing of counters, > > the first 4 patches are there to extend the existing list of counters > > and to reorganize the code so that it fits better with the new eth_ops > > callbacks. > > > > Ioana Ciornei (6): > >net: ldpaa_eth: fix the memory layout of the dpmac_get_counters() API > >net: ldpaa_eth: transform dpni_statistics from a struct to a union > >net: ldpaa_eth: extend debug capabilities with DPNI statistics > >net: ldpaa_eth: extend debug capabilities with DPMAC statistics > >cmd: net: add a 'net stats' command to dump network statistics > >net: ldpaa_eth: export DPNI and DPMAC counters through 'net stats' > > > > cmd/net.c | 54 ++- > > drivers/net/fsl-mc/dpni.c | 2 +- > > drivers/net/ldpaa_eth/ldpaa_eth.c | 248 +++--- > > drivers/net/ldpaa_eth/ldpaa_eth.h | 64 > > include/fsl-mc/fsl_dpmac.h| 7 +- > > include/fsl-mc/fsl_dpni.h | 143 - > > include/net.h | 6 + > > 7 files changed, 353 insertions(+), 171 deletions(-) > > > > -- > > 2.25.1 > > Hi Peng, I reviewed everything. Tom will pick this up. Thanks, Ramon
Re: [PATCH 14/14] net: sh_eth: Fix RX error handling
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > From: Valentine Barshak > > In case RX error occurs, and the RD_RFE bit is set, the descriptor > is never returned back to the queue. Make sh_eth_recv_start return > zero length in this case so that the descriptor can be released > and pushed back to the list. Also return the more appropriate > -EAGAIN instead of -EINVAL if the descriptor is not ready yet. > > Signed-off-by: Valentine Barshak > Reviewed-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/sh_eth.c | 16 +++- > 1 file changed, 7 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c > index 7314caadfdc..7b1f59dc498 100644 > --- a/drivers/net/sh_eth.c > +++ b/drivers/net/sh_eth.c > @@ -129,11 +129,11 @@ static int sh_eth_recv_start(struct sh_eth_dev *eth) > /* Check if the rx descriptor is ready */ > invalidate_cache(port_info->rx_desc_cur, sizeof(struct rx_desc_s)); > if (port_info->rx_desc_cur->rd0 & RD_RACT) > - return -EINVAL; > + return -EAGAIN; > > /* Check for errors */ > if (port_info->rx_desc_cur->rd0 & RD_RFE) > - return -EINVAL; > + return 0; > > return port_info->rx_desc_cur->rd1 & 0x; > } > @@ -556,15 +556,13 @@ static int sh_ether_recv(struct udevice *dev, int > flags, uchar **packetp) > *packetp = packet; > > return len; > - } else { > - len = 0; > + } > > - /* Restart the receiver if disabled */ > - if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) > - sh_eth_write(port_info, EDRRR_R, EDRRR); > + /* Restart the receiver if disabled */ > + if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) > + sh_eth_write(port_info, EDRRR_R, EDRRR); > > - return -EAGAIN; > - } > + return len; > } > > static int sh_ether_free_pkt(struct udevice *dev, uchar *packet, int length) > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 13/14] net: sh_eth: Workaround cache issues
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > From: Valentine Barshak > > U-Boot writes to RX packets when constructing replies. > This can cause stale cached data to be written to RX > buffer while we're receiving a packet. This causes RX > packet corruption because we invalidate the cache right > before processing the packet. Invalidate packet buffer > cache when preparing RX descriptor as well. This seems > to fix RX packet drops with high RX traffic. > > While at it flush the descriptors right before enabling > RX/TX in sh_eth_tx_desc_init/sh_eth_rx_desc_init callbacks > when they are ready instead of flushing after allocation. > > Signed-off-by: Valentine Barshak > Reviewed-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/sh_eth.c | 10 ++ > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c > index 95042daade0..7314caadfdc 100644 > --- a/drivers/net/sh_eth.c > +++ b/drivers/net/sh_eth.c > @@ -142,6 +142,8 @@ static void sh_eth_recv_finish(struct sh_eth_dev *eth) > { > struct sh_eth_info *port_info = ð->port_info[eth->port]; > > + invalidate_cache(ADDR_TO_P2(port_info->rx_desc_cur->rd2), > MAX_BUF_SIZE); > + > /* Make current descriptor available again */ > if (port_info->rx_desc_cur->rd0 & RD_RDLE) > port_info->rx_desc_cur->rd0 = RD_RACT | RD_RDLE; > @@ -210,8 +212,6 @@ static int sh_eth_tx_desc_init(struct sh_eth_dev *eth) > goto err; > } > > - flush_cache_wback(port_info->tx_desc_alloc, alloc_desc_size); > - > /* Make sure we use a P2 address (non-cacheable) */ > port_info->tx_desc_base = > (struct tx_desc_s > *)ADDR_TO_P2((uintptr_t)port_info->tx_desc_alloc); > @@ -229,6 +229,7 @@ static int sh_eth_tx_desc_init(struct sh_eth_dev *eth) > cur_tx_desc--; > cur_tx_desc->td0 |= TD_TDLE; > > + flush_cache_wback(port_info->tx_desc_alloc, alloc_desc_size); > /* > * Point the controller to the tx descriptor list. Must use physical > * addresses > @@ -264,8 +265,6 @@ static int sh_eth_rx_desc_init(struct sh_eth_dev *eth) > goto err; > } > > - flush_cache_wback(port_info->rx_desc_alloc, alloc_desc_size); > - > /* Make sure we use a P2 address (non-cacheable) */ > port_info->rx_desc_base = > (struct rx_desc_s > *)ADDR_TO_P2((uintptr_t)port_info->rx_desc_alloc); > @@ -299,6 +298,9 @@ static int sh_eth_rx_desc_init(struct sh_eth_dev *eth) > cur_rx_desc--; > cur_rx_desc->rd0 |= RD_RDLE; > > + invalidate_cache(port_info->rx_buf_alloc, NUM_RX_DESC * MAX_BUF_SIZE); > + flush_cache_wback(port_info->rx_desc_alloc, alloc_desc_size); > + > /* Point the controller to the rx descriptor list */ > sh_eth_write(port_info, ADDR_TO_PHY(port_info->rx_desc_base), RDLAR); > #if defined(SH_ETH_TYPE_GETHER) || defined(SH_ETH_TYPE_RZ) > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 12/14] net: sh_eth: Drop reset GPIO handling in favor of common code
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > The common code is now capable of handling reset GPIO associated > with PHY. Drop the local ad-hoc code in favor of common code. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/Kconfig | 1 + > drivers/net/sh_eth.c | 17 - > 2 files changed, 1 insertion(+), 17 deletions(-) > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index 48f9efcc94f..7d482cb7745 100644 > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -695,6 +695,7 @@ config SUN8I_EMAC > config SH_ETHER > bool "Renesas SH Ethernet MAC" > select PHYLIB > + select PHY_ETHERNET_ID > help > This driver supports the Ethernet for Renesas SH and ARM SoCs. > > diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c > index 14f7fd1bcc0..95042daade0 100644 > --- a/drivers/net/sh_eth.c > +++ b/drivers/net/sh_eth.c > @@ -530,7 +530,6 @@ struct sh_ether_priv { > struct mii_dev *bus; > phys_addr_t iobase; > struct clk clk; > - struct gpio_descreset_gpio; > }; > > static int sh_ether_send(struct udevice *dev, void *packet, int len) > @@ -650,7 +649,6 @@ static int sh_ether_probe(struct udevice *udev) > struct eth_pdata *pdata = dev_get_plat(udev); > struct sh_ether_priv *priv = dev_get_priv(udev); > struct sh_eth_dev *eth = &priv->shdev; > - struct ofnode_phandle_args phandle_args; > struct mii_dev *mdiodev; > int ret; > > @@ -661,18 +659,6 @@ static int sh_ether_probe(struct udevice *udev) > if (ret < 0) > return ret; > #endif > - > - ret = dev_read_phandle_with_args(udev, "phy-handle", NULL, 0, 0, > &phandle_args); > - if (!ret) { > - gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", > 0, > - &priv->reset_gpio, GPIOD_IS_OUT); > - } > - > - if (!dm_gpio_is_valid(&priv->reset_gpio)) { > - gpio_request_by_name(udev, "reset-gpios", 0, > &priv->reset_gpio, > -GPIOD_IS_OUT); > - } > - > mdiodev = mdio_alloc(); > if (!mdiodev) { > ret = -ENOMEM; > @@ -735,9 +721,6 @@ static int sh_ether_remove(struct udevice *udev) > mdio_unregister(priv->bus); > mdio_free(priv->bus); > > - if (dm_gpio_is_valid(&priv->reset_gpio)) > - dm_gpio_free(udev, &priv->reset_gpio); > - > return 0; > } > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 11/14] net: ravb: Drop reset GPIO handling in favor of common code
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > The common code is now capable of handling reset GPIO associated > with PHY. Drop the local ad-hoc code in favor of common code. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/Kconfig | 1 + > drivers/net/ravb.c | 22 -- > 2 files changed, 1 insertion(+), 22 deletions(-) > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index 09039a283eb..48f9efcc94f 100644 > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -764,6 +764,7 @@ config RENESAS_RAVB > bool "Renesas Ethernet AVB MAC" > depends on RCAR_64 > select PHYLIB > + select PHY_ETHERNET_ID > help > This driver implements support for the Ethernet AVB block in > Renesas M3 and H3 SoCs. > diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c > index c74c8a81f94..0bcd6cfd3f3 100644 > --- a/drivers/net/ravb.c > +++ b/drivers/net/ravb.c > @@ -131,7 +131,6 @@ struct ravb_priv { > struct mii_dev *bus; > void __iomem*iobase; > struct clk_bulk clks; > - struct gpio_descreset_gpio; > }; > > static inline void ravb_flush_dcache(u32 addr, u32 len) > @@ -312,13 +311,6 @@ static int ravb_phy_config(struct udevice *dev) > struct phy_device *phydev; > int reg; > > - if (dm_gpio_is_valid(ð->reset_gpio)) { > - dm_gpio_set_value(ð->reset_gpio, 1); > - mdelay(20); > - dm_gpio_set_value(ð->reset_gpio, 0); > - mdelay(1); > - } > - > phydev = phy_connect(eth->bus, -1, dev, pdata->phy_interface); > if (!phydev) > return -ENODEV; > @@ -503,7 +495,6 @@ static int ravb_probe(struct udevice *dev) > { > struct eth_pdata *pdata = dev_get_plat(dev); > struct ravb_priv *eth = dev_get_priv(dev); > - struct ofnode_phandle_args phandle_args; > struct mii_dev *mdiodev; > void __iomem *iobase; > int ret; > @@ -515,17 +506,6 @@ static int ravb_probe(struct udevice *dev) > if (ret < 0) > goto err_mdio_alloc; > > - ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, > &phandle_args); > - if (!ret) { > - gpio_request_by_name_nodev(phandle_args.node, "reset-gpios", > 0, > - ð->reset_gpio, GPIOD_IS_OUT); > - } > - > - if (!dm_gpio_is_valid(ð->reset_gpio)) { > - gpio_request_by_name(dev, "reset-gpios", 0, ð->reset_gpio, > -GPIOD_IS_OUT); > - } > - > mdiodev = mdio_alloc(); > if (!mdiodev) { > ret = -ENOMEM; > @@ -576,8 +556,6 @@ static int ravb_remove(struct udevice *dev) > free(eth->phydev); > mdio_unregister(eth->bus); > mdio_free(eth->bus); > - if (dm_gpio_is_valid(ð->reset_gpio)) > - dm_gpio_free(dev, ð->reset_gpio); > unmap_physmem(eth->iobase, MAP_NOCACHE); > > return 0; > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 10/14] net: phy: Handle reset-delay-us/reset-post-delay-us properties
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > These two properties are used by various DTs in place of > current reset-assert-us/reset-deassert-us , handle both . > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/eth-phy-uclass.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c > index 231bad66514..9d1e8d38ffa 100644 > --- a/drivers/net/eth-phy-uclass.c > +++ b/drivers/net/eth-phy-uclass.c > @@ -144,6 +144,14 @@ static int eth_phy_of_to_plat(struct udevice *dev) > uc_priv->reset_assert_delay = dev_read_u32_default(dev, > "reset-assert-us", 0); > uc_priv->reset_deassert_delay = dev_read_u32_default(dev, > "reset-deassert-us", 0); > > + /* These are used by some DTs, try these as a fallback. */ > + if (!uc_priv->reset_assert_delay && !uc_priv->reset_deassert_delay) { > + uc_priv->reset_assert_delay = > + dev_read_u32_default(dev, "reset-delay-us", 0); > + uc_priv->reset_deassert_delay = > + dev_read_u32_default(dev, "reset-post-delay-us", 0); > + } > + > return 0; > } > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 09/14] net: phy: Bind ETH_PHY uclass driver to each new PHY
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > In case a new PHY is created and DM_ETH_PHY is enabled, bind a > generic PHY driver from ETH_PHY uclass to the PHY to have a > matching DM representation of that PHY. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/phy/ethernet_id.c | 17 + > 1 file changed, 17 insertions(+) > > diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c > index a715e83db98..877a51c3d00 100644 > --- a/drivers/net/phy/ethernet_id.c > +++ b/drivers/net/phy/ethernet_id.c > @@ -7,6 +7,8 @@ > > #include > #include > +#include > +#include > #include > #include > #include > @@ -17,6 +19,8 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, > struct udevice *dev, > struct phy_device *phydev; > struct ofnode_phandle_args phandle_args; > struct gpio_desc gpio; > + const char *node_name; > + struct udevice *pdev; > ofnode node; > u32 id, assert, deassert; > u16 vendor, device; > @@ -72,5 +76,18 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, > struct udevice *dev, > if (phydev) > phydev->node = node; > > + if (IS_ENABLED(CONFIG_DM_ETH_PHY) && ofnode_valid(node)) { > + node_name = ofnode_get_name(node); > + ret = device_bind_driver_to_node(dev, "eth_phy_generic_drv", > +node_name, node, > +&pdev); > + if (ret) > + return NULL; > + > + ret = device_probe(pdev); > + if (ret) > + return NULL; > + } > + > return phydev; > } > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 08/14] net: phy: Unpublish phy_connect_dev()
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > The phy_connect_dev() is legacy API, now that there are no users, > make it internal to phy.c and unpublish it from headers. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/phy/phy.c | 4 ++-- > include/phy.h | 9 - > 2 files changed, 2 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 0eeb0cb3a85..ae21acb059b 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -812,8 +812,8 @@ struct phy_device *phy_find_by_mask(struct mii_dev *bus, > uint phy_mask) > return get_phy_device_by_mask(bus, phy_mask); > } > > -void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, > -phy_interface_t interface) > +static void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, > + phy_interface_t interface) > { > /* Soft Reset the PHY */ > phy_reset(phydev); > diff --git a/include/phy.h b/include/phy.h > index 247223d92be..f023a3c2685 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -223,15 +223,6 @@ static inline struct phy_device *fixed_phy_create(ofnode > node) > > #endif > > -/** > - * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices > - * @phydev:PHY device > - * @dev: Ethernet device > - * @interface: type of MAC-PHY interface > - */ > -void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, > -phy_interface_t interface); > - > /** > * phy_connect() - Creates a PHY device for the Ethernet interface > * Creates a PHY device for the PHY at the given address, if one doesn't > exist > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 07/14] net: sunxi_emac: Switch to new U-Boot PHY API
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > Use new U-Boot phy_connect() API which also supports fixed PHYs. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/sunxi_emac.c | 7 +++ > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c > index ad9e1abd161..4c90d4b4981 100644 > --- a/drivers/net/sunxi_emac.c > +++ b/drivers/net/sunxi_emac.c > @@ -248,10 +248,10 @@ static int emac_mdio_write(struct mii_dev *bus, int > addr, int devad, int reg, > > static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev) > { > - int ret, mask = 0x; > + int ret, mask = -1; > > #ifdef CONFIG_PHY_ADDR > - mask = 1 << CONFIG_PHY_ADDR; > + mask = CONFIG_PHY_ADDR; > #endif > > priv->bus = mdio_alloc(); > @@ -269,11 +269,10 @@ static int sunxi_emac_init_phy(struct emac_eth_dev > *priv, void *dev) > if (ret) > return ret; > > - priv->phydev = phy_find_by_mask(priv->bus, mask); > + priv->phydev = phy_connect(priv->bus, mask, dev, > PHY_INTERFACE_MODE_MII); > if (!priv->phydev) > return -ENODEV; > > - phy_connect_dev(priv->phydev, dev, PHY_INTERFACE_MODE_MII); > phy_config(priv->phydev); > > return 0; > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 06/14] net: sh_eth: Switch to new U-Boot PHY API
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > Use new U-Boot phy_connect() API which also supports fixed PHYs. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/sh_eth.c | 5 + > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c > index 8f162ca58fb..14f7fd1bcc0 100644 > --- a/drivers/net/sh_eth.c > +++ b/drivers/net/sh_eth.c > @@ -601,14 +601,11 @@ static int sh_eth_phy_config(struct udevice *dev) > int ret = 0; > struct sh_eth_info *port_info = ð->port_info[eth->port]; > struct phy_device *phydev; > - int mask = 0x; > > - phydev = phy_find_by_mask(priv->bus, mask); > + phydev = phy_connect(priv->bus, -1, dev, pdata->phy_interface); > if (!phydev) > return -ENODEV; > > - phy_connect_dev(phydev, dev, pdata->phy_interface); > - > port_info->phydev = phydev; > phy_config(phydev); > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 05/14] net: pch_gbe: Switch to new U-Boot PHY API
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > Use new U-Boot phy_connect() API which also supports fixed PHYs. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/pch_gbe.c | 5 + > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c > index ad7b5b8e99b..ecf8c28fe41 100644 > --- a/drivers/net/pch_gbe.c > +++ b/drivers/net/pch_gbe.c > @@ -414,16 +414,13 @@ static int pch_gbe_phy_init(struct udevice *dev) > struct pch_gbe_priv *priv = dev_get_priv(dev); > struct eth_pdata *plat = dev_get_plat(dev); > struct phy_device *phydev; > - int mask = 0x; > > - phydev = phy_find_by_mask(priv->bus, mask); > + phydev = phy_connect(priv->bus, -1, dev, plat->phy_interface); > if (!phydev) { > printf("pch_gbe: cannot find the phy\n"); > return -1; > } > > - phy_connect_dev(phydev, dev, plat->phy_interface); > - > phydev->supported &= PHY_GBIT_FEATURES; > phydev->advertising = phydev->supported; > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 04/14] net: ethoc: Switch to new U-Boot PHY API
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > Use new U-Boot phy_connect() API which also supports fixed PHYs. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/ethoc.c | 8 +++- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c > index 29067e9e949..13fad8119bb 100644 > --- a/drivers/net/ethoc.c > +++ b/drivers/net/ethoc.c > @@ -608,18 +608,16 @@ static int ethoc_mdio_init(const char *name, struct > ethoc *priv) > static int ethoc_phy_init(struct ethoc *priv, void *dev) > { > struct phy_device *phydev; > - int mask = 0x; > + int mask = -1; > > #ifdef CONFIG_PHY_ADDR > - mask = 1 << CONFIG_PHY_ADDR; > + mask = CONFIG_PHY_ADDR; > #endif > > - phydev = phy_find_by_mask(priv->bus, mask); > + phydev = phy_connect(priv->bus, mask, dev, PHY_INTERFACE_MODE_MII); > if (!phydev) > return -ENODEV; > > - phy_connect_dev(phydev, dev, PHY_INTERFACE_MODE_MII); > - > phydev->supported &= PHY_BASIC_FEATURES; > phydev->advertising = phydev->supported; > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 03/14] net: ave: Switch to new U-Boot PHY API
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > Use new U-Boot phy_connect() API which also supports fixed PHYs. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/sni_ave.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c > index 014b070d9e5..f5a0d80af7a 100644 > --- a/drivers/net/sni_ave.c > +++ b/drivers/net/sni_ave.c > @@ -391,14 +391,12 @@ static int ave_mdiobus_init(struct ave_private *priv, > const char *name) > static int ave_phy_init(struct ave_private *priv, void *dev) > { > struct phy_device *phydev; > - int mask = GENMASK(31, 0), ret; > + int ret; > > - phydev = phy_find_by_mask(priv->bus, mask); > + phydev = phy_connect(priv->bus, -1, dev, priv->phy_mode); > if (!phydev) > return -ENODEV; > > - phy_connect_dev(phydev, dev, priv->phy_mode); > - > phydev->supported &= PHY_GBIT_FEATURES; > if (priv->max_speed) { > ret = phy_set_supported(phydev, priv->max_speed); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 02/14] net: altera_tsa: Switch to new U-Boot PHY API
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > Use new U-Boot phy_connect() API which also supports fixed PHYs. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/altera_tse.c | 8 +--- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c > index 912d28fca2e..e2340936fa6 100644 > --- a/drivers/net/altera_tse.c > +++ b/drivers/net/altera_tse.c > @@ -430,17 +430,11 @@ static int tse_mdio_init(const char *name, struct > altera_tse_priv *priv) > static int tse_phy_init(struct altera_tse_priv *priv, void *dev) > { > struct phy_device *phydev; > - unsigned int mask = 0x; > > - if (priv->phyaddr) > - mask = 1 << priv->phyaddr; > - > - phydev = phy_find_by_mask(priv->bus, mask); > + phydev = phy_connect(priv->bus, -1, dev, priv->interface); > if (!phydev) > return -ENODEV; > > - phy_connect_dev(phydev, dev, priv->interface); > - > phydev->supported &= PHY_GBIT_FEATURES; > phydev->advertising = phydev->supported; > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 01/14] net: eth-phy: staticize eth_phy_reset()
On Wed, May 31, 2023 at 1:51 AM Marek Vasut wrote: > > The eth_phy_reset() is not used outside of this file, staticize it. > No functional change. > > Signed-off-by: Marek Vasut > --- > Cc: Geert Uytterhoeven > Cc: Joe Hershberger > Cc: Michal Simek > Cc: Nishanth Menon > Cc: Ramon Fried > --- > drivers/net/eth-phy-uclass.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c > index 27b77444a0c..231bad66514 100644 > --- a/drivers/net/eth-phy-uclass.c > +++ b/drivers/net/eth-phy-uclass.c > @@ -147,7 +147,7 @@ static int eth_phy_of_to_plat(struct udevice *dev) > return 0; > } > > -void eth_phy_reset(struct udevice *dev, int value) > +static void eth_phy_reset(struct udevice *dev, int value) > { > struct eth_phy_device_priv *uc_priv = dev_get_uclass_priv(dev); > u32 delay; > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 6/6] net: ldpaa_eth: export DPNI and DPMAC counters through 'net stats'
On Tue, May 23, 2023 at 4:48 PM Ioana Ciornei wrote: > > Export the already existing DPNI and DPMAC counters through the newly > added callbacks. > > Signed-off-by: Ioana Ciornei > --- > drivers/net/ldpaa_eth/ldpaa_eth.c | 44 --- > 1 file changed, 40 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c > b/drivers/net/ldpaa_eth/ldpaa_eth.c > index 53c5b8ba2b1d..8c0b5a3b6fd2 100644 > --- a/drivers/net/ldpaa_eth/ldpaa_eth.c > +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c > @@ -998,11 +998,47 @@ static int ldpaa_eth_of_to_plat(struct udevice *dev) > return 0; > } > > +static int ldpaa_eth_get_sset_count(struct udevice *dev) > +{ > + return LDPAA_ETH_DPNI_NUM_STATS + LDPAA_ETH_DPMAC_NUM_STATS; > +} > + > +static void ldpaa_eth_get_strings(struct udevice *dev, u8 *data) > +{ > + u8 *p = data; > + int i; > + > + for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++) { > + strlcpy(p, ldpaa_eth_dpni_stat_strings[i], ETH_GSTRING_LEN); > + p += ETH_GSTRING_LEN; > + } > + > + for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) { > + strlcpy(p, ldpaa_eth_dpmac_stat_strings[i], ETH_GSTRING_LEN); > + p += ETH_GSTRING_LEN; > + } > +} > + > +static void ldpaa_eth_get_stats(struct udevice *dev, u64 *data) > +{ > + struct ldpaa_eth_priv *priv = dev_get_priv(dev); > + int i, j = 0; > + > + for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++) > + *(data + j++) = priv->dpni_stats[i]; > + > + for (i = 0; i < LDPAA_ETH_DPMAC_NUM_STATS; i++) > + *(data + j++) = priv->dpmac_stats[i]; > +} > + > static const struct eth_ops ldpaa_eth_ops = { > - .start = ldpaa_eth_open, > - .send = ldpaa_eth_tx, > - .recv = ldpaa_eth_pull_dequeue_rx, > - .stop = ldpaa_eth_stop, > + .start = ldpaa_eth_open, > + .send = ldpaa_eth_tx, > + .recv = ldpaa_eth_pull_dequeue_rx, > + .stop = ldpaa_eth_stop, > + .get_sset_count = ldpaa_eth_get_sset_count, > + .get_strings = ldpaa_eth_get_strings, > + .get_stats = ldpaa_eth_get_stats, > }; > > static const struct udevice_id ldpaa_eth_of_ids[] = { > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH 5/6] cmd: net: add a 'net stats' command to dump network statistics
On Tue, May 23, 2023 at 4:48 PM Ioana Ciornei wrote: > > Add a new option to the 'net' command which can be used to dump network > statistics. > > To do this, 3 new callbacks are added to the eth_ops structure: > .get_sset_count(), .get_strings(), .get_stats(). These callbacks > have the same functions as in Linux: to return the number of counters, > the strings which describe those counters and the actual values. > > Signed-off-by: Ioana Ciornei > --- > cmd/net.c | 54 ++- > include/net.h | 6 ++ > 2 files changed, 59 insertions(+), 1 deletion(-) > > diff --git a/cmd/net.c b/cmd/net.c > index 68d406291ef1..dfe811f41acf 100644 > --- a/cmd/net.c > +++ b/cmd/net.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -691,8 +692,58 @@ static int do_net_list(struct cmd_tbl *cmdtp, int flag, > int argc, char *const ar > return CMD_RET_SUCCESS; > } > > +static int do_net_stats(struct cmd_tbl *cmdtp, int flag, int argc, char > *const argv[]) > +{ > + int nstats, err, i, off; > + struct udevice *dev; > + u64 *values; > + u8 *strings; > + > + if (argc < 2) > + return CMD_RET_USAGE; > + > + err = uclass_get_device_by_name(UCLASS_ETH, argv[1], &dev); > + if (err) { > + printf("Could not find device %s\n", argv[1]); > + return CMD_RET_FAILURE; > + } > + > + if (!eth_get_ops(dev)->get_sset_count || > + !eth_get_ops(dev)->get_strings || > + !eth_get_ops(dev)->get_stats) { > + printf("Driver does not implement stats dump!\n"); > + return CMD_RET_FAILURE; > + } > + > + nstats = eth_get_ops(dev)->get_sset_count(dev); > + strings = kcalloc(nstats, ETH_GSTRING_LEN, GFP_KERNEL); > + if (!strings) > + return CMD_RET_FAILURE; > + > + values = kcalloc(nstats, sizeof(u64), GFP_KERNEL); > + if (!values) > + goto err_free_strings; > + > + eth_get_ops(dev)->get_strings(dev, strings); > + eth_get_ops(dev)->get_stats(dev, values); > + > + off = 0; > + for (i = 0; i < nstats; i++) { > + printf(" %s: %llu\n", &strings[off], values[i]); > + off += ETH_GSTRING_LEN; > + }; > + > + return CMD_RET_SUCCESS; > + > +err_free_strings: > + kfree(strings); > + > + return CMD_RET_FAILURE; > +} > + > static struct cmd_tbl cmd_net[] = { > U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""), > + U_BOOT_CMD_MKENT(stats, 2, 0, do_net_stats, "", ""), > }; > > static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char *const > argv[]) > @@ -714,9 +765,10 @@ static int do_net(struct cmd_tbl *cmdtp, int flag, int > argc, char *const argv[]) > } > > U_BOOT_CMD( > - net, 2, 1, do_net, > + net, 3, 1, do_net, > "NET sub-system", > "list - list available devices\n" > + "stats - dump statistics for specified device\n" > ); > > #if defined(CONFIG_CMD_NCSI) > diff --git a/include/net.h b/include/net.h > index 785cb1059ef9..e254df7d7f43 100644 > --- a/include/net.h > +++ b/include/net.h > @@ -167,6 +167,9 @@ enum eth_recv_flags { > * to the network stack. This function should fill in the > * eth_pdata::enetaddr field - optional > * set_promisc: Enable or Disable promiscuous mode > + * get_sset_count: Number of statistics counters > + * get_string: Names of the statistic counters > + * get_stats: The values of the statistic counters > */ > struct eth_ops { > int (*start)(struct udevice *dev); > @@ -178,6 +181,9 @@ struct eth_ops { > int (*write_hwaddr)(struct udevice *dev); > int (*read_rom_hwaddr)(struct udevice *dev); > int (*set_promisc)(struct udevice *dev, bool enable); > + int (*get_sset_count)(struct udevice *dev); > + void (*get_strings)(struct udevice *dev, u8 *data); > + void (*get_stats)(struct udevice *dev, u64 *data); > }; > > #define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops) > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH 4/6] net: ldpaa_eth: extend debug capabilities with DPMAC statistics
ot;, > + [DPMAC_CNT_EGR_BYTE]= "[mac] tx bytes", > +}; > + > +#define LDPAA_ETH_DPMAC_NUM_STATS > ARRAY_SIZE(ldpaa_eth_dpmac_stat_strings) > + > struct ldpaa_eth_priv { > struct phy_device *phy; > int phy_mode; > @@ -159,6 +192,7 @@ struct ldpaa_eth_priv { > > /* SW kept statistics */ > u64 dpni_stats[LDPAA_ETH_DPNI_NUM_STATS]; > + u64 dpmac_stats[LDPAA_ETH_DPMAC_NUM_STATS]; > }; > > struct dprc_endpoint dpmac_endpoint; > diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h > index 8f5e17fe222a..1fa26ef3805a 100644 > --- a/include/fsl-mc/fsl_dpmac.h > +++ b/include/fsl-mc/fsl_dpmac.h > @@ -412,6 +412,8 @@ int dpmac_set_link_state(struct fsl_mc_io > *mc_io, > * @DPMAC_CNT_EGR_ERR_FRAME: counts frame transmitted with an error > * @DPMAC_CNT_ING_GOOD_FRAME: counts frame received without error, including > * pause frames. > + * @DPMAC_CNT_EGR_GOOD_FRAME: counts frames transmitted without error, > including > + * pause frames. > */ > enum dpmac_counter { > DPMAC_CNT_ING_FRAME_64, > @@ -440,7 +442,8 @@ enum dpmac_counter { > DPMAC_CNT_EGR_BCAST_FRAME, > DPMAC_CNT_EGR_UCAST_FRAME, > DPMAC_CNT_EGR_ERR_FRAME, > - DPMAC_CNT_ING_GOOD_FRAME > + DPMAC_CNT_ING_GOOD_FRAME, > + DPMAC_CNT_EGR_GOOD_FRAME, > }; > > /** > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH 3/6] net: ldpaa_eth: extend debug capabilities with DPNI statistics
> - for (page = 0; page < 3; page++) { > - err = dpni_get_statistics(dflt_mc_io, MC_CMD_NO_FLAGS, > - dflt_dpni->dpni_handle, page, > - &dpni_stats); > - if (err < 0) { > - printf("dpni_get_statistics: failed:"); > - printf("%d for page[%d]\n", err, page); > - return; > - } > - print_dpni_stats(dpni_statistics[page], dpni_stats); > - } > + printf("DPNI counters:\n"); > + for (i = 0; i < LDPAA_ETH_DPNI_NUM_STATS; i++) > + printf(" %s: %llu\n", ldpaa_eth_dpni_stat_strings[i], > data[i]); > } > > static void ldpaa_eth_get_dpmac_counter(struct udevice *dev) > @@ -556,12 +544,22 @@ static void ldpaa_eth_stop(struct udevice *dev) > struct ldpaa_eth_priv *priv = dev_get_priv(dev); > struct phy_device *phydev = NULL; > int err = 0; > + u64 *data; > > if (!eth_is_active(dev)) > return; > > + data = kzalloc(sizeof(u64) * LDPAA_ETH_DPNI_NUM_STATS, GFP_KERNEL); > + if (data) { > + ldpaa_eth_collect_dpni_stats(dev, data); > + ldpaa_eth_add_dpni_stats(dev, data); > +#ifdef DEBUG > + ldpaa_eth_dump_dpni_stats(dev, data); > +#endif > + } > + kfree(data); > + > #ifdef DEBUG > - ldpaa_eth_get_dpni_counter(); > ldpaa_eth_get_dpmac_counter(dev); > #endif > > diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.h > b/drivers/net/ldpaa_eth/ldpaa_eth.h > index 16d0106233e0..62dc9dd31029 100644 > --- a/drivers/net/ldpaa_eth/ldpaa_eth.h > +++ b/drivers/net/ldpaa_eth/ldpaa_eth.h > @@ -115,6 +115,33 @@ struct ldpaa_fas { > LDPAA_ETH_FAS_MNLE | \ > LDPAA_ETH_FAS_TIDE) > > +static const char ldpaa_eth_dpni_stat_strings[][ETH_GSTRING_LEN] = { > + "[dpni ] rx frames", > + "[dpni ] rx bytes", > + "[dpni ] rx mcast frames", > + "[dpni ] rx mcast bytes", > + "[dpni ] rx bcast frames", > + "[dpni ] rx bcast bytes", > + "[dpni ] tx frames", > + "[dpni ] tx bytes", > + "[dpni ] tx mcast frames", > + "[dpni ] tx mcast bytes", > + "[dpni ] tx bcast frames", > + "[dpni ] tx bcast bytes", > + "[dpni ] rx filtered frames", > + "[dpni ] rx discarded frames", > + "[dpni ] rx nobuffer discards", > + "[dpni ] tx discarded frames", > + "[dpni ] tx confirmed frames", > + "[dpni ] tx dequeued bytes", > + "[dpni ] tx dequeued frames", > + "[dpni ] tx rejected bytes", > + "[dpni ] tx rejected frames", > + "[dpni ] tx pending frames", > +}; > + > +#define LDPAA_ETH_DPNI_NUM_STATS > ARRAY_SIZE(ldpaa_eth_dpni_stat_strings) > + > struct ldpaa_eth_priv { > struct phy_device *phy; > int phy_mode; > @@ -129,6 +156,9 @@ struct ldpaa_eth_priv { > uint16_t tx_flow_id; > > enum ldpaa_eth_type type; /* 1G or 10G ethernet */ > + > + /* SW kept statistics */ > + u64 dpni_stats[LDPAA_ETH_DPNI_NUM_STATS]; > }; > > struct dprc_endpoint dpmac_endpoint; > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH 2/6] net: ldpaa_eth: transform dpni_statistics from a struct to a union
ed_frames: Ingress discarded frame count > -* @ingress_nobuffer_discards: Ingress discarded frame count due to > -* lack of buffers. > -* @egress_discarded_frames: Egress discarded frame count > -* @egress_confirmed_frames: Egress confirmed frame count > -*/ > > - uint64_t counter0; > - uint64_t counter1; > - uint64_t counter2; > - uint64_t counter3; > - uint64_t counter4; > - uint64_t counter5; > - uint64_t counter6; > +#define DPNI_STATISTICS_CNT7 > + > +/** > + * union dpni_statistics - Union describing the DPNI statistics > + * @page_0: Page_0 statistics structure > + * @page_0.ingress_all_frames: Ingress frame count > + * @page_0.ingress_all_bytes: Ingress byte count > + * @page_0.ingress_multicast_frames: Ingress multicast frame count > + * @page_0.ingress_multicast_bytes: Ingress multicast byte count > + * @page_0.ingress_broadcast_frames: Ingress broadcast frame count > + * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count > + * @page_1: Page_1 statistics structure > + * @page_1.egress_all_frames: Egress frame count > + * @page_1.egress_all_bytes: Egress byte count > + * @page_1.egress_multicast_frames: Egress multicast frame count > + * @page_1.egress_multicast_bytes: Egress multicast byte count > + * @page_1.egress_broadcast_frames: Egress broadcast frame count > + * @page_1.egress_broadcast_bytes: Egress broadcast byte count > + * @page_2: Page_2 statistics structure > + * @page_2.ingress_filtered_frames: Ingress filtered frame count > + * @page_2.ingress_discarded_frames: Ingress discarded frame count > + * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to > + * lack of buffers > + * @page_2.egress_discarded_frames: Egress discarded frame count > + * @page_2.egress_confirmed_frames: Egress confirmed frame count > + * @page_3: Page_3 statistics structure > + * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes > + * dequeued from egress FQs > + * @page_3.egress_dequeue_frames: Cumulative count of the number of frames > + * dequeued from egress FQs > + * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in > + * egress frames whose enqueue was rejected > + * @page_3.egress_reject_frames: Cumulative count of the number of egress > + * frames whose enqueue was rejected > + * @page_4: Page_4 statistics structure: congestion points > + * @page_4.cgr_reject_frames: number of rejected frames due to congestion > point > + * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point > + * @page_5: Page_5 statistics structure: policer > + * @page_5.policer_cnt_red: NUmber of red colored frames > + * @page_5.policer_cnt_yellow: number of yellow colored frames > + * @page_5.policer_cnt_green: number of green colored frames > + * @page_5.policer_cnt_re_red: number of recolored red frames > + * @page_5.policer_cnt_re_yellow: number of recolored yellow frames > + * @page_6: Page_6 statistics structure > + * @page_6.tx_pending_frames: total number of frames pending in egress FQs > + * @raw: raw statistics structure, used to index counters > + */ > +union dpni_statistics { > + struct { > + u64 ingress_all_frames; > + u64 ingress_all_bytes; > + u64 ingress_multicast_frames; > + u64 ingress_multicast_bytes; > + u64 ingress_broadcast_frames; > + u64 ingress_broadcast_bytes; > + } page_0; > + struct { > + u64 egress_all_frames; > + u64 egress_all_bytes; > + u64 egress_multicast_frames; > + u64 egress_multicast_bytes; > + u64 egress_broadcast_frames; > + u64 egress_broadcast_bytes; > + } page_1; > + struct { > + u64 ingress_filtered_frames; > + u64 ingress_discarded_frames; > + u64 ingress_nobuffer_discards; > + u64 egress_discarded_frames; > + u64 egress_confirmed_frames; > + } page_2; > + struct { > + u64 egress_dequeue_bytes; > + u64 egress_dequeue_frames; > + u64 egress_reject_bytes; > + u64 egress_reject_frames; > + } page_3; > + struct { > + u64 cgr_reject_frames; > + u64 cgr_reject_bytes; > + } page_4; > + struct { > + u64 policer_cnt_red; > + u64 policer_cnt_yellow; > + u64 policer_cnt_green; > + u64 policer_cnt_re_red; > + u64 policer_cnt_re_yellow; > + } page_5; > + struct { > + u64 tx_pending_frames; > + } page_6; > + struct { > + u64 counter[DPNI_STATISTICS_CNT]; > + } raw; > }; > > /** > @@ -1308,7 +1369,7 @@ int dpni_get_statistics(struct fsl_mc_io *mc_io, > uint32_t cmd_flags, > uint16_t token, > uint8_t page, > - struct dpni_statistics *stat); > + union dpni_statistics *stat); > > /** > * dpni_reset_statistics() - Clears DPNI statistics > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH 1/6] net: ldpaa_eth: fix the memory layout of the dpmac_get_counters() API
On Tue, May 23, 2023 at 4:48 PM Ioana Ciornei wrote: > > Each MC commands has a specific predefined memory layout that gets > interpreted by the firmware. The dpmac_get_counters() API memory layout > is wrong, thus the results returned by the command are incorrect. > > Fix this by updating the offset of the counter field. > > Signed-off-by: Ioana Ciornei > --- > include/fsl-mc/fsl_dpmac.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/fsl-mc/fsl_dpmac.h b/include/fsl-mc/fsl_dpmac.h > index 1cea123a3164..8f5e17fe222a 100644 > --- a/include/fsl-mc/fsl_dpmac.h > +++ b/include/fsl-mc/fsl_dpmac.h > @@ -84,7 +84,7 @@ do { \ > > /*cmd, param, offset, width, type, arg_name */ > #define DPMAC_CMD_GET_COUNTER(cmd, type) \ > - MC_CMD_OP(cmd, 1, 0, 64, enum dpmac_counter, type) > + MC_CMD_OP(cmd, 0, 0, 8, enum dpmac_counter, type) > > /*cmd, param, offset, width, type, arg_name */ > #define DPMAC_RSP_GET_COUNTER(cmd, counter) \ > -- > 2.25.1 > Reviewed-by: Ramon Fried
Re: [PATCH 2/2] net: ipv6: network protocol structures should be packed
On Thu, May 18, 2023 at 9:24 PM wrote: > > From: Ehsan Mohandesi > > The structure icmp6_ra_prefix_info needs to be packed because it is read > from a network stream. > > Signed-off-by: Ehsan Mohandesi > --- > include/net6.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/net6.h b/include/net6.h > index beafc05..1e766aa 100644 > --- a/include/net6.h > +++ b/include/net6.h > @@ -204,7 +204,7 @@ struct icmp6_ra_prefix_info { > * be initialized to zero by the sender and ignored by the receiver. > */ > struct in6_addr prefix; > -}; > +} __packed; > > extern struct in6_addr const net_null_addr_ip6;/* NULL IPv6 address > */ > extern struct in6_addr net_gateway6; /* Our gateways IPv6 address */ > -- > 1.8.3.1 > Reviewed-by: Ramon Fried
Re: [PATCH 1/2] net: ipv6: router advertisement message length should be within limits
On Thu, May 18, 2023 at 9:24 PM wrote: > > From: Ehsan Mohandesi > > The argument len passed to function process_ra is the length of the IPv6 > router advertisement message and needs to be between 0 and MTU because > it is assigned to remaining_option_len and used as a loop variable. > > Addresses-Coverity-ID: 450971 ("TAINTED_SCALAR") > Signed-off-by: Ehsan Mohandesi > --- > net/ndisc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/ndisc.c b/net/ndisc.c > index 0b27779..d1cec06 100644 > --- a/net/ndisc.c > +++ b/net/ndisc.c > @@ -382,6 +382,8 @@ int process_ra(struct ip6_hdr *ip6, int len) > unsigned char type = 0; > struct icmp6_ra_prefix_info *prefix = NULL; > > + if (len > ETH_MAX_MTU) > + return -EMSGSIZE; > /* Ignore the packet if router lifetime is 0. */ > if (!icmp->icmp6_rt_lifetime) > return -EOPNOTSUPP; > -- > 1.8.3.1 > Reviewed-by: Ramon Fried
Re: [PATCH 2/2] net: dhcp6: Fix VCI string
On Thu, May 18, 2023 at 10:35 PM wrote: > > From: Sean Edmond > > Change VCI string from "U-boot" to "U-Boot". > > Signed-off-by: Sean Edmond > --- > net/dhcpv6.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/dhcpv6.h b/net/dhcpv6.h > index 80ca520432..65c8e4c71d 100644 > --- a/net/dhcpv6.h > +++ b/net/dhcpv6.h > @@ -38,7 +38,7 @@ > #define DUID_MAX_SIZE DUID_LL_SIZE /* only supports DUID-LL > currently */ > > /* vendor-class-data to send in vendor clas option */ > -#define DHCP6_VCI_STRING "U-boot" > +#define DHCP6_VCI_STRING "U-Boot" > > #define DHCP6_MULTICAST_ADDR "ff02::1:2" /* DHCP multicast address */ > > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH 1/2] net: ipv6: Fix CID 453851 and CID 436278
On Thu, May 18, 2023 at 10:35 PM wrote: > > From: Sean Edmond > > CID 453851 : sprintf() shouldn't copy from/to tmp > CID 436278 : DHCP6 option_len should be checked before use > > Signed-off-by: Sean Edmond > --- > cmd/net.c| 12 ++-- > net/dhcpv6.c | 5 + > 2 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/cmd/net.c b/cmd/net.c > index 68d406291e..9e1f40a56e 100644 > --- a/cmd/net.c > +++ b/cmd/net.c > @@ -209,7 +209,7 @@ U_BOOT_CMD( > > static void netboot_update_env(void) > { > - char tmp[44]; > + char tmp[46]; > > if (net_gateway.s_addr) { > ip_to_string(net_gateway, tmp); > @@ -274,20 +274,20 @@ static void netboot_update_env(void) > if (IS_ENABLED(CONFIG_IPV6)) { > if (!ip6_is_unspecified_addr(&net_ip6) || > net_prefix_length != 0) { > - sprintf(tmp, "%pI6c", &net_ip6); > if (net_prefix_length != 0) > - sprintf(tmp, "%s/%d", tmp, net_prefix_length); > - > + snprintf(tmp, sizeof(tmp), "%pI6c/%d", > &net_ip6, net_prefix_length); > + else > + snprintf(tmp, sizeof(tmp), "%pI6c", &net_ip6); > env_set("ip6addr", tmp); > } > > if (!ip6_is_unspecified_addr(&net_server_ip6)) { > - sprintf(tmp, "%pI6c", &net_server_ip6); > + snprintf(tmp, sizeof(tmp), "%pI6c", &net_server_ip6); > env_set("serverip6", tmp); > } > > if (!ip6_is_unspecified_addr(&net_gateway6)) { > - sprintf(tmp, "%pI6c", &net_gateway6); > + snprintf(tmp, sizeof(tmp), "%pI6c", &net_gateway6); > env_set("gatewayip6", tmp); > } > } > diff --git a/net/dhcpv6.c b/net/dhcpv6.c > index 0d1c600632..73a1067877 100644 > --- a/net/dhcpv6.c > +++ b/net/dhcpv6.c > @@ -316,6 +316,11 @@ static void dhcp6_parse_options(uchar *rx_pkt, unsigned > int len) > option_ptr = ((uchar *)option_hdr) + sizeof(struct dhcp6_hdr); > option_len = ntohs(option_hdr->option_len); > > + if (option_ptr + option_len > rx_pkt + len) { > + debug("Invalid option length\n"); > + return; > + } > + > switch (ntohs(option_hdr->option_id)) { > case DHCP6_OPTION_CLIENTID: > if (memcmp(option_ptr, sm_params.duid, option_len) > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH] net: rtl8169: add depends on PCI
On Wed, May 17, 2023 at 1:41 PM Eugen Hristev wrote: > > The rtl8169 driver uses calls to dm_pci_bus_to_phys, > which are compiled under CONFIG_PCI. > > Without CONFIG_PCI, this happens: > > drivers/net/rtl8169.o: in function `rtl_recv_common': > drivers/net/rtl8169.c:555: undefined reference to `dm_pci_bus_to_phys' > > It is only natural that this driver depends on CONFIG_PCI then. > The device does not work connected in another way anyway, and the driver > does not assume anything else at this moment. > > Signed-off-by: Eugen Hristev > --- > drivers/net/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index 09039a283eb5..39eee98ca79f 100644 > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -633,6 +633,7 @@ config RTL8139 > > config RTL8169 > bool "Realtek 8169 series Ethernet controller driver" > + depends on PCI > help > This driver supports Realtek 8169 series gigabit ethernet family of > PCI/PCIe chipsets/adapters. > -- > 2.34.1 > Reviewed-by: Ramon Fried
Re: [PATCH v3 02/11] net: dwc_eth_qos: Add StarFive ethernet driver glue layer
eqos->config->interface(dev); > + if (data->interface == PHY_INTERFACE_MODE_NA) { > + pr_err("Invalid PHY interface\n"); > + return -EINVAL; > + } > + > + ret = reset_get_bulk(dev, &data->resets); > + if (ret < 0) > + return ret; > + > + ret = clk_get_bulk(dev, &data->clks); > + if (ret < 0) > + return ret; > + > + ret = clk_get_by_name(dev, "gtx", &eqos->clk_tx); > + if (ret) > + return ret; > + > + data->tx_use_rgmii_clk = dev_read_bool(dev, > "starfive,tx-use-rgmii-clk"); > + > + return eqos_interface_init_jh7110(dev); > +} > + > +static struct eqos_ops eqos_jh7110_ops = { > + .eqos_inval_desc = eqos_inval_desc_generic, > + .eqos_flush_desc = eqos_flush_desc_generic, > + .eqos_inval_buffer = eqos_inval_buffer_generic, > + .eqos_flush_buffer = eqos_flush_buffer_generic, > + .eqos_probe_resources = eqos_probe_resources_jh7110, > + .eqos_remove_resources = eqos_remove_resources_jh7110, > + .eqos_stop_resets = eqos_stop_resets_jh7110, > + .eqos_start_resets = eqos_start_resets_jh7110, > + .eqos_stop_clks = eqos_stop_clks_jh7110, > + .eqos_start_clks = eqos_start_clks_jh7110, > + .eqos_calibrate_pads = eqos_null_ops, > + .eqos_disable_calibration = eqos_null_ops, > + .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_jh7110, > + .eqos_get_enetaddr = eqos_null_ops, > + .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_jh7110 > +}; > + > +/* mdio_wait: There is no need to wait after setting the MAC_MDIO_Address > register > + * swr_wait: Software reset bit must be read at least 4 CSR clock cycles > + * after it is written to 1. > + * config_mac: Enable rx queue to DCB mode. > + * config_mac_mdio: CSR clock range is 250-300 Mhz. > + * axi_bus_width: The width of the data bus is 64 bit. > + */ > +struct eqos_config __maybe_unused eqos_jh7110_config = { > + .reg_access_always_ok = false, > + .mdio_wait = 0, > + .swr_wait = 4, > + .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB, > + .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300, > + .axi_bus_width = EQOS_AXI_WIDTH_64, > + .interface = dev_read_phy_mode, > + .ops = &eqos_jh7110_ops > +}; > -- > 2.17.1 > Reviewed-by: Ramon Fried
Re: [PATCH] net: sh_eth: Fix RX error handling
On Sun, Apr 30, 2023 at 5:54 PM Marek Vasut wrote: > > From: Valentine Barshak > > In case RX error occurs, and the RD_RFE bit is set, the descriptor > is never returned back to the queue. Make sh_eth_recv_start return > zero length in this case so that the descriptor can be released > and pushed back to the list. Also return the more appropriate > -EAGAIN instead of -EINVAL if the descriptor is not ready yet. > > Reviewed-by: Marek Vasut > Signed-off-by: Valentine Barshak > --- > Cc: Joe Hershberger > Cc: Ramon Fried > --- > drivers/net/sh_eth.c | 16 +++- > 1 file changed, 7 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c > index 8f162ca58fb..da1bc7cb40b 100644 > --- a/drivers/net/sh_eth.c > +++ b/drivers/net/sh_eth.c > @@ -129,11 +129,11 @@ static int sh_eth_recv_start(struct sh_eth_dev *eth) > /* Check if the rx descriptor is ready */ > invalidate_cache(port_info->rx_desc_cur, sizeof(struct rx_desc_s)); > if (port_info->rx_desc_cur->rd0 & RD_RACT) > - return -EINVAL; > + return -EAGAIN; > > /* Check for errors */ > if (port_info->rx_desc_cur->rd0 & RD_RFE) > - return -EINVAL; > + return 0; > > return port_info->rx_desc_cur->rd1 & 0x; > } > @@ -555,15 +555,13 @@ static int sh_ether_recv(struct udevice *dev, int > flags, uchar **packetp) > *packetp = packet; > > return len; > - } else { > - len = 0; > + } > > - /* Restart the receiver if disabled */ > - if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) > - sh_eth_write(port_info, EDRRR_R, EDRRR); > + /* Restart the receiver if disabled */ > + if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) > + sh_eth_write(port_info, EDRRR_R, EDRRR); > > - return -EAGAIN; > - } > + return len; > } > > static int sh_ether_free_pkt(struct udevice *dev, uchar *packet, int length) > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 1/2] net: rtl8169: add minimal support for 8125B variant
On Tue, Apr 25, 2023 at 10:47 PM Eugen Hristev wrote: > > On 4/25/23 22:22, Ramon Fried wrote: > > On Tue, Apr 25, 2023 at 4:17 PM Eugen Hristev > > wrote: > >> > >> On 4/25/23 16:06, Eugen Hristev wrote: > >>> Add minimal support for 8125B version. > >>> Changes are based on the Linux driver. > >>> Tested on Radxa Rock 5B Rk3588 board. > >>> > >>> Connection to a laptop worked fine in 100 Mbps mode. > >>> 1000 Mbps mode is not working at the moment. > >>> > >>> Signed-off-by: Eugen Hristev > >>> --- > >> > >> The one thing that impacts all the rtl chips is the way the pci BAR is > >> now mapped. > >> I could not test this on another platform so help on this matter is > >> appreciated. > >> > >> Thanks! > >> Eugen > > Let's wait a bit to see if someone can test it. why did you change the > > mapping of the BAR ? > > It did not work with the old code. It provided a bad address, to some > area which did not have the right registers. > I looked into similar drivers and they were using this call, which works > perfectly for 8125b device > > Eugen Ok. Hopefully nothing breaks. Reviewed-by: Ramon Fried
Re: [PATCH V3 2/3] net: phy: Drop phy_interface_is_sgmii
On Sat, Apr 15, 2023 at 1:06 AM Nishanth Menon wrote: > > Recent commit 75d28899e3e9 ("net: phy: Synchronize PHY interface modes > with Linux") reordered the enum definitions. This caused the range of > enums that this api was checking to go bad. > > There aren't anymore users of phy_interface_is_sgmii, so, just drop > it. Also the protocols are so very different that it makes no sense to > provide a helper wrapper in the hope of reuse for phy drivers. > > Reported-by: Tom Rini > Suggested-by: Marek Vasut > Suggested-by: Marek Behún > Link: https://lore.kernel.org/all/20230414103852.38705065@dellmb/ > Signed-off-by: Nishanth Menon > --- > Changes Since v2: > * Redone the patch, but original versions below (did'nt make sense to > carry reviewed-by) > * Just drop the phy_interface_is_sgmii > V2: https://lore.kernel.org/r/20230414042433.3436425-2...@ti.com > V1: https://lore.kernel.org/r/20230413180713.2922524-2...@ti.com > > include/phy.h | 12 > 1 file changed, 12 deletions(-) > > diff --git a/include/phy.h b/include/phy.h > index a837fed72352..cb87d1d4fc95 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -365,18 +365,6 @@ static inline bool phy_interface_is_rgmii(struct > phy_device *phydev) > phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID; > } > > -/** > - * phy_interface_is_sgmii - Convenience function for testing if a PHY > interface > - * is SGMII (all variants) > - * @phydev: the phy_device struct > - * @return: true if MII bus is SGMII or false if it is not > - */ > -static inline bool phy_interface_is_sgmii(struct phy_device *phydev) > -{ > - return phydev->interface >= PHY_INTERFACE_MODE_SGMII && > - phydev->interface <= PHY_INTERFACE_MODE_QSGMII; > -} > - > bool phy_interface_is_ncsi(void); > > /* PHY UIDs for various PHYs that are referenced in external code */ > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH V3 3/3] net: phy: Make phy_interface_is_rgmii a switch statement
On Sat, Apr 15, 2023 at 1:06 AM Nishanth Menon wrote: > > Recent commit 75d28899e3e9 ("net: phy: Synchronize PHY interface modes > with Linux") reordered the enum definitions. This exposed a problem > in range checking functions to identify the interface type. Though > this specific api wasn't impacted (all the RGMII definitions remained > within range), this experience should be used to never to have to face > this kind of challenge again. > > While it is possible for the phy drivers to use the enums directly, > drivers such as dp83867, dp83869, marvell, micrel_ksz90x1 etc use this > api. > > Reported-by: Tom Rini > Reviewed-by: Marek Vasut > Reviewed-by: Marek Behún > Signed-off-by: Nishanth Menon > --- > Changes since V2: > * picked up reviewed-by > * s/was'nt/wasn't/g in commit message, minor rewording. > V2: https://lore.kernel.org/r/20230414042433.3436425-3...@ti.com > V1: https://lore.kernel.org/r/20230413180713.2922524-3...@ti.com > include/phy.h | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/include/phy.h b/include/phy.h > index cb87d1d4fc95..247223d92be7 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -361,8 +361,15 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, > u32 *phy_id); > */ > static inline bool phy_interface_is_rgmii(struct phy_device *phydev) > { > - return phydev->interface >= PHY_INTERFACE_MODE_RGMII && > - phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID; > + switch (phydev->interface) { > + case PHY_INTERFACE_MODE_RGMII: > + case PHY_INTERFACE_MODE_RGMII_ID: > + case PHY_INTERFACE_MODE_RGMII_RXID: > + case PHY_INTERFACE_MODE_RGMII_TXID: > + return 1; > + default: > + return 0; > + } > } > > bool phy_interface_is_ncsi(void); > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH V3 1/3] net: phy: dp83867: Explicitly check against sgmii
On Sat, Apr 15, 2023 at 1:06 AM Nishanth Menon wrote: > > dp83867 driver only supports sgmii and not all the newer protocols. > Drop the usage of the generic phy_interface_is_sgmii function and just > matchup to the specific mode supported. > > Reported-by: Tom Rini > Suggested-by: Marek Vasut > Suggested-by: Marek Behún > Link: > https://lore.kernel.org/all/b82ac325-4818-8e72-054b-640268dbf...@mailbox.org/ > Signed-off-by: Nishanth Menon > --- > Changes since v2: > * New patch. > > drivers/net/phy/dp83867.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c > index b861bf7cef36..7111e36aa0d0 100644 > --- a/drivers/net/phy/dp83867.c > +++ b/drivers/net/phy/dp83867.c > @@ -330,7 +330,7 @@ static int dp83867_config(struct phy_device *phydev) > DP83867_RGMIIDCTL, delay); > } > > - if (phy_interface_is_sgmii(phydev)) { > + if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { > if (dp83867->sgmii_ref_clk_en) > phy_write_mmd(phydev, DP83867_DEVADDR, > DP83867_SGMIICTL, > DP83867_SGMII_TYPE); > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH 1/2] net: rtl8169: add minimal support for 8125B variant
On Tue, Apr 25, 2023 at 4:17 PM Eugen Hristev wrote: > > On 4/25/23 16:06, Eugen Hristev wrote: > > Add minimal support for 8125B version. > > Changes are based on the Linux driver. > > Tested on Radxa Rock 5B Rk3588 board. > > > > Connection to a laptop worked fine in 100 Mbps mode. > > 1000 Mbps mode is not working at the moment. > > > > Signed-off-by: Eugen Hristev > > --- > > The one thing that impacts all the rtl chips is the way the pci BAR is > now mapped. > I could not test this on another platform so help on this matter is > appreciated. > > Thanks! > Eugen Let's wait a bit to see if someone can test it. why did you change the mapping of the BAR ?
Re: [PATCH 2/2] net: phy: Make phy_interface_is_rgmii a switch statement
On Thu, Apr 13, 2023 at 9:07 PM Nishanth Menon wrote: > > Recent commit 75d28899e3e9 ("net: phy: Synchronize PHY interface modes > with Linux") reordered the enum definitions. This exposed a problem in > range checking functions to identify the interface type. Though this > specific api was'nt impacted (all the RGMII definitions remained within > range), this experience should be used to never to have to face this > kind of challenge again. > > While it is possible for the phy drivers to practically use the enum's > directly, drivers such as dp83867, dp83869, marvell, micrel_ksz90x1 etc > use the same. > > Reported-by: Tom Rini > Signed-off-by: Nishanth Menon > --- > include/phy.h | 12 ++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/include/phy.h b/include/phy.h > index 1c4dc23bc5ba..812694cf4a81 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -361,8 +361,16 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, > u32 *phy_id); > */ > static inline bool phy_interface_is_rgmii(struct phy_device *phydev) > { > - return phydev->interface >= PHY_INTERFACE_MODE_RGMII && > - phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID; > + switch (phydev->interface) { > + case PHY_INTERFACE_MODE_RGMII: > + case PHY_INTERFACE_MODE_RGMII_ID: > + case PHY_INTERFACE_MODE_RGMII_RXID: > + case PHY_INTERFACE_MODE_RGMII_TXID: > + return 1; > + default: > + fallthrough; > + } > + return 0; > } > > /** > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH v3 3/3] net: dhcp6: Add a sandbox test for dhcp6
On Tue, Apr 11, 2023 at 8:48 PM wrote: > > From: Sean Edmond > > Requires proper environment with DHCP6 server provisioned. > > Signed-off-by: Sean Edmond > --- > configs/sandbox_defconfig | 1 + > test/py/tests/test_net.py | 25 + > 2 files changed, 26 insertions(+) > > diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig > index ca95b2c5d2..d7ceedd601 100644 > --- a/configs/sandbox_defconfig > +++ b/configs/sandbox_defconfig > @@ -341,3 +341,4 @@ CONFIG_UNIT_TEST=y > CONFIG_UT_TIME=y > CONFIG_UT_DM=y > CONFIG_CMD_2048=y > +CONFIG_CMD_DHCP6=y > diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py > index 9ca6743afd..0447c0b2e0 100644 > --- a/test/py/tests/test_net.py > +++ b/test/py/tests/test_net.py > @@ -29,6 +29,11 @@ env__net_uses_pci = True > # set to False. > env__net_dhcp_server = True > > +# True if a DHCPv6 server is attached to the network, and should be tested. > +# If DHCPv6 testing is not possible or desired, this variable may be omitted > or > +# set to False. > +env__net_dhcp6_server = True > + > # A list of environment variables that should be set in order to configure a > # static IP. If solely relying on DHCP, this variable may be omitted or set > to > # an empty list. > @@ -58,6 +63,7 @@ env__net_nfs_readable_file = { > """ > > net_set_up = False > +net6_set_up = False > > def test_net_pre_commands(u_boot_console): > """Execute any commands required to enable network hardware. > @@ -93,6 +99,25 @@ def test_net_dhcp(u_boot_console): > global net_set_up > net_set_up = True > > +@pytest.mark.buildconfigspec('cmd_dhcp6') > +def test_net_dhcp6(u_boot_console): > +"""Test the dhcp6 command. > + > +The boardenv_* file may be used to enable/disable this test; see the > +comment at the beginning of this file. > +""" > + > +test_dhcp6 = u_boot_console.config.env.get('env__net_dhcp6_server', > False) > +if not test_dhcp6: > +pytest.skip('No DHCP6 server available') > + > +u_boot_console.run_command('setenv autoload no') > +output = u_boot_console.run_command('dhcp6') > +assert 'DHCP6 client bound to ' in output > + > +global net6_set_up > +net6_set_up = True > + > @pytest.mark.buildconfigspec('net') > def test_net_setup_static(u_boot_console): > """Set up a static IP configuration. > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH v3 1/3] net: dhcp6: Add DHCPv6 (DHCP for IPv6)
rx_status: Status from received message > + * @server_uid: Saved Server UID for selected server > + * @duid: pointer to transmitted Client DUID > + */ > +struct dhcp6_sm_params { > + enum dhcp6_statecurr_state; > + enum dhcp6_statenext_state; > + ulong dhcp6_start_ms; > + ulong dhcp6_retry_start_ms; > + ulong dhcp6_retry_ms; > + u32 retry_cnt; > + u32 trans_id; > + u32 ia_id; > + int irt_ms; > + int mrt_ms; > + int mrc; > + int mrd_ms; > + int rt_ms; > + int rt_prev_ms; > + struct dhcp6_rx_pkt_status rx_status; > + struct dhcp6_server_uid server_uid; > + char duid[DUID_MAX_SIZE]; > +}; > + > +/* Starts a DHCPv6 4-message exchange as a DHCPv6 client. On successful > exchange, > + * the DHCPv6 state machine will transition from internal states: > + * DHCP6_INIT->DHCP6_SOLICIT->DHCP6_REQUEST->DHCP6_DONE > + * > + * Transmitted SOLICIT and REQUEST packets will set/request the minimum > required > + * DHCPv6 options to PXE boot. > + * > + * After a successful exchange, the DHCPv6 assigned address will be set in > net_ip6 > + * > + * Additionally, the following will be set after receiving these options: > + * DHCP6_OPTION_OPT_BOOTFILE_URL (option 59) -> net_server_ip6, > net_boot_file_name > + * DHCP6_OPTION_OPT_BOOTFILE_PARAM (option 60) - > pxelinux_configfile > + * > + * Illustration of a 4-message exchange with 2 servers (copied from > + * https://www.rfc-editor.org/rfc/rfc8415): > + * > + * Server Server > + * (not selected) Client(selected) > + * > + * v v v > + * | | | > + * | Begins initialization | > + * | | | > + *start of | _/|\_ | > + *4-message|/ Solicit | Solicit \| > + *exchange | | | > + * Determines | Determines > + *configuration| configuration > + * | | | > + * |\ | /| > + * | \ | /Advertise| > + * | Advertise\|/ | > + * | \ | | > + * | Collects Advertises | > + * | \ | | > + * | Selects configuration | > + * | | | > + * | _/|\_ | > + * |/ Request | Request \| > + * | | | > + * | | Commits configuration > + * | | | > + *end of | | _/| > + *4-message| |/ Reply| > + *exchange | | | > + * |Initialization complete| > + * | | | > + */ > +void dhcp6_start(void); > + > +#endif /* __DHCP6_H__ */ > diff --git a/net/net.c b/net/net.c > index c9a749f6cc..8cb8b4b9f3 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -107,6 +107,8 @@ > #include > #include > #include > +#include > +#include > #include "arp.h" > #include "bootp.h" > #include "cdp.h" > @@ -120,8 +122,7 @@ > #if defined(CONFIG_CMD_WOL) > #include "wol.h" > #endif > -#include > -#include > +#include "dhcpv6.h" > > /** BOOTP EXTENTIONS **/ > > @@ -135,6 +136,8 @@ struct in_addr net_dns_server; > /* Our 2nd DNS IP address */ > struct in_addr net_dns_server2; > #endif > +/* Indicates whether the pxe path prefix / config file was specified in dhcp > option */ > +char *pxelinux_configfile; > > /** END OF BOOTP EXTENTIONS **/ > > @@ -510,6 +513,10 @@ restart: > dhcp_request(); /* Basically same as BOOTP */ > break; > #endif > + case DHCP6: > + if (IS_ENABLED(CONFIG_CMD_DHCP6)) > + dhcp6_start(); > + break; > #if defined(CONFIG_CMD_BOOTP) > case BOOTP: > bootp_reset(); > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH v3 2/3] net: dhcp6: pxe: Add DHCP/PXE commands for IPv6
gt; + use_ipv6 = true; > + > + if (!(argc == 1 || (argc == 2 && use_ipv6))) > + return CMD_RET_USAGE; > + } else { > + if (argc != 1) > + return CMD_RET_USAGE; > + } > > pxefile_addr_str = from_env("pxefile_addr_r"); > > @@ -183,7 +228,7 @@ do_pxe_get(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > if (ret < 0) > return 1; > > - ret = pxe_get(pxefile_addr_r, &fname, &size); > + ret = pxe_get(pxefile_addr_r, &fname, &size, use_ipv6); > switch (ret) { > case 0: > printf("Config file '%s' found\n", fname); > @@ -211,13 +256,19 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > char *pxefile_addr_str; > struct pxe_context ctx; > int ret; > + bool use_ipv6 = false; > + > + if (IS_ENABLED(CONFIG_IPV6)) { > + if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) > + use_ipv6 = true; > + } > > - if (argc == 1) { > + if (argc == 1 || (argc == 2 && use_ipv6)) { > pxefile_addr_str = from_env("pxefile_addr_r"); > if (!pxefile_addr_str) > return 1; > > - } else if (argc == 2) { > + } else if (argc == 2 || (argc == 3 && use_ipv6)) { > pxefile_addr_str = argv[1]; > } else { > return CMD_RET_USAGE; > @@ -229,7 +280,7 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > } > > if (pxe_setup_ctx(&ctx, cmdtp, do_get_tftp, NULL, false, > - env_get("bootfile"))) { > + env_get("bootfile"), use_ipv6)) { > printf("Out of memory\n"); > return CMD_RET_FAILURE; > } > @@ -244,8 +295,8 @@ do_pxe_boot(struct cmd_tbl *cmdtp, int flag, int argc, > char *const argv[]) > } > > static struct cmd_tbl cmd_pxe_sub[] = { > - U_BOOT_CMD_MKENT(get, 1, 1, do_pxe_get, "", ""), > - U_BOOT_CMD_MKENT(boot, 2, 1, do_pxe_boot, "", "") > + U_BOOT_CMD_MKENT(get, 2, 1, do_pxe_get, "", ""), > + U_BOOT_CMD_MKENT(boot, 3, 1, do_pxe_boot, "", "") > }; > > static void __maybe_unused pxe_reloc(void) > @@ -281,9 +332,11 @@ static int do_pxe(struct cmd_tbl *cmdtp, int flag, int > argc, char *const argv[]) > return CMD_RET_USAGE; > } > > -U_BOOT_CMD(pxe, 3, 1, do_pxe, > - "commands to get and boot from pxe files", > - "get - try to retrieve a pxe file using tftp\n" > - "pxe boot [pxefile_addr_r] - boot from the pxe file at > pxefile_addr_r\n" > +U_BOOT_CMD(pxe, 4, 1, do_pxe, > + "commands to get and boot from pxe files\n" > + "To use IPv6 add -ipv6 parameter", > + "get [" USE_IP6_CMD_PARAM "] - try to retrieve a pxe file using > tftp\n" > + "pxe boot [pxefile_addr_r] [-ipv6] - boot from the pxe file at > pxefile_addr_r\n" > ); > -#endif > + > +#endif /* CONFIG_CMD_NET */ > diff --git a/cmd/sysboot.c b/cmd/sysboot.c > index 04c0702026..63a7806deb 100644 > --- a/cmd/sysboot.c > +++ b/cmd/sysboot.c > @@ -101,7 +101,7 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, > int argc, > } > > if (pxe_setup_ctx(&ctx, cmdtp, sysboot_read_file, &info, true, > - filename)) { > + filename, false)) { > printf("Out of memory\n"); > return CMD_RET_FAILURE; > } > diff --git a/include/pxe_utils.h b/include/pxe_utils.h > index 1e5e8424f5..9f19593048 100644 > --- a/include/pxe_utils.h > +++ b/include/pxe_utils.h > @@ -93,6 +93,7 @@ typedef int (*pxe_getfile_func)(struct pxe_context *ctx, > const char *file_path, > * @bootdir: Directory that files are loaded from ("" if no directory). This > is > * allocated > * @pxe_file_size: Size of the PXE file > + * @use_ipv6: TRUE : use IPv6 addressing, FALSE : use IPv4 addressing > */ > struct pxe_context { > struct cmd_tbl *cmdtp; > @@ -112,6 +113,7 @@ struct pxe_context { > bool allow_abs_path; > char *bootdir; > ulong pxe_file_size; > + bool use_ipv6; > }; > > /** > @@ -209,12 +211,14 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); > * @allow_abs_path: true to allow absolute paths > * @bootfile: Bootfile whose directory loaded files are relative to, NULL if > * none > + * @use_ipv6: TRUE : use IPv6 addressing > + *FALSE : use IPv4 addressing > * Return: 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger > than > * MAX_TFTP_PATH_LEN bytes > */ > int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, > pxe_getfile_func getfile, void *userdata, > - bool allow_abs_path, const char *bootfile); > + bool allow_abs_path, const char *bootfile, bool use_ipv6); > > /** > * pxe_destroy_ctx() - Destroy a PXE context > @@ -251,7 +255,9 @@ int pxe_get_file_size(ulong *sizep); > * "rpi/info", which indicates that all files should be fetched from the > * "rpi/" subdirectory > * @sizep: Size of the PXE file (not bootfile) > + * @use_ipv6: TRUE : use IPv6 addressing > + *FALSE : use IPv4 addressing > */ > -int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep); > +int pxe_get(ulong pxefile_addr_r, char **bootdirp, ulong *sizep, bool > use_ipv6); > > #endif /* __PXE_UTILS_H */ > -- > 2.40.0 > Reviewed-by: Ramon Fried
Re: [PATCH v2 3/3] net: dhcp6: Add a sandbox test for dhcp6
On Fri, Apr 7, 2023 at 9:55 PM Simon Glass wrote: > > On Fri, 7 Apr 2023 at 18:56, wrote: > > > > From: Sean Edmond > > > > Requires proper environment with DHCP6 server provisioned. > > > > Signed-off-by: Sean Edmond > > --- > > configs/sandbox_defconfig | 1 + > > test/py/tests/test_net.py | 25 + > > 2 files changed, 26 insertions(+) > > Reviewed-by: Simon Glass Acked-by: Ramon Fried
Re: [PATCH v2 1/3] net: dhcp6: Add DHCPv6 (DHCP for IPv6)
On Fri, Apr 7, 2023 at 9:55 PM Simon Glass wrote: > > Hi, > > On Fri, 7 Apr 2023 at 18:56, wrote: > > > > From: Sean Edmond > > > > Adds DHCPv6 protocol to u-boot. > > > > Allows for address assignement with DHCPv6 4-message exchange > > (SOLICIT->ADVERTISE->REQUEST->REPLY). Includes DHCPv6 options > > required by RFC 8415. Also adds DHCPv6 options required > > for PXE boot. > > > > Possible enhancements: > > - Duplicate address detection on DHCPv6 assigned address > > - IPv6 address assignement through SLAAC > > - Sending/parsing other DHCPv6 options (NTP, DNS, etc...) > > > > Signed-off-by: Sean Edmond > > --- > > include/net.h | 8 +- > > net/Makefile | 1 + > > net/dhcpv6.c | 735 ++ > > net/dhcpv6.h | 212 +++ > > net/net.c | 12 + > > 5 files changed, 966 insertions(+), 2 deletions(-) > > create mode 100644 net/dhcpv6.c > > create mode 100644 net/dhcpv6.h > > This looks good to me. I just have a few nits below. With those fixed: > > Reviewed-by: Simon Glass > > > > > diff --git a/include/net.h b/include/net.h > > index 399af5e064..cac818e292 100644 > > --- a/include/net.h > > +++ b/include/net.h > > @@ -484,6 +484,10 @@ extern charnet_hostname[32]; /* Our > > hostname */ > > #ifdef CONFIG_NET > > extern charnet_root_path[CONFIG_BOOTP_MAX_ROOT_PATH_LEN]; /* Our root > > path */ > > #endif > > +#if defined(CONFIG_DHCP6_PXE_DHCP_OPTION) > > You can drop this #ifdef as any reference to a non-existent var will > give a build error. > > > +/* Indicates whether the pxe path prefix / config file was specified in > > dhcp option */ > > +extern char *pxelinux_configfile; > > +#endif > > /** END OF BOOTP EXTENTIONS **/ > > extern u8 net_ethaddr[ARP_HLEN]; /* Our ethernet > > address */ > > extern u8 net_server_ethaddr[ARP_HLEN]; /* Boot server enet > > address */ > > @@ -504,8 +508,8 @@ extern ushort net_native_vlan;/* > > Our Native VLAN */ > > extern int net_restart_wrap; /* Tried all network > > devices */ > > > > enum proto_t { > > - BOOTP, RARP, ARP, TFTPGET, DHCP, PING, PING6, DNS, NFS, CDP, > > NETCONS, > > - SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET > > + BOOTP, RARP, ARP, TFTPGET, DHCP, DHCP6, PING, PING6, DNS, NFS, CDP, > > + NETCONS, SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, > > NCSI, WGET > > }; > > > > extern charnet_boot_file_name[1024];/* Boot File name */ > > diff --git a/net/Makefile b/net/Makefile > > index bea000b206..5968110170 100644 > > --- a/net/Makefile > > +++ b/net/Makefile > > @@ -22,6 +22,7 @@ obj-$(CONFIG_IPV6) += net6.o > > obj-$(CONFIG_CMD_NFS) += nfs.o > > obj-$(CONFIG_CMD_PING) += ping.o > > obj-$(CONFIG_CMD_PING6) += ping6.o > > +obj-$(CONFIG_CMD_DHCP6) += dhcpv6.o > > obj-$(CONFIG_CMD_PCAP) += pcap.o > > obj-$(CONFIG_CMD_RARP) += rarp.o > > obj-$(CONFIG_CMD_SNTP) += sntp.o > > diff --git a/net/dhcpv6.c b/net/dhcpv6.c > > new file mode 100644 > > index 00..9204909c1f > > --- /dev/null > > +++ b/net/dhcpv6.c > > @@ -0,0 +1,735 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * Copyright (C) Microsoft Corporation > > + * Author: Sean Edmond > > + * > > + */ > > + > > +/* Simple DHCP6 network layer implementation. */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "dhcpv6.h" > > +#include > > +#include > > +#include "net_rand.h" > > Please fix header order: > https://u-boot.readthedocs.io/en/latest/develop/codingstyle.html#include-files > > > + > > +#define PORT_DHCP6_S 547 /* DHCP6 server UDP port */ > > +#define PORT_DHCP6_C 546 /* DHCP6 client UDP port */ > > + > > +/* default timeout parameters (in ms) */ > > +#define SOL_MAX_DELAY_MS 1000 > > +#define SOL_TIMEOUT_MS 1000 > > +#define SOL_MAX_RT_MS 360 > > +#define REQ_TIMEOUT_MS 1000 > > +#define REQ_MAX_RT_MS 3 > > +#define REQ_MAX_RC 10 > > +#define MAX_WAIT_TIME_MS 6 > > + > > +/* global variable to track any updates from DHCP6 server */ > > +int updated_sol_max_rt_ms = SOL_MAX_RT_MS; > > + > > +static void dhcp6_timeout_handler(void); > > +static void dhcp6_state_machine(bool timeout, uchar *rx_pkt, unsigned int > > len); > > +static void dhcp6_parse_options(uchar *rx_pkt, unsigned int len); > > Rather than forward decls can you reorder the functions? > > > + > > +struct dhcp6_sm_params sm_params; > > + > > +/* > > + * Handle DHCP received packets (set as UDP handler) > > + */ > > Please check single-line comment style > > > +static void dhcp6_handler(uchar *pkt, unsigned int dest, struct in_addr > > sip, > > + unsigned int src, unsigned int len) > > +{ > > + /* return if ports don't mat
Re: [PATCH] net: ravb: Support fixed PHY in R-Car
On Tue, Feb 28, 2023 at 1:04 AM Marek Vasut wrote: > > From: Mikhail Lappo > > Calling old U-Boot API doesn't allow to use fixed PHY. > Searching by mask is the part of new function, after > scanning FDT for a fixed PHY definition > > Fixes: e821a7bdb13 ("net: ravb: Detect PHY correctly") > Reviewed-by: Marek Vasut > Signed-off-by: Mikhail Lappo > Signed-off-by: Hai Pham > [Hai Pham: Drop phy_connect_dev since it's called in phy_connect] > Signed-off-by: Marek Vasut > [Marek: Use mask -1 instead of 0 to reinstate the search behavior > over all PHY addresses. Add Fixes tag, sort the tag list.] > --- > Cc: Joe Hershberger > Cc: Ramon Fried > --- > drivers/net/ravb.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c > index 5a835cc06ff..0bc50dc7335 100644 > --- a/drivers/net/ravb.c > +++ b/drivers/net/ravb.c > @@ -310,7 +310,7 @@ static int ravb_phy_config(struct udevice *dev) > struct ravb_priv *eth = dev_get_priv(dev); > struct eth_pdata *pdata = dev_get_plat(dev); > struct phy_device *phydev; > - int mask = 0x, reg; > + int reg; > > if (dm_gpio_is_valid(ð->reset_gpio)) { > dm_gpio_set_value(ð->reset_gpio, 1); > @@ -319,12 +319,10 @@ static int ravb_phy_config(struct udevice *dev) > mdelay(1); > } > > - phydev = phy_find_by_mask(eth->bus, mask); > + phydev = phy_connect(eth->bus, -1, dev, pdata->phy_interface); > if (!phydev) > return -ENODEV; > > - phy_connect_dev(phydev, dev, pdata->phy_interface); > - > eth->phydev = phydev; > > phydev->supported &= SUPPORTED_100baseT_Full | > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH v2 1/5] net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy
0; > +} > + > +static int yt8531_probe(struct phy_device *phydev) > +{ > + struct ytphy_plat_priv *priv; > + > + priv = calloc(1, sizeof(struct ytphy_plat_priv)); > + if (!priv) > + return -ENOMEM; > + > + phydev->priv = priv; > + > + return 0; > +} > + > +static struct phy_driver motorcomm8531_driver = { > + .name = "YT8531 Gigabit Ethernet", > + .uid = PHY_ID_YT8531, > + .mask = PHY_ID_MASK, > + .features = PHY_GBIT_FEATURES, > + .probe = &yt8531_probe, > + .config= &yt8531_config, > + .startup = &yt8531_startup, > + .shutdown = &genphy_shutdown, > +}; > + > +int phy_motorcomm_init(void) > +{ > + phy_register(&motorcomm8531_driver); > + > + return 0; > +} > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 80230b907c..78bde61798 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -570,6 +570,9 @@ int phy_init(void) > #endif > #ifdef CONFIG_PHY_XILINX_GMII2RGMII > phy_xilinx_gmii2rgmii_init(); > +#endif > +#ifdef CONFIG_PHY_MOTORCOMM > + phy_motorcomm_init(); > #endif > genphy_init(); > > @@ -755,7 +758,6 @@ static struct phy_device *create_phy_by_mask(struct > mii_dev *bus, > while (phy_mask) { > int addr = ffs(phy_mask) - 1; > int r = get_phy_id(bus, addr, devad, &phy_id); > - > /* > * If the PHY ID is flat 0 we ignore it. There are C45 PHYs > * that return all 0s for C22 reads (like Aquantia AQR112) and > diff --git a/include/phy.h b/include/phy.h > index 87aa86c2e7..f7bb2fe0af 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -344,6 +344,7 @@ int phy_mscc_init(void); > int phy_fixed_init(void); > int phy_ncsi_init(void); > int phy_xilinx_gmii2rgmii_init(void); > +int phy_motorcomm_init(void); > > int board_phy_config(struct phy_device *phydev); > int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id); > -- > 2.17.1 > Reviewed-by: Ramon Fried
Re: [PATCH] net: ipv6: Add support for default gateway discovery.
e set, the RA packet is ignored. > The > +* reason is that the U-Boot code is supposed to be as compact > +* as possible and does not need to take care of multiple > +* routers. In addition to that, U-Boot does not want to > handle > +* scenarios like a router setting its lifetime to zero to > +* indicate it is not routing anymore. U-Boot program has a > +* short life when the system boots up and does not need such > +* sophistication. > +*/ > + if (!ip6_is_unspecified_addr(&net_gateway6) && > + net_prefix_length != 0) { > + break; > + } > + if (!validate_ra(ip6, len)) { > + debug("Invalid router advertisement message.\n"); > + break; > + } > + err = process_ra(ip6, len); > + if (err) > + debug("Ignored router advertisement. Error: %d\n", > err); > + else > + printf("Set gatewayip6: %pI6c, prefix_length: %d\n", > + &net_gateway6, net_prefix_length); > + break; > default: > debug("Unexpected ICMPv6 type 0x%x\n", icmp->icmp6_type); > return -1; > diff --git a/net/net.c b/net/net.c > index c9a749f..39f0b81 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -24,7 +24,7 @@ > * - name of bootfile > * Next step: ARP > * > - * LINK_LOCAL: > + * LINKLOCAL: > * > * Prerequisites: - own ethernet address > * We want:- own IP address > @@ -122,6 +122,7 @@ > #endif > #include > #include > +#include "net_rand.h" > > /** BOOTP EXTENTIONS **/ > > @@ -346,6 +347,8 @@ void net_auto_load(void) > > static int net_init_loop(void) > { > + static bool first_call = true; > + > if (eth_get_dev()) { > memcpy(net_ethaddr, eth_get_ethaddr(), 6); > > @@ -365,6 +368,12 @@ static int net_init_loop(void) > */ > return -ENONET; > > + if (IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY)) > + if (first_call && use_ip6) { > + first_call = false; > + srand_mac(); /* This is for rand used in ip6_send_rs. > */ > + net_loop(RS); > + } > return 0; > } > > @@ -574,6 +583,10 @@ restart: > ncsi_probe_packages(); > break; > #endif > + case RS: > + if (IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY)) > + ip6_send_rs(); > + break; > default: > break; > } > @@ -671,7 +684,13 @@ restart: > x = time_handler; > time_handler = (thand_f *)0; > (*x)(); > - } > + } else if (IS_ENABLED(CONFIG_IPV6_ROUTER_DISCOVERY)) > + if (time_handler && protocol == RS) > + if (!ip6_is_unspecified_addr(&net_gateway6) && > + net_prefix_length != 0) { > + net_set_state(NETLOOP_SUCCESS); > + net_set_timeout_handler(0, 0); > + } > > if (net_state == NETLOOP_FAIL) > ret = net_start_again(); > diff --git a/net/net6.c b/net/net6.c > index 75577bc..2dd64c0 100644 > --- a/net/net6.c > +++ b/net/net6.c > @@ -413,6 +413,7 @@ int net_ip6_handler(struct ethernet_hdr *et, struct > ip6_hdr *ip6, int len) > break; > case IPV6_NDISC_NEIGHBOUR_SOLICITATION: > case IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT: > + case IPV6_NDISC_ROUTER_ADVERTISEMENT: > ndisc_receive(et, ip6, len); > break; > default: > -- > 1.8.3.1 > Reviewed-by: Ramon Fried
Re: [PATCH 1/4] net: e1000: add and make use of NUM_RX_DESC macro
On Fri, Mar 3, 2023 at 10:49 PM Christian Gmeiner wrote: > > The call to DEFINE_ALIGN_BUFFER for the rx_desc array > conained an icnonsistency as 16 receive descriptors > were allocated when the remaining code would only use > 8 of them. > > Signed-off-by: Christian Gmeiner > --- > drivers/net/e1000.c | 6 +++--- > drivers/net/e1000.h | 2 ++ > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c > index 41e6ba760e..8dccf29c7e 100644 > --- a/drivers/net/e1000.c > +++ b/drivers/net/e1000.c > @@ -60,7 +60,7 @@ tested on both gig copper and gig fiber boards > * move these buffers and the tx/rx pointers to struct e1000_hw. > */ > DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN); > -DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, 16, E1000_BUFFER_ALIGN); > +DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, > E1000_BUFFER_ALIGN); > DEFINE_ALIGN_BUFFER(unsigned char, packet, 4096, E1000_BUFFER_ALIGN); > > static int tx_tail; > @@ -5095,7 +5095,7 @@ fill_rx(struct e1000_hw *hw) > > rx_last = rx_tail; > rd = rx_base + rx_tail; > - rx_tail = (rx_tail + 1) % 8; > + rx_tail = (rx_tail + 1) % NUM_RX_DESC; > memset(rd, 0, 16); > rd->buffer_addr = cpu_to_le64(virt_to_phys(packet)); > > @@ -5272,7 +5272,7 @@ e1000_configure_rx(struct e1000_hw *hw) > E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(rx_base))); > E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(rx_base))); > > - E1000_WRITE_REG(hw, RDLEN, 128); > + E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct > e1000_rx_desc)); > > /* Setup the HW Rx Head and Tail Descriptor Pointers */ > E1000_WRITE_REG(hw, RDH, 0); > diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h > index f788394da8..69882ba66f 100644 > --- a/drivers/net/e1000.h > +++ b/drivers/net/e1000.h > @@ -42,6 +42,8 @@ > #define DEBUGOUT(fmt, args...) do { } while (0) > #endif > > +#define NUM_RX_DESC8 > + > /* I/O wrapper functions */ > #define E1000_WRITE_REG(a, reg, value) \ > writel((value), ((a)->hw_addr + E1000_##reg)) > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 01/41] net: phy: aquantia: Staticize PHY driver entries
On Sun, Mar 19, 2023 at 7:03 PM Marek Vasut wrote: > > These struct phy_driver ... instances are local to this source code > file, staticize them. No functional change. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/aquantia.c | 18 +- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c > index 8eb6024829d..fa887ade0c2 100644 > --- a/drivers/net/phy/aquantia.c > +++ b/drivers/net/phy/aquantia.c > @@ -598,7 +598,7 @@ int aquantia_startup(struct phy_device *phydev) > return 0; > } > > -struct phy_driver aq1202_driver = { > +static struct phy_driver aq1202_driver = { > .name = "Aquantia AQ1202", > .uid = 0x3a1b445, > .mask = 0xfff0, > @@ -611,7 +611,7 @@ struct phy_driver aq1202_driver = { > .shutdown = &gen10g_shutdown, > }; > > -struct phy_driver aq2104_driver = { > +static struct phy_driver aq2104_driver = { > .name = "Aquantia AQ2104", > .uid = 0x3a1b460, > .mask = 0xfff0, > @@ -624,7 +624,7 @@ struct phy_driver aq2104_driver = { > .shutdown = &gen10g_shutdown, > }; > > -struct phy_driver aqr105_driver = { > +static struct phy_driver aqr105_driver = { > .name = "Aquantia AQR105", > .uid = 0x3a1b4a2, > .mask = 0xfff0, > @@ -638,7 +638,7 @@ struct phy_driver aqr105_driver = { > .data = AQUANTIA_GEN1, > }; > > -struct phy_driver aqr106_driver = { > +static struct phy_driver aqr106_driver = { > .name = "Aquantia AQR106", > .uid = 0x3a1b4d0, > .mask = 0xfff0, > @@ -651,7 +651,7 @@ struct phy_driver aqr106_driver = { > .shutdown = &gen10g_shutdown, > }; > > -struct phy_driver aqr107_driver = { > +static struct phy_driver aqr107_driver = { > .name = "Aquantia AQR107", > .uid = 0x3a1b4e0, > .mask = 0xfff0, > @@ -665,7 +665,7 @@ struct phy_driver aqr107_driver = { > .data = AQUANTIA_GEN2, > }; > > -struct phy_driver aqr112_driver = { > +static struct phy_driver aqr112_driver = { > .name = "Aquantia AQR112", > .uid = 0x3a1b660, > .mask = 0xfff0, > @@ -679,7 +679,7 @@ struct phy_driver aqr112_driver = { > .data = AQUANTIA_GEN3, > }; > > -struct phy_driver aqr113c_driver = { > +static struct phy_driver aqr113c_driver = { > .name = "Aquantia AQR113C", > .uid = 0x31c31c12, > .mask = 0xfff0, > @@ -693,7 +693,7 @@ struct phy_driver aqr113c_driver = { > .data = AQUANTIA_GEN3, > }; > > -struct phy_driver aqr405_driver = { > +static struct phy_driver aqr405_driver = { > .name = "Aquantia AQR405", > .uid = 0x3a1b4b2, > .mask = 0xfff0, > @@ -707,7 +707,7 @@ struct phy_driver aqr405_driver = { > .data = AQUANTIA_GEN1, > }; > > -struct phy_driver aqr412_driver = { > +static struct phy_driver aqr412_driver = { > .name = "Aquantia AQR412", > .uid = 0x3a1b710, > .mask = 0xfff0, > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH v2 3/3] net: phy: Synchronize PHY interface modes with Linux
On Tue, Mar 21, 2023 at 7:26 PM Marek Vasut wrote: > > Synchronize PHY interface modes with Linux next 6.2.y commit: > 0194b64578e90 ("net: phy: improve phy_read_poll_timeout") > > Retain LX2160A/LX2162A PHY modes as those are not yet supported > by the Linux kernel, but isolate those with ifdeffery. > > Isolate NCSI which are also not supported by Linux kernel. Note > that the ifdeffery cannot be avoided with IS_ENABLED() here due > to compilation of the entire conditional, which would fail in > case NCSI symbols are not available. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Ramon Fried > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > V2: No change > --- > drivers/net/phy/phy.c | 4 +++ > include/phy_interface.h | 68 + > 2 files changed, 53 insertions(+), 19 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 9b0e497f223..f720d0a7920 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -1160,7 +1160,11 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int > devad, u32 regnum, u16 val > > bool phy_interface_is_ncsi(void) > { > +#ifdef CONFIG_PHY_NCSI > struct eth_pdata *pdata = dev_get_plat(eth_get_dev()); > > return pdata->phy_interface == PHY_INTERFACE_MODE_NCSI; > +#else > + return 0; > +#endif > } > diff --git a/include/phy_interface.h b/include/phy_interface.h > index 52af7e612b6..31be3228c7c 100644 > --- a/include/phy_interface.h > +++ b/include/phy_interface.h > @@ -14,65 +14,95 @@ > > typedef enum { > PHY_INTERFACE_MODE_NA, /* don't touch */ > + PHY_INTERFACE_MODE_INTERNAL, > PHY_INTERFACE_MODE_MII, > PHY_INTERFACE_MODE_GMII, > PHY_INTERFACE_MODE_SGMII, > - PHY_INTERFACE_MODE_SGMII_2500, > - PHY_INTERFACE_MODE_QSGMII, > PHY_INTERFACE_MODE_TBI, > + PHY_INTERFACE_MODE_REVMII, > PHY_INTERFACE_MODE_RMII, > + PHY_INTERFACE_MODE_REVRMII, > PHY_INTERFACE_MODE_RGMII, > PHY_INTERFACE_MODE_RGMII_ID, > PHY_INTERFACE_MODE_RGMII_RXID, > PHY_INTERFACE_MODE_RGMII_TXID, > PHY_INTERFACE_MODE_RTBI, > + PHY_INTERFACE_MODE_SMII, > + PHY_INTERFACE_MODE_XGMII, > + PHY_INTERFACE_MODE_XLGMII, > + PHY_INTERFACE_MODE_MOCA, > + PHY_INTERFACE_MODE_QSGMII, > + PHY_INTERFACE_MODE_TRGMII, > + PHY_INTERFACE_MODE_100BASEX, > PHY_INTERFACE_MODE_1000BASEX, > PHY_INTERFACE_MODE_2500BASEX, > - PHY_INTERFACE_MODE_XGMII, > - PHY_INTERFACE_MODE_XAUI, > - PHY_INTERFACE_MODE_RXAUI, > PHY_INTERFACE_MODE_5GBASER, > - PHY_INTERFACE_MODE_SFI, > - PHY_INTERFACE_MODE_INTERNAL, > + PHY_INTERFACE_MODE_RXAUI, > + PHY_INTERFACE_MODE_XAUI, > + /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */ > + PHY_INTERFACE_MODE_10GBASER, > + PHY_INTERFACE_MODE_25GBASER, > + PHY_INTERFACE_MODE_USXGMII, > + /* 10GBASE-KR - with Clause 73 AN */ > + PHY_INTERFACE_MODE_10GKR, > + PHY_INTERFACE_MODE_QUSGMII, > + PHY_INTERFACE_MODE_1000BASEKX, > +#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A) > + /* LX2160A SERDES modes */ > PHY_INTERFACE_MODE_25G_AUI, > PHY_INTERFACE_MODE_XLAUI, > PHY_INTERFACE_MODE_CAUI2, > PHY_INTERFACE_MODE_CAUI4, > +#endif > +#if defined(CONFIG_PHY_NCSI) > PHY_INTERFACE_MODE_NCSI, > - PHY_INTERFACE_MODE_10GBASER, > - PHY_INTERFACE_MODE_USXGMII, > +#endif > PHY_INTERFACE_MODE_MAX, > } phy_interface_t; > > static const char * const phy_interface_strings[] = { > - [PHY_INTERFACE_MODE_NA] = "", > + [PHY_INTERFACE_MODE_NA] = "", > + [PHY_INTERFACE_MODE_INTERNAL] = "internal", > [PHY_INTERFACE_MODE_MII]= "mii", > [PHY_INTERFACE_MODE_GMII] = "gmii", > [PHY_INTERFACE_MODE_SGMII] = "sgmii", > - [PHY_INTERFACE_MODE_SGMII_2500] = "sgmii-2500", > - [PHY_INTERFACE_MODE_QSGMII] = "qsgmii", > [PHY_INTERFACE_MODE_TBI]= "tbi", > + [PHY_INTERFACE_MODE_REVMII] = "rev-mii", > [PHY_INTERFACE_MODE_RMII] = "rmii", > + [PHY_INTERFACE_MODE_REVRMII]
Re: [PATCH v2 2/3] net: mvpp2: Replace PHY_INTERFACE_MODE_SFI with 5GBASER/10GBASER/XAUI
On Tue, Mar 21, 2023 at 7:26 PM Marek Vasut wrote: > > Replace PHY_INTERFACE_MODE_SFI with PHY_INTERFACE_MODE_5GBASER, > PHY_INTERFACE_MODE_10GBASER and PHY_INTERFACE_MODE_XAUI to match > Linux PHY interface modes. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Ramon Fried > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > V2: No change > --- > drivers/net/mvpp2.c | 8 ++-- > include/phy_interface.h | 2 ++ > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c > index c99d52c85d7..f407d8f6a81 100644 > --- a/drivers/net/mvpp2.c > +++ b/drivers/net/mvpp2.c > @@ -3391,7 +3391,9 @@ static int gop_port_init(struct mvpp2_port *port) > gop_gmac_reset(port, 0); > break; > > - case PHY_INTERFACE_MODE_SFI: > + case PHY_INTERFACE_MODE_10GBASER: > + case PHY_INTERFACE_MODE_5GBASER: > + case PHY_INTERFACE_MODE_XAUI: > num_of_act_lanes = 2; > mac_num = 0; > /* configure PCS */ > @@ -3442,7 +3444,9 @@ static void gop_port_enable(struct mvpp2_port *port, > int enable) > mvpp2_port_disable(port); > break; > > - case PHY_INTERFACE_MODE_SFI: > + case PHY_INTERFACE_MODE_10GBASER: > + case PHY_INTERFACE_MODE_5GBASER: > + case PHY_INTERFACE_MODE_XAUI: > gop_xlg_mac_port_enable(port, enable); > > break; > diff --git a/include/phy_interface.h b/include/phy_interface.h > index fed3357b9a2..52af7e612b6 100644 > --- a/include/phy_interface.h > +++ b/include/phy_interface.h > @@ -31,6 +31,7 @@ typedef enum { > PHY_INTERFACE_MODE_XGMII, > PHY_INTERFACE_MODE_XAUI, > PHY_INTERFACE_MODE_RXAUI, > + PHY_INTERFACE_MODE_5GBASER, > PHY_INTERFACE_MODE_SFI, > PHY_INTERFACE_MODE_INTERNAL, > PHY_INTERFACE_MODE_25G_AUI, > @@ -62,6 +63,7 @@ static const char * const phy_interface_strings[] = { > [PHY_INTERFACE_MODE_XGMII] = "xgmii", > [PHY_INTERFACE_MODE_XAUI] = "xaui", > [PHY_INTERFACE_MODE_RXAUI] = "rxaui", > + [PHY_INTERFACE_MODE_5GBASER]= "5gbase-r", > [PHY_INTERFACE_MODE_SFI]= "sfi", > [PHY_INTERFACE_MODE_INTERNAL] = "internal", > [PHY_INTERFACE_MODE_25G_AUI]= "25g-aui", > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH] net: rswitch: Add Renesas Ethernet Switch
On Mon, Mar 20, 2023 at 10:05 PM Marek Vasut wrote: > > From: Phong Hoang > > This patch adds Ethernet Switch support that found on R-Car S4 > (r8a779f0) SoC. This is extracted from multiple patches from > downstream BSP, with additional rework of the network device > registration. > > Signed-off-by: Hai Pham > Signed-off-by: Marek Vasut > Signed-off-by: Phong Hoang > Signed-off-by: Takeshi Kihara > [Marek: Rework the driver to support all ports via subdrivers. > Split the driver up, add generic PHY framework support. > Generic code clean ups.] > --- > Cc: Hai Pham > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Peng Fan > Cc: Ramon Fried > Cc: Simon Glass > --- > drivers/net/Kconfig |8 + > drivers/net/Makefile |1 + > drivers/net/rswitch.c | 1139 + > 3 files changed, 1148 insertions(+) > create mode 100644 drivers/net/rswitch.c > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index 5c29e63d0be..09039a283eb 100644 > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -752,6 +752,14 @@ config GMAC_ROCKCHIP > This driver provides Rockchip SoCs network support based on the > Synopsys Designware driver. > > +config RENESAS_ETHER_SWITCH > + bool "Renesas Ethernet Switch support" > + depends on DM_ETH && R8A779F0 > + select PHYLIB > + help > + This driver implements support for the Renesas Ethernet Switch > + which is available on R-Car S4 SoC (r8a779f0). > + > config RENESAS_RAVB > bool "Renesas Ethernet AVB MAC" > depends on RCAR_64 > diff --git a/drivers/net/Makefile b/drivers/net/Makefile > index 75daa5e694c..46a40e2ed9f 100644 > --- a/drivers/net/Makefile > +++ b/drivers/net/Makefile > @@ -76,6 +76,7 @@ obj-$(CONFIG_OCTEONTX_SMI) += octeontx/smi.o > obj-$(CONFIG_PCH_GBE) += pch_gbe.o > obj-$(CONFIG_PCNET) += pcnet.o > obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o > +obj-$(CONFIG_RENESAS_ETHER_SWITCH) += rswitch.o > obj-$(CONFIG_RENESAS_RAVB) += ravb.o > obj-$(CONFIG_RTL8139) += rtl8139.o > obj-$(CONFIG_RTL8169) += rtl8169.o > diff --git a/drivers/net/rswitch.c b/drivers/net/rswitch.c > new file mode 100644 > index 000..5a69ca1a0f9 > --- /dev/null > +++ b/drivers/net/rswitch.c > @@ -0,0 +1,1139 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Driver for Renesas Ethernet RSwitch2 (Ethernet-TSN). > + * > + * Copyright (C) 2021 Renesas Electronics Corporation > + * > + * Based on the Renesas Ethernet AVB driver. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define RSWITCH_SLEEP_US 1000 > +#define RSWITCH_TIMEOUT_US 100 > + > +#define RSWITCH_NUM_HW 5 > + > +#define ETHA_TO_GWCA(i)((i) % 2) > +#define GWCA_TO_HW_INDEX(i)((i) + 3) > +#define HW_INDEX_TO_GWCA(i)((i) - 3) > + > +#define RSWITCH_MAX_CTAG_PCP 7 > + > +/* Registers */ > +#define RSWITCH_COMA_OFFSET 0x9000 > +#define RSWITCH_ETHA_OFFSET 0xa000 /* with RMAC */ > +#define RSWITCH_ETHA_SIZE 0x2000 /* with RMAC */ > +#define RSWITCH_GWCA_OFFSET0x0001 > +#define RSWITCH_GWCA_SIZE 0x2000 > + > +#define FWRO0 > +#define CARORSWITCH_COMA_OFFSET > +#define GWRO0 > +#define TARO0 > +#define RMRO0x1000 > + > +enum rswitch_reg { > + EAMC= TARO + 0x, > + EAMS= TARO + 0x0004, > + EATDQDC = TARO + 0x0060, > + EATTFC = TARO + 0x0138, > + EATASRIRM = TARO + 0x03E4, > + > + GWMC= GWRO + 0x, > + GWMS= GWRO + 0x0004, > + GWMTIRM = GWRO + 0x0100, > + GWVCC = GWRO + 0x0130, > + GWTTFC = GWRO + 0x0138, > + GWDCBAC0= GWRO + 0x0194, > + GWDCBAC1= GWRO + 0x0198, > + GWTRC = GWRO + 0x0200, > + GWARIRM = GWRO + 0x0380, > + GWDCC = GWRO + 0x0400, > + > + RRC = CARO + 0x0004, > + RCEC= CARO + 0x0008, > + RCDC= CARO + 0x000C, > + CABPIRM = CARO + 0x0140, > + > + FWPC0 = FWRO + 0x0100, > + FWPBFC = FWRO + 0x4A00, > + FWPBFCSDC = FWRO + 0x4A04, > + > + MPSM
Re: [PATCH v2 1/3] net: mvpp2: Drop PHY_INTERFACE_MODE_SGMII_2500 support
On Tue, Mar 21, 2023 at 7:26 PM Marek Vasut wrote: > > This mode does not seem to be well defined and used anywhere, remove support > for it. > Based on discussion: > - 1000baseX does c37 AN of duplex+pause > - SGMII does AN of duplex+pause+speed, at lower speed bytes are repeated > 10x/100x > - 2500baseX does not do AN, or does very different c73 AN > - SGMII 2500 behavior is unclear > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Ramon Fried > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > V2: Drop SGMII 2500 support, if it becomes required and/or standardized, > this patch can be reverted > --- > drivers/net/mvpp2.c | 53 - > 1 file changed, 53 deletions(-) > > diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c > index 1bad50d344c..c99d52c85d7 100644 > --- a/drivers/net/mvpp2.c > +++ b/drivers/net/mvpp2.c > @@ -2871,7 +2871,6 @@ static void mvpp2_port_mii_set(struct mvpp2_port *port) > > switch (port->phy_interface) { > case PHY_INTERFACE_MODE_SGMII: > - case PHY_INTERFACE_MODE_SGMII_2500: > val |= MVPP2_GMAC_INBAND_AN_MASK; > break; > case PHY_INTERFACE_MODE_1000BASEX: > @@ -2939,7 +2938,6 @@ static void mvpp2_port_loopback_set(struct mvpp2_port > *port) > val &= ~MVPP2_GMAC_GMII_LB_EN_MASK; > > if (port->phy_interface == PHY_INTERFACE_MODE_SGMII || > - port->phy_interface == PHY_INTERFACE_MODE_SGMII_2500 || > port->phy_interface == PHY_INTERFACE_MODE_1000BASEX || > port->phy_interface == PHY_INTERFACE_MODE_2500BASEX) > val |= MVPP2_GMAC_PCS_LB_EN_MASK; > @@ -3027,48 +3025,6 @@ static int gop_bypass_clk_cfg(struct mvpp2_port *port, > int en) > return 0; > } > > -static void gop_gmac_sgmii2_5_cfg(struct mvpp2_port *port) > -{ > - u32 val, thresh; > - > - /* > -* Configure minimal level of the Tx FIFO before the lower part > -* starts to read a packet > -*/ > - thresh = MVPP2_SGMII2_5_TX_FIFO_MIN_TH; > - val = readl(port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG); > - val &= ~MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK; > - val |= MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(thresh); > - writel(val, port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG); > - > - /* Disable bypass of sync module */ > - val = readl(port->base + MVPP2_GMAC_CTRL_4_REG); > - val |= MVPP2_GMAC_CTRL4_SYNC_BYPASS_MASK; > - /* configure DP clock select according to mode */ > - val |= MVPP2_GMAC_CTRL4_DP_CLK_SEL_MASK; > - /* configure QSGMII bypass according to mode */ > - val |= MVPP2_GMAC_CTRL4_QSGMII_BYPASS_ACTIVE_MASK; > - writel(val, port->base + MVPP2_GMAC_CTRL_4_REG); > - > - val = readl(port->base + MVPP2_GMAC_CTRL_0_REG); > - /* > -* Configure GIG MAC to SGMII mode connected to a fiber > -* transceiver > -*/ > - val &= ~MVPP2_GMAC_PORT_TYPE_MASK; > - writel(val, port->base + MVPP2_GMAC_CTRL_0_REG); > - > - /* configure AN 0x9268 */ > - val = MVPP2_GMAC_EN_PCS_AN | > - MVPP2_GMAC_AN_BYPASS_EN | > - MVPP2_GMAC_CONFIG_MII_SPEED | > - MVPP2_GMAC_CONFIG_GMII_SPEED | > - MVPP2_GMAC_FC_ADV_EN| > - MVPP2_GMAC_CONFIG_FULL_DUPLEX | > - MVPP2_GMAC_CHOOSE_SAMPLE_TX_CONFIG; > - writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG); > -} > - > static void gop_gmac_sgmii_cfg(struct mvpp2_port *port) > { > u32 val, thresh; > @@ -3239,9 +3195,6 @@ static int gop_gmac_mode_cfg(struct mvpp2_port *port) > case PHY_INTERFACE_MODE_SGMII: > gop_gmac_sgmii_cfg(port); > break; > - case PHY_INTERFACE_MODE_SGMII_2500: > - gop_gmac_sgmii2_5_cfg(port); > - break; > case PHY_INTERFACE_MODE_1000BASEX: > gop_gmac_1000basex_cfg(port); > break; > @@ -3422,7 +3375,6 @@ static int gop_port_init(struct mvpp2_port *port) > break; > > case PHY_INTERFACE_MODE_SGMII: > - case PHY_INTERFACE_MODE_SGMII_2500: > case PHY_INTERFACE_MODE_1000BASEX: > case PHY_INTERFACE_MODE_2500BASEX: > /* configure PCS */ > @@ -3482,7 +3434,6 @@ static void gop_port_enable(struct mvpp2_port *port, > int enable) > case PHY_IN
Re: [PATCH 3/3] net: share fastboot boot handle logic between transports
On Sat, Apr 1, 2023 at 9:36 AM Simon Glass wrote: > > On Wed, 29 Mar 2023 at 09:31, Dmitrii Merkurev wrote: > > > > Introduce reboot, boot and continue commands support to > > TCP fastboot by moving existing UDP logic into the common module. > > > > Cc: Ying-Chun Liu (PaulLiu) > > Cc: Simon Glass > > Сс: Joe Hershberger > > Сс: Ramon Fried > > Signed-off-by: Dmitrii Merkurev > > --- > > > > drivers/fastboot/fb_common.c | 32 > > include/fastboot.h | 9 + > > net/fastboot_tcp.c | 5 - > > net/fastboot_udp.c | 29 + > > 4 files changed, 46 insertions(+), 29 deletions(-) > > Reviewed-by: Simon Glass Reviewed-by: Ramon Fried
Re: [PATCH 1/3] net: support being a TCP server to unblock TCP fastboot
On Sat, Apr 1, 2023 at 9:36 AM Simon Glass wrote: > > On Wed, 29 Mar 2023 at 09:31, Dmitrii Merkurev wrote: > > > > Make following changes to unblock TCP fastboot support: > > > > 1. Implement being a TCP server support > > 2. Introduce dedicated TCP traffic handler (get rid of UDP signature) > > 3. Ensure seq_num and ack_num are respected in net_send_tcp_packet > > function (make sure existing wget_cmd code is reflected with the fix) > > > > Signed-off-by: Dmitrii Merkurev > > Cc: Ying-Chun Liu (PaulLiu) > > Cc: Simon Glass > > Сс: Joe Hershberger > > Сс: Ramon Fried > > --- > > > > include/net/tcp.h | 16 +-- > > net/tcp.c | 115 +++--- > > net/wget.c| 43 ++++----- > > 3 files changed, 90 insertions(+), 84 deletions(-) > > > Reviewed-by: Simon Glass Reviewed-by: Ramon Fried
Re: [PATCH 1/1] net: replace /* Fall through */
On Sat, Apr 1, 2023 at 10:30 AM Heinrich Schuchardt wrote: > > gcc 12 does not understand /* Fall through */. > Use the fallthrough macro instead. > > Fallthrough at the start of a switch statement makes no sense. > > Signed-off-by: Heinrich Schuchardt > --- > net/net.c | 9 - > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/net/net.c b/net/net.c > index c9a749f6cc..b3199572b7 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -1435,7 +1435,6 @@ void net_process_received_packet(uchar *in_packet, int > len) > static int net_check_prereq(enum proto_t protocol) > { > switch (protocol) { > - /* Fall through */ > #if defined(CONFIG_CMD_PING) > case PING: > if (net_ping_ip.s_addr == 0) { > @@ -1470,7 +1469,7 @@ static int net_check_prereq(enum proto_t protocol) > #if defined(CONFIG_CMD_NFS) > case NFS: > #endif > - /* Fall through */ > + fallthrough; > case TFTPGET: > case TFTPPUT: > if (IS_ENABLED(CONFIG_IPV6) && use_ip6) { > @@ -1484,11 +1483,11 @@ static int net_check_prereq(enum proto_t protocol) > puts("*** ERROR: `serverip' not set\n"); > return 1; > } > + fallthrough; > #ifdefined(CONFIG_CMD_PING) || \ > defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP) > common: > #endif > - /* Fall through */ > > case NETCONS: > case FASTBOOT: > @@ -1503,7 +1502,7 @@ common: > puts("*** ERROR: `ipaddr' not set\n"); > return 1; > } > - /* Fall through */ > + fallthrough; > > #ifdef CONFIG_CMD_RARP > case RARP: > @@ -1534,7 +1533,7 @@ common: > net_start_again(); > return 2; > } > - /* Fall through */ > + fallthrough; > default: > return 0; > } > -- > 2.39.2 > Reviewed-by: Ramon Fried BTW, where is the fallthrough macro defined ?
Re: [PATCH 5/5] net: phy: marvell10g: Adapt Marvell 10G PHY driver from Linux
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut wrote: > > Pull Marvell 10G PHY driver from Linux 6.1.y as of commit > d6d29292640d3 ("net: phy: marvell10g: select host interface configuration") > and heavily adapt to match U-Boot PHY framework. Support for > hwmon is removed as is much other functionality which could > not be tested, this results in much simpler driver which can > only bring the PHY up and set MAC type. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Nate Drude > Cc: Ramon Fried > Cc: Simon Glass > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > drivers/net/phy/Kconfig | 5 + > drivers/net/phy/Makefile | 1 + > drivers/net/phy/marvell10g.c | 605 +++ > 3 files changed, 611 insertions(+) > create mode 100644 drivers/net/phy/marvell10g.c > > diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig > index 6806e3c0903..24158776f52 100644 > --- a/drivers/net/phy/Kconfig > +++ b/drivers/net/phy/Kconfig > @@ -174,6 +174,11 @@ config PHY_LXT > config PHY_MARVELL > bool "Marvell Ethernet PHYs support" > > +config PHY_MARVELL_10G > + bool "Marvell Alaska 10Gbit PHYs" > + help > + Support for the Marvell Alaska MV88X3310 and compatible PHYs. > + > config PHY_MESON_GXL > bool "Amlogic Meson GXL Internal PHY support" > > diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile > index 963d96e2bcb..85d17f109cd 100644 > --- a/drivers/net/phy/Makefile > +++ b/drivers/net/phy/Makefile > @@ -20,6 +20,7 @@ obj-$(CONFIG_PHY_DAVICOM) += davicom.o > obj-$(CONFIG_PHY_ET1011C) += et1011c.o > obj-$(CONFIG_PHY_LXT) += lxt.o > obj-$(CONFIG_PHY_MARVELL) += marvell.o > +obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o > obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o > obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o > obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o > diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c > new file mode 100644 > index 000..9e64672f5ca > --- /dev/null > +++ b/drivers/net/phy/marvell10g.c > @@ -0,0 +1,605 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Marvell 10G 88x3310 PHY driver > + * > + * Based upon the ID registers, this PHY appears to be a mixture of IPs > + * from two different companies. > + * > + * There appears to be several different data paths through the PHY which > + * are automatically managed by the PHY. The following has been determined > + * via observation and experimentation for a setup using single-lane Serdes: > + * > + * SGMII PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for <= 1G) > + * 10GBASE-KR PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for 10G) > + * 10GBASE-KR PHYXS -- BASE-R PCS -- Fiber > + * > + * With XAUI, observation shows: > + * > + *XAUI PHYXS -- > + * > + * and no switching of the host interface mode occurs. > + * > + * If both the fiber and copper ports are connected, the first to gain > + * link takes priority and the other port is completely locked out. > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MV_PHY_ALASKA_NBT_QUIRK_MASK 0xfffe > +#define MV_PHY_ALASKA_NBT_QUIRK_REV(MARVELL_PHY_ID_88X3310 | 0xa) > + > +#define MV_VERSION(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) > + > +enum { > + MV_PMA_FW_VER0 = 0xc011, > + MV_PMA_FW_VER1 = 0xc012, > + MV_PMA_21X0_PORT_CTRL = 0xc04a, > + MV_PMA_21X0_PORT_CTRL_SWRST = BIT(15), > + MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK = 0x7, > + MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII = 0x0, > + MV_PMA_2180_PORT_CTRL_MACTYPE_DXGMII= 0x1, > + MV_PMA_2180_PORT_CTRL_MACTYPE_QXGMII= 0x2, > + MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER = 0x4, > + MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN = 0x5, > + MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH = 0x6, > + MV_PMA_BOOT = 0xc050, > + MV_PMA_BOOT_FATAL = BIT(0), > + > + MV_PCS_BASE_T = 0x, > + MV_PCS_BASE_R = 0x1000, > + MV_PCS_1000BASEX= 0x2000, > + > + MV_PCS_CSCR1
Re: [PATCH 4/5] net: phy: Add MDIO PCS 2.5G and 5G speed macros from Linux
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut wrote: > > Add MDIO PCS 2.5G and 5G speed macros from Linux 5.1.y as of commit > 7fd8afa8933a0 ("net: phy: Add generic support for 2.5GBaseT and 5GBaseT") > This is used by the upcoming Marvell 10G PHY driver. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Nate Drude > Cc: Ramon Fried > Cc: Simon Glass > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > include/linux/mdio.h | 18 ++ > 1 file changed, 18 insertions(+) > > diff --git a/include/linux/mdio.h b/include/linux/mdio.h > index 6e821d906fb..b7c845155e4 100644 > --- a/include/linux/mdio.h > +++ b/include/linux/mdio.h > @@ -44,6 +44,7 @@ > #define MDIO_AN_ADVERTISE 16 /* AN advertising (base page) */ > #define MDIO_AN_LPA19 /* AN LP abilities (base page) */ > #define MDIO_PCS_EEE_ABLE 20 /* EEE Capability register */ > +#define MDIO_PMA_NG_EXTABLE21 /* 2.5G/5G PMA/PMD extended ability */ > #define MDIO_PCS_EEE_WK_ERR22 /* EEE wake error counter */ > #define MDIO_PHYXS_LNSTAT 24 /* PHY XGXS lane state */ > #define MDIO_AN_EEE_ADV60 /* EEE advertisement */ > @@ -91,6 +92,10 @@ > #define MDIO_CTRL1_SPEED10G(MDIO_CTRL1_SPEEDSELEXT | 0x00) > /* 10PASS-TS/2BASE-TL */ > #define MDIO_CTRL1_SPEED10P2B (MDIO_CTRL1_SPEEDSELEXT | 0x04) > +/* 2.5 Gb/s */ > +#define MDIO_CTRL1_SPEED2_5G (MDIO_CTRL1_SPEEDSELEXT | 0x18) > +/* 5 Gb/s */ > +#define MDIO_CTRL1_SPEED5G (MDIO_CTRL1_SPEEDSELEXT | 0x1c) > > /* Status register 1. */ > #define MDIO_STAT1_LPOWERABLE 0x0002 /* Low-power ability */ > @@ -111,6 +116,8 @@ > #define MDIO_PMA_SPEED_100 0x0020 /* 100M capable */ > #define MDIO_PMA_SPEED_10 0x0040 /* 10M capable */ > #define MDIO_PCS_SPEED_10P2B 0x0002 /* 10PASS-TS/2BASE-TL capable > */ > +#define MDIO_PCS_SPEED_2_5G0x0040 /* 2.5G capable */ > +#define MDIO_PCS_SPEED_5G 0x0080 /* 5G capable */ > > /* Device present registers. */ > #define MDIO_DEVS_PRESENT(devad) (1 << (devad)) > @@ -150,6 +157,8 @@ > #define MDIO_PMA_CTRL2_1000BKX 0x000d /* 1000BASE-KX type */ > #define MDIO_PMA_CTRL2_100BTX 0x000e /* 100BASE-TX type */ > #define MDIO_PMA_CTRL2_10BT0x000f /* 10BASE-T type */ > +#define MDIO_PMA_CTRL2_2_5GBT 0x0030 /* 2.5GBaseT type */ > +#define MDIO_PMA_CTRL2_5GBT0x0031 /* 5GBaseT type */ > #define MDIO_PCS_CTRL2_TYPE0x0003 /* PCS type selection */ > #define MDIO_PCS_CTRL2_10GBR 0x /* 10GBASE-R type */ > #define MDIO_PCS_CTRL2_10GBX 0x0001 /* 10GBASE-X type */ > @@ -203,6 +212,7 @@ > #define MDIO_PMA_EXTABLE_1000BKX 0x0040 /* 1000BASE-KX ability */ > #define MDIO_PMA_EXTABLE_100BTX0x0080 /* 100BASE-TX ability > */ > #define MDIO_PMA_EXTABLE_10BT 0x0100 /* 10BASE-T ability */ > +#define MDIO_PMA_EXTABLE_NBT 0x4000 /* 2.5/5GBASE-T ability */ > > /* PHY XGXS lane state register. */ > #define MDIO_PHYXS_LNSTAT_SYNC00x0001 > @@ -239,9 +249,13 @@ > #define MDIO_PCS_10GBRT_STAT2_BER 0x3f00 > > /* AN 10GBASE-T control register. */ > +#define MDIO_AN_10GBT_CTRL_ADV2_5G 0x0080 /* Advertise 2.5GBASE-T */ > +#define MDIO_AN_10GBT_CTRL_ADV5G 0x0100 /* Advertise 5GBASE-T */ > #define MDIO_AN_10GBT_CTRL_ADV10G 0x1000 /* Advertise 10GBASE-T */ > > /* AN 10GBASE-T status register. */ > +#define MDIO_AN_10GBT_STAT_LP2_5G 0x0020 /* LP is 2.5GBT capable */ > +#define MDIO_AN_10GBT_STAT_LP5G0x0040 /* LP is 5GBT capable > */ > #define MDIO_AN_10GBT_STAT_LPTRR 0x0200 /* LP training reset req. */ > #define MDIO_AN_10GBT_STAT_LPLTABLE0x0400 /* LP loop timing ability */ > #define MDIO_AN_10GBT_STAT_LP10G 0x0800 /* LP is 10GBT capable */ > @@ -270,6 +284,10 @@ > #define MDIO_EEE_10GKX40x0020 /* 10G KX4 EEE cap */ > #define MDIO_EEE_10GKR 0x0040 /* 10G KR EEE cap */ > > +/* 2.5G/5G Extended abilities register. */ > +#define MDIO_PMA_NG_EXTABLE_2_5GBT 0x0001 /* 2.5GBASET ability */ > +#define MDIO_PMA_NG_EXTABLE_5GBT 0x0002 /* 5GBASET ability */ > + > /* LASI RX_ALARM control/status registers. */ > #define MDIO_PMA_LASI_RX_PHYXSLFLT 0x0001 /* PHY XS RX local fault */ > #define MDIO_PMA_LASI_RX_PCSLFLT 0x0008 /* PCS RX local fault */ > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 3/5] net: phy: Add phy_read_mmd_poll_timeout() from Linux
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut wrote: > > Add phy_read_mmd_poll_timeout() from Linux 5.7.y as of commit > bd971ff0b7392 ("net: phy: introduce phy_read_mmd_poll_timeout macro") > This is used by the upcoming Marvell 10G PHY driver. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Nate Drude > Cc: Ramon Fried > Cc: Simon Glass > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > include/phy.h | 31 +++ > 1 file changed, 31 insertions(+) > > diff --git a/include/phy.h b/include/phy.h > index 34675b2c9c0..a837fed7235 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -282,6 +282,37 @@ static inline ofnode phy_get_ofnode(struct phy_device > *phydev) > return dev_ofnode(phydev->dev); > } > > +/** > + * phy_read_mmd_poll_timeout - Periodically poll a PHY register until a > + * condition is met or a timeout occurs > + * > + * @phydev: The phy_device struct > + * @devaddr: The MMD to read from > + * @regnum: The register on the MMD to read > + * @val: Variable to read the register into > + * @cond: Break condition (usually involving @val) > + * @sleep_us: Maximum time to sleep between reads in us (0 > + *tight-loops). Should be less than ~20ms since usleep_range > + *is used (see Documentation/timers/timers-howto.rst). > + * @timeout_us: Timeout in us, 0 means never timeout > + * @sleep_before_read: if it is true, sleep @sleep_us before read. > + * Returns 0 on success and -ETIMEDOUT upon a timeout. In either > + * case, the last read value at @args is stored in @val. Must not > + * be called from atomic context if sleep_us or timeout_us are used. > + */ > +#define phy_read_mmd_poll_timeout(phydev, devaddr, regnum, val, cond, \ > + sleep_us, timeout_us, sleep_before_read) \ > +({ \ > + int __ret = read_poll_timeout(phy_read_mmd, val, (cond) || val < 0, \ > + sleep_us, timeout_us, \ > + phydev, devaddr, regnum); \ > + if (val < 0) \ > + __ret = val; \ > + if (__ret) \ > + dev_err(phydev->dev, "%s failed: %d\n", __func__, __ret); \ > + __ret; \ > +}) > + > int phy_read(struct phy_device *phydev, int devad, int regnum); > int phy_write(struct phy_device *phydev, int devad, int regnum, u16 val); > void phy_mmd_start_indirect(struct phy_device *phydev, int devad, int > regnum); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 2/5] net: phy: Add phy_modify_mmd() and phy_modify_mmd_changed() from Linux
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut wrote: > > Add phy_modify_mmd()/phy_modify_mmd_changed() from Linux 5.1.y as of commit > b8554d4f7288f ("net: phy: add register modifying helpers returning 1 on > change") > This is used by the upcoming Marvell 10G PHY driver. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Nate Drude > Cc: Ramon Fried > Cc: Simon Glass > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > drivers/net/phy/phy.c | 54 +++ > include/phy.h | 4 > 2 files changed, 58 insertions(+) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index f720d0a7920..0eeb0cb3a85 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -1158,6 +1158,60 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int > devad, u32 regnum, u16 val > return 0; > } > > +/** > + * phy_modify_mmd_changed - Function for modifying a register on MMD > + * @phydev: the phy_device struct > + * @devad: the MMD containing register to modify > + * @regnum: register number to modify > + * @mask: bit mask of bits to clear > + * @set: new value of bits set in mask to write to @regnum > + * > + * NOTE: MUST NOT be called from interrupt context, > + * because the bus read/write functions may wait for an interrupt > + * to conclude the operation. > + * > + * Returns negative errno, 0 if there was no change, and 1 in case of change > + */ > +int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum, > + u16 mask, u16 set) > +{ > + int new, ret; > + > + ret = phy_read_mmd(phydev, devad, regnum); > + if (ret < 0) > + return ret; > + > + new = (ret & ~mask) | set; > + if (new == ret) > + return 0; > + > + ret = phy_write_mmd(phydev, devad, regnum, new); > + > + return ret < 0 ? ret : 1; > +} > + > +/** > + * phy_modify_mmd - Convenience function for modifying a register on MMD > + * @phydev: the phy_device struct > + * @devad: the MMD containing register to modify > + * @regnum: register number to modify > + * @mask: bit mask of bits to clear > + * @set: new value of bits set in mask to write to @regnum > + * > + * NOTE: MUST NOT be called from interrupt context, > + * because the bus read/write functions may wait for an interrupt > + * to conclude the operation. > + */ > +int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, > + u16 mask, u16 set) > +{ > + int ret; > + > + ret = phy_modify_mmd_changed(phydev, devad, regnum, mask, set); > + > + return ret < 0 ? ret : 0; > +} > + > bool phy_interface_is_ncsi(void) > { > #ifdef CONFIG_PHY_NCSI > diff --git a/include/phy.h b/include/phy.h > index 4a9de461152..34675b2c9c0 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -289,6 +289,10 @@ int phy_read_mmd(struct phy_device *phydev, int devad, > int regnum); > int phy_write_mmd(struct phy_device *phydev, int devad, int regnum, u16 val); > int phy_set_bits_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 > val); > int phy_clear_bits_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 > val); > +int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum, > + u16 mask, u16 set); > +int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum, > + u16 mask, u16 set); > > int phy_startup(struct phy_device *phydev); > int phy_config(struct phy_device *phydev); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 1/5] net: phy: marvell: Import and use marvell_phy.h from Linux
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut wrote: > > Import marvell_phy.h from Linux 5.14.y as of commit > a5de4be06 ("net: phy: marvell10g: fix differentiation of 88X3310 from > 88X3340") > and use it in marvell PHY driver instead of current ad-hoc macros. > Two of the PHY IDs are unknown to Linux, 88E1149S and 88E1680, for > those two, only sync the length of the hexadecimal number to 8 digits. > > No functional change. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Nate Drude > Cc: Ramon Fried > Cc: Simon Glass > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > drivers/net/phy/marvell.c | 45 +++-- > include/marvell_phy.h | 47 +++ > 2 files changed, 70 insertions(+), 22 deletions(-) > create mode 100644 include/marvell_phy.h > > diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c > index 8992be6e89e..0a90f710dfe 100644 > --- a/drivers/net/phy/marvell.c > +++ b/drivers/net/phy/marvell.c > @@ -7,6 +7,7 @@ > */ > #include > #include > +#include > #include > #include > #include > @@ -695,8 +696,8 @@ static int m88e1680_config(struct phy_device *phydev) > > U_BOOT_PHY_DRIVER(m88e1011s) = { > .name = "Marvell 88E1011S", > - .uid = 0x1410c60, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E1101, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1011s_config, > .startup = &m88e1011s_startup, > @@ -705,8 +706,8 @@ U_BOOT_PHY_DRIVER(m88e1011s) = { > > U_BOOT_PHY_DRIVER(m88es) = { > .name = "Marvell 88ES", > - .uid = 0x1410cc0, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88es_config, > .startup = &m88e1011s_startup, > @@ -715,8 +716,8 @@ U_BOOT_PHY_DRIVER(m88es) = { > > U_BOOT_PHY_DRIVER(m88e1118) = { > .name = "Marvell 88E1118", > - .uid = 0x1410e10, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E1118, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1118_config, > .startup = &m88e1118_startup, > @@ -725,8 +726,8 @@ U_BOOT_PHY_DRIVER(m88e1118) = { > > U_BOOT_PHY_DRIVER(m88e1118r) = { > .name = "Marvell 88E1118R", > - .uid = 0x1410e40, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E1116R, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1118_config, > .startup = &m88e1118_startup, > @@ -735,8 +736,8 @@ U_BOOT_PHY_DRIVER(m88e1118r) = { > > U_BOOT_PHY_DRIVER(m88e1121r) = { > .name = "Marvell 88E1121R", > - .uid = 0x1410cb0, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E1121R, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1121_config, > .startup = &genphy_startup, > @@ -745,8 +746,8 @@ U_BOOT_PHY_DRIVER(m88e1121r) = { > > U_BOOT_PHY_DRIVER(m88e1145) = { > .name = "Marvell 88E1145", > - .uid = 0x1410cd0, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E1145, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1145_config, > .startup = &m88e1145_startup, > @@ -755,8 +756,8 @@ U_BOOT_PHY_DRIVER(m88e1145) = { > > U_BOOT_PHY_DRIVER(m88e1149s) = { > .name = "Marvell 88E1149S", > - .uid = 0x1410ca0, > - .mask = 0xff0, > + .uid = 0x01410ca0, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1149_config, > .startup = &m88e1011s_startup, > @@ -765,8 +766,8 @@ U_BOOT_PHY_DRIVER(m88e1149s) = { > > U_BOOT_PHY_DRIVER(m88e1240) = { > .name = "Marvell 88E1240", > - .uid = 0x1410e30, > - .mask = 0xff0, > + .uid = MARVELL_PHY_ID_88E1240, > + .mask = MARVELL_PHY_ID_MASK, > .features = PHY_GBIT_FEATURES, > .config = &m88e1240_config, > .startup = &m88e1011s_startup, > @@ -775,8 +776,8 @@ U_BOOT_PHY_DRIVER(m88e1240) = { > > U_BOOT_PHY_DRIVE
Re: [PATCH 3/3] net: phy: Synchronize PHY interface modes with Linux
On Sun, Mar 19, 2023 at 7:07 PM Marek Vasut wrote: > > Synchronize PHY interface modes with Linux next 6.2.y commit: > 0194b64578e90 ("net: phy: improve phy_read_poll_timeout") > > Retain LX2160A/LX2162A PHY modes as those are not yet supported > by the Linux kernel, but isolate those with ifdeffery. > > Isolate NCSI which are also not supported by Linux kernel. Note > that the ifdeffery cannot be avoided with IS_ENABLED() here due > to compilation of the entire conditional, which would fail in > case NCSI symbols are not available. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Ramon Fried > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > drivers/net/phy/phy.c | 4 +++ > include/phy_interface.h | 68 + > 2 files changed, 53 insertions(+), 19 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 9b0e497f223..f720d0a7920 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -1160,7 +1160,11 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int > devad, u32 regnum, u16 val > > bool phy_interface_is_ncsi(void) > { > +#ifdef CONFIG_PHY_NCSI > struct eth_pdata *pdata = dev_get_plat(eth_get_dev()); > > return pdata->phy_interface == PHY_INTERFACE_MODE_NCSI; > +#else > + return 0; > +#endif > } > diff --git a/include/phy_interface.h b/include/phy_interface.h > index 52af7e612b6..31be3228c7c 100644 > --- a/include/phy_interface.h > +++ b/include/phy_interface.h > @@ -14,65 +14,95 @@ > > typedef enum { > PHY_INTERFACE_MODE_NA, /* don't touch */ > + PHY_INTERFACE_MODE_INTERNAL, > PHY_INTERFACE_MODE_MII, > PHY_INTERFACE_MODE_GMII, > PHY_INTERFACE_MODE_SGMII, > - PHY_INTERFACE_MODE_SGMII_2500, > - PHY_INTERFACE_MODE_QSGMII, > PHY_INTERFACE_MODE_TBI, > + PHY_INTERFACE_MODE_REVMII, > PHY_INTERFACE_MODE_RMII, > + PHY_INTERFACE_MODE_REVRMII, > PHY_INTERFACE_MODE_RGMII, > PHY_INTERFACE_MODE_RGMII_ID, > PHY_INTERFACE_MODE_RGMII_RXID, > PHY_INTERFACE_MODE_RGMII_TXID, > PHY_INTERFACE_MODE_RTBI, > + PHY_INTERFACE_MODE_SMII, > + PHY_INTERFACE_MODE_XGMII, > + PHY_INTERFACE_MODE_XLGMII, > + PHY_INTERFACE_MODE_MOCA, > + PHY_INTERFACE_MODE_QSGMII, > + PHY_INTERFACE_MODE_TRGMII, > + PHY_INTERFACE_MODE_100BASEX, > PHY_INTERFACE_MODE_1000BASEX, > PHY_INTERFACE_MODE_2500BASEX, > - PHY_INTERFACE_MODE_XGMII, > - PHY_INTERFACE_MODE_XAUI, > - PHY_INTERFACE_MODE_RXAUI, > PHY_INTERFACE_MODE_5GBASER, > - PHY_INTERFACE_MODE_SFI, > - PHY_INTERFACE_MODE_INTERNAL, > + PHY_INTERFACE_MODE_RXAUI, > + PHY_INTERFACE_MODE_XAUI, > + /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */ > + PHY_INTERFACE_MODE_10GBASER, > + PHY_INTERFACE_MODE_25GBASER, > + PHY_INTERFACE_MODE_USXGMII, > + /* 10GBASE-KR - with Clause 73 AN */ > + PHY_INTERFACE_MODE_10GKR, > + PHY_INTERFACE_MODE_QUSGMII, > + PHY_INTERFACE_MODE_1000BASEKX, > +#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A) > + /* LX2160A SERDES modes */ > PHY_INTERFACE_MODE_25G_AUI, > PHY_INTERFACE_MODE_XLAUI, > PHY_INTERFACE_MODE_CAUI2, > PHY_INTERFACE_MODE_CAUI4, > +#endif > +#if defined(CONFIG_PHY_NCSI) > PHY_INTERFACE_MODE_NCSI, > - PHY_INTERFACE_MODE_10GBASER, > - PHY_INTERFACE_MODE_USXGMII, > +#endif > PHY_INTERFACE_MODE_MAX, > } phy_interface_t; > > static const char * const phy_interface_strings[] = { > - [PHY_INTERFACE_MODE_NA] = "", > + [PHY_INTERFACE_MODE_NA] = "", > + [PHY_INTERFACE_MODE_INTERNAL] = "internal", > [PHY_INTERFACE_MODE_MII]= "mii", > [PHY_INTERFACE_MODE_GMII] = "gmii", > [PHY_INTERFACE_MODE_SGMII] = "sgmii", > - [PHY_INTERFACE_MODE_SGMII_2500] = "sgmii-2500", > - [PHY_INTERFACE_MODE_QSGMII] = "qsgmii", > [PHY_INTERFACE_MODE_TBI]= "tbi", > + [PHY_INTERFACE_MODE_REVMII] = "rev-mii", > [PHY_INTERFACE_MODE_RMII] = "rmii", > + [PHY_INTERFACE_MODE_REVRMII]
Re: [PATCH 2/3] net: mvpp2: Replace PHY_INTERFACE_MODE_SFI with 5GBASER/10GBASER/XAUI
On Sun, Mar 19, 2023 at 7:07 PM Marek Vasut wrote: > > Replace PHY_INTERFACE_MODE_SFI with PHY_INTERFACE_MODE_5GBASER, > PHY_INTERFACE_MODE_10GBASER and PHY_INTERFACE_MODE_XAUI to match > Linux PHY interface modes. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Marek Behún" > Cc: Joe Hershberger > Cc: Marek Vasut > Cc: Ramon Fried > Cc: Stefan Roese > Cc: Tim Harvey > Cc: Vladimir Oltean > --- > drivers/net/mvpp2.c | 8 ++-- > include/phy_interface.h | 2 ++ > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c > index 71347b7e69c..096b8a35853 100644 > --- a/drivers/net/mvpp2.c > +++ b/drivers/net/mvpp2.c > @@ -3438,7 +3438,9 @@ static int gop_port_init(struct mvpp2_port *port) > gop_gmac_reset(port, 0); > break; > > - case PHY_INTERFACE_MODE_SFI: > + case PHY_INTERFACE_MODE_10GBASER: > + case PHY_INTERFACE_MODE_5GBASER: > + case PHY_INTERFACE_MODE_XAUI: > num_of_act_lanes = 2; > mac_num = 0; > /* configure PCS */ > @@ -3489,7 +3491,9 @@ static void gop_port_enable(struct mvpp2_port *port, > int enable) > mvpp2_port_disable(port); > break; > > - case PHY_INTERFACE_MODE_SFI: > + case PHY_INTERFACE_MODE_10GBASER: > + case PHY_INTERFACE_MODE_5GBASER: > + case PHY_INTERFACE_MODE_XAUI: > gop_xlg_mac_port_enable(port, enable); > > break; > diff --git a/include/phy_interface.h b/include/phy_interface.h > index fed3357b9a2..52af7e612b6 100644 > --- a/include/phy_interface.h > +++ b/include/phy_interface.h > @@ -31,6 +31,7 @@ typedef enum { > PHY_INTERFACE_MODE_XGMII, > PHY_INTERFACE_MODE_XAUI, > PHY_INTERFACE_MODE_RXAUI, > + PHY_INTERFACE_MODE_5GBASER, > PHY_INTERFACE_MODE_SFI, > PHY_INTERFACE_MODE_INTERNAL, > PHY_INTERFACE_MODE_25G_AUI, > @@ -62,6 +63,7 @@ static const char * const phy_interface_strings[] = { > [PHY_INTERFACE_MODE_XGMII] = "xgmii", > [PHY_INTERFACE_MODE_XAUI] = "xaui", > [PHY_INTERFACE_MODE_RXAUI] = "rxaui", > + [PHY_INTERFACE_MODE_5GBASER] = "5gbase-r", > [PHY_INTERFACE_MODE_SFI]= "sfi", > [PHY_INTERFACE_MODE_INTERNAL] = "internal", > [PHY_INTERFACE_MODE_25G_AUI]= "25g-aui", > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 41/41] net: phy: Only call phy_init() on systems needing manual relocation
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > The phy_init() is now used only to perform manual relocation of PHY > driver callbacks. Wrap it in ifdeffery and only call it on systems > which still require manual relocation, i.e. m68k . > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c | 4 ++-- > net/eth_common.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 61603f28179..9b0e497f223 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -463,9 +463,9 @@ U_BOOT_PHY_DRIVER(genphy) = { > .shutdown = genphy_shutdown, > }; > > +#ifdef CONFIG_NEEDS_MANUAL_RELOC > int phy_init(void) > { > -#ifdef CONFIG_NEEDS_MANUAL_RELOC > const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver); > struct phy_driver *drv, *ll_entry; > > @@ -489,10 +489,10 @@ int phy_init(void) > if (drv->write_mmd) > drv->write_mmd += gd->reloc_off; > } > -#endif > > return 0; > } > +#endif > > int phy_set_supported(struct phy_device *phydev, u32 max_speed) > { > diff --git a/net/eth_common.c b/net/eth_common.c > index 82d527abba6..c94a7ba6ae7 100644 > --- a/net/eth_common.c > +++ b/net/eth_common.c > @@ -37,7 +37,7 @@ void eth_common_init(void) > miiphy_init(); > #endif > > -#ifdef CONFIG_PHYLIB > +#if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_PHYLIB) > phy_init(); > #endif > #endif > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 40/41] net: phy: Re-inline phy_drv_reloc()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Wrap phy_drv_reloc() back into phy_init() to reduce ifdeffery, > since phy_drv_reloc() is now called only from one call site. > No functional change. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c | 42 ++ > 1 file changed, 18 insertions(+), 24 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 15da9a80de2..61603f28179 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -463,28 +463,6 @@ U_BOOT_PHY_DRIVER(genphy) = { > .shutdown = genphy_shutdown, > }; > > -#ifdef CONFIG_NEEDS_MANUAL_RELOC > -static void phy_drv_reloc(struct phy_driver *drv) > -{ > - if (drv->probe) > - drv->probe += gd->reloc_off; > - if (drv->config) > - drv->config += gd->reloc_off; > - if (drv->startup) > - drv->startup += gd->reloc_off; > - if (drv->shutdown) > - drv->shutdown += gd->reloc_off; > - if (drv->readext) > - drv->readext += gd->reloc_off; > - if (drv->writeext) > - drv->writeext += gd->reloc_off; > - if (drv->read_mmd) > - drv->read_mmd += gd->reloc_off; > - if (drv->write_mmd) > - drv->write_mmd += gd->reloc_off; > -} > -#endif > - > int phy_init(void) > { > #ifdef CONFIG_NEEDS_MANUAL_RELOC > @@ -493,8 +471,24 @@ int phy_init(void) > > /* Perform manual relocation on linker list based PHY drivers */ > ll_entry = ll_entry_start(struct phy_driver, phy_driver); > - for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++) > - phy_drv_reloc(drv); > + for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++) { > + if (drv->probe) > + drv->probe += gd->reloc_off; > + if (drv->config) > + drv->config += gd->reloc_off; > + if (drv->startup) > + drv->startup += gd->reloc_off; > + if (drv->shutdown) > + drv->shutdown += gd->reloc_off; > + if (drv->readext) > + drv->readext += gd->reloc_off; > + if (drv->writeext) > + drv->writeext += gd->reloc_off; > + if (drv->read_mmd) > + drv->read_mmd += gd->reloc_off; > + if (drv->write_mmd) > + drv->write_mmd += gd->reloc_off; > + } > #endif > > return 0; > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 39/41] net: phy: Drop unused phy_register()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > This function is no longer used, drop it. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c | 8 > include/phy.h | 1 - > 2 files changed, 9 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index f4aa1f664cb..15da9a80de2 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -500,14 +500,6 @@ int phy_init(void) > return 0; > } > > -int phy_register(struct phy_driver *drv) > -{ > -#ifdef CONFIG_NEEDS_MANUAL_RELOC > - phy_drv_reloc(drv); > -#endif > - return 0; > -} > - > int phy_set_supported(struct phy_device *phydev, u32 max_speed) > { > /* The default values for phydev->supported are provided by the PHY > diff --git a/include/phy.h b/include/phy.h > index 5e8ae5e29aa..4a9de461152 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -293,7 +293,6 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int > devad, u32 regnum, u16 val > int phy_startup(struct phy_device *phydev); > int phy_config(struct phy_device *phydev); > int phy_shutdown(struct phy_device *phydev); > -int phy_register(struct phy_driver *drv); > int phy_set_supported(struct phy_device *phydev, u32 max_speed); > int phy_modify(struct phy_device *phydev, int devad, int regnum, u16 mask, >u16 set); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 38/41] net: phy: Drop static phy_drivers list
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > The static phy_drivers list is superseded by linker list of struct phy_drivers > now that all drivers have been converted to the later. Drop the phy_drivers > list as well as list_head from struct phy_driver. > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c | 26 ++ > include/phy.h | 2 -- > 2 files changed, 2 insertions(+), 26 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index bd9c576f459..f4aa1f664cb 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -463,8 +463,6 @@ U_BOOT_PHY_DRIVER(genphy) = { > .shutdown = genphy_shutdown, > }; > > -static LIST_HEAD(phy_drivers); > - > #ifdef CONFIG_NEEDS_MANUAL_RELOC > static void phy_drv_reloc(struct phy_driver *drv) > { > @@ -493,16 +491,6 @@ int phy_init(void) > const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver); > struct phy_driver *drv, *ll_entry; > > - /* > -* The pointers inside phy_drivers also needs to be updated incase of > -* manual reloc, without which these points to some invalid > -* pre reloc address and leads to invalid accesses, hangs. > -*/ > - struct list_head *head = &phy_drivers; > - > - head->next = (void *)head->next + gd->reloc_off; > - head->prev = (void *)head->prev + gd->reloc_off; > - > /* Perform manual relocation on linker list based PHY drivers */ > ll_entry = ll_entry_start(struct phy_driver, phy_driver); > for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++) > @@ -514,9 +502,6 @@ int phy_init(void) > > int phy_register(struct phy_driver *drv) > { > - INIT_LIST_HEAD(&drv->list); > - list_add_tail(&drv->list, &phy_drivers); > - > #ifdef CONFIG_NEEDS_MANUAL_RELOC > phy_drv_reloc(drv); > #endif > @@ -575,16 +560,9 @@ static struct phy_driver *generic_for_phy(struct > phy_device *phydev) > static struct phy_driver *get_phy_driver(struct phy_device *phydev) > { > const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver); > - struct phy_driver *ll_entry; > - struct list_head *entry; > int phy_id = phydev->phy_id; > - struct phy_driver *drv = NULL; > - > - list_for_each(entry, &phy_drivers) { > - drv = list_entry(entry, struct phy_driver, list); > - if ((drv->uid & drv->mask) == (phy_id & drv->mask)) > - return drv; > - } > + struct phy_driver *ll_entry; > + struct phy_driver *drv; > > ll_entry = ll_entry_start(struct phy_driver, phy_driver); > for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++) > diff --git a/include/phy.h b/include/phy.h > index 5f4967cb150..5e8ae5e29aa 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -125,8 +125,6 @@ struct phy_driver { > int (*write_mmd)(struct phy_device *phydev, int devad, int reg, > u16 val); > > - struct list_head list; > - > /* driver private data */ > ulong data; > }; > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 37/41] net: phy: gen10g: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/generic_10g.c | 2 +- > drivers/net/phy/phy.c | 2 +- > include/phy.h | 4 > 3 files changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/phy/generic_10g.c b/drivers/net/phy/generic_10g.c > index b4384e1f781..34ac51ea070 100644 > --- a/drivers/net/phy/generic_10g.c > +++ b/drivers/net/phy/generic_10g.c > @@ -80,7 +80,7 @@ int gen10g_config(struct phy_device *phydev) > return gen10g_discover_mmds(phydev); > } > > -struct phy_driver gen10g_driver = { > +U_BOOT_PHY_DRIVER(gen10g) = { > .uid= 0x, > .mask = 0x, > .name = "Generic 10G PHY", > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index b1e9861c6f3..bd9c576f459 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -566,7 +566,7 @@ static struct phy_driver *generic_for_phy(struct > phy_device *phydev) > { > #ifdef CONFIG_PHYLIB_10G > if (phydev->is_c45) > - return &gen10g_driver; > + return ll_entry_get(struct phy_driver, gen10g, phy_driver); > #endif > > return ll_entry_get(struct phy_driver, genphy, phy_driver); > diff --git a/include/phy.h b/include/phy.h > index df2586f89ea..5f4967cb150 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -173,10 +173,6 @@ struct fixed_link { > int asym_pause; > }; > > -#ifdef CONFIG_PHYLIB_10G > -extern struct phy_driver gen10g_driver; > -#endif > - > /** > * phy_init() - Initializes the PHY drivers > * This function registers all available PHY drivers > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 35/41] net: phy: xilinx-gmii2rgmii: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c | 3 --- > drivers/net/phy/xilinx_gmii2rgmii.c | 9 + > include/phy.h | 2 -- > 3 files changed, 1 insertion(+), 13 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 69db79f79e0..9d5d1494616 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_XILINX_GMII2RGMII > - phy_xilinx_gmii2rgmii_init(); > -#endif > genphy_init(); > > return 0; > diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c > b/drivers/net/phy/xilinx_gmii2rgmii.c > index 73762839565..0b7436a7e1e 100644 > --- a/drivers/net/phy/xilinx_gmii2rgmii.c > +++ b/drivers/net/phy/xilinx_gmii2rgmii.c > @@ -124,7 +124,7 @@ static int xilinxgmiitorgmii_probe(struct phy_device > *phydev) > return 0; > } > > -static struct phy_driver gmii2rgmii_driver = { > +U_BOOT_PHY_DRIVER(gmii2rgmii) = { > .name = "XILINX GMII2RGMII", > .uid = PHY_GMII2RGMII_ID, > .mask = 0x, > @@ -135,10 +135,3 @@ static struct phy_driver gmii2rgmii_driver = { > .writeext = xilinxgmiitorgmii_extwrite, > .readext = xilinxgmiitorgmii_extread, > }; > - > -int phy_xilinx_gmii2rgmii_init(void) > -{ > - phy_register(&gmii2rgmii_driver); > - > - return 0; > -} > diff --git a/include/phy.h b/include/phy.h > index 001c998db47..df2586f89ea 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -315,8 +315,6 @@ int gen10g_startup(struct phy_device *phydev); > int gen10g_shutdown(struct phy_device *phydev); > int gen10g_discover_mmds(struct phy_device *phydev); > > -int phy_xilinx_gmii2rgmii_init(void); > - > /** > * U_BOOT_PHY_DRIVER() - Declare a new U-Boot driver > * @__name: name of the driver > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 34/41] net: phy: ncsi: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/ncsi.c | 8 +--- > drivers/net/phy/phy.c | 3 --- > include/phy.h | 1 - > 3 files changed, 1 insertion(+), 11 deletions(-) > > diff --git a/drivers/net/phy/ncsi.c b/drivers/net/phy/ncsi.c > index bb7ecebed38..eb3fd65bb47 100644 > --- a/drivers/net/phy/ncsi.c > +++ b/drivers/net/phy/ncsi.c > @@ -881,7 +881,7 @@ int ncsi_shutdown(struct phy_device *phydev) > return 0; > } > > -static struct phy_driver ncsi_driver = { > +U_BOOT_PHY_DRIVER(ncsi) = { > .uid= PHY_NCSI_ID, > .mask = 0x, > .name = "NC-SI", > @@ -891,9 +891,3 @@ static struct phy_driver ncsi_driver = { > .startup= ncsi_startup, > .shutdown = ncsi_shutdown, > }; > - > -int phy_ncsi_init(void) > -{ > - phy_register(&ncsi_driver); > - return 0; > -} > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 245357c31dc..69db79f79e0 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_NCSI > - phy_ncsi_init(); > -#endif > #ifdef CONFIG_PHY_XILINX_GMII2RGMII > phy_xilinx_gmii2rgmii_init(); > #endif > diff --git a/include/phy.h b/include/phy.h > index 9cabfeedec8..001c998db47 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev); > int gen10g_shutdown(struct phy_device *phydev); > int gen10g_discover_mmds(struct phy_device *phydev); > > -int phy_ncsi_init(void); > int phy_xilinx_gmii2rgmii_init(void); > > /** > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 33/41] net: phy: fixed: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/fixed.c | 8 +--- > drivers/net/phy/phy.c | 3 --- > include/phy.h | 1 - > 3 files changed, 1 insertion(+), 11 deletions(-) > > diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c > index 1192915ee52..2f0823b8365 100644 > --- a/drivers/net/phy/fixed.c > +++ b/drivers/net/phy/fixed.c > @@ -93,7 +93,7 @@ static int fixedphy_shutdown(struct phy_device *phydev) > return 0; > } > > -static struct phy_driver fixedphy_driver = { > +U_BOOT_PHY_DRIVER(fixedphy) = { > .uid= PHY_FIXED_ID, > .mask = 0x, > .name = "Fixed PHY", > @@ -103,9 +103,3 @@ static struct phy_driver fixedphy_driver = { > .startup= fixedphy_startup, > .shutdown = fixedphy_shutdown, > }; > - > -int phy_fixed_init(void) > -{ > - phy_register(&fixedphy_driver); > - return 0; > -} > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index c20e750aa16..245357c31dc 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_FIXED > - phy_fixed_init(); > -#endif > #ifdef CONFIG_PHY_NCSI > phy_ncsi_init(); > #endif > diff --git a/include/phy.h b/include/phy.h > index e4a3e10c48b..9cabfeedec8 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev); > int gen10g_shutdown(struct phy_device *phydev); > int gen10g_discover_mmds(struct phy_device *phydev); > > -int phy_fixed_init(void); > int phy_ncsi_init(void); > int phy_xilinx_gmii2rgmii_init(void); > > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 32/41] net: phy: mscc: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/mscc.c | 27 +++ > drivers/net/phy/phy.c | 3 --- > include/phy.h | 1 - > 3 files changed, 7 insertions(+), 24 deletions(-) > > diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c > index f9482b21a01..ef1761a8bda 100644 > --- a/drivers/net/phy/mscc.c > +++ b/drivers/net/phy/mscc.c > @@ -1558,7 +1558,7 @@ static int vsc8502_config(struct phy_device *phydev) > return 0; > } > > -static struct phy_driver VSC8530_driver = { > +U_BOOT_PHY_DRIVER(vsc8530) = { > .name = "Microsemi VSC8530", > .uid = PHY_ID_VSC8530, > .mask = 0x0000, > @@ -1568,7 +1568,7 @@ static struct phy_driver VSC8530_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8531_driver = { > +U_BOOT_PHY_DRIVER(vsc8531) = { > .name = "Microsemi VSC8531", > .uid = PHY_ID_VSC8531, > .mask = 0x0000, > @@ -1578,7 +1578,7 @@ static struct phy_driver VSC8531_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8502_driver = { > +U_BOOT_PHY_DRIVER(vsc8502) = { > .name = "Microsemi VSC8502", > .uid = PHY_ID_VSC8502, > .mask = 0x0000, > @@ -1588,7 +1588,7 @@ static struct phy_driver VSC8502_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8540_driver = { > +U_BOOT_PHY_DRIVER(vsc8540) = { > .name = "Microsemi VSC8540", > .uid = PHY_ID_VSC8540, > .mask = 0x0000, > @@ -1598,7 +1598,7 @@ static struct phy_driver VSC8540_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8541_driver = { > +U_BOOT_PHY_DRIVER(vsc8541) = { > .name = "Microsemi VSC8541", > .uid = PHY_ID_VSC8541, > .mask = 0x0000, > @@ -1608,7 +1608,7 @@ static struct phy_driver VSC8541_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8574_driver = { > +U_BOOT_PHY_DRIVER(vsc8574) = { > .name = "Microsemi VSC8574", > .uid = PHY_ID_VSC8574, > .mask = 0x0000, > @@ -1618,7 +1618,7 @@ static struct phy_driver VSC8574_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8584_driver = { > +U_BOOT_PHY_DRIVER(vsc8584) = { > .name = "Microsemi VSC8584", > .uid = PHY_ID_VSC8584, > .mask = 0x0000, > @@ -1627,16 +1627,3 @@ static struct phy_driver VSC8584_driver = { > .startup = &mscc_startup, > .shutdown = &genphy_shutdown, > }; > - > -int phy_mscc_init(void) > -{ > - phy_register(&VSC8530_driver); > - phy_register(&VSC8531_driver); > - phy_register(&VSC8502_driver); > - phy_register(&VSC8540_driver); > - phy_register(&VSC8541_driver); > - phy_register(&VSC8574_driver); > - phy_register(&VSC8584_driver); > - > - return 0; > -} > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 1542fe89252..c20e750aa16 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_MSCC > - phy_mscc_init(); > -#endif > #ifdef CONFIG_PHY_FIXED > phy_fixed_init(); > #endif > diff --git a/include/phy.h b/include/phy.h > index fc8300d5d97..e4a3e10c48b 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev); > int gen10g_shutdown(struct phy_device *phydev); > int gen10g_discover_mmds(struct phy_device *phydev); > > -int phy_mscc_init(void); > int phy_fixed_init(void); > int phy_ncsi_init(void); > int phy_xilinx_gmii2rgmii_init(void); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 31/41] net: phy: intel-xway: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/intel_xway.c | 9 + > drivers/net/phy/phy.c| 3 --- > include/phy.h| 1 - > 3 files changed, 1 insertion(+), 12 deletions(-) > > diff --git a/drivers/net/phy/intel_xway.c b/drivers/net/phy/intel_xway.c > index dfce3f8332e..9d1b97d349f 100644 > --- a/drivers/net/phy/intel_xway.c > +++ b/drivers/net/phy/intel_xway.c > @@ -30,7 +30,7 @@ static int xway_config(struct phy_device *phydev) > return 0; > } > > -static struct phy_driver XWAY_driver = { > +U_BOOT_PHY_DRIVER(xway) = { > .name = "XWAY", > .uid = 0xD565A400, > .mask = 0xff00, > @@ -39,10 +39,3 @@ static struct phy_driver XWAY_driver = { > .startup = genphy_startup, > .shutdown = genphy_shutdown, > }; > - > -int phy_xway_init(void) > -{ > - phy_register(&XWAY_driver); > - > - return 0; > -} > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index b85d5c4566d..1542fe89252 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_XWAY > - phy_xway_init(); > -#endif > #ifdef CONFIG_PHY_MSCC > phy_mscc_init(); > #endif > diff --git a/include/phy.h b/include/phy.h > index e128ddf0037..fc8300d5d97 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev); > int gen10g_shutdown(struct phy_device *phydev); > int gen10g_discover_mmds(struct phy_device *phydev); > > -int phy_xway_init(void); > int phy_mscc_init(void); > int phy_fixed_init(void); > int phy_ncsi_init(void); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 30/41] net: phy: xilinx: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c| 3 --- > drivers/net/phy/xilinx_phy.c | 10 +- > include/phy.h| 1 - > 3 files changed, 1 insertion(+), 13 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index fff1d669fcd..b85d5c4566d 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_XILINX > - phy_xilinx_init(); > -#endif > #ifdef CONFIG_PHY_XWAY > phy_xway_init(); > #endif > diff --git a/drivers/net/phy/xilinx_phy.c b/drivers/net/phy/xilinx_phy.c > index 39dbfdb7da8..1df639d6f44 100644 > --- a/drivers/net/phy/xilinx_phy.c > +++ b/drivers/net/phy/xilinx_phy.c > @@ -127,7 +127,7 @@ static int xilinxphy_config(struct phy_device *phydev) > return 0; > } > > -static struct phy_driver xilinxphy_driver = { > +U_BOOT_PHY_DRIVER(xilinxphy) = { > .uid = XILINX_PHY_ID, > .mask = XILINX_PHY_ID_MASK, > .name = "Xilinx PCS/PMA PHY", > @@ -136,11 +136,3 @@ static struct phy_driver xilinxphy_driver = { > .startup = &xilinxphy_startup, > .shutdown = &genphy_shutdown, > }; > - > -int phy_xilinx_init(void) > -{ > - debug("%s\n", __func__); > - phy_register(&xilinxphy_driver); > - > - return 0; > -} > diff --git a/include/phy.h b/include/phy.h > index 74f3ada2491..e128ddf0037 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev); > int gen10g_shutdown(struct phy_device *phydev); > int gen10g_discover_mmds(struct phy_device *phydev); > > -int phy_xilinx_init(void); > int phy_xway_init(void); > int phy_mscc_init(void); > int phy_fixed_init(void); > -- > 2.39.2 > Reviewed-by: Ramon Fried
Re: [PATCH 29/41] net: phy: vitesse: Convert to U_BOOT_PHY_DRIVER()
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut wrote: > > Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init > call. > > Converted using sed > "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {" > > Signed-off-by: Marek Vasut > --- > Cc: "Ariel D'Alessandro" > Cc: "Cédric Le Goater" > Cc: "Marek Behún" > Cc: Alex Nemirovsky > Cc: Haolin Li > Cc: Heinrich Schuchardt > Cc: Joe Hershberger > Cc: Joel Stanley > Cc: Josua Mayer > Cc: Marek Vasut > Cc: Michael Trimarchi > Cc: Michal Simek > Cc: Nate Drude > Cc: Neil Armstrong > Cc: Radu Pirea > Cc: Ramon Fried > Cc: Samuel Mendoza-Jonas > Cc: Stefan Roese > Cc: T Karthik Reddy > Cc: Tim Harvey > Cc: Vladimir Oltean > Cc: u-boot-amlo...@groups.io > --- > drivers/net/phy/phy.c | 3 --- > drivers/net/phy/vitesse.c | 45 +++ > include/phy.h | 1 - > 3 files changed, 13 insertions(+), 36 deletions(-) > > diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c > index 404d61c5ab3..fff1d669fcd 100644 > --- a/drivers/net/phy/phy.c > +++ b/drivers/net/phy/phy.c > @@ -514,9 +514,6 @@ int phy_init(void) > phy_drv_reloc(drv); > #endif > > -#ifdef CONFIG_PHY_VITESSE > - phy_vitesse_init(); > -#endif > #ifdef CONFIG_PHY_XILINX > phy_xilinx_init(); > #endif > diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c > index eca26c98938..c5cf0d7dfbd 100644 > --- a/drivers/net/phy/vitesse.c > +++ b/drivers/net/phy/vitesse.c > @@ -293,7 +293,7 @@ static int vsc8664_config(struct phy_device *phydev) > return 0; > } > > -static struct phy_driver VSC8211_driver = { > +U_BOOT_PHY_DRIVER(vsc8211) = { > .name = "Vitesse VSC8211", > .uid= 0xfc4b0, > .mask = 0x0, > @@ -303,7 +303,7 @@ static struct phy_driver VSC8211_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8221_driver = { > +U_BOOT_PHY_DRIVER(vsc8221) = { > .name = "Vitesse VSC8221", > .uid = 0xfc550, > .mask = 0x0, > @@ -313,7 +313,7 @@ static struct phy_driver VSC8221_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8244_driver = { > +U_BOOT_PHY_DRIVER(vsc8244) = { > .name = "Vitesse VSC8244", > .uid = 0xfc6c0, > .mask = 0x0, > @@ -323,7 +323,7 @@ static struct phy_driver VSC8244_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8234_driver = { > +U_BOOT_PHY_DRIVER(vsc8234) = { > .name = "Vitesse VSC8234", > .uid = 0xfc620, > .mask = 0x0, > @@ -333,7 +333,7 @@ static struct phy_driver VSC8234_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8574_driver = { > +U_BOOT_PHY_DRIVER(vsc8574) = { > .name = "Vitesse VSC8574", > .uid = 0x704a0, > .mask = 0x0, > @@ -343,7 +343,7 @@ static struct phy_driver VSC8574_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8514_driver = { > +U_BOOT_PHY_DRIVER(vsc8514) = { > .name = "Vitesse VSC8514", > .uid = 0x70670, > .mask = 0x0, > @@ -353,7 +353,7 @@ static struct phy_driver VSC8514_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8584_driver = { > +U_BOOT_PHY_DRIVER(vsc8584) = { > .name = "Vitesse VSC8584", > .uid = 0x707c0, > .mask = 0x0, > @@ -363,7 +363,7 @@ static struct phy_driver VSC8584_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8601_driver = { > +U_BOOT_PHY_DRIVER(vsc8601) = { > .name = "Vitesse VSC8601", > .uid = 0x70420, > .mask = 0x0, > @@ -373,7 +373,7 @@ static struct phy_driver VSC8601_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8641_driver = { > +U_BOOT_PHY_DRIVER(vsc8641) = { > .name = "Vitesse VSC8641", > .uid = 0x70430, > .mask = 0x0, > @@ -383,7 +383,7 @@ static struct phy_driver VSC8641_driver = { > .shutdown = &genphy_shutdown, > }; > > -static struct phy_driver VSC8662_driver = { > +U_BOOT_PHY_DRIVER(vsc8662) = { > .name = "Vitesse VSC8662", > .uid = 0x70660, > .mask =
Re: [Patch] net: dwc_eth_qos - works with fixed-phy
On Fri, Feb 17, 2023 at 5:03 AM Marek Vasut wrote: > > On 2/16/23 17:45, Nicole Battenfeld wrote: > > > > Am 16.02.23 um 02:39 schrieb Marek Vasut: > >> On 2/15/23 17:16, Elmar Psilog wrote: > >>> Let the EQoS in imx8mp handle fixed-phy too. > >>> Without that patch it lost track to the node to scan > >>> speed and duplex. > >>> Patch was created by Marek Vasut, just tested by me. > >>> > >>> Signed-off-by: Elmar Psilog > >>> --- > >>> drivers/net/dwc_eth_qos.c > >>> 1 file changed > >> > >> If you were to use 'git format-patch' and 'git send-email', those > >> tools would generate the correct Subject and diffstat etc. for you. > >> Also have a look at scripts/checkpatch.pl to validate whether a patch > >> is correct. > >> > >>> diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c > >>> index afc47b56ff..10915d8e47 100644 > >>> --- a/drivers/net/dwc_eth_qos.c > >>> +++ b/drivers/net/dwc_eth_qos.c > >>> @@ -785,9 +785,21 @@ static int eqos_start(struct udevice *dev) > >>> */ > >>> if (!eqos->phy) { > >>> int addr = -1; > >>> - addr = eqos_get_phy_addr(eqos, dev); > >>> - eqos->phy = phy_connect(eqos->mii, addr, dev, > >>> - eqos->config->interface(dev)); > >>> + ofnode fixed_node; > >>> + > >>> + if (IS_ENABLED(CONFIG_PHY_FIXED)) { > >>> + fixed_node = > >>> ofnode_find_subnode(dev_ofnode(dev), > >>> + "fixed-link"); > >>> + if (ofnode_valid(fixed_node)) { > >>> + eqos->phy = > >>> fixed_phy_create(dev_ofnode(dev)); > >>> + eqos->phy_of_node = fixed_node; > >>> + } > >>> + } > >>> + if (!eqos->phy) { > >>> + addr = eqos_get_phy_addr(eqos, dev); > >>> + eqos->phy = phy_connect(eqos->mii, addr, dev, > >>> eqos->config->interface(dev)); > >>> + } > >>> + > >>> if (!eqos->phy) { > >>> pr_err("phy_connect() failed"); > >>> goto err_stop_resets; > >> > >> +CC Ramon the network maintainer . > > > > > > New attempt: used script to check and fix and used git format-patch. > > > > Also base is latest trunk, not v2023.1 as before. > > > > Hope this fits your needs, otherwise I afraid I need detailed instruction. > > Basically the process is documented at length here: > > https://u-boot.readthedocs.io/en/latest/develop/sending_patches.html > > which is very much identical to even lengthier Linux patch submission > guidelines: > > https://www.kernel.org/doc/html/latest/process/submitting-patches.html > > If you use git send-email , that will do most of the work for you, > including correct formatting etc. The invocation is something like: > > $ git send-email --annotate --to=u-boot@lists.denx.de > --cc=additional-per...@to.copy --cc=one@more.person -1 > > Note that you do have to configure SMTP access in git-config for that to > work. > > You had the patch right very much the first time, except for a few style > issues, like [Patch] instead of [PATCH] in the subject, patch itself was > malformed likely due to copy-paste, and the checkpatch issues had to be > addressed . When sending a new revision, include changelog in the patch > below the --- below diffstat, and also make sure the Subjects reads > [PATCH v2], git send-email -v2 does that for you (and -v3 does v3 etc.). > You're almost there, no worries. > > Wait for Ramon to review this patch and then send V2 if needed. Okay by me, please send a fresh V2 so we can apply it easily.