All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Cc: Stephen Hemminger <shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH 3/6] ixgbe: use eth_dev_{get,set}_link
Date: Wed, 14 May 2014 11:55:30 -0700	[thread overview]
Message-ID: <20140514185745.171589218@networkplumber.org> (raw)
In-Reply-To: 20140514185527.771828962@networkplumber.org

[-- Attachment #1: ixgbe-dev-link.patch --]
[-- Type: text/plain, Size: 4145 bytes --]

New common code can be used, eliminating driver code.

Signed-off-by: Stephen Hemminger <shemming-43mecJUBy8ZBDgjK7y7TUQ@public.gmane.org>

--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c	2014-05-14 11:26:30.381274255 -0700
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c	2014-05-14 11:37:51.319893900 -0700
@@ -56,7 +56,6 @@
 #include <rte_alarm.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
-#include <rte_atomic.h>
 #include <rte_malloc.h>
 
 #include "ixgbe_logs.h"
@@ -325,58 +324,6 @@ static struct eth_dev_ops ixgbevf_eth_de
 	.tx_queue_release     = ixgbe_dev_tx_queue_release,
 };
 
-/**
- * Atomically reads the link status information from global
- * structure rte_eth_dev.
- *
- * @param dev
- *   - Pointer to the structure rte_eth_dev to read from.
- *   - Pointer to the buffer to be saved with the link status.
- *
- * @return
- *   - On success, zero.
- *   - On failure, negative value.
- */
-static inline int
-rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
-				struct rte_eth_link *link)
-{
-	struct rte_eth_link *dst = link;
-	struct rte_eth_link *src = &(dev->data->dev_link);
-
-	if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
-					*(uint64_t *)src) == 0)
-		return -1;
-
-	return 0;
-}
-
-/**
- * Atomically writes the link status information into global
- * structure rte_eth_dev.
- *
- * @param dev
- *   - Pointer to the structure rte_eth_dev to read from.
- *   - Pointer to the buffer to be saved with the link status.
- *
- * @return
- *   - On success, zero.
- *   - On failure, negative value.
- */
-static inline int
-rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
-				struct rte_eth_link *link)
-{
-	struct rte_eth_link *dst = &(dev->data->dev_link);
-	struct rte_eth_link *src = link;
-
-	if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
-					*(uint64_t *)src) == 0)
-		return -1;
-
-	return 0;
-}
-
 /*
  * This function is the same as ixgbe_is_sfp() in ixgbe/ixgbe.h.
  */
@@ -1453,7 +1400,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)
 
 	/* Clear recorded link status */
 	memset(&link, 0, sizeof(link));
-	rte_ixgbe_dev_atomic_write_link_status(dev, &link);
+	rte_eth_dev_set_link(dev, &link);
 }
 
 /*
@@ -1764,11 +1711,8 @@ ixgbe_dev_link_update(struct rte_eth_dev
 	int link_up;
 	int diag;
 
-	link.link_status = 0;
-	link.link_speed = 0;
-	link.link_duplex = 0;
-	memset(&old, 0, sizeof(old));
-	rte_ixgbe_dev_atomic_read_link_status(dev, &old);
+	memset(&link, 0, sizeof(link));
+	rte_eth_dev_get_link(dev, &old);
 
 	/* check if it needs to wait to complete, if lsc interrupt is enabled */
 	if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
@@ -1778,14 +1722,14 @@ ixgbe_dev_link_update(struct rte_eth_dev
 	if (diag != 0) {
 		link.link_speed = ETH_LINK_SPEED_100;
 		link.link_duplex = ETH_LINK_HALF_DUPLEX;
-		rte_ixgbe_dev_atomic_write_link_status(dev, &link);
+		rte_eth_dev_set_link(dev, &link);
 		if (link.link_status == old.link_status)
 			return -1;
 		return 0;
 	}
 
 	if (link_up == 0) {
-		rte_ixgbe_dev_atomic_write_link_status(dev, &link);
+		rte_eth_dev_set_link(dev, &link);
 		if (link.link_status == old.link_status)
 			return -1;
 		return 0;
@@ -1812,7 +1756,7 @@ ixgbe_dev_link_update(struct rte_eth_dev
 		link.link_speed = ETH_LINK_SPEED_10000;
 		break;
 	}
-	rte_ixgbe_dev_atomic_write_link_status(dev, &link);
+	rte_eth_dev_set_link(dev, &link);
 
 	if (link.link_status == old.link_status)
 		return -1;
@@ -1946,8 +1890,7 @@ ixgbe_dev_link_status_print(struct rte_e
 {
 	struct rte_eth_link link;
 
-	memset(&link, 0, sizeof(link));
-	rte_ixgbe_dev_atomic_read_link_status(dev, &link);
+	rte_eth_dev_get_link(dev, &link);
 	if (link.link_status) {
 		PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
 					(int)(dev->data->port_id),
@@ -1993,8 +1936,7 @@ ixgbe_dev_interrupt_action(struct rte_et
 
 	if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
 		/* get the link status before link update, for predicting later */
-		memset(&link, 0, sizeof(link));
-		rte_ixgbe_dev_atomic_read_link_status(dev, &link);
+		rte_eth_dev_get_link(dev, &link);
 
 		ixgbe_dev_link_update(dev, 0);
 

  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 ` [PATCH 2/6] Subjet: ethdev: add common code to atomicly access link Stephen Hemminger
     [not found]   ` <20140514185743.414400480-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
2014-05-15  8:43     ` Ivan Boule
2014-05-14 18:55 ` Stephen Hemminger [this message]
2014-05-14 18:55 ` [PATCH 4/6] e1000: use eth_dev_{get,set}_link 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=20140514185745.171589218@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.