All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Awogbemila <awogbemila@google.com>
To: netdev@vger.kernel.org
Cc: Patricio Noyola <patricion@google.com>,
	Yangchun Fu <yangchun@google.com>,
	David Awogbemila <awogbemila@google.com>
Subject: [PATCH net-next v3 8/9] gve: Use link status register to report link status
Date: Tue,  8 Sep 2020 11:39:08 -0700	[thread overview]
Message-ID: <20200908183909.4156744-9-awogbemila@google.com> (raw)
In-Reply-To: <20200908183909.4156744-1-awogbemila@google.com>

From: Patricio Noyola <patricion@google.com>

This makes the driver better aware of the connectivity status of the
device. Based on the device's status register, the driver can call
netif_carrier_{on,off}.

Reviewed-by: Yangchun Fu <yangchun@google.com>
Signed-off-by: Patricio Noyola <patricion@google.com>
Signed-off-by: David Awogbemila <awogbemila@google.com>
---
 drivers/net/ethernet/google/gve/gve_main.c | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index ea35589ac0d6..271252d936dc 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -767,7 +767,7 @@ static int gve_open(struct net_device *dev)
 	gve_set_device_rings_ok(priv);
 
 	gve_turnup(priv);
-	netif_carrier_on(dev);
+	queue_work(priv->gve_wq, &priv->service_task);
 	priv->interface_up_cnt++;
 	return 0;
 
@@ -1024,16 +1024,34 @@ void gve_handle_report_stats(struct gve_priv *priv)
 	}
 }
 
+static void gve_handle_link_status(struct gve_priv *priv, bool link_status)
+{
+	if (!gve_get_napi_enabled(priv))
+		return;
+
+	if (link_status == netif_carrier_ok(priv->dev))
+		return;
+
+	if (link_status) {
+		dev_info(&priv->pdev->dev, "Device link is up.\n");
+		netif_carrier_on(priv->dev);
+	} else {
+		dev_info(&priv->pdev->dev, "Device link is down.\n");
+		netif_carrier_off(priv->dev);
+	}
+}
+
 /* Handle NIC status register changes, reset requests and report stats */
 static void gve_service_task(struct work_struct *work)
 {
 	struct gve_priv *priv = container_of(work, struct gve_priv,
 					     service_task);
+	u32 status = ioread32be(&priv->reg_bar0->device_status);
 
-	gve_handle_status(priv,
-			  ioread32be(&priv->reg_bar0->device_status));
+	gve_handle_status(priv, status);
 
 	gve_handle_reset(priv);
+	gve_handle_link_status(priv, GVE_DEVICE_STATUS_LINK_STATUS_MASK & status);
 	if (gve_get_do_report_stats(priv)) {
 		gve_handle_report_stats(priv);
 		gve_clear_do_report_stats(priv);
-- 
2.28.0.526.ge36021eeef-goog


  parent reply	other threads:[~2020-09-08 18:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 18:39 [PATCH net-next v3 0/9] Add GVE Features David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 1/9] gve: Get and set Rx copybreak via ethtool David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 2/9] gve: Add stats for gve David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 3/9] gve: Use dev_info/err instead of netif_info/err David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 4/9] gve: Add support for dma_mask register David Awogbemila
2020-09-08 19:14   ` Jakub Kicinski
2020-09-09 22:12     ` David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 5/9] gve: Add Gvnic stats AQ command and ethtool show/set-priv-flags David Awogbemila
2020-09-08 19:17   ` Jakub Kicinski
2020-09-08 19:24   ` Jakub Kicinski
2020-09-09 22:12     ` David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 6/9] gve: NIC stats for report-stats and for ethtool David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 7/9] gve: Batch AQ commands for creating and destroying queues David Awogbemila
2020-09-08 18:39 ` David Awogbemila [this message]
2020-09-08 19:27   ` [PATCH net-next v3 8/9] gve: Use link status register to report link status Jakub Kicinski
2020-09-09 22:12     ` David Awogbemila
2020-09-08 18:39 ` [PATCH net-next v3 9/9] gve: Enable Link Speed Reporting in the driver David Awogbemila

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=20200908183909.4156744-9-awogbemila@google.com \
    --to=awogbemila@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=patricion@google.com \
    --cc=yangchun@google.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 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.