Skip to content

Commit 3f3d61b

Browse files
committed
include/net/if.h: Add mechanism for MMD access with SIOCxMIIREG ioctls
Add mdio_phy_id_c45 macro. This macro allows encoding of additional information needed for MMD access into the phy_id field of the mii_ioctl_data_s structure. This macro is intended for use by user applications. Add macros for decoding the phy_id encoded with the mdio_phy_id_c45 macro. These macros are intended for use by network drivers implementing SIOCxMIIREG commands. Signed-off-by: michal matias <[email protected]>
1 parent 9c6d502 commit 3f3d61b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

include/net/if.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@
127127
# define IFF_IS_IPv4(f) (1)
128128
#endif
129129

130+
/* MDIO Manageable Device (MMD) support with SIOCxMIIREG ioctl commands */
131+
132+
#define MDIO_PHY_ID_C45 0x8000
133+
#define MDIO_PHY_ID_PRTAD 0x03E0
134+
#define MDIO_PHY_ID_DEVAD 0x001F
135+
#define MDIO_PHY_ID_C45_MASK \
136+
(MDIO_PHY_ID_C45 | MDIO_PHY_ID_PRTAD | MDIO_PHY_ID_DEVAD)
137+
138+
#define mdio_phy_id_c45(prtad, devad) \
139+
((uint16_t)(MDIO_PHY_ID_C45 | ((prtad) << 5) | (devad)))
140+
130141
/* RFC 2863 operational status */
131142

132143
enum

include/nuttx/net/netdev.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* include/nuttx/net/netdev.h
33
*
44
* SPDX-License-Identifier: BSD-3-Clause
5-
* SPDX-FileCopyrightText: 2007, 2009, 2011-2018 Gregory Nutt. All rights reserved.
5+
* SPDX-FileCopyrightText: 2007,2009 Gregory Nutt. All rights reserved.
6+
* SPDX-FileCopyrightText: 2011-2018 Gregory Nutt. All rights reserved.
67
* SPDX-FileCopyrightText: 2001-2003, Adam Dunkels. All rights reserved.
78
* SPDX-FileContributor: Gregory Nutt <[email protected]>
89
*
@@ -216,6 +217,17 @@
216217
(netdev_ipv6_lookup(dev, addr, true) != NULL)
217218
#endif
218219

220+
/* MDIO Manageable Device (MMD) support with SIOCxMIIREG ioctl commands */
221+
222+
#define mdio_phy_id_is_c45(phy_id) \
223+
(((phy_id) & MDIO_PHY_ID_C45) && !((phy_id) & ~MDIO_PHY_ID_C45_MASK))
224+
225+
#define mdio_phy_id_prtad(phy_id) \
226+
((uint16_t)(((phy_id) & MDIO_PHY_ID_PRTAD) >> 5))
227+
228+
#define mdio_phy_id_devad(phy_id) \
229+
((uint16_t)((phy_id) & MDIO_PHY_ID_DEVAD))
230+
219231
/****************************************************************************
220232
* Public Types
221233
****************************************************************************/

0 commit comments

Comments
 (0)