ntb_hw.h revision 289538
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: head/sys/dev/ntb/ntb_hw/ntb_hw.h 289538 2015-10-18 20:19:44Z cem $ 27 */ 28 29#ifndef _NTB_HW_H_ 30#define _NTB_HW_H_ 31 32struct ntb_softc; 33 34#define NTB_MAX_NUM_MW 3 35 36enum ntb_link_event { 37 NTB_LINK_DOWN = 0, 38 NTB_LINK_UP, 39}; 40 41enum ntb_hw_event { 42 NTB_EVENT_SW_EVENT0 = 0, 43 NTB_EVENT_SW_EVENT1, 44 NTB_EVENT_SW_EVENT2, 45 NTB_EVENT_HW_ERROR, 46 NTB_EVENT_HW_LINK_UP, 47 NTB_EVENT_HW_LINK_DOWN, 48}; 49 50SYSCTL_DECL(_hw_ntb); 51 52typedef int (*ntb_db_callback)(void *data, int db_num); 53typedef void (*ntb_event_callback)(void *data, enum ntb_hw_event event); 54 55int ntb_register_event_callback(struct ntb_softc *ntb, ntb_event_callback func); 56void ntb_unregister_event_callback(struct ntb_softc *ntb); 57int ntb_register_db_callback(struct ntb_softc *ntb, unsigned int idx, 58 void *data, ntb_db_callback func); 59void ntb_unregister_db_callback(struct ntb_softc *ntb, unsigned int idx); 60void *ntb_find_transport(struct ntb_softc *ntb); 61struct ntb_softc *ntb_register_transport(struct ntb_softc *ntb, 62 void *transport); 63void ntb_unregister_transport(struct ntb_softc *ntb); 64uint8_t ntb_get_max_cbs(struct ntb_softc *ntb); 65uint8_t ntb_get_max_mw(struct ntb_softc *ntb); 66uint8_t ntb_get_max_spads(struct ntb_softc *ntb); 67int ntb_write_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val); 68int ntb_read_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val); 69int ntb_write_remote_spad(struct ntb_softc *ntb, unsigned int idx, 70 uint32_t val); 71int ntb_read_remote_spad(struct ntb_softc *ntb, unsigned int idx, 72 uint32_t *val); 73void *ntb_get_mw_vbase(struct ntb_softc *ntb, unsigned int mw); 74vm_paddr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw); 75u_long ntb_get_mw_size(struct ntb_softc *ntb, unsigned int mw); 76void ntb_set_mw_addr(struct ntb_softc *ntb, unsigned int mw, uint64_t addr); 77void ntb_ring_doorbell(struct ntb_softc *ntb, unsigned int db); 78bool ntb_query_link_status(struct ntb_softc *ntb); 79device_t ntb_get_device(struct ntb_softc *ntb); 80 81/* Hardware owns the low 32 bits of features. */ 82#define NTB_BAR_SIZE_4K (1 << 0) 83#define NTB_SDOORBELL_LOCKUP (1 << 1) 84#define NTB_SB01BASE_LOCKUP (1 << 2) 85#define NTB_B2BDOORBELL_BIT14 (1 << 3) 86/* Software/configuration owns the top 32 bits. */ 87#define NTB_SPLIT_BAR (1ull << 32) 88bool ntb_has_feature(struct ntb_softc *, uint64_t); 89 90#endif /* _NTB_HW_H_ */ 91