Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Jul 2015 16:25:19 +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: r285798 - head/sys/dev/sfxge/common
Message-ID:  <201507221625.t6MGPJYd025391@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Wed Jul 22 16:25:18 2015
New Revision: 285798
URL: https://svnweb.freebsd.org/changeset/base/285798

Log:
  sfxge: added fallbacks for pre 4.2.1 firmware support
  
  Driver must be able to start against older firmware that is missing
  recently added MCDI calls, otherwise firmware upgrade will not be
  possible.
  
  Submitted by:   Richard Houldsworth <rhouldsworth at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:      2 days
  Differential Revision: https://reviews.freebsd.org/D3145

Modified:
  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/hunt_impl.h
==============================================================================
--- head/sys/dev/sfxge/common/hunt_impl.h	Wed Jul 22 16:25:07 2015	(r285797)
+++ head/sys/dev/sfxge/common/hunt_impl.h	Wed Jul 22 16:25:18 2015	(r285798)
@@ -695,6 +695,21 @@ hunt_tx_qstats_update(
 
 #define	HUNT_MIN_PIO_ALLOC_SIZE	(HUNT_PIOBUF_SIZE / 32)
 
+#define HUNT_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			|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_PTP			|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_INSECURE_FILTERS		|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING		|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_UNICAST			|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_MULTICAST			|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_BROADCAST			|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_ALL_MULTICAST		|	\
+	MC_CMD_PRIVILEGE_MASK_IN_GRP_PROMISCUOUS)
+
+#define HUNT_LEGACY_VF_PRIVILEGE_MASK	0
+
 typedef uint32_t	efx_piobuf_handle_t;
 
 #define	EFX_PIOBUF_HANDLE_INVALID	((efx_piobuf_handle_t) -1)

Modified: head/sys/dev/sfxge/common/hunt_mac.c
==============================================================================
--- head/sys/dev/sfxge/common/hunt_mac.c	Wed Jul 22 16:25:07 2015	(r285797)
+++ head/sys/dev/sfxge/common/hunt_mac.c	Wed Jul 22 16:25:18 2015	(r285798)
@@ -150,8 +150,19 @@ hunt_mac_addr_set(
 {
 	int rc;
 
-	if ((rc = efx_mcdi_vadapter_set_mac(enp)) != 0)
-		goto fail1;
+	if ((rc = efx_mcdi_vadapter_set_mac(enp)) != 0) {
+		if (rc != ENOTSUP)
+			goto fail1;
+
+		/* Fallback for older firmware without Vadapter support */
+		if ((rc = hunt_mac_reconfigure(enp)) != 0)
+			goto fail2;
+	}
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
 
 fail1:
 	EFSYS_PROBE1(fail1, int, rc);

Modified: head/sys/dev/sfxge/common/hunt_nic.c
==============================================================================
--- head/sys/dev/sfxge/common/hunt_nic.c	Wed Jul 22 16:25:07 2015	(r285797)
+++ head/sys/dev/sfxge/common/hunt_nic.c	Wed Jul 22 16:25:18 2015	(r285798)
@@ -1239,8 +1239,19 @@ 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)
-		goto fail13;
+	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;
+		}
+	}
 
 	encp->enc_privilege_mask = mask;
 



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