MCPcopy Index your code
hub / github.com/F-Stack/f-stack / iflib_register

Function iflib_register

freebsd/net/iflib.c:5474–5542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5472}
5473
5474static int
5475iflib_register(if_ctx_t ctx)
5476{
5477 if_shared_ctx_t sctx = ctx->ifc_sctx;
5478 driver_t *driver = sctx->isc_driver;
5479 device_t dev = ctx->ifc_dev;
5480 if_t ifp;
5481 u_char type;
5482 int iflags;
5483
5484 if ((sctx->isc_flags & IFLIB_PSEUDO) == 0)
5485 _iflib_assert(sctx);
5486
5487 CTX_LOCK_INIT(ctx);
5488 STATE_LOCK_INIT(ctx, device_get_nameunit(ctx->ifc_dev));
5489 if (sctx->isc_flags & IFLIB_PSEUDO) {
5490 if (sctx->isc_flags & IFLIB_PSEUDO_ETHER)
5491 type = IFT_ETHER;
5492 else
5493 type = IFT_PPP;
5494 } else
5495 type = IFT_ETHER;
5496 ifp = ctx->ifc_ifp = if_alloc(type);
5497 if (ifp == NULL) {
5498 device_printf(dev, "can not allocate ifnet structure\n");
5499 return (ENOMEM);
5500 }
5501
5502 /*
5503 * Initialize our context's device specific methods
5504 */
5505 kobj_init((kobj_t) ctx, (kobj_class_t) driver);
5506 kobj_class_compile((kobj_class_t) driver);
5507
5508 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
5509 if_setsoftc(ifp, ctx);
5510 if_setdev(ifp, dev);
5511 if_setinitfn(ifp, iflib_if_init);
5512 if_setioctlfn(ifp, iflib_if_ioctl);
5513#ifdef ALTQ
5514 if_setstartfn(ifp, iflib_altq_if_start);
5515 if_settransmitfn(ifp, iflib_altq_if_transmit);
5516 if_setsendqready(ifp);
5517#else
5518 if_settransmitfn(ifp, iflib_if_transmit);
5519#endif
5520 if_setqflushfn(ifp, iflib_if_qflush);
5521 iflags = IFF_MULTICAST | IFF_KNOWSEPOCH;
5522
5523 if ((sctx->isc_flags & IFLIB_PSEUDO) &&
5524 (sctx->isc_flags & IFLIB_PSEUDO_ETHER) == 0)
5525 iflags |= IFF_POINTOPOINT;
5526 else
5527 iflags |= IFF_BROADCAST | IFF_SIMPLEX;
5528 if_setflags(ifp, iflags);
5529 ctx->ifc_vlan_attach_event =
5530 EVENTHANDLER_REGISTER(vlan_config, iflib_vlan_register, ctx,
5531 EVENTHANDLER_PRI_FIRST);

Callers 2

iflib_device_registerFunction · 0.85
iflib_pseudo_registerFunction · 0.85

Calls 15

_iflib_assertFunction · 0.85
device_get_nameunitFunction · 0.85
if_allocFunction · 0.85
device_printfFunction · 0.85
kobj_initFunction · 0.85
kobj_class_compileFunction · 0.85
if_initnameFunction · 0.85
device_get_nameFunction · 0.85
device_get_unitFunction · 0.85
if_setsoftcFunction · 0.85
if_setdevFunction · 0.85
if_setinitfnFunction · 0.85

Tested by

no test coverage detected