diff options
author | Ioana Radulescu <ruxandra.radulescu@freescale.com> | 2013-08-08 13:17:47 (GMT) |
---|---|---|
committer | Rivera Jose-B46482 <German.Rivera@freescale.com> | 2013-09-10 23:17:30 (GMT) |
commit | f1df4a5deb8b65f6e6f615a97918930f5923750e (patch) | |
tree | 1161365f83a20e696c47adede9364e7e24b9a325 /drivers/net/ethernet/freescale/dpa | |
parent | a1a881aba8cb274025e84eabf7ef3a1009510b63 (diff) | |
download | linux-fsl-qoriq-f1df4a5deb8b65f6e6f615a97918930f5923750e.tar.xz |
dpaa_eth: Replace drain callback in dpa_bp structure
Instead use a callback for freeing individual buffers acquired from
the pool. This solution is more flexible and allows for simpler code
when new pools will be added to the driver.
Signed-off-by: Ioana Radulescu <ruxandra.radulescu@freescale.com>
Change-Id: I52376b5dab53957e497b112df7c42ef18d7a9347
Reviewed-on: http://git.am.freescale.net:8181/4190
Reviewed-by: Rivera Jose-B46482 <German.Rivera@freescale.com>
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-on: http://git.am.freescale.net:8181/4467
Reviewed-by: Sovaiala Cristian-Constantin-B39531 <Cristian.Sovaiala@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/dpa')
4 files changed, 13 insertions, 9 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c index 42737d1..b239dc3 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c @@ -625,10 +625,12 @@ dpa_priv_bp_probe(struct device *dev) dpa_bp->percpu_count = alloc_percpu(*dpa_bp->percpu_count); dpa_bp->target_count = CONFIG_FSL_DPAA_ETH_MAX_BUF_COUNT; - dpa_bp->drain_cb = dpa_bp_drain; #ifdef CONFIG_FSL_DPAA_ETH_SG_SUPPORT dpa_bp->seed_cb = dpa_bp_priv_seed; + dpa_bp->free_buf_cb = _dpa_bp_free_pf; +#else + dpa_bp->free_buf_cb = _dpa_bp_free_skb; #endif /* CONFIG_FSL_DPAA_ETH_SG_SUPPORT */ return dpa_bp; diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth.h b/drivers/net/ethernet/freescale/dpa/dpaa_eth.h index 611e5d8..344fa87 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth.h @@ -348,8 +348,10 @@ struct dpa_bp { atomic_t refs; /* some bpools need to be seeded before use by this cb */ int (*seed_cb)(struct dpa_bp *); - /* some bpools need to be emptied before freeing by this cb */ - void (*drain_cb)(struct dpa_bp *); + /* some bpools need to be emptied before freeing; this cb is used + * for freeing of individual buffers taken from the pool + */ + void (*free_buf_cb)(void *addr); }; struct dpa_rx_errors { @@ -681,7 +683,7 @@ void dpa_bp_default_buf_size_update(uint32_t size); uint32_t dpa_bp_default_buf_size_get(void); void dpa_bp_priv_non_sg_seed(struct dpa_bp *dpa_bp); -static inline void _dpa_bp_free_buf(void *addr) +static inline void _dpa_bp_free_skb(void *addr) { struct sk_buff **skbh = addr; struct sk_buff *skb; @@ -690,7 +692,7 @@ static inline void _dpa_bp_free_buf(void *addr) dev_kfree_skb_any(skb); } #else -static inline void _dpa_bp_free_buf(void *addr) +static inline void _dpa_bp_free_pf(void *addr) { put_page(virt_to_head_page(addr)); } diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_common.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_common.c index 82900dc..be31b7d 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_common.c @@ -724,7 +724,7 @@ void dpa_bp_drain(struct dpa_bp *bp) dma_unmap_single(bp->dev, addr, bp->size, DMA_BIDIRECTIONAL); - _dpa_bp_free_buf(phys_to_virt(addr)); + bp->free_buf_cb(phys_to_virt(addr)); } } while (num == 8); } @@ -737,8 +737,8 @@ _dpa_bp_free(struct dpa_bp *dpa_bp) if (!atomic_dec_and_test(&bp->refs)) return; - if (bp->drain_cb) - bp->drain_cb(bp); + if (bp->free_buf_cb) + dpa_bp_drain(bp); dpa_bp_array[bp->bpid] = 0; bman_free_pool(bp->pool); diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.c index 4856e15..08f9001 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.c @@ -364,7 +364,7 @@ void dpa_unit_test_drain_default_pool(struct net_device *net_dev) default_pool->size, DMA_BIDIRECTIONAL); - _dpa_bp_free_buf(phys_to_virt(addr)); + dpa_bp->free_buf_cb(phys_to_virt(addr)); } } while (num == 8); |