net/mlx5: support flag flow action
authorNélio Laranjeiro <nelio.laranjeiro@6wind.com>
Wed, 1 Mar 2017 12:49:45 +0000 (13:49 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 4 Apr 2017 13:52:51 +0000 (15:52 +0200)
This action is not terminal in this PMD, it must be followed by a queue
action.

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
drivers/net/mlx5/mlx5_flow.c
drivers/net/mlx5/mlx5_prm.h
drivers/net/mlx5/mlx5_rxtx.c

index a885f6e..39a96ea 100644 (file)
@@ -146,6 +146,7 @@ static const enum rte_flow_action_type valid_actions[] = {
        RTE_FLOW_ACTION_TYPE_DROP,
        RTE_FLOW_ACTION_TYPE_QUEUE,
        RTE_FLOW_ACTION_TYPE_MARK,
+       RTE_FLOW_ACTION_TYPE_FLAG,
        RTE_FLOW_ACTION_TYPE_END,
 };
 
@@ -476,6 +477,8 @@ priv_flow_validate(struct priv *priv,
                                return -rte_errno;
                        }
                        action.mark = 1;
+               } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) {
+                       action.mark = 1;
                } else {
                        goto exit_action_not_supported;
                }
@@ -1061,6 +1064,8 @@ priv_flow_create(struct priv *priv,
                        if (mark)
                                action.mark_id = mark->id;
                        action.mark = !action.drop;
+               } else if (actions->type == RTE_FLOW_ACTION_TYPE_FLAG) {
+                       action.mark = 1;
                } else {
                        rte_flow_error_set(error, ENOTSUP,
                                           RTE_FLOW_ERROR_TYPE_ACTION,
index 755b5d7..3318668 100644 (file)
@@ -227,9 +227,11 @@ mlx5_flow_mark_set(uint32_t val)
 
        /*
         * Add one to the user value to differentiate un-marked flows from
-        * marked flows.
+        * marked flows, if the ID is equal to MLX5_FLOW_MARK_DEFAULT it
+        * remains untouched.
         */
-       ++val;
+       if (val != MLX5_FLOW_MARK_DEFAULT)
+               ++val;
 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
        /*
         * Mark is 24 bits (minus reserved values) but is stored on a 32 bit
@@ -241,7 +243,6 @@ mlx5_flow_mark_set(uint32_t val)
 #else
        ret = val;
 #endif
-       assert(ret <= MLX5_FLOW_MARK_MAX);
        return ret;
 }
 
index fc75e6f..8399a91 100644 (file)
@@ -1505,14 +1505,17 @@ mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
                                pkt->hash.rss = rss_hash_res;
                                pkt->ol_flags = PKT_RX_RSS_HASH;
                        }
-                       if (rxq->mark &&
-                           ((cqe->sop_drop_qpn !=
-                             htonl(MLX5_FLOW_MARK_INVALID)) &&
-                            (cqe->sop_drop_qpn !=
-                             htonl(MLX5_FLOW_MARK_DEFAULT)))) {
-                               pkt->hash.fdir.hi =
-                                       mlx5_flow_mark_get(cqe->sop_drop_qpn);
-                               pkt->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
+                       if (rxq->mark && (cqe->sop_drop_qpn !=
+                                         htonl(MLX5_FLOW_MARK_INVALID))) {
+                               pkt->ol_flags |= PKT_RX_FDIR;
+                               if (cqe->sop_drop_qpn !=
+                                   htonl(MLX5_FLOW_MARK_DEFAULT)) {
+                                       uint32_t mark = cqe->sop_drop_qpn;
+
+                                       pkt->ol_flags |= PKT_RX_FDIR_ID;
+                                       pkt->hash.fdir.hi =
+                                               mlx5_flow_mark_get(mark);
+                               }
                        }
                        if (rxq->csum | rxq->csum_l2tun | rxq->vlan_strip |
                            rxq->crc_present) {