All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH S13 v2 17/17] ice: Enable link events over the ARQ
Date: Tue, 26 Feb 2019 16:35:23 -0800	[thread overview]
Message-ID: <20190227003523.28733-18-anirudh.venkataramanan@intel.com> (raw)
In-Reply-To: <20190227003523.28733-1-anirudh.venkataramanan@intel.com>

From: Brett Creeley <brett.creeley@intel.com>

The hardware now supports link events over the admin receive queue (ARQ),
so enable HW link events over the ARQ and remove code for link event
polling.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Reviewed-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
---
[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> rewrote commit message]
---
 drivers/net/ethernet/intel/ice/ice_common.c | 28 +++++++++++-
 drivers/net/ethernet/intel/ice/ice_common.h |  6 +++
 drivers/net/ethernet/intel/ice/ice_main.c   | 68 +++++++++++++++++++++++++++--
 3 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 06a1a2cb5358..be67d07b75cb 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -262,7 +262,7 @@ static enum ice_media_type ice_get_media_type(struct ice_port_info *pi)
  *
  * Get Link Status (0x607). Returns the link status of the adapter.
  */
-static enum ice_status
+enum ice_status
 ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
 		     struct ice_link_status *link, struct ice_sq_cd *cd)
 {
@@ -2150,6 +2150,32 @@ ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
 	return ice_aq_send_cmd(pi->hw, &desc, NULL, 0, cd);
 }
 
+/**
+ * ice_aq_set_event_mask
+ * @hw: pointer to the HW struct
+ * @port_num: port number of the physical function
+ * @mask: event mask to be set
+ * @cd: pointer to command details structure or NULL
+ *
+ * Set event mask (0x0613)
+ */
+enum ice_status
+ice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
+		      struct ice_sq_cd *cd)
+{
+	struct ice_aqc_set_event_mask *cmd;
+	struct ice_aq_desc desc;
+
+	cmd = &desc.params.set_event_mask;
+
+	ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_event_mask);
+
+	cmd->lport_num = port_num;
+
+	cmd->event_mask = cpu_to_le16(mask);
+	return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
+}
+
 /**
  * ice_aq_set_port_id_led
  * @pi: pointer to the port information
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index 38578f7c3622..fbdfdee353bc 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -89,6 +89,12 @@ enum ice_status
 ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
 			   struct ice_sq_cd *cd);
 enum ice_status
+ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,
+		     struct ice_link_status *link, struct ice_sq_cd *cd);
+enum ice_status
+ice_aq_set_event_mask(struct ice_hw *hw, u8 port_num, u16 mask,
+		      struct ice_sq_cd *cd);
+enum ice_status
 ice_aq_set_port_id_led(struct ice_port_info *pi, bool is_orig_mode,
 		       struct ice_sq_cd *cd);
 
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 4731b5d147b7..d0ea4d059a05 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -698,9 +698,6 @@ static void ice_watchdog_subtask(struct ice_pf *pf)
 
 	pf->serv_tmr_prev = jiffies;
 
-	if (ice_link_event(pf, pf->hw.port_info))
-		dev_dbg(&pf->pdev->dev, "ice_link_event failed\n");
-
 	/* Update the stats for active netdevs so the network stack
 	 * can look at updated numbers whenever it cares to
 	 */
@@ -710,6 +707,60 @@ static void ice_watchdog_subtask(struct ice_pf *pf)
 			ice_update_vsi_stats(pf->vsi[i]);
 }
 
+/**
+ * ice_init_link_events - enable/initialize link events
+ * @pi: pointer to the port_info instance
+ *
+ * Returns -EIO on failure, 0 on success
+ */
+static int ice_init_link_events(struct ice_port_info *pi)
+{
+	u16 mask;
+
+	mask = ~((u16)(ICE_AQ_LINK_EVENT_UPDOWN | ICE_AQ_LINK_EVENT_MEDIA_NA |
+		       ICE_AQ_LINK_EVENT_MODULE_QUAL_FAIL));
+
+	if (ice_aq_set_event_mask(pi->hw, pi->lport, mask, NULL)) {
+		dev_dbg(ice_hw_to_dev(pi->hw),
+			"Failed to set link event mask for port %d\n",
+			pi->lport);
+		return -EIO;
+	}
+
+	if (ice_aq_get_link_info(pi, true, NULL, NULL)) {
+		dev_dbg(ice_hw_to_dev(pi->hw),
+			"Failed to enable link events for port %d\n",
+			pi->lport);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_handle_link_event - handle link event via ARQ
+ * @pf: pf that the link event is associated with
+ *
+ * Return -EINVAL if port_info is null
+ * Return status on success
+ */
+static int ice_handle_link_event(struct ice_pf *pf)
+{
+	struct ice_port_info *port_info;
+	int status;
+
+	port_info = pf->hw.port_info;
+	if (!port_info)
+		return -EINVAL;
+
+	status = ice_link_event(pf, port_info);
+	if (status)
+		dev_dbg(&pf->pdev->dev,
+			"Could not process link event, error %d\n", status);
+
+	return status;
+}
+
 /**
  * __ice_clean_ctrlq - helper function to clean controlq rings
  * @pf: ptr to struct ice_pf
@@ -813,6 +864,11 @@ static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type)
 		opcode = le16_to_cpu(event.desc.opcode);
 
 		switch (opcode) {
+		case ice_aqc_opc_get_link_status:
+			if (ice_handle_link_event(pf))
+				dev_err(&pf->pdev->dev,
+					"Could not handle link event\n");
+			break;
 		case ice_mbx_opc_send_msg_to_pf:
 			ice_vc_process_vf_msg(pf, &event);
 			break;
@@ -2267,6 +2323,12 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	/* since everything is good, start the service timer */
 	mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period));
 
+	err = ice_init_link_events(pf->hw.port_info);
+	if (err) {
+		dev_err(dev, "ice_init_link_events failed: %d\n", err);
+		goto err_alloc_sw_unroll;
+	}
+
 	ice_verify_cacheline_size(pf);
 
 	return 0;
-- 
2.14.5


  parent reply	other threads:[~2019-02-27  0:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27  0:35 [Intel-wired-lan] [PATCH S13 v2 00/17] Bug fixes and minor feature updates for ice Anirudh Venkataramanan
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 01/17] ice: fix static analysis warnings Anirudh Venkataramanan
2019-02-28 23:54   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 02/17] ice: Remove unused function prototype Anirudh Venkataramanan
2019-02-28 23:50   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 03/17] ice: Fix issue reconfiguring VF queues Anirudh Venkataramanan
2019-03-08  0:49   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 04/17] ice: fix the divide by zero issue Anirudh Venkataramanan
2019-02-28 23:08   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 05/17] ice: fix some function prototype and signature style issues Anirudh Venkataramanan
2019-02-28 23:53   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 06/17] ice: Remove unused vsi_id field Anirudh Venkataramanan
2019-02-28 23:52   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 07/17] ice: code cleanup in ice_sched.c Anirudh Venkataramanan
2019-02-28 23:53   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 08/17] ice: Add support for PF/VF promiscuous mode Anirudh Venkataramanan
2019-03-08  0:50   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 09/17] ice: Enable LAN_EN for the right recipes Anirudh Venkataramanan
2019-03-08  0:50   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 10/17] ice: Do not set LB_EN for prune switch rules Anirudh Venkataramanan
2019-03-08  0:51   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 11/17] ice: Set LAN_EN for all directional rules Anirudh Venkataramanan
2019-03-08  0:53   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 12/17] ice: Don't let VF know that it is untrusted Anirudh Venkataramanan
2019-03-01 23:55   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 13/17] ice: Get VF VSI instances directly via PF Anirudh Venkataramanan
2019-03-08  0:52   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 14/17] ice: update VSI config dynamically Anirudh Venkataramanan
2019-03-08  0:52   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 15/17] ice: Restore VLAN switch rule if port VLAN existed before Anirudh Venkataramanan
2019-03-04 18:43   ` Bowers, AndrewX
2019-02-27  0:35 ` [Intel-wired-lan] [PATCH S13 v2 16/17] ice: use irq_num var in ice_vsi_req_irq_msix Anirudh Venkataramanan
2019-02-28 23:07   ` Bowers, AndrewX
2019-02-27  0:35 ` Anirudh Venkataramanan [this message]
2019-03-08  0:51   ` [Intel-wired-lan] [PATCH S13 v2 17/17] ice: Enable link events over the ARQ Bowers, AndrewX

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=20190227003523.28733-18-anirudh.venkataramanan@intel.com \
    --to=anirudh.venkataramanan@intel.com \
    --cc=intel-wired-lan@osuosl.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.