xref: /freebsd/sys/dev/ntb/ntb_transport.h (revision 48c4767756a1e2a77abfed24e34650f74ba1c540)
19a5325c2SAlexander Motin /*-
29a5325c2SAlexander Motin  * Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
39a5325c2SAlexander Motin  * All rights reserved.
49a5325c2SAlexander Motin  *
59a5325c2SAlexander Motin  * Redistribution and use in source and binary forms, with or without
69a5325c2SAlexander Motin  * modification, are permitted provided that the following conditions
79a5325c2SAlexander Motin  * are met:
89a5325c2SAlexander Motin  * 1. Redistributions of source code must retain the above copyright
99a5325c2SAlexander Motin  *    notice, this list of conditions and the following disclaimer.
109a5325c2SAlexander Motin  * 2. Redistributions in binary form must reproduce the above copyright
119a5325c2SAlexander Motin  *    notice, this list of conditions and the following disclaimer in the
129a5325c2SAlexander Motin  *    documentation and/or other materials provided with the distribution.
139a5325c2SAlexander Motin  *
149a5325c2SAlexander Motin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
159a5325c2SAlexander Motin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
169a5325c2SAlexander Motin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
179a5325c2SAlexander Motin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
189a5325c2SAlexander Motin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199a5325c2SAlexander Motin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
209a5325c2SAlexander Motin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
219a5325c2SAlexander Motin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
229a5325c2SAlexander Motin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
239a5325c2SAlexander Motin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
249a5325c2SAlexander Motin  * SUCH DAMAGE.
259a5325c2SAlexander Motin  *
269a5325c2SAlexander Motin  * $FreeBSD$
279a5325c2SAlexander Motin  */
289a5325c2SAlexander Motin 
299a5325c2SAlexander Motin struct ntb_transport_qp;
309a5325c2SAlexander Motin 
319a5325c2SAlexander Motin extern devclass_t ntb_transport_devclass;
329a5325c2SAlexander Motin 
339a5325c2SAlexander Motin enum ntb_link_event {
349a5325c2SAlexander Motin 	NTB_LINK_DOWN = 0,
359a5325c2SAlexander Motin 	NTB_LINK_UP,
369a5325c2SAlexander Motin };
379a5325c2SAlexander Motin 
389a5325c2SAlexander Motin struct ntb_queue_handlers {
399a5325c2SAlexander Motin 	void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data,
409a5325c2SAlexander Motin 	    void *data, int len);
419a5325c2SAlexander Motin 	void (*tx_handler)(struct ntb_transport_qp *qp, void *qp_data,
429a5325c2SAlexander Motin 	    void *data, int len);
439a5325c2SAlexander Motin 	void (*event_handler)(void *data, enum ntb_link_event status);
449a5325c2SAlexander Motin };
459a5325c2SAlexander Motin 
466bd57d14SAlexander Motin int ntb_transport_queue_count(device_t dev);
476bd57d14SAlexander Motin struct ntb_transport_qp *
486bd57d14SAlexander Motin ntb_transport_create_queue(device_t dev, int q,
496bd57d14SAlexander Motin     const struct ntb_queue_handlers *handlers, void *data);
506bd57d14SAlexander Motin void ntb_transport_free_queue(struct ntb_transport_qp *qp);
519a5325c2SAlexander Motin unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp);
529a5325c2SAlexander Motin unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp);
539a5325c2SAlexander Motin int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
549a5325c2SAlexander Motin 			     unsigned int len);
559a5325c2SAlexander Motin int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
569a5325c2SAlexander Motin 			     unsigned int len);
579a5325c2SAlexander Motin void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len);
589a5325c2SAlexander Motin void ntb_transport_link_up(struct ntb_transport_qp *qp);
599a5325c2SAlexander Motin void ntb_transport_link_down(struct ntb_transport_qp *qp);
609a5325c2SAlexander Motin bool ntb_transport_link_query(struct ntb_transport_qp *qp);
61*48c47677SAlexander Motin uint64_t ntb_transport_link_speed(struct ntb_transport_qp *qp);
629a5325c2SAlexander Motin unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp);
63