Changeset View
Changeset View
Standalone View
Standalone View
sys/net/iflib.c
Show First 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | #endif | ||||
iflib_rxq_t ifl_rxq; | iflib_rxq_t ifl_rxq; | ||||
uint8_t ifl_id; | uint8_t ifl_id; | ||||
bus_dma_tag_t ifl_desc_tag; | bus_dma_tag_t ifl_desc_tag; | ||||
iflib_dma_info_t ifl_ifdi; | iflib_dma_info_t ifl_ifdi; | ||||
uint64_t ifl_bus_addrs[IFLIB_MAX_RX_REFRESH] __aligned(CACHE_LINE_SIZE); | uint64_t ifl_bus_addrs[IFLIB_MAX_RX_REFRESH] __aligned(CACHE_LINE_SIZE); | ||||
caddr_t ifl_vm_addrs[IFLIB_MAX_RX_REFRESH]; | caddr_t ifl_vm_addrs[IFLIB_MAX_RX_REFRESH]; | ||||
} __aligned(CACHE_LINE_SIZE); | } __aligned(CACHE_LINE_SIZE); | ||||
/* | |||||
* XXX: This really needs a comment | |||||
*/ | |||||
static inline int | static inline int | ||||
get_inuse(int size, int cidx, int pidx, int gen) | get_inuse(int size, int cidx, int pidx, int gen) | ||||
{ | { | ||||
int used; | int used; | ||||
if (pidx > cidx) | if (pidx > cidx) | ||||
used = pidx - cidx; | used = pidx - cidx; | ||||
else if (pidx < cidx) | else if (pidx < cidx) | ||||
▲ Show 20 Lines • Show All 2,974 Lines • ▼ Show 20 Lines | if (ifa->ifa_addr->sa_family == AF_INET6) | ||||
avoid_reset = TRUE; | avoid_reset = TRUE; | ||||
#endif | #endif | ||||
/* | /* | ||||
** Calling init results in link renegotiation, | ** Calling init results in link renegotiation, | ||||
** so we avoid doing it when possible. | ** so we avoid doing it when possible. | ||||
*/ | */ | ||||
if (avoid_reset) { | if (avoid_reset) { | ||||
if_setflagbits(ifp, IFF_UP,0); | if_setflagbits(ifp, IFF_UP,0); | ||||
if (!(if_getdrvflags(ifp)& IFF_DRV_RUNNING)) | if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) | ||||
reinit = 1; | reinit = 1; | ||||
#ifdef INET | #ifdef INET | ||||
if (!(if_getflags(ifp) & IFF_NOARP)) | if (!(if_getflags(ifp) & IFF_NOARP)) | ||||
arp_ifinit(ifp, ifa); | arp_ifinit(ifp, ifa); | ||||
#endif | #endif | ||||
} else | } else | ||||
err = ether_ioctl(ifp, command, data); | err = ether_ioctl(ifp, command, data); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | case SIOCSIFCAP: | ||||
mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); | mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); | ||||
setmask = 0; | setmask = 0; | ||||
#ifdef TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
setmask |= mask & (IFCAP_TOE4|IFCAP_TOE6); | setmask |= mask & (IFCAP_TOE4|IFCAP_TOE6); | ||||
#endif | #endif | ||||
setmask |= (mask & IFCAP_FLAGS); | setmask |= (mask & IFCAP_FLAGS); | ||||
if (setmask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) | if (setmask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) | ||||
setmask |= (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); | setmask |= (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); | ||||
if ((mask & IFCAP_WOL) && | if ((mask & IFCAP_WOL) && | ||||
(if_getcapabilities(ifp) & IFCAP_WOL) != 0) | (if_getcapabilities(ifp) & IFCAP_WOL) != 0) | ||||
setmask |= (mask & (IFCAP_WOL_MCAST|IFCAP_WOL_MAGIC)); | setmask |= (mask & (IFCAP_WOL_MCAST|IFCAP_WOL_MAGIC)); | ||||
if_vlancap(ifp); | if_vlancap(ifp); | ||||
/* | /* | ||||
* want to ensure that traffic has stopped before we change any of the flags | * want to ensure that traffic has stopped before we change any of the flags | ||||
*/ | */ | ||||
if (setmask) { | if (setmask) { | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
bits = if_getdrvflags(ifp); | bits = if_getdrvflags(ifp); | ||||
if (bits & IFF_DRV_RUNNING) | if (bits & IFF_DRV_RUNNING) | ||||
iflib_stop(ctx); | iflib_stop(ctx); | ||||
if_togglecapenable(ifp, setmask); | if_togglecapenable(ifp, setmask); | ||||
if (bits & IFF_DRV_RUNNING) | if (bits & IFF_DRV_RUNNING) | ||||
iflib_init_locked(ctx); | iflib_init_locked(ctx); | ||||
if_setdrvflags(ifp, bits); | if_setdrvflags(ifp, bits); | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
case SIOCGPRIVATE_0: | case SIOCGPRIVATE_0: | ||||
case SIOCSDRVSPEC: | case SIOCSDRVSPEC: | ||||
case SIOCGDRVSPEC: | case SIOCGDRVSPEC: | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
err = IFDI_PRIV_IOCTL(ctx, command, data); | err = IFDI_PRIV_IOCTL(ctx, command, data); | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
break; | break; | ||||
default: | default: | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ctxp) | ||||
int err, rid, msix, msix_bar; | int err, rid, msix, msix_bar; | ||||
if_ctx_t ctx; | if_ctx_t ctx; | ||||
if_t ifp; | if_t ifp; | ||||
if_softc_ctx_t scctx; | if_softc_ctx_t scctx; | ||||
int i; | int i; | ||||
uint16_t main_txq; | uint16_t main_txq; | ||||
uint16_t main_rxq; | uint16_t main_rxq; | ||||
ctx = malloc(sizeof(* ctx), M_IFLIB, M_WAITOK|M_ZERO); | ctx = malloc(sizeof(* ctx), M_IFLIB, M_WAITOK|M_ZERO); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
sc = malloc(sctx->isc_driver->size, M_IFLIB, M_WAITOK|M_ZERO); | sc = malloc(sctx->isc_driver->size, M_IFLIB, M_WAITOK|M_ZERO); | ||||
device_set_softc(dev, ctx); | device_set_softc(dev, ctx); | ||||
ctx->ifc_flags |= IFC_SC_ALLOCATED; | ctx->ifc_flags |= IFC_SC_ALLOCATED; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,184 Lines • ▼ Show 20 Lines | iflib_msix_init(if_ctx_t ctx) | ||||
device_printf(dev, "msix_init qsets capped at %d\n", iflib_num_tx_queues); | device_printf(dev, "msix_init qsets capped at %d\n", iflib_num_tx_queues); | ||||
bar = ctx->ifc_softc_ctx.isc_msix_bar; | bar = ctx->ifc_softc_ctx.isc_msix_bar; | ||||
admincnt = sctx->isc_admin_intrcnt; | admincnt = sctx->isc_admin_intrcnt; | ||||
/* Override by tuneable */ | /* Override by tuneable */ | ||||
if (enable_msix == 0) | if (enable_msix == 0) | ||||
goto msi; | goto msi; | ||||
// Don't need to set busmaster here... | |||||
#if 0 | |||||
/* | /* | ||||
** When used in a virtualized environment | ** When used in a virtualized environment | ||||
** PCI BUSMASTER capability may not be set | ** PCI BUSMASTER capability may not be set | ||||
** so explicity set it here and rewrite | ** so explicity set it here and rewrite | ||||
** the ENABLE in the MSIX control register | ** the ENABLE in the MSIX control register | ||||
** at this point to cause the host to | ** at this point to cause the host to | ||||
** successfully initialize us. | ** successfully initialize us. | ||||
*/ | */ | ||||
{ | { | ||||
int msix_ctrl, rid; | int msix_ctrl, rid; | ||||
pci_enable_busmaster(dev); | pci_enable_busmaster(dev); | ||||
rid = 0; | rid = 0; | ||||
if (pci_find_cap(dev, PCIY_MSIX, &rid) == 0 && rid != 0) { | if (pci_find_cap(dev, PCIY_MSIX, &rid) == 0 && rid != 0) { | ||||
rid += PCIR_MSIX_CTRL; | rid += PCIR_MSIX_CTRL; | ||||
msix_ctrl = pci_read_config(dev, rid, 2); | msix_ctrl = pci_read_config(dev, rid, 2); | ||||
msix_ctrl |= PCIM_MSIXCTRL_MSIX_ENABLE; | msix_ctrl |= PCIM_MSIXCTRL_MSIX_ENABLE; | ||||
pci_write_config(dev, rid, msix_ctrl, 2); | pci_write_config(dev, rid, msix_ctrl, 2); | ||||
} else { | } else { | ||||
device_printf(dev, "PCIY_MSIX capability not found; " | device_printf(dev, "PCIY_MSIX capability not found; " | ||||
"or rid %d == 0.\n", rid); | "or rid %d == 0.\n", rid); | ||||
goto msi; | goto msi; | ||||
} | } | ||||
} | } | ||||
#endif | |||||
/* | /* | ||||
* bar == -1 => "trust me I know what I'm doing" | * bar == -1 => "trust me I know what I'm doing" | ||||
* https://www.youtube.com/watch?v=nnwWKkNau4I | * https://www.youtube.com/watch?v=nnwWKkNau4I | ||||
* Some drivers are for hardware that is so shoddily | * Some drivers are for hardware that is so shoddily | ||||
* documented that no one knows which bars are which | * documented that no one knows which bars are which | ||||
* so the developer has to map all bars. This hack | * so the developer has to map all bars. This hack | ||||
* allows shoddy garbage to use msix in this framework. | * allows shoddy garbage to use msix in this framework. | ||||
▲ Show 20 Lines • Show All 373 Lines • Show Last 20 Lines |