Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/cxgbe/t4_tracer.c
| Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | if (strncmp(name, "t4nex", 5) != 0 && | ||||
| strncmp(name, "t6nex", 5) != 0) | strncmp(name, "t6nex", 5) != 0) | ||||
| return (0); | return (0); | ||||
| if (name[5] < '0' || name[5] > '9') | if (name[5] < '0' || name[5] > '9') | ||||
| return (0); | return (0); | ||||
| return (1); | return (1); | ||||
| } | } | ||||
| static int | static int | ||||
| t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) | t4_cloner_create(struct if_clone *ifc, char *name, size_t len, | ||||
| struct ifc_data *ifd, struct ifnet **ifpp) | |||||
| { | { | ||||
| struct match_rr mrr; | struct match_rr mrr; | ||||
| struct adapter *sc; | struct adapter *sc; | ||||
| if_t ifp; | if_t ifp; | ||||
| int rc, unit; | int rc, unit; | ||||
| const uint8_t lla[ETHER_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; | const uint8_t lla[ETHER_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; | ||||
| mrr.name = name; | mrr.name = name; | ||||
| Show All 16 Lines | if (sc->ifp != NULL) { | ||||
| rc = EEXIST; | rc = EEXIST; | ||||
| goto done; | goto done; | ||||
| } | } | ||||
| if (sc->traceq < 0) { | if (sc->traceq < 0) { | ||||
| rc = EAGAIN; | rc = EAGAIN; | ||||
| goto done; | goto done; | ||||
| } | } | ||||
| unit = -1; | unit = -1; | ||||
| rc = ifc_alloc_unit(ifc, &unit); | rc = ifc_alloc_unit(ifc, &unit); | ||||
| if (rc != 0) | if (rc != 0) | ||||
| goto done; | goto done; | ||||
| ifp = if_alloc(IFT_ETHER); | ifp = if_alloc(IFT_ETHER); | ||||
| if (ifp == NULL) { | if (ifp == NULL) { | ||||
| ifc_free_unit(ifc, unit); | ifc_free_unit(ifc, unit); | ||||
| rc = ENOMEM; | rc = ENOMEM; | ||||
| goto done; | goto done; | ||||
| } | } | ||||
| /* Note that if_xname is not <if_dname><if_dunit>. */ | /* Note that if_xname is not <if_dname><if_dunit>. */ | ||||
| if_initname(ifp, name, unit); | if_initname(ifp, name, ifd->unit); | ||||
melifaro: Does this change work for you? | |||||
| if_setdname(ifp, t4_cloner_name); | if_setdname(ifp, t4_cloner_name); | ||||
| if_setinitfn(ifp, tracer_init); | if_setinitfn(ifp, tracer_init); | ||||
| if_setflags(ifp, IFF_SIMPLEX | IFF_DRV_RUNNING); | if_setflags(ifp, IFF_SIMPLEX | IFF_DRV_RUNNING); | ||||
| if_setioctlfn(ifp, tracer_ioctl); | if_setioctlfn(ifp, tracer_ioctl); | ||||
| if_settransmitfn(ifp, tracer_transmit); | if_settransmitfn(ifp, tracer_transmit); | ||||
| if_setqflushfn(ifp, tracer_qflush); | if_setqflushfn(ifp, tracer_qflush); | ||||
| if_setcapabilities(ifp, IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU); | if_setcapabilities(ifp, IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU); | ||||
| ifmedia_init(&sc->media, IFM_IMASK, tracer_media_change, | ifmedia_init(&sc->media, IFM_IMASK, tracer_media_change, | ||||
| tracer_media_status); | tracer_media_status); | ||||
| ifmedia_add(&sc->media, IFM_ETHER | IFM_FDX | IFM_NONE, 0, NULL); | ifmedia_add(&sc->media, IFM_ETHER | IFM_FDX | IFM_NONE, 0, NULL); | ||||
| ifmedia_set(&sc->media, IFM_ETHER | IFM_FDX | IFM_NONE); | ifmedia_set(&sc->media, IFM_ETHER | IFM_FDX | IFM_NONE); | ||||
| ether_ifattach(ifp, lla); | ether_ifattach(ifp, lla); | ||||
| mtx_lock(&sc->ifp_lock); | mtx_lock(&sc->ifp_lock); | ||||
| if_setsoftc(ifp, sc); | if_setsoftc(ifp, sc); | ||||
| sc->ifp = ifp; | sc->ifp = ifp; | ||||
| mtx_unlock(&sc->ifp_lock); | mtx_unlock(&sc->ifp_lock); | ||||
| *ifpp = ifp; | |||||
| done: | done: | ||||
| sx_xunlock(&t4_trace_lock); | sx_xunlock(&t4_trace_lock); | ||||
| end_synchronized_op(sc, 0); | end_synchronized_op(sc, 0); | ||||
| return (rc); | return (rc); | ||||
| } | } | ||||
| static int | static int | ||||
| t4_cloner_destroy(struct if_clone *ifc, if_t ifp) | t4_cloner_destroy(struct if_clone *ifc, if_t ifp, uint32_t flags) | ||||
| { | { | ||||
| struct adapter *sc; | struct adapter *sc; | ||||
| int unit = if_getdunit(ifp); | int unit = if_getdunit(ifp); | ||||
| sx_xlock(&t4_trace_lock); | sx_xlock(&t4_trace_lock); | ||||
| sc = if_getsoftc(ifp); | sc = if_getsoftc(ifp); | ||||
| if (sc != NULL) { | if (sc != NULL) { | ||||
| mtx_lock(&sc->ifp_lock); | mtx_lock(&sc->ifp_lock); | ||||
| Show All 10 Lines | t4_cloner_destroy(struct if_clone *ifc, if_t ifp, uint32_t flags) | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| void | void | ||||
| t4_tracer_modload(void) | t4_tracer_modload(void) | ||||
| { | { | ||||
| sx_init(&t4_trace_lock, "T4/T5 tracer lock"); | sx_init(&t4_trace_lock, "T4/T5 tracer lock"); | ||||
| t4_cloner = if_clone_advanced(t4_cloner_name, 0, t4_cloner_match, | struct if_clone_addreq req = { | ||||
| t4_cloner_create, t4_cloner_destroy); | .match_f = t4_cloner_match, | ||||
| .create_f = t4_cloner_create, | |||||
| .destroy_f = t4_cloner_destroy, | |||||
| }; | |||||
| t4_cloner = ifc_attach_cloner(t4_cloner_name, &req); | |||||
| } | } | ||||
| void | void | ||||
| t4_tracer_modunload(void) | t4_tracer_modunload(void) | ||||
| { | { | ||||
| if (t4_cloner != NULL) { | if (t4_cloner != NULL) { | ||||
| /* | /* | ||||
| ▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines | |||||
Does this change work for you?