From owner-svn-src-head@freebsd.org Fri Dec 4 06:54:48 2015 Return-Path: Delivered-To: svn-src-head@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 21D86A403B7; Fri, 4 Dec 2015 06:54:48 +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 D283F1BD7; Fri, 4 Dec 2015 06:54:47 +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 tB46skMg010725; Fri, 4 Dec 2015 06:54:46 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB46skXH010721; Fri, 4 Dec 2015 06:54:46 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201512040654.tB46skXH010721@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 4 Dec 2015 06:54:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291747 - head/sys/dev/sfxge/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2015 06:54:48 -0000 Author: arybchik Date: Fri Dec 4 06:54:46 2015 New Revision: 291747 URL: https://svnweb.freebsd.org/changeset/base/291747 Log: sfxge: [EF10] support RxQ scattering control If, for example, a VF is configured to use a 1500 byte MTU, but the port it is attached to is set to 9000 bytes, overlength frames can be received by the VF. As Huntington scatters by default, these overlength packets would be scattered across several descriptors, with all except the last having the CONT bit set. To avoid this, disable scatter when creating RXQs if the firmware supports doing so, which all recent versions do. Then we only get a single descriptor from an overlength frame. This will have the CONT bit set to indicate it was truncated, so we can discard it. Submitted by: Mark Spender Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4354 Modified: head/sys/dev/sfxge/common/efx.h head/sys/dev/sfxge/common/hunt_ev.c head/sys/dev/sfxge/common/hunt_nic.c head/sys/dev/sfxge/common/hunt_rx.c Modified: head/sys/dev/sfxge/common/efx.h ============================================================================== --- head/sys/dev/sfxge/common/efx.h Fri Dec 4 06:51:37 2015 (r291746) +++ head/sys/dev/sfxge/common/efx.h Fri Dec 4 06:54:46 2015 (r291747) @@ -1174,6 +1174,7 @@ typedef struct efx_nic_cfg_s { boolean_t enc_hw_tx_insert_vlan_enabled; /* Datapath firmware vadapter/vport/vswitch support */ boolean_t enc_datapath_cap_evb; + boolean_t enc_rx_disable_scatter_supported; /* External port identifier */ uint8_t enc_external_port; } efx_nic_cfg_t; Modified: head/sys/dev/sfxge/common/hunt_ev.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_ev.c Fri Dec 4 06:51:37 2015 (r291746) +++ head/sys/dev/sfxge/common/hunt_ev.c Fri Dec 4 06:54:46 2015 (r291747) @@ -528,10 +528,14 @@ hunt_ev_rx( if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_CONT) != 0) { /* + * This may be part of a scattered frame, or it may be a + * truncated frame if scatter is disabled on this RXQ. + * Overlength frames can be received if e.g. a VF is configured + * for 1500 MTU but connected to a port set to 9000 MTU + * (see bug56567). * FIXME: There is not yet any driver that supports scatter on * Huntington. Scatter support is required for OSX. */ - EFSYS_ASSERT(0); flags |= EFX_PKT_CONT; } Modified: head/sys/dev/sfxge/common/hunt_nic.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_nic.c Fri Dec 4 06:51:37 2015 (r291746) +++ head/sys/dev/sfxge/common/hunt_nic.c Fri Dec 4 06:54:46 2015 (r291747) @@ -920,6 +920,14 @@ hunt_get_datapath_caps( encp->enc_rx_batching_enabled = B_FALSE; } + /* Check if the firmware supports disabling scatter on RXQs */ + if (MCDI_CMD_DWORD_FIELD(&datapath_capabilities, + GET_CAPABILITIES_OUT_RX_DISABLE_SCATTER) == 1) { + encp->enc_rx_disable_scatter_supported = B_TRUE; + } else { + encp->enc_rx_disable_scatter_supported = B_FALSE; + } + return (0); fail2: Modified: head/sys/dev/sfxge/common/hunt_rx.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_rx.c Fri Dec 4 06:51:37 2015 (r291746) +++ head/sys/dev/sfxge/common/hunt_rx.c Fri Dec 4 06:54:46 2015 (r291747) @@ -46,7 +46,8 @@ efx_mcdi_init_rxq( __in uint32_t target_evq, __in uint32_t label, __in uint32_t instance, - __in efsys_mem_t *esmp) + __in efsys_mem_t *esmp, + __in boolean_t disable_scatter) { efx_mcdi_req_t req; uint8_t payload[ @@ -71,12 +72,13 @@ efx_mcdi_init_rxq( MCDI_IN_SET_DWORD(req, INIT_RXQ_IN_TARGET_EVQ, target_evq); MCDI_IN_SET_DWORD(req, INIT_RXQ_IN_LABEL, label); MCDI_IN_SET_DWORD(req, INIT_RXQ_IN_INSTANCE, instance); - MCDI_IN_POPULATE_DWORD_5(req, INIT_RXQ_IN_FLAGS, - INIT_RXQ_IN_FLAG_BUFF_MODE, 0, - INIT_RXQ_IN_FLAG_HDR_SPLIT, 0, - INIT_RXQ_IN_FLAG_TIMESTAMP, 0, - INIT_RXQ_IN_CRC_MODE, 0, - INIT_RXQ_IN_FLAG_PREFIX, 1); + MCDI_IN_POPULATE_DWORD_6(req, INIT_RXQ_IN_FLAGS, + INIT_RXQ_IN_FLAG_BUFF_MODE, 0, + INIT_RXQ_IN_FLAG_HDR_SPLIT, 0, + INIT_RXQ_IN_FLAG_TIMESTAMP, 0, + INIT_RXQ_IN_CRC_MODE, 0, + INIT_RXQ_IN_FLAG_PREFIX, 1, + INIT_RXQ_IN_FLAG_DISABLE_SCATTER, disable_scatter); MCDI_IN_SET_DWORD(req, INIT_RXQ_IN_OWNER_ID, 0); MCDI_IN_SET_DWORD(req, INIT_RXQ_IN_PORT_ID, EVB_PORT_ID_ASSIGNED); @@ -685,6 +687,7 @@ hunt_rx_qcreate( { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_rc_t rc; + boolean_t disable_scatter; _NOTE(ARGUNUSED(erp)) @@ -704,14 +707,21 @@ hunt_rx_qcreate( goto fail2; } + /* Scatter can only be disabled if the firmware supports doing so */ + if ((type != EFX_RXQ_TYPE_SCATTER) && + enp->en_nic_cfg.enc_rx_disable_scatter_supported) { + disable_scatter = B_TRUE; + } else { + disable_scatter = B_FALSE; + } + /* - * FIXME: Siena code handles different queue types (default, header - * split, scatter); we'll need to do something more here later, but - * all that stuff is TBD for now. + * Note: EFX_RXQ_TYPE_SPLIT_HEADER and EFX_RXQ_TYPE_SPLIT_PAYLOAD are + * not supported here. */ if ((rc = efx_mcdi_init_rxq(enp, n, eep->ee_index, label, index, - esmp)) != 0) + esmp, disable_scatter)) != 0) goto fail3; erp->er_eep = eep;