Date: Thu, 29 Dec 2016 06:57:36 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310749 - head/sys/dev/sfxge/common Message-ID: <201612290657.uBT6vapt050364@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <amoreton at solarflare.com> 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612290657.uBT6vapt050364>