struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) { struct zd_mac *mac; struct ieee80211_hw *hw; int i; hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); if (!hw) { dev_dbg_f(&intf->dev, "out of memory\n"); return NULL; } mac = zd_hw_mac(hw); memset(mac, 0, sizeof(*mac)); spin_lock_init(&mac->lock); mac->hw = hw; mac->type = IEEE80211_IF_TYPE_INVALID; memcpy(mac->channels, zd_channels, sizeof(zd_channels)); memcpy(mac->rates, zd_rates, sizeof(zd_rates)); mac->modes[0].mode = MODE_IEEE80211G; mac->modes[0].num_rates = ARRAY_SIZE(zd_rates); mac->modes[0].rates = mac->rates; mac->modes[0].num_channels = ARRAY_SIZE(zd_channels); mac->modes[0].channels = mac->channels; mac->modes[1].mode = MODE_IEEE80211B; mac->modes[1].num_rates = 4; mac->modes[1].rates = mac->rates; mac->modes[1].num_channels = ARRAY_SIZE(zd_channels); mac->modes[1].channels = mac->channels; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED; hw->max_rssi = 100; hw->max_signal = 100; hw->queues = 1; hw->extra_tx_headroom = sizeof(struct zd_ctrlset); skb_queue_head_init(&mac->ack_wait_queue); for (i = 0; i < 2; i++) { if (ieee80211_register_hwmode(hw, &mac->modes[i])) { dev_dbg_f(&intf->dev, "cannot register hwmode\n"); ieee80211_free_hw(hw); return NULL; } } zd_chip_init(&mac->chip, hw, intf); housekeeping_init(mac); INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); INIT_WORK(&mac->set_rts_cts_work, set_rts_cts_work); INIT_WORK(&mac->set_rx_filter_work, set_rx_filter_handler); SET_IEEE80211_DEV(hw, &intf->dev); return hw; }
struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) { struct zd_mac *mac; struct ieee80211_hw *hw; hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); if (!hw) { dev_dbg_f(&intf->dev, "out of memory\n"); return NULL; } mac = zd_hw_mac(hw); memset(mac, 0, sizeof(*mac)); spin_lock_init(&mac->lock); mac->hw = hw; mac->type = IEEE80211_IF_TYPE_INVALID; memcpy(mac->channels, zd_channels, sizeof(zd_channels)); memcpy(mac->rates, zd_rates, sizeof(zd_rates)); mac->band.n_bitrates = ARRAY_SIZE(zd_rates); mac->band.bitrates = mac->rates; mac->band.n_channels = ARRAY_SIZE(zd_channels); mac->band.channels = mac->channels; hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE; hw->max_rssi = 100; hw->max_signal = 100; hw->queues = 1; hw->extra_tx_headroom = sizeof(struct zd_ctrlset); skb_queue_head_init(&mac->ack_wait_queue); zd_chip_init(&mac->chip, hw, intf); housekeeping_init(mac); INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); INIT_WORK(&mac->set_rts_cts_work, set_rts_cts_work); INIT_WORK(&mac->set_rx_filter_work, set_rx_filter_handler); INIT_WORK(&mac->process_intr, zd_process_intr); SET_IEEE80211_DEV(hw, &intf->dev); return hw; }
int zd_mac_init(struct zd_mac *mac, struct net_device *netdev, struct usb_interface *intf) { struct ieee80211_device *ieee = zd_netdev_ieee80211(netdev); memset(mac, 0, sizeof(*mac)); spin_lock_init(&mac->lock); mac->netdev = netdev; INIT_DELAYED_WORK(&mac->set_rts_cts_work, set_rts_cts_work); INIT_DELAYED_WORK(&mac->set_basic_rates_work, set_basic_rates_work); skb_queue_head_init(&mac->rx_queue); tasklet_init(&mac->rx_tasklet, do_rx, (unsigned long)mac); tasklet_disable(&mac->rx_tasklet); ieee_init(ieee); softmac_init(ieee80211_priv(netdev)); zd_chip_init(&mac->chip, netdev, intf); housekeeping_init(mac); INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); return 0; }