summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarybchik <arybchik@FreeBSD.org>2017-01-01 19:06:02 +0000
committerarybchik <arybchik@FreeBSD.org>2017-01-01 19:06:02 +0000
commit887c8e49fc22f05d7adb22709eb4a79087b400c1 (patch)
treef30bbf49a8a11d8ff61588cd58c5817a6adc345d
parent6e58803647a7020a71cd317ecb5dece0775462e7 (diff)
downloadFreeBSD-src-887c8e49fc22f05d7adb22709eb4a79087b400c1.zip
FreeBSD-src-887c8e49fc22f05d7adb22709eb4a79087b400c1.tar.gz
MFC r310746
sfxge(4): make the common code determine the number of PFs Submitted by: Ivan Malov <Ivan.Malov at oktetlabs.ru> Sponsored by: Solarflare Communications, Inc.
-rw-r--r--sys/dev/sfxge/common/ef10_nic.c47
-rw-r--r--sys/dev/sfxge/common/efx.h2
-rw-r--r--sys/dev/sfxge/common/siena_nic.c7
3 files changed, 56 insertions, 0 deletions
diff --git a/sys/dev/sfxge/common/ef10_nic.c b/sys/dev/sfxge/common/ef10_nic.c
index 8481c26..24ecb4b 100644
--- a/sys/dev/sfxge/common/ef10_nic.c
+++ b/sys/dev/sfxge/common/ef10_nic.c
@@ -961,6 +961,50 @@ ef10_nic_pio_unlink(
return (efx_mcdi_unlink_piobuf(enp, vi_index));
}
+static __checkReturn efx_rc_t
+ef10_mcdi_get_pf_count(
+ __in efx_nic_t *enp,
+ __out uint32_t *pf_countp)
+{
+ efx_mcdi_req_t req;
+ uint8_t payload[MAX(MC_CMD_GET_PF_COUNT_IN_LEN,
+ MC_CMD_GET_PF_COUNT_OUT_LEN)];
+ efx_rc_t rc;
+
+ (void) memset(payload, 0, sizeof (payload));
+ req.emr_cmd = MC_CMD_GET_PF_COUNT;
+ req.emr_in_buf = payload;
+ req.emr_in_length = MC_CMD_GET_PF_COUNT_IN_LEN;
+ req.emr_out_buf = payload;
+ req.emr_out_length = MC_CMD_GET_PF_COUNT_OUT_LEN;
+
+ efx_mcdi_execute(enp, &req);
+
+ if (req.emr_rc != 0) {
+ rc = req.emr_rc;
+ goto fail1;
+ }
+
+ if (req.emr_out_length_used < MC_CMD_GET_PF_COUNT_OUT_LEN) {
+ rc = EMSGSIZE;
+ goto fail2;
+ }
+
+ *pf_countp = *MCDI_OUT(req, uint8_t,
+ MC_CMD_GET_PF_COUNT_OUT_PF_COUNT_OFST);
+
+ EFSYS_ASSERT(*pf_countp != 0);
+
+ return (0);
+
+fail2:
+ EFSYS_PROBE(fail2);
+fail1:
+ EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+ return (rc);
+}
+
__checkReturn efx_rc_t
ef10_get_datapath_caps(
__in efx_nic_t *enp)
@@ -975,6 +1019,9 @@ ef10_get_datapath_caps(
&tso2nc)) != 0)
goto fail1;
+ if ((rc = ef10_mcdi_get_pf_count(enp, &encp->enc_hw_pf_count)) != 0)
+ goto fail1;
+
#define CAP_FLAG(flags1, field) \
((flags1) & (1 << (MC_CMD_GET_CAPABILITIES_V2_OUT_ ## field ## _LBN)))
diff --git a/sys/dev/sfxge/common/efx.h b/sys/dev/sfxge/common/efx.h
index 0ab8476..b17d3ab 100644
--- a/sys/dev/sfxge/common/efx.h
+++ b/sys/dev/sfxge/common/efx.h
@@ -1142,6 +1142,8 @@ typedef struct efx_nic_cfg_s {
/* Number of TSO contexts on the NIC (FATSOv2) */
uint32_t enc_fw_assisted_tso_v2_n_contexts;
boolean_t enc_hw_tx_insert_vlan_enabled;
+ /* Number of PFs on the NIC */
+ uint32_t enc_hw_pf_count;
/* Datapath firmware vadapter/vport/vswitch support */
boolean_t enc_datapath_cap_evb;
boolean_t enc_rx_disable_scatter_supported;
diff --git a/sys/dev/sfxge/common/siena_nic.c b/sys/dev/sfxge/common/siena_nic.c
index 002f18d..6dfc054 100644
--- a/sys/dev/sfxge/common/siena_nic.c
+++ b/sys/dev/sfxge/common/siena_nic.c
@@ -105,6 +105,13 @@ siena_board_cfg(
encp->enc_board_type = board_type;
+ /*
+ * There is no possibility to determine the number of PFs on Siena
+ * by issuing MCDI request, and it is not an easy task to find the
+ * value based on the board type, so 'enc_hw_pf_count' is set to 1
+ */
+ encp->enc_hw_pf_count = 1;
+
/* Additional capabilities */
encp->enc_clk_mult = 1;
if (EFX_DWORD_FIELD(capabilities, MC_CMD_CAPABILITIES_TURBO)) {
OpenPOWER on IntegriCloud