From: Andy Moreton Date: Mon, 10 Sep 2018 09:33:25 +0000 (+0100) Subject: net/sfc/base: fix ID retrieval in v3 licensing X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=416aa7f1c98acfaf996a54f63fd2a02dc5ef3a73;p=dpdk.git net/sfc/base: fix ID retrieval in v3 licensing Fixes: 05fce2ce8451 ("net/sfc/base: import libefx licensing") Fixes: f67e4719147d ("net/sfc/base: fix coding style") Cc: stable@dpdk.org Signed-off-by: Andy Moreton Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/base/efx_lic.c b/drivers/net/sfc/base/efx_lic.c index 2a6da2647f..4081aef1b9 100644 --- a/drivers/net/sfc/base/efx_lic.c +++ b/drivers/net/sfc/base/efx_lic.c @@ -983,26 +983,14 @@ efx_mcdi_licensing_v3_get_id( { efx_mcdi_req_t req; EFX_MCDI_DECLARE_BUF(payload, MC_CMD_LICENSING_GET_ID_V3_IN_LEN, - MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN); + MC_CMD_LICENSING_GET_ID_V3_OUT_LENMAX); efx_rc_t rc; req.emr_cmd = MC_CMD_LICENSING_GET_ID_V3; - - if (bufferp == NULL) { - /* Request id type and length only */ - req.emr_in_buf = bufferp; - req.emr_in_length = MC_CMD_LICENSING_GET_ID_V3_IN_LEN; - req.emr_out_buf = bufferp; - req.emr_out_length = MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN; - } else { - /* Request full buffer */ - req.emr_in_buf = bufferp; - req.emr_in_length = MC_CMD_LICENSING_GET_ID_V3_IN_LEN; - req.emr_out_buf = bufferp; - req.emr_out_length = - MIN(buffer_size, MC_CMD_LICENSING_GET_ID_V3_OUT_LENMAX); - (void) memset(bufferp, 0, req.emr_out_length); - } + req.emr_in_buf = payload; + req.emr_in_length = MC_CMD_LICENSING_GET_ID_V3_IN_LEN; + req.emr_out_buf = payload; + req.emr_out_length = MC_CMD_LICENSING_GET_ID_V3_OUT_LENMAX; efx_mcdi_execute_quiet(enp, &req); @@ -1020,19 +1008,10 @@ efx_mcdi_licensing_v3_get_id( *lengthp = MCDI_OUT_DWORD(req, LICENSING_GET_ID_V3_OUT_LICENSE_ID_LENGTH); - if (bufferp == NULL) { - /* - * Modify length requirements to indicate to caller the extra - * buffering needed to read the complete output. - */ - *lengthp += MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN; - } else { - /* Shift ID down to start of buffer */ - memmove(bufferp, - bufferp + MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST, - *lengthp); - memset(bufferp + (*lengthp), 0, - MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST); + if (bufferp != NULL) { + memcpy(bufferp, + payload + MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST, + MIN(buffer_size, *lengthp)); } return (0);