DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pascal Mazon <pascal.mazon@6wind.com>
To: keith.wiles@intel.com
Cc: dev@dpdk.org, Pascal Mazon <pascal.mazon@6wind.com>
Subject: [dpdk-dev] [PATCH 1/2] net/tap: improve link_update
Date: Wed, 22 Mar 2017 09:40:00 +0100	[thread overview]
Message-ID: <fa9ce2ddc2cac000570b6ed58fa607e235992a3f.1490171928.git.pascal.mazon@6wind.com> (raw)

Reflect device link status according to the state of the tap netdevice
and the remote netdevice (if any). If both are UP and RUNNING, then the
device link status is set to ETH_LINK_UP, otherwise ETH_LINK_DOWN.

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
---
 drivers/net/tap/rte_eth_tap.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 1570aef297a0..54122fd13c66 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -443,6 +443,14 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,
 	 * If there is a remote netdevice, apply ioctl on it, then apply it on
 	 * the tap netdevice.
 	 */
+	if (request == SIOCGIFFLAGS && !set) {
+		/*
+		 * Special case for getting flags. If set is given,
+		 * then return the flags from the remote netdevice only.
+		 * Otherwise return the flags from the tap netdevice.
+		 */
+		remote = 0;
+	}
 apply:
 	if (remote)
 		snprintf(ifr->ifr_name, IFNAMSIZ, "%s", pmd->remote_iface);
@@ -458,6 +466,10 @@ tap_ioctl(struct pmd_internals *pmd, unsigned long request,
 		else
 			ifr->ifr_flags &= ~req_flags;
 		break;
+	case SIOCGIFFLAGS:
+		if (remote && set)
+			remote = 0; /* don't loop */
+		break;
 	case SIOCGIFHWADDR:
 		/* Set remote MAC on the tap netdevice */
 		if (!remote && pmd->remote_if_index) {
@@ -674,9 +686,25 @@ tap_tx_queue_release(void *queue)
 }
 
 static int
-tap_link_update(struct rte_eth_dev *dev __rte_unused,
-		int wait_to_complete __rte_unused)
+tap_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)
 {
+	struct rte_eth_link *dev_link = &dev->data->dev_link;
+	struct pmd_internals *pmd = dev->data->dev_private;
+	struct ifreq ifr = { .ifr_flags = 0 };
+
+	if (pmd->remote_if_index) {
+		tap_ioctl(pmd, SIOCGIFFLAGS, &ifr, 1);
+		if (!(ifr.ifr_flags & IFF_UP) ||
+		    !(ifr.ifr_flags & IFF_RUNNING)) {
+			dev_link->link_status = ETH_LINK_DOWN;
+			return 0;
+		}
+	}
+	tap_ioctl(pmd, SIOCGIFFLAGS, &ifr, 0);
+	dev_link->link_status =
+		((ifr.ifr_flags & IFF_UP) && (ifr.ifr_flags & IFF_RUNNING) ?
+		 ETH_LINK_UP :
+		 ETH_LINK_DOWN);
 	return 0;
 }
 
-- 
2.12.0.306.g4a9b9b3

             reply	other threads:[~2017-03-22  8:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22  8:40 Pascal Mazon [this message]
2017-03-22  8:40 ` [dpdk-dev] [PATCH 2/2] net/tap: add link status notification Pascal Mazon
2017-03-22 14:10   ` Wiles, Keith
2017-03-22 14:11 ` [dpdk-dev] [PATCH 1/2] net/tap: improve link_update Wiles, Keith
2017-03-24 16:02   ` Ferruh Yigit
2017-03-27  9:45     ` Pascal Mazon
2017-03-27 11:21       ` Ferruh Yigit
2017-03-27 11:34         ` Pascal Mazon

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=fa9ce2ddc2cac000570b6ed58fa607e235992a3f.1490171928.git.pascal.mazon@6wind.com \
    --to=pascal.mazon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.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).