From owner-svn-src-head@freebsd.org Wed Jul 22 16:25:20 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 363889A7270; Wed, 22 Jul 2015 16:25:20 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2713D19E8; Wed, 22 Jul 2015 16:25:20 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6MGPK4s025396; Wed, 22 Jul 2015 16:25:20 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6MGPJYd025391; Wed, 22 Jul 2015 16:25:19 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201507221625.t6MGPJYd025391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Wed, 22 Jul 2015 16:25:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285798 - head/sys/dev/sfxge/common X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2015 16:25:20 -0000 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 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;