diff --git a/include/net/if.h b/include/net/if.h index 7afcc2d15a..2e869d6b24 100644 --- a/include/net/if.h +++ b/include/net/if.h @@ -127,6 +127,17 @@ # define IFF_IS_IPv4(f) (1) #endif +/* MDIO Manageable Device (MMD) support with SIOCxMIIREG ioctl commands */ + +#define MDIO_PHY_ID_C45 0x8000 +#define MDIO_PHY_ID_PRTAD 0x03E0 +#define MDIO_PHY_ID_DEVAD 0x001F +#define MDIO_PHY_ID_C45_MASK \ + (MDIO_PHY_ID_C45 | MDIO_PHY_ID_PRTAD | MDIO_PHY_ID_DEVAD) + +#define mdio_phy_id_c45(prtad, devad) \ + ((uint16_t)(MDIO_PHY_ID_C45 | ((prtad) << 5) | (devad))) + /* RFC 2863 operational status */ enum diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index c31ce180d7..460420b74c 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -2,7 +2,8 @@ * include/nuttx/net/netdev.h * * SPDX-License-Identifier: BSD-3-Clause - * SPDX-FileCopyrightText: 2007, 2009, 2011-2018 Gregory Nutt. All rights reserved. + * SPDX-FileCopyrightText: 2007,2009 Gregory Nutt. All rights reserved. + * SPDX-FileCopyrightText: 2011-2018 Gregory Nutt. All rights reserved. * SPDX-FileCopyrightText: 2001-2003, Adam Dunkels. All rights reserved. * SPDX-FileContributor: Gregory Nutt * @@ -216,6 +217,17 @@ (netdev_ipv6_lookup(dev, addr, true) != NULL) #endif +/* MDIO Manageable Device (MMD) support with SIOCxMIIREG ioctl commands */ + +#define mdio_phy_id_is_c45(phy_id) \ + (((phy_id) & MDIO_PHY_ID_C45) && !((phy_id) & ~MDIO_PHY_ID_C45_MASK)) + +#define mdio_phy_id_prtad(phy_id) \ + ((uint16_t)(((phy_id) & MDIO_PHY_ID_PRTAD) >> 5)) + +#define mdio_phy_id_devad(phy_id) \ + ((uint16_t)((phy_id) & MDIO_PHY_ID_DEVAD)) + /**************************************************************************** * Public Types ****************************************************************************/