// SPDX-License-Identifier: GPL-2.0-only /* * NXP Wireless LAN device driver: major functions * * Copyright 2011-2020 NXP */ #include <linux/suspend.h> #include "main.h" #include "wmm.h" #include "cfg80211.h" #include "11n.h" #define VERSION … #define MFG_FIRMWARE … static unsigned int debug_mask = …; module_param(debug_mask, uint, 0); MODULE_PARM_DESC(…) …; const char driver_version[] = …; static char *cal_data_cfg; module_param(cal_data_cfg, charp, 0); static unsigned short driver_mode; module_param(driver_mode, ushort, 0); MODULE_PARM_DESC(…) …; bool mfg_mode; module_param(mfg_mode, bool, 0); MODULE_PARM_DESC(…) …; bool aggr_ctrl; module_param(aggr_ctrl, bool, 0000); MODULE_PARM_DESC(…) …; const u16 mwifiex_1d_to_wmm_queue[8] = …; /* * This function registers the device and performs all the necessary * initializations. * * The following initialization operations are performed - * - Allocate adapter structure * - Save interface specific operations table in adapter * - Call interface specific initialization routine * - Allocate private structures * - Set default adapter structure parameters * - Initialize locks * * In case of any errors during inittialization, this function also ensures * proper cleanup before exiting. */ static int mwifiex_register(void *card, struct device *dev, struct mwifiex_if_ops *if_ops, void **padapter) { … } /* * This function unregisters the device and performs all the necessary * cleanups. * * The following cleanup operations are performed - * - Free the timers * - Free beacon buffers * - Free private structures * - Free adapter structure */ static int mwifiex_unregister(struct mwifiex_adapter *adapter) { … } void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) { … } static int mwifiex_process_rx(struct mwifiex_adapter *adapter) { … } static void maybe_quirk_fw_disable_ds(struct mwifiex_adapter *adapter) { … } /* * The main process. * * This function is the main procedure of the driver and handles various driver * operations. It runs in a loop and provides the core functionalities. * * The main responsibilities of this function are - * - Ensure concurrency control * - Handle pending interrupts and call interrupt handlers * - Wake up the card if required * - Handle command responses and call response handlers * - Handle events and call event handlers * - Execute pending commands * - Transmit pending data packets */ int mwifiex_main_process(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); /* * This function frees the adapter structure. * * Additionally, this closes the netlink socket, frees the timers * and private structures. */ static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) { … } /* * This function cancels all works in the queue and destroys * the main workqueue. */ static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) { … } /* * This function gets firmware and initializes it. * * The main initialization steps followed are - * - Download the correct firmware to card * - Issue the init commands to firmware */ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context) { … } static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) { … } /* * This function gets the firmware and (if called asynchronously) kicks off the * HW init when done. */ static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, bool req_fw_nowait) { … } /* * CFG802.11 network device handler for open. * * Starts the data queue. */ static int mwifiex_open(struct net_device *dev) { … } /* * CFG802.11 network device handler for close. */ static int mwifiex_close(struct net_device *dev) { … } static bool mwifiex_bypass_tx_queue(struct mwifiex_private *priv, struct sk_buff *skb) { … } /* * Add buffer into wmm tx queue and queue work to transmit it. */ int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb) { … } struct sk_buff * mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv, struct sk_buff *skb, u8 flag, u64 *cookie) { … } /* * CFG802.11 network device handler for data transmission. */ static netdev_tx_t mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { … } int mwifiex_set_mac_address(struct mwifiex_private *priv, struct net_device *dev, bool external, u8 *new_mac) { … } /* CFG802.11 network device handler for setting MAC address. */ static int mwifiex_ndo_set_mac_address(struct net_device *dev, void *addr) { … } /* * CFG802.11 network device handler for setting multicast list. */ static void mwifiex_set_multicast_list(struct net_device *dev) { … } /* * CFG802.11 network device handler for transmission timeout. */ static void mwifiex_tx_timeout(struct net_device *dev, unsigned int txqueue) { … } void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); /* * CFG802.11 network device handler for statistics retrieval. */ static struct net_device_stats *mwifiex_get_stats(struct net_device *dev) { … } static u16 mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev) { … } /* Network device handlers */ static const struct net_device_ops mwifiex_netdev_ops = …; /* * This function initializes the private structure parameters. * * The following wait queues are initialized - * - IOCTL wait queue * - Command wait queue * - Statistics wait queue * * ...and the following default parameters are set - * - Current key index : Set to 0 * - Rate index : Set to auto * - Media connected : Set to disconnected * - Adhoc link sensed : Set to false * - Nick name : Set to null * - Number of Tx timeout : Set to 0 * - Device address : Set to current address * - Rx histogram statistc : Set to 0 * * In addition, the CFG80211 work queue is also created. */ void mwifiex_init_priv_params(struct mwifiex_private *priv, struct net_device *dev) { … } /* * This function check if command is pending. */ int is_command_pending(struct mwifiex_adapter *adapter) { … } /* * This is the RX work queue function. * * It handles the RX operations. */ static void mwifiex_rx_work_queue(struct work_struct *work) { … } /* * This is the main work queue function. * * It handles the main process, which in turn handles the complete * driver operations. */ static void mwifiex_main_work_queue(struct work_struct *work) { … } /* Common teardown code used for both device removal and reset */ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) { … } /* * This function can be used for shutting down the adapter SW. */ int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); /* This function can be used for reinitting the adapter SW. Required * code is extracted from mwifiex_add_card() */ int mwifiex_reinit_sw(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); static irqreturn_t mwifiex_irq_wakeup_handler(int irq, void *priv) { … } static void mwifiex_probe_of(struct mwifiex_adapter *adapter) { … } /* * This function adds the card. * * This function follows the following major steps to set up the device - * - Initialize software. This includes probing the card, registering * the interface operations table, and allocating/initializing the * adapter structure * - Set up the netlink socket * - Create and start the main work queue * - Register the device * - Initialize firmware and hardware * - Add logical interfaces */ int mwifiex_add_card(void *card, struct completion *fw_done, struct mwifiex_if_ops *if_ops, u8 iface_type, struct device *dev) { … } EXPORT_SYMBOL_GPL(…); /* * This function removes the card. * * This function follows the following major steps to remove the device - * - Stop data traffic * - Shutdown firmware * - Remove the logical interfaces * - Terminate the work queue * - Unregister the device * - Free the adapter structure */ int mwifiex_remove_card(struct mwifiex_adapter *adapter) { … } EXPORT_SYMBOL_GPL(…); void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, const char *fmt, ...) { … } EXPORT_SYMBOL_GPL(…); /* * This function initializes the module. * * The debug FS is also initialized if configured. */ static int mwifiex_init_module(void) { … } /* * This function cleans up the module. * * The debug FS is removed if available. */ static void mwifiex_cleanup_module(void) { … } module_init(…) …; module_exit(mwifiex_cleanup_module); MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_VERSION(…); MODULE_LICENSE(…) …;