1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00

NTB: Diff reduce with Linux

No functional change.

Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Conrad Meyer 2015-11-11 18:55:25 +00:00
parent e4a818a922
commit 9cf310367f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290682
3 changed files with 48 additions and 26 deletions

View File

@ -273,7 +273,7 @@ static void ntb_net_tx_handler(struct ntb_transport_qp *qp, void *qp_data,
static void ntb_net_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
void *data, int len);
static void ntb_net_event_handler(void *data, enum ntb_link_event status);
static int ntb_transport_init(struct ntb_softc *ntb);
static int ntb_transport_probe(struct ntb_softc *ntb);
static void ntb_transport_free(struct ntb_transport_ctx *);
static void ntb_transport_init_queue(struct ntb_transport_ctx *nt,
unsigned int qp_num);
@ -368,7 +368,7 @@ ntb_setup_interface(void)
return (ENXIO);
}
rc = ntb_transport_init(net_softc.ntb);
rc = ntb_transport_probe(net_softc.ntb);
if (rc != 0) {
printf("ntb: Cannot init transport: %d\n", rc);
return (rc);
@ -541,7 +541,7 @@ ntb_net_event_handler(void *data, enum ntb_link_event status)
/* Transport Init and teardown */
static int
ntb_transport_init(struct ntb_softc *ntb)
ntb_transport_probe(struct ntb_softc *ntb)
{
struct ntb_transport_ctx *nt = &net_softc;
struct ntb_transport_mw *mw;
@ -596,6 +596,8 @@ ntb_transport_init(struct ntb_softc *ntb)
nt->link_is_up = false;
ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
ntb_link_event(ntb);
callout_reset(&nt->link_work, 0, ntb_transport_link_work, nt);
return (0);
err:
@ -693,6 +695,8 @@ ntb_transport_init_queue(struct ntb_transport_ctx *nt, unsigned int qp_num)
STAILQ_INIT(&qp->rx_pend_q);
STAILQ_INIT(&qp->rx_free_q);
STAILQ_INIT(&qp->tx_free_q);
callout_reset(&qp->link_work, 0, ntb_qp_link_work, qp);
}
static void

View File

@ -518,26 +518,26 @@ ntb_attach(device_t device)
error = ntb_detect_atom(ntb);
else
error = ntb_detect_xeon(ntb);
if (error)
if (error != 0)
goto out;
ntb_detect_max_mw(ntb);
pci_enable_busmaster(ntb->device);
error = ntb_map_pci_bars(ntb);
if (error)
if (error != 0)
goto out;
if (ntb->type == NTB_ATOM)
error = ntb_atom_init_dev(ntb);
else
error = ntb_xeon_init_dev(ntb);
if (error)
if (error != 0)
goto out;
error = ntb_init_isr(ntb);
if (error)
goto out;
ntb_sysctl_init(ntb);
pci_enable_busmaster(ntb->device);
ntb_poll_link(ntb);
ntb_sysctl_init(ntb);
out:
if (error != 0)
@ -556,6 +556,7 @@ ntb_detach(device_t device)
ntb_db_set_mask(ntb, ntb->db_valid_mask);
callout_drain(&ntb->heartbeat_timer);
callout_drain(&ntb->lr_timer);
pci_disable_busmaster(ntb->device);
if (ntb->type == NTB_XEON)
ntb_teardown_xeon(ntb);
ntb_teardown_interrupts(ntb);
@ -1274,18 +1275,22 @@ ntb_xeon_init_dev(struct ntb_softc *ntb)
return (rc);
/* Enable Bus Master and Memory Space on the secondary side */
ntb_reg_write(2, XEON_PCICMD_OFFSET,
ntb_reg_write(2, XEON_SPCICMD_OFFSET,
PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
/* Enable link training */
ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
/*
* Mask all doorbell interrupts.
*/
ntb_db_set_mask(ntb, ntb->db_valid_mask);
return (0);
rc = ntb_init_isr(ntb);
return (rc);
}
static int
ntb_atom_init_dev(struct ntb_softc *ntb)
{
int error;
KASSERT(ntb->conn_type == NTB_CONN_B2B,
("Unsupported NTB configuration (%d)\n", ntb->conn_type));
@ -1310,9 +1315,13 @@ ntb_atom_init_dev(struct ntb_softc *ntb)
configure_atom_secondary_side_bars(ntb);
/* Enable Bus Master and Memory Space on the secondary side */
ntb_reg_write(2, ATOM_PCICMD_OFFSET,
ntb_reg_write(2, ATOM_SPCICMD_OFFSET,
PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
error = ntb_init_isr(ntb);
if (error != 0)
return (error);
/* Initiate PCI-E link training */
ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
@ -1988,6 +1997,19 @@ ntb_sysctl_init(struct ntb_softc *ntb)
CTLFLAG_RD, NULL, "Raw HW registers (big-endian)");
regpar = SYSCTL_CHILDREN(tmptree);
SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "ntbcntl",
CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 |
ntb->reg->ntb_ctl, sysctl_handle_register, "IU",
"NTB Control register");
SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcap",
CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 |
0x19c, sysctl_handle_register, "IU",
"NTB Link Capabilities");
SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "lnkcon",
CTLFLAG_RD | CTLTYPE_OPAQUE, ntb, NTB_REG_32 |
0x1a0, sysctl_handle_register, "IU",
"NTB Link Control register");
SYSCTL_ADD_PROC(ctx, regpar, OID_AUTO, "db_mask",
CTLFLAG_RD | CTLTYPE_OPAQUE, ntb,
NTB_REG_64 | NTB_DB_READ | ntb->self_reg->db_mask,
@ -2352,7 +2374,7 @@ ntb_peer_spad_write(struct ntb_softc *ntb, unsigned int idx, uint32_t val)
return (EINVAL);
if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP))
ntb_mw_write(4, XEON_SHADOW_SPAD_OFFSET + idx * 4, val);
ntb_mw_write(4, XEON_SPAD_OFFSET + idx * 4, val);
else
ntb_reg_write(4, ntb->peer_reg->spad + idx * 4, val);
@ -2378,7 +2400,7 @@ ntb_peer_spad_read(struct ntb_softc *ntb, unsigned int idx, uint32_t *val)
return (EINVAL);
if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP))
*val = ntb_mw_read(4, XEON_SHADOW_SPAD_OFFSET + idx * 4);
*val = ntb_mw_read(4, XEON_SPAD_OFFSET + idx * 4);
else
*val = ntb_reg_read(4, ntb->peer_reg->spad + idx * 4);
@ -2564,7 +2586,7 @@ ntb_peer_db_set(struct ntb_softc *ntb, uint64_t bit)
{
if (HAS_FEATURE(NTB_SDOORBELL_LOCKUP)) {
ntb_mw_write(2, XEON_SHADOW_PDOORBELL_OFFSET, bit);
ntb_mw_write(2, XEON_PDOORBELL_OFFSET, bit);
return;
}
@ -2600,7 +2622,7 @@ ntb_get_peer_db_addr(struct ntb_softc *ntb, vm_size_t *sz_out)
("invalid b2b idx"));
bar = &ntb->bar_info[ntb_mw_to_bar(ntb, ntb->b2b_mw_idx)];
regoff = XEON_SHADOW_PDOORBELL_OFFSET;
regoff = XEON_PDOORBELL_OFFSET;
}
KASSERT(bar->pci_bus_tag != X86_BUS_SPACE_IO, ("uh oh"));

View File

@ -46,7 +46,7 @@
#define XEON_DB_LINK_BIT (1 << XEON_DB_LINK)
#define XEON_SPAD_COUNT 16
#define XEON_PCICMD_OFFSET 0x0504
#define XEON_SPCICMD_OFFSET 0x0504
#define XEON_DEVCTRL_OFFSET 0x0598
#define XEON_DEVSTS_OFFSET 0x059a
#define XEON_LINK_STATUS_OFFSET 0x01a2
@ -91,7 +91,7 @@
#define ATOM_DB_MSIX_VECTOR_SHIFT 1
#define ATOM_SPAD_COUNT 16
#define ATOM_PCICMD_OFFSET 0xb004
#define ATOM_SPCICMD_OFFSET 0xb004
#define ATOM_MBAR23_OFFSET 0xb018
#define ATOM_MBAR45_OFFSET 0xb020
#define ATOM_DEVCTRL_OFFSET 0xb048
@ -168,8 +168,4 @@
/* The peer ntb secondary config space is 32KB fixed size */
#define XEON_B2B_MIN_SIZE 0x8000
/* XEON Shadowed MMIO Space */
#define XEON_SHADOW_PDOORBELL_OFFSET 0x60
#define XEON_SHADOW_SPAD_OFFSET 0x80
#endif /* _NTB_REGS_H_ */