net/ice/base: add method to disable FDIR swap option
[dpdk.git] / drivers / net / ice / base / ice_common.c
index 2447d15..ae55beb 100644 (file)
@@ -200,6 +200,31 @@ bool ice_is_e810(struct ice_hw *hw)
        return hw->mac_type == ICE_MAC_E810;
 }
 
+/**
+ * ice_is_e810t
+ * @hw: pointer to the hardware structure
+ *
+ * returns true if the device is E810T based, false if not.
+ */
+bool ice_is_e810t(struct ice_hw *hw)
+{
+       switch (hw->device_id) {
+       case ICE_DEV_ID_E810C_SFP:
+               if (hw->subsystem_device_id == ICE_SUBDEV_ID_E810T ||
+                   hw->subsystem_device_id == ICE_SUBDEV_ID_E810T2)
+                       return true;
+               break;
+       case ICE_DEV_ID_E810C_QSFP:
+               if (hw->subsystem_device_id == ICE_SUBDEV_ID_E810T2)
+                       return true;
+               break;
+       default:
+               break;
+       }
+
+       return false;
+}
+
 /**
  * ice_clear_pf_cfg - Clear PF configuration
  * @hw: pointer to the hardware structure
@@ -852,6 +877,17 @@ void ice_print_rollback_msg(struct ice_hw *hw)
                 nvm_str, hw->fw_maj_ver, hw->fw_min_ver);
 }
 
+/**
+ * ice_set_umac_shared
+ * @hw: pointer to the hw struct
+ *
+ * Set boolean flag to allow unicast MAC sharing
+ */
+void ice_set_umac_shared(struct ice_hw *hw)
+{
+       hw->umac_shared = true;
+}
+
 /**
  * ice_init_hw - main hardware initialization routine
  * @hw: pointer to the hardware structure
@@ -982,6 +1018,12 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
 
        if (status)
                goto err_unroll_fltr_mgmt_struct;
+
+       /* enable jumbo frame support at MAC level */
+       status = ice_aq_set_mac_cfg(hw, ICE_AQ_SET_MAC_FRAME_SIZE_MAX, NULL);
+       if (status)
+               goto err_unroll_fltr_mgmt_struct;
+
        /* Obtain counter base index which would be used by flow director */
        status = ice_alloc_fd_res_cntr(hw, &hw->fd_ctr_base);
        if (status)
@@ -1315,6 +1357,7 @@ const struct ice_ctx_ele ice_tlan_ctx_info[] = {
        ICE_CTX_STORE(ice_tlan_ctx, cache_prof_idx,             2,      166),
        ICE_CTX_STORE(ice_tlan_ctx, pkt_shaper_prof_idx,        3,      168),
        ICE_CTX_STORE(ice_tlan_ctx, int_q_state,                122,    171),
+       ICE_CTX_STORE(ice_tlan_ctx, gsc_ena,                    1,      172),
        { 0 }
 };
 
@@ -2269,6 +2312,18 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,
                ice_debug(hw, ICE_DBG_INIT, "%s: max_mtu = %d\n",
                          prefix, caps->max_mtu);
                break;
+       case ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE:
+               caps->pcie_reset_avoidance = (number > 0);
+               ice_debug(hw, ICE_DBG_INIT,
+                         "%s: pcie_reset_avoidance = %d\n", prefix,
+                         caps->pcie_reset_avoidance);
+               break;
+       case ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT:
+               caps->reset_restrict_support = (number == 1);
+               ice_debug(hw, ICE_DBG_INIT,
+                         "%s: reset_restrict_support = %d\n", prefix,
+                         caps->reset_restrict_support);
+               break;
        case ICE_AQC_CAPS_EXT_TOPO_DEV_IMG0:
        case ICE_AQC_CAPS_EXT_TOPO_DEV_IMG1:
        case ICE_AQC_CAPS_EXT_TOPO_DEV_IMG2:
@@ -2494,6 +2549,23 @@ ice_parse_func_caps(struct ice_hw *hw, struct ice_hw_func_caps *func_p,
        ice_recalc_port_limited_caps(hw, &func_p->common_cap);
 }
 
+/**
+ * ice_func_id_to_logical_id - map from function id to logical pf id
+ * @active_function_bitmap: active function bitmap
+ * @pf_id: function number of device
+ */
+static int ice_func_id_to_logical_id(u32 active_function_bitmap, u8 pf_id)
+{
+       u8 logical_id = 0;
+       u8 i;
+
+       for (i = 0; i < pf_id; i++)
+               if (active_function_bitmap & BIT(i))
+                       logical_id++;
+
+       return logical_id;
+}
+
 /**
  * ice_parse_valid_functions_cap - Parse ICE_AQC_CAPS_VALID_FUNCTIONS caps
  * @hw: pointer to the HW struct
@@ -2511,6 +2583,8 @@ ice_parse_valid_functions_cap(struct ice_hw *hw, struct ice_hw_dev_caps *dev_p,
        dev_p->num_funcs = ice_hweight32(number);
        ice_debug(hw, ICE_DBG_INIT, "dev caps: num_funcs = %d\n",
                  dev_p->num_funcs);
+
+       hw->logical_pf_id = ice_func_id_to_logical_id(number, hw->pf_id);
 }
 
 /**
@@ -2938,6 +3012,28 @@ ice_aq_set_port_params(struct ice_port_info *pi, u16 bad_frame_vsi,
        return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
 }
 
+/**
+ * ice_is_100m_speed_supported
+ * @hw: pointer to the HW struct
+ *
+ * returns true if 100M speeds are supported by the device,
+ * false otherwise.
+ */
+bool ice_is_100m_speed_supported(struct ice_hw *hw)
+{
+       switch (hw->device_id) {
+       case ICE_DEV_ID_E822C_10G_BASE_T:
+       case ICE_DEV_ID_E822C_SGMII:
+       case ICE_DEV_ID_E822L_10G_BASE_T:
+       case ICE_DEV_ID_E822L_SGMII:
+       case ICE_DEV_ID_E823L_10G_BASE_T:
+       case ICE_DEV_ID_E823L_1GBE:
+               return true;
+       default:
+               return false;
+       }
+}
+
 /**
  * ice_get_link_speed_based_on_phy_type - returns link speed
  * @phy_type_low: lower part of phy_type
@@ -3487,7 +3583,7 @@ ice_phy_caps_equals_cfg(struct ice_aqc_get_phy_caps_data *phy_caps,
 /**
  * ice_copy_phy_caps_to_cfg - Copy PHY ability data to configuration data
  * @pi: port information structure
- * @caps: PHY ability structure to copy date from
+ * @caps: PHY ability structure to copy data from
  * @cfg: PHY configuration structure to copy data to
  *
  * Helper function to copy AQC PHY get ability data to PHY set configuration
@@ -4505,6 +4601,56 @@ ice_set_ctx(struct ice_hw *hw, u8 *src_ctx, u8 *dest_ctx,
        return ICE_SUCCESS;
 }
 
+/**
+ * ice_aq_get_internal_data
+ * @hw: pointer to the hardware structure
+ * @cluster_id: specific cluster to dump
+ * @table_id: table ID within cluster
+ * @start: index of line in the block to read
+ * @buf: dump buffer
+ * @buf_size: dump buffer size
+ * @ret_buf_size: return buffer size (returned by FW)
+ * @ret_next_table: next block to read (returned by FW)
+ * @ret_next_index: next index to read (returned by FW)
+ * @cd: pointer to command details structure
+ *
+ * Get internal FW/HW data (0xFF08) for debug purposes.
+ */
+enum ice_status
+ice_aq_get_internal_data(struct ice_hw *hw, u8 cluster_id, u16 table_id,
+                        u32 start, void *buf, u16 buf_size, u16 *ret_buf_size,
+                        u16 *ret_next_table, u32 *ret_next_index,
+                        struct ice_sq_cd *cd)
+{
+       struct ice_aqc_debug_dump_internals *cmd;
+       struct ice_aq_desc desc;
+       enum ice_status status;
+
+       cmd = &desc.params.debug_dump;
+
+       if (buf_size == 0 || !buf)
+               return ICE_ERR_PARAM;
+
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_debug_dump_internals);
+
+       cmd->cluster_id = cluster_id;
+       cmd->table_id = CPU_TO_LE16(table_id);
+       cmd->idx = CPU_TO_LE32(start);
+
+       status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
+
+       if (!status) {
+               if (ret_buf_size)
+                       *ret_buf_size = LE16_TO_CPU(desc.datalen);
+               if (ret_next_table)
+                       *ret_next_table = LE16_TO_CPU(cmd->table_id);
+               if (ret_next_index)
+                       *ret_next_index = LE32_TO_CPU(cmd->idx);
+       }
+
+       return status;
+}
+
 /**
  * ice_read_byte - read context byte into struct
  * @src_ctx:  the context structure to read from
@@ -5007,7 +5153,7 @@ static bool ice_is_main_vsi(struct ice_hw *hw, u16 vsi_handle)
  *
  * Initializes required config data for VSI, FD, ACL, and RSS before replay.
  */
-static enum ice_status
+enum ice_status
 ice_replay_pre_init(struct ice_hw *hw, struct ice_switch_info *sw)
 {
        enum ice_status status;
@@ -5348,6 +5494,81 @@ ice_aq_write_i2c(struct ice_hw *hw, struct ice_aqc_link_topo_addr topo_addr,
        return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
 }
 
+/**
+ * ice_aq_set_driver_param - Set driver parameter to share via firmware
+ * @hw: pointer to the HW struct
+ * @idx: parameter index to set
+ * @value: the value to set the parameter to
+ * @cd: pointer to command details structure or NULL
+ *
+ * Set the value of one of the software defined parameters. All PFs connected
+ * to this device can read the value using ice_aq_get_driver_param.
+ *
+ * Note that firmware provides no synchronization or locking, and will not
+ * save the parameter value during a device reset. It is expected that
+ * a single PF will write the parameter value, while all other PFs will only
+ * read it.
+ */
+enum ice_status
+ice_aq_set_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
+                       u32 value, struct ice_sq_cd *cd)
+{
+       struct ice_aqc_driver_shared_params *cmd;
+       struct ice_aq_desc desc;
+
+       if (idx >= ICE_AQC_DRIVER_PARAM_MAX)
+               return ICE_ERR_OUT_OF_RANGE;
+
+       cmd = &desc.params.drv_shared_params;
+
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_driver_shared_params);
+
+       cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_SET;
+       cmd->param_indx = idx;
+       cmd->param_val = CPU_TO_LE32(value);
+
+       return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
+}
+
+/**
+ * ice_aq_get_driver_param - Get driver parameter shared via firmware
+ * @hw: pointer to the HW struct
+ * @idx: parameter index to set
+ * @value: storage to return the shared parameter
+ * @cd: pointer to command details structure or NULL
+ *
+ * Get the value of one of the software defined parameters.
+ *
+ * Note that firmware provides no synchronization or locking. It is expected
+ * that only a single PF will write a given parameter.
+ */
+enum ice_status
+ice_aq_get_driver_param(struct ice_hw *hw, enum ice_aqc_driver_params idx,
+                       u32 *value, struct ice_sq_cd *cd)
+{
+       struct ice_aqc_driver_shared_params *cmd;
+       struct ice_aq_desc desc;
+       enum ice_status status;
+
+       if (idx >= ICE_AQC_DRIVER_PARAM_MAX)
+               return ICE_ERR_OUT_OF_RANGE;
+
+       cmd = &desc.params.drv_shared_params;
+
+       ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_driver_shared_params);
+
+       cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_GET;
+       cmd->param_indx = idx;
+
+       status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
+       if (status)
+               return status;
+
+       *value = LE32_TO_CPU(cmd->param_val);
+
+       return ICE_SUCCESS;
+}
+
 /**
  * ice_aq_set_gpio
  * @hw: pointer to the hw struct