From owner-svn-src-head@freebsd.org Thu Dec 29 06:57:38 2016 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 1905AC95BF0; Thu, 29 Dec 2016 06:57:38 +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 C2C161065; Thu, 29 Dec 2016 06:57:37 +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 uBT6vaAP050365; Thu, 29 Dec 2016 06:57:36 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBT6vapt050364; Thu, 29 Dec 2016 06:57:36 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201612290657.uBT6vapt050364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Thu, 29 Dec 2016 06:57:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310749 - 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.23 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: Thu, 29 Dec 2016 06:57:38 -0000 Author: arybchik Date: Thu Dec 29 06:57:36 2016 New Revision: 310749 URL: https://svnweb.freebsd.org/changeset/base/310749 Log: sfxge(4): use correct port number in sensor decoding The port mask used for per-port sensors in mcdi_sensor_map assumes zero-based port numbering. The port mask used in the code is based on the one-based MCDI port number. Fix this to lookup the correct per-port sensors, and to allow reporting of sensor events from higher port numbers. Submitted by: Andy Moreton Reviewed by: gnn Sponsored by: Solarflare Communications, Inc. MFC after: 2 days Differential Revision: https://reviews.freebsd.org/D8947 Modified: head/sys/dev/sfxge/common/mcdi_mon.c Modified: head/sys/dev/sfxge/common/mcdi_mon.c ============================================================================== --- head/sys/dev/sfxge/common/mcdi_mon.c Thu Dec 29 06:56:18 2016 (r310748) +++ head/sys/dev/sfxge/common/mcdi_mon.c Thu Dec 29 06:57:36 2016 (r310749) @@ -50,6 +50,9 @@ __FBSDID("$FreeBSD$"); #define MCDI_MON_PORT_P4 (0x08) #define MCDI_MON_PORT_Px (0xFFFF) +/* Get port mask from one-based MCDI port number */ +#define MCDI_MON_PORT_MASK(_emip) (1U << ((_emip)->emi_port - 1)) + /* Entry for MCDI sensor in sensor map */ #define STAT(portmask, stat) \ { (MCDI_MON_PORT_##portmask), (EFX_MON_STAT_##stat) } @@ -166,10 +169,10 @@ static const struct mcdi_sensor_map_s { static void mcdi_mon_decode_stats( __in efx_nic_t *enp, - __in_ecount(sensor_mask_size) uint32_t *sensor_mask, + __in_bcount(sensor_mask_size) uint32_t *sensor_mask, __in size_t sensor_mask_size, __in_opt efsys_mem_t *esmp, - __out_ecount_opt(sensor_mask_size) uint32_t *stat_maskp, + __out_bcount_opt(sensor_mask_size) uint32_t *stat_maskp, __inout_ecount_opt(EFX_MON_NSTATS) efx_mon_stat_value_t *stat) { efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); @@ -192,7 +195,8 @@ mcdi_mon_decode_stats( sensor_max = MIN((8 * sensor_mask_size), EFX_ARRAY_SIZE(mcdi_sensor_map)); - port_mask = 1U << emip->emi_port; + EFSYS_ASSERT(emip->emi_port > 0); /* MCDI port number is one-based */ + port_mask = MCDI_MON_PORT_MASK(emip); memset(stat_mask, 0, sizeof (stat_mask)); @@ -269,9 +273,8 @@ mcdi_mon_ev( efx_mon_stat_t id; efx_rc_t rc; - port_mask = (emip->emi_port == 1) - ? MCDI_MON_PORT_P1 - : MCDI_MON_PORT_P2; + EFSYS_ASSERT(emip->emi_port > 0); /* MCDI port number is one-based */ + port_mask = MCDI_MON_PORT_MASK(emip); sensor = (uint16_t)MCDI_EV_FIELD(eqp, SENSOREVT_MONITOR); state = (uint16_t)MCDI_EV_FIELD(eqp, SENSOREVT_STATE);