net/mlx5: fix tunnel offload freeing
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index ad891d6..52ade39 100644 (file)
@@ -777,6 +777,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
                        return priv->mtr_color_reg != REG_C_2 ? REG_C_2 :
                               REG_C_3;
        case MLX5_MTR_COLOR:
+       case MLX5_ASO_FLOW_HIT: /* Both features use the same REG_C. */
                MLX5_ASSERT(priv->mtr_color_reg != REG_NON);
                return priv->mtr_color_reg;
        case MLX5_COPY_MARK:
@@ -3547,9 +3548,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,
                        break;
                case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
                        raw_encap = actions->conf;
-                       if (raw_encap->size >
-                           (sizeof(struct rte_flow_item_eth) +
-                            sizeof(struct rte_flow_item_ipv4)))
+                       if (raw_encap->size > MLX5_ENCAPSULATION_DECISION_SIZE)
                                split++;
                        action_n++;
                        break;
@@ -3984,9 +3983,7 @@ flow_hairpin_split(struct rte_eth_dev *dev,
                        break;
                case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
                        raw_encap = actions->conf;
-                       if (raw_encap->size >
-                           (sizeof(struct rte_flow_item_eth) +
-                            sizeof(struct rte_flow_item_ipv4))) {
+                       if (raw_encap->size > MLX5_ENCAPSULATION_DECISION_SIZE) {
                                memcpy(actions_tx, actions,
                                       sizeof(struct rte_flow_action));
                                actions_tx++;
@@ -3999,9 +3996,7 @@ flow_hairpin_split(struct rte_eth_dev *dev,
                        break;
                case RTE_FLOW_ACTION_TYPE_RAW_DECAP:
                        raw_decap = actions->conf;
-                       if (raw_decap->size <
-                           (sizeof(struct rte_flow_item_eth) +
-                            sizeof(struct rte_flow_item_ipv4))) {
+                       if (raw_decap->size < MLX5_ENCAPSULATION_DECISION_SIZE) {
                                memcpy(actions_tx, actions,
                                       sizeof(struct rte_flow_action));
                                actions_tx++;
@@ -7428,6 +7423,7 @@ mlx5_flow_tunnel_free(struct rte_eth_dev *dev,
 
        DRV_LOG(DEBUG, "port %u release pmd tunnel id=0x%x",
                dev->data->port_id, tunnel->tunnel_id);
+       LIST_REMOVE(tunnel, chain);
        mlx5_hlist_destroy(tunnel->groups);
        ipool = priv->sh->ipool[MLX5_IPOOL_TUNNEL_ID];
        mlx5_ipool_free(ipool, tunnel->tunnel_id);
@@ -7819,6 +7815,11 @@ mlx5_flow_tunnel_get_restore_info(struct rte_eth_dev *dev,
        const struct mlx5_flow_tbl_data_entry *tble;
        const uint64_t mask = PKT_RX_FDIR | PKT_RX_FDIR_ID;
 
+       if (!is_tunnel_offload_active(dev)) {
+               info->flags = 0;
+               return 0;
+       }
+
        if ((ol_flags & mask) != mask)
                goto err;
        tble = tunnel_mark_decode(dev, m->hash.fdir.hi);