[PATCH rtems 10/18] mv643xx_eth_bsdnet.c, mv643xx_eth.c, mv643xx_eth.h: init_hw has new 'speed' argument

Vijay Kumar Banerjee vijay at rtems.org
Tue Mar 30 01:27:42 UTC 2021


From: till straumann <till.straumann at alumni.tu-berlin.de>

Remove any calls to mii_ioctl from the low-level driver. Instead, the caller
must determine the current speed and communicate to init_hw().

Update #4344
---
 .../powerpc/beatnik/include/bsp/mv643xx_eth.h |  2 +-
 bsps/powerpc/beatnik/net/if_mve/mv643xx_eth.c | 12 ++---
 .../beatnik/net/if_mve/mv643xx_eth_bsdnet.c   | 54 ++++++++++++-------
 3 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/bsps/powerpc/beatnik/include/bsp/mv643xx_eth.h b/bsps/powerpc/beatnik/include/bsp/mv643xx_eth.h
index 160cadbc82..5bfcd9b26a 100644
--- a/bsps/powerpc/beatnik/include/bsp/mv643xx_eth.h
+++ b/bsps/powerpc/beatnik/include/bsp/mv643xx_eth.h
@@ -301,7 +301,7 @@ BSP_mve_dump_stats(struct mveth_private *mp, FILE *f);
  *              are programmed to accept all multicast frames.
  */
 void
-BSP_mve_init_hw(struct mveth_private *mp, int promisc, unsigned char *enaddr);
+BSP_mve_init_hw(struct mveth_private *mp, int promisc, unsigned char *enaddr, int speed);
 
 /*
  * Update the serial port to a new speed (e.g., result of a PHY IRQ)
diff --git a/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth.c b/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth.c
index f786b66c5c..35ef6622d9 100644
--- a/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth.c
+++ b/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth.c
@@ -2063,7 +2063,7 @@ uint32_t mveth_serial_ctrl_config_val = MVETH_SERIAL_CTRL_CONFIG_VAL;
  */
 
 void
-BSP_mve_init_hw(struct mveth_private *mp, int promisc, unsigned char *enaddr)
+BSP_mve_init_hw(struct mveth_private *mp, int promisc, unsigned char *enaddr, int media)
 {
 int					i;
 uint32_t			v;
@@ -2173,15 +2173,9 @@ static int			inited = 0;
 	v |= mveth_serial_ctrl_config_val;
 	MV_WRITE(MV643XX_ETH_SERIAL_CONTROL_R(mp->port_num), v);
 
-#ifdef BSDMII
-#warning FIXME
-	i = IFM_MAKEWORD(0, 0, 0, 0);
-	if ( 0 == BSP_mve_media_ioctl(mp, SIOCGIFMEDIA, &i) ) {
-	    if ( (IFM_LINK_OK & i) ) {
-			mveth_update_serial_port(mp, i);
-		}
+	if ( (MV643XX_MEDIA_LINK & media) ) {
+		BSP_mve_update_serial_port(mp, media);
 	}
-#endif
 
 	/* enable serial port */
 	v  = MV_READ(MV643XX_ETH_SERIAL_CONTROL_R(mp->port_num));
diff --git a/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c b/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c
index 0a42dc4190..cdec5c6e14 100644
--- a/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c
+++ b/bsps/powerpc/beatnik/net/if_mve/mv643xx_eth_bsdnet.c
@@ -563,6 +563,34 @@ int rval;
 	return rval;
 }
 
+/* Translate IFFLAGS to low-level driver representation */
+static int
+xlateMediaFlags(int media)
+{
+int lowLevelFlags = 0;
+
+	if ( IFM_LINK_OK & media ) {
+		lowLevelFlags |= MV643XX_MEDIA_LINK;
+
+		if ( IFM_FDX & media ) {
+			lowLevelFlags |= MV643XX_MEDIA_FD;
+		}
+
+		switch ( IFM_SUBTYPE(media) ) {
+			default: /* treat as 10 */
+				lowLevelFlags |= MV643XX_MEDIA_10;
+				break;
+			case IFM_100_TX:
+				lowLevelFlags |= MV643XX_MEDIA_100;
+				break;
+			case IFM_1000_T:
+				lowLevelFlags |= MV643XX_MEDIA_1000;
+				break;
+		}
+	}
+	return lowLevelFlags;
+}
+
 int
 BSP_mve_ack_link_chg(struct mveth_private *mp, int *pmedia)
 {
@@ -570,23 +598,7 @@ int media = IFM_MAKEWORD(0,0,0,0);
 
 	if ( 0 == BSP_mve_media_ioctl(mp, SIOCGIFMEDIA, &media)) {
 		if ( IFM_LINK_OK & media ) {
-			int serport_cfg = 0;
-
-			if ( IFM_FDX & media ) {
-				serport_cfg |= MV643XX_MEDIA_FD;
-			}
-
-			switch ( IFM_SUBTYPE(media) ) {
-				default: /* treat as 10 */
-					serport_cfg |= MV643XX_MEDIA_10;
-					break;
-				case IFM_100_TX:
-					serport_cfg |= MV643XX_MEDIA_100;
-					break;
-				case IFM_1000_T:
-					serport_cfg |= MV643XX_MEDIA_1000;
-					break;
-			}
+			int serport_cfg = xlateMediaFlags( media );
 
 			BSP_mve_update_serial_port(mp, serport_cfg);
 		}
@@ -713,8 +725,7 @@ mveth_init(void *arg)
 struct mveth_softc	*sc  = arg;
 struct ifnet		*ifp = &sc->arpcom.ac_if;
 int                 media;
-
-	BSP_mve_init_hw(sc->pvt, ifp->if_flags & IFF_PROMISC, sc->arpcom.ac_enaddr);
+int                 lowLevelMediaStatus;
 
 	media = IFM_MAKEWORD(0, 0, 0, 0);
 	if ( 0 == BSP_mve_media_ioctl(sc->pvt, SIOCGIFMEDIA, &media) ) {
@@ -725,6 +736,11 @@ int                 media;
 		}
 	}
 
+	lowLevelMediaStatus = xlateMediaFlags( media );
+
+	BSP_mve_init_hw(sc->pvt, ifp->if_flags & IFF_PROMISC, sc->arpcom.ac_enaddr, lowLevelMediaStatus);
+
+
 	/* if promiscuous then there is no need to change */
 	if ( ! (ifp->if_flags & IFF_PROMISC) )
 		mveth_set_filters(ifp);
-- 
2.26.2



More information about the devel mailing list