Author: arybchik Date: Wed Feb 18 06:23:16 2015 New Revision: 278941 URL: https://svnweb.freebsd.org/changeset/base/278941
Log: sfxge: support variable-length response to MCDI GET_BOARD_CFG Allocate the minimum or maximum response length for GET_BOARD_CFG as appropriate. When looking up firmware subtypes by partition ID, check the ID against the actual response length. Merge of the patch made by Ben Hutchings in 2011. Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor) Modified: head/sys/dev/sfxge/common/efx_regs_mcdi.h head/sys/dev/sfxge/common/siena_nic.c head/sys/dev/sfxge/common/siena_nvram.c Modified: head/sys/dev/sfxge/common/efx_regs_mcdi.h ============================================================================== --- head/sys/dev/sfxge/common/efx_regs_mcdi.h Wed Feb 18 06:21:59 2015 (r278940) +++ head/sys/dev/sfxge/common/efx_regs_mcdi.h Wed Feb 18 06:23:16 2015 (r278941) @@ -709,7 +709,9 @@ #define MC_CMD_GET_BOARD_CFG_IN_LEN 0 /* MC_CMD_GET_BOARD_CFG_OUT msgresponse */ -#define MC_CMD_GET_BOARD_CFG_OUT_LEN 96 +#define MC_CMD_GET_BOARD_CFG_OUT_LENMIN 96 +#define MC_CMD_GET_BOARD_CFG_OUT_LENMAX 136 +#define MC_CMD_GET_BOARD_CFG_OUT_LEN(num) (72+2*(num)) #define MC_CMD_GET_BOARD_CFG_OUT_BOARD_TYPE_OFST 0 #define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_OFST 4 #define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_LEN 32 @@ -729,7 +731,8 @@ #define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT1_OFST 68 #define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST 72 #define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN 2 -#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_NUM 12 +#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM 12 +#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM 32 /***********************************/ Modified: head/sys/dev/sfxge/common/siena_nic.c ============================================================================== --- head/sys/dev/sfxge/common/siena_nic.c Wed Feb 18 06:21:59 2015 (r278940) +++ head/sys/dev/sfxge/common/siena_nic.c Wed Feb 18 06:23:16 2015 (r278941) @@ -276,7 +276,7 @@ siena_board_cfg( { efx_nic_cfg_t *encp = &(enp->en_nic_cfg); efx_mcdi_iface_t *emip = &(enp->en_u.siena.enu_mip); - uint8_t outbuf[MAX(MC_CMD_GET_BOARD_CFG_OUT_LEN, + uint8_t outbuf[MAX(MC_CMD_GET_BOARD_CFG_OUT_LENMIN, MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN)]; efx_mcdi_req_t req; uint8_t *src; @@ -288,7 +288,7 @@ siena_board_cfg( req.emr_in_buf = NULL; req.emr_in_length = 0; req.emr_out_buf = outbuf; - req.emr_out_length = MC_CMD_GET_BOARD_CFG_OUT_LEN; + req.emr_out_length = MC_CMD_GET_BOARD_CFG_OUT_LENMIN; efx_mcdi_execute(enp, &req); @@ -297,7 +297,7 @@ siena_board_cfg( goto fail1; } - if (req.emr_out_length_used < MC_CMD_GET_BOARD_CFG_OUT_LEN) { + if (req.emr_out_length_used < MC_CMD_GET_BOARD_CFG_OUT_LENMIN) { rc = EMSGSIZE; goto fail2; } Modified: head/sys/dev/sfxge/common/siena_nvram.c ============================================================================== --- head/sys/dev/sfxge/common/siena_nvram.c Wed Feb 18 06:21:59 2015 (r278940) +++ head/sys/dev/sfxge/common/siena_nvram.c Wed Feb 18 06:23:16 2015 (r278941) @@ -587,7 +587,7 @@ siena_nvram_get_subtype( __out uint32_t *subtypep) { efx_mcdi_req_t req; - uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LEN]; + uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMAX]; efx_word_t *fw_list; int rc; @@ -605,17 +605,26 @@ siena_nvram_get_subtype( goto fail1; } - if (req.emr_out_length_used < MC_CMD_GET_BOARD_CFG_OUT_LEN) { + if (req.emr_out_length_used < MC_CMD_GET_BOARD_CFG_OUT_LENMIN) { rc = EMSGSIZE; goto fail2; } + if (req.emr_out_length_used < + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST + + (partn + 1) * sizeof(efx_word_t)) { + rc = ENOENT; + goto fail3; + } + fw_list = MCDI_OUT2(req, efx_word_t, GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST); *subtypep = EFX_WORD_FIELD(fw_list[partn], EFX_WORD_0); return (0); +fail3: + EFSYS_PROBE(fail3); fail2: EFSYS_PROBE(fail2); fail1: _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"