net/i40e/base: decouple MIB change event from DCB init
authorXiaolong Ye <xiaolong.ye@intel.com>
Mon, 13 Jan 2020 02:39:16 +0000 (10:39 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:46:02 +0000 (19:46 +0100)
There is a need to enable MIB change event, not at the same time as
init_dcb. This patch will serve this requirement.

Modify the i40e_init_dcb to return the correct error when LLDP or DCBX
is not in operational state.

Signed-off-by: Chinh T Cao <chinh.t.cao@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
drivers/net/i40e/i40e_ethdev.c

index a26f82b..7cc8c83 100644 (file)
@@ -863,22 +863,23 @@ out:
 /**
  * i40e_init_dcb
  * @hw: pointer to the hw struct
+ * @enable_mib_change: enable mib change event
  *
  * Update DCB configuration from the Firmware
  **/
-enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw)
+enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw, bool enable_mib_change)
 {
        enum i40e_status_code ret = I40E_SUCCESS;
        struct i40e_lldp_variables lldp_cfg;
        u8 adminstatus = 0;
 
        if (!hw->func_caps.dcb)
-               return ret;
+               return I40E_NOT_SUPPORTED;
 
        /* Read LLDP NVM area */
        ret = i40e_read_lldp_cfg(hw, &lldp_cfg);
        if (ret)
-               return ret;
+               return I40E_ERR_NOT_READY;
 
        /* Get the LLDP AdminStatus for the current port */
        adminstatus = lldp_cfg.adminstatus >> (hw->port * 4);
@@ -887,7 +888,7 @@ enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw)
        /* LLDP agent disabled */
        if (!adminstatus) {
                hw->dcbx_status = I40E_DCBX_STATUS_DISABLED;
-               return ret;
+               return I40E_ERR_NOT_READY;
        }
 
        /* Get DCBX status */
@@ -896,26 +897,19 @@ enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw)
                return ret;
 
        /* Check the DCBX Status */
-       switch (hw->dcbx_status) {
-       case I40E_DCBX_STATUS_DONE:
-       case I40E_DCBX_STATUS_IN_PROGRESS:
+       if (hw->dcbx_status == I40E_DCBX_STATUS_DONE ||
+           hw->dcbx_status == I40E_DCBX_STATUS_IN_PROGRESS) {
                /* Get current DCBX configuration */
                ret = i40e_get_dcb_config(hw);
                if (ret)
                        return ret;
-               break;
-       case I40E_DCBX_STATUS_DISABLED:
-               return ret;
-       case I40E_DCBX_STATUS_NOT_STARTED:
-       case I40E_DCBX_STATUS_MULTIPLE_PEERS:
-       default:
-               break;
+       } else if (hw->dcbx_status == I40E_DCBX_STATUS_DISABLED) {
+               return I40E_ERR_NOT_READY;
        }
 
        /* Configure the LLDP MIB change event */
-       ret = i40e_aq_cfg_lldp_mib_change_event(hw, true, NULL);
-       if (ret)
-               return ret;
+       if (enable_mib_change)
+               ret = i40e_aq_cfg_lldp_mib_change_event(hw, true, NULL);
 
        return ret;
 }
index 85b0eed..2539433 100644 (file)
@@ -186,7 +186,8 @@ enum i40e_status_code i40e_aq_get_dcb_config(struct i40e_hw *hw, u8 mib_type,
                                             u8 bridgetype,
                                             struct i40e_dcbx_config *dcbcfg);
 enum i40e_status_code i40e_get_dcb_config(struct i40e_hw *hw);
-enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw);
+enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw,
+                                   bool enable_mib_change);
 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);
index 86fc4f4..d636587 100644 (file)
@@ -11579,7 +11579,7 @@ i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb)
                                PMD_INIT_LOG(DEBUG, "Failed to stop lldp");
                }
 
-               ret = i40e_init_dcb(hw);
+               ret = i40e_init_dcb(hw, true);
                /* If lldp agent is stopped, the return value from
                 * i40e_init_dcb we expect is failure with I40E_AQ_RC_EPERM
                 * adminq status. Otherwise, it should return success.
@@ -11627,7 +11627,7 @@ i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb)
                if (ret != I40E_SUCCESS)
                        PMD_INIT_LOG(DEBUG, "Failed to start lldp");
 
-               ret = i40e_init_dcb(hw);
+               ret = i40e_init_dcb(hw, true);
                if (!ret) {
                        if (hw->dcbx_status == I40E_DCBX_STATUS_DISABLED) {
                                PMD_INIT_LOG(ERR,