action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
                                  MLX5_FLOW_CONTEXT_ACTION_COUNT;
-                       if (netdev_port_same_parent_id(priv->netdev, out_dev)) {
+                       if (encap) {
+                               parse_attr->mirred_ifindex[attr->out_count] =
+                                       out_dev->ifindex;
+                               parse_attr->tun_info[attr->out_count] = dup_tun_info(info);
+                               if (!parse_attr->tun_info[attr->out_count])
+                                       return -ENOMEM;
+                               encap = false;
+                               attr->dests[attr->out_count].flags |=
+                                       MLX5_ESW_DEST_ENCAP;
+                               attr->out_count++;
+                               /* attr->dests[].rep is resolved when we
+                                * handle encap
+                                */
+                       } else if (netdev_port_same_parent_id(priv->netdev, out_dev)) {
                                struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
                                struct net_device *uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);
                                struct net_device *uplink_upper;
                                attr->dests[attr->out_count].rep = rpriv->rep;
                                attr->dests[attr->out_count].mdev = out_priv->mdev;
                                attr->out_count++;
-                       } else if (encap) {
-                               parse_attr->mirred_ifindex[attr->out_count] =
-                                       out_dev->ifindex;
-                               parse_attr->tun_info[attr->out_count] = dup_tun_info(info);
-                               if (!parse_attr->tun_info[attr->out_count])
-                                       return -ENOMEM;
-                               encap = false;
-                               attr->dests[attr->out_count].flags |=
-                                       MLX5_ESW_DEST_ENCAP;
-                               attr->out_count++;
-                               /* attr->dests[].rep is resolved when we
-                                * handle encap
-                                */
                        } else if (parse_attr->filter_dev != priv->netdev) {
                                /* All mlx5 devices are called to configure
                                 * high level device filters. Therefore, the