From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] ethdev: add helper functions to get eth_dev and dev private data
Date: Wed, 17 Feb 2016 14:20:15 +0000 [thread overview]
Message-ID: <1455718817-14171-2-git-send-email-ferruh.yigit@intel.com> (raw)
In-Reply-To: <1455718817-14171-1-git-send-email-ferruh.yigit@intel.com>
This is to provide abstraction and reduce global variable access.
Global variable rte_eth_devices kept exported to not break ABI.
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/librte_ether/rte_ethdev.h | 44 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 6afb5a9..7209b83 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3881,6 +3881,50 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
uint16_t queue_id, size_t size,
unsigned align, int socket_id);
+/**
+ * Return rte_eth_dev by port id
+ *
+ * This is to abstract device access and limit global variable access.
+ *
+ * @param port_id
+ * port_id of the device to return.
+ */
+static inline struct rte_eth_dev *
+rte_eth_by_port(uint16_t port_id)
+{
+ return &rte_eth_devices[port_id];
+}
+
+/**
+ * Return rte_eth_dev private data structure by port id
+ *
+ * This is to abstract device private data access and
+ * limit global variable access.
+ *
+ * @param port_id
+ * port_id of the device to return.
+ */
+static inline void *
+rte_eth_private_by_port(uint16_t port_id)
+{
+ return rte_eth_devices[port_id].data->dev_private;
+}
+
+/**
+ * Return rte_eth_dev private data structure by rte_eth_dev
+ *
+ * This is helper function to access device private data, also
+ * provides some abstraction on how private data kept.
+ *
+ * @param dev
+ * rte_eth_dev
+ */
+static inline void *
+rte_eth_private_by_dev(struct rte_eth_dev *dev)
+{
+ return dev->data->dev_private;
+}
+
#ifdef __cplusplus
}
#endif
--
2.5.0
next prev parent reply other threads:[~2016-02-17 14:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 14:20 [dpdk-dev] [PATCH 0/3] " Ferruh Yigit
2016-02-17 14:20 ` Ferruh Yigit [this message]
2016-02-17 14:20 ` [dpdk-dev] [PATCH 2/3] app/test: use ethdev helper functions Ferruh Yigit
2016-02-17 14:20 ` [dpdk-dev] [PATCH 3/3] bonding: " Ferruh Yigit
2016-03-10 0:00 ` [dpdk-dev] [PATCH 0/3] ethdev: add helper functions to get eth_dev and dev private data Thomas Monjalon
2016-03-10 13:37 ` Ferruh Yigit
2016-06-22 21:47 ` 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=1455718817-14171-2-git-send-email-ferruh.yigit@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).