net/mlx4: simplify Rx buffer handling
[dpdk.git] / drivers / net / mlx4 / mlx4_flow.c
index 5ad50bd..58d4698 100644 (file)
@@ -2,7 +2,7 @@
  *   BSD LICENSE
  *
  *   Copyright 2017 6WIND S.A.
- *   Copyright 2017 Mellanox.
+ *   Copyright 2017 Mellanox
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -37,9 +37,6 @@
 #include <rte_flow_driver.h>
 #include <rte_malloc.h>
 
-/* Generated configuration header. */
-#include "mlx4_autoconf.h"
-
 /* PMD headers. */
 #include "mlx4.h"
 #include "mlx4_flow.h"
@@ -755,29 +752,21 @@ mlx4_flow_create_drop_queue(struct priv *priv)
                ERROR("Cannot allocate memory for drop struct");
                goto err;
        }
-       cq = ibv_exp_create_cq(priv->ctx, 1, NULL, NULL, 0,
-                             &(struct ibv_exp_cq_init_attr){
-                                       .comp_mask = 0,
-                             });
+       cq = ibv_create_cq(priv->ctx, 1, NULL, NULL, 0);
        if (!cq) {
                ERROR("Cannot create drop CQ");
                goto err_create_cq;
        }
-       qp = ibv_exp_create_qp(priv->ctx,
-                             &(struct ibv_exp_qp_init_attr){
-                                       .send_cq = cq,
-                                       .recv_cq = cq,
-                                       .cap = {
-                                               .max_recv_wr = 1,
-                                               .max_recv_sge = 1,
-                                       },
-                                       .qp_type = IBV_QPT_RAW_PACKET,
-                                       .comp_mask =
-                                               IBV_EXP_QP_INIT_ATTR_PD |
-                                               IBV_EXP_QP_INIT_ATTR_PORT,
-                                       .pd = priv->pd,
-                                       .port_num = priv->port,
-                             });
+       qp = ibv_create_qp(priv->pd,
+                          &(struct ibv_qp_init_attr){
+                               .send_cq = cq,
+                               .recv_cq = cq,
+                               .cap = {
+                                       .max_recv_wr = 1,
+                                       .max_recv_sge = 1,
+                               },
+                               .qp_type = IBV_QPT_RAW_PACKET,
+                          });
        if (!qp) {
                ERROR("Cannot create drop QP");
                goto err_create_qp;
@@ -829,7 +818,7 @@ priv_flow_create_action_queue(struct priv *priv,
                return NULL;
        }
        if (action->drop) {
-               qp = priv->flow_drop_queue->qp;
+               qp = priv->flow_drop_queue ? priv->flow_drop_queue->qp : NULL;
        } else {
                struct rxq *rxq = (*priv->rxqs)[action->queue_id];
 
@@ -837,6 +826,8 @@ priv_flow_create_action_queue(struct priv *priv,
                rte_flow->qp = qp;
        }
        rte_flow->ibv_attr = ibv_attr;
+       if (!priv->started)
+               return rte_flow;
        rte_flow->ibv_flow = ibv_create_flow(qp, rte_flow->ibv_attr);
        if (!rte_flow->ibv_flow) {
                rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,