1/*- 2 * Copyright (C) 2013 Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: releng/10.2/sys/dev/ntb/ntb_hw/ntb_hw.h 255268 2013-09-05 22:46:48Z carl $ 27 */ 28 29#ifndef _NTB_HW_H_ 30#define _NTB_HW_H_ 31 32struct ntb_softc; 33 34#define NTB_NUM_MW 2 35#define NTB_LINK_DOWN 0 36#define NTB_LINK_UP 1 37 38enum ntb_hw_event { 39 NTB_EVENT_SW_EVENT0 = 0, 40 NTB_EVENT_SW_EVENT1, 41 NTB_EVENT_SW_EVENT2, 42 NTB_EVENT_HW_ERROR, 43 NTB_EVENT_HW_LINK_UP, 44 NTB_EVENT_HW_LINK_DOWN, 45}; 46 47typedef void (*ntb_db_callback)(void *data, int db_num); 48typedef void (*ntb_event_callback)(void *data, enum ntb_hw_event event); 49 50int ntb_register_event_callback(struct ntb_softc *ntb, ntb_event_callback func); 51void ntb_unregister_event_callback(struct ntb_softc *ntb); 52int ntb_register_db_callback(struct ntb_softc *ntb, unsigned int idx, 53 void *data, ntb_db_callback func); 54void ntb_unregister_db_callback(struct ntb_softc *ntb, unsigned int idx); 55void *ntb_find_transport(struct ntb_softc *ntb); 56struct ntb_softc *ntb_register_transport(struct ntb_softc *ntb, 57 void *transport); 58void ntb_unregister_transport(struct ntb_softc *ntb); 59int ntb_get_max_spads(struct ntb_softc *ntb); 60int ntb_write_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val); 61int ntb_read_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val); 62int ntb_write_remote_spad(struct ntb_softc *ntb, unsigned int idx, 63 uint32_t val); 64int ntb_read_remote_spad(struct ntb_softc *ntb, unsigned int idx, 65 uint32_t *val); 66void *ntb_get_mw_vbase(struct ntb_softc *ntb, unsigned int mw); 67vm_paddr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw); 68u_long ntb_get_mw_size(struct ntb_softc *ntb, unsigned int mw); 69void ntb_set_mw_addr(struct ntb_softc *ntb, unsigned int mw, uint64_t addr); 70void ntb_ring_sdb(struct ntb_softc *ntb, unsigned int db); 71bool ntb_query_link_status(struct ntb_softc *ntb); 72device_t ntb_get_device(struct ntb_softc *ntb); 73 74#endif /* _NTB_HW_H_ */ 75