DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Somalapuram, Amaranath" <Amaranath.Somalapuram@amd.com>
To: "Sebastian, Selwin" <Selwin.Sebastian@amd.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	Ferruh Yigit <ferruh.yigit@intel.com>
Subject: Re: [dpdk-dev] [PATCH v1] net/axgbe: add support for device reset
Date: Fri, 20 Nov 2020 05:16:20 +0000
Message-ID: <BYAPR12MB28216D2326BAE83A9B46737FF8FF0@BYAPR12MB2821.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20201119132158.10821-1-selwin.sebastian@amd.com>

[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>

  reply	other threads:[~2020-11-20  5:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 13:21 selwin.sebastian
2020-11-20  5:16 ` Somalapuram, Amaranath [this message]
2020-12-08 12:45   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BYAPR12MB28216D2326BAE83A9B46737FF8FF0@BYAPR12MB2821.namprd12.prod.outlook.com \
    --to=amaranath.somalapuram@amd.com \
    --cc=Selwin.Sebastian@amd.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://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/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


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