Skip to contentSkip to conversation

enable DCF datapath configuration

PATCH Superseded Ting Xu 2 participants 18 messages Jun 16, 2020 – Jun 19, 2020 Network drivers

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ting Xu

author
#0 lore raw

v3 cover enable DCF datapath configuration

This patchset adds support to configure DCF datapath, including Rx/Tx queues setup, start and stop, device configuration, RSS and flexible descriptor RXDID initialization and MAC filter setup.

Qi Zhang (11):
net/ice: init RSS and supported RXDID in DCF net/ice: complete device info get in DCF net/ice: complete dev configure in DCF net/ice: complete queue setup in DCF net/ice: add stop flag for device start / stop net/ice: add Rx queue init in DCF net/ice: init RSS during DCF start net/ice: add queue config in DCF net/ice: add queue start and stop for DCF net/ice: enable stats for DCF
net/ice: set MAC filter during dev start for DCF

Ting Xu (1):
doc: enable DCF datapath configuration

 doc/guides/rel_notes/release_20_08.rst |   6 +
 drivers/net/ice/ice_dcf.c              | 408 ++++++++++++-
 drivers/net/ice/ice_dcf.h              |  17 +
 drivers/net/ice/ice_dcf_ethdev.c       | 771 +++++++++++++++++++++++--
 drivers/net/ice/ice_dcf_ethdev.h       |   3 -
 drivers/net/ice/ice_dcf_parent.c       |   8 +
 6 files changed, 1160 insertions(+), 53 deletions(-)

---
v2->v3:
Correct coding style issue

v1->v2:
Optimize coding style
Correct some return values
Add support to stop started queues when queue start failed

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 1/12 net/ice: init RSS and supported RXDID in DCF

From: Qi Zhang <[email protected]>

Enable RSS parameters initialization and get the supported flexible descriptor RXDIDs bitmap from PF during DCF init.

---
 drivers/net/ice/ice_dcf.c | 54 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/ice/ice_dcf.h |  3 +++
 2 files changed, 56 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +53 -1
index 0cd5d1bf6..93fabd5f7 100644
@@ -233,7 +233,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 
 	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
 	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
-	       VF_BASE_MODE_OFFLOADS;
+	       VF_BASE_MODE_OFFLOADS | VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC;
 
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
 					  (uint8_t *)&caps, sizeof(caps));
@@ -547,6 +547,30 @@ ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
 	return err;
 }
 
+static int
+ice_dcf_get_supported_rxdid(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw,
+					  VIRTCHNL_OP_GET_SUPPORTED_RXDIDS,
+					  NULL, 0);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Failed to send OP_GET_SUPPORTED_RXDIDS");
+		return -1;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_GET_SUPPORTED_RXDIDS,
+					  (uint8_t *)&hw->supported_rxdid,
+					  sizeof(uint64_t), NULL);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Failed to get response of OP_GET_SUPPORTED_RXDIDS");
+		return -1;
+	}
+
+	return 0;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
@@ -620,6 +644,29 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 		goto err_alloc;
 	}
 
+	/* Allocate memory for RSS info */
+	if (hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
+		hw->rss_key = rte_zmalloc(NULL,
+					  hw->vf_res->rss_key_size, 0);
+		if (!hw->rss_key) {
+			PMD_INIT_LOG(ERR, "unable to allocate rss_key memory");
+			goto err_alloc;
+		}
+		hw->rss_lut = rte_zmalloc("rss_lut",
+					  hw->vf_res->rss_lut_size, 0);
+		if (!hw->rss_lut) {
+			PMD_INIT_LOG(ERR, "unable to allocate rss_lut memory");
+			goto err_rss;
+		}
+	}
+
+	if (hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
+		if (ice_dcf_get_supported_rxdid(hw) != 0) {
+			PMD_INIT_LOG(ERR, "failed to do get supported rxdid");
+			goto err_rss;
+		}
+	}
+
 	hw->eth_dev = eth_dev;
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   ice_dcf_dev_interrupt_handler, hw);
@@ -628,6 +675,9 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 
 	return 0;
 
+err_rss:
+	rte_free(hw->rss_key);
+	rte_free(hw->rss_lut);
 err_alloc:
 	rte_free(hw->vf_res);
 err_api:
@@ -655,4 +705,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_free(hw->arq_buf);
 	rte_free(hw->vf_vsi_map);
 	rte_free(hw->vf_res);
+	rte_free(hw->rss_lut);
+	rte_free(hw->rss_key);
 }
drivers/net/ice/ice_dcf.h +3 -0
index d2e447b48..152266e3c 100644
@@ -50,6 +50,9 @@ struct ice_dcf_hw {
 	uint16_t vsi_id;
 
 	struct rte_eth_dev *eth_dev;
+	uint8_t *rss_lut;
+	uint8_t *rss_key;
+	uint64_t supported_rxdid;
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v3 2/12 net/ice: complete device info get in DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Add support to get complete device information for DCF, including Rx/Tx offload capabilities and default configuration.

---
 drivers/net/ice/ice_dcf_ethdev.c | 72 ++++++++++++++++++++++++++++++--
 1 file changed, 69 insertions(+), 3 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +69 -3
index e5ba1a61f..7f24ef81a 100644
@@ -24,6 +24,7 @@
 
 #include "ice_generic_flow.h"
 #include "ice_dcf_ethdev.h"
+#include "ice_rxtx.h"
 
 static uint16_t
 ice_dcf_recv_pkts(__rte_unused void *rx_queue,
@@ -66,11 +67,76 @@ ice_dcf_dev_info_get(struct rte_eth_dev *dev,
 		     struct rte_eth_dev_info *dev_info)
 {
 	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &adapter->real_hw;
 
 	dev_info->max_mac_addrs = 1;
-	dev_info->max_rx_pktlen = (uint32_t)-1;
-	dev_info->max_rx_queues = RTE_DIM(adapter->rxqs);
-	dev_info->max_tx_queues = RTE_DIM(adapter->txqs);
+	dev_info->max_rx_queues = hw->vsi_res->num_queue_pairs;
+	dev_info->max_tx_queues = hw->vsi_res->num_queue_pairs;
+	dev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN;
+	dev_info->max_rx_pktlen = ICE_FRAME_SIZE_MAX;
+	dev_info->hash_key_size = hw->vf_res->rss_key_size;
+	dev_info->reta_size = hw->vf_res->rss_lut_size;
+	dev_info->flow_type_rss_offloads = ICE_RSS_OFFLOAD_ALL;
+
+	dev_info->rx_offload_capa =
+		DEV_RX_OFFLOAD_VLAN_STRIP |
+		DEV_RX_OFFLOAD_QINQ_STRIP |
+		DEV_RX_OFFLOAD_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_UDP_CKSUM |
+		DEV_RX_OFFLOAD_TCP_CKSUM |
+		DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_SCATTER |
+		DEV_RX_OFFLOAD_JUMBO_FRAME |
+		DEV_RX_OFFLOAD_VLAN_FILTER |
+		DEV_RX_OFFLOAD_RSS_HASH;
+	dev_info->tx_offload_capa =
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_QINQ_INSERT |
+		DEV_TX_OFFLOAD_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_TCP_TSO |
+		DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
+		DEV_TX_OFFLOAD_GRE_TNL_TSO |
+		DEV_TX_OFFLOAD_IPIP_TNL_TSO |
+		DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+		DEV_TX_OFFLOAD_MULTI_SEGS;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_thresh = {
+			.pthresh = ICE_DEFAULT_RX_PTHRESH,
+			.hthresh = ICE_DEFAULT_RX_HTHRESH,
+			.wthresh = ICE_DEFAULT_RX_WTHRESH,
+		},
+		.rx_free_thresh = ICE_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_thresh = {
+			.pthresh = ICE_DEFAULT_TX_PTHRESH,
+			.hthresh = ICE_DEFAULT_TX_HTHRESH,
+			.wthresh = ICE_DEFAULT_TX_WTHRESH,
+		},
+		.tx_free_thresh = ICE_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = ICE_DEFAULT_TX_RSBIT_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = ICE_MAX_RING_DESC,
+		.nb_min = ICE_MIN_RING_DESC,
+		.nb_align = ICE_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = ICE_MAX_RING_DESC,
+		.nb_min = ICE_MIN_RING_DESC,
+		.nb_align = ICE_ALIGN_RING_DESC,
+	};
 
 	return 0;
 }
Signature · 1 line
2.17.1
#3 lore raw

Re: [dpdk-dev] [PATCH v3 02/12] net/ice: complete device info get in DCF

Quoted 48 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Tuesday, June 16, 2020 20:41
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Kovacevic, Marko <[email protected]>; Mcnamara, John <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v3 02/12] net/ice: complete device info get in DCF

From: Qi Zhang <[email protected]>

Add support to get complete device information for DCF, including Rx/Tx offload capabilities and default configuration.

---
 drivers/net/ice/ice_dcf_ethdev.c | 72
++++++++++++++++++++++++++++++--
 1 file changed, 69 insertions(+), 3 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +1 -0
index e5ba1a61f..7f24ef81a 100644
@@ -24,6 +24,7 @@
 
 #include "ice_generic_flow.h"
 #include "ice_dcf_ethdev.h"
+#include "ice_rxtx.h"
 
 static uint16_t
 ice_dcf_recv_pkts(__rte_unused void *rx_queue, @@ -66,11 +67,76 @@

ice_dcf_dev_info_get(struct rte_eth_dev *dev,

drivers/net/ice/ice_dcf_ethdev.c +2 -3
 		     struct rte_eth_dev_info *dev_info)  {
 	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &adapter->real_hw;
 
 	dev_info->max_mac_addrs = 1;
-	dev_info->max_rx_pktlen = (uint32_t)-1;
-	dev_info->max_rx_queues = RTE_DIM(adapter->rxqs);
-	dev_info->max_tx_queues = RTE_DIM(adapter->txqs);
+	dev_info->max_rx_queues = hw->vsi_res->num_queue_pairs;

drivers/net/ice/ice_dcf_ethdev.c ice_dcf_dev_info_get(struct rte_eth_dev *dev, · line 83

Quoted 10 lines
drivers/net/ice/ice_dcf_ethdev.c +10 -0
+	dev_info->max_tx_queues = hw->vsi_res->num_queue_pairs;
+	dev_info->min_rx_bufsize = ICE_BUF_SIZE_MIN;
+	dev_info->max_rx_pktlen = ICE_FRAME_SIZE_MAX;
+	dev_info->hash_key_size = hw->vf_res->rss_key_size;
+	dev_info->reta_size = hw->vf_res->rss_lut_size;
+	dev_info->flow_type_rss_offloads = ICE_RSS_OFFLOAD_ALL;
+
+	dev_info->rx_offload_capa =
+		DEV_RX_OFFLOAD_VLAN_STRIP |
+		DEV_RX_OFFLOAD_QINQ_STRIP |

Do we support QINQ in DCF now?

drivers/net/ice/ice_dcf_ethdev.c ice_dcf_dev_info_get(struct rte_eth_dev *dev, · line 94

Quoted 11 lines
drivers/net/ice/ice_dcf_ethdev.c +11 -0
+		DEV_RX_OFFLOAD_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_UDP_CKSUM |
+		DEV_RX_OFFLOAD_TCP_CKSUM |
+		DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_SCATTER |
+		DEV_RX_OFFLOAD_JUMBO_FRAME |
+		DEV_RX_OFFLOAD_VLAN_FILTER |
+		DEV_RX_OFFLOAD_RSS_HASH;
+	dev_info->tx_offload_capa =
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_QINQ_INSERT |

Same as above

Quoted 50 lines
drivers/net/ice/ice_dcf_ethdev.c +45 -1
+		DEV_TX_OFFLOAD_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_UDP_CKSUM |
+		DEV_TX_OFFLOAD_TCP_CKSUM |
+		DEV_TX_OFFLOAD_SCTP_CKSUM |
+		DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+		DEV_TX_OFFLOAD_TCP_TSO |
+		DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
+		DEV_TX_OFFLOAD_GRE_TNL_TSO |
+		DEV_TX_OFFLOAD_IPIP_TNL_TSO |
+		DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+		DEV_TX_OFFLOAD_MULTI_SEGS;
+
+	dev_info->default_rxconf = (struct rte_eth_rxconf) {
+		.rx_thresh = {
+			.pthresh = ICE_DEFAULT_RX_PTHRESH,
+			.hthresh = ICE_DEFAULT_RX_HTHRESH,
+			.wthresh = ICE_DEFAULT_RX_WTHRESH,
+		},
+		.rx_free_thresh = ICE_DEFAULT_RX_FREE_THRESH,
+		.rx_drop_en = 0,
+		.offloads = 0,
+	};
+
+	dev_info->default_txconf = (struct rte_eth_txconf) {
+		.tx_thresh = {
+			.pthresh = ICE_DEFAULT_TX_PTHRESH,
+			.hthresh = ICE_DEFAULT_TX_HTHRESH,
+			.wthresh = ICE_DEFAULT_TX_WTHRESH,
+		},
+		.tx_free_thresh = ICE_DEFAULT_TX_FREE_THRESH,
+		.tx_rs_thresh = ICE_DEFAULT_TX_RSBIT_THRESH,
+		.offloads = 0,
+	};
+
+	dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = ICE_MAX_RING_DESC,
+		.nb_min = ICE_MIN_RING_DESC,
+		.nb_align = ICE_ALIGN_RING_DESC,
+	};
+
+	dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
+		.nb_max = ICE_MAX_RING_DESC,
+		.nb_min = ICE_MIN_RING_DESC,
+		.nb_align = ICE_ALIGN_RING_DESC,
+	};
 
 	return 0;
 }
--

2.17.1

author
#4 lore raw

PATCH v3 3/12 net/ice: complete dev configure in DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Enable device configuration function in DCF.

---
 drivers/net/ice/ice_dcf_ethdev.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf_ethdev.c +10 -1
index 7f24ef81a..41d130cd9 100644
@@ -57,8 +57,17 @@ ice_dcf_dev_stop(struct rte_eth_dev *dev)
 }
 
 static int
-ice_dcf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+ice_dcf_dev_configure(struct rte_eth_dev *dev)
 {
+	struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
+	struct ice_adapter *ad = &dcf_ad->parent;
+
+	ad->rx_bulk_alloc_allowed = true;
+	ad->tx_simple_allowed = true;
+
+	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
 	return 0;
 }
 
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v3 4/12 net/ice: complete queue setup in DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Delete original DCF queue setup functions and use ice queue setup and release functions instead.

---
 drivers/net/ice/ice_dcf_ethdev.c | 42 +++-----------------------------
 drivers/net/ice/ice_dcf_ethdev.h |  3 ---
 drivers/net/ice/ice_dcf_parent.c |  7 ++++++
 3 files changed, 11 insertions(+), 41 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +4 -38
index 41d130cd9..0c3013228 100644
@@ -231,11 +231,6 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 }
 
-static void
-ice_dcf_queue_release(__rte_unused void *q)
-{
-}
-
 static int
 ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev,
 		    __rte_unused int wait_to_complete)
@@ -243,45 +238,16 @@ ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev,
 	return 0;
 }
 
-static int
-ice_dcf_rx_queue_setup(struct rte_eth_dev *dev,
-		       uint16_t rx_queue_id,
-		       __rte_unused uint16_t nb_rx_desc,
-		       __rte_unused unsigned int socket_id,
-		       __rte_unused const struct rte_eth_rxconf *rx_conf,
-		       __rte_unused struct rte_mempool *mb_pool)
-{
-	struct ice_dcf_adapter *adapter = dev->data->dev_private;
-
-	dev->data->rx_queues[rx_queue_id] = &adapter->rxqs[rx_queue_id];
-
-	return 0;
-}
-
-static int
-ice_dcf_tx_queue_setup(struct rte_eth_dev *dev,
-		       uint16_t tx_queue_id,
-		       __rte_unused uint16_t nb_tx_desc,
-		       __rte_unused unsigned int socket_id,
-		       __rte_unused const struct rte_eth_txconf *tx_conf)
-{
-	struct ice_dcf_adapter *adapter = dev->data->dev_private;
-
-	dev->data->tx_queues[tx_queue_id] = &adapter->txqs[tx_queue_id];
-
-	return 0;
-}
-
 static const struct eth_dev_ops ice_dcf_eth_dev_ops = {
 	.dev_start               = ice_dcf_dev_start,
 	.dev_stop                = ice_dcf_dev_stop,
 	.dev_close               = ice_dcf_dev_close,
 	.dev_configure           = ice_dcf_dev_configure,
 	.dev_infos_get           = ice_dcf_dev_info_get,
-	.rx_queue_setup          = ice_dcf_rx_queue_setup,
-	.tx_queue_setup          = ice_dcf_tx_queue_setup,
-	.rx_queue_release        = ice_dcf_queue_release,
-	.tx_queue_release        = ice_dcf_queue_release,
+	.rx_queue_setup          = ice_rx_queue_setup,
+	.tx_queue_setup          = ice_tx_queue_setup,
+	.rx_queue_release        = ice_rx_queue_release,
+	.tx_queue_release        = ice_tx_queue_release,
 	.link_update             = ice_dcf_link_update,
 	.stats_get               = ice_dcf_stats_get,
 	.stats_reset             = ice_dcf_stats_reset,
drivers/net/ice/ice_dcf_ethdev.h +0 -3
index e60e808d8..b54528bea 100644
@@ -19,10 +19,7 @@ struct ice_dcf_queue {
 
 struct ice_dcf_adapter {
 	struct ice_adapter parent; /* Must be first */
-
 	struct ice_dcf_hw real_hw;
-	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
-	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
 };
 
 void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
drivers/net/ice/ice_dcf_parent.c +7 -0
index d13e19d78..322a5273f 100644
@@ -335,6 +335,13 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
 	parent_adapter->eth_dev = eth_dev;
 	parent_adapter->pf.adapter = parent_adapter;
 	parent_adapter->pf.dev_data = eth_dev->data;
+	/* create a dummy main_vsi */
+	parent_adapter->pf.main_vsi =
+		rte_zmalloc(NULL, sizeof(struct ice_vsi), 0);
+	if (!parent_adapter->pf.main_vsi)
+		return -ENOMEM;
+	parent_adapter->pf.main_vsi->adapter = parent_adapter;
+
 	parent_hw->back = parent_adapter;
 	parent_hw->mac_type = ICE_MAC_GENERIC;
 	parent_hw->vendor_id = ICE_INTEL_VENDOR_ID;
Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v3 5/12 net/ice: add stop flag for device start / stop

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Add stop flag for DCF device start and stop.

---
 drivers/net/ice/ice_dcf_ethdev.c | 12 ++++++++++++
 drivers/net/ice/ice_dcf_parent.c |  1 +
 2 files changed, 13 insertions(+)
drivers/net/ice/ice_dcf_ethdev.c +12 -0
index 0c3013228..ff2cab054 100644
@@ -45,6 +45,11 @@ ice_dcf_xmit_pkts(__rte_unused void *tx_queue,
 static int
 ice_dcf_dev_start(struct rte_eth_dev *dev)
 {
+	struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
+	struct ice_adapter *ad = &dcf_ad->parent;
+
+	ad->pf.adapter_stopped = 0;
+
 	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
@@ -53,7 +58,14 @@ ice_dcf_dev_start(struct rte_eth_dev *dev)
 static void
 ice_dcf_dev_stop(struct rte_eth_dev *dev)
 {
+	struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
+	struct ice_adapter *ad = &dcf_ad->parent;
+
+	if (ad->pf.adapter_stopped == 1)
+		return;
+
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	ad->pf.adapter_stopped = 1;
 }
 
 static int
drivers/net/ice/ice_dcf_parent.c +1 -0
index 322a5273f..c5dfdd36e 100644
@@ -341,6 +341,7 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
 	if (!parent_adapter->pf.main_vsi)
 		return -ENOMEM;
 	parent_adapter->pf.main_vsi->adapter = parent_adapter;
+	parent_adapter->pf.adapter_stopped = 1;
 
 	parent_hw->back = parent_adapter;
 	parent_hw->mac_type = ICE_MAC_GENERIC;
Signature · 1 line
2.17.1
#7 lore raw

Re: [dpdk-dev] [PATCH v3 05/12] net/ice: add stop flag for device start / stop

Quoted 40 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Tuesday, June 16, 2020 20:41
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Kovacevic, Marko <[email protected]>; Mcnamara, John <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v3 05/12] net/ice: add stop flag for device start / stop

From: Qi Zhang <[email protected]>

Add stop flag for DCF device start and stop.

---
 drivers/net/ice/ice_dcf_ethdev.c | 12 ++++++++++++
drivers/net/ice/ice_dcf_parent.c |  1 +
 2 files changed, 13 insertions(+)
drivers/net/ice/ice_dcf_ethdev.c +5 -0
index 0c3013228..ff2cab054 100644
@@ -45,6 +45,11 @@ ice_dcf_xmit_pkts(__rte_unused void *tx_queue,
 static int  ice_dcf_dev_start(struct rte_eth_dev *dev)  {
+	struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
+	struct ice_adapter *ad = &dcf_ad->parent;
+
+	ad->pf.adapter_stopped = 0;
+
 	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;

drivers/net/ice/ice_dcf_ethdev.c ice_dcf_dev_start(struct rte_eth_dev *dev) static · line 62

Quoted 5 lines
drivers/net/ice/ice_dcf_ethdev.c +4 -0
@@ -53,7 +58,14 @@ ice_dcf_dev_start(struct rte_eth_dev *dev)  static
 void  ice_dcf_dev_stop(struct rte_eth_dev *dev)  {
+	struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
+	struct ice_adapter *ad = &dcf_ad->parent;
+
+	if (ad->pf.adapter_stopped == 1)

We can add logs like 'port already stopped'

Quoted 23 lines
drivers/net/ice/ice_dcf_ethdev.c +3 -0
+		return;
+
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	ad->pf.adapter_stopped = 1;
 }
 
 static int
drivers/net/ice/ice_dcf_parent.c +1 -0
index 322a5273f..c5dfdd36e 100644
@@ -341,6 +341,7 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev
 *eth_dev)
 	if (!parent_adapter->pf.main_vsi)
 		return -ENOMEM;
 	parent_adapter->pf.main_vsi->adapter = parent_adapter;
+	parent_adapter->pf.adapter_stopped = 1;
 
 	parent_hw->back = parent_adapter;

parent_hw->mac_type = ICE_MAC_GENERIC;
--
2.17.1

author
#8 lore raw

PATCH v3 6/12 net/ice: add Rx queue init in DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Enable Rx queues initialization during device start in DCF.

---
 drivers/net/ice/ice_dcf.h        |  1 +
 drivers/net/ice/ice_dcf_ethdev.c | 83 ++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+)
drivers/net/ice/ice_dcf.h +1 -0
index 152266e3c..dcb2a0283 100644
@@ -53,6 +53,7 @@ struct ice_dcf_hw {
 	uint8_t *rss_lut;
 	uint8_t *rss_key;
 	uint64_t supported_rxdid;
+	uint16_t num_queue_pairs;
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
drivers/net/ice/ice_dcf_ethdev.c +83 -0

97 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v3 7/12 net/ice: init RSS during DCF start

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Enable RSS initialization during DCF start. Add RSS LUT and RSS key configuration functions.

---
 drivers/net/ice/ice_dcf.c        | 117 +++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h        |   1 +
 drivers/net/ice/ice_dcf_ethdev.c |   8 +++
 3 files changed, 126 insertions(+)
drivers/net/ice/ice_dcf.c +117 -0
index 93fabd5f7..f285323dd 100644
@@ -708,3 +708,120 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_free(hw->rss_lut);
 	rte_free(hw->rss_key);
 }
+
+static int
+ice_dcf_configure_rss_key(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_rss_key *rss_key;
+	struct dcf_virtchnl_cmd args;
+	int len, err;
+
+	len = sizeof(*rss_key) + hw->vf_res->rss_key_size - 1;
+	rss_key = rte_zmalloc("rss_key", len, 0);
+	if (!rss_key)
+		return -ENOMEM;
+
+	rss_key->vsi_id = hw->vsi_res->vsi_id;
+	rss_key->key_len = hw->vf_res->rss_key_size;
+	rte_memcpy(rss_key->key, hw->rss_key, hw->vf_res->rss_key_size);
+
+	args.v_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
+	args.req_msglen = len;
+	args.req_msg = (uint8_t *)rss_key;
+	args.rsp_msglen = 0;
+	args.rsp_buflen = 0;
+	args.rsp_msgbuf = NULL;
+	args.pending = 0;
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_INIT_LOG(ERR, "Failed to execute OP_CONFIG_RSS_KEY");
+
+	rte_free(rss_key);
+	return err;
+}
+
+static int
+ice_dcf_configure_rss_lut(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_rss_lut *rss_lut;
+	struct dcf_virtchnl_cmd args;
+	int len, err;
+
+	len = sizeof(*rss_lut) + hw->vf_res->rss_lut_size - 1;
+	rss_lut = rte_zmalloc("rss_lut", len, 0);
+	if (!rss_lut)
+		return -ENOMEM;
+
+	rss_lut->vsi_id = hw->vsi_res->vsi_id;
+	rss_lut->lut_entries = hw->vf_res->rss_lut_size;
+	rte_memcpy(rss_lut->lut, hw->rss_lut, hw->vf_res->rss_lut_size);
+
+	args.v_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
+	args.req_msglen = len;
+	args.req_msg = (uint8_t *)rss_lut;
+	args.rsp_msglen = 0;
+	args.rsp_buflen = 0;
+	args.rsp_msgbuf = NULL;
+	args.pending = 0;
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_INIT_LOG(ERR, "Failed to execute OP_CONFIG_RSS_LUT");
+
+	rte_free(rss_lut);
+	return err;
+}
+
+int
+ice_dcf_init_rss(struct ice_dcf_hw *hw)
+{
+	struct rte_eth_dev *dev = hw->eth_dev;
+	struct rte_eth_rss_conf *rss_conf;
+	uint8_t i, j, nb_q;
+	int ret;
+
+	rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
+	nb_q = dev->data->nb_rx_queues;
+
+	if (!(hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF)) {
+		PMD_DRV_LOG(DEBUG, "RSS is not supported");
+		return -ENOTSUP;
+	}
+	if (dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) {
+		PMD_DRV_LOG(WARNING, "RSS is enabled by PF by default");
+		/* set all lut items to default queue */
+		memset(hw->rss_lut, 0, hw->vf_res->rss_lut_size);
+		return ice_dcf_configure_rss_lut(hw);
+	}
+
+	/* In IAVF, RSS enablement is set by PF driver. It is not supported
+	 * to set based on rss_conf->rss_hf.
+	 */
+
+	/* configure RSS key */
+	if (!rss_conf->rss_key)
+		/* Calculate the default hash key */
+		for (i = 0; i < hw->vf_res->rss_key_size; i++)
+			hw->rss_key[i] = (uint8_t)rte_rand();
+	else
+		rte_memcpy(hw->rss_key, rss_conf->rss_key,
+			   RTE_MIN(rss_conf->rss_key_len,
+				   hw->vf_res->rss_key_size));
+
+	/* init RSS LUT table */
+	for (i = 0, j = 0; i < hw->vf_res->rss_lut_size; i++, j++) {
+		if (j >= nb_q)
+			j = 0;
+		hw->rss_lut[i] = j;
+	}
+	/* send virtchnnl ops to configure rss*/
+	ret = ice_dcf_configure_rss_lut(hw);
+	if (ret)
+		return ret;
+	ret = ice_dcf_configure_rss_key(hw);
+	if (ret)
+		return ret;
+
+	return 0;
+}
drivers/net/ice/ice_dcf.h +1 -0
index dcb2a0283..eea4b286b 100644
@@ -63,5 +63,6 @@ int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
+int ice_dcf_init_rss(struct ice_dcf_hw *hw);
 
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +8 -0
index 6d0f93ca7..e021d779a 100644
@@ -133,6 +133,14 @@ ice_dcf_dev_start(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	if (hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
+		ret = ice_dcf_init_rss(hw);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "Failed to configure RSS");
+			return ret;
+		}
+	}
+
 	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
Signature · 1 line
2.17.1
author
#10 lore raw

PATCH v3 8/12 net/ice: add queue config in DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Add queues and Rx queue irqs configuration during device start in DCF. The setup is sent to PF via virtchnl.

---
 drivers/net/ice/ice_dcf.c        | 111 +++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h        |   6 ++
 drivers/net/ice/ice_dcf_ethdev.c | 126 +++++++++++++++++++++++++++++++
 3 files changed, 243 insertions(+)
drivers/net/ice/ice_dcf.c +111 -0
index f285323dd..8869e0d1c 100644
@@ -24,6 +24,7 @@
 #include <rte_dev.h>
 
 #include "ice_dcf.h"
+#include "ice_rxtx.h"
 
 #define ICE_DCF_AQ_LEN     32
 #define ICE_DCF_AQ_BUF_SZ  4096
@@ -825,3 +826,113 @@ ice_dcf_init_rss(struct ice_dcf_hw *hw)
 
 	return 0;
 }
+
+#define IAVF_RXDID_LEGACY_1 1
+#define IAVF_RXDID_COMMS_GENERIC 16
+
+int
+ice_dcf_configure_queues(struct ice_dcf_hw *hw)
+{
+	struct ice_rx_queue **rxq =
+		(struct ice_rx_queue **)hw->eth_dev->data->rx_queues;
+	struct ice_tx_queue **txq =
+		(struct ice_tx_queue **)hw->eth_dev->data->tx_queues;
+	struct virtchnl_vsi_queue_config_info *vc_config;
+	struct virtchnl_queue_pair_info *vc_qp;
+	struct dcf_virtchnl_cmd args;
+	uint16_t i, size;
+	int err;
+
+	size = sizeof(*vc_config) +
+	       sizeof(vc_config->qpair[0]) * hw->num_queue_pairs;
+	vc_config = rte_zmalloc("cfg_queue", size, 0);
+	if (!vc_config)
+		return -ENOMEM;
+
+	vc_config->vsi_id = hw->vsi_res->vsi_id;
+	vc_config->num_queue_pairs = hw->num_queue_pairs;
+
+	for (i = 0, vc_qp = vc_config->qpair;
+	     i < hw->num_queue_pairs;
+	     i++, vc_qp++) {
+		vc_qp->txq.vsi_id = hw->vsi_res->vsi_id;
+		vc_qp->txq.queue_id = i;
+		if (i < hw->eth_dev->data->nb_tx_queues) {
+			vc_qp->txq.ring_len = txq[i]->nb_tx_desc;
+			vc_qp->txq.dma_ring_addr = txq[i]->tx_ring_dma;
+		}
+		vc_qp->rxq.vsi_id = hw->vsi_res->vsi_id;
+		vc_qp->rxq.queue_id = i;
+		vc_qp->rxq.max_pkt_size = rxq[i]->max_pkt_len;
+
+		if (i >= hw->eth_dev->data->nb_rx_queues)
+			continue;
+
+		vc_qp->rxq.ring_len = rxq[i]->nb_rx_desc;
+		vc_qp->rxq.dma_ring_addr = rxq[i]->rx_ring_dma;
+		vc_qp->rxq.databuffer_size = rxq[i]->rx_buf_len;
+
+		if (hw->vf_res->vf_cap_flags &
+		    VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC &&
+		    hw->supported_rxdid &
+		    BIT(IAVF_RXDID_COMMS_GENERIC)) {
+			vc_qp->rxq.rxdid = IAVF_RXDID_COMMS_GENERIC;
+			PMD_DRV_LOG(NOTICE, "request RXDID == %d in "
+				    "Queue[%d]", vc_qp->rxq.rxdid, i);
+		} else {
+			PMD_DRV_LOG(ERR, "RXDID 16 is not supported");
+			return -EINVAL;
+		}
+	}
+
+	memset(&args, 0, sizeof(args));
+	args.v_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
+	args.req_msg = (uint8_t *)vc_config;
+	args.req_msglen = size;
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_DRV_LOG(ERR, "Failed to execute command of"
+			    " VIRTCHNL_OP_CONFIG_VSI_QUEUES");
+
+	rte_free(vc_config);
+	return err;
+}
+
+int
+ice_dcf_config_irq_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_irq_map_info *map_info;
+	struct virtchnl_vector_map *vecmap;
+	struct dcf_virtchnl_cmd args;
+	int len, i, err;
+
+	len = sizeof(struct virtchnl_irq_map_info) +
+	      sizeof(struct virtchnl_vector_map) * hw->nb_msix;
+
+	map_info = rte_zmalloc("map_info", len, 0);
+	if (!map_info)
+		return -ENOMEM;
+
+	map_info->num_vectors = hw->nb_msix;
+	for (i = 0; i < hw->nb_msix; i++) {
+		vecmap = &map_info->vecmap[i];
+		vecmap->vsi_id = hw->vsi_res->vsi_id;
+		vecmap->rxitr_idx = 0;
+		vecmap->vector_id = hw->msix_base + i;
+		vecmap->txq_map = 0;
+		vecmap->rxq_map = hw->rxq_map[hw->msix_base + i];
+	}
+
+	memset(&args, 0, sizeof(args));
+	args.v_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
+	args.req_msg = (u8 *)map_info;
+	args.req_msglen = len;
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP");
+
+	rte_free(map_info);
+	return err;
+}
drivers/net/ice/ice_dcf.h +6 -0
index eea4b286b..9470d1df7 100644
@@ -54,6 +54,10 @@ struct ice_dcf_hw {
 	uint8_t *rss_key;
 	uint64_t supported_rxdid;
 	uint16_t num_queue_pairs;
+
+	uint16_t msix_base;
+	uint16_t nb_msix;
+	uint16_t rxq_map[16];
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
@@ -64,5 +68,7 @@ int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 int ice_dcf_init_rss(struct ice_dcf_hw *hw);
+int ice_dcf_configure_queues(struct ice_dcf_hw *hw);
+int ice_dcf_config_irq_map(struct ice_dcf_hw *hw);
 
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +126 -0

142 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#11 lore raw

PATCH v3 9/12 net/ice: add queue start and stop for DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Add queue start and stop in DCF. Support queue enable and disable through virtual channel. Add support for Rx queue mbufs allocation and queue reset.

---
 drivers/net/ice/ice_dcf.c        |  57 ++++++
 drivers/net/ice/ice_dcf.h        |   3 +-
 drivers/net/ice/ice_dcf_ethdev.c | 320 +++++++++++++++++++++++++++++++
 3 files changed, 379 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +57 -0
index 8869e0d1c..f18c0f16a 100644
@@ -936,3 +936,60 @@ ice_dcf_config_irq_map(struct ice_dcf_hw *hw)
 	rte_free(map_info);
 	return err;
 }
+
+int
+ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on)
+{
+	struct virtchnl_queue_select queue_select;
+	struct dcf_virtchnl_cmd args;
+	int err;
+
+	memset(&queue_select, 0, sizeof(queue_select));
+	queue_select.vsi_id = hw->vsi_res->vsi_id;
+	if (rx)
+		queue_select.rx_queues |= 1 << qid;
+	else
+		queue_select.tx_queues |= 1 << qid;
+
+	memset(&args, 0, sizeof(args));
+	if (on)
+		args.v_op = VIRTCHNL_OP_ENABLE_QUEUES;
+	else
+		args.v_op = VIRTCHNL_OP_DISABLE_QUEUES;
+
+	args.req_msg = (u8 *)&queue_select;
+	args.req_msglen = sizeof(queue_select);
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_DRV_LOG(ERR, "Failed to execute command of %s",
+			    on ? "OP_ENABLE_QUEUES" : "OP_DISABLE_QUEUES");
+
+	return err;
+}
+
+int
+ice_dcf_disable_queues(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_queue_select queue_select;
+	struct dcf_virtchnl_cmd args;
+	int err;
+
+	memset(&queue_select, 0, sizeof(queue_select));
+	queue_select.vsi_id = hw->vsi_res->vsi_id;
+
+	queue_select.rx_queues = BIT(hw->eth_dev->data->nb_rx_queues) - 1;
+	queue_select.tx_queues = BIT(hw->eth_dev->data->nb_tx_queues) - 1;
+
+	memset(&args, 0, sizeof(args));
+	args.v_op = VIRTCHNL_OP_DISABLE_QUEUES;
+	args.req_msg = (u8 *)&queue_select;
+	args.req_msglen = sizeof(queue_select);
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of OP_DISABLE_QUEUES");
+
+	return err;
+}
drivers/net/ice/ice_dcf.h +2 -1
index 9470d1df7..68e1661c0 100644
@@ -70,5 +70,6 @@ void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 int ice_dcf_init_rss(struct ice_dcf_hw *hw);
 int ice_dcf_configure_queues(struct ice_dcf_hw *hw);
 int ice_dcf_config_irq_map(struct ice_dcf_hw *hw);
-
+int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on);
+int ice_dcf_disable_queues(struct ice_dcf_hw *hw);
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +320 -0

352 lines not on this page · raw message

Signature · 1 line
2.17.1
#12 lore raw

Re: [dpdk-dev] [PATCH v3 09/12] net/ice: add queue start and stop for DCF

Quoted 37 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Tuesday, June 16, 2020 20:41
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Kovacevic, Marko <[email protected]>; Mcnamara, John <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v3 09/12] net/ice: add queue start and stop for DCF

From: Qi Zhang <[email protected]>

Add queue start and stop in DCF. Support queue enable and disable through virtual channel. Add support for Rx queue mbufs allocation and queue reset.

---
 drivers/net/ice/ice_dcf.c        |  57 ++++++
 drivers/net/ice/ice_dcf.h        |   3 +-
 drivers/net/ice/ice_dcf_ethdev.c | 320
+++++++++++++++++++++++++++++++
 3 files changed, 379 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c index renamed from drivers/net/ice/ice_dcf.c +0 -0

8869e0d1c..f18c0f16a 100644

drivers/net/ice/ice_dcf.c +1 -0
@@ -936,3 +936,60 @@ ice_dcf_config_irq_map(struct ice_dcf_hw *hw)
 	rte_free(map_info);
 	return err;
 }
+

[snip]

Quoted 25 lines
drivers/net/ice/ice_dcf.c +25 -0
+
+static int
+ice_dcf_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) {
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct iavf_hw *hw = &ad->real_hw.avf;
+	struct ice_rx_queue *rxq;
+	int err = 0;
+
+	if (rx_queue_id >= dev->data->nb_rx_queues)
+		return -EINVAL;
+
+	rxq = dev->data->rx_queues[rx_queue_id];
+
+	err = alloc_rxq_mbufs(rxq);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
+		return err;
+	}
+
+	rte_wmb();
+
+	/* Init the RX tail register. */
+	IAVF_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
+	IAVF_WRITE_FLUSH(hw);
+

drivers/net/ice/ice_dcf.c

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+	/* Ready to switch the queue on */
+	err = ice_dcf_switch_queue(&ad->real_hw, rx_queue_id, true, true);
+	if (err)
+		PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
+			    rx_queue_id);
+	else
+		dev->data->rx_queue_state[rx_queue_id] =
+			RTE_ETH_QUEUE_STATE_STARTED;
+
+	return err;

The 'else' is no need in this function. Follow the clean code rule this part should be

If (err)

	PMD_DRV_LOG()
	Return err;

.....

Return 0;

Quoted 282 lines
drivers/net/ice/ice_dcf.c +19 -0
+}
+
+static inline void
+reset_rx_queue(struct ice_rx_queue *rxq) {
+	uint16_t len;
+	uint32_t i;
+
+	if (!rxq)
+		return;
+
+	len = rxq->nb_rx_desc + ICE_RX_MAX_BURST;
+
+	for (i = 0; i < len * sizeof(union ice_rx_flex_desc); i++)
+		((volatile char *)rxq->rx_ring)[i] = 0;
+
+	memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
+
+	for (i = 0; i < ICE_RX_MAX_BURST; i++)
+		rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq-
Quoted 1 line

fake_mbuf;

drivers/net/ice/ice_dcf.c +32 -0
+
+	/* for rx bulk */
+	rxq->rx_nb_avail = 0;
+	rxq->rx_next_avail = 0;
+	rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
+
+	rxq->rx_tail = 0;
+	rxq->nb_rx_hold = 0;
+	rxq->pkt_first_seg = NULL;
+	rxq->pkt_last_seg = NULL;
+}
+
+static inline void
+reset_tx_queue(struct ice_tx_queue *txq) {
+	struct ice_tx_entry *txe;
+	uint32_t i, size;
+	uint16_t prev;
+
+	if (!txq) {
+		PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
+		return;
+	}
+
+	txe = txq->sw_ring;
+	size = sizeof(struct ice_tx_desc) * txq->nb_tx_desc;
+	for (i = 0; i < size; i++)
+		((volatile char *)txq->tx_ring)[i] = 0;
+
+	prev = (uint16_t)(txq->nb_tx_desc - 1);
+	for (i = 0; i < txq->nb_tx_desc; i++) {
+		txq->tx_ring[i].cmd_type_offset_bsz =
+
	rte_cpu_to_le_64(IAVF_TX_DESC_DTYPE_DESC_DONE);
drivers/net/ice/ice_dcf.c +36 -0
+		txe[i].mbuf =  NULL;
+		txe[i].last_id = i;
+		txe[prev].next_id = i;
+		prev = i;
+	}
+
+	txq->tx_tail = 0;
+	txq->nb_tx_used = 0;
+
+	txq->last_desc_cleaned = txq->nb_tx_desc - 1;
+	txq->nb_tx_free = txq->nb_tx_desc - 1;
+
+	txq->tx_next_dd = txq->tx_rs_thresh - 1;
+	txq->tx_next_rs = txq->tx_rs_thresh - 1; }
+
+static int
+ice_dcf_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) {
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &ad->real_hw;
+	struct ice_rx_queue *rxq;
+	int err;
+
+	if (rx_queue_id >= dev->data->nb_rx_queues)
+		return -EINVAL;
+
+	err = ice_dcf_switch_queue(hw, rx_queue_id, true, false);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
+			    rx_queue_id);
+		return err;
+	}
+
+	rxq = dev->data->rx_queues[rx_queue_id];
+	rxq->rx_rel_mbufs(rxq);
+	reset_rx_queue(rxq);
+	dev->data->rx_queue_state[rx_queue_id] =

RTE_ETH_QUEUE_STATE_STOPPED;

drivers/net/ice/ice_dcf.c +23 -0
+
+	return 0;
+}
+
+static int
+ice_dcf_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) {
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct iavf_hw *hw = &ad->real_hw.avf;
+	struct ice_tx_queue *txq;
+	int err = 0;
+
+	if (tx_queue_id >= dev->data->nb_tx_queues)
+		return -EINVAL;
+
+	txq = dev->data->tx_queues[tx_queue_id];
+
+	/* Init the RX tail register. */
+	txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(tx_queue_id);
+	IAVF_PCI_REG_WRITE(txq->qtx_tail, 0);
+	IAVF_WRITE_FLUSH(hw);
+
+	/* Ready to switch the queue on */
+	err = ice_dcf_switch_queue(&ad->real_hw, tx_queue_id, false,

true);

drivers/net/ice/ice_dcf.c +32 -0
+
+	if (err)
+		PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
+			    tx_queue_id);
+	else
+		dev->data->tx_queue_state[tx_queue_id] =
+			RTE_ETH_QUEUE_STATE_STARTED;
+
+	return err;
+}
+
+static int
+ice_dcf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) {
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &ad->real_hw;
+	struct ice_tx_queue *txq;
+	int err;
+
+	if (tx_queue_id >= dev->data->nb_tx_queues)
+		return -EINVAL;
+
+	err = ice_dcf_switch_queue(hw, tx_queue_id, false, false);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
+			    tx_queue_id);
+		return err;
+	}
+
+	txq = dev->data->tx_queues[tx_queue_id];
+	txq->tx_rel_mbufs(txq);
+	reset_tx_queue(txq);
+	dev->data->tx_queue_state[tx_queue_id] =

RTE_ETH_QUEUE_STATE_STOPPED;

drivers/net/ice/ice_dcf.c +17 -0
+
+	return 0;
+}
+
+static int
+ice_dcf_start_queues(struct rte_eth_dev *dev) {
+	struct ice_rx_queue *rxq;
+	struct ice_tx_queue *txq;
+	int nb_rxq = 0;
+	int nb_txq, i;
+
+	for (nb_txq = 0; nb_txq < dev->data->nb_tx_queues; nb_txq++) {
+		txq = dev->data->tx_queues[nb_txq];
+		if (txq->tx_deferred_start)
+			continue;
+		if (ice_dcf_tx_queue_start(dev, nb_txq) != 0) {
+			PMD_DRV_LOG(ERR, "Fail to start queue %u",

nb_txq);

drivers/net/ice/ice_dcf.c +10 -0
+			goto tx_err;
+		}
+	}
+
+	for (nb_rxq = 0; nb_rxq < dev->data->nb_rx_queues; nb_rxq++) {
+		rxq = dev->data->rx_queues[nb_rxq];
+		if (rxq->rx_deferred_start)
+			continue;
+		if (ice_dcf_rx_queue_start(dev, nb_rxq) != 0) {
+			PMD_DRV_LOG(ERR, "Fail to start queue %u",

nb_rxq);

drivers/net/ice/ice_dcf.c +17 -0
+			goto rx_err;
+		}
+	}
+
+	return 0;
+
+	/* stop the started queues if failed to start all queues */
+rx_err:
+	for (i = 0; i < nb_rxq; i++)
+		ice_dcf_rx_queue_stop(dev, i);
+tx_err:
+	for (i = 0; i < nb_txq; i++)
+		ice_dcf_tx_queue_stop(dev, i);
+
+	return -1;
+}
+
 static int
 ice_dcf_dev_start(struct rte_eth_dev *dev)  { @@ -267,20 +531,72 @@

ice_dcf_dev_start(struct rte_eth_dev *dev)

drivers/net/ice/ice_dcf.c +31 -0
 		return ret;
 	}
 
+	if (dev->data->dev_conf.intr_conf.rxq != 0) {
+		rte_intr_disable(intr_handle);
+		rte_intr_enable(intr_handle);
+	}
+
+	ret = ice_dcf_start_queues(dev);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to enable queues");
+		return ret;
+	}
+
 	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
 }
 
+static void
+ice_dcf_stop_queues(struct rte_eth_dev *dev) {
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &ad->real_hw;
+	struct ice_rx_queue *rxq;
+	struct ice_tx_queue *txq;
+	int ret, i;
+
+	/* Stop All queues */
+	ret = ice_dcf_disable_queues(hw);
+	if (ret)
+		PMD_DRV_LOG(WARNING, "Fail to stop queues");
+
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		txq = dev->data->tx_queues[i];
+		if (!txq)
+			continue;
+		txq->tx_rel_mbufs(txq);
+		reset_tx_queue(txq);
+		dev->data->tx_queue_state[i] =

RTE_ETH_QUEUE_STATE_STOPPED;

drivers/net/ice/ice_dcf.c +8 -0
+	}
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (!rxq)
+			continue;
+		rxq->rx_rel_mbufs(rxq);
+		reset_rx_queue(rxq);
+		dev->data->rx_queue_state[i] =

RTE_ETH_QUEUE_STATE_STOPPED;

drivers/net/ice/ice_dcf.c +16 -0
+	}
+}
+
 static void
 ice_dcf_dev_stop(struct rte_eth_dev *dev)  {
 	struct ice_dcf_adapter *dcf_ad = dev->data->dev_private;
+	struct rte_intr_handle *intr_handle = dev->intr_handle;
 	struct ice_adapter *ad = &dcf_ad->parent;
 
 	if (ad->pf.adapter_stopped == 1)
 		return;
 
+	ice_dcf_stop_queues(dev);
+
+	rte_intr_efd_disable(intr_handle);
+	if (intr_handle->intr_vec) {
+		rte_free(intr_handle->intr_vec);
+		intr_handle->intr_vec = NULL;
+	}
+
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	ad->pf.adapter_stopped = 1;
 }
@@ -477,6 +793,10 @@ static const struct eth_dev_ops
 ice_dcf_eth_dev_ops = {
 	.tx_queue_setup          = ice_tx_queue_setup,
 	.rx_queue_release        = ice_rx_queue_release,
 	.tx_queue_release        = ice_tx_queue_release,
+	.rx_queue_start          = ice_dcf_rx_queue_start,
+	.tx_queue_start          = ice_dcf_tx_queue_start,
+	.rx_queue_stop           = ice_dcf_rx_queue_stop,
+	.tx_queue_stop           = ice_dcf_tx_queue_stop,
 	.link_update             = ice_dcf_link_update,
 	.stats_get               = ice_dcf_stats_get,

.stats_reset = ice_dcf_stats_reset,
--
2.17.1

author
#13 lore raw

PATCH v3 10/12 net/ice: enable stats for DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Add support to get and reset Rx/Tx stats in DCF. Query stats from PF.

---
 drivers/net/ice/ice_dcf.c        |  27 ++++++++
 drivers/net/ice/ice_dcf.h        |   4 ++
 drivers/net/ice/ice_dcf_ethdev.c | 102 +++++++++++++++++++++++++++----
 3 files changed, 120 insertions(+), 13 deletions(-)
drivers/net/ice/ice_dcf.c +27 -0
index f18c0f16a..fbeb58ee1 100644
@@ -993,3 +993,30 @@ ice_dcf_disable_queues(struct ice_dcf_hw *hw)
 
 	return err;
 }
+
+int
+ice_dcf_query_stats(struct ice_dcf_hw *hw,
+				   struct virtchnl_eth_stats *pstats)
+{
+	struct virtchnl_queue_select q_stats;
+	struct dcf_virtchnl_cmd args;
+	int err;
+
+	memset(&q_stats, 0, sizeof(q_stats));
+	q_stats.vsi_id = hw->vsi_res->vsi_id;
+
+	args.v_op = VIRTCHNL_OP_GET_STATS;
+	args.req_msg = (uint8_t *)&q_stats;
+	args.req_msglen = sizeof(q_stats);
+	args.rsp_msglen = sizeof(*pstats);
+	args.rsp_msgbuf = (uint8_t *)pstats;
+	args.rsp_buflen = sizeof(*pstats);
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err) {
+		PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS");
+		return err;
+	}
+
+	return 0;
+}
drivers/net/ice/ice_dcf.h +4 -0
index 68e1661c0..e82bc7748 100644
@@ -58,6 +58,7 @@ struct ice_dcf_hw {
 	uint16_t msix_base;
 	uint16_t nb_msix;
 	uint16_t rxq_map[16];
+	struct virtchnl_eth_stats eth_stats_offset;
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
@@ -72,4 +73,7 @@ int ice_dcf_configure_queues(struct ice_dcf_hw *hw);
 int ice_dcf_config_irq_map(struct ice_dcf_hw *hw);
 int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on);
 int ice_dcf_disable_queues(struct ice_dcf_hw *hw);
+int ice_dcf_query_stats(struct ice_dcf_hw *hw,
+			struct virtchnl_eth_stats *pstats);
+
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +89 -13

114 lines not on this page · raw message

Signature · 1 line
2.17.1
#14 lore raw

Re: [dpdk-dev] [PATCH v3 10/12] net/ice: enable stats for DCF

Quoted 43 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Tuesday, June 16, 2020 20:41
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Kovacevic, Marko <[email protected]>; Mcnamara, John <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v3 10/12] net/ice: enable stats for DCF

From: Qi Zhang <[email protected]>

Add support to get and reset Rx/Tx stats in DCF. Query stats from PF.

---
 drivers/net/ice/ice_dcf.c        |  27 ++++++++
 drivers/net/ice/ice_dcf.h        |   4 ++
 drivers/net/ice/ice_dcf_ethdev.c | 102 +++++++++++++++++++++++++++--
--
 3 files changed, 120 insertions(+), 13 deletions(-)
drivers/net/ice/ice_dcf.c index renamed from drivers/net/ice/ice_dcf.c +0 -0

f18c0f16a..fbeb58ee1 100644

drivers/net/ice/ice_dcf.c +9 -0
@@ -993,3 +993,30 @@ ice_dcf_disable_queues(struct ice_dcf_hw *hw)
 
 	return err;
 }
+
+int
+ice_dcf_query_stats(struct ice_dcf_hw *hw,
+				   struct virtchnl_eth_stats *pstats) {
+	struct virtchnl_queue_select q_stats;
+	struct dcf_virtchnl_cmd args;
+	int err;
+
+	memset(&q_stats, 0, sizeof(q_stats));

drivers/net/ice/ice_dcf.c ice_dcf_disable_queues(struct ice_dcf_hw *hw) · line 1014

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+	q_stats.vsi_id = hw->vsi_res->vsi_id;
+
+	args.v_op = VIRTCHNL_OP_GET_STATS;
+	args.req_msg = (uint8_t *)&q_stats;
+	args.req_msglen = sizeof(q_stats);
+	args.rsp_msglen = sizeof(*pstats);
+	args.rsp_msgbuf = (uint8_t *)pstats;
+	args.rsp_buflen = sizeof(*pstats);
+
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);

Why don't use ice_dcf_send_cmd_req_no_irq? all the other virtual channel interface are called by ice_dcf_send_cmd_req_no_irq in dcf, like ice_dcf_get_vf_vsi_map

Quoted 143 lines
drivers/net/ice/ice_dcf.c +2 -0
+	if (err) {
+		PMD_DRV_LOG(ERR, "fail to execute command

OP_GET_STATS");

drivers/net/ice/ice_dcf.c +5 -0
+		return err;
+	}
+
+	return 0;
+}
drivers/net/ice/ice_dcf.h index renamed from drivers/net/ice/ice_dcf.h +0 -0

68e1661c0..e82bc7748 100644

drivers/net/ice/ice_dcf.h +1 -0
@@ -58,6 +58,7 @@ struct ice_dcf_hw {
 	uint16_t msix_base;
 	uint16_t nb_msix;
 	uint16_t rxq_map[16];
+	struct virtchnl_eth_stats eth_stats_offset;
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw, @@ -72,4 +73,7

@@ int ice_dcf_configure_queues(struct ice_dcf_hw *hw); int ice_dcf_config_irq_map(struct ice_dcf_hw *hw); int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on); int ice_dcf_disable_queues(struct ice_dcf_hw *hw);

drivers/net/ice/ice_dcf.h +3 -0
+int ice_dcf_query_stats(struct ice_dcf_hw *hw,
+			struct virtchnl_eth_stats *pstats);
+
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +84 -13
index 239426b09..1a675064a 100644
@@ -695,19 +695,6 @@ ice_dcf_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
-static int
-ice_dcf_stats_get(__rte_unused struct rte_eth_dev *dev,
-		  __rte_unused struct rte_eth_stats *igb_stats)
-{
-	return 0;
-}
-
-static int
-ice_dcf_stats_reset(__rte_unused struct rte_eth_dev *dev) -{
-	return 0;
-}
-
 static int
 ice_dcf_dev_promiscuous_enable(__rte_unused struct rte_eth_dev *dev)
 { @@ -760,6 +747,95 @@ ice_dcf_dev_filter_ctrl(struct rte_eth_dev *dev,
 	return ret;
 }
 
+#define ICE_DCF_32_BIT_WIDTH (CHAR_BIT * 4) #define
+ICE_DCF_48_BIT_WIDTH (CHAR_BIT * 6) #define ICE_DCF_48_BIT_MASK
+RTE_LEN2MASK(ICE_DCF_48_BIT_WIDTH, uint64_t)
+
+static void
+ice_dcf_stat_update_48(uint64_t *offset, uint64_t *stat) {
+	if (*stat >= *offset)
+		*stat = *stat - *offset;
+	else
+		*stat = (uint64_t)((*stat +
+			((uint64_t)1 << ICE_DCF_48_BIT_WIDTH)) - *offset);
+
+	*stat &= ICE_DCF_48_BIT_MASK;
+}
+
+static void
+ice_dcf_stat_update_32(uint64_t *offset, uint64_t *stat) {
+	if (*stat >= *offset)
+		*stat = (uint64_t)(*stat - *offset);
+	else
+		*stat = (uint64_t)((*stat +
+			((uint64_t)1 << ICE_DCF_32_BIT_WIDTH)) - *offset); }
+
+static void
+ice_dcf_update_stats(struct virtchnl_eth_stats *oes,
+		     struct virtchnl_eth_stats *nes)
+{
+	ice_dcf_stat_update_48(&oes->rx_bytes, &nes->rx_bytes);
+	ice_dcf_stat_update_48(&oes->rx_unicast, &nes->rx_unicast);
+	ice_dcf_stat_update_48(&oes->rx_multicast, &nes->rx_multicast);
+	ice_dcf_stat_update_48(&oes->rx_broadcast, &nes->rx_broadcast);
+	ice_dcf_stat_update_32(&oes->rx_discards, &nes->rx_discards);
+	ice_dcf_stat_update_48(&oes->tx_bytes, &nes->tx_bytes);
+	ice_dcf_stat_update_48(&oes->tx_unicast, &nes->tx_unicast);
+	ice_dcf_stat_update_48(&oes->tx_multicast, &nes->tx_multicast);
+	ice_dcf_stat_update_48(&oes->tx_broadcast, &nes->tx_broadcast);
+	ice_dcf_stat_update_32(&oes->tx_errors, &nes->tx_errors);
+	ice_dcf_stat_update_32(&oes->tx_discards, &nes->tx_discards); }
+
+
+static int
+ice_dcf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &ad->real_hw;
+	struct virtchnl_eth_stats pstats;
+	int ret;
+
+	ret = ice_dcf_query_stats(hw, &pstats);
+	if (ret == 0) {
+		ice_dcf_update_stats(&hw->eth_stats_offset, &pstats);
+		stats->ipackets = pstats.rx_unicast + pstats.rx_multicast +
+				pstats.rx_broadcast - pstats.rx_discards;
+		stats->opackets = pstats.tx_broadcast + pstats.tx_multicast +
+						pstats.tx_unicast;
+		stats->imissed = pstats.rx_discards;
+		stats->oerrors = pstats.tx_errors + pstats.tx_discards;
+		stats->ibytes = pstats.rx_bytes;
+		stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN;
+		stats->obytes = pstats.tx_bytes;
+	} else {
+		PMD_DRV_LOG(ERR, "Get statistics failed");
+	}
+	return ret;
+}
+
+static int
+ice_dcf_stats_reset(struct rte_eth_dev *dev) {
+	struct ice_dcf_adapter *ad = dev->data->dev_private;
+	struct ice_dcf_hw *hw = &ad->real_hw;
+	struct virtchnl_eth_stats pstats;
+	int ret;
+
+	/* read stat values to clear hardware registers */
+	ret = ice_dcf_query_stats(hw, &pstats);
+	if (ret != 0)
+		return ret;
+
+	/* set stats offset base on current values */
+	hw->eth_stats_offset = pstats;
+
+	return 0;
+}
+
 static void
 ice_dcf_dev_close(struct rte_eth_dev *dev)  {
--

2.17.1

author
#15 lore raw

Re: [dpdk-dev] [PATCH v3 10/12] net/ice: enable stats for DCF

Hi, Qiming,

Quoted 59 lines

-----Original Message-----
From: Yang, Qiming <[email protected]>
Sent: Thursday, June 18, 2020 2:32 PM
To: Xu, Ting <[email protected]>; [email protected]
Cc: Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Kovacevic, Marko <[email protected]>; Mcnamara, John <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: RE: [PATCH v3 10/12] net/ice: enable stats for DCF

Quoted 8 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Tuesday, June 16, 2020 20:41
To: [email protected]
Cc: Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Kovacevic, Marko <[email protected]>; Mcnamara, John

<[email protected]>;

Quoted 38 lines

Ye, Xiaolong <[email protected]>
Subject: [PATCH v3 10/12] net/ice: enable stats for DCF

From: Qi Zhang <[email protected]>

Add support to get and reset Rx/Tx stats in DCF. Query stats from PF.

---
 drivers/net/ice/ice_dcf.c        |  27 ++++++++
 drivers/net/ice/ice_dcf.h        |   4 ++
 drivers/net/ice/ice_dcf_ethdev.c | 102 +++++++++++++++++++++++++++--
--
 3 files changed, 120 insertions(+), 13 deletions(-)
drivers/net/ice/ice_dcf.c +0 -0

index
f18c0f16a..fbeb58ee1 100644

drivers/net/ice/ice_dcf.c +13 -0
@@ -993,3 +993,30 @@ ice_dcf_disable_queues(struct ice_dcf_hw *hw)
 
 return err;
 }
+
+int
+ice_dcf_query_stats(struct ice_dcf_hw *hw,
+   struct virtchnl_eth_stats *pstats) { struct virtchnl_queue_select
+q_stats; struct dcf_virtchnl_cmd args; int err;
+
+memset(&q_stats, 0, sizeof(q_stats)); q_stats.vsi_id =
+hw->vsi_res->vsi_id;
+
+args.v_op = VIRTCHNL_OP_GET_STATS;
+args.req_msg = (uint8_t *)&q_stats;
+args.req_msglen = sizeof(q_stats);
+args.rsp_msglen = sizeof(*pstats);
Quoted 9 lines

drivers/net/ice/ice_dcf.c ice_dcf_disable_queues(struct ice_dcf_hw *hw) · line 1015

Quoted 4 lines
drivers/net/ice/ice_dcf.c +4 -0
+args.rsp_msgbuf = (uint8_t *)pstats;
+args.rsp_buflen = sizeof(*pstats);
+
+err = ice_dcf_execute_virtchnl_cmd(hw, &args);

Why don't use ice_dcf_send_cmd_req_no_irq? all the other virtual channel interface are called by ice_dcf_send_cmd_req_no_irq in dcf, like ice_dcf_get_vf_vsi_map

ice_dcf_send_cmd_req_no_irq() are always used combined with ice_dcf_recv_cmd_rsp_no_irq(), their function is the same as ice_dcf_execute_virtchnl_cmd().
The difference is that ice_dcf_send_cmd_req_no_irq() is used in initialization, before the interrupt is enabled. ice_dcf_execute_virtchnl_cmd() should be used after interrupt enable for safety.

In this way, I think it is better to use ice_dcf_execute_virtchnl_cmd() here since these functions will be called after initialization.

Best Regards,
Xu, Ting

Quoted 123 lines
Quoted 122 lines
drivers/net/ice/ice_dcf.c +2 -0
+if (err) {
+PMD_DRV_LOG(ERR, "fail to execute command

OP_GET_STATS");

drivers/net/ice/ice_dcf.c +5 -0
+return err;
+}
+
+return 0;
+}
drivers/net/ice/ice_dcf.h +0 -0

index
68e1661c0..e82bc7748 100644

drivers/net/ice/ice_dcf.h +2 -0
@@ -58,6 +58,7 @@ struct ice_dcf_hw {
 uint16_t msix_base;
 uint16_t nb_msix;
 uint16_t rxq_map[16];
+struct virtchnl_eth_stats eth_stats_offset;
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw, @@ -72,4
+73,7 @@ int ice_dcf_configure_queues(struct ice_dcf_hw *hw);  int

ice_dcf_config_irq_map(struct ice_dcf_hw *hw); int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on); int ice_dcf_disable_queues(struct ice_dcf_hw *hw);

drivers/net/ice/ice_dcf.h +3 -0
+int ice_dcf_query_stats(struct ice_dcf_hw *hw, struct
+virtchnl_eth_stats *pstats);
+
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +0 -7
index 239426b09..1a675064a 100644
@@ -695,19 +695,6 @@ ice_dcf_dev_info_get(struct rte_eth_dev *dev,
 return 0;  }
 
-static int
-ice_dcf_stats_get(__rte_unused struct rte_eth_dev *dev,
-  __rte_unused struct rte_eth_stats *igb_stats) -{ -return 0; -}
-
-static int
-ice_dcf_stats_reset(__rte_unused struct rte_eth_dev *dev) -{ -return
 0; -}
-
 static int
 ice_dcf_dev_promiscuous_enable(__rte_unused struct rte_eth_dev *dev)

{ @@ -760,6 +747,95 @@ ice_dcf_dev_filter_ctrl(struct rte_eth_dev *dev, return ret; }

drivers/net/ice/ice_dcf_ethdev.c +68 -1
+#define ICE_DCF_32_BIT_WIDTH (CHAR_BIT * 4) #define
+ICE_DCF_48_BIT_WIDTH (CHAR_BIT * 6) #define ICE_DCF_48_BIT_MASK
+RTE_LEN2MASK(ICE_DCF_48_BIT_WIDTH, uint64_t)
+
+static void
+ice_dcf_stat_update_48(uint64_t *offset, uint64_t *stat) { if (*stat
+>= *offset) *stat = *stat - *offset; else *stat = (uint64_t)((*stat +
+((uint64_t)1 << ICE_DCF_48_BIT_WIDTH)) - *offset);
+
+*stat &= ICE_DCF_48_BIT_MASK;
+}
+
+static void
+ice_dcf_stat_update_32(uint64_t *offset, uint64_t *stat) { if (*stat
+>= *offset) *stat = (uint64_t)(*stat - *offset); else *stat =
+(uint64_t)((*stat +
+((uint64_t)1 << ICE_DCF_32_BIT_WIDTH)) - *offset); }
+
+static void
+ice_dcf_update_stats(struct virtchnl_eth_stats *oes,
+     struct virtchnl_eth_stats *nes)
+{
+ice_dcf_stat_update_48(&oes->rx_bytes, &nes->rx_bytes);
+ice_dcf_stat_update_48(&oes->rx_unicast, &nes->rx_unicast);
+ice_dcf_stat_update_48(&oes->rx_multicast, &nes->rx_multicast);
+ice_dcf_stat_update_48(&oes->rx_broadcast, &nes->rx_broadcast);
+ice_dcf_stat_update_32(&oes->rx_discards, &nes->rx_discards);
+ice_dcf_stat_update_48(&oes->tx_bytes, &nes->tx_bytes);
+ice_dcf_stat_update_48(&oes->tx_unicast, &nes->tx_unicast);
+ice_dcf_stat_update_48(&oes->tx_multicast, &nes->tx_multicast);
+ice_dcf_stat_update_48(&oes->tx_broadcast, &nes->tx_broadcast);
+ice_dcf_stat_update_32(&oes->tx_errors, &nes->tx_errors);
+ice_dcf_stat_update_32(&oes->tx_discards, &nes->tx_discards); }
+
+
+static int
+ice_dcf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats
+*stats) { struct ice_dcf_adapter *ad = dev->data->dev_private; struct
+ice_dcf_hw *hw = &ad->real_hw; struct virtchnl_eth_stats pstats; int
+ret;
+
+ret = ice_dcf_query_stats(hw, &pstats); if (ret == 0) {
+ice_dcf_update_stats(&hw->eth_stats_offset, &pstats);
+stats->ipackets = pstats.rx_unicast + pstats.rx_multicast +
+pstats.rx_broadcast - pstats.rx_discards;
+stats->opackets = pstats.tx_broadcast + pstats.tx_multicast +
+pstats.tx_unicast;
+stats->imissed = pstats.rx_discards;
+stats->oerrors = pstats.tx_errors + pstats.tx_discards; ibytes =
+stats->pstats.rx_bytes; ibytes -= stats->ipackets *
+stats->RTE_ETHER_CRC_LEN; obytes = pstats.tx_bytes;
+} else {
+PMD_DRV_LOG(ERR, "Get statistics failed"); } return ret; }
+
+static int
+ice_dcf_stats_reset(struct rte_eth_dev *dev) { struct ice_dcf_adapter
+*ad = dev->data->dev_private; struct ice_dcf_hw *hw = &ad->real_hw;
+struct virtchnl_eth_stats pstats; int ret;
+
+/* read stat values to clear hardware registers */ ret =
+ice_dcf_query_stats(hw, &pstats); if (ret != 0) return ret;
+
+/* set stats offset base on current values */
+hw->eth_stats_offset = pstats;
+
+return 0;
+}
+
 static void
 ice_dcf_dev_close(struct rte_eth_dev *dev)  {
--

2.17.1

author
#16 lore raw

PATCH v3 11/12 net/ice: set MAC filter during dev start for DCF

In reply to Ting Xu

From: Qi Zhang <[email protected]>

Add support to add and delete MAC address filter in DCF.

---
 drivers/net/ice/ice_dcf.c        | 42 ++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h        |  1 +
 drivers/net/ice/ice_dcf_ethdev.c |  7 ++++++
 3 files changed, 50 insertions(+)
drivers/net/ice/ice_dcf.c +42 -0
index fbeb58ee1..712f43825 100644
@@ -1020,3 +1020,45 @@ ice_dcf_query_stats(struct ice_dcf_hw *hw,
 
 	return 0;
 }
+
+int
+ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add)
+{
+	struct virtchnl_ether_addr_list *list;
+	struct rte_ether_addr *addr;
+	struct dcf_virtchnl_cmd args;
+	int len, err = 0;
+
+	len = sizeof(struct virtchnl_ether_addr_list);
+	addr = hw->eth_dev->data->mac_addrs;
+	len += sizeof(struct virtchnl_ether_addr);
+
+	list = rte_zmalloc(NULL, len, 0);
+	if (!list) {
+		PMD_DRV_LOG(ERR, "fail to allocate memory");
+		return -ENOMEM;
+	}
+
+	rte_memcpy(list->list[0].addr, addr->addr_bytes,
+			sizeof(addr->addr_bytes));
+	PMD_DRV_LOG(DEBUG, "add/rm mac:%x:%x:%x:%x:%x:%x",
+			    addr->addr_bytes[0], addr->addr_bytes[1],
+			    addr->addr_bytes[2], addr->addr_bytes[3],
+			    addr->addr_bytes[4], addr->addr_bytes[5]);
+
+	list->vsi_id = hw->vsi_res->vsi_id;
+	list->num_elements = 1;
+
+	memset(&args, 0, sizeof(args));
+	args.v_op = add ? VIRTCHNL_OP_ADD_ETH_ADDR :
+			VIRTCHNL_OP_DEL_ETH_ADDR;
+	args.req_msg = (uint8_t *)list;
+	args.req_msglen  = len;
+	err = ice_dcf_execute_virtchnl_cmd(hw, &args);
+	if (err)
+		PMD_DRV_LOG(ERR, "fail to execute command %s",
+			    add ? "OP_ADD_ETHER_ADDRESS" :
+			    "OP_DEL_ETHER_ADDRESS");
+	rte_free(list);
+	return err;
+}
drivers/net/ice/ice_dcf.h +1 -0
index e82bc7748..a44a01e90 100644
@@ -75,5 +75,6 @@ int ice_dcf_switch_queue(struct ice_dcf_hw *hw, uint16_t qid, bool rx, bool on);
 int ice_dcf_disable_queues(struct ice_dcf_hw *hw);
 int ice_dcf_query_stats(struct ice_dcf_hw *hw,
 			struct virtchnl_eth_stats *pstats);
+int ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add);
 
 #endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c +7 -0
index 1a675064a..7912dc18a 100644
@@ -542,6 +542,12 @@ ice_dcf_dev_start(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	ret = ice_dcf_add_del_all_mac_addr(hw, true);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to add mac addr");
+		return ret;
+	}
+
 	dev->data->dev_link.link_status = ETH_LINK_UP;
 
 	return 0;
@@ -597,6 +603,7 @@ ice_dcf_dev_stop(struct rte_eth_dev *dev)
 		intr_handle->intr_vec = NULL;
 	}
 
+	ice_dcf_add_del_all_mac_addr(&dcf_ad->real_hw, false);
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
 	ad->pf.adapter_stopped = 1;
 }
Signature · 1 line
2.17.1
author
#17 lore raw

PATCH v3 12/12 doc: enable DCF datapath configuration

In reply to Ting Xu

Add doc for DCF datapath configuration in DPDK 20.08 release note.

---
 doc/guides/rel_notes/release_20_08.rst | 6 ++++++
 1 file changed, 6 insertions(+)
doc/guides/rel_notes/release_20_08.rst +6 -0
index dee4ccbb5..1a3a4cdb2 100644
@@ -56,6 +56,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF datapath configuration.
+
 * **Updated Mellanox mlx5 driver.**
 
   Updated Mellanox mlx5 driver with new features and improvements, including:
Signature · 1 line
2.17.1