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 <levans at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision: https://reviews.freebsd.org/D4388
This commit is contained in:
arybchik 2015-12-07 06:01:14 +00:00
parent 9a5e277612
commit 5dc5e31412
5 changed files with 43 additions and 5 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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: