[dpdk-dev] [PATCH v3 06/10] net/atlantic: fix EEPROM get for small and uneven lengths

Igor Russkikh Igor.Russkikh at aquantia.com
Tue Mar 12 16:25:01 CET 2019


From: Pavel Belous <Pavel.Belous at aquantia.com>

Fixes: ce4e8d418097 ("net/atlantic: implement EEPROM get/set")
Cc: stable at dpdk.org
Signed-off-by: Igor Russkikh <igor.russkikh at aquantia.com>
Signed-off-by: Pavel Belous <Pavel.Belous at aquantia.com>
---
 .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c   | 28 ++++++++++++++++---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 1d9190155421..f215ceb70435 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -534,13 +534,33 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
 		return err;
 
 	if (result == 0) {
-		err = hw_atl_utils_fw_downld_dwords(self,
+		u32 num_dwords = len / sizeof(u32);
+		u32 bytes_remains = len % sizeof(u32);
+
+		if (num_dwords) {
+			err = hw_atl_utils_fw_downld_dwords(self,
 				self->rpc_addr + sizeof(u32) * 2,
 				data,
-				RTE_ALIGN(len, sizeof(u32)));
+				num_dwords);
 
-		if (err < 0)
-			return err;
+			if (err < 0)
+				return err;
+		}
+
+		if (bytes_remains) {
+			u32 val = 0;
+
+			err = hw_atl_utils_fw_downld_dwords(self,
+				self->rpc_addr + sizeof(u32) * 2 + num_dwords,
+				&val,
+				sizeof(u32));
+
+			if (err < 0)
+				return err;
+
+			rte_memcpy((u8 *)data + len - bytes_remains,
+				   &val, bytes_remains);
+		}
 	}
 
 	return 0;
-- 
2.17.1



More information about the dev mailing list