49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Copyright (c) 2009-2015 Solarflare Communications Inc.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * All rights reserved.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Redistribution and use in source and binary forms, with or without
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * modification, are permitted provided that the following conditions are met:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 1. Redistributions of source code must retain the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 2. Redistributions in binary form must reproduce the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer in the documentation
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * and/or other materials provided with the distribution.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * The views and conclusions contained in the software and documentation are
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * those of the authors and should not be interpreted as representing official
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * policies, either expressed or implied, of the FreeBSD Project.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_HUNTINGTON | EFSYS_OPT_SIENA */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestatic const efx_lic_ops_t __efx_lic_v1_ops = {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_fc_license_update_license, /* elo_update_licenses */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_fc_license_get_key_stats, /* elo_get_key_stats */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_find_start, /* elo_find_start */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_validate_key, /* elo_validate_key */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_delete_key, /* elo_delete_key */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_create_partition, /* elo_create_partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_finish_partition, /* elo_finish_partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_SIENA */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestatic const efx_lic_ops_t __efx_lic_v2_ops = {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensing_update_licenses, /* elo_update_licenses */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensing_get_key_stats, /* elo_get_key_stats */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensed_app_state, /* elo_app_state */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_find_start, /* elo_find_start */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_validate_key, /* elo_validate_key */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_delete_key, /* elo_delete_key */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_create_partition, /* elo_create_partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v1v2_finish_partition, /* elo_finish_partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_HUNTINGTON */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __out_bcount_part_opt(buffer_size, *lengthp)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestatic const efx_lic_ops_t __efx_lic_v3_ops = {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensing_v3_update_licenses, /* elo_update_licenses */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensing_v3_report_license, /* elo_get_key_stats */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensing_v3_app_state, /* elo_app_state */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_mcdi_licensing_v3_get_id, /* elo_get_id */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v3_validate_key, /* elo_validate_key */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v3_create_partition, /* elo_create_partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore efx_lic_v3_finish_partition, /* elo_finish_partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_MEDFORD */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* V1 Licensing - used in Siena Modena only */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_FC_IN_LICENSE_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_FC_IN_LICENSE_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_SIENA);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_FC_IN_LICENSE_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_FC_OUT_LICENSE_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_FC_OUT_LICENSE_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, FC_OUT_LICENSE_VALID_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, FC_OUT_LICENSE_INVALID_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, FC_OUT_LICENSE_BLACKLISTED_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_SIENA */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* V1 and V2 Partition format - based on a 16-bit TLV format */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * V1/V2 format - defined in SF-108542-TC section 4.2:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Type (T): 16bit - revision/HMAC algorithm
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Length (L): 16bit - value length in bytes
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Value (V): L bytes - payload
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#define EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX (256)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#define EFX_LICENSE_V1V2_HEADER_LENGTH (2*sizeof(uint16_t))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *endp = offset + EFX_LICENSE_V1V2_HEADER_LENGTH;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if((size_t)buffer_size - offset < EFX_LICENSE_V1V2_HEADER_LENGTH)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore tlv_type = __LE_TO_CPU_16(((uint16_t*)&bufferp[offset])[0]);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore tlv_length = __LE_TO_CPU_16(((uint16_t*)&bufferp[offset])[1]);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((tlv_length > EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX) ||
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *lengthp = tlv_length + EFX_LICENSE_V1V2_HEADER_LENGTH;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (length < EFX_LICENSE_V1V2_HEADER_LENGTH) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore tlv_type = __LE_TO_CPU_16(((uint16_t*)keyp)[0]);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore tlv_length = __LE_TO_CPU_16(((uint16_t*)keyp)[1]);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if(tlv_length > EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((tlv_length + EFX_LICENSE_V1V2_HEADER_LENGTH) != length) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(length <= (EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX +
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memcpy(keyp, &bufferp[offset], length);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(length <= (EFX_LICENSE_V1V2_PAYLOAD_LENGTH_MAX +
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore // Ensure space for terminator remains
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (buffer_size - EFX_LICENSE_V1V2_HEADER_LENGTH) ) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memcpy(bufferp + offset, keyp, length);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore // Shift everything after the key down
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore memmove(bufferp + offset, bufferp + move_start, move_length);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(EFX_LICENSE_V1V2_HEADER_LENGTH <= buffer_size);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore // Write terminator
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(bufferp, '\0', EFX_LICENSE_V1V2_HEADER_LENGTH);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_HUNTINGTON | EFSYS_OPT_SIENA */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* V2 Licensing - used by Huntington family only. See SF-113611-TC */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_GET_LICENSED_APP_STATE_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* V2 licensing supports 32bit app id only */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_cmd = MC_CMD_GET_LICENSED_APP_STATE;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_GET_LICENSED_APP_STATE_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_GET_LICENSED_APP_STATE_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, GET_LICENSED_APP_STATE_IN_APP_ID,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_GET_LICENSED_APP_STATE_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore app_state = (MCDI_OUT_DWORD(req, GET_LICENSED_APP_STATE_OUT_STATE));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (app_state != MC_CMD_GET_LICENSED_APP_STATE_OUT_NOT_LICENSED) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_LICENSING_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_LICENSING_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_LICENSING_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_LICENSING_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_LICENSING_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_OUT_VALID_APP_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_OUT_INVALID_APP_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_OUT_BLACKLISTED_APP_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_OUT_UNVERIFIABLE_APP_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_OUT_WRONG_NODE_APP_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_HUNTINGTON */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* V3 Licensing - used starting from Medford family. See SF-114884-SW */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MC_CMD_LICENSING_V3_IN_LEN];
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_MEDFORD);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_LICENSING_V3_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_LICENSING_V3_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_MEDFORD);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_LICENSING_V3_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_LICENSING_V3_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_LICENSING_V3_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_VALID_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_INVALID_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_UNVERIFIABLE_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_WRONG_NODE_KEYS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_LICENSED_APPS_LO);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_LICENSED_APPS_HI);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_LICENSED_FEATURES_LO);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, LICENSING_V3_OUT_LICENSED_FEATURES_HI);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_GET_LICENSED_V3_APP_STATE_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(enp->en_family == EFX_FAMILY_MEDFORD);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_cmd = MC_CMD_GET_LICENSED_V3_APP_STATE;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_GET_LICENSED_V3_APP_STATE_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, GET_LICENSED_V3_APP_STATE_IN_APP_ID_LO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, GET_LICENSED_V3_APP_STATE_IN_APP_ID_HI,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore app_state = (MCDI_OUT_DWORD(req, GET_LICENSED_V3_APP_STATE_OUT_STATE));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (app_state != MC_CMD_GET_LICENSED_V3_APP_STATE_OUT_NOT_LICENSED) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __out_bcount_part_opt(buffer_size, *lengthp)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_LICENSING_GET_ID_V3_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Request id type and length only */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_LICENSING_GET_ID_V3_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Request full buffer */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_LICENSING_GET_ID_V3_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MIN(buffer_size, MC_CMD_LICENSING_GET_ID_V3_OUT_LENMAX);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(bufferp, 0, req.emr_out_length);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *typep = MCDI_OUT_DWORD(req, LICENSING_GET_ID_V3_OUT_LICENSE_TYPE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *lengthp = MCDI_OUT_DWORD(req, LICENSING_GET_ID_V3_OUT_LICENSE_ID_LENGTH);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* modify length requirements to indicate to caller the extra buffering
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore ** needed to read the complete output.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *lengthp += MC_CMD_LICENSING_GET_ID_V3_OUT_LENMIN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Shift ID down to start of buffer */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore bufferp+MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MC_CMD_LICENSING_GET_ID_V3_OUT_LICENSE_ID_OFST);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* V3 format uses Huntington TLV format partition. See SF-108797-SW */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return ef10_nvram_buffer_find_item_start(bufferp, buffer_size, startp);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return ef10_nvram_buffer_find_end(bufferp, buffer_size, offset, endp);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return ef10_nvram_buffer_find_item(bufferp, buffer_size,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore // Check key is a valid V3 key
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (length < EFX_LICENSE_V3_KEY_LENGTH_MIN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore key_length = ((uint8_t*)keyp)[1] + EFX_LICENSE_V3_HASH_LENGTH;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if(key_length > EFX_LICENSE_V3_KEY_LENGTH_MAX) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return ef10_nvram_buffer_get_item(bufferp, buffer_size,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore offset, length, keyp, key_max_size, lengthp);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(length <= EFX_LICENSE_V3_KEY_LENGTH_MAX);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return ef10_nvram_buffer_insert_item(bufferp, buffer_size,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = ef10_nvram_buffer_delete_item(bufferp,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore // Construct empty partition
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore // Validate completed partition
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = ef10_nvram_buffer_validate(enp, NVRAM_PARTITION_TYPE_LICENSE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_MEDFORD */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_LIC));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_SIENA */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_HUNTINGTON */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_MEDFORD */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_update_licenses(enp)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_get_key_stats(enp, eksp)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_app_state(enp, app_id, licensedp)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_get_id(enp, buffer_size, typep,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* Buffer management API - abstracts varying TLV format used for License partition */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_find_start(enp, bufferp, buffer_size, startp)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_find_end(enp, bufferp, buffer_size, offset, endp)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return (elop->elo_find_key(enp, bufferp, buffer_size, offset,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* Validate that the buffer contains a single key in a recognised format.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore** An empty or terminator buffer is not accepted as a valid key.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __checkReturn __success(return != B_FALSE) boolean_t
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_validate_key(enp, keyp, length)) == B_FALSE)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_read_key(enp, bufferp, buffer_size, offset,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_write_key(enp, bufferp, buffer_size, offset,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_delete_key(enp, bufferp, buffer_size, offset,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_create_partition(enp, bufferp, buffer_size)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_LIC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = elop->elo_finish_partition(enp, bufferp, buffer_size)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_LICENSING */