common/mlx5: fix default devargs initialization
[dpdk.git] / drivers / net / i40e / i40e_flow.c
index 3e514d5..e0cf996 100644 (file)
@@ -2015,7 +2015,7 @@ i40e_get_outer_vlan(struct rte_eth_dev *dev)
 {
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        int qinq = dev->data->dev_conf.rxmode.offloads &
-               DEV_RX_OFFLOAD_VLAN_EXTEND;
+               RTE_ETH_RX_OFFLOAD_VLAN_EXTEND;
        uint64_t reg_r = 0;
        uint16_t reg_id;
        uint16_t tpid;
@@ -2243,82 +2243,6 @@ i40e_flow_check_raw_item(const struct rte_flow_item *item,
        return 0;
 }
 
-static int
-i40e_flow_set_fdir_inset(struct i40e_pf *pf,
-                        enum i40e_filter_pctype pctype,
-                        uint64_t input_set)
-{
-       struct i40e_hw *hw = I40E_PF_TO_HW(pf);
-       uint64_t inset_reg = 0;
-       uint32_t mask_reg[I40E_INSET_MASK_NUM_REG] = {0};
-       int i, num;
-
-       /* Check if the input set is valid */
-       if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
-                                   input_set) != 0) {
-               PMD_DRV_LOG(ERR, "Invalid input set");
-               return -EINVAL;
-       }
-
-       /* Check if the configuration is conflicted */
-       if (pf->fdir.inset_flag[pctype] &&
-           memcmp(&pf->fdir.input_set[pctype], &input_set, sizeof(uint64_t)))
-               return -1;
-
-       if (pf->fdir.inset_flag[pctype] &&
-           !memcmp(&pf->fdir.input_set[pctype], &input_set, sizeof(uint64_t)))
-               return 0;
-
-       num = i40e_generate_inset_mask_reg(input_set, mask_reg,
-                                          I40E_INSET_MASK_NUM_REG);
-       if (num < 0)
-               return -EINVAL;
-
-       if (pf->support_multi_driver) {
-               for (i = 0; i < num; i++)
-                       if (i40e_read_rx_ctl(hw,
-                                       I40E_GLQF_FD_MSK(i, pctype)) !=
-                                       mask_reg[i]) {
-                               PMD_DRV_LOG(ERR, "Input set setting is not"
-                                               " supported with"
-                                               " `support-multi-driver`"
-                                               " enabled!");
-                               return -EPERM;
-                       }
-               for (i = num; i < I40E_INSET_MASK_NUM_REG; i++)
-                       if (i40e_read_rx_ctl(hw,
-                                       I40E_GLQF_FD_MSK(i, pctype)) != 0) {
-                               PMD_DRV_LOG(ERR, "Input set setting is not"
-                                               " supported with"
-                                               " `support-multi-driver`"
-                                               " enabled!");
-                               return -EPERM;
-                       }
-
-       } else {
-               for (i = 0; i < num; i++)
-                       i40e_check_write_reg(hw, I40E_GLQF_FD_MSK(i, pctype),
-                               mask_reg[i]);
-               /*clear unused mask registers of the pctype */
-               for (i = num; i < I40E_INSET_MASK_NUM_REG; i++)
-                       i40e_check_write_reg(hw,
-                                       I40E_GLQF_FD_MSK(i, pctype), 0);
-       }
-
-       inset_reg |= i40e_translate_input_set_reg(hw->mac.type, input_set);
-
-       i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 0),
-                            (uint32_t)(inset_reg & UINT32_MAX));
-       i40e_check_write_reg(hw, I40E_PRTQF_FD_INSET(pctype, 1),
-                            (uint32_t)((inset_reg >>
-                                        I40E_32_BIT_WIDTH) & UINT32_MAX));
-
-       I40E_WRITE_FLUSH(hw);
-
-       pf->fdir.input_set[pctype] = input_set;
-       pf->fdir.inset_flag[pctype] = 1;
-       return 0;
-}
 
 static uint8_t
 i40e_flow_fdir_get_pctype_value(struct i40e_pf *pf,
@@ -3119,12 +3043,15 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
                                rte_flow_error_set(error, EINVAL,
                                           RTE_FLOW_ERROR_TYPE_ITEM,
                                           item,
-                                          "Exceeds maxmial payload limit.");
+                                          "Exceeds maximal payload limit.");
                                return -rte_errno;
                        }
 
                        for (i = 0; i < raw_spec->length; i++) {
                                j = i + next_dst_off;
+                               if (j >= RTE_ETH_FDIR_MAX_FLEXLEN ||
+                                               j >= I40E_FDIR_MAX_FLEX_LEN)
+                                       break;
                                filter->input.flow_ext.flexbytes[j] =
                                        raw_spec->pattern[i];
                                filter->input.flow_ext.flex_mask[j] =
@@ -3212,18 +3139,14 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 
        /* If customized pctype is not used, set fdir configuration.*/
        if (!filter->input.flow_ext.customized_pctype) {
-               ret = i40e_flow_set_fdir_inset(pf, pctype, input_set);
-               if (ret == -1) {
-                       rte_flow_error_set(error, EINVAL,
-                                          RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                          "Conflict with the first rule's input set.");
-                       return -rte_errno;
-               } else if (ret == -EINVAL) {
-                       rte_flow_error_set(error, EINVAL,
-                                          RTE_FLOW_ERROR_TYPE_ITEM, item,
-                                          "Invalid pattern mask.");
-                       return -rte_errno;
+               /* Check if the input set is valid */
+               if (i40e_validate_input_set(pctype, RTE_ETH_FILTER_FDIR,
+                                               input_set) != 0) {
+                       PMD_DRV_LOG(ERR, "Invalid input set");
+                       return -EINVAL;
                }
+
+               filter->input.flow_ext.input_set = input_set;
        }
 
        filter->input.pctype = pctype;
@@ -3681,13 +3604,13 @@ i40e_flow_parse_l4_cloud_filter(struct rte_eth_dev *dev,
 }
 
 static uint16_t i40e_supported_tunnel_filter_types[] = {
-       ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID |
-       ETH_TUNNEL_FILTER_IVLAN,
-       ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_IVLAN,
-       ETH_TUNNEL_FILTER_IMAC | ETH_TUNNEL_FILTER_TENID,
-       ETH_TUNNEL_FILTER_OMAC | ETH_TUNNEL_FILTER_TENID |
-       ETH_TUNNEL_FILTER_IMAC,
-       ETH_TUNNEL_FILTER_IMAC,
+       RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID |
+       RTE_ETH_TUNNEL_FILTER_IVLAN,
+       RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_IVLAN,
+       RTE_ETH_TUNNEL_FILTER_IMAC | RTE_ETH_TUNNEL_FILTER_TENID,
+       RTE_ETH_TUNNEL_FILTER_OMAC | RTE_ETH_TUNNEL_FILTER_TENID |
+       RTE_ETH_TUNNEL_FILTER_IMAC,
+       RTE_ETH_TUNNEL_FILTER_IMAC,
 };
 
 static int
@@ -3777,12 +3700,12 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
                                        rte_memcpy(&filter->outer_mac,
                                                   &eth_spec->dst,
                                                   RTE_ETHER_ADDR_LEN);
-                                       filter_type |= ETH_TUNNEL_FILTER_OMAC;
+                                       filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
                                } else {
                                        rte_memcpy(&filter->inner_mac,
                                                   &eth_spec->dst,
                                                   RTE_ETHER_ADDR_LEN);
-                                       filter_type |= ETH_TUNNEL_FILTER_IMAC;
+                                       filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
                                }
                        }
                        break;
@@ -3804,7 +3727,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
                                        filter->inner_vlan =
                                              rte_be_to_cpu_16(vlan_spec->tci) &
                                              I40E_VLAN_TCI_MASK;
-                               filter_type |= ETH_TUNNEL_FILTER_IVLAN;
+                               filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
                        }
                        break;
                case RTE_FLOW_ITEM_TYPE_IPV4:
@@ -3878,7 +3801,7 @@ i40e_flow_parse_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
                                           vxlan_spec->vni, 3);
                                filter->tenant_id =
                                        rte_be_to_cpu_32(tenant_id_be);
-                               filter_type |= ETH_TUNNEL_FILTER_TENID;
+                               filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
                        }
 
                        vxlan_flag = 1;
@@ -4007,12 +3930,12 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
                                        rte_memcpy(&filter->outer_mac,
                                                   &eth_spec->dst,
                                                   RTE_ETHER_ADDR_LEN);
-                                       filter_type |= ETH_TUNNEL_FILTER_OMAC;
+                                       filter_type |= RTE_ETH_TUNNEL_FILTER_OMAC;
                                } else {
                                        rte_memcpy(&filter->inner_mac,
                                                   &eth_spec->dst,
                                                   RTE_ETHER_ADDR_LEN);
-                                       filter_type |= ETH_TUNNEL_FILTER_IMAC;
+                                       filter_type |= RTE_ETH_TUNNEL_FILTER_IMAC;
                                }
                        }
 
@@ -4035,7 +3958,7 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
                                        filter->inner_vlan =
                                              rte_be_to_cpu_16(vlan_spec->tci) &
                                              I40E_VLAN_TCI_MASK;
-                               filter_type |= ETH_TUNNEL_FILTER_IVLAN;
+                               filter_type |= RTE_ETH_TUNNEL_FILTER_IVLAN;
                        }
                        break;
                case RTE_FLOW_ITEM_TYPE_IPV4:
@@ -4130,7 +4053,7 @@ i40e_flow_parse_nvgre_pattern(__rte_unused struct rte_eth_dev *dev,
                                           nvgre_spec->tni, 3);
                                filter->tenant_id =
                                        rte_be_to_cpu_32(tenant_id_be);
-                               filter_type |= ETH_TUNNEL_FILTER_TENID;
+                               filter_type |= RTE_ETH_TUNNEL_FILTER_TENID;
                        }
 
                        nvgre_flag = 1;
@@ -4977,7 +4900,7 @@ i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 static int
 i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
 {
-       struct rte_eth_dev *dev = pf->adapter->eth_dev;
+       struct rte_eth_dev *dev = &rte_eth_devices[pf->dev_data->port_id];
        struct i40e_fdir_info *fdir_info = &pf->fdir;
        struct i40e_fdir_filter *fdir_filter;
        enum i40e_filter_pctype pctype;
@@ -4997,7 +4920,7 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
                }
 
                /* Delete FDIR flows in flow list. */
-               TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
+               RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
                        if (flow->filter_type == RTE_ETH_FILTER_FDIR) {
                                TAILQ_REMOVE(&pf->flow_list, flow, node);
                        }
@@ -5020,7 +4943,7 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf)
 
                for (pctype = I40E_FILTER_PCTYPE_NONF_IPV4_UDP;
                     pctype <= I40E_FILTER_PCTYPE_L2_PAYLOAD; pctype++) {
-                       pf->fdir.inset_flag[pctype] = 0;
+                       pf->fdir.flow_count[pctype] = 0;
                        pf->fdir.flex_mask_flag[pctype] = 0;
                }
 
@@ -5052,7 +4975,7 @@ i40e_flow_flush_ethertype_filter(struct i40e_pf *pf)
        }
 
        /* Delete ethertype flows in flow list. */
-       TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
+       RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
                if (flow->filter_type == RTE_ETH_FILTER_ETHERTYPE) {
                        TAILQ_REMOVE(&pf->flow_list, flow, node);
                        rte_free(flow);
@@ -5080,7 +5003,7 @@ i40e_flow_flush_tunnel_filter(struct i40e_pf *pf)
        }
 
        /* Delete tunnel flows in flow list. */
-       TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
+       RTE_TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
                if (flow->filter_type == RTE_ETH_FILTER_TUNNEL) {
                        TAILQ_REMOVE(&pf->flow_list, flow, node);
                        rte_free(flow);