Skip to contentSkip to conversation

net/atlantic: bugfixes and code cleanup

PATCH In review Igor Russkikh 3 participants 15 messages Mar 12, 2019 – Mar 20, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

v3 cover net/atlantic: bugfixes and code cleanup

The patchset mainly fixes some Coverity issues,
couple of minor bugs and overflows.

It also improves eeprom get/set logic with ability of custom device address and dump length.

v3: added coverity ids where known
v2: better git log, line lengths, Fixes tags.

Igor Russkikh (7):
net/atlantic: fix negative error codes net/atlantic: remove unused variable net/atlantic: extra checks for error codes net/atlantic: fix link configuration net/atlantic: eliminate excessive log levels on Rx/Tx net/atlantic: fix missing VLAN filter offload net/atlantic: fix xstats to return correct number of items

Pavel Belous (3):
net/atlantic: fix buffer overflow
net/atlantic: use EEPROM magic as a device address net/atlantic: fix EEPROM get for small and uneven lengths

 drivers/net/atlantic/atl_ethdev.c             | 76 ++++++++++---------
 drivers/net/atlantic/atl_rxtx.c               | 20 ++---
 drivers/net/atlantic/atl_types.h              |  7 +-
 drivers/net/atlantic/hw_atl/hw_atl_b0.c       |  6 +-
 drivers/net/atlantic/hw_atl/hw_atl_utils.c    |  9 ++-
 drivers/net/atlantic/hw_atl/hw_atl_utils.h    | 23 +++---
 .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c   | 66 +++++++++++-----
 7 files changed, 118 insertions(+), 89 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/10 net/atlantic: fix negative error codes

These are just convention breakage on rte_errno,
no real harm from that.

Fixes 2b1472d7150c ("net/atlantic: implement Tx path")
---
 drivers/net/atlantic/atl_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/atlantic/atl_rxtx.c +2 -2
index 40c913795c79..aea58c0d5b83 100644
@@ -812,12 +812,12 @@ atl_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 		ol_flags = m->ol_flags;
 
 		if (m->nb_segs > AQ_HW_MAX_SEGS_SIZE) {
-			rte_errno = -EINVAL;
+			rte_errno = EINVAL;
 			return i;
 		}
 
 		if (ol_flags & ATL_TX_OFFLOAD_NOTSUP_MASK) {
-			rte_errno = -ENOTSUP;
+			rte_errno = ENOTSUP;
 			return i;
 		}
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 2/10 net/atlantic: remove unused variable

In reply to Igor Russkikh

Found by coverity scan.

Fixes 7906661edac6 ("net/atlantic: add b0 hardware layer")

Coverity issue: 323512

---
 drivers/net/atlantic/hw_atl/hw_atl_b0.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/atlantic/hw_atl/hw_atl_b0.c +1 -5
index 9400e0edb999..53fd8e9f0237 100644
@@ -31,7 +31,6 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
 	u32 tc = 0U;
 	u32 buff_size = 0U;
 	unsigned int i_priority = 0U;
-	bool is_rx_flow_control = false;
 
 	/* TPS Descriptor rate init */
 	hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set(self, 0x0U);
@@ -64,7 +63,6 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
 
 	/* QoS Rx buf size per TC */
 	tc = 0;
-	is_rx_flow_control = 0;
 	buff_size = HW_ATL_B0_RXBUF_MAX;
 
 	hw_atl_rpb_rx_pkt_buff_size_per_tc_set(self, buff_size, tc);
@@ -76,9 +74,7 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
 						   (buff_size *
 						   (1024U / 32U) * 50U) /
 						   100U, tc);
-	hw_atl_rpb_rx_xoff_en_per_tc_set(self,
-					 is_rx_flow_control ? 1U : 0U,
-					 tc);
+	hw_atl_rpb_rx_xoff_en_per_tc_set(self, 0U, tc);
 
 	/* QoS 802.1p priority -> TC mapping */
 	for (i_priority = 8U; i_priority--;)
Signature · 1 line
2.17.1
#3 lore raw

PATCH v3 3/10 net/atlantic: extra checks for error codes

In reply to Igor Russkikh

Found by Coverity scan. Checks are useless
because at these code places err is always zero.

---
 drivers/net/atlantic/hw_atl/hw_atl_utils.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/atlantic/hw_atl/hw_atl_utils.c +1 -4
index f11093a50404..13f02b9f99c5 100644
@@ -462,8 +462,6 @@ int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self,
 				goto err_exit;
 		}
 	} while (sw.tid != fw.tid || 0xFFFFU == fw.len);
-	if (err < 0)
-		goto err_exit;
 
 	if (rpc) {
 		if (fw.len) {
@@ -875,8 +873,7 @@ static int aq_fw1x_set_wol(struct aq_hw_s *self, bool wol_enabled, u8 *mac)
 	}
 
 	err = hw_atl_utils_fw_rpc_call(self, rpc_size);
-	if (err < 0)
-		goto err_exit;
+
 err_exit:
 	return err;
 }
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v3 03/10] net/atlantic: extra checks for error codes

Quoted 2 lines · Igor Russkikh

Found by Coverity scan. Checks are useless
because at these code places err is always zero.

Can you please add Coverity issue number, I can squash it later.

Quoted 3 lines

---

<...>

#5 lore raw

Re: [PATCH v3 03/10] net/atlantic: extra checks for error codes

Hi Ferruh,

Sorry forgot that.

Coverity issue: 187034

Quoted 12 lines · Ferruh Yigit
Quoted 2 lines · Igor Russkikh

Found by Coverity scan. Checks are useless
because at these code places err is always zero.

Can you please add Coverity issue number, I can squash it later.

Quoted 3 lines

---

<...>

#6 lore raw

PATCH v3 4/10 net/atlantic: fix buffer overflow

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

Found by Coverity scan. This is a real memory corruption. There is no need in extra RTE_ALIGN macros since the request/result structures are 4-byte aligned by definition.

Fixes ce4e8d418097 ("net/atlantic: implement EEPROM get/set")

Coverity issue: 323518
Coverity issue: 323520

---
 drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c +4 -4
index 6841d9bce39c..f90ccfe9e010 100644
@@ -501,7 +501,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	/* Write SMBUS request to cfg memory */
 	err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
 				(u32 *)(void *)&request,
-				RTE_ALIGN(sizeof(request), sizeof(u32)));
+				sizeof(request) / sizeof(u32));
 
 	if (err < 0)
 		return err;
@@ -523,7 +523,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 
 	err = hw_atl_utils_fw_downld_dwords(self, self->rpc_addr + sizeof(u32),
 			&result,
-			RTE_ALIGN(sizeof(result), sizeof(u32)));
+			sizeof(result) / sizeof(u32));
 
 	if (err < 0)
 		return err;
@@ -558,7 +558,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	/* Write SMBUS request to cfg memory */
 	err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
 				(u32 *)(void *)&request,
-				RTE_ALIGN(sizeof(request), sizeof(u32)));
+				sizeof(request) / sizeof(u32));
 
 	if (err < 0)
 		return err;
@@ -589,7 +589,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	/* Read status of write operation */
 	err = hw_atl_utils_fw_downld_dwords(self, self->rpc_addr + sizeof(u32),
 				&result,
-				RTE_ALIGN(sizeof(result), sizeof(u32)));
+				sizeof(result) / sizeof(u32));
 
 	if (err < 0)
 		return err;
Signature · 1 line
2.17.1
#7 lore raw

PATCH v3 5/10 net/atlantic: use EEPROM magic as a device address

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

Default dev addr is replaced with magic field from the request. Length is allowed to be less than maximum.
SMBUS access bit definitions also better organised now.

---
 drivers/net/atlantic/atl_ethdev.c             | 25 +++++++++++-----
 drivers/net/atlantic/atl_types.h              |  7 +++--
 drivers/net/atlantic/hw_atl/hw_atl_utils.c    |  4 +++
 drivers/net/atlantic/hw_atl/hw_atl_utils.h    | 23 +++++++-------
 .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c   | 30 +++++++++++--------
 5 files changed, 58 insertions(+), 31 deletions(-)
drivers/net/atlantic/atl_ethdev.c +18 -7
index 5bc04f55cc21..a510646a5f7e 100644
@@ -1102,24 +1102,31 @@ atl_dev_get_eeprom_length(struct rte_eth_dev *dev __rte_unused)
 	return SFP_EEPROM_SIZE;
 }
 
-static int
-atl_dev_get_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
+int atl_dev_get_eeprom(struct rte_eth_dev *dev,
+		       struct rte_dev_eeprom_info *eeprom)
 {
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t dev_addr = SMBUS_DEVICE_ID;
 
 	if (hw->aq_fw_ops->get_eeprom == NULL)
 		return -ENOTSUP;
 
-	if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
+	if (eeprom->length + eeprom->offset > SFP_EEPROM_SIZE ||
+	    eeprom->data == NULL)
 		return -EINVAL;
 
-	return hw->aq_fw_ops->get_eeprom(hw, eeprom->data, eeprom->length);
+	if (eeprom->magic)
+		dev_addr = eeprom->magic;
+
+	return hw->aq_fw_ops->get_eeprom(hw, dev_addr, eeprom->data,
+					 eeprom->length, eeprom->offset);
 }
 
-static int
-atl_dev_set_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
+int atl_dev_set_eeprom(struct rte_eth_dev *dev,
+		       struct rte_dev_eeprom_info *eeprom)
 {
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t dev_addr = SMBUS_DEVICE_ID;
 
 	if (hw->aq_fw_ops->set_eeprom == NULL)
 		return -ENOTSUP;
@@ -1127,7 +1134,11 @@ atl_dev_set_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom)
 	if (eeprom->length != SFP_EEPROM_SIZE || eeprom->data == NULL)
 		return -EINVAL;
 
-	return hw->aq_fw_ops->set_eeprom(hw, eeprom->data, eeprom->length);
+	if (eeprom->magic)
+		dev_addr = eeprom->magic;
+
+	return hw->aq_fw_ops->set_eeprom(hw, dev_addr,
+					 eeprom->data, eeprom->length);
 }
 
 static int
drivers/net/atlantic/atl_types.h +5 -2
index 3d90f6caefc2..3edaf0c7c047 100644
@@ -137,9 +137,12 @@ struct aq_fw_ops {
 
 	int (*led_control)(struct aq_hw_s *self, u32 mode);
 
-	int (*get_eeprom)(struct aq_hw_s *self, u32 *data, u32 len);
+	int (*get_eeprom)(struct aq_hw_s *self, int dev_addr,
+			  u32 *data, u32 len, u32 offset);
+
+	int (*set_eeprom)(struct aq_hw_s *self, int dev_addr,
+			  u32 *data, u32 len);
 
-	int (*set_eeprom)(struct aq_hw_s *self, u32 *data, u32 len);
 };
 
 struct atl_sw_stats {
drivers/net/atlantic/hw_atl/hw_atl_utils.c +4 -0
index 13f02b9f99c5..4299b7016e2f 100644
@@ -305,6 +305,10 @@ int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a,
 			AQ_HW_WAIT_FOR(!(0x100 & aq_hw_read_reg(self,
 							   HW_ATL_MIF_CMD)),
 				       1, 1000U);
+			if (err) {
+				err = -ETIMEDOUT;
+				goto err_exit;
+			}
 
 		*(p++) = aq_hw_read_reg(self, HW_ATL_MIF_VAL);
 		a += 4;
drivers/net/atlantic/hw_atl/hw_atl_utils.h +13 -10
index 5f3f70847310..f2a87826c0d1 100644
@@ -8,6 +8,7 @@
 #ifndef HW_ATL_UTILS_H
 #define HW_ATL_UTILS_H
 
+#define BIT(x)  (1UL << (x))
 #define HW_ATL_FLUSH() { (void)aq_hw_read_reg(self, 0x10); }
 
 /* Hardware tx descriptor */
@@ -389,18 +390,8 @@ enum hal_atl_utils_fw_state_e {
 #define HAL_ATLANTIC_UTILS_FW_MSG_OFFLOAD_DEL  10U
 #define HAL_ATLANTIC_UTILS_FW_MSG_CABLE_DIAG   13U // 0xd
 
-#define SMBUS_READ_REQUEST BIT(13)
-#define SMBUS_WRITE_REQUEST BIT(14)
 #define SMBUS_DEVICE_ID 0x50
 
-enum hw_atl_fw2x_rate {
-	FW2X_RATE_100M    = 0x20,
-	FW2X_RATE_1G      = 0x100,
-	FW2X_RATE_2G5     = 0x200,
-	FW2X_RATE_5G      = 0x400,
-	FW2X_RATE_10G     = 0x800,
-};
-
 enum hw_atl_fw2x_caps_lo {
 	CAPS_LO_10BASET_HD = 0x00,
 	CAPS_LO_10BASET_FD,
@@ -414,6 +405,10 @@ enum hw_atl_fw2x_caps_lo {
 	CAPS_LO_2P5GBASET_FD,
 	CAPS_LO_5GBASET_FD,
 	CAPS_LO_10GBASET_FD,
+	CAPS_LO_AUTONEG,
+	CAPS_LO_SMBUS_READ,
+	CAPS_LO_SMBUS_WRITE,
+	CAPS_LO_MACSEC
 };
 
 enum hw_atl_fw2x_caps_hi {
@@ -451,6 +446,14 @@ enum hw_atl_fw2x_caps_hi {
 	CAPS_HI_TRANSACTION_ID,
 };
 
+enum hw_atl_fw2x_rate {
+	FW2X_RATE_100M    = BIT(CAPS_LO_100BASETX_FD),
+	FW2X_RATE_1G      = BIT(CAPS_LO_1000BASET_FD),
+	FW2X_RATE_2G5     = BIT(CAPS_LO_2P5GBASET_FD),
+	FW2X_RATE_5G      = BIT(CAPS_LO_5GBASET_FD),
+	FW2X_RATE_10G     = BIT(CAPS_LO_10GBASET_FD),
+};
+
 struct aq_hw_s;
 struct aq_fw_ops;
 struct aq_hw_link_status_s;
drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c +18 -12
index f90ccfe9e010..1d9190155421 100644
@@ -129,7 +129,11 @@ static u32 fw2x_to_eee_mask(u32 speed)
 
 static int aq_fw2x_set_link_speed(struct aq_hw_s *self, u32 speed)
 {
-	u32 val = link_speed_mask_2fw2x_ratemask(speed);
+	u32 rate_mask = link_speed_mask_2fw2x_ratemask(speed);
+	u32 reg_val = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL_ADDR);
+	u32 val = rate_mask | ((BIT(CAPS_LO_SMBUS_READ) |
+				BIT(CAPS_LO_SMBUS_WRITE) |
+				BIT(CAPS_LO_MACSEC)) & reg_val);
 
 	aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL_ADDR, val);
 
@@ -484,7 +488,8 @@ static int aq_fw2x_led_control(struct aq_hw_s *self, u32 mode)
 	return 0;
 }
 
-static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
+static int aq_fw2x_get_eeprom(struct aq_hw_s *self, int dev_addr,
+			      u32 *data, u32 len, u32 offset)
 {
 	int err = 0;
 	struct smbus_read_request request;
@@ -494,8 +499,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	if (self->fw_ver_actual < HW_ATL_FW_FEATURE_EEPROM)
 		return -EOPNOTSUPP;
 
-	request.device_id = SMBUS_DEVICE_ID;
-	request.address = 0;
+	request.device_id = dev_addr;
+	request.address = offset;
 	request.length = len;
 
 	/* Write SMBUS request to cfg memory */
@@ -506,16 +511,16 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	if (err < 0)
 		return err;
 
-	/* Toggle 0x368.SMBUS_READ_REQUEST bit */
+	/* Toggle 0x368.CAPS_LO_SMBUS_READ bit */
 	mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL_ADDR);
-	mpi_opts ^= SMBUS_READ_REQUEST;
+	mpi_opts ^= BIT(CAPS_LO_SMBUS_READ);
 
 	aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL_ADDR, mpi_opts);
 
 	/* Wait until REQUEST_BIT matched in 0x370 */
 
 	AQ_HW_WAIT_FOR((aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE_ADDR) &
-		SMBUS_READ_REQUEST) == (mpi_opts & SMBUS_READ_REQUEST),
+		BIT(CAPS_LO_SMBUS_READ)) == (mpi_opts & BIT(CAPS_LO_SMBUS_READ)),
 		10U, 10000U);
 
 	if (err < 0)
@@ -542,7 +547,8 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 }
 
 
-static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
+static int aq_fw2x_set_eeprom(struct aq_hw_s *self, int dev_addr,
+			      u32 *data, u32 len)
 {
 	struct smbus_write_request request;
 	u32 mpi_opts, result = 0;
@@ -551,7 +557,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	if (self->fw_ver_actual < HW_ATL_FW_FEATURE_EEPROM)
 		return -EOPNOTSUPP;
 
-	request.device_id = SMBUS_DEVICE_ID;
+	request.device_id = dev_addr;
 	request.address = 0;
 	request.length = len;
 
@@ -572,15 +578,15 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 	if (err < 0)
 		return err;
 
-	/* Toggle 0x368.SMBUS_WRITE_REQUEST bit */
+	/* Toggle 0x368.CAPS_LO_SMBUS_WRITE bit */
 	mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL_ADDR);
-	mpi_opts ^= SMBUS_WRITE_REQUEST;
+	mpi_opts ^= BIT(CAPS_LO_SMBUS_WRITE);
 
 	aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL_ADDR, mpi_opts);
 
 	/* Wait until REQUEST_BIT matched in 0x370 */
 	AQ_HW_WAIT_FOR((aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE_ADDR) &
-		SMBUS_WRITE_REQUEST) == (mpi_opts & SMBUS_WRITE_REQUEST),
+		BIT(CAPS_LO_SMBUS_WRITE)) == (mpi_opts & BIT(CAPS_LO_SMBUS_WRITE)),
 		10U, 10000U);
 
 	if (err < 0)
Signature · 1 line
2.17.1
#8 lore raw

PATCH v3 6/10 net/atlantic: fix EEPROM get for small and uneven lengths

In reply to Igor Russkikh

From: Pavel Belous <[email protected]>

Fixes ce4e8d418097 ("net/atlantic: implement EEPROM get/set")
---
 .../net/atlantic/hw_atl/hw_atl_utils_fw2x.c   | 28 ++++++++++++++++---
 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c +24 -4
index 1d9190155421..f215ceb70435 100644
@@ -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;
Signature · 1 line
2.17.1
#9 lore raw

PATCH v3 7/10 net/atlantic: fix link configuration

In reply to Igor Russkikh

In case link speed is re configured after port start, it does not takes the requested speed value, but instead just sets full autoneg mask.

Fixes 7943ba05f67c ("net/atlantic: add link status and interrupt management")
---
 drivers/net/atlantic/atl_ethdev.c | 44 ++++++++++++++-----------------
 1 file changed, 20 insertions(+), 24 deletions(-)
drivers/net/atlantic/atl_ethdev.c +20 -24
index a510646a5f7e..e43e1e724696 100644
@@ -465,8 +465,6 @@ atl_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	uint32_t *link_speeds;
-	uint32_t speed = 0;
 	int status;
 	int err;
 
@@ -543,6 +541,8 @@ atl_dev_start(struct rte_eth_dev *dev)
 		goto error;
 	}
 
+	err = atl_dev_set_link_up(dev);
+
 	err = hw->aq_fw_ops->update_link_status(hw);
 
 	if (err)
@@ -550,26 +550,6 @@ atl_dev_start(struct rte_eth_dev *dev)
 
 	dev->data->dev_link.link_status = hw->aq_link_status.mbps != 0;
 
-	link_speeds = &dev->data->dev_conf.link_speeds;
-
-	speed = 0x0;
-
-	if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
-		speed = hw->aq_nic_cfg->link_speed_msk;
-	} else {
-		if (*link_speeds & ETH_LINK_SPEED_10G)
-			speed |= AQ_NIC_RATE_10G;
-		if (*link_speeds & ETH_LINK_SPEED_5G)
-			speed |= AQ_NIC_RATE_5G;
-		if (*link_speeds & ETH_LINK_SPEED_1G)
-			speed |= AQ_NIC_RATE_1G;
-		if (*link_speeds & ETH_LINK_SPEED_2_5G)
-			speed |=  AQ_NIC_RATE_2G5;
-		if (*link_speeds & ETH_LINK_SPEED_100M)
-			speed |= AQ_NIC_RATE_100M;
-	}
-
-	err = hw->aq_fw_ops->set_link_speed(hw, speed);
 	if (err)
 		goto error;
 
@@ -657,9 +637,25 @@ static int
 atl_dev_set_link_up(struct rte_eth_dev *dev)
 {
 	struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t link_speeds = dev->data->dev_conf.link_speeds;
+	uint32_t speed_mask = 0;
+
+	if (link_speeds == ETH_LINK_SPEED_AUTONEG) {
+		speed_mask = hw->aq_nic_cfg->link_speed_msk;
+	} else {
+		if (link_speeds & ETH_LINK_SPEED_10G)
+			speed_mask |= AQ_NIC_RATE_10G;
+		if (link_speeds & ETH_LINK_SPEED_5G)
+			speed_mask |= AQ_NIC_RATE_5G;
+		if (link_speeds & ETH_LINK_SPEED_1G)
+			speed_mask |= AQ_NIC_RATE_1G;
+		if (link_speeds & ETH_LINK_SPEED_2_5G)
+			speed_mask |=  AQ_NIC_RATE_2G5;
+		if (link_speeds & ETH_LINK_SPEED_100M)
+			speed_mask |= AQ_NIC_RATE_100M;
+	}
 
-	return hw->aq_fw_ops->set_link_speed(hw,
-			hw->aq_nic_cfg->link_speed_msk);
+	return hw->aq_fw_ops->set_link_speed(hw, speed_mask);
 }
 
 /*
Signature · 1 line
2.17.1
#10 lore raw

PATCH v3 8/10 net/atlantic: eliminate excessive log levels on Rx/Tx

In reply to Igor Russkikh

Default rxtx logging used ERR level, that caused logger to always trigger. That may cause perf degradation even if logger was not enabled but compiled in.

---
 drivers/net/atlantic/atl_rxtx.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/atlantic/atl_rxtx.c +4 -12
index aea58c0d5b83..f1519594adad 100644
@@ -946,7 +946,7 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 			break;
 		}
 
-		PMD_RX_LOG(ERR, "port_id=%u queue_id=%u tail=%u "
+		PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u tail=%u "
 			   "eop=0x%x pkt_len=%u hash=0x%x hash_type=0x%x",
 			   (unsigned int)rxq->port_id,
 			   (unsigned int)rxq->queue_id,
@@ -981,7 +981,7 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		while (true) {
 			new_mbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
 			if (new_mbuf == NULL) {
-				PMD_RX_LOG(ERR,
+				PMD_RX_LOG(DEBUG,
 				   "RX mbuf alloc failed port_id=%u "
 				   "queue_id=%u", (unsigned int)rxq->port_id,
 				   (unsigned int)rxq->queue_id);
@@ -1084,7 +1084,7 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		adapter->sw_stats.q_ibytes[rxq->queue_id] +=
 			rx_mbuf_first->pkt_len;
 
-		PMD_RX_LOG(ERR, "add mbuf segs=%d pkt_len=%d",
+		PMD_RX_LOG(DEBUG, "add mbuf segs=%d pkt_len=%d",
 			rx_mbuf_first->nb_segs,
 			rx_mbuf_first->pkt_len);
 	}
@@ -1104,7 +1104,7 @@ atl_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	 */
 	nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
 	if (nb_hold > rxq->rx_free_thresh) {
-		PMD_RX_LOG(ERR, "port_id=%u queue_id=%u rx_tail=%u "
+		PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_tail=%u "
 			"nb_hold=%u nb_rx=%u",
 			(unsigned int)rxq->port_id, (unsigned int)rxq->queue_id,
 			(unsigned int)tail, (unsigned int)nb_hold,
@@ -1129,8 +1129,6 @@ atl_xmit_cleanup(struct atl_tx_queue *txq)
 	struct hw_atl_txd_s *txd;
 	int to_clean = 0;
 
-	PMD_INIT_FUNC_TRACE();
-
 	if (txq != NULL) {
 		sw_ring = txq->sw_ring;
 		int head = txq->tx_head;
@@ -1181,11 +1179,7 @@ atl_tso_setup(struct rte_mbuf *tx_pkt, union hw_atl_txc_s *txc)
 	uint32_t tx_cmd = 0;
 	uint64_t ol_flags = tx_pkt->ol_flags;
 
-	PMD_INIT_FUNC_TRACE();
-
 	if (ol_flags & PKT_TX_TCP_SEG) {
-		PMD_DRV_LOG(DEBUG, "xmit TSO pkt");
-
 		tx_cmd |= tx_desc_cmd_lso | tx_desc_cmd_l4cs;
 
 		txc->cmd = 0x4;
@@ -1240,8 +1234,6 @@ atl_xmit_pkt(struct aq_hw_s *hw, struct atl_tx_queue *txq,
 	u32 tx_cmd = 0U;
 	int desc_count = 0;
 
-	PMD_INIT_FUNC_TRACE();
-
 	tail = txq->tx_tail;
 
 	txc = (union hw_atl_txc_s *)&txq->hw_ring[tail];
Signature · 1 line
2.17.1
#11 lore raw

PATCH v3 9/10 net/atlantic: fix missing VLAN filter offload

In reply to Igor Russkikh

Original vlan offload code declared callbacks, but did not enable the feature offload bit

Fixes f7c2c2c8c558 ("net/atlantic: implement VLAN filters and offloads")
---
 drivers/net/atlantic/atl_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/atlantic/atl_ethdev.c +2 -1
index e43e1e724696..b05dc545d0b1 100644
@@ -165,7 +165,8 @@ static struct rte_pci_driver rte_atl_pmd = {
 			| DEV_RX_OFFLOAD_IPV4_CKSUM \
 			| DEV_RX_OFFLOAD_UDP_CKSUM \
 			| DEV_RX_OFFLOAD_TCP_CKSUM \
-			| DEV_RX_OFFLOAD_JUMBO_FRAME)
+			| DEV_RX_OFFLOAD_JUMBO_FRAME \
+			| DEV_RX_OFFLOAD_VLAN_FILTER)
 
 #define ATL_TX_OFFLOADS (DEV_TX_OFFLOAD_VLAN_INSERT \
 			| DEV_TX_OFFLOAD_IPV4_CKSUM \
Signature · 1 line
2.17.1
#13 lore raw

PATCH v3 10/10 net/atlantic: fix xstats to return correct number of items

In reply to Igor Russkikh

Max number of xstats items was returned instead of actual number of filled in records.

Fixes fbe059e87209 ("net/atlantic: implement device statistics")
---
 drivers/net/atlantic/atl_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/atlantic/atl_ethdev.c +2 -2
index b05dc545d0b1..5c62d137b255 100644
@@ -758,7 +758,7 @@ atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
 		snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, "%s",
 			atl_xstats_tbl[i].name);
 
-	return size;
+	return i;
 }
 
 static int
@@ -778,7 +778,7 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
 					atl_xstats_tbl[i].offset);
 	}
 
-	return n;
+	return i;
 }
 
 static int
Signature · 1 line
2.17.1
#14 lore raw
In reply to Igor Russkikh
Quoted 19 lines · Igor Russkikh

The patchset mainly fixes some Coverity issues,
couple of minor bugs and overflows.

It also improves eeprom get/set logic with ability of custom device address and dump length.

v3: added coverity ids where known
v2: better git log, line lengths, Fixes tags.

Igor Russkikh (7):
net/atlantic: fix negative error codes net/atlantic: remove unused variable net/atlantic: extra checks for error codes net/atlantic: fix link configuration net/atlantic: eliminate excessive log levels on Rx/Tx net/atlantic: fix missing VLAN filter offload net/atlantic: fix xstats to return correct number of items

Quoted 4 lines

Pavel Belous (3):
net/atlantic: fix buffer overflow
net/atlantic: use EEPROM magic as a device address net/atlantic: fix EEPROM get for small and uneven lengths

Series applied to dpdk-next-net/master, thanks.