Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/ntb/ntb_hw/ntb_hw.c
Show First 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | |||||
static void ntb_interrupt(struct ntb_softc *, uint32_t vec); | static void ntb_interrupt(struct ntb_softc *, uint32_t vec); | ||||
static void ndev_vec_isr(void *arg); | static void ndev_vec_isr(void *arg); | ||||
static void ndev_irq_isr(void *arg); | static void ndev_irq_isr(void *arg); | ||||
static inline uint64_t db_ioread(struct ntb_softc *, uint64_t regoff); | static inline uint64_t db_ioread(struct ntb_softc *, uint64_t regoff); | ||||
static inline void db_iowrite(struct ntb_softc *, uint64_t regoff, uint64_t); | static inline void db_iowrite(struct ntb_softc *, uint64_t regoff, uint64_t); | ||||
static inline void db_iowrite_raw(struct ntb_softc *, uint64_t regoff, uint64_t); | static inline void db_iowrite_raw(struct ntb_softc *, uint64_t regoff, uint64_t); | ||||
static int ntb_create_msix_vec(struct ntb_softc *ntb, uint32_t num_vectors); | static int ntb_create_msix_vec(struct ntb_softc *ntb, uint32_t num_vectors); | ||||
static void ntb_free_msix_vec(struct ntb_softc *ntb); | static void ntb_free_msix_vec(struct ntb_softc *ntb); | ||||
static void ntb_get_msix_info(struct ntb_softc *ntb, uint32_t num_vectors); | static void ntb_get_msix_info(struct ntb_softc *ntb); | ||||
static void ntb_exchange_msix(void *); | static void ntb_exchange_msix(void *); | ||||
static struct ntb_hw_info *ntb_get_device_info(uint32_t device_id); | static struct ntb_hw_info *ntb_get_device_info(uint32_t device_id); | ||||
static void ntb_detect_max_mw(struct ntb_softc *ntb); | static void ntb_detect_max_mw(struct ntb_softc *ntb); | ||||
static int ntb_detect_xeon(struct ntb_softc *ntb); | static int ntb_detect_xeon(struct ntb_softc *ntb); | ||||
static int ntb_detect_atom(struct ntb_softc *ntb); | static int ntb_detect_atom(struct ntb_softc *ntb); | ||||
static int ntb_xeon_init_dev(struct ntb_softc *ntb); | static int ntb_xeon_init_dev(struct ntb_softc *ntb); | ||||
static int ntb_atom_init_dev(struct ntb_softc *ntb); | static int ntb_atom_init_dev(struct ntb_softc *ntb); | ||||
static void ntb_teardown_xeon(struct ntb_softc *ntb); | static void ntb_teardown_xeon(struct ntb_softc *ntb); | ||||
▲ Show 20 Lines • Show All 717 Lines • ▼ Show 20 Lines | if (HAS_FEATURE(NTB_SB01BASE_LOCKUP)) { | ||||
"Errata workaround does not support MSI or INTX\n"); | "Errata workaround does not support MSI or INTX\n"); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
ntb->db_vec_count = 1; | ntb->db_vec_count = 1; | ||||
ntb->db_vec_shift = XEON_DB_TOTAL_SHIFT; | ntb->db_vec_shift = XEON_DB_TOTAL_SHIFT; | ||||
rc = ntb_setup_legacy_interrupt(ntb); | rc = ntb_setup_legacy_interrupt(ntb); | ||||
} else { | } else { | ||||
if (num_vectors - 1 != XEON_NONLINK_DB_MSIX_BITS && | |||||
HAS_FEATURE(NTB_SB01BASE_LOCKUP)) { | |||||
device_printf(ntb->device, | |||||
"Errata workaround expects %d doorbell bits\n", | |||||
XEON_NONLINK_DB_MSIX_BITS); | |||||
return (EINVAL); | |||||
} | |||||
ntb_create_msix_vec(ntb, num_vectors); | ntb_create_msix_vec(ntb, num_vectors); | ||||
rc = ntb_setup_msix(ntb, num_vectors); | rc = ntb_setup_msix(ntb, num_vectors); | ||||
if (rc == 0 && HAS_FEATURE(NTB_SB01BASE_LOCKUP)) | if (rc == 0 && HAS_FEATURE(NTB_SB01BASE_LOCKUP)) | ||||
ntb_get_msix_info(ntb, num_vectors); | ntb_get_msix_info(ntb); | ||||
} | } | ||||
if (rc != 0) { | if (rc != 0) { | ||||
device_printf(ntb->device, | device_printf(ntb->device, | ||||
"Error allocating interrupts: %d\n", rc); | "Error allocating interrupts: %d\n", rc); | ||||
ntb_free_msix_vec(ntb); | ntb_free_msix_vec(ntb); | ||||
} | } | ||||
return (rc); | return (rc); | ||||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | ntb_free_msix_vec(struct ntb_softc *ntb) | ||||
if (ntb->msix_vec == NULL) | if (ntb->msix_vec == NULL) | ||||
return; | return; | ||||
free(ntb->msix_vec, M_NTB); | free(ntb->msix_vec, M_NTB); | ||||
ntb->msix_vec = NULL; | ntb->msix_vec = NULL; | ||||
} | } | ||||
static void | static void | ||||
ntb_get_msix_info(struct ntb_softc *ntb, uint32_t num_vectors) | ntb_get_msix_info(struct ntb_softc *ntb) | ||||
{ | { | ||||
struct pci_devinfo *dinfo; | struct pci_devinfo *dinfo; | ||||
struct pcicfg_msix *msix; | struct pcicfg_msix *msix; | ||||
uint32_t laddr, data, i, offset; | uint32_t laddr, data, i, offset; | ||||
dinfo = device_get_ivars(ntb->device); | dinfo = device_get_ivars(ntb->device); | ||||
msix = &dinfo->cfg.msix; | msix = &dinfo->cfg.msix; | ||||
laddr = data = 0; | laddr = data = 0; | ||||
for (i = 0; i < num_vectors; i++) { | CTASSERT(XEON_NONLINK_DB_MSIX_BITS == nitems(ntb->msix_data)); | ||||
for (i = 0; i < XEON_NONLINK_DB_MSIX_BITS; i++) { | |||||
offset = msix->msix_table_offset + i * PCI_MSIX_ENTRY_SIZE; | offset = msix->msix_table_offset + i * PCI_MSIX_ENTRY_SIZE; | ||||
laddr = bus_read_4(msix->msix_table_res, offset + | laddr = bus_read_4(msix->msix_table_res, offset + | ||||
PCI_MSIX_ENTRY_LOWER_ADDR); | PCI_MSIX_ENTRY_LOWER_ADDR); | ||||
ntb_printf(2, "local lower MSIX addr(%u): 0x%x\n", i, laddr); | ntb_printf(2, "local lower MSIX addr(%u): 0x%x\n", i, laddr); | ||||
KASSERT((laddr & MSI_INTEL_ADDR_BASE) == MSI_INTEL_ADDR_BASE, | KASSERT((laddr & MSI_INTEL_ADDR_BASE) == MSI_INTEL_ADDR_BASE, | ||||
("local MSIX addr 0x%x not in MSI base 0x%x", laddr, | ("local MSIX addr 0x%x not in MSI base 0x%x", laddr, | ||||
▲ Show 20 Lines • Show All 2,019 Lines • Show Last 20 Lines |