From owner-svn-src-stable@freebsd.org Fri Jun 17 08:56:03 2016 Return-Path: Delivered-To: svn-src-stable@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 416B9A78CBD; Fri, 17 Jun 2016 08:56:03 +0000 (UTC) (envelope-from arybchik@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 1C5052D18; Fri, 17 Jun 2016 08:56:03 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5H8u225011036; Fri, 17 Jun 2016 08:56:02 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5H8u1XR011030; Fri, 17 Jun 2016 08:56:01 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201606170856.u5H8u1XR011030@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 17 Jun 2016 08:56:01 +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: r301980 - in stable/10/sys/dev/sfxge: . common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 08:56:03 -0000 Author: arybchik Date: Fri Jun 17 08:56:01 2016 New Revision: 301980 URL: https://svnweb.freebsd.org/changeset/base/301980 Log: MFC r301122 sfxge(4): set moderation in efx_ev_qcreate This simplifies setting an initial interrupt moderation value, and avoids most calls to evx_ev_qmoderate from contexts where MCDI is not allowed (MCDI is need for an EVQ timer workaround in a later patch). Submitted by: Andy Moreton Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D6673 Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c stable/10/sys/dev/sfxge/common/ef10_impl.h stable/10/sys/dev/sfxge/common/efx.h stable/10/sys/dev/sfxge/common/efx_ev.c stable/10/sys/dev/sfxge/common/efx_impl.h stable/10/sys/dev/sfxge/sfxge_ev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/ef10_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/ef10_ev.c Fri Jun 17 08:56:01 2016 (r301980) @@ -92,8 +92,10 @@ efx_mcdi_init_evq( __in unsigned int instance, __in efsys_mem_t *esmp, __in size_t nevs, - __in uint32_t irq) + __in uint32_t irq, + __in uint32_t us) { + efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_mcdi_req_t req; uint8_t payload[ MAX(MC_CMD_INIT_EVQ_IN_LEN(EFX_EVQ_NBUFS(EFX_EVQ_MAXNEVS)), @@ -141,10 +143,26 @@ efx_mcdi_init_evq( INIT_EVQ_IN_FLAG_RX_MERGE, 1, INIT_EVQ_IN_FLAG_TX_MERGE, 1); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, - MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, 0); - MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, 0); + if (us == 0) { + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, + MC_CMD_INIT_EVQ_IN_TMR_MODE_DIS); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, 0); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, 0); + } else { + uint32_t timer_val; + + /* Calculate the timer value in quanta */ + timer_val = us * 1000 / encp->enc_evq_timer_quantum_ns; + + /* Moderation value is base 0 so we need to deduct 1 */ + if (timer_val > 0) + timer_val--; + + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_MODE, + MC_CMD_INIT_EVQ_IN_TMR_INT_HLDOFF); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_LOAD, timer_val); + MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_TMR_RELOAD, timer_val); + } MCDI_IN_SET_DWORD(req, INIT_EVQ_IN_COUNT_MODE, MC_CMD_INIT_EVQ_IN_COUNT_MODE_DIS); @@ -246,6 +264,7 @@ ef10_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep) { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); @@ -266,6 +285,11 @@ ef10_ev_qcreate( goto fail2; } + if (us > encp->enc_evq_timer_max_us) { + rc = EINVAL; + goto fail3; + } + /* Set up the handler table */ eep->ee_rx = ef10_ev_rx; eep->ee_tx = ef10_ev_tx; @@ -280,11 +304,13 @@ ef10_ev_qcreate( * Interrupts may be raised for events immediately after the queue is * created. See bug58606. */ - if ((rc = efx_mcdi_init_evq(enp, index, esmp, n, irq)) != 0) - goto fail3; + if ((rc = efx_mcdi_init_evq(enp, index, esmp, n, irq, us)) != 0) + goto fail4; return (0); +fail4: + EFSYS_PROBE(fail4); fail3: EFSYS_PROBE(fail3); fail2: Modified: stable/10/sys/dev/sfxge/common/ef10_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/ef10_impl.h Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/ef10_impl.h Fri Jun 17 08:56:01 2016 (r301980) @@ -84,6 +84,7 @@ ef10_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep); void Modified: stable/10/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/efx.h Fri Jun 17 08:56:01 2016 (r301980) @@ -1602,6 +1602,7 @@ efx_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __deref_out efx_evq_t **eepp); extern void Modified: stable/10/sys/dev/sfxge/common/efx_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/efx_ev.c Fri Jun 17 08:56:01 2016 (r301980) @@ -70,6 +70,7 @@ siena_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep); static void @@ -226,6 +227,7 @@ efx_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __deref_out efx_evq_t **eepp) { const efx_ev_ops_t *eevop = enp->en_eevop; @@ -262,7 +264,7 @@ efx_ev_qcreate( enp->en_ev_qcount++; *eepp = eep; - if ((rc = eevop->eevo_qcreate(enp, index, esmp, n, id, eep)) != 0) + if ((rc = eevop->eevo_qcreate(enp, index, esmp, n, id, us, eep)) != 0) goto fail2; return (0); @@ -1257,6 +1259,7 @@ siena_ev_qcreate( __in efsys_mem_t *esmp, __in size_t n, __in uint32_t id, + __in uint32_t us, __in efx_evq_t *eep) { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); @@ -1312,6 +1315,9 @@ siena_ev_qcreate( EFX_BAR_TBL_WRITEO(enp, FR_AZ_EVQ_PTR_TBL, index, &oword, B_TRUE); + /* Set initial interrupt moderation */ + siena_ev_qmoderate(eep, us); + return (0); fail4: Modified: stable/10/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_impl.h Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/common/efx_impl.h Fri Jun 17 08:56:01 2016 (r301980) @@ -95,7 +95,7 @@ typedef struct efx_ev_ops_s { void (*eevo_fini)(efx_nic_t *); efx_rc_t (*eevo_qcreate)(efx_nic_t *, unsigned int, efsys_mem_t *, size_t, uint32_t, - efx_evq_t *); + uint32_t, efx_evq_t *); void (*eevo_qdestroy)(efx_evq_t *); efx_rc_t (*eevo_qprime)(efx_evq_t *, unsigned int); void (*eevo_qpost)(efx_evq_t *, uint16_t); Modified: stable/10/sys/dev/sfxge/sfxge_ev.c ============================================================================== --- stable/10/sys/dev/sfxge/sfxge_ev.c Fri Jun 17 08:54:43 2016 (r301979) +++ stable/10/sys/dev/sfxge/sfxge_ev.c Fri Jun 17 08:56:01 2016 (r301980) @@ -699,14 +699,11 @@ sfxge_ev_qstart(struct sfxge_softc *sc, /* Create the common code event queue. */ if ((rc = efx_ev_qcreate(sc->enp, index, esmp, evq->entries, - evq->buf_base_id, &evq->common)) != 0) + evq->buf_base_id, sc->ev_moderation, &evq->common)) != 0) goto fail; SFXGE_EVQ_LOCK(evq); - /* Set the default moderation */ - (void)efx_ev_qmoderate(evq->common, sc->ev_moderation); - /* Prime the event queue for interrupts */ if ((rc = efx_ev_qprime(evq->common, evq->read_ptr)) != 0) goto fail2;