From owner-svn-src-all@freebsd.org Mon Dec 7 06:01:16 2015 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 7E35B9B793C; Mon, 7 Dec 2015 06:01:16 +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 3A23B12BE; Mon, 7 Dec 2015 06:01:16 +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 tB761FXq015550; Mon, 7 Dec 2015 06:01:15 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB761EJu015545; Mon, 7 Dec 2015 06:01:14 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201512070601.tB761EJu015545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Mon, 7 Dec 2015 06:01:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291923 - 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-all@freebsd.org X-Mailman-Version: 2.1.20 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: Mon, 07 Dec 2015 06:01:16 -0000 Author: arybchik Date: Mon Dec 7 06:01:14 2015 New Revision: 291923 URL: https://svnweb.freebsd.org/changeset/base/291923 Log: sfxge: [Sorrento] support writing of MUM firmware When writing the MUM firmware the chunk size must be equal to the erase size. Submitted by: Laurence Evans Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4388 Modified: head/sys/dev/sfxge/common/efx.h head/sys/dev/sfxge/common/efx_nvram.c head/sys/dev/sfxge/common/hunt_nic.c head/sys/dev/sfxge/common/hunt_nvram.c head/sys/dev/sfxge/common/siena_nic.c Modified: head/sys/dev/sfxge/common/efx.h ============================================================================== --- head/sys/dev/sfxge/common/efx.h Mon Dec 7 05:59:24 2015 (r291922) +++ head/sys/dev/sfxge/common/efx.h Mon Dec 7 06:01:14 2015 (r291923) @@ -1176,6 +1176,7 @@ typedef struct efx_nic_cfg_s { boolean_t enc_allow_set_mac_with_installed_filters; /* External port identifier */ uint8_t enc_external_port; + uint32_t enc_mcdi_max_payload_length; } efx_nic_cfg_t; #define EFX_PCI_FUNCTION_IS_PF(_encp) ((_encp)->enc_vf == 0xffff) Modified: head/sys/dev/sfxge/common/efx_nvram.c ============================================================================== --- head/sys/dev/sfxge/common/efx_nvram.c Mon Dec 7 05:59:24 2015 (r291922) +++ head/sys/dev/sfxge/common/efx_nvram.c Mon Dec 7 06:01:14 2015 (r291923) @@ -749,6 +749,11 @@ fail1: return (rc); } +/* + * The NVRAM_WRITE MCDI command is a V1 command and so is supported by both + * Sienna and EF10 based boards. However EF10 based boards support the use + * of this command with payloads up to the maximum MCDI V2 payload length. + */ __checkReturn efx_rc_t efx_mcdi_nvram_write( __in efx_nic_t *enp, @@ -758,11 +763,18 @@ efx_mcdi_nvram_write( __in size_t size) { efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_NVRAM_WRITE_IN_LENMAX, - MC_CMD_NVRAM_WRITE_OUT_LEN)]; + uint8_t payload[MAX(MCDI_CTL_SDU_LEN_MAX_V1, + MCDI_CTL_SDU_LEN_MAX_V2)]; efx_rc_t rc; + size_t max_data_size; - if (size > MC_CMD_NVRAM_WRITE_IN_LENMAX) { + max_data_size = enp->en_nic_cfg.enc_mcdi_max_payload_length + - MC_CMD_NVRAM_WRITE_IN_LEN(0); + EFSYS_ASSERT3U(enp->en_nic_cfg.enc_mcdi_max_payload_length, >, 0); + EFSYS_ASSERT3U(max_data_size, <, + enp->en_nic_cfg.enc_mcdi_max_payload_length); + + if (size > max_data_size) { rc = EINVAL; goto fail1; } Modified: head/sys/dev/sfxge/common/hunt_nic.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_nic.c Mon Dec 7 05:59:24 2015 (r291922) +++ head/sys/dev/sfxge/common/hunt_nic.c Mon Dec 7 06:01:14 2015 (r291923) @@ -1681,6 +1681,7 @@ hunt_nic_init( } enp->en_vport_id = EVB_PORT_ID_ASSIGNED; + enp->en_nic_cfg.enc_mcdi_max_payload_length = MCDI_CTL_SDU_LEN_MAX_V2; return (0); Modified: head/sys/dev/sfxge/common/hunt_nvram.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_nvram.c Mon Dec 7 05:59:24 2015 (r291922) +++ head/sys/dev/sfxge/common/hunt_nvram.c Mon Dec 7 06:01:14 2015 (r291923) @@ -1409,14 +1409,32 @@ hunt_nvram_partn_write( __in size_t size) { size_t chunk; + uint32_t write_size; efx_rc_t rc; + if ((rc = efx_mcdi_nvram_info(enp, partn, NULL, NULL, + NULL, &write_size)) != 0) + goto fail1; + + if (write_size != 0) { + /* + * Check that the size is a multiple of the write chunk size if + * the write chunk size is available. + */ + if (size % write_size != 0) { + rc = EINVAL; + goto fail2; + } + } else { + write_size = HUNTINGTON_NVRAM_CHUNK; + } + while (size > 0) { - chunk = MIN(size, HUNTINGTON_NVRAM_CHUNK); + chunk = MIN(size, write_size); if ((rc = efx_mcdi_nvram_write(enp, partn, offset, data, chunk)) != 0) { - goto fail1; + goto fail3; } size -= chunk; @@ -1426,6 +1444,10 @@ hunt_nvram_partn_write( return (0); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); Modified: head/sys/dev/sfxge/common/siena_nic.c ============================================================================== --- head/sys/dev/sfxge/common/siena_nic.c Mon Dec 7 05:59:24 2015 (r291922) +++ head/sys/dev/sfxge/common/siena_nic.c Mon Dec 7 06:01:14 2015 (r291923) @@ -420,6 +420,8 @@ siena_nic_init( if ((rc = siena_phy_reconfigure(enp)) != 0) goto fail2; + enp->en_nic_cfg.enc_mcdi_max_payload_length = MCDI_CTL_SDU_LEN_MAX_V1; + return (0); fail2: