[rtems-libbsd commit] dpaa: Use only one FMan MAC SGT zone

Sebastian Huber sebh at rtems.org
Mon Oct 23 07:27:51 UTC 2017


Module:    rtems-libbsd
Branch:    master
Commit:    a677fe99320c93b78e8bc12e2554c080da9e86e0
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=a677fe99320c93b78e8bc12e2554c080da9e86e0

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Oct 23 09:11:15 2017 +0200

dpaa: Use only one FMan MAC SGT zone

---

 .../net/ethernet/freescale/dpaa/if_fmanmac.c       | 35 ++++++++++++----------
 .../net/ethernet/freescale/dpaa/if_fmanmac.h       |  1 -
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.c b/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.c
index 640ca50..12106c0 100644
--- a/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.c
+++ b/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.c
@@ -62,6 +62,20 @@ struct fman_mac_sgt {
 	struct mbuf *m;
 };
 
+static uma_zone_t fman_mac_sgt_zone;
+
+static void
+fman_mac_sgt_init(void)
+{
+
+	fman_mac_sgt_zone = uma_zcreate("FMan MAC SGT", sizeof(struct fman_mac_sgt),
+	    NULL, NULL, NULL, NULL, 16, 0);
+	if (fman_mac_sgt_zone == NULL) {
+		panic("Cannot create FMan MAC SGT zone");
+	}
+}
+SYSINIT(fman_mac_sgt, SI_SUB_MBUF, SI_ORDER_ANY, fman_mac_sgt_init, NULL);
+
 static void
 fman_mac_enable_tx_csum(struct mbuf *m, struct qm_fd *fd,
     struct fman_prs_result *prs)
@@ -121,7 +135,7 @@ fman_mac_txstart_locked(struct ifnet *ifp, struct fman_mac_softc *sc)
 			break;
 		}
 
-		sgt = uma_zalloc(sc->sgt_zone, M_NOWAIT);
+		sgt = uma_zalloc(fman_mac_sgt_zone, M_NOWAIT);
 		if (sgt == NULL) {
 			if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
 			m_freem(m);
@@ -162,7 +176,7 @@ repeat_with_collapsed_mbuf_chain:
 			if (c == NULL) {
 				if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
 				m_freem(m);
-				uma_zfree(sc->sgt_zone, sgt);
+				uma_zfree(fman_mac_sgt_zone, sgt);
 				continue;
 			}
 
@@ -417,16 +431,10 @@ fman_mac_dev_attach(device_t dev)
 
 	callout_init_mtx(&sc->fman_mac_callout, &sc->mtx, 0);
 
-	sc->sgt_zone = uma_zcreate("FMan MAC SGT", sizeof(struct fman_mac_sgt),
-	    NULL, NULL, NULL, NULL, 16, 0);
-	if (sc->sgt_zone == NULL) {
-		goto error_0;
-	}
-
 	/* Set up the Ethernet interface */
 	sc->ifp = ifp = if_alloc(IFT_ETHER);
 	if (sc->ifp == NULL) {
-		goto error_1;
+		goto error;
 	}
 
 	snprintf(&sc->name[0], sizeof(sc->name), "fm%im",
@@ -468,9 +476,7 @@ fman_mac_dev_attach(device_t dev)
 	return (0);
 
 	if_free(ifp);
-error_1:
-	uma_zdestroy(sc->sgt_zone);
-error_0:
+error:
 	mtx_destroy(&sc->mtx);
 	return (ENXIO);
 }
@@ -487,7 +493,6 @@ fman_mac_dev_detach(device_t _dev)
 	FMAN_MAC_UNLOCK(sc);
 
 	if_free(sc->ifp);
-	uma_zdestroy(sc->sgt_zone);
 	mtx_destroy(&sc->mtx);
 
 	return (bus_generic_detach(_dev));
@@ -570,16 +575,14 @@ fman_mac_miibus_statchg(device_t dev)
 
 void dpaa_cleanup_tx_fd(struct ifnet *ifp, const struct qm_fd *fd)
 {
-	struct fman_mac_softc *sc;
 	struct fman_mac_sgt *sgt;
 
 	BSD_ASSERT(qm_fd_get_format(fd) == qm_fd_sg);
 
-	sc = ifp->if_softc;
 	sgt = (struct fman_mac_sgt *)qm_fd_addr(fd);
 
 	m_freem(sgt->m);
-	uma_zfree(sc->sgt_zone, sgt);
+	uma_zfree(fman_mac_sgt_zone, sgt);
 }
 
 struct dpaa_priv *
diff --git a/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.h b/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.h
index 92242ae..1765e52 100644
--- a/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.h
+++ b/rtemsbsd/sys/powerpc/drivers/net/ethernet/freescale/dpaa/if_fmanmac.h
@@ -59,7 +59,6 @@ struct fman_mac_softc {
 	struct ifnet		*ifp;
 	int			if_flags;
 	struct mtx		mtx;
-	uma_zone_t		sgt_zone;
 	struct callout		fman_mac_callout;
 	char			name[8];
 };



More information about the vc mailing list