diff options
author | Shraddha Barke <shraddha.6596@gmail.com> | 2016-03-06 00:55:31 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-03-11 22:09:09 -0800 |
commit | 3765dc92cb1ce1615538216c7870fcfbc026c714 (patch) | |
tree | 438587ecfbdb35d6bac8eeb60f06cee0e1450bd0 /drivers | |
parent | e0a2d503a96b97d6478c5b00f4d3e3446f7b95e8 (diff) |
Staging: gdm72xx: Remove gdm72xx driver
Remove support for gdm72xx driver from the kernel since Wimax is dead.
[1] http://www.networkworld.com/article/2220370/4g/wimax-is-dead.html
[2] http://www.androidcentral.com/sprint-confirms-wimax-shutdown-november-6-2015
Chrome OS can distribute this driver alongside their library.
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
22 files changed, 0 insertions, 4214 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index ff894bc63b3b..f0ca4a18b799 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -72,8 +72,6 @@ source "drivers/staging/android/Kconfig" source "drivers/staging/board/Kconfig" -source "drivers/staging/gdm72xx/Kconfig" - source "drivers/staging/gdm724x/Kconfig" source "drivers/staging/fwserial/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index c008cfc7f4b1..22464a09cb27 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -26,7 +26,6 @@ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_STAGING_RDMA) += rdma/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_STAGING_BOARD) += board/ -obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/ obj-$(CONFIG_LTE_GDM724X) += gdm724x/ obj-$(CONFIG_FIREWIRE_SERIAL) += fwserial/ obj-$(CONFIG_GOLDFISH) += goldfish/ diff --git a/drivers/staging/gdm72xx/Kconfig b/drivers/staging/gdm72xx/Kconfig deleted file mode 100644 index bf11a7fbfc51..000000000000 --- a/drivers/staging/gdm72xx/Kconfig +++ /dev/null @@ -1,63 +0,0 @@ -# -# GCT GDM72xx WiMAX driver configuration -# - -menuconfig WIMAX_GDM72XX - tristate "GCT GDM72xx WiMAX support" - depends on NET && (USB || MMC) - help - Support a WiMAX module based on the GCT GDM72xx WiMAX chip. - -if WIMAX_GDM72XX - -config WIMAX_GDM72XX_QOS - bool "Enable QoS support" - default n - help - Enable Quality of Service support based on the data protocol of - transmitting packets. - -config WIMAX_GDM72XX_K_MODE - bool "Enable K mode" - default n - help - Enable support for proprietary functions for KT (Korea Telecom). - -config WIMAX_GDM72XX_WIMAX2 - bool "Enable WiMAX2 support" - default n - help - Enable support for transmitting multiple packets (packet - aggregation) from the WiMAX module to the host processor. - -choice - prompt "Select interface" - -config WIMAX_GDM72XX_USB - bool "USB interface" - depends on (USB = y || USB = WIMAX_GDM72XX) - help - Select this option if the WiMAX module interfaces with the host - processor via USB. - -config WIMAX_GDM72XX_SDIO - bool "SDIO interface" - depends on (MMC = y || MMC = WIMAX_GDM72XX) - help - Select this option if the WiMAX module interfaces with the host - processor via SDIO. - -endchoice - -if WIMAX_GDM72XX_USB - -config WIMAX_GDM72XX_USB_PM - bool "Enable power management support" - depends on PM - help - Enable USB power management in order to reduce power consumption - while the interface is not in use. - -endif # WIMAX_GDM72XX_USB - -endif # WIMAX_GDM72XX diff --git a/drivers/staging/gdm72xx/Makefile b/drivers/staging/gdm72xx/Makefile deleted file mode 100644 index 35da7b90b19b..000000000000 --- a/drivers/staging/gdm72xx/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -obj-$(CONFIG_WIMAX_GDM72XX) := gdmwm.o - -gdmwm-y += gdm_wimax.o netlink_k.o -gdmwm-$(CONFIG_WIMAX_GDM72XX_QOS) += gdm_qos.o -gdmwm-$(CONFIG_WIMAX_GDM72XX_SDIO) += gdm_sdio.o sdio_boot.o -gdmwm-$(CONFIG_WIMAX_GDM72XX_USB) += gdm_usb.o usb_boot.o diff --git a/drivers/staging/gdm72xx/TODO b/drivers/staging/gdm72xx/TODO deleted file mode 100644 index 62d0cd6225c8..000000000000 --- a/drivers/staging/gdm72xx/TODO +++ /dev/null @@ -1,2 +0,0 @@ -TODO: -- Clean up coding style to meet kernel standard. diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c deleted file mode 100644 index 9fc476f0ce88..000000000000 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include <linux/etherdevice.h> -#include <asm/byteorder.h> - -#include <linux/ip.h> -#include <linux/tcp.h> -#include <linux/if_ether.h> - -#include "gdm_wimax.h" -#include "hci.h" -#include "gdm_qos.h" - -#define MAX_FREE_LIST_CNT 32 -static struct { - struct list_head head; - int cnt; - spinlock_t lock; /* protect structure fields */ -} qos_free_list; - -static void init_qos_entry_list(void) -{ - qos_free_list.cnt = 0; - INIT_LIST_HEAD(&qos_free_list.head); - spin_lock_init(&qos_free_list.lock); -} - -static void *alloc_qos_entry(void) -{ - struct qos_entry_s *entry; - unsigned long flags; - - spin_lock_irqsave(&qos_free_list.lock, flags); - if (qos_free_list.cnt) { - entry = list_entry(qos_free_list.head.prev, struct qos_entry_s, - list); - list_del(&entry->list); - qos_free_list.cnt--; - spin_unlock_irqrestore(&qos_free_list.lock, flags); - return entry; - } - spin_unlock_irqrestore(&qos_free_list.lock, flags); - - return kmalloc(sizeof(*entry), GFP_ATOMIC); -} - -static void free_qos_entry(void *entry) -{ - struct qos_entry_s *qentry = entry; - unsigned long flags; - - spin_lock_irqsave(&qos_free_list.lock, flags); - if (qos_free_list.cnt < MAX_FREE_LIST_CNT) { - list_add(&qentry->list, &qos_free_list.head); - qos_free_list.cnt++; - spin_unlock_irqrestore(&qos_free_list.lock, flags); - return; - } - spin_unlock_irqrestore(&qos_free_list.lock, flags); - - kfree(entry); -} - -static void free_qos_entry_list(struct list_head *free_list) -{ - struct qos_entry_s *entry, *n; - int total_free = 0; - - list_for_each_entry_safe(entry, n, free_list, list) { - list_del(&entry->list); - kfree(entry); - total_free++; - } - - pr_debug("%s: total_free_cnt=%d\n", __func__, total_free); -} - -void gdm_qos_init(void *nic_ptr) -{ - struct nic *nic = nic_ptr; - struct qos_cb_s *qcb = &nic->qos; - int i; - - for (i = 0; i < QOS_MAX; i++) { - INIT_LIST_HEAD(&qcb->qos_list[i]); - qcb->csr[i].qos_buf_count = 0; - qcb->csr[i].enabled = false; - } - - qcb->qos_list_cnt = 0; - qcb->qos_null_idx = QOS_MAX - 1; - qcb->qos_limit_size = 255; - - spin_lock_init(&qcb->qos_lock); - - init_qos_entry_list(); -} - -void gdm_qos_release_list(void *nic_ptr) -{ - struct nic *nic = nic_ptr; - struct qos_cb_s *qcb = &nic->qos; - unsigned long flags; - struct qos_entry_s *entry, *n; - struct list_head free_list; - int i; - - INIT_LIST_HEAD(&free_list); - - spin_lock_irqsave(&qcb->qos_lock, flags); - - for (i = 0; i < QOS_MAX; i++) { - qcb->csr[i].qos_buf_count = 0; - qcb->csr[i].enabled = false; - } - - qcb->qos_list_cnt = 0; - qcb->qos_null_idx = QOS_MAX - 1; - - for (i = 0; i < QOS_MAX; i++) { - list_for_each_entry_safe(entry, n, &qcb->qos_list[i], list) { - list_move_tail(&entry->list, &free_list); - } - } - spin_unlock_irqrestore(&qcb->qos_lock, flags); - free_qos_entry_list(&free_list); -} - -static int chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *stream, u8 *port) -{ - int i; - - if (csr->classifier_rule_en & IPTYPEOFSERVICE) { - if (((stream[1] & csr->ip2s_mask) < csr->ip2s_lo) || - ((stream[1] & csr->ip2s_mask) > csr->ip2s_hi)) - return 1; - } - - if (csr->classifier_rule_en & PROTOCOL) { - if (stream[9] != csr->protocol) - return 1; - } - - if (csr->classifier_rule_en & IPMASKEDSRCADDRESS) { - for (i = 0; i < 4; i++) { - if ((stream[12 + i] & csr->ipsrc_addrmask[i]) != - (csr->ipsrc_addr[i] & csr->ipsrc_addrmask[i])) - return 1; - } - } - - if (csr->classifier_rule_en & IPMASKEDDSTADDRESS) { - for (i = 0; i < 4; i++) { - if ((stream[16 + i] & csr->ipdst_addrmask[i]) != - (csr->ipdst_addr[i] & csr->ipdst_addrmask[i])) - return 1; - } - } - - if (csr->classifier_rule_en & PROTOCOLSRCPORTRANGE) { - i = ((port[0] << 8) & 0xff00) + port[1]; - if ((i < csr->srcport_lo) || (i > csr->srcport_hi)) - return 1; - } - - if (csr->classifier_rule_en & PROTOCOLDSTPORTRANGE) { - i = ((port[2] << 8) & 0xff00) + port[3]; - if ((i < csr->dstport_lo) || (i > csr->dstport_hi)) - return 1; - } - - return 0; -} - -static int get_qos_index(struct nic *nic, u8 *iph, u8 *tcpudph) -{ - int ip_ver, i; - struct qos_cb_s *qcb = &nic->qos; - - if (!iph || !tcpudph) - return -1; - - ip_ver = (iph[0] >> 4) & 0xf; - - if (ip_ver != 4) - return -1; - - for (i = 0; i < QOS_MAX; i++) { - if (!qcb->csr[i].enabled) - continue; - if (!qcb->csr[i].classifier_rule_en) - continue; - if (chk_ipv4_rule(&qcb->csr[i], iph, tcpudph) == 0) - return i; - } - - return -1; -} - -static void extract_qos_list(struct nic *nic, struct list_head *head) -{ - struct qos_cb_s *qcb = &nic->qos; - struct qos_entry_s *entry; - int i; - - INIT_LIST_HEAD(head); - - for (i = 0; i < QOS_MAX; i++) { - if (!qcb->csr[i].enabled) - continue; - if (qcb->csr[i].qos_buf_count >= qcb->qos_limit_size) - continue; - if (list_empty(&qcb->qos_list[i])) - continue; - - entry = list_entry(qcb->qos_list[i].prev, struct qos_entry_s, - list); - - list_move_tail(&entry->list, head); - qcb->csr[i].qos_buf_count++; - - if (!list_empty(&qcb->qos_list[i])) - netdev_warn(nic->netdev, "Index(%d) is piled!!\n", i); - } -} - -static void send_qos_list(struct nic *nic, struct list_head *head) -{ - struct qos_entry_s *entry, *n; - - list_for_each_entry_safe(entry, n, head, list) { - list_del(&entry->list); - gdm_wimax_send_tx(entry->skb, entry->dev); - free_qos_entry(entry); - } -} - -int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev) -{ - struct nic *nic = netdev_priv(dev); - int index; - struct qos_cb_s *qcb = &nic->qos; - unsigned long flags; - struct ethhdr *ethh = (struct ethhdr *)(skb->data + HCI_HEADER_SIZE); - struct iphdr *iph = (struct iphdr *)((char *)ethh + ETH_HLEN); - struct tcphdr *tcph; - struct qos_entry_s *entry = NULL; - struct list_head send_list; - int ret = 0; - - tcph = (struct tcphdr *)iph + iph->ihl * 4; - - if (ethh->h_proto == cpu_to_be16(ETH_P_IP)) { - if (qcb->qos_list_cnt && !qos_free_list.cnt) { - entry = alloc_qos_entry(); - entry->skb = skb; - entry->dev = dev; - netdev_dbg(dev, "qcb->qos_list_cnt=%d\n", - qcb->qos_list_cnt); - } - - spin_lock_irqsave(&qcb->qos_lock, flags); - if (qcb->qos_list_cnt) { - index = get_qos_index(nic, (u8 *)iph, (u8 *)tcph); - if (index == -1) - index = qcb->qos_null_idx; - - if (!entry) { - entry = alloc_qos_entry(); - entry->skb = skb; - entry->dev = dev; - } - - list_add_tail(&entry->list, &qcb->qos_list[index]); - extract_qos_list(nic, &send_list); - spin_unlock_irqrestore(&qcb->qos_lock, flags); - send_qos_list(nic, &send_list); - goto out; - } - spin_unlock_irqrestore(&qcb->qos_lock, flags); - if (entry) - free_qos_entry(entry); - } - - ret = gdm_wimax_send_tx(skb, dev); -out: - return ret; -} - -static int get_csr(struct qos_cb_s *qcb, u32 sfid, int mode) -{ - int i; - - for (i = 0; i < qcb->qos_list_cnt; i++) { - if (qcb->csr[i].sfid == sfid) - return i; - } - - if (mode) { - for (i = 0; i < QOS_MAX; i++) { - if (!qcb->csr[i].enabled) { - qcb->csr[i].enabled = true; - qcb->qos_list_cnt++; - return i; - } - } - } - return -1; -} - -#define QOS_CHANGE_DEL 0xFC -#define QOS_ADD 0xFD -#define QOS_REPORT 0xFE - -void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) -{ - struct nic *nic = nic_ptr; - int i, index, pos; - u32 sfid; - u8 sub_cmd_evt; - struct qos_cb_s *qcb = &nic->qos; - struct qos_entry_s *entry, *n; - struct list_head send_list; - struct list_head free_list; - unsigned long flags; - - sub_cmd_evt = (u8)buf[4]; - - if (sub_cmd_evt == QOS_REPORT) { - spin_lock_irqsave(&qcb->qos_lock, flags); - for (i = 0; i < qcb->qos_list_cnt; i++) { - sfid = ((buf[(i * 5) + 6] << 24) & 0xff000000); - sfid += ((buf[(i * 5) + 7] << 16) & 0xff0000); - sfid += ((buf[(i * 5) + 8] << 8) & 0xff00); - sfid += (buf[(i * 5) + 9]); - index = get_csr(qcb, sfid, 0); - if (index == -1) { - spin_unlock_irqrestore(&qcb->qos_lock, flags); - netdev_err(nic->netdev, "QoS ERROR: No SF\n"); - return; - } - qcb->csr[index].qos_buf_count = buf[(i * 5) + 10]; - } - - extract_qos_list(nic, &send_list); - spin_unlock_irqrestore(&qcb->qos_lock, flags); - send_qos_list(nic, &send_list); - return; - } - - /* sub_cmd_evt == QOS_ADD || sub_cmd_evt == QOS_CHANG_DEL */ - pos = 6; - sfid = ((buf[pos++] << 24) & 0xff000000); - sfid += ((buf[pos++] << 16) & 0xff0000); - sfid += ((buf[pos++] << 8) & 0xff00); - sfid += (buf[pos++]); - - index = get_csr(qcb, sfid, 1); - if (index == -1) { - netdev_err(nic->netdev, - "QoS ERROR: csr Update Error / Wrong index (%d)\n", - index); - return; - } - - if (sub_cmd_evt == QOS_ADD) { - netdev_dbg(nic->netdev, "QOS_ADD SFID = 0x%x, index=%d\n", - sfid, index); - - spin_lock_irqsave(&qcb->qos_lock, flags); - qcb->csr[index].sfid = sfid; - qcb->csr[index].classifier_rule_en = ((buf[pos++] << 8) & 0xff00); - qcb->csr[index].classifier_rule_en += buf[pos++]; - if (qcb->csr[index].classifier_rule_en == 0) - qcb->qos_null_idx = index; - qcb->csr[index].ip2s_mask = buf[pos++]; - qcb->csr[index].ip2s_lo = buf[pos++]; - qcb->csr[index].ip2s_hi = buf[pos++]; - qcb->csr[index].protocol = buf[pos++]; - qcb->csr[index].ipsrc_addrmask[0] = buf[pos++]; - qcb->csr[index].ipsrc_addrmask[1] = buf[pos++]; - qcb->csr[index].ipsrc_addrmask[2] = buf[pos++]; - qcb->csr[index].ipsrc_addrmask[3] = buf[pos++]; - qcb->csr[index].ipsrc_addr[0] = buf[pos++]; - qcb->csr[index].ipsrc_addr[1] = buf[pos++]; - qcb->csr[index].ipsrc_addr[2] = buf[pos++]; - qcb->csr[index].ipsrc_addr[3] = buf[pos++]; - qcb->csr[index].ipdst_addrmask[0] = buf[pos++]; - qcb->csr[index].ipdst_addrmask[1] = buf[pos++]; - qcb->csr[index].ipdst_addrmask[2] = buf[pos++]; - qcb->csr[index].ipdst_addrmask[3] = buf[pos++]; - qcb->csr[index].ipdst_addr[0] = buf[pos++]; - qcb->csr[index].ipdst_addr[1] = buf[pos++]; - qcb->csr[index].ipdst_addr[2] = buf[pos++]; - qcb->csr[index].ipdst_addr[3] = buf[pos++]; - qcb->csr[index].srcport_lo = ((buf[pos++] << 8) & 0xff00); - qcb->csr[index].srcport_lo += buf[pos++]; - qcb->csr[index].srcport_hi = ((buf[pos++] << 8) & 0xff00); - qcb->csr[index].srcport_hi += buf[pos++]; - qcb->csr[index].dstport_lo = ((buf[pos++] << 8) & 0xff00); - qcb->csr[index].dstport_lo += buf[pos++]; - qcb->csr[index].dstport_hi = ((buf[pos++] << 8) & 0xff00); - qcb->csr[index].dstport_hi += buf[pos++]; - - qcb->qos_limit_size = 254 / qcb->qos_list_cnt; - spin_unlock_irqrestore(&qcb->qos_lock, flags); - } else if (sub_cmd_evt == QOS_CHANGE_DEL) { - netdev_dbg(nic->netdev, "QOS_CHANGE_DEL SFID = 0x%x, index=%d\n", - sfid, index); - - INIT_LIST_HEAD(&free_list); - - spin_lock_irqsave(&qcb->qos_lock, flags); - qcb->csr[index].enabled = false; - qcb->qos_list_cnt--; - qcb->qos_limit_size = 254 / qcb->qos_list_cnt; - - list_for_each_entry_safe(entry, n, &qcb->qos_list[index], - list) { - list_move_tail(&entry->list, &free_list); - } - spin_unlock_irqrestore(&qcb->qos_lock, flags); - free_qos_entry_list(&free_list); - } -} diff --git a/drivers/staging/gdm72xx/gdm_qos.h b/drivers/staging/gdm72xx/gdm_qos.h deleted file mode 100644 index a4e5c1c5677f..000000000000 --- a/drivers/staging/gdm72xx/gdm_qos.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __GDM72XX_GDM_QOS_H__ -#define __GDM72XX_GDM_QOS_H__ - -#include <linux/types.h> -#include <linux/usb.h> -#include <linux/list.h> - -#define QOS_MAX 16 -#define IPTYPEOFSERVICE 0x8000 -#define PROTOCOL 0x4000 -#define IPMASKEDSRCADDRESS 0x2000 -#define IPMASKEDDSTADDRESS 0x1000 -#define PROTOCOLSRCPORTRANGE 0x800 -#define PROTOCOLDSTPORTRANGE 0x400 -#define DSTMACADDR 0x200 -#define SRCMACADDR 0x100 -#define ETHERTYPE 0x80 -#define IEEE802_1DUSERPRIORITY 0x40 -#define IEEE802_1QVLANID 0x10 - -struct gdm_wimax_csr_s { - bool enabled; - u32 sfid; - u8 qos_buf_count; - u16 classifier_rule_en; - u8 ip2s_lo; - u8 ip2s_hi; - u8 ip2s_mask; - u8 protocol; - u8 ipsrc_addr[16]; - u8 ipsrc_addrmask[16]; - u8 ipdst_addr[16]; - u8 ipdst_addrmask[16]; - u16 srcport_lo; - u16 srcport_hi; - u16 dstport_lo; - u16 dstport_hi; -}; - -struct qos_entry_s { - struct list_head list; - struct sk_buff *skb; - struct net_device *dev; - -}; - -struct qos_cb_s { - struct list_head qos_list[QOS_MAX]; - int qos_list_cnt; - int qos_null_idx; - struct gdm_wimax_csr_s csr[QOS_MAX]; - spinlock_t qos_lock; /* Protect structure fields */ - int qos_limit_size; -}; - -void gdm_qos_init(void *nic_ptr); -void gdm_qos_release_list(void *nic_ptr); -int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev); -void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size); - -#endif /* __GDM72XX_GDM_QOS_H__ */ diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c deleted file mode 100644 index 9449418dd8fe..000000000000 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ /dev/null @@ -1,700 +0,0 @@ -/* - * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include <linux/module.h> -#include <linux/init.h> -#include <linux/kernel.h> - -#include <linux/mmc/core.h> -#include <linux/mmc/card.h> -#include <linux/mmc/sdio_func.h> -#include <linux/mmc/sdio_ids.h> - -#include "gdm_sdio.h" -#include "gdm_wimax.h" -#include "sdio_boot.h" -#include "hci.h" - -#define TYPE_A_HEADER_SIZE 4 -#define TYPE_A_LOOKAHEAD_SIZE 16 - -#define MAX_NR_RX_BUF 4 - -#define SDU_TX_BUF_SIZE 2048 -#define TX_BUF_SIZE 2048 -#define TX_CHUNK_SIZE (2048 - TYPE_A_HEADER_SIZE) -#define RX_BUF_SIZE (25 * 1024) - -#define TX_HZ 2000 -#define TX_INTERVAL (NSEC_PER_SEC / TX_HZ) - -static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx) -{ - struct sdio_tx *t = kzalloc(sizeof(*t), GFP_ATOMIC); - - if (!t) - return NULL; - - t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC); - if (!t->buf) { - kfree(t); - return NULL; - } - - t->tx_cxt = tx; - - return t; -} - -static void free_tx_struct(struct sdio_tx *t) -{ - if (t) { - kfree(t->buf); - kfree(t); - } -} - -static struct sdio_rx *alloc_rx_struct(struct rx_cxt *rx) -{ - struct sdio_rx *r = kzalloc(sizeof(*r), GFP_ATOMIC); - - if (r) - r->rx_cxt = rx; - - return r; -} - -static void free_rx_struct(struct sdio_rx *r) -{ - kfree(r); -} - -/* Before this function is called, spin lock should be locked. */ -static struct sdio_tx *get_tx_struct(struct tx_cxt *tx, int *no_spc) -{ - struct sdio_tx *t; - - if (list_empty(&tx->free_list)) - return NULL; - - t = list_entry(tx->free_list.prev, struct sdio_tx, list); - list_del(&t->list); - - *no_spc = list_empty(&tx->free_list) ? 1 : 0; - - return t; -} - -/* Before this function is called, spin lock should be locked. */ -static void put_tx_struct(struct tx_cxt *tx, struct sdio_tx *t) -{ - list_add_tail(&t->list, &tx->free_list); -} - -/* Before this function is called, spin lock should be locked. */ -static struct sdio_rx *get_rx_struct(struct rx_cxt *rx) -{ - struct sdio_rx *r; - - if (list_empty(&rx->free_list)) - return NULL; - - r = list_entry(rx->free_list.prev, struct sdio_rx, list); - list_del(&r->list); - - return r; -} - -/* Before this function is called, spin lock should be locked. */ -static void put_rx_struct(struct rx_cxt *rx, struct sdio_rx *r) -{ - list_add_tail(&r->list, &rx->free_list); -} - -static void release_sdio(struct sdiowm_dev *sdev) -{ - struct tx_cxt *tx = &sdev->tx; - struct rx_cxt *rx = &sdev->rx; - struct sdio_tx *t, *t_next; - struct sdio_rx *r, *r_next; - - kfree(tx->sdu_buf); - - list_for_each_entry_safe(t, t_next, &tx->free_list, list) { - list_del(&t->list); - free_tx_struct(t); - } - - list_for_each_entry_safe(t, t_next, &tx->sdu_list, list) { - list_del(&t->list); - free_tx_struct(t); - } - - list_for_each_entry_safe(t, t_next, &tx->hci_list, list) { - list_del(&t->list); - free_tx_struct(t); - } - - kfree(rx->rx_buf); - - list_for_each_entry_safe(r, r_next, &rx->free_list, list) { - list_del(&r->list); - free_rx_struct(r); - } - - list_for_each_entry_safe(r, r_next, &rx->req_list, list) { - list_del(&r->list); - free_rx_struct(r); - } -} - -static int init_sdio(struct sdiowm_dev *sdev) -{ - int ret = 0, i; - struct tx_cxt *tx = &sdev->tx; - struct rx_cxt *rx = &sdev->rx; - struct sdio_tx *t; - struct sdio_rx *r; - - INIT_LIST_HEAD(&tx->free_list); - INIT_LIST_HEAD(&tx->sdu_list); - INIT_LIST_HEAD(&tx->hci_list); - - spin_lock_init(&tx->lock); - - tx->sdu_buf = kmalloc(SDU_TX_BUF_SIZE, GFP_KERNEL); - if (!tx->sdu_buf) - goto fail; - - for (i = 0; i < MAX_NR_SDU_BUF; i++) { - t = alloc_tx_struct(tx); - if (!t) { - ret = -ENOMEM; - goto fail; - } - list_add(&t->list, &tx->free_list); - } - - INIT_LIST_HEAD(&rx->free_list); - INIT_LIST_HEAD(&rx->req_list); - - spin_lock_init(&rx->lock); - - for (i = 0; i < MAX_NR_RX_BUF; i++) { - r = alloc_rx_struct(rx); - if (!r) { - ret = -ENOMEM; - goto fail; - } - list_add(&r->list, &rx->free_list); - } - - rx->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); - if (!rx->rx_buf) - goto fail; - - return 0; - -fail: - release_sdio(sdev); - return ret; -} - -static void send_sdio_pkt(struct sdio_func *func, u8 *data, int len) -{ - int n, blocks, ret, remain; - - sdio_claim_host(func); - - blocks = len / func->cur_blksize; - n = blocks * func->cur_blksize; - if (blocks) { - ret = sdio_memcpy_toio(func, 0, data, n); - if (ret < 0) { - if (ret != -ENOMEDIUM) - dev_err(&func->dev, - "gdmwms: error: ret = %d\n", ret); - goto end_io; - } - } - - remain = len - n; - remain = (remain + 3) & ~3; - - if (remain) { - ret = sdio_memcpy_toio(func, 0, data + n, remain); - if (ret < 0) { - if (ret != -ENOMEDIUM) - dev_err(&func->dev, - "gdmwms: error: ret = %d\n", ret); - goto end_io; - } - } - -end_io: - sdio_release_host(func); -} - -static void send_sdu(struct sdio_func *func, struct tx_cxt *tx) -{ - struct list_head *l, *next; - struct hci_s *hci; - struct sdio_tx *t; - int pos, len, i, estlen, aggr_num = 0, aggr_len; - u8 *buf; - unsigned long flags; - - spin_lock_irqsave(&tx->lock, flags); - - pos = TYPE_A_HEADER_SIZE + HCI_HEADER_SIZE; - list_for_each_entry(t, &tx->sdu_list, list) { - estlen = ((t->len + 3) & ~3) + 4; - if ((pos + estlen) > SDU_TX_BUF_SIZE) - break; - - aggr_num++; - memcpy(tx->sdu_buf + pos, t->buf, t->len); - memset(tx->sdu_buf + pos + t->len, 0, estlen - t->len); - pos += estlen; - } - aggr_len = pos; - - hci = (struct hci_s *)(tx->sdu_buf + TYPE_A_HEADER_SIZE); - hci->cmd_evt = cpu_to_be16(WIMAX_TX_SDU_AGGR); - hci->length = cpu_to_be16(aggr_len - TYPE_A_HEADER_SIZE - - HCI_HEADER_SIZE); - - spin_unlock_irqrestore(&tx->lock, flags); - - dev_dbg(&func->dev, "sdio_send: %*ph\n", aggr_len - TYPE_A_HEADER_SIZE, - tx->sdu_buf + TYPE_A_HEADER_SIZE); - - for (pos = TYPE_A_HEADER_SIZE; pos < aggr_len; pos += TX_CHUNK_SIZE) { - len = aggr_len - pos; - len = len > TX_CHUNK_SIZE ? TX_CHUNK_SIZE : len; - buf = tx->sdu_buf + pos - TYPE_A_HEADER_SIZE; - - buf[0] = len & 0xff; - buf[1] = (len >> 8) & 0xff; - buf[2] = (len >> 16) & 0xff; - buf[3] = (pos + len) >= aggr_len ? 0 : 1; - send_sdio_pkt(func, buf, len + TYPE_A_HEADER_SIZE); - } - - spin_lock_irqsave(&tx->lock, flags); - - for (l = tx->sdu_list.next, i = 0; i < aggr_num; i++, l = next) { - next = l->next; - t = list_entry(l, struct sdio_tx, list); - if (t->callback) - t->callback(t->cb_data); - - list_del(l); - put_tx_struct(t->tx_cxt, t); - } - - tx->sdu_stamp = ktime_get(); - spin_unlock_irqrestore(&tx->lock, flags); -} - -static void send_hci(struct sdio_func *func, struct tx_cxt *tx, - struct sdio_tx *t) -{ - unsigned long flags; - - dev_dbg(&func->dev, "sdio_send: %*ph\n", t->len - TYPE_A_HEADER_SIZE, - t->buf + TYPE_A_HEADER_SIZE); - - send_sdio_pkt(func, t->buf, t->len); - - spin_lock_irqsave(&tx->lock, flags); - if (t->callback) - t->callback(t->cb_data); - free_tx_struct(t); - spin_unlock_irqrestore(&tx->lock, flags); -} - -static void do_tx(struct work_struct *work) -{ - struct sdiowm_dev *sdev = container_of(work, struct sdiowm_dev, ws); - struct sdio_func *func = sdev->func; - struct tx_cxt *tx = &sdev->tx; - struct sdio_tx *t = NULL; - ktime_t now, before; - int is_sdu = 0; - long diff; - unsigned long flags; - - spin_lock_irqsave(&tx->lock, flags); - if (!tx->can_send) { - spin_unlock_irqrestore(&tx->lock, flags); - return; - } - - if (!list_empty(&tx->hci_list)) { - t = list_entry(tx->hci_list.next, struct sdio_tx, list); - list_del(&t->list); - is_sdu = 0; - } else if (!tx->stop_sdu_tx && !list_empty(&tx->sdu_list)) { - now = ktime_get(); - before = tx->sdu_stamp; - - diff = ktime_to_ns(ktime_sub(now, before)); - if (diff >= 0 && diff < TX_INTERVAL) { - schedule_work(&sdev->ws); - spin_unlock_irqrestore(&tx->lock, flags); - return; - } - is_sdu = 1; - } - - if (!is_sdu && !t) { - sp |