net/mlx4: add new memory region support
[dpdk.git] / drivers / net / mlx4 / mlx4_rxtx.c
index 21ffd43..44efeb4 100644 (file)
@@ -343,24 +343,6 @@ mlx4_txq_complete(struct txq *txq, const unsigned int elts_m,
        txq->elts_tail = elts_tail;
 }
 
-/**
- * Get memory pool (MP) from mbuf. If mbuf is indirect, the pool from which
- * the cloned mbuf is allocated is returned instead.
- *
- * @param buf
- *   Pointer to mbuf.
- *
- * @return
- *   Memory pool where data is located for given mbuf.
- */
-static struct rte_mempool *
-mlx4_txq_mb2mp(struct rte_mbuf *buf)
-{
-       if (unlikely(RTE_MBUF_INDIRECT(buf)))
-               return rte_mbuf_from_indirect(buf)->pool;
-       return buf->pool;
-}
-
 /**
  * Write Tx data segment to the SQ.
  *
@@ -378,7 +360,7 @@ mlx4_fill_tx_data_seg(volatile struct mlx4_wqe_data_seg *dseg,
                       uint32_t lkey, uintptr_t addr, rte_be32_t  byte_count)
 {
        dseg->addr = rte_cpu_to_be_64(addr);
-       dseg->lkey = rte_cpu_to_be_32(lkey);
+       dseg->lkey = lkey;
 #if RTE_CACHE_LINE_SIZE < 64
        /*
         * Need a barrier here before writing the byte_count
@@ -437,7 +419,7 @@ mlx4_tx_burst_segs(struct rte_mbuf *buf, struct txq *txq,
        goto txbb_tail_segs;
 txbb_head_seg:
        /* Memory region key (big endian) for this memory pool. */
-       lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(sbuf));
+       lkey = mlx4_tx_mb2mr(txq, sbuf);
        if (unlikely(lkey == (uint32_t)-1)) {
                DEBUG("%p: unable to get MP <-> MR association",
                      (void *)txq);
@@ -449,7 +431,7 @@ txbb_head_seg:
                dseg = (volatile struct mlx4_wqe_data_seg *)
                        sq->buf;
        dseg->addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(sbuf, uintptr_t));
-       dseg->lkey = rte_cpu_to_be_32(lkey);
+       dseg->lkey = lkey;
        /*
         * This data segment starts at the beginning of a new
         * TXBB, so we need to postpone its byte_count writing
@@ -469,7 +451,7 @@ txbb_tail_segs:
        /* Jump to default if there are more than two segments remaining. */
        switch (nb_segs) {
        default:
-               lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(sbuf));
+               lkey = mlx4_tx_mb2mr(txq, sbuf);
                if (unlikely(lkey == (uint32_t)-1)) {
                        DEBUG("%p: unable to get MP <-> MR association",
                              (void *)txq);
@@ -485,7 +467,7 @@ txbb_tail_segs:
                nb_segs--;
                /* fallthrough */
        case 2:
-               lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(sbuf));
+               lkey = mlx4_tx_mb2mr(txq, sbuf);
                if (unlikely(lkey == (uint32_t)-1)) {
                        DEBUG("%p: unable to get MP <-> MR association",
                              (void *)txq);
@@ -501,7 +483,7 @@ txbb_tail_segs:
                nb_segs--;
                /* fallthrough */
        case 1:
-               lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(sbuf));
+               lkey = mlx4_tx_mb2mr(txq, sbuf);
                if (unlikely(lkey == (uint32_t)-1)) {
                        DEBUG("%p: unable to get MP <-> MR association",
                              (void *)txq);
@@ -611,7 +593,7 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
                                elt->buf = NULL;
                                break;
                        }
-                       lkey = mlx4_txq_mp2mr(txq, mlx4_txq_mb2mp(buf));
+                       lkey = mlx4_tx_mb2mr(txq, buf);
                        if (unlikely(lkey == (uint32_t)-1)) {
                                /* MR does not exist. */
                                DEBUG("%p: unable to get MP <-> MR association",
@@ -966,6 +948,9 @@ mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
                 * changes.
                 */
                scat->addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(rep, uintptr_t));
+               /* If there's only one MR, no need to replace LKey in WQE. */
+               if (unlikely(mlx4_mr_btree_len(&rxq->mr_ctrl.cache_bh) > 1))
+                       scat->lkey = mlx4_rx_mb2mr(rxq, rep);
                if (len > seg->data_len) {
                        len -= seg->data_len;
                        ++pkt->nb_segs;