From owner-svn-soc-all@freebsd.org Mon Jul 4 07:43:55 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93A69B91D08 for ; Mon, 4 Jul 2016 07:43:55 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6EF07261B for ; Mon, 4 Jul 2016 07:43:55 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u647htw6050727 for ; Mon, 4 Jul 2016 07:43:55 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u647hsot050724 for svn-soc-all@FreeBSD.org; Mon, 4 Jul 2016 07:43:54 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 4 Jul 2016 07:43:54 GMT Message-Id: <201607040743.u647hsot050724@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r305712 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2016 07:43:55 -0000 Author: vincenzo Date: Mon Jul 4 07:43:54 2016 New Revision: 305712 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305712 Log: freebsd: ptnet_transmit: add support for multi-queue 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 Mon Jul 4 07:43:40 2016 (r305711) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon Jul 4 07:43:54 2016 (r305712) @@ -132,6 +132,7 @@ struct resource *msix_mem; unsigned int num_rings; + unsigned int num_tx_rings; struct ptnet_queue *queues; struct ptnet_queue *rxqueues; struct ptnet_csb *csb; @@ -290,6 +291,7 @@ num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); sc->num_rings = num_tx_rings + num_rx_rings; + sc->num_tx_rings = num_tx_rings; /* Allocate and initialize per-queue data structures. */ sc->queues = malloc(sizeof(struct ptnet_queue) * sc->num_rings, @@ -522,14 +524,11 @@ { int rid = PCIR_BAR(PTNETMAP_MSIX_PCI_BAR); int nvecs = sc->num_rings; - unsigned int num_tx_rings; device_t dev = sc->dev; int err = ENOSPC; int cpu_cur; int i; - num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); - if (pci_find_cap(dev, PCIY_MSIX, NULL) != 0) { device_printf(dev, "Could not find MSI-X capability\n"); return (ENXIO); @@ -572,7 +571,7 @@ struct ptnet_queue *pq = sc->queues + i; void (*handler)(void *) = ptnet_tx_intr; - if (i >= num_tx_rings) { + if (i >= sc->num_tx_rings) { handler = ptnet_rx_intr; } err = bus_setup_intr(dev, pq->irq, INTR_TYPE_NET | INTR_MPSAFE, @@ -598,7 +597,7 @@ struct ptnet_queue *pq = sc->queues + i; static void (*handler)(void *context, int pending); - handler = (i < num_tx_rings) ? ptnet_tx_task : ptnet_rx_task; + handler = (i < sc->num_tx_rings) ? ptnet_tx_task : ptnet_rx_task; TASK_INIT(&pq->task, 0, handler, pq); pq->taskq = taskqueue_create_fast("ptnet_queue", M_NOWAIT, @@ -1323,11 +1322,20 @@ { struct ptnet_softc *sc = ifp->if_softc; struct ptnet_queue *pq; + unsigned int queue_idx; int err; DBG(device_printf(sc->dev, "transmit %p\n", m)); - pq = sc->queues + 0; + /* Get the flow-id if available. */ + queue_idx = (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) ? + m->m_pkthdr.flowid : curcpu; + + if (unlikely(queue_idx >= sc->num_tx_rings)) { + queue_idx %= sc->num_tx_rings; + } + + pq = sc->queues + queue_idx; err = drbr_enqueue(ifp, pq->bufring, m); if (err) {