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
|
|
|
|
2015-10-18 20:20:57 +00:00
|
|
|
enum ntb_speed {
|
|
|
|
NTB_SPEED_AUTO = -1,
|
|
|
|
NTB_SPEED_NONE = 0,
|
|
|
|
NTB_SPEED_GEN1 = 1,
|
|
|
|
NTB_SPEED_GEN2 = 2,
|
|
|
|
NTB_SPEED_GEN3 = 3,
|
2015-10-14 23:44:42 +00:00
|
|
|
};
|
2013-04-29 22:48:53 +00:00
|
|
|
|
2015-10-18 20:20:57 +00:00
|
|
|
enum ntb_width {
|
|
|
|
NTB_WIDTH_AUTO = -1,
|
|
|
|
NTB_WIDTH_NONE = 0,
|
|
|
|
NTB_WIDTH_1 = 1,
|
|
|
|
NTB_WIDTH_2 = 2,
|
|
|
|
NTB_WIDTH_4 = 4,
|
|
|
|
NTB_WIDTH_8 = 8,
|
|
|
|
NTB_WIDTH_12 = 12,
|
|
|
|
NTB_WIDTH_16 = 16,
|
|
|
|
NTB_WIDTH_32 = 32,
|
2013-04-29 22:48:53 +00:00
|
|
|
};
|
|
|
|
|
2015-10-13 03:11:21 +00:00
|
|
|
SYSCTL_DECL(_hw_ntb);
|
|
|
|
|
2015-10-18 20:20:57 +00:00
|
|
|
typedef void (*ntb_db_callback)(void *data, int vector);
|
|
|
|
typedef void (*ntb_event_callback)(void *data);
|
|
|
|
|
|
|
|
struct ntb_ctx_ops {
|
|
|
|
ntb_event_callback link_event;
|
|
|
|
ntb_db_callback db_event;
|
|
|
|
};
|
|
|
|
|
|
|
|
device_t ntb_get_device(struct ntb_softc *);
|
|
|
|
|
|
|
|
bool ntb_link_is_up(struct ntb_softc *, enum ntb_speed *, enum ntb_width *);
|
|
|
|
void ntb_link_event(struct ntb_softc *);
|
|
|
|
int ntb_link_enable(struct ntb_softc *, enum ntb_speed, enum ntb_width);
|
|
|
|
int ntb_link_disable(struct ntb_softc *);
|
|
|
|
|
|
|
|
int ntb_set_ctx(struct ntb_softc *, void *, const struct ntb_ctx_ops *);
|
|
|
|
void *ntb_get_ctx(struct ntb_softc *, const struct ntb_ctx_ops **);
|
|
|
|
void ntb_clear_ctx(struct ntb_softc *);
|
|
|
|
|
|
|
|
uint8_t ntb_mw_count(struct ntb_softc *);
|
|
|
|
int ntb_mw_get_range(struct ntb_softc *, unsigned mw_idx, vm_paddr_t *base,
|
|
|
|
void **vbase, size_t *size, size_t *align, size_t *align_size);
|
|
|
|
int ntb_mw_set_trans(struct ntb_softc *, unsigned mw_idx, bus_addr_t, size_t);
|
|
|
|
int ntb_mw_clear_trans(struct ntb_softc *, unsigned mw_idx);
|
|
|
|
|
2015-10-13 03:12:11 +00:00
|
|
|
uint8_t ntb_get_max_spads(struct ntb_softc *ntb);
|
2015-10-18 20:20:48 +00:00
|
|
|
int ntb_spad_write(struct ntb_softc *ntb, unsigned int idx, uint32_t val);
|
|
|
|
int ntb_spad_read(struct ntb_softc *ntb, unsigned int idx, uint32_t *val);
|
|
|
|
int ntb_peer_spad_write(struct ntb_softc *ntb, unsigned int idx,
|
2013-04-29 22:48:53 +00:00
|
|
|
uint32_t val);
|
2015-10-18 20:20:48 +00:00
|
|
|
int ntb_peer_spad_read(struct ntb_softc *ntb, unsigned int idx,
|
2013-04-29 22:48:53 +00:00
|
|
|
uint32_t *val);
|
2015-10-18 20:20:57 +00:00
|
|
|
|
|
|
|
uint64_t ntb_db_valid_mask(struct ntb_softc *);
|
|
|
|
bus_addr_t ntb_get_peer_db_addr(struct ntb_softc *, vm_size_t *sz_out);
|
|
|
|
|
|
|
|
void ntb_db_clear(struct ntb_softc *, uint64_t bits);
|
|
|
|
void ntb_db_clear_mask(struct ntb_softc *, uint64_t bits);
|
|
|
|
uint64_t ntb_db_read(struct ntb_softc *);
|
|
|
|
void ntb_db_set_mask(struct ntb_softc *, uint64_t bits);
|
|
|
|
uint64_t ntb_db_vector_mask(struct ntb_softc *, int vector);
|
|
|
|
void ntb_peer_db_set(struct ntb_softc *, uint64_t bits);
|
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_ */
|