Re: [PATCH net-next v3 3/7] net: dsa: microchip: ksz9477: add Wake on LAN support

From: Andrew Lunn
Date: Sat Oct 14 2023 - 13:15:41 EST


> + * ksz9477_get_wol - Get Wake-on-LAN settings for a specified port.
> + * @dev: The device structure.
> + * @port: The port number.
> + * @wol: Pointer to ethtool Wake-on-LAN settings structure.
> + *
> + * This function checks the PME Pin Control Register to see if PME Pin Output
> + * Enable is set, indicating PME is enabled. If enabled, it sets the supported
> + * and active WoL flags.

I'm missing something here: Why would the PME Pin Output Enable not be
set?

I also wounder if there should be one additional test. Is the MAC
address on the user interface the same as the one programmed in the
switch? If it is different supported should not be set.

> +void ksz9477_get_wol(struct ksz_device *dev, int port,
> + struct ethtool_wolinfo *wol)
> +{
> + u8 pme_ctrl, pme_conf;
> + int ret;
> +
> + ret = ksz_read8(dev, REG_SW_PME_CTRL, &pme_conf);
> + if (ret)
> + return;
> +
> + if (!(pme_conf & PME_ENABLE))
> + return;
> +
> + wol->supported = WAKE_MAGIC;
> +
> + ret = ksz_pread8(dev, port, REG_PORT_PME_CTRL, &pme_ctrl);
> + if (ret)
> + return;
> +
> + if (pme_ctrl & PME_WOL_MAGICPKT)
> + wol->wolopts |= WAKE_MAGIC;
> +}

> +static void ksz_get_wol(struct dsa_switch *ds, int port,
> + struct ethtool_wolinfo *wol)
> +{
> + struct ksz_device *dev = ds->priv;
> +
> + memset(wol, 0, sizeof(*wol));

Drivers should not need this, i would expect the core to zero the
structure.


Andrew

---
pw-bot: cr