Lines Matching refs:sc

78 	struct ip17x_softc *sc;
81 sc = device_get_softc(dev);
98 sc->sc_switchtype = IP17X_SWITCH_IP175A;
101 sc->sc_switchtype = IP17X_SWITCH_IP175C;
113 sc->sc_switchtype = IP17X_SWITCH_IP175D;
118 sc->sc_switchtype = IP17X_SWITCH_IP178C;
126 ip17x_attach_phys(struct ip17x_softc *sc)
134 snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
136 if (((1 << phy) & sc->phymask) == 0)
138 sc->phyport[phy] = port;
139 sc->portphy[port] = phy;
140 sc->ifp[port] = if_alloc(IFT_ETHER);
141 sc->ifp[port]->if_softc = sc;
142 sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
144 if_initname(sc->ifp[port], name, port);
145 sc->miibus[port] = malloc(sizeof(device_t), M_IP17X,
147 err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port],
150 DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n",
151 device_get_nameunit(*sc->miibus[port]),
152 sc->ifp[port]->if_xname);
154 device_printf(sc->sc_dev,
159 sc->info.es_nports = port + 1;
160 if (++port >= sc->numports)
169 struct ip17x_softc *sc;
172 sc = device_get_softc(dev);
174 sc->sc_dev = dev;
175 mtx_init(&sc->sc_mtx, "ip17x", NULL, MTX_DEF);
176 strlcpy(sc->info.es_name, device_get_desc(dev),
177 sizeof(sc->info.es_name));
180 sc->phymask = 0x0f;
181 sc->media = 100;
184 "phymask", &sc->phymask);
187 sc->info.es_nvlangroups = IP17X_MAX_VLANS;
190 if (IP17X_IS_SWITCH(sc, IP175C))
191 ip175c_attach(sc);
192 else if (IP17X_IS_SWITCH(sc, IP175D))
193 ip175d_attach(sc);
199 sc->phymask |= (1 << sc->cpuport);
201 sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_IP17X,
203 sc->pvid = malloc(sizeof(uint32_t) * sc->numports, M_IP17X,
205 sc->miibus = malloc(sizeof(device_t *) * sc->numports, M_IP17X,
207 sc->portphy = malloc(sizeof(int) * sc->numports, M_IP17X,
211 sc->hal.ip17x_reset(sc);
216 err = ip17x_attach_phys(sc);
224 sc->hal.ip17x_set_vlan_mode(sc, ETHERSWITCH_VLAN_PORT);
232 callout_init(&sc->callout_tick, 0);
234 ip17x_tick(sc);
242 struct ip17x_softc *sc;
245 sc = device_get_softc(dev);
246 callout_drain(&sc->callout_tick);
249 if (((1 << i) & sc->phymask) == 0)
251 port = sc->phyport[i];
252 if (sc->miibus[port] != NULL)
253 device_delete_child(dev, (*sc->miibus[port]));
254 if (sc->ifp[port] != NULL)
255 if_free(sc->ifp[port]);
256 free(sc->miibus[port], M_IP17X);
259 free(sc->portphy, M_IP17X);
260 free(sc->miibus, M_IP17X);
261 free(sc->pvid, M_IP17X);
262 free(sc->ifp, M_IP17X);
265 sc->hal.ip17x_reset(sc);
268 mtx_destroy(&sc->sc_mtx);
274 ip17x_miiforport(struct ip17x_softc *sc, int port)
277 if (port < 0 || port > sc->numports)
279 return (device_get_softc(*sc->miibus[port]));
283 ip17x_ifpforport(struct ip17x_softc *sc, int port)
286 if (port < 0 || port > sc->numports)
288 return (sc->ifp[port]);
295 ip17x_miipollstat(struct ip17x_softc *sc)
301 IP17X_LOCK_ASSERT(sc, MA_NOTOWNED);
304 if (((1 << i) & sc->phymask) == 0)
306 port = sc->phyport[i];
307 if ((*sc->miibus[port]) == NULL)
309 mii = device_get_softc(*sc->miibus[port]);
323 struct ip17x_softc *sc;
325 sc = arg;
326 ip17x_miipollstat(sc);
327 callout_reset(&sc->callout_tick, hz, ip17x_tick, sc);
333 struct ip17x_softc *sc;
335 sc = device_get_softc(dev);
336 IP17X_LOCK_ASSERT(sc, MA_NOTOWNED);
337 IP17X_LOCK(sc);
343 struct ip17x_softc *sc;
345 sc = device_get_softc(dev);
346 IP17X_LOCK_ASSERT(sc, MA_OWNED);
347 IP17X_UNLOCK(sc);
353 struct ip17x_softc *sc;
355 sc = device_get_softc(dev);
356 return (&sc->info);
362 struct ip17x_softc *sc;
367 sc = device_get_softc(dev);
368 if (p->es_port < 0 || p->es_port >= sc->numports)
371 phy = sc->portphy[p->es_port];
374 p->es_pvid = sc->pvid[phy];
377 if (sc->addtag & (1 << phy))
379 if (sc->striptag & (1 << phy))
388 mii = ip17x_miiforport(sc, p->es_port);
391 if (phy == sc->cpuport) {
395 if (sc->media == 100)
415 struct ip17x_softc *sc;
421 sc = device_get_softc(dev);
422 if (p->es_port < 0 || p->es_port >= sc->numports)
425 phy = sc->portphy[p->es_port];
426 ifp = ip17x_ifpforport(sc, p->es_port);
427 mii = ip17x_miiforport(sc, p->es_port);
432 if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) {
436 if (IP17X_IS_SWITCH(sc, IP175C) &&
439 sc->pvid[phy] = p->es_pvid;
448 sc->addtag &= ~(1 << phy);
449 sc->striptag &= ~(1 << phy);
453 sc->addtag |= (1 << phy);
455 sc->striptag |= (1 << phy);
459 if (sc->hal.ip17x_hw_setup(sc))
463 if (phy == sc->cpuport)
484 struct ip17x_softc *sc;
487 sc = ifp->if_softc;
488 DPRINTF(sc->sc_dev, "%s\n", __func__);
489 mii = ip17x_miiforport(sc, ifp->if_dunit);
500 struct ip17x_softc *sc;
503 sc = ifp->if_softc;
504 DPRINTF(sc->sc_dev, "%s\n", __func__);
505 mii = ip17x_miiforport(sc, ifp->if_dunit);
516 struct ip17x_softc *sc;
518 sc = device_get_softc(dev);
519 IP17X_LOCK_ASSERT(sc, MA_OWNED);
528 struct ip17x_softc *sc;
530 sc = device_get_softc(dev);
531 IP17X_LOCK_ASSERT(sc, MA_OWNED);
540 struct ip17x_softc *sc;
542 sc = device_get_softc(dev);
546 conf->vlan_mode = sc->hal.ip17x_get_vlan_mode(sc);
554 struct ip17x_softc *sc;
556 sc = device_get_softc(dev);
560 sc->hal.ip17x_set_vlan_mode(sc, conf->vlan_mode);