]> git.droids-corp.org - dpdk.git/commitdiff
net/i40e/base: add function to get FW LLDP agent status
authorXiaolong Ye <xiaolong.ye@intel.com>
Mon, 13 Jan 2020 02:39:23 +0000 (10:39 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:46:02 +0000 (19:46 +0100)
This change introduces i40e_get_fw_lldp_status() function capable of
reporting status of FW Link Layer Discovery Protocol (LLDP) agent.

Since reading LLDP configuration from NVM only gives information what
is the default state of FW LLDP agent after POR, this change introduces
more reliable method for checking if agent is enabled.

Current state of FW LLDP agent may be different if user disabled the
agent, so i40e_get_fw_lldp_status() uses LLDP MIB checking to determine
status of the agent.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/i40e/base/i40e_dcb.c
drivers/net/i40e/base/i40e_dcb.h

index 7cc8c83dc00b7ba35eba0bc85f524919ba40c8c8..f1465daa361ca3ac406fad7ee910108f86a442fb 100644 (file)
@@ -914,6 +914,49 @@ enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw, bool enable_mib_change)
        return ret;
 }
 
+/**
+ * i40e_get_fw_lldp_status
+ * @hw: pointer to the hw struct
+ * @lldp_status: pointer to the status enum
+ *
+ * Get status of FW Link Layer Discovery Protocol (LLDP) Agent.
+ * Status of agent is reported via @lldp_status parameter.
+ **/
+enum i40e_status_code
+i40e_get_fw_lldp_status(struct i40e_hw *hw,
+                       enum i40e_get_fw_lldp_status_resp *lldp_status)
+{
+       enum i40e_status_code ret;
+       struct i40e_virt_mem mem;
+       u8 *lldpmib;
+
+       if (!lldp_status)
+               return I40E_ERR_PARAM;
+
+       /* Allocate buffer for the LLDPDU */
+       ret = i40e_allocate_virt_mem(hw, &mem, I40E_LLDPDU_SIZE);
+       if (ret)
+               return ret;
+
+       lldpmib = (u8 *)mem.va;
+       ret = i40e_aq_get_lldp_mib(hw, 0, 0, (void *)lldpmib,
+                                  I40E_LLDPDU_SIZE, NULL, NULL, NULL);
+
+       if (ret == I40E_SUCCESS) {
+               *lldp_status = I40E_GET_FW_LLDP_STATUS_ENABLED;
+       } else if (hw->aq.asq_last_status == I40E_AQ_RC_ENOENT) {
+               /* MIB is not available yet but the agent is running */
+               *lldp_status = I40E_GET_FW_LLDP_STATUS_ENABLED;
+               ret = I40E_SUCCESS;
+       } else if (hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
+               *lldp_status = I40E_GET_FW_LLDP_STATUS_DISABLED;
+               ret = I40E_SUCCESS;
+       }
+
+       i40e_free_virt_mem(hw, &mem);
+       return ret;
+}
+
 /**
  * i40e_add_ieee_ets_tlv - Prepare ETS TLV in IEEE format
  * @tlv: Fill the ETS config data in IEEE format
index 2539433083f4b540d46507fff4de60a2d16670cb..88fe405d7beff311b07751935b1ca249cd9cbfcd 100644 (file)
@@ -178,6 +178,12 @@ struct i40e_dcbx_variables {
        u32 deftsaassignment;
 };
 
+
+enum i40e_get_fw_lldp_status_resp {
+       I40E_GET_FW_LLDP_STATUS_DISABLED = 0,
+       I40E_GET_FW_LLDP_STATUS_ENABLED = 1
+};
+
 enum i40e_status_code i40e_get_dcbx_status(struct i40e_hw *hw,
                                           u16 *status);
 enum i40e_status_code i40e_lldp_to_dcb_config(u8 *lldpmib,
@@ -188,6 +194,9 @@ enum i40e_status_code i40e_aq_get_dcb_config(struct i40e_hw *hw, u8 mib_type,
 enum i40e_status_code i40e_get_dcb_config(struct i40e_hw *hw);
 enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw,
                                    bool enable_mib_change);
+enum i40e_status_code
+i40e_get_fw_lldp_status(struct i40e_hw *hw,
+                       enum i40e_get_fw_lldp_status_resp *lldp_status);
 enum i40e_status_code i40e_set_dcb_config(struct i40e_hw *hw);
 enum i40e_status_code i40e_dcb_config_to_lldp(u8 *lldpmib, u16 *miblen,
                                              struct i40e_dcbx_config *dcbcfg);