net/mlx4: move rdma-core calls to separate file
[dpdk.git] / drivers / net / mlx4 / mlx4_flow.c
index 96a6a6f..8b6f8a0 100644 (file)
@@ -57,7 +57,7 @@
 #include <rte_byteorder.h>
 #include <rte_errno.h>
 #include <rte_eth_ctrl.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_ether.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -65,6 +65,7 @@
 
 /* PMD headers. */
 #include "mlx4.h"
+#include "mlx4_glue.h"
 #include "mlx4_flow.h"
 #include "mlx4_rxtx.h"
 #include "mlx4_utils.h"
@@ -922,24 +923,25 @@ mlx4_drop_get(struct priv *priv)
                .priv = priv,
                .refcnt = 1,
        };
-       drop->cq = ibv_create_cq(priv->ctx, 1, NULL, NULL, 0);
+       drop->cq = mlx4_glue->create_cq(priv->ctx, 1, NULL, NULL, 0);
        if (!drop->cq)
                goto error;
-       drop->qp = ibv_create_qp(priv->pd,
-                                &(struct ibv_qp_init_attr){
-                                       .send_cq = drop->cq,
-                                       .recv_cq = drop->cq,
-                                       .qp_type = IBV_QPT_RAW_PACKET,
-                                });
+       drop->qp = mlx4_glue->create_qp
+               (priv->pd,
+                &(struct ibv_qp_init_attr){
+                       .send_cq = drop->cq,
+                       .recv_cq = drop->cq,
+                       .qp_type = IBV_QPT_RAW_PACKET,
+                });
        if (!drop->qp)
                goto error;
        priv->drop = drop;
        return drop;
 error:
        if (drop->qp)
-               claim_zero(ibv_destroy_qp(drop->qp));
+               claim_zero(mlx4_glue->destroy_qp(drop->qp));
        if (drop->cq)
-               claim_zero(ibv_destroy_cq(drop->cq));
+               claim_zero(mlx4_glue->destroy_cq(drop->cq));
        if (drop)
                rte_free(drop);
        rte_errno = ENOMEM;
@@ -959,8 +961,8 @@ mlx4_drop_put(struct mlx4_drop *drop)
        if (--drop->refcnt)
                return;
        drop->priv->drop = NULL;
-       claim_zero(ibv_destroy_qp(drop->qp));
-       claim_zero(ibv_destroy_cq(drop->cq));
+       claim_zero(mlx4_glue->destroy_qp(drop->qp));
+       claim_zero(mlx4_glue->destroy_cq(drop->cq));
        rte_free(drop);
 }
 
@@ -992,7 +994,7 @@ mlx4_flow_toggle(struct priv *priv,
        if (!enable) {
                if (!flow->ibv_flow)
                        return 0;
-               claim_zero(ibv_destroy_flow(flow->ibv_flow));
+               claim_zero(mlx4_glue->destroy_flow(flow->ibv_flow));
                flow->ibv_flow = NULL;
                if (flow->drop)
                        mlx4_drop_put(priv->drop);
@@ -1005,7 +1007,7 @@ mlx4_flow_toggle(struct priv *priv,
            !priv->isolated &&
            flow->ibv_attr->priority == MLX4_FLOW_PRIORITY_LAST) {
                if (flow->ibv_flow) {
-                       claim_zero(ibv_destroy_flow(flow->ibv_flow));
+                       claim_zero(mlx4_glue->destroy_flow(flow->ibv_flow));
                        flow->ibv_flow = NULL;
                        if (flow->drop)
                                mlx4_drop_put(priv->drop);
@@ -1035,7 +1037,7 @@ mlx4_flow_toggle(struct priv *priv,
                        if (missing ^ !flow->drop)
                                return 0;
                        /* Verbs flow needs updating. */
-                       claim_zero(ibv_destroy_flow(flow->ibv_flow));
+                       claim_zero(mlx4_glue->destroy_flow(flow->ibv_flow));
                        flow->ibv_flow = NULL;
                        if (flow->drop)
                                mlx4_drop_put(priv->drop);
@@ -1067,7 +1069,7 @@ mlx4_flow_toggle(struct priv *priv,
        assert(qp);
        if (flow->ibv_flow)
                return 0;
-       flow->ibv_flow = ibv_create_flow(qp, flow->ibv_attr);
+       flow->ibv_flow = mlx4_glue->create_flow(qp, flow->ibv_attr);
        if (flow->ibv_flow)
                return 0;
        if (flow->drop)
@@ -1223,9 +1225,12 @@ mlx4_flow_internal_next_vlan(struct priv *priv, uint16_t vlan)
  *
  * Various flow rules are created depending on the mode the device is in:
  *
- * 1. Promiscuous: port MAC + catch-all (VLAN filtering is ignored).
- * 2. All multicast: port MAC/VLAN + catch-all multicast.
- * 3. Otherwise: port MAC/VLAN + broadcast MAC/VLAN.
+ * 1. Promiscuous:
+ *       port MAC + broadcast + catch-all (VLAN filtering is ignored).
+ * 2. All multicast:
+ *       port MAC/VLAN + broadcast + catch-all multicast.
+ * 3. Otherwise:
+ *       port MAC/VLAN + broadcast MAC/VLAN.
  *
  * About MAC flow rules:
  *
@@ -1305,9 +1310,6 @@ mlx4_flow_internal(struct priv *priv, struct rte_flow_error *error)
                !priv->dev->data->promiscuous ?
                &vlan_spec.tci :
                NULL;
-       int broadcast =
-               !priv->dev->data->promiscuous &&
-               !priv->dev->data->all_multicast;
        uint16_t vlan = 0;
        struct rte_flow *flow;
        unsigned int i;
@@ -1341,7 +1343,7 @@ next_vlan:
                        rule_vlan = NULL;
                }
        }
-       for (i = 0; i != RTE_DIM(priv->mac) + broadcast; ++i) {
+       for (i = 0; i != RTE_DIM(priv->mac) + 1; ++i) {
                const struct ether_addr *mac;
 
                /* Broadcasts are handled by an extra iteration. */
@@ -1405,7 +1407,7 @@ next_vlan:
                        goto next_vlan;
        }
        /* Take care of promiscuous and all multicast flow rules. */
-       if (!broadcast) {
+       if (priv->dev->data->promiscuous || priv->dev->data->all_multicast) {
                for (flow = LIST_FIRST(&priv->flows);
                     flow && flow->internal;
                     flow = LIST_NEXT(flow, next)) {