Skip to contentSkip to conversation

Bugs Porting from I40evf For IAVF Feature

PATCH In review SteveX Yang 6 participants 33 messages Aug 11, 2020 – Sep 11, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

cover Bugs Porting from I40evf For IAVF Feature

These patches are bugs porting from i40evf to iavf.

[PATCH 1/7] net/iavf: fix scattered Rx enabling
[PATCH 2/7] net/iavf: set speed to undefined for default case [PATCH 3/7] net/iavf: fix port start during configuration restore [PATCH 4/7] net/iavf: fix setting of MAC address on iavf [PATCH 5/7] net/iavf: fix multiple interrupts for VF [PATCH 6/7] net/iavf: downgrade error log
[PATCH 7/7] net/iavf: fix port close

 drivers/net/iavf/iavf.h        |  1 +
 drivers/net/iavf/iavf_ethdev.c | 24 ++++++++++----
 drivers/net/iavf/iavf_vchnl.c  | 58 +++++++++++++++++++++++++++-------
 3 files changed, 65 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/7 net/iavf: fix scattered Rx enabling

No need to add additional vlan tag size for max packet size, since for i40e, the queue's Rx Max Frame Size (rxq->max_pkt_len) already includes the vlan header size.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_ethdev.c +1 -1
index c3aa4cd72..f9dd5710c 100644
@@ -253,7 +253,7 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct iavf_rx_queue *rxq)
 
 	rxq->max_pkt_len = max_pkt_len;
 	if ((dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SCATTER) ||
-	    (rxq->max_pkt_len + 2 * IAVF_VLAN_TAG_SIZE) > buf_size) {
+	    rxq->max_pkt_len > buf_size) {
 		dev_data->scattered_rx = 1;
 	}
 	IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/7 net/iavf: set speed to undefined for default case

In reply to SteveX Yang

During PF/VF link update, a default speed value of 100M will be set if get_link_info has failed or speed is unknown.

Consequently if PF is put in no-carrier state, VFs will switch to "in carrier" state due to a link up + a link speed set to 100M (default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in same carrier state, sets default speed to undefined (instead of 100M) and updates a link status of VF only if link is up and speed is different from undefined.

Fixes 48de41ca11f0 ("net/avf: enable link status update")
---
 drivers/net/iavf/iavf_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ethdev.c +3 -2
index f9dd5710c..ae508f2f0 100644
@@ -620,8 +620,9 @@ iavf_dev_link_update(struct rte_eth_dev *dev,
 	}
 
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up &&
+				new_link.link_speed != ETH_SPEED_NUM_NONE)
+				? ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				ETH_LINK_SPEED_FIXED);
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/7 net/iavf: fix port start during configuration restore

In reply to SteveX Yang

If configuring VF promiscuous mode is not supported, return -ENOTSUP error code in .promiscuous_enable/disable dev_ops. This is to fix the port start during configuration restore, where if .promiscuous_enable/disable dev_ops exists
and return any value other than -ENOTSUP, start will fail.

Same is done for .allmulticast_enable/disable dev_ops.

Fixes ca041cd44fcc ("ethdev: change allmulticast callbacks to return status")
Fixes 9039c8125730 ("ethdev: change promiscuous callbacks to return status")
---
 drivers/net/iavf/iavf_ethdev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/iavf/iavf_ethdev.c +8 -0
index ae508f2f0..349c82cae 100644
@@ -648,6 +648,8 @@ iavf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, true, vf->promisc_multicast_enabled);
 	if (!ret)
 		vf->promisc_unicast_enabled = true;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -669,6 +671,8 @@ iavf_dev_promiscuous_disable(struct rte_eth_dev *dev)
 				  vf->promisc_multicast_enabled);
 	if (!ret)
 		vf->promisc_unicast_enabled = false;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -689,6 +693,8 @@ iavf_dev_allmulticast_enable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, true);
 	if (!ret)
 		vf->promisc_multicast_enabled = true;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -709,6 +715,8 @@ iavf_dev_allmulticast_disable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, false);
 	if (!ret)
 		vf->promisc_multicast_enabled = false;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/7 net/iavf: fix setting of MAC address on iavf

In reply to SteveX Yang

When setting the MAC address, the ethdev layer copies the new mac address in dev->data->mac_addrs[0] before calling the dev_ops.

Therefore, is_same_ether_addr(mac_addr, dev->data->mac_addrs) was always true, and the MAC was never set. Remove this test to fix the issue.

Fixes 538da7a1cad2 ("net: add rte prefix to ether functions")
---
 drivers/net/iavf/iavf_ethdev.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/iavf/iavf_ethdev.c +0 -3
index 349c82cae..f16aff531 100644
@@ -978,9 +978,6 @@ iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev,
 	old_addr = (struct rte_ether_addr *)hw->mac.addr;
 	perm_addr = (struct rte_ether_addr *)hw->mac.perm_addr;
 
-	if (rte_is_same_ether_addr(mac_addr, old_addr))
-		return 0;
-
 	/* If the MAC address is configured by host, skip the setting */
 	if (rte_is_valid_assigned_ether_addr(perm_addr))
 		return -EPERM;
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/7 net/iavf: fix multiple interrupts for VF

In reply to SteveX Yang

Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt bind by code reconstruction.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_vchnl.c | 56 ++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_vchnl.c +45 -11
index 33acea54a..614ea7e79 100644
@@ -18,6 +18,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_dev.h>
+#include <rte_bus_pci.h>
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
@@ -686,20 +687,53 @@ int
 iavf_config_irq_map(struct iavf_adapter *adapter)
 {
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct iavf_cmd_info args;
+	uint8_t *cmd_buffer = NULL;
 	struct virtchnl_irq_map_info *map_info;
 	struct virtchnl_vector_map *vecmap;
-	struct iavf_cmd_info args;
-	int len, i, err;
+	struct rte_eth_dev *dev = adapter->eth_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 vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
+	uint16_t rxq_map[vf->vf_res->max_vectors];
+	int err;
 
-	len = sizeof(struct virtchnl_irq_map_info) +
-	      sizeof(struct virtchnl_vector_map) * vf->nb_msix;
+	memset(rxq_map, 0, sizeof(rxq_map));
+	if (dev->data->dev_conf.intr_conf.rxq &&
+		rte_intr_allow_others(intr_handle)) {
+		msix_base = IAVF_RX_VEC_START;
+		max_vectors = vf->vf_res->max_vectors - 1;
+		nb_msix = RTE_MIN(max_vectors, intr_handle->nb_efd);
+
+		vec = msix_base;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[vec] |= 1 << i;
+			intr_handle->intr_vec[i] = vec++;
+			if (vec >= vf->vf_res->max_vectors)
+				vec = msix_base;
+		}
+	} else {
+		msix_base = IAVF_MISC_VEC_ID;
+		nb_msix = 1;
 
-	map_info = rte_zmalloc("map_info", len, 0);
-	if (!map_info)
-		return -ENOMEM;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[msix_base] |= 1 << i;
+			if (rte_intr_dp_is_en(intr_handle))
+				intr_handle->intr_vec[i] = msix_base;
+		}
+	}
 
-	map_info->num_vectors = vf->nb_msix;
-	for (i = 0; i < vf->nb_msix; i++) {
+	cmd_buffer_size = sizeof(struct virtchnl_irq_map_info) +
+	      sizeof(struct virtchnl_vector_map) * nb_msix;
+	cmd_buffer = rte_zmalloc("iavf", cmd_buffer_size, 0);
+	if (!cmd_buffer) {
+		PMD_DRV_LOG(ERR, "Failed to allocate memory");
+		return IAVF_ERR_NO_MEMORY;
+	}
+
+	map_info = (struct virtchnl_irq_map_info *)cmd_buffer;
+	map_info->num_vectors = nb_msix;
+	for (i = 0; i < nb_msix; i++) {
 		vecmap = &map_info->vecmap[i];
 		vecmap->vsi_id = vf->vsi_res->vsi_id;
 		vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
@@ -709,8 +743,8 @@ iavf_config_irq_map(struct iavf_adapter *adapter)
 	}
 
 	args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
-	args.in_args = (u8 *)map_info;
-	args.in_args_size = len;
+	args.in_args = (u8 *)cmd_buffer;
+	args.in_args_size = cmd_buffer_size;
 	args.out_buffer = vf->aq_resp;
 	args.out_size = IAVF_AQ_BUF_SZ;
 	err = iavf_execute_vf_cmd(adapter, &args);
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/7 net/iavf: downgrade error log

In reply to SteveX Yang

When receiving the unsupported AQ messages, it's taken as an error. It's not appropriate and triggers too much unnecessary print.

Fixes 22b123a36d07 ("net/avf: initialize PMD")
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_vchnl.c +1 -1
index 614ea7e79..06eaae0e4 100644
@@ -266,7 +266,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 			}
 			break;
 		default:
-			PMD_DRV_LOG(ERR, "Request %u is not supported yet",
+			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
 				    aq_opc);
 			break;
 		}
Signature · 1 line
2.17.1
#7 lore raw

PATCH 7/7 net/iavf: fix port close

In reply to SteveX Yang

Port reset will call iavf_dev_uninit() to release resources. It wants to call iavf_dev_close() to release resources. So there will be a call conflict if calling iavf_dev_reset() and iavf_dev_close() at the same time.

This patch added adapter->closed flag in iavf_dev_close() to control the status of close.

Fixes 83fe5e80692a ("net/iavf: move device state flag")
---
 drivers/net/iavf/iavf.h        | 1 +
 drivers/net/iavf/iavf_ethdev.c | 6 ++++++
 2 files changed, 7 insertions(+)
drivers/net/iavf/iavf.h +1 -0
index 9be8a2381..06cbe6089 100644
@@ -161,6 +161,7 @@ struct iavf_adapter {
 	bool tx_vec_allowed;
 	const uint32_t *ptype_tbl;
 	bool stopped;
+	bool closed;
 	uint16_t fdir_ref_cnt;
 };
 
drivers/net/iavf/iavf_ethdev.c +6 -0
index f16aff531..b58e57b07 100644
@@ -1367,6 +1367,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->back = IAVF_DEV_PRIVATE_TO_ADAPTER(eth_dev->data->dev_private);
 	adapter->eth_dev = eth_dev;
 	adapter->stopped = 1;
+	adapter->closed = 0;
 
 	if (iavf_init_vf(eth_dev) != 0) {
 		PMD_INIT_LOG(ERR, "Init vf failed");
@@ -1423,6 +1424,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
+	if (adapter->closed == 1)
+		return;
+
 	iavf_dev_stop(dev);
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
@@ -1434,6 +1438,8 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     iavf_dev_interrupt_handler, dev);
 	iavf_disable_irq0(hw);
+
+	adapter->closed = 1;
 }
 
 static int
Signature · 1 line
2.17.1
#8 lore raw

Re: [dpdk-dev] [PATCH 7/7] net/iavf: fix port close

If RTE_ETH_DEV_CLOSE_REMOVE is set, port would be released when dev_close is called. So it is not necessary to mark it as closed.

Another concern in my mind is the REST virtchnl message is missed to send to PF in iavf_dev_reset.

Thanks
Jingjing

Quoted 70 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Tuesday, August 11, 2020 3:59 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH 7/7] net/iavf: fix port close

Port reset will call iavf_dev_uninit() to release resources. It wants to call iavf_dev_close() to release resources. So there will be a call conflict if calling iavf_dev_reset() and iavf_dev_close() at the same time.

This patch added adapter->closed flag in iavf_dev_close() to control the status of close.

Fixes 83fe5e80692a ("net/iavf: move device state flag")
---
 drivers/net/iavf/iavf.h        | 1 +
 drivers/net/iavf/iavf_ethdev.c | 6 ++++++
 2 files changed, 7 insertions(+)
drivers/net/iavf/iavf.h index renamed from drivers/net/iavf/iavf.h +0 -0

9be8a2381..06cbe6089 100644

drivers/net/iavf/iavf.h +1 -0
@@ -161,6 +161,7 @@ struct iavf_adapter {
 	bool tx_vec_allowed;
 	const uint32_t *ptype_tbl;
 	bool stopped;
+	bool closed;
 	uint16_t fdir_ref_cnt;
 };
 
drivers/net/iavf/iavf_ethdev.c +1 -0
index f16aff531..b58e57b07 100644
@@ -1367,6 +1367,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->back = IAVF_DEV_PRIVATE_TO_ADAPTER(eth_dev->data-
 >dev_private);
 	adapter->eth_dev = eth_dev;
 	adapter->stopped = 1;
+	adapter->closed = 0;
 
 	if (iavf_init_vf(eth_dev) != 0) {
drivers/net/iavf/iavf_ethdev.c +5 -1
 		PMD_INIT_LOG(ERR, "Init vf failed");
@@ -1423,6 +1424,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
+	if (adapter->closed == 1)
+		return;
+
 	iavf_dev_stop(dev);
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
@@ -1434,6 +1438,8 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     iavf_dev_interrupt_handler, dev);
 	iavf_disable_irq0(hw);
+
+	adapter->closed = 1;
 }
 
 static int
--

2.17.1

#9 lore raw

v2 cover These patches are bugs porting from i40evf to

In reply to SteveX Yang

v2:
removed patch (net/iavf: fix port close), because all resources will be released in dev_close when RTE_ETH_DEV_CLOSE_REMOVE is set.

SteveX Yang (6):
net/iavf: fix scattered Rx enabling net/iavf: set speed to undefined for default case net/iavf: fix port start during configuration restore net/iavf: fix setting of MAC address on iavf net/iavf: fix multiple interrupts for VF net/iavf: downgrade error log

 drivers/net/iavf/iavf_ethdev.c | 18 +++++++----
 drivers/net/iavf/iavf_vchnl.c  | 58 +++++++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.1
#10 lore raw

v2 cover These patches are bugs porting from i40evf to

In reply to SteveX Yang

v2:
removed patch (net/iavf: fix port close), because all resources will be released in dev_close when RTE_ETH_DEV_CLOSE_REMOVE is set.

SteveX Yang (6):
net/iavf: fix scattered Rx enabling net/iavf: set speed to undefined for default case net/iavf: fix port start during configuration restore net/iavf: fix setting of MAC address on iavf net/iavf: fix multiple interrupts for VF net/iavf: downgrade error log

 drivers/net/iavf/iavf_ethdev.c | 18 +++++++----
 drivers/net/iavf/iavf_vchnl.c  | 58 +++++++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.1
#11 lore raw

PATCH v2 1/6 net/iavf: fix scattered Rx enabling

No need to add additional vlan tag size for max packet size, since for i40e, the queue's Rx Max Frame Size (rxq->max_pkt_len) already includes the vlan header size.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_ethdev.c +1 -1
index c3aa4cd72..f9dd5710c 100644
@@ -253,7 +253,7 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct iavf_rx_queue *rxq)
 
 	rxq->max_pkt_len = max_pkt_len;
 	if ((dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SCATTER) ||
-	    (rxq->max_pkt_len + 2 * IAVF_VLAN_TAG_SIZE) > buf_size) {
+	    rxq->max_pkt_len > buf_size) {
 		dev_data->scattered_rx = 1;
 	}
 	IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
Signature · 1 line
2.17.1
#12 lore raw

Re: [dpdk-dev] [PATCH v2 1/6] net/iavf: fix scattered Rx enabling

Quoted 11 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Thursday, August 27, 2020 9:14 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v2 1/6] net/iavf: fix scattered Rx enabling

Quoted 1 line

No need to add additional vlan tag size for max packet size, since for i40e, the

Seems my comment in v1 patch is not addressed.

Quoted 27 lines

queue's Rx Max Frame Size (rxq->max_pkt_len) already includes the vlan header size.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_ethdev.c +0 -0
index c3aa4cd72..f9dd5710c 100644
@@ -253,7 +253,7 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct
 iavf_rx_queue *rxq)
 
 	rxq->max_pkt_len = max_pkt_len;
 	if ((dev_data->dev_conf.rxmode.offloads &

DEV_RX_OFFLOAD_SCATTER) ||

drivers/net/iavf/iavf_ethdev.c +1 -2
-	    (rxq->max_pkt_len + 2 * IAVF_VLAN_TAG_SIZE) > buf_size) {
+	    rxq->max_pkt_len > buf_size) {
 		dev_data->scattered_rx = 1;
 	}
 	IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
--

2.17.1

#13 lore raw

PATCH v2 2/6 net/iavf: set speed to undefined for default case

In reply to SteveX Yang

During PF/VF link update, a default speed value of 100M will be set if get_link_info has failed or speed is unknown.

Consequently if PF is put in no-carrier state, VFs will switch to "in carrier" state due to a link up + a link speed set to 100M (default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in same carrier state, sets default speed to undefined (instead of 100M) and updates a link status of VF only if link is up and speed is different from undefined.

Fixes 48de41ca11f0 ("net/avf: enable link status update")
---
 drivers/net/iavf/iavf_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ethdev.c +3 -2
index f9dd5710c..ae508f2f0 100644
@@ -620,8 +620,9 @@ iavf_dev_link_update(struct rte_eth_dev *dev,
 	}
 
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up &&
+				new_link.link_speed != ETH_SPEED_NUM_NONE)
+				? ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				ETH_LINK_SPEED_FIXED);
 
Signature · 1 line
2.17.1
#14 lore raw

Re: [dpdk-dev] [PATCH v2 2/6] net/iavf: set speed to undefined for default case

Quoted 14 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Thursday, August 27, 2020 9:14 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v2 2/6] net/iavf: set speed to undefined for default case

During PF/VF link update, a default speed value of 100M will be set if get_link_info has failed or speed is unknown.

Quoted 6 lines

Consequently if PF is put in no-carrier state, VFs will switch to "in carrier" state due to a link up + a link speed set to 100M (default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in same carrier state, sets default speed to undefined (instead of 100M) and updates a link status of VF only if link is up and speed is different from undefined.

The original fix is focus on i40e, the fix includes changes for both PF and VF. But this patch is only for iavf, so please pay attention:
1. rework the commit log, since the PF changes has been applied.
2. double check if the issue exists on ice.

Thanks,
Beilei

Quoted 27 lines
Fixes 48de41ca11f0 ("net/avf: enable link status update")
---
 drivers/net/iavf/iavf_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ethdev.c +3 -3
index f9dd5710c..ae508f2f0 100644
@@ -620,8 +620,9 @@ iavf_dev_link_update(struct rte_eth_dev *dev,
 	}
 
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up &&
+				new_link.link_speed !=
 ETH_SPEED_NUM_NONE)
+				? ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				ETH_LINK_SPEED_FIXED);
 
--

2.17.1

#15 lore raw

PATCH v2 3/6 net/iavf: fix port start during configuration restore

In reply to SteveX Yang

If configuring VF promiscuous mode is not supported, return -ENOTSUP error code in .promiscuous_enable/disable dev_ops. This is to fix the port start during configuration restore, where if .promiscuous_enable/disable dev_ops exists
and return any value other than -ENOTSUP, start will fail.

Same is done for .allmulticast_enable/disable dev_ops.

Fixes ca041cd44fcc ("ethdev: change allmulticast callbacks to return status")
Fixes 9039c8125730 ("ethdev: change promiscuous callbacks to return status")
---
 drivers/net/iavf/iavf_ethdev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/iavf/iavf_ethdev.c +8 -0
index ae508f2f0..349c82cae 100644
@@ -648,6 +648,8 @@ iavf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, true, vf->promisc_multicast_enabled);
 	if (!ret)
 		vf->promisc_unicast_enabled = true;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -669,6 +671,8 @@ iavf_dev_promiscuous_disable(struct rte_eth_dev *dev)
 				  vf->promisc_multicast_enabled);
 	if (!ret)
 		vf->promisc_unicast_enabled = false;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -689,6 +693,8 @@ iavf_dev_allmulticast_enable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, true);
 	if (!ret)
 		vf->promisc_multicast_enabled = true;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -709,6 +715,8 @@ iavf_dev_allmulticast_disable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, false);
 	if (!ret)
 		vf->promisc_multicast_enabled = false;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
Signature · 1 line
2.17.1
#16 lore raw

PATCH v2 4/6 net/iavf: fix setting of MAC address on iavf

In reply to SteveX Yang

When setting the MAC address, the ethdev layer copies the new mac address in dev->data->mac_addrs[0] before calling the dev_ops.

Therefore, is_same_ether_addr(mac_addr, dev->data->mac_addrs) was always true, and the MAC was never set. Remove this test to fix the issue.

Fixes 538da7a1cad2 ("net: add rte prefix to ether functions")
---
 drivers/net/iavf/iavf_ethdev.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/iavf/iavf_ethdev.c +0 -3
index 349c82cae..f16aff531 100644
@@ -978,9 +978,6 @@ iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev,
 	old_addr = (struct rte_ether_addr *)hw->mac.addr;
 	perm_addr = (struct rte_ether_addr *)hw->mac.perm_addr;
 
-	if (rte_is_same_ether_addr(mac_addr, old_addr))
-		return 0;
-
 	/* If the MAC address is configured by host, skip the setting */
 	if (rte_is_valid_assigned_ether_addr(perm_addr))
 		return -EPERM;
Signature · 1 line
2.17.1
#17 lore raw

PATCH v2 5/6 net/iavf: fix multiple interrupts for VF

In reply to SteveX Yang

Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt bind by code reconstruction.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_vchnl.c | 56 ++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_vchnl.c +45 -11
index 33acea54a..614ea7e79 100644
@@ -18,6 +18,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_dev.h>
+#include <rte_bus_pci.h>
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
@@ -686,20 +687,53 @@ int
 iavf_config_irq_map(struct iavf_adapter *adapter)
 {
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct iavf_cmd_info args;
+	uint8_t *cmd_buffer = NULL;
 	struct virtchnl_irq_map_info *map_info;
 	struct virtchnl_vector_map *vecmap;
-	struct iavf_cmd_info args;
-	int len, i, err;
+	struct rte_eth_dev *dev = adapter->eth_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 vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
+	uint16_t rxq_map[vf->vf_res->max_vectors];
+	int err;
 
-	len = sizeof(struct virtchnl_irq_map_info) +
-	      sizeof(struct virtchnl_vector_map) * vf->nb_msix;
+	memset(rxq_map, 0, sizeof(rxq_map));
+	if (dev->data->dev_conf.intr_conf.rxq &&
+		rte_intr_allow_others(intr_handle)) {
+		msix_base = IAVF_RX_VEC_START;
+		max_vectors = vf->vf_res->max_vectors - 1;
+		nb_msix = RTE_MIN(max_vectors, intr_handle->nb_efd);
+
+		vec = msix_base;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[vec] |= 1 << i;
+			intr_handle->intr_vec[i] = vec++;
+			if (vec >= vf->vf_res->max_vectors)
+				vec = msix_base;
+		}
+	} else {
+		msix_base = IAVF_MISC_VEC_ID;
+		nb_msix = 1;
 
-	map_info = rte_zmalloc("map_info", len, 0);
-	if (!map_info)
-		return -ENOMEM;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[msix_base] |= 1 << i;
+			if (rte_intr_dp_is_en(intr_handle))
+				intr_handle->intr_vec[i] = msix_base;
+		}
+	}
 
-	map_info->num_vectors = vf->nb_msix;
-	for (i = 0; i < vf->nb_msix; i++) {
+	cmd_buffer_size = sizeof(struct virtchnl_irq_map_info) +
+	      sizeof(struct virtchnl_vector_map) * nb_msix;
+	cmd_buffer = rte_zmalloc("iavf", cmd_buffer_size, 0);
+	if (!cmd_buffer) {
+		PMD_DRV_LOG(ERR, "Failed to allocate memory");
+		return IAVF_ERR_NO_MEMORY;
+	}
+
+	map_info = (struct virtchnl_irq_map_info *)cmd_buffer;
+	map_info->num_vectors = nb_msix;
+	for (i = 0; i < nb_msix; i++) {
 		vecmap = &map_info->vecmap[i];
 		vecmap->vsi_id = vf->vsi_res->vsi_id;
 		vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
@@ -709,8 +743,8 @@ iavf_config_irq_map(struct iavf_adapter *adapter)
 	}
 
 	args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
-	args.in_args = (u8 *)map_info;
-	args.in_args_size = len;
+	args.in_args = (u8 *)cmd_buffer;
+	args.in_args_size = cmd_buffer_size;
 	args.out_buffer = vf->aq_resp;
 	args.out_size = IAVF_AQ_BUF_SZ;
 	err = iavf_execute_vf_cmd(adapter, &args);
Signature · 1 line
2.17.1
#18 lore raw

PATCH v2 6/6 net/iavf: downgrade error log

In reply to SteveX Yang

When receiving the unsupported AQ messages, it's taken as an error. It's not appropriate and triggers too much unnecessary print.

Fixes 22b123a36d07 ("net/avf: initialize PMD")
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_vchnl.c +1 -1
index 614ea7e79..06eaae0e4 100644
@@ -266,7 +266,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 			}
 			break;
 		default:
-			PMD_DRV_LOG(ERR, "Request %u is not supported yet",
+			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
 				    aq_opc);
 			break;
 		}
Signature · 1 line
2.17.1
#19 lore raw

v3 cover Bugs Porting from I40evf For IAVF Feature

In reply to SteveX Yang

These patches are bugs porting from i40evf to iavf.

v3:
- changed the comment of patch (net/iavf: fix scattered Rx enabling).
- changed the comment of patch (net/iavf: fix incorrect link status when speed is undefined).

v2:
- removed patch (net/iavf: fix port close), because all resources will be released in dev_close when RTE_ETH_DEV_CLOSE_REMOVE is set.

SteveX Yang (6):
net/iavf: fix scattered Rx enabling
net/iavf: fix incorrect link status when speed is undefined net/iavf: fix port start during configuration restore net/iavf: fix setting of MAC address on iavf net/iavf: fix multiple interrupts for VF net/iavf: downgrade error log

 drivers/net/iavf/iavf_ethdev.c | 18 +++++++----
 drivers/net/iavf/iavf_vchnl.c  | 58 +++++++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.1
#20 lore raw

PATCH v3 1/6 net/iavf: fix scattered Rx enabling

No need to add additional vlan tag size for max packet size, the queue's Rx Max Frame Size (rxq->max_pkt_len) already includes the vlan header size in iavf.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_ethdev.c +1 -1
index c3aa4cd72..f9dd5710c 100644
@@ -253,7 +253,7 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct iavf_rx_queue *rxq)
 
 	rxq->max_pkt_len = max_pkt_len;
 	if ((dev_data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SCATTER) ||
-	    (rxq->max_pkt_len + 2 * IAVF_VLAN_TAG_SIZE) > buf_size) {
+	    rxq->max_pkt_len > buf_size) {
 		dev_data->scattered_rx = 1;
 	}
 	IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
Signature · 1 line
2.17.1
#21 lore raw

PATCH v3 2/6 net/iavf: fix incorrect link status when speed is undefined

In reply to SteveX Yang

When PF is put in no-carrier state, iavf VFs will switch to "in carrier" state due to a link up + a link speed set to 0 (default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in same carrier state, updates a link status of VF only if link is up and speed is different from undefined.

Fixes 48de41ca11f0 ("net/avf: enable link status update")
---
 drivers/net/iavf/iavf_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ethdev.c +3 -2
index f9dd5710c..ae508f2f0 100644
@@ -620,8 +620,9 @@ iavf_dev_link_update(struct rte_eth_dev *dev,
 	}
 
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up &&
+				new_link.link_speed != ETH_SPEED_NUM_NONE)
+				? ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				ETH_LINK_SPEED_FIXED);
 
Signature · 1 line
2.17.1
#22 lore raw

Re: [dpdk-dev] [PATCH v3 2/6] net/iavf: fix incorrect link status when speed is undefined

Quoted 22 lines · SteveX Yang

When PF is put in no-carrier state, iavf VFs will switch to "in carrier" state due to a link up + a link speed set to 0 (default value if no speed detected).

To be consistent with linux drivers on which PF and VFs are in same carrier state, updates a link status of VF only if link is up and speed is different from undefined.

Fixes 48de41ca11f0 ("net/avf: enable link status update")
---
 drivers/net/iavf/iavf_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/iavf/iavf_ethdev.c +0 -0
index f9dd5710c..ae508f2f0 100644
@@ -620,8 +620,9 @@ iavf_dev_link_update(struct rte_eth_dev *dev,
 	}

drivers/net/iavf/iavf_ethdev.c iavf_dev_link_update(struct rte_eth_dev *dev, · line 628

Quoted 10 lines
drivers/net/iavf/iavf_ethdev.c +3 -2
 
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up &&
+				new_link.link_speed != ETH_SPEED_NUM_NONE)
+				? ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				ETH_LINK_SPEED_FIXED);
 

Hi Steve,

There is a new 'ETH_SPEED_NUM_UNKNOWN' macro, and can you please check how it is used for 'i40e' [1], can same done here?

[1]
https://git.dpdk.org/next/dpdk-next-net/commit/?id=bd1868e46d1b

#23 lore raw

PATCH v3 3/6 net/iavf: fix port start during configuration restore

In reply to SteveX Yang

If configuring VF promiscuous mode is not supported, return -ENOTSUP error code in .promiscuous_enable/disable dev_ops. This is to fix the port start during configuration restore, where if .promiscuous_enable/disable dev_ops exists
and return any value other than -ENOTSUP, start will fail.

Same is done for .allmulticast_enable/disable dev_ops.

Fixes ca041cd44fcc ("ethdev: change allmulticast callbacks to return status")
Fixes 9039c8125730 ("ethdev: change promiscuous callbacks to return status")
---
 drivers/net/iavf/iavf_ethdev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/iavf/iavf_ethdev.c +8 -0
index ae508f2f0..349c82cae 100644
@@ -648,6 +648,8 @@ iavf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, true, vf->promisc_multicast_enabled);
 	if (!ret)
 		vf->promisc_unicast_enabled = true;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -669,6 +671,8 @@ iavf_dev_promiscuous_disable(struct rte_eth_dev *dev)
 				  vf->promisc_multicast_enabled);
 	if (!ret)
 		vf->promisc_unicast_enabled = false;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -689,6 +693,8 @@ iavf_dev_allmulticast_enable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, true);
 	if (!ret)
 		vf->promisc_multicast_enabled = true;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
@@ -709,6 +715,8 @@ iavf_dev_allmulticast_disable(struct rte_eth_dev *dev)
 	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, false);
 	if (!ret)
 		vf->promisc_multicast_enabled = false;
+	else if (ret == IAVF_NOT_SUPPORTED)
+		ret = -ENOTSUP;
 	else
 		ret = -EAGAIN;
 
Signature · 1 line
2.17.1
#24 lore raw

PATCH v3 4/6 net/iavf: fix setting of MAC address on iavf

In reply to SteveX Yang

When setting the MAC address, the ethdev layer copies the new mac address in dev->data->mac_addrs[0] before calling the dev_ops.

Therefore, is_same_ether_addr(mac_addr, dev->data->mac_addrs) was always true, and the MAC was never set. Remove this test to fix the issue.

Fixes 538da7a1cad2 ("net: add rte prefix to ether functions")
---
 drivers/net/iavf/iavf_ethdev.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/net/iavf/iavf_ethdev.c +0 -3
index 349c82cae..f16aff531 100644
@@ -978,9 +978,6 @@ iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev,
 	old_addr = (struct rte_ether_addr *)hw->mac.addr;
 	perm_addr = (struct rte_ether_addr *)hw->mac.perm_addr;
 
-	if (rte_is_same_ether_addr(mac_addr, old_addr))
-		return 0;
-
 	/* If the MAC address is configured by host, skip the setting */
 	if (rte_is_valid_assigned_ether_addr(perm_addr))
 		return -EPERM;
Signature · 1 line
2.17.1
#25 lore raw

PATCH v3 5/6 net/iavf: fix multiple interrupts for VF

In reply to SteveX Yang

Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt bind by code reconstruction.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_vchnl.c | 56 ++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_vchnl.c +45 -11
index 33acea54a..614ea7e79 100644
@@ -18,6 +18,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_dev.h>
+#include <rte_bus_pci.h>
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
@@ -686,20 +687,53 @@ int
 iavf_config_irq_map(struct iavf_adapter *adapter)
 {
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct iavf_cmd_info args;
+	uint8_t *cmd_buffer = NULL;
 	struct virtchnl_irq_map_info *map_info;
 	struct virtchnl_vector_map *vecmap;
-	struct iavf_cmd_info args;
-	int len, i, err;
+	struct rte_eth_dev *dev = adapter->eth_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 vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
+	uint16_t rxq_map[vf->vf_res->max_vectors];
+	int err;
 
-	len = sizeof(struct virtchnl_irq_map_info) +
-	      sizeof(struct virtchnl_vector_map) * vf->nb_msix;
+	memset(rxq_map, 0, sizeof(rxq_map));
+	if (dev->data->dev_conf.intr_conf.rxq &&
+		rte_intr_allow_others(intr_handle)) {
+		msix_base = IAVF_RX_VEC_START;
+		max_vectors = vf->vf_res->max_vectors - 1;
+		nb_msix = RTE_MIN(max_vectors, intr_handle->nb_efd);
+
+		vec = msix_base;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[vec] |= 1 << i;
+			intr_handle->intr_vec[i] = vec++;
+			if (vec >= vf->vf_res->max_vectors)
+				vec = msix_base;
+		}
+	} else {
+		msix_base = IAVF_MISC_VEC_ID;
+		nb_msix = 1;
 
-	map_info = rte_zmalloc("map_info", len, 0);
-	if (!map_info)
-		return -ENOMEM;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[msix_base] |= 1 << i;
+			if (rte_intr_dp_is_en(intr_handle))
+				intr_handle->intr_vec[i] = msix_base;
+		}
+	}
 
-	map_info->num_vectors = vf->nb_msix;
-	for (i = 0; i < vf->nb_msix; i++) {
+	cmd_buffer_size = sizeof(struct virtchnl_irq_map_info) +
+	      sizeof(struct virtchnl_vector_map) * nb_msix;
+	cmd_buffer = rte_zmalloc("iavf", cmd_buffer_size, 0);
+	if (!cmd_buffer) {
+		PMD_DRV_LOG(ERR, "Failed to allocate memory");
+		return IAVF_ERR_NO_MEMORY;
+	}
+
+	map_info = (struct virtchnl_irq_map_info *)cmd_buffer;
+	map_info->num_vectors = nb_msix;
+	for (i = 0; i < nb_msix; i++) {
 		vecmap = &map_info->vecmap[i];
 		vecmap->vsi_id = vf->vsi_res->vsi_id;
 		vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
@@ -709,8 +743,8 @@ iavf_config_irq_map(struct iavf_adapter *adapter)
 	}
 
 	args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
-	args.in_args = (u8 *)map_info;
-	args.in_args_size = len;
+	args.in_args = (u8 *)cmd_buffer;
+	args.in_args_size = cmd_buffer_size;
 	args.out_buffer = vf->aq_resp;
 	args.out_size = IAVF_AQ_BUF_SZ;
 	err = iavf_execute_vf_cmd(adapter, &args);
Signature · 1 line
2.17.1
#26 lore raw

Re: [dpdk-dev] [PATCH v3 5/6] net/iavf: fix multiple interrupts for VF

Hi, Steve,

I am also coding on this part for large VF recently, and see that you sent a fix patch, and I have some questions not quite clear, which are shown below in inline.

Thanks!

Best Regards,
Xu Ting

Quoted 67 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of SteveX Yang
Sent: Friday, September 4, 2020 3:29 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 5/6] net/iavf: fix multiple interrupts for VF

Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt bind by code reconstruction.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_vchnl.c | 56 ++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 11 deletions(-)
drivers/net/iavf/iavf_vchnl.c index renamed from drivers/net/iavf/iavf_vchnl.c +0 -0

33acea54a..614ea7e79 100644

drivers/net/iavf/iavf_vchnl.c +26 -4
@@ -18,6 +18,7 @@
 #include <rte_ether.h>
 #include <rte_ethdev_driver.h>
 #include <rte_dev.h>
+#include <rte_bus_pci.h>
 
 #include "iavf.h"
 #include "iavf_rxtx.h"
@@ -686,20 +687,53 @@ int
 iavf_config_irq_map(struct iavf_adapter *adapter)  {
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct iavf_cmd_info args;
+	uint8_t *cmd_buffer = NULL;
 	struct virtchnl_irq_map_info *map_info;
 	struct virtchnl_vector_map *vecmap;
-	struct iavf_cmd_info args;
-	int len, i, err;
+	struct rte_eth_dev *dev = adapter->eth_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 vec, cmd_buffer_size, max_vectors, nb_msix, msix_base, i;
+	uint16_t rxq_map[vf->vf_res->max_vectors];
+	int err;
 
-	len = sizeof(struct virtchnl_irq_map_info) +
-	      sizeof(struct virtchnl_vector_map) * vf->nb_msix;
+	memset(rxq_map, 0, sizeof(rxq_map));
+	if (dev->data->dev_conf.intr_conf.rxq &&
+		rte_intr_allow_others(intr_handle)) {
+		msix_base = IAVF_RX_VEC_START;
+		max_vectors = vf->vf_res->max_vectors - 1;
+		nb_msix = RTE_MIN(max_vectors, intr_handle->nb_efd);
+
+		vec = msix_base;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[vec] |= 1 << i;
+			intr_handle->intr_vec[i] = vec++;
+			if (vec >= vf->vf_res->max_vectors)
+				vec = msix_base;
+		}
+	} else {
+		msix_base = IAVF_MISC_VEC_ID;
+		nb_msix = 1;
 

drivers/net/iavf/iavf_vchnl.c int · line 724

Quoted 10 lines
drivers/net/iavf/iavf_vchnl.c +6 -3
-	map_info = rte_zmalloc("map_info", len, 0);
-	if (!map_info)
-		return -ENOMEM;
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq_map[msix_base] |= 1 << i;
+			if (rte_intr_dp_is_en(intr_handle))
+				intr_handle->intr_vec[i] = msix_base;
+		}
+	}
 

This part to configure parameters like nb_msix, msix_base and rxq_map, is already done in the upper level function iavf_config_rx_queues_irqs, why shall we do it again here? Or is it OK to change in that function directly if necessary?

Quoted 6 lines
drivers/net/iavf/iavf_vchnl.c +4 -2
-	map_info->num_vectors = vf->nb_msix;
-	for (i = 0; i < vf->nb_msix; i++) {
+	cmd_buffer_size = sizeof(struct virtchnl_irq_map_info) +
+	      sizeof(struct virtchnl_vector_map) * nb_msix;
+	cmd_buffer = rte_zmalloc("iavf", cmd_buffer_size, 0);
+	if (!cmd_buffer) {

drivers/net/iavf/iavf_vchnl.c int

Quoted 10 lines
drivers/net/iavf/iavf_vchnl.c +7 -0
+		PMD_DRV_LOG(ERR, "Failed to allocate memory");
+		return IAVF_ERR_NO_MEMORY;
+	}
+
+	map_info = (struct virtchnl_irq_map_info *)cmd_buffer;
+	map_info->num_vectors = nb_msix;
+	for (i = 0; i < nb_msix; i++) {
 		vecmap = &map_info->vecmap[i];
 		vecmap->vsi_id = vf->vsi_res->vsi_id;
 		vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT; @@ -709,8

Here is a line of code "vecmap->rxq_map = vf->rxq_map[vf->msix_base + i];" not displayed. I noticed that this is not changed. That means we still use the bitmap configured in iavf_config_rx_queues_irqs, not the new one here (although they may be the same) But it seems that the new rxq_map is not used. Do I miss something? Thank!

Quoted 13 lines
drivers/net/iavf/iavf_vchnl.c +3 -3
+743,8 @@ iavf_config_irq_map(struct iavf_adapter *adapter)
 	}
 
 	args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
-	args.in_args = (u8 *)map_info;
-	args.in_args_size = len;
+	args.in_args = (u8 *)cmd_buffer;
+	args.in_args_size = cmd_buffer_size;
 	args.out_buffer = vf->aq_resp;
 	args.out_size = IAVF_AQ_BUF_SZ;
 	err = iavf_execute_vf_cmd(adapter, &args);
--

2.17.1

#27 lore raw

Re: [dpdk-dev] [PATCH v3 5/6] net/iavf: fix multiple interrupts for VF

In reply to SteveX Yang
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of SteveX Yang
Sent: Friday, September 4, 2020 3:29 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 5/6] net/iavf: fix multiple interrupts for VF

Quoted 6 lines

Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt bind by code reconstruction.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")

The patch has been reverted from dpdk-next-net-intel, since it's not necessary.

#28 lore raw

Re: [dpdk-dev] [PATCH v3 5/6] net/iavf: fix multiple interrupts for VF

Quoted 11 lines · Qi Z
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of SteveX Yang
Sent: Friday, September 4, 2020 3:29 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [dpdk-dev] [PATCH v3 5/6] net/iavf: fix multiple interrupts for VF

Quoted 9 lines
Quoted 6 lines

Interrupt mapping should be 1:n queue(s).This patch fixes the logic of interrupt bind by code reconstruction.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")

The patch has been reverted from dpdk-next-net-intel, since it's not necessary.

Dropped from next-net, patchwork status updated as rejected.

#29 lore raw

PATCH v3 6/6 net/iavf: downgrade error log

In reply to SteveX Yang

When receiving the unsupported AQ messages, it's taken as an error. It's not appropriate and triggers too much unnecessary print.

Fixes 22b123a36d07 ("net/avf: initialize PMD")
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_vchnl.c +1 -1
index 614ea7e79..06eaae0e4 100644
@@ -266,7 +266,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 			}
 			break;
 		default:
-			PMD_DRV_LOG(ERR, "Request %u is not supported yet",
+			PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
 				    aq_opc);
 			break;
 		}
Signature · 1 line
2.17.1
Acked-by on the v3 series
#30 lore raw
In reply to SteveX Yang
Quoted 30 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Friday, September 4, 2020 3:29 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v3 0/6] Bugs Porting from I40evf For IAVF Feature

These patches are bugs porting from i40evf to iavf.

v3:
- changed the comment of patch (net/iavf: fix scattered Rx enabling).
- changed the comment of patch (net/iavf: fix incorrect link status when speed is undefined).

v2:
- removed patch (net/iavf: fix port close), because all resources will be released in dev_close when RTE_ETH_DEV_CLOSE_REMOVE is set.

SteveX Yang (6):
net/iavf: fix scattered Rx enabling
net/iavf: fix incorrect link status when speed is undefined net/iavf: fix port start during configuration restore net/iavf: fix setting of MAC address on iavf net/iavf: fix multiple interrupts for VF net/iavf: downgrade error log

Quoted 6 lines

drivers/net/iavf/iavf_ethdev.c | 18 +++++++---- drivers/net/iavf/iavf_vchnl.c
| 58 +++++++++++++++++++++++++++-------

 2 files changed, 58 insertions(+), 18 deletions(-)

--
2.17.1

Applied
#31 lore raw
Quoted 47 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Xing, Beilei
Sent: Friday, September 4, 2020 4:18 PM
To: Yang, SteveX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/6] Bugs Porting from I40evf For IAVF Feature

Quoted 11 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Friday, September 4, 2020 3:29 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v3 0/6] Bugs Porting from I40evf For IAVF Feature

These patches are bugs porting from i40evf to iavf.

Quoted 8 lines

v3:
- changed the comment of patch (net/iavf: fix scattered Rx enabling).
- changed the comment of patch (net/iavf: fix incorrect link status when speed is undefined).

v2:
- removed patch (net/iavf: fix port close), because all resources will be released in dev_close when RTE_ETH_DEV_CLOSE_REMOVE is

set.

Quoted 14 lines

SteveX Yang (6):
net/iavf: fix scattered Rx enabling
net/iavf: fix incorrect link status when speed is undefined net/iavf: fix port start during configuration restore net/iavf: fix setting of MAC address on iavf net/iavf: fix multiple interrupts for VF net/iavf: downgrade error log

 drivers/net/iavf/iavf_ethdev.c | 18 +++++++----
drivers/net/iavf/iavf_vchnl.c
| 58 +++++++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 18 deletions(-)
Quoted 4 lines
Quoted 2 lines

--
2.17.1

Applied to dpdk-next-net-intel.

Thanks
Qi

#32 lore raw
Quoted 47 lines · Qi Z
Quoted 47 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Xing, Beilei
Sent: Friday, September 4, 2020 4:18 PM
To: Yang, SteveX <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 0/6] Bugs Porting from I40evf For IAVF Feature

Quoted 11 lines

-----Original Message-----
From: Yang, SteveX <[email protected]>
Sent: Friday, September 4, 2020 3:29 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: [PATCH v3 0/6] Bugs Porting from I40evf For IAVF Feature

These patches are bugs porting from i40evf to iavf.

Quoted 8 lines

v3:
- changed the comment of patch (net/iavf: fix scattered Rx enabling).
- changed the comment of patch (net/iavf: fix incorrect link status when speed is undefined).

v2:
- removed patch (net/iavf: fix port close), because all resources will be released in dev_close when RTE_ETH_DEV_CLOSE_REMOVE is

set.

Quoted 14 lines

SteveX Yang (6):
net/iavf: fix scattered Rx enabling
net/iavf: fix incorrect link status when speed is undefined net/iavf: fix port start during configuration restore net/iavf: fix setting of MAC address on iavf net/iavf: fix multiple interrupts for VF net/iavf: downgrade error log

 drivers/net/iavf/iavf_ethdev.c | 18 +++++++----
drivers/net/iavf/iavf_vchnl.c
| 58 +++++++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 18 deletions(-)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

--
2.17.1

Applied to dpdk-next-net-intel.

Pulled except 2/6 since it is independent and it can be done differently after 'ETH_SPEED_NUM_UNKNOWN' merged.