net/mlx4: advertise Rx jumbo frame support
[dpdk.git] / drivers / net / mlx4 / mlx4_rxq.c
index bc7d9e8..9737da2 100644 (file)
@@ -338,6 +338,12 @@ mlx4_rss_init(struct priv *priv)
 
        if (priv->rss_init)
                return 0;
+       if (priv->dev->data->nb_rx_queues > priv->hw_rss_max_qps) {
+               ERROR("RSS does not support more than %d queues",
+                     priv->hw_rss_max_qps);
+               rte_errno = EINVAL;
+               return -rte_errno;
+       }
        /* Prepare range for RSS contexts before creating the first WQ. */
        ret = mlx4_glue->dv_set_context_attr
                (priv->ctx,
@@ -488,6 +494,7 @@ mlx4_rxq_attach(struct rxq *rxq)
        }
 
        struct priv *priv = rxq->priv;
+       struct rte_eth_dev *dev = priv->dev;
        const uint32_t elts_n = 1 << rxq->elts_n;
        const uint32_t sges_n = 1 << rxq->sges_n;
        struct rte_mbuf *(*elts)[elts_n] = rxq->elts;
@@ -552,6 +559,11 @@ mlx4_rxq_attach(struct rxq *rxq)
                msg = "failed to obtain device information from WQ/CQ objects";
                goto error;
        }
+       /* Pre-register Rx mempool. */
+       DEBUG("port %u Rx queue %u registering mp %s having %u chunks",
+             priv->dev->data->port_id, rxq->stats.idx,
+             rxq->mp->name, rxq->mp->nb_mem_chunks);
+       mlx4_mr_update_mp(dev, &rxq->mr_ctrl, rxq->mp);
        wqes = (volatile struct mlx4_wqe_data_seg (*)[])
                ((uintptr_t)dv_rwq.buf.buf + dv_rwq.rq.offset);
        for (i = 0; i != RTE_DIM(*elts); ++i) {
@@ -583,7 +595,7 @@ mlx4_rxq_attach(struct rxq *rxq)
                        .addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf,
                                                                  uintptr_t)),
                        .byte_count = rte_cpu_to_be_32(buf->data_len),
-                       .lkey = rte_cpu_to_be_32(rxq->mr->lkey),
+                       .lkey = mlx4_rx_mb2mr(rxq, buf),
                };
                (*elts)[i] = buf;
        }
@@ -666,7 +678,9 @@ uint64_t
 mlx4_get_rx_queue_offloads(struct priv *priv)
 {
        uint64_t offloads = DEV_RX_OFFLOAD_SCATTER |
-                           DEV_RX_OFFLOAD_CRC_STRIP;
+                           DEV_RX_OFFLOAD_CRC_STRIP |
+                           DEV_RX_OFFLOAD_KEEP_CRC |
+                           DEV_RX_OFFLOAD_JUMBO_FRAME;
 
        if (priv->hw_csum)
                offloads |= DEV_RX_OFFLOAD_CHECKSUM;
@@ -765,16 +779,16 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                     (void *)dev, idx, desc);
        }
        /* By default, FCS (CRC) is stripped by hardware. */
-       if (offloads & DEV_RX_OFFLOAD_CRC_STRIP) {
-               crc_present = 0;
-       } else if (priv->hw_fcs_strip) {
-               crc_present = 1;
-       } else {
-               WARN("%p: CRC stripping has been disabled but will still"
-                    " be performed by hardware, make sure MLNX_OFED and"
-                    " firmware are up to date",
-                    (void *)dev);
-               crc_present = 0;
+       crc_present = 0;
+       if (rte_eth_dev_must_keep_crc(offloads)) {
+               if (priv->hw_fcs_strip) {
+                       crc_present = 1;
+               } else {
+                       WARN("%p: CRC stripping has been disabled but will still"
+                            " be performed by hardware, make sure MLNX_OFED and"
+                            " firmware are up to date",
+                            (void *)dev);
+               }
        }
        DEBUG("%p: CRC stripping is %s, %u bytes will be subtracted from"
              " incoming frames to hide it",
@@ -855,11 +869,9 @@ mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
                      1 << rxq->sges_n);
                goto error;
        }
-       /* Use the entire Rx mempool as the memory region. */
-       rxq->mr = mlx4_mr_get(priv, mp);
-       if (!rxq->mr) {
-               ERROR("%p: MR creation failure: %s",
-                     (void *)dev, strerror(rte_errno));
+       if (mlx4_mr_btree_init(&rxq->mr_ctrl.cache_bh,
+                              MLX4_MR_BTREE_CACHE_N, socket)) {
+               /* rte_errno is already set. */
                goto error;
        }
        if (dev->data->dev_conf.intr_conf.rxq) {
@@ -919,7 +931,6 @@ mlx4_rx_queue_release(void *dpdk_rxq)
        assert(!rxq->rq_db);
        if (rxq->channel)
                claim_zero(mlx4_glue->destroy_comp_channel(rxq->channel));
-       if (rxq->mr)
-               mlx4_mr_put(rxq->mr);
+       mlx4_mr_btree_free(&rxq->mr_ctrl.cache_bh);
        rte_free(rxq);
 }