Skip to contentSkip to conversation

net/ice: refactor DCF VLAN handling

PATCH Superseded Haiyue Wang 2 participants 3 messages Jan 18, 2021 – Jan 19, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: refactor DCF VLAN handling

Since DCF always configure the outer VLAN offloads for the target AVF, so rename the related variables to align with this design.

Also, the DCF needs to trace the AVF reset status to re-apply the VLAN offload setting, refactor the reset event handling to support this.

Change the VF representor API 'ethdev' parameter to 'vf_rep_eth_dev' to avoid introducing confusion with VF representor eth_dev ops name.

---
 drivers/net/ice/ice_dcf_ethdev.c         |  47 ++++-
 drivers/net/ice/ice_dcf_ethdev.h         |  23 ++-
 drivers/net/ice/ice_dcf_parent.c         |  62 +++++--
 drivers/net/ice/ice_dcf_vf_representor.c | 218 +++++++++++++++++++----
 4 files changed, 298 insertions(+), 52 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +46 -1
index a9e78064d..f9025d189 100644
@@ -601,6 +601,9 @@ ice_dcf_dev_stop(struct rte_eth_dev *dev)
 		return 0;
 	}
 
+	/* Stop the VF representors for this device */
+	ice_dcf_vf_repr_stop_all(dcf_ad);
+
 	ice_dcf_stop_queues(dev);
 
 	rte_intr_efd_disable(intr_handle);
@@ -849,6 +852,30 @@ ice_dcf_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void
+ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter)
+{
+	if (dcf_adapter->repr_infos) {
+		rte_free(dcf_adapter->repr_infos);
+		dcf_adapter->repr_infos = NULL;
+	}
+}
+
+static int
+ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter)
+{
+	dcf_adapter->repr_infos =
+			rte_calloc("ice_dcf_rep_info",
+				   dcf_adapter->real_hw.num_vfs,
+				   sizeof(dcf_adapter->repr_infos[0]), 0);
+	if (!dcf_adapter->repr_infos) {
+		PMD_DRV_LOG(ERR, "Failed to alloc memory for VF representors\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int
 ice_dcf_dev_close(struct rte_eth_dev *dev)
 {
@@ -857,6 +884,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 
@@ -1000,21 +1028,26 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
 		return -ENODEV;
 
 	dcf_adapter = dcf_ethdev->data->dev_private;
+	ret = ice_dcf_init_repr_info(dcf_adapter);
+	if (ret)
+		return ret;
 
 	if (eth_da.nb_representor_ports > dcf_adapter->real_hw.num_vfs ||
 	    eth_da.nb_representor_ports >= RTE_MAX_ETHPORTS) {
 		PMD_DRV_LOG(ERR, "the number of port representors is too large: %u",
 			    eth_da.nb_representor_ports);
+		ice_dcf_free_repr_info(dcf_adapter);
 		return -EINVAL;
 	}
 
 	dcf_vsi_id = dcf_adapter->real_hw.vsi_id | VIRTCHNL_DCF_VF_VSI_VALID;
 
-	repr_param.adapter = dcf_adapter;
+	repr_param.dcf_eth_dev = dcf_ethdev;
 	repr_param.switch_domain_id = 0;
 
 	for (i = 0; i < eth_da.nb_representor_ports; i++) {
 		uint16_t vf_id = eth_da.representor_ports[i];
+		struct rte_eth_dev *vf_rep_eth_dev;
 
 		if (vf_id >= dcf_adapter->real_hw.num_vfs) {
 			PMD_DRV_LOG(ERR, "VF ID %u is out of range (0 ~ %u)",
@@ -1041,6 +1074,18 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
 				    repr_name);
 			break;
 		}
+
+		vf_rep_eth_dev = rte_eth_dev_allocated(repr_name);
+		if (!vf_rep_eth_dev) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to find the ethdev for DCF VF representor: %s",
+				    repr_name);
+			ret = -ENODEV;
+			break;
+		}
+
+		dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev = vf_rep_eth_dev;
+		dcf_adapter->num_reprs++;
 	}
 
 	return ret;
drivers/net/ice/ice_dcf_ethdev.h +17 -6
index 7695815e1..e7c9d7fe4 100644
@@ -17,30 +17,39 @@ struct ice_dcf_queue {
 	uint64_t dummy;
 };
 
+struct ice_dcf_repr_info {
+	struct rte_eth_dev *vf_rep_eth_dev;
+};
+
 struct ice_dcf_adapter {
 	struct ice_adapter parent; /* Must be first */
 	struct ice_dcf_hw real_hw;
+
+	int num_reprs;
+	struct ice_dcf_repr_info *repr_infos;
 };
 
 struct ice_dcf_vf_repr_param {
-	struct ice_dcf_adapter *adapter;
+	struct rte_eth_dev *dcf_eth_dev;
 	uint16_t switch_domain_id;
 	uint16_t vf_id;
 };
 
 struct ice_dcf_vlan {
+	bool port_vlan_ena;
+	bool stripping_ena;
+
 	uint16_t tpid;
 	uint16_t vid;
 };
 
 struct ice_dcf_vf_repr {
-	struct ice_dcf_adapter *dcf_adapter;
+	struct rte_eth_dev *dcf_eth_dev;
 	struct rte_ether_addr mac_addr;
 	uint16_t switch_domain_id;
 	uint16_t vf_id;
 
-	bool port_vlan_ena;
-	struct ice_dcf_vlan port_vlan_info;
+	struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
 
 void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
@@ -48,7 +57,9 @@ void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
 int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
 void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
 
-int ice_dcf_vf_repr_init(struct rte_eth_dev *ethdev, void *init_param);
-int ice_dcf_vf_repr_uninit(struct rte_eth_dev *ethdev);
+int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param);
+int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
+int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
+void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c +52 -10

105 lines not on this page · raw message

drivers/net/ice/ice_dcf_vf_representor.c +183 -35

308 lines not on this page · raw message

Signature · 1 line
2.30.0
#1 lore raw

PATCH v2 1/1 net/ice: refactor DCF VLAN handling

Since DCF always configure the outer VLAN offloads for the target AVF, so rename the related variables to align with this design.

Also, the DCF needs to trace the AVF reset status to re-apply the VLAN offload setting, refactor the reset event handling to support this.

Change the VF representor API 'ethdev' parameter to 'vf_rep_eth_dev' to avoid introducing confusion with VF representor eth_dev ops name.

---
v2: change the reset log from ERR to DEBUG level

---
 drivers/net/ice/ice_dcf_ethdev.c         |  47 ++++-
 drivers/net/ice/ice_dcf_ethdev.h         |  23 ++-
 drivers/net/ice/ice_dcf_parent.c         |  62 +++++--
 drivers/net/ice/ice_dcf_vf_representor.c | 218 +++++++++++++++++++----
 4 files changed, 298 insertions(+), 52 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +46 -1
index a9e78064d..f9025d189 100644
@@ -601,6 +601,9 @@ ice_dcf_dev_stop(struct rte_eth_dev *dev)
 		return 0;
 	}
 
+	/* Stop the VF representors for this device */
+	ice_dcf_vf_repr_stop_all(dcf_ad);
+
 	ice_dcf_stop_queues(dev);
 
 	rte_intr_efd_disable(intr_handle);
@@ -849,6 +852,30 @@ ice_dcf_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static void
+ice_dcf_free_repr_info(struct ice_dcf_adapter *dcf_adapter)
+{
+	if (dcf_adapter->repr_infos) {
+		rte_free(dcf_adapter->repr_infos);
+		dcf_adapter->repr_infos = NULL;
+	}
+}
+
+static int
+ice_dcf_init_repr_info(struct ice_dcf_adapter *dcf_adapter)
+{
+	dcf_adapter->repr_infos =
+			rte_calloc("ice_dcf_rep_info",
+				   dcf_adapter->real_hw.num_vfs,
+				   sizeof(dcf_adapter->repr_infos[0]), 0);
+	if (!dcf_adapter->repr_infos) {
+		PMD_DRV_LOG(ERR, "Failed to alloc memory for VF representors\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int
 ice_dcf_dev_close(struct rte_eth_dev *dev)
 {
@@ -857,6 +884,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 
@@ -1000,21 +1028,26 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
 		return -ENODEV;
 
 	dcf_adapter = dcf_ethdev->data->dev_private;
+	ret = ice_dcf_init_repr_info(dcf_adapter);
+	if (ret)
+		return ret;
 
 	if (eth_da.nb_representor_ports > dcf_adapter->real_hw.num_vfs ||
 	    eth_da.nb_representor_ports >= RTE_MAX_ETHPORTS) {
 		PMD_DRV_LOG(ERR, "the number of port representors is too large: %u",
 			    eth_da.nb_representor_ports);
+		ice_dcf_free_repr_info(dcf_adapter);
 		return -EINVAL;
 	}
 
 	dcf_vsi_id = dcf_adapter->real_hw.vsi_id | VIRTCHNL_DCF_VF_VSI_VALID;
 
-	repr_param.adapter = dcf_adapter;
+	repr_param.dcf_eth_dev = dcf_ethdev;
 	repr_param.switch_domain_id = 0;
 
 	for (i = 0; i < eth_da.nb_representor_ports; i++) {
 		uint16_t vf_id = eth_da.representor_ports[i];
+		struct rte_eth_dev *vf_rep_eth_dev;
 
 		if (vf_id >= dcf_adapter->real_hw.num_vfs) {
 			PMD_DRV_LOG(ERR, "VF ID %u is out of range (0 ~ %u)",
@@ -1041,6 +1074,18 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
 				    repr_name);
 			break;
 		}
+
+		vf_rep_eth_dev = rte_eth_dev_allocated(repr_name);
+		if (!vf_rep_eth_dev) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to find the ethdev for DCF VF representor: %s",
+				    repr_name);
+			ret = -ENODEV;
+			break;
+		}
+
+		dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev = vf_rep_eth_dev;
+		dcf_adapter->num_reprs++;
 	}
 
 	return ret;
drivers/net/ice/ice_dcf_ethdev.h +17 -6
index 7695815e1..e7c9d7fe4 100644
@@ -17,30 +17,39 @@ struct ice_dcf_queue {
 	uint64_t dummy;
 };
 
+struct ice_dcf_repr_info {
+	struct rte_eth_dev *vf_rep_eth_dev;
+};
+
 struct ice_dcf_adapter {
 	struct ice_adapter parent; /* Must be first */
 	struct ice_dcf_hw real_hw;
+
+	int num_reprs;
+	struct ice_dcf_repr_info *repr_infos;
 };
 
 struct ice_dcf_vf_repr_param {
-	struct ice_dcf_adapter *adapter;
+	struct rte_eth_dev *dcf_eth_dev;
 	uint16_t switch_domain_id;
 	uint16_t vf_id;
 };
 
 struct ice_dcf_vlan {
+	bool port_vlan_ena;
+	bool stripping_ena;
+
 	uint16_t tpid;
 	uint16_t vid;
 };
 
 struct ice_dcf_vf_repr {
-	struct ice_dcf_adapter *dcf_adapter;
+	struct rte_eth_dev *dcf_eth_dev;
 	struct rte_ether_addr mac_addr;
 	uint16_t switch_domain_id;
 	uint16_t vf_id;
 
-	bool port_vlan_ena;
-	struct ice_dcf_vlan port_vlan_info;
+	struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */
 };
 
 void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
@@ -48,7 +57,9 @@ void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
 int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
 void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
 
-int ice_dcf_vf_repr_init(struct rte_eth_dev *ethdev, void *init_param);
-int ice_dcf_vf_repr_uninit(struct rte_eth_dev *ethdev);
+int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param);
+int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
+int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
+void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c +52 -10

105 lines not on this page · raw message

drivers/net/ice/ice_dcf_vf_representor.c +183 -35

308 lines not on this page · raw message

Signature · 1 line
2.30.0
Acked-by on v2 1/1 Applied
#2 lore raw
Quoted 13 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Monday, January 18, 2021 7:38 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Fu, Qi <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [PATCH v2] net/ice: refactor DCF VLAN handling

Since DCF always configure the outer VLAN offloads for the target AVF, so rename the related variables to align with this design.

Quoted 7 lines

Also, the DCF needs to trace the AVF reset status to re-apply the VLAN offload setting, refactor the reset event handling to support this.

Change the VF representor API 'ethdev' parameter to 'vf_rep_eth_dev' to avoid introducing confusion with VF representor eth_dev ops name.

Applied to dpdk-next-net-intel.

Thanks
Qi