net/mlx4: fix ring wraparound compiler hint
[dpdk.git] / drivers / net / mlx4 / mlx4_rxtx.c
index 67dc712..3169fe5 100644 (file)
@@ -37,7 +37,6 @@
  */
 
 #include <assert.h>
-#include <inttypes.h>
 #include <stdint.h>
 #include <string.h>
 
@@ -169,6 +168,7 @@ mlx4_txq_complete(struct txq *txq)
                 * Make sure we read the CQE after we read the ownership bit.
                 */
                rte_rmb();
+#ifndef NDEBUG
                if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
                             MLX4_CQE_OPCODE_ERROR)) {
                        struct mlx4_err_cqe *cqe_err =
@@ -178,6 +178,7 @@ mlx4_txq_complete(struct txq *txq)
                              (void *)txq, cqe_err->vendor_err,
                              cqe_err->syndrome);
                }
+#endif /* NDEBUG */
                /* Get WQE index reported in the CQE. */
                new_index =
                        rte_be_to_cpu_16(cqe->wqe_index) & sq->txbb_cnt_mask;
@@ -236,63 +237,6 @@ mlx4_txq_mb2mp(struct rte_mbuf *buf)
        return buf->pool;
 }
 
-/**
- * Get memory region (MR) <-> memory pool (MP) association from txq->mp2mr[].
- * Add MP to txq->mp2mr[] if it's not registered yet. If mp2mr[] is full,
- * remove an entry first.
- *
- * @param txq
- *   Pointer to Tx queue structure.
- * @param[in] mp
- *   Memory pool for which a memory region lkey must be returned.
- *
- * @return
- *   mr->lkey on success, (uint32_t)-1 on failure.
- */
-uint32_t
-mlx4_txq_mp2mr(struct txq *txq, struct rte_mempool *mp)
-{
-       unsigned int i;
-       struct ibv_mr *mr;
-
-       for (i = 0; (i != RTE_DIM(txq->mp2mr)); ++i) {
-               if (unlikely(txq->mp2mr[i].mp == NULL)) {
-                       /* Unknown MP, add a new MR for it. */
-                       break;
-               }
-               if (txq->mp2mr[i].mp == mp) {
-                       assert(txq->mp2mr[i].lkey != (uint32_t)-1);
-                       assert(txq->mp2mr[i].mr->lkey == txq->mp2mr[i].lkey);
-                       return txq->mp2mr[i].lkey;
-               }
-       }
-       /* Add a new entry, register MR first. */
-       DEBUG("%p: discovered new memory pool \"%s\" (%p)",
-             (void *)txq, mp->name, (void *)mp);
-       mr = mlx4_mp2mr(txq->priv->pd, mp);
-       if (unlikely(mr == NULL)) {
-               DEBUG("%p: unable to configure MR, ibv_reg_mr() failed.",
-                     (void *)txq);
-               return (uint32_t)-1;
-       }
-       if (unlikely(i == RTE_DIM(txq->mp2mr))) {
-               /* Table is full, remove oldest entry. */
-               DEBUG("%p: MR <-> MP table full, dropping oldest entry.",
-                     (void *)txq);
-               --i;
-               claim_zero(ibv_dereg_mr(txq->mp2mr[0].mr));
-               memmove(&txq->mp2mr[0], &txq->mp2mr[1],
-                       (sizeof(txq->mp2mr) - sizeof(txq->mp2mr[0])));
-       }
-       /* Store the new entry. */
-       txq->mp2mr[i].mp = mp;
-       txq->mp2mr[i].mr = mr;
-       txq->mp2mr[i].lkey = mr->lkey;
-       DEBUG("%p: new MR lkey for MP \"%s\" (%p): 0x%08" PRIu32,
-             (void *)txq, mp->name, (void *)mp, txq->mp2mr[i].lkey);
-       return txq->mp2mr[i].lkey;
-}
-
 /**
  * Posts a single work request to a send queue.
  *
@@ -302,7 +246,7 @@ mlx4_txq_mp2mr(struct txq *txq, struct rte_mempool *mp)
  *   Packet to transmit.
  *
  * @return
- *   0 on success, negative errno value otherwise and rte_errno is set.
+ *   0 on success, negative errno value otherwise.
  */
 static inline int
 mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt)
@@ -322,7 +266,6 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt)
        uint32_t byte_count;
        int wqe_real_size;
        int nr_txbbs;
-       int rc;
        struct pv *pv = (struct pv *)txq->bounce_buf;
        int pv_counter = 0;
 
@@ -337,8 +280,7 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt)
        if (((sq->head - sq->tail) + nr_txbbs +
             sq->headroom_txbbs) >= sq->txbb_cnt ||
            nr_txbbs > MLX4_MAX_WQE_TXBBS) {
-               rc = ENOSPC;
-               goto err;
+               return -ENOSPC;
        }
        /* Get the control and data entries of the WQE. */
        ctrl = (struct mlx4_wqe_ctrl_seg *)mlx4_get_send_wqe(sq, head_idx);
@@ -349,11 +291,12 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt)
                addr = rte_pktmbuf_mtod(buf, uintptr_t);
                rte_prefetch0((volatile void *)addr);
                /* Handle WQE wraparound. */
-               if (unlikely(dseg >= (struct mlx4_wqe_data_seg *)sq->eob))
+               if (dseg >= (struct mlx4_wqe_data_seg *)sq->eob)
                        dseg = (struct mlx4_wqe_data_seg *)sq->buf;
                dseg->addr = rte_cpu_to_be_64(addr);
                /* Memory region key for this memory pool. */
                lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(buf));
+#ifndef NDEBUG
                if (unlikely(lkey == (uint32_t)-1)) {
                        /* MR does not exist. */
                        DEBUG("%p: unable to get MP <-> MR association",
@@ -366,9 +309,9 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt)
                        ctrl->fence_size = (wqe_real_size >> 4) & 0x3f;
                        mlx4_txq_stamp_freed_wqe(sq, head_idx,
                                     (sq->head & sq->txbb_cnt) ? 0 : 1);
-                       rc = EFAULT;
-                       goto err;
+                       return -EFAULT;
                }
+#endif /* NDEBUG */
                dseg->lkey = rte_cpu_to_be_32(lkey);
                if (likely(buf->data_len)) {
                        byte_count = rte_cpu_to_be_32(buf->data_len);
@@ -471,9 +414,6 @@ mlx4_post_send(struct txq *txq, struct rte_mbuf *pkt)
                                               MLX4_BIT_WQE_OWN : 0));
        sq->head += nr_txbbs;
        return 0;
-err:
-       rte_errno = rc;
-       return -rc;
 }
 
 /**