/* Support for hardware buffer manager. * * Copyright (C) 2016 Marvell * * Gregory CLEMENT * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #include #include #include #include void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) { if (likely(bm_pool->frag_size <= PAGE_SIZE)) skb_free_frag(buf); else kfree(buf); } EXPORT_SYMBOL_GPL(hwbm_buf_free); /* Refill processing for HW buffer management */ int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) { int frag_size = bm_pool->frag_size; void *buf; if (likely(frag_size <= PAGE_SIZE)) buf = netdev_alloc_frag(frag_size); else buf = kmalloc(frag_size, gfp); if (!buf) return -ENOMEM; if (bm_pool->construct) if (bm_pool->construct(bm_pool, buf)) { hwbm_buf_free(bm_pool, buf); return -ENOMEM; } return 0; } EXPORT_SYMBOL_GPL(hwbm_pool_refill); int hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num, gfp_t gfp) { int err, i; unsigned long flags; spin_lock_irqsave(&bm_pool->lock, flags); if (bm_pool->buf_num == bm_pool->size) { pr_warn("pool already filled\n"); spin_unlock_irqrestore(&bm_pool->lock, flags); return bm_pool->buf_num; } if (buf_num + bm_pool->buf_num > bm_pool->size) { pr_warn("cannot allocate %d buffers for pool\n", buf_num); spin_unlock_irqrestore(&bm_pool->lock, flags); return 0; } if ((buf_num + bm_pool->buf_num) < bm_pool->buf_num) { pr_warn("Adding %d buffers to the %d current buffers will overflow\n", buf_num, bm_pool->buf_num); spin_unlock_irqrestore(&bm_pool->lock, flags); return 0; } for (i = 0; i < buf_num; i++) { err = hwbm_pool_refill(bm_pool, gfp); if (err < 0) break; } /* Update BM driver with number of buffers added to pool */ bm_pool->buf_num += i; pr_debug("hwpm pool: %d of %d buffers added\n", i, buf_num); spin_unlock_irqrestore(&bm_pool->lock, flags); return i; } EXPORT_SYMBOL_GPL(hwbm_pool_add); t/sched/sch_fifo.c'>
diff options
context:
space:
mode:
authorBhumika Goyal <bhumirks@gmail.com>2017-01-25 00:54:07 +0530
committerDan Williams <dan.j.williams@intel.com>2017-01-31 18:16:30 -0800
commit970d14e3989160ee9e97c7d75ecbc893fd29dab9 (patch)
tree4a731cac4efedb17f86a912ec56c151d26792abe /net/sched/sch_fifo.c
parent7a308bb3016f57e5be11a677d15b821536419d36 (diff)
nvdimm: constify device_type structures
Declare device_type structure as const as it is only stored in the type field of a device structure. This field is of type const, so add const to declaration of device_type structure. File size before: text data bss dec hex filename 19278 3199 16 22493 57dd nvdimm/namespace_devs.o File size after: text data bss dec hex filename 19929 3160 16 23105 5a41 nvdimm/namespace_devs.o Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'net/sched/sch_fifo.c')