diff mbox series

[v1] net/axgbe: add support for device reset

Message ID 20201119132158.10821-1-selwin.sebastian@amd.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series [v1] net/axgbe: add support for device reset | expand

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Sebastian, Selwin Nov. 19, 2020, 1:21 p.m. UTC
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(-)

Comments

Somalapuram, Amaranath Nov. 20, 2020, 5:16 a.m. UTC | #1
[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>
Ferruh Yigit Dec. 8, 2020, 12:45 p.m. UTC | #2
On 11/20/2020 5:16 AM, Somalapuram, Amaranath wrote:
> [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>

<...>

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

Applied to dpdk-next-net/main, thanks.
diff mbox series

Patch

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;