Changeset View
Changeset View
Standalone View
Standalone View
sys/net/iflib.c
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | struct iflib_ctx { | ||||
struct cdev *ifc_led_dev; | struct cdev *ifc_led_dev; | ||||
struct resource *ifc_msix_mem; | struct resource *ifc_msix_mem; | ||||
struct if_irq ifc_legacy_irq; | struct if_irq ifc_legacy_irq; | ||||
struct grouptask ifc_admin_task; | struct grouptask ifc_admin_task; | ||||
struct grouptask ifc_vflr_task; | struct grouptask ifc_vflr_task; | ||||
struct iflib_filter_info ifc_filter_info; | struct iflib_filter_info ifc_filter_info; | ||||
struct ifmedia ifc_media; | struct ifmedia ifc_media; | ||||
struct ifmedia *ifc_mediap; | |||||
struct sysctl_oid *ifc_sysctl_node; | struct sysctl_oid *ifc_sysctl_node; | ||||
uint16_t ifc_sysctl_ntxqs; | uint16_t ifc_sysctl_ntxqs; | ||||
uint16_t ifc_sysctl_nrxqs; | uint16_t ifc_sysctl_nrxqs; | ||||
uint16_t ifc_sysctl_qs_eq_override; | uint16_t ifc_sysctl_qs_eq_override; | ||||
uint16_t ifc_sysctl_rx_budget; | uint16_t ifc_sysctl_rx_budget; | ||||
uint16_t ifc_sysctl_tx_abdicate; | uint16_t ifc_sysctl_tx_abdicate; | ||||
uint16_t ifc_sysctl_core_offset; | uint16_t ifc_sysctl_core_offset; | ||||
Show All 40 Lines | iflib_get_ifp(if_ctx_t ctx) | ||||
return (ctx->ifc_ifp); | return (ctx->ifc_ifp); | ||||
} | } | ||||
struct ifmedia * | struct ifmedia * | ||||
iflib_get_media(if_ctx_t ctx) | iflib_get_media(if_ctx_t ctx) | ||||
{ | { | ||||
return (&ctx->ifc_media); | return (ctx->ifc_mediap); | ||||
} | } | ||||
uint32_t | uint32_t | ||||
iflib_get_flags(if_ctx_t ctx) | iflib_get_flags(if_ctx_t ctx) | ||||
{ | { | ||||
return (ctx->ifc_flags); | return (ctx->ifc_flags); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 3,929 Lines • ▼ Show 20 Lines | case SIOCDELMULTI: | ||||
break; | break; | ||||
case SIOCSIFMEDIA: | case SIOCSIFMEDIA: | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
IFDI_MEDIA_SET(ctx); | IFDI_MEDIA_SET(ctx); | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
/* falls thru */ | /* falls thru */ | ||||
case SIOCGIFMEDIA: | case SIOCGIFMEDIA: | ||||
case SIOCGIFXMEDIA: | case SIOCGIFXMEDIA: | ||||
err = ifmedia_ioctl(ifp, ifr, &ctx->ifc_media, command); | err = ifmedia_ioctl(ifp, ifr, ctx->ifc_mediap, command); | ||||
break; | break; | ||||
case SIOCGI2C: | case SIOCGI2C: | ||||
{ | { | ||||
struct ifi2creq i2c; | struct ifi2creq i2c; | ||||
err = copyin(ifr_data_get_ptr(ifr), &i2c, sizeof(i2c)); | err = copyin(ifr_data_get_ptr(ifr), &i2c, sizeof(i2c)); | ||||
if (err != 0) | if (err != 0) | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ctxp) | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
if ((err = IFDI_ATTACH_PRE(ctx)) != 0) { | if ((err = IFDI_ATTACH_PRE(ctx)) != 0) { | ||||
device_printf(dev, "IFDI_ATTACH_PRE failed %d\n", err); | device_printf(dev, "IFDI_ATTACH_PRE failed %d\n", err); | ||||
goto fail_unlock; | goto fail_unlock; | ||||
} | } | ||||
_iflib_pre_assert(scctx); | _iflib_pre_assert(scctx); | ||||
ctx->ifc_txrx = *scctx->isc_txrx; | ctx->ifc_txrx = *scctx->isc_txrx; | ||||
if (sctx->isc_flags & IFLIB_DRIVER_MEDIA) | |||||
ctx->ifc_mediap = scctx->isc_media; | |||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
MPASS(scctx->isc_capabilities); | MPASS(scctx->isc_capabilities); | ||||
if (scctx->isc_capabilities & IFCAP_TXCSUM) | if (scctx->isc_capabilities & IFCAP_TXCSUM) | ||||
marius: Second level indent are 4 spaces according to style(9). Apart from that, this change looks good… | |||||
MPASS(scctx->isc_tx_csum_flags); | MPASS(scctx->isc_tx_csum_flags); | ||||
Not Done Inline ActionsNote for the miibus case, I don't think you want to init/add/set anything because the phy does that already aryeeteygerald_rogers.com: Note for the miibus case, I don't think you want to init/add/set anything because the phy does… | |||||
Not Done Inline ActionsActually I forgot that mii_media is setup when the miibus is attached (sometime after iflib_device_register). So my comments shouldn't apply. iflib_media_change and iflib_media_status aren't exposed though. aryeeteygerald_rogers.com: Actually I forgot that `mii_media` is setup when the miibus is attached (sometime after… | |||||
#endif | #endif | ||||
if_setcapabilities(ifp, scctx->isc_capabilities | IFCAP_HWSTATS); | if_setcapabilities(ifp, scctx->isc_capabilities | IFCAP_HWSTATS); | ||||
if_setcapenable(ifp, scctx->isc_capenable | IFCAP_HWSTATS); | if_setcapenable(ifp, scctx->isc_capenable | IFCAP_HWSTATS); | ||||
if (scctx->isc_ntxqsets == 0 || (scctx->isc_ntxqsets_max && scctx->isc_ntxqsets_max < scctx->isc_ntxqsets)) | if (scctx->isc_ntxqsets == 0 || (scctx->isc_ntxqsets_max && scctx->isc_ntxqsets_max < scctx->isc_ntxqsets)) | ||||
scctx->isc_ntxqsets = scctx->isc_ntxqsets_max; | scctx->isc_ntxqsets = scctx->isc_ntxqsets_max; | ||||
if (scctx->isc_nrxqsets == 0 || (scctx->isc_nrxqsets_max && scctx->isc_nrxqsets_max < scctx->isc_nrxqsets)) | if (scctx->isc_nrxqsets == 0 || (scctx->isc_nrxqsets_max && scctx->isc_nrxqsets_max < scctx->isc_nrxqsets)) | ||||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | iflib_pseudo_register(device_t dev, if_shared_ctx_t sctx, if_ctx_t *ctxp, | ||||
} | } | ||||
if (sctx->isc_flags & IFLIB_GEN_MAC) | if (sctx->isc_flags & IFLIB_GEN_MAC) | ||||
ether_gen_addr(ifp, &ctx->ifc_mac); | ether_gen_addr(ifp, &ctx->ifc_mac); | ||||
if ((err = IFDI_CLONEATTACH(ctx, clctx->cc_ifc, clctx->cc_name, | if ((err = IFDI_CLONEATTACH(ctx, clctx->cc_ifc, clctx->cc_name, | ||||
clctx->cc_params)) != 0) { | clctx->cc_params)) != 0) { | ||||
device_printf(dev, "IFDI_CLONEATTACH failed %d\n", err); | device_printf(dev, "IFDI_CLONEATTACH failed %d\n", err); | ||||
goto fail_ctx_free; | goto fail_ctx_free; | ||||
} | } | ||||
ifmedia_add(&ctx->ifc_media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); | ifmedia_add(ctx->ifc_mediap, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); | ||||
ifmedia_add(&ctx->ifc_media, IFM_ETHER | IFM_AUTO, 0, NULL); | ifmedia_add(ctx->ifc_mediap, IFM_ETHER | IFM_AUTO, 0, NULL); | ||||
ifmedia_set(&ctx->ifc_media, IFM_ETHER | IFM_AUTO); | ifmedia_set(ctx->ifc_mediap, IFM_ETHER | IFM_AUTO); | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
MPASS(scctx->isc_capabilities); | MPASS(scctx->isc_capabilities); | ||||
if (scctx->isc_capabilities & IFCAP_TXCSUM) | if (scctx->isc_capabilities & IFCAP_TXCSUM) | ||||
MPASS(scctx->isc_tx_csum_flags); | MPASS(scctx->isc_tx_csum_flags); | ||||
#endif | #endif | ||||
if_setcapabilities(ifp, scctx->isc_capabilities | IFCAP_HWSTATS | IFCAP_LINKSTATE); | if_setcapabilities(ifp, scctx->isc_capabilities | IFCAP_HWSTATS | IFCAP_LINKSTATE); | ||||
▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Lines | #endif | ||||
ctx->ifc_vlan_attach_event = | ctx->ifc_vlan_attach_event = | ||||
EVENTHANDLER_REGISTER(vlan_config, iflib_vlan_register, ctx, | EVENTHANDLER_REGISTER(vlan_config, iflib_vlan_register, ctx, | ||||
EVENTHANDLER_PRI_FIRST); | EVENTHANDLER_PRI_FIRST); | ||||
ctx->ifc_vlan_detach_event = | ctx->ifc_vlan_detach_event = | ||||
EVENTHANDLER_REGISTER(vlan_unconfig, iflib_vlan_unregister, ctx, | EVENTHANDLER_REGISTER(vlan_unconfig, iflib_vlan_unregister, ctx, | ||||
EVENTHANDLER_PRI_FIRST); | EVENTHANDLER_PRI_FIRST); | ||||
ifmedia_init(&ctx->ifc_media, IFM_IMASK, | if ((sctx->isc_flags & IFLIB_DRIVER_MEDIA) == 0) { | ||||
ctx->ifc_mediap = &ctx->ifc_media; | |||||
ifmedia_init(ctx->ifc_mediap, IFM_IMASK, | |||||
iflib_media_change, iflib_media_status); | iflib_media_change, iflib_media_status); | ||||
} | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
iflib_queues_alloc(if_ctx_t ctx) | iflib_queues_alloc(if_ctx_t ctx) | ||||
{ | { | ||||
if_shared_ctx_t sctx = ctx->ifc_sctx; | if_shared_ctx_t sctx = ctx->ifc_sctx; | ||||
▲ Show 20 Lines • Show All 1,367 Lines • Show Last 20 Lines |
Second level indent are 4 spaces according to style(9). Apart from that, this change looks good to me.