xref: /openbmc/linux/include/linux/ntb_transport.h (revision e74bfeed)
1ec110bc7SAllen Hubbe /*
2ec110bc7SAllen Hubbe  * This file is provided under a dual BSD/GPLv2 license.  When using or
3ec110bc7SAllen Hubbe  *   redistributing this file, you may do so under either license.
4ec110bc7SAllen Hubbe  *
5ec110bc7SAllen Hubbe  *   GPL LICENSE SUMMARY
6ec110bc7SAllen Hubbe  *
7ec110bc7SAllen Hubbe  *   Copyright(c) 2012 Intel Corporation. All rights reserved.
8e26a5843SAllen Hubbe  *   Copyright (C) 2015 EMC Corporation. All Rights Reserved.
9ec110bc7SAllen Hubbe  *
10ec110bc7SAllen Hubbe  *   This program is free software; you can redistribute it and/or modify
11ec110bc7SAllen Hubbe  *   it under the terms of version 2 of the GNU General Public License as
12ec110bc7SAllen Hubbe  *   published by the Free Software Foundation.
13ec110bc7SAllen Hubbe  *
14ec110bc7SAllen Hubbe  *   BSD LICENSE
15ec110bc7SAllen Hubbe  *
16ec110bc7SAllen Hubbe  *   Copyright(c) 2012 Intel Corporation. All rights reserved.
17e26a5843SAllen Hubbe  *   Copyright (C) 2015 EMC Corporation. All Rights Reserved.
18ec110bc7SAllen Hubbe  *
19ec110bc7SAllen Hubbe  *   Redistribution and use in source and binary forms, with or without
20ec110bc7SAllen Hubbe  *   modification, are permitted provided that the following conditions
21ec110bc7SAllen Hubbe  *   are met:
22ec110bc7SAllen Hubbe  *
23ec110bc7SAllen Hubbe  *     * Redistributions of source code must retain the above copyright
24ec110bc7SAllen Hubbe  *       notice, this list of conditions and the following disclaimer.
25ec110bc7SAllen Hubbe  *     * Redistributions in binary form must reproduce the above copy
26ec110bc7SAllen Hubbe  *       notice, this list of conditions and the following disclaimer in
27ec110bc7SAllen Hubbe  *       the documentation and/or other materials provided with the
28ec110bc7SAllen Hubbe  *       distribution.
29ec110bc7SAllen Hubbe  *     * Neither the name of Intel Corporation nor the names of its
30ec110bc7SAllen Hubbe  *       contributors may be used to endorse or promote products derived
31ec110bc7SAllen Hubbe  *       from this software without specific prior written permission.
32ec110bc7SAllen Hubbe  *
33ec110bc7SAllen Hubbe  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34ec110bc7SAllen Hubbe  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35ec110bc7SAllen Hubbe  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
36ec110bc7SAllen Hubbe  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37ec110bc7SAllen Hubbe  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38ec110bc7SAllen Hubbe  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39ec110bc7SAllen Hubbe  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
40ec110bc7SAllen Hubbe  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
41ec110bc7SAllen Hubbe  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42ec110bc7SAllen Hubbe  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43ec110bc7SAllen Hubbe  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44ec110bc7SAllen Hubbe  *
45e26a5843SAllen Hubbe  * PCIe NTB Transport Linux driver
46ec110bc7SAllen Hubbe  *
47ec110bc7SAllen Hubbe  * Contact Information:
48ec110bc7SAllen Hubbe  * Jon Mason <jon.mason@intel.com>
49ec110bc7SAllen Hubbe  */
50ec110bc7SAllen Hubbe 
51ec110bc7SAllen Hubbe struct ntb_transport_qp;
52ec110bc7SAllen Hubbe 
53e26a5843SAllen Hubbe struct ntb_transport_client {
54ec110bc7SAllen Hubbe 	struct device_driver driver;
55e26a5843SAllen Hubbe 	int (*probe)(struct device *client_dev);
56e26a5843SAllen Hubbe 	void (*remove)(struct device *client_dev);
57ec110bc7SAllen Hubbe };
58ec110bc7SAllen Hubbe 
59e26a5843SAllen Hubbe int ntb_transport_register_client(struct ntb_transport_client *drvr);
60e26a5843SAllen Hubbe void ntb_transport_unregister_client(struct ntb_transport_client *drvr);
61e26a5843SAllen Hubbe int ntb_transport_register_client_dev(char *device_name);
62e26a5843SAllen Hubbe void ntb_transport_unregister_client_dev(char *device_name);
63ec110bc7SAllen Hubbe 
64ec110bc7SAllen Hubbe struct ntb_queue_handlers {
65ec110bc7SAllen Hubbe 	void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data,
66ec110bc7SAllen Hubbe 			   void *data, int len);
67ec110bc7SAllen Hubbe 	void (*tx_handler)(struct ntb_transport_qp *qp, void *qp_data,
68ec110bc7SAllen Hubbe 			   void *data, int len);
69ec110bc7SAllen Hubbe 	void (*event_handler)(void *data, int status);
70ec110bc7SAllen Hubbe };
71ec110bc7SAllen Hubbe 
72ec110bc7SAllen Hubbe unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp);
73ec110bc7SAllen Hubbe unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp);
74ec110bc7SAllen Hubbe struct ntb_transport_qp *
75e26a5843SAllen Hubbe ntb_transport_create_queue(void *data, struct device *client_dev,
76ec110bc7SAllen Hubbe 			   const struct ntb_queue_handlers *handlers);
77ec110bc7SAllen Hubbe void ntb_transport_free_queue(struct ntb_transport_qp *qp);
78ec110bc7SAllen Hubbe int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
79ec110bc7SAllen Hubbe 			     unsigned int len);
80ec110bc7SAllen Hubbe int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
81ec110bc7SAllen Hubbe 			     unsigned int len);
82ec110bc7SAllen Hubbe void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len);
83ec110bc7SAllen Hubbe void ntb_transport_link_up(struct ntb_transport_qp *qp);
84ec110bc7SAllen Hubbe void ntb_transport_link_down(struct ntb_transport_qp *qp);
85ec110bc7SAllen Hubbe bool ntb_transport_link_query(struct ntb_transport_qp *qp);
86e74bfeedSDave Jiang unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp);
87