18d59ecb2SHans Petter Selasky /*- 28d59ecb2SHans Petter Selasky * Copyright (c) 2010 Isilon Systems, Inc. 38d59ecb2SHans Petter Selasky * Copyright (c) 2010 iX Systems, Inc. 48d59ecb2SHans Petter Selasky * Copyright (c) 2010 Panasas, Inc. 58d59ecb2SHans Petter Selasky * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 68d59ecb2SHans Petter Selasky * All rights reserved. 78d59ecb2SHans Petter Selasky * 88d59ecb2SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 98d59ecb2SHans Petter Selasky * modification, are permitted provided that the following conditions 108d59ecb2SHans Petter Selasky * are met: 118d59ecb2SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 128d59ecb2SHans Petter Selasky * notice unmodified, this list of conditions, and the following 138d59ecb2SHans Petter Selasky * disclaimer. 148d59ecb2SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 158d59ecb2SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 168d59ecb2SHans Petter Selasky * documentation and/or other materials provided with the distribution. 178d59ecb2SHans Petter Selasky * 188d59ecb2SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 198d59ecb2SHans Petter Selasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 208d59ecb2SHans Petter Selasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 218d59ecb2SHans Petter Selasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 228d59ecb2SHans Petter Selasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 238d59ecb2SHans Petter Selasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 248d59ecb2SHans Petter Selasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 258d59ecb2SHans Petter Selasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 268d59ecb2SHans Petter Selasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 278d59ecb2SHans Petter Selasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 288d59ecb2SHans Petter Selasky * 298d59ecb2SHans Petter Selasky * $FreeBSD$ 308d59ecb2SHans Petter Selasky */ 318d59ecb2SHans Petter Selasky #ifndef _LINUX_DMAPOOL_H_ 328d59ecb2SHans Petter Selasky #define _LINUX_DMAPOOL_H_ 338d59ecb2SHans Petter Selasky 348d59ecb2SHans Petter Selasky #include <linux/types.h> 358d59ecb2SHans Petter Selasky #include <linux/io.h> 368d59ecb2SHans Petter Selasky #include <linux/scatterlist.h> 378d59ecb2SHans Petter Selasky #include <linux/device.h> 388d59ecb2SHans Petter Selasky #include <linux/slab.h> 398d59ecb2SHans Petter Selasky 40*93a203eaSHans Petter Selasky struct dma_pool; 41f211d536STycho Nightingale struct dma_pool *linux_dma_pool_create(char *name, struct device *dev, 42f211d536STycho Nightingale size_t size, size_t align, size_t boundary); 43f211d536STycho Nightingale void linux_dma_pool_destroy(struct dma_pool *pool); 44f211d536STycho Nightingale void *linux_dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, 45f211d536STycho Nightingale dma_addr_t *handle); 46f211d536STycho Nightingale void linux_dma_pool_free(struct dma_pool *pool, void *vaddr, 47f211d536STycho Nightingale dma_addr_t dma_addr); 48f211d536STycho Nightingale 498d59ecb2SHans Petter Selasky static inline struct dma_pool * 508d59ecb2SHans Petter Selasky dma_pool_create(char *name, struct device *dev, size_t size, 518d59ecb2SHans Petter Selasky size_t align, size_t boundary) 528d59ecb2SHans Petter Selasky { 538d59ecb2SHans Petter Selasky 54f211d536STycho Nightingale return (linux_dma_pool_create(name, dev, size, align, boundary)); 558d59ecb2SHans Petter Selasky } 568d59ecb2SHans Petter Selasky 578d59ecb2SHans Petter Selasky static inline void 588d59ecb2SHans Petter Selasky dma_pool_destroy(struct dma_pool *pool) 598d59ecb2SHans Petter Selasky { 60f211d536STycho Nightingale 61f211d536STycho Nightingale linux_dma_pool_destroy(pool); 628d59ecb2SHans Petter Selasky } 638d59ecb2SHans Petter Selasky 648d59ecb2SHans Petter Selasky static inline void * 658d59ecb2SHans Petter Selasky dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle) 668d59ecb2SHans Petter Selasky { 678d59ecb2SHans Petter Selasky 68f211d536STycho Nightingale return (linux_dma_pool_alloc(pool, mem_flags, handle)); 698d59ecb2SHans Petter Selasky } 708d59ecb2SHans Petter Selasky 718ad9551dSHans Petter Selasky static inline void * 728ad9551dSHans Petter Selasky dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle) 738ad9551dSHans Petter Selasky { 748ad9551dSHans Petter Selasky 758ad9551dSHans Petter Selasky return (dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle)); 768ad9551dSHans Petter Selasky } 778ad9551dSHans Petter Selasky 788d59ecb2SHans Petter Selasky static inline void 79f211d536STycho Nightingale dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma_addr) 808d59ecb2SHans Petter Selasky { 81f211d536STycho Nightingale 82f211d536STycho Nightingale linux_dma_pool_free(pool, vaddr, dma_addr); 838d59ecb2SHans Petter Selasky } 848d59ecb2SHans Petter Selasky 858d59ecb2SHans Petter Selasky 868d59ecb2SHans Petter Selasky #endif /* _LINUX_DMAPOOL_H_ */ 87