Lines Matching refs:drv

86 	struct wpa_driver_roboswitch_data *drv, u8 reg)  in wpa_driver_roboswitch_mdio_read()  argument
88 struct mii_ioctl_data *mii = if_mii(&drv->ifr); in wpa_driver_roboswitch_mdio_read()
93 if (ioctl(drv->fd, SIOCGMIIREG, &drv->ifr) < 0) { in wpa_driver_roboswitch_mdio_read()
103 struct wpa_driver_roboswitch_data *drv, u8 reg, u16 val) in wpa_driver_roboswitch_mdio_write() argument
105 struct mii_ioctl_data *mii = if_mii(&drv->ifr); in wpa_driver_roboswitch_mdio_write()
111 if (ioctl(drv->fd, SIOCSMIIREG, &drv->ifr) < 0) { in wpa_driver_roboswitch_mdio_write()
118 static int wpa_driver_roboswitch_reg(struct wpa_driver_roboswitch_data *drv, in wpa_driver_roboswitch_reg() argument
124 wpa_driver_roboswitch_mdio_write(drv, ROBO_MII_PAGE, in wpa_driver_roboswitch_reg()
127 wpa_driver_roboswitch_mdio_write(drv, ROBO_MII_ADDR, (reg << 8) | op); in wpa_driver_roboswitch_reg()
131 if ((wpa_driver_roboswitch_mdio_read(drv, ROBO_MII_ADDR) & 3) in wpa_driver_roboswitch_reg()
140 static int wpa_driver_roboswitch_read(struct wpa_driver_roboswitch_data *drv, in wpa_driver_roboswitch_read() argument
146 wpa_driver_roboswitch_reg(drv, page, reg, ROBO_MII_ADDR_READ) < 0) in wpa_driver_roboswitch_read()
151 drv, ROBO_MII_DATA_OFFSET + i); in wpa_driver_roboswitch_read()
158 static int wpa_driver_roboswitch_write(struct wpa_driver_roboswitch_data *drv, in wpa_driver_roboswitch_write() argument
165 wpa_driver_roboswitch_mdio_write(drv, ROBO_MII_DATA_OFFSET + i, in wpa_driver_roboswitch_write()
168 return wpa_driver_roboswitch_reg(drv, page, reg, ROBO_MII_ADDR_WRITE); in wpa_driver_roboswitch_write()
175 struct wpa_driver_roboswitch_data *drv = priv; in wpa_driver_roboswitch_receive() local
178 os_memcmp(buf, drv->own_addr, ETH_ALEN) == 0) in wpa_driver_roboswitch_receive()
179 drv_event_eapol_rx(drv->ctx, src_addr, buf + 14, len - 14); in wpa_driver_roboswitch_receive()
209 struct wpa_driver_roboswitch_data *drv = priv; in wpa_driver_roboswitch_set_param() local
213 sep = drv->ifname + os_strlen(drv->ifname); in wpa_driver_roboswitch_set_param()
215 drv->l2 = l2_packet_init(drv->ifname, NULL, ETH_P_ALL, in wpa_driver_roboswitch_set_param()
216 wpa_driver_roboswitch_receive, drv, in wpa_driver_roboswitch_set_param()
218 if (drv->l2 == NULL) { in wpa_driver_roboswitch_set_param()
220 __func__, drv->ifname); in wpa_driver_roboswitch_set_param()
224 l2_packet_get_own_addr(drv->l2, drv->own_addr); in wpa_driver_roboswitch_set_param()
227 drv->l2 = NULL; in wpa_driver_roboswitch_set_param()
235 struct wpa_driver_roboswitch_data *drv = priv; in wpa_driver_roboswitch_get_ifname() local
236 return drv->ifname; in wpa_driver_roboswitch_get_ifname()
240 static int wpa_driver_roboswitch_join(struct wpa_driver_roboswitch_data *drv, in wpa_driver_roboswitch_join() argument
247 if (wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
253 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
255 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
257 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
259 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
261 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
265 if (wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
267 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
271 if (wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
273 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
277 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
279 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_join()
286 static int wpa_driver_roboswitch_leave(struct wpa_driver_roboswitch_data *drv, in wpa_driver_roboswitch_leave() argument
293 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_CONF, in wpa_driver_roboswitch_leave()
298 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
300 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, ROBO_ARLCTRL_VEC_1, in wpa_driver_roboswitch_leave()
304 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
306 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
312 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
316 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
319 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
322 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
325 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
330 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
332 wpa_driver_roboswitch_read(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
337 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
340 wpa_driver_roboswitch_write(drv, ROBO_ARLCTRL_PAGE, in wpa_driver_roboswitch_leave()
351 struct wpa_driver_roboswitch_data *drv; in wpa_driver_roboswitch_init() local
355 drv = os_zalloc(sizeof(*drv)); in wpa_driver_roboswitch_init()
356 if (drv == NULL) return NULL; in wpa_driver_roboswitch_init()
357 drv->ctx = ctx; in wpa_driver_roboswitch_init()
358 drv->own_addr[0] = '\0'; in wpa_driver_roboswitch_init()
361 sep = drv->ifname + in wpa_driver_roboswitch_init()
362 os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)) - 2; in wpa_driver_roboswitch_init()
364 while (sep > drv->ifname && *sep != '.') sep--; in wpa_driver_roboswitch_init()
365 if (sep <= drv->ifname) { in wpa_driver_roboswitch_init()
367 "interface name %s", __func__, drv->ifname); in wpa_driver_roboswitch_init()
368 os_free(drv); in wpa_driver_roboswitch_init()
376 os_free(drv); in wpa_driver_roboswitch_init()
384 os_free(drv); in wpa_driver_roboswitch_init()
389 drv->fd = socket(PF_INET, SOCK_DGRAM, 0); in wpa_driver_roboswitch_init()
390 if (drv->fd < 0) { in wpa_driver_roboswitch_init()
392 os_free(drv); in wpa_driver_roboswitch_init()
396 os_memset(&drv->ifr, 0, sizeof(drv->ifr)); in wpa_driver_roboswitch_init()
397 os_strlcpy(drv->ifr.ifr_name, drv->ifname, IFNAMSIZ); in wpa_driver_roboswitch_init()
398 if (ioctl(drv->fd, SIOCGMIIPHY, &drv->ifr) < 0) { in wpa_driver_roboswitch_init()
401 os_free(drv); in wpa_driver_roboswitch_init()
404 if (if_mii(&drv->ifr)->phy_id != ROBO_PHY_ADDR) { in wpa_driver_roboswitch_init()
407 os_free(drv); in wpa_driver_roboswitch_init()
413 wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE, ROBO_VLAN_ACCESS_5350, in wpa_driver_roboswitch_init()
415 wpa_driver_roboswitch_read(drv, ROBO_VLAN_PAGE, ROBO_VLAN_ACCESS_5350, in wpa_driver_roboswitch_init()
417 drv->is_5350 = _read[0] == _read[1]; in wpa_driver_roboswitch_init()
421 wpa_driver_roboswitch_write(drv, ROBO_VLAN_PAGE, in wpa_driver_roboswitch_init()
422 drv->is_5350 ? ROBO_VLAN_ACCESS_5350 in wpa_driver_roboswitch_init()
425 wpa_driver_roboswitch_read(drv, ROBO_VLAN_PAGE, ROBO_VLAN_READ, _read, in wpa_driver_roboswitch_init()
426 drv->is_5350 ? 2 : 1); in wpa_driver_roboswitch_init()
427 if (!(drv->is_5350 ? _read[1] & (1 << 4) : _read[0] & (1 << 14))) { in wpa_driver_roboswitch_init()
430 os_free(drv); in wpa_driver_roboswitch_init()
433 drv->ports = _read[0] & 0x001F; in wpa_driver_roboswitch_init()
435 drv->ports |= 1 << 8; in wpa_driver_roboswitch_init()
436 if (wpa_driver_roboswitch_join(drv, drv->ports, pae_group_addr) < 0) { in wpa_driver_roboswitch_init()
438 os_free(drv); in wpa_driver_roboswitch_init()
445 return drv; in wpa_driver_roboswitch_init()
451 struct wpa_driver_roboswitch_data *drv = priv; in wpa_driver_roboswitch_deinit() local
453 if (drv->l2) { in wpa_driver_roboswitch_deinit()
454 l2_packet_deinit(drv->l2); in wpa_driver_roboswitch_deinit()
455 drv->l2 = NULL; in wpa_driver_roboswitch_deinit()
457 if (wpa_driver_roboswitch_leave(drv, drv->ports, pae_group_addr) < 0) { in wpa_driver_roboswitch_deinit()
462 close(drv->fd); in wpa_driver_roboswitch_deinit()
463 os_free(drv); in wpa_driver_roboswitch_deinit()