net/i40e/base: add flags and fields for double VLAN
[dpdk.git] / drivers / net / i40e / base / i40e_dcb.c
index 7cc8c83..27b52bc 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2001-2018
+ * Copyright(c) 2001-2020 Intel Corporation
  */
 
 #include "i40e_adminq.h"
@@ -315,9 +315,15 @@ static void i40e_parse_cee_pgcfg_tlv(struct i40e_cee_feat_tlv *tlv,
         *        |pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7|
         *        ---------------------------------
         */
-       for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)
+       for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
                etscfg->tcbwtable[i] = buf[offset++];
 
+               if (etscfg->prioritytable[i] == I40E_CEE_PGID_STRICT)
+                       dcbcfg->etscfg.tsatable[i] = I40E_IEEE_TSA_STRICT;
+               else
+                       dcbcfg->etscfg.tsatable[i] = I40E_IEEE_TSA_ETS;
+       }
+
        /* Number of TCs supported (1 octet) */
        etscfg->maxtcs = buf[offset];
 }
@@ -877,7 +883,25 @@ enum i40e_status_code i40e_init_dcb(struct i40e_hw *hw, bool enable_mib_change)
                return I40E_NOT_SUPPORTED;
 
        /* Read LLDP NVM area */
-       ret = i40e_read_lldp_cfg(hw, &lldp_cfg);
+       if (hw->flags & I40E_HW_FLAG_FW_LLDP_PERSISTENT) {
+               u8 offset = 0;
+
+               if (hw->mac.type == I40E_MAC_XL710)
+                       offset = I40E_LLDP_CURRENT_STATUS_XL710_OFFSET;
+               else if (hw->mac.type == I40E_MAC_X722)
+                       offset = I40E_LLDP_CURRENT_STATUS_X722_OFFSET;
+               else
+                       return I40E_NOT_SUPPORTED;
+
+               ret = i40e_read_nvm_module_data(hw,
+                                               I40E_SR_EMP_SR_SETTINGS_PTR,
+                                               offset,
+                                               I40E_LLDP_CURRENT_STATUS_OFFSET,
+                                               I40E_LLDP_CURRENT_STATUS_SIZE,
+                                               &lldp_cfg.adminstatus);
+       } else {
+               ret = i40e_read_lldp_cfg(hw, &lldp_cfg);
+       }
        if (ret)
                return I40E_ERR_NOT_READY;
 
@@ -914,6 +938,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
@@ -1206,7 +1273,8 @@ enum i40e_status_code i40e_set_dcb_config(struct i40e_hw *hw)
 
 /**
  * i40e_dcb_config_to_lldp - Convert Dcbconfig to MIB format
- * @hw: pointer to the hw struct
+ * @lldpmib: pointer to mib to be output
+ * @miblen: pointer to u16 for length of lldpmib
  * @dcbcfg: store for LLDPDU data
  *
  * send DCB configuration to FW