Date: Tue, 31 May 2016 10:22:28 GMT From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r304243 - soc2016/vincenzo/head/sys/dev/netmap Message-ID: <201605311022.u4VAMSpt066544@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: vincenzo Date: Tue May 31 10:22:27 2016 New Revision: 304243 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304243 Log: freebsd: ptnet: per-queue data structure Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Tue May 31 09:24:16 2016 (r304242) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Tue May 31 10:22:27 2016 (r304243) @@ -90,6 +90,14 @@ #error "No support for on-device CSB" #endif +struct ptnet_softc; + +struct ptnet_queue { + struct ptnet_softc *sc; + struct resource *irq; + int kring_id; +}; + struct ptnet_softc { device_t dev; struct ifnet *ifp; @@ -106,7 +114,7 @@ struct resource *msix_mem; unsigned int num_rings; - + struct ptnet_queue *queues; struct ptnet_csb *csb; }; @@ -183,6 +191,7 @@ struct ifnet *ifp; uint32_t macreg; int err, rid; + int i; device_printf(dev, "%s\n", __func__); @@ -216,6 +225,24 @@ num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); sc->num_rings = num_tx_rings + num_rx_rings; + /* Allocate per-queue data structures. */ + sc->queues = malloc(sizeof(struct ptnet_queue) * sc->num_rings, + M_DEVBUF, M_NOWAIT | M_ZERO); + if (sc->queues == NULL) { + err = ENOMEM; + goto err_path; + } + + for (i = 0; i < sc->num_rings; i++) { + struct ptnet_queue *pq = sc->queues + i; + + pq->sc = sc; + pq->kring_id = i; + if (i >= num_tx_rings) { + pq->kring_id -= num_tx_rings; + } + } + /* Allocate CSB and carry out CSB allocation protocol (CSBBAH first, * then CSBBAL). */ sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, @@ -311,6 +338,11 @@ sc->csb = NULL; } + if (sc->queues) { + free(sc->queues, M_DEVBUF); + sc->queues = NULL; + } + if (sc->iomem) { bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(PTNETMAP_IO_PCI_BAR), sc->iomem);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605311022.u4VAMSpt066544>