sfxge: Medford still needs fallback for no privilege mask

Submitted by:   Mark Spender <mspender at solarflare.com>
Reviewed by:    gnn
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision: https://reviews.freebsd.org/D4936
This commit is contained in:
Andrew Rybchenko 2016-01-15 06:27:51 +00:00
parent 739ebba619
commit 80af6f263c
4 changed files with 46 additions and 18 deletions

View File

@ -81,6 +81,11 @@ extern __checkReturn efx_rc_t
ef10_get_datapath_caps(
__in efx_nic_t *enp);
extern __checkReturn efx_rc_t
ef10_get_privilege_mask(
__in efx_nic_t *enp,
__out uint32_t *maskp);
extern __checkReturn efx_rc_t
ef10_external_port_mapping(
__in efx_nic_t *enp,

View File

@ -742,7 +742,7 @@ ef10_tx_qstats_update(
#define HUNT_MIN_PIO_ALLOC_SIZE (HUNT_PIOBUF_SIZE / 32)
#define HUNT_LEGACY_PF_PRIVILEGE_MASK \
#define EF10_LEGACY_PF_PRIVILEGE_MASK \
(MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN | \
MC_CMD_PRIVILEGE_MASK_IN_GRP_LINK | \
MC_CMD_PRIVILEGE_MASK_IN_GRP_ONLOAD | \
@ -755,7 +755,7 @@ ef10_tx_qstats_update(
MC_CMD_PRIVILEGE_MASK_IN_GRP_ALL_MULTICAST | \
MC_CMD_PRIVILEGE_MASK_IN_GRP_PROMISCUOUS)
#define HUNT_LEGACY_VF_PRIVILEGE_MASK 0
#define EF10_LEGACY_VF_PRIVILEGE_MASK 0
typedef uint32_t efx_piobuf_handle_t;

View File

@ -980,6 +980,42 @@ fail1:
return (rc);
}
__checkReturn efx_rc_t
ef10_get_privilege_mask(
__in efx_nic_t *enp,
__out uint32_t *maskp)
{
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
uint32_t mask;
efx_rc_t rc;
if ((rc = efx_mcdi_privilege_mask(enp, encp->enc_pf, encp->enc_vf,
&mask)) != 0) {
if (rc != ENOTSUP)
goto fail1;
/* Fallback for old firmware without privilege mask support */
if (EFX_PCI_FUNCTION_IS_PF(encp)) {
/* Assume PF has admin privilege */
mask = EF10_LEGACY_PF_PRIVILEGE_MASK;
} else {
/* VF is always unprivileged by default */
mask = EF10_LEGACY_VF_PRIVILEGE_MASK;
}
}
*maskp = mask;
return (0);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
/*
* The external port mapping is a one-based numbering of the external
* connectors on the board. It does not distinguish off-board separated
@ -1312,20 +1348,8 @@ hunt_board_cfg(
* the privilege mask to check for sufficient privileges, as that
* can result in time-of-check/time-of-use bugs.
*/
if ((rc = efx_mcdi_privilege_mask(enp, pf, vf, &mask)) != 0) {
if (rc != ENOTSUP)
goto fail13;
/* Fallback for old firmware without privilege mask support */
if (EFX_PCI_FUNCTION_IS_PF(encp)) {
/* Assume PF has admin privilege */
mask = HUNT_LEGACY_PF_PRIVILEGE_MASK;
} else {
/* VF is always unprivileged by default */
mask = HUNT_LEGACY_VF_PRIVILEGE_MASK;
}
}
if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
goto fail13;
encp->enc_privilege_mask = mask;
/* Get interrupt vector limits */

View File

@ -189,9 +189,8 @@ medford_board_cfg(
* the privilege mask to check for sufficient privileges, as that
* can result in time-of-check/time-of-use bugs.
*/
if ((rc = efx_mcdi_privilege_mask(enp, pf, vf, &mask)) != 0)
if ((rc = ef10_get_privilege_mask(enp, &mask)) != 0)
goto fail10;
encp->enc_privilege_mask = mask;
/* Get interrupt vector limits */