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