1278886Shselasky/* 2278886Shselasky * Copyright (c) 2013, Mellanox Technologies. All rights reserved. 3278886Shselasky * 4278886Shselasky * This software is available to you under a choice of one of two 5278886Shselasky * licenses. You may choose to be licensed under the terms of the GNU 6278886Shselasky * General Public License (GPL) Version 2, available from the file 7278886Shselasky * COPYING in the main directory of this source tree, or the 8278886Shselasky * OpenIB.org BSD license below: 9278886Shselasky * 10278886Shselasky * Redistribution and use in source and binary forms, with or 11278886Shselasky * without modification, are permitted provided that the following 12278886Shselasky * conditions are met: 13278886Shselasky * 14278886Shselasky * - Redistributions of source code must retain the above 15278886Shselasky * copyright notice, this list of conditions and the following 16278886Shselasky * disclaimer. 17278886Shselasky * 18278886Shselasky * - Redistributions in binary form must reproduce the above 19278886Shselasky * copyright notice, this list of conditions and the following 20278886Shselasky * disclaimer in the documentation and/or other materials 21278886Shselasky * provided with the distribution. 22278886Shselasky * 23278886Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24278886Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25278886Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26278886Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27278886Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28278886Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29278886Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30278886Shselasky * SOFTWARE. 31278886Shselasky */ 32278886Shselasky 33278886Shselasky#if !defined(PEER_MEM_H) 34278886Shselasky#define PEER_MEM_H 35278886Shselasky 36278886Shselasky#include <linux/module.h> 37278886Shselasky#include <linux/slab.h> 38278886Shselasky#include <linux/errno.h> 39278886Shselasky#include <linux/scatterlist.h> 40278886Shselasky#include <linux/mutex.h> 41278886Shselasky 42278886Shselasky 43278886Shselasky#define IB_PEER_MEMORY_NAME_MAX 64 44278886Shselasky#define IB_PEER_MEMORY_VER_MAX 16 45278886Shselasky 46278886Shselaskystruct peer_memory_client { 47278886Shselasky char name[IB_PEER_MEMORY_NAME_MAX]; 48278886Shselasky char version[IB_PEER_MEMORY_VER_MAX]; 49278886Shselasky /* acquire return code: 1 mine, 0 - not mine */ 50278886Shselasky int (*acquire) (unsigned long addr, size_t size, void *peer_mem_private_data, 51278886Shselasky char *peer_mem_name, void **client_context); 52278886Shselasky int (*get_pages) (unsigned long addr, 53278886Shselasky size_t size, int write, int force, 54278886Shselasky struct sg_table *sg_head, 55278886Shselasky void *client_context, void *core_context); 56278886Shselasky int (*dma_map) (struct sg_table *sg_head, void *client_context, 57278886Shselasky struct device *dma_device, int dmasync, int *nmap); 58278886Shselasky int (*dma_unmap) (struct sg_table *sg_head, void *client_context, 59278886Shselasky struct device *dma_device); 60278886Shselasky void (*put_pages) (struct sg_table *sg_head, void *client_context); 61278886Shselasky unsigned long (*get_page_size) (void *client_context); 62278886Shselasky void (*release) (void *client_context); 63278886Shselasky 64278886Shselasky}; 65278886Shselasky 66278886Shselaskytypedef int (*invalidate_peer_memory)(void *reg_handle, 67278886Shselasky void *core_context); 68278886Shselasky 69278886Shselaskyvoid *ib_register_peer_memory_client(struct peer_memory_client *peer_client, 70278886Shselasky invalidate_peer_memory *invalidate_callback); 71278886Shselaskyvoid ib_unregister_peer_memory_client(void *reg_handle); 72278886Shselasky 73278886Shselasky#endif 74