Lines Matching refs:bm_pool
387 struct mvpp2_bm_pool *bm_pool, int size) in mvpp2_bm_pool_create() argument
401 bm_pool->size_bytes = 2 * sizeof(u32) * size; in mvpp2_bm_pool_create()
403 bm_pool->size_bytes = 2 * sizeof(u64) * size; in mvpp2_bm_pool_create()
405 bm_pool->virt_addr = dma_alloc_coherent(dev, bm_pool->size_bytes, in mvpp2_bm_pool_create()
406 &bm_pool->dma_addr, in mvpp2_bm_pool_create()
408 if (!bm_pool->virt_addr) in mvpp2_bm_pool_create()
411 if (!IS_ALIGNED((unsigned long)bm_pool->virt_addr, in mvpp2_bm_pool_create()
413 dma_free_coherent(dev, bm_pool->size_bytes, in mvpp2_bm_pool_create()
414 bm_pool->virt_addr, bm_pool->dma_addr); in mvpp2_bm_pool_create()
416 bm_pool->id, MVPP2_BM_POOL_PTR_ALIGN); in mvpp2_bm_pool_create()
420 mvpp2_write(priv, MVPP2_BM_POOL_BASE_REG(bm_pool->id), in mvpp2_bm_pool_create()
421 lower_32_bits(bm_pool->dma_addr)); in mvpp2_bm_pool_create()
422 mvpp2_write(priv, MVPP2_BM_POOL_SIZE_REG(bm_pool->id), size); in mvpp2_bm_pool_create()
424 val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id)); in mvpp2_bm_pool_create()
439 mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val); in mvpp2_bm_pool_create()
441 bm_pool->size = size; in mvpp2_bm_pool_create()
442 bm_pool->pkt_size = 0; in mvpp2_bm_pool_create()
443 bm_pool->buf_num = 0; in mvpp2_bm_pool_create()
450 struct mvpp2_bm_pool *bm_pool, in mvpp2_bm_pool_bufsize_set() argument
455 bm_pool->buf_size = buf_size; in mvpp2_bm_pool_bufsize_set()
458 mvpp2_write(priv, MVPP2_POOL_BUF_SIZE_REG(bm_pool->id), val); in mvpp2_bm_pool_bufsize_set()
462 struct mvpp2_bm_pool *bm_pool, in mvpp2_bm_bufs_get_addrs() argument
469 MVPP2_BM_PHY_ALLOC_REG(bm_pool->id)); in mvpp2_bm_bufs_get_addrs()
493 struct mvpp2_bm_pool *bm_pool, int buf_num) in mvpp2_bm_bufs_free() argument
498 if (buf_num > bm_pool->buf_num) { in mvpp2_bm_bufs_free()
500 bm_pool->id, buf_num); in mvpp2_bm_bufs_free()
501 buf_num = bm_pool->buf_num; in mvpp2_bm_bufs_free()
505 pp = priv->page_pool[bm_pool->id]; in mvpp2_bm_bufs_free()
512 mvpp2_bm_bufs_get_addrs(dev, priv, bm_pool, in mvpp2_bm_bufs_free()
517 bm_pool->buf_size, DMA_FROM_DEVICE); in mvpp2_bm_bufs_free()
523 mvpp2_frag_free(bm_pool, pp, data); in mvpp2_bm_bufs_free()
527 bm_pool->buf_num -= i; in mvpp2_bm_bufs_free()
531 static int mvpp2_check_hw_buf_num(struct mvpp2 *priv, struct mvpp2_bm_pool *bm_pool) in mvpp2_check_hw_buf_num() argument
535 buf_num += mvpp2_read(priv, MVPP2_BM_POOL_PTRS_NUM_REG(bm_pool->id)) & in mvpp2_check_hw_buf_num()
537 buf_num += mvpp2_read(priv, MVPP2_BM_BPPI_PTRS_NUM_REG(bm_pool->id)) & in mvpp2_check_hw_buf_num()
549 struct mvpp2_bm_pool *bm_pool) in mvpp2_bm_pool_destroy() argument
554 buf_num = mvpp2_check_hw_buf_num(priv, bm_pool); in mvpp2_bm_pool_destroy()
555 mvpp2_bm_bufs_free(dev, priv, bm_pool, buf_num); in mvpp2_bm_pool_destroy()
558 buf_num = mvpp2_check_hw_buf_num(priv, bm_pool); in mvpp2_bm_pool_destroy()
561 bm_pool->id, bm_pool->buf_num); in mvpp2_bm_pool_destroy()
565 val = mvpp2_read(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id)); in mvpp2_bm_pool_destroy()
567 mvpp2_write(priv, MVPP2_BM_POOL_CTRL_REG(bm_pool->id), val); in mvpp2_bm_pool_destroy()
570 page_pool_destroy(priv->page_pool[bm_pool->id]); in mvpp2_bm_pool_destroy()
571 priv->page_pool[bm_pool->id] = NULL; in mvpp2_bm_pool_destroy()
574 dma_free_coherent(dev, bm_pool->size_bytes, in mvpp2_bm_pool_destroy()
575 bm_pool->virt_addr, in mvpp2_bm_pool_destroy()
576 bm_pool->dma_addr); in mvpp2_bm_pool_destroy()
583 struct mvpp2_bm_pool *bm_pool; in mvpp2_bm_pools_init() local
591 bm_pool = &priv->bm_pools[i]; in mvpp2_bm_pools_init()
592 bm_pool->id = i; in mvpp2_bm_pools_init()
593 err = mvpp2_bm_pool_create(dev, priv, bm_pool, size); in mvpp2_bm_pools_init()
596 mvpp2_bm_pool_bufsize_set(priv, bm_pool, 0); in mvpp2_bm_pools_init()
737 struct mvpp2_bm_pool *bm_pool, in mvpp2_buf_alloc() argument
747 data = mvpp2_frag_alloc(bm_pool, page_pool); in mvpp2_buf_alloc()
757 MVPP2_RX_BUF_SIZE(bm_pool->pkt_size), in mvpp2_buf_alloc()
760 mvpp2_frag_free(bm_pool, NULL, data); in mvpp2_buf_alloc()
1019 struct mvpp2_bm_pool *bm_pool, int buf_num) in mvpp2_bm_bufs_add() argument
1028 bm_pool->pkt_size > MVPP2_BM_LONG_PKT_SIZE) { in mvpp2_bm_bufs_add()
1034 buf_size = MVPP2_RX_BUF_SIZE(bm_pool->pkt_size); in mvpp2_bm_bufs_add()
1038 (buf_num + bm_pool->buf_num > bm_pool->size)) { in mvpp2_bm_bufs_add()
1041 buf_num, bm_pool->id); in mvpp2_bm_bufs_add()
1046 pp = port->priv->page_pool[bm_pool->id]; in mvpp2_bm_bufs_add()
1048 buf = mvpp2_buf_alloc(port, bm_pool, pp, &dma_addr, in mvpp2_bm_bufs_add()
1053 mvpp2_bm_pool_put(port, bm_pool->id, dma_addr, in mvpp2_bm_bufs_add()
1058 bm_pool->buf_num += i; in mvpp2_bm_bufs_add()
1062 bm_pool->id, bm_pool->pkt_size, buf_size, total_size); in mvpp2_bm_bufs_add()
1066 bm_pool->id, i, buf_num); in mvpp2_bm_bufs_add()
1228 struct mvpp2_bm_pool *bm_pool; in mvpp2_swf_bm_pool_init_percpu() local
1232 bm_pool = mvpp2_bm_pool_use_percpu(port, MVPP2_BM_SHORT, i, in mvpp2_swf_bm_pool_init_percpu()
1234 if (!bm_pool) in mvpp2_swf_bm_pool_init_percpu()
1237 bm_pool->port_map |= BIT(port->id); in mvpp2_swf_bm_pool_init_percpu()
1238 mvpp2_rxq_short_pool_set(port, i, bm_pool->id); in mvpp2_swf_bm_pool_init_percpu()
1242 bm_pool = mvpp2_bm_pool_use_percpu(port, MVPP2_BM_LONG, i + port->nrxqs, in mvpp2_swf_bm_pool_init_percpu()
1244 if (!bm_pool) in mvpp2_swf_bm_pool_init_percpu()
1247 bm_pool->port_map |= BIT(port->id); in mvpp2_swf_bm_pool_init_percpu()
1248 mvpp2_rxq_long_pool_set(port, i, bm_pool->id); in mvpp2_swf_bm_pool_init_percpu()
3565 struct mvpp2_bm_pool *bm_pool, in mvpp2_rx_refill() argument
3572 buf = mvpp2_buf_alloc(port, bm_pool, page_pool, in mvpp2_rx_refill()
3893 struct mvpp2_bm_pool *bm_pool; in mvpp2_rx() local
3917 bm_pool = &port->priv->bm_pools[pool]; in mvpp2_rx()
3945 if (bm_pool->frag_size > PAGE_SIZE) in mvpp2_rx()
3948 frag_size = bm_pool->frag_size; in mvpp2_rx()
3953 if (bm_pool->pkt_size == MVPP2_BM_SHORT_PKT_SIZE) in mvpp2_rx()
3967 err = mvpp2_rx_refill(port, bm_pool, pp, pool); in mvpp2_rx()
3994 err = mvpp2_rx_refill(port, bm_pool, pp, pool); in mvpp2_rx()
4005 bm_pool->buf_size, DMA_FROM_DEVICE, in mvpp2_rx()
7652 struct mvpp2_bm_pool *bm_pool = &priv->bm_pools[i]; in mvpp2_remove() local
7654 mvpp2_bm_pool_destroy(&pdev->dev, priv, bm_pool); in mvpp2_remove()