|
@@ -200,7 +200,6 @@ int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix)
|
|
|
|
|
|
*((dma_addr_t *)skb->cb) = dma_addr;
|
|
|
wqe->data.addr = cpu_to_be64(dma_addr);
|
|
|
- wqe->data.lkey = rq->mkey_be;
|
|
|
|
|
|
rq->skb[ix] = skb;
|
|
|
|
|
@@ -231,44 +230,11 @@ static inline int mlx5e_mpwqe_strides_per_page(struct mlx5e_rq *rq)
|
|
|
return rq->mpwqe_num_strides >> MLX5_MPWRQ_WQE_PAGE_ORDER;
|
|
|
}
|
|
|
|
|
|
-static inline void
|
|
|
-mlx5e_dma_pre_sync_linear_mpwqe(struct device *pdev,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- u32 wqe_offset, u32 len)
|
|
|
-{
|
|
|
- dma_sync_single_for_cpu(pdev, wi->dma_info.addr + wqe_offset,
|
|
|
- len, DMA_FROM_DEVICE);
|
|
|
-}
|
|
|
-
|
|
|
-static inline void
|
|
|
-mlx5e_dma_pre_sync_fragmented_mpwqe(struct device *pdev,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- u32 wqe_offset, u32 len)
|
|
|
-{
|
|
|
- /* No dma pre sync for fragmented MPWQE */
|
|
|
-}
|
|
|
-
|
|
|
-static inline void
|
|
|
-mlx5e_add_skb_frag_linear_mpwqe(struct mlx5e_rq *rq,
|
|
|
- struct sk_buff *skb,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- u32 page_idx, u32 frag_offset,
|
|
|
- u32 len)
|
|
|
-{
|
|
|
- unsigned int truesize = ALIGN(len, rq->mpwqe_stride_sz);
|
|
|
-
|
|
|
- wi->skbs_frags[page_idx]++;
|
|
|
- skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
|
|
|
- &wi->dma_info.page[page_idx], frag_offset,
|
|
|
- len, truesize);
|
|
|
-}
|
|
|
-
|
|
|
-static inline void
|
|
|
-mlx5e_add_skb_frag_fragmented_mpwqe(struct mlx5e_rq *rq,
|
|
|
- struct sk_buff *skb,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- u32 page_idx, u32 frag_offset,
|
|
|
- u32 len)
|
|
|
+static inline void mlx5e_add_skb_frag_mpwqe(struct mlx5e_rq *rq,
|
|
|
+ struct sk_buff *skb,
|
|
|
+ struct mlx5e_mpw_info *wi,
|
|
|
+ u32 page_idx, u32 frag_offset,
|
|
|
+ u32 len)
|
|
|
{
|
|
|
unsigned int truesize = ALIGN(len, rq->mpwqe_stride_sz);
|
|
|
|
|
@@ -282,24 +248,11 @@ mlx5e_add_skb_frag_fragmented_mpwqe(struct mlx5e_rq *rq,
|
|
|
}
|
|
|
|
|
|
static inline void
|
|
|
-mlx5e_copy_skb_header_linear_mpwqe(struct device *pdev,
|
|
|
- struct sk_buff *skb,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- u32 page_idx, u32 offset,
|
|
|
- u32 headlen)
|
|
|
-{
|
|
|
- struct page *page = &wi->dma_info.page[page_idx];
|
|
|
-
|
|
|
- skb_copy_to_linear_data(skb, page_address(page) + offset,
|
|
|
- ALIGN(headlen, sizeof(long)));
|
|
|
-}
|
|
|
-
|
|
|
-static inline void
|
|
|
-mlx5e_copy_skb_header_fragmented_mpwqe(struct device *pdev,
|
|
|
- struct sk_buff *skb,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- u32 page_idx, u32 offset,
|
|
|
- u32 headlen)
|
|
|
+mlx5e_copy_skb_header_mpwqe(struct device *pdev,
|
|
|
+ struct sk_buff *skb,
|
|
|
+ struct mlx5e_mpw_info *wi,
|
|
|
+ u32 page_idx, u32 offset,
|
|
|
+ u32 headlen)
|
|
|
{
|
|
|
u16 headlen_pg = min_t(u32, headlen, PAGE_SIZE - offset);
|
|
|
struct mlx5e_dma_info *dma_info = &wi->umr.dma_info[page_idx];
|
|
@@ -324,46 +277,9 @@ mlx5e_copy_skb_header_fragmented_mpwqe(struct device *pdev,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix)
|
|
|
-{
|
|
|
- return rq->mpwqe_mtt_offset +
|
|
|
- wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
|
|
|
-}
|
|
|
-
|
|
|
-static void mlx5e_build_umr_wqe(struct mlx5e_rq *rq,
|
|
|
- struct mlx5e_sq *sq,
|
|
|
- struct mlx5e_umr_wqe *wqe,
|
|
|
- u16 ix)
|
|
|
+static inline void mlx5e_post_umr_wqe(struct mlx5e_rq *rq, u16 ix)
|
|
|
{
|
|
|
- struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl;
|
|
|
- struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl;
|
|
|
- struct mlx5_wqe_data_seg *dseg = &wqe->data;
|
|
|
struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
|
|
|
- u8 ds_cnt = DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS);
|
|
|
- u32 umr_wqe_mtt_offset = mlx5e_get_wqe_mtt_offset(rq, ix);
|
|
|
-
|
|
|
- memset(wqe, 0, sizeof(*wqe));
|
|
|
- cseg->opmod_idx_opcode =
|
|
|
- cpu_to_be32((sq->pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) |
|
|
|
- MLX5_OPCODE_UMR);
|
|
|
- cseg->qpn_ds = cpu_to_be32((sq->sqn << MLX5_WQE_CTRL_QPN_SHIFT) |
|
|
|
- ds_cnt);
|
|
|
- cseg->fm_ce_se = MLX5_WQE_CTRL_CQ_UPDATE;
|
|
|
- cseg->imm = rq->umr_mkey_be;
|
|
|
-
|
|
|
- ucseg->flags = MLX5_UMR_TRANSLATION_OFFSET_EN;
|
|
|
- ucseg->klm_octowords =
|
|
|
- cpu_to_be16(MLX5_MTT_OCTW(MLX5_MPWRQ_PAGES_PER_WQE));
|
|
|
- ucseg->bsf_octowords =
|
|
|
- cpu_to_be16(MLX5_MTT_OCTW(umr_wqe_mtt_offset));
|
|
|
- ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE);
|
|
|
-
|
|
|
- dseg->lkey = sq->mkey_be;
|
|
|
- dseg->addr = cpu_to_be64(wi->umr.mtt_addr);
|
|
|
-}
|
|
|
-
|
|
|
-static void mlx5e_post_umr_wqe(struct mlx5e_rq *rq, u16 ix)
|
|
|
-{
|
|
|
struct mlx5e_sq *sq = &rq->channel->icosq;
|
|
|
struct mlx5_wq_cyc *wq = &sq->wq;
|
|
|
struct mlx5e_umr_wqe *wqe;
|
|
@@ -378,129 +294,141 @@ static void mlx5e_post_umr_wqe(struct mlx5e_rq *rq, u16 ix)
|
|
|
}
|
|
|
|
|
|
wqe = mlx5_wq_cyc_get_wqe(wq, pi);
|
|
|
- mlx5e_build_umr_wqe(rq, sq, wqe, ix);
|
|
|
+ memcpy(wqe, &wi->umr.wqe, sizeof(*wqe));
|
|
|
+ wqe->ctrl.opmod_idx_opcode =
|
|
|
+ cpu_to_be32((sq->pc << MLX5_WQE_CTRL_WQE_INDEX_SHIFT) |
|
|
|
+ MLX5_OPCODE_UMR);
|
|
|
+
|
|
|
sq->ico_wqe_info[pi].opcode = MLX5_OPCODE_UMR;
|
|
|
sq->ico_wqe_info[pi].num_wqebbs = num_wqebbs;
|
|
|
sq->pc += num_wqebbs;
|
|
|
mlx5e_tx_notify_hw(sq, &wqe->ctrl, 0);
|
|
|
}
|
|
|
|
|
|
-static inline int mlx5e_get_wqe_mtt_sz(void)
|
|
|
+static inline bool mlx5e_rx_cache_put(struct mlx5e_rq *rq,
|
|
|
+ struct mlx5e_dma_info *dma_info)
|
|
|
{
|
|
|
- /* UMR copies MTTs in units of MLX5_UMR_MTT_ALIGNMENT bytes.
|
|
|
- * To avoid copying garbage after the mtt array, we allocate
|
|
|
- * a little more.
|
|
|
- */
|
|
|
- return ALIGN(MLX5_MPWRQ_PAGES_PER_WQE * sizeof(__be64),
|
|
|
- MLX5_UMR_MTT_ALIGNMENT);
|
|
|
+ struct mlx5e_page_cache *cache = &rq->page_cache;
|
|
|
+ u32 tail_next = (cache->tail + 1) & (MLX5E_CACHE_SIZE - 1);
|
|
|
+
|
|
|
+ if (tail_next == cache->head) {
|
|
|
+ rq->stats.cache_full++;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ cache->page_cache[cache->tail] = *dma_info;
|
|
|
+ cache->tail = tail_next;
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+static inline bool mlx5e_rx_cache_get(struct mlx5e_rq *rq,
|
|
|
+ struct mlx5e_dma_info *dma_info)
|
|
|
+{
|
|
|
+ struct mlx5e_page_cache *cache = &rq->page_cache;
|
|
|
+
|
|
|
+ if (unlikely(cache->head == cache->tail)) {
|
|
|
+ rq->stats.cache_empty++;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (page_ref_count(cache->page_cache[cache->head].page) != 1) {
|
|
|
+ rq->stats.cache_busy++;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ *dma_info = cache->page_cache[cache->head];
|
|
|
+ cache->head = (cache->head + 1) & (MLX5E_CACHE_SIZE - 1);
|
|
|
+ rq->stats.cache_reuse++;
|
|
|
+
|
|
|
+ dma_sync_single_for_device(rq->pdev, dma_info->addr, PAGE_SIZE,
|
|
|
+ DMA_FROM_DEVICE);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
-static int mlx5e_alloc_and_map_page(struct mlx5e_rq *rq,
|
|
|
- struct mlx5e_mpw_info *wi,
|
|
|
- int i)
|
|
|
+static inline int mlx5e_page_alloc_mapped(struct mlx5e_rq *rq,
|
|
|
+ struct mlx5e_dma_info *dma_info)
|
|
|
{
|
|
|
struct page *page;
|
|
|
|
|
|
+ if (mlx5e_rx_cache_get(rq, dma_info))
|
|
|
+ return 0;
|
|
|
+
|
|
|
page = dev_alloc_page();
|
|
|
if (unlikely(!page))
|
|
|
return -ENOMEM;
|
|
|
|
|
|
- wi->umr.dma_info[i].page = page;
|
|
|
- wi->umr.dma_info[i].addr = dma_map_page(rq->pdev, page, 0, PAGE_SIZE,
|
|
|
- PCI_DMA_FROMDEVICE);
|
|
|
- if (unlikely(dma_mapping_error(rq->pdev, wi->umr.dma_info[i].addr))) {
|
|
|
+ dma_info->page = page;
|
|
|
+ dma_info->addr = dma_map_page(rq->pdev, page, 0, PAGE_SIZE,
|
|
|
+ DMA_FROM_DEVICE);
|
|
|
+ if (unlikely(dma_mapping_error(rq->pdev, dma_info->addr))) {
|
|
|
put_page(page);
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
- wi->umr.mtt[i] = cpu_to_be64(wi->umr.dma_info[i].addr | MLX5_EN_WR);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int mlx5e_alloc_rx_fragmented_mpwqe(struct mlx5e_rq *rq,
|
|
|
- struct mlx5e_rx_wqe *wqe,
|
|
|
- u16 ix)
|
|
|
+void mlx5e_page_release(struct mlx5e_rq *rq, struct mlx5e_dma_info *dma_info,
|
|
|
+ bool recycle)
|
|
|
+{
|
|
|
+ if (likely(recycle) && mlx5e_rx_cache_put(rq, dma_info))
|
|
|
+ return;
|
|
|
+
|
|
|
+ dma_unmap_page(rq->pdev, dma_info->addr, PAGE_SIZE, DMA_FROM_DEVICE);
|
|
|
+ put_page(dma_info->page);
|
|
|
+}
|
|
|
+
|
|
|
+static int mlx5e_alloc_rx_umr_mpwqe(struct mlx5e_rq *rq,
|
|
|
+ struct mlx5e_rx_wqe *wqe,
|
|
|
+ u16 ix)
|
|
|
{
|
|
|
struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
|
|
|
- int mtt_sz = mlx5e_get_wqe_mtt_sz();
|
|
|
u64 dma_offset = (u64)mlx5e_get_wqe_mtt_offset(rq, ix) << PAGE_SHIFT;
|
|
|
+ int pg_strides = mlx5e_mpwqe_strides_per_page(rq);
|
|
|
+ int err;
|
|
|
int i;
|
|
|
|
|
|
- wi->umr.dma_info = kmalloc(sizeof(*wi->umr.dma_info) *
|
|
|
- MLX5_MPWRQ_PAGES_PER_WQE,
|
|
|
- GFP_ATOMIC);
|
|
|
- if (unlikely(!wi->umr.dma_info))
|
|
|
- goto err_out;
|
|
|
-
|
|
|
- /* We allocate more than mtt_sz as we will align the pointer */
|
|
|
- wi->umr.mtt_no_align = kzalloc(mtt_sz + MLX5_UMR_ALIGN - 1,
|
|
|
- GFP_ATOMIC);
|
|
|
- if (unlikely(!wi->umr.mtt_no_align))
|
|
|
- goto err_free_umr;
|
|
|
-
|
|
|
- wi->umr.mtt = PTR_ALIGN(wi->umr.mtt_no_align, MLX5_UMR_ALIGN);
|
|
|
- wi->umr.mtt_addr = dma_map_single(rq->pdev, wi->umr.mtt, mtt_sz,
|
|
|
- PCI_DMA_TODEVICE);
|
|
|
- if (unlikely(dma_mapping_error(rq->pdev, wi->umr.mtt_addr)))
|
|
|
- goto err_free_mtt;
|
|
|
-
|
|
|
for (i = 0; i < MLX5_MPWRQ_PAGES_PER_WQE; i++) {
|
|
|
- if (unlikely(mlx5e_alloc_and_map_page(rq, wi, i)))
|
|
|
+ struct mlx5e_dma_info *dma_info = &wi->umr.dma_info[i];
|
|
|
+
|
|
|
+ err = mlx5e_page_alloc_mapped(rq, dma_info);
|
|
|
+ if (unlikely(err))
|
|
|
goto err_unmap;
|
|
|
- page_ref_add(wi->umr.dma_info[i].page,
|
|
|
- mlx5e_mpwqe_strides_per_page(rq));
|
|
|
+ wi->umr.mtt[i] = cpu_to_be64(dma_info->addr | MLX5_EN_WR);
|
|
|
+ page_ref_add(dma_info->page, pg_strides);
|
|
|
wi->skbs_frags[i] = 0;
|
|
|
}
|
|
|
|
|
|
wi->consumed_strides = 0;
|
|
|
- wi->dma_pre_sync = mlx5e_dma_pre_sync_fragmented_mpwqe;
|
|
|
- wi->add_skb_frag = mlx5e_add_skb_frag_fragmented_mpwqe;
|
|
|
- wi->copy_skb_header = mlx5e_copy_skb_header_fragmented_mpwqe;
|
|
|
- wi->free_wqe = mlx5e_free_rx_fragmented_mpwqe;
|
|
|
- wqe->data.lkey = rq->umr_mkey_be;
|
|
|
wqe->data.addr = cpu_to_be64(dma_offset);
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
err_unmap:
|
|
|
while (--i >= 0) {
|
|
|
- dma_unmap_page(rq->pdev, wi->umr.dma_info[i].addr, PAGE_SIZE,
|
|
|
- PCI_DMA_FROMDEVICE);
|
|
|
- page_ref_sub(wi->umr.dma_info[i].page,
|
|
|
- mlx5e_mpwqe_strides_per_page(rq));
|
|
|
- put_page(wi->umr.dma_info[i].page);
|
|
|
- }
|
|
|
- dma_unmap_single(rq->pdev, wi->umr.mtt_addr, mtt_sz, PCI_DMA_TODEVICE);
|
|
|
-
|
|
|
-err_free_mtt:
|
|
|
- kfree(wi->umr.mtt_no_align);
|
|
|
+ struct mlx5e_dma_info *dma_info = &wi->umr.dma_info[i];
|
|
|
|
|
|
-err_free_umr:
|
|
|
- kfree(wi->umr.dma_info);
|
|
|
+ page_ref_sub(dma_info->page, pg_strides);
|
|
|
+ mlx5e_page_release(rq, dma_info, true);
|
|
|
+ }
|
|
|
|
|
|
-err_out:
|
|
|
- return -ENOMEM;
|
|
|
+ return err;
|
|
|
}
|
|
|
|
|
|
-void mlx5e_free_rx_fragmented_mpwqe(struct mlx5e_rq *rq,
|
|
|
- struct mlx5e_mpw_info *wi)
|
|
|
+void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi)
|
|
|
{
|
|
|
- int mtt_sz = mlx5e_get_wqe_mtt_sz();
|
|
|
+ int pg_strides = mlx5e_mpwqe_strides_per_page(rq);
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; i < MLX5_MPWRQ_PAGES_PER_WQE; i++) {
|
|
|
- dma_unmap_page(rq->pdev, wi->umr.dma_info[i].addr, PAGE_SIZE,
|
|
|
- PCI_DMA_FROMDEVICE);
|
|
|
- page_ref_sub(wi->umr.dma_info[i].page,
|
|
|
- mlx5e_mpwqe_strides_per_page(rq) - wi->skbs_frags[i]);
|
|
|
- put_page(wi->umr.dma_info[i].page);
|
|
|
+ struct mlx5e_dma_info *dma_info = &wi->umr.dma_info[i];
|
|
|
+
|
|
|
+ page_ref_sub(dma_info->page, pg_strides - wi->skbs_frags[i]);
|
|
|
+ mlx5e_page_release(rq, dma_info, true);
|
|
|
}
|
|
|
- dma_unmap_single(rq->pdev, wi->umr.mtt_addr, mtt_sz, PCI_DMA_TODEVICE);
|
|
|
- kfree(wi->umr.mtt_no_align);
|
|
|
- kfree(wi->umr.dma_info);
|
|
|
}
|
|
|
|
|
|
-void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq)
|
|
|
+void mlx5e_post_rx_mpwqe(struct mlx5e_rq *rq)
|
|
|
{
|
|
|
struct mlx5_wq_ll *wq = &rq->wq;
|
|
|
struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head);
|
|
@@ -508,12 +436,11 @@ void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq)
|
|
|
clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
|
|
|
|
|
|
if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) {
|
|
|
- mlx5e_free_rx_fragmented_mpwqe(rq, &rq->wqe_info[wq->head]);
|
|
|
+ mlx5e_free_rx_mpwqe(rq, &rq->wqe_info[wq->head]);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index));
|
|
|
- rq->stats.mpwqe_frag++;
|
|
|
|
|
|
/* ensure wqes are visible to device before updating doorbell record */
|
|
|
dma_wmb();
|
|
@@ -521,84 +448,23 @@ void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq)
|
|
|
mlx5_wq_ll_update_db_record(wq);
|
|
|
}
|
|
|
|
|
|
-static int mlx5e_alloc_rx_linear_mpwqe(struct mlx5e_rq *rq,
|
|
|
- struct mlx5e_rx_wqe *wqe,
|
|
|
- u16 ix)
|
|
|
-{
|
|
|
- struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
|
|
|
- gfp_t gfp_mask;
|
|
|
- int i;
|
|
|
-
|
|
|
- gfp_mask = GFP_ATOMIC | __GFP_COLD | __GFP_MEMALLOC;
|
|
|
- wi->dma_info.page = alloc_pages_node(NUMA_NO_NODE, gfp_mask,
|
|
|
- MLX5_MPWRQ_WQE_PAGE_ORDER);
|
|
|
- if (unlikely(!wi->dma_info.page))
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- wi->dma_info.addr = dma_map_page(rq->pdev, wi->dma_info.page, 0,
|
|
|
- rq->wqe_sz, PCI_DMA_FROMDEVICE);
|
|
|
- if (unlikely(dma_mapping_error(rq->pdev, wi->dma_info.addr))) {
|
|
|
- put_page(wi->dma_info.page);
|
|
|
- return -ENOMEM;
|
|
|
- }
|
|
|
-
|
|
|
- /* We split the high-order page into order-0 ones and manage their
|
|
|
- * reference counter to minimize the memory held by small skb fragments
|
|
|
- */
|
|
|
- split_page(wi->dma_info.page, MLX5_MPWRQ_WQE_PAGE_ORDER);
|
|
|
- for (i = 0; i < MLX5_MPWRQ_PAGES_PER_WQE; i++) {
|
|
|
- page_ref_add(&wi->dma_info.page[i],
|
|
|
- mlx5e_mpwqe_strides_per_page(rq));
|
|
|
- wi->skbs_frags[i] = 0;
|
|
|
- }
|
|
|
-
|
|
|
- wi->consumed_strides = 0;
|
|
|
- wi->dma_pre_sync = mlx5e_dma_pre_sync_linear_mpwqe;
|
|
|
- wi->add_skb_frag = mlx5e_add_skb_frag_linear_mpwqe;
|
|
|
- wi->copy_skb_header = mlx5e_copy_skb_header_linear_mpwqe;
|
|
|
- wi->free_wqe = mlx5e_free_rx_linear_mpwqe;
|
|
|
- wqe->data.lkey = rq->mkey_be;
|
|
|
- wqe->data.addr = cpu_to_be64(wi->dma_info.addr);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-void mlx5e_free_rx_linear_mpwqe(struct mlx5e_rq *rq,
|
|
|
- struct mlx5e_mpw_info *wi)
|
|
|
-{
|
|
|
- int i;
|
|
|
-
|
|
|
- dma_unmap_page(rq->pdev, wi->dma_info.addr, rq->wqe_sz,
|
|
|
- PCI_DMA_FROMDEVICE);
|
|
|
- for (i = 0; i < MLX5_MPWRQ_PAGES_PER_WQE; i++) {
|
|
|
- page_ref_sub(&wi->dma_info.page[i],
|
|
|
- mlx5e_mpwqe_strides_per_page(rq) - wi->skbs_frags[i]);
|
|
|
- put_page(&wi->dma_info.page[i]);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix)
|
|
|
+int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_rx_wqe *wqe, u16 ix)
|
|
|
{
|
|
|
int err;
|
|
|
|
|
|
- err = mlx5e_alloc_rx_linear_mpwqe(rq, wqe, ix);
|
|
|
- if (unlikely(err)) {
|
|
|
- err = mlx5e_alloc_rx_fragmented_mpwqe(rq, wqe, ix);
|
|
|
- if (unlikely(err))
|
|
|
- return err;
|
|
|
- set_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
|
|
|
- mlx5e_post_umr_wqe(rq, ix);
|
|
|
- return -EBUSY;
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
+ err = mlx5e_alloc_rx_umr_mpwqe(rq, wqe, ix);
|
|
|
+ if (unlikely(err))
|
|
|
+ return err;
|
|
|
+ set_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
|
|
|
+ mlx5e_post_umr_wqe(rq, ix);
|
|
|
+ return -EBUSY;
|
|
|
}
|
|
|
|
|
|
void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
|
|
|
{
|
|
|
struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
|
|
|
|
|
|
- wi->free_wqe(rq, wi);
|
|
|
+ mlx5e_free_rx_mpwqe(rq, wi);
|
|
|
}
|
|
|
|
|
|
#define RQ_CANNOT_POST(rq) \
|
|
@@ -617,9 +483,10 @@ bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
|
|
|
int err;
|
|
|
|
|
|
err = rq->alloc_wqe(rq, wqe, wq->head);
|
|
|
+ if (err == -EBUSY)
|
|
|
+ return true;
|
|
|
if (unlikely(err)) {
|
|
|
- if (err != -EBUSY)
|
|
|
- rq->stats.buff_alloc_err++;
|
|
|
+ rq->stats.buff_alloc_err++;
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -831,7 +698,6 @@ static inline void mlx5e_mpwqe_fill_rx_skb(struct mlx5e_rq *rq,
|
|
|
u32 cqe_bcnt,
|
|
|
struct sk_buff *skb)
|
|
|
{
|
|
|
- u32 consumed_bytes = ALIGN(cqe_bcnt, rq->mpwqe_stride_sz);
|
|
|
u16 stride_ix = mpwrq_get_cqe_stride_index(cqe);
|
|
|
u32 wqe_offset = stride_ix * rq->mpwqe_stride_sz;
|
|
|
u32 head_offset = wqe_offset & (PAGE_SIZE - 1);
|
|
@@ -845,21 +711,20 @@ static inline void mlx5e_mpwqe_fill_rx_skb(struct mlx5e_rq *rq,
|
|
|
page_idx++;
|
|
|
frag_offset -= PAGE_SIZE;
|
|
|
}
|
|
|
- wi->dma_pre_sync(rq->pdev, wi, wqe_offset, consumed_bytes);
|
|
|
|
|
|
while (byte_cnt) {
|
|
|
u32 pg_consumed_bytes =
|
|
|
min_t(u32, PAGE_SIZE - frag_offset, byte_cnt);
|
|
|
|
|
|
- wi->add_skb_frag(rq, skb, wi, page_idx, frag_offset,
|
|
|
- pg_consumed_bytes);
|
|
|
+ mlx5e_add_skb_frag_mpwqe(rq, skb, wi, page_idx, frag_offset,
|
|
|
+ pg_consumed_bytes);
|
|
|
byte_cnt -= pg_consumed_bytes;
|
|
|
frag_offset = 0;
|
|
|
page_idx++;
|
|
|
}
|
|
|
/* copy header */
|
|
|
- wi->copy_skb_header(rq->pdev, skb, wi, head_page_idx, head_offset,
|
|
|
- headlen);
|
|
|
+ mlx5e_copy_skb_header_mpwqe(rq->pdev, skb, wi, head_page_idx,
|
|
|
+ head_offset, headlen);
|
|
|
/* skb linear part was allocated with headlen and aligned to long */
|
|
|
skb->tail += headlen;
|
|
|
skb->len += headlen;
|
|
@@ -904,7 +769,7 @@ mpwrq_cqe_out:
|
|
|
if (likely(wi->consumed_strides < rq->mpwqe_num_strides))
|
|
|
return;
|
|
|
|
|
|
- wi->free_wqe(rq, wi);
|
|
|
+ mlx5e_free_rx_mpwqe(rq, wi);
|
|
|
mlx5_wq_ll_pop(&rq->wq, cqe->wqe_id, &wqe->next.next_wqe_index);
|
|
|
}
|
|
|
|