Index: head/sys/dev/sfxge/common/efx.h =================================================================== --- head/sys/dev/sfxge/common/efx.h +++ head/sys/dev/sfxge/common/efx.h @@ -1176,6 +1176,7 @@ 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) Index: head/sys/dev/sfxge/common/efx_nvram.c =================================================================== --- head/sys/dev/sfxge/common/efx_nvram.c +++ head/sys/dev/sfxge/common/efx_nvram.c @@ -749,6 +749,11 @@ 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 @@ __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; + + 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 > MC_CMD_NVRAM_WRITE_IN_LENMAX) { + if (size > max_data_size) { rc = EINVAL; goto fail1; } Index: head/sys/dev/sfxge/common/hunt_nic.c =================================================================== --- head/sys/dev/sfxge/common/hunt_nic.c +++ head/sys/dev/sfxge/common/hunt_nic.c @@ -1681,6 +1681,7 @@ } 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); Index: head/sys/dev/sfxge/common/hunt_nvram.c =================================================================== --- head/sys/dev/sfxge/common/hunt_nvram.c +++ head/sys/dev/sfxge/common/hunt_nvram.c @@ -1409,14 +1409,32 @@ __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 @@ return (0); +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); Index: head/sys/dev/sfxge/common/siena_nic.c =================================================================== --- head/sys/dev/sfxge/common/siena_nic.c +++ head/sys/dev/sfxge/common/siena_nic.c @@ -420,6 +420,8 @@ 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: