i40e/i40evf: Add new HW link info variable an_enabled and function update_link_info
authorCatherine Sullivan <catherine.sullivan@intel.com>
Wed, 4 Jun 2014 08:45:24 +0000 (08:45 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 3 Jul 2014 02:02:21 +0000 (19:02 -0700)
Add a new variable, hw.phy.link_info.an_enabled, to track whether autoneg is
enabled.  Also add a new function update_link_info that will update that
variable as well as calling get_link_info to update the rest of the link info.
Also add get_phy_capabilities to support this.

Change-ID: I5157ef03492b6dd8ec5e608ba0cf9b0db9c01710
Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_common.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40e/i40e_prototype.h
drivers/net/ethernet/intel/i40e/i40e_type.h
drivers/net/ethernet/intel/i40evf/i40e_type.h

index 9d09ab31ec89ef49f605436c4ba4dcf31770dc11..debca01e684f3b618a6dc1114cd23d707f718b55 100644 (file)
@@ -1036,6 +1036,52 @@ void i40e_led_set(struct i40e_hw *hw, u32 mode, bool blink)
 
 /* Admin command wrappers */
 
+/**
+ * i40e_aq_get_phy_capabilities
+ * @hw: pointer to the hw struct
+ * @abilities: structure for PHY capabilities to be filled
+ * @qualified_modules: report Qualified Modules
+ * @report_init: report init capabilities (active are default)
+ * @cmd_details: pointer to command details structure or NULL
+ *
+ * Returns the various PHY abilities supported on the Port.
+ **/
+i40e_status i40e_aq_get_phy_capabilities(struct i40e_hw *hw,
+                       bool qualified_modules, bool report_init,
+                       struct i40e_aq_get_phy_abilities_resp *abilities,
+                       struct i40e_asq_cmd_details *cmd_details)
+{
+       struct i40e_aq_desc desc;
+       i40e_status status;
+       u16 abilities_size = sizeof(struct i40e_aq_get_phy_abilities_resp);
+
+       if (!abilities)
+               return I40E_ERR_PARAM;
+
+       i40e_fill_default_direct_cmd_desc(&desc,
+                                         i40e_aqc_opc_get_phy_abilities);
+
+       desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
+       if (abilities_size > I40E_AQ_LARGE_BUF)
+               desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
+
+       if (qualified_modules)
+               desc.params.external.param0 |=
+                       cpu_to_le32(I40E_AQ_PHY_REPORT_QUALIFIED_MODULES);
+
+       if (report_init)
+               desc.params.external.param0 |=
+                       cpu_to_le32(I40E_AQ_PHY_REPORT_INITIAL_VALUES);
+
+       status = i40e_asq_send_command(hw, &desc, abilities, abilities_size,
+                                      cmd_details);
+
+       if (hw->aq.asq_last_status == I40E_AQ_RC_EIO)
+               status = I40E_ERR_UNKNOWN_PHY;
+
+       return status;
+}
+
 /**
  * i40e_aq_clear_pxe_mode
  * @hw: pointer to the hw struct
@@ -1162,6 +1208,35 @@ aq_get_link_info_exit:
        return status;
 }
 
+/**
+ * i40e_update_link_info
+ * @hw: pointer to the hw struct
+ * @enable_lse: enable/disable LinkStatusEvent reporting
+ *
+ * Returns the link status of the adapter
+ **/
+i40e_status i40e_update_link_info(struct i40e_hw *hw, bool enable_lse)
+{
+       struct i40e_aq_get_phy_abilities_resp abilities;
+       i40e_status status;
+
+       status = i40e_aq_get_link_info(hw, enable_lse, NULL, NULL);
+       if (status)
+               return status;
+
+       status = i40e_aq_get_phy_capabilities(hw, false, false,
+                                             &abilities, NULL);
+       if (status)
+               return status;
+
+       if (abilities.abilities & I40E_AQ_PHY_AN_ENABLED)
+               hw->phy.link_info.an_enabled = true;
+       else
+               hw->phy.link_info.an_enabled = false;
+
+       return status;
+}
+
 /**
  * i40e_aq_add_vsi
  * @hw: pointer to the hw struct
index ac90d5f40652c90c2e768ddffad0f92e49128442..71eff167677841ab1a46f1cbbdfce23a585bef0e 100644 (file)
@@ -5292,7 +5292,7 @@ static void i40e_handle_link_event(struct i40e_pf *pf,
         * then see if the status changed while processing the
         * initial event.
         */
-       i40e_aq_get_link_info(&pf->hw, true, NULL, NULL);
+       i40e_update_link_info(&pf->hw, true);
        i40e_link_event(pf);
 }
 
@@ -8337,7 +8337,7 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
                i40e_config_rss(pf);
 
        /* fill in link information and enable LSE reporting */
-       i40e_aq_get_link_info(&pf->hw, true, NULL, NULL);
+       i40e_update_link_info(&pf->hw, true);
        i40e_link_event(pf);
 
        /* Initialize user-specific link properties */
index 77c515d026be9a2af32c44cedf396e6929aaf506..679087867bd28e48f2ceb5d08ff5f5a22cdd5330 100644 (file)
@@ -82,6 +82,7 @@ i40e_status i40e_aq_set_link_restart_an(struct i40e_hw *hw,
 i40e_status i40e_aq_get_link_info(struct i40e_hw *hw,
                                bool enable_lse, struct i40e_link_status *link,
                                struct i40e_asq_cmd_details *cmd_details);
+i40e_status i40e_update_link_info(struct i40e_hw *hw, bool enable_lse);
 i40e_status i40e_aq_set_local_advt_reg(struct i40e_hw *hw,
                                u64 advt_reg,
                                struct i40e_asq_cmd_details *cmd_details);
index 11dd2dcfb59271fb8840ba94a1089c504de87332..f1c58ab8f60d56598e0a9c3988b2d2315836d326 100644 (file)
@@ -166,6 +166,7 @@ struct i40e_link_status {
        u8 an_info;
        u8 ext_info;
        u8 loopback;
+       bool an_enabled;
        /* is Link Status Event notification to SW enabled */
        bool lse_enable;
        u16 max_frame_size;
index 23cd18b66b714dcc7b14e9b824758478b6fbeb42..5b6e955cfc6658d6a36bb31723653f804ce838ce 100644 (file)
@@ -166,6 +166,7 @@ struct i40e_link_status {
        u8 an_info;
        u8 ext_info;
        u8 loopback;
+       bool an_enabled;
        /* is Link Status Event notification to SW enabled */
        bool lse_enable;
        u16 max_frame_size;