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.
This commit is contained in:
Justin Hibbits 2017-11-01 00:46:48 +00:00
parent 9d98ae7d5f
commit 1c41f28f7c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325255
5 changed files with 27 additions and 45 deletions

View File

@ -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

View File

@ -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,49 +385,31 @@ fman_error_callback(t_Handle app_handle, e_FmPortType port_type,
*/
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 = fm_sc->fm_handle;
*fmh = 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 = fm_sc->muram_handle;
*muramh = 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(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;
*fm_base = rman_get_bushandle(sc->mem_res);
return (0);
}
@ -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) {

View File

@ -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_ */

View File

@ -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;

View File

@ -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 */