net/mlx5e: Replace multiplication by stride size with a shift
authorTariq Toukan <tariqt@mellanox.com>
Sun, 2 Jul 2017 16:02:05 +0000 (19:02 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Sun, 3 Sep 2017 03:34:08 +0000 (06:34 +0300)
In RX data-path, use shift operations instead of a regular multiplication
by stride size, as it is a power of two.

Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

index d964db286c95579094b8e77c6a8bcbedba7eafce..44bd8df905caf526351c39dd37568e968a1d5f16 100644 (file)
@@ -535,8 +535,8 @@ struct mlx5e_rq {
                struct {
                        struct mlx5e_mpw_info *info;
                        void                  *mtt_no_align;
-                       u16                    stride_sz;
                        u16                    num_strides;
+                       u8                     log_stride_sz;
                } mpwqe;
        };
        struct {
index 94761d0e1b333c53f57a3b6f4efac49faeaa315b..7a25d952c922136b8effe354babba1f92ac8d05e 100644 (file)
@@ -615,10 +615,10 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
                        goto err_rq_wq_destroy;
                }
 
-               rq->mpwqe.stride_sz = BIT(params->mpwqe_log_stride_sz);
+               rq->mpwqe.log_stride_sz = params->mpwqe_log_stride_sz;
                rq->mpwqe.num_strides = BIT(params->mpwqe_log_num_strides);
 
-               rq->buff.wqe_sz = rq->mpwqe.stride_sz * rq->mpwqe.num_strides;
+               rq->buff.wqe_sz = rq->mpwqe.num_strides << rq->mpwqe.log_stride_sz;
                byte_count = rq->buff.wqe_sz;
 
                err = mlx5e_create_rq_umr_mkey(mdev, rq);
index 1b50f1e7e48a38176ea083e145b3d5f1c71979c7..aa5cc15908599c7f64ede6a65793cd4cab373f09 100644 (file)
@@ -304,7 +304,7 @@ static inline void mlx5e_add_skb_frag_mpwqe(struct mlx5e_rq *rq,
                                            u32 page_idx, u32 frag_offset,
                                            u32 len)
 {
-       unsigned int truesize = ALIGN(len, rq->mpwqe.stride_sz);
+       unsigned int truesize = ALIGN(len, BIT(rq->mpwqe.log_stride_sz));
 
        dma_sync_single_for_cpu(rq->pdev,
                                wi->umr.dma_info[page_idx].addr + frag_offset,
@@ -910,7 +910,7 @@ static inline void mlx5e_mpwqe_fill_rx_skb(struct mlx5e_rq *rq,
                                           struct sk_buff *skb)
 {
        u16 stride_ix      = mpwrq_get_cqe_stride_index(cqe);
-       u32 wqe_offset     = stride_ix * rq->mpwqe.stride_sz;
+       u32 wqe_offset     = stride_ix << rq->mpwqe.log_stride_sz;
        u32 head_offset    = wqe_offset & (PAGE_SIZE - 1);
        u32 page_idx       = wqe_offset >> PAGE_SHIFT;
        u32 head_page_idx  = page_idx;