From owner-svn-src-head@freebsd.org Tue Dec 1 15:38:41 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 7C8CBA2CE3E; Tue, 1 Dec 2015 15:38:41 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 55AEB12F7; Tue, 1 Dec 2015 15:38:41 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB1FceH3092016; Tue, 1 Dec 2015 15:38:40 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB1FcdKS092009; Tue, 1 Dec 2015 15:38:39 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201512011538.tB1FcdKS092009@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Tue, 1 Dec 2015 15:38:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291588 - 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: Tue, 01 Dec 2015 15:38:41 -0000 Author: arybchik Date: Tue Dec 1 15:38:39 2015 New Revision: 291588 URL: https://svnweb.freebsd.org/changeset/base/291588 Log: sfxge: add function to query link control privilege Make link control privilege visible to OS driver to guard updates to flow control and PHY advertised capabilities. Submitted by: Richard Houldsworth Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D4330 Modified: head/sys/dev/sfxge/common/efx_impl.h head/sys/dev/sfxge/common/efx_mcdi.c head/sys/dev/sfxge/common/efx_mcdi.h head/sys/dev/sfxge/common/hunt_impl.h head/sys/dev/sfxge/common/hunt_mcdi.c head/sys/dev/sfxge/common/siena_impl.h head/sys/dev/sfxge/common/siena_mcdi.c Modified: head/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- head/sys/dev/sfxge/common/efx_impl.h Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/efx_impl.h Tue Dec 1 15:38:39 2015 (r291588) @@ -462,6 +462,7 @@ typedef struct efx_mcdi_ops_s { void (*emco_fini)(efx_nic_t *); efx_rc_t (*emco_fw_update_supported)(efx_nic_t *, boolean_t *); efx_rc_t (*emco_macaddr_change_supported)(efx_nic_t *, boolean_t *); + efx_rc_t (*emco_link_control_supported)(efx_nic_t *, boolean_t *); } efx_mcdi_ops_t; typedef struct efx_mcdi_s { Modified: head/sys/dev/sfxge/common/efx_mcdi.c ============================================================================== --- head/sys/dev/sfxge/common/efx_mcdi.c Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/efx_mcdi.c Tue Dec 1 15:38:39 2015 (r291588) @@ -53,6 +53,8 @@ static efx_mcdi_ops_t __efx_mcdi_siena_o siena_mcdi_fw_update_supported, /* emco_fw_update_supported */ siena_mcdi_macaddr_change_supported, /* emco_macaddr_change_supported */ + siena_mcdi_link_control_supported, + /* emco_link_control_supported */ }; #endif /* EFSYS_OPT_SIENA */ @@ -69,6 +71,8 @@ static efx_mcdi_ops_t __efx_mcdi_hunt_op hunt_mcdi_fw_update_supported, /* emco_fw_update_supported */ hunt_mcdi_macaddr_change_supported, /* emco_macaddr_change_supported */ + hunt_mcdi_link_control_supported, + /* emco_link_control_supported */ }; #endif /* EFSYS_OPT_HUNTINGTON */ @@ -1169,6 +1173,31 @@ fail1: return (rc); } + __checkReturn efx_rc_t +efx_mcdi_link_control_supported( + __in efx_nic_t *enp, + __out boolean_t *supportedp) +{ + efx_mcdi_ops_t *emcop = enp->en_mcdi.em_emcop; + efx_rc_t rc; + + if (emcop != NULL && emcop->emco_link_control_supported != NULL) { + if ((rc = emcop->emco_link_control_supported(enp, supportedp)) + != 0) + goto fail1; + } else { + /* Earlier devices always supported link control */ + *supportedp = B_TRUE; + } + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + #if EFSYS_OPT_BIST #if EFSYS_OPT_HUNTINGTON Modified: head/sys/dev/sfxge/common/efx_mcdi.h ============================================================================== --- head/sys/dev/sfxge/common/efx_mcdi.h Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/efx_mcdi.h Tue Dec 1 15:38:39 2015 (r291588) @@ -151,6 +151,11 @@ efx_mcdi_macaddr_change_supported( __in efx_nic_t *enp, __out boolean_t *supportedp); +extern __checkReturn efx_rc_t +efx_mcdi_link_control_supported( + __in efx_nic_t *enp, + __out boolean_t *supportedp); + #if EFSYS_OPT_BIST #if EFSYS_OPT_HUNTINGTON extern __checkReturn efx_rc_t Modified: head/sys/dev/sfxge/common/hunt_impl.h ============================================================================== --- head/sys/dev/sfxge/common/hunt_impl.h Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/hunt_impl.h Tue Dec 1 15:38:39 2015 (r291588) @@ -286,6 +286,11 @@ hunt_mcdi_macaddr_change_supported( __in efx_nic_t *enp, __out boolean_t *supportedp); +extern __checkReturn efx_rc_t +hunt_mcdi_link_control_supported( + __in efx_nic_t *enp, + __out boolean_t *supportedp); + #endif /* EFSYS_OPT_MCDI */ /* NVRAM */ Modified: head/sys/dev/sfxge/common/hunt_mcdi.c ============================================================================== --- head/sys/dev/sfxge/common/hunt_mcdi.c Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/hunt_mcdi.c Tue Dec 1 15:38:39 2015 (r291588) @@ -471,6 +471,30 @@ hunt_mcdi_macaddr_change_supported( return (0); } + __checkReturn efx_rc_t +hunt_mcdi_link_control_supported( + __in efx_nic_t *enp, + __out boolean_t *supportedp) +{ + efx_nic_cfg_t *encp = &(enp->en_nic_cfg); + uint32_t privilege_mask = encp->enc_privilege_mask; + + EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_HUNTINGTON); + + /* + * Use privilege mask state at MCDI attach. + * Admin privilege used prior to introduction of + * specific flag. + */ + *supportedp = + ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_LINK) == + MC_CMD_PRIVILEGE_MASK_IN_GRP_LINK) || + ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN) == + MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN); + + return (0); +} + #endif /* EFSYS_OPT_MCDI */ #endif /* EFSYS_OPT_HUNTINGTON */ Modified: head/sys/dev/sfxge/common/siena_impl.h ============================================================================== --- head/sys/dev/sfxge/common/siena_impl.h Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/siena_impl.h Tue Dec 1 15:38:39 2015 (r291588) @@ -148,6 +148,11 @@ siena_mcdi_macaddr_change_supported( __in efx_nic_t *enp, __out boolean_t *supportedp); +extern __checkReturn efx_rc_t +siena_mcdi_link_control_supported( + __in efx_nic_t *enp, + __out boolean_t *supportedp); + #endif /* EFSYS_OPT_MCDI */ #if EFSYS_OPT_NVRAM || EFSYS_OPT_VPD Modified: head/sys/dev/sfxge/common/siena_mcdi.c ============================================================================== --- head/sys/dev/sfxge/common/siena_mcdi.c Tue Dec 1 15:32:37 2015 (r291587) +++ head/sys/dev/sfxge/common/siena_mcdi.c Tue Dec 1 15:38:39 2015 (r291588) @@ -351,4 +351,16 @@ siena_mcdi_macaddr_change_supported( return (0); } + __checkReturn efx_rc_t +siena_mcdi_link_control_supported( + __in efx_nic_t *enp, + __out boolean_t *supportedp) +{ + EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA); + + *supportedp = B_TRUE; + + return (0); +} + #endif /* EFSYS_OPT_SIENA && EFSYS_OPT_MCDI */