Changeset View
Changeset View
Standalone View
Standalone View
sys/net/iflib.c
Show First 20 Lines • Show All 4,467 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
**********************************************************************/ | **********************************************************************/ | ||||
static void | static void | ||||
iflib_vlan_register(void *arg, if_t ifp, uint16_t vtag) | iflib_vlan_register(void *arg, if_t ifp, uint16_t vtag) | ||||
{ | { | ||||
if_ctx_t ctx = if_getsoftc(ifp); | if_ctx_t ctx = if_getsoftc(ifp); | ||||
if ((void *)ctx != arg) | if ((void *)ifp != arg) | ||||
return; | return; | ||||
if ((vtag == 0) || (vtag > 4095)) | if ((vtag == 0) || (vtag > 4095)) | ||||
return; | return; | ||||
if (iflib_in_detach(ctx)) | if (iflib_in_detach(ctx)) | ||||
return; | return; | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
/* Driver may need all untagged packets to be flushed */ | /* Driver may need all untagged packets to be flushed */ | ||||
if (IFDI_NEEDS_RESTART(ctx, IFLIB_RESTART_VLAN_CONFIG)) | if (IFDI_NEEDS_RESTART(ctx, IFLIB_RESTART_VLAN_CONFIG)) | ||||
iflib_stop(ctx); | iflib_stop(ctx); | ||||
IFDI_VLAN_REGISTER(ctx, vtag); | IFDI_VLAN_REGISTER(ctx, vtag); | ||||
/* Re-init to load the changes, if required */ | /* Re-init to load the changes, if required */ | ||||
if (IFDI_NEEDS_RESTART(ctx, IFLIB_RESTART_VLAN_CONFIG)) | if (IFDI_NEEDS_RESTART(ctx, IFLIB_RESTART_VLAN_CONFIG)) | ||||
iflib_init_locked(ctx); | iflib_init_locked(ctx); | ||||
CTX_UNLOCK(ctx); | CTX_UNLOCK(ctx); | ||||
} | } | ||||
static void | static void | ||||
iflib_vlan_unregister(void *arg, if_t ifp, uint16_t vtag) | iflib_vlan_unregister(void *arg, if_t ifp, uint16_t vtag) | ||||
{ | { | ||||
if_ctx_t ctx = if_getsoftc(ifp); | if_ctx_t ctx = if_getsoftc(ifp); | ||||
if ((void *)ctx != arg) | if ((void *)ifp != arg) | ||||
return; | return; | ||||
if ((vtag == 0) || (vtag > 4095)) | if ((vtag == 0) || (vtag > 4095)) | ||||
return; | return; | ||||
CTX_LOCK(ctx); | CTX_LOCK(ctx); | ||||
/* Driver may need all tagged packets to be flushed */ | /* Driver may need all tagged packets to be flushed */ | ||||
if (IFDI_NEEDS_RESTART(ctx, IFLIB_RESTART_VLAN_CONFIG)) | if (IFDI_NEEDS_RESTART(ctx, IFLIB_RESTART_VLAN_CONFIG)) | ||||
▲ Show 20 Lines • Show All 1,315 Lines • ▼ Show 20 Lines | #endif | ||||
if ((sctx->isc_flags & IFLIB_PSEUDO) && | if ((sctx->isc_flags & IFLIB_PSEUDO) && | ||||
(sctx->isc_flags & IFLIB_PSEUDO_ETHER) == 0) | (sctx->isc_flags & IFLIB_PSEUDO_ETHER) == 0) | ||||
iflags |= IFF_POINTOPOINT; | iflags |= IFF_POINTOPOINT; | ||||
else | else | ||||
iflags |= IFF_BROADCAST | IFF_SIMPLEX; | iflags |= IFF_BROADCAST | IFF_SIMPLEX; | ||||
if_setflags(ifp, iflags); | if_setflags(ifp, iflags); | ||||
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, ifp, | ||||
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, ifp, | ||||
EVENTHANDLER_PRI_FIRST); | EVENTHANDLER_PRI_FIRST); | ||||
if ((sctx->isc_flags & IFLIB_DRIVER_MEDIA) == 0) { | if ((sctx->isc_flags & IFLIB_DRIVER_MEDIA) == 0) { | ||||
ctx->ifc_mediap = &ctx->ifc_media; | ctx->ifc_mediap = &ctx->ifc_media; | ||||
ifmedia_init(ctx->ifc_mediap, IFM_IMASK, | ifmedia_init(ctx->ifc_mediap, IFM_IMASK, | ||||
iflib_media_change, iflib_media_status); | iflib_media_change, iflib_media_status); | ||||
} | } | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 1,319 Lines • Show Last 20 Lines |