Commit 95287e1b authored by Edward Cree's avatar Edward Cree Committed by David S. Miller
Browse files

sfc: detect ef100 MAE admin privilege/capability at probe time



One PCIe function per network port (more precisely, per m-port group) is
 responsible for configuring the Match-Action Engine which performs
 switching and packet modification in the slice to support flower/OVS
 offload.  The GRP_MAE bit in the privilege mask indicates whether a
 given function has this capability.
At probe time, call MCDIs to read the calling function's privilege mask,
 and store the GRP_MAE bit in a new ef100_nic_data member.

Signed-off-by: default avatarEdward Cree <ecree.xilinx@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8ca353da
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -946,6 +946,7 @@ static int ef100_probe_main(struct efx_nic *efx)
	unsigned int bar_size = resource_size(&efx->pci_dev->resource[efx->mem_bar]);
	struct ef100_nic_data *nic_data;
	char fw_version[32];
	u32 priv_mask = 0;
	int i, rc;

	if (WARN_ON(bar_size == 0))
@@ -1027,6 +1028,12 @@ static int ef100_probe_main(struct efx_nic *efx)
	efx_mcdi_print_fwver(efx, fw_version, sizeof(fw_version));
	pci_dbg(efx->pci_dev, "Firmware version %s\n", fw_version);

	rc = efx_mcdi_get_privilege_mask(efx, &priv_mask);
	if (rc) /* non-fatal, and priv_mask will still be 0 */
		pci_info(efx->pci_dev,
			 "Failed to get privilege mask from FW, rc %d\n", rc);
	nic_data->grp_mae = !!(priv_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_MAE);

	if (compare_versions(fw_version, "1.1.0.1000") < 0) {
		pci_info(efx->pci_dev, "Firmware uses old event descriptors\n");
		rc = -EINVAL;
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ struct ef100_nic_data {
	u8 port_id[ETH_ALEN];
	DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS);
	u64 stats[EF100_STAT_COUNT];
	bool grp_mae; /* MAE Privilege */
	u16 tso_max_hdr_len;
	u16 tso_max_payload_num_segs;
	u16 tso_max_frames;
+46 −0
Original line number Diff line number Diff line
@@ -2129,6 +2129,52 @@ int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out,
	return rc;
}

/* Failure to read a privilege mask is never fatal, because we can always
 * carry on as though we didn't have the privilege we were interested in.
 * So use efx_mcdi_rpc_quiet().
 */
int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask)
{
	MCDI_DECLARE_BUF(fi_outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN);
	MCDI_DECLARE_BUF(pm_inbuf, MC_CMD_PRIVILEGE_MASK_IN_LEN);
	MCDI_DECLARE_BUF(pm_outbuf, MC_CMD_PRIVILEGE_MASK_OUT_LEN);
	size_t outlen;
	u16 pf, vf;
	int rc;

	if (!efx || !mask)
		return -EINVAL;

	/* Get our function number */
	rc = efx_mcdi_rpc_quiet(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0,
				fi_outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN,
				&outlen);
	if (rc != 0)
		return rc;
	if (outlen < MC_CMD_GET_FUNCTION_INFO_OUT_LEN)
		return -EIO;

	pf = MCDI_DWORD(fi_outbuf, GET_FUNCTION_INFO_OUT_PF);
	vf = MCDI_DWORD(fi_outbuf, GET_FUNCTION_INFO_OUT_VF);

	MCDI_POPULATE_DWORD_2(pm_inbuf, PRIVILEGE_MASK_IN_FUNCTION,
			      PRIVILEGE_MASK_IN_FUNCTION_PF, pf,
			      PRIVILEGE_MASK_IN_FUNCTION_VF, vf);

	rc = efx_mcdi_rpc_quiet(efx, MC_CMD_PRIVILEGE_MASK,
				pm_inbuf, sizeof(pm_inbuf),
				pm_outbuf, sizeof(pm_outbuf), &outlen);

	if (rc != 0)
		return rc;
	if (outlen < MC_CMD_PRIVILEGE_MASK_OUT_LEN)
		return -EIO;

	*mask = MCDI_DWORD(pm_outbuf, PRIVILEGE_MASK_OUT_OLD_MASK);

	return 0;
}

#ifdef CONFIG_SFC_MTD

#define EFX_MCDI_NVRAM_LEN_MAX 128
+1 −0
Original line number Diff line number Diff line
@@ -366,6 +366,7 @@ int efx_mcdi_set_workaround(struct efx_nic *efx, u32 type, bool enabled,
			    unsigned int *flags);
int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out,
			     unsigned int *enabled_out);
int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask);

#ifdef CONFIG_SFC_MCDI_MON
int efx_mcdi_mon_probe(struct efx_nic *efx);