common/mlx5: introduce common library
[dpdk.git] / drivers / net / mlx5 / mlx5_flow_verbs.c
index ea85fa1..9231451 100644 (file)
 #include <rte_malloc.h>
 #include <rte_ip.h>
 
-#include "mlx5.h"
+#include <mlx5_glue.h>
+#include <mlx5_prm.h>
+
 #include "mlx5_defs.h"
+#include "mlx5.h"
 #include "mlx5_flow.h"
-#include "mlx5_glue.h"
-#include "mlx5_prm.h"
 #include "mlx5_rxtx.h"
 
 #define VERBS_SPEC_INNER(item_flags) \
@@ -191,7 +192,7 @@ flow_verbs_counter_query(struct rte_eth_dev *dev __rte_unused,
 {
 #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \
        defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
-       if (flow->counter->cs) {
+       if (flow->counter && flow->counter->cs) {
                struct rte_flow_query_count *qc = data;
                uint64_t counters[2] = {0, 0};
 #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42)
@@ -1255,6 +1256,18 @@ flow_verbs_validate(struct rte_eth_dev *dev,
                                                  "action not supported");
                }
        }
+       /*
+        * Validate the drop action mutual exclusion with other actions.
+        * Drop action is mutually-exclusive with any other action, except for
+        * Count action.
+        */
+       if ((action_flags & MLX5_FLOW_ACTION_DROP) &&
+           (action_flags & ~(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_COUNT)))
+               return rte_flow_error_set(error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+                                         "Drop action is mutually-exclusive "
+                                         "with any other action, except for "
+                                         "Count action");
        if (!(action_flags & MLX5_FLOW_FATE_ACTIONS))
                return rte_flow_error_set(error, EINVAL,
                                          RTE_FLOW_ERROR_TYPE_ACTION, actions,