Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jan 2016 06:19:29 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294253 - head/sys/dev/sfxge/common
Message-ID:  <201601180619.u0I6JThW038816@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Mon Jan 18 06:19:28 2016
New Revision: 294253
URL: https://svnweb.freebsd.org/changeset/base/294253

Log:
  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.
  MFC after:      2 days
  Differential Revision: https://reviews.freebsd.org/D4958

Modified:
  head/sys/dev/sfxge/common/efx.h
  head/sys/dev/sfxge/common/efx_impl.h
  head/sys/dev/sfxge/common/efx_mac.c
  head/sys/dev/sfxge/common/hunt_impl.h
  head/sys/dev/sfxge/common/hunt_mac.c
  head/sys/dev/sfxge/common/hunt_nic.c

Modified: head/sys/dev/sfxge/common/efx.h
==============================================================================
--- head/sys/dev/sfxge/common/efx.h	Mon Jan 18 06:18:01 2016	(r294252)
+++ head/sys/dev/sfxge/common/efx.h	Mon Jan 18 06:19:28 2016	(r294253)
@@ -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: head/sys/dev/sfxge/common/efx_impl.h
==============================================================================
--- head/sys/dev/sfxge/common/efx_impl.h	Mon Jan 18 06:18:01 2016	(r294252)
+++ head/sys/dev/sfxge/common/efx_impl.h	Mon Jan 18 06:19:28 2016	(r294253)
@@ -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: head/sys/dev/sfxge/common/efx_mac.c
==============================================================================
--- head/sys/dev/sfxge/common/efx_mac.c	Mon Jan 18 06:18:01 2016	(r294252)
+++ head/sys/dev/sfxge/common/efx_mac.c	Mon Jan 18 06:19:28 2016	(r294253)
@@ -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: head/sys/dev/sfxge/common/hunt_impl.h
==============================================================================
--- head/sys/dev/sfxge/common/hunt_impl.h	Mon Jan 18 06:18:01 2016	(r294252)
+++ head/sys/dev/sfxge/common/hunt_impl.h	Mon Jan 18 06:19:28 2016	(r294253)
@@ -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: head/sys/dev/sfxge/common/hunt_mac.c
==============================================================================
--- head/sys/dev/sfxge/common/hunt_mac.c	Mon Jan 18 06:18:01 2016	(r294252)
+++ head/sys/dev/sfxge/common/hunt_mac.c	Mon Jan 18 06:19:28 2016	(r294253)
@@ -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: head/sys/dev/sfxge/common/hunt_nic.c
==============================================================================
--- head/sys/dev/sfxge/common/hunt_nic.c	Mon Jan 18 06:18:01 2016	(r294252)
+++ head/sys/dev/sfxge/common/hunt_nic.c	Mon Jan 18 06:19:28 2016	(r294253)
@@ -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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601180619.u0I6JThW038816>