/*---------------------------------------------------------------- * wlan_setup * * Roughly matches the functionality of ether_setup. Here * we set up any members of the wlandevice structure that are common * to all devices. Additionally, we allocate a linux 'struct device' * and perform the same setup as ether_setup. * * Note: It's important that the caller have setup the wlandev->name * ptr prior to calling this function. * * Arguments: * wlandev ptr to the wlandev structure for the * interface. * physdev ptr to usb device * Returns: * zero on success, non-zero otherwise. * Call Context: * Should be process thread. We'll assume it might be * interrupt though. When we add support for statically * compiled drivers, this function will be called in the * context of the kernel startup code. *---------------------------------------------------------------- */ int wlan_setup(struct wlandevice *wlandev, struct device *physdev) { int result = 0; struct net_device *netdev; struct wiphy *wiphy; struct wireless_dev *wdev; /* Set up the wlandev */ wlandev->state = WLAN_DEVICE_CLOSED; wlandev->ethconv = WLAN_ETHCONV_8021h; wlandev->macmode = WLAN_MACMODE_NONE; /* Set up the rx queue */ skb_queue_head_init(&wlandev->nsd_rxq); tasklet_init(&wlandev->rx_bh, p80211netdev_rx_bh, (unsigned long)wlandev); /* Allocate and initialize the wiphy struct */ wiphy = wlan_create_wiphy(physdev, wlandev); if (!wiphy) { dev_err(physdev, "Failed to alloc wiphy.\n"); return 1; } /* Allocate and initialize the struct device */ netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", NET_NAME_UNKNOWN, ether_setup); if (!netdev) { dev_err(physdev, "Failed to alloc netdev.\n"); wlan_free_wiphy(wiphy); result = 1; } else { wlandev->netdev = netdev; netdev->ml_priv = wlandev; netdev->netdev_ops = &p80211_netdev_ops; wdev = netdev_priv(netdev); wdev->wiphy = wiphy; wdev->iftype = NL80211_IFTYPE_STATION; netdev->ieee80211_ptr = wdev; netdev->min_mtu = 68; /* 2312 is max 802.11 payload, 20 is overhead, * (ether + llc + snap) and another 8 for wep. */ netdev->max_mtu = (2312 - 20 - 8); netif_stop_queue(netdev); netif_carrier_off(netdev); } return result; }
/*---------------------------------------------------------------- * wlan_setup * * Roughly matches the functionality of ether_setup. Here * we set up any members of the wlandevice structure that are common * to all devices. Additionally, we allocate a linux 'struct device' * and perform the same setup as ether_setup. * * Note: It's important that the caller have setup the wlandev->name * ptr prior to calling this function. * * Arguments: * wlandev ptr to the wlandev structure for the * interface. * physdev ptr to usb device * Returns: * zero on success, non-zero otherwise. * Call Context: * Should be process thread. We'll assume it might be * interrupt though. When we add support for statically * compiled drivers, this function will be called in the * context of the kernel startup code. ----------------------------------------------------------------*/ int wlan_setup(wlandevice_t *wlandev, struct device *physdev) { int result = 0; netdevice_t *netdev; struct wiphy *wiphy; struct wireless_dev *wdev; /* Set up the wlandev */ wlandev->state = WLAN_DEVICE_CLOSED; wlandev->ethconv = WLAN_ETHCONV_8021h; wlandev->macmode = WLAN_MACMODE_NONE; /* Set up the rx queue */ skb_queue_head_init(&wlandev->nsd_rxq); tasklet_init(&wlandev->rx_bh, p80211netdev_rx_bh, (unsigned long)wlandev); /* Allocate and initialize the wiphy struct */ wiphy = wlan_create_wiphy(physdev, wlandev); if (wiphy == NULL) { dev_err(physdev, "Failed to alloc wiphy.\n"); return 1; } /* Allocate and initialize the struct device */ netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", ether_setup); if (netdev == NULL) { dev_err(physdev, "Failed to alloc netdev.\n"); wlan_free_wiphy(wiphy); result = 1; } else { wlandev->netdev = netdev; netdev->ml_priv = wlandev; netdev->netdev_ops = &p80211_netdev_ops; wdev = netdev_priv(netdev); wdev->wiphy = wiphy; wdev->iftype = NL80211_IFTYPE_STATION; netdev->ieee80211_ptr = wdev; netif_stop_queue(netdev); netif_carrier_off(netdev); } return result; }