lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 9 Mar 2020 07:46:35 +0100
From:   Sascha Hauer <s.hauer@...gutronix.de>
To:     Madalin Bucur <madalin.bucur@....nxp.com>
Cc:     davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v3 2/3] fsl/fman: tolerate missing MAC address
 in device tree

On Thu, Mar 05, 2020 at 07:08:57PM +0200, Madalin Bucur wrote:
> Allow the initialization of the MAC to be performed even if the
> device tree does not provide a valid MAC address. Later a random
> MAC address should be assigned by the Ethernet driver.
> 
> Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
> Signed-off-by: Madalin Bucur <madalin.bucur@....nxp.com>
> ---
>  drivers/net/ethernet/freescale/fman/fman_dtsec.c | 10 ++++------
>  drivers/net/ethernet/freescale/fman/fman_memac.c | 10 ++++------
>  drivers/net/ethernet/freescale/fman/fman_tgec.c  | 10 ++++------
>  drivers/net/ethernet/freescale/fman/mac.c        | 13 ++++++-------
>  4 files changed, 18 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> index f7aec507787f..004c266802a8 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
> @@ -514,8 +514,10 @@ static int init(struct dtsec_regs __iomem *regs, struct dtsec_cfg *cfg,
>  
>  	iowrite32be(0xffffffff, &regs->ievent);
>  
> -	MAKE_ENET_ADDR_FROM_UINT64(addr, eth_addr);
> -	set_mac_address(regs, (u8 *)eth_addr);
> +	if (addr) {
> +		MAKE_ENET_ADDR_FROM_UINT64(addr, eth_addr);
> +		set_mac_address(regs, (u8 *)eth_addr);
> +	}
>  
>  	/* HASH */
>  	for (i = 0; i < NUM_OF_HASH_REGS; i++) {
> @@ -553,10 +555,6 @@ static int check_init_parameters(struct fman_mac *dtsec)
>  		pr_err("1G MAC driver supports 1G or lower speeds\n");
>  		return -EINVAL;
>  	}
> -	if (dtsec->addr == 0) {
> -		pr_err("Ethernet MAC Must have a valid MAC Address\n");
> -		return -EINVAL;
> -	}
>  	if ((dtsec->dtsec_drv_param)->rx_prepend >
>  	    MAX_PACKET_ALIGNMENT) {
>  		pr_err("packetAlignmentPadding can't be > than %d\n",
> diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c
> index e1901874c19f..f2b2bfcbb529 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_memac.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
> @@ -596,10 +596,6 @@ static void setup_sgmii_internal_phy_base_x(struct fman_mac *memac)
>  
>  static int check_init_parameters(struct fman_mac *memac)
>  {
> -	if (memac->addr == 0) {
> -		pr_err("Ethernet MAC must have a valid MAC address\n");
> -		return -EINVAL;
> -	}
>  	if (!memac->exception_cb) {
>  		pr_err("Uninitialized exception handler\n");
>  		return -EINVAL;
> @@ -1057,8 +1053,10 @@ int memac_init(struct fman_mac *memac)
>  	}
>  
>  	/* MAC Address */
> -	MAKE_ENET_ADDR_FROM_UINT64(memac->addr, eth_addr);
> -	add_addr_in_paddr(memac->regs, (u8 *)eth_addr, 0);
> +	if (memac->addr != 0) {
> +		MAKE_ENET_ADDR_FROM_UINT64(memac->addr, eth_addr);
> +		add_addr_in_paddr(memac->regs, (u8 *)eth_addr, 0);
> +	}
>  
>  	fixed_link = memac_drv_param->fixed_link;
>  
> diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c b/drivers/net/ethernet/freescale/fman/fman_tgec.c
> index f75b9c11b2d2..8c7eb878d5b4 100644
> --- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
> +++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
> @@ -273,10 +273,6 @@ static int check_init_parameters(struct fman_mac *tgec)
>  		pr_err("10G MAC driver only support 10G speed\n");
>  		return -EINVAL;
>  	}
> -	if (tgec->addr == 0) {
> -		pr_err("Ethernet 10G MAC Must have valid MAC Address\n");
> -		return -EINVAL;
> -	}
>  	if (!tgec->exception_cb) {
>  		pr_err("uninitialized exception_cb\n");
>  		return -EINVAL;
> @@ -706,8 +702,10 @@ int tgec_init(struct fman_mac *tgec)
>  
>  	cfg = tgec->cfg;
>  
> -	MAKE_ENET_ADDR_FROM_UINT64(tgec->addr, eth_addr);
> -	set_mac_address(tgec->regs, (u8 *)eth_addr);
> +	if (tgec->addr) {
> +		MAKE_ENET_ADDR_FROM_UINT64(tgec->addr, eth_addr);
> +		set_mac_address(tgec->regs, (u8 *)eth_addr);
> +	}
>  
>  	/* interrupts */
>  	/* FM_10G_REM_N_LCL_FLT_EX_10GMAC_ERRATA_SW005 Errata workaround */
> diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
> index 55f2122c3217..43427c5b9396 100644
> --- a/drivers/net/ethernet/freescale/fman/mac.c
> +++ b/drivers/net/ethernet/freescale/fman/mac.c
> @@ -724,12 +724,10 @@ static int mac_probe(struct platform_device *_of_dev)
>  
>  	/* Get the MAC address */
>  	mac_addr = of_get_mac_address(mac_node);
> -	if (IS_ERR(mac_addr)) {
> -		dev_err(dev, "of_get_mac_address(%pOF) failed\n", mac_node);
> -		err = -EINVAL;
> -		goto _return_of_get_parent;
> -	}
> -	ether_addr_copy(mac_dev->addr, mac_addr);
> +	if (IS_ERR(mac_addr))
> +		dev_warn(dev, "of_get_mac_address(%pOF) failed\n", mac_node);

Why this warning? There's nothing wrong with not providing the MAC in
the device tree.

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Powered by blists - more mailing lists