Date: Fri, 30 Nov 2018 07:08:38 +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: r341313 - head/sys/dev/sfxge/common Message-ID: <201811300708.wAU78cHV083251@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Fri Nov 30 07:08:38 2018 New Revision: 341313 URL: https://svnweb.freebsd.org/changeset/base/341313 Log: sfxge(4): adjust PHY module info interface Adjust data types in interface to permit the complete module information buffer to be obtained in a single call. Submitted by: Richard Houldsworth <rhouldsworth at solarflare.com> Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D18275 Modified: head/sys/dev/sfxge/common/efx.h head/sys/dev/sfxge/common/efx_mcdi.c head/sys/dev/sfxge/common/efx_mcdi.h head/sys/dev/sfxge/common/efx_phy.c Modified: head/sys/dev/sfxge/common/efx.h ============================================================================== --- head/sys/dev/sfxge/common/efx.h Fri Nov 30 07:08:27 2018 (r341312) +++ head/sys/dev/sfxge/common/efx.h Fri Nov 30 07:08:38 2018 (r341313) @@ -1079,12 +1079,18 @@ efx_phy_media_type_get( */ #define EFX_PHY_MEDIA_INFO_DEV_ADDR_QSFP 0xA0 +/* + * Maximum accessible data offset for PHY module information. + */ +#define EFX_PHY_MEDIA_INFO_MAX_OFFSET 0x100 + + extern __checkReturn efx_rc_t efx_phy_module_get_info( __in efx_nic_t *enp, __in uint8_t dev_addr, - __in uint8_t offset, - __in uint8_t len, + __in size_t offset, + __in size_t len, __out_bcount(len) uint8_t *data); #if EFSYS_OPT_PHY_STATS Modified: head/sys/dev/sfxge/common/efx_mcdi.c ============================================================================== --- head/sys/dev/sfxge/common/efx_mcdi.c Fri Nov 30 07:08:27 2018 (r341312) +++ head/sys/dev/sfxge/common/efx_mcdi.c Fri Nov 30 07:08:38 2018 (r341313) @@ -2243,8 +2243,8 @@ fail1: efx_mcdi_phy_module_get_info( __in efx_nic_t *enp, __in uint8_t dev_addr, - __in uint8_t offset, - __in uint8_t len, + __in size_t offset, + __in size_t len, __out_bcount(len) uint8_t *data) { efx_port_t *epp = &(enp->en_port); @@ -2325,12 +2325,14 @@ efx_mcdi_phy_module_get_info( goto fail1; } + EFX_STATIC_ASSERT(EFX_PHY_MEDIA_INFO_PAGE_SIZE <= 0xFF); + if (offset < EFX_PHY_MEDIA_INFO_PAGE_SIZE) { - uint8_t read_len = + size_t read_len = MIN(len, EFX_PHY_MEDIA_INFO_PAGE_SIZE - offset); rc = efx_mcdi_get_phy_media_info(enp, - mcdi_lower_page, offset, read_len, data); + mcdi_lower_page, (uint8_t)offset, (uint8_t)read_len, data); if (rc != 0) goto fail2; @@ -2347,7 +2349,7 @@ efx_mcdi_phy_module_get_info( EFSYS_ASSERT3U(offset, <, EFX_PHY_MEDIA_INFO_PAGE_SIZE); rc = efx_mcdi_get_phy_media_info(enp, - mcdi_upper_page, offset, len, data); + mcdi_upper_page, (uint8_t)offset, (uint8_t)len, data); if (rc != 0) goto fail3; } Modified: head/sys/dev/sfxge/common/efx_mcdi.h ============================================================================== --- head/sys/dev/sfxge/common/efx_mcdi.h Fri Nov 30 07:08:27 2018 (r341312) +++ head/sys/dev/sfxge/common/efx_mcdi.h Fri Nov 30 07:08:38 2018 (r341313) @@ -247,8 +247,8 @@ extern __checkReturn efx_rc_t efx_mcdi_phy_module_get_info( __in efx_nic_t *enp, __in uint8_t dev_addr, - __in uint8_t offset, - __in uint8_t len, + __in size_t offset, + __in size_t len, __out_bcount(len) uint8_t *data); #define MCDI_IN(_emr, _type, _ofst) \ Modified: head/sys/dev/sfxge/common/efx_phy.c ============================================================================== --- head/sys/dev/sfxge/common/efx_phy.c Fri Nov 30 07:08:27 2018 (r341312) +++ head/sys/dev/sfxge/common/efx_phy.c Fri Nov 30 07:08:38 2018 (r341313) @@ -317,8 +317,8 @@ efx_phy_media_type_get( efx_phy_module_get_info( __in efx_nic_t *enp, __in uint8_t dev_addr, - __in uint8_t offset, - __in uint8_t len, + __in size_t offset, + __in size_t len, __out_bcount(len) uint8_t *data) { efx_rc_t rc; @@ -326,7 +326,8 @@ efx_phy_module_get_info( EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); EFSYS_ASSERT(data != NULL); - if ((uint32_t)offset + len > 0x100) { + if ((offset > EFX_PHY_MEDIA_INFO_MAX_OFFSET) || + ((offset + len) > EFX_PHY_MEDIA_INFO_MAX_OFFSET)) { rc = EINVAL; goto fail1; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811300708.wAU78cHV083251>