Date: Mon, 2 Jan 2017 09:34:45 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r311082 - stable/10/sys/dev/sfxge/common Message-ID: <201701020934.v029Yjct006130@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Mon Jan 2 09:34:45 2017 New Revision: 311082 URL: https://svnweb.freebsd.org/changeset/base/311082 Log: MFC r310749 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 <amoreton at solarflare.com> Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/mcdi_mon.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/mcdi_mon.c ============================================================================== --- stable/10/sys/dev/sfxge/common/mcdi_mon.c Mon Jan 2 09:34:05 2017 (r311081) +++ stable/10/sys/dev/sfxge/common/mcdi_mon.c Mon Jan 2 09:34:45 2017 (r311082) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701020934.v029Yjct006130>