diff options
author | Madalin Bucur <madalin.bucur@freescale.com> | 2013-07-30 13:12:52 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-07-31 21:50:16 (GMT) |
commit | afc6f594c4f7f77f1bca9fe90c7a4ac80a95a416 (patch) | |
tree | 1daef3a73d3714df54bd591e50ccaac89d0c5d5b /drivers/net/ethernet/freescale/dpa | |
parent | 83821dd80bccd017570355049612050c98285d0b (diff) | |
download | linux-fsl-qoriq-afc6f594c4f7f77f1bca9fe90c7a4ac80a95a416.tar.xz |
dpaa_eth: private bpool seeding code refactoring
Moved globals used only by non-sg code to the apropriate file,
renamed seeding functions.
Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
Change-Id: If9a4945be3e7a1d6ce3c752ba3c2f581651b5dec
Reviewed-on: http://git.am.freescale.net:8181/3659
Reviewed-by: Hamciuc Bogdan-BHAMCIU1 <bogdan.hamciuc@freescale.com>
Reviewed-by: Radulescu Ruxandra Ioana-B05472 <ruxandra.radulescu@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/dpa')
6 files changed, 48 insertions, 21 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c index 01954f5..2976f7e 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c @@ -119,8 +119,6 @@ int dpa_free_pcd_fqids(struct device *, uint32_t) __attribute__((weak)); #define DPAA_ETH_MAX_PAD (L1_CACHE_BYTES * 8) struct dpa_bp *default_pool; -bool default_pool_seeded; -uint32_t default_buf_size; /* A set of callbacks for hooking into the fastpath at different points. */ struct dpaa_eth_hooks_s dpaa_eth_hooks; @@ -514,11 +512,7 @@ static int __cold dpa_eth_priv_start(struct net_device *net_dev) * of a private port. Update the percpu buffer counters * of each private interface. */ - if (!default_pool_seeded) { - default_pool->size = default_buf_size; - dpa_make_private_pool(default_pool); - default_pool_seeded = true; - } + dpa_bp_priv_non_sg_seed(default_pool); #endif dpaa_eth_napi_enable(priv); @@ -641,6 +635,10 @@ dpa_priv_bp_probe(struct device *dev) 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; +#endif /* CONFIG_FSL_DPAA_ETH_SG_SUPPORT */ + return dpa_bp; } @@ -687,9 +685,9 @@ dpa_priv_bp_alloc(struct dpa_bp *dpa_bp) dpa_bp->dev = &pdev->dev; -#ifdef CONFIG_FSL_DPAA_ETH_SG_SUPPORT - dpa_make_private_pool(dpa_bp); -#endif + if (dpa_bp->seed_cb) + dpa_bp->seed_cb(dpa_bp); + default_pool = dpa_bp; dpa_bpid2pool_map(dpa_bp->bpid, dpa_bp); @@ -808,8 +806,7 @@ dpaa_eth_priv_probe(struct platform_device *_of_dev) */ dpa_bp->size = dpa_bp_size(&buf_layout[RX]); #ifndef CONFIG_FSL_DPAA_ETH_SG_SUPPORT - if (dpa_bp->size > default_buf_size) - default_buf_size = dpa_bp->size; + dpa_bp_default_buf_size_update(dpa_bp->size); #endif INIT_LIST_HEAD(&priv->dpa_fq_list); diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth.h b/drivers/net/ethernet/freescale/dpa/dpaa_eth.h index fed4109..4f743c3 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth.h +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth.h @@ -118,14 +118,14 @@ struct dpa_buffer_layout_s { SMP_CACHE_BYTES) /* We must ensure that skb_shinfo is always cacheline-aligned. */ #define DPA_SKB_SIZE(size) ((size) & ~(SMP_CACHE_BYTES - 1)) -#else +#else /* CONFIG_FSL_DPAA_ETH_SG_SUPPORT */ /* Default buffer size is based on L2 MAX_FRM value, minus the FCS which * is stripped down by hardware. */ #define dpa_bp_size(buffer_layout) \ dpa_get_buffer_size(buffer_layout, (dpa_get_max_frm() - ETH_FCS_LEN)) -#endif +#endif /* CONFIG_FSL_DPAA_ETH_SG_SUPPORT */ /* * Maximum size of a buffer for which recycling is allowed. @@ -475,7 +475,7 @@ struct fm_port_fqs { }; /* functions with different implementation for SG and non-SG: */ -void dpa_make_private_pool(struct dpa_bp *dpa_bp); +void dpa_bp_priv_seed(struct dpa_bp *dpa_bp); int dpaa_eth_refill_bpools(struct dpa_percpu_priv_s *percpu_priv); void __hot _dpa_rx(struct net_device *net_dev, const struct dpa_priv_s *priv, @@ -699,6 +699,10 @@ static inline void _dpa_assign_wq(struct dpa_fq *fq) #endif #ifndef CONFIG_FSL_DPAA_ETH_SG_SUPPORT +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) { struct sk_buff **skbh = addr; diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_non_sg.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_non_sg.c index 9927918..428553a 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_non_sg.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_non_sg.c @@ -52,6 +52,7 @@ dpa_get_buffer_size(&priv->buf_layout[TX], 256) extern struct dpaa_eth_hooks_s dpaa_eth_hooks; +uint32_t default_buf_size; /* Allocate 8 socket buffers. * These buffers are counted for a particular CPU. @@ -120,9 +121,21 @@ static void dpa_bp_add_8(const struct dpa_bp *dpa_bp, unsigned int cpu) } } -void dpa_make_private_pool(struct dpa_bp *dpa_bp) +void dpa_bp_default_buf_size_update(uint32_t size) +{ + if (size > default_buf_size) + default_buf_size = size; +} + +uint32_t dpa_bp_default_buf_size_get(void) +{ + return default_buf_size; +} + +void dpa_bp_priv_seed(struct dpa_bp *dpa_bp) { int i; + dpa_bp->size = default_buf_size; /* Give each cpu an allotment of "count" buffers */ for_each_online_cpu(i) { @@ -133,6 +146,18 @@ void dpa_make_private_pool(struct dpa_bp *dpa_bp) } } +void dpa_bp_priv_non_sg_seed(struct dpa_bp *dpa_bp) +{ + static bool default_pool_seeded; + + if (default_pool_seeded) + return; + + default_pool_seeded = true; + + dpa_bp_priv_seed(dpa_bp); +} + /* Add buffers/(skbuffs) for Rx processing whenever bpool count falls below * REFILL_THRESHOLD. */ diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c index 588c2d7..0b5d269 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c @@ -132,7 +132,7 @@ void dpa_bp_add_8_bufs(const struct dpa_bp *dpa_bp, int cpu) *count_ptr += _dpa_bp_add_8_bufs(dpa_bp); } -void dpa_make_private_pool(struct dpa_bp *dpa_bp) +void dpa_bp_priv_seed(struct dpa_bp *dpa_bp) { int i; 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 7c820d9..224720f 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.c @@ -378,8 +378,11 @@ void dpa_unit_test_seed_default_pool(struct net_device *net_dev) priv = netdev_priv(net_dev); - default_pool->size = default_buf_size; - dpa_make_private_pool(default_pool); +#ifndef CONFIG_FSL_DPAA_ETH_SG_SUPPORT + default_pool->size = dpa_bp_default_buf_size_get(); +#endif /* CONFIG_FSL_DPAA_ETH_SG_SUPPORT */ + + dpa_bp_priv_seed(default_pool); } void dpa_unit_tests(struct net_device *net_dev) diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.h b/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.h index 21ee967..fbc9035 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.h +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_unit_test.h @@ -35,8 +35,6 @@ extern int dpa_max_frm; extern struct dpa_bp *default_pool; -extern bool default_pool_seeded; -extern uint32_t default_buf_size; void dpa_unit_tests(struct net_device *net_dev); |