From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <shemming@brocade.com>
Subject: [dpdk-dev] [PATCH 2/6] Subjet: ethdev: add common code to atomicly access link
Date: Wed, 14 May 2014 11:55:29 -0700 [thread overview]
Message-ID: <20140514185743.414400480@networkplumber.org> (raw)
In-Reply-To: <20140514185527.771828962@networkplumber.org>
[-- Attachment #1: eth-dev-link.patch --]
[-- Type: text/plain, Size: 1419 bytes --]
Many drivers copy/paste same code to atomicly access link information.
Add functions to do this instead.
Signed-off-by: Stephen Hemminger <shemming@brocade.com>
--- a/lib/librte_ether/rte_ethdev.h 2014-05-14 11:27:07.409461720 -0700
+++ b/lib/librte_ether/rte_ethdev.h 2014-05-14 11:27:07.409461720 -0700
@@ -1704,6 +1704,45 @@ extern void rte_eth_link_get_nowait(uint
struct rte_eth_link *link);
/**
+ * @internal
+ * Retrieve the link status from device in atomic fashion.
+ */
+static inline void rte_eth_dev_get_link(struct rte_eth_dev *dev,
+ struct rte_eth_link *link)
+{
+ int64_t val;
+
+ val = rte_atomic64_read((rte_atomic64_t *)&dev->data->dev_link);
+
+ memcpy(link, &val, sizeof(struct rte_eth_link));
+}
+
+/**
+ * @internal
+ * Set the link status from device in atomic fashion.
+ * Returns non-zero on success; 0 on failure
+ * Callers should retry on failure
+ */
+static inline void rte_eth_dev_set_link(struct rte_eth_dev *dev,
+ struct rte_eth_link *link)
+{
+ rte_atomic64_t *dst = (rte_atomic64_t *)&dev->data->dev_link;
+
+ rte_atomic64_set(dst, *(int64_t *)link);
+}
+
+/**
+ * @internal
+ * Clear link status.
+ */
+static inline void rte_eth_dev_clear_link(struct rte_eth_dev *dev)
+{
+ rte_atomic64_t *dst = (rte_atomic64_t *)&dev->data->dev_link;
+
+ rte_atomic64_set(dst, 0);
+}
+
+/**
* Retrieve the general I/O statistics of an Ethernet device.
*
* @param port_id
next prev parent reply other threads:[~2014-05-14 18:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-14 18:55 [dpdk-dev] [PATCH 0/6] Ethernet driver enhancements Stephen Hemminger
2014-05-14 18:55 ` [dpdk-dev] [PATCH 1/6] Subjec: ethdev: add macro to cover all checksum flags Stephen Hemminger
2014-05-14 18:55 ` Stephen Hemminger [this message]
2014-05-15 8:43 ` [dpdk-dev] [PATCH 2/6] Subjet: ethdev: add common code to atomicly access link Ivan Boule
2014-05-14 18:55 ` [dpdk-dev] [PATCH 3/6] ixgbe: use eth_dev_{get,set}_link Stephen Hemminger
2014-05-14 18:55 ` [dpdk-dev] [PATCH 4/6] e1000: " Stephen Hemminger
2014-05-14 18:55 ` [dpdk-dev] [PATCH 5/6] ether: allow setting mac address Stephen Hemminger
2014-05-15 9:04 ` Ivan Boule
2014-05-21 15:24 ` Ivan Boule
2014-05-14 18:55 ` [dpdk-dev] [PATCH 6/6] vmxnet3: replace Intel driver Stephen Hemminger
2014-05-15 17:14 ` 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=20140514185743.414400480@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=shemming@brocade.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
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).