Date: Wed, 20 Jan 2016 08:26:58 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r294403 - stable/10/sys/dev/sfxge/common Message-ID: <201601200826.u0K8QwAM037684@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Wed Jan 20 08:26:58 2016 New Revision: 294403 URL: https://svnweb.freebsd.org/changeset/base/294403 Log: MFC r294309 sfxge: select whether to read current or backup partition in Medford A/B scheme The dynamic config on Medford is stored using two partitions in flash, and at any time one is the 'current' partition, used to provide the active config, and the other 'backup' partition is used for writes. This means that there are two potential partitions that can be used to service reads, and which is required can depend on, for example, whether the read is to get the current contents or to verify a write. When the partition write lock is held, the default behaviour is to read from the backup partition, which was wrong for most reads in the common code which require the current partition. This change allows the current partition to be read whilst the write lock is held. There is one read in Manftest which needs the backup partition. ef10_nvram_partn_read_mode() is created to avoid changing ef10_nvram_partn_read() which shares a prototype with the equivalent Falcon and Siena methods. MC_CMD_NVRAM_READ_IN_V2 adds an extra field, but firmware which doesn't support it just ignores it. Submitted by: Mark Spender <mspender at solarflare.com> Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_impl.h stable/10/sys/dev/sfxge/common/efx_nvram.c stable/10/sys/dev/sfxge/common/hunt_impl.h stable/10/sys/dev/sfxge/common/hunt_nvram.c stable/10/sys/dev/sfxge/common/siena_nvram.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_impl.h Wed Jan 20 08:25:41 2016 (r294402) +++ stable/10/sys/dev/sfxge/common/efx_impl.h Wed Jan 20 08:26:58 2016 (r294403) @@ -559,7 +559,8 @@ efx_mcdi_nvram_read( __in uint32_t partn, __in uint32_t offset, __out_bcount(size) caddr_t data, - __in size_t size); + __in size_t size, + __in uint32_t mode); __checkReturn efx_rc_t efx_mcdi_nvram_erase( Modified: stable/10/sys/dev/sfxge/common/efx_nvram.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_nvram.c Wed Jan 20 08:25:41 2016 (r294402) +++ stable/10/sys/dev/sfxge/common/efx_nvram.c Wed Jan 20 08:26:58 2016 (r294403) @@ -721,10 +721,11 @@ efx_mcdi_nvram_read( __in uint32_t partn, __in uint32_t offset, __out_bcount(size) caddr_t data, - __in size_t size) + __in size_t size, + __in uint32_t mode) { efx_mcdi_req_t req; - uint8_t payload[MAX(MC_CMD_NVRAM_READ_IN_LEN, + uint8_t payload[MAX(MC_CMD_NVRAM_READ_IN_V2_LEN, MC_CMD_NVRAM_READ_OUT_LENMAX)]; efx_rc_t rc; @@ -736,13 +737,14 @@ efx_mcdi_nvram_read( (void) memset(payload, 0, sizeof (payload)); req.emr_cmd = MC_CMD_NVRAM_READ; req.emr_in_buf = payload; - req.emr_in_length = MC_CMD_NVRAM_READ_IN_LEN; + req.emr_in_length = MC_CMD_NVRAM_READ_IN_V2_LEN; req.emr_out_buf = payload; req.emr_out_length = MC_CMD_NVRAM_READ_OUT_LENMAX; - MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_TYPE, partn); - MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_OFFSET, offset); - MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_LENGTH, size); + MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_V2_TYPE, partn); + MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_V2_OFFSET, offset); + MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_V2_LENGTH, size); + MCDI_IN_SET_DWORD(req, NVRAM_READ_IN_V2_MODE, mode); efx_mcdi_execute(enp, &req); Modified: stable/10/sys/dev/sfxge/common/hunt_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/hunt_impl.h Wed Jan 20 08:25:41 2016 (r294402) +++ stable/10/sys/dev/sfxge/common/hunt_impl.h Wed Jan 20 08:26:58 2016 (r294403) @@ -409,6 +409,15 @@ ef10_nvram_partn_rw_start( __out size_t *chunk_sizep); extern __checkReturn efx_rc_t +ef10_nvram_partn_read_mode( + __in efx_nic_t *enp, + __in uint32_t partn, + __in unsigned int offset, + __out_bcount(size) caddr_t data, + __in size_t size, + __in uint32_t mode); + +extern __checkReturn efx_rc_t ef10_nvram_partn_read( __in efx_nic_t *enp, __in uint32_t partn, Modified: stable/10/sys/dev/sfxge/common/hunt_nvram.c ============================================================================== --- stable/10/sys/dev/sfxge/common/hunt_nvram.c Wed Jan 20 08:25:41 2016 (r294402) +++ stable/10/sys/dev/sfxge/common/hunt_nvram.c Wed Jan 20 08:26:58 2016 (r294403) @@ -598,8 +598,9 @@ ef10_nvram_read_tlv_segment( } /* Read initial chunk of the segment, starting at offset */ - if ((rc = ef10_nvram_partn_read(enp, partn, seg_offset, seg_data, - EF10_NVRAM_CHUNK)) != 0) { + if ((rc = ef10_nvram_partn_read_mode(enp, partn, seg_offset, seg_data, + EF10_NVRAM_CHUNK, + MC_CMD_NVRAM_READ_IN_V2_TARGET_CURRENT)) != 0) { goto fail2; } @@ -624,10 +625,11 @@ ef10_nvram_read_tlv_segment( /* Read the remaining segment content */ if (total_length > EF10_NVRAM_CHUNK) { - if ((rc = ef10_nvram_partn_read(enp, partn, + if ((rc = ef10_nvram_partn_read_mode(enp, partn, seg_offset + EF10_NVRAM_CHUNK, seg_data + EF10_NVRAM_CHUNK, - total_length - EF10_NVRAM_CHUNK)) != 0) + total_length - EF10_NVRAM_CHUNK, + MC_CMD_NVRAM_READ_IN_V2_TARGET_CURRENT)) != 0) goto fail6; } @@ -1321,12 +1323,13 @@ fail1: } __checkReturn efx_rc_t -ef10_nvram_partn_read( +ef10_nvram_partn_read_mode( __in efx_nic_t *enp, __in uint32_t partn, __in unsigned int offset, __out_bcount(size) caddr_t data, - __in size_t size) + __in size_t size, + __in uint32_t mode) { size_t chunk; efx_rc_t rc; @@ -1335,7 +1338,7 @@ ef10_nvram_partn_read( chunk = MIN(size, EF10_NVRAM_CHUNK); if ((rc = efx_mcdi_nvram_read(enp, partn, offset, - data, chunk)) != 0) { + data, chunk, mode)) != 0) { goto fail1; } @@ -1353,6 +1356,22 @@ fail1: } __checkReturn efx_rc_t +ef10_nvram_partn_read( + __in efx_nic_t *enp, + __in uint32_t partn, + __in unsigned int offset, + __out_bcount(size) caddr_t data, + __in size_t size) +{ + /* + * Read requests which come in through the EFX API expect to + * read the current, active partition. + */ + return ef10_nvram_partn_read_mode(enp, partn, offset, data, size, + MC_CMD_NVRAM_READ_IN_V2_TARGET_CURRENT); +} + + __checkReturn efx_rc_t ef10_nvram_partn_erase( __in efx_nic_t *enp, __in uint32_t partn, Modified: stable/10/sys/dev/sfxge/common/siena_nvram.c ============================================================================== --- stable/10/sys/dev/sfxge/common/siena_nvram.c Wed Jan 20 08:25:41 2016 (r294402) +++ stable/10/sys/dev/sfxge/common/siena_nvram.c Wed Jan 20 08:26:58 2016 (r294403) @@ -99,8 +99,8 @@ siena_nvram_partn_read( while (size > 0) { chunk = MIN(size, SIENA_NVRAM_CHUNK); - if ((rc = efx_mcdi_nvram_read(enp, partn, offset, - data, chunk)) != 0) { + if ((rc = efx_mcdi_nvram_read(enp, partn, offset, data, chunk, + MC_CMD_NVRAM_READ_IN_V2_DEFAULT)) != 0) { goto fail1; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601200826.u0K8QwAM037684>