From: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Cc: Stephen Hemminger <shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.org>
Subject: [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: 1447 bytes --]
Many drivers copy/paste same code to atomicly access link information.
Add functions to do this instead.
Signed-off-by: Stephen Hemminger <shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.org>
--- 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:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-14 18:55 [PATCH 0/6] Ethernet driver enhancements Stephen Hemminger
2014-05-14 18:55 ` [PATCH 1/6] Subjec: ethdev: add macro to cover all checksum flags Stephen Hemminger
2014-05-14 18:55 ` Stephen Hemminger [this message]
[not found] ` <20140514185743.414400480-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-05-15 8:43 ` [PATCH 2/6] Subjet: ethdev: add common code to atomicly access link Ivan Boule
2014-05-14 18:55 ` [PATCH 3/6] ixgbe: use eth_dev_{get,set}_link Stephen Hemminger
2014-05-14 18:55 ` [PATCH 4/6] e1000: " Stephen Hemminger
2014-05-14 18:55 ` [PATCH 5/6] ether: allow setting mac address Stephen Hemminger
[not found] ` <20140514185750.257523699-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-05-15 9:04 ` Ivan Boule
[not found] ` <CAOm6c7qumb3xHT4K0QXzyPBbfXsWTeZLp4pxAKoJT6Dh+VpiHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-21 15:24 ` Ivan Boule
2014-05-14 18:55 ` [PATCH 6/6] vmxnet3: replace Intel driver Stephen Hemminger
[not found] ` <20140514185752.176396147-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
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-otpzqlsittunbdjkjebofr2eb7je58tq@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
--cc=shemming-43mecJUBy8ZBDgjK7y7TUQ@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.