From owner-svn-src-all@freebsd.org Thu Aug 18 10:42:13 2016 Return-Path: Delivered-To: svn-src-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 7CC4ABBE054; Thu, 18 Aug 2016 10:42:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 590F11B3A; Thu, 18 Aug 2016 10:42:13 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7IAgCnb023350; Thu, 18 Aug 2016 10:42:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7IAgCP3023349; Thu, 18 Aug 2016 10:42:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201608181042.u7IAgCP3023349@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 18 Aug 2016 10:42:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r304385 - stable/10/sys/dev/ntb X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2016 10:42:13 -0000 Author: mav Date: Thu Aug 18 10:42:12 2016 New Revision: 304385 URL: https://svnweb.freebsd.org/changeset/base/304385 Log: MFC r302490: Create separate RX taskqueue for each qp. Modified: stable/10/sys/dev/ntb/ntb_transport.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ntb/ntb_transport.c ============================================================================== --- stable/10/sys/dev/ntb/ntb_transport.c Thu Aug 18 10:41:34 2016 (r304384) +++ stable/10/sys/dev/ntb/ntb_transport.c Thu Aug 18 10:42:12 2016 (r304385) @@ -162,6 +162,7 @@ struct ntb_transport_qp { /* ntb_rx_q_lock: synchronize access to rx_XXXX_q */ struct mtx ntb_rx_q_lock; struct task rxc_db_work; + struct taskqueue *rxc_tq; caddr_t rx_buff; ntb_q_idx_t rx_index; ntb_q_idx_t rx_max_entry; @@ -204,6 +205,7 @@ struct ntb_transport_mw { }; struct ntb_transport_ctx { + device_t dev; device_t ntb; struct ntb_transport_mw *mw_vec; struct ntb_transport_qp *qp_vec; @@ -341,6 +343,7 @@ ntb_transport_attach(device_t dev) int rc; unsigned i; + nt->dev = dev; nt->ntb = ntb; nt->mw_count = NTB_MW_COUNT(ntb); nt->mw_vec = malloc(nt->mw_count * sizeof(*nt->mw_vec), M_NTB_T, @@ -501,6 +504,10 @@ ntb_transport_init_queue(struct ntb_tran mtx_init(&qp->ntb_tx_free_q_lock, "ntb tx free q", NULL, MTX_SPIN); mtx_init(&qp->tx_lock, "ntb transport tx", NULL, MTX_DEF); TASK_INIT(&qp->rxc_db_work, 0, ntb_transport_rxc_db, qp); + qp->rxc_tq = taskqueue_create("ntbt_rx", M_WAITOK, + taskqueue_thread_enqueue, &qp->rxc_tq); + taskqueue_start_threads(&qp->rxc_tq, 1, PI_NET, "%s rx%d", + device_get_nameunit(nt->dev), qp_num); STAILQ_INIT(&qp->rx_post_q); STAILQ_INIT(&qp->rx_pend_q); @@ -520,7 +527,8 @@ ntb_transport_free_queue(struct ntb_tran callout_drain(&qp->link_work); NTB_DB_SET_MASK(qp->ntb, 1ull << qp->qp_num); - taskqueue_drain(taskqueue_swi, &qp->rxc_db_work); + taskqueue_drain_all(qp->rxc_tq); + taskqueue_free(qp->rxc_tq); qp->cb_data = NULL; qp->rx_handler = NULL; @@ -783,35 +791,18 @@ static void ntb_transport_rxc_db(void *arg, int pending __unused) { struct ntb_transport_qp *qp = arg; - ntb_q_idx_t i; int rc; - /* - * Limit the number of packets processed in a single interrupt to - * provide fairness to others - */ CTR0(KTR_NTB, "RX: transport_rx"); - for (i = 0; i < qp->rx_max_entry; i++) { - rc = ntb_process_rxc(qp); - if (rc != 0) { - CTR0(KTR_NTB, "RX: process_rxc failed"); - break; - } - } +again: + while ((rc = ntb_process_rxc(qp)) == 0) + ; + CTR1(KTR_NTB, "RX: process_rxc returned %d", rc); - if (i == qp->rx_max_entry) - taskqueue_enqueue(taskqueue_swi, &qp->rxc_db_work); - else if ((NTB_DB_READ(qp->ntb) & (1ull << qp->qp_num)) != 0) { - /* If db is set, clear it and read it back to commit clear. */ + if ((NTB_DB_READ(qp->ntb) & (1ull << qp->qp_num)) != 0) { + /* If db is set, clear it and check queue once more. */ NTB_DB_CLEAR(qp->ntb, 1ull << qp->qp_num); - (void)NTB_DB_READ(qp->ntb); - - /* - * An interrupt may have arrived between finishing - * ntb_process_rxc and clearing the doorbell bit: there might - * be some more work to do. - */ - taskqueue_enqueue(taskqueue_swi, &qp->rxc_db_work); + goto again; } } @@ -973,12 +964,14 @@ ntb_transport_doorbell_callback(void *da BIT_NAND(QP_SETSIZE, &db_bits, &nt->qp_bitmap_free); vec_mask = NTB_DB_VECTOR_MASK(nt->ntb, vector); + if ((vec_mask & (vec_mask - 1)) != 0) + vec_mask &= NTB_DB_READ(nt->ntb); while (vec_mask != 0) { qp_num = ffsll(vec_mask) - 1; if (test_bit(qp_num, &db_bits)) { qp = &nt->qp_vec[qp_num]; - taskqueue_enqueue(taskqueue_swi, &qp->rxc_db_work); + taskqueue_enqueue(qp->rxc_tq, &qp->rxc_db_work); } vec_mask &= ~(1ull << qp_num); @@ -1227,7 +1220,7 @@ ntb_qp_link_work(void *arg) if (qp->event_handler != NULL) qp->event_handler(qp->cb_data, NTB_LINK_UP); - taskqueue_enqueue(taskqueue_swi, &qp->rxc_db_work); + taskqueue_enqueue(qp->rxc_tq, &qp->rxc_db_work); } else if (nt->link_is_up) callout_reset(&qp->link_work, NTB_LINK_DOWN_TIMEOUT * hz / 1000, ntb_qp_link_work, qp);