DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH v1] net/axgbe: add support for device reset
@ 2020-11-19 13:21 selwin.sebastian
  2020-11-20  5:16 ` Somalapuram, Amaranath
  0 siblings, 1 reply; 2+ messages in thread
From: selwin.sebastian @ 2020-11-19 13:21 UTC (permalink / raw)
  To: dev; +Cc: amaranath.somalapuram

From: Selwin Sebastian <selwin.sebastian@amd.com>

Added support for device reset

Signed-off-by: Selwin Sebastian <selwin.sebastian@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 75 ++++++++++++++++++++++++--------
 1 file changed, 56 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index cfe6aba73..4c6366da8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -16,6 +16,7 @@ static int  axgbe_dev_start(struct rte_eth_dev *dev);
 static int  axgbe_dev_stop(struct rte_eth_dev *dev);
 static void axgbe_dev_interrupt_handler(void *param);
 static int axgbe_dev_close(struct rte_eth_dev *dev);
+static int axgbe_dev_reset(struct rte_eth_dev *dev);
 static int axgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static int axgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
 static int axgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
@@ -215,6 +216,7 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = {
 	.dev_start            = axgbe_dev_start,
 	.dev_stop             = axgbe_dev_stop,
 	.dev_close            = axgbe_dev_close,
+	.dev_reset            = axgbe_dev_reset,
 	.promiscuous_enable   = axgbe_dev_promiscuous_enable,
 	.promiscuous_disable  = axgbe_dev_promiscuous_disable,
 	.allmulticast_enable  = axgbe_dev_allmulticast_enable,
@@ -618,6 +620,20 @@ axgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+axgbe_dev_reset(struct rte_eth_dev *dev)
+{
+	int ret = 0;
+
+	ret = axgbe_dev_close(dev);
+	if (ret)
+		return ret;
+
+	ret = eth_axgbe_dev_init(dev);
+
+	return ret;
+}
+
 static void
 axgbe_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 {
@@ -1104,22 +1120,33 @@ axgbe_dev_stats_get(struct rte_eth_dev *dev,
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		rxq = dev->data->rx_queues[i];
-		stats->q_ipackets[i] = rxq->pkts;
-		stats->ipackets += rxq->pkts;
-		stats->q_ibytes[i] = rxq->bytes;
-		stats->ibytes += rxq->bytes;
-		stats->rx_nombuf += rxq->rx_mbuf_alloc_failed;
-		stats->q_errors[i] = rxq->errors + rxq->rx_mbuf_alloc_failed;
-		stats->ierrors += rxq->errors;
+		if (rxq) {
+			stats->q_ipackets[i] = rxq->pkts;
+			stats->ipackets += rxq->pkts;
+			stats->q_ibytes[i] = rxq->bytes;
+			stats->ibytes += rxq->bytes;
+			stats->rx_nombuf += rxq->rx_mbuf_alloc_failed;
+			stats->q_errors[i] = rxq->errors
+				+ rxq->rx_mbuf_alloc_failed;
+			stats->ierrors += rxq->errors;
+		} else {
+			PMD_DRV_LOG(DEBUG, "Rx queue not setup for port %d\n",
+					dev->data->port_id);
+		}
 	}
 
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		txq = dev->data->tx_queues[i];
-		stats->q_opackets[i] = txq->pkts;
-		stats->opackets += txq->pkts;
-		stats->q_obytes[i] = txq->bytes;
-		stats->obytes += txq->bytes;
-		stats->oerrors += txq->errors;
+		if (txq) {
+			stats->q_opackets[i] = txq->pkts;
+			stats->opackets += txq->pkts;
+			stats->q_obytes[i] = txq->bytes;
+			stats->obytes += txq->bytes;
+			stats->oerrors += txq->errors;
+		} else {
+			PMD_DRV_LOG(DEBUG, "Tx queue not setup for port %d\n",
+					dev->data->port_id);
+		}
 	}
 
 	return 0;
@@ -1134,16 +1161,26 @@ axgbe_dev_stats_reset(struct rte_eth_dev *dev)
 
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		rxq = dev->data->rx_queues[i];
-		rxq->pkts = 0;
-		rxq->bytes = 0;
-		rxq->errors = 0;
-		rxq->rx_mbuf_alloc_failed = 0;
+		if (rxq) {
+			rxq->pkts = 0;
+			rxq->bytes = 0;
+			rxq->errors = 0;
+			rxq->rx_mbuf_alloc_failed = 0;
+		} else {
+			PMD_DRV_LOG(DEBUG, "Rx queue not setup for port %d\n",
+					dev->data->port_id);
+		}
 	}
 	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		txq = dev->data->tx_queues[i];
-		txq->pkts = 0;
-		txq->bytes = 0;
-		txq->errors = 0;
+		if (txq) {
+			txq->pkts = 0;
+			txq->bytes = 0;
+			txq->errors = 0;
+		} else {
+			PMD_DRV_LOG(DEBUG, "Tx queue not setup for port %d\n",
+					dev->data->port_id);
+		}
 	}
 
 	return 0;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH v1] net/axgbe: add support for device reset
  2020-11-19 13:21 [dpdk-dev] [PATCH v1] net/axgbe: add support for device reset selwin.sebastian
@ 2020-11-20  5:16 ` Somalapuram, Amaranath
  0 siblings, 0 replies; 2+ messages in thread
From: Somalapuram, Amaranath @ 2020-11-20  5:16 UTC (permalink / raw)
  To: Sebastian, Selwin, dev, Ferruh Yigit

[AMD Official Use Only - Internal Distribution Only]

-----Original Message-----
From: Sebastian, Selwin <Selwin.Sebastian@amd.com>
Sent: Thursday, November 19, 2020 6:52 PM
To: dev@dpdk.org
Cc: Somalapuram, Amaranath <Amaranath.Somalapuram@amd.com>
Subject: [PATCH v1] net/axgbe: add support for device reset

From: Selwin Sebastian <selwin.sebastian@amd.com>

Added support for device reset

Signed-off-by: Selwin Sebastian <selwin.sebastian@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 75 ++++++++++++++++++++++++--------
 1 file changed, 56 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index cfe6aba73..4c6366da8 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -16,6 +16,7 @@ static int  axgbe_dev_start(struct rte_eth_dev *dev);  static int  axgbe_dev_stop(struct rte_eth_dev *dev);  static void axgbe_dev_interrupt_handler(void *param);  static int axgbe_dev_close(struct rte_eth_dev *dev);
+static int axgbe_dev_reset(struct rte_eth_dev *dev);
 static int axgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);  static int axgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);  static int axgbe_dev_allmulticast_enable(struct rte_eth_dev *dev); @@ -215,6 +216,7 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = {
 .dev_start            = axgbe_dev_start,
 .dev_stop             = axgbe_dev_stop,
 .dev_close            = axgbe_dev_close,
+.dev_reset            = axgbe_dev_reset,
 .promiscuous_enable   = axgbe_dev_promiscuous_enable,
 .promiscuous_disable  = axgbe_dev_promiscuous_disable,
 .allmulticast_enable  = axgbe_dev_allmulticast_enable, @@ -618,6 +620,20 @@ axgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
 return 0;
 }

+static int
+axgbe_dev_reset(struct rte_eth_dev *dev) {
+int ret = 0;
+
+ret = axgbe_dev_close(dev);
+if (ret)
+return ret;
+
+ret = eth_axgbe_dev_init(dev);
+
+return ret;
+}
+
 static void
 axgbe_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)  { @@ -1104,22 +1120,33 @@ axgbe_dev_stats_get(struct rte_eth_dev *dev,

 for (i = 0; i < dev->data->nb_rx_queues; i++) {
 rxq = dev->data->rx_queues[i];
-stats->q_ipackets[i] = rxq->pkts;
-stats->ipackets += rxq->pkts;
-stats->q_ibytes[i] = rxq->bytes;
-stats->ibytes += rxq->bytes;
-stats->rx_nombuf += rxq->rx_mbuf_alloc_failed;
-stats->q_errors[i] = rxq->errors + rxq->rx_mbuf_alloc_failed;
-stats->ierrors += rxq->errors;
+if (rxq) {
+stats->q_ipackets[i] = rxq->pkts;
+stats->ipackets += rxq->pkts;
+stats->q_ibytes[i] = rxq->bytes;
+stats->ibytes += rxq->bytes;
+stats->rx_nombuf += rxq->rx_mbuf_alloc_failed;
+stats->q_errors[i] = rxq->errors
++ rxq->rx_mbuf_alloc_failed;
+stats->ierrors += rxq->errors;
+} else {
+PMD_DRV_LOG(DEBUG, "Rx queue not setup for port %d\n",
+dev->data->port_id);
+}
 }

 for (i = 0; i < dev->data->nb_tx_queues; i++) {
 txq = dev->data->tx_queues[i];
-stats->q_opackets[i] = txq->pkts;
-stats->opackets += txq->pkts;
-stats->q_obytes[i] = txq->bytes;
-stats->obytes += txq->bytes;
-stats->oerrors += txq->errors;
+if (txq) {
+stats->q_opackets[i] = txq->pkts;
+stats->opackets += txq->pkts;
+stats->q_obytes[i] = txq->bytes;
+stats->obytes += txq->bytes;
+stats->oerrors += txq->errors;
+} else {
+PMD_DRV_LOG(DEBUG, "Tx queue not setup for port %d\n",
+dev->data->port_id);
+}
 }

 return 0;
@@ -1134,16 +1161,26 @@ axgbe_dev_stats_reset(struct rte_eth_dev *dev)

 for (i = 0; i < dev->data->nb_rx_queues; i++) {
 rxq = dev->data->rx_queues[i];
-rxq->pkts = 0;
-rxq->bytes = 0;
-rxq->errors = 0;
-rxq->rx_mbuf_alloc_failed = 0;
+if (rxq) {
+rxq->pkts = 0;
+rxq->bytes = 0;
+rxq->errors = 0;
+rxq->rx_mbuf_alloc_failed = 0;
+} else {
+PMD_DRV_LOG(DEBUG, "Rx queue not setup for port %d\n",
+dev->data->port_id);
+}
 }
 for (i = 0; i < dev->data->nb_tx_queues; i++) {
 txq = dev->data->tx_queues[i];
-txq->pkts = 0;
-txq->bytes = 0;
-txq->errors = 0;
+if (txq) {
+txq->pkts = 0;
+txq->bytes = 0;
+txq->errors = 0;
+} else {
+PMD_DRV_LOG(DEBUG, "Tx queue not setup for port %d\n",
+dev->data->port_id);
+}
 }

 return 0;
--
2.17.1

Acked-by: Amaranath Somalapuram <asomalap@amd.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 13:21 [dpdk-dev] [PATCH v1] net/axgbe: add support for device reset selwin.sebastian
2020-11-20  5:16 ` Somalapuram, Amaranath

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox