svn commit: r294397 - stable/10/sys/dev/sfxge/common

Andrew Rybchenko arybchik at FreeBSD.org
Wed Jan 20 08:17:30 UTC 2016


Author: arybchik
Date: Wed Jan 20 08:17:28 2016
New Revision: 294397
URL: https://svnweb.freebsd.org/changeset/base/294397

Log:
  MFC r294253
  
  sfxge: if supported by firmware, use enhanced SET_MAC command to only configure the MTU
  
  This allows an MTU change to be requested on unpriviliged functions
  without also setting all the other parameters supported by MC_CMD_SET_MAC.
  
  The enhanced SET_MAC command was introduced in v4_7 firmware.
  
  Submitted by:   Mark Spender <mspender at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.

Modified:
  stable/10/sys/dev/sfxge/common/efx.h
  stable/10/sys/dev/sfxge/common/efx_impl.h
  stable/10/sys/dev/sfxge/common/efx_mac.c
  stable/10/sys/dev/sfxge/common/hunt_impl.h
  stable/10/sys/dev/sfxge/common/hunt_mac.c
  stable/10/sys/dev/sfxge/common/hunt_nic.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/sfxge/common/efx.h
==============================================================================
--- stable/10/sys/dev/sfxge/common/efx.h	Wed Jan 20 08:16:30 2016	(r294396)
+++ stable/10/sys/dev/sfxge/common/efx.h	Wed Jan 20 08:17:28 2016	(r294397)
@@ -1159,6 +1159,7 @@ typedef struct efx_nic_cfg_s {
 	boolean_t		enc_datapath_cap_evb;
 	boolean_t               enc_rx_disable_scatter_supported;
 	boolean_t               enc_allow_set_mac_with_installed_filters;
+	boolean_t		enc_enhanced_set_mac_supported;
 	/* External port identifier */
 	uint8_t			enc_external_port;
 	uint32_t		enc_mcdi_max_payload_length;

Modified: stable/10/sys/dev/sfxge/common/efx_impl.h
==============================================================================
--- stable/10/sys/dev/sfxge/common/efx_impl.h	Wed Jan 20 08:16:30 2016	(r294396)
+++ stable/10/sys/dev/sfxge/common/efx_impl.h	Wed Jan 20 08:17:28 2016	(r294397)
@@ -194,6 +194,7 @@ typedef struct efx_mac_ops_s {
 	efx_rc_t	(*emo_poll)(efx_nic_t *, efx_link_mode_t *);
 	efx_rc_t	(*emo_up)(efx_nic_t *, boolean_t *);
 	efx_rc_t	(*emo_addr_set)(efx_nic_t *);
+	efx_rc_t	(*emo_pdu_set)(efx_nic_t *);
 	efx_rc_t	(*emo_reconfigure)(efx_nic_t *);
 	efx_rc_t	(*emo_multicast_list_set)(efx_nic_t *);
 	efx_rc_t	(*emo_filter_default_rxq_set)(efx_nic_t *,

Modified: stable/10/sys/dev/sfxge/common/efx_mac.c
==============================================================================
--- stable/10/sys/dev/sfxge/common/efx_mac.c	Wed Jan 20 08:16:30 2016	(r294396)
+++ stable/10/sys/dev/sfxge/common/efx_mac.c	Wed Jan 20 08:17:28 2016	(r294397)
@@ -56,6 +56,7 @@ static efx_mac_ops_t	__efx_falcon_gmac_o
 	falcon_mac_poll,			/* emo_poll */
 	falcon_mac_up,				/* emo_up */
 	falcon_gmac_reconfigure,		/* emo_addr_set */
+	falcon_gmac_reconfigure,		/* emo_pdu_set */
 	falcon_gmac_reconfigure,		/* emo_reconfigure */
 	falconsiena_mac_multicast_list_set,	/* emo_multicast_list_set */
 	NULL,					/* emo_filter_set_default_rxq */
@@ -77,6 +78,7 @@ static efx_mac_ops_t	__efx_falcon_xmac_o
 	falcon_mac_poll,			/* emo_poll */
 	falcon_mac_up,				/* emo_up */
 	falcon_xmac_reconfigure,		/* emo_addr_set */
+	falcon_xmac_reconfigure,		/* emo_pdu_set */
 	falcon_xmac_reconfigure,		/* emo_reconfigure */
 	falconsiena_mac_multicast_list_set,	/* emo_multicast_list_set */
 	NULL,					/* emo_filter_set_default_rxq */
@@ -98,6 +100,7 @@ static efx_mac_ops_t	__efx_siena_mac_ops
 	siena_mac_poll,				/* emo_poll */
 	siena_mac_up,				/* emo_up */
 	siena_mac_reconfigure,			/* emo_addr_set */
+	siena_mac_reconfigure,			/* emo_pdu_set */
 	siena_mac_reconfigure,			/* emo_reconfigure */
 	falconsiena_mac_multicast_list_set,	/* emo_multicast_list_set */
 	NULL,					/* emo_filter_set_default_rxq */
@@ -119,6 +122,7 @@ static efx_mac_ops_t	__efx_ef10_mac_ops 
 	ef10_mac_poll,				/* emo_poll */
 	ef10_mac_up,				/* emo_up */
 	ef10_mac_addr_set,			/* emo_addr_set */
+	ef10_mac_pdu_set,			/* emo_pdu_set */
 	ef10_mac_reconfigure,			/* emo_reconfigure */
 	ef10_mac_multicast_list_set,		/* emo_multicast_list_set */
 	ef10_mac_filter_default_rxq_set,	/* emo_filter_default_rxq_set */
@@ -196,7 +200,7 @@ efx_mac_pdu_set(
 
 	old_pdu = epp->ep_mac_pdu;
 	epp->ep_mac_pdu = (uint32_t)pdu;
-	if ((rc = emop->emo_reconfigure(enp)) != 0)
+	if ((rc = emop->emo_pdu_set(enp)) != 0)
 		goto fail3;
 
 	return (0);

Modified: stable/10/sys/dev/sfxge/common/hunt_impl.h
==============================================================================
--- stable/10/sys/dev/sfxge/common/hunt_impl.h	Wed Jan 20 08:16:30 2016	(r294396)
+++ stable/10/sys/dev/sfxge/common/hunt_impl.h	Wed Jan 20 08:17:28 2016	(r294397)
@@ -234,6 +234,10 @@ ef10_mac_addr_set(
 	__in	efx_nic_t *enp);
 
 extern	__checkReturn	efx_rc_t
+ef10_mac_pdu_set(
+	__in	efx_nic_t *enp);
+
+extern	__checkReturn	efx_rc_t
 ef10_mac_reconfigure(
 	__in	efx_nic_t *enp);
 

Modified: stable/10/sys/dev/sfxge/common/hunt_mac.c
==============================================================================
--- stable/10/sys/dev/sfxge/common/hunt_mac.c	Wed Jan 20 08:16:30 2016	(r294396)
+++ stable/10/sys/dev/sfxge/common/hunt_mac.c	Wed Jan 20 08:17:28 2016	(r294397)
@@ -162,6 +162,74 @@ fail1:
 	return (rc);
 }
 
+static	__checkReturn	efx_rc_t
+efx_mcdi_mtu_set(
+	__in		efx_nic_t *enp,
+	__in		uint32_t mtu)
+{
+	efx_mcdi_req_t req;
+	uint8_t payload[MAX(MC_CMD_SET_MAC_EXT_IN_LEN,
+			    MC_CMD_SET_MAC_OUT_LEN)];
+	efx_rc_t rc;
+
+	(void) memset(payload, 0, sizeof (payload));
+	req.emr_cmd = MC_CMD_SET_MAC;
+	req.emr_in_buf = payload;
+	req.emr_in_length = MC_CMD_SET_MAC_EXT_IN_LEN;
+	req.emr_out_buf = payload;
+	req.emr_out_length = MC_CMD_SET_MAC_OUT_LEN;
+
+	/* Only configure the MTU in this call to MC_CMD_SET_MAC */
+	MCDI_IN_SET_DWORD(req, SET_MAC_EXT_IN_MTU, mtu);
+	MCDI_IN_POPULATE_DWORD_1(req, SET_MAC_EXT_IN_CONTROL,
+			    SET_MAC_EXT_IN_CFG_MTU, 1);
+
+	efx_mcdi_execute(enp, &req);
+
+	if (req.emr_rc != 0) {
+		rc = req.emr_rc;
+		goto fail1;
+	}
+
+	return (0);
+
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+ef10_mac_pdu_set(
+	__in		efx_nic_t *enp)
+{
+	efx_port_t *epp = &(enp->en_port);
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+	efx_rc_t rc;
+
+	if (encp->enc_enhanced_set_mac_supported) {
+		if ((rc = efx_mcdi_mtu_set(enp, epp->ep_mac_pdu)) != 0)
+			goto fail1;
+	} else {
+		/*
+		 * Fallback for older Huntington firmware, which always
+		 * configure all of the parameters to MC_CMD_SET_MAC. This isn't
+		 * suitable for setting the MTU on unpriviliged functions.
+		 */
+		if ((rc = ef10_mac_reconfigure(enp)) != 0)
+			goto fail2;
+	}
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
 __checkReturn	efx_rc_t
 ef10_mac_reconfigure(
 	__in		efx_nic_t *enp)

Modified: stable/10/sys/dev/sfxge/common/hunt_nic.c
==============================================================================
--- stable/10/sys/dev/sfxge/common/hunt_nic.c	Wed Jan 20 08:16:30 2016	(r294396)
+++ stable/10/sys/dev/sfxge/common/hunt_nic.c	Wed Jan 20 08:17:28 2016	(r294397)
@@ -951,6 +951,13 @@ ef10_get_datapath_caps(
 	    CAP_FLAG(flags, VADAPTOR_PERMIT_SET_MAC_WHEN_FILTERS_INSTALLED) ?
 	    B_TRUE : B_FALSE;
 
+	/*
+	 * Check if firmware supports the extended MC_CMD_SET_MAC, which allows
+	 * specifying which parameters to configure.
+	 */
+	encp->enc_enhanced_set_mac_supported =
+		CAP_FLAG(flags, SET_MAC_ENHANCED) ? B_TRUE : B_FALSE;
+
 #undef CAP_FLAG
 #undef CAP_FLAG2
 


More information about the svn-src-all mailing list