From owner-svn-src-stable@freebsd.org Thu Jan 14 15:32:26 2016 Return-Path: Delivered-To: svn-src-stable@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 28ABDA82529; Thu, 14 Jan 2016 15:32:26 +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 F01461ECC; Thu, 14 Jan 2016 15:32:25 +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 u0EFWOWm046147; Thu, 14 Jan 2016 15:32:24 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0EFWOgt046145; Thu, 14 Jan 2016 15:32:24 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201601141532.u0EFWOgt046145@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Thu, 14 Jan 2016 15:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r293967 - stable/10/sys/dev/sfxge/common X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jan 2016 15:32:26 -0000 Author: arybchik Date: Thu Jan 14 15:32:24 2016 New Revision: 293967 URL: https://svnweb.freebsd.org/changeset/base/293967 Log: MFC r292052 sfxge: simplify privilege checks with macro Submitted by: Richard Houldsworth Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx_mcdi.h stable/10/sys/dev/sfxge/common/hunt_mcdi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx_mcdi.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_mcdi.h Thu Jan 14 15:30:46 2016 (r293966) +++ stable/10/sys/dev/sfxge/common/efx_mcdi.h Thu Jan 14 15:32:24 2016 (r293967) @@ -386,6 +386,11 @@ efx_mcdi_get_loopback_modes( #define MCDI_CMD_DWORD_FIELD(_edp, _field) \ EFX_DWORD_FIELD(*_edp, MC_CMD_ ## _field) +#define EFX_MCDI_HAVE_PRIVILEGE(mask, priv) \ + (((mask) & \ + (MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv)) == \ + (MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv)) + #ifdef __cplusplus } #endif Modified: stable/10/sys/dev/sfxge/common/hunt_mcdi.c ============================================================================== --- stable/10/sys/dev/sfxge/common/hunt_mcdi.c Thu Jan 14 15:30:46 2016 (r293966) +++ stable/10/sys/dev/sfxge/common/hunt_mcdi.c Thu Jan 14 15:32:24 2016 (r293967) @@ -412,9 +412,8 @@ hunt_mcdi_fw_update_supported( * Admin privilege must be used prior to introduction of * specific flag. */ - *supportedp = (encp->enc_privilege_mask & - MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN) - == MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN; + *supportedp = + EFX_MCDI_HAVE_PRIVILEGE(encp->enc_privilege_mask, ADMIN); return (0); } @@ -436,12 +435,9 @@ hunt_mcdi_macaddr_change_supported( * introduction of change mac spoofing privilege (at v4.7) */ *supportedp = - ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_CHANGE_MAC) == - MC_CMD_PRIVILEGE_MASK_IN_GRP_CHANGE_MAC) || - ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING) == - MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING) || - ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN) == - MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN); + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, CHANGE_MAC) || + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING) || + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN); return (0); } @@ -463,12 +459,9 @@ hunt_mcdi_mac_spoofing_supported( * introduction of mac spoofing TX privilege (at v4.7) */ *supportedp = - ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING_TX) == - MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING_TX) || - ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING) == - MC_CMD_PRIVILEGE_MASK_IN_GRP_MAC_SPOOFING) || - ((privilege_mask & MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN) == - MC_CMD_PRIVILEGE_MASK_IN_GRP_ADMIN); + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING_TX) || + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, MAC_SPOOFING) || + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN); return (0); } @@ -490,10 +483,8 @@ hunt_mcdi_link_control_supported( * 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); + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, LINK) || + EFX_MCDI_HAVE_PRIVILEGE(privilege_mask, ADMIN); return (0); }