summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarybchik <arybchik@FreeBSD.org>2016-01-19 06:03:44 +0000
committerarybchik <arybchik@FreeBSD.org>2016-01-19 06:03:44 +0000
commite6feb41fb00b99ac863bbb6784838070478ae73c (patch)
tree20caffa027c1b3db86ff96d9d1efba27f3df237b
parentefa39bda1b02d9056f6f52efed6dc85673c3f6c7 (diff)
downloadFreeBSD-src-e6feb41fb00b99ac863bbb6784838070478ae73c.zip
FreeBSD-src-e6feb41fb00b99ac863bbb6784838070478ae73c.tar.gz
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. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4974
-rw-r--r--sys/dev/sfxge/common/efx_impl.h3
-rw-r--r--sys/dev/sfxge/common/efx_nvram.c14
-rw-r--r--sys/dev/sfxge/common/hunt_impl.h9
-rw-r--r--sys/dev/sfxge/common/hunt_nvram.c33
-rw-r--r--sys/dev/sfxge/common/siena_nvram.c4
5 files changed, 47 insertions, 16 deletions
diff --git a/sys/dev/sfxge/common/efx_impl.h b/sys/dev/sfxge/common/efx_impl.h
index 3faf2dd..5495b15 100644
--- a/sys/dev/sfxge/common/efx_impl.h
+++ b/sys/dev/sfxge/common/efx_impl.h
@@ -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(
diff --git a/sys/dev/sfxge/common/efx_nvram.c b/sys/dev/sfxge/common/efx_nvram.c
index 463596f..272e6c7 100644
--- a/sys/dev/sfxge/common/efx_nvram.c
+++ b/sys/dev/sfxge/common/efx_nvram.c
@@ -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);
diff --git a/sys/dev/sfxge/common/hunt_impl.h b/sys/dev/sfxge/common/hunt_impl.h
index 9f53df8..49ecbea 100644
--- a/sys/dev/sfxge/common/hunt_impl.h
+++ b/sys/dev/sfxge/common/hunt_impl.h
@@ -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,
diff --git a/sys/dev/sfxge/common/hunt_nvram.c b/sys/dev/sfxge/common/hunt_nvram.c
index bc9c827..dd471f4 100644
--- a/sys/dev/sfxge/common/hunt_nvram.c
+++ b/sys/dev/sfxge/common/hunt_nvram.c
@@ -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,
diff --git a/sys/dev/sfxge/common/siena_nvram.c b/sys/dev/sfxge/common/siena_nvram.c
index 476e666..9708e0c 100644
--- a/sys/dev/sfxge/common/siena_nvram.c
+++ b/sys/dev/sfxge/common/siena_nvram.c
@@ -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;
}
OpenPOWER on IntegriCloud