svn commit: r325255 - in head: share/man/man4/man4.powerpc sys/dev/dpaa

Justin Hibbits jhibbits at FreeBSD.org
Wed Nov 1 00:46:49 UTC 2017


Author: jhibbits
Date: Wed Nov  1 00:46:48 2017
New Revision: 325255
URL: https://svnweb.freebsd.org/changeset/base/325255

Log:
  Remove a singleton in the DPAA driver, to allow multiple fman instances
  
  Some devices (P5040, P4080) have multiple frame managers in their DPAA
  subsystems.  This was prevented by use of a softc singleton in the DPAA
  driver.  Since if_dtsec(4) has moved to be a child of fman, it can access
  the fman device data via the parent object.

Modified:
  head/share/man/man4/man4.powerpc/dtsec.4
  head/sys/dev/dpaa/fman.c
  head/sys/dev/dpaa/fman.h
  head/sys/dev/dpaa/fman_mdio.c
  head/sys/dev/dpaa/if_dtsec.c

Modified: head/share/man/man4/man4.powerpc/dtsec.4
==============================================================================
--- head/share/man/man4/man4.powerpc/dtsec.4	Wed Nov  1 00:33:54 2017	(r325254)
+++ head/share/man/man4/man4.powerpc/dtsec.4	Wed Nov  1 00:46:48 2017	(r325255)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 16, 2017
+.Dd October 31, 2017
 .Dt DTSEC 4
 .Os
 .Sh NAME
@@ -89,6 +89,14 @@ P2041, P3041
 .It
 P5010, P5020
 .El
+.Pp
+Additionally, the following devices are expected to work, but are untested:
+.Bl -bullet -compact
+.It
+P4080, P4040
+.It
+P5040
+.El
 .Sh SEE ALSO
 .Xr altq 4 ,
 .Xr arp 4 ,
@@ -96,13 +104,6 @@ P5010, P5020
 .Xr netintro 4 ,
 .Xr ng_ether 4 ,
 .Xr ifconfig 8
-.Sh BUGS
-The
-.Nm
-driver assumes that there is only one Frame Manager, and that dtsec0 controls
-the MDIO interface.  Though this is the case for the supported devices, other
-SoCs with the DPAA controller may not work correctly.  Particularly, the P5040
-and P4080 SoCs have two frame managers, which breaks this assumption.
 .Sh HISTORY
 The
 .Nm

Modified: head/sys/dev/dpaa/fman.c
==============================================================================
--- head/sys/dev/dpaa/fman.c	Wed Nov  1 00:33:54 2017	(r325254)
+++ head/sys/dev/dpaa/fman.c	Wed Nov  1 00:46:48 2017	(r325255)
@@ -87,7 +87,6 @@ struct fman_config {
  */
 const uint32_t fman_firmware[] = FMAN_UC_IMG;
 const uint32_t fman_firmware_size = sizeof(fman_firmware);
-static struct fman_softc *fm_sc = NULL;
 
 int
 fman_activate_resource(device_t bus, device_t child, int type, int rid,
@@ -386,54 +385,36 @@ fman_error_callback(t_Handle app_handle, e_FmPortType 
  */
 
 int
-fman_get_handle(t_Handle *fmh)
+fman_get_handle(device_t dev, t_Handle *fmh)
 {
+	struct fman_softc *sc = device_get_softc(dev);
 
-	if (fm_sc == NULL)
-		return (ENOMEM);
+	*fmh = sc->fm_handle;
 
-	*fmh = fm_sc->fm_handle;
-
 	return (0);
 }
 
 int
-fman_get_muram_handle(t_Handle *muramh)
+fman_get_muram_handle(device_t dev, t_Handle *muramh)
 {
+	struct fman_softc *sc = device_get_softc(dev);
 
-	if (fm_sc == NULL)
-		return (ENOMEM);
+	*muramh = sc->muram_handle;
 
-	*muramh = fm_sc->muram_handle;
-
 	return (0);
 }
 
 int
-fman_get_bushandle(vm_offset_t *fm_base)
+fman_get_bushandle(device_t dev, vm_offset_t *fm_base)
 {
+	struct fman_softc *sc = device_get_softc(dev);
 
-	if (fm_sc == NULL)
-		return (ENOMEM);
+	*fm_base = rman_get_bushandle(sc->mem_res);
 
-	*fm_base = rman_get_bushandle(fm_sc->mem_res);
-
 	return (0);
 }
 
 int
-fman_get_dev(device_t *fm_dev)
-{
-
-	if (fm_sc == NULL)
-		return (ENOMEM);
-
-	*fm_dev = fm_sc->sc_base.dev;
-
-	return (0);
-}
-
-int
 fman_attach(device_t dev)
 {
 	struct fman_softc *sc;
@@ -443,7 +424,6 @@ fman_attach(device_t dev)
 
 	sc = device_get_softc(dev);
 	sc->sc_base.dev = dev;
-	fm_sc = sc;
 
 	/* Check if MallocSmart allocator is ready */
 	if (XX_MallocSmartInit() != E_OK) {

Modified: head/sys/dev/dpaa/fman.h
==============================================================================
--- head/sys/dev/dpaa/fman.h	Wed Nov  1 00:33:54 2017	(r325254)
+++ head/sys/dev/dpaa/fman.h	Wed Nov  1 00:46:48 2017	(r325255)
@@ -72,9 +72,8 @@ int	fman_qman_channel_id(device_t, int);
 /** @} */
 
 uint32_t	fman_get_clock(struct fman_softc *sc);
-int	fman_get_handle(t_Handle *fmh);
-int	fman_get_muram_handle(t_Handle *muramh);
-int	fman_get_bushandle(vm_offset_t *fm_base);
-int	fman_get_dev(device_t *fmd);
+int	fman_get_handle(device_t dev, t_Handle *fmh);
+int	fman_get_muram_handle(device_t dev, t_Handle *muramh);
+int	fman_get_bushandle(device_t dev, vm_offset_t *fm_base);
 
 #endif /* FMAN_H_ */

Modified: head/sys/dev/dpaa/fman_mdio.c
==============================================================================
--- head/sys/dev/dpaa/fman_mdio.c	Wed Nov  1 00:33:54 2017	(r325254)
+++ head/sys/dev/dpaa/fman_mdio.c	Wed Nov  1 00:46:48 2017	(r325255)
@@ -130,7 +130,7 @@ pqmdio_fdt_attach(device_t dev)
 
 	sc = device_get_softc(dev);
 
-	fman_get_bushandle(&sc->sc_handle);
+	fman_get_bushandle(device_get_parent(dev), &sc->sc_handle);
 	bus_get_resource(dev, SYS_RES_MEMORY, 0, &start, &count);
 	sc->sc_offset = start;
 

Modified: head/sys/dev/dpaa/if_dtsec.c
==============================================================================
--- head/sys/dev/dpaa/if_dtsec.c	Wed Nov  1 00:33:54 2017	(r325254)
+++ head/sys/dev/dpaa/if_dtsec.c	Wed Nov  1 00:46:48 2017	(r325255)
@@ -569,11 +569,13 @@ int
 dtsec_attach(device_t dev)
 {
 	struct dtsec_softc *sc;
+	device_t parent;
 	int error;
 	struct ifnet *ifp;
 
 	sc = device_get_softc(dev);
 
+	parent = device_get_parent(dev);
 	sc->sc_dev = dev;
 	sc->sc_mac_mdio_irq = NO_IRQ;
 	sc->sc_eth_id = device_get_unit(dev);
@@ -594,13 +596,13 @@ dtsec_attach(device_t dev)
 	callout_init(&sc->sc_tick_callout, CALLOUT_MPSAFE);
 
 	/* Read configuraton */
-	if ((error = fman_get_handle(&sc->sc_fmh)) != 0)
+	if ((error = fman_get_handle(parent, &sc->sc_fmh)) != 0)
 		return (error);
 
-	if ((error = fman_get_muram_handle(&sc->sc_muramh)) != 0)
+	if ((error = fman_get_muram_handle(parent, &sc->sc_muramh)) != 0)
 		return (error);
 
-	if ((error = fman_get_bushandle(&sc->sc_fm_base)) != 0)
+	if ((error = fman_get_bushandle(parent, &sc->sc_fm_base)) != 0)
 		return (error);
 
 	/* Configure working mode */


More information about the svn-src-all mailing list