netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuval Mintz <Yuval.Mintz@qlogic.com>
To: <netdev@vger.kernel.org>
Cc: <Ariel.Elior@qlogic.com>, <Yuval.Mintz@qlogic.com>,
	Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Subject: [PATCH v4 net-next 08/10] qede: Add support for link
Date: Wed, 7 Oct 2015 14:25:25 +0300	[thread overview]
Message-ID: <1444217127-17557-9-git-send-email-Yuval.Mintz@qlogic.com> (raw)
In-Reply-To: <1444217127-17557-1-git-send-email-Yuval.Mintz@qlogic.com>

From: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>

This adds basic link functionality to qede - driver still doesn't provide
users with an API to change any link property, but it does request qed to
initialize the link using default configuration, and registers a callback
that allows it to get link notifications.

This patch adds the ability of the driver to set the carrier as active and
to enable traffic as a result of async. link notifications.
Following this patch, driver should be capable of running traffic.

Signed-off-by: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: Ariel Elior <Ariel.Elior@qlogic.com>
---
 drivers/net/ethernet/qlogic/qede/qede_main.c | 47 ++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 7720571..f38a9d1 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -87,6 +87,7 @@ static int qede_probe(struct pci_dev *pdev, const struct pci_device_id *id);
 static void qede_remove(struct pci_dev *pdev);
 static int qede_alloc_rx_buffer(struct qede_dev *edev,
 				struct qede_rx_queue *rxq);
+static void qede_link_update(void *dev, struct qed_link_output *link);
 
 static struct pci_driver qede_pci_driver = {
 	.name = "qede",
@@ -95,6 +96,12 @@ static struct pci_driver qede_pci_driver = {
 	.remove = qede_remove,
 };
 
+static struct qed_eth_cb_ops qede_ll_ops = {
+	{
+		.link_update = qede_link_update,
+	},
+};
+
 static int qede_netdev_event(struct notifier_block *this, unsigned long event,
 			     void *ptr)
 {
@@ -1304,6 +1311,8 @@ static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level,
 
 	edev->ops->common->set_id(cdev, edev->ndev->name, DRV_MODULE_VERSION);
 
+	edev->ops->register_ops(cdev, &qede_ll_ops, edev);
+
 	INIT_DELAYED_WORK(&edev->sp_task, qede_sp_task);
 	mutex_init(&edev->qede_lock);
 
@@ -2088,6 +2097,7 @@ enum qede_unload_mode {
 
 static void qede_unload(struct qede_dev *edev, enum qede_unload_mode mode)
 {
+	struct qed_link_params link_params;
 	int rc;
 
 	DP_INFO(edev, "Starting qede unload\n");
@@ -2099,6 +2109,10 @@ static void qede_unload(struct qede_dev *edev, enum qede_unload_mode mode)
 	netif_tx_disable(edev->ndev);
 	netif_carrier_off(edev->ndev);
 
+	/* Reset the link */
+	memset(&link_params, 0, sizeof(link_params));
+	link_params.link_up = false;
+	edev->ops->common->set_link(edev->cdev, &link_params);
 	rc = qede_stop_queues(edev);
 	if (rc) {
 		qede_sync_free_irqs(edev);
@@ -2129,6 +2143,8 @@ enum qede_load_mode {
 
 static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
 {
+	struct qed_link_params link_params;
+	struct qed_link_output link_output;
 	int			rc;
 
 	DP_INFO(edev, "Starting qede load\n");
@@ -2172,6 +2188,17 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
 	mutex_lock(&edev->qede_lock);
 	edev->state = QEDE_STATE_OPEN;
 	mutex_unlock(&edev->qede_lock);
+
+	/* Ask for link-up using current configuration */
+	memset(&link_params, 0, sizeof(link_params));
+	link_params.link_up = true;
+	edev->ops->common->set_link(edev->cdev, &link_params);
+
+	/* Query whether link is already-up */
+	memset(&link_output, 0, sizeof(link_output));
+	edev->ops->common->get_link(edev->cdev, &link_output);
+	qede_link_update(edev, &link_output);
+
 	DP_INFO(edev, "Ending successfully qede load\n");
 
 	return 0;
@@ -2212,6 +2239,26 @@ static int qede_close(struct net_device *ndev)
 	return 0;
 }
 
+static void qede_link_update(void *dev, struct qed_link_output *link)
+{
+	struct qede_dev *edev = dev;
+
+	if (!netif_running(edev->ndev)) {
+		DP_VERBOSE(edev, NETIF_MSG_LINK, "Interface is not running\n");
+		return;
+	}
+
+	if (link->link_up) {
+		DP_NOTICE(edev, "Link is up\n");
+		netif_tx_start_all_queues(edev->ndev);
+		netif_carrier_on(edev->ndev);
+	} else {
+		DP_NOTICE(edev, "Link is down\n");
+		netif_tx_disable(edev->ndev);
+		netif_carrier_off(edev->ndev);
+	}
+}
+
 static int qede_set_mac_addr(struct net_device *ndev, void *p)
 {
 	struct qede_dev *edev = netdev_priv(ndev);
-- 
1.9.3

  parent reply	other threads:[~2015-10-07 11:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-07 11:25 [PATCH v4 net-next 00/10] Add new drivers: qed & qede Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 01/10] qed: Add module with basic common support Yuval Mintz
2015-10-10 13:24   ` David Miller
2015-10-10 14:18     ` Yuval Mintz
2015-10-11 11:16       ` David Miller
2015-10-07 11:25 ` [PATCH v4 net-next 02/10] qed: Add basic L2 interface Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 03/10] qede: Add basic Network driver Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 04/10] qed: Add slowpath L2 support Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 05/10] qede: Add basic network device support Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 06/10] qede: classification configuration Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 07/10] qed: Add link support Yuval Mintz
2015-10-07 11:25 ` Yuval Mintz [this message]
2015-10-07 11:25 ` [PATCH v4 net-next 09/10] qed: Add statistics support Yuval Mintz
2015-10-07 11:25 ` [PATCH v4 net-next 10/10] qede: Add basic ethtool support Yuval Mintz

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=1444217127-17557-9-git-send-email-Yuval.Mintz@qlogic.com \
    --to=yuval.mintz@qlogic.com \
    --cc=Ariel.Elior@qlogic.com \
    --cc=Sudarsana.Kalluru@qlogic.com \
    --cc=netdev@vger.kernel.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 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).