2 * Copyright (C) 2013 Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
35 #define NTB_LINK_DOWN 0
39 NTB_EVENT_SW_EVENT0 = 0,
44 NTB_EVENT_HW_LINK_DOWN,
49 typedef int (*ntb_db_callback)(void *data, int db_num);
50 typedef void (*ntb_event_callback)(void *data, enum ntb_hw_event event);
52 int ntb_register_event_callback(struct ntb_softc *ntb, ntb_event_callback func);
53 void ntb_unregister_event_callback(struct ntb_softc *ntb);
54 int ntb_register_db_callback(struct ntb_softc *ntb, unsigned int idx,
55 void *data, ntb_db_callback func);
56 void ntb_unregister_db_callback(struct ntb_softc *ntb, unsigned int idx);
57 void *ntb_find_transport(struct ntb_softc *ntb);
58 struct ntb_softc *ntb_register_transport(struct ntb_softc *ntb,
60 void ntb_unregister_transport(struct ntb_softc *ntb);
61 uint8_t ntb_get_max_spads(struct ntb_softc *ntb);
62 int ntb_write_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val);
63 int ntb_read_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val);
64 int ntb_write_remote_spad(struct ntb_softc *ntb, unsigned int idx,
66 int ntb_read_remote_spad(struct ntb_softc *ntb, unsigned int idx,
68 void *ntb_get_mw_vbase(struct ntb_softc *ntb, unsigned int mw);
69 vm_paddr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw);
70 u_long ntb_get_mw_size(struct ntb_softc *ntb, unsigned int mw);
71 void ntb_set_mw_addr(struct ntb_softc *ntb, unsigned int mw, uint64_t addr);
72 void ntb_ring_doorbell(struct ntb_softc *ntb, unsigned int db);
73 bool ntb_query_link_status(struct ntb_softc *ntb);
74 device_t ntb_get_device(struct ntb_softc *ntb);
76 #define NTB_BAR_SIZE_4K (1 << 0)
77 /* REGS_THRU_MW is the equivalent of Linux's NTB_HWERR_SDOORBELL_LOCKUP */
78 #define NTB_REGS_THRU_MW (1 << 1)
79 #define NTB_SB01BASE_LOCKUP (1 << 2)
80 #define NTB_B2BDOORBELL_BIT14 (1 << 3)
81 bool ntb_has_feature(struct ntb_softc *, uint64_t);
83 #endif /* _NTB_HW_H_ */