aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/base/efx_lic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sfc/base/efx_lic.c')
-rw-r--r--drivers/net/sfc/base/efx_lic.c228
1 files changed, 84 insertions, 144 deletions
diff --git a/drivers/net/sfc/base/efx_lic.c b/drivers/net/sfc/base/efx_lic.c
index 2cd05cc8..ad4d2211 100644
--- a/drivers/net/sfc/base/efx_lic.c
+++ b/drivers/net/sfc/base/efx_lic.c
@@ -1,31 +1,7 @@
-/*
- * Copyright (c) 2009-2016 Solarflare Communications Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
+/* SPDX-License-Identifier: BSD-3-Clause
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are
- * those of the authors and should not be interpreted as representing official
- * policies, either expressed or implied, of the FreeBSD Project.
+ * Copyright (c) 2009-2018 Solarflare Communications Inc.
+ * All rights reserved.
*/
#include "efx.h"
@@ -43,8 +19,7 @@ efx_lic_v1v2_find_start(
__in_bcount(buffer_size)
caddr_t bufferp,
__in size_t buffer_size,
- __out uint32_t *startp
- );
+ __out uint32_t *startp);
__checkReturn efx_rc_t
efx_lic_v1v2_find_end(
@@ -53,8 +28,7 @@ efx_lic_v1v2_find_end(
caddr_t bufferp,
__in size_t buffer_size,
__in uint32_t offset,
- __out uint32_t *endp
- );
+ __out uint32_t *endp);
__checkReturn __success(return != B_FALSE) boolean_t
efx_lic_v1v2_find_key(
@@ -64,15 +38,13 @@ efx_lic_v1v2_find_key(
__in size_t buffer_size,
__in uint32_t offset,
__out uint32_t *startp,
- __out uint32_t *lengthp
- );
+ __out uint32_t *lengthp);
__checkReturn __success(return != B_FALSE) boolean_t
efx_lic_v1v2_validate_key(
__in efx_nic_t *enp,
__in_bcount(length) caddr_t keyp,
- __in uint32_t length
- );
+ __in uint32_t length);
__checkReturn efx_rc_t
efx_lic_v1v2_read_key(
@@ -85,8 +57,7 @@ efx_lic_v1v2_read_key(
__out_bcount_part(key_max_size, *lengthp)
caddr_t keyp,
__in size_t key_max_size,
- __out uint32_t *lengthp
- );
+ __out uint32_t *lengthp);
__checkReturn efx_rc_t
efx_lic_v1v2_write_key(
@@ -97,8 +68,7 @@ efx_lic_v1v2_write_key(
__in uint32_t offset,
__in_bcount(length) caddr_t keyp,
__in uint32_t length,
- __out uint32_t *lengthp
- );
+ __out uint32_t *lengthp);
__checkReturn efx_rc_t
efx_lic_v1v2_delete_key(
@@ -109,24 +79,21 @@ efx_lic_v1v2_delete_key(
__in uint32_t offset,
__in uint32_t length,
__in uint32_t end,
- __out uint32_t *deltap
- );
+ __out uint32_t *deltap);
__checkReturn efx_rc_t
efx_lic_v1v2_create_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- );
+ __in size_t buffer_size);
__checkReturn efx_rc_t
efx_lic_v1v2_finish_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- );
+ __in size_t buffer_size);
#endif /* EFSYS_OPT_HUNTINGTON | EFSYS_OPT_SIENA */
@@ -227,8 +194,7 @@ efx_lic_v3_find_start(
__in_bcount(buffer_size)
caddr_t bufferp,
__in size_t buffer_size,
- __out uint32_t *startp
- );
+ __out uint32_t *startp);
__checkReturn efx_rc_t
efx_lic_v3_find_end(
@@ -237,8 +203,7 @@ efx_lic_v3_find_end(
caddr_t bufferp,
__in size_t buffer_size,
__in uint32_t offset,
- __out uint32_t *endp
- );
+ __out uint32_t *endp);
__checkReturn __success(return != B_FALSE) boolean_t
efx_lic_v3_find_key(
@@ -248,15 +213,13 @@ efx_lic_v3_find_key(
__in size_t buffer_size,
__in uint32_t offset,
__out uint32_t *startp,
- __out uint32_t *lengthp
- );
+ __out uint32_t *lengthp);
__checkReturn __success(return != B_FALSE) boolean_t
efx_lic_v3_validate_key(
__in efx_nic_t *enp,
__in_bcount(length) caddr_t keyp,
- __in uint32_t length
- );
+ __in uint32_t length);
__checkReturn efx_rc_t
efx_lic_v3_read_key(
@@ -269,8 +232,7 @@ efx_lic_v3_read_key(
__out_bcount_part(key_max_size, *lengthp)
caddr_t keyp,
__in size_t key_max_size,
- __out uint32_t *lengthp
- );
+ __out uint32_t *lengthp);
__checkReturn efx_rc_t
efx_lic_v3_write_key(
@@ -281,8 +243,7 @@ efx_lic_v3_write_key(
__in uint32_t offset,
__in_bcount(length) caddr_t keyp,
__in uint32_t length,
- __out uint32_t *lengthp
- );
+ __out uint32_t *lengthp);
__checkReturn efx_rc_t
efx_lic_v3_delete_key(
@@ -293,31 +254,28 @@ efx_lic_v3_delete_key(
__in uint32_t offset,
__in uint32_t length,
__in uint32_t end,
- __out uint32_t *deltap
- );
+ __out uint32_t *deltap);
__checkReturn efx_rc_t
efx_lic_v3_create_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- );
+ __in size_t buffer_size);
__checkReturn efx_rc_t
efx_lic_v3_finish_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- );
+ __in size_t buffer_size);
static const efx_lic_ops_t __efx_lic_v3_ops = {
efx_mcdi_licensing_v3_update_licenses, /* elo_update_licenses */
efx_mcdi_licensing_v3_report_license, /* elo_get_key_stats */
efx_mcdi_licensing_v3_app_state, /* elo_app_state */
efx_mcdi_licensing_v3_get_id, /* elo_get_id */
- efx_lic_v3_find_start, /* elo_find_start*/
+ efx_lic_v3_find_start, /* elo_find_start */
efx_lic_v3_find_end, /* elo_find_end */
efx_lic_v3_find_key, /* elo_find_key */
efx_lic_v3_validate_key, /* elo_validate_key */
@@ -452,8 +410,8 @@ fail1:
* Length (L): 16bit - value length in bytes
* Value (V): L bytes - payload
*/
-#define EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX (256)
-#define EFX_LICENSE_V1V2_HEADER_LENGTH (2 * sizeof(uint16_t))
+#define EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX (256)
+#define EFX_LICENSE_V1V2_HEADER_LENGTH (2 * sizeof (uint16_t))
__checkReturn efx_rc_t
efx_lic_v1v2_find_start(
@@ -461,8 +419,7 @@ efx_lic_v1v2_find_start(
__in_bcount(buffer_size)
caddr_t bufferp,
__in size_t buffer_size,
- __out uint32_t *startp
- )
+ __out uint32_t *startp)
{
_NOTE(ARGUNUSED(enp, bufferp, buffer_size))
@@ -477,8 +434,7 @@ efx_lic_v1v2_find_end(
caddr_t bufferp,
__in size_t buffer_size,
__in uint32_t offset,
- __out uint32_t *endp
- )
+ __out uint32_t *endp)
{
_NOTE(ARGUNUSED(enp, bufferp, buffer_size))
@@ -494,8 +450,7 @@ efx_lic_v1v2_find_key(
__in size_t buffer_size,
__in uint32_t offset,
__out uint32_t *startp,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
boolean_t found;
uint16_t tlv_type;
@@ -519,7 +474,7 @@ efx_lic_v1v2_find_key(
return (found);
fail1:
- EFSYS_PROBE(fail1);
+ EFSYS_PROBE1(fail1, boolean_t, B_FALSE);
return (B_FALSE);
}
@@ -528,8 +483,7 @@ fail1:
efx_lic_v1v2_validate_key(
__in efx_nic_t *enp,
__in_bcount(length) caddr_t keyp,
- __in uint32_t length
- )
+ __in uint32_t length)
{
uint16_t tlv_type;
uint16_t tlv_length;
@@ -562,7 +516,7 @@ fail3:
fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE(fail1);
+ EFSYS_PROBE1(fail1, boolean_t, B_FALSE);
return (B_FALSE);
}
@@ -579,12 +533,11 @@ efx_lic_v1v2_read_key(
__out_bcount_part(key_max_size, *lengthp)
caddr_t keyp,
__in size_t key_max_size,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
efx_rc_t rc;
- _NOTE(ARGUNUSED(enp))
+ _NOTE(ARGUNUSED(enp, buffer_size))
EFSYS_ASSERT(length <= (EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX +
EFX_LICENSE_V1V2_HEADER_LENGTH));
@@ -613,8 +566,7 @@ efx_lic_v1v2_write_key(
__in uint32_t offset,
__in_bcount(length) caddr_t keyp,
__in uint32_t length,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
efx_rc_t rc;
@@ -650,13 +602,12 @@ efx_lic_v1v2_delete_key(
__in uint32_t offset,
__in uint32_t length,
__in uint32_t end,
- __out uint32_t *deltap
- )
+ __out uint32_t *deltap)
{
uint32_t move_start = offset + length;
uint32_t move_length = end - move_start;
- _NOTE(ARGUNUSED(enp))
+ _NOTE(ARGUNUSED(enp, buffer_size))
EFSYS_ASSERT(end <= buffer_size);
/* Shift everything after the key down */
@@ -672,10 +623,9 @@ efx_lic_v1v2_create_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- )
+ __in size_t buffer_size)
{
- _NOTE(ARGUNUSED(enp))
+ _NOTE(ARGUNUSED(enp, buffer_size))
EFSYS_ASSERT(EFX_LICENSE_V1V2_HEADER_LENGTH <= buffer_size);
/* Write terminator */
@@ -689,8 +639,7 @@ efx_lic_v1v2_finish_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- )
+ __in size_t buffer_size)
{
_NOTE(ARGUNUSED(enp, bufferp, buffer_size))
@@ -1002,7 +951,8 @@ efx_mcdi_licensing_v3_app_state(
goto fail1;
}
- if (req.emr_out_length_used < MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_LEN) {
+ if (req.emr_out_length_used <
+ MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_LEN) {
rc = EMSGSIZE;
goto fail2;
}
@@ -1052,7 +1002,8 @@ efx_mcdi_licensing_v3_get_id(
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);
+ req.emr_out_length =
+ MIN(buffer_size, MC_CMD_LICENSING_GET_ID_V3_OUT_LENMAX);
(void) memset(bufferp, 0, req.emr_out_length);
}
@@ -1069,12 +1020,14 @@ efx_mcdi_licensing_v3_get_id(
}
*typep = MCDI_OUT_DWORD(req, LICENSING_GET_ID_V3_OUT_LICENSE_TYPE);
- *lengthp = MCDI_OUT_DWORD(req, LICENSING_GET_ID_V3_OUT_LICENSE_ID_LENGTH);
+ *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.
- */
+ /*
+ * 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 */
@@ -1096,8 +1049,8 @@ fail1:
}
/* V3 format uses Huntington TLV format partition. See SF-108797-SW */
-#define EFX_LICENSE_V3_KEY_LENGTH_MIN (64)
-#define EFX_LICENSE_V3_KEY_LENGTH_MAX (160)
+#define EFX_LICENSE_V3_KEY_LENGTH_MIN (64)
+#define EFX_LICENSE_V3_KEY_LENGTH_MAX (160)
__checkReturn efx_rc_t
efx_lic_v3_find_start(
@@ -1105,12 +1058,12 @@ efx_lic_v3_find_start(
__in_bcount(buffer_size)
caddr_t bufferp,
__in size_t buffer_size,
- __out uint32_t *startp
- )
+ __out uint32_t *startp)
{
_NOTE(ARGUNUSED(enp))
- return ef10_nvram_buffer_find_item_start(bufferp, buffer_size, startp);
+ return (ef10_nvram_buffer_find_item_start(bufferp, buffer_size,
+ startp));
}
__checkReturn efx_rc_t
@@ -1120,12 +1073,11 @@ efx_lic_v3_find_end(
caddr_t bufferp,
__in size_t buffer_size,
__in uint32_t offset,
- __out uint32_t *endp
- )
+ __out uint32_t *endp)
{
_NOTE(ARGUNUSED(enp))
- return ef10_nvram_buffer_find_end(bufferp, buffer_size, offset, endp);
+ return (ef10_nvram_buffer_find_end(bufferp, buffer_size, offset, endp));
}
__checkReturn __success(return != B_FALSE) boolean_t
@@ -1136,8 +1088,7 @@ efx_lic_v3_find_key(
__in size_t buffer_size,
__in uint32_t offset,
__out uint32_t *startp,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
_NOTE(ARGUNUSED(enp))
@@ -1149,8 +1100,7 @@ efx_lic_v3_find_key(
efx_lic_v3_validate_key(
__in efx_nic_t *enp,
__in_bcount(length) caddr_t keyp,
- __in uint32_t length
- )
+ __in uint32_t length)
{
/* Check key is a valid V3 key */
uint8_t key_type;
@@ -1184,7 +1134,7 @@ fail3:
fail2:
EFSYS_PROBE(fail2);
fail1:
- EFSYS_PROBE(fail1);
+ EFSYS_PROBE1(fail1, boolean_t, B_FALSE);
return (B_FALSE);
}
@@ -1200,8 +1150,7 @@ efx_lic_v3_read_key(
__out_bcount_part(key_max_size, *lengthp)
caddr_t keyp,
__in size_t key_max_size,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
_NOTE(ARGUNUSED(enp))
@@ -1218,8 +1167,7 @@ efx_lic_v3_write_key(
__in uint32_t offset,
__in_bcount(length) caddr_t keyp,
__in uint32_t length,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
_NOTE(ARGUNUSED(enp))
EFSYS_ASSERT(length <= EFX_LICENSE_V3_KEY_LENGTH_MAX);
@@ -1237,8 +1185,7 @@ efx_lic_v3_delete_key(
__in uint32_t offset,
__in uint32_t length,
__in uint32_t end,
- __out uint32_t *deltap
- )
+ __out uint32_t *deltap)
{
efx_rc_t rc;
@@ -1264,8 +1211,7 @@ efx_lic_v3_create_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- )
+ __in size_t buffer_size)
{
efx_rc_t rc;
@@ -1290,8 +1236,7 @@ efx_lic_v3_finish_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- )
+ __in size_t buffer_size)
{
efx_rc_t rc;
@@ -1383,7 +1328,7 @@ efx_lic_check_support(
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
- return enp->en_licensing_supported;
+ return (enp->en_licensing_supported);
}
void
@@ -1474,8 +1419,7 @@ efx_lic_get_id(
__in size_t buffer_size,
__out uint32_t *typep,
__out size_t *lengthp,
- __out_opt uint8_t *bufferp
- )
+ __out_opt uint8_t *bufferp)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1498,7 +1442,10 @@ fail1:
return (rc);
}
-/* Buffer management API - abstracts varying TLV format used for License partition */
+/*
+ * Buffer management API - abstracts varying TLV format used for License
+ * partition.
+ */
__checkReturn efx_rc_t
efx_lic_find_start(
@@ -1506,8 +1453,7 @@ efx_lic_find_start(
__in_bcount(buffer_size)
caddr_t bufferp,
__in size_t buffer_size,
- __out uint32_t *startp
- )
+ __out uint32_t *startp)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1533,8 +1479,7 @@ efx_lic_find_end(
caddr_t bufferp,
__in size_t buffer_size,
__in uint32_t offset,
- __out uint32_t *endp
- )
+ __out uint32_t *endp)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1542,7 +1487,8 @@ efx_lic_find_end(
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
- if ((rc = elop->elo_find_end(enp, bufferp, buffer_size, offset, endp)) != 0)
+ rc = elop->elo_find_end(enp, bufferp, buffer_size, offset, endp);
+ if (rc != 0)
goto fail1;
return (0);
@@ -1561,8 +1507,7 @@ efx_lic_find_key(
__in size_t buffer_size,
__in uint32_t offset,
__out uint32_t *startp,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
const efx_lic_ops_t *elop = enp->en_elop;
@@ -1578,15 +1523,15 @@ efx_lic_find_key(
}
-/* Validate that the buffer contains a single key in a recognised format.
-** An empty or terminator buffer is not accepted as a valid key.
-*/
+/*
+ * Validate that the buffer contains a single key in a recognised format.
+ * An empty or terminator buffer is not accepted as a valid key.
+ */
__checkReturn __success(return != B_FALSE) boolean_t
efx_lic_validate_key(
__in efx_nic_t *enp,
__in_bcount(length) caddr_t keyp,
- __in uint32_t length
- )
+ __in uint32_t length)
{
const efx_lic_ops_t *elop = enp->en_elop;
boolean_t rc;
@@ -1616,8 +1561,7 @@ efx_lic_read_key(
__out_bcount_part(key_max_size, *lengthp)
caddr_t keyp,
__in size_t key_max_size,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1646,8 +1590,7 @@ efx_lic_write_key(
__in uint32_t offset,
__in_bcount(length) caddr_t keyp,
__in uint32_t length,
- __out uint32_t *lengthp
- )
+ __out uint32_t *lengthp)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1676,8 +1619,7 @@ efx_lic_delete_key(
__in uint32_t offset,
__in uint32_t length,
__in uint32_t end,
- __out uint32_t *deltap
- )
+ __out uint32_t *deltap)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1702,8 +1644,7 @@ efx_lic_create_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- )
+ __in size_t buffer_size)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;
@@ -1728,8 +1669,7 @@ efx_lic_finish_partition(
__in efx_nic_t *enp,
__in_bcount(buffer_size)
caddr_t bufferp,
- __in size_t buffer_size
- )
+ __in size_t buffer_size)
{
const efx_lic_ops_t *elop = enp->en_elop;
efx_rc_t rc;