2013-04-29 22:48:53 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (C) 2013 Intel Corporation
|
NTB: "Split ntb_hw_intel and ntb_transport drivers"
This Linux commit was more or less a rewrite. Unfortunately, the commit
log does not give a lot of context for the rewrite. I have tried to
faithfully follow the changes made upstream, including matching function
names where possible, while churning the FreeBSD driver as little as
possible.
This is the bulk of the rewrite. There are two groups of changes to
follow in separate commits: fleshing out the rest of the changes to
xeon_setup_b2b_mw(), and some changes to if_ntb.
Yes, this is a big patch (3 files changed, 416 insertions(+), 237
deletions(-)), but the Linux patch was 13 files changed, 2,589
additions(+) and 2,195 deletions(-).
Original Linux commit log:
Change ntb_hw_intel to use the new NTB hardware abstraction layer.
Split ntb_transport into its own driver. Change it to use the new NTB
hardware abstraction layer.
Authored by: Allen Hubbe
Obtained from: Linux (e26a5843) (Dual BSD/GPL driver)
Sponsored by: EMC / Isilon Storage Division
2015-10-18 20:20:20 +00:00
|
|
|
* Copyright (C) 2015 EMC Corporation
|
2013-04-29 22:48:53 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NTB_HW_H_
|
|
|
|
#define _NTB_HW_H_
|
|
|
|
|
|
|
|
struct ntb_softc;
|
|
|
|
|
2015-10-15 23:46:07 +00:00
|
|
|
#define NTB_MAX_NUM_MW 3
|
2015-10-14 23:44:42 +00:00
|
|
|
|
|
|
|
enum ntb_link_event {
|
|
|
|
NTB_LINK_DOWN = 0,
|
|
|
|
NTB_LINK_UP,
|
|
|
|
};
|
2013-04-29 22:48:53 +00:00
|
|
|
|
|
|
|
enum ntb_hw_event {
|
|
|
|
NTB_EVENT_SW_EVENT0 = 0,
|
|
|
|
NTB_EVENT_SW_EVENT1,
|
|
|
|
NTB_EVENT_SW_EVENT2,
|
|
|
|
NTB_EVENT_HW_ERROR,
|
|
|
|
NTB_EVENT_HW_LINK_UP,
|
|
|
|
NTB_EVENT_HW_LINK_DOWN,
|
|
|
|
};
|
|
|
|
|
2015-10-13 03:11:21 +00:00
|
|
|
SYSCTL_DECL(_hw_ntb);
|
|
|
|
|
2015-10-14 02:14:45 +00:00
|
|
|
typedef int (*ntb_db_callback)(void *data, int db_num);
|
2013-04-29 22:48:53 +00:00
|
|
|
typedef void (*ntb_event_callback)(void *data, enum ntb_hw_event event);
|
|
|
|
|
|
|
|
int ntb_register_event_callback(struct ntb_softc *ntb, ntb_event_callback func);
|
|
|
|
void ntb_unregister_event_callback(struct ntb_softc *ntb);
|
|
|
|
int ntb_register_db_callback(struct ntb_softc *ntb, unsigned int idx,
|
|
|
|
void *data, ntb_db_callback func);
|
|
|
|
void ntb_unregister_db_callback(struct ntb_softc *ntb, unsigned int idx);
|
|
|
|
void *ntb_find_transport(struct ntb_softc *ntb);
|
|
|
|
struct ntb_softc *ntb_register_transport(struct ntb_softc *ntb,
|
|
|
|
void *transport);
|
|
|
|
void ntb_unregister_transport(struct ntb_softc *ntb);
|
2015-10-15 23:45:43 +00:00
|
|
|
uint8_t ntb_get_max_cbs(struct ntb_softc *ntb);
|
2015-10-18 20:19:53 +00:00
|
|
|
uint8_t ntb_mw_count(struct ntb_softc *ntb);
|
2015-10-13 03:12:11 +00:00
|
|
|
uint8_t ntb_get_max_spads(struct ntb_softc *ntb);
|
2013-04-29 22:48:53 +00:00
|
|
|
int ntb_write_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t val);
|
|
|
|
int ntb_read_local_spad(struct ntb_softc *ntb, unsigned int idx, uint32_t *val);
|
|
|
|
int ntb_write_remote_spad(struct ntb_softc *ntb, unsigned int idx,
|
|
|
|
uint32_t val);
|
|
|
|
int ntb_read_remote_spad(struct ntb_softc *ntb, unsigned int idx,
|
|
|
|
uint32_t *val);
|
|
|
|
void *ntb_get_mw_vbase(struct ntb_softc *ntb, unsigned int mw);
|
NTB: "Split ntb_hw_intel and ntb_transport drivers"
This Linux commit was more or less a rewrite. Unfortunately, the commit
log does not give a lot of context for the rewrite. I have tried to
faithfully follow the changes made upstream, including matching function
names where possible, while churning the FreeBSD driver as little as
possible.
This is the bulk of the rewrite. There are two groups of changes to
follow in separate commits: fleshing out the rest of the changes to
xeon_setup_b2b_mw(), and some changes to if_ntb.
Yes, this is a big patch (3 files changed, 416 insertions(+), 237
deletions(-)), but the Linux patch was 13 files changed, 2,589
additions(+) and 2,195 deletions(-).
Original Linux commit log:
Change ntb_hw_intel to use the new NTB hardware abstraction layer.
Split ntb_transport into its own driver. Change it to use the new NTB
hardware abstraction layer.
Authored by: Allen Hubbe
Obtained from: Linux (e26a5843) (Dual BSD/GPL driver)
Sponsored by: EMC / Isilon Storage Division
2015-10-18 20:20:20 +00:00
|
|
|
bus_addr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw);
|
2013-04-29 22:48:53 +00:00
|
|
|
u_long ntb_get_mw_size(struct ntb_softc *ntb, unsigned int mw);
|
|
|
|
void ntb_set_mw_addr(struct ntb_softc *ntb, unsigned int mw, uint64_t addr);
|
2015-10-13 19:44:25 +00:00
|
|
|
void ntb_ring_doorbell(struct ntb_softc *ntb, unsigned int db);
|
NTB: "Split ntb_hw_intel and ntb_transport drivers"
This Linux commit was more or less a rewrite. Unfortunately, the commit
log does not give a lot of context for the rewrite. I have tried to
faithfully follow the changes made upstream, including matching function
names where possible, while churning the FreeBSD driver as little as
possible.
This is the bulk of the rewrite. There are two groups of changes to
follow in separate commits: fleshing out the rest of the changes to
xeon_setup_b2b_mw(), and some changes to if_ntb.
Yes, this is a big patch (3 files changed, 416 insertions(+), 237
deletions(-)), but the Linux patch was 13 files changed, 2,589
additions(+) and 2,195 deletions(-).
Original Linux commit log:
Change ntb_hw_intel to use the new NTB hardware abstraction layer.
Split ntb_transport into its own driver. Change it to use the new NTB
hardware abstraction layer.
Authored by: Allen Hubbe
Obtained from: Linux (e26a5843) (Dual BSD/GPL driver)
Sponsored by: EMC / Isilon Storage Division
2015-10-18 20:20:20 +00:00
|
|
|
bus_addr_t ntb_get_peer_db_addr(struct ntb_softc *ntb, vm_size_t *sz_out);
|
2013-04-29 22:48:53 +00:00
|
|
|
bool ntb_query_link_status(struct ntb_softc *ntb);
|
2013-09-05 22:46:48 +00:00
|
|
|
device_t ntb_get_device(struct ntb_softc *ntb);
|
2013-04-29 22:48:53 +00:00
|
|
|
|
2015-10-15 23:46:07 +00:00
|
|
|
/* Hardware owns the low 32 bits of features. */
|
2015-10-13 03:12:11 +00:00
|
|
|
#define NTB_BAR_SIZE_4K (1 << 0)
|
2015-10-18 20:19:44 +00:00
|
|
|
#define NTB_SDOORBELL_LOCKUP (1 << 1)
|
2015-10-13 17:21:38 +00:00
|
|
|
#define NTB_SB01BASE_LOCKUP (1 << 2)
|
|
|
|
#define NTB_B2BDOORBELL_BIT14 (1 << 3)
|
2015-10-15 23:46:07 +00:00
|
|
|
/* Software/configuration owns the top 32 bits. */
|
|
|
|
#define NTB_SPLIT_BAR (1ull << 32)
|
2015-10-13 03:12:11 +00:00
|
|
|
bool ntb_has_feature(struct ntb_softc *, uint64_t);
|
|
|
|
|
2013-04-29 22:48:53 +00:00
|
|
|
#endif /* _NTB_HW_H_ */
|