Lines Matching +full:t +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2007-2012 Siemens AG
23 static void ieee802154_tasklet_handler(struct tasklet_struct *t) in ieee802154_tasklet_handler() argument
25 struct ieee802154_local *local = from_tasklet(local, t, tasklet); in ieee802154_tasklet_handler()
28 while ((skb = skb_dequeue(&local->skb_queue))) { in ieee802154_tasklet_handler()
29 switch (skb->pkt_type) { in ieee802154_tasklet_handler()
31 /* Clear skb->pkt_type in order to not confuse kernel in ieee802154_tasklet_handler()
34 skb->pkt_type = 0; in ieee802154_tasklet_handler()
39 skb->pkt_type); in ieee802154_tasklet_handler()
49 struct wpan_phy *phy; in ieee802154_alloc_hw() local
53 if (WARN_ON(!ops || !(ops->xmit_async || ops->xmit_sync) || !ops->ed || in ieee802154_alloc_hw()
54 !ops->start || !ops->stop || !ops->set_channel)) in ieee802154_alloc_hw()
57 /* Ensure 32-byte alignment of our private data and hw private data. in ieee802154_alloc_hw()
63 * +-------------------------+ in ieee802154_alloc_hw()
65 * +-------------------------+ in ieee802154_alloc_hw()
67 * +-------------------------+ in ieee802154_alloc_hw()
69 * +-------------------------+ in ieee802154_alloc_hw()
71 * Due to ieee802154 layer isn't aware of driver and MAC structures, in ieee802154_alloc_hw()
77 phy = wpan_phy_new(&mac802154_config_ops, priv_size); in ieee802154_alloc_hw()
78 if (!phy) { in ieee802154_alloc_hw()
83 phy->privid = mac802154_wpan_phy_privid; in ieee802154_alloc_hw()
85 local = wpan_phy_priv(phy); in ieee802154_alloc_hw()
86 local->phy = phy; in ieee802154_alloc_hw()
87 local->hw.phy = local->phy; in ieee802154_alloc_hw()
88 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); in ieee802154_alloc_hw()
89 local->ops = ops; in ieee802154_alloc_hw()
91 INIT_LIST_HEAD(&local->interfaces); in ieee802154_alloc_hw()
92 INIT_LIST_HEAD(&local->rx_beacon_list); in ieee802154_alloc_hw()
93 INIT_LIST_HEAD(&local->rx_mac_cmd_list); in ieee802154_alloc_hw()
94 mutex_init(&local->iflist_mtx); in ieee802154_alloc_hw()
96 tasklet_setup(&local->tasklet, ieee802154_tasklet_handler); in ieee802154_alloc_hw()
98 skb_queue_head_init(&local->skb_queue); in ieee802154_alloc_hw()
100 INIT_WORK(&local->sync_tx_work, ieee802154_xmit_sync_worker); in ieee802154_alloc_hw()
101 INIT_DELAYED_WORK(&local->scan_work, mac802154_scan_worker); in ieee802154_alloc_hw()
102 INIT_WORK(&local->rx_beacon_work, mac802154_rx_beacon_worker); in ieee802154_alloc_hw()
103 INIT_DELAYED_WORK(&local->beacon_work, mac802154_beacon_worker); in ieee802154_alloc_hw()
104 INIT_WORK(&local->rx_mac_cmd_work, mac802154_rx_mac_cmd_worker); in ieee802154_alloc_hw()
107 phy->supported.max_minbe = 8; in ieee802154_alloc_hw()
108 phy->supported.min_maxbe = 3; in ieee802154_alloc_hw()
109 phy->supported.max_maxbe = 8; in ieee802154_alloc_hw()
110 phy->supported.min_frame_retries = 0; in ieee802154_alloc_hw()
111 phy->supported.max_frame_retries = 7; in ieee802154_alloc_hw()
112 phy->supported.max_csma_backoffs = 5; in ieee802154_alloc_hw()
113 phy->supported.lbt = NL802154_SUPPORTED_BOOL_FALSE; in ieee802154_alloc_hw()
116 phy->supported.iftypes = BIT(NL802154_IFTYPE_NODE) | BIT(NL802154_IFTYPE_COORD); in ieee802154_alloc_hw()
118 return &local->hw; in ieee802154_alloc_hw()
122 void ieee802154_configure_durations(struct wpan_phy *phy, in ieee802154_configure_durations() argument
130 /* 868 MHz BPSK 802.15.4-2003: 20 ksym/s */ in ieee802154_configure_durations()
133 /* 915 MHz BPSK 802.15.4-2003: 40 ksym/s */ in ieee802154_configure_durations()
136 /* 2400 MHz O-QPSK 802.15.4-2006: 62.5 ksym/s */ in ieee802154_configure_durations()
141 /* 868 MHz O-QPSK 802.15.4-2006: 25 ksym/s */ in ieee802154_configure_durations()
144 /* 915 MHz O-QPSK 802.15.4-2006: 62.5 ksym/s */ in ieee802154_configure_durations()
149 /* 2.4 GHz CSS 802.15.4a-2007: 1/6 Msym/s */ in ieee802154_configure_durations()
157 pr_debug("Unknown PHY symbol duration\n"); in ieee802154_configure_durations()
161 phy->symbol_duration = duration; in ieee802154_configure_durations()
162 phy->lifs_period = (IEEE802154_LIFS_PERIOD * phy->symbol_duration) / NSEC_PER_SEC; in ieee802154_configure_durations()
163 phy->sifs_period = (IEEE802154_SIFS_PERIOD * phy->symbol_duration) / NSEC_PER_SEC; in ieee802154_configure_durations()
171 BUG_ON(!list_empty(&local->interfaces)); in ieee802154_free_hw()
173 mutex_destroy(&local->iflist_mtx); in ieee802154_free_hw()
175 wpan_phy_free(local->phy); in ieee802154_free_hw()
185 wpan_phy->lifs_period = in ieee802154_setup_wpan_phy_pib()
186 (IEEE802154_LIFS_PERIOD * wpan_phy->symbol_duration) / 1000; in ieee802154_setup_wpan_phy_pib()
187 wpan_phy->sifs_period = in ieee802154_setup_wpan_phy_pib()
188 (IEEE802154_SIFS_PERIOD * wpan_phy->symbol_duration) / 1000; in ieee802154_setup_wpan_phy_pib()
196 int rc = -ENOSYS; in ieee802154_register_hw()
198 local->workqueue = in ieee802154_register_hw()
199 create_singlethread_workqueue(wpan_phy_name(local->phy)); in ieee802154_register_hw()
200 if (!local->workqueue) { in ieee802154_register_hw()
201 rc = -ENOMEM; in ieee802154_register_hw()
205 snprintf(mac_wq_name, IFNAMSIZ + 10, "%s-mac-cmds", wpan_phy_name(local->phy)); in ieee802154_register_hw()
206 local->mac_wq = create_singlethread_workqueue(mac_wq_name); in ieee802154_register_hw()
207 if (!local->mac_wq) { in ieee802154_register_hw()
208 rc = -ENOMEM; in ieee802154_register_hw()
212 hrtimer_init(&local->ifs_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in ieee802154_register_hw()
213 local->ifs_timer.function = ieee802154_xmit_ifs_timer; in ieee802154_register_hw()
215 wpan_phy_set_dev(local->phy, local->hw.parent); in ieee802154_register_hw()
217 ieee802154_setup_wpan_phy_pib(local->phy); in ieee802154_register_hw()
219 ieee802154_configure_durations(local->phy, local->phy->current_page, in ieee802154_register_hw()
220 local->phy->current_channel); in ieee802154_register_hw()
222 if (!(hw->flags & IEEE802154_HW_CSMA_PARAMS)) { in ieee802154_register_hw()
223 local->phy->supported.min_csma_backoffs = 4; in ieee802154_register_hw()
224 local->phy->supported.max_csma_backoffs = 4; in ieee802154_register_hw()
225 local->phy->supported.min_maxbe = 5; in ieee802154_register_hw()
226 local->phy->supported.max_maxbe = 5; in ieee802154_register_hw()
227 local->phy->supported.min_minbe = 3; in ieee802154_register_hw()
228 local->phy->supported.max_minbe = 3; in ieee802154_register_hw()
231 if (!(hw->flags & IEEE802154_HW_FRAME_RETRIES)) { in ieee802154_register_hw()
232 local->phy->supported.min_frame_retries = 3; in ieee802154_register_hw()
233 local->phy->supported.max_frame_retries = 3; in ieee802154_register_hw()
236 if (hw->flags & IEEE802154_HW_PROMISCUOUS) in ieee802154_register_hw()
237 local->phy->supported.iftypes |= BIT(NL802154_IFTYPE_MONITOR); in ieee802154_register_hw()
239 rc = wpan_phy_register(local->phy); in ieee802154_register_hw()
259 wpan_phy_unregister(local->phy); in ieee802154_register_hw()
261 destroy_workqueue(local->mac_wq); in ieee802154_register_hw()
263 destroy_workqueue(local->workqueue); in ieee802154_register_hw()
273 tasklet_kill(&local->tasklet); in ieee802154_unregister_hw()
274 flush_workqueue(local->workqueue); in ieee802154_unregister_hw()
282 destroy_workqueue(local->mac_wq); in ieee802154_unregister_hw()
283 destroy_workqueue(local->workqueue); in ieee802154_unregister_hw()
284 wpan_phy_unregister(local->phy); in ieee802154_unregister_hw()