/*1* Copyright (c) 2007 Cisco Systems. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/3132#ifndef IB_UMEM_H33#define IB_UMEM_H3435#include <linux/list.h>36#include <linux/scatterlist.h>37#include <linux/workqueue.h>3839struct ib_ucontext;4041struct ib_umem {42struct ib_ucontext *context;43size_t length;44int offset;45int page_size;46int writable;47int hugetlb;48struct list_head chunk_list;49struct work_struct work;50struct mm_struct *mm;51unsigned long diff;52};5354struct ib_umem_chunk {55struct list_head list;56int nents;57int nmap;58struct scatterlist page_list[0];59};6061#ifdef CONFIG_INFINIBAND_USER_MEM6263struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,64size_t size, int access, int dmasync);65void ib_umem_release(struct ib_umem *umem);66int ib_umem_page_count(struct ib_umem *umem);6768#else /* CONFIG_INFINIBAND_USER_MEM */6970#include <linux/err.h>7172static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,73unsigned long addr, size_t size,74int access, int dmasync) {75return ERR_PTR(-EINVAL);76}77static inline void ib_umem_release(struct ib_umem *umem) { }78static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }7980#endif /* CONFIG_INFINIBAND_USER_MEM */8182#endif /* IB_UMEM_H */838485