All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jia Yu <jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: [PATCH 2/2] rte_ethdev: add return status for rte_eth_stats_get
Date: Fri,  7 Nov 2014 09:31:51 -0800	[thread overview]
Message-ID: <1415381511-43364-3-git-send-email-jyu@vmware.com> (raw)
In-Reply-To: <1415381511-43364-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>

rte_eth_stats_get is to get physical device statistics. Without
return status, caller does not know whether function fails or not
(i.e. invalid port_id, driver has no stats_get callback). Caller
cannot differiente normal 0 stats or error case. This fix adds
a return status to the function.

Signed-off-by: Jia Yu <jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 lib/librte_ether/rte_ethdev.c | 7 ++++---
 lib/librte_ether/rte_ethdev.h | 4 +++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 6c01b02..4ec9ca6 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1226,21 +1226,22 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
 	}
 }
 
-void
+int
 rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
 {
 	struct rte_eth_dev *dev;
 
 	if (port_id >= nb_ports) {
 		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-		return;
+		return (-ENODEV);
 	}
 	dev = &rte_eth_devices[port_id];
 	memset(stats, 0, sizeof(*stats));
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->stats_get);
+	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP);
 	(*dev->dev_ops->stats_get)(dev, stats);
 	stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
+        return 0;
 }
 
 void
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 8bf274d..e29e9be 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2054,8 +2054,10 @@ extern void rte_eth_link_get_nowait(uint8_t port_id,
  *   - *obytes*   with the total of successfully transmitted bytes.
  *   - *ierrors*  with the total of erroneous received packets.
  *   - *oerrors*  with the total of failed transmitted packets.
+ * @return
+ *   Zero if successful. Non-zero otherwise.
  */
-extern void rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
+extern int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
 
 /**
  * Reset the general I/O statistics of an Ethernet device.
-- 
1.9.1

  parent reply	other threads:[~2014-11-07 17:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 17:31 [PATCH 0/2] rte_ethdev fix/improvement Jia Yu
     [not found] ` <1415381511-43364-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2014-11-07 17:31   ` [PATCH 1/2] rte_ethdev: update link status (speed, duplex, link_up) after rte_eth_dev_start Jia Yu
     [not found]     ` <1415381511-43364-2-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2014-11-12  3:57       ` Zhang, Helin
     [not found]         ` <F35DEAC7BCE34641BA9FAC6BCA4A12E70A7BBF2A-0J0gbvR4kTg/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-01-30 10:28           ` Thomas Monjalon
2015-02-03  8:00             ` Jia Yu
     [not found]               ` <D0F5BD49.32466%jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2015-02-03  8:35                 ` Zhang, Helin
     [not found]                   ` <F35DEAC7BCE34641BA9FAC6BCA4A12E70A803FED-0J0gbvR4kTg/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-02-03 18:53                     ` Jia Yu
     [not found]                       ` <D0F656A6.32525%jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2015-02-04  0:37                         ` Zhang, Helin
2014-11-07 17:31   ` Jia Yu [this message]
2014-11-10  9:40   ` [PATCH 0/2] rte_ethdev fix/improvement Thomas Monjalon
2014-11-11 23:48     ` Jia Yu
     [not found]       ` <D087DFF2.2BC9E%jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2014-11-12  9:35         ` Thomas Monjalon
2015-02-11  3:20   ` Zhang, Helin
     [not found]     ` <F35DEAC7BCE34641BA9FAC6BCA4A12E70A806C0B-0J0gbvR4kTg/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-02-18 16:51       ` Thomas Monjalon

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=1415381511-43364-3-git-send-email-jyu@vmware.com \
    --to=jyu-pghwnbhtmq7qt0dzr+alfa@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.