Commit 4daffe35 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: add support for Marvell USB8797 chipset

This patch supports Avastar 88W8797 chipset with USB interface.

The corresponding firmware image file is located at:
"mrvl/usb8797_uapsta.bin"
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarKiran Divekar <dkiran@marvell.com>
Signed-off-by: default avatarFrank Huang <frankh@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent aee286c2
...@@ -233,6 +233,11 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, ...@@ -233,6 +233,11 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
skb_push(skb_aggr, headroom); skb_push(skb_aggr, headroom);
if (adapter->iface_type == MWIFIEX_USB) {
adapter->data_sent = true;
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_DATA,
skb_aggr, NULL);
} else {
/* /*
* Padding per MSDU will affect the length of next * Padding per MSDU will affect the length of next
* packet and hence the exact length of next packet * packet and hence the exact length of next packet
...@@ -248,6 +253,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, ...@@ -248,6 +253,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA, ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA,
skb_aggr, &tx_param); skb_aggr, &tx_param);
}
switch (ret) { switch (ret) {
case -EBUSY: case -EBUSY:
spin_lock_irqsave(&priv->wmm.ra_list_spinlock, ra_list_flags); spin_lock_irqsave(&priv->wmm.ra_list_spinlock, ra_list_flags);
......
...@@ -30,3 +30,14 @@ config MWIFIEX_PCIE ...@@ -30,3 +30,14 @@ config MWIFIEX_PCIE
If you choose to build it as a module, it will be called If you choose to build it as a module, it will be called
mwifiex_pcie. mwifiex_pcie.
config MWIFIEX_USB
tristate "Marvell WiFi-Ex Driver for USB8797"
depends on MWIFIEX && USB
select FW_LOADER
---help---
This adds support for wireless adapters based on Marvell
Avastar 88W8797 chipset with USB interface.
If you choose to build it as a module, it will be called
mwifiex_usb.
...@@ -42,3 +42,6 @@ obj-$(CONFIG_MWIFIEX_SDIO) += mwifiex_sdio.o ...@@ -42,3 +42,6 @@ obj-$(CONFIG_MWIFIEX_SDIO) += mwifiex_sdio.o
mwifiex_pcie-y += pcie.o mwifiex_pcie-y += pcie.o
obj-$(CONFIG_MWIFIEX_PCIE) += mwifiex_pcie.o obj-$(CONFIG_MWIFIEX_PCIE) += mwifiex_pcie.o
mwifiex_usb-y += usb.o
obj-$(CONFIG_MWIFIEX_USB) += mwifiex_usb.o
...@@ -139,6 +139,7 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, ...@@ -139,6 +139,7 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
uint16_t cmd_size; uint16_t cmd_size;
struct timeval tstamp; struct timeval tstamp;
unsigned long flags; unsigned long flags;
__le32 tmp;
if (!adapter || !cmd_node) if (!adapter || !cmd_node)
return -1; return -1;
...@@ -178,15 +179,28 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, ...@@ -178,15 +179,28 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
le16_to_cpu(*(__le16 *) ((u8 *) host_cmd + S_DS_GEN)), cmd_size, le16_to_cpu(*(__le16 *) ((u8 *) host_cmd + S_DS_GEN)), cmd_size,
le16_to_cpu(host_cmd->seq_num)); le16_to_cpu(host_cmd->seq_num));
if (adapter->iface_type == MWIFIEX_USB) {
tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD);
skb_push(cmd_node->cmd_skb, MWIFIEX_TYPE_LEN);
memcpy(cmd_node->cmd_skb->data, &tmp, MWIFIEX_TYPE_LEN);
adapter->cmd_sent = true;
ret = adapter->if_ops.host_to_card(adapter,
MWIFIEX_USB_EP_CMD_EVENT,
cmd_node->cmd_skb, NULL);
skb_pull(cmd_node->cmd_skb, MWIFIEX_TYPE_LEN);
if (ret == -EBUSY)
cmd_node->cmd_skb = NULL;
} else {
skb_push(cmd_node->cmd_skb, INTF_HEADER_LEN); skb_push(cmd_node->cmd_skb, INTF_HEADER_LEN);
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_CMD, ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_CMD,
cmd_node->cmd_skb, NULL); cmd_node->cmd_skb, NULL);
skb_pull(cmd_node->cmd_skb, INTF_HEADER_LEN); skb_pull(cmd_node->cmd_skb, INTF_HEADER_LEN);
}
if (ret == -1) { if (ret == -1) {
dev_err(adapter->dev, "DNLD_CMD: host to card failed\n"); dev_err(adapter->dev, "DNLD_CMD: host to card failed\n");
if (adapter->iface_type == MWIFIEX_USB)
adapter->cmd_sent = false;
if (cmd_node->wait_q_enabled) if (cmd_node->wait_q_enabled)
adapter->cmd_wait_q.status = -1; adapter->cmd_wait_q.status = -1;
mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
...@@ -232,6 +246,9 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) ...@@ -232,6 +246,9 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter)
struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = struct mwifiex_opt_sleep_confirm *sleep_cfm_buf =
(struct mwifiex_opt_sleep_confirm *) (struct mwifiex_opt_sleep_confirm *)
adapter->sleep_cfm->data; adapter->sleep_cfm->data;
struct sk_buff *sleep_cfm_tmp;
__le32 tmp;
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
sleep_cfm_buf->seq_num = sleep_cfm_buf->seq_num =
...@@ -240,10 +257,28 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) ...@@ -240,10 +257,28 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter)
priv->bss_type))); priv->bss_type)));
adapter->seq_num++; adapter->seq_num++;
if (adapter->iface_type == MWIFIEX_USB) {
sleep_cfm_tmp =
dev_alloc_skb(sizeof(struct mwifiex_opt_sleep_confirm)
+ MWIFIEX_TYPE_LEN);
skb_put(sleep_cfm_tmp, sizeof(struct mwifiex_opt_sleep_confirm)
+ MWIFIEX_TYPE_LEN);
tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD);
memcpy(sleep_cfm_tmp->data, &tmp, MWIFIEX_TYPE_LEN);
memcpy(sleep_cfm_tmp->data + MWIFIEX_TYPE_LEN,
adapter->sleep_cfm->data,
sizeof(struct mwifiex_opt_sleep_confirm));
ret = adapter->if_ops.host_to_card(adapter,
MWIFIEX_USB_EP_CMD_EVENT,
sleep_cfm_tmp, NULL);
if (ret != -EBUSY)
dev_kfree_skb_any(sleep_cfm_tmp);
} else {
skb_push(adapter->sleep_cfm, INTF_HEADER_LEN); skb_push(adapter->sleep_cfm, INTF_HEADER_LEN);
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_CMD, ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_CMD,
adapter->sleep_cfm, NULL); adapter->sleep_cfm, NULL);
skb_pull(adapter->sleep_cfm, INTF_HEADER_LEN); skb_pull(adapter->sleep_cfm, INTF_HEADER_LEN);
}
if (ret == -1) { if (ret == -1) {
dev_err(adapter->dev, "SLEEP_CFM: failed\n"); dev_err(adapter->dev, "SLEEP_CFM: failed\n");
...@@ -343,6 +378,11 @@ int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter) ...@@ -343,6 +378,11 @@ int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter)
} }
if (!cmd_array[i].resp_skb) if (!cmd_array[i].resp_skb)
continue; continue;
if (adapter->iface_type == MWIFIEX_USB)
adapter->if_ops.cmdrsp_complete(adapter,
cmd_array[i].resp_skb);
else
dev_kfree_skb_any(cmd_array[i].resp_skb); dev_kfree_skb_any(cmd_array[i].resp_skb);
} }
/* Release struct cmd_ctrl_node */ /* Release struct cmd_ctrl_node */
...@@ -1083,6 +1123,7 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter) ...@@ -1083,6 +1123,7 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter)
MWIFIEX_BSS_ROLE_ANY), MWIFIEX_BSS_ROLE_ANY),
false); false);
} }
EXPORT_SYMBOL_GPL(mwifiex_process_hs_config);
/* /*
* This function handles the command response of a sleep confirm command. * This function handles the command response of a sleep confirm command.
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#define MWIFIEX_RATE_BITMAP_MCS127 159 #define MWIFIEX_RATE_BITMAP_MCS127 159
#define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024) #define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024)
#define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024)
#define MWIFIEX_RTS_MIN_VALUE (0) #define MWIFIEX_RTS_MIN_VALUE (0)
#define MWIFIEX_RTS_MAX_VALUE (2347) #define MWIFIEX_RTS_MAX_VALUE (2347)
......
...@@ -81,6 +81,11 @@ enum KEY_TYPE_ID { ...@@ -81,6 +81,11 @@ enum KEY_TYPE_ID {
#define FIRMWARE_READY_SDIO 0xfedc #define FIRMWARE_READY_SDIO 0xfedc
#define FIRMWARE_READY_PCIE 0xfedcba00 #define FIRMWARE_READY_PCIE 0xfedcba00
enum mwifiex_usb_ep {
MWIFIEX_USB_EP_CMD_EVENT = 1,
MWIFIEX_USB_EP_DATA = 2,
};
enum MWIFIEX_802_11_PRIVACY_FILTER { enum MWIFIEX_802_11_PRIVACY_FILTER {
MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL, MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL,
MWIFIEX_802_11_PRIV_FILTER_8021X_WEP MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
......
...@@ -188,10 +188,10 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) ...@@ -188,10 +188,10 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
adapter->cmd_sent = false; adapter->cmd_sent = false;
if (adapter->iface_type == MWIFIEX_PCIE) if (adapter->iface_type == MWIFIEX_SDIO)
adapter->data_sent = false;
else
adapter->data_sent = true; adapter->data_sent = true;
else
adapter->data_sent = false;
adapter->cmd_resp_received = false; adapter->cmd_resp_received = false;
adapter->event_received = false; adapter->event_received = false;
...@@ -379,6 +379,7 @@ mwifiex_free_adapter(struct mwifiex_adapter *adapter) ...@@ -379,6 +379,7 @@ mwifiex_free_adapter(struct mwifiex_adapter *adapter)
dev_dbg(adapter->dev, "info: free scan table\n"); dev_dbg(adapter->dev, "info: free scan table\n");
if (adapter->if_ops.cleanup_if)
adapter->if_ops.cleanup_if(adapter); adapter->if_ops.cleanup_if(adapter);
if (adapter->sleep_cfm) if (adapter->sleep_cfm)
...@@ -419,6 +420,8 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter) ...@@ -419,6 +420,8 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
spin_lock_init(&adapter->cmd_pending_q_lock); spin_lock_init(&adapter->cmd_pending_q_lock);
spin_lock_init(&adapter->scan_pending_q_lock); spin_lock_init(&adapter->scan_pending_q_lock);
skb_queue_head_init(&adapter->usb_rx_data_q);
for (i = 0; i < adapter->priv_num; ++i) { for (i = 0; i < adapter->priv_num; ++i) {
INIT_LIST_HEAD(&adapter->bss_prio_tbl[i].bss_prio_head); INIT_LIST_HEAD(&adapter->bss_prio_tbl[i].bss_prio_head);
adapter->bss_prio_tbl[i].bss_prio_cur = NULL; adapter->bss_prio_tbl[i].bss_prio_cur = NULL;
...@@ -574,6 +577,7 @@ mwifiex_shutdown_drv(struct mwifiex_adapter *adapter) ...@@ -574,6 +577,7 @@ mwifiex_shutdown_drv(struct mwifiex_adapter *adapter)
struct mwifiex_private *priv; struct mwifiex_private *priv;
s32 i; s32 i;
unsigned long flags; unsigned long flags;
struct sk_buff *skb;
/* mwifiex already shutdown */ /* mwifiex already shutdown */
if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY) if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY)
...@@ -601,6 +605,18 @@ mwifiex_shutdown_drv(struct mwifiex_adapter *adapter) ...@@ -601,6 +605,18 @@ mwifiex_shutdown_drv(struct mwifiex_adapter *adapter)
spin_lock_irqsave(&adapter->mwifiex_lock, flags); spin_lock_irqsave(&adapter->mwifiex_lock, flags);
if (adapter->if_ops.data_complete) {
while ((skb = skb_dequeue(&adapter->usb_rx_data_q))) {
struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
priv = adapter->priv[rx_info->bss_num];
if (priv)
priv->stats.rx_dropped++;
adapter->if_ops.data_complete(adapter, skb);
}
}
/* Free adapter structure */ /* Free adapter structure */
mwifiex_free_adapter(adapter); mwifiex_free_adapter(adapter);
...@@ -630,24 +646,28 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, ...@@ -630,24 +646,28 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter,
int ret; int ret;
u32 poll_num = 1; u32 poll_num = 1;
if (adapter->if_ops.check_fw_status) {
adapter->winner = 0; adapter->winner = 0;
/* Check if firmware is already running */ /* check if firmware is already running */
ret = adapter->if_ops.check_fw_status(adapter, poll_num); ret = adapter->if_ops.check_fw_status(adapter, poll_num);
if (!ret) { if (!ret) {
dev_notice(adapter->dev, dev_notice(adapter->dev,
"WLAN FW already running! Skip FW download\n"); "WLAN FW already running! Skip FW dnld\n");
goto done; goto done;
} }
poll_num = MAX_FIRMWARE_POLL_TRIES; poll_num = MAX_FIRMWARE_POLL_TRIES;
/* Check if we are the winner for downloading FW */ /* check if we are the winner for downloading FW */
if (!adapter->winner) { if (!adapter->winner) {
dev_notice(adapter->dev, dev_notice(adapter->dev,
"Other intf already running! Skip FW download\n"); "FW already running! Skip FW dnld\n");
poll_num = MAX_MULTI_INTERFACE_POLL_TRIES; poll_num = MAX_MULTI_INTERFACE_POLL_TRIES;
goto poll_fw; goto poll_fw;
} }
}
if (pmfw) { if (pmfw) {
/* Download firmware with helper */ /* Download firmware with helper */
ret = adapter->if_ops.prog_fw(adapter, pmfw); ret = adapter->if_ops.prog_fw(adapter, pmfw);
...@@ -666,6 +686,8 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, ...@@ -666,6 +686,8 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter,
} }
done: done:
/* re-enable host interrupt for mwifiex after fw dnld is successful */ /* re-enable host interrupt for mwifiex after fw dnld is successful */
if (adapter->if_ops.enable_int)
adapter->if_ops.enable_int(adapter); adapter->if_ops.enable_int(adapter);
return ret; return ret;
} }
...@@ -58,6 +58,7 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, ...@@ -58,6 +58,7 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops)); memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops));
/* card specific initialization has been deferred until now .. */ /* card specific initialization has been deferred until now .. */
if (adapter->if_ops.init_if)
if (adapter->if_ops.init_if(adapter)) if (adapter->if_ops.init_if(adapter))
goto error; goto error;
...@@ -140,6 +141,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -140,6 +141,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
{ {
int ret = 0; int ret = 0;
unsigned long flags; unsigned long flags;
struct sk_buff *skb;
spin_lock_irqsave(&adapter->main_proc_lock, flags); spin_lock_irqsave(&adapter->main_proc_lock, flags);
...@@ -161,6 +163,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -161,6 +163,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
if (adapter->int_status) { if (adapter->int_status) {
if (adapter->hs_activated) if (adapter->hs_activated)
mwifiex_process_hs_config(adapter); mwifiex_process_hs_config(adapter);
if (adapter->if_ops.process_int_status)
adapter->if_ops.process_int_status(adapter); adapter->if_ops.process_int_status(adapter);
} }
...@@ -174,6 +177,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -174,6 +177,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
adapter->if_ops.wakeup(adapter); adapter->if_ops.wakeup(adapter);
continue; continue;
} }
if (IS_CARD_RX_RCVD(adapter)) { if (IS_CARD_RX_RCVD(adapter)) {
adapter->pm_wakeup_fw_try = false; adapter->pm_wakeup_fw_try = false;
if (adapter->ps_state == PS_STATE_SLEEP) if (adapter->ps_state == PS_STATE_SLEEP)
...@@ -194,6 +198,11 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -194,6 +198,11 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
} }
} }
/* Check Rx data for USB */
if (adapter->iface_type == MWIFIEX_USB)
while ((skb = skb_dequeue(&adapter->usb_rx_data_q)))
mwifiex_handle_rx_packet(adapter, skb);
/* Check for Cmd Resp */ /* Check for Cmd Resp */
if (adapter->cmd_resp_received) { if (adapter->cmd_resp_received) {
adapter->cmd_resp_received = false; adapter->cmd_resp_received = false;
...@@ -317,6 +326,9 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) ...@@ -317,6 +326,9 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
fw.fw_buf = (u8 *) adapter->firmware->data; fw.fw_buf = (u8 *) adapter->firmware->data;
fw.fw_len = adapter->firmware->size; fw.fw_len = adapter->firmware->size;
if (adapter->if_ops.dnld_fw)
ret = adapter->if_ops.dnld_fw(adapter, &fw);
else
ret = mwifiex_dnld_fw(adapter, &fw); ret = mwifiex_dnld_fw(adapter, &fw);
if (ret == -1) if (ret == -1)
goto done; goto done;
...@@ -731,6 +743,7 @@ mwifiex_add_card(void *card, struct semaphore *sem, ...@@ -731,6 +743,7 @@ mwifiex_add_card(void *card, struct semaphore *sem,
err_init_fw: err_init_fw:
pr_debug("info: %s: unregister device\n", __func__); pr_debug("info: %s: unregister device\n", __func__);
if (adapter->if_ops.unregister_dev)
adapter->if_ops.unregister_dev(adapter); adapter->if_ops.unregister_dev(adapter);
err_registerdev: err_registerdev:
adapter->surprise_removed = true; adapter->surprise_removed = true;
...@@ -836,6 +849,7 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem) ...@@ -836,6 +849,7 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
/* Unregister device */ /* Unregister device */
dev_dbg(adapter->dev, "info: unregister device\n"); dev_dbg(adapter->dev, "info: unregister device\n");
if (adapter->if_ops.unregister_dev)
adapter->if_ops.unregister_dev(adapter); adapter->if_ops.unregister_dev(adapter);
/* Free adapter structure */ /* Free adapter structure */
dev_dbg(adapter->dev, "info: free adapter\n"); dev_dbg(adapter->dev, "info: free adapter\n");
......
...@@ -92,9 +92,16 @@ enum { ...@@ -92,9 +92,16 @@ enum {
#define MWIFIEX_OUI_NOT_PRESENT 0 #define MWIFIEX_OUI_NOT_PRESENT 0
#define MWIFIEX_OUI_PRESENT 1 #define MWIFIEX_OUI_PRESENT 1
/*
* Do not check for data_received for USB, as data_received
* is handled in mwifiex_usb_recv for USB
*/
#define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \ #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
adapter->event_received || \ adapter->event_received || \
adapter->data_received) ((adapter->iface_type != MWIFIEX_USB) && \
adapter->data_received) || \
((adapter->iface_type == MWIFIEX_USB) && \
!skb_queue_empty(&adapter->usb_rx_data_q)))
#define MWIFIEX_TYPE_CMD 1 #define MWIFIEX_TYPE_CMD 1
#define MWIFIEX_TYPE_DATA 0 #define MWIFIEX_TYPE_DATA 0
...@@ -110,6 +117,11 @@ enum { ...@@ -110,6 +117,11 @@ enum {
#define MWIFIEX_EVENT_HEADER_LEN 4 #define MWIFIEX_EVENT_HEADER_LEN 4
#define MWIFIEX_TYPE_LEN 4
#define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
#define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
#define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
struct mwifiex_dbg { struct mwifiex_dbg {
u32 num_cmd_host_to_card_failure; u32 num_cmd_host_to_card_failure;
u32 num_cmd_sleep_cfm_host_to_card_failure; u32 num_cmd_sleep_cfm_host_to_card_failure;
...@@ -162,6 +174,7 @@ enum MWIFIEX_PS_STATE { ...@@ -162,6 +174,7 @@ enum MWIFIEX_PS_STATE {
enum mwifiex_iface_type { enum mwifiex_iface_type {
MWIFIEX_SDIO, MWIFIEX_SDIO,
MWIFIEX_PCIE, MWIFIEX_PCIE,
MWIFIEX_USB
}; };
struct mwifiex_add_ba_param { struct mwifiex_add_ba_param {
...@@ -546,6 +559,8 @@ struct mwifiex_if_ops { ...@@ -546,6 +559,8 @@ struct mwifiex_if_ops {
void (*cleanup_mpa_buf) (struct mwifiex_adapter *); void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *); int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *); int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
int (*data_complete) (struct mwifiex_adapter *, struct sk_buff *);
int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
}; };
struct mwifiex_adapter { struct mwifiex_adapter {
...@@ -608,6 +623,7 @@ struct mwifiex_adapter { ...@@ -608,6 +623,7 @@ struct mwifiex_adapter {
struct list_head scan_pending_q; struct list_head scan_pending_q;
/* spin lock for scan_pending_q */ /* spin lock for scan_pending_q */
spinlock_t scan_pending_q_lock; spinlock_t scan_pending_q_lock;
struct sk_buff_head usb_rx_data_q;
u32 scan_processing; u32 scan_processing;
u16 region_code; u16 region_code;
struct mwifiex_802_11d_domain_reg domain_reg; struct mwifiex_802_11d_domain_reg domain_reg;
......
...@@ -1293,7 +1293,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) ...@@ -1293,7 +1293,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
if (ret) if (ret)
return -1; return -1;
if (first_sta) { if (first_sta && (priv->adapter->iface_type != MWIFIEX_USB)) {
/* Enable auto deep sleep */ /* Enable auto deep sleep */
auto_ds.auto_ds = DEEP_SLEEP_ON; auto_ds.auto_ds = DEEP_SLEEP_ON;
auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME; auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
......
...@@ -145,7 +145,12 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, ...@@ -145,7 +145,12 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
" rx_pkt_offset=%d, rx_pkt_length=%d\n", skb->len, " rx_pkt_offset=%d, rx_pkt_length=%d\n", skb->len,
local_rx_pd->rx_pkt_offset, local_rx_pd->rx_pkt_length); local_rx_pd->rx_pkt_offset, local_rx_pd->rx_pkt_length);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
if (adapter->if_ops.data_complete)
adapter->if_ops.data_complete(adapter, skb);
else
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return ret; return ret;
} }
...@@ -196,8 +201,12 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, ...@@ -196,8 +201,12 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
(u8) local_rx_pd->rx_pkt_type, (u8) local_rx_pd->rx_pkt_type,
skb); skb);
if (ret || (rx_pkt_type == PKT_TYPE_BAR)) if (ret || (rx_pkt_type == PKT_TYPE_BAR)) {
if (adapter->if_ops.data_complete)
adapter->if_ops.data_complete(adapter, skb);
else
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
}
if (ret) if (ret)
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
......
...@@ -149,10 +149,14 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags) ...@@ -149,10 +149,14 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags)
local_tx_pd->bss_num = priv->bss_num; local_tx_pd->bss_num = priv->bss_num;
local_tx_pd->bss_type = priv->bss_type; local_tx_pd->bss_type = priv->bss_type;
if (adapter->iface_type == MWIFIEX_USB) {
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_DATA,
skb, NULL);
} else {
skb_push(skb, INTF_HEADER_LEN); skb_push(skb, INTF_HEADER_LEN);
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA, ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA,
skb, NULL); skb, NULL);
}
switch (ret) { switch (ret) {
case -EBUSY: case -EBUSY:
adapter->data_sent = true; adapter->data_sent = true;
......
...@@ -77,12 +77,23 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb, ...@@ -77,12 +77,23 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA)
local_tx_pd = local_tx_pd =
(struct txpd *) (head_ptr + INTF_HEADER_LEN); (struct txpd *) (head_ptr + INTF_HEADER_LEN);
if (adapter->iface_type == MWIFIEX_USB) {
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA, adapter->data_sent = true;
skb_pull(skb, INTF_HEADER_LEN);
ret = adapter->if_ops.host_to_card(adapter,
MWIFIEX_USB_EP_DATA,
skb, NULL);
} else {
ret = adapter->if_ops.host_to_card(adapter,
MWIFIEX_TYPE_DATA,
skb, tx_param); skb, tx_param);
} }
}
switch (ret) { switch (ret) {
case -ENOSR:
dev_err(adapter->dev, "data: -ENOSR is returned\n");
break;
case -EBUSY: case -EBUSY:
if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
(adapter->pps_uapsd_mode) && (adapter->tx_lock_flag)) { (adapter->pps_uapsd_mode) && (adapter->tx_lock_flag)) {
...@@ -135,6 +146,9 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, ...@@ -135,6 +146,9 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
if (!priv) if (!priv)
goto done; goto done;
if (adapter->iface_type == MWIFIEX_USB)
adapter->data_sent = false;
mwifiex_set_trans_start(priv->netdev); mwifiex_set_trans_start(priv->netdev);
if (!status) { if (!status) {
priv->stats.tx_packets++; priv->stats.tx_packets++;
...@@ -162,4 +176,5 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, ...@@ -162,4 +176,5 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mwifiex_write_data_complete);
This diff is collapsed.
/*
* This file contains definitions for mwifiex USB interface driver.
*
* Copyright (C) 2012, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
#ifndef _MWIFIEX_USB_H
#define _MWIFIEX_USB_H
#include <linux/usb.h>
#define USB8797_VID 0x1286
#define USB8797_PID_1 0x2043
#define USB8797_PID_2 0x2044
#define USB8797_FW_DNLD 1
#define USB8797_FW_READY 2
#define USB8797_FW_MAX_RETRY 3
#define MWIFIEX_TX_DATA_URB 6
#define MWIFIEX_RX_DATA_URB 6
#define MWIFIEX_USB_TIMEOUT 100
#define USB8797_DEFAULT_FW_NAME "mrvl/usb8797_uapsta.bin"
#define FW_DNLD_TX_BUF_SIZE 620
#define FW_DNLD_RX_BUF_SIZE 2048
#define FW_HAS_LAST_BLOCK 0x00000004
#define FW_DATA_XMIT_SIZE \
(sizeof(struct fw_header) + dlen + sizeof(u32))
struct urb_context {
struct mwifiex_adapter *adapter;
struct sk_buff *skb;
struct urb *urb;
u8 ep;
};
struct usb_card_rec {
struct mwifiex_adapter *adapter;
struct usb_device *udev;
struct usb_interface *intf;
u8 rx_cmd_ep;
struct urb_context rx_cmd;
atomic_t rx_cmd_urb_pending;
struct urb_context rx_data_list[MWIFIEX_RX_DATA_URB];
u8 usb_boot_state;
u8 rx_data_ep;
atomic_t rx_data_urb_pending;
u8 tx_data_ep;
u8 tx_cmd_ep;
atomic_t tx_data_urb_pending;
atomic_t tx_cmd_urb_pending;
int bulk_out_maxpktsize;
struct urb_context tx_cmd;
int tx_data_ix;
struct urb_context tx_data_list[MWIFIEX_TX_DATA_URB];
};
struct fw_header {
__le32 dnld_cmd;
__le32 base_addr;
__le32 data_len;
__le32 crc;
};
struct fw_sync_header {
__le32 cmd;
__le32 seq_num;
};
struct fw_data {
struct fw_header fw_hdr;
__le32 seq_num;
u8 data[1];
};
/* This function is called after the card has woken up. */
static inline int
mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter)
{
return 0;
}
#endif /*_MWIFIEX_USB_H */
...@@ -167,6 +167,28 @@ int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb) ...@@ -167,6 +167,28 @@ int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb)
skb->dev = priv->netdev; skb->dev = priv->netdev;
skb->protocol = eth_type_trans(skb, priv->netdev); skb->protocol = eth_type_trans(skb, priv->netdev);
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
/* This is required only in case of 11n and USB as we alloc
* a buffer of 4K only if its 11N (to be able to receive 4K
* AMSDU packets). In case of SD we allocate buffers based
* on the size of packet and hence this is not needed.
*
* Modifying the truesize here as our allocation for each
* skb is 4K but we only receive 2K packets and this cause
* the kernel to start dropping packets in case where
* application has allocated buffer based on 2K size i.e.
* if there a 64K packet received (in IP fragments and
* application allocates 64K to receive this packet but
* this packet would almost double up because we allocate
* each 1.5K fragment in 4K and pass it up. As soon as the
* 64K limit hits kernel will start to drop rest of the
* fragments. Currently we fail the Filesndl-ht.scr script
* for UDP, hence this fix
*/
if ((adapter->iface_type == MWIFIEX_USB) &&
(skb->truesize > MWIFIEX_RX_DATA_BUF_SIZE))
skb->truesize += (skb->len - MWIFIEX_RX_DATA_BUF_SIZE);
priv->stats.rx_bytes += skb->len; priv->stats.rx_bytes += skb->len;
priv->stats.rx_packets++; priv->stats.rx_packets++;
if (in_interrupt()) if (in_interrupt())
......
...@@ -1120,11 +1120,19 @@ mwifiex_send_processed_packet(struct mwifiex_private *priv, ...@@ -1120,11 +1120,19 @@ mwifiex_send_processed_packet(struct mwifiex_private *priv,
tx_info = MWIFIEX_SKB_TXCB(skb); tx_info = MWIFIEX_SKB_TXCB(skb);
spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, ra_list_flags); spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, ra_list_flags);
if (adapter->iface_type == MWIFIEX_USB) {
adapter->data_sent = true;
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_DATA,
skb, NULL);
} else {
tx_param.next_pkt_len = tx_param.next_pkt_len =
((skb_next) ? skb_next->len + ((skb_next) ? skb_next->len +
sizeof(struct txpd) : 0); sizeof(struct txpd) : 0);
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA, skb, ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_DATA,
&tx_param); skb, &tx_param);
}
switch (ret) { switch (ret) {
case -EBUSY: case -EBUSY:
dev_dbg(adapter->dev, "data: -EBUSY is returned\n"); dev_dbg(adapter->dev, "data: -EBUSY is returned\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment