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 279a5325c2SAlexander Motin struct ntb_transport_qp; 289a5325c2SAlexander Motin 299a5325c2SAlexander Motin enum ntb_link_event { 309a5325c2SAlexander Motin NTB_LINK_DOWN = 0, 319a5325c2SAlexander Motin NTB_LINK_UP, 329a5325c2SAlexander Motin }; 339a5325c2SAlexander Motin 349a5325c2SAlexander Motin struct ntb_queue_handlers { 359a5325c2SAlexander Motin void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data, 369a5325c2SAlexander Motin void *data, int len); 379a5325c2SAlexander Motin void (*tx_handler)(struct ntb_transport_qp *qp, void *qp_data, 389a5325c2SAlexander Motin void *data, int len); 399a5325c2SAlexander Motin void (*event_handler)(void *data, enum ntb_link_event status); 409a5325c2SAlexander Motin }; 419a5325c2SAlexander Motin 426bd57d14SAlexander Motin int ntb_transport_queue_count(device_t dev); 436bd57d14SAlexander Motin struct ntb_transport_qp * 446bd57d14SAlexander Motin ntb_transport_create_queue(device_t dev, int q, 456bd57d14SAlexander Motin const struct ntb_queue_handlers *handlers, void *data); 466bd57d14SAlexander Motin void ntb_transport_free_queue(struct ntb_transport_qp *qp); 479a5325c2SAlexander Motin unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp); 489a5325c2SAlexander Motin unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp); 499a5325c2SAlexander Motin int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, 509a5325c2SAlexander Motin unsigned int len); 519a5325c2SAlexander Motin int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, 529a5325c2SAlexander Motin unsigned int len); 539a5325c2SAlexander Motin void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len); 549a5325c2SAlexander Motin void ntb_transport_link_up(struct ntb_transport_qp *qp); 559a5325c2SAlexander Motin void ntb_transport_link_down(struct ntb_transport_qp *qp); 569a5325c2SAlexander Motin bool ntb_transport_link_query(struct ntb_transport_qp *qp); 57*48c47677SAlexander Motin uint64_t ntb_transport_link_speed(struct ntb_transport_qp *qp); 589a5325c2SAlexander Motin unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp); 59