common/sfc_efx/base: add API for querying board info
Riverhead boards can provide extended version information. Implement facilities necessary to obtain it. Add an API for querying board information. A client driver may use this to discover which of its instances relate to which physical boards, based on board serial number persistence for a given physical board. Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
parent
312191e86e
commit
833cfcd590
@ -1647,6 +1647,22 @@ efx_nic_get_fw_version(
|
||||
__in efx_nic_t *enp,
|
||||
__out efx_nic_fw_info_t *enfip);
|
||||
|
||||
#define EFX_NIC_BOARD_INFO_SERIAL_LEN (64)
|
||||
#define EFX_NIC_BOARD_INFO_NAME_LEN (16)
|
||||
|
||||
typedef struct efx_nic_board_info_s {
|
||||
/* The following two fields are NUL-terminated ASCII strings. */
|
||||
char enbi_serial[EFX_NIC_BOARD_INFO_SERIAL_LEN];
|
||||
char enbi_name[EFX_NIC_BOARD_INFO_NAME_LEN];
|
||||
uint32_t enbi_revision;
|
||||
} efx_nic_board_info_t;
|
||||
|
||||
LIBEFX_API
|
||||
extern __checkReturn efx_rc_t
|
||||
efx_nic_get_board_info(
|
||||
__in efx_nic_t *enp,
|
||||
__out efx_nic_board_info_t *board_infop);
|
||||
|
||||
/* Driver resource limits (minimum required/maximum usable). */
|
||||
typedef struct efx_drv_limits_s {
|
||||
uint32_t edl_min_evq_count;
|
||||
|
@ -964,11 +964,13 @@ efx_mcdi_ev_death(
|
||||
__checkReturn efx_rc_t
|
||||
efx_mcdi_get_version(
|
||||
__in efx_nic_t *enp,
|
||||
__in uint32_t flags_req,
|
||||
__out efx_mcdi_version_t *verp)
|
||||
{
|
||||
efx_nic_board_info_t *board_infop = &verp->emv_board_info;
|
||||
EFX_MCDI_DECLARE_BUF(payload,
|
||||
MC_CMD_GET_VERSION_IN_LEN,
|
||||
MC_CMD_GET_VERSION_OUT_LEN);
|
||||
MC_CMD_GET_VERSION_EXT_IN_LEN,
|
||||
MC_CMD_GET_VERSION_V2_OUT_LEN);
|
||||
size_t min_resp_len_required;
|
||||
efx_mcdi_req_t req;
|
||||
efx_rc_t rc;
|
||||
@ -978,15 +980,35 @@ efx_mcdi_get_version(
|
||||
EFX_STATIC_ASSERT(sizeof (verp->emv_firmware) ==
|
||||
MC_CMD_GET_VERSION_OUT_FIRMWARE_LEN);
|
||||
|
||||
EFX_STATIC_ASSERT(EFX_MCDI_VERSION_BOARD_INFO ==
|
||||
(1U << MC_CMD_GET_VERSION_V2_OUT_BOARD_EXT_INFO_PRESENT_LBN));
|
||||
|
||||
EFX_STATIC_ASSERT(sizeof (board_infop->enbi_serial) ==
|
||||
MC_CMD_GET_VERSION_V2_OUT_BOARD_SERIAL_LEN);
|
||||
EFX_STATIC_ASSERT(sizeof (board_infop->enbi_name) ==
|
||||
MC_CMD_GET_VERSION_V2_OUT_BOARD_NAME_LEN);
|
||||
EFX_STATIC_ASSERT(sizeof (board_infop->enbi_revision) ==
|
||||
MC_CMD_GET_VERSION_V2_OUT_BOARD_REVISION_LEN);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
|
||||
|
||||
req.emr_cmd = MC_CMD_GET_VERSION;
|
||||
req.emr_in_buf = payload;
|
||||
req.emr_out_buf = payload;
|
||||
req.emr_in_length = MC_CMD_GET_VERSION_IN_LEN;
|
||||
req.emr_out_length = MC_CMD_GET_VERSION_OUT_LEN;
|
||||
|
||||
min_resp_len_required = MC_CMD_GET_VERSION_V0_OUT_LEN;
|
||||
if (flags_req != 0) {
|
||||
/* Request basic + extended version information. */
|
||||
req.emr_in_length = MC_CMD_GET_VERSION_EXT_IN_LEN;
|
||||
req.emr_out_length = MC_CMD_GET_VERSION_V2_OUT_LEN;
|
||||
|
||||
min_resp_len_required = MC_CMD_GET_VERSION_V2_OUT_LEN;
|
||||
} else {
|
||||
/* Request only basic version information. */
|
||||
req.emr_in_length = MC_CMD_GET_VERSION_IN_LEN;
|
||||
req.emr_out_length = MC_CMD_GET_VERSION_OUT_LEN;
|
||||
|
||||
min_resp_len_required = MC_CMD_GET_VERSION_V0_OUT_LEN;
|
||||
}
|
||||
|
||||
efx_mcdi_execute(enp, &req);
|
||||
|
||||
@ -1020,6 +1042,20 @@ efx_mcdi_get_version(
|
||||
|
||||
verp->emv_firmware = MCDI_OUT_DWORD(req, GET_VERSION_OUT_FIRMWARE);
|
||||
|
||||
verp->emv_flags = MCDI_OUT_DWORD(req, GET_VERSION_V2_OUT_FLAGS);
|
||||
verp->emv_flags &= flags_req;
|
||||
|
||||
if ((verp->emv_flags & EFX_MCDI_VERSION_BOARD_INFO) != 0) {
|
||||
memcpy(board_infop->enbi_serial,
|
||||
MCDI_OUT2(req, char, GET_VERSION_V2_OUT_BOARD_SERIAL),
|
||||
sizeof (board_infop->enbi_serial));
|
||||
memcpy(board_infop->enbi_name,
|
||||
MCDI_OUT2(req, char, GET_VERSION_V2_OUT_BOARD_NAME),
|
||||
sizeof (board_infop->enbi_name));
|
||||
board_infop->enbi_revision =
|
||||
MCDI_OUT_DWORD(req, GET_VERSION_V2_OUT_BOARD_REVISION);
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
fail3:
|
||||
@ -1090,7 +1126,7 @@ efx_mcdi_version(
|
||||
efx_mcdi_boot_t status;
|
||||
efx_rc_t rc;
|
||||
|
||||
rc = efx_mcdi_get_version(enp, &ver);
|
||||
rc = efx_mcdi_get_version(enp, 0, &ver);
|
||||
if (rc != 0)
|
||||
goto fail1;
|
||||
|
||||
|
@ -118,16 +118,34 @@ efx_mcdi_raise_exception(
|
||||
__in_opt efx_mcdi_req_t *emrp,
|
||||
__in int rc);
|
||||
|
||||
/*
|
||||
* Flags that name portions of extended version information
|
||||
*
|
||||
* The values match their MCDI counterparts.
|
||||
*/
|
||||
#define EFX_MCDI_VERSION_BOARD_INFO (1U << 4)
|
||||
|
||||
typedef struct efx_mcdi_version_s {
|
||||
/* Basic version information */
|
||||
uint16_t emv_version[4];
|
||||
uint32_t emv_firmware;
|
||||
|
||||
/*
|
||||
* Extended version information
|
||||
*
|
||||
* Valid portions of obtained information are indicated by flags.
|
||||
*/
|
||||
uint32_t emv_flags;
|
||||
|
||||
/* Information valid if emv_flags has EFX_MCDI_VERSION_BOARD_INFO set */
|
||||
efx_nic_board_info_t emv_board_info;
|
||||
} efx_mcdi_version_t;
|
||||
|
||||
LIBEFX_INTERNAL
|
||||
extern __checkReturn efx_rc_t
|
||||
efx_mcdi_get_version(
|
||||
__in efx_nic_t *enp,
|
||||
__in uint32_t flags_req,
|
||||
__out efx_mcdi_version_t *verp);
|
||||
|
||||
typedef enum efx_mcdi_boot_e {
|
||||
|
@ -791,6 +791,52 @@ efx_nic_get_fw_version(
|
||||
|
||||
return (0);
|
||||
|
||||
fail3:
|
||||
EFSYS_PROBE(fail3);
|
||||
fail2:
|
||||
EFSYS_PROBE(fail2);
|
||||
fail1:
|
||||
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
||||
|
||||
return (rc);
|
||||
}
|
||||
|
||||
__checkReturn efx_rc_t
|
||||
efx_nic_get_board_info(
|
||||
__in efx_nic_t *enp,
|
||||
__out efx_nic_board_info_t *board_infop)
|
||||
{
|
||||
efx_mcdi_version_t ver;
|
||||
efx_rc_t rc;
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
|
||||
EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
|
||||
|
||||
rc = efx_mcdi_get_version(enp, EFX_MCDI_VERSION_BOARD_INFO, &ver);
|
||||
if (rc == EMSGSIZE) {
|
||||
/*
|
||||
* Typically, EMSGSIZE is returned by above call in the
|
||||
* case when the NIC does not provide extra information.
|
||||
*/
|
||||
rc = ENOTSUP;
|
||||
goto fail1;
|
||||
} else if (rc != 0) {
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
if ((ver.emv_flags & EFX_MCDI_VERSION_BOARD_INFO) == 0) {
|
||||
rc = ENOTSUP;
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
memcpy(board_infop, &ver.emv_board_info, sizeof (*board_infop));
|
||||
|
||||
/* MCDI should provide NUL-terminated strings, but stay vigilant. */
|
||||
board_infop->enbi_serial[sizeof (board_infop->enbi_serial) - 1] = '\0';
|
||||
board_infop->enbi_name[sizeof (board_infop->enbi_name) - 1] = '\0';
|
||||
|
||||
return (0);
|
||||
|
||||
fail3:
|
||||
EFSYS_PROBE(fail3);
|
||||
fail2:
|
||||
|
@ -131,6 +131,7 @@ INTERNAL {
|
||||
efx_nic_destroy;
|
||||
efx_nic_fini;
|
||||
efx_nic_get_bar_region;
|
||||
efx_nic_get_board_info;
|
||||
efx_nic_get_fw_subvariant;
|
||||
efx_nic_get_fw_version;
|
||||
efx_nic_get_vi_pool;
|
||||
|
Loading…
Reference in New Issue
Block a user