]> git.droids-corp.org - dpdk.git/commitdiff
net/sfc/base: adjust PHY module info interface
authorRichard Houldsworth <rhouldsworth@solarflare.com>
Mon, 24 Sep 2018 13:50:22 +0000 (14:50 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 27 Sep 2018 23:41:03 +0000 (01:41 +0200)
Adjust data types in interface to permit the complete
module information buffer to be obtained in a single
call.

Signed-off-by: Richard Houldsworth <rhouldsworth@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/base/efx.h
drivers/net/sfc/base/efx_mcdi.c
drivers/net/sfc/base/efx_mcdi.h
drivers/net/sfc/base/efx_phy.c

index 9eefda6a53bc31cd64d227c7a59ef0396a988330..a8c3ae30153ff8396163633592ec4018692b4e0b 100644 (file)
@@ -1051,12 +1051,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
index 01cc64e2ee0f223dab79a56fd5a92587d8454df0..f53be015b87975404d5d3069461296a03137c9e5 100644 (file)
@@ -2214,8 +2214,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);
@@ -2296,12 +2296,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;
 
@@ -2318,7 +2320,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;
        }
index 40072405e7c2d9845253a6b96e7801bcf45ea42d..ddf91c1113272d6bed0e7c9aad58b14c082bc6f3 100644 (file)
@@ -219,8 +219,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)                                     \
index e78d6efcbb00d2a078abd97114832a9fd63a5a7c..63b89e6a4dcb85991872313cca297784bf875f6e 100644 (file)
@@ -288,8 +288,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;
@@ -297,7 +297,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;
        }