ice: Enable link events over the ARQ
authorBrett Creeley <brett.creeley@intel.com>
Wed, 27 Feb 2019 00:35:23 +0000 (16:35 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Mon, 25 Mar 2019 14:54:44 +0000 (07:54 -0700)
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>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_common.c
drivers/net/ethernet/intel/ice/ice_common.h
drivers/net/ethernet/intel/ice/ice_main.c

index 06a1a2c..be67d07 100644 (file)
@@ -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)
 {
@@ -2151,6 +2151,32 @@ ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,
 }
 
 /**
+ * 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
  * @is_orig_mode: is this LED set to original mode (by the net-list)
index 38578f7..fbdfdee 100644 (file)
@@ -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);
 
index 4731b5d..d0ea4d0 100644 (file)
@@ -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
         */
@@ -711,6 +708,60 @@ static void ice_watchdog_subtask(struct ice_pf *pf)
 }
 
 /**
+ * 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
  * @q_type: specific Control queue type
@@ -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;