diff options
Diffstat (limited to 'drivers')
152 files changed, 2149 insertions, 8161 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 3bd80f9695ac..64a531accd72 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -60,8 +60,6 @@ source "drivers/staging/board/Kconfig" source "drivers/staging/gdm724x/Kconfig" -source "drivers/staging/fwserial/Kconfig" - source "drivers/staging/clocking-wizard/Kconfig" source "drivers/staging/fbtft/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 1d9ae39fea14..6af299b9045b 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -20,7 +20,6 @@ obj-$(CONFIG_USB_EMXX) += emxx_udc/ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_STAGING_BOARD) += board/ obj-$(CONFIG_LTE_GDM724X) += gdm724x/ -obj-$(CONFIG_FIREWIRE_SERIAL) += fwserial/ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ obj-$(CONFIG_FB_TFT) += fbtft/ obj-$(CONFIG_MOST) += most/ diff --git a/drivers/staging/fwserial/Kconfig b/drivers/staging/fwserial/Kconfig deleted file mode 100644 index 6964aac2a7ed..000000000000 --- a/drivers/staging/fwserial/Kconfig +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config FIREWIRE_SERIAL - tristate "TTY over Firewire" - depends on FIREWIRE && TTY - help - This enables TTY over IEEE 1394, providing high-speed serial - connectivity to cabled peers. This driver implements a - ad-hoc transport protocol and is currently limited to - Linux-to-Linux communication. - - To compile this driver as a module, say M here: the module will - be called firewire-serial. - -if FIREWIRE_SERIAL - -config FWTTY_MAX_TOTAL_PORTS - int "Maximum number of serial ports supported" - default "64" - help - Set this to the maximum number of serial ports you want the - firewire-serial driver to support. - -config FWTTY_MAX_CARD_PORTS - int "Maximum number of serial ports supported per adapter" - range 0 FWTTY_MAX_TOTAL_PORTS - default "32" - help - Set this to the maximum number of serial ports each firewire - adapter supports. The actual number of serial ports registered - is set with the module parameter "ttys". - -endif diff --git a/drivers/staging/fwserial/Makefile b/drivers/staging/fwserial/Makefile deleted file mode 100644 index 1cd5c5c7e805..000000000000 --- a/drivers/staging/fwserial/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_FIREWIRE_SERIAL) += firewire-serial.o -firewire-serial-objs := fwserial.o dma_fifo.o diff --git a/drivers/staging/fwserial/TODO b/drivers/staging/fwserial/TODO deleted file mode 100644 index 382a7959407c..000000000000 --- a/drivers/staging/fwserial/TODO +++ /dev/null @@ -1,14 +0,0 @@ -TODOs prior to this driver moving out of staging ------------------------------------------------- -1. Implement retries for RCODE_BUSY, RCODE_NO_ACK and RCODE_SEND_ERROR - - I/O is handled asynchronously which presents some issues when error - conditions occur. -2. Implement _robust_ console on top of this. The existing prototype console - driver is not ready for the big leagues yet. -3. Expose means of controlling attach/detach of peers via sysfs. Include - GUID-to-port matching/whitelist/blacklist. - --- Issues with firewire stack -- -1. This driver uses the same unregistered vendor id that the firewire core does - (0xd00d1e). Perhaps this could be exposed as a define in - firewire.h? diff --git a/drivers/staging/fwserial/dma_fifo.c b/drivers/staging/fwserial/dma_fifo.c deleted file mode 100644 index 5dcbab6fd622..000000000000 --- a/drivers/staging/fwserial/dma_fifo.c +++ /dev/null @@ -1,294 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * DMA-able FIFO implementation - * - * Copyright (C) 2012 Peter Hurley <peter@hurleysoftware.com> - */ - -#include <linux/kernel.h> -#include <linux/slab.h> -#include <linux/list.h> -#include <linux/bug.h> - -#include "dma_fifo.h" - -#ifdef DEBUG_TRACING -#define df_trace(s, args...) pr_debug(s, ##args) -#else -#define df_trace(s, args...) -#endif - -#define FAIL(fifo, condition, format...) ({ \ - fifo->corrupt = !!(condition); \ - WARN(fifo->corrupt, format); \ -}) - -/* - * private helper fn to determine if check is in open interval (lo,hi) - */ -static bool addr_check(unsigned int check, unsigned int lo, unsigned int hi) -{ - return check - (lo + 1) < (hi - 1) - lo; -} - -/** - * dma_fifo_init: initialize the fifo to a valid but inoperative state - * @fifo: address of in-place "struct dma_fifo" object - */ -void dma_fifo_init(struct dma_fifo *fifo) -{ - memset(fifo, 0, sizeof(*fifo)); - INIT_LIST_HEAD(&fifo->pending); -} - -/** - * dma_fifo_alloc - initialize and allocate dma_fifo - * @fifo: address of in-place "struct dma_fifo" object - * @size: 'apparent' size, in bytes, of fifo - * @align: dma alignment to maintain (should be at least cpu cache alignment), - * must be power of 2 - * @tx_limit: maximum # of bytes transmissible per dma (rounded down to - * multiple of alignment, but at least align size) - * @open_limit: maximum # of outstanding dma transactions allowed - * @gfp_mask: get_free_pages mask, passed to kmalloc() - * - * The 'apparent' size will be rounded up to next greater aligned size. - * Returns 0 if no error, otherwise an error code - */ -int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned int align, - int tx_limit, int open_limit, gfp_t gfp_mask) -{ - int capacity; - - if (!is_power_of_2(align) || size < 0) - return -EINVAL; - - size = round_up(size, align); - capacity = size + align * open_limit + align * DMA_FIFO_GUARD; - fifo->data = kmalloc(capacity, gfp_mask); - if (!fifo->data) - return -ENOMEM; - - fifo->in = 0; - fifo->out = 0; - fifo->done = 0; - fifo->size = size; - fifo->avail = size; - fifo->align = align; - fifo->tx_limit = max_t(int, round_down(tx_limit, align), align); - fifo->open = 0; - fifo->open_limit = open_limit; - fifo->guard = size + align * open_limit; - fifo->capacity = capacity; - fifo->corrupt = 0; - - return 0; -} - -/** - * dma_fifo_free - frees the fifo - * @fifo: address of in-place "struct dma_fifo" to free - * - * Also reinits the fifo to a valid but inoperative state. This - * allows the fifo to be reused with a different target requiring - * different fifo parameters. - */ -void dma_fifo_free(struct dma_fifo *fifo) -{ - struct dma_pending *pending, *next; - - if (!fifo->data) - return; - - list_for_each_entry_safe(pending, next, &fifo->pending, link) - list_del_init(&pending->link); - kfree(fifo->data); - fifo->data = NULL; -} - -/** - * dma_fifo_reset - dumps the fifo contents and reinits for reuse - * @fifo: address of in-place "struct dma_fifo" to reset - */ -void dma_fifo_reset(struct dma_fifo *fifo) -{ - struct dma_pending *pending, *next; - - if (!fifo->data) - return; - - list_for_each_entry_safe(pending, next, &fifo->pending, link) - list_del_init(&pending->link); - fifo->in = 0; - fifo->out = 0; - fifo->done = 0; - fifo->avail = fifo->size; - fifo->open = 0; - fifo->corrupt = 0; -} - -/** - * dma_fifo_in - copies data into the fifo - * @fifo: address of in-place "struct dma_fifo" to write to - * @src: buffer to copy from - * @n: # of bytes to copy - * - * Returns the # of bytes actually copied, which can be less than requested if - * the fifo becomes full. If < 0, return is error code. - */ -int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n) -{ - int ofs, l; - - if (!fifo->data) - return -ENOENT; - if (fifo->corrupt) - return -ENXIO; - - if (n > fifo->avail) - n = fifo->avail; - if (n <= 0) - return 0; - - ofs = fifo->in % fifo->capacity; - l = min(n, fifo->capacity - ofs); - memcpy(fifo->data + ofs, src, l); - memcpy(fifo->data, src + l, n - l); - - if (FAIL(fifo, addr_check(fifo->done, fifo->in, fifo->in + n) || - fifo->avail < n, - "fifo corrupt: in:%u out:%u done:%u n:%d avail:%d", - fifo->in, fifo->out, fifo->done, n, fifo->avail)) - return -ENXIO; - - fifo->in += n; - fifo->avail -= n; - - df_trace("in:%u out:%u done:%u n:%d avail:%d", fifo->in, fifo->out, - fifo->done, n, fifo->avail); - - return n; -} - -/** - * dma_fifo_out_pend - gets address/len of next avail read and marks as pended - * @fifo: address of in-place "struct dma_fifo" to read from - * @pended: address of structure to fill with read address/len - * The data/len fields will be NULL/0 if no dma is pended. - * - * Returns the # of used bytes remaining in fifo (ie, if > 0, more data - * remains in the fifo that was not pended). If < 0, return is error code. - */ -int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended) -{ - unsigned int len, n, ofs, l, limit; - - if (!fifo->data) - return -ENOENT; - if (fifo->corrupt) - return -ENXIO; - - pended->len = 0; - pended->data = NULL; - pended->out = fifo->out; - - len = fifo->in - fifo->out; - if (!len) - return -ENODATA; - if (fifo->open == fifo->open_limit) - return -EAGAIN; - - n = len; - ofs = fifo->out % fifo->capacity; - l = fifo->capacity - ofs; - limit = min_t(unsigned int, l, fifo->tx_limit); - if (n > limit) { - n = limit; - fifo->out += limit; - } else if (ofs + n > fifo->guard) { - fifo->out += l; - fifo->in = fifo->out; - } else { - fifo->out += round_up(n, fifo->align); - fifo->in = fifo->out; - } - - df_trace("in: %u out: %u done: %u n: %d len: %u avail: %d", fifo->in, - fifo->out, fifo->done, n, len, fifo->avail); - - pended->len = n; - pended->data = fifo->data + ofs; - pended->next = fifo->out; - list_add_tail(&pended->link, &fifo->pending); - ++fifo->open; - - if (FAIL(fifo, fifo->open > fifo->open_limit, - "past open limit:%d (limit:%d)", - fifo->open, fifo->open_limit)) - return -ENXIO; - if (FAIL(fifo, fifo->out & (fifo->align - 1), - "fifo out unaligned:%u (align:%u)", - fifo->out, fifo->align)) - return -ENXIO; - - return len - n; -} - -/** - * dma_fifo_out_complete - marks pended dma as completed - * @fifo: address of in-place "struct dma_fifo" which was read from - * @complete: address of structure for previously pended dma to mark completed - */ -int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete) -{ - struct dma_pending *pending, *next, *tmp; - - if (!fifo->data) - return -ENOENT; - if (fifo->corrupt) - return -ENXIO; - if (list_empty(&fifo->pending) && fifo->open == 0) - return -EINVAL; - - if (FAIL(fifo, list_empty(&fifo->pending) != (fifo->open == 0), - "pending list disagrees with open count:%d", - fifo->open)) - return -ENXIO; - - tmp = complete->data; - *tmp = *complete; - list_replace(&complete->link, &tmp->link); - dp_mark_completed(tmp); - - /* Only update the fifo in the original pended order */ - list_for_each_entry_safe(pending, next, &fifo->pending, link) { - if (!dp_is_completed(pending)) { - df_trace("still pending: saved out: %u len: %d", - pending->out, pending->len); - break; - } - - if (FAIL(fifo, pending->out != fifo->done || - addr_check(fifo->in, fifo->done, pending->next), - "in:%u out:%u done:%u saved:%u next:%u", - fifo->in, fifo->out, fifo->done, pending->out, - pending->next)) - return -ENXIO; - - list_del_init(&pending->link); - fifo->done = pending->next; - fifo->avail += pending->len; - --fifo->open; - - df_trace("in: %u out: %u done: %u len: %u avail: %d", fifo->in, - fifo->out, fifo->done, pending->len, fifo->avail); - } - - if (FAIL(fifo, fifo->open < 0, "open dma:%d < 0", fifo->open)) - return -ENXIO; - if (FAIL(fifo, fifo->avail > fifo->size, "fifo avail:%d > size:%d", - fifo->avail, fifo->size)) - return -ENXIO; - - return 0; -} diff --git a/drivers/staging/fwserial/dma_fifo.h b/drivers/staging/fwserial/dma_fifo.h deleted file mode 100644 index c46a06336975..000000000000 --- a/drivers/staging/fwserial/dma_fifo.h +++ /dev/null @@ -1,117 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * DMA-able FIFO interface - * - * Copyright (C) 2012 Peter Hurley <peter@hurleysoftware.com> - */ - -#ifndef _DMA_FIFO_H_ -#define _DMA_FIFO_H_ - -/** - * The design basis for the DMA FIFO is to provide an output side that - * complies with the streaming DMA API design that can be DMA'd from directly - * (without additional copying), coupled with an input side that maintains a - * logically consistent 'apparent' size (ie, bytes in + bytes avail is static - * for the lifetime of the FIFO). - * - * DMA output transactions originate on a cache line boundary and can be - * variably-sized. DMA output transactions can be retired out-of-order but - * the FIFO will only advance the output in the original input sequence. - * This means the FIFO will eventually stall if a transaction is never retired. - * - * Chunking the output side into cache line multiples means that some FIFO - * memory is unused. For example, if all the avail input has been pended out, - * then the in and out markers are re-aligned to the next cache line. - * The maximum possible waste is - * (cache line alignment - 1) * (max outstanding dma transactions) - * This potential waste requires additional hidden capacity within the FIFO - * to be able to accept input while the 'apparent' size has not been reached. - * - * Additional cache lines (ie, guard area) are used to minimize DMA - * fragmentation when wrapping at the end of the FIFO. Input is allowed into the - * guard area, but the in and out FIFO markers are wrapped when DMA is pended. - */ - -#define DMA_FIFO_GUARD 3 /* # of cache lines to reserve for the guard area */ - -struct dma_fifo { - unsigned int in; - unsigned int out; /* updated when dma is pended */ - unsigned int done; /* updated upon dma completion */ - struct { - unsigned corrupt:1; - }; - int size; /* 'apparent' size of fifo */ - int guard; /* ofs of guard area */ - int capacity; /* size + reserved */ - int avail; /* # of unused bytes in fifo */ - unsigned int align; /* must be power of 2 */ - int tx_limit; /* max # of bytes per dma transaction */ - int open_limit; /* max # of outstanding allowed */ - int open; /* # of outstanding dma transactions */ - struct list_head pending; /* fifo markers for outstanding dma */ - void *data; -}; - -struct dma_pending { - struct list_head link; - void *data; - unsigned int len; - unsigned int next; - unsigned int out; -}; - -static inline void dp_mark_completed(struct dma_pending *dp) -{ - dp->data += 1; -} - -static inline bool dp_is_completed(struct dma_pending *dp) -{ - return (unsigned long)dp->data & 1UL; -} - -void dma_fifo_init(struct dma_fifo *fifo); -int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned int align, - int tx_limit, int open_limit, gfp_t gfp_mask); -void dma_fifo_free(struct dma_fifo *fifo); -void dma_fifo_reset(struct dma_fifo *fifo); -int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n); -int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended); -int dma_fifo_out_complete(struct dma_fifo *fifo, - struct dma_pending *complete); - -/* returns the # of used bytes in the fifo */ -static inline int dma_fifo_level(struct dma_fifo *fifo) -{ - return fifo->size - fifo->avail; -} - -/* returns the # of bytes ready for output in the fifo */ -static inline int dma_fifo_out_level(struct dma_fifo *fifo) -{ - return fifo->in - fifo->out; -} - -/* returns the # of unused bytes in the fifo */ -static inline int dma_fifo_avail(struct dma_fifo *fifo) -{ - return fifo->avail; -} - -/* returns true if fifo has max # of outstanding dmas */ -static inline bool dma_fifo_busy(struct dma_fifo *fifo) -{ - return fifo->open == fifo->open_limit; -} - -/* changes the max size of dma returned from dma_fifo_out_pend() */ -static inline int dma_fifo_change_tx_limit(struct dma_fifo *fifo, int tx_limit) -{ - tx_limit = round_down(tx_limit, fifo->align); - fifo->tx_limit = max_t(int, tx_limit, fifo->align); - return 0; -} - -#endif /* _DMA_FIFO_H_ */ diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c deleted file mode 100644 index 81b06d88ed0d..000000000000 --- a/drivers/staging/fwserial/fwserial.c +++ /dev/null @@ -1,2891 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * FireWire Serial driver - * - * Copyright (C) 2012 Peter Hurley <peter@hurleysoftware.com> - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include <linux/sched.h> -#include <linux/slab.h> -#include <linux/device.h> -#include <linux/mod_devicetable.h> -#include <linux/rculist.h> -#include <linux/workqueue.h> -#include <linux/ratelimit.h> -#include <linux/bug.h> -#include <linux/uaccess.h> - -#include "fwserial.h" - -inline u64 be32_to_u64(__be32 hi, __be32 lo) -{ - return ((u64)be32_to_cpu(hi) << 32 | be32_to_cpu(lo)); -} - -#define LINUX_VENDOR_ID 0xd00d1eU /* same id used in card root directory */ -#define FWSERIAL_VERSION 0x00e81cU /* must be unique within LINUX_VENDOR_ID */ - -/* configurable options */ -static int num_ttys = 4; /* # of std ttys to create per fw_card */ - /* - doubles as loopback port index */ -static bool auto_connect = true; /* try to VIRT_CABLE to every peer */ -static bool create_loop_dev = true; /* create a loopback device for each card */ - -module_param_named(ttys, num_ttys, int, 0644); -module_param_named(auto, auto_connect, bool, 0644); -module_param_named(loop, create_loop_dev, bool, 0644); - -/* - * Threshold below which the tty is woken for writing - * - should be equal to WAKEUP_CHARS in drivers/tty/n_tty.c because - * even if the writer is woken, n_tty_poll() won't set EPOLLOUT until - * our fifo is below this level - */ -#define WAKEUP_CHARS 256 - -/* - * fwserial_list: list of every fw_serial created for each fw_card - * See discussion in fwserial_probe. - */ -static LIST_HEAD(fwserial_list); -static DEFINE_MUTEX(fwserial_list_mutex); - -/* - * port_table: array of tty ports allocated to each fw_card - * - * tty ports are allocated during probe when an fw_serial is first - * created for a given fw_card. Ports are allocated in a contiguous block, - * each block consisting of 'num_ports' ports. - */ -static struct fwtty_port *port_table[MAX_TOTAL_PORTS]; -static DEFINE_MUTEX(port_table_lock); -static bool port_table_corrupt; -#define FWTTY_INVALID_INDEX MAX_TOTAL_PORTS - -#define loop_idx(port) (((port)->index) / num_ports) -#define table_idx(loop) ((loop) * num_ports + num_ttys) - -/* total # of tty ports created per fw_card */ -static int num_ports; - -/* slab used as pool for struct fwtty_transactions */ -static struct kmem_cache *fwtty_txn_cache; - -struct tty_driver *fwtty_driver; -static struct tty_driver *fwloop_driver; - -static struct dentry *fwserial_debugfs; - -struct fwtty_transaction; -typedef void (*fwtty_transaction_cb)(struct fw_card *card, int rcode, - void *data, size_t length, - struct fwtty_transaction *txn); - -struct fwtty_transaction { - struct fw_transaction fw_txn; - fwtty_transaction_cb callback; - struct fwtty_port *port; - union { - struct dma_pending dma_pended; - }; -}; - -#define to_device(a, b) (a->b) -#define fwtty_err(p, fmt, ...) \ - dev_err(to_device(p, device), fmt, ##__VA_ARGS__) -#define fwtty_info(p, fmt, ...) \ - dev_info(to_device(p, device), fmt, ##__VA_ARGS__) -#define fwtty_notice(p, fmt, ...) \ - dev_notice(to_device(p, device), fmt, ##__VA_ARGS__) -#define fwtty_dbg(p, fmt, ...) \ - dev_dbg(to_device(p, device), "%s: " fmt, __func__, ##__VA_ARGS__) -#define fwtty_err_ratelimited(p, fmt, ...) \ - dev_err_ratelimited(to_device(p, device), fmt, ##__VA_ARGS__) - -#ifdef DEBUG -static inline void debug_short_write(struct fwtty_port *port, int c, int n) -{ - int avail; - - if (n < c) { - spin_lock_bh(&port->lock); - avail = dma_fifo_avail(&port->tx_fifo); - spin_unlock_bh(&port->lock); - fwtty_dbg(port, "short write: avail:%d req:%d wrote:%d\n", - avail, c, n); - } -} -#else -#define debug_short_write(port, c, n) -#endif - -static struct fwtty_peer *__fwserial_peer_by_node_id(struct fw_card *card, - int generation, int id); - -#ifdef FWTTY_PROFILING - -static void fwtty_profile_fifo(struct fwtty_port *port, unsigned int *stat) -{ - spin_lock_bh(&port->lock); - fwtty_profile_data(stat, dma_fifo_avail(&port->tx_fifo)); - spin_unlock_bh(&port->lock); -} - -static void fwtty_dump_profile(struct seq_file *m, struct stats *stats) -{ - /* for each stat, print sum of 0 to 2^k, then individually */ - int k = 4; - unsigned int sum; - int j; - char t[10]; - - snprintf(t, 10, "< %d", 1 << k); - seq_printf(m, "\n%14s %6s", " ", t); - for (j = k + 1; j < DISTRIBUTION_MAX_INDEX; ++j) - seq_printf(m, "%6d", 1 << j); - - ++k; - for (j = 0, sum = 0; j <= k; ++j) - sum += stats->reads[j]; - seq_printf(m, "\n%14s: %6d", "reads", sum); - for (j = k + 1; j <= DISTRIBUTION_MAX_INDEX; ++j) - seq_printf(m, "%6d", stats->reads[j]); - - for (j = 0, sum = 0; j <= k; ++j) - sum += stats->writes[j]; - seq_printf(m, "\n%14s: %6d", "writes", sum); - for (j = k + 1; j <= DISTRIBUTION_MAX_INDEX; ++j) - seq_printf(m, "%6d", stats->writes[j]); - - for (j = 0, sum = 0; j <= k; ++j) - sum += stats->txns[j]; - seq_printf(m, "\n%14s: %6d", "txns", sum); - for (j = k + 1; j <= DISTRIBUTION_MAX_INDEX; ++j) - seq_printf(m, "%6d", stats->txns[j]); - - for (j = 0, sum = 0; j <= k; ++j) - sum += stats->unthrottle[j]; - seq_printf(m, "\n%14s: %6d", "avail @ unthr", sum); - for (j = k + 1; j <= DISTRIBUTION_MAX_INDEX; ++j) - seq_printf(m, "%6d", stats->unthrottle[j]); -} - -#else -#define fwtty_profile_fifo(port, stat) -#define fwtty_dump_profile(m, stats) -#endif - -/* - * Returns the max receive packet size for the given node - * Devices which are OHCI v1.0/ v1.1/ v1.2-draft or RFC 2734 compliant - * are required by specification to support max_rec of 8 (512 bytes) or more. - */ -static inline int device_max_receive(struct fw_device *fw_device) -{ - /* see IEEE 1394-2008 table 8-8 */ - return min(2 << fw_device->max_rec, 4096); -} - -static void fwtty_log_tx_error(struct fwtty_port *port, int rcode) -{ - switch (rcode) { - case RCODE_SEND_ERROR: - fwtty_err_ratelimited(port, "card busy\n"); - break; - case RCODE_ADDRESS_ERROR: - fwtty_err_ratelimited(port, "bad unit addr or write length\n"); - break; - case RCODE_DATA_ERROR: - fwtty_err_ratelimited(port, "failed rx\n"); - break; - case RCODE_NO_ACK: - fwtty_err_ratelimited(port, "missing ack\n"); - break; - case RCODE_BUSY: - fwtty_err_ratelimited(port, "remote busy\n"); - break; - default: - fwtty_err_ratelimited(port, "failed tx: %d\n", rcode); - } -} - -static void fwtty_common_callback(struct fw_card *card, int rcode, - void *payload, size_t len, void *cb_data) -{ - struct fwtty_transaction *txn = cb_data; - struct fwtty_port *port = txn->port; - - if (port && rcode != RCODE_COMPLETE) - fwtty_log_tx_error(port, rcode); - if (txn->callback) - txn->callback(card, rcode, payload, len, txn); - kmem_cache_free(fwtty_txn_cache, txn); -} - -static int fwtty_send_data_async(struct fwtty_peer *peer, int tcode, - unsigned long long addr, void *payload, - size_t len, fwtty_transaction_cb callback, - struct fwtty_port *port) -{ - struct fwtty_transaction *txn; - int generation; - - txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC); - if (!txn) - return -ENOMEM; - - txn->callback = callback; - txn->port = port; - - generation = peer->generation; - smp_rmb(); - fw_send_request(peer->serial->card, &txn->fw_txn, tcode, - peer->node_id, generation, peer->speed, addr, payload, - len, fwtty_common_callback, txn); - return 0; -} - -static void fwtty_send_txn_async(struct fwtty_peer *peer, - struct fwtty_transaction *txn, int tcode, - unsigned long long addr, void *payload, - size_t len, fwtty_transaction_cb callback, - struct fwtty_port *port) -{ - int generation; - - txn->callback = callback; - txn->port = port; - - generation = peer->generation; - smp_rmb(); - fw_send_request(peer->serial->card, &txn->fw_txn, tcode, - peer->node_id, generation, peer->speed, addr, payload, - len, fwtty_common_callback, txn); -} - -static void __fwtty_restart_tx(struct fwtty_port *port) -{ - int len, avail; - - len = dma_fifo_out_level(&port->tx_fifo); - if (len) - schedule_delayed_work(&port->drain, 0); - avail = dma_fifo_avail(&port->tx_fifo); - - fwtty_dbg(port, "fifo len: %d avail: %d\n", len, avail); -} - -static void fwtty_restart_tx(struct fwtty_port *port) -{ - spin_lock_bh(&port->lock); - __fwtty_restart_tx(port); - spin_unlock_bh(&port->lock); -} - -/* - * fwtty_update_port_status - decodes & dispatches line status changes - * - * Note: in loopback, the port->lock is being held. Only use functions that - * don't attempt to reclaim the port->lock. - */ -static void fwtty_update_port_status(struct fwtty_port *port, - unsigned int status) -{ - unsigned int delta; - struct tty_struct *tty; - - /* simulated LSR/MSR status from remote */ - status &= ~MCTRL_MASK; - delta = (port->mstatus ^ status) & ~MCTRL_MASK; - delta &= ~(status & TIOCM_RNG); - port->mstatus = status; - - if (delta & TIOCM_RNG) - ++port->icount.rng; - if (delta & TIOCM_DSR) - ++port->icount.dsr; - if (delta & TIOCM_CAR) - ++port->icount.dcd; - if (delta & TIOCM_CTS) - ++port->icount.cts; - - fwtty_dbg(port, "status: %x delta: %x\n", status, delta); - - if (delta & TIOCM_CAR) { - tty = tty_port_tty_get(&port->port); - if (tty && !C_CLOCAL(tty)) { - if (status & TIOCM_CAR) - wake_up_interruptible(&port->port.open_wait); - else - schedule_work(&port->hangup); - } - tty_kref_put(tty); - } - - if (delta & TIOCM_CTS) { - tty = tty_port_tty_get(&port->port); - if (tty && C_CRTSCTS(tty)) { - if (tty->hw_stopped) { - if (status & TIOCM_CTS) { - tty->hw_stopped = 0; - if (port->loopback) - __fwtty_restart_tx(port); - else - fwtty_restart_tx(port); - } - } else { - if (~status & TIOCM_CTS) - tty->hw_stopped = 1; - } - } - tty_kref_put(tty); - - } else if (delta & OOB_TX_THROTTLE) { - tty = tty_port_tty_get(&port->port); - if (tty) { - if (tty->hw_stopped) { - if (~status & OOB_TX_THROTTLE) { - tty->hw_stopped = 0; - if (port->loopback) - __fwtty_restart_tx(port); - else - fwtty_restart_tx(port); - } - } else { - if (status & OOB_TX_THROTTLE) - tty->hw_stopped = 1; - } - } - tty_kref_put(tty); - } - - if (delta & (UART_LSR_BI << 24)) { - if (status & (UART_LSR_BI << 24)) { - port->break_last = jiffies; - schedule_delayed_work(&port->emit_breaks, 0); - } else { - /* run emit_breaks one last time (if pending) */ - mod_delayed_work(system_wq, &port->emit_breaks, 0); - } - } - - if (delta & (TIOCM_DSR | TIOCM_CAR | TIOCM_CTS | TIOCM_RNG)) - wake_up_interruptible(&port->port.delta_msr_wait); -} - -/* - * __fwtty_port_line_status - generate 'line status' for indicated port - * - * This function returns a remote 'MSR' state based on the local 'MCR' state, - * as if a null modem cable was attached. The actual status is a mangling - * of TIOCM_* bits suitable for sending to a peer's status_addr. - * - * Note: caller must be holding port lock - */ -static unsigned int __fwtty_port_line_status(struct fwtty_port *port) -{ - unsigned int status = 0; - - /* TODO: add module param to tie RNG to DTR as well */ - - if (port->mctrl & TIOCM_DTR) - status |= TIOCM_DSR | TIOCM_CAR; - if (port->mctrl & TIOCM_RTS) - status |= TIOCM_CTS; - if (port->mctrl & OOB_RX_THROTTLE) - status |= OOB_TX_THROTTLE; - /* emulate BRK as add'l line status */ - if (port->break_ctl) - status |= UART_LSR_BI << 24; - - return status; -} - -/* - * __fwtty_write_port_status - send the port line status to peer - * - * Note: caller must be holding the port lock. - */ -static int __fwtty_write_port_status(struct fwtty_port *port) -{ - struct fwtty_peer *peer; - int err = -ENOENT; - unsigned int status = __fwtty_port_line_status(port); - - rcu_read_lock(); - peer = rcu_dereference(port->peer); - if (peer) { - err = fwtty_send_data_async(peer, TCODE_WRITE_QUADLET_REQUEST, - peer->status_addr, &status, - sizeof(status), NULL, port); - } - rcu_read_unlock(); - - return err; -} - -/* - * fwtty_write_port_status - same as above but locked by port lock - */ -static int fwtty_write_port_status(struct fwtty_port *port) -{ - int err; - - spin_lock_bh(&port->lock); - err = __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); - return err; -} - -static void fwtty_throttle_port(struct fwtty_port *port) -{ - struct tty_struct *tty; - unsigned int old; - - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - - spin_lock_bh(&port->lock); - - old = port->mctrl; - port->mctrl |= OOB_RX_THROTTLE; - if (C_CRTSCTS(tty)) - port->mctrl &= ~TIOCM_RTS; - if (~old & OOB_RX_THROTTLE) - __fwtty_write_port_status(port); - - spin_unlock_bh(&port->lock); - - tty_kref_put(tty); -} - -/* - * fwtty_do_hangup - wait for ldisc to deliver all pending rx; only then hangup - * - * When the remote has finished tx, and all in-flight rx has been received and - * pushed to the flip buffer, the remote may close its device. This will - * drop DTR on the remote which will drop carrier here. Typically, the tty is - * hung up when carrier is dropped or lost. - * - * However, there is a race between the hang up and the line discipline - * delivering its data to the reader. A hangup will cause the ldisc to flush - * (ie., clear) the read buffer and flip buffer. Because of firewire's - * relatively high throughput, the ldisc frequently lags well behind the driver, - * resulting in lost data (which has already been received and written to - * the flip buffer) when the remote closes its end. - * - * Unfortunately, since the flip buffer offers no direct method for determining - * if it holds data, ensuring the ldisc has delivered all data is problematic. - */ - -/* FIXME: drop this workaround when __tty_hangup waits for ldisc completion */ -static void fwtty_do_hangup(struct work_struct *work) -{ - struct fwtty_port *port = to_port(work, hangup); - struct tty_struct *tty; - - schedule_timeout_uninterruptible(msecs_to_jiffies(50)); - - tty = tty_port_tty_get(&port->port); - if (tty) - tty_vhangup(tty); - tty_kref_put(tty); -} - -static void fwtty_emit_breaks(struct work_struct *work) -{ - struct fwtty_port *port = to_port(to_delayed_work(work), emit_breaks); - static const char buf[16]; - unsigned long now = jiffies; - unsigned long elapsed = now - port->break_last; - int n, t, c, brk = 0; - - /* generate breaks at the line rate (but at least 1) */ - n = (elapsed * port->cps) / HZ + 1; - port->break_last = now; - - fwtty_dbg(port, "sending %d brks\n", n); - - while (n) { - t = min(n, 16); - c = tty_insert_flip_string_fixed_flag(&port->port, buf, - TTY_BREAK, t); - n -= c; - brk += c; - if (c < t) - break; - } - tty_flip_buffer_push(&port->port); - - if (port->mstatus & (UART_LSR_BI << 24)) - schedule_delayed_work(&port->emit_breaks, FREQ_BREAKS); - port->icount.brk += brk; -} - -static int fwtty_rx(struct fwtty_port *port, unsigned char *data, size_t len) -{ - int c, n = len; - unsigned int lsr; - int err = 0; - - fwtty_dbg(port, "%d\n", n); - fwtty_profile_data(port->stats.reads, n); - - if (port->write_only) { - n = 0; - goto out; - } - - /* disregard break status; breaks are generated by emit_breaks work */ - lsr = (port->mstatus >> 24) & ~UART_LSR_BI; - - if (port->overrun) - lsr |= UART_LSR_OE; - - if (lsr & UART_LSR_OE) - ++port->icount.overrun; - - lsr &= port->status_mask; - if (lsr & ~port->ignore_mask & UART_LSR_OE) { - if (!tty_insert_flip_char(&port->port, 0, TTY_OVERRUN)) { - err = -EIO; - goto out; - } - } - port->overrun = false; - - if (lsr & port->ignore_mask & ~UART_LSR_OE) { - /* TODO: don't drop SAK and Magic SysRq here */ - n = 0; - goto out; - } - - c = tty_insert_flip_string_fixed_flag(&port->port, data, TTY_NORMAL, n); - if (c > 0) - tty_flip_buffer_push(&port->port); - n -= c; - - if (n) { - port->overrun = true; - err = -EIO; - fwtty_err_ratelimited(port, "flip buffer overrun\n"); - - } else { - /* throttle the sender if remaining flip buffer space has - * reached high watermark to avoid losing data which may be - * in-flight. Since the AR request context is 32k, that much - * data may have _already_ been acked. - */ - if (tty_buffer_space_avail(&port->port) < HIGH_WATERMARK) - fwtty_throttle_port(port); - } - -out: - port->icount.rx += len; - port->stats.lost += n; - return err; -} - -/* - * fwtty_port_handler - bus address handler for port reads/writes - * - * This handler is responsible for handling inbound read/write dma from remotes. - */ -static void fwtty_port_handler(struct fw_card *card, - struct fw_request *request, - int tcode, int destination, int source, - int generation, - unsigned long long addr, - void *data, size_t len, - void *callback_data) -{ - struct fwtty_port *port = callback_data; - struct fwtty_peer *peer; - int err; - int rcode; - - /* Only accept rx from the peer virtual-cabled to this port */ - rcu_read_lock(); - peer = __fwserial_peer_by_node_id(card, generation, source); - rcu_read_unlock(); - if (!peer || peer != rcu_access_pointer(port->peer)) { - rcode = RCODE_ADDRESS_ERROR; - fwtty_err_ratelimited(port, "ignoring unauthenticated data\n"); - goto respond; - } - - switch (tcode) { - case TCODE_WRITE_QUADLET_REQUEST: - if (addr != port->rx_handler.offset || len != 4) { - rcode = RCODE_ADDRESS_ERROR; - } else { - fwtty_update_port_status(port, *(unsigned int *)data); - rcode = RCODE_COMPLETE; - } - break; - - case TCODE_WRITE_BLOCK_REQUEST: - if (addr != port->rx_handler.offset + 4 || - len > port->rx_handler.length - 4) { - rcode = RCODE_ADDRESS_ERROR; - } else { - err = fwtty_rx(port, data, len); - switch (err) { - case 0: - rcode = RCODE_COMPLETE; - break; - case -EIO: - rcode = RCODE_DATA_ERROR; - break; - default: - rcode = RCODE_CONFLICT_ERROR; - break; - } - } - break; - - default: - rcode = RCODE_TYPE_ERROR; - } - -respond: - fw_send_response(card, request, rcode); -} - -/* - * fwtty_tx_complete - callback for tx dma - * @data: ignored, has no meaning for write txns - * @length: ignored, has no meaning for write txns - * - * The writer must be woken here if the fifo has been emptied because it - * may have slept if chars_in_buffer was != 0 - */ -static void fwtty_tx_complete(struct fw_card *card, int rcode, - void *data, size_t length, - struct fwtty_transaction *txn) -{ - struct fwtty_port *port = txn->port; - int len; - - fwtty_dbg(port, "rcode: %d\n", rcode); - - switch (rcode) { - case RCODE_COMPLETE: - spin_lock_bh(&port->lock); - dma_fifo_out_complete(&port->tx_fifo, &txn->dma_pended); - len = dma_fifo_level(&port->tx_fifo); - spin_unlock_bh(&port->lock); - - port->icount.tx += txn->dma_pended.len; - break; - - default: - /* TODO: implement retries */ - spin_lock_bh(&port->lock); - dma_fifo_out_complete(&port->tx_fifo, &txn->dma_pended); - len = dma_fifo_level(&port->tx_fifo); - spin_unlock_bh(&port->lock); - - port->stats.dropped += txn->dma_pended.len; - } - - if (len < WAKEUP_CHARS) - tty_port_tty_wakeup(&port->port); -} - -static int fwtty_tx(struct fwtty_port *port, bool drain) -{ - struct fwtty_peer *peer; - struct fwtty_transaction *txn; - struct tty_struct *tty; - int n, len; - - tty = tty_port_tty_get(&port->port); - if (!tty) - return -ENOENT; - - rcu_read_lock(); - peer = rcu_dereference(port->peer); - if (!peer) { - n = -EIO; - goto out; - } - - if (test_and_set_bit(IN_TX, &port->flags)) { - n = -EALREADY; - goto out; - } - - /* try to write as many dma transactions out as possible */ - n = -EAGAIN; - while (!tty->flow.stopped && !tty->hw_stopped && - !test_bit(STOP_TX, &port->flags)) { - txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC); - if (!txn) { - n = -ENOMEM; - break; - } - - spin_lock_bh(&port->lock); - n = dma_fifo_out_pend(&port->tx_fifo, &txn->dma_pended); - spin_unlock_bh(&port->lock); - - fwtty_dbg(port, "out: %u rem: %d\n", txn->dma_pended.len, n); - - if (n < 0) { - kmem_cache_free(fwtty_txn_cache, txn); - if (n == -EAGAIN) { - ++port->stats.tx_stall; - } else if (n == -ENODATA) { - fwtty_profile_data(port->stats.txns, 0); - } else { - ++port->stats.fifo_errs; - fwtty_err_ratelimited(port, "fifo err: %d\n", - n); - } - break; - } - - fwtty_profile_data(port->stats.txns, txn->dma_pended.len); - - fwtty_send_txn_async(peer, txn, TCODE_WRITE_BLOCK_REQUEST, - peer->fifo_addr, txn->dma_pended.data, - txn->dma_pended.len, fwtty_tx_complete, - port); - ++port->stats.sent; - - /* - * Stop tx if the 'last view' of the fifo is empty or if - * this is the writer and there's not enough data to bother - */ - if (n == 0 || (!drain && n < WRITER_MINIMUM)) - break; - } - - if (n >= 0 || n == -EAGAIN || n == -ENOMEM || n == -ENODATA) { - spin_lock_bh(&port->lock); - len = dma_fifo_out_level(&port->tx_fifo); - if (len) { - unsigned long delay = (n == -ENOMEM) ? HZ : 1; - - schedule_delayed_work(&port->drain, delay); - } - len = dma_fifo_level(&port->tx_fifo); - spin_unlock_bh(&port->lock); - - /* wakeup the writer */ - if (drain && len < WAKEUP_CHARS) - tty_wakeup(tty); - } - - clear_bit(IN_TX, &port->flags); - wake_up_interruptible(&port->wait_tx); - -out: - rcu_read_unlock(); - tty_kref_put(tty); - return n; -} - -static void fwtty_drain_tx(struct work_struct *work) -{ - struct fwtty_port *port = to_port(to_delayed_work(work), drain); - - fwtty_tx(port, true); -} - -static void fwtty_write_xchar(struct fwtty_port *port, char ch) -{ - struct fwtty_peer *peer; - - ++port->stats.xchars; - - fwtty_dbg(port, "%02x\n", ch); - - rcu_read_lock(); - peer = rcu_dereference(port->peer); - if (peer) { - fwtty_send_data_async(peer, TCODE_WRITE_BLOCK_REQUEST, - peer->fifo_addr, &ch, sizeof(ch), - NULL, port); - } - rcu_read_unlock(); -} - -static struct fwtty_port *fwtty_port_get(unsigned int index) -{ - struct fwtty_port *port; - - if (index >= MAX_TOTAL_PORTS) - return NULL; - - mutex_lock(&port_table_lock); - port = port_table[index]; - if (port) - kref_get(&port->serial->kref); - mutex_unlock(&port_table_lock); - return port; -} - -static int fwtty_ports_add(struct fw_serial *serial) -{ - int err = -EBUSY; - int i, j; - - if (port_table_corrupt) - return err; - - mutex_lock(&port_table_lock); - for (i = 0; i + num_ports <= MAX_TOTAL_PORTS; i += num_ports) { - if (!port_table[i]) { - for (j = 0; j < num_ports; ++i, ++j) { - serial->ports[j]->index = i; - port_table[i] = serial->ports[j]; - } - err = 0; - break; - } - } - mutex_unlock(&port_table_lock); - return err; -} - -static void fwserial_destroy(struct kref *kref) -{ - struct fw_serial *serial = to_serial(kref, kref); - struct fwtty_port **ports = serial->ports; - int j, i = ports[0]->index; - - synchronize_rcu(); - - mutex_lock(&port_table_lock); - for (j = 0; j < num_ports; ++i, ++j) { - port_table_corrupt |= port_table[i] != ports[j]; - WARN_ONCE(port_table_corrupt, "port_table[%d]: %p != ports[%d]: %p", - i, port_table[i], j, ports[j]); - - port_table[i] = NULL; - } - mutex_unlock(&port_table_lock); - - for (j = 0; j < num_ports; ++j) { - fw_core_remove_address_handler(&ports[j]->rx_handler); - tty_port_destroy(&ports[j]->port); - kfree(ports[j]); - } - kfree(serial); -} - -static void fwtty_port_put(struct fwtty_port *port) -{ - kref_put(&port->serial->kref, fwserial_destroy); -} - -static void fwtty_port_dtr_rts(struct tty_port *tty_port, int on) -{ - struct fwtty_port *port = to_port(tty_port, port); - - fwtty_dbg(port, "on/off: %d\n", on); - - spin_lock_bh(&port->lock); - /* Don't change carrier state if this is a console */ - if (!port->port.console) { - if (on) - port->mctrl |= TIOCM_DTR | TIOCM_RTS; - else - port->mctrl &= ~(TIOCM_DTR | TIOCM_RTS); - } - - __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); -} - -/* - * fwtty_port_carrier_raised: required tty_port operation - * - * This port operation is polled after a tty has been opened and is waiting for - * carrier detect -- see drivers/tty/tty_port:tty_port_block_til_ready(). - */ -static int fwtty_port_carrier_raised(struct tty_port *tty_port) -{ - struct fwtty_port *port = to_port(tty_port, port); - int rc; - - rc = (port->mstatus & TIOCM_CAR); - - fwtty_dbg(port, "%d\n", rc); - - return rc; -} - -static unsigned int set_termios(struct fwtty_port *port, struct tty_struct *tty) -{ - unsigned int baud, frame; - - baud = tty_termios_baud_rate(&tty->termios); - tty_termios_encode_baud_rate(&tty->termios, baud, baud); - - /* compute bit count of 2 frames */ - frame = 12 + ((C_CSTOPB(tty)) ? 4 : 2) + ((C_PARENB(tty)) ? 2 : 0); - - switch (C_CSIZE(tty)) { - case CS5: - frame -= (C_CSTOPB(tty)) ? 1 : 0; - break; - case CS6: - frame += 2; - break; - case CS7: - frame += 4; - break; - case CS8: - frame += 6; - break; - } - - port->cps = (baud << 1) / frame; - - port->status_mask = UART_LSR_OE; - if (_I_FLAG(tty, BRKINT | PARMRK)) - port->status_mask |= UART_LSR_BI; - - port->ignore_mask = 0; - if (I_IGNBRK(tty)) { - port->ignore_mask |= UART_LSR_BI; - if (I_IGNPAR(tty)) - port->ignore_mask |= UART_LSR_OE; - } - - port->write_only = !C_CREAD(tty); - - /* turn off echo and newline xlat if loopback */ - if (port->loopback) { - tty->termios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHOKE | - ECHONL | ECHOPRT | ECHOCTL); - tty->termios.c_oflag &= ~ONLCR; - } - - return baud; -} - -static int fwtty_port_activate(struct tty_port *tty_port, - struct tty_struct *tty) -{ - struct fwtty_port *port = to_port(tty_port, port); - unsigned int baud; - int err; - - set_bit(TTY_IO_ERROR, &tty->flags); - - err = dma_fifo_alloc(&port->tx_fifo, FWTTY_PORT_TXFIFO_LEN, - cache_line_size(), - port->max_payload, - FWTTY_PORT_MAX_PEND_DMA, - GFP_KERNEL); - if (err) - return err; - - spin_lock_bh(&port->lock); - - baud = set_termios(port, tty); - - /* if console, don't change carrier state */ - if (!port->port.console) { - port->mctrl = 0; - if (baud != 0) - port->mctrl = TIOCM_DTR | TIOCM_RTS; - } - - if (C_CRTSCTS(tty) && ~port->mstatus & TIOCM_CTS) - tty->hw_stopped = 1; - - __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); - - clear_bit(TTY_IO_ERROR, &tty->flags); - - return 0; -} - -/* - * fwtty_port_shutdown - * - * Note: the tty port core ensures this is not the console and - * manages TTY_IO_ERROR properly - */ -static void fwtty_port_shutdown(struct tty_port *tty_port) -{ - struct fwtty_port *port = to_port(tty_port, port); - - /* TODO: cancel outstanding transactions */ - - cancel_delayed_work_sync(&port->emit_breaks); - cancel_delayed_work_sync(&port->drain); - - spin_lock_bh(&port->lock); - port->flags = 0; - port->break_ctl = 0; - port->overrun = 0; - __fwtty_write_port_status(port); - dma_fifo_free(&port->tx_fifo); - spin_unlock_bh(&port->lock); -} - -static int fwtty_open(struct tty_struct *tty, struct file *fp) -{ - struct fwtty_port *port = tty->driver_data; - - return tty_port_open(&port->port, tty, fp); -} - -static void fwtty_close(struct tty_struct *tty, struct file *fp) -{ - struct fwtty_port *port = tty->driver_data; - - tty_port_close(&port->port, tty, fp); -} - -static void fwtty_hangup(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - - tty_port_hangup(&port->port); -} - -static void fwtty_cleanup(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - - tty->driver_data = NULL; - fwtty_port_put(port); -} - -static int fwtty_install(struct tty_driver *driver, struct tty_struct *tty) -{ - struct fwtty_port *port = fwtty_port_get(tty->index); - int err; - - err = tty_standard_install(driver, tty); - if (!err) - tty->driver_data = port; - else - fwtty_port_put(port); - return err; -} - -static int fwloop_install(struct tty_driver *driver, struct tty_struct *tty) -{ - struct fwtty_port *port = fwtty_port_get(table_idx(tty->index)); - int err; - - err = tty_standard_install(driver, tty); - if (!err) - tty->driver_data = port; - else - fwtty_port_put(port); - return err; -} - -static int fwtty_write(struct tty_struct *tty, const unsigned char *buf, int c) -{ - struct fwtty_port *port = tty->driver_data; - int n, len; - - fwtty_dbg(port, "%d\n", c); - fwtty_profile_data(port->stats.writes, c); - - spin_lock_bh(&port->lock); - n = dma_fifo_in(&port->tx_fifo, buf, c); - len = dma_fifo_out_level(&port->tx_fifo); - if (len < DRAIN_THRESHOLD) - schedule_delayed_work(&port->drain, 1); - spin_unlock_bh(&port->lock); - - if (len >= DRAIN_THRESHOLD) - fwtty_tx(port, false); - - debug_short_write(port, c, n); - - return (n < 0) ? 0 : n; -} - -static unsigned int fwtty_write_room(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - unsigned int n; - - spin_lock_bh(&port->lock); - n = dma_fifo_avail(&port->tx_fifo); - spin_unlock_bh(&port->lock); - - fwtty_dbg(port, "%u\n", n); - - return n; -} - -static unsigned int fwtty_chars_in_buffer(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - unsigned int n; - - spin_lock_bh(&port->lock); - n = dma_fifo_level(&port->tx_fifo); - spin_unlock_bh(&port->lock); - - fwtty_dbg(port, "%u\n", n); - - return n; -} - -static void fwtty_send_xchar(struct tty_struct *tty, char ch) -{ - struct fwtty_port *port = tty->driver_data; - - fwtty_dbg(port, "%02x\n", ch); - - fwtty_write_xchar(port, ch); -} - -static void fwtty_throttle(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - - /* - * Ignore throttling (but not unthrottling). - * It only makes sense to throttle when data will no longer be - * accepted by the tty flip buffer. For example, it is - * possible for received data to overflow the tty buffer long - * before the line discipline ever has a chance to throttle the driver. - * Additionally, the driver may have already completed the I/O - * but the tty buffer is still emptying, so the line discipline is - * throttling and unthrottling nothing. - */ - - ++port->stats.throttled; -} - -static void fwtty_unthrottle(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - - fwtty_dbg(port, "CRTSCTS: %d\n", C_CRTSCTS(tty) != 0); - - fwtty_profile_fifo(port, port->stats.unthrottle); - - spin_lock_bh(&port->lock); - port->mctrl &= ~OOB_RX_THROTTLE; - if (C_CRTSCTS(tty)) - port->mctrl |= TIOCM_RTS; - __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); -} - -static int check_msr_delta(struct fwtty_port *port, unsigned long mask, - struct async_icount *prev) -{ - struct async_icount now; - int delta; - - now = port->icount; - - delta = ((mask & TIOCM_RNG && prev->rng != now.rng) || - (mask & TIOCM_DSR && prev->dsr != now.dsr) || - (mask & TIOCM_CAR && prev->dcd != now.dcd) || - (mask & TIOCM_CTS && prev->cts != now.cts)); - - *prev = now; - - return delta; -} - -static int wait_msr_change(struct fwtty_port *port, unsigned long mask) -{ - struct async_icount prev; - - prev = port->icount; - - return wait_event_interruptible(port->port.delta_msr_wait, - check_msr_delta(port, mask, &prev)); -} - -static int get_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct fwtty_port *port = tty->driver_data; - - mutex_lock(&port->port.mutex); - ss->line = port->index; - ss->baud_base = 400000000; - ss->close_delay = jiffies_to_msecs(port->port.close_delay) / 10; - ss->closing_wait = 3000; - mutex_unlock(&port->port.mutex); - - return 0; -} - -static int set_serial_info(struct tty_struct *tty, - struct serial_struct *ss) -{ - struct fwtty_port *port = tty->driver_data; - unsigned int cdelay; - - cdelay = msecs_to_jiffies(ss->close_delay * 10); - - mutex_lock(&port->port.mutex); - if (!capable(CAP_SYS_ADMIN)) { - if (cdelay != port->port.close_delay || - ((ss->flags & ~ASYNC_USR_MASK) != - (port->port.flags & ~ASYNC_USR_MASK))) { - mutex_unlock(&port->port.mutex); - return -EPERM; - } - } - port->port.close_delay = cdelay; - mutex_unlock(&port->port.mutex); - - return 0; -} - -static int fwtty_ioctl(struct tty_struct *tty, unsigned int cmd, - unsigned long arg) -{ - struct fwtty_port *port = tty->driver_data; - int err; - - switch (cmd) { - case TIOCMIWAIT: - err = wait_msr_change(port, arg); - break; - - default: - err = -ENOIOCTLCMD; - } - - return err; -} - -static void fwtty_set_termios(struct tty_struct *tty, - const struct ktermios *old) -{ - struct fwtty_port *port = tty->driver_data; - unsigned int baud; - - spin_lock_bh(&port->lock); - baud = set_termios(port, tty); - - if ((baud == 0) && (old->c_cflag & CBAUD)) { - port->mctrl &= ~(TIOCM_DTR | TIOCM_RTS); - } else if ((baud != 0) && !(old->c_cflag & CBAUD)) { - if (C_CRTSCTS(tty) || !tty_throttled(tty)) - port->mctrl |= TIOCM_DTR | TIOCM_RTS; - else - port->mctrl |= TIOCM_DTR; - } - __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); - - if (old->c_cflag & CRTSCTS) { - if (!C_CRTSCTS(tty)) { - tty->hw_stopped = 0; - fwtty_restart_tx(port); - } - } else if (C_CRTSCTS(tty) && ~port->mstatus & TIOCM_CTS) { - tty->hw_stopped = 1; - } -} - -/* - * fwtty_break_ctl - start/stop sending breaks - * - * Signals the remote to start or stop generating simulated breaks. - * First, stop dequeueing from the fifo and wait for writer/drain to leave tx - * before signalling the break line status. This guarantees any pending rx will - * be queued to the line discipline before break is simulated on the remote. - * Conversely, turning off break_ctl requires signalling the line status change, - * then enabling tx. - */ -static int fwtty_break_ctl(struct tty_struct *tty, int state) -{ - struct fwtty_port *port = tty->driver_data; - long ret; - - fwtty_dbg(port, "%d\n", state); - - if (state == -1) { - set_bit(STOP_TX, &port->flags); - ret = wait_event_interruptible_timeout(port->wait_tx, - !test_bit(IN_TX, &port->flags), - 10); - if (ret == 0 || ret == -ERESTARTSYS) { - clear_bit(STOP_TX, &port->flags); - fwtty_restart_tx(port); - return -EINTR; - } - } - - spin_lock_bh(&port->lock); - port->break_ctl = (state == -1); - __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); - - if (state == 0) { - spin_lock_bh(&port->lock); - dma_fifo_reset(&port->tx_fifo); - clear_bit(STOP_TX, &port->flags); - spin_unlock_bh(&port->lock); - } - return 0; -} - -static int fwtty_tiocmget(struct tty_struct *tty) -{ - struct fwtty_port *port = tty->driver_data; - unsigned int tiocm; - - spin_lock_bh(&port->lock); - tiocm = (port->mctrl & MCTRL_MASK) | (port->mstatus & ~MCTRL_MASK); - spin_unlock_bh(&port->lock); - - fwtty_dbg(port, "%x\n", tiocm); - - return tiocm; -} - -static int fwtty_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear) -{ - struct fwtty_port *port = tty->driver_data; - - fwtty_dbg(port, "set: %x clear: %x\n", set, clear); - - /* TODO: simulate loopback if TIOCM_LOOP set */ - - spin_lock_bh(&port->lock); - port->mctrl &= ~(clear & MCTRL_MASK & 0xffff); - port->mctrl |= set & MCTRL_MASK & 0xffff; - __fwtty_write_port_status(port); - spin_unlock_bh(&port->lock); - return 0; -} - -static int fwtty_get_icount(struct tty_struct *tty, - struct serial_icounter_struct *icount) -{ - struct fwtty_port *port = tty->driver_data; - struct stats stats; - - memcpy(&stats, &port->stats, sizeof(stats)); - if (port->port.console) - (*port->fwcon_ops->stats)(&stats, port->con_data); - - icount->cts = port->icount.cts; - icount->dsr = port->icount.dsr; - icount->rng = port->icount.rng; - icount->dcd = port->icount.dcd; - icount->rx = port->icount.rx; - icount->tx = port->icount.tx + stats.xchars; - icount->frame = port->icount.frame; - icount->overrun = port->icount.overrun; - icount->parity = port->icount.parity; - icount->brk = port->icount.brk; - icount->buf_overrun = port->icount.overrun; - return 0; -} - -static void fwtty_proc_show_port(struct seq_file *m, struct fwtty_port *port) -{ - struct stats stats; - - memcpy(&stats, &port->stats, sizeof(stats)); - if (port->port.console) - (*port->fwcon_ops->stats)(&stats, port->con_data); - - seq_printf(m, " addr:%012llx tx:%d rx:%d", port->rx_handler.offset, - port->icount.tx + stats.xchars, port->icount.rx); - seq_printf(m, " cts:%d dsr:%d rng:%d dcd:%d", port->icount.cts, - port->icount.dsr, port->icount.rng, port->icount.dcd); - seq_printf(m, " fe:%d oe:%d pe:%d brk:%d", port->icount.frame, - port->icount.overrun, port->icount.parity, port->icount.brk); -} - -static void fwtty_debugfs_show_port(struct seq_file *m, struct fwtty_port *port) -{ - struct stats stats; - - memcpy(&stats, &port->stats, sizeof(stats)); - if (port->port.console) - (*port->fwcon_ops->stats)(&stats, port->con_data); - - seq_printf(m, " dr:%d st:%d err:%d lost:%d", stats.dropped, - stats.tx_stall, stats.fifo_errs, stats.lost); - seq_printf(m, " pkts:%d thr:%d", stats.sent, stats.throttled); - - if (port->port.console) { - seq_puts(m, "\n "); - (*port->fwcon_ops->proc_show)(m, port->con_data); - } - - fwtty_dump_profile(m, &port->stats); -} - -static void fwtty_debugfs_show_peer(struct seq_file *m, struct fwtty_peer *peer) -{ - int generation = peer->generation; - - smp_rmb(); - seq_printf(m, " %s:", dev_name(&peer->unit->device)); - seq_printf(m, " node:%04x gen:%d", peer->node_id, generation); - seq_printf(m, " sp:%d max:%d guid:%016llx", peer->speed, - peer->max_payload, (unsigned long long)peer->guid); - seq_printf(m, " mgmt:%012llx", (unsigned long long)peer->mgmt_addr); - seq_printf(m, " addr:%012llx", (unsigned long long)peer->status_addr); - seq_putc(m, '\n'); -} - -static int fwtty_proc_show(struct seq_file *m, void *v) -{ - struct fwtty_port *port; - int i; - - seq_puts(m, "fwserinfo: 1.0 driver: 1.0\n"); - for (i = 0; i < MAX_TOTAL_PORTS && (port = fwtty_port_get(i)); ++i) { - seq_printf(m, "%2d:", i); - if (capable(CAP_SYS_ADMIN)) - fwtty_proc_show_port(m, port); - fwtty_port_put(port); - seq_puts(m, "\n"); - } - return 0; -} - -static int fwtty_stats_show(struct seq_file *m, void *v) -{ - struct fw_serial *serial = m->private; - struct fwtty_port *port; - int i; - - for (i = 0; i < num_ports; ++i) { - port = fwtty_port_get(serial->ports[i]->index); - if (port) { - seq_printf(m, "%2d:", port->index); - fwtty_proc_show_port(m, port); - fwtty_debugfs_show_port(m, port); - fwtty_port_put(port); - seq_puts(m, "\n"); - } - } - return 0; -} -DEFINE_SHOW_ATTRIBUTE(fwtty_stats); - -static int fwtty_peers_show(struct seq_file *m, void *v) -{ - struct fw_serial *serial = m->private; - struct fwtty_peer *peer; - - rcu_read_lock(); - seq_printf(m, "card: %s guid: %016llx\n", - dev_name(serial->card->device), - (unsigned long long)serial->card->guid); - list_for_each_entry_rcu(peer, &serial->peer_list, list) - fwtty_debugfs_show_peer(m, peer); - rcu_read_unlock(); - return 0; -} -DEFINE_SHOW_ATTRIBUTE(fwtty_peers); - -static const struct tty_port_operations fwtty_port_ops = { - .dtr_rts = fwtty_port_dtr_rts, - .carrier_raised = fwtty_port_carrier_raised, - .shutdown = fwtty_port_shutdown, - .activate = fwtty_port_activate, -}; - -static const struct tty_operations fwtty_ops = { - .open = fwtty_open, - .close = fwtty_close, - .hangup = fwtty_hangup, - .cleanup = fwtty_cleanup, - .install = fwtty_install, - .write = fwtty_write, - .write_room = fwtty_write_room, - .chars_in_buffer = fwtty_chars_in_buffer, - .send_xchar = fwtty_send_xchar, - .throttle = fwtty_throttle, - .unthrottle = fwtty_unthrottle, - .ioctl = fwtty_ioctl, - .set_termios = fwtty_set_termios, - .break_ctl = fwtty_break_ctl, - .tiocmget = fwtty_tiocmget, - .tiocmset = fwtty_tiocmset, - .get_icount = fwtty_get_icount, - .set_serial = set_serial_info, - .get_serial = get_serial_info, - .proc_show = fwtty_proc_show, -}; - -static const struct tty_operations fwloop_ops = { - .open = fwtty_open, - .close = fwtty_close, - .hangup = fwtty_hangup, - .cleanup = fwtty_cleanup, - .install = fwloop_install, - .write = fwtty_write, - .write_room = fwtty_write_room, - .chars_in_buffer = fwtty_chars_in_buffer, - .send_xchar = fwtty_send_xchar, - .throttle = fwtty_throttle, - .unthrottle = fwtty_unthrottle, - .ioctl = fwtty_ioctl, - .set_termios = fwtty_set_termios, - .break_ctl = fwtty_break_ctl, - .tiocmget = fwtty_tiocmget, - .tiocmset = fwtty_tiocmset, - .get_icount = fwtty_get_icount, - .set_serial = set_serial_info, - .get_serial = get_serial_info, -}; - -static inline int mgmt_pkt_expected_len(__be16 code) -{ - static const struct fwserial_mgmt_pkt pkt; - - switch (be16_to_cpu(code)) { - case FWSC_VIRT_CABLE_PLUG: - return sizeof(pkt.hdr) + sizeof(pkt.plug_req); - - case FWSC_VIRT_CABLE_PLUG_RSP: /* | FWSC_RSP_OK */ - return sizeof(pkt.hdr) + sizeof(pkt.plug_rsp); - - case FWSC_VIRT_CABLE_UNPLUG: - case FWSC_VIRT_CABLE_UNPLUG_RSP: - case FWSC_VIRT_CABLE_PLUG_RSP | FWSC_RSP_NACK: - case FWSC_VIRT_CABLE_UNPLUG_RSP | FWSC_RSP_NACK: - return sizeof(pkt.hdr); - - default: - return -1; - } -} - -static inline void fill_plug_params(struct virt_plug_params *params, - struct fwtty_port *port) -{ - u64 status_addr = port->rx_handler.offset; - u64 fifo_addr = port->rx_handler.offset + 4; - size_t fifo_len = port->rx_handler.length - 4; - - params->status_hi = cpu_to_be32(status_addr >> 32); - params->status_lo = cpu_to_be32(status_addr); - params->fifo_hi = cpu_to_be32(fifo_addr >> 32); - params->fifo_lo = cpu_to_be32(fifo_addr); - params->fifo_len = cpu_to_be32(fifo_len); -} - -static inline void fill_plug_req(struct fwserial_mgmt_pkt *pkt, - struct fwtty_port *port) -{ - pkt->hdr.code = cpu_to_be16(FWSC_VIRT_CABLE_PLUG); - pkt->hdr.len = cpu_to_be16(mgmt_pkt_expected_len(pkt->hdr.code)); - fill_plug_params(&pkt->plug_req, port); -} - -static inline void fill_plug_rsp_ok(struct fwserial_mgmt_pkt *pkt, - struct fwtty_port *port) -{ - pkt->hdr.code = cpu_to_be16(FWSC_VIRT_CABLE_PLUG_RSP); - pkt->hdr.len = cpu_to_be16(mgmt_pkt_expected_len(pkt->hdr.code)); - fill_plug_params(&pkt->plug_rsp, port); -} - -static inline void fill_plug_rsp_nack(struct fwserial_mgmt_pkt *pkt) -{ - pkt->hdr.code = cpu_to_be16(FWSC_VIRT_CABLE_PLUG_RSP | FWSC_RSP_NACK); - pkt->hdr.len = cpu_to_be16(mgmt_pkt_expected_len(pkt->hdr.code)); -} - -static inline void fill_unplug_rsp_nack(struct fwserial_mgmt_pkt *pkt) -{ - pkt->hdr.code = cpu_to_be16(FWSC_VIRT_CABLE_UNPLUG_RSP | FWSC_RSP_NACK); - pkt->hdr.len = cpu_to_be16(mgmt_pkt_expected_len(pkt->hdr.code)); -} - -static inline void fill_unplug_rsp_ok(struct fwserial_mgmt_pkt *pkt) -{ - pkt->hdr.code = cpu_to_be16(FWSC_VIRT_CABLE_UNPLUG_RSP); - pkt->hdr.len = cpu_to_be16(mgmt_pkt_expected_len(pkt->hdr.code)); -} - -static void fwserial_virt_plug_complete(struct fwtty_peer *peer, - struct virt_plug_params *params) -{ - struct fwtty_port *port = peer->port; - - peer->status_addr = be32_to_u64(params->status_hi, params->status_lo); - peer->fifo_addr = be32_to_u64(params->fifo_hi, params->fifo_lo); - peer->fifo_len = be32_to_cpu(params->fifo_len); - peer_set_state(peer, FWPS_ATTACHED); - - /* reconfigure tx_fifo optimally for this peer */ - spin_lock_bh(&port->lock); - port->max_payload = min(peer->max_payload, peer->fifo_len); - dma_fifo_change_tx_limit(&port->tx_fifo, port->max_payload); - spin_unlock_bh(&peer->port->lock); - - if (port->port.console && port->fwcon_ops->notify) - (*port->fwcon_ops->notify)(FWCON_NOTIFY_ATTACH, port->con_data); - - fwtty_info(&peer->unit, "peer (guid:%016llx) connected on %s\n", - (unsigned long long)peer->guid, dev_name(port->device)); -} - -static inline int fwserial_send_mgmt_sync(struct fwtty_peer *peer, - struct fwserial_mgmt_pkt *pkt) -{ - int generation; - int rcode, tries = 5; - - do { - generation = peer->generation; - smp_rmb(); - - rcode = fw_run_transaction(peer->serial->card, - TCODE_WRITE_BLOCK_REQUEST, - peer->node_id, - generation, peer->speed, - peer->mgmt_addr, - pkt, be16_to_cpu(pkt->hdr.len)); - if (rcode == RCODE_BUSY || rcode == RCODE_SEND_ERROR || - rcode == RCODE_GENERATION) { - fwtty_dbg(&peer->unit, "mgmt write error: %d\n", rcode); - continue; - } else { - break; - } - } while (--tries > 0); - return rcode; -} - -/* - * fwserial_claim_port - attempt to claim port @ index for peer - * - * Returns ptr to claimed port or error code (as ERR_PTR()) - * Can sleep - must be called from process context - */ -static struct fwtty_port *fwserial_claim_port(struct fwtty_peer *peer, - int index) -{ - struct fwtty_port *port; - - if (index < 0 || index >= num_ports) - return ERR_PTR(-EINVAL); - - /* must guarantee that previous port releases have completed */ - synchronize_rcu(); - - port = peer->serial->ports[index]; - spin_lock_bh(&port->lock); - if (!rcu_access_pointer(port->peer)) - rcu_assign_pointer(port->peer, peer); - else - port = ERR_PTR(-EBUSY); - spin_unlock_bh(&port->lock); - - return port; -} - -/* - * fwserial_find_port - find avail port and claim for peer - * - * Returns ptr to claimed port or NULL if none avail - * Can sleep - must be called from process context - */ -static struct fwtty_port *fwserial_find_port(struct fwtty_peer *peer) -{ - struct fwtty_port **ports = peer->serial->ports; - int i; - - /* must guarantee that previous port releases have completed */ - synchronize_rcu(); - - /* TODO: implement optional GUID-to-specific port # matching */ - - /* find an unattached port (but not the loopback port, if present) */ - for (i = 0; i < num_ttys; ++i) { - spin_lock_bh(&ports[i]->lock); - if (!ports[i]->peer) { - /* claim port */ - rcu_assign_pointer(ports[i]->peer, peer); - spin_unlock_bh(&ports[i]->lock); - return ports[i]; - } - spin_unlock_bh(&ports[i]->lock); - } - return NULL; -} - -static void fwserial_release_port(struct fwtty_port *port, bool reset) -{ - /* drop carrier (and all other line status) */ - if (reset) - fwtty_update_port_status(port, 0); - - spin_lock_bh(&port->lock); - - /* reset dma fifo max transmission size back to S100 */ - port->max_payload = link_speed_to_max_payload(SCODE_100); - dma_fifo_change_tx_limit(&port->tx_fifo, port->max_payload); - - RCU_INIT_POINTER(port->peer, NULL); - spin_unlock_bh(&port->lock); - - if (port->port.console && port->fwcon_ops->notify) - (*port->fwcon_ops->notify)(FWCON_NOTIFY_DETACH, port->con_data); -} - -static void fwserial_plug_timeout(struct timer_list *t) -{ - struct fwtty_peer *peer = from_timer(peer, t, timer); - struct fwtty_port *port; - - spin_lock_bh(&peer->lock); - if (peer->state != FWPS_PLUG_PENDING) { - spin_unlock_bh(&peer->lock); - return; - } - - port = peer_revert_state(peer); - spin_unlock_bh(&peer->lock); - - if (port) - fwserial_release_port(port, false); -} - -/* - * fwserial_connect_peer - initiate virtual cable with peer - * - * Returns 0 if VIRT_CABLE_PLUG request was successfully sent, - * otherwise error code. Must be called from process context. - */ -static int fwserial_connect_peer(struct fwtty_peer *peer) -{ - struct fwtty_port *port; - struct fwserial_mgmt_pkt *pkt; - int err, rcode; - - pkt = kmalloc(sizeof(*pkt), GFP_KERNEL); - if (!pkt) - return -ENOMEM; - - port = fwserial_find_port(peer); - if (!port) { - fwtty_err(&peer->unit, "avail ports in use\n"); - err = -EBUSY; - goto free_pkt; - } - - spin_lock_bh(&peer->lock); - - /* only initiate VIRT_CABLE_PLUG if peer is currently not attached */ - if (peer->state != FWPS_NOT_ATTACHED) { - err = -EBUSY; - goto release_port; - } - - peer->port = port; - peer_set_state(peer, FWPS_PLUG_PENDING); - - fill_plug_req(pkt, peer->port); - - mod_timer(&peer->timer, jiffies + VIRT_CABLE_PLUG_TIMEOUT); - spin_unlock_bh(&peer->lock); - - rcode = fwserial_send_mgmt_sync(peer, pkt); - - spin_lock_bh(&peer->lock); - if (peer->state == FWPS_PLUG_PENDING && rcode != RCODE_COMPLETE) { - if (rcode == RCODE_CONFLICT_ERROR) - err = -EAGAIN; - else - err = -EIO; - goto cancel_timer; - } - spin_unlock_bh(&peer->lock); - - kfree(pkt); - return 0; - -cancel_timer: - del_timer(&peer->timer); - peer_revert_state(peer); -release_port: - spin_unlock_bh(&peer->lock); - fwserial_release_port(port, false); -free_pkt: - kfree(pkt); - return err; -} - -/* - * fwserial_close_port - - * HUP the tty (if the tty exists) and unregister the tty device. - * Only used by the unit driver upon unit removal to disconnect and - * cleanup all attached ports - * - * The port reference is put by fwtty_cleanup (if a reference was - * ever taken). - */ -static void fwserial_close_port(struct tty_driver *driver, - struct fwtty_port *port) -{ - struct tty_struct *tty; - - mutex_lock(&port->port.mutex); - tty = tty_port_tty_get(&port->port); - if (tty) { - tty_vhangup(tty); - tty_kref_put(tty); - } - mutex_unlock(&port->port.mutex); - - if (driver == fwloop_driver) - tty_unregister_device(driver, loop_idx(port)); - else - tty_unregister_device(driver, port->index); -} - -/** - * fwserial_lookup - finds first fw_serial associated with card - * @card: fw_card to match - * - * NB: caller must be holding fwserial_list_mutex - */ -static struct fw_serial *fwserial_lookup(struct fw_card *card) -{ - struct fw_serial *serial; - - list_for_each_entry(serial, &fwserial_list, list) { - if (card == serial->card) - return serial; - } - - return NULL; -} - -/** - * __fwserial_lookup_rcu - finds first fw_serial associated with card - * @card: fw_card to match - * - * NB: caller must be inside rcu_read_lock() section - */ -static struct fw_serial *__fwserial_lookup_rcu(struct fw_card *card) -{ - struct fw_serial *serial; - - list_for_each_entry_rcu(serial, &fwserial_list, list) { - if (card == serial->card) - return serial; - } - - return NULL; -} - -/* - * __fwserial_peer_by_node_id - finds a peer matching the given generation + id - * - * If a matching peer could not be found for the specified generation/node id, - * this could be because: - * a) the generation has changed and one of the nodes hasn't updated yet - * b) the remote node has created its remote unit device before this - * local node has created its corresponding remote unit device - * In either case, the remote node should retry - * - * Note: caller must be in rcu_read_lock() section - */ -static struct fwtty_peer *__fwserial_peer_by_node_id(struct fw_card *card, - int generation, int id) -{ - struct fw_serial *serial; - struct fwtty_peer *peer; - - serial = __fwserial_lookup_rcu(card); - if (!serial) { - /* - * Something is very wrong - there should be a matching - * fw_serial structure for every fw_card. Maybe the remote node - * has created its remote unit device before this driver has - * been probed for any unit devices... - */ - fwtty_err(card, "unknown card (guid %016llx)\n", - (unsigned long long)card->guid); - return NULL; - } - - list_for_each_entry_rcu(peer, &serial->peer_list, list) { - int g = peer->generation; - - smp_rmb(); - if (generation == g && id == peer->node_id) - return peer; - } - - return NULL; -} - -#ifdef DEBUG -static void __dump_peer_list(struct fw_card *card) -{ - struct fw_serial *serial; - struct fwtty_peer *peer; - - serial = __fwserial_lookup_rcu(card); - if (!serial) - return; - - list_for_each_entry_rcu(peer, &serial->peer_list, list) { - int g = peer->generation; - - smp_rmb(); - fwtty_dbg(card, "peer(%d:%x) guid: %016llx\n", - g, peer->node_id, (unsigned long long)peer->guid); - } -} -#else -#define __dump_peer_list(s) -#endif - -static void fwserial_auto_connect(struct work_struct *work) -{ - struct fwtty_peer *peer = to_peer(to_delayed_work(work), connect); - int err; - - err = fwserial_connect_peer(peer); - if (err == -EAGAIN && ++peer->connect_retries < MAX_CONNECT_RETRIES) - schedule_delayed_work(&peer->connect, CONNECT_RETRY_DELAY); -} - -static void fwserial_peer_workfn(struct work_struct *work) -{ - struct fwtty_peer *peer = to_peer(work, work); - - peer->workfn(work); -} - -/** - * fwserial_add_peer - add a newly probed 'serial' unit device as a 'peer' - * @serial: aggregate representing the specific fw_card to add the peer to - * @unit: 'peer' to create and add to peer_list of serial - * - * Adds a 'peer' (ie, a local or remote 'serial' unit device) to the list of - * peers for a specific fw_card. Optionally, auto-attach this peer to an - * available tty port. This function is called either directly or indirectly - * as a result of a 'serial' unit device being created & probed. - * - * Note: this function is serialized with fwserial_remove_peer() by the - * fwserial_list_mutex held in fwserial_probe(). - * - * A 1:1 correspondence between an fw_unit and an fwtty_peer is maintained - * via the dev_set_drvdata() for the device of the fw_unit. - */ -static int fwserial_add_peer(struct fw_serial *serial, struct fw_unit *unit) -{ - struct device *dev = &unit->device; - struct fw_device *parent = fw_parent_device(unit); - struct fwtty_peer *peer; - struct fw_csr_iterator ci; - int key, val; - int generation; - - peer = kzalloc(sizeof(*peer), GFP_KERNEL); - if (!peer) - return -ENOMEM; - - peer_set_state(peer, FWPS_NOT_ATTACHED); - - dev_set_drvdata(dev, peer); - peer->unit = unit; - peer->guid = (u64)parent->config_rom[3] << 32 | parent->config_rom[4]; - peer->speed = parent->max_speed; - peer->max_payload = min(device_max_receive(parent), - link_speed_to_max_payload(peer->speed)); - - generation = parent->generation; - smp_rmb(); - peer->node_id = parent->node_id; - smp_wmb(); - peer->generation = generation; - - /* retrieve the mgmt bus addr from the unit directory */ - fw_csr_iterator_init(&ci, unit->directory); - while (fw_csr_iterator_next(&ci, &key, &val)) { - if (key == (CSR_OFFSET | CSR_DEPENDENT_INFO)) { - peer->mgmt_addr = CSR_REGISTER_BASE + 4 * val; - break; - } - } - if (peer->mgmt_addr == 0ULL) { - /* - * No mgmt address effectively disables VIRT_CABLE_PLUG - - * this peer will not be able to attach to a remote - */ - peer_set_state(peer, FWPS_NO_MGMT_ADDR); - } - - spin_lock_init(&peer->lock); - peer->port = NULL; - - timer_setup(&peer->timer, fwserial_plug_timeout, 0); - INIT_WORK(&peer->work, fwserial_peer_workfn); - INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect); - - /* associate peer with specific fw_card */ - peer->serial = serial; - list_add_rcu(&peer->list, &serial->peer_list); - - fwtty_info(&peer->unit, "peer added (guid:%016llx)\n", - (unsigned long long)peer->guid); - - /* identify the local unit & virt cable to loopback port */ - if (parent->is_local) { - serial->self = peer; - if (create_loop_dev) { - struct fwtty_port *port; - - port = fwserial_claim_port(peer, num_ttys); - if (!IS_ERR(port)) { - struct virt_plug_params params; - - spin_lock_bh(&peer->lock); - peer->port = port; - fill_plug_params(¶ms, port); - fwserial_virt_plug_complete(peer, ¶ms); - spin_unlock_bh(&peer->lock); - - fwtty_write_port_status(port); - } - } - - } else if (auto_connect) { - /* auto-attach to remote units only (if policy allows) */ - schedule_delayed_work(&peer->connect, 1); - } - - return 0; -} - -/* - * fwserial_remove_peer - remove a 'serial' unit device as a 'peer' - * - * Remove a 'peer' from its list of peers. This function is only - * called by fwserial_remove() on bus removal of the unit device. - * - * Note: this function is serialized with fwserial_add_peer() by the - * fwserial_list_mutex held in fwserial_remove(). - */ -static void fwserial_remove_peer(struct fwtty_peer *peer) -{ - struct fwtty_port *port; - - spin_lock_bh(&peer->lock); - peer_set_state(peer, FWPS_GONE); - spin_unlock_bh(&peer->lock); - - cancel_delayed_work_sync(&peer->connect); - cancel_work_sync(&peer->work); - - spin_lock_bh(&peer->lock); - /* if this unit is the local unit, clear link */ - if (peer == peer->serial->self) - peer->serial->self = NULL; - - /* cancel the request timeout timer (if running) */ - del_timer(&peer->timer); - - port = peer->port; - peer->port = NULL; - - list_del_rcu(&peer->list); - - fwtty_info(&peer->unit, "peer removed (guid:%016llx)\n", - (unsigned long long)peer->guid); - - spin_unlock_bh(&peer->lock); - - if (port) - fwserial_release_port(port, true); - - synchronize_rcu(); - kfree(peer); -} - -/** - * fwserial_create - init everything to create TTYs for a specific fw_card - * @unit: fw_unit for first 'serial' unit device probed for this fw_card - * - * This function inits the aggregate structure (an fw_serial instance) - * used to manage the TTY ports registered by a specific fw_card. Also, the - * unit device is added as the first 'peer'. - * - * This unit device may represent a local unit device (as specified by the - * config ROM unit directory) or it may represent a remote unit device - * (as specified by the reading of the remote node's config ROM). - * - * Returns 0 to indicate "ownership" of the unit device, or a negative errno - * value to indicate which error. - */ -static int fwserial_create(struct fw_unit *unit) -{ - struct fw_device *parent = fw_parent_device(unit); - struct fw_card *card = parent->card; - struct fw_serial *serial; - struct fwtty_port *port; - struct device *tty_dev; - int i, j; - int err; - - serial = kzalloc(sizeof(*serial), GFP_KERNEL); - if (!serial) - return -ENOMEM; - - kref_init(&serial->kref); - serial->card = card; - INIT_LIST_HEAD(&serial->peer_list); - - for (i = 0; i < num_ports; ++i) { - port = kzalloc(sizeof(*port), GFP_KERNEL); - if (!port) { - err = -ENOMEM; - goto free_ports; - } - tty_port_init(&port->port); - port->index = FWTTY_INVALID_INDEX; - port->port.ops = &fwtty_port_ops; - port->serial = serial; - tty_buffer_set_limit(&port->port, 128 * 1024); - - spin_lock_init(&port->lock); - INIT_DELAYED_WORK(&port->drain, fwtty_drain_tx); - INIT_DELAYED_WORK(&port->emit_breaks, fwtty_emit_breaks); - INIT_WORK(&port->hangup, fwtty_do_hangup); - init_waitqueue_head(&port->wait_tx); - port->max_payload = link_speed_to_max_payload(SCODE_100); - dma_fifo_init(&port->tx_fifo); - - RCU_INIT_POINTER(port->peer, NULL); - serial->ports[i] = port; - - /* get unique bus addr region for port's status & recv fifo */ - port->rx_handler.length = FWTTY_PORT_RXFIFO_LEN + 4; - port->rx_handler.address_callback = fwtty_port_handler; - port->rx_handler.callback_data = port; - /* - * XXX: use custom memory region above cpu physical memory addrs - * this will ease porting to 64-bit firewire adapters - */ - err = fw_core_add_address_handler(&port->rx_handler, - &fw_high_memory_region); - if (err) { - tty_port_destroy(&port->port); - kfree(port); - goto free_ports; - } - } - /* preserve i for error cleanup */ - - err = fwtty_ports_add(serial); - if (err) { - fwtty_err(&unit, "no space in port table\n"); - goto free_ports; - } - - for (j = 0; j < num_ttys; ++j) { - tty_dev = tty_port_register_device(&serial->ports[j]->port, - fwtty_driver, - serial->ports[j]->index, - card->device); - if (IS_ERR(tty_dev)) { - err = PTR_ERR(tty_dev); - fwtty_err(&unit, "register tty device error (%d)\n", - err); - goto unregister_ttys; - } - - serial->ports[j]->device = tty_dev; - } - /* preserve j for error cleanup */ - - if (create_loop_dev) { - struct device *loop_dev; - - loop_dev = tty_port_register_device(&serial->ports[j]->port, - fwloop_driver, - loop_idx(serial->ports[j]), - card->device); - if (IS_ERR(loop_dev)) { - err = PTR_ERR(loop_dev); - fwtty_err(&unit, "create loop device failed (%d)\n", - err); - goto unregister_ttys; - } - serial->ports[j]->device = loop_dev; - serial->ports[j]->loopback = true; - } - - if (!IS_ERR_OR_NULL(fwserial_debugfs)) { - serial->debugfs = debugfs_create_dir(dev_name(&unit->device), - fwserial_debugfs); - if (!IS_ERR_OR_NULL(serial->debugfs)) { - debugfs_create_file("peers", 0444, serial->debugfs, - serial, &fwtty_peers_fops); - debugfs_create_file("stats", 0444, serial->debugfs, - serial, &fwtty_stats_fops); - } - } - - list_add_rcu(&serial->list, &fwserial_list); - - fwtty_notice(&unit, "TTY over FireWire on device %s (guid %016llx)\n", - dev_name(card->device), (unsigned long long)card->guid); - - err = fwserial_add_peer(serial, unit); - if (!err) - return 0; - - fwtty_err(&unit, "unable to add peer unit device (%d)\n", err); - - /* fall-through to error processing */ - debugfs_remove_recursive(serial->debugfs); - - list_del_rcu(&serial->list); - if (create_loop_dev) - tty_unregister_device(fwloop_driver, - loop_idx(serial->ports[j])); -unregister_ttys: - for (--j; j >= 0; --j) - tty_unregister_device(fwtty_driver, serial->ports[j]->index); - kref_put(&serial->kref, fwserial_destroy); - return err; - -free_ports: - for (--i; i >= 0; --i) { - fw_core_remove_address_handler(&serial->ports[i]->rx_handler); - tty_port_destroy(&serial->ports[i]->port); - kfree(serial->ports[i]); - } - kfree(serial); - return err; -} - -/* - * fwserial_probe: bus probe function for firewire 'serial' unit devices - * - * A 'serial' unit device is created and probed as a result of: - * - declaring a ieee1394 bus id table for 'devices' matching a fabricated - * 'serial' unit specifier id - * - adding a unit directory to the config ROM(s) for a 'serial' unit - * - * The firewire core registers unit devices by enumerating unit directories - * of a node's config ROM after reading the config ROM when a new node is - * added to the bus topology after a bus reset. - * - * The practical implications of this are: - * - this probe is called for both local and remote nodes that have a 'serial' - * unit directory in their config ROM (that matches the specifiers in - * fwserial_id_table). - * - no specific order is enforced for local vs. remote unit devices - * - * This unit driver copes with the lack of specific order in the same way the - * firewire net driver does -- each probe, for either a local or remote unit - * device, is treated as a 'peer' (has a struct fwtty_peer instance) and the - * first peer created for a given fw_card (tracked by the global fwserial_list) - * creates the underlying TTYs (aggregated in a fw_serial instance). - * - * NB: an early attempt to differentiate local & remote unit devices by creating - * peers only for remote units and fw_serial instances (with their - * associated TTY devices) only for local units was discarded. Managing - * the peer lifetimes on device removal proved too complicated. - * - * fwserial_probe/fwserial_remove are effectively serialized by the - * fwserial_list_mutex. This is necessary because the addition of the first peer - * for a given fw_card will trigger the creation of the fw_serial for that - * fw_card, which must not simultaneously contend with the removal of the - * last peer for a given fw_card triggering the destruction of the same - * fw_serial for the same fw_card. - */ -static int fwserial_probe(struct fw_unit *unit, - const struct ieee1394_device_id *id) -{ - struct fw_serial *serial; - int err; - - mutex_lock(&fwserial_list_mutex); - serial = fwserial_lookup(fw_parent_device(unit)->card); - if (!serial) - err = fwserial_create(unit); - else - err = fwserial_add_peer(serial, unit); - mutex_unlock(&fwserial_list_mutex); - return err; -} - -/* - * fwserial_remove: bus removal function for firewire 'serial' unit devices - * - * The corresponding 'peer' for this unit device is removed from the list of - * peers for the associated fw_serial (which has a 1:1 correspondence with a - * specific fw_card). If this is the last peer being removed, then trigger - * the destruction of the underlying TTYs. - */ -static void fwserial_remove(struct fw_unit *unit) -{ - struct fwtty_peer *peer = dev_get_drvdata(&unit->device); - struct fw_serial *serial = peer->serial; - int i; - - mutex_lock(&fwserial_list_mutex); - fwserial_remove_peer(peer); - - if (list_empty(&serial->peer_list)) { - /* unlink from the fwserial_list here */ - list_del_rcu(&serial->list); - - debugfs_remove_recursive(serial->debugfs); - - for (i = 0; i < num_ttys; ++i) - fwserial_close_port(fwtty_driver, serial->ports[i]); - if (create_loop_dev) - fwserial_close_port(fwloop_driver, serial->ports[i]); - kref_put(&serial->kref, fwserial_destroy); - } - mutex_unlock(&fwserial_list_mutex); -} - -/* - * fwserial_update: bus update function for 'firewire' serial unit devices - * - * Updates the new node_id and bus generation for this peer. Note that locking - * is unnecessary; but careful memory barrier usage is important to enforce the - * load and store order of generation & node_id. - * - * The fw-core orders the write of node_id before generation in the parent - * fw_device to ensure that a stale node_id cannot be used with a current - * bus generation. So the generation value must be read before the node_id. - * - * In turn, this orders the write of node_id before generation in the peer to - * also ensure a stale node_id cannot be used with a current bus generation. - */ -static void fwserial_update(struct fw_unit *unit) -{ - struct fw_device *parent = fw_parent_device(unit); - struct fwtty_peer *peer = dev_get_drvdata(&unit->device); - int generation; - - generation = parent->generation; - smp_rmb(); - peer->node_id = parent->node_id; - smp_wmb(); - peer->generation = generation; -} - -static const struct ieee1394_device_id fwserial_id_table[] = { - { - .match_flags = IEEE1394_MATCH_SPECIFIER_ID | - IEEE1394_MATCH_VERSION, - .specifier_id = LINUX_VENDOR_ID, - .version = FWSERIAL_VERSION, - }, - { } -}; - -static struct fw_driver fwserial_driver = { - .driver = { - .owner = THIS_MODULE, - .name = KBUILD_MODNAME, - .bus = &fw_bus_type, - }, - .probe = fwserial_probe, - .update = fwserial_update, - .remove = fwserial_remove, - .id_table = fwserial_id_table, -}; - -#define FW_UNIT_SPECIFIER(id) ((CSR_SPECIFIER_ID << 24) | (id)) -#define FW_UNIT_VERSION(ver) ((CSR_VERSION << 24) | (ver)) -#define FW_UNIT_ADDRESS(ofs) (((CSR_OFFSET | CSR_DEPENDENT_INFO) << 24) \ - | (((ofs) - CSR_REGISTER_BASE) >> 2)) -/* XXX: config ROM definitons could be improved with semi-automated offset - * and length calculation - */ -#define FW_ROM_LEN(quads) ((quads) << 16) -#define FW_ROM_DESCRIPTOR(ofs) (((CSR_LEAF | CSR_DESCRIPTOR) << 24) | (ofs)) - -struct fwserial_unit_directory_data { - u32 len_crc; - u32 unit_specifier; - u32 unit_sw_version; - u32 unit_addr_offset; - u32 desc1_ofs; - u32 desc1_len_crc; - u32 desc1_data[5]; -} __packed; - -static struct fwserial_unit_directory_data fwserial_unit_directory_data = { - .len_crc = FW_ROM_LEN(4), - .unit_specifier = FW_UNIT_SPECIFIER(LINUX_VENDOR_ID), - .unit_sw_version = FW_UNIT_VERSION(FWSERIAL_VERSION), - .desc1_ofs = FW_ROM_DESCRIPTOR(1), - .desc1_len_crc = FW_ROM_LEN(5), - .desc1_data = { - 0x00000000, /* type = text */ - 0x00000000, /* enc = ASCII, lang EN */ - 0x4c696e75, /* 'Linux TTY' */ - 0x78205454, - 0x59000000, - }, -}; - -static struct fw_descriptor fwserial_unit_directory = { - .length = sizeof(fwserial_unit_directory_data) / sizeof(u32), - .key = (CSR_DIRECTORY | CSR_UNIT) << 24, - .data = (u32 *)&fwserial_unit_directory_data, -}; - -/* - * The management address is in the unit space region but above other known - * address users (to keep wild writes from causing havoc) - */ -static const struct fw_address_region fwserial_mgmt_addr_region = { - .start = CSR_REGISTER_BASE + 0x1e0000ULL, - .end = 0x1000000000000ULL, -}; - -static struct fw_address_handler fwserial_mgmt_addr_handler; - -/** - * fwserial_handle_plug_req - handle VIRT_CABLE_PLUG request work - * @work: ptr to peer->work - * - * Attempts to complete the VIRT_CABLE_PLUG handshake sequence for this peer. - * - * This checks for a collided request-- ie, that a VIRT_CABLE_PLUG request was - * already sent to this peer. If so, the collision is resolved by comparing - * guid values; the loser sends the plug response. - * - * Note: if an error prevents a response, don't do anything -- the - * remote will timeout its request. - */ -static void fwserial_handle_plug_req(struct work_struct *work) -{ - struct fwtty_peer *peer = to_peer(work, work); - struct virt_plug_params *plug_req = &peer->work_params.plug_req; - struct fwtty_port *port; - struct fwserial_mgmt_pkt *pkt; - int rcode; - - pkt = kmalloc(sizeof(*pkt), GFP_KERNEL); - if (!pkt) - return; - - port = fwserial_find_port(peer); - - spin_lock_bh(&peer->lock); - - switch (peer->state) { - case FWPS_NOT_ATTACHED: - if (!port) { - fwtty_err(&peer->unit, "no more ports avail\n"); - fill_plug_rsp_nack(pkt); - } else { - peer->port = port; - fill_plug_rsp_ok(pkt, peer->port); - peer_set_state(peer, FWPS_PLUG_RESPONDING); - /* don't release claimed port */ - port = NULL; - } - break; - - case FWPS_PLUG_PENDING: - if (peer->serial->card->guid > peer->guid) - goto cleanup; - - /* We lost - hijack the already-claimed port and send ok */ - del_timer(&peer->timer); - fill_plug_rsp_ok(pkt, peer->port); - peer_set_state(peer, FWPS_PLUG_RESPONDING); - break; - - default: - fill_plug_rsp_nack(pkt); - } - - spin_unlock_bh(&peer->lock); - if (port) - fwserial_release_port(port, false); - - rcode = fwserial_send_mgmt_sync(peer, pkt); - - spin_lock_bh(&peer->lock); - if (peer->state == FWPS_PLUG_RESPONDING) { - if (rcode == RCODE_COMPLETE) { - struct fwtty_port *tmp = peer->port; - - fwserial_virt_plug_complete(peer, plug_req); - spin_unlock_bh(&peer->lock); - - fwtty_write_port_status(tmp); - spin_lock_bh(&peer->lock); - } else { - fwtty_err(&peer->unit, "PLUG_RSP error (%d)\n", rcode); - port = peer_revert_state(peer); - } - } -cleanup: - spin_unlock_bh(&peer->lock); - if (port) - fwserial_release_port(port, false); - kfree(pkt); -} - -static void fwserial_handle_unplug_req(struct work_struct *work) -{ - struct fwtty_peer *peer = to_peer(work, work); - struct fwtty_port *port = NULL; - struct fwserial_mgmt_pkt *pkt; - int rcode; - - pkt = kmalloc(sizeof(*pkt), GFP_KERNEL); - if (!pkt) - return; - - spin_lock_bh(&peer->lock); - - switch (peer->state) { - case FWPS_ATTACHED: - fill_unplug_rsp_ok(pkt); - peer_set_state(peer, FWPS_UNPLUG_RESPONDING); - break; - - case FWPS_UNPLUG_PENDING: - if (peer->serial->card->guid > peer->guid) - goto cleanup; - - /* We lost - send unplug rsp */ - del_timer(&peer->timer); - fill_unplug_rsp_ok(pkt); - peer_set_state(peer, FWPS_UNPLUG_RESPONDING); - break; - - default: - fill_unplug_rsp_nack(pkt); - } - - spin_unlock_bh(&peer->lock); - - rcode = fwserial_send_mgmt_sync(peer, pkt); - - spin_lock_bh(&peer->lock); - if (peer->state == FWPS_UNPLUG_RESPONDING) { - if (rcode != RCODE_COMPLETE) - fwtty_err(&peer->unit, "UNPLUG_RSP error (%d)\n", - rcode); - port = peer_revert_state(peer); - } -cleanup: - spin_unlock_bh(&peer->lock); - if (port) - fwserial_release_port(port, true); - kfree(pkt); -} - -static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, - struct fwserial_mgmt_pkt *pkt, - unsigned long long addr, - size_t len) -{ - struct fwtty_port *port = NULL; - bool reset = false; - int rcode; - - if (addr != fwserial_mgmt_addr_handler.offset || len < sizeof(pkt->hdr)) - return RCODE_ADDRESS_ERROR; - - if (len != be16_to_cpu(pkt->hdr.len) || - len != mgmt_pkt_expected_len(pkt->hdr.code)) - return RCODE_DATA_ERROR; - - spin_lock_bh(&peer->lock); - if (peer->state == FWPS_GONE) { - /* - * This should never happen - it would mean that the - * remote unit that just wrote this transaction was - * already removed from the bus -- and the removal was - * processed before we rec'd this transaction - */ - fwtty_err(&peer->unit, "peer already removed\n"); - spin_unlock_bh(&peer->lock); - return RCODE_ADDRESS_ERROR; - } - - rcode = RCODE_COMPLETE; - - fwtty_dbg(&peer->unit, "mgmt: hdr.code: %04x\n", pkt->hdr.code); - - switch (be16_to_cpu(pkt->hdr.code) & FWSC_CODE_MASK) { - case FWSC_VIRT_CABLE_PLUG: - if (work_pending(&peer->work)) { - fwtty_err(&peer->unit, "plug req: busy\n"); - rcode = RCODE_CONFLICT_ERROR; - - } else { - peer->work_params.plug_req = pkt->plug_req; - peer->workfn = fwserial_handle_plug_req; - queue_work(system_unbound_wq, &peer->work); - } - break; - - case FWSC_VIRT_CABLE_PLUG_RSP: - if (peer->state != FWPS_PLUG_PENDING) { - rcode = RCODE_CONFLICT_ERROR; - - } else if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) { - fwtty_notice(&peer->unit, "NACK plug rsp\n"); - port = peer_revert_state(peer); - - } else { - struct fwtty_port *tmp = peer->port; - - fwserial_virt_plug_complete(peer, &pkt->plug_rsp); - spin_unlock_bh(&peer->lock); - - fwtty_write_port_status(tmp); - spin_lock_bh(&peer->lock); - } - break; - - case FWSC_VIRT_CABLE_UNPLUG: - if (work_pending(&peer->work)) { - fwtty_err(&peer->unit, "unplug req: busy\n"); - rcode = RCODE_CONFLICT_ERROR; - } else { - peer->workfn = fwserial_handle_unplug_req; - queue_work(system_unbound_wq, &peer->work); - } - break; - - case FWSC_VIRT_CABLE_UNPLUG_RSP: - if (peer->state != FWPS_UNPLUG_PENDING) { - rcode = RCODE_CONFLICT_ERROR; - } else { - if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) - fwtty_notice(&peer->unit, "NACK unplug?\n"); - port = peer_revert_state(peer); - reset = true; - } - break; - - default: - fwtty_err(&peer->unit, "unknown mgmt code %d\n", - be16_to_cpu(pkt->hdr.code)); - rcode = RCODE_DATA_ERROR; - } - spin_unlock_bh(&peer->lock); - - if (port) - fwserial_release_port(port, reset); - - return rcode; -} - -/* - * fwserial_mgmt_handler: bus address handler for mgmt requests - * - * This handler is responsible for handling virtual cable requests from remotes - * for all cards. - */ -static void fwserial_mgmt_handler(struct fw_card *card, - struct fw_request *request, - int tcode, int destination, int source, - int generation, - unsigned long long addr, - void *data, size_t len, - void *callback_data) -{ - struct fwserial_mgmt_pkt *pkt = data; - struct fwtty_peer *peer; - int rcode; - - rcu_read_lock(); - peer = __fwserial_peer_by_node_id(card, generation, source); - if (!peer) { - fwtty_dbg(card, "peer(%d:%x) not found\n", generation, source); - __dump_peer_list(card); - rcode = RCODE_CONFLICT_ERROR; - - } else { - switch (tcode) { - case TCODE_WRITE_BLOCK_REQUEST: - rcode = fwserial_parse_mgmt_write(peer, pkt, addr, len); - break; - - default: - rcode = RCODE_TYPE_ERROR; - } - } - - rcu_read_unlock(); - fw_send_response(card, request, rcode); -} - -static int __init fwserial_init(void) -{ - int err, num_loops = !!(create_loop_dev); - - /* XXX: placeholder for a "firewire" debugfs node */ - fwserial_debugfs = debugfs_create_dir(KBUILD_MODNAME, NULL); - - /* num_ttys/num_ports must not be set above the static alloc avail */ - if (num_ttys + num_loops > MAX_CARD_PORTS) - num_ttys = MAX_CARD_PORTS - num_loops; - - num_ports = num_ttys + num_loops; - - fwtty_driver = tty_alloc_driver(MAX_TOTAL_PORTS, TTY_DRIVER_REAL_RAW - | TTY_DRIVER_DYNAMIC_DEV); - if (IS_ERR(fwtty_driver)) { - err = PTR_ERR(fwtty_driver); - goto remove_debugfs; - } - - fwtty_driver->driver_name = KBUILD_MODNAME; - fwtty_driver->name = tty_dev_name; - fwtty_driver->major = 0; - fwtty_driver->minor_start = 0; - fwtty_driver->type = TTY_DRIVER_TYPE_SERIAL; - fwtty_driver->subtype = SERIAL_TYPE_NORMAL; - fwtty_driver->init_termios = tty_std_termios; - fwtty_driver->init_termios.c_cflag |= CLOCAL; - tty_set_operations(fwtty_driver, &fwtty_ops); - - err = tty_register_driver(fwtty_driver); - if (err) { - pr_err("register tty driver failed (%d)\n", err); - goto put_tty; - } - - if (create_loop_dev) { - fwloop_driver = tty_alloc_driver(MAX_TOTAL_PORTS / num_ports, - TTY_DRIVER_REAL_RAW - | TTY_DRIVER_DYNAMIC_DEV); - if (IS_ERR(fwloop_driver)) { - err = PTR_ERR(fwloop_driver); - goto unregister_driver; - } - - fwloop_driver->driver_name = KBUILD_MODNAME "_loop"; - fwloop_driver->name = loop_dev_name; - fwloop_driver->major = 0; - fwloop_driver->minor_start = 0; - fwloop_driver->type = TTY_DRIVER_TYPE_SERIAL; - fwloop_driver->subtype = SERIAL_TYPE_NORMAL; - fwloop_driver->init_termios = tty_std_termios; - fwloop_driver->init_termios.c_cflag |= CLOCAL; - tty_set_operations(fwloop_driver, &fwloop_ops); - - err = tty_register_driver(fwloop_driver); - if (err) { - pr_err("register loop driver failed (%d)\n", err); - goto put_loop; - } - } - - fwtty_txn_cache = kmem_cache_create("fwtty_txn_cache", - sizeof(struct fwtty_transaction), - 0, 0, NULL); - if (!fwtty_txn_cache) { - err = -ENOMEM; - goto unregister_loop; - } - - /* - * Ideally, this address handler would be registered per local node - * (rather than the same handler for all local nodes). However, - * since the firewire core requires the config rom descriptor *before* - * the local unit device(s) are created, a single management handler - * must suffice for all local serial units. - */ - fwserial_mgmt_addr_handler.length = sizeof(struct fwserial_mgmt_pkt); - fwserial_mgmt_addr_handler.address_callback = fwserial_mgmt_handler; - - err = fw_core_add_address_handler(&fwserial_mgmt_addr_handler, - &fwserial_mgmt_addr_region); - if (err) { - pr_err("add management handler failed (%d)\n", err); - goto destroy_cache; - } - - fwserial_unit_directory_data.unit_addr_offset = - FW_UNIT_ADDRESS(fwserial_mgmt_addr_handler.offset); - err = fw_core_add_descriptor(&fwserial_unit_directory); - if (err) { - pr_err("add unit descriptor failed (%d)\n", err); - goto remove_handler; - } - - err = driver_register(&fwserial_driver.driver); - if (err) { - pr_err("register fwserial driver failed (%d)\n", err); - goto remove_descriptor; - } - - return 0; - -remove_descriptor: - fw_core_remove_descriptor(&fwserial_unit_directory); -remove_handler: - fw_core_remove_address_handler(&fwserial_mgmt_addr_handler); -destroy_cache: - kmem_cache_destroy(fwtty_txn_cache); -unregister_loop: - if (create_loop_dev) - tty_unregister_driver(fwloop_driver); -put_loop: - if (create_loop_dev) - tty_driver_kref_put(fwloop_driver); -unregister_driver: - tty_unregister_driver(fwtty_driver); -put_tty: - tty_driver_kref_put(fwtty_driver); -remove_debugfs: - debugfs_remove_recursive(fwserial_debugfs); - - return err; -} - -static void __exit fwserial_exit(void) -{ - driver_unregister(&fwserial_driver.driver); - fw_core_remove_descriptor(&fwserial_unit_directory); - fw_core_remove_address_handler(&fwserial_mgmt_addr_handler); - kmem_cache_destroy(fwtty_txn_cache); - if (create_loop_dev) { - tty_unregister_driver(fwloop_driver); - tty_driver_kref_put(fwloop_driver); - } - tty_unregister_driver(fwtty_driver); - tty_driver_kref_put(fwtty_driver); - debugfs_remove_recursive(fwserial_debugfs); -} - -module_init(fwserial_init); -module_exit(fwserial_exit); - -MODULE_AUTHOR("Peter Hurley (peter@hurleysoftware.com)"); -MODULE_DESCRIPTION("FireWire Serial TTY Driver"); -MODULE_LICENSE("GPL"); -MODULE_DEVICE_TABLE(ieee1394, fwserial_id_table); -MODULE_PARM_DESC(ttys, "Number of ttys to create for each local firewire node"); -MODULE_PARM_DESC(auto, "Auto-connect a tty to each firewire node discovered"); -MODULE_PARM_DESC(loop, "Create a loopback device, fwloop<n>, with ttys"); diff --git a/drivers/staging/fwserial/fwserial.h b/drivers/staging/fwserial/fwserial.h deleted file mode 100644 index 1d15f183e0fa..000000000000 --- a/drivers/staging/fwserial/fwserial.h +++ /dev/null @@ -1,359 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _FIREWIRE_FWSERIAL_H -#define _FIREWIRE_FWSERIAL_H - -#include <linux/kernel.h> -#include <linux/tty.h> -#include <linux/tty_driver.h> -#include <linux/tty_flip.h> -#include <linux/list.h> -#include <linux/firewire.h> -#include <linux/firewire-constants.h> -#include <linux/spinlock.h> -#include <linux/rcupdate.h> -#include <linux/mutex.h> -#include <linux/serial.h> -#include <linux/serial_reg.h> -#include <linux/module.h> -#include <linux/seq_file.h> -#include <linux/debugfs.h> - -#include "dma_fifo.h" - -#ifdef FWTTY_PROFILING -#define DISTRIBUTION_MAX_SIZE 8192 -#define DISTRIBUTION_MAX_INDEX (ilog2(DISTRIBUTION_MAX_SIZE) + 1) -static inline void fwtty_profile_data(unsigned int stat[], unsigned int val) -{ - int n = (val) ? min(ilog2(val) + 1, DISTRIBUTION_MAX_INDEX) : 0; - ++stat[n]; -} -#else -#define DISTRIBUTION_MAX_INDEX 0 -#define fwtty_profile_data(st, n) -#endif - -/* Parameters for both VIRT_CABLE_PLUG & VIRT_CABLE_PLUG_RSP mgmt codes */ -struct virt_plug_params { - __be32 status_hi; - __be32 status_lo; - __be32 fifo_hi; - __be32 fifo_lo; - __be32 fifo_len; -}; - -struct peer_work_params { - union { - struct virt_plug_params plug_req; - }; -}; - -/** - * fwtty_peer: structure representing local & remote unit devices - * @unit: unit child device of fw_device node - * @serial: back pointer to associated fw_serial aggregate - * @guid: unique 64-bit guid for this unit device - * @generation: most recent bus generation - * @node_id: most recent node_id - * @speed: link speed of peer (0 = S100, 2 = S400, ... 5 = S3200) - * @mgmt_addr: bus addr region to write mgmt packets to - * @status_addr: bus addr register to write line status to - * @fifo_addr: bus addr region to write serial output to - * @fifo_len: max length for single write to fifo_addr - * @list: link for insertion into fw_serial's peer_list - * @rcu: for deferring peer reclamation - * @lock: spinlock to synchonize changes to state & port fields - * @work: only one work item can be queued at any one time - * Note: pending work is canceled prior to removal, so this - * peer is valid for at least the lifetime of the work function - * @work_params: parameter block for work functions - * @timer: timer for resetting peer state if remote request times out - * @state: current state - * @connect: work item for auto-connecting - * @connect_retries: # of connections already attempted - * @port: associated tty_port (usable if state == FWSC_ATTACHED) - */ -struct fwtty_peer { - struct fw_unit *unit; - struct fw_serial *serial; - u64 guid; - int generation; - int node_id; - unsigned int speed; - int max_payload; - u64 mgmt_addr; - - /* these are usable only if state == FWSC_ATTACHED */ - u64 status_addr; - u64 fifo_addr; - int fifo_len; - - struct list_head list; - struct rcu_head rcu; - - spinlock_t lock; - work_func_t workfn; - struct work_struct work; - struct peer_work_params work_params; - struct timer_list timer; - int state; - struct delayed_work connect; - int connect_retries; - - struct fwtty_port *port; -}; - -#define to_peer(ptr, field) (container_of(ptr, struct fwtty_peer, field)) - -/* state values for fwtty_peer.state field */ -enum fwtty_peer_state { - FWPS_GONE, - FWPS_NOT_ATTACHED, - FWPS_ATTACHED, - FWPS_PLUG_PENDING, - FWPS_PLUG_RESPONDING, - FWPS_UNPLUG_PENDING, - FWPS_UNPLUG_RESPONDING, - - FWPS_NO_MGMT_ADDR = -1, -}; - -#define CONNECT_RETRY_DELAY HZ -#define MAX_CONNECT_RETRIES 10 - -/* must be holding peer lock for these state funclets */ -static inline void peer_set_state(struct fwtty_peer *peer, int new) -{ - peer->state = new; -} - -static inline struct fwtty_port *peer_revert_state(struct fwtty_peer *peer) -{ - struct fwtty_port *port = peer->port; - - peer->port = NULL; - peer_set_state(peer, FWPS_NOT_ATTACHED); - return port; -} - -struct fwserial_mgmt_pkt { - struct { - __be16 len; - __be16 code; - } hdr; - union { - struct virt_plug_params plug_req; - struct virt_plug_params plug_rsp; - }; -} __packed; - -/* fwserial_mgmt_packet codes */ -#define FWSC_RSP_OK 0x0000 -#define FWSC_RSP_NACK 0x8000 -#define FWSC_CODE_MASK 0x0fff - -#define FWSC_VIRT_CABLE_PLUG 1 -#define FWSC_VIRT_CABLE_UNPLUG 2 -#define FWSC_VIRT_CABLE_PLUG_RSP 3 -#define FWSC_VIRT_CABLE_UNPLUG_RSP 4 - -/* 1 min. plug timeout -- suitable for userland authorization */ -#define VIRT_CABLE_PLUG_TIMEOUT (60 * HZ) - -struct stats { - unsigned int xchars; - unsigned int dropped; - unsigned int tx_stall; - unsigned int fifo_errs; - unsigned int sent; - unsigned int lost; - unsigned int throttled; - unsigned int reads[DISTRIBUTION_MAX_INDEX + 1]; - unsigned int writes[DISTRIBUTION_MAX_INDEX + 1]; - unsigned int txns[DISTRIBUTION_MAX_INDEX + 1]; - unsigned int unthrottle[DISTRIBUTION_MAX_INDEX + 1]; -}; - -struct fwconsole_ops { - void (*notify)(int code, void *data); - void (*stats)(struct stats *stats, void *data); - void (*proc_show)(struct seq_file *m, void *data); -}; - -/* codes for console ops notify */ -#define FWCON_NOTIFY_ATTACH 1 -#define FWCON_NOTIFY_DETACH 2 - -/** - * fwtty_port: structure used to track/represent underlying tty_port - * @port: underlying tty_port - * @device: tty device - * @index: index into port_table for this particular port - * note: minor = index + minor_start assigned by tty_alloc_driver() - * @serial: back pointer to the containing fw_serial - * @rx_handler: bus address handler for unique addr region used by remotes - * to communicate with this port. Every port uses - * fwtty_port_handler() for per port transactions. - * @fwcon_ops: ops for attached fw_console (if any) - * @con_data: private data for fw_console - * @wait_tx: waitqueue for sleeping until writer/drain completes tx - * @emit_breaks: delayed work responsible for generating breaks when the - * break line status is active - * @cps : characters per second computed from the termios settings - * @break_last: timestamp in jiffies from last emit_breaks - * @hangup: work responsible for HUPing when carrier is dropped/lost - * @mstatus: loose virtualization of LSR/MSR - * bits 15..0 correspond to TIOCM_* bits - * bits 19..16 reserved for mctrl - * bit 20 OOB_TX_THROTTLE - * bits 23..21 reserved - * bits 31..24 correspond to UART_LSR_* bits - * @lock: spinlock for protecting concurrent access to fields below it - * @mctrl: loose virtualization of MCR - * bits 15..0 correspond to TIOCM_* bits - * bit 16 OOB_RX_THROTTLE - * bits 19..17 reserved - * bits 31..20 reserved for mstatus - * @drain: delayed work scheduled to ensure that writes are flushed. - * The work can race with the writer but concurrent sending is - * prevented with the IN_TX flag. Scheduled under lock to - * limit scheduling when fifo has just been drained. - * @tx_fifo: fifo used to store & block-up writes for dma to remote - * @max_payload: max bytes transmissible per dma (based on peer's max_payload) - * @status_mask: UART_LSR_* bitmask significant to rx (based on termios) - * @ignore_mask: UART_LSR_* bitmask of states to ignore (also based on termios) - * @break_ctl: if set, port is 'sending break' to remote - * @write_only: self-explanatory - * @overrun: previous rx was lost (partially or completely) - * @loopback: if set, port is in loopback mode - * @flags: atomic bit flags - * bit 0: IN_TX - gate to allow only one cpu to send from the dma fifo - * at a time. - * bit 1: STOP_TX - force tx to exit while sending - * @peer: rcu-pointer to associated fwtty_peer (if attached) - * NULL if no peer attached - * @icount: predefined statistics reported by the TIOCGICOUNT ioctl - * @stats: additional statistics reported in /proc/tty/driver/firewire_serial - */ -struct fwtty_port { - struct tty_port port; - struct device *device; - unsigned int index; - struct fw_serial *serial; - struct fw_address_handler rx_handler; - - struct fwconsole_ops *fwcon_ops; - void *con_data; - - wait_queue_head_t wait_tx; - struct delayed_work emit_breaks; - unsigned int cps; - unsigned long break_last; - - struct work_struct hangup; - - unsigned int mstatus; - - spinlock_t lock; - unsigned int mctrl; - struct delayed_work drain; - struct dma_fifo tx_fifo; - int max_payload; - unsigned int status_mask; - unsigned int ignore_mask; - unsigned int break_ctl:1, - write_only:1, - overrun:1, - loopback:1; - unsigned long flags; - - struct fwtty_peer __rcu *peer; - - struct async_icount icount; - struct stats stats; -}; - -#define to_port(ptr, field) (container_of(ptr, struct fwtty_port, field)) - -/* bit #s for flags field */ -#define IN_TX 0 -#define STOP_TX 1 - -/* bitmasks for special mctrl/mstatus bits */ -#define OOB_RX_THROTTLE 0x00010000 -#define MCTRL_RSRVD 0x000e0000 -#define OOB_TX_THROTTLE 0x00100000 -#define MSTATUS_RSRVD 0x00e00000 - -#define MCTRL_MASK (TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 | TIOCM_OUT2 | \ - TIOCM_LOOP | OOB_RX_THROTTLE | MCTRL_RSRVD) - -/* XXX even every 1/50th secs. may be unnecessarily accurate */ -/* delay in jiffies between brk emits */ -#define FREQ_BREAKS (HZ / 50) - -/* Ports are allocated in blocks of num_ports for each fw_card */ -#define MAX_CARD_PORTS CONFIG_FWTTY_MAX_CARD_PORTS -#define MAX_TOTAL_PORTS CONFIG_FWTTY_MAX_TOTAL_PORTS - -/* tuning parameters */ -#define FWTTY_PORT_TXFIFO_LEN 4096 -#define FWTTY_PORT_MAX_PEND_DMA 8 /* costs a cache line per pend */ -#define DRAIN_THRESHOLD 1024 -#define MAX_ASYNC_PAYLOAD 4096 /* ohci-defined limit */ -#define WRITER_MINIMUM 128 -/* TODO: how to set watermark to AR context size? see fwtty_rx() */ -#define HIGH_WATERMARK 32768 /* AR context is 32K */ - -/* - * Size of bus addr region above 4GB used per port as the recv addr - * - must be at least as big as the MAX_ASYNC_PAYLOAD - */ -#define FWTTY_PORT_RXFIFO_LEN MAX_ASYNC_PAYLOAD - -/** - * fw_serial: aggregate used to associate tty ports with specific fw_card - * @card: fw_card associated with this fw_serial device (1:1 association) - * @kref: reference-counted multi-port management allows delayed destroy - * @self: local unit device as 'peer'. Not valid until local unit device - * is enumerated. - * @list: link for insertion into fwserial_list - * @peer_list: list of local & remote unit devices attached to this card - * @ports: fixed array of tty_ports provided by this serial device - */ -struct fw_serial { - struct fw_card *card; - struct kref kref; - - struct dentry *debugfs; - struct fwtty_peer *self; - - struct list_head list; - struct list_head peer_list; - - struct fwtty_port *ports[MAX_CARD_PORTS]; -}; - -#define to_serial(ptr, field) (container_of(ptr, struct fw_serial, field)) - -#define TTY_DEV_NAME "fwtty" /* ttyFW was taken */ -static const char tty_dev_name[] = TTY_DEV_NAME; -static const char loop_dev_name[] = "fwloop"; - -extern struct tty_driver *fwtty_driver; - -/* - * Returns the max send async payload size in bytes based on the unit device - * link speed. Self-limiting asynchronous bandwidth (via reducing the payload) - * is not necessary and does not work, because - * 1) asynchronous traffic will absorb all available bandwidth (less that - * being used for isochronous traffic) - * 2) isochronous arbitration always wins. - */ -static inline int link_speed_to_max_payload(unsigned int speed) -{ - /* Max async payload is 4096 - see IEEE 1394-2008 tables 6-4, 16-18 */ - return min(512 << speed, 4096); -} - -#endif /* _FIREWIRE_FWSERIAL_H */ diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c index 05e91e6bc2a0..223987616e07 100644 --- a/drivers/staging/greybus/audio_helper.c +++ b/drivers/staging/greybus/audio_helper.c @@ -3,7 +3,6 @@ * Greybus Audio Sound SoC helper APIs */ -#include <linux/debugfs.h> #include <sound/core.h> #include <sound/soc.h> #include <sound/soc-dapm.h> @@ -116,10 +115,6 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, { int i; struct snd_soc_dapm_widget *w, *tmp_w; -#ifdef CONFIG_DEBUG_FS - struct dentry *parent = dapm->debugfs_dapm; - struct dentry *debugfs_w = NULL; -#endif mutex_lock(&dapm->card->dapm_mutex); for (i = 0; i < num; i++) { @@ -139,12 +134,6 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, continue; } widget++; -#ifdef CONFIG_DEBUG_FS - if (!parent) - debugfs_w = debugfs_lookup(w->name, parent); - debugfs_remove(debugfs_w); - debugfs_w = NULL; -#endif gbaudio_dapm_free_widget(w); } mutex_unlock(&dapm->card->dapm_mutex); diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 1ad94c5060b5..a36e36701c74 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -125,7 +125,7 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev) * * Returns Always returns NETDEV_TX_OK */ -int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) +netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) { union cvmx_pko_command_word0 pko_command; union cvmx_buf_ptr hw_buffer; @@ -506,7 +506,7 @@ skip_xmit: * @dev: Device info structure * Returns Always returns zero */ -int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev) +netdev_tx_t cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); void *packet_buffer; diff --git a/drivers/staging/octeon/ethernet-tx.h b/drivers/staging/octeon/ethernet-tx.h index 78936e9b33b0..6c524668f65a 100644 --- a/drivers/staging/octeon/ethernet-tx.h +++ b/drivers/staging/octeon/ethernet-tx.h @@ -5,8 +5,8 @@ * Copyright (c) 2003-2007 Cavium Networks */ -int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev); -int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev); +netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev); +netdev_tx_t cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev); int cvm_oct_transmit_qos(struct net_device *dev, void *work_queue_entry, int do_free, int qos); void cvm_oct_tx_initialize(void); diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index df02335fdbab..d4e06a3929f3 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1149,19 +1149,7 @@ out_unlock: return ret; } - -static int pi433_debugfs_regs_open(struct inode *inode, struct file *filp) -{ - return single_open(filp, pi433_debugfs_regs_show, inode->i_private); -} - -static const struct file_operations debugfs_fops = { - .llseek = seq_lseek, - .open = pi433_debugfs_regs_open, - .owner = THIS_MODULE, - .read = seq_read, - .release = single_release -}; +DEFINE_SHOW_ATTRIBUTE(pi433_debugfs_regs); /*-------------------------------------------------------------------------*/ @@ -1320,7 +1308,7 @@ static int pi433_probe(struct spi_device *spi) entry = debugfs_create_dir(dev_name(device->dev), debugfs_lookup(KBUILD_MODNAME, NULL)); - debugfs_create_file("regs", 0400, entry, device, &debugfs_fops); + debugfs_create_file("regs", 0400, entry, device, &pi433_debugfs_regs_fops); return 0; diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 659c8c1b38fd..8c7fab6a46bb 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -816,7 +816,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size) if (size > FIFO_SIZE) { dev_dbg(&spi->dev, - "read fifo: passed in buffer bigger then internal buffer\n"); + "write fifo: passed in buffer bigger then internal buffer\n"); return -EMSGSIZE; } diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index eea16eb7caa0..fd494c2299e6 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -10,7 +10,6 @@ r8188eu-y = \ hal/hal_com.o \ hal/odm.o \ hal/odm_HWConfig.o \ - hal/odm_RegConfig8188E.o \ hal/odm_RTL8188E.o \ hal/rtl8188e_cmd.o \ hal/rtl8188e_dm.o \ @@ -18,19 +17,14 @@ r8188eu-y = \ hal/rtl8188e_phycfg.o \ hal/rtl8188e_rf6052.o \ hal/rtl8188e_rxdesc.o \ - hal/rtl8188e_xmit.o \ - hal/rtl8188eu_recv.o \ hal/rtl8188eu_xmit.o \ hal/usb_halinit.o \ hal/usb_ops_linux.o \ os_dep/ioctl_linux.o \ - os_dep/mlme_linux.o \ os_dep/os_intfs.o \ os_dep/osdep_service.o \ - os_dep/recv_linux.o \ os_dep/usb_intf.o \ os_dep/usb_ops_linux.o \ - os_dep/xmit_linux.o \ core/rtw_ap.o \ core/rtw_br_ext.o \ core/rtw_cmd.o \ diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 5bd9dfa57cc5..24eb8dce9bfe 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -935,6 +935,48 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) return beacon_updated; } +void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta) +{ + union iwreq_data wrqu; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (!psta) + return; + + if (psta->aid > NUM_STA) + return; + + if (pstapriv->sta_aid[psta->aid - 1] != psta) + return; + + wrqu.addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); + + wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL); +} + +static void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta) +{ + union iwreq_data wrqu; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (!psta) + return; + + if (psta->aid > NUM_STA) + return; + + if (pstapriv->sta_aid[psta->aid - 1] != psta) + return; + + wrqu.addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); + + wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL); +} + u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, bool active, u16 reason) { diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index bca20fe5c983..4c5f30792a46 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -12,7 +12,6 @@ #include "../include/drv_types.h" #include "../include/rtw_br_ext.h" #include "../include/usb_osintf.h" -#include "../include/recv_osdep.h" #ifndef csum_ipv6_magic #include "../include/net/ip6_checksum.h" diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 5b6a891b5d67..3fadace33de6 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -5,8 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/mlme_osdep.h" #include "../include/rtw_br_ext.h" #include "../include/rtw_mlme_ext.h" #include "../include/rtl8188e_dm.h" @@ -58,8 +56,6 @@ exit: u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { - u32 res = _SUCCESS; - init_completion(&pcmdpriv->enqueue_cmd); /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ init_completion(&pcmdpriv->start_cmd_thread); @@ -74,27 +70,24 @@ u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, GFP_KERNEL); - if (!pcmdpriv->cmd_allocated_buf) { - res = _FAIL; - goto exit; - } + if (!pcmdpriv->cmd_allocated_buf) + return _FAIL; pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ - 1)); pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL); if (!pcmdpriv->rsp_allocated_buf) { - res = _FAIL; - goto exit; + kfree(pcmdpriv->cmd_allocated_buf); + return _FAIL; } pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3); pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; -exit: - return res; + return _SUCCESS; } u32 rtw_init_evt_priv(struct evt_priv *pevtpriv) @@ -288,8 +281,7 @@ post_process: * ### NOTE:#### (!!!!) * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock */ -u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, - struct rtw_ieee80211_channel *ch, int ch_num) +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num) { u8 res = _FAIL; struct cmd_obj *ph2c; @@ -331,17 +323,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, } } - /* prepare channel list */ - if (ch) { - int i; - for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { - if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) { - memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); - psurveyPara->ch_num++; - } - } - } - set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); res = rtw_enqueue_cmd(pcmdpriv, ph2c); @@ -1290,6 +1271,66 @@ exit: return res; } +/* C2H event format: + * Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID + * BITS [127:120] [119:16] [15:8] [7:4] [3:0] + */ +static s32 c2h_evt_read(struct adapter *adapter, u8 *buf) +{ + s32 ret = _FAIL; + struct c2h_evt_hdr *c2h_evt; + int i; + u8 trigger; + + if (!buf) + goto exit; + + ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger); + if (ret) + return _FAIL; + + if (trigger == C2H_EVT_HOST_CLOSE) + goto exit; /* Not ready */ + else if (trigger != C2H_EVT_FW_CLOSE) + goto clear_evt; /* Not a valid value */ + + c2h_evt = (struct c2h_evt_hdr *)buf; + + memset(c2h_evt, 0, 16); + + ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf); + if (ret) { + ret = _FAIL; + goto clear_evt; + } + + ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1); + if (ret) { + ret = _FAIL; + goto clear_evt; + } + /* Read the content */ + for (i = 0; i < c2h_evt->plen; i++) { + ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + + sizeof(*c2h_evt) + i, c2h_evt->payload + i); + if (ret) { + ret = _FAIL; + goto clear_evt; + } + } + + ret = _SUCCESS; + +clear_evt: + /* Clear event to notify FW we have read the command. + * If this field isn't clear, the FW won't update the next + * command message. + */ + rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); +exit: + return ret; +} + static void c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) { u8 buf[16]; diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c index 95534f9c7a0f..682c65b1e04c 100644 --- a/drivers/staging/r8188eu/core/rtw_fw.c +++ b/drivers/staging/r8188eu/core/rtw_fw.c @@ -236,7 +236,7 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device) { int ret = _SUCCESS; const struct firmware *fw; - const char *fw_name = "rtlwifi/rtl8188eufw.bin"; + const char *fw_name = FW_RTL8188EU; int err = request_firmware(&fw, fw_name, device); if (err) { diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 17f6bcbeebf4..55e6b0f41dc3 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -11,8 +11,6 @@ #include "../include/usb_osintf.h" #include "../include/usb_ops.h" -extern void indicate_wx_scan_complete_event(struct adapter *padapter); - u8 rtw_do_join(struct adapter *padapter) { struct list_head *plist, *phead; @@ -43,7 +41,7 @@ u8 rtw_do_join(struct adapter *padapter) if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || pmlmepriv->to_roaming > 0) { /* submit site_survey_cmd */ - ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); + ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1); if (ret != _SUCCESS) pmlmepriv->to_join = false; } else { @@ -89,7 +87,7 @@ u8 rtw_do_join(struct adapter *padapter) /* we try to issue sitesurvey firstly */ if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || pmlmepriv->to_roaming > 0) { - ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); + ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1); if (ret != _SUCCESS) pmlmepriv->to_join = false; } else { @@ -353,14 +351,9 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s /* Scan or linking is in progress, do nothing. */ res = true; } else { - if (rtw_is_scan_deny(padapter)) { - indicate_wx_scan_complete_event(padapter); - return _SUCCESS; - } - spin_lock_bh(&pmlmepriv->lock); - res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num, NULL, 0); + res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num); spin_unlock_bh(&pmlmepriv->lock); } diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index d5c6c5e29621..1e316e6358ea 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -25,9 +25,7 @@ static void ResetLedStatus(struct led_priv *pLed) pLed->bLedWPSBlinkInProgress = false; pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */ - pLed->BlinkingLedState = LED_UNKNOWN; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */ - pLed->bLedNoLinkBlinkInProgress = false; pLed->bLedLinkBlinkInProgress = false; pLed->bLedScanBlinkInProgress = false; } @@ -37,7 +35,7 @@ static void SwLedOn(struct adapter *padapter, struct led_priv *pLed) u8 LedCfg; int res; - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + if (padapter->bDriverStopped) return; res = rtw_read8(padapter, REG_LEDCFG2, &LedCfg); @@ -53,7 +51,7 @@ static void SwLedOff(struct adapter *padapter, struct led_priv *pLed) u8 LedCfg; int res; - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + if (padapter->bDriverStopped) goto exit; res = rtw_read8(padapter, REG_LEDCFG2, &LedCfg);/* 0x4E */ @@ -79,41 +77,25 @@ static void blink_work(struct work_struct *work) struct adapter *padapter = pLed->padapter; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) - return; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff(padapter, pLed); ResetLedStatus(pLed); return; } - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - SwLedOn(padapter, pLed); - else + if (pLed->bLedOn) SwLedOff(padapter, pLed); + else + SwLedOn(padapter, pLed); switch (pLed->CurrLedState) { case LED_BLINK_SLOWLY: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL); break; case LED_BLINK_NORMAL: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); break; case LED_BLINK_SCAN: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; pLed->BlinkTimes--; if (pLed->BlinkTimes == 0) { if (check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -121,7 +103,6 @@ static void blink_work(struct work_struct *work) pLed->CurrLedState = LED_BLINK_NORMAL; schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); } else { - pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL); } @@ -131,10 +112,6 @@ static void blink_work(struct work_struct *work) } break; case LED_BLINK_TXRX: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; pLed->BlinkTimes--; if (pLed->BlinkTimes == 0) { if (check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -142,7 +119,6 @@ static void blink_work(struct work_struct *work) pLed->CurrLedState = LED_BLINK_NORMAL; schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); } else { - pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL); } @@ -152,25 +128,16 @@ static void blink_work(struct work_struct *work) } break; case LED_BLINK_WPS: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL); break; case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState != RTW_LED_ON) { + if (!pLed->bLedOn) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); pLed->bLedWPSBlinkInProgress = false; } else { - pLed->BlinkingLedState = RTW_LED_OFF; schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL); } break; @@ -217,192 +184,110 @@ void rtw_led_control(struct adapter *padapter, enum LED_CTL_MODE LedAction) switch (LedAction) { case LED_CTL_START_TO_LINK: case LED_CTL_NO_LINK: - if (!pLed->bLedNoLinkBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedBlinkInProgress = false; - } + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL); - } + cancel_delayed_work(&pLed->blink_work); + + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + + pLed->CurrLedState = LED_BLINK_SLOWLY; + schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL); break; case LED_CTL_LINK: - if (!pLed->bLedLinkBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); - } + if (!pLed->bLedLinkBlinkInProgress) + return; + + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + + cancel_delayed_work(&pLed->blink_work); + + pLed->bLedBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = true; + + pLed->CurrLedState = LED_BLINK_NORMAL; + schedule_delayed_work(&pLed->blink_work, LED_BLINK_LINK_INTVL); break; case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - ; - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL); - } + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) + return; + + if (pLed->bLedScanBlinkInProgress) + return; + + if (IS_LED_WPS_BLINKING(pLed)) + return; + + cancel_delayed_work(&pLed->blink_work); + + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = true; + + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL); break; case LED_CTL_TX: case LED_CTL_RX: - if (!pLed->bLedBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - schedule_delayed_work(&pLed->blink_work, LED_BLINK_FASTER_INTVL); - } + if (pLed->bLedBlinkInProgress) + return; + + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + + cancel_delayed_work(&pLed->blink_work); + + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = true; + + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + schedule_delayed_work(&pLed->blink_work, LED_BLINK_FASTER_INTVL); break; case LED_CTL_START_WPS: /* wait until xinpin finish */ - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedNoLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL); - } + if (pLed->bLedWPSBlinkInProgress) + return; + + cancel_delayed_work(&pLed->blink_work); + + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + schedule_delayed_work(&pLed->blink_work, LED_BLINK_SCAN_INTVL); break; case LED_CTL_STOP_WPS: - if (pLed->bLedNoLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) - cancel_delayed_work(&pLed->blink_work); - else - pLed->bLedWPSBlinkInProgress = true; + cancel_delayed_work(&pLed->blink_work); + + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS_STOP; if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; schedule_delayed_work(&pLed->blink_work, LED_BLINK_WPS_SUCESS_INTVL); } else { - pLed->BlinkingLedState = RTW_LED_ON; schedule_delayed_work(&pLed->blink_work, 0); } break; case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->bLedNoLinkBlinkInProgress = true; + cancel_delayed_work(&pLed->blink_work); + pLed->bLedWPSBlinkInProgress = false; pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; schedule_delayed_work(&pLed->blink_work, LED_BLINK_NO_LINK_INTVL); break; case LED_CTL_POWER_OFF: pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedNoLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedWPSBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - cancel_delayed_work(&pLed->blink_work); - pLed->bLedScanBlinkInProgress = false; - } + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; + pLed->bLedWPSBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; + cancel_delayed_work(&pLed->blink_work); SwLedOff(padapter, pLed); break; default: diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 2705c9d87b14..5ca03d6cac32 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -5,10 +5,7 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/xmit_osdep.h" #include "../include/hal_intf.h" -#include "../include/mlme_osdep.h" #include "../include/sta_info.h" #include "../include/wifi.h" #include "../include/wlan_bssdef.h" @@ -190,6 +187,37 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie) return ie + 8; } +static void rtw_join_timeout_handler(struct timer_list *t) +{ + struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer); + + _rtw_join_timeout_handler(adapter); +} + +static void _rtw_scan_timeout_handler(struct timer_list *t) +{ + struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer); + + rtw_scan_timeout_handler(adapter); +} + +static void _dynamic_check_timer_handlder(struct timer_list *t) +{ + struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer); + + rtw_dynamic_check_timer_handlder(adapter); + _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); +} + +static void rtw_init_mlme_timer(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0); + timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0); + timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0); +} + int rtw_init_mlme_priv(struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ { int i; @@ -235,8 +263,6 @@ int rtw_init_mlme_priv(struct adapter *padapter)/* struct mlme_priv *pmlmepriv) /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - rtw_clear_scan_deny(padapter); - rtw_init_mlme_timer(padapter); exit: @@ -641,6 +667,23 @@ exit: spin_unlock_bh(&pmlmepriv->lock); } +static void rtw_xmit_schedule(struct adapter *padapter) +{ + struct xmit_priv *pxmitpriv; + + if (!padapter) + return; + + pxmitpriv = &padapter->xmitpriv; + + spin_lock_bh(&pxmitpriv->lock); + + if (rtw_txframes_pending(padapter)) + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); + + spin_unlock_bh(&pxmitpriv->lock); +} + void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -697,7 +740,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) } else { if (rtw_to_roaming(adapter) != 0) { if (--pmlmepriv->to_roaming == 0 || - rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0) != _SUCCESS) { + rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1) != _SUCCESS) { rtw_set_roaming(adapter, 0); rtw_free_assoc_resources(adapter, 1); rtw_indicate_disconnect(adapter); @@ -719,7 +762,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, _FW_LINKED)) p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0); - rtw_os_xmit_schedule(adapter); + rtw_xmit_schedule(adapter); } static void free_scanqueue(struct mlme_priv *pmlmepriv) @@ -795,6 +838,48 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) } +static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE]; + +static void rtw_reset_securitypriv(struct adapter *adapter) +{ + u8 backup_index; + u8 backup_counter; + u32 backup_time; + + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + /* 802.1x */ + /* We have to backup the PMK information for WiFi PMK Caching test item. */ + /* Backup the btkip_countermeasure information. */ + /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */ + memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + backup_index = adapter->securitypriv.PMKIDIndex; + backup_counter = adapter->securitypriv.btkip_countermeasure; + backup_time = adapter->securitypriv.btkip_countermeasure_time; + memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); + + /* Restore the PMK information to securitypriv structure for the following connection. */ + memcpy(&adapter->securitypriv.PMKIDList[0], + &backup_pmkid[0], + sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + adapter->securitypriv.PMKIDIndex = backup_index; + adapter->securitypriv.btkip_countermeasure = backup_counter; + adapter->securitypriv.btkip_countermeasure_time = backup_time; + adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + } else { + /* reset values in securitypriv */ + struct security_priv *psec_priv = &adapter->securitypriv; + + psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psec_priv->dot11PrivacyKeyIndex = 0; + psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psec_priv->dot118021XGrpKeyid = 1; + psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; + psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; + } +} + /* *rtw_indicate_connect: the caller has to lock pmlmepriv->lock */ @@ -809,12 +894,13 @@ void rtw_indicate_connect(struct adapter *padapter) rtw_led_control(padapter, LED_CTL_LINK); - rtw_os_indicate_connect(padapter); + rtw_indicate_wx_assoc_event(padapter); + netif_carrier_on(padapter->pnetdev); + if (padapter->pid[2] != 0) + rtw_signal_process(padapter->pid[2], SIGALRM); } pmlmepriv->to_roaming = 0; - - rtw_set_scan_deny(padapter, 3000); } /* @@ -831,11 +917,14 @@ void rtw_indicate_disconnect(struct adapter *padapter) if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || (pmlmepriv->to_roaming <= 0)) { - rtw_os_indicate_disconnect(padapter); + /* Do it first for tx broadcast pkt after disconnection issue! */ + netif_carrier_off(padapter->pnetdev); + + rtw_indicate_wx_disassoc_event(padapter); + rtw_reset_securitypriv(padapter); _clr_fwstate_(pmlmepriv, _FW_LINKED); rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_clear_scan_deny(padapter); } p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); @@ -843,9 +932,9 @@ void rtw_indicate_disconnect(struct adapter *padapter) } -inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) +inline void rtw_indicate_scan_done(struct adapter *padapter) { - rtw_os_indicate_scan_done(padapter, aborted); + indicate_wx_scan_complete_event(padapter); } static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, struct wlan_network *pnetwork) @@ -1068,8 +1157,7 @@ void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); - rtw_os_xmit_schedule(adapter); - + rtw_xmit_schedule(adapter); } void rtw_set_max_rpt_macid(struct adapter *adapter, u8 macid) @@ -1316,7 +1404,7 @@ void rtw_scan_timeout_handler (struct adapter *adapter) spin_lock_bh(&pmlmepriv->lock); _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); spin_unlock_bh(&pmlmepriv->lock); - rtw_indicate_scan_done(adapter, true); + rtw_indicate_scan_done(adapter); } static void rtw_auto_scan_handler(struct adapter *padapter) @@ -1442,10 +1530,6 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) pmlmepriv->pscanned = phead->next; while (phead != pmlmepriv->pscanned) { pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); - if (!pnetwork) { - ret = _FAIL; - goto exit; - } pmlmepriv->pscanned = pmlmepriv->pscanned->next; rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); } @@ -1639,6 +1723,33 @@ static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie return ie_len; } +static void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) +{ + uint len; + u8 *buff, *p, i; + union iwreq_data wrqu; + + buff = NULL; + if (authmode == _WPA_IE_ID_) { + buff = kzalloc(IW_CUSTOM_MAX, GFP_ATOMIC); + if (!buff) + return; + p = buff; + p += sprintf(p, "ASSOCINFO(ReqIEs ="); + len = sec_ie[1] + 2; + len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; + for (i = 0; i < len; i++) + p += sprintf(p, "%02x", sec_ie[i]); + p += sprintf(p, ")"); + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.length = p - buff; + wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? + wrqu.data.length : IW_CUSTOM_MAX; + wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); + kfree(buff); + } +} + int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { u8 authmode = 0; diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 32d0e101d0c2..07905e2ae8e0 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -9,8 +9,6 @@ #include "../include/wifi.h" #include "../include/rtw_mlme_ext.h" #include "../include/wlan_bssdef.h" -#include "../include/mlme_osdep.h" -#include "../include/recv_osdep.h" #include "../include/rtl8188e_xmit.h" #include "../include/rtl8188e_dm.h" @@ -334,6 +332,28 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c return chanset_size; } +static void _survey_timer_hdl(struct timer_list *t) +{ + struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer); + + survey_timer_hdl(padapter); +} + +static void _link_timer_hdl(struct timer_list *t) +{ + struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer); + + link_timer_hdl(padapter); +} + +static void init_mlme_ext_timer(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0); + timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0); +} + void init_mlme_ext_priv(struct adapter *padapter) { struct registry_priv *pregistrypriv = &padapter->registrypriv; @@ -910,6 +930,46 @@ authclnt_fail: return _FAIL; } +static void UpdateBrateTbl(u8 *mbrate) +{ + u8 i; + u8 rate; + + /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + rate = mbrate[i] & 0x7f; + switch (rate) { + case IEEE80211_CCK_RATE_1MB: + case IEEE80211_CCK_RATE_2MB: + case IEEE80211_CCK_RATE_5MB: + case IEEE80211_CCK_RATE_11MB: + case IEEE80211_OFDM_RATE_6MB: + case IEEE80211_OFDM_RATE_12MB: + case IEEE80211_OFDM_RATE_24MB: + mbrate[i] |= IEEE80211_BASIC_RATE_MASK; + break; + } + } +} + +static void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) +{ + u8 i; + u8 rate; + + for (i = 0; i < bssratelen; i++) { + rate = bssrateset[i] & 0x7f; + switch (rate) { + case IEEE80211_CCK_RATE_1MB: + case IEEE80211_CCK_RATE_2MB: + case IEEE80211_CCK_RATE_5MB: + case IEEE80211_CCK_RATE_11MB: + bssrateset[i] |= IEEE80211_BASIC_RATE_MASK; + break; + } + } +} + unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) { u16 capab_info; @@ -1320,9 +1380,9 @@ OnAssocReqFail: unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) { + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data; uint i; int res; - unsigned short status; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -1331,7 +1391,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame uint pkt_len = precv_frame->len; /* check A1 matches or not */ - if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), mgmt->da, ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) @@ -1342,28 +1402,24 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame _cancel_timer_ex(&pmlmeext->link_timer); - /* status */ - status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); - if (status > 0) { + if (le16_to_cpu(mgmt->u.assoc_resp.status_code) > 0) { pmlmeinfo->state = WIFI_FW_NULL_STATE; res = -4; goto report_assoc_result; } - /* get capabilities */ - pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + pmlmeinfo->capability = le16_to_cpu(mgmt->u.assoc_resp.capab_info); /* set slot time */ pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; - /* AID */ - pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4)) & 0x3fff); + pmlmeinfo->aid = le16_to_cpu(mgmt->u.assoc_resp.aid) & 0x3fff; res = pmlmeinfo->aid; /* following are moved to join event callback function */ /* to handle HT, WMM, rate adaptive, update MAC reg */ /* for not to handle the synchronous IO in the tasklet */ - for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { + for (i = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); i < pkt_len;) { pIE = (struct ndis_802_11_var_ie *)(pframe + i); switch (pIE->ElementID) { @@ -1391,7 +1447,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ - UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); + UpdateBrateTbl(pmlmeinfo->network.SupportedRates); report_assoc_result: report_join_res(padapter, res); @@ -7858,7 +7914,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) spin_unlock_bh(&psta_bmc->sleep_q.lock); if (rtl8188eu_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta_bmc->sleep_q.lock); } spin_unlock_bh(&psta_bmc->sleep_q.lock); diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index bd654d4ff8b4..dc159e58f428 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1883,15 +1883,14 @@ void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) { - int ret = _SUCCESS; + int ret; struct wifidirect_info *pwdinfo = &padapter->wdinfo; if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) { /* leave IPS/Autosuspend */ - if (rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } + ret = rtw_pwr_wakeup(padapter); + if (ret) + return ret; /* Added by Albert 2011/03/22 */ /* In the P2P mode, the driver should not support the b mode. */ @@ -1902,10 +1901,9 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) init_wifidirect_info(padapter, role); } else if (role == P2P_ROLE_DISABLE) { - if (rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } + ret = rtw_pwr_wakeup(padapter); + if (ret) + return ret; /* Disable P2P function */ if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { @@ -1923,6 +1921,5 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); } -exit: - return ret; + return 0; } diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 10550bd2c16d..870d81735b8d 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -89,7 +89,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) struct wifidirect_info *pwdinfo = &adapter->wdinfo; bool ret = false; - if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) + if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) goto exit; if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) || diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index e5a7b7dfc387..bb5c3b3888e0 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -6,8 +6,6 @@ #include <linux/ieee80211.h> #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/mlme_osdep.h" #include "../include/usb_ops.h" #include "../include/wifi.h" #include "../include/rtl8188e_recv.h" @@ -37,6 +35,69 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) } +static int rtl8188eu_init_recv_priv(struct adapter *padapter) +{ + struct recv_priv *precvpriv = &padapter->recvpriv; + int i, res = _SUCCESS; + struct recv_buf *precvbuf; + + tasklet_init(&precvpriv->recv_tasklet, + rtl8188eu_recv_tasklet, + (unsigned long)padapter); + + /* init recv_buf */ + rtw_init_queue(&precvpriv->free_recv_buf_queue); + + precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, + GFP_KERNEL); + if (!precvpriv->pallocated_recv_buf) { + res = _FAIL; + goto exit; + } + + precvpriv->precv_buf = (u8 *)ALIGN((size_t)(precvpriv->pallocated_recv_buf), 4); + + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + + for (i = 0; i < NR_RECVBUFF; i++) { + precvbuf->pskb = NULL; + precvbuf->reuse = false; + precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); + if (!precvbuf->purb) { + res = _FAIL; + break; + } + precvbuf->adapter = padapter; + precvbuf++; + } + precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; + skb_queue_head_init(&precvpriv->rx_skb_queue); + { + int i; + size_t tmpaddr = 0; + size_t alignment = 0; + struct sk_buff *pskb = NULL; + + skb_queue_head_init(&precvpriv->free_recv_skb_queue); + + for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { + pskb = __netdev_alloc_skb(padapter->pnetdev, + MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL); + if (pskb) { + pskb->dev = padapter->pnetdev; + tmpaddr = (size_t)pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); + skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); + + skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + } + pskb = NULL; + } + } +exit: + return res; +} + int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) { int i; @@ -91,6 +152,26 @@ exit: return res; } +static void rtl8188eu_free_recv_priv(struct adapter *padapter) +{ + int i; + struct recv_buf *precvbuf; + struct recv_priv *precvpriv = &padapter->recvpriv; + + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + + for (i = 0; i < NR_RECVBUFF; i++) { + usb_free_urb(precvbuf->purb); + precvbuf++; + } + + kfree(precvpriv->pallocated_recv_buf); + + skb_queue_purge(&precvpriv->rx_skb_queue); + + skb_queue_purge(&precvpriv->free_recv_skb_queue); +} + void _rtw_free_recv_priv(struct recv_priv *precvpriv) { struct adapter *padapter = precvpriv->adapter; @@ -244,6 +325,42 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) return cnt; } +static void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) +{ + union iwreq_data wrqu; + struct iw_michaelmicfailure ev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 cur_time = 0; + + if (psecuritypriv->last_mic_err_time == 0) { + psecuritypriv->last_mic_err_time = jiffies; + } else { + cur_time = jiffies; + + if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) { + psecuritypriv->btkip_countermeasure = true; + psecuritypriv->last_mic_err_time = 0; + psecuritypriv->btkip_countermeasure_time = cur_time; + } else { + psecuritypriv->last_mic_err_time = jiffies; + } + } + + memset(&ev, 0x00, sizeof(ev)); + if (bgroup) + ev.flags |= IW_MICFAILURE_GROUP; + else + ev.flags |= IW_MICFAILURE_PAIRWISE; + + ev.src_addr.sa_family = ARPHRD_ETHER; + memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN); + memset(&wrqu, 0x00, sizeof(wrqu)); + wrqu.data.length = sizeof(ev); + wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, + &wrqu, (char *)&ev); +} + static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvframe) { int i, res = _SUCCESS; @@ -1294,7 +1411,6 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) u8 nr_subframes, i; unsigned char *pdata; struct rx_pkt_attrib *pattrib; - unsigned char *data_ptr; struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; struct recv_priv *precvpriv = &padapter->recvpriv; @@ -1329,8 +1445,7 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) sub_skb = dev_alloc_skb(nSubframe_Length + 12); if (sub_skb) { skb_reserve(sub_skb, 12); - data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); - memcpy(data_ptr, pdata, nSubframe_Length); + skb_put_data(sub_skb, pdata, nSubframe_Length); } else { sub_skb = skb_clone(prframe->pkt, GFP_ATOMIC); if (sub_skb) { @@ -1460,6 +1575,85 @@ static bool enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, s return true; } +static int rtw_recv_indicatepkt(struct adapter *padapter, struct recv_frame *precv_frame) +{ + struct recv_priv *precvpriv; + struct __queue *pfree_recv_queue; + struct sk_buff *skb; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + precvpriv = &padapter->recvpriv; + pfree_recv_queue = &precvpriv->free_recv_queue; + + skb = precv_frame->pkt; + if (!skb) + goto _recv_indicatepkt_drop; + + skb->data = precv_frame->rx_data; + + skb_set_tail_pointer(skb, precv_frame->len); + + skb->len = precv_frame->len; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sk_buff *pskb2 = NULL; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + bool bmcast = is_multicast_ether_addr(pattrib->dst); + + if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) { + if (bmcast) { + psta = rtw_get_bcmc_stainfo(padapter); + pskb2 = skb_clone(skb, GFP_ATOMIC); + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->dst); + } + + if (psta) { + struct net_device *pnetdev; + + pnetdev = (struct net_device *)padapter->pnetdev; + skb->dev = pnetdev; + skb_set_queue_mapping(skb, rtw_recv_select_queue(skb)); + + rtw_xmit_entry(skb, pnetdev); + + if (bmcast) + skb = pskb2; + else + goto _recv_indicatepkt_end; + } + } + } + + rcu_read_lock(); + rcu_dereference(padapter->pnetdev->rx_handler_data); + rcu_read_unlock(); + + skb->ip_summed = CHECKSUM_NONE; + skb->dev = padapter->pnetdev; + skb->protocol = eth_type_trans(skb, padapter->pnetdev); + + netif_rx(skb); + +_recv_indicatepkt_end: + + /* pointers to NULL before rtw_free_recvframe() */ + precv_frame->pkt = NULL; + + rtw_free_recvframe(precv_frame, pfree_recv_queue); + + return _SUCCESS; + +_recv_indicatepkt_drop: + + /* enqueue back to free_recv_queue */ + rtw_free_recvframe(precv_frame, pfree_recv_queue); + + return _FAIL; +} + static bool recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) { struct list_head *phead, *plist; diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 357f98e22d8a..98eeb16cab6c 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -5,9 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/xmit_osdep.h" -#include "../include/mlme_osdep.h" #include "../include/sta_info.h" static void _rtw_init_stainfo(struct sta_info *psta) @@ -141,6 +138,31 @@ void _rtw_free_sta_priv(struct sta_priv *pstapriv) } } +static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t) +{ + struct recv_reorder_ctrl *preorder_ctrl; + + preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer); + rtw_reordering_ctrl_timeout_handler(preorder_ctrl); +} + +static void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) +{ + timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0); +} + +static void _addba_timer_hdl(struct timer_list *t) +{ + struct sta_info *psta = from_timer(psta, t, addba_retry_timer); + + addba_timer_hdl(psta); +} + +static void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) +{ + timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0); +} + struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { s32 index; diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 3a002cb6834f..e50631848cab 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -222,46 +222,6 @@ void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrat memcpy(pbssrate, supportedrates, *bssrate_len); } -void UpdateBrateTbl(struct adapter *Adapter, u8 *mbrate) -{ - u8 i; - u8 rate; - - /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ - for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - rate = mbrate[i] & 0x7f; - switch (rate) { - case IEEE80211_CCK_RATE_1MB: - case IEEE80211_CCK_RATE_2MB: - case IEEE80211_CCK_RATE_5MB: - case IEEE80211_CCK_RATE_11MB: - case IEEE80211_OFDM_RATE_6MB: - case IEEE80211_OFDM_RATE_12MB: - case IEEE80211_OFDM_RATE_24MB: - mbrate[i] |= IEEE80211_BASIC_RATE_MASK; - break; - } - } -} - -void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) -{ - u8 i; - u8 rate; - - for (i = 0; i < bssratelen; i++) { - rate = bssrateset[i] & 0x7f; - switch (rate) { - case IEEE80211_CCK_RATE_1MB: - case IEEE80211_CCK_RATE_2MB: - case IEEE80211_CCK_RATE_5MB: - case IEEE80211_CCK_RATE_11MB: - bssrateset[i] |= IEEE80211_BASIC_RATE_MASK; - break; - } - } -} - void Save_DM_Func_Flag(struct adapter *padapter) { struct hal_data_8188e *haldata = &padapter->haldata; @@ -1578,10 +1538,8 @@ void beacon_timing_control(struct adapter *padapter) static struct adapter *pbuddy_padapter; -int rtw_handle_dualmac(struct adapter *adapter, bool init) +void rtw_handle_dualmac(struct adapter *adapter, bool init) { - int status = _SUCCESS; - if (init) { if (!pbuddy_padapter) { pbuddy_padapter = adapter; @@ -1594,5 +1552,4 @@ int rtw_handle_dualmac(struct adapter *adapter, bool init) } else { pbuddy_padapter = NULL; } - return status; } diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 24401f3ae2a0..873d2c5c3634 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -33,6 +33,32 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) INIT_LIST_HEAD(&psta_xmitpriv->apsd); } +static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, + u32 alloc_sz) +{ + pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL); + if (!pxmitbuf->pallocated_buf) + return _FAIL; + + pxmitbuf->pbuf = (u8 *)ALIGN((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); + pxmitbuf->dma_transfer_addr = 0; + + pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL); + if (!pxmitbuf->pxmit_urb) { + kfree(pxmitbuf->pallocated_buf); + return _FAIL; + } + + return _SUCCESS; +} + +static void rtw_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, + u32 free_sz) +{ + usb_free_urb(pxmitbuf->pxmit_urb); + kfree(pxmitbuf->pallocated_buf); +} + s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) { int i; @@ -108,7 +134,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (!pxmitpriv->pallocated_xmitbuf) { res = _FAIL; - goto exit; + goto free_frame_buf; } pxmitpriv->pxmitbuf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_xmitbuf), 4); @@ -125,12 +151,12 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->ext_tag = false; /* Tx buf allocation may fail sometimes, so sleep and retry. */ - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + res = rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) { msleep(10); - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + res = rtw_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) - goto exit; + goto free_xmitbuf; } pxmitbuf->flags = XMIT_VO_QUEUE; @@ -148,7 +174,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (!pxmitpriv->pallocated_xmit_extbuf) { res = _FAIL; - goto exit; + goto free_xmitbuf; } pxmitpriv->pxmit_extbuf = (u8 *)ALIGN((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4); @@ -162,10 +188,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->padapter = padapter; pxmitbuf->ext_tag = true; - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); + res = rtw_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); if (res == _FAIL) { res = _FAIL; - goto exit; + goto free_xmit_extbuf; } list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); @@ -176,7 +202,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (rtw_alloc_hwxmits(padapter)) { res = _FAIL; - goto exit; + goto free_xmit_extbuf; } rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); @@ -200,11 +226,54 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) rtl8188eu_init_xmit_priv(padapter); -exit: + return _SUCCESS; +free_xmit_extbuf: + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + while (i--) { + rtw_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); + pxmitbuf++; + } + vfree(pxmitpriv->pallocated_xmit_extbuf); + i = NR_XMITBUFF; +free_xmitbuf: + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + while (i--) { + rtw_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + pxmitbuf++; + } + vfree(pxmitpriv->pallocated_xmitbuf); +free_frame_buf: + vfree(pxmitpriv->pallocated_frame_buf); +exit: return res; } +static void rtw_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) +{ + u16 queue; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + queue = skb_get_queue_mapping(pkt); + if (padapter->registrypriv.wifi_spec) { + if (__netif_subqueue_stopped(padapter->pnetdev, queue) && + (pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD)) + netif_wake_subqueue(padapter->pnetdev, queue); + } else { + if (__netif_subqueue_stopped(padapter->pnetdev, queue)) + netif_wake_subqueue(padapter->pnetdev, queue); + } + + dev_kfree_skb_any(pkt); +} + +void rtw_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe) +{ + if (pxframe->pkt) + rtw_pkt_complete(padapter, pxframe->pkt); + pxframe->pkt = NULL; +} + void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) { int i; @@ -218,13 +287,13 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) return; for (i = 0; i < NR_XMITFRAME; i++) { - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_xmit_complete(padapter, pxmitframe); pxmitframe++; } for (i = 0; i < NR_XMITBUFF; i++) { - rtw_os_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + rtw_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); pxmitbuf++; } @@ -234,7 +303,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; for (i = 0; i < num_xmit_extbuf; i++) { - rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); + rtw_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); pxmitbuf++; } @@ -378,18 +447,59 @@ u8 qos_acm(u8 acm_mask, u8 priority) return change_priority; } +static void rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) +{ + if (!pktptr) { + pr_err("8188eu: pktptr is NULL\n"); + return; + } + if (!pfile) { + pr_err("8188eu: pfile is NULL\n"); + return; + } + pfile->pkt = pktptr; + pfile->cur_addr = pktptr->data; + pfile->buf_start = pktptr->data; + pfile->pkt_len = pktptr->len; + pfile->buf_len = pktptr->len; + + pfile->cur_buffer = pfile->buf_start; +} + +static uint rtw_remainder_len(struct pkt_file *pfile) +{ + return pfile->buf_len - ((size_t)(pfile->cur_addr) - + (size_t)(pfile->buf_start)); +} + +static uint rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) +{ + uint len; + + len = rtw_remainder_len(pfile); + len = (rlen > len) ? len : rlen; + + if (rmem) + skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len); + + pfile->cur_addr += len; + pfile->pkt_len -= len; + + return len; +} + static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) { struct ethhdr etherhdr; struct iphdr ip_hdr; s32 user_prio = 0; - _rtw_open_pktfile(ppktfile->pkt, ppktfile); - _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); + rtw_open_pktfile(ppktfile->pkt, ppktfile); + rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); /* get user_prio from IP hdr */ if (pattrib->ether_type == 0x0800) { - _rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); + rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); /* user_prio = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ user_prio = ip_hdr.tos >> 5; } else if (pattrib->ether_type == 0x888e) { @@ -418,8 +528,8 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p - _rtw_open_pktfile(pkt, &pktfile); - _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); + rtw_open_pktfile(pkt, &pktfile); + rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); pattrib->ether_type = ntohs(etherhdr.h_proto); @@ -447,7 +557,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p /* to prevent DHCP protocol fail */ u8 tmp[24]; - _rtw_pktfile_read(&pktfile, &tmp[0], 24); + rtw_pktfile_read(&pktfile, &tmp[0], 24); pattrib->dhcp_pkt = 0; if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ if (((tmp[21] == 68) && (tmp[23] == 67)) || @@ -460,9 +570,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p } } - if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) - rtw_set_scan_deny(padapter, 3000); - /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ if ((pattrib->ether_type == 0x0806) || (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1); @@ -897,8 +1004,8 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct goto exit; } - _rtw_open_pktfile(pkt, &pktfile); - _rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen); + rtw_open_pktfile(pkt, &pktfile); + rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen); frg_inx = 0; frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ @@ -956,9 +1063,9 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct if (bmcst) { /* don't do fragment to broadcast/multicast packets */ - mem_sz = _rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen); + mem_sz = rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen); } else { - mem_sz = _rtw_pktfile_read(&pktfile, pframe, mpdu_len); + mem_sz = rtw_pktfile_read(&pktfile, pframe, mpdu_len); } pframe += mem_sz; @@ -970,7 +1077,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct frg_inx++; - if (bmcst || rtw_endofpktfile(&pktfile)) { + if (bmcst || pktfile.pkt_len == 0) { pattrib->nr_frags = frg_inx; pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz : 0) + @@ -1286,7 +1393,7 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram spin_unlock_bh(&pfree_xmit_queue->lock); if (pndis_pkt) - rtw_os_pkt_complete(padapter, pndis_pkt); + rtw_pkt_complete(padapter, pndis_pkt); exit: @@ -1945,7 +2052,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) spin_unlock_bh(&psta->sleep_q.lock); if (rtl8188eu_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta->sleep_q.lock); } @@ -1995,7 +2102,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) spin_unlock_bh(&psta_bmc->sleep_q.lock); if (rtl8188eu_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta_bmc->sleep_q.lock); } @@ -2069,7 +2176,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst pxmitframe->attrib.triggered = 1; if (rtl8188eu_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_xmit_complete(padapter, pxmitframe); if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { pstapriv->tim_bitmap &= ~BIT(psta->aid); @@ -2136,3 +2243,105 @@ void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status) if (pxmitpriv->ack_tx) rtw_sctx_done_err(&pack_tx_ops, status); } + +static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u16 queue; + + queue = skb_get_queue_mapping(pkt); + if (padapter->registrypriv.wifi_spec) { + /* No free space for Tx, tx_worker is too slow */ + if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) + netif_stop_subqueue(padapter->pnetdev, queue); + } else { + if (pxmitpriv->free_xmitframe_cnt <= 4) { + if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue))) + netif_stop_subqueue(padapter->pnetdev, queue); + } + } +} + +static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct list_head *phead, *plist; + struct sk_buff *newskb; + struct sta_info *psta = NULL; + s32 res; + + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* free sta asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + + plist = plist->next; + + /* avoid come from STA1 and send back STA1 */ + if (!memcmp(psta->hwaddr, &skb->data[6], 6)) + continue; + + newskb = skb_copy(skb, GFP_ATOMIC); + + if (newskb) { + memcpy(newskb->data, psta->hwaddr, 6); + res = rtw_xmit(padapter, &newskb); + if (res < 0) { + pxmitpriv->tx_drop++; + dev_kfree_skb_any(newskb); + } else { + pxmitpriv->tx_pkts++; + } + } else { + pxmitpriv->tx_drop++; + + spin_unlock_bh(&pstapriv->asoc_list_lock); + return false; /* Caller shall tx this multicast frame via normal way. */ + } + } + + spin_unlock_bh(&pstapriv->asoc_list_lock); + dev_kfree_skb_any(skb); + return true; +} + +netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + s32 res = 0; + + if (!rtw_if_up(padapter)) + goto drop_packet; + + rtw_check_xmit_resource(padapter, pkt); + + if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) && + (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) && + (padapter->registrypriv.wifi_spec == 0)) { + if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) { + res = rtw_mlcst2unicst(padapter, pkt); + if (res) + goto exit; + } + } + + res = rtw_xmit(padapter, &pkt); + if (res < 0) + goto drop_packet; + + pxmitpriv->tx_pkts++; + goto exit; + +drop_packet: + pxmitpriv->tx_drop++; + dev_kfree_skb_any(pkt); + +exit: + return NETDEV_TX_OK; +} diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c index 7901d0afa2e7..23b7205722b5 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -166,7 +166,14 @@ static u32 array_agc_tab_1t_8188e[] = { 0xC78, 0x407F0001, }; -enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) +static void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) +{ + rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data); + /* Add 1us delay between BB/RF register setting. */ + udelay(1); +} + +int ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) { u32 hex = 0; u32 i = 0; @@ -176,7 +183,6 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) struct adapter *adapter = dm_odm->Adapter; struct xmit_frame *pxmit_frame = NULL; u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; hex += ODM_ITRF_USB << 8; hex += ODM_CE << 16; @@ -187,7 +193,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; + return -ENOMEM; } } @@ -238,10 +244,10 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) if (biol) { if (!rtl8188e_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { printk("~~~ %s IOL_exec_cmds Failed !!!\n", __func__); - rst = HAL_STATUS_FAILURE; + return -1; } } - return rst; + return 0; } /****************************************************************************** @@ -442,7 +448,31 @@ static u32 array_phy_reg_1t_8188e[] = { 0xF00, 0x00000300, }; -enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) +static void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) +{ + if (Addr == 0xfe) { + msleep(50); + } else if (Addr == 0xfd) { + mdelay(5); + } else if (Addr == 0xfc) { + mdelay(1); + } else if (Addr == 0xfb) { + udelay(50); + } else if (Addr == 0xfa) { + udelay(5); + } else if (Addr == 0xf9) { + udelay(1); + } else { + if (Addr == 0xa24) + pDM_Odm->RFCalibrateInfo.RegA24 = Data; + rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data); + + /* Add 1us delay between BB/RF register setting. */ + udelay(1); + } +} + +int ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) { u32 hex = 0; u32 i = 0; @@ -452,7 +482,6 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) struct adapter *adapter = dm_odm->Adapter; struct xmit_frame *pxmit_frame = NULL; u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; hex += ODM_ITRF_USB << 8; hex += ODM_CE << 16; hex += 0xFF000000; @@ -462,7 +491,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; + return -ENOMEM; } } @@ -544,11 +573,11 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) } if (biol) { if (!rtl8188e_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { - rst = HAL_STATUS_FAILURE; pr_info("~~~ IOL Config %s Failed !!!\n", __func__); + return -1; } } - return rst; + return 0; } /****************************************************************************** @@ -647,6 +676,25 @@ static u32 array_phy_reg_pg_8188e[] = { }; +static void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, + u32 Data) +{ + if (Addr == 0xfe) + msleep(50); + else if (Addr == 0xfd) + mdelay(5); + else if (Addr == 0xfc) + mdelay(1); + else if (Addr == 0xfb) + udelay(50); + else if (Addr == 0xfa) + udelay(5); + else if (Addr == 0xf9) + udelay(1); + else + storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data); +} + void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm) { u32 hex; diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c index 77b25885c63b..da71867bcca3 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c @@ -126,7 +126,12 @@ static u32 array_MAC_REG_8188E[] = { 0x70B, 0x00000087, }; -enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) +static void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) +{ + rtw_write8(pDM_Odm->Adapter, Addr, Data); +} + +int ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) { #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i + 1]; } while (0) @@ -139,7 +144,6 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) struct adapter *adapt = dm_odm->Adapter; struct xmit_frame *pxmit_frame = NULL; u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; hex += ODM_ITRF_USB << 8; hex += ODM_CE << 16; hex += 0xFF000000; @@ -150,7 +154,7 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt); if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; + return -ENOMEM; } } @@ -201,8 +205,8 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) if (biol) { if (!rtl8188e_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { pr_info("~~~ MAC IOL_exec_cmds Failed !!!\n"); - rst = HAL_STATUS_FAILURE; + return -1; } } - return rst; + return 0; } diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c index 08cbfce3808d..a4c3d3d149f7 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -130,7 +130,37 @@ static u32 Array_RadioA_1T_8188E[] = { 0x000, 0x00033E60, }; -enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) +static void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Data, u32 RegAddr) +{ + if (Addr == 0xffe) { + msleep(50); + } else if (Addr == 0xfd) { + mdelay(5); + } else if (Addr == 0xfc) { + mdelay(1); + } else if (Addr == 0xfb) { + udelay(50); + } else if (Addr == 0xfa) { + udelay(5); + } else if (Addr == 0xf9) { + udelay(1); + } else { + rtl8188e_PHY_SetRFReg(pDM_Odm->Adapter, RegAddr, bRFRegOffsetMask, Data); + /* Add 1us delay between BB/RF register setting. */ + udelay(1); + } +} + +static void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) +{ + u32 content = 0x1000; /* RF_Content: radioa_txt */ + u32 maskforPhySet = (u32)(content & 0xE000); + + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, Addr | maskforPhySet); +} + +int ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) { #define READ_NEXT_PAIR(v1, v2, i) do \ { i += 2; v1 = Array[i]; \ @@ -144,7 +174,6 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) struct adapter *Adapter = pDM_Odm->Adapter; struct xmit_frame *pxmit_frame = NULL; u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; hex += ODM_ITRF_USB << 8; hex += ODM_CE << 16; @@ -155,7 +184,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter); if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; + return -ENOMEM; } } @@ -232,9 +261,9 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) } if (biol) { if (!rtl8188e_IOL_exec_cmds_sync(pDM_Odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { - rst = HAL_STATUS_FAILURE; pr_info("~~~ IOL Config %s Failed !!!\n", __func__); + return -1; } } - return rst; + return 0; } diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index 6a1cdc67335b..33967eb3c0d0 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -137,176 +137,3 @@ void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg) } } } - -static void one_out_pipe(struct adapter *adapter) -{ - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ -} - -static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) -{ - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - - if (wifi_cfg) { /* WMM */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:L */ - - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - - } else {/* typical setting */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:L */ - - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - } -} - -static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) -{ - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - - if (wifi_cfg) {/* for WMM */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:N, 2:L */ - - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - - } else {/* typical setting */ - /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ - /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */ - /* 0:H, 1:N, 2:L */ - - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - } -} - -bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe) -{ - struct registry_priv *pregistrypriv = &adapter->registrypriv; - bool wifi_cfg = pregistrypriv->wifi_spec; - bool result = true; - - switch (numoutpipe) { - case 2: - two_out_pipe(adapter, wifi_cfg); - break; - case 3: - three_out_pipe(adapter, wifi_cfg); - break; - case 1: - one_out_pipe(adapter); - break; - default: - result = false; - break; - } - return result; -} - -/* -* C2H event format: -* Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID -* BITS [127:120] [119:16] [15:8] [7:4] [3:0] -*/ - -s32 c2h_evt_read(struct adapter *adapter, u8 *buf) -{ - s32 ret = _FAIL; - struct c2h_evt_hdr *c2h_evt; - int i; - u8 trigger; - - if (!buf) - goto exit; - - ret = rtw_read8(adapter, REG_C2HEVT_CLEAR, &trigger); - if (ret) - return _FAIL; - - if (trigger == C2H_EVT_HOST_CLOSE) - goto exit; /* Not ready */ - else if (trigger != C2H_EVT_FW_CLOSE) - goto clear_evt; /* Not a valid value */ - - c2h_evt = (struct c2h_evt_hdr *)buf; - - memset(c2h_evt, 0, 16); - - ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL, buf); - if (ret) { - ret = _FAIL; - goto clear_evt; - } - - ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1, buf + 1); - if (ret) { - ret = _FAIL; - goto clear_evt; - } - /* Read the content */ - for (i = 0; i < c2h_evt->plen; i++) { - ret = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + - sizeof(*c2h_evt) + i, c2h_evt->payload + i); - if (ret) { - ret = _FAIL; - goto clear_evt; - } - } - - ret = _SUCCESS; - -clear_evt: - /* - * Clear event to notify FW we have read the command. - * If this field isn't clear, the FW won't update the next - * command message. - */ - rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); -exit: - return ret; -} diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 54cc3d7789cd..38f357e8aeda 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -3,38 +3,38 @@ #include "../include/drv_types.h" -static u8 odm_QueryRxPwrPercentage(s8 AntPower) +static u8 odm_query_rxpwrpercentage(s8 antpower) { - if ((AntPower <= -100) || (AntPower >= 20)) - return 0; - else if (AntPower >= 0) - return 100; + if ((antpower <= -100) || (antpower >= 20)) + return 0; + else if (antpower >= 0) + return 100; else - return 100 + AntPower; + return 100 + antpower; } -static s32 odm_SignalScaleMapping(struct odm_dm_struct *dm_odm, s32 CurrSig) +static s32 odm_signal_scale_mapping(struct odm_dm_struct *dm_odm, s32 currsig) { - s32 RetSig = 0; - - if (CurrSig >= 51 && CurrSig <= 100) - RetSig = 100; - else if (CurrSig >= 41 && CurrSig <= 50) - RetSig = 80 + ((CurrSig - 40) * 2); - else if (CurrSig >= 31 && CurrSig <= 40) - RetSig = 66 + (CurrSig - 30); - else if (CurrSig >= 21 && CurrSig <= 30) - RetSig = 54 + (CurrSig - 20); - else if (CurrSig >= 10 && CurrSig <= 20) - RetSig = 42 + (((CurrSig - 10) * 2) / 3); - else if (CurrSig >= 5 && CurrSig <= 9) - RetSig = 22 + (((CurrSig - 5) * 3) / 2); - else if (CurrSig >= 1 && CurrSig <= 4) - RetSig = 6 + (((CurrSig - 1) * 3) / 2); + s32 retsig; + + if (currsig >= 51 && currsig <= 100) + retsig = 100; + else if (currsig >= 41 && currsig <= 50) + retsig = 80 + ((currsig - 40) * 2); + else if (currsig >= 31 && currsig <= 40) + retsig = 66 + (currsig - 30); + else if (currsig >= 21 && currsig <= 30) + retsig = 54 + (currsig - 20); + else if (currsig >= 10 && currsig <= 20) + retsig = 42 + (((currsig - 10) * 2) / 3); + else if (currsig >= 5 && currsig <= 9) + retsig = 22 + (((currsig - 5) * 3) / 2); + else if (currsig >= 1 && currsig <= 4) + retsig = 6 + (((currsig - 1) * 3) / 2); else - RetSig = CurrSig; + retsig = currsig; - return RetSig; + return retsig; } static u8 odm_evm_db_to_percentage(s8 value) @@ -117,7 +117,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, break; } rx_pwr_all += 6; - PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all); if (!cck_highpwr) { if (PWDB_ALL >= 80) PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80; @@ -162,7 +162,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, pPhyInfo->RxPwr[i] = rx_pwr[i]; /* Translate DBM to percentage. */ - RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]); + RSSI = odm_query_rxpwrpercentage(rx_pwr[i]); total_rssi += RSSI; pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; @@ -173,7 +173,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; - PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all); pPhyInfo->RxPWDBAll = PWDB_ALL; pPhyInfo->RxPower = rx_pwr_all; @@ -200,10 +200,10 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ if (isCCKrate) { - pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */ + pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */ } else { if (rf_rx_num != 0) - pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(dm_odm, total_rssi /= rf_rx_num)); + pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, total_rssi /= rf_rx_num)); } /* For 88E HW Antenna Diversity */ @@ -347,8 +347,3 @@ void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, pPktinfo, adapt); odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo); } - -enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *dm_odm) -{ - return ODM_ReadAndConfig_RadioA_1T_8188E(dm_odm); -} diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c deleted file mode 100644 index 0fa17a99f9e9..000000000000 --- a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c +++ /dev/null @@ -1,89 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#include "../include/drv_types.h" - -static void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Data, u32 RegAddr) -{ - if (Addr == 0xffe) { - msleep(50); - } else if (Addr == 0xfd) { - mdelay(5); - } else if (Addr == 0xfc) { - mdelay(1); - } else if (Addr == 0xfb) { - udelay(50); - } else if (Addr == 0xfa) { - udelay(5); - } else if (Addr == 0xf9) { - udelay(1); - } else { - rtl8188e_PHY_SetRFReg(pDM_Odm->Adapter, RegAddr, bRFRegOffsetMask, Data); - /* Add 1us delay between BB/RF register setting. */ - udelay(1); - } -} - -void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) -{ - u32 content = 0x1000; /* RF_Content: radioa_txt */ - u32 maskforPhySet = (u32)(content & 0xE000); - - odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, Addr | maskforPhySet); -} - -void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) -{ - rtw_write8(pDM_Odm->Adapter, Addr, Data); -} - -void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) -{ - rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data); - /* Add 1us delay between BB/RF register setting. */ - udelay(1); -} - -void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Bitmask, u32 Data) -{ - if (Addr == 0xfe) - msleep(50); - else if (Addr == 0xfd) - mdelay(5); - else if (Addr == 0xfc) - mdelay(1); - else if (Addr == 0xfb) - udelay(50); - else if (Addr == 0xfa) - udelay(5); - else if (Addr == 0xf9) - udelay(1); - else - storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data); -} - -void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) -{ - if (Addr == 0xfe) { - msleep(50); - } else if (Addr == 0xfd) { - mdelay(5); - } else if (Addr == 0xfc) { - mdelay(1); - } else if (Addr == 0xfb) { - udelay(50); - } else if (Addr == 0xfa) { - udelay(5); - } else if (Addr == 0xf9) { - udelay(1); - } else { - if (Addr == 0xa24) - pDM_Odm->RFCalibrateInfo.RegA24 = Data; - rtl8188e_PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data); - - /* Add 1us delay between BB/RF register setting. */ - udelay(1); - } -} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index b01ee1695fee..8310d7f53982 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -5,8 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/mlme_osdep.h" #include "../include/rtw_ioctl_set.h" #include "../include/rtl8188e_hal.h" diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 5b8f1a912bbb..158260547f2b 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -526,43 +526,38 @@ void rtl8188e_ReadEFuse(struct adapter *Adapter, u16 _size_byte, u8 *pbuf) Hal_EfuseReadEFuse88E(Adapter, 0, _size_byte, pbuf); } -static void dump_chip_info(struct HAL_VERSION chip_vers) +static void dump_chip_info(struct adapter *adapter, struct HAL_VERSION chip_vers) { - uint cnt = 0; - char buf[128]; - - cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_"); - cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ? - "Normal_Chip" : "Test_Chip"); - cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ? - "TSMC" : "UMC"); + struct net_device *netdev = adapter->pnetdev; + char *cut = NULL; + char buf[25]; switch (chip_vers.CUTVersion) { case A_CUT_VERSION: - cnt += sprintf((buf + cnt), "A_CUT_"); + cut = "A_CUT"; break; case B_CUT_VERSION: - cnt += sprintf((buf + cnt), "B_CUT_"); + cut = "B_CUT"; break; case C_CUT_VERSION: - cnt += sprintf((buf + cnt), "C_CUT_"); + cut = "C_CUT"; break; case D_CUT_VERSION: - cnt += sprintf((buf + cnt), "D_CUT_"); + cut = "D_CUT"; break; case E_CUT_VERSION: - cnt += sprintf((buf + cnt), "E_CUT_"); + cut = "E_CUT"; break; default: - cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion); + snprintf(buf, sizeof(buf), "UNKNOWN_CUT(%d)", chip_vers.CUTVersion); + cut = buf; break; } - cnt += sprintf((buf + cnt), "1T1R_"); - - cnt += sprintf((buf + cnt), "RomVer(%d)\n", 0); - - pr_info("%s", buf); + netdev_dbg(netdev, "Chip Version Info: CHIP_8188E_%s_%s_%s_1T1R_RomVer(%d)\n", + IS_NORMAL_CHIP(chip_vers) ? "Normal_Chip" : "Test_Chip", + IS_CHIP_VENDOR_TSMC(chip_vers) ? "TSMC" : "UMC", + cut, 0); } void rtl8188e_read_chip_version(struct adapter *padapter) @@ -581,7 +576,7 @@ void rtl8188e_read_chip_version(struct adapter *padapter) ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ - dump_chip_info(ChipVersion); + dump_chip_info(padapter, ChipVersion); pHalData->VersionID = ChipVersion; } @@ -688,6 +683,7 @@ Hal_EfuseParseIDCode88E( ) { struct eeprom_priv *pEEPROM = &padapter->eeprompriv; + struct net_device *netdev = padapter->pnetdev; u16 EEPROMId; /* Check 0x8129 again for making sure autoload status!! */ @@ -699,7 +695,7 @@ Hal_EfuseParseIDCode88E( pEEPROM->bautoload_fail_flag = false; } - pr_info("EEPROM ID = 0x%04x\n", EEPROMId); + netdev_dbg(netdev, "EEPROM ID = 0x%04x\n", EEPROMId); } static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index dea6d915a1f4..532c63bce0bf 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -12,26 +12,12 @@ /* 1. BB register R/W API */ /* */ -/** -* Function: phy_CalculateBitShift -* -* OverView: Get shifted position of the BitMask -* -* Input: -* u32 BitMask, -* -* Output: none -* Return: u32 Return the shift bit bit position of the mask -*/ -static u32 phy_CalculateBitShift(u32 BitMask) +/* Get shifted position of the bit mask */ +static u32 phy_calculate_bit_shift(u32 bitmask) { - u32 i; + u32 i = ffs(bitmask); - for (i = 0; i <= 31; i++) { - if (((BitMask >> i) & 0x1) == 1) - break; - } - return i; + return i ? i - 1 : 32; } /** @@ -62,7 +48,7 @@ rtl8188e_PHY_QueryBBReg( if (res) return 0; - BitShift = phy_CalculateBitShift(BitMask); + BitShift = phy_calculate_bit_shift(BitMask); ReturnValue = (OriginalValue & BitMask) >> BitShift; return ReturnValue; } @@ -95,7 +81,7 @@ void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u3 if (res) return; - BitShift = phy_CalculateBitShift(BitMask); + BitShift = phy_calculate_bit_shift(BitMask); Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); } @@ -267,7 +253,7 @@ u32 rtl8188e_PHY_QueryRFReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask) Original_Value = phy_RFSerialRead(Adapter, RegAddr); - BitShift = phy_CalculateBitShift(BitMask); + BitShift = phy_calculate_bit_shift(BitMask); Readback_Value = (Original_Value & BitMask) >> BitShift; return Readback_Value; } @@ -302,7 +288,7 @@ rtl8188e_PHY_SetRFReg( /* RF data is 12 bits only */ if (BitMask != bRFRegOffsetMask) { Original_Value = phy_RFSerialRead(Adapter, RegAddr); - BitShift = phy_CalculateBitShift(BitMask); + BitShift = phy_calculate_bit_shift(BitMask); Data = ((Original_Value & (~BitMask)) | (Data << BitShift)); } @@ -337,7 +323,7 @@ s32 PHY_MACConfig8188E(struct adapter *Adapter) /* */ /* Config MAC */ /* */ - if (HAL_STATUS_FAILURE == ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv)) + if (ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv)) rtStatus = _FAIL; /* 2010.07.13 AMPDU aggregation number B */ @@ -469,7 +455,7 @@ static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) /* 1. Read PHY_REG.TXT BB INIT!! */ /* We will separate as 88C / 92C according to chip version */ /* */ - if (HAL_STATUS_FAILURE == ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv)) + if (ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv)) return _FAIL; /* 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ @@ -479,7 +465,7 @@ static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) } /* 3. BB AGC table Initialization */ - if (HAL_STATUS_FAILURE == ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv)) + if (ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv)) return _FAIL; return _SUCCESS; @@ -521,15 +507,6 @@ PHY_BBConfig8188E( return rtStatus; } -int PHY_RFConfig8188E(struct adapter *Adapter) -{ - int rtStatus = _SUCCESS; - - /* RF config */ - rtStatus = PHY_RF6052_Config8188E(Adapter); - return rtStatus; -} - static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, u8 *ofdmPowerLevel, u8 *BW20PowerLevel, u8 *BW40PowerLevel) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index d043b7bc4142..e5ec6e563fbd 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -366,7 +366,7 @@ rtl8188e_PHY_RF6052SetOFDMTxPower( } } -static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) +int phy_RF6052_Config_ParaFile(struct adapter *Adapter) { struct bb_reg_def *pPhyReg; struct hal_data_8188e *pHalData = &Adapter->haldata; @@ -396,7 +396,7 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) udelay(1);/* PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv)) + if (ODM_ReadAndConfig_RadioA_1T_8188E(&pHalData->odmpriv)) rtStatus = _FAIL; /*----Restore RFENV control type----*/; @@ -404,14 +404,3 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) return rtStatus; } - -int PHY_RF6052_Config8188E(struct adapter *Adapter) -{ - int rtStatus = _SUCCESS; - - /* */ - /* Config BB and RF */ - /* */ - rtStatus = phy_RF6052_Config_ParaFile(Adapter); - return rtStatus; -} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c deleted file mode 100644 index 46b871f3f631..000000000000 --- a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#define _RTL8188E_XMIT_C_ - -#include "../include/osdep_service.h" -#include "../include/drv_types.h" -#include "../include/rtl8188e_hal.h" - -void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) -{ - struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; - - if (txrpt_ccx->int_ccx) { - if (txrpt_ccx->pkt_ok) - rtw_ack_tx_done(&adapter->xmitpriv, - RTW_SCTX_DONE_SUCCESS); - else - rtw_ack_tx_done(&adapter->xmitpriv, - RTW_SCTX_DONE_CCX_PKT_FAIL); - } -} diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c deleted file mode 100644 index def6d0d6e402..000000000000 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#define _RTL8188EU_RECV_C_ -#include "../include/osdep_service.h" -#include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/mlme_osdep.h" - -#include "../include/usb_ops.h" -#include "../include/wifi.h" - -#include "../include/rtl8188e_hal.h" - -int rtl8188eu_init_recv_priv(struct adapter *padapter) -{ - struct recv_priv *precvpriv = &padapter->recvpriv; - int i, res = _SUCCESS; - struct recv_buf *precvbuf; - - tasklet_init(&precvpriv->recv_tasklet, - rtl8188eu_recv_tasklet, - (unsigned long)padapter); - - /* init recv_buf */ - rtw_init_queue(&precvpriv->free_recv_buf_queue); - - precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, - GFP_KERNEL); - if (!precvpriv->pallocated_recv_buf) { - res = _FAIL; - goto exit; - } - - precvpriv->precv_buf = (u8 *)ALIGN((size_t)(precvpriv->pallocated_recv_buf), 4); - - precvbuf = (struct recv_buf *)precvpriv->precv_buf; - - for (i = 0; i < NR_RECVBUFF; i++) { - res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); - if (res == _FAIL) - break; - precvbuf->adapter = padapter; - precvbuf++; - } - precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; - skb_queue_head_init(&precvpriv->rx_skb_queue); - { - int i; - size_t tmpaddr = 0; - size_t alignment = 0; - struct sk_buff *pskb = NULL; - - skb_queue_head_init(&precvpriv->free_recv_skb_queue); - - for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { - pskb = __netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL); - if (pskb) { - pskb->dev = padapter->pnetdev; - tmpaddr = (size_t)pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); - skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); - - skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); - } - pskb = NULL; - } - } -exit: - return res; -} - -void rtl8188eu_free_recv_priv(struct adapter *padapter) -{ - int i; - struct recv_buf *precvbuf; - struct recv_priv *precvpriv = &padapter->recvpriv; - - precvbuf = (struct recv_buf *)precvpriv->precv_buf; - - for (i = 0; i < NR_RECVBUFF; i++) { - rtw_os_recvbuf_resource_free(padapter, precvbuf); - precvbuf++; - } - - kfree(precvpriv->pallocated_recv_buf); - - skb_queue_purge(&precvpriv->rx_skb_queue); - - skb_queue_purge(&precvpriv->free_recv_skb_queue); -} diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index bdfa51949289..8e4a5acc0b18 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -431,7 +431,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); /* always return ndis_packet after rtw_xmitframe_coalesce */ - rtw_os_xmit_complete(adapt, pxmitframe); + rtw_xmit_complete(adapt, pxmitframe); /* 3 2. aggregate same priority and same DA(AP or STA) frames */ pfirstframe = pxmitframe; @@ -501,7 +501,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); /* always return ndis_packet after rtw_xmitframe_coalesce */ - rtw_os_xmit_complete(adapt, pxmitframe); + rtw_xmit_complete(adapt, pxmitframe); /* (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */ update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz, true); diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index ff074d246dab..d28b4dc2a767 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -13,40 +13,77 @@ #include "../include/usb_osintf.h" #include "../include/HalPwrSeqCmd.h" -static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe) +static void one_out_pipe(struct adapter *adapter) { - struct hal_data_8188e *haldata = &adapt->haldata; + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - switch (NumOutPipe) { - case 3: - haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ; - haldata->OutEpNumber = 3; - break; - case 2: - haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; - haldata->OutEpNumber = 2; - break; - case 1: - haldata->OutEpQueueSel = TX_SELE_HQ; - haldata->OutEpNumber = 1; - break; - default: - break; + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ +} + +static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + /* 0:H, 1:L */ + + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ + + if (wifi_cfg) { + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ + } else { + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ } } -static bool HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumOutPipe) +static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) { + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + /* 0:H, 1:N, 2:L */ - _ConfigNormalChipOutEP_8188E(adapt, NumOutPipe); - return Hal_MappingOutPipe(adapt, NumOutPipe); + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ + + pdvobjpriv->Queue2Pipe[3] = wifi_cfg ? + pdvobjpriv->RtOutPipe[1] : pdvobjpriv->RtOutPipe[2];/* BK */ } -void rtl8188eu_interface_configure(struct adapter *adapt) +int rtl8188eu_interface_configure(struct adapter *adapt) { + struct registry_priv *pregistrypriv = &adapt->registrypriv; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt); + struct hal_data_8188e *haldata = &adapt->haldata; + bool wifi_cfg = pregistrypriv->wifi_spec; - HalUsbSetQueuePipeMapping8188EUsb(adapt, pdvobjpriv->RtNumOutPipes); + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + + switch (pdvobjpriv->RtNumOutPipes) { + case 3: + haldata->out_ep_extra_queues = TX_SELE_LQ | TX_SELE_NQ; + three_out_pipe(adapt, wifi_cfg); + break; + case 2: + haldata->out_ep_extra_queues = TX_SELE_NQ; + two_out_pipe(adapt, wifi_cfg); + break; + case 1: + one_out_pipe(adapt); + break; + default: + return -ENXIO; + } + + return 0; } u32 rtl8188eu_InitPowerOn(struct adapter *adapt) @@ -116,32 +153,24 @@ static void _InitQueueReservedPage(struct adapter *Adapter) { struct hal_data_8188e *haldata = &Adapter->haldata; struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u32 numHQ = 0; - u32 numLQ = 0; - u32 numNQ = 0; - u32 numPubQ; - u32 value32; - u8 value8; - bool bWiFiConfig = pregistrypriv->wifi_spec; - - if (bWiFiConfig) { - if (haldata->OutEpQueueSel & TX_SELE_HQ) - numHQ = 0x29; + u8 numLQ = 0; + u8 numNQ = 0; + u8 numPubQ; - if (haldata->OutEpQueueSel & TX_SELE_LQ) + if (pregistrypriv->wifi_spec) { + if (haldata->out_ep_extra_queues & TX_SELE_LQ) numLQ = 0x1C; /* NOTE: This step shall be proceed before writing REG_RQPN. */ - if (haldata->OutEpQueueSel & TX_SELE_NQ) + if (haldata->out_ep_extra_queues & TX_SELE_NQ) numNQ = 0x1C; - value8 = (u8)_NPQ(numNQ); - rtw_write8(Adapter, REG_RQPN_NPQ, value8); - numPubQ = 0xA8 - numHQ - numLQ - numNQ; + rtw_write8(Adapter, REG_RQPN_NPQ, numNQ); + + numPubQ = 0xA8 - NUM_HQ - numLQ - numNQ; /* TX DMA */ - value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; - rtw_write32(Adapter, REG_RQPN, value32); + rtw_write32(Adapter, REG_RQPN, LD_RQPN | numPubQ << 16 | numLQ << 8 | NUM_HQ); } else { rtw_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ rtw_write16(Adapter, REG_RQPN_NPQ, 0x0d); @@ -187,69 +216,20 @@ static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); } -static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) -{ - struct hal_data_8188e *haldata = &Adapter->haldata; - - u16 value = 0; - switch (haldata->OutEpQueueSel) { - case TX_SELE_HQ: - value = QUEUE_HIGH; - break; - case TX_SELE_LQ: - value = QUEUE_LOW; - break; - case TX_SELE_NQ: - value = QUEUE_NORMAL; - break; - default: - break; - } - _InitNormalChipRegPriority(Adapter, value, value, value, value, - value, value); -} - static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter) { - struct hal_data_8188e *haldata = &Adapter->haldata; struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; - u16 valueHi = 0; - u16 valueLow = 0; - - switch (haldata->OutEpQueueSel) { - case (TX_SELE_HQ | TX_SELE_LQ): - valueHi = QUEUE_HIGH; - valueLow = QUEUE_LOW; - break; - case (TX_SELE_NQ | TX_SELE_LQ): - valueHi = QUEUE_NORMAL; - valueLow = QUEUE_LOW; - break; - case (TX_SELE_HQ | TX_SELE_NQ): - valueHi = QUEUE_HIGH; - valueLow = QUEUE_NORMAL; - break; - default: - break; - } + u16 bkQ, voQ; if (!pregistrypriv->wifi_spec) { - beQ = valueLow; - bkQ = valueLow; - viQ = valueHi; - voQ = valueHi; - mgtQ = valueHi; - hiQ = valueHi; + bkQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; } else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */ - beQ = valueLow; - bkQ = valueHi; - viQ = valueHi; - voQ = valueLow; - mgtQ = valueHi; - hiQ = valueHi; + bkQ = QUEUE_HIGH; + voQ = QUEUE_NORMAL; } - _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); + _InitNormalChipRegPriority(Adapter, QUEUE_NORMAL, bkQ, QUEUE_HIGH, + voQ, QUEUE_HIGH, QUEUE_HIGH); } static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter) @@ -277,11 +257,12 @@ static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter) static void _InitQueuePriority(struct adapter *Adapter) { - struct hal_data_8188e *haldata = &Adapter->haldata; + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter); - switch (haldata->OutEpNumber) { + switch (pdvobjpriv->RtNumOutPipes) { case 1: - _InitNormalChipOneOutEpPriority(Adapter); + _InitNormalChipRegPriority(Adapter, QUEUE_HIGH, QUEUE_HIGH, QUEUE_HIGH, + QUEUE_HIGH, QUEUE_HIGH, QUEUE_HIGH); break; case 2: _InitNormalChipTwoOutEpPriority(Adapter); @@ -515,8 +496,7 @@ static int _InitBeaconParameters(struct adapter *Adapter) return 0; } -static void _BeaconFunctionEnable(struct adapter *Adapter, - bool Enable, bool Linked) +static void _BeaconFunctionEnable(struct adapter *Adapter) { rtw_write8(Adapter, REG_BCN_CTRL, (BIT(4) | BIT(3) | BIT(1))); @@ -567,7 +547,6 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) { u8 value8 = 0; u16 value16; - u8 txpktbuf_bndy; u32 status = _SUCCESS; int res; struct hal_data_8188e *haldata = &Adapter->haldata; @@ -600,13 +579,6 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) /* HW GPIO pin. Before PHY_RFConfig8192C. */ /* 2010/08/26 MH If Efuse does not support sective suspend then disable the function. */ - if (!pregistrypriv->wifi_spec) { - txpktbuf_bndy = TX_PAGE_BOUNDARY_88E; - } else { - /* for WMM */ - txpktbuf_bndy = WMM_NORMAL_TX_PAGE_BOUNDARY_88E; - } - _InitQueueReservedPage(Adapter); _InitQueuePriority(Adapter); _InitPageBoundary(Adapter); @@ -639,7 +611,7 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) if (status == _FAIL) goto exit; - status = PHY_RFConfig8188E(Adapter); + status = phy_RF6052_Config_ParaFile(Adapter); if (status == _FAIL) goto exit; @@ -647,9 +619,9 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) if (status == _FAIL) goto exit; - _InitTxBufferBoundary(Adapter, txpktbuf_bndy); + _InitTxBufferBoundary(Adapter, TX_PAGE_BOUNDARY_88E); - status = InitLLTTable(Adapter, txpktbuf_bndy); + status = InitLLTTable(Adapter, TX_PAGE_BOUNDARY_88E); if (status == _FAIL) goto exit; @@ -922,7 +894,7 @@ static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool } } -void ReadAdapterInfo8188EU(struct adapter *Adapter) +int ReadAdapterInfo8188EU(struct adapter *Adapter) { struct eeprom_priv *eeprom = &Adapter->eeprompriv; struct led_priv *ledpriv = &Adapter->ledpriv; @@ -933,13 +905,13 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter) /* check system boot selection */ res = rtw_read8(Adapter, REG_9346CR, &eeValue); if (res) - return; + return res; eeprom->bautoload_fail_flag = !(eeValue & EEPROM_EN); efuse_buf = kmalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); if (!efuse_buf) - return; + return -ENOMEM; memset(efuse_buf, 0xFF, EFUSE_MAP_LEN_88E); if (!(eeValue & BOOT_FROM_EEPROM) && !eeprom->bautoload_fail_flag) { @@ -961,6 +933,7 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter) ledpriv->bRegUseLed = true; kfree(efuse_buf); + return 0; } void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level) @@ -1069,7 +1042,7 @@ void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) rtw_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); rtw_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); - _BeaconFunctionEnable(adapt, true, true); + _BeaconFunctionEnable(adapt); rtw_resume_tx_beacon(adapt); diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index c1a4d023f627..7c72f5e04d9b 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -5,7 +5,6 @@ #include "../include/drv_types.h" #include "../include/osdep_intf.h" #include "../include/usb_ops.h" -#include "../include/recv_osdep.h" #include "../include/rtl8188e_hal.h" static int usb_read(struct intf_hdl *intf, u16 value, void *data, u8 size) @@ -190,6 +189,20 @@ int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *data) return RTW_STATUS_CODE(ret); } +static void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) +{ + struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + + if (txrpt_ccx->int_ccx) { + if (txrpt_ccx->pkt_ok) + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_SUCCESS); + else + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_CCX_PKT_FAIL); + } +} + static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) { u8 *pbuf; diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h index 9e6f2361b090..4a0b782c33be 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h @@ -80,7 +80,6 @@ void rtl8188e_PHY_SetRFReg(struct adapter *adapter, u32 regaddr, u32 mask, u32 d /* MAC/BB/RF HAL config */ int PHY_MACConfig8188E(struct adapter *adapter); int PHY_BBConfig8188E(struct adapter *adapter); -int PHY_RFConfig8188E(struct adapter *adapter); /* BB TX Power R/W */ void PHY_SetTxPowerLevel8188E(struct adapter *adapter, u8 channel); diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h index 8270fdbc2844..0a290bc31c4d 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h @@ -10,13 +10,13 @@ * AGC_TAB_1T.TXT ******************************************************************************/ -enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *odm); +int ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *odm); /****************************************************************************** * PHY_REG_1T.TXT ******************************************************************************/ -enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *odm); +int ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *odm); /****************************************************************************** * PHY_REG_PG.TXT diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h index 391c1754b0b6..b3d67c1a8050 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h @@ -7,7 +7,6 @@ /****************************************************************************** * MAC_REG.TXT ******************************************************************************/ - -enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *pDM_Odm); +int ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *pDM_Odm); #endif /* end of HWIMG_SUPPORT */ diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h index 0c67c3df20b9..880feadb4340 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h @@ -8,6 +8,6 @@ * RadioA_1T.TXT ******************************************************************************/ -enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *odm); +int ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *odm); #endif /* end of HWIMG_SUPPORT */ diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index bba88a0ede61..1bd0c8f3a358 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -10,8 +10,6 @@ #ifndef __DRV_TYPES_H__ #define __DRV_TYPES_H__ -#define DRV_NAME "r8188eu" - #include "osdep_service.h" #include "wlan_bssdef.h" #include "rtw_ht.h" @@ -36,10 +34,9 @@ #include "rtl8188e_hal.h" #include "rtw_fw.h" -#define DRIVERVERSION "v4.1.4_6773.20130222" +#define FW_RTL8188EU "rtlwifi/rtl8188eufw.bin" struct registry_priv { - u8 chip_version; u8 rfintfs; u8 lbkmode; u8 hci; @@ -222,7 +219,7 @@ struct adapter { #define adapter_to_dvobj(adapter) (adapter->dvobj) -int rtw_handle_dualmac(struct adapter *adapter, bool init); +void rtw_handle_dualmac(struct adapter *adapter, bool init); static inline u8 *myid(struct eeprom_priv *peepriv) { diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h index d7e333f6ce39..cd3f845e146a 100644 --- a/drivers/staging/r8188eu/include/hal_com.h +++ b/drivers/staging/r8188eu/include/hal_com.h @@ -143,8 +143,4 @@ u8 MRateToHwRate(u8 rate); void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg); -bool Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe); - -s32 c2h_evt_read(struct adapter *adapter, u8 *buf); - #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index ab6856d8a090..ac6e3f95c5b7 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -10,8 +10,8 @@ typedef s32 (*c2h_id_filter)(u8 id); -void rtl8188eu_interface_configure(struct adapter *adapt); -void ReadAdapterInfo8188EU(struct adapter *Adapter); +int rtl8188eu_interface_configure(struct adapter *adapt); +int ReadAdapterInfo8188EU(struct adapter *Adapter); void rtl8188eu_init_default_value(struct adapter *adapt); void rtl8188e_SetHalODMVar(struct adapter *Adapter, void *pValue1, bool bSet); u32 rtl8188eu_InitPowerOn(struct adapter *adapt); @@ -39,7 +39,6 @@ void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level); void rtw_hal_clone_data(struct adapter *dst_adapt, struct adapter *src_adapt); -void indicate_wx_scan_complete_event(struct adapter *padapter); u8 rtw_do_join(struct adapter *padapter); #endif /* __HAL_INTF_H__ */ diff --git a/drivers/staging/r8188eu/include/ioctl_cfg80211.h b/drivers/staging/r8188eu/include/ioctl_cfg80211.h deleted file mode 100644 index 738f645f9bbc..000000000000 --- a/drivers/staging/r8188eu/include/ioctl_cfg80211.h +++ /dev/null @@ -1,89 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ - -#ifndef __IOCTL_CFG80211_H__ -#define __IOCTL_CFG80211_H__ - -struct rtw_wdev_invit_info { - u8 token; - u8 flags; - u8 status; - u8 req_op_ch; - u8 rsp_op_ch; -}; - -#define rtw_wdev_invit_info_init(invit_info) \ - do { \ - (invit_info)->token = 0; \ - (invit_info)->flags = 0x00; \ - (invit_info)->status = 0xff; \ - (invit_info)->req_op_ch = 0; \ - (invit_info)->rsp_op_ch = 0; \ - } while (0) - -struct rtw_wdev_priv { - struct wireless_dev *rtw_wdev; - - struct adapter *padapter; - - struct cfg80211_scan_request *scan_request; - spinlock_t scan_req_lock; - - struct net_device *pmon_ndev;/* for monitor interface */ - char ifname_mon[IFNAMSIZ + 1]; /* name of monitor interface */ - - u8 p2p_enabled; - - u8 provdisc_req_issued; - - struct rtw_wdev_invit_info invit_info; - - u8 bandroid_scan; - bool block; - bool power_mgmt; -}; - -#define wdev_to_priv(w) ((struct rtw_wdev_priv *)(wdev_priv(w))) - -#define wiphy_to_wdev(x) \ -((struct wireless_dev *)(((struct rtw_wdev_priv *)wiphy_priv(x))->rtw_wdev)) - -int rtw_wdev_alloc(struct adapter *padapter, struct device *dev); -void rtw_wdev_free(struct wireless_dev *wdev); -void rtw_wdev_unregister(struct wireless_dev *wdev); - -void rtw_cfg80211_init_wiphy(struct adapter *padapter); - -void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter); - -void rtw_cfg80211_indicate_connect(struct adapter *padapter); -void rtw_cfg80211_indicate_disconnect(struct adapter *padapter); -void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, - bool aborted); - -void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, - u8 *pmgmt_frame, uint frame_len); -void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, - unsigned char *da, - unsigned short reason); - -void rtw_cfg80211_issue_p2p_provision_request(struct adapter *padapter, - const u8 *buf, size_t len); -void rtw_cfg80211_rx_p2p_action_public(struct adapter *padapter, - u8 *pmgmt_frame, uint frame_len); -void rtw_cfg80211_rx_action_p2p(struct adapter *padapter, u8 *pmgmt_frame, - uint frame_len); -void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, - uint frame_len, const char *msg); - -int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, - char *buf, int len, int type); - -bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter); - -#define rtw_cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) \ - cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) -#define rtw_cfg80211_send_rx_assoc(dev, bss, buf, len) \ - cfg80211_send_rx_assoc(dev, bss, buf, len) - -#endif /* __IOCTL_CFG80211_H__ */ diff --git a/drivers/staging/r8188eu/include/mlme_osdep.h b/drivers/staging/r8188eu/include/mlme_osdep.h deleted file mode 100644 index 5b9f688f9424..000000000000 --- a/drivers/staging/r8188eu/include/mlme_osdep.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __MLME_OSDEP_H_ -#define __MLME_OSDEP_H_ - -#include "osdep_service.h" -#include "drv_types.h" - -void rtw_init_mlme_timer(struct adapter *padapter); -void rtw_os_indicate_disconnect(struct adapter *adapter); -void rtw_os_indicate_connect(struct adapter *adapter); -void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted); -void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie); - -void rtw_reset_securitypriv(struct adapter *adapter); -void indicate_wx_scan_complete_event(struct adapter *padapter); - -#endif /* _MLME_OSDEP_H_ */ diff --git a/drivers/staging/r8188eu/include/odm_HWConfig.h b/drivers/staging/r8188eu/include/odm_HWConfig.h index b37962edb2ed..3f7185780e87 100644 --- a/drivers/staging/r8188eu/include/odm_HWConfig.h +++ b/drivers/staging/r8188eu/include/odm_HWConfig.h @@ -66,5 +66,4 @@ void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm, struct odm_per_pkt_info *pPktinfo, struct adapter *adapt); -enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *pDM_Odm); #endif diff --git a/drivers/staging/r8188eu/include/odm_RegConfig8188E.h b/drivers/staging/r8188eu/include/odm_RegConfig8188E.h deleted file mode 100644 index 683fa4a07956..000000000000 --- a/drivers/staging/r8188eu/include/odm_RegConfig8188E.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __INC_ODM_REGCONFIG_H_8188E -#define __INC_ODM_REGCONFIG_H_8188E - -void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, - u32 Addr, u32 Data); - -void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data); - -void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Bitmask, u32 Data); - -void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Bitmask, u32 Data); - -void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Bitmask, u32 Data); - -#endif diff --git a/drivers/staging/r8188eu/include/odm_types.h b/drivers/staging/r8188eu/include/odm_types.h index 08ba7a418ba8..76302df4b330 100644 --- a/drivers/staging/r8188eu/include/odm_types.h +++ b/drivers/staging/r8188eu/include/odm_types.h @@ -6,11 +6,6 @@ #define ODM_CE 0x04 /* BIT(2) */ -enum HAL_STATUS { - HAL_STATUS_SUCCESS, - HAL_STATUS_FAILURE, -}; - #define SET_TX_DESC_ANTSEL_A_88E(__ptxdesc, __value) \ le32p_replace_bits((__le32 *)(__ptxdesc + 8), __value, BIT(24)) #define SET_TX_DESC_ANTSEL_B_88E(__ptxdesc, __value) \ diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h index 0d7009269aab..36511c469546 100644 --- a/drivers/staging/r8188eu/include/osdep_intf.h +++ b/drivers/staging/r8188eu/include/osdep_intf.h @@ -39,6 +39,9 @@ The protection mechanism is through the pending queue. u8 bio_timer_cancel; }; +int netdev_open(struct net_device *pnetdev); +int netdev_close(struct net_device *pnetdev); + u8 rtw_init_drv_sw(struct adapter *padapter); u8 rtw_free_drv_sw(struct adapter *padapter); u8 rtw_reset_drv_sw(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/recv_osdep.h b/drivers/staging/r8188eu/include/recv_osdep.h deleted file mode 100644 index ca8a613508fd..000000000000 --- a/drivers/staging/r8188eu/include/recv_osdep.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __RECV_OSDEP_H_ -#define __RECV_OSDEP_H_ - -#include "osdep_service.h" -#include "drv_types.h" - -int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); -void _rtw_free_recv_priv(struct recv_priv *precvpriv); - -s32 rtw_recv_entry(struct recv_frame *precv_frame); -int rtw_recv_indicatepkt(struct adapter *adapter, struct recv_frame *recv_frame); -void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *retpkt); - -void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); - -int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); -void rtw_free_recv_priv(struct recv_priv *precvpriv); - -int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); -int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); - -void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); -int _netdev_open(struct net_device *pnetdev); -int netdev_open(struct net_device *pnetdev); -int netdev_close(struct net_device *pnetdev); - -#endif /* */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h index 5cd62b216720..ed4091e7cc7e 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h @@ -23,7 +23,6 @@ #include "HalHWImg8188E_MAC.h" #include "HalHWImg8188E_RF.h" #include "HalHWImg8188E_BB.h" -#include "odm_RegConfig8188E.h" #include "odm_RTL8188E.h" #define DRVINFO_SZ 4 /* unit is 8bytes */ @@ -36,7 +35,6 @@ 0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8), * WOLPattern(16*24)) */ -#define TX_SELE_HQ BIT(0) /* High Queue */ #define TX_SELE_LQ BIT(1) /* Low Queue */ #define TX_SELE_NQ BIT(2) /* Normal Queue */ @@ -51,12 +49,6 @@ #define TX_PAGE_BOUNDARY_88E (TX_TOTAL_PAGE_NUMBER_88E + 1) -/* Note: For Normal Chip Setting ,modify later */ -#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER \ - TX_TOTAL_PAGE_NUMBER_88E /* 0xA9 , 0xb0=>176=>22k */ -#define WMM_NORMAL_TX_PAGE_BOUNDARY_88E \ - (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */ - #include "HalVerDef.h" #include "hal_com.h" @@ -155,8 +147,7 @@ struct hal_data_8188e { u8 AntDivCfg; u8 TRxAntDivType; - u8 OutEpQueueSel; - u8 OutEpNumber; + u8 out_ep_extra_queues; struct P2P_PS_Offload_t p2p_ps_offload; diff --git a/drivers/staging/r8188eu/include/rtl8188e_recv.h b/drivers/staging/r8188eu/include/rtl8188e_recv.h index b752c5c06309..dc4f358f646d 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/r8188eu/include/rtl8188e_recv.h @@ -33,8 +33,6 @@ enum rx_packet_type { HIS_REPORT,/* USB HISR RPT */ }; -s32 rtl8188eu_init_recv_priv(struct adapter *padapter); -void rtl8188eu_free_recv_priv(struct adapter * padapter); void rtl8188eu_recv_tasklet(unsigned long priv); void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); void update_recvframe_attrib_88e(struct recv_frame *fra, struct recv_stat *stat); diff --git a/drivers/staging/r8188eu/include/rtl8188e_rf.h b/drivers/staging/r8188eu/include/rtl8188e_rf.h index 04556496baad..63ac0acc68fd 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_rf.h +++ b/drivers/staging/r8188eu/include/rtl8188e_rf.h @@ -8,7 +8,7 @@ #define RF6052_MAX_REG 0x3F #define RF6052_MAX_PATH 2 -int PHY_RF6052_Config8188E(struct adapter *Adapter); +int phy_RF6052_Config_ParaFile(struct adapter *Adapter); void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter, enum ht_channel_width Bandwidth); void rtl8188e_PHY_RF6052SetCckTxPower(struct adapter *Adapter, u8 *level); diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h index 9e7b1f89037c..e34619140e33 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h @@ -924,15 +924,9 @@ Current IOREG MAP #define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) /* 0x0200h ~ 0x027Fh TXDMA Configuration */ -/* 2RQPN */ -#define _HPQ(x) ((x) & 0xFF) -#define _LPQ(x) (((x) & 0xFF) << 8) -#define _PUBQ(x) (((x) & 0xFF) << 16) -/* NOTE: in RQPN_NPQ register */ -#define _NPQ(x) ((x) & 0xFF) - -#define HPQ_PUBLIC_DIS BIT(24) -#define LPQ_PUBLIC_DIS BIT(25) + +#define NUM_HQ 0x29 + #define LD_RQPN BIT(31) /* 2TDECTRL */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index 8adb672f7a07..6db7fabebea9 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -83,12 +83,6 @@ /* OFFSET 20 */ #define RTY_LMT_EN BIT(17) -enum TXDESC_SC { - SC_DONT_CARE = 0x00, - SC_UPPER = 0x01, - SC_LOWER = 0x02, - SC_DUPLICATE = 0x03 -}; /* OFFSET 20 */ #define SGI BIT(6) #define USB_TXAGG_NUM_SHT 24 @@ -147,6 +141,4 @@ bool rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); - #endif /* __RTL8188E_XMIT_H__ */ diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h index 724229fe84aa..8b4134eb3095 100644 --- a/drivers/staging/r8188eu/include/rtw_ap.h +++ b/drivers/staging/r8188eu/include/rtw_ap.h @@ -10,8 +10,6 @@ /* external function */ void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta); -void rtw_indicate_sta_disassoc_event(struct adapter *padapter, - struct sta_info *psta); void init_mlme_ap_info(struct adapter *padapter); void free_mlme_ap_info(struct adapter *padapter); void update_beacon(struct adapter *padapter, u8 ie_id, diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h index 6b6d560d7143..9a76aa85de94 100644 --- a/drivers/staging/r8188eu/include/rtw_cmd.h +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -730,9 +730,7 @@ Result: #define H2C_CMD_OVERFLOW 0x06 #define H2C_RESERVED 0x07 -u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, - int ssid_num, struct rtw_ieee80211_channel *ch, - int ch_num); +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num); u8 rtw_createbss_cmd(struct adapter *padapter); u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key); u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue); diff --git a/drivers/staging/r8188eu/include/rtw_led.h b/drivers/staging/r8188eu/include/rtw_led.h index d6b0c1c2f9a2..8520f022a67f 100644 --- a/drivers/staging/r8188eu/include/rtw_led.h +++ b/drivers/staging/r8188eu/include/rtw_led.h @@ -21,20 +21,15 @@ enum LED_CTL_MODE { }; enum LED_STATE_871x { - LED_UNKNOWN = 0, - RTW_LED_ON = 1, RTW_LED_OFF = 2, LED_BLINK_NORMAL = 3, LED_BLINK_SLOWLY = 4, LED_BLINK_SCAN = 6, /* LED is blinking during scanning period, * the # of times to blink is depend on time * for scanning. */ - LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer - * Server case */ LED_BLINK_TXRX = 9, LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */ LED_BLINK_WPS_STOP = 11, - LED_BLINK_RUNTOP = 13, /* Customized for RunTop */ }; struct led_priv { @@ -43,8 +38,6 @@ struct led_priv { bool bRegUseLed; enum LED_STATE_871x CurrLedState; /* Current LED state. */ - enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, - * either RTW_LED_ON or RTW_LED_OFF are. */ bool bLedOn; /* true if LED is ON, false if LED is OFF. */ @@ -54,7 +47,6 @@ struct led_priv { u32 BlinkTimes; /* Number of times to toggle led state for blinking. */ - bool bLedNoLinkBlinkInProgress; bool bLedLinkBlinkInProgress; bool bLedScanBlinkInProgress; struct delayed_work blink_work; diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index d81668498e46..b69989cbab21 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -5,7 +5,6 @@ #define __RTW_MLME_H_ #include "osdep_service.h" -#include "mlme_osdep.h" #include "drv_types.h" #include "wlan_bssdef.h" @@ -64,17 +63,6 @@ enum rt_scan_type { SCAN_MIX, }; -enum SCAN_RESULT_TYPE { - SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ - SCAN_RESULT_ALL = 1, /* Will return all the scanned device, - * include AP. */ - SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD - * device. */ - /* If this device is Miracast sink - * device, it will just return all the - * Miracast source devices. */ -}; - /* there are several "locks" in mlme_priv, since mlme_priv is a shared resource between many threads, @@ -433,8 +421,6 @@ void indicate_wx_scan_complete_event(struct adapter *padapter); void rtw_indicate_wx_assoc_event(struct adapter *padapter); void rtw_indicate_wx_disassoc_event(struct adapter *padapter); int event_thread(void *context); -void rtw_join_timeout_handler (struct timer_list *t); -void _rtw_scan_timeout_handler (struct timer_list *t); void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall); int rtw_init_mlme_priv(struct adapter *adapter); void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv); @@ -537,7 +523,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue); void rtw_indicate_disconnect(struct adapter *adapter); void rtw_indicate_connect(struct adapter *adapter); -void rtw_indicate_scan_done( struct adapter *padapter, bool aborted); +void rtw_indicate_scan_done(struct adapter *padapter); int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len); @@ -551,10 +537,6 @@ void _rtw_join_timeout_handler(struct adapter *adapter); void rtw_scan_timeout_handler(struct adapter *adapter); void rtw_dynamic_check_timer_handlder(struct adapter *adapter); -#define rtw_is_scan_deny(adapter) false -#define rtw_clear_scan_deny(adapter) do {} while (0) -#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0) -#define rtw_set_scan_deny(adapter, ms) do {} while (0) void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index 343ce1ce4b3d..b322d0848db9 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -388,15 +388,11 @@ struct mlme_ext_priv { void init_mlme_ext_priv(struct adapter *adapter); int init_hw_mlme_ext(struct adapter *padapter); void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext); -extern void init_mlme_ext_timer(struct adapter *padapter); -extern void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta); extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); unsigned char networktype_to_raid(unsigned char network_type); u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len); void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len); -void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS); -void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen); void Save_DM_Func_Flag(struct adapter *padapter); void Restore_DM_Func_Flag(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index 66d240a7123d..7768b0c5988c 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -243,6 +243,9 @@ struct recv_frame { struct recv_reorder_ctrl *preorder_ctrl; }; +int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); +void _rtw_free_recv_priv(struct recv_priv *precvpriv); +s32 rtw_recv_entry(struct recv_frame *precv_frame); struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); int rtw_free_recvframe(struct recv_frame *precvframe, diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h index 034a9f8f51c9..82efcd54af3f 100644 --- a/drivers/staging/r8188eu/include/rtw_xmit.h +++ b/drivers/staging/r8188eu/include/rtw_xmit.h @@ -7,6 +7,9 @@ #include "osdep_service.h" #include "drv_types.h" +#define NR_XMITFRAME 256 +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME * 2 / 5) + #define MAX_XMITBUF_SZ (20480) /* 20k */ #define NR_XMITBUFF (4) @@ -304,6 +307,15 @@ struct xmit_priv { struct submit_ctx ack_tx_ops; }; +struct pkt_file { + struct sk_buff *pkt; + size_t pkt_len; /* the remainder length of the open_file */ + unsigned char *cur_buffer; + u8 *buf_start; + u8 *cur_addr; + size_t buf_len; +}; + struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv); s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); @@ -355,7 +367,7 @@ u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe); int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms); void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status); -/* include after declaring struct xmit_buf, in order to avoid warning */ -#include "xmit_osdep.h" +void rtw_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe); +netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); #endif /* _RTL871X_XMIT_H_ */ diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h index 9d1c9e763287..81bda91a4136 100644 --- a/drivers/staging/r8188eu/include/wlan_bssdef.h +++ b/drivers/staging/r8188eu/include/wlan_bssdef.h @@ -133,10 +133,6 @@ struct ndis_802_11_assoc_info { u32 OffsetResponseIEs; }; -enum ndis_802_11_reload_def { - Ndis802_11ReloadWEPKeys -}; - /* Key mapping keys require a BSSID */ struct ndis_802_11_key { u32 Length; /* Length of this structure */ diff --git a/drivers/staging/r8188eu/include/xmit_osdep.h b/drivers/staging/r8188eu/include/xmit_osdep.h deleted file mode 100644 index 00658681fef9..000000000000 --- a/drivers/staging/r8188eu/include/xmit_osdep.h +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __XMIT_OSDEP_H_ -#define __XMIT_OSDEP_H_ - -#include "osdep_service.h" -#include "drv_types.h" - -struct pkt_file { - struct sk_buff *pkt; - size_t pkt_len; /* the remainder length of the open_file */ - unsigned char *cur_buffer; - u8 *buf_start; - u8 *cur_addr; - size_t buf_len; -}; - -extern int rtw_ht_enable; -extern int rtw_cbw40_enable; -extern int rtw_ampdu_enable;/* for enable tx_ampdu */ - -#define NR_XMITFRAME 256 - -struct xmit_priv; -struct pkt_attrib; -struct sta_xmit_priv; -struct xmit_frame; -struct xmit_buf; - -int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); - -void rtw_os_xmit_schedule(struct adapter *padapter); - -int rtw_os_xmit_resource_alloc(struct adapter *padapter, - struct xmit_buf *pxmitbuf, u32 alloc_sz); -void rtw_os_xmit_resource_free(struct adapter *padapter, - struct xmit_buf *pxmitbuf, u32 free_sz); - -uint rtw_remainder_len(struct pkt_file *pfile); -void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile); -uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen); -bool rtw_endofpktfile(struct pkt_file *pfile); - -void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt); -void rtw_os_xmit_complete(struct adapter *padapter, - struct xmit_frame *pxframe); - -#endif /* __XMIT_OSDEP_H_ */ diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 7f91dac2e41b..2de2e1e32738 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1099,7 +1099,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, spin_lock_bh(&pmlmepriv->lock); - _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); + _status = rtw_sitesurvey_cmd(padapter, ssid, 1); spin_unlock_bh(&pmlmepriv->lock); } @@ -1836,7 +1836,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, goto out; } - strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); + strscpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) param->u.crypt.set_tx = 1; @@ -2079,7 +2079,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret = 0; + int ret; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct wifidirect_info *pwdinfo = &padapter->wdinfo; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2094,10 +2094,9 @@ static int rtw_wext_p2p_enable(struct net_device *dev, else if (*extra == '3') init_role = P2P_ROLE_GO; - if (_FAIL == rtw_p2p_enable(padapter, init_role)) { - ret = -EFAULT; - goto exit; - } + ret = rtw_p2p_enable(padapter, init_role); + if (ret) + return ret; /* set channel/bandwidth */ if (init_role != P2P_ROLE_DISABLE) { @@ -2121,8 +2120,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev, set_channel_bwmode(padapter, channel, ch_offset, bwmode); } -exit: - return ret; + return 0; } static void rtw_p2p_set_go_nego_ssid(struct net_device *dev, diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c deleted file mode 100644 index 899d8e9c3834..000000000000 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ /dev/null @@ -1,205 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ - -#define _MLME_OSDEP_C_ - -#include "../include/osdep_service.h" -#include "../include/drv_types.h" -#include "../include/mlme_osdep.h" - -void rtw_join_timeout_handler (struct timer_list *t) -{ - struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer); - - _rtw_join_timeout_handler(adapter); -} - -void _rtw_scan_timeout_handler (struct timer_list *t) -{ - struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer); - - rtw_scan_timeout_handler(adapter); -} - -static void _dynamic_check_timer_handlder(struct timer_list *t) -{ - struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer); - - rtw_dynamic_check_timer_handlder(adapter); - _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); -} - -void rtw_init_mlme_timer(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0); - timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0); - timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0); -} - -void rtw_os_indicate_connect(struct adapter *adapter) -{ - - rtw_indicate_wx_assoc_event(adapter); - netif_carrier_on(adapter->pnetdev); - if (adapter->pid[2] != 0) - rtw_signal_process(adapter->pid[2], SIGALRM); - -} - -void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) -{ - indicate_wx_scan_complete_event(padapter); -} - -static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE]; - -void rtw_reset_securitypriv(struct adapter *adapter) -{ - u8 backup_index = 0; - u8 backup_counter = 0x00; - u32 backup_time = 0; - - if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { - /* 802.1x */ - /* We have to backup the PMK information for WiFi PMK Caching test item. */ - /* Backup the btkip_countermeasure information. */ - /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */ - memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - backup_index = adapter->securitypriv.PMKIDIndex; - backup_counter = adapter->securitypriv.btkip_countermeasure; - backup_time = adapter->securitypriv.btkip_countermeasure_time; - memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); - - /* Restore the PMK information to securitypriv structure for the following connection. */ - memcpy(&adapter->securitypriv.PMKIDList[0], - &backup_pmkid[0], - sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - adapter->securitypriv.PMKIDIndex = backup_index; - adapter->securitypriv.btkip_countermeasure = backup_counter; - adapter->securitypriv.btkip_countermeasure_time = backup_time; - adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; - adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; - } else { - /* reset values in securitypriv */ - struct security_priv *psec_priv = &adapter->securitypriv; - - psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ - psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; - psec_priv->dot11PrivacyKeyIndex = 0; - psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; - psec_priv->dot118021XGrpKeyid = 1; - psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; - psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; - } -} - -void rtw_os_indicate_disconnect(struct adapter *adapter) -{ - - netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */ - rtw_indicate_wx_disassoc_event(adapter); - rtw_reset_securitypriv(adapter); -} - -void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) -{ - uint len; - u8 *buff, *p, i; - union iwreq_data wrqu; - - buff = NULL; - if (authmode == _WPA_IE_ID_) { - buff = kzalloc(IW_CUSTOM_MAX, GFP_ATOMIC); - if (!buff) - return; - p = buff; - p += sprintf(p, "ASSOCINFO(ReqIEs ="); - len = sec_ie[1] + 2; - len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; - for (i = 0; i < len; i++) - p += sprintf(p, "%02x", sec_ie[i]); - p += sprintf(p, ")"); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = p - buff; - wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? - wrqu.data.length : IW_CUSTOM_MAX; - wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); - kfree(buff); - } -} - -static void _survey_timer_hdl(struct timer_list *t) -{ - struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer); - - survey_timer_hdl(padapter); -} - -static void _link_timer_hdl(struct timer_list *t) -{ - struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer); - link_timer_hdl(padapter); -} - -static void _addba_timer_hdl(struct timer_list *t) -{ - struct sta_info *psta = from_timer(psta, t, addba_retry_timer); - addba_timer_hdl(psta); -} - -void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) -{ - timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0); -} - -void init_mlme_ext_timer(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0); - timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0); -} - -void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta) -{ - union iwreq_data wrqu; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!psta) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL); -} - -void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta) -{ - union iwreq_data wrqu; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!psta) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL); -} diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index aa100b5141e1..6a45315d01a2 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -5,8 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/xmit_osdep.h" -#include "../include/recv_osdep.h" #include "../include/hal_intf.h" #include "../include/rtw_ioctl.h" #include "../include/usb_osintf.h" @@ -17,14 +15,12 @@ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); -MODULE_VERSION(DRIVERVERSION); -MODULE_FIRMWARE("rtlwifi/rtl8188eufw.bin"); +MODULE_FIRMWARE(FW_RTL8188EU); #define CONFIG_BR_EXT_BRNAME "br0" #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ /* module param defaults */ -static int rtw_chip_version = 0x00; static int rtw_rfintfs = HWPI; static int rtw_lbkmode;/* RTL8712_AIR_TRX; */ static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */ @@ -67,9 +63,9 @@ static int rtw_uapsd_acvo_en; static int rtw_led_enable = 1; -int rtw_ht_enable = 1; -int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ -int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ +static int rtw_ht_enable = 1; +static int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ @@ -106,7 +102,6 @@ char *rtw_initmac; /* temp mac address if users want to use instead of the mac module_param(rtw_initmac, charp, 0644); module_param(rtw_channel_plan, int, 0644); -module_param(rtw_chip_version, int, 0644); module_param(rtw_rfintfs, int, 0644); module_param(rtw_lbkmode, int, 0644); module_param(rtw_network_mode, int, 0644); @@ -153,7 +148,6 @@ static uint loadparam(struct adapter *padapter) { struct registry_priv *registry_par = &padapter->registrypriv; - registry_par->chip_version = (u8)rtw_chip_version; registry_par->rfintfs = (u8)rtw_rfintfs; registry_par->lbkmode = (u8)rtw_lbkmode; registry_par->network_mode = (u8)rtw_network_mode; @@ -622,7 +616,7 @@ void netdev_br_init(struct net_device *netdev) rcu_read_unlock(); } -int _netdev_open(struct net_device *pnetdev) +static int _netdev_open(struct net_device *pnetdev) { uint status; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); @@ -636,7 +630,7 @@ int _netdev_open(struct net_device *pnetdev) if (status == _FAIL) goto netdev_open_error; - pr_info("MAC Address = %pM\n", pnetdev->dev_addr); + netdev_dbg(pnetdev, "MAC Address = %pM\n", pnetdev->dev_addr); status = rtw_start_drv_threads(padapter); if (status == _FAIL) { diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 3504a0a9ba87..88271f956b52 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -5,7 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" #include "../include/rtw_ioctl_set.h" /* @@ -54,14 +53,13 @@ struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); if (!pnetdev) - goto RETURN; + return NULL; pnetdev->dev.type = &wlan_type; pnpi = netdev_priv(pnetdev); pnpi->priv = old_priv; pnpi->sizeof_priv = sizeof_priv; -RETURN: return pnetdev; } @@ -72,19 +70,18 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv) pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); if (!pnetdev) - goto RETURN; + return NULL; pnpi = netdev_priv(pnetdev); pnpi->priv = vzalloc(sizeof_priv); if (!pnpi->priv) { free_netdev(pnetdev); - pnetdev = NULL; - goto RETURN; + return NULL; } pnpi->sizeof_priv = sizeof_priv; -RETURN: + return pnetdev; } diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c deleted file mode 100644 index 1e14b6d49795..000000000000 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ /dev/null @@ -1,165 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#define _RECV_OSDEP_C_ - -#include "../include/osdep_service.h" -#include "../include/drv_types.h" - -#include "../include/wifi.h" -#include "../include/recv_osdep.h" - -#include "../include/osdep_intf.h" -#include "../include/usb_ops.h" - -/* alloc os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, - struct recv_buf *precvbuf) -{ - int res = _SUCCESS; - - precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); - if (!precvbuf->purb) - res = _FAIL; - precvbuf->pskb = NULL; - precvbuf->reuse = false; - return res; -} - -/* free os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_free(struct adapter *padapter, - struct recv_buf *precvbuf) -{ - usb_free_urb(precvbuf->purb); - return _SUCCESS; -} - -void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) -{ - union iwreq_data wrqu; - struct iw_michaelmicfailure ev; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - u32 cur_time = 0; - - if (psecuritypriv->last_mic_err_time == 0) { - psecuritypriv->last_mic_err_time = jiffies; - } else { - cur_time = jiffies; - - if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) { - psecuritypriv->btkip_countermeasure = true; - psecuritypriv->last_mic_err_time = 0; - psecuritypriv->btkip_countermeasure_time = cur_time; - } else { - psecuritypriv->last_mic_err_time = jiffies; - } - } - - memset(&ev, 0x00, sizeof(ev)); - if (bgroup) - ev.flags |= IW_MICFAILURE_GROUP; - else - ev.flags |= IW_MICFAILURE_PAIRWISE; - - ev.src_addr.sa_family = ARPHRD_ETHER; - memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN); - memset(&wrqu, 0x00, sizeof(wrqu)); - wrqu.data.length = sizeof(ev); - wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, - &wrqu, (char *)&ev); -} - -int rtw_recv_indicatepkt(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct recv_priv *precvpriv; - struct __queue *pfree_recv_queue; - struct sk_buff *skb; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - precvpriv = &padapter->recvpriv; - pfree_recv_queue = &precvpriv->free_recv_queue; - - skb = precv_frame->pkt; - if (!skb) - goto _recv_indicatepkt_drop; - - skb->data = precv_frame->rx_data; - - skb_set_tail_pointer(skb, precv_frame->len); - - skb->len = precv_frame->len; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - struct sk_buff *pskb2 = NULL; - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - bool bmcast = is_multicast_ether_addr(pattrib->dst); - - if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), - ETH_ALEN)) { - if (bmcast) { - psta = rtw_get_bcmc_stainfo(padapter); - pskb2 = skb_clone(skb, GFP_ATOMIC); - } else { - psta = rtw_get_stainfo(pstapriv, pattrib->dst); - } - - if (psta) { - struct net_device *pnetdev; - - pnetdev = (struct net_device *)padapter->pnetdev; - skb->dev = pnetdev; - skb_set_queue_mapping(skb, rtw_recv_select_queue(skb)); - - rtw_xmit_entry(skb, pnetdev); - - if (bmcast) - skb = pskb2; - else - goto _recv_indicatepkt_end; - } - } - } - - rcu_read_lock(); - rcu_dereference(padapter->pnetdev->rx_handler_data); - rcu_read_unlock(); - - skb->ip_summed = CHECKSUM_NONE; - skb->dev = padapter->pnetdev; - skb->protocol = eth_type_trans(skb, padapter->pnetdev); - - netif_rx(skb); - -_recv_indicatepkt_end: - - /* pointers to NULL before rtw_free_recvframe() */ - precv_frame->pkt = NULL; - - rtw_free_recvframe(precv_frame, pfree_recv_queue); - - return _SUCCESS; - -_recv_indicatepkt_drop: - - /* enqueue back to free_recv_queue */ - rtw_free_recvframe(precv_frame, pfree_recv_queue); - - return _FAIL; -} - -static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t) -{ - struct recv_reorder_ctrl *preorder_ctrl; - - preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer); - rtw_reordering_ctrl_timeout_handler(preorder_ctrl); -} - -void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) -{ - timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0); -} diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 9147d176da4f..5fbfbcd95de2 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -4,8 +4,6 @@ #include <linux/usb.h> #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/recv_osdep.h" -#include "../include/xmit_osdep.h" #include "../include/hal_intf.h" #include "../include/osdep_intf.h" #include "../include/usb_ops.h" @@ -55,7 +53,7 @@ struct rtw_usb_drv { }; static struct rtw_usb_drv rtl8188e_usb_drv = { - .usbdrv.name = "r8188eu", + .usbdrv.name = KBUILD_MODNAME, .usbdrv.probe = rtw_drv_init, .usbdrv.disconnect = rtw_dev_remove, .usbdrv.id_table = rtw_usb_id_tbl, @@ -232,7 +230,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) mutex_unlock(&pwrpriv->lock); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - rtw_indicate_scan_done(padapter, 1); + rtw_indicate_scan_done(padapter); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) rtw_indicate_disconnect(padapter); @@ -288,17 +286,17 @@ exit: * We accept the new device by returning 0. */ -static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, - struct usb_interface *pusb_intf) +static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusb_intf) { struct adapter *padapter = NULL; struct net_device *pnetdev = NULL; struct io_priv *piopriv; struct intf_hdl *pintf; + int ret; padapter = vzalloc(sizeof(*padapter)); if (!padapter) - return NULL; + return -ENOMEM; padapter->dvobj = dvobj; dvobj->if1 = padapter; @@ -307,12 +305,13 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->hw_init_mutex = &usb_drv->hw_init_mutex; - if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) - goto free_adapter; + rtw_handle_dualmac(padapter, 1); pnetdev = rtw_init_netdev(padapter); - if (!pnetdev) + if (!pnetdev) { + ret = -ENODEV; goto handle_dualmac; + } SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); padapter = rtw_netdev_priv(pnetdev); @@ -330,14 +329,20 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, rtl8188e_read_chip_version(padapter); /* step usb endpoint mapping */ - rtl8188eu_interface_configure(padapter); + ret = rtl8188eu_interface_configure(padapter); + if (ret) + goto handle_dualmac; /* step read efuse/eeprom data and get mac_addr */ - ReadAdapterInfo8188EU(padapter); + ret = ReadAdapterInfo8188EU(padapter); + if (ret) + goto handle_dualmac; /* step 5. */ - if (rtw_init_drv_sw(padapter) == _FAIL) + if (rtw_init_drv_sw(padapter) == _FAIL) { + ret = -ENODEV; goto handle_dualmac; + } #ifdef CONFIG_PM if (padapter->pwrctrlpriv.bSupportRemoteWakeup) { @@ -352,7 +357,8 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, usb_autopm_get_interface(pusb_intf); /* alloc dev name after read efuse. */ - if (rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname) < 0) + ret = rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname); + if (ret) goto free_drv_sw; rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, @@ -360,23 +366,23 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr); /* step 6. Tell the network stack we exist */ - if (register_netdev(pnetdev) != 0) + ret = register_netdev(pnetdev); + if (ret) goto free_drv_sw; - return padapter; + return 0; free_drv_sw: rtw_cancel_all_timer(padapter); rtw_free_drv_sw(padapter); handle_dualmac: rtw_handle_dualmac(padapter, 0); -free_adapter: if (pnetdev) rtw_free_netdev(pnetdev); else vfree(padapter); - return NULL; + return ret; } static void rtw_usb_if1_deinit(struct adapter *if1) @@ -404,27 +410,24 @@ static void rtw_usb_if1_deinit(struct adapter *if1) static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) { - struct adapter *if1 = NULL; struct dvobj_priv *dvobj; + int ret; /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); if (!dvobj) - goto err; + return -ENODEV; - if1 = rtw_usb_if1_init(dvobj, pusb_intf); - if (!if1) - goto free_dvobj; + ret = rtw_usb_if1_init(dvobj, pusb_intf); + if (ret) { + usb_dvobj_deinit(pusb_intf); + return ret; + } if (ui_pid[1] != 0) rtw_signal_process(ui_pid[1], SIGUSR2); return 0; - -free_dvobj: - usb_dvobj_deinit(pusb_intf); -err: - return -ENODEV; } /* diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c deleted file mode 100644 index 91a1e4e3219a..000000000000 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ /dev/null @@ -1,237 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2012 Realtek Corporation. */ - -#define _XMIT_OSDEP_C_ - -#include "../include/osdep_service.h" -#include "../include/drv_types.h" -#include "../include/wifi.h" -#include "../include/mlme_osdep.h" -#include "../include/xmit_osdep.h" -#include "../include/osdep_intf.h" -#include "../include/usb_osintf.h" - -uint rtw_remainder_len(struct pkt_file *pfile) -{ - return pfile->buf_len - ((size_t)(pfile->cur_addr) - - (size_t)(pfile->buf_start)); -} - -void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) -{ - - if (!pktptr) { - pr_err("8188eu: pktptr is NULL\n"); - return; - } - if (!pfile) { - pr_err("8188eu: pfile is NULL\n"); - return; - } - pfile->pkt = pktptr; - pfile->cur_addr = pktptr->data; - pfile->buf_start = pktptr->data; - pfile->pkt_len = pktptr->len; - pfile->buf_len = pktptr->len; - - pfile->cur_buffer = pfile->buf_start; - -} - -uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) -{ - uint len = 0; - - len = rtw_remainder_len(pfile); - len = (rlen > len) ? len : rlen; - - if (rmem) - skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len); - - pfile->cur_addr += len; - pfile->pkt_len -= len; - - return len; -} - -bool rtw_endofpktfile(struct pkt_file *pfile) -{ - - if (pfile->pkt_len == 0) { - - return true; - } - - return false; -} - -int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) -{ - pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL); - if (!pxmitbuf->pallocated_buf) - return _FAIL; - - pxmitbuf->pbuf = (u8 *)ALIGN((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); - pxmitbuf->dma_transfer_addr = 0; - - pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!pxmitbuf->pxmit_urb) - return _FAIL; - - return _SUCCESS; -} - -void rtw_os_xmit_resource_free(struct adapter *padapter, - struct xmit_buf *pxmitbuf, u32 free_sz) -{ - usb_free_urb(pxmitbuf->pxmit_urb); - - kfree(pxmitbuf->pallocated_buf); -} - -#define WMM_XMIT_THRESHOLD (NR_XMITFRAME * 2 / 5) - -void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) -{ - u16 queue; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - queue = skb_get_queue_mapping(pkt); - if (padapter->registrypriv.wifi_spec) { - if (__netif_subqueue_stopped(padapter->pnetdev, queue) && - (pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD)) - netif_wake_subqueue(padapter->pnetdev, queue); - } else { - if (__netif_subqueue_stopped(padapter->pnetdev, queue)) - netif_wake_subqueue(padapter->pnetdev, queue); - } - - dev_kfree_skb_any(pkt); -} - -void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe) -{ - if (pxframe->pkt) - rtw_os_pkt_complete(padapter, pxframe->pkt); - pxframe->pkt = NULL; -} - -void rtw_os_xmit_schedule(struct adapter *padapter) -{ - struct xmit_priv *pxmitpriv; - - if (!padapter) - return; - - pxmitpriv = &padapter->xmitpriv; - - spin_lock_bh(&pxmitpriv->lock); - - if (rtw_txframes_pending(padapter)) - tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - - spin_unlock_bh(&pxmitpriv->lock); -} - -static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt) -{ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u16 queue; - - queue = skb_get_queue_mapping(pkt); - if (padapter->registrypriv.wifi_spec) { - /* No free space for Tx, tx_worker is too slow */ - if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) - netif_stop_subqueue(padapter->pnetdev, queue); - } else { - if (pxmitpriv->free_xmitframe_cnt <= 4) { - if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue))) - netif_stop_subqueue(padapter->pnetdev, queue); - } - } -} - -static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct list_head *phead, *plist; - struct sk_buff *newskb; - struct sta_info *psta = NULL; - s32 res; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - plist = phead->next; - - /* free sta asoc_queue */ - while (phead != plist) { - psta = container_of(plist, struct sta_info, asoc_list); - - plist = plist->next; - - /* avoid come from STA1 and send back STA1 */ - if (!memcmp(psta->hwaddr, &skb->data[6], 6)) - continue; - - newskb = skb_copy(skb, GFP_ATOMIC); - - if (newskb) { - memcpy(newskb->data, psta->hwaddr, 6); - res = rtw_xmit(padapter, &newskb); - if (res < 0) { - pxmitpriv->tx_drop++; - dev_kfree_skb_any(newskb); - } else { - pxmitpriv->tx_pkts++; - } - } else { - pxmitpriv->tx_drop++; - - spin_unlock_bh(&pstapriv->asoc_list_lock); - return false; /* Caller shall tx this multicast frame via normal way. */ - } - } - - spin_unlock_bh(&pstapriv->asoc_list_lock); - dev_kfree_skb_any(skb); - return true; -} - -int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) -{ - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - s32 res = 0; - - if (!rtw_if_up(padapter)) - goto drop_packet; - - rtw_check_xmit_resource(padapter, pkt); - - if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) && - (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) && - (padapter->registrypriv.wifi_spec == 0)) { - if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) { - res = rtw_mlcst2unicst(padapter, pkt); - if (res) - goto exit; - } - } - - res = rtw_xmit(padapter, &pkt); - if (res < 0) - goto drop_packet; - - pxmitpriv->tx_pkts++; - goto exit; - -drop_packet: - pxmitpriv->tx_drop++; - dev_kfree_skb_any(pkt); - -exit: - - return 0; -} diff --git a/drivers/staging/rtl8192e/Kconfig b/drivers/staging/rtl8192e/Kconfig index 39f5a6a7346a..e06c189b4ce4 100644 --- a/drivers/staging/rtl8192e/Kconfig +++ b/drivers/staging/rtl8192e/Kconfig @@ -10,6 +10,9 @@ config RTLLIB If unsure, say N. + This driver adds support for rtllib wireless cards. + Only the rtl8192e is supported as of now. + if RTLLIB config RTLLIB_CRYPTO_CCMP @@ -23,6 +26,8 @@ config RTLLIB_CRYPTO_CCMP CCMP crypto driver for rtllib. If you enabled RTLLIB, you want this. + Adds support for the CCM mode Protocol crypto driver for + use in wireless cards (including rtllib cards). config RTLLIB_CRYPTO_TKIP tristate "Support for rtllib TKIP crypto" @@ -35,6 +40,8 @@ config RTLLIB_CRYPTO_TKIP TKIP crypto driver for rtllib. If you enabled RTLLIB, you want this. + Adds support for the Temporal Key Integrity Protocol for + the IEEE 802.11i standard for use on wireless cards. config RTLLIB_CRYPTO_WEP tristate "Support for rtllib WEP crypto" @@ -42,9 +49,12 @@ config RTLLIB_CRYPTO_WEP depends on RTLLIB default y help - TKIP crypto driver for rtllib. + WEP crypto driver for rtllib. If you enabled RTLLIB, you want this. + Adds support for the (now weak) Wired Equivalent Privacy + (WEP) crypto protocol for wireless cards. + NOTE: This protocol is now considered insecure. source "drivers/staging/rtl8192e/rtl8192e/Kconfig" diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c index 4abec7b42993..ab2e9b729883 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c @@ -10,7 +10,7 @@ #include "r8190P_rtl8256.h" void rtl92e_set_bandwidth(struct net_device *dev, - enum ht_channel_width Bandwidth) + enum ht_channel_width bandwidth) { u8 eRFPath; struct r8192_priv *priv = rtllib_priv(dev); @@ -25,7 +25,7 @@ void rtl92e_set_bandwidth(struct net_device *dev, if (!rtl92e_is_legal_rf_path(dev, eRFPath)) continue; - switch (Bandwidth) { + switch (bandwidth) { case HT_CHANNEL_WIDTH_20: rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x100); @@ -44,7 +44,7 @@ void rtl92e_set_bandwidth(struct net_device *dev, break; default: netdev_err(dev, "%s(): Unknown bandwidth: %#X\n", - __func__, Bandwidth); + __func__, bandwidth); break; } } @@ -115,10 +115,6 @@ bool rtl92e_config_rf(struct net_device *dev) (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, - "RF %d %d register final value: %x\n", - eRFPath, RegOffSetToBeCheck, - RF3_Final_Value); RetryTimes--; } @@ -142,8 +138,6 @@ bool rtl92e_config_rf(struct net_device *dev) goto fail; } } - - RT_TRACE(COMP_PHY, "PHY Initialization Success\n"); return true; fail: diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h index 4cb483f1a152..3c52e2b43095 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h @@ -9,7 +9,7 @@ #define RTL819X_TOTAL_RF_PATH 2 void rtl92e_set_bandwidth(struct net_device *dev, - enum ht_channel_width Bandwidth); + enum ht_channel_width bandwidth); bool rtl92e_config_rf(struct net_device *dev); void rtl92e_set_cck_tx_power(struct net_device *dev, u8 powerlevel); void rtl92e_set_ofdm_tx_power(struct net_device *dev, u8 powerlevel); diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c index cd8bbc358d01..8bf06f736ffb 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c @@ -21,8 +21,6 @@ bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data, struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, len); - do { if ((len - frag_offset) > CMDPACKET_FRAG_SIZE) { frag_length = CMDPACKET_FRAG_SIZE; @@ -61,8 +59,7 @@ bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data, tcb_desc->txbuf_size = frag_length; } - seg_ptr = skb_put(skb, frag_length); - memcpy(seg_ptr, data, (u32)frag_length); + skb_put_data(skb, data, frag_length); if (type == DESC_PACKET_TYPE_INIT && (!priv->rtllib->check_nic_enough_desc(dev, TXCMD_QUEUE) || diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 4b9249195b5a..18e4e5d84878 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -186,8 +186,6 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) AC_PARAM_ECW_MIN_OFFSET) | (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET); - RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", - __func__, eACI, u4bAcParam); switch (eACI) { case AC1_BK: rtl92e_writel(dev, EDCAPARA_BK, u4bAcParam); @@ -226,8 +224,6 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) u8 acm = pAciAifsn->f.acm; u8 AcmCtrl = rtl92e_readb(dev, AcmHwCtrl); - RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", - __func__, eACI); AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2) ? 0x0 : 0x1); if (acm) { @@ -243,12 +239,6 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) case AC3_VO: AcmCtrl |= AcmHw_VoqEn; break; - - default: - RT_TRACE(COMP_QOS, - "SetHwReg8185(): [HW_VAR_ACM_CTRL] acm set failed: eACI is %d\n", - eACI); - break; } } else { switch (eACI) { @@ -268,10 +258,6 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) break; } } - - RT_TRACE(COMP_QOS, - "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", - AcmCtrl); rtl92e_writeb(dev, AcmHwCtrl, AcmCtrl); break; } @@ -304,8 +290,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) u16 i, usValue, IC_Version; u16 EEPROMId; - RT_TRACE(COMP_INIT, "====> %s\n", __func__); - EEPROMId = rtl92e_eeprom_read(dev, 0); if (EEPROMId != RTL8190_EEPROM_ID) { netdev_err(dev, "%s(): Invalid EEPROM ID: %x\n", __func__, @@ -329,8 +313,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) ICVer8192 = IC_Version & 0xf; ICVer8256 = (IC_Version & 0xf0)>>4; - RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192); - RT_TRACE(COMP_INIT, "\nICVer8256 = 0x%x\n", ICVer8256); if (ICVer8192 == 0x2) { if (ICVer8256 == 0x5) priv->card_8192_version = VERSION_8190_BE; @@ -343,22 +325,14 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->card_8192_version = VERSION_8190_BD; break; } - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", - priv->card_8192_version); } else { priv->card_8192_version = VERSION_8190_BD; priv->eeprom_vid = 0; priv->eeprom_did = 0; priv->eeprom_CustomerID = 0; priv->eeprom_ChannelPlan = 0; - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", 0xff); } - RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); - RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); - RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", - priv->eeprom_CustomerID); - if (!priv->AutoloadFailFlag) { u8 addr[ETH_ALEN]; @@ -372,9 +346,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) eth_hw_addr_set(dev, bMac_Tmp_Addr); } - RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", - dev->dev_addr); - if (priv->card_8192_version > VERSION_8190_BD) priv->bTXPowerDataReadFromEEPORM = true; else @@ -395,8 +366,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) } else { priv->EEPROMLegacyHTTxPowerDiff = 0x04; } - RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", - priv->EEPROMLegacyHTTxPowerDiff); if (!priv->AutoloadFailFlag) priv->EEPROMThermalMeter = ((rtl92e_eeprom_read(dev, @@ -404,8 +373,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) 0xff00) >> 8; else priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", - priv->EEPROMThermalMeter); priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; if (priv->epromtype == EEPROM_93C46) { @@ -421,10 +388,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; } - RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", - priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", - priv->EEPROMCrystalCap); for (i = 0; i < 14; i += 2) { if (!priv->AutoloadFailFlag) @@ -434,12 +397,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) usValue = EEPROM_Default_TxPower; *((u16 *)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; - RT_TRACE(COMP_INIT, - "CCK Tx Power Level, Index %d = 0x%02x\n", - i, priv->EEPROMTxPowerLevelCCK[i]); - RT_TRACE(COMP_INIT, - "CCK Tx Power Level, Index %d = 0x%02x\n", - i+1, priv->EEPROMTxPowerLevelCCK[i+1]); } for (i = 0; i < 14; i += 2) { if (!priv->AutoloadFailFlag) @@ -449,13 +406,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) usValue = EEPROM_Default_TxPower; *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; - RT_TRACE(COMP_INIT, - "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", - i, priv->EEPROMTxPowerLevelOFDM24G[i]); - RT_TRACE(COMP_INIT, - "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", - i + 1, - priv->EEPROMTxPowerLevelOFDM24G[i+1]); } } if (priv->epromtype == EEPROM_93C46) { @@ -508,22 +458,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; } - for (i = 0; i < 14; i++) - RT_TRACE(COMP_INIT, - "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", - i, priv->TxPowerLevelCCK_A[i]); - for (i = 0; i < 14; i++) - RT_TRACE(COMP_INIT, - "priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", - i, priv->TxPowerLevelOFDM24G_A[i]); - for (i = 0; i < 14; i++) - RT_TRACE(COMP_INIT, - "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", - i, priv->TxPowerLevelCCK_C[i]); - for (i = 0; i < 14; i++) - RT_TRACE(COMP_INIT, - "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", - i, priv->TxPowerLevelOFDM24G_C[i]); priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; priv->AntennaTxPwDiff[0] = 0; @@ -536,13 +470,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) } } - if (priv->rf_type == RF_1T2R) { - /* no matter what checkpatch says, the braces are needed */ - RT_TRACE(COMP_INIT, "\n1T2R config\n"); - } else if (priv->rf_type == RF_2T4R) { - RT_TRACE(COMP_INIT, "\n2T4R config\n"); - } - rtl92e_init_adaptive_rate(dev); priv->rf_chip = RF_8256; @@ -574,8 +501,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; else priv->ChannelPlan = 0x0; - RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", - priv->ChannelPlan); break; case EEPROM_CID_Nettronix: priv->ScanDelay = 100; @@ -602,10 +527,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->rtllib->bSupportRemoteWakeUp = true; else priv->rtllib->bSupportRemoteWakeUp = false; - - RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); - RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); - RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); } void rtl92e_get_eeprom_size(struct net_device *dev) @@ -613,14 +534,9 @@ void rtl92e_get_eeprom_size(struct net_device *dev) u16 curCR; struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); curCR = rtl92e_readw(dev, EPROM_CMD); - RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, - curCR); priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : EEPROM_93C46; - RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, - priv->epromtype); _rtl92e_read_eeprom_info(dev); } @@ -697,7 +613,6 @@ bool rtl92e_start_adapter(struct net_device *dev) int i = 0; u32 retry_times = 0; - RT_TRACE(COMP_INIT, "====>%s()\n", __func__); priv->being_init_adapter = true; start: @@ -710,7 +625,7 @@ start: priv->pFirmware->status = FW_STATUS_0_INIT; if (priv->RegRfOff) - priv->rtllib->eRFPowerState = eRfOff; + priv->rtllib->rf_power_state = rf_off; ulRegRead = rtl92e_readl(dev, CPU_GEN); if (priv->pFirmware->status == FW_STATUS_0_INIT) @@ -732,13 +647,11 @@ start: rtl92e_writeb(dev, SWREGULATOR, 0xb8); } } - RT_TRACE(COMP_INIT, "BB Config Start!\n"); rtStatus = rtl92e_config_bb(dev); if (!rtStatus) { netdev_warn(dev, "%s(): Failed to configure BB\n", __func__); return rtStatus; } - RT_TRACE(COMP_INIT, "BB Config Finished!\n"); priv->LoopbackMode = RTL819X_NO_LOOPBACK; if (priv->ResetProgress == RESET_TYPE_NORESET) { @@ -818,19 +731,7 @@ start: tmpvalue = rtl92e_readb(dev, IC_VERRSION); priv->IC_Cut = tmpvalue; - RT_TRACE(COMP_INIT, "priv->IC_Cut= 0x%x\n", priv->IC_Cut); - if (priv->IC_Cut >= IC_VersionCut_D) { - if (priv->IC_Cut == IC_VersionCut_D) { - /* no matter what checkpatch says, braces are needed */ - RT_TRACE(COMP_INIT, "D-cut\n"); - } else if (priv->IC_Cut == IC_VersionCut_E) { - RT_TRACE(COMP_INIT, "E-cut\n"); - } - } else { - RT_TRACE(COMP_INIT, "Before C-cut\n"); - } - RT_TRACE(COMP_INIT, "Load Firmware!\n"); bfirmwareok = rtl92e_init_fw(dev); if (!bfirmwareok) { if (retry_times < 10) { @@ -841,15 +742,13 @@ start: goto end; } } - RT_TRACE(COMP_INIT, "Load Firmware finished!\n"); + if (priv->ResetProgress == RESET_TYPE_NORESET) { - RT_TRACE(COMP_INIT, "RF Config Started!\n"); rtStatus = rtl92e_config_phy(dev); if (!rtStatus) { netdev_info(dev, "RF Config failed\n"); return rtStatus; } - RT_TRACE(COMP_INIT, "RF Config Finished!\n"); } rtl92e_set_bb_reg(dev, rFPGA0_RFMOD, bCCKEn, 0x1); @@ -858,25 +757,14 @@ start: rtl92e_writeb(dev, 0x87, 0x0); if (priv->RegRfOff) { - RT_TRACE((COMP_INIT | COMP_RF | COMP_POWER), - "%s(): Turn off RF for RegRfOff ----------\n", - __func__); - rtl92e_set_rf_state(dev, eRfOff, RF_CHANGE_BY_SW); - } else if (priv->rtllib->RfOffReason > RF_CHANGE_BY_PS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), - "%s(): Turn off RF for RfOffReason(%d) ----------\n", - __func__, priv->rtllib->RfOffReason); - rtl92e_set_rf_state(dev, eRfOff, priv->rtllib->RfOffReason); - } else if (priv->rtllib->RfOffReason >= RF_CHANGE_BY_IPS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), - "%s(): Turn off RF for RfOffReason(%d) ----------\n", - __func__, priv->rtllib->RfOffReason); - rtl92e_set_rf_state(dev, eRfOff, priv->rtllib->RfOffReason); + rtl92e_set_rf_state(dev, rf_off, RF_CHANGE_BY_SW); + } else if (priv->rtllib->rf_off_reason > RF_CHANGE_BY_PS) { + rtl92e_set_rf_state(dev, rf_off, priv->rtllib->rf_off_reason); + } else if (priv->rtllib->rf_off_reason >= RF_CHANGE_BY_IPS) { + rtl92e_set_rf_state(dev, rf_off, priv->rtllib->rf_off_reason); } else { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON\n", - __func__); - priv->rtllib->eRFPowerState = eRfOn; - priv->rtllib->RfOffReason = 0; + priv->rtllib->rf_power_state = rf_on; + priv->rtllib->rf_off_reason = 0; } if (priv->rtllib->FwRWRF) @@ -915,18 +803,6 @@ start: priv->CCKPresentAttentuation_difference = 0; priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; - RT_TRACE(COMP_POWER_TRACKING, - "priv->rfa_txpowertrackingindex_initial = %d\n", - priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, - "priv->rfa_txpowertrackingindex_real__initial = %d\n", - priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, - "priv->CCKPresentAttentuation_difference_initial = %d\n", - priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, - "priv->CCKPresentAttentuation_initial = %d\n", - priv->CCKPresentAttentuation); priv->btxpower_tracking = false; } } @@ -946,7 +822,7 @@ static void _rtl92e_net_update(struct net_device *dev) net = &priv->rtllib->current_network; rtl92e_config_rate(dev, &rate_config); - priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; + priv->dot11_current_preamble_mode = PREAMBLE_AUTO; priv->basic_rate = rate_config &= 0x15f; rtl92e_writew(dev, BSSIDR, *(u16 *)net->bssid); rtl92e_writel(dev, BSSIDR + 2, *(u32 *)(net->bssid + 2)); @@ -1237,7 +1113,6 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, static u8 tmp; if (!tmp) { - RT_TRACE(COMP_DBG, "==>================hw sec\n"); tmp = 1; } switch (priv->rtllib->pairwise_key_type) { @@ -1350,12 +1225,6 @@ static u8 _rtl92e_rate_hw_to_mgn(bool bIsHT, u8 rate) case DESC90_RATE54M: ret_rate = MGN_54M; break; - - default: - RT_TRACE(COMP_RECV, - "%s: Non supportedRate [%x], bIsHT = %d!!!\n", - __func__, rate, bIsHT); - break; } } else { @@ -1411,12 +1280,6 @@ static u8 _rtl92e_rate_hw_to_mgn(bool bIsHT, u8 rate) case DESC90_RATEMCS32: ret_rate = 0x80 | 0x20; break; - - default: - RT_TRACE(COMP_RECV, - "%s: Non supported Rate [%x], bIsHT = %d!!!\n", - __func__, rate, bIsHT); - break; } } @@ -1721,9 +1584,6 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) { if (!rtl92e_is_legal_rf_path(priv->rtllib->dev, rfpath)) continue; - RT_TRACE(COMP_DBG, - "Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath] = %d\n", - prev_st->RxMIMOSignalStrength[rfpath]); if (priv->stats.rx_rssi_percentage[rfpath] == 0) { priv->stats.rx_rssi_percentage[rfpath] = prev_st->RxMIMOSignalStrength[rfpath]; @@ -1745,9 +1605,6 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, (prev_st->RxMIMOSignalStrength[rfpath])) / (RX_SMOOTH); } - RT_TRACE(COMP_DBG, - "Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d\n", - priv->stats.rx_rssi_percentage[rfpath]); } } @@ -1772,11 +1629,6 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, if (prev_st->RxPWDBAll >= 3) prev_st->RxPWDBAll -= 3; } - - RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", - prev_st->bIsCCK ? "CCK" : "OFDM", - prev_st->RxPWDBAll); - if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || prev_st->bToSelfBA) { if (priv->undecorated_smoothed_pwdb < 0) @@ -2052,11 +1904,6 @@ bool rtl92e_get_rx_stats(struct net_device *dev, struct rtllib_rx_stats *stats, stats->RxIs40MHzPacket = pDrvInfo->BW; _rtl92e_translate_rx_signal_stats(dev, skb, stats, pdesc, pDrvInfo); - - if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1) - RT_TRACE(COMP_RXDESC, - "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", - pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); skb_trim(skb, skb->len - 4/*sCrcLng*/); @@ -2138,7 +1985,7 @@ void rtl92e_update_ratr_table(struct net_device *dev) break; case IEEE_N_24G: case IEEE_N_5G: - if (ieee->pHTInfo->PeerMimoPs == 0) { + if (ieee->pHTInfo->peer_mimo_ps == 0) { ratr_value &= 0x0007F007; } else { if (priv->rf_type == RF_1T2R) @@ -2151,10 +1998,10 @@ void rtl92e_update_ratr_table(struct net_device *dev) break; } ratr_value &= 0x0FFFFFFF; - if (ieee->pHTInfo->bCurTxBW40MHz && + if (ieee->pHTInfo->cur_tx_bw40mhz && ieee->pHTInfo->bCurShortGI40MHz) ratr_value |= 0x80000000; - else if (!ieee->pHTInfo->bCurTxBW40MHz && + else if (!ieee->pHTInfo->cur_tx_bw40mhz && ieee->pHTInfo->bCurShortGI20MHz) ratr_value |= 0x80000000; rtl92e_writel(dev, RATR0+rate_index*4, ratr_value); @@ -2261,9 +2108,6 @@ bool rtl92e_is_rx_stuck(struct net_device *dev) u8 i; u8 SilentResetRxSoltNum = 4; - RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d, RxCounter is %d\n", - __func__, RegRxCounter, priv->RxCounter); - rx_chk_cnt++; if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) { rx_chk_cnt = 0; @@ -2321,9 +2165,6 @@ bool rtl92e_is_tx_stuck(struct net_device *dev) bool bStuck = false; u16 RegTxCounter = rtl92e_readw(dev, 0x128); - RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", - __func__, RegTxCounter, priv->TxCounter); - if (priv->TxCounter == RegTxCounter) bStuck = true; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index 38110fa4f36d..789d288d7503 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -77,10 +77,6 @@ static bool _rtl92e_fw_check_ready(struct net_device *dev, rt_status = _rtl92e_wait_for_fw(dev, CPU_GEN_FIRM_RDY, 20); if (rt_status) pfirmware->status = FW_STATUS_5_READY; - else - RT_TRACE(COMP_FIRMWARE, - "_rtl92e_is_fw_ready fail(%d)!\n", - rt_status); break; default: rt_status = false; @@ -149,9 +145,6 @@ bool rtl92e_init_fw(struct net_device *dev) } else if (pfirmware->status == FW_STATUS_5_READY) { rst_opt = OPT_FIRMWARE_RESET; starting_state = FW_INIT_STEP2_DATA; - } else { - RT_TRACE(COMP_FIRMWARE, - "PlatformInitFirmware: undefined firmware state\n"); } for (i = starting_state; i <= FW_INIT_STEP2_DATA; i++) { diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index f92551094738..1b592258e640 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -117,8 +117,6 @@ static u32 _rtl92e_phy_rf_read(struct net_device *dev, } else NewOffset = Offset; } else { - RT_TRACE((COMP_PHY|COMP_ERR), - "check RF type here, need to be 8256\n"); NewOffset = Offset; } rtl92e_set_bb_reg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, @@ -173,8 +171,6 @@ static void _rtl92e_phy_rf_write(struct net_device *dev, } else NewOffset = Offset; } else { - RT_TRACE((COMP_PHY|COMP_ERR), - "check RF type here, need to be 8256\n"); NewOffset = Offset; } @@ -204,10 +200,9 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath, if (!rtl92e_is_legal_rf_path(dev, eRFPath)) return; - if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) + if (priv->rtllib->rf_power_state != rf_on && !priv->being_init_adapter) return; - RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); if (priv->Rf_Mode == RF_OP_By_FW) { if (BitMask != bMask12Bits) { Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath, @@ -242,7 +237,7 @@ u32 rtl92e_get_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath, if (!rtl92e_is_legal_rf_path(dev, eRFPath)) return 0; - if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) + if (priv->rtllib->rf_power_state != rf_on && !priv->being_init_adapter) return 0; mutex_lock(&priv->rf_mutex); if (priv->Rf_Mode == RF_OP_By_FW) { @@ -312,19 +307,14 @@ void rtl92e_config_mac(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); if (priv->bTXPowerDataReadFromEEPORM) { - RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); dwArrayLen = MACPHY_Array_PGLength; pdwArray = Rtl819XMACPHY_Array_PG; } else { - RT_TRACE(COMP_PHY, "Read rtl819XMACPHY_Array\n"); dwArrayLen = MACPHY_ArrayLength; pdwArray = Rtl819XMACPHY_Array; } for (i = 0; i < dwArrayLen; i += 3) { - RT_TRACE(COMP_DBG, - "The Rtl8190MACPHY_Array[0] is %x Rtl8190MACPHY_Array[1] is %x Rtl8190MACPHY_Array[2] is %x\n", - pdwArray[i], pdwArray[i+1], pdwArray[i+2]); if (pdwArray[i] == 0x318) pdwArray[i+2] = 0x00000800; rtl92e_set_bb_reg(dev, pdwArray[i], pdwArray[i+1], @@ -357,20 +347,12 @@ static void _rtl92e_phy_config_bb(struct net_device *dev, u8 ConfigType) rtl92e_set_bb_reg(dev, Rtl819XPHY_REGArray_Table[i], bMaskDWord, Rtl819XPHY_REGArray_Table[i+1]); - RT_TRACE(COMP_DBG, - "i: %x, The Rtl819xUsbPHY_REGArray[0] is %x Rtl819xUsbPHY_REGArray[1] is %x\n", - i, Rtl819XPHY_REGArray_Table[i], - Rtl819XPHY_REGArray_Table[i+1]); } } else if (ConfigType == BaseBand_Config_AGC_TAB) { for (i = 0; i < AGCTAB_ArrayLen; i += 2) { rtl92e_set_bb_reg(dev, Rtl819XAGCTAB_Array_Table[i], bMaskDWord, Rtl819XAGCTAB_Array_Table[i+1]); - RT_TRACE(COMP_DBG, - "i:%x, The rtl819XAGCTAB_Array[0] is %x rtl819XAGCTAB_Array[1] is %x\n", - i, Rtl819XAGCTAB_Array_Table[i], - Rtl819XAGCTAB_Array_Table[i+1]); } } } @@ -478,8 +460,6 @@ bool rtl92e_check_bb_and_rf(struct net_device *dev, enum hw90_block CheckBlock, WriteAddr[HW90_BLOCK_PHY0] = 0x900; WriteAddr[HW90_BLOCK_PHY1] = 0x800; WriteAddr[HW90_BLOCK_RF] = 0x3; - RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, - CheckBlock); if (CheckBlock == HW90_BLOCK_MAC) { netdev_warn(dev, "%s(): No checks available for MAC block.\n", @@ -543,9 +523,6 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev) (enum hw90_block)eCheckItem, (enum rf90_radio_path)0); if (!rtStatus) { - RT_TRACE((COMP_ERR | COMP_PHY), - "rtl92e_config_rf():Check PHY%d Fail!!\n", - eCheckItem-1); return rtStatus; } } @@ -602,15 +579,9 @@ void rtl92e_get_tx_power(struct net_device *dev) priv->DefaultInitialGain[1] = rtl92e_readb(dev, rOFDM0_XBAGCCore1); priv->DefaultInitialGain[2] = rtl92e_readb(dev, rOFDM0_XCAGCCore1); priv->DefaultInitialGain[3] = rtl92e_readb(dev, rOFDM0_XDAGCCore1); - RT_TRACE(COMP_INIT, - "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n", - priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], - priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); priv->framesync = rtl92e_readb(dev, rOFDM0_RxDetector3); priv->framesyncC34 = rtl92e_readl(dev, rOFDM0_RxDetector2); - RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n", - rOFDM0_RxDetector3, priv->framesync); priv->SifsTime = rtl92e_readw(dev, SIFS); } @@ -813,9 +784,6 @@ static u8 _rtl92e_phy_switch_channel_step(struct net_device *dev, u8 channel, struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; - RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", - __func__, *stage, *step, channel); - if (!rtllib_legal_channel(priv->rtllib, channel)) { netdev_err(dev, "Invalid channel requested: %d\n", channel); return true; @@ -976,21 +944,13 @@ static void _rtl92e_phy_switch_channel_work_item(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_TRACE, "==> SwChnlCallback819xUsbWorkItem()\n"); - - RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, - priv->chan, priv); - _rtl92e_phy_switch_channel(dev, priv->chan); - - RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); } u8 rtl92e_set_channel(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_PHY, "=====>%s()\n", __func__); if (!priv->up) { netdev_err(dev, "%s(): Driver is not initialized\n", __func__); return false; @@ -1060,10 +1020,6 @@ static void _rtl92e_cck_tx_power_track_bw_switch_tssi(struct net_device *dev) if (priv->CCKPresentAttentuation < 0) priv->CCKPresentAttentuation = 0; - RT_TRACE(COMP_POWER_TRACKING, - "20M, priv->CCKPresentAttentuation = %d\n", - priv->CCKPresentAttentuation); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) { priv->bcck_in_ch14 = true; @@ -1082,9 +1038,6 @@ static void _rtl92e_cck_tx_power_track_bw_switch_tssi(struct net_device *dev) priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; - RT_TRACE(COMP_POWER_TRACKING, - "40M, priv->CCKPresentAttentuation = %d\n", - priv->CCKPresentAttentuation); if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength - 1)) priv->CCKPresentAttentuation = @@ -1123,16 +1076,10 @@ static void _rtl92e_cck_tx_power_track_bw_switch_thermal(struct net_device *dev) if (priv->Record_CCK_20Mindex == 0) priv->Record_CCK_20Mindex = 6; priv->CCK_index = priv->Record_CCK_20Mindex; - RT_TRACE(COMP_POWER_TRACKING, - "20MHz, %s,CCK_index = %d\n", __func__, - priv->CCK_index); break; case HT_CHANNEL_WIDTH_20_40: priv->CCK_index = priv->Record_CCK_40Mindex; - RT_TRACE(COMP_POWER_TRACKING, - "40MHz, %s, CCK_index = %d\n", __func__, - priv->CCK_index); break; } rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); @@ -1154,12 +1101,6 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u8 regBwOpMode; - RT_TRACE(COMP_SWBW, - "==>%s Switch to %s bandwidth\n", __func__, - priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz"); - - if (priv->rf_chip == RF_PSEUDO_11N) { priv->SetBWModeInProgress = false; return; @@ -1251,11 +1192,9 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) atomic_dec(&(priv->rtllib->atm_swbw)); priv->SetBWModeInProgress = false; - - RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); } -void rtl92e_set_bw_mode(struct net_device *dev, enum ht_channel_width Bandwidth, +void rtl92e_set_bw_mode(struct net_device *dev, enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1267,7 +1206,7 @@ void rtl92e_set_bw_mode(struct net_device *dev, enum ht_channel_width Bandwidth, atomic_inc(&(priv->rtllib->atm_swbw)); priv->SetBWModeInProgress = true; - priv->CurrentChannelBW = Bandwidth; + priv->CurrentChannelBW = bandwidth; if (Offset == HT_EXTCHNL_OFFSET_LOWER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; @@ -1291,8 +1230,6 @@ void rtl92e_init_gain(struct net_device *dev, u8 Operation) if (priv->up) { switch (Operation) { case IG_Backup: - RT_TRACE(COMP_SCAN, - "IG_Backup, backup the initial gain.\n"); initial_gain = SCAN_RX_INITIAL_GAIN; BitMask = bMaskByte0; if (dm_digtable.dig_algorithm == @@ -1314,35 +1251,13 @@ void rtl92e_init_gain(struct net_device *dev, u8 Operation) priv->initgain_backup.cca = (u8)rtl92e_get_bb_reg(dev, rCCK0_CCA, BitMask); - RT_TRACE(COMP_SCAN, - "Scan InitialGainBackup 0xc50 is %x\n", - priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, - "Scan InitialGainBackup 0xc58 is %x\n", - priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, - "Scan InitialGainBackup 0xc60 is %x\n", - priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, - "Scan InitialGainBackup 0xc68 is %x\n", - priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, - "Scan InitialGainBackup 0xa0a is %x\n", - priv->initgain_backup.cca); - - RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x\n", - initial_gain); rtl92e_writeb(dev, rOFDM0_XAAGCCore1, initial_gain); rtl92e_writeb(dev, rOFDM0_XBAGCCore1, initial_gain); rtl92e_writeb(dev, rOFDM0_XCAGCCore1, initial_gain); rtl92e_writeb(dev, rOFDM0_XDAGCCore1, initial_gain); - RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x\n", - POWER_DETECTION_TH); rtl92e_writeb(dev, 0xa0a, POWER_DETECTION_TH); break; case IG_Restore: - RT_TRACE(COMP_SCAN, - "IG_Restore, restore the initial gain.\n"); BitMask = 0x7f; if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) @@ -1360,22 +1275,6 @@ void rtl92e_init_gain(struct net_device *dev, u8 Operation) rtl92e_set_bb_reg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, - "Scan BBInitialGainRestore 0xc50 is %x\n", - priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, - "Scan BBInitialGainRestore 0xc58 is %x\n", - priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, - "Scan BBInitialGainRestore 0xc60 is %x\n", - priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, - "Scan BBInitialGainRestore 0xc68 is %x\n", - priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, - "Scan BBInitialGainRestore 0xa0a is %x\n", - priv->initgain_backup.cca); - rtl92e_set_tx_power(dev, priv->rtllib->current_network.channel); @@ -1383,9 +1282,6 @@ void rtl92e_init_gain(struct net_device *dev, u8 Operation) DIG_ALGO_BY_FALSE_ALARM) rtl92e_set_bb_reg(dev, UFWP, bMaskByte1, 0x1); break; - default: - RT_TRACE(COMP_SCAN, "Unknown IG Operation.\n"); - break; } } } @@ -1405,7 +1301,7 @@ void rtl92e_set_rf_off(struct net_device *dev) } static bool _rtl92e_set_rf_power_state(struct net_device *dev, - enum rt_rf_power_state eRFPowerState) + enum rt_rf_power_state rf_power_state) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1416,15 +1312,13 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, if (priv->SetRFPowerStateInProgress) return false; - RT_TRACE(COMP_PS, "===========> %s!\n", __func__); priv->SetRFPowerStateInProgress = true; switch (priv->rf_chip) { case RF_8256: - switch (eRFPowerState) { - case eRfOn: - RT_TRACE(COMP_PS, "%s eRfOn!\n", __func__); - if ((priv->rtllib->eRFPowerState == eRfOff) && + switch (rf_power_state) { + case rf_on: + if ((priv->rtllib->rf_power_state == rf_off) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { bool rtstatus; u32 InitilizeCount = 3; @@ -1469,8 +1363,8 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, break; - case eRfSleep: - if (priv->rtllib->eRFPowerState == eRfOff) + case rf_sleep: + if (priv->rtllib->rf_power_state == rf_off) break; @@ -1481,25 +1375,18 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, QueueID++; continue; } else { - RT_TRACE((COMP_POWER|COMP_RF), - "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", - (i+1), QueueID); udelay(10); i++; } if (i >= MAX_DOZE_WAITING_TIMES_9x) { - RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! %s: eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n", - __func__, MAX_DOZE_WAITING_TIMES_9x, QueueID); break; } } rtl92e_set_rf_off(dev); break; - case eRfOff: - RT_TRACE(COMP_PS, "%s eRfOff/Sleep !\n", __func__); - + case rf_off: for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { ring = &priv->tx_ring[QueueID]; @@ -1507,18 +1394,11 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, QueueID++; continue; } else { - RT_TRACE(COMP_POWER, - "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", - (i+1), QueueID); udelay(10); i++; } if (i >= MAX_DOZE_WAITING_TIMES_9x) { - RT_TRACE(COMP_POWER, - "\n\n\n SetZebra: RFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n", - MAX_DOZE_WAITING_TIMES_9x, - QueueID); break; } } @@ -1538,7 +1418,7 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, bResult = false; netdev_warn(dev, "%s(): Unknown state requested: 0x%X.\n", - __func__, eRFPowerState); + __func__, rf_power_state); break; } @@ -1550,7 +1430,7 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, } if (bResult) { - priv->rtllib->eRFPowerState = eRFPowerState; + priv->rtllib->rf_power_state = rf_power_state; switch (priv->rf_chip) { case RF_8256: @@ -1563,30 +1443,22 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, } priv->SetRFPowerStateInProgress = false; - RT_TRACE(COMP_PS, "<=========== %s bResult = %d!\n", __func__, bResult); return bResult; } bool rtl92e_set_rf_power_state(struct net_device *dev, - enum rt_rf_power_state eRFPowerState) + enum rt_rf_power_state rf_power_state) { struct r8192_priv *priv = rtllib_priv(dev); bool bResult = false; - RT_TRACE(COMP_PS, - "---------> %s: eRFPowerState(%d)\n", __func__, eRFPowerState); - if (eRFPowerState == priv->rtllib->eRFPowerState && + if (rf_power_state == priv->rtllib->rf_power_state && priv->bHwRfOffAction == 0) { - RT_TRACE(COMP_PS, "<--------- %s: discard the request for eRFPowerState(%d) is the same.\n", - __func__, eRFPowerState); return bResult; } - bResult = _rtl92e_set_rf_power_state(dev, eRFPowerState); - - RT_TRACE(COMP_PS, "<--------- %s: bResult(%d)\n", __func__, bResult); - + bResult = _rtl92e_set_rf_power_state(dev, rf_power_state); return bResult; } @@ -1603,10 +1475,6 @@ void rtl92e_scan_op_backup(struct net_device *dev, u8 Operation) case SCAN_OPT_RESTORE: priv->rtllib->InitialGainHandler(dev, IG_Restore); break; - - default: - RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation.\n"); - break; } } } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h index 7c9148e033d8..75629f5df954 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h @@ -75,15 +75,14 @@ u8 rtl92e_config_rf_path(struct net_device *dev, enum rf90_radio_path eRFPath); u8 rtl92e_set_channel(struct net_device *dev, u8 channel); void rtl92e_set_bw_mode(struct net_device *dev, - enum ht_channel_width Bandwidth, + enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset); void rtl92e_init_gain(struct net_device *dev, u8 Operation); void rtl92e_set_rf_off(struct net_device *dev); bool rtl92e_set_rf_power_state(struct net_device *dev, - enum rt_rf_power_state eRFPowerState); -#define PHY_SetRFPowerState rtl92e_set_rf_power_state + enum rt_rf_power_state rf_power_state); void rtl92e_scan_op_backup(struct net_device *dev, u8 Operation); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c index d7630f02a910..41faeb4b9b9b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c @@ -42,14 +42,10 @@ void rtl92e_enable_hw_security_config(struct net_device *dev) ieee->hwsec_active = 1; - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) { + if ((ieee->pHTInfo->iot_action & HT_IOT_ACT_PURE_N_MODE) || !hwwep) { ieee->hwsec_active = 0; SECR_value &= ~SCR_RxDecEnable; } - - RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", - __func__, ieee->hwsec_active, ieee->pairwise_key_type, - SECR_value); rtl92e_writeb(dev, SECR, SECR_value); } @@ -60,10 +56,6 @@ void rtl92e_set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; - RT_TRACE(COMP_DBG, - "===========>%s():EntryNo is %d,KeyIndex is %d,KeyType is %d,is_mesh is %d\n", - __func__, EntryNo, KeyIndex, KeyType, is_mesh); - if (EntryNo >= TOTAL_CAM_ENTRY) return; @@ -86,12 +78,12 @@ void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 usConfig = 0; u8 i; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - enum rt_rf_power_state rtState; + enum rt_rf_power_state rt_state; - rtState = priv->rtllib->eRFPowerState; + rt_state = priv->rtllib->rf_power_state; if (priv->rtllib->PowerSaveControl.bInactivePs) { - if (rtState == eRfOff) { - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + if (rt_state == rf_off) { + if (priv->rtllib->rf_off_reason > RF_CHANGE_BY_IPS) { netdev_warn(dev, "%s(): RF is OFF.\n", __func__); return; @@ -107,10 +99,6 @@ void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex, return; } - RT_TRACE(COMP_SEC, - "====>to %s, dev:%p, EntryNo:%d, KeyIndex:%d,KeyType:%d, MacAddr %pM\n", - __func__, dev, EntryNo, KeyIndex, KeyType, MacAddr); - if (DefaultKey) usConfig |= BIT15 | (KeyType<<2); else @@ -144,7 +132,6 @@ void rtl92e_set_key(struct net_device *dev, u8 EntryNo, u8 KeyIndex, } } } - RT_TRACE(COMP_SEC, "=========>after set key, usconfig:%x\n", usConfig); } void rtl92e_cam_restore(struct net_device *dev) @@ -163,9 +150,6 @@ void rtl92e_cam_restore(struct net_device *dev) 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - RT_TRACE(COMP_SEC, "%s:\n", __func__); - - if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40) || (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) { diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index b9ce71848023..89bc989cffba 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -25,7 +25,6 @@ int hwwep = 1; static char *ifname = "wlan%d"; - static const struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size = rtl92e_get_eeprom_size, @@ -44,8 +43,8 @@ static const struct rtl819x_ops rtl819xp_ops = { .rx_enable = rtl92e_enable_rx, .tx_enable = rtl92e_enable_tx, .interrupt_recognized = rtl92e_ack_irq, - .TxCheckStuckHandler = rtl92e_is_tx_stuck, - .RxCheckStuckHandler = rtl92e_is_rx_stuck, + .tx_check_stuck_handler = rtl92e_is_tx_stuck, + .rx_check_stuck_handler = rtl92e_is_rx_stuck, }; static struct pci_device_id rtl8192_pci_id_tbl[] = { @@ -133,36 +132,27 @@ void rtl92e_writew(struct net_device *dev, int x, u16 y) * -----------------------------GENERAL FUNCTION------------------------- ****************************************************************************/ bool rtl92e_set_rf_state(struct net_device *dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource) + enum rt_rf_power_state state_to_set, + RT_RF_CHANGE_SOURCE change_source) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; - bool bActionAllowed = false; - bool bConnectBySSID = false; - enum rt_rf_power_state rtState; - u16 RFWaitCounter = 0; + bool action_allowed = false; + bool connect_by_ssid = false; + enum rt_rf_power_state rt_state; + u16 rf_wait_counter = 0; unsigned long flag; - RT_TRACE((COMP_PS | COMP_RF), - "===>%s: StateToSet(%d)\n", __func__, StateToSet); - while (true) { spin_lock_irqsave(&priv->rf_ps_lock, flag); - if (priv->RFChangeInProgress) { + if (priv->rf_change_in_progress) { spin_unlock_irqrestore(&priv->rf_ps_lock, flag); - RT_TRACE((COMP_PS | COMP_RF), - "%s: RF Change in progress! Wait to set..StateToSet(%d).\n", - __func__, StateToSet); - - while (priv->RFChangeInProgress) { - RFWaitCounter++; - RT_TRACE((COMP_PS | COMP_RF), - "%s: Wait 1 ms (%d times)...\n", - __func__, RFWaitCounter); + + while (priv->rf_change_in_progress) { + rf_wait_counter++; mdelay(1); - if (RFWaitCounter > 100) { + if (rf_wait_counter > 100) { netdev_warn(dev, "%s(): Timeout waiting for RF change.\n", __func__); @@ -170,43 +160,37 @@ bool rtl92e_set_rf_state(struct net_device *dev, } } } else { - priv->RFChangeInProgress = true; + priv->rf_change_in_progress = true; spin_unlock_irqrestore(&priv->rf_ps_lock, flag); break; } } - rtState = priv->rtllib->eRFPowerState; + rt_state = priv->rtllib->rf_power_state; - switch (StateToSet) { - case eRfOn: - priv->rtllib->RfOffReason &= (~ChangeSource); + switch (state_to_set) { + case rf_on: + priv->rtllib->rf_off_reason &= (~change_source); - if ((ChangeSource == RF_CHANGE_BY_HW) && priv->bHwRadioOff) - priv->bHwRadioOff = false; + if ((change_source == RF_CHANGE_BY_HW) && priv->hw_radio_off) + priv->hw_radio_off = false; - if (!priv->rtllib->RfOffReason) { - priv->rtllib->RfOffReason = 0; - bActionAllowed = true; - - - if (rtState == eRfOff && - ChangeSource >= RF_CHANGE_BY_HW) - bConnectBySSID = true; - } else { - RT_TRACE((COMP_PS | COMP_RF), - "%s - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", - __func__, priv->rtllib->RfOffReason, ChangeSource); - } + if (!priv->rtllib->rf_off_reason) { + priv->rtllib->rf_off_reason = 0; + action_allowed = true; + if (rt_state == rf_off && + change_source >= RF_CHANGE_BY_HW) + connect_by_ssid = true; + } break; - case eRfOff: + case rf_off: if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || (priv->rtllib->iw_mode == IW_MODE_ADHOC)) { - if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || - (ChangeSource > RF_CHANGE_BY_IPS)) { + if ((priv->rtllib->rf_off_reason > RF_CHANGE_BY_IPS) || + (change_source > RF_CHANGE_BY_IPS)) { if (ieee->state == RTLLIB_LINKED) priv->blinked_ingpio = true; else @@ -215,46 +199,36 @@ bool rtl92e_set_rf_state(struct net_device *dev, WLAN_REASON_DISASSOC_STA_HAS_LEFT); } } - if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff) - priv->bHwRadioOff = true; - priv->rtllib->RfOffReason |= ChangeSource; - bActionAllowed = true; + if ((change_source == RF_CHANGE_BY_HW) && !priv->hw_radio_off) + priv->hw_radio_off = true; + priv->rtllib->rf_off_reason |= change_source; + action_allowed = true; break; - case eRfSleep: - priv->rtllib->RfOffReason |= ChangeSource; - bActionAllowed = true; + case rf_sleep: + priv->rtllib->rf_off_reason |= change_source; + action_allowed = true; break; default: break; } - if (bActionAllowed) { - RT_TRACE((COMP_PS | COMP_RF), - "%s: Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", - __func__, StateToSet, priv->rtllib->RfOffReason); - PHY_SetRFPowerState(dev, StateToSet); - if (StateToSet == eRfOn) { - - if (bConnectBySSID && priv->blinked_ingpio) { + if (action_allowed) { + rtl92e_set_rf_power_state(dev, state_to_set); + if (state_to_set == rf_on) { + if (connect_by_ssid && priv->blinked_ingpio) { schedule_delayed_work( &ieee->associate_procedure_wq, 0); priv->blinked_ingpio = false; } } - } else { - RT_TRACE((COMP_PS | COMP_RF), - "%s: Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", - __func__, StateToSet, ChangeSource, priv->rtllib->RfOffReason); } spin_lock_irqsave(&priv->rf_ps_lock, flag); - priv->RFChangeInProgress = false; + priv->rf_change_in_progress = false; spin_unlock_irqrestore(&priv->rf_ps_lock, flag); - - RT_TRACE((COMP_PS | COMP_RF), "<===%s\n", __func__); - return bActionAllowed; + return action_allowed; } static short _rtl92e_check_nic_enough_desc(struct net_device *dev, int prio) @@ -297,7 +271,6 @@ static void _rtl92e_set_chan(struct net_device *dev, short ch) { struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); if (priv->chan_forced) return; @@ -314,22 +287,16 @@ static void _rtl92e_update_cap(struct net_device *dev, u16 cap) bool ShortPreamble; if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) { - if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) { + if (priv->dot11_current_preamble_mode != PREAMBLE_SHORT) { ShortPreamble = true; - priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; - RT_TRACE(COMP_DBG, - "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n", - __func__); + priv->dot11_current_preamble_mode = PREAMBLE_SHORT; priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble); } } else { - if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) { + if (priv->dot11_current_preamble_mode != PREAMBLE_LONG) { ShortPreamble = false; - priv->dot11CurrentPreambleMode = PREAMBLE_LONG; - RT_TRACE(COMP_DBG, - "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n", - __func__); + priv->dot11_current_preamble_mode = PREAMBLE_LONG; priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble); } @@ -337,17 +304,17 @@ static void _rtl92e_update_cap(struct net_device *dev, u16 cap) if (net->mode & (IEEE_G | IEEE_N_24G)) { u8 slot_time_val; - u8 CurSlotTime = priv->slot_time; + u8 cur_slot_time = priv->slot_time; if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && - (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) { - if (CurSlotTime != SHORT_SLOT_TIME) { + (!priv->rtllib->pHTInfo->current_rt2rt_long_slot_time)) { + if (cur_slot_time != SHORT_SLOT_TIME) { slot_time_val = SHORT_SLOT_TIME; priv->rtllib->SetHwRegHandler(dev, HW_VAR_SLOT_TIME, &slot_time_val); } } else { - if (CurSlotTime != NON_SHORT_SLOT_TIME) { + if (cur_slot_time != NON_SHORT_SLOT_TIME) { slot_time_val = NON_SHORT_SLOT_TIME; priv->rtllib->SetHwRegHandler(dev, HW_VAR_SLOT_TIME, &slot_time_val); @@ -374,7 +341,7 @@ static void _rtl92e_update_beacon(void *data) if (ieee->pHTInfo->bCurrentHTSupport) HT_update_self_and_peer_setting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bd_rt2rt_long_slot_time; + ieee->pHTInfo->current_rt2rt_long_slot_time = net->bssht.bd_rt2rt_long_slot_time; ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.rt2rt_ht_mode; _rtl92e_update_cap(dev, net->capability); } @@ -389,13 +356,10 @@ static void _rtl92e_qos_activate(void *data) mutex_lock(&priv->mutex); if (priv->rtllib->state != RTLLIB_LINKED) goto success; - RT_TRACE(COMP_QOS, - "qos active process with associate response received\n"); for (i = 0; i < QOS_QUEUE_NUM; i++) priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); - success: mutex_unlock(&priv->mutex); } @@ -426,18 +390,14 @@ static int _rtl92e_qos_handle_probe_response(struct r8192_priv *priv, network->qos_data.param_count; priv->rtllib->wmm_acm = network->qos_data.wmm_acm; schedule_work(&priv->qos_activate); - RT_TRACE(COMP_QOS, - "QoS parameters change call qos_activate\n"); } } else { memcpy(&priv->rtllib->current_network.qos_data.parameters, &def_qos_parameters, size); - if ((network->qos_data.active == 1) && (active_network == 1)) { + if ((network->qos_data.active == 1) && (active_network == 1)) schedule_work(&priv->qos_activate); - RT_TRACE(COMP_QOS, - "QoS was disabled call qos_activate\n"); - } + network->qos_data.active = 0; network->qos_data.supported = 0; } @@ -455,7 +415,6 @@ static int _rtl92e_handle_beacon(struct net_device *dev, schedule_delayed_work(&priv->update_beacon_wq, 0); return 0; - } static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv, @@ -496,8 +455,6 @@ static int _rtl92e_qos_assoc_resp(struct r8192_priv *priv, spin_unlock_irqrestore(&priv->rtllib->lock, flags); - RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, - network->flags, priv->rtllib->current_network.qos_data.active); if (set_qos_param == 1) { rtl92e_dm_init_edca_turbo(priv->rtllib->dev); schedule_work(&priv->qos_activate); @@ -716,15 +673,9 @@ void rtl92e_set_wireless_mode(struct net_device *dev, u8 wireless_mode) if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) { priv->rtllib->pHTInfo->bEnableHT = 1; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", - __func__, wireless_mode); } else { priv->rtllib->pHTInfo->bEnableHT = 0; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", - __func__, wireless_mode); } - - RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); _rtl92e_refresh_support_rate(priv); } @@ -742,7 +693,6 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset) priv->rtllib->ieee_up = 1; priv->up_first_time = 0; - RT_TRACE(COMP_INIT, "Bringing up iface"); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (!init_status) { @@ -751,7 +701,6 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset) return -1; } - RT_TRACE(COMP_INIT, "start adapter finished\n"); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; @@ -790,7 +739,6 @@ static int _rtl92e_sta_down(struct net_device *dev, bool shutdownrf) priv->up = 0; priv->rtllib->ieee_up = 0; priv->bfirst_after_down = true; - RT_TRACE(COMP_DOWN, "==========>%s()\n", __func__); if (!netif_queue_stopped(dev)) netif_stop_queue(dev); @@ -807,29 +755,25 @@ static int _rtl92e_sta_down(struct net_device *dev, bool shutdownrf) rtllib_softmac_stop_protocol(priv->rtllib, 0, true); spin_lock_irqsave(&priv->rf_ps_lock, flags); - while (priv->RFChangeInProgress) { + while (priv->rf_change_in_progress) { spin_unlock_irqrestore(&priv->rf_ps_lock, flags); if (RFInProgressTimeOut > 100) { spin_lock_irqsave(&priv->rf_ps_lock, flags); break; } - RT_TRACE(COMP_DBG, - "===>%s():RF is in progress, need to wait until rf change is done.\n", - __func__); mdelay(1); RFInProgressTimeOut++; spin_lock_irqsave(&priv->rf_ps_lock, flags); } - priv->RFChangeInProgress = true; + priv->rf_change_in_progress = true; spin_unlock_irqrestore(&priv->rf_ps_lock, flags); priv->ops->stop_adapter(dev, false); spin_lock_irqsave(&priv->rf_ps_lock, flags); - priv->RFChangeInProgress = false; + priv->rf_change_in_progress = false; spin_unlock_irqrestore(&priv->rf_ps_lock, flags); udelay(100); memset(&priv->rtllib->current_network, 0, offsetof(struct rtllib_network, list)); - RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); return 0; } @@ -883,14 +827,13 @@ static void _rtl92e_init_priv_constant(struct net_device *dev) pPSC->RegMaxLPSAwakeIntvl = 5; } - static void _rtl92e_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 i; priv->AcmMethod = eAcmWay2_SW; - priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; + priv->dot11_current_preamble_mode = PREAMBLE_AUTO; priv->rtllib->status = 0; priv->polling_timer_on = 0; priv->up_first_time = 1; @@ -935,12 +878,12 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) memset(&priv->InterruptLog, 0, sizeof(struct log_int_8190)); priv->RxCounter = 0; priv->rtllib->wx_set_enc = 0; - priv->bHwRadioOff = false; + priv->hw_radio_off = false; priv->RegRfOff = false; priv->isRFOff = false; priv->bInPowerSaveMode = false; - priv->rtllib->RfOffReason = 0; - priv->RFChangeInProgress = false; + priv->rtllib->rf_off_reason = 0; + priv->rf_change_in_progress = false; priv->bHwRfOffAction = 0; priv->SetRFPowerStateInProgress = false; priv->rtllib->PowerSaveControl.bInactivePs = true; @@ -949,7 +892,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->rtllib->PowerSaveControl.bFwCtrlLPS = false; priv->rtllib->LPSDelayCnt = 0; priv->rtllib->sta_sleep = LPS_IS_WAKE; - priv->rtllib->eRFPowerState = eRfOn; + priv->rtllib->rf_power_state = rf_on; priv->rtllib->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; priv->rtllib->iw_mode = IW_MODE_INFRA; @@ -1032,7 +975,6 @@ static short _rtl92e_get_channel_map(struct net_device *dev) "rtl819x_init:Error channel plan! Set to default.\n"); priv->ChannelPlan = COUNTRY_CODE_FCC; } - RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan); dot11d_init(priv->rtllib); dot11d_channel_map(priv->ChannelPlan, priv->rtllib); for (i = 1; i <= 11; i++) @@ -1072,7 +1014,6 @@ static short _rtl92e_init(struct net_device *dev) } priv->irq = dev->irq; - RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq); if (_rtl92e_pci_initdescring(dev) != 0) { netdev_err(dev, "Endopoints initialization failed"); @@ -1149,11 +1090,8 @@ static enum reset_type _rtl92e_tx_check_stuck(struct net_device *dev) spin_unlock_irqrestore(&priv->irq_th_lock, flags); if (bCheckFwTxCnt) { - if (priv->ops->TxCheckStuckHandler(dev)) { - RT_TRACE(COMP_RESET, - "TxCheckStuck(): Fw indicates no Tx condition!\n"); + if (priv->ops->tx_check_stuck_handler(dev)) return RESET_TYPE_SILENT; - } } return RESET_TYPE_NORESET; @@ -1163,10 +1101,8 @@ static enum reset_type _rtl92e_rx_check_stuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->ops->RxCheckStuckHandler(dev)) { - RT_TRACE(COMP_RESET, "RxStuck Condition\n"); + if (priv->ops->rx_check_stuck_handler(dev)) return RESET_TYPE_SILENT; - } return RESET_TYPE_NORESET; } @@ -1178,12 +1114,12 @@ static enum reset_type _rtl92e_if_check_reset(struct net_device *dev) enum reset_type RxResetType = RESET_TYPE_NORESET; enum rt_rf_power_state rfState; - rfState = priv->rtllib->eRFPowerState; + rfState = priv->rtllib->rf_power_state; - if (rfState == eRfOn) + if (rfState == rf_on) TxResetType = _rtl92e_tx_check_stuck(dev); - if (rfState == eRfOn && + if (rfState == rf_on && (priv->rtllib->iw_mode == IW_MODE_INFRA) && (priv->rtllib->state == RTLLIB_LINKED)) RxResetType = _rtl92e_rx_check_stuck(dev); @@ -1201,7 +1137,6 @@ static enum reset_type _rtl92e_if_check_reset(struct net_device *dev) } else { return RESET_TYPE_NORESET; } - } static void _rtl92e_if_silent_reset(struct net_device *dev) @@ -1213,17 +1148,14 @@ static void _rtl92e_if_silent_reset(struct net_device *dev) unsigned long flag; if (priv->ResetProgress == RESET_TYPE_NORESET) { - - RT_TRACE(COMP_RESET, "=========>Reset progress!!\n"); - priv->ResetProgress = RESET_TYPE_SILENT; spin_lock_irqsave(&priv->rf_ps_lock, flag); - if (priv->RFChangeInProgress) { + if (priv->rf_change_in_progress) { spin_unlock_irqrestore(&priv->rf_ps_lock, flag); goto END; } - priv->RFChangeInProgress = true; + priv->rf_change_in_progress = true; priv->bResetInProgress = true; spin_unlock_irqrestore(&priv->rf_ps_lock, flag); @@ -1242,12 +1174,7 @@ RESET_START: } priv->up = 0; - RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", - __func__); mdelay(1000); - RT_TRACE(COMP_RESET, - "%s():111111111111111111111111======>start to down the driver\n", - __func__); if (!netif_queue_stopped(dev)) netif_stop_queue(dev); @@ -1275,16 +1202,8 @@ RESET_START: rtl92e_dm_backup_state(dev); mutex_unlock(&priv->wx_mutex); - RT_TRACE(COMP_RESET, - "%s():<==========down process is finished\n", - __func__); - - RT_TRACE(COMP_RESET, "%s():<===========up process start\n", - __func__); reset_status = _rtl92e_up(dev, true); - RT_TRACE(COMP_RESET, - "%s():<===========up process is finished\n", __func__); if (reset_status == -1) { if (reset_times < 3) { reset_times++; @@ -1298,7 +1217,7 @@ RESET_START: ieee->is_silent_reset = 1; spin_lock_irqsave(&priv->rf_ps_lock, flag); - priv->RFChangeInProgress = false; + priv->rf_change_in_progress = false; spin_unlock_irqrestore(&priv->rf_ps_lock, flag); rtl92e_enable_hw_security_config(dev); @@ -1333,8 +1252,6 @@ END: priv->bResetInProgress = false; rtl92e_writeb(dev, UFWP, 1); - RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", - priv->reset_count); } } @@ -1375,7 +1292,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) bool bHigherBusyRxTraffic = false; bool bEnterPS = false; - if (!priv->up || priv->bHwRadioOff) + if (!priv->up || priv->hw_radio_off) return; if (priv->rtllib->state >= RTLLIB_LINKED) { @@ -1390,13 +1307,11 @@ static void _rtl92e_watchdog_wq_cb(void *data) if (!rtllib_act_scanning(priv->rtllib, false)) { if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == RTLLIB_NOLINK) && - (ieee->eRFPowerState == eRfOn) && !ieee->is_set_key && + (ieee->rf_power_state == rf_on) && !ieee->is_set_key && (!ieee->proto_stoppping) && !ieee->wx_set_enc) { if ((ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE) && (!ieee->bNetPromiscuousMode)) { - RT_TRACE(COMP_PS, - "====================>haha: rtl92e_ips_enter()\n"); rtl92e_ips_enter(dev); } } @@ -1407,7 +1322,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) ieee->LinkDetectInfo.NumTxOkInPeriod > 100) bBusyTraffic = true; - if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) { bHigherBusyTraffic = true; @@ -1433,7 +1347,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) rtl92e_leisure_ps_leave(dev); } else { - RT_TRACE(COMP_LPS, "====>no link LPS leave\n"); rtl92e_leisure_ps_leave(dev); } @@ -1456,9 +1369,8 @@ static void _rtl92e_watchdog_wq_cb(void *data) else priv->check_roaming_cnt = 0; - if (priv->check_roaming_cnt > 0) { - if (ieee->eRFPowerState == eRfOff) + if (ieee->rf_power_state == rf_off) netdev_info(dev, "%s(): RF is off\n", __func__); netdev_info(dev, @@ -1487,12 +1399,11 @@ static void _rtl92e_watchdog_wq_cb(void *data) } ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; - } spin_lock_irqsave(&priv->tx_lock, flags); if ((check_reset_cnt++ >= 3) && (!ieee->is_roaming) && - (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) { + (!priv->rf_change_in_progress) && (!pPSC->bSwRfProcessing)) { ResetType = _rtl92e_if_check_reset(dev); check_reset_cnt = 3; } @@ -1500,7 +1411,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) { priv->ResetProgress = RESET_TYPE_NORMAL; - RT_TRACE(COMP_RESET, "%s(): NOMAL RESET\n", __func__); return; } @@ -1510,7 +1420,6 @@ static void _rtl92e_watchdog_wq_cb(void *data) priv->force_reset = false; priv->bForcedSilentReset = false; priv->bResetInProgress = false; - RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); } static void _rtl92e_watchdog_timer_cb(struct timer_list *t) @@ -1541,7 +1450,6 @@ void rtl92e_tx_enable(struct net_device *dev) rtllib_reset_queue(priv->rtllib); } - static void _rtl92e_free_rx_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1599,7 +1507,7 @@ static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if ((priv->rtllib->eRFPowerState == eRfOff) || !priv->up || + if ((priv->rtllib->rf_power_state == rf_off) || !priv->up || priv->bResetInProgress) { kfree_skb(skb); return; @@ -1632,7 +1540,7 @@ static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) u8 queue_index = tcb_desc->queue_index; if (queue_index != TXCMD_QUEUE) { - if ((priv->rtllib->eRFPowerState == eRfOff) || + if ((priv->rtllib->rf_power_state == rf_off) || !priv->up || priv->bResetInProgress) { kfree_skb(skb); return 0; @@ -1936,13 +1844,11 @@ long rtl92e_translate_to_dbm(struct r8192_priv *priv, u8 signal_strength_index) return signal_power; } - void rtl92e_update_rx_statistics(struct r8192_priv *priv, struct rtllib_rx_stats *pprevious_stats) { int weighting = 0; - if (priv->stats.recv_signal_power == 0) priv->stats.recv_signal_power = pprevious_stats->RecvSignalPower; @@ -1985,8 +1891,6 @@ void rtl92e_copy_mpdu_stats(struct rtllib_rx_stats *psrc_stats, ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; } - - static void _rtl92e_rx_normal(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2086,7 +1990,6 @@ done: priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; } - } static void _rtl92e_tx_resume(struct net_device *dev) @@ -2151,7 +2054,6 @@ static int _rtl92e_open(struct net_device *dev) ret = _rtl92e_try_up(dev); mutex_unlock(&priv->wx_mutex); return ret; - } static int _rtl92e_try_up(struct net_device *dev) @@ -2163,7 +2065,6 @@ static int _rtl92e_try_up(struct net_device *dev) return _rtl92e_up(dev, false); } - static int _rtl92e_close(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2181,7 +2082,6 @@ static int _rtl92e_close(struct net_device *dev) mutex_unlock(&priv->wx_mutex); return ret; - } static int _rtl92e_down(struct net_device *dev, bool shutdownrf) @@ -2224,10 +2124,8 @@ static void _rtl92e_set_multicast(struct net_device *dev) promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->promisc = promisc; - } - static int _rtl92e_set_mac_adr(struct net_device *dev, void *mac) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2278,21 +2176,13 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) goto done; } - if (inta & IMR_TBDOK) { - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + if (inta & IMR_TBDOK) priv->stats.txbeaconokint++; - } - if (inta & IMR_TBDER) { - RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); + if (inta & IMR_TBDER) priv->stats.txbeaconerr++; - } - - if (inta & IMR_BDOK) - RT_TRACE(COMP_INTR, "beacon interrupt!\n"); if (inta & IMR_MGNTDOK) { - RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); priv->stats.txmanageokint++; _rtl92e_tx_isr(dev, MGNT_QUEUE); spin_unlock_irqrestore(&priv->irq_th_lock, flags); @@ -2319,13 +2209,10 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) tasklet_schedule(&priv->irq_rx_tasklet); } - if (inta & IMR_BcnInt) { - RT_TRACE(COMP_INTR, "prepare beacon for interrupt!\n"); + if (inta & IMR_BcnInt) tasklet_schedule(&priv->irq_prepare_beacon_tasklet); - } if (inta & IMR_RDU) { - RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); priv->stats.rxrdu++; rtl92e_writel(dev, INTA_MASK, rtl92e_readl(dev, INTA_MASK) & ~IMR_RDU); @@ -2333,7 +2220,6 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) } if (inta & IMR_RXFOVW) { - RT_TRACE(COMP_INTR, "rx overflow !\n"); priv->stats.rxoverflow++; tasklet_schedule(&priv->irq_rx_tasklet); } @@ -2342,21 +2228,18 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) priv->stats.txoverflow++; if (inta & IMR_BKDOK) { - RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); priv->stats.txbkokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, BK_QUEUE); } if (inta & IMR_BEDOK) { - RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); priv->stats.txbeokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, BE_QUEUE); } if (inta & IMR_VIDOK) { - RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); priv->stats.txviokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, VI_QUEUE); @@ -2364,7 +2247,6 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) if (inta & IMR_VODOK) { priv->stats.txvookint++; - RT_TRACE(COMP_INTR, "Vo TX OK interrupt!\n"); priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, VO_QUEUE); } @@ -2376,8 +2258,6 @@ done: return IRQ_HANDLED; } - - /**************************************************************************** * ---------------------------- PCI_STUFF--------------------------- ****************************************************************************/ @@ -2402,8 +2282,6 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, int err = -ENOMEM; u8 revision_id; - RT_TRACE(COMP_INIT, "Configuring chip resources"); - if (pci_enable_device(pdev)) { dev_err(&pdev->dev, "Failed to enable PCI device"); return -EIO; @@ -2452,7 +2330,6 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, goto err_rel_rtllib; } - ioaddr = (unsigned long)ioremap(pmem_start, pmem_len); if (ioaddr == (unsigned long)NULL) { netdev_err(dev, "ioremap failed!"); @@ -2483,13 +2360,9 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, dev->type = ARPHRD_ETHER; dev->watchdog_timeo = HZ * 3; - if (dev_alloc_name(dev, ifname) < 0) { - RT_TRACE(COMP_INIT, - "Oops: devname already taken! Trying wlan%%d...\n"); + if (dev_alloc_name(dev, ifname) < 0) dev_alloc_name(dev, ifname); - } - RT_TRACE(COMP_INIT, "Driver probe completed1\n"); if (_rtl92e_init(dev) != 0) { netdev_warn(dev, "Initialization failed"); goto err_free_irq; @@ -2500,12 +2373,10 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, if (register_netdev(dev)) goto err_free_irq; - RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); if (priv->polling_timer_on == 0) rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer); - RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; err_free_irq: @@ -2560,7 +2431,6 @@ static void _rtl92e_pci_disconnect(struct pci_dev *pdev) } pci_disable_device(pdev); - RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } bool rtl92e_enable_nic(struct net_device *dev) @@ -2576,7 +2446,6 @@ bool rtl92e_enable_nic(struct net_device *dev) return false; } - RT_TRACE(COMP_PS, "===========>%s()\n", __func__); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (!init_status) { @@ -2584,13 +2453,11 @@ bool rtl92e_enable_nic(struct net_device *dev) priv->bdisable_nic = false; return false; } - RT_TRACE(COMP_INIT, "start adapter finished\n"); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; rtl92e_irq_enable(dev); priv->bdisable_nic = false; - RT_TRACE(COMP_PS, "<===========%s()\n", __func__); return init_status; } @@ -2599,7 +2466,6 @@ bool rtl92e_disable_nic(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u8 tmp_state = 0; - RT_TRACE(COMP_PS, "=========>%s()\n", __func__); priv->bdisable_nic = true; tmp_state = priv->rtllib->state; rtllib_softmac_stop_protocol(priv->rtllib, 0, false); @@ -2608,8 +2474,6 @@ bool rtl92e_disable_nic(struct net_device *dev) rtl92e_irq_disable(dev); priv->ops->stop_adapter(dev, false); - RT_TRACE(COMP_PS, "<=========%s()\n", __func__); - return true; } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 698552a92100..7021f9c435d9 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -299,8 +299,8 @@ struct rtl819x_ops { void (*tx_enable)(struct net_device *dev); void (*interrupt_recognized)(struct net_device *dev, u32 *p_inta, u32 *p_intb); - bool (*TxCheckStuckHandler)(struct net_device *dev); - bool (*RxCheckStuckHandler)(struct net_device *dev); + bool (*tx_check_stuck_handler)(struct net_device *dev); + bool (*rx_check_stuck_handler)(struct net_device *dev); }; struct r8192_priv { @@ -392,7 +392,7 @@ struct r8192_priv { u16 ShortRetryLimit; u16 LongRetryLimit; - bool bHwRadioOff; + bool hw_radio_off; bool blinked_ingpio; u8 polling_timer_on; @@ -430,7 +430,7 @@ struct r8192_priv { u16 basic_rate; u8 short_preamble; - u8 dot11CurrentPreambleMode; + u8 dot11_current_preamble_mode; u8 slot_time; u16 SifsTime; @@ -478,7 +478,7 @@ struct r8192_priv { bool bInPowerSaveMode; u8 bHwRfOffAction; - bool RFChangeInProgress; + bool rf_change_in_progress; bool SetRFPowerStateInProgress; bool bdisable_nic; @@ -598,6 +598,6 @@ bool rtl92e_enable_nic(struct net_device *dev); bool rtl92e_disable_nic(struct net_device *dev); bool rtl92e_set_rf_state(struct net_device *dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource); + enum rt_rf_power_state state_to_set, + RT_RF_CHANGE_SOURCE change_source); #endif diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index d58800d06e8f..702551056227 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -268,8 +268,6 @@ static void _rtl92e_dm_check_ac_dc_power(struct net_device *dev) NULL}; if (priv->ResetProgress == RESET_TYPE_SILENT) { - RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), - "GPIOChangeRFWorkItemCallBack(): Silent Reset!!!!!!!\n"); return; } @@ -333,8 +331,6 @@ static void _rtl92e_dm_check_rate_adaptive(struct net_device *dev) static u8 ping_rssi_state; if (!priv->up) { - RT_TRACE(COMP_RATE, - "<---- %s: driver is going to unload\n", __func__); return; } @@ -347,9 +343,9 @@ static void _rtl92e_dm_check_rate_adaptive(struct net_device *dev) if (priv->rtllib->state == RTLLIB_LINKED) { - bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && + bshort_gi_enabled = (pHTInfo->cur_tx_bw40mhz && pHTInfo->bCurShortGI40MHz) || - (!pHTInfo->bCurTxBW40MHz && + (!pHTInfo->cur_tx_bw40mhz && pHTInfo->bCurShortGI20MHz); pra->upper_rssi_threshold_ratr = @@ -423,9 +419,6 @@ static void _rtl92e_dm_check_rate_adaptive(struct net_device *dev) u32 ratr_value; ratr_value = targetRATR; - RT_TRACE(COMP_RATE, - "currentRATR = %x, targetRATR = %x\n", - currentRATR, targetRATR); if (priv->rf_type == RF_1T2R) ratr_value &= ~(RATE_ALL_OFDM_2SS); rtl92e_writel(dev, RATR0, ratr_value); @@ -628,7 +621,6 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver = 0; u32 delta = 0; - RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); priv->rtllib->bdynamic_txpower_enable = false; @@ -637,10 +629,6 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) RF_Type = priv->rf_type; Value = (RF_Type<<8) | powerlevelOFDM24G; - RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", - powerlevelOFDM24G); - - for (j = 0; j <= 30; j++) { tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; @@ -656,15 +644,11 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) mdelay(1); if (priv->bResetInProgress) { - RT_TRACE(COMP_POWER_TRACKING, - "we are in silent reset progress, so return\n"); rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); return; } - if (priv->rtllib->eRFPowerState != eRfOn) { - RT_TRACE(COMP_POWER_TRACKING, - "we are in power save, so return\n"); + if (priv->rtllib->rf_power_state != rf_on) { rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); return; @@ -689,10 +673,6 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) tmp_report[k] = rtl92e_readb(dev, Tssi_Report_Value2); - RT_TRACE(COMP_POWER_TRACKING, - "TSSI_report_value = %d\n", - tmp_report[k]); - if (tmp_report[k] <= 20) { viviflag = true; break; @@ -702,8 +682,6 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) if (viviflag) { rtl92e_writeb(dev, Pw_Track_Flag, 0); viviflag = false; - RT_TRACE(COMP_POWER_TRACKING, - "we filted this data\n"); for (k = 0; k < 5; k++) tmp_report[k] = 0; break; @@ -713,12 +691,7 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) Avg_TSSI_Meas_from_driver += tmp_report[k]; Avg_TSSI_Meas_from_driver *= 100 / 5; - RT_TRACE(COMP_POWER_TRACKING, - "Avg_TSSI_Meas_from_driver = %d\n", - Avg_TSSI_Meas_from_driver); TSSI_13dBm = priv->TSSI_13dBm; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", - TSSI_13dBm); if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; @@ -729,20 +702,6 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) priv->rtllib->bdynamic_txpower_enable = true; rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, - "tx power track is done\n"); - RT_TRACE(COMP_POWER_TRACKING, - "priv->rfa_txpowertrackingindex = %d\n", - priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, - "priv->rfa_txpowertrackingindex_real = %d\n", - priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, - "priv->CCKPresentAttentuation_difference = %d\n", - priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, - "priv->CCKPresentAttentuation = %d\n", - priv->CCKPresentAttentuation); return; } if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) @@ -785,26 +744,12 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) } else rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); } - RT_TRACE(COMP_POWER_TRACKING, - "priv->rfa_txpowertrackingindex = %d\n", - priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, - "priv->rfa_txpowertrackingindex_real = %d\n", - priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, - "priv->CCKPresentAttentuation_difference = %d\n", - priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, - "priv->CCKPresentAttentuation = %d\n", - priv->CCKPresentAttentuation); if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) { priv->rtllib->bdynamic_txpower_enable = true; rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, - "tx power track--->limited\n"); return; } @@ -834,10 +779,6 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) for (i = 0; i < OFDM_Table_Length; i++) { if (tmpRegA == OFDMSwingTable[i]) { priv->OFDM_index[0] = i; - RT_TRACE(COMP_POWER_TRACKING, - "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n", - rOFDM0_XATxIQImbalance, tmpRegA, - priv->OFDM_index[0]); } } @@ -845,10 +786,6 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) for (i = 0; i < CCK_Table_length; i++) { if (TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0]) { priv->CCK_index = i; - RT_TRACE(COMP_POWER_TRACKING, - "Initial reg0x%x = 0x%x, CCK_index = 0x%x\n", - rCCK0_TxFilter1, TempCCk, - priv->CCK_index); break; } } @@ -857,12 +794,10 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) } tmpRegA = rtl92e_get_rf_reg(dev, RF90_PATH_A, 0x12, 0x078); - RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d\n", tmpRegA); if (tmpRegA < 3 || tmpRegA > 13) return; if (tmpRegA >= 12) tmpRegA = 12; - RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d\n", tmpRegA); priv->ThermalMeter[0] = ThermalMeterVal; priv->ThermalMeter[1] = ThermalMeterVal; @@ -894,9 +829,6 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) priv->Record_CCK_20Mindex = tmpCCK20Mindex; priv->Record_CCK_40Mindex = tmpCCK40Mindex; - RT_TRACE(COMP_POWER_TRACKING, - "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n", - priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) { @@ -919,9 +851,6 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) priv->OFDM_index[0] = tmpOFDMindex; rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index[0]]); - RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n", - priv->OFDM_index[0], - OFDMSwingTable[priv->OFDM_index[0]]); } priv->txpower_count = 0; } @@ -960,8 +889,6 @@ static void _rtl92e_dm_init_tx_power_tracking_thermal(struct net_device *dev) priv->btxpower_tracking = false; priv->txpower_count = 0; priv->btxpower_trackingInit = false; - RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", - priv->btxpower_tracking); } void rtl92e_dm_init_txpower_tracking(struct net_device *dev) @@ -979,7 +906,6 @@ static void _rtl92e_dm_check_tx_power_tracking_tssi(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); static u32 tx_power_track_counter; - RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); if (rtl92e_readb(dev, 0x11e) == 1) return; if (!priv->btxpower_tracking) @@ -1086,44 +1012,29 @@ static void _rtl92e_dm_cck_tx_power_adjust_thermal_meter(struct net_device *dev, TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1] << 8); rtl92e_set_bb_reg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, - "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1, - TempVal); TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3] << 8) + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4] << 16)+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5] << 24); rtl92e_set_bb_reg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, - "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2, - TempVal); TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7] << 8); rtl92e_set_bb_reg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, - "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, - TempVal); } else { TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + (CCKSwingTable_Ch14[priv->CCK_index][1] << 8); rtl92e_set_bb_reg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter1, TempVal); TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3] << 8) + (CCKSwingTable_Ch14[priv->CCK_index][4] << 16)+ (CCKSwingTable_Ch14[priv->CCK_index][5] << 24); rtl92e_set_bb_reg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", - rCCK0_TxFilter2, TempVal); TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + (CCKSwingTable_Ch14[priv->CCK_index][7]<<8); rtl92e_set_bb_reg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", - rCCK0_DebugPort, TempVal); } } @@ -1141,32 +1052,12 @@ static void _rtl92e_dm_tx_power_reset_recovery(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n"); rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, dm_tx_bb_gain[priv->rfa_txpowertrackingindex]); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n", - dm_tx_bb_gain[priv->rfa_txpowertrackingindex]); - RT_TRACE(COMP_POWER_TRACKING, - "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", - priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, - "Reset Recovery : RF A I/Q Amplify Gain is %d\n", - dm_tx_bb_gain_idx_to_amplify(priv->rfa_txpowertrackingindex)); - RT_TRACE(COMP_POWER_TRACKING, - "Reset Recovery: CCK Attenuation is %d dB\n", - priv->CCKPresentAttentuation); rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); rtl92e_set_bb_reg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, dm_tx_bb_gain[priv->rfc_txpowertrackingindex]); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n", - dm_tx_bb_gain[priv->rfc_txpowertrackingindex]); - RT_TRACE(COMP_POWER_TRACKING, - "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", - priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, - "Reset Recovery : RF C I/Q Amplify Gain is %d\n", - dm_tx_bb_gain_idx_to_amplify(priv->rfc_txpowertrackingindex)); } void rtl92e_dm_restore_state(struct net_device *dev) @@ -1176,8 +1067,6 @@ void rtl92e_dm_restore_state(struct net_device *dev) u32 ratr_value; if (!priv->up) { - RT_TRACE(COMP_RATE, - "<---- %s: driver is going to unload\n", __func__); return; } @@ -1218,17 +1107,6 @@ static void _rtl92e_dm_bb_initialgain_restore(struct net_device *dev) bit_mask = bMaskByte2; rtl92e_set_bb_reg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca); - - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", - priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", - priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", - priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", - priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", - priv->initgain_backup.cca); rtl92e_set_bb_reg(dev, UFWP, bMaskByte1, 0x1); } @@ -1251,17 +1129,6 @@ void rtl92e_dm_backup_state(struct net_device *dev) priv->initgain_backup.xdagccore1 = rtl92e_get_bb_reg(dev, rOFDM0_XDAGCCore1, bit_mask); bit_mask = bMaskByte2; priv->initgain_backup.cca = (u8)rtl92e_get_bb_reg(dev, rCCK0_CCA, bit_mask); - - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", - priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", - priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", - priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", - priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", - priv->initgain_backup.cca); } static void _rtl92e_dm_dig_init(struct net_device *dev) @@ -1681,13 +1548,13 @@ static void _rtl92e_dm_check_edca_turbo(struct net_device *dev) goto dm_CheckEdcaTurbo_EXIT; if (priv->rtllib->state != RTLLIB_LINKED) goto dm_CheckEdcaTurbo_EXIT; - if (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) + if (priv->rtllib->pHTInfo->iot_action & HT_IOT_ACT_DISABLE_EDCA_TURBO) goto dm_CheckEdcaTurbo_EXIT; if (!priv->rtllib->bis_any_nonbepkts) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) { + if (pHTInfo->iot_action & HT_IOT_ACT_EDCA_BIAS_ON_RX) { if (curTxOkCnt > 4*curRxOkCnt) { if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) { @@ -1766,16 +1633,16 @@ static void _rtl92e_dm_cts_to_self(struct net_device *dev) unsigned long curRxOkCnt = 0; if (!priv->rtllib->bCTSToSelfEnable) { - pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; + pHTInfo->iot_action &= ~HT_IOT_ACT_FORCED_CTS2SELF; return; } if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; if (curRxOkCnt > 4*curTxOkCnt) - pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; + pHTInfo->iot_action &= ~HT_IOT_ACT_FORCED_CTS2SELF; else - pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; + pHTInfo->iot_action |= HT_IOT_ACT_FORCED_CTS2SELF; lastTxOkCnt = priv->stats.txbytesunicast; lastRxOkCnt = priv->stats.rxbytesunicast; @@ -1798,7 +1665,7 @@ static void _rtl92e_dm_check_rf_ctrl_gpio(void *data) struct r8192_priv, gpio_change_rf_wq); struct net_device *dev = priv->rtllib->dev; u8 tmp1byte; - enum rt_rf_power_state eRfPowerStateToSet; + enum rt_rf_power_state rf_power_state_to_set; bool bActuallySet = false; char *argv[3]; static const char RadioPowerPath[] = "/etc/acpi/events/RadioPower.sh"; @@ -1817,25 +1684,23 @@ static void _rtl92e_dm_check_rf_ctrl_gpio(void *data) tmp1byte = rtl92e_readb(dev, GPI); - eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; + rf_power_state_to_set = (tmp1byte&BIT1) ? rf_on : rf_off; - if (priv->bHwRadioOff && (eRfPowerStateToSet == eRfOn)) { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); + if (priv->hw_radio_off && (rf_power_state_to_set == rf_on)) { netdev_info(dev, "gpiochangeRF - HW Radio ON\n"); - priv->bHwRadioOff = false; + priv->hw_radio_off = false; bActuallySet = true; - } else if (!priv->bHwRadioOff && (eRfPowerStateToSet == eRfOff)) { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); + } else if (!priv->hw_radio_off && (rf_power_state_to_set == rf_off)) { netdev_info(dev, "gpiochangeRF - HW Radio OFF\n"); - priv->bHwRadioOff = true; + priv->hw_radio_off = true; bActuallySet = true; } if (bActuallySet) { mdelay(1000); priv->bHwRfOffAction = 1; - rtl92e_set_rf_state(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW); - if (priv->bHwRadioOff) + rtl92e_set_rf_state(dev, rf_power_state_to_set, RF_CHANGE_BY_HW); + if (priv->hw_radio_off) argv[1] = "RFOFF"; else argv[1] = "RFON"; @@ -2132,7 +1997,7 @@ static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t) if (priv->rtllib->state == RTLLIB_LINKED && priv->rtllib->bfsync_enable && - (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) { + (priv->rtllib->pHTInfo->iot_action & HT_IOT_ACT_CDD_FSYNC)) { u32 rate_bitmap; for (rate_index = 0; rate_index <= 27; rate_index++) { @@ -2173,10 +2038,6 @@ static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t) } priv->rate_record = rate_count; priv->rateCountDiffRecord = rate_count_diff; - RT_TRACE(COMP_HALDM, - "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", - priv->rate_record, rate_count, rate_count_diff, - priv->bswitch_fsync); if (priv->undecorated_smoothed_pwdb > priv->rtllib->fsync_rssi_threshold && bSwitchFromCountDiff) { @@ -2220,11 +2081,6 @@ static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t) priv->ContinueDiffCount = 0; rtl92e_writel(dev, rOFDM0_RxDetector2, 0x465c52cd); } - RT_TRACE(COMP_HALDM, "ContinueDiffCount %d\n", priv->ContinueDiffCount); - RT_TRACE(COMP_HALDM, - "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", - priv->rate_record, rate_count, rate_count_diff, - priv->bswitch_fsync); } static void _rtl92e_dm_start_hw_fsync(struct net_device *dev) @@ -2232,7 +2088,6 @@ static void _rtl92e_dm_start_hw_fsync(struct net_device *dev) u8 rf_timing = 0x77; struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_HALDM, "%s\n", __func__); rtl92e_writel(dev, rOFDM0_RxDetector2, 0x465c12cf); priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8 *)(&rf_timing)); @@ -2244,7 +2099,6 @@ static void _rtl92e_dm_end_hw_fsync(struct net_device *dev) u8 rf_timing = 0xaa; struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_HALDM, "%s\n", __func__); rtl92e_writel(dev, rOFDM0_RxDetector2, 0x465c52cd); priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8 *) (&rf_timing)); @@ -2255,7 +2109,6 @@ static void _rtl92e_dm_end_sw_fsync(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_HALDM, "%s\n", __func__); del_timer_sync(&(priv->fsync_timer)); if (priv->bswitch_fsync) { @@ -2276,7 +2129,6 @@ static void _rtl92e_dm_start_sw_fsync(struct net_device *dev) u32 rateIndex; u32 rateBitmap; - RT_TRACE(COMP_HALDM, "%s\n", __func__); priv->rate_record = 0; priv->ContinueDiffCount = 0; priv->rateCountDiffRecord = 0; @@ -2315,17 +2167,6 @@ static void _rtl92e_dm_check_fsync(struct net_device *dev) static u8 reg_c38_State = RegC38_Default; static u32 reset_cnt; - RT_TRACE(COMP_HALDM, - "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", - priv->rtllib->fsync_rssi_threshold, - priv->rtllib->fsync_time_interval, - priv->rtllib->fsync_multiple_timeinterval); - RT_TRACE(COMP_HALDM, - "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", - priv->rtllib->fsync_rate_bitmap, - priv->rtllib->fsync_firstdiff_ratethreshold, - priv->rtllib->fsync_seconddiff_ratethreshold); - if (priv->rtllib->state == RTLLIB_LINKED && priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { if (priv->rtllib->bfsync_enable == 0) { @@ -2461,9 +2302,6 @@ static void _rtl92e_dm_dynamic_tx_power(struct net_device *dev) txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; } - RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n", - priv->undecorated_smoothed_pwdb); - if (priv->rtllib->state == RTLLIB_LINKED) { if (priv->undecorated_smoothed_pwdb >= txhipower_threshold) { priv->bDynamicTxHighPower = true; @@ -2484,9 +2322,6 @@ static void _rtl92e_dm_dynamic_tx_power(struct net_device *dev) if ((priv->bDynamicTxHighPower != priv->bLastDTPFlag_High) || (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low)) { - RT_TRACE(COMP_TXAGC, "SetTxPowerLevel8190() channel = %d\n", - priv->rtllib->current_network.channel); - rtl92e_set_tx_power(dev, priv->rtllib->current_network.channel); } priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; @@ -2499,14 +2334,9 @@ static void _rtl92e_dm_check_txrateandretrycount(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; - ieee->softmac_stats.CurrentShowTxate = rtl92e_readb(dev, - Current_Tx_Rate_Reg); - - ieee->softmac_stats.last_packet_rate = rtl92e_readb(dev, - Initial_Tx_Rate_Reg); - - ieee->softmac_stats.txretrycount = rtl92e_readl(dev, - Tx_Retry_Count_Reg); + ieee->softmac_stats.CurrentShowTxate = rtl92e_readb(dev, CURRENT_TX_RATE_REG); + ieee->softmac_stats.last_packet_rate = rtl92e_readb(dev, INITIAL_TX_RATE_REG); + ieee->softmac_stats.txretrycount = rtl92e_readl(dev, TX_RETRY_COUNT_REG); } static void _rtl92e_dm_send_rssi_to_fw(struct net_device *dev) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h index ea1b14bbcdcd..51e295d389a8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h @@ -42,9 +42,9 @@ #define TX_POWER_ATHEROAP_THRESH_HIGH 78 #define TX_POWER_ATHEROAP_THRESH_LOW 72 -#define Current_Tx_Rate_Reg 0x1e0 -#define Initial_Tx_Rate_Reg 0x1e1 -#define Tx_Retry_Count_Reg 0x1ac +#define CURRENT_TX_RATE_REG 0x1e0 +#define INITIAL_TX_RATE_REG 0x1e1 +#define TX_RETRY_COUNT_REG 0x1ac #define RegC38_TH 20 #define DM_Type_ByDriver 1 diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c index 1d992d5c4e17..81e1bb856c60 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c @@ -16,11 +16,9 @@ static void _rtl92e_parse_pci_configuration(struct pci_dev *pdev, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); u8 tmp; - u16 LinkCtrlReg; + u16 link_ctrl_reg; - pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &LinkCtrlReg); - - RT_TRACE(COMP_INIT, "Link Control Register =%x\n", LinkCtrlReg); + pcie_capability_read_word(priv->pdev, PCI_EXP_LNKCTL, &link_ctrl_reg); pci_read_config_byte(pdev, 0x98, &tmp); tmp |= BIT4; @@ -33,28 +31,28 @@ static void _rtl92e_parse_pci_configuration(struct pci_dev *pdev, bool rtl92e_check_adapter(struct pci_dev *pdev, struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u16 DeviceID; - u8 RevisionID; - u16 IrqLine; + u16 device_id; + u8 revision_id; + u16 irq_line; - DeviceID = pdev->device; - RevisionID = pdev->revision; - pci_read_config_word(pdev, 0x3C, &IrqLine); + device_id = pdev->device; + revision_id = pdev->revision; + pci_read_config_word(pdev, 0x3C, &irq_line); priv->card_8192 = priv->ops->nic_type; - if (DeviceID == 0x8192) { - switch (RevisionID) { + if (device_id == 0x8192) { + switch (revision_id) { case HAL_HW_PCI_REVISION_ID_8192PCIE: dev_info(&pdev->dev, "Adapter(8192 PCI-E) is found - DeviceID=%x\n", - DeviceID); + device_id); priv->card_8192 = NIC_8192E; break; case HAL_HW_PCI_REVISION_ID_8192SE: dev_info(&pdev->dev, "Adapter(8192SE) is found - DeviceID=%x\n", - DeviceID); + device_id); priv->card_8192 = NIC_8192SE; break; default: diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c index 5575186caebd..82b45c61ac75 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c @@ -32,7 +32,7 @@ int rtl92e_suspend(struct device *dev_d) netif_device_detach(dev); if (!priv->rtllib->bSupportRemoteWakeUp) { - rtl92e_set_rf_state(dev, eRfOff, RF_CHANGE_BY_INIT); + rtl92e_set_rf_state(dev, rf_off, RF_CHANGE_BY_INIT); ulRegRead = rtl92e_readl(dev, CPU_GEN); ulRegRead |= CPU_GEN_SYSTEM_RESET; rtl92e_writel(dev, CPU_GEN, ulRegRead); @@ -83,10 +83,9 @@ int rtl92e_resume(struct device *dev_d) dev->netdev_ops->ndo_open(dev); if (!priv->rtllib->bSupportRemoteWakeUp) - rtl92e_set_rf_state(dev, eRfOn, RF_CHANGE_BY_INIT); + rtl92e_set_rf_state(dev, rf_on, RF_CHANGE_BY_INIT); out: - RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); return 0; } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index c5e89eb40342..8c00b111ddb2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -21,16 +21,12 @@ static void _rtl92e_hw_sleep(struct net_device *dev) unsigned long flags = 0; spin_lock_irqsave(&priv->rf_ps_lock, flags); - if (priv->RFChangeInProgress) { + if (priv->rf_change_in_progress) { spin_unlock_irqrestore(&priv->rf_ps_lock, flags); - RT_TRACE(COMP_DBG, - "%s(): RF Change in progress!\n", __func__); return; } spin_unlock_irqrestore(&priv->rf_ps_lock, flags); - RT_TRACE(COMP_DBG, "%s()============>come to sleep down\n", __func__); - - rtl92e_set_rf_state(dev, eRfSleep, RF_CHANGE_BY_PS); + rtl92e_set_rf_state(dev, rf_sleep, RF_CHANGE_BY_PS); } void rtl92e_hw_sleep_wq(void *data) @@ -48,17 +44,14 @@ void rtl92e_hw_wakeup(struct net_device *dev) unsigned long flags = 0; spin_lock_irqsave(&priv->rf_ps_lock, flags); - if (priv->RFChangeInProgress) { + if (priv->rf_change_in_progress) { spin_unlock_irqrestore(&priv->rf_ps_lock, flags); - RT_TRACE(COMP_DBG, - "%s(): RF Change in progress!\n", __func__); schedule_delayed_work(&priv->rtllib->hw_wakeup_wq, msecs_to_jiffies(10)); return; } spin_unlock_irqrestore(&priv->rf_ps_lock, flags); - RT_TRACE(COMP_PS, "%s()============>come to wake up\n", __func__); - rtl92e_set_rf_state(dev, eRfOn, RF_CHANGE_BY_PS); + rtl92e_set_rf_state(dev, rf_on, RF_CHANGE_BY_PS); } void rtl92e_hw_wakeup_wq(void *data) @@ -110,15 +103,10 @@ static void _rtl92e_ps_update_rf_state(struct net_device *dev) struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) &(priv->rtllib->PowerSaveControl); - RT_TRACE(COMP_PS, "%s() --------->\n", __func__); pPSC->bSwRfProcessing = true; - - RT_TRACE(COMP_PS, "%s(): Set RF to %s.\n", __func__, - pPSC->eInactivePowerState == eRfOff ? "OFF" : "ON"); rtl92e_set_rf_state(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS); pPSC->bSwRfProcessing = false; - RT_TRACE(COMP_PS, "%s() <---------\n", __func__); } void rtl92e_ips_enter(struct net_device *dev) @@ -126,15 +114,14 @@ void rtl92e_ips_enter(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) &(priv->rtllib->PowerSaveControl); - enum rt_rf_power_state rtState; + enum rt_rf_power_state rt_state; if (pPSC->bInactivePs) { - rtState = priv->rtllib->eRFPowerState; - if (rtState == eRfOn && !pPSC->bSwRfProcessing && + rt_state = priv->rtllib->rf_power_state; + if (rt_state == rf_on && !pPSC->bSwRfProcessing && (priv->rtllib->state != RTLLIB_LINKED) && (priv->rtllib->iw_mode != IW_MODE_MASTER)) { - RT_TRACE(COMP_PS, "%s(): Turn off RF.\n", __func__); - pPSC->eInactivePowerState = eRfOff; + pPSC->eInactivePowerState = rf_off; priv->isRFOff = true; priv->bInPowerSaveMode = true; _rtl92e_ps_update_rf_state(dev); @@ -147,14 +134,13 @@ void rtl92e_ips_leave(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) &(priv->rtllib->PowerSaveControl); - enum rt_rf_power_state rtState; + enum rt_rf_power_state rt_state; if (pPSC->bInactivePs) { - rtState = priv->rtllib->eRFPowerState; - if (rtState != eRfOn && !pPSC->bSwRfProcessing && - priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) { - RT_TRACE(COMP_PS, "%s(): Turn on RF.\n", __func__); - pPSC->eInactivePowerState = eRfOn; + rt_state = priv->rtllib->rf_power_state; + if (rt_state != rf_on && !pPSC->bSwRfProcessing && + priv->rtllib->rf_off_reason <= RF_CHANGE_BY_IPS) { + pPSC->eInactivePowerState = rf_on; priv->bInPowerSaveMode = false; _rtl92e_ps_update_rf_state(dev); } @@ -176,13 +162,13 @@ void rtl92e_ips_leave_wq(void *data) void rtl92e_rtllib_ips_leave_wq(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - enum rt_rf_power_state rtState; + enum rt_rf_power_state rt_state; - rtState = priv->rtllib->eRFPowerState; + rt_state = priv->rtllib->rf_power_state; if (priv->rtllib->PowerSaveControl.bInactivePs) { - if (rtState == eRfOff) { - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + if (rt_state == rf_off) { + if (priv->rtllib->rf_off_reason > RF_CHANGE_BY_IPS) { netdev_warn(dev, "%s(): RF is OFF.\n", __func__); return; @@ -210,7 +196,6 @@ static bool _rtl92e_ps_set_mode(struct net_device *dev, u8 rtPsMode) if (priv->rtllib->iw_mode == IW_MODE_ADHOC) return false; - RT_TRACE(COMP_LPS, "%s(): set ieee->ps = %x\n", __func__, rtPsMode); if (!priv->ps_force) priv->rtllib->ps = rtPsMode; if (priv->rtllib->sta_sleep != LPS_IS_WAKE && @@ -221,8 +206,6 @@ static bool _rtl92e_ps_set_mode(struct net_device *dev, u8 rtPsMode) priv->rtllib->sta_sleep = LPS_IS_WAKE; spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); - RT_TRACE(COMP_DBG, - "LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n"); rtllib_sta_ps_send_null_frame(priv->rtllib, 0); spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); } @@ -236,12 +219,6 @@ void rtl92e_leisure_ps_enter(struct net_device *dev) struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) &(priv->rtllib->PowerSaveControl); - RT_TRACE(COMP_PS, "%s()...\n", __func__); - RT_TRACE(COMP_PS, - "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", - pPSC->bLeisurePs, priv->rtllib->ps, pPSC->LpsIdleCount, - RT_CHECK_FOR_HANG_PERIOD); - if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && (priv->rtllib->state == RTLLIB_LINKED)) || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || @@ -252,10 +229,6 @@ void rtl92e_leisure_ps_enter(struct net_device *dev) if (pPSC->LpsIdleCount >= RT_CHECK_FOR_HANG_PERIOD) { if (priv->rtllib->ps == RTLLIB_PS_DISABLED) { - - RT_TRACE(COMP_LPS, - "%s(): Enter 802.11 power save mode...\n", __func__); - if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) priv->rtllib->SetFwCmdHandler( @@ -275,15 +248,8 @@ void rtl92e_leisure_ps_leave(struct net_device *dev) struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) &(priv->rtllib->PowerSaveControl); - - RT_TRACE(COMP_PS, "%s()...\n", __func__); - RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d\n", - pPSC->bLeisurePs, priv->rtllib->ps); - if (pPSC->bLeisurePs) { if (priv->rtllib->ps != RTLLIB_PS_DISABLED) { - RT_TRACE(COMP_LPS, - "%s(): Busy Traffic , Leave 802.11 power save..\n", __func__); _rtl92e_ps_set_mode(dev, RTLLIB_PS_DISABLED); if (!pPSC->bFwCtrlLPS) { diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 407effde5e71..4920cb49e381 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -52,7 +52,7 @@ static int _rtl92e_wx_set_rate(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -71,7 +71,7 @@ static int _rtl92e_wx_set_rts(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -99,7 +99,7 @@ static int _rtl92e_wx_set_power(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) { + if (priv->hw_radio_off) { netdev_warn(dev, "%s(): Can't set Power: Radio is Off.\n", __func__); return 0; @@ -129,7 +129,7 @@ static int _rtl92e_wx_set_rawtx(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); int ret; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -149,8 +149,6 @@ static int _rtl92e_wx_force_reset(struct net_device *dev, mutex_lock(&priv->wx_mutex); - RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", - __func__, *extra); priv->force_reset = *extra; mutex_unlock(&priv->wx_mutex); return 0; @@ -167,8 +165,6 @@ static int _rtl92e_wx_adapter_power_status(struct net_device *dev, mutex_lock(&priv->wx_mutex); - RT_TRACE(COMP_POWER, "%s(): %s\n", __func__, (*extra == 6) ? - "DC power" : "AC power"); if (*extra || priv->force_lps) { priv->ps_force = false; pPSC->bLeisurePs = true; @@ -228,7 +224,7 @@ static int _rtl92e_wx_set_debug(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); u8 c = *extra; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; netdev_info(dev, "=====>%s(), *extra:%x, debugflag:%x\n", __func__, @@ -247,18 +243,18 @@ static int _rtl92e_wx_set_mode(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = netdev_priv_rsl(dev); - enum rt_rf_power_state rtState; + enum rt_rf_power_state rt_state; int ret; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; - rtState = priv->rtllib->eRFPowerState; + rt_state = priv->rtllib->rf_power_state; mutex_lock(&priv->wx_mutex); if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR || ieee->bNetPromiscuousMode) { if (priv->rtllib->PowerSaveControl.bInactivePs) { - if (rtState == eRfOff) { - if (priv->rtllib->RfOffReason > + if (rt_state == rf_off) { + if (priv->rtllib->rf_off_reason > RF_CHANGE_BY_IPS) { netdev_warn(dev, "%s(): RF is OFF.\n", __func__); @@ -379,7 +375,7 @@ static int _rtl92e_wx_set_scan(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; - enum rt_rf_power_state rtState; + enum rt_rf_power_state rt_state; int ret; if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { @@ -391,12 +387,12 @@ static int _rtl92e_wx_set_scan(struct net_device *dev, return 0; } - if (priv->bHwRadioOff) { + if (priv->hw_radio_off) { netdev_info(dev, "================>%s(): hwradio off\n", __func__); return 0; } - rtState = priv->rtllib->eRFPowerState; + rt_state = priv->rtllib->rf_power_state; if (!priv->up) return -ENETDOWN; if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true) @@ -419,17 +415,14 @@ static int _rtl92e_wx_set_scan(struct net_device *dev, if (priv->rtllib->state != RTLLIB_LINKED) { if (priv->rtllib->PowerSaveControl.bInactivePs) { - if (rtState == eRfOff) { - if (priv->rtllib->RfOffReason > + if (rt_state == rf_off) { + if (priv->rtllib->rf_off_reason > RF_CHANGE_BY_IPS) { netdev_warn(dev, "%s(): RF is OFF.\n", __func__); mutex_unlock(&priv->wx_mutex); return -1; } - RT_TRACE(COMP_PS, - "=========>%s(): rtl92e_ips_leave\n", - __func__); mutex_lock(&priv->rtllib->ips_mutex); rtl92e_ips_leave(dev); mutex_unlock(&priv->rtllib->ips_mutex); @@ -440,7 +433,7 @@ static int _rtl92e_wx_set_scan(struct net_device *dev, priv->rtllib->LedControlHandler(dev, LED_CTL_SITE_SURVEY); - if (priv->rtllib->eRFPowerState != eRfOff) { + if (priv->rtllib->rf_power_state != rf_off) { priv->rtllib->actscanning = true; if (ieee->ScanOperationBackupHandler) @@ -473,7 +466,7 @@ static int _rtl92e_wx_get_scan(struct net_device *dev, if (!priv->up) return -ENETDOWN; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -492,9 +485,9 @@ static int _rtl92e_wx_set_essid(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); int ret; - if (priv->bHwRadioOff) { + if (priv->hw_radio_off) { netdev_info(dev, - "=========>%s():hw radio off,or Rf state is eRfOff, return\n", + "=========>%s():hw radio off,or Rf state is rf_off, return\n", __func__); return 0; } @@ -560,7 +553,7 @@ static int _rtl92e_wx_set_freq(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -586,7 +579,7 @@ static int _rtl92e_wx_set_frag(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; if (wrqu->frag.disabled) @@ -622,7 +615,7 @@ static int _rtl92e_wx_set_wap(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -669,7 +662,7 @@ static int _rtl92e_wx_set_enc(struct net_device *dev, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} }; int i; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; if (!priv->up) @@ -681,7 +674,6 @@ static int _rtl92e_wx_set_enc(struct net_device *dev, mutex_unlock(&priv->rtllib->ips_mutex); mutex_lock(&priv->wx_mutex); - RT_TRACE(COMP_SEC, "Setting SW wep key"); ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key); mutex_unlock(&priv->wx_mutex); @@ -754,7 +746,7 @@ static int _rtl92e_wx_set_scan_type(struct net_device *dev, int *parms = (int *)p; int mode = parms[0]; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; priv->rtllib->active_scan = mode; @@ -770,7 +762,7 @@ static int _rtl92e_wx_set_retry(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); int err = 0; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -843,7 +835,7 @@ static int _rtl92e_wx_set_sens(struct net_device *dev, short err = 0; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -870,7 +862,7 @@ static int _rtl92e_wx_set_encode_ext(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -950,7 +942,7 @@ static int _rtl92e_wx_set_auth(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -967,7 +959,7 @@ static int _rtl92e_wx_set_mlme(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); @@ -984,7 +976,7 @@ static int _rtl92e_wx_set_gen_ie(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff) + if (priv->hw_radio_off) return 0; mutex_lock(&priv->wx_mutex); diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 7d04966afdd9..19d13b3fcecf 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -100,8 +100,6 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, *tag++ = pBA->dialog_token; if (type == ACT_ADDBARSP) { - RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); - put_unaligned_le16(StatusCode, tag); tag += 2; } @@ -183,7 +181,6 @@ static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); if (skb) { - RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n"); softmac_mgmt_xmit(skb, ieee); } else { netdev_dbg(ieee->dev, "Failed to generate ADDBAReq packet.\n"); @@ -247,10 +244,9 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from : %pM\n", dst); if (!ieee->current_network.qos_data.active || !ieee->pHTInfo->bCurrentHTSupport || - (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { + (ieee->pHTInfo->iot_action & HT_IOT_ACT_REJECT_ADDBA_REQ)) { rc = ADDBA_STATUS_REFUSED; netdev_warn(ieee->dev, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", @@ -282,7 +278,7 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) pBA->ba_start_seq_ctrl = *pBaStartSeqCtrl; if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev) || - (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) + (ieee->pHTInfo->iot_action & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) pBA->ba_param_set.field.buffer_size = 1; else pBA->ba_param_set.field.buffer_size = 32; @@ -330,7 +326,6 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) pBaParamSet = (union ba_param_set *)(tag + 5); pBaTimeoutVal = (u16 *)(tag + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBARSP from : %pM\n", dst); if (!ieee->current_network.qos_data.active || !ieee->pHTInfo->bCurrentHTSupport || !ieee->pHTInfo->bCurrentAMPDUEnable) { diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index ce13b41074a7..76bc9c5a6d83 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -131,51 +131,40 @@ struct rt_hi_throughput { u8 AMPDU_Factor; u8 CurrentAMPDUFactor; u8 MPDU_Density; - u8 CurrentMPDUDensity; + u8 current_mpdu_density; enum ht_aggre_mode ForcedAMPDUMode; - u8 ForcedAMPDUFactor; - u8 ForcedMPDUDensity; + u8 forced_ampdu_factor; + u8 forced_mpdu_density; enum ht_aggre_mode ForcedAMSDUMode; - u16 ForcedAMSDUMaxSize; + u8 forced_short_gi; - u8 bForcedShortGI; + u8 current_op_mode; - u8 CurrentOpMode; - - u8 SelfMimoPs; - u8 PeerMimoPs; + u8 self_mimo_ps; + u8 peer_mimo_ps; enum ht_extchnl_offset CurSTAExtChnlOffset; - u8 bCurTxBW40MHz; - u8 PeerBandwidth; - - u8 bSwBwInProgress; - u8 SwBwStep; - - u8 bRegRT2RTAggregation; + u8 cur_tx_bw40mhz; + u8 sw_bw_in_progress; + u8 reg_rt2rt_aggregation; u8 RT2RT_HT_Mode; - u8 bCurrentRT2RTAggregation; - u8 bCurrentRT2RTLongSlotTime; - u8 szRT2RTAggBuffer[10]; - - u8 bRegRxReorderEnable; - u8 bCurRxReorderEnable; - u8 RxReorderWinSize; - u8 RxReorderPendingTime; - u16 RxReorderDropCounter; - - u8 bIsPeerBcm; - + u8 current_rt2rt_aggregation; + u8 current_rt2rt_long_slot_time; + u8 sz_rt2rt_agg_buf[10]; + + u8 reg_rx_reorder_enable; + u8 cur_rx_reorder_enable; + u8 rx_reorder_win_size; + u8 rx_reorder_pending_time; + u16 rx_reorder_drop_counter; u8 IOTPeer; - u32 IOTAction; - u8 IOTRaFunc; + u32 iot_action; + u8 iot_ra_func; u8 bWAIotBroadcom; u8 WAIotTH; - - u8 bAcceptAddbaReq; } __packed; struct bss_ht { diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 3b8efaf9b88c..ef3dca51cf99 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -70,9 +70,6 @@ static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; void HTUpdateDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - pHTInfo->bAcceptAddbaReq = 1; - pHTInfo->bRegShortGI20MHz = 1; pHTInfo->bRegShortGI40MHz = 1; @@ -90,19 +87,19 @@ void HTUpdateDefaultSetting(struct rtllib_device *ieee) pHTInfo->AMPDU_Factor = 2; pHTInfo->MPDU_Density = 0; - pHTInfo->SelfMimoPs = 3; - if (pHTInfo->SelfMimoPs == 2) - pHTInfo->SelfMimoPs = 3; + pHTInfo->self_mimo_ps = 3; + if (pHTInfo->self_mimo_ps == 2) + pHTInfo->self_mimo_ps = 3; ieee->bTxDisableRateFallBack = 0; ieee->bTxUseDriverAssingedRate = 0; ieee->bTxEnableFwCalcDur = 1; - pHTInfo->bRegRT2RTAggregation = 1; + pHTInfo->reg_rt2rt_aggregation = 1; - pHTInfo->bRegRxReorderEnable = 1; - pHTInfo->RxReorderWinSize = 64; - pHTInfo->RxReorderPendingTime = 30; + pHTInfo->reg_rx_reorder_enable = 1; + pHTInfo->rx_reorder_win_size = 64; + pHTInfo->rx_reorder_pending_time = 30; } static u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) @@ -254,20 +251,20 @@ static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; + pHTInfo->iot_ra_func &= HT_IOT_RAFUNC_DISABLE_ALL; if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss) - pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R; + pHTInfo->iot_ra_func |= HT_IOT_RAFUNC_PEER_1R; - if (pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE) - pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU; + if (pHTInfo->iot_action & HT_IOT_ACT_AMSDU_ENABLE) + pHTInfo->iot_ra_func |= HT_IOT_RAFUNC_TX_AMSDU; } void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { - pHTInfo->IOTAction = 0; + pHTInfo->iot_action = 0; pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; - pHTInfo->IOTRaFunc = 0; + pHTInfo->iot_ra_func = 0; } void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, @@ -300,7 +297,7 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, else pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0); - pCapELE->MimoPwrSave = pHT->SelfMimoPs; + pCapELE->MimoPwrSave = pHT->self_mimo_ps; pCapELE->GreenField = 0; pCapELE->ShortGI20Mhz = 1; pCapELE->ShortGI40Mhz = 1; @@ -332,16 +329,16 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, pCapELE->ASCap = 0; if (bAssoc) { - if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15) + if (pHT->iot_action & HT_IOT_ACT_DISABLE_MCS15) pCapELE->MCS[1] &= 0x7f; - if (pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14) + if (pHT->iot_action & HT_IOT_ACT_DISABLE_MCS14) pCapELE->MCS[1] &= 0xbf; - if (pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS) + if (pHT->iot_action & HT_IOT_ACT_DISABLE_ALL_2SS) pCapELE->MCS[1] &= 0x00; - if (pHT->IOTAction & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI) + if (pHT->iot_action & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI) pCapELE->ShortGI40Mhz = 0; if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { @@ -377,7 +374,7 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo, pHTInfoEle->RIFS = 0; pHTInfoEle->PSMPAccessOnly = 0; pHTInfoEle->SrvIntGranularity = 0; - pHTInfoEle->OptMode = pHT->CurrentOpMode; + pHTInfoEle->OptMode = pHT->current_op_mode; pHTInfoEle->NonGFDevPresent = 0; pHTInfoEle->DualBeacon = 0; pHTInfoEle->SecondaryBeacon = 0; @@ -506,7 +503,7 @@ static u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, } void HTSetConnectBwMode(struct rtllib_device *ieee, - enum ht_channel_width Bandwidth, + enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset); void HTOnAssocRsp(struct rtllib_device *ieee) @@ -543,7 +540,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) #endif HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); - pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ? + pHTInfo->cur_tx_bw40mhz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ? true : false); pHTInfo->bCurShortGI20MHz = ((pHTInfo->bRegShortGI20MHz) ? @@ -574,7 +571,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pHTInfo->bCurrentAMPDUEnable = false; } - if (!pHTInfo->bRegRT2RTAggregation) { + if (!pHTInfo->reg_rt2rt_aggregation) { if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; @@ -597,15 +594,14 @@ void HTOnAssocRsp(struct rtllib_device *ieee) } } if (pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity) - pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; + pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; else - pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; - if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) { + pHTInfo->current_mpdu_density = pPeerHTCap->MPDUDensity; + if (pHTInfo->iot_action & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; - pHTInfo->ForcedAMSDUMaxSize = 7935; } - pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable; + pHTInfo->cur_rx_reorder_enable = pHTInfo->reg_rx_reorder_enable; if (pPeerHTCap->MCS[0] == 0) pPeerHTCap->MCS[0] = 0xff; @@ -614,8 +610,8 @@ void HTOnAssocRsp(struct rtllib_device *ieee) HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); - pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave; - if (pHTInfo->PeerMimoPs == MIMO_PS_STATIC) + pHTInfo->peer_mimo_ps = pPeerHTCap->MimoPwrSave; + if (pHTInfo->peer_mimo_ps == MIMO_PS_STATIC) pMcsFilter = MCS_FILTER_1SS; else pMcsFilter = MCS_FILTER_ALL; @@ -623,7 +619,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) ieee->dot11HTOperationalRateSet, pMcsFilter); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; - pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; + pHTInfo->current_op_mode = pPeerHTInfo->OptMode; } void HTInitializeHTInfo(struct rtllib_device *ieee) @@ -633,17 +629,17 @@ void HTInitializeHTInfo(struct rtllib_device *ieee) pHTInfo->bCurrentHTSupport = false; pHTInfo->bCurBW40MHz = false; - pHTInfo->bCurTxBW40MHz = false; + pHTInfo->cur_tx_bw40mhz = false; pHTInfo->bCurShortGI20MHz = false; pHTInfo->bCurShortGI40MHz = false; - pHTInfo->bForcedShortGI = false; + pHTInfo->forced_short_gi = false; pHTInfo->bCurSuppCCK = true; pHTInfo->bCurrent_AMSDU_Support = false; pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; - pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; + pHTInfo->current_mpdu_density = pHTInfo->MPDU_Density; pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; memset((void *)(&(pHTInfo->SelfHTCap)), 0, @@ -655,17 +651,17 @@ void HTInitializeHTInfo(struct rtllib_device *ieee) memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); - pHTInfo->bSwBwInProgress = false; + pHTInfo->sw_bw_in_progress = false; pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE; - pHTInfo->bCurrentRT2RTAggregation = false; - pHTInfo->bCurrentRT2RTLongSlotTime = false; + pHTInfo->current_rt2rt_aggregation = false; + pHTInfo->current_rt2rt_long_slot_time = false; pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; pHTInfo->IOTPeer = 0; - pHTInfo->IOTAction = 0; - pHTInfo->IOTRaFunc = 0; + pHTInfo->iot_action = 0; + pHTInfo->iot_ra_func = 0; { u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); @@ -717,51 +713,51 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, pNetwork->bssht.bd_ht_info_buf, pNetwork->bssht.bd_ht_info_len); - if (pHTInfo->bRegRT2RTAggregation) { - pHTInfo->bCurrentRT2RTAggregation = + if (pHTInfo->reg_rt2rt_aggregation) { + pHTInfo->current_rt2rt_aggregation = pNetwork->bssht.bd_rt2rt_aggregation; - pHTInfo->bCurrentRT2RTLongSlotTime = + pHTInfo->current_rt2rt_long_slot_time = pNetwork->bssht.bd_rt2rt_long_slot_time; pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.rt2rt_ht_mode; } else { - pHTInfo->bCurrentRT2RTAggregation = false; - pHTInfo->bCurrentRT2RTLongSlotTime = false; + pHTInfo->current_rt2rt_aggregation = false; + pHTInfo->current_rt2rt_long_slot_time = false; pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; } HTIOTPeerDetermine(ieee); - pHTInfo->IOTAction = 0; + pHTInfo->iot_action = 0; bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid); if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14; + pHTInfo->iot_action |= HT_IOT_ACT_DISABLE_MCS14; bIOTAction = HTIOTActIsDisableMCS15(ieee); if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15; + pHTInfo->iot_action |= HT_IOT_ACT_DISABLE_MCS15; bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee); if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS; + pHTInfo->iot_action |= HT_IOT_ACT_DISABLE_ALL_2SS; bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid); if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; + pHTInfo->iot_action |= HT_IOT_ACT_DISABLE_EDCA_TURBO; bIOTAction = HTIOTActIsMgntUseCCK6M(ieee, pNetwork); if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; + pHTInfo->iot_action |= HT_IOT_ACT_MGNT_USE_CCK_6M; bIOTAction = HTIOTActIsCCDFsync(ieee); if (bIOTAction) - pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC; + pHTInfo->iot_action |= HT_IOT_ACT_CDD_FSYNC; } else { pHTInfo->bCurrentHTSupport = false; - pHTInfo->bCurrentRT2RTAggregation = false; - pHTInfo->bCurrentRT2RTLongSlotTime = false; + pHTInfo->current_rt2rt_aggregation = false; + pHTInfo->current_rt2rt_long_slot_time = false; pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; - pHTInfo->IOTAction = 0; - pHTInfo->IOTRaFunc = 0; + pHTInfo->iot_action = 0; + pHTInfo->iot_ra_func = 0; } } @@ -774,7 +770,7 @@ void HT_update_self_and_peer_setting(struct rtllib_device *ieee, if (pHTInfo->bCurrentHTSupport) { if (pNetwork->bssht.bd_ht_info_len != 0) - pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; + pHTInfo->current_op_mode = pPeerHTInfo->OptMode; } } EXPORT_SYMBOL(HT_update_self_and_peer_setting); @@ -801,7 +797,7 @@ void HTUseDefaultSetting(struct rtllib_device *ieee) pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity; + pHTInfo->current_mpdu_density = pHTInfo->current_mpdu_density; HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, ieee->dot11HTOperationalRateSet); @@ -850,11 +846,11 @@ static void HTSetConnectBwModeCallback(struct rtllib_device *ieee) HT_EXTCHNL_OFFSET_NO_EXT); } - pHTInfo->bSwBwInProgress = false; + pHTInfo->sw_bw_in_progress = false; } void HTSetConnectBwMode(struct rtllib_device *ieee, - enum ht_channel_width Bandwidth, + enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -863,13 +859,13 @@ void HTSetConnectBwMode(struct rtllib_device *ieee, return; if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - Bandwidth = HT_CHANNEL_WIDTH_20; + bandwidth = HT_CHANNEL_WIDTH_20; - if (pHTInfo->bSwBwInProgress) { - pr_info("%s: bSwBwInProgress!!\n", __func__); + if (pHTInfo->sw_bw_in_progress) { + pr_info("%s: sw_bw_in_progress!!\n", __func__); return; } - if (Bandwidth == HT_CHANNEL_WIDTH_20_40) { + if (bandwidth == HT_CHANNEL_WIDTH_20_40) { if (ieee->current_network.channel < 2 && Offset == HT_EXTCHNL_OFFSET_LOWER) Offset = HT_EXTCHNL_OFFSET_NO_EXT; @@ -889,7 +885,7 @@ void HTSetConnectBwMode(struct rtllib_device *ieee, netdev_dbg(ieee->dev, "%s():pHTInfo->bCurBW40MHz:%x\n", __func__, pHTInfo->bCurBW40MHz); - pHTInfo->bSwBwInProgress = true; + pHTInfo->sw_bw_in_progress = true; HTSetConnectBwModeCallback(ieee); } diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 34b00a76b6bd..05c7e822f372 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -83,7 +83,7 @@ static void RxPktPendingTimeout(struct timer_list *t) if (bPktInBuf && (pRxTs->rx_timeout_indicate_seq == 0xffff)) { pRxTs->rx_timeout_indicate_seq = pRxTs->rx_indicate_seq; mod_timer(&pRxTs->rx_pkt_pending_timer, jiffies + - msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime) + msecs_to_jiffies(ieee->pHTInfo->rx_reorder_pending_time) ); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 0ecd81a81866..3c72ed2a30a4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1244,9 +1244,9 @@ enum ips_callback_function { }; enum rt_rf_power_state { - eRfOn, - eRfSleep, - eRfOff + rf_on, + rf_sleep, + rf_off }; struct rt_pwr_save_ctrl { @@ -1434,8 +1434,8 @@ struct rtllib_device { bool FirstIe_InScan; bool be_scan_inprogress; bool beinretry; - enum rt_rf_power_state eRFPowerState; - RT_RF_CHANGE_SOURCE RfOffReason; + enum rt_rf_power_state rf_power_state; + RT_RF_CHANGE_SOURCE rf_off_reason; bool is_set_key; bool wx_set_enc; struct rt_hi_throughput *pHTInfo; @@ -1765,7 +1765,7 @@ struct rtllib_device { /* check whether Tx hw resource available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); void (*SetBWModeHandler)(struct net_device *dev, - enum ht_channel_width Bandwidth, + enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset); bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); @@ -1938,7 +1938,7 @@ int rtllib_encrypt_fragment( struct sk_buff *frag, int hdr_len); -int rtllib_xmit(struct sk_buff *skb, struct net_device *dev); +netdev_tx_t rtllib_xmit(struct sk_buff *skb, struct net_device *dev); void rtllib_txb_free(struct rtllib_txb *txb); /* rtllib_rx.c */ @@ -2073,7 +2073,7 @@ int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info, #define MAX_RECEIVE_BUFFER_SIZE 9100 void HTSetConnectBwMode(struct rtllib_device *ieee, - enum ht_channel_width Bandwidth, + enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset); void HTUpdateDefaultSetting(struct rtllib_device *ieee); void HTConstructCapabilityElement(struct rtllib_device *ieee, diff --git a/drivers/staging/rtl8192e/rtllib_debug.h b/drivers/staging/rtl8192e/rtllib_debug.h index e3e8302945eb..f6b23defe225 100644 --- a/drivers/staging/rtl8192e/rtllib_debug.h +++ b/drivers/staging/rtl8192e/rtllib_debug.h @@ -46,10 +46,4 @@ enum RTL_DEBUG { COMP_ERR = BIT(31) }; -#define RT_TRACE(component, x, args...) \ -do { \ - if (rt_global_debug_component & component) \ - printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\ -} while (0) - #endif diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index abe5c153f74e..46d75e925ee9 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -569,7 +569,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; - u8 WinSize = pHTInfo->RxReorderWinSize; + u8 WinSize = pHTInfo->rx_reorder_win_size; u16 WinEnd = 0; u8 index = 0; bool bMatchWinStart = false, bPktInBuf = false; @@ -591,7 +591,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, netdev_dbg(ieee->dev, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->rx_indicate_seq, SeqNum); - pHTInfo->RxReorderDropCounter++; + pHTInfo->rx_reorder_drop_counter++; { int i; @@ -755,7 +755,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, netdev_dbg(ieee->dev, "%s(): SET rx timeout timer\n", __func__); pTS->rx_timeout_indicate_seq = pTS->rx_indicate_seq; mod_timer(&pTS->rx_pkt_pending_timer, jiffies + - msecs_to_jiffies(pHTInfo->RxReorderPendingTime)); + msecs_to_jiffies(pHTInfo->rx_reorder_pending_time)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } @@ -924,7 +924,7 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if (!ieee->pHTInfo->bCurRxReorderEnable || + if (!ieee->pHTInfo->cur_rx_reorder_enable || !ieee->current_network.qos_data.active || !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { @@ -1442,7 +1442,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, } /* Indicate packets to upper layer or Rx Reorder */ - if (!ieee->pHTInfo->bCurRxReorderEnable || pTS == NULL || bToOtherSTA) + if (!ieee->pHTInfo->cur_rx_reorder_enable || pTS == NULL || bToOtherSTA) rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); else RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b5f4d35954a9..1a3ca3e57623 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -180,7 +180,7 @@ static u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 rate; - if (pHTInfo->IOTAction & HT_IOT_ACT_MGNT_USE_CCK_6M) + if (pHTInfo->iot_action & HT_IOT_ACT_MGNT_USE_CCK_6M) rate = 0x0c; else rate = ieee->basic_rate & 0x7f; @@ -586,9 +586,9 @@ static void rtllib_softmac_scan_wq(void *data) mutex_lock(&ieee->scan_mutex); - if (ieee->eRFPowerState == eRfOff) { + if (ieee->rf_power_state == rf_off) { netdev_info(ieee->dev, - "======>%s():rf state is eRfOff, return\n", + "======>%s():rf state is rf_off, return\n", __func__); goto out1; } @@ -865,10 +865,10 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, encrypt); - if (pHTInfo->bRegRT2RTAggregation) { - tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; + if (pHTInfo->reg_rt2rt_aggregation) { + tmp_generic_ie_buf = ieee->pHTInfo->sz_rt2rt_agg_buf; tmp_generic_ie_len = - sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + sizeof(ieee->pHTInfo->sz_rt2rt_agg_buf); HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); } @@ -1189,10 +1189,10 @@ rtllib_association_req(struct rtllib_network *beacon, ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt, true); - if (ieee->pHTInfo->bCurrentRT2RTAggregation) { - realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; + if (ieee->pHTInfo->current_rt2rt_aggregation) { + realtek_ie_buf = ieee->pHTInfo->sz_rt2rt_agg_buf; realtek_ie_len = - sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + sizeof(ieee->pHTInfo->sz_rt2rt_agg_buf); HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); } @@ -1368,7 +1368,7 @@ rtllib_association_req(struct rtllib_network *beacon, tag += ht_cap_len - 2; } - if (ieee->pHTInfo->bCurrentRT2RTAggregation) { + if (ieee->pHTInfo->current_rt2rt_aggregation) { tag = skb_put(skb, realtek_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = realtek_ie_len - 2; @@ -1584,13 +1584,8 @@ static void rtllib_associate_procedure_wq(void *data) ieee->data_hard_stop(ieee->dev); rtllib_stop_scan(ieee); - RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, - ieee->current_network.channel); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - if (ieee->eRFPowerState == eRfOff) { - RT_TRACE(COMP_DBG, - "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n", - __func__); + if (ieee->rf_power_state == rf_off) { if (ieee->rtllib_ips_leave_wq != NULL) ieee->rtllib_ips_leave_wq(ieee->dev); mutex_unlock(&ieee->wx_mutex); @@ -1611,7 +1606,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, short apset, ssidset, ssidbroad, apmatch, ssidmatch; - /* we are interested in new new only if we are not associated + /* we are interested in new only if we are not associated * and we are not associating / authenticating */ if (ieee->state != RTLLIB_NOLINK) @@ -1899,7 +1894,7 @@ static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, ((ieee->mode == IEEE_G) && (ieee->current_network.mode == IEEE_N_24G) && (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { - ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; + ieee->pHTInfo->iot_action |= HT_IOT_ACT_PURE_N_MODE; } else { ieee->AsocRetryCount = 0; } @@ -2062,9 +2057,6 @@ static inline void rtllib_sta_ps(struct work_struct *work) if ((ieee->ps == RTLLIB_PS_DISABLED || ieee->iw_mode != IW_MODE_INFRA || ieee->state != RTLLIB_LINKED)) { - RT_TRACE(COMP_DBG, - "=====>%s(): no need to ps,wake up!! ieee->ps is %d, ieee->iw_mode is %d, ieee->state is %d\n", - __func__, ieee->ps, ieee->iw_mode, ieee->state); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); rtllib_sta_wakeup(ieee, 1); @@ -2109,7 +2101,7 @@ static void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) { if (ieee->sta_sleep == LPS_IS_WAKE) { if (nl) { - if (ieee->pHTInfo->IOTAction & + if (ieee->pHTInfo->iot_action & HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); @@ -2125,7 +2117,7 @@ static void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) if (ieee->sta_sleep == LPS_IS_SLEEP) ieee->sta_wake_up(ieee->dev); if (nl) { - if (ieee->pHTInfo->IOTAction & + if (ieee->pHTInfo->iot_action & HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); @@ -2160,7 +2152,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) if ((ieee->sta_sleep == LPS_IS_WAKE) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->pHTInfo->IOTAction & + if (ieee->pHTInfo->iot_action & HT_IOT_ACT_NULL_DATA_POWER_SAVING) rtllib_sta_ps_send_null_frame(ieee, 0); else @@ -2304,7 +2296,7 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) if (ieee->open_wep || !challenge) { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - if (!(ieee->pHTInfo->IOTAction & HT_IOT_ACT_PURE_N_MODE)) { + if (!(ieee->pHTInfo->iot_action & HT_IOT_ACT_PURE_N_MODE)) { if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { if (IsHTHalfNmodeAPs(ieee)) { bSupportNmode = true; diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 70a62ca0f69a..f9589c5b62ba 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -364,8 +364,6 @@ void rtllib_wx_sync_scan_wq(void *data) b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; bandwidth = (enum ht_channel_width)ieee->pHTInfo->bCurBW40MHz; - RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", - chan_offset, bandwidth); ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); } @@ -373,7 +371,6 @@ void rtllib_wx_sync_scan_wq(void *data) rtllib_start_scan_syncro(ieee, 0); if (b40M) { - RT_TRACE(COMP_DBG, "Scan in 20M, back to 40M\n"); if (chan_offset == HT_EXTCHNL_OFFSET_UPPER) ieee->set_chan(ieee->dev, chan + 2); else if (chan_offset == HT_EXTCHNL_OFFSET_LOWER) @@ -571,14 +568,11 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, mutex_lock(&ieee->wx_mutex); if (wrqu->power.disabled) { - RT_TRACE(COMP_DBG, "===>%s(): power disable\n", __func__); ieee->ps = RTLLIB_PS_DISABLED; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { ieee->ps_timeout = wrqu->power.value / 1000; - RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n", __func__, - ieee->ps_timeout); } if (wrqu->power.flags & IW_POWER_PERIOD) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 42f81b23a144..e307020580a0 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -284,7 +284,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, if (tcb_desc->bdhcp || ieee->CntAfterLink < 2) return; - if (pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) + if (pHTInfo->iot_action & HT_IOT_ACT_TX_NO_AGGREGATION) return; if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) @@ -315,7 +315,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, if (ieee->iw_mode == IW_MODE_INFRA) { tcb_desc->bAMPDUEnable = true; tcb_desc->ampdu_factor = pHTInfo->CurrentAMPDUFactor; - tcb_desc->ampdu_density = pHTInfo->CurrentMPDUDensity; + tcb_desc->ampdu_density = pHTInfo->current_mpdu_density; } } FORCED_AGG_SETTING: @@ -325,8 +325,8 @@ FORCED_AGG_SETTING: case HT_AGG_FORCE_ENABLE: tcb_desc->bAMPDUEnable = true; - tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; - tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; + tcb_desc->ampdu_density = pHTInfo->forced_mpdu_density; + tcb_desc->ampdu_factor = pHTInfo->forced_ampdu_factor; break; case HT_AGG_FORCE_DISABLE: @@ -358,7 +358,7 @@ static void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; - if (pHTInfo->bForcedShortGI) { + if (pHTInfo->forced_short_gi) { tcb_desc->bUseShortGI = true; return; } @@ -384,7 +384,7 @@ static void rtllib_query_BandwidthMode(struct rtllib_device *ieee, if ((tcb_desc->data_rate & 0x80) == 0) return; - if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && + if (pHTInfo->bCurBW40MHz && pHTInfo->cur_tx_bw40mhz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) tcb_desc->bPacketBW = true; } @@ -422,12 +422,12 @@ static void rtllib_query_protectionmode(struct rtllib_device *ieee, pHTInfo = ieee->pHTInfo; while (true) { - if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) { + if (pHTInfo->iot_action & HT_IOT_ACT_FORCED_CTS2SELF) { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; - } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS | + } else if (pHTInfo->iot_action & (HT_IOT_ACT_FORCED_RTS | HT_IOT_ACT_PURE_N_MODE)) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; @@ -440,7 +440,7 @@ static void rtllib_query_protectionmode(struct rtllib_device *ieee, break; } if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) { - u8 HTOpMode = pHTInfo->CurrentOpMode; + u8 HTOpMode = pHTInfo->current_op_mode; if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) || @@ -885,7 +885,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) tcb_desc->priority = skb->priority; if (ether_type == ETH_P_PAE) { - if (ieee->pHTInfo->IOTAction & + if (ieee->pHTInfo->iot_action & HT_IOT_ACT_WA_IOT_Broadcom) { tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); @@ -910,7 +910,7 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) tcb_desc->data_rate = rtllib_current_rate(ieee); if (bdhcp) { - if (ieee->pHTInfo->IOTAction & + if (ieee->pHTInfo->iot_action & HT_IOT_ACT_WA_IOT_Broadcom) { tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); @@ -962,9 +962,9 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } -int rtllib_xmit(struct sk_buff *skb, struct net_device *dev) +netdev_tx_t rtllib_xmit(struct sk_buff *skb, struct net_device *dev) { memset(skb->cb, 0, sizeof(skb->cb)); - return rtllib_xmit_inter(skb, dev); + return rtllib_xmit_inter(skb, dev) ? NETDEV_TX_BUSY : NETDEV_TX_OK; } EXPORT_SYMBOL(rtllib_xmit); diff --git a/drivers/staging/rtl8192u/Makefile b/drivers/staging/rtl8192u/Makefile index 0be7426b6ebc..d32dfd89a606 100644 --- a/drivers/staging/rtl8192u/Makefile +++ b/drivers/staging/rtl8192u/Makefile @@ -8,6 +8,7 @@ ccflags-y += -DTHOMAS_BEACON -DTHOMAS_TASKLET -DTHOMAS_SKB -DTHOMAS_TURBO r8192u_usb-y := r8192U_core.o r8180_93cx6.o r8192U_wx.o \ r8190_rtl8256.o r819xU_phy.o r819xU_firmware.o \ r819xU_cmdpkt.o r8192U_dm.o r819xU_firmware_img.o \ + r8192U_debugfs.o \ ieee80211/ieee80211_crypt.o \ ieee80211/ieee80211_crypt_tkip.o \ ieee80211/ieee80211_crypt_ccmp.o \ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index b577f9c81f85..9cd4b1896745 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -2178,7 +2178,7 @@ int ieee80211_set_encryption(struct ieee80211_device *ieee); int ieee80211_encrypt_fragment(struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len); -int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); +netdev_tx_t ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); void ieee80211_txb_free(struct ieee80211_txb *txb); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 8602e3a6c837..e4b6454809a0 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -526,7 +526,7 @@ static void ieee80211_query_seqnum(struct ieee80211_device *ieee, } } -int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) +netdev_tx_t ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); struct ieee80211_txb *txb = NULL; @@ -822,13 +822,13 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += __le16_to_cpu(txb->payload_size); - return 0; + return NETDEV_TX_OK; } ieee80211_txb_free(txb); } } - return 0; + return NETDEV_TX_OK; failed: spin_unlock_irqrestore(&ieee->lock, flags); diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 1942cb849374..ff0ada00bf41 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -1061,6 +1061,9 @@ typedef struct r8192_priv { struct delayed_work gpio_change_rf_wq; struct delayed_work initialgain_operate_wq; struct workqueue_struct *priv_wq; + + /* debugfs */ + struct dentry *debugfs_dir; } r8192_priv; /* For rtl8187B */ @@ -1117,4 +1120,10 @@ void EnableHWSecurityConfig8192(struct net_device *dev); void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); +void rtl8192_debugfs_init_one(struct net_device *dev); +void rtl8192_debugfs_exit_one(struct net_device *dev); +void rtl8192_debugfs_rename_one(struct net_device *dev); +void rtl8192_debugfs_init(void); +void rtl8192_debugfs_exit(void); + #endif diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 2ca925f35830..0a60ef20107c 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -56,7 +56,6 @@ double __extendsfdf2(float a) #include "r8192U_dm.h" #include <linux/usb.h> #include <linux/slab.h> -#include <linux/proc_fs.h> #include <linux/seq_file.h> /* FIXME: check if 2.6.7 is ok */ @@ -453,179 +452,6 @@ static void rtl8192_restart(struct work_struct *work); static void watch_dog_timer_callback(struct timer_list *t); /**************************************************************************** - * -----------------------------PROCFS STUFF------------------------- - ****************************************************************************/ - -static struct proc_dir_entry *rtl8192_proc; - -static int __maybe_unused proc_get_stats_ap(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - struct ieee80211_device *ieee = priv->ieee80211; - struct ieee80211_network *target; - - list_for_each_entry(target, &ieee->network_list, list) { - const char *wpa = "non_WPA"; - - if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) - wpa = "WPA"; - - seq_printf(m, "%s %s\n", target->ssid, wpa); - } - - return 0; -} - -static int __maybe_unused proc_get_registers(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - int i, n, max = 0xff; - u8 byte_rd; - - seq_puts(m, "\n####################page 0##################\n "); - - for (n = 0; n <= max;) { - seq_printf(m, "\nD: %2x > ", n); - - for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x000 | n, &byte_rd); - seq_printf(m, "%2x ", byte_rd); - } - } - - seq_puts(m, "\n####################page 1##################\n "); - for (n = 0; n <= max;) { - seq_printf(m, "\nD: %2x > ", n); - - for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x100 | n, &byte_rd); - seq_printf(m, "%2x ", byte_rd); - } - } - - seq_puts(m, "\n####################page 3##################\n "); - for (n = 0; n <= max;) { - seq_printf(m, "\nD: %2x > ", n); - - for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x300 | n, &byte_rd); - seq_printf(m, "%2x ", byte_rd); - } - } - - seq_putc(m, '\n'); - return 0; -} - -static int __maybe_unused proc_get_stats_tx(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - - seq_printf(m, - "TX VI priority ok int: %lu\n" - "TX VI priority error int: %lu\n" - "TX VO priority ok int: %lu\n" - "TX VO priority error int: %lu\n" - "TX BE priority ok int: %lu\n" - "TX BE priority error int: %lu\n" - "TX BK priority ok int: %lu\n" - "TX BK priority error int: %lu\n" - "TX MANAGE priority ok int: %lu\n" - "TX MANAGE priority error int: %lu\n" - "TX BEACON priority ok int: %lu\n" - "TX BEACON priority error int: %lu\n" - "TX queue resume: %lu\n" - "TX queue stopped?: %d\n" - "TX fifo overflow: %lu\n" - "TX VI queue: %d\n" - "TX VO queue: %d\n" - "TX BE queue: %d\n" - "TX BK queue: %d\n" - "TX VI dropped: %lu\n" - "TX VO dropped: %lu\n" - "TX BE dropped: %lu\n" - "TX BK dropped: %lu\n" - "TX total data packets %lu\n", - priv->stats.txviokint, - priv->stats.txvierr, - priv->stats.txvookint, - priv->stats.txvoerr, - priv->stats.txbeokint, - priv->stats.txbeerr, - priv->stats.txbkokint, - priv->stats.txbkerr, - priv->stats.txmanageokint, - priv->stats.txmanageerr, - priv->stats.txbeaconokint, - priv->stats.txbeaconerr, - priv->stats.txresumed, - netif_queue_stopped(dev), - priv->stats.txoverflow, - atomic_read(&(priv->tx_pending[VI_PRIORITY])), - atomic_read(&(priv->tx_pending[VO_PRIORITY])), - atomic_read(&(priv->tx_pending[BE_PRIORITY])), - atomic_read(&(priv->tx_pending[BK_PRIORITY])), - priv->stats.txvidrop, - priv->stats.txvodrop, - priv->stats.txbedrop, - priv->stats.txbkdrop, - priv->stats.txdatapkt - ); - - return 0; -} - -static int __maybe_unused proc_get_stats_rx(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - - seq_printf(m, - "RX packets: %lu\n" - "RX urb status error: %lu\n" - "RX invalid urb error: %lu\n", - priv->stats.rxoktotal, - priv->stats.rxstaterr, - priv->stats.rxurberr); - - return 0; -} - -static void rtl8192_proc_module_init(void) -{ - RT_TRACE(COMP_INIT, "Initializing proc filesystem"); - rtl8192_proc = proc_mkdir(RTL819XU_MODULE_NAME, init_net.proc_net); -} - -static void rtl8192_proc_init_one(struct net_device *dev) -{ - struct proc_dir_entry *dir; - - if (!rtl8192_proc) - return; - - dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); - if (!dir) - return; - - proc_create_single("stats-rx", S_IFREG | 0444, dir, - proc_get_stats_rx); - proc_create_single("stats-tx", S_IFREG | 0444, dir, - proc_get_stats_tx); - proc_create_single("stats-ap", S_IFREG | 0444, dir, - proc_get_stats_ap); - proc_create_single("registers", S_IFREG | 0444, dir, - proc_get_registers); -} - -static void rtl8192_proc_remove_one(struct net_device *dev) -{ - remove_proc_subtree(dev->name, rtl8192_proc); -} - -/**************************************************************************** * -----------------------------MISC STUFF------------------------- *****************************************************************************/ @@ -4730,7 +4556,7 @@ static int rtl8192_usb_probe(struct usb_interface *intf, goto fail2; RT_TRACE(COMP_INIT, "dev name=======> %s\n", dev->name); - rtl8192_proc_init_one(dev); + rtl8192_debugfs_init_one(dev); RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; @@ -4764,10 +4590,11 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) struct net_device *dev = usb_get_intfdata(intf); struct r8192_priv *priv = ieee80211_priv(dev); - unregister_netdev(dev); RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n"); - rtl8192_proc_remove_one(dev); + rtl8192_debugfs_exit_one(dev); + + unregister_netdev(dev); rtl8192_down(dev); kfree(priv->pFirmware); @@ -4779,6 +4606,30 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } +static int rtl8192_usb_netdev_event(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct net_device *netdev = netdev_notifier_info_to_dev(data); + + if (netdev->netdev_ops != &rtl8192_netdev_ops) + goto out; + + switch (event) { + case NETDEV_CHANGENAME: + rtl8192_debugfs_rename_one(netdev); + break; + default: + break; + } + +out: + return NOTIFY_DONE; +} + +static struct notifier_block rtl8192_usb_netdev_notifier = { + .notifier_call = rtl8192_usb_netdev_event, +}; + static int __init rtl8192_usb_module_init(void) { int ret; @@ -4788,10 +4639,17 @@ static int __init rtl8192_usb_module_init(void) RT_TRACE(COMP_INIT, "Initializing module"); RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT); + ret = register_netdevice_notifier(&rtl8192_usb_netdev_notifier); + if (ret) { + pr_err("register_netdevice_notifier failed %d\n", ret); + return ret; + } + + rtl8192_debugfs_init(); ret = ieee80211_debug_init(); if (ret) { pr_err("ieee80211_debug_init() failed %d\n", ret); - return ret; + goto debugfs_exit; } ret = ieee80211_crypto_init(); @@ -4818,14 +4676,12 @@ static int __init rtl8192_usb_module_init(void) goto crypto_ccmp_exit; } - rtl8192_proc_module_init(); ret = usb_register(&rtl8192_usb_driver); if (ret) - goto rtl8192_proc_module_exit; + goto crypto_wep_exit; return ret; -rtl8192_proc_module_exit: - remove_proc_entry(RTL819XU_MODULE_NAME, init_net.proc_net); +crypto_wep_exit: ieee80211_crypto_wep_exit(); crypto_ccmp_exit: ieee80211_crypto_ccmp_exit(); @@ -4835,18 +4691,22 @@ crypto_exit: ieee80211_crypto_deinit(); debug_exit: ieee80211_debug_exit(); +debugfs_exit: + rtl8192_debugfs_exit(); + unregister_netdevice_notifier(&rtl8192_usb_netdev_notifier); return ret; } static void __exit rtl8192_usb_module_exit(void) { usb_deregister(&rtl8192_usb_driver); - remove_proc_entry(RTL819XU_MODULE_NAME, init_net.proc_net); ieee80211_crypto_wep_exit(); ieee80211_crypto_ccmp_exit(); ieee80211_crypto_tkip_exit(); ieee80211_crypto_deinit(); ieee80211_debug_exit(); + rtl8192_debugfs_exit(); + unregister_netdevice_notifier(&rtl8192_usb_netdev_notifier); RT_TRACE(COMP_DOWN, "Exiting"); } diff --git a/drivers/staging/rtl8192u/r8192U_debugfs.c b/drivers/staging/rtl8192u/r8192U_debugfs.c new file mode 100644 index 000000000000..fe8ef72506ee --- /dev/null +++ b/drivers/staging/rtl8192u/r8192U_debugfs.c @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0 +/**************************************************************************** + * -----------------------------DEGUGFS STUFF------------------------- + ****************************************************************************/ +#include <linux/debugfs.h> +#include <linux/seq_file.h> +#include "r8192U.h" + +#define KBUILD_MODNAME "r8192u_usb" + +static int rtl8192_usb_stats_ap_show(struct seq_file *m, void *v) +{ + struct net_device *dev = m->private; + struct r8192_priv *priv = ieee80211_priv(dev); + struct ieee80211_device *ieee = priv->ieee80211; + struct ieee80211_network *target; + + list_for_each_entry(target, &ieee->network_list, list) { + const char *wpa = "non_WPA"; + + if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) + wpa = "WPA"; + + seq_printf(m, "%s %s\n", target->ssid, wpa); + } + + return 0; +} + +static int rtl8192_usb_registers_show(struct seq_file *m, void *v) +{ + struct net_device *dev = m->private; + int i, n, max = 0xff; + u8 byte_rd; + + seq_puts(m, "\n####################page 0##################\n "); + + for (n = 0; n <= max;) { + seq_printf(m, "\nD: %2x > ", n); + + for (i = 0; i < 16 && n <= max; i++, n++) { + read_nic_byte(dev, 0x000 | n, &byte_rd); + seq_printf(m, "%2x ", byte_rd); + } + } + + seq_puts(m, "\n####################page 1##################\n "); + for (n = 0; n <= max;) { + seq_printf(m, "\nD: %2x > ", n); + + for (i = 0; i < 16 && n <= max; i++, n++) { + read_nic_byte(dev, 0x100 | n, &byte_rd); + seq_printf(m, "%2x ", byte_rd); + } + } + + seq_puts(m, "\n####################page 3##################\n "); + for (n = 0; n <= max;) { + seq_printf(m, "\nD: %2x > ", n); + + for (i = 0; i < 16 && n <= max; i++, n++) { + read_nic_byte(dev, 0x300 | n, &byte_rd); + seq_printf(m, "%2x ", byte_rd); + } + } + + seq_putc(m, '\n'); + return 0; +} + +static int rtl8192_usb_stats_tx_show(struct seq_file *m, void *v) +{ + struct net_device *dev = m->private; + struct r8192_priv *priv = ieee80211_priv(dev); + + seq_printf(m, + "TX VI priority ok int: %lu\n" + "TX VI priority error int: %lu\n" + "TX VO priority ok int: %lu\n" + "TX VO priority error int: %lu\n" + "TX BE priority ok int: %lu\n" + "TX BE priority error int: %lu\n" + "TX BK priority ok int: %lu\n" + "TX BK priority error int: %lu\n" + "TX MANAGE priority ok int: %lu\n" + "TX MANAGE priority error int: %lu\n" + "TX BEACON priority ok int: %lu\n" + "TX BEACON priority error int: %lu\n" + "TX queue resume: %lu\n" + "TX queue stopped?: %d\n" + "TX fifo overflow: %lu\n" + "TX VI queue: %d\n" + "TX VO queue: %d\n" + "TX BE queue: %d\n" + "TX BK queue: %d\n" + "TX VI dropped: %lu\n" + "TX VO dropped: %lu\n" + "TX BE dropped: %lu\n" + "TX BK dropped: %lu\n" + "TX total data packets %lu\n", + priv->stats.txviokint, + priv->stats.txvierr, + priv->stats.txvookint, + priv->stats.txvoerr, + priv->stats.txbeokint, + priv->stats.txbeerr, + priv->stats.txbkokint, + priv->stats.txbkerr, + priv->stats.txmanageokint, + priv->stats.txmanageerr, + priv->stats.txbeaconokint, + priv->stats.txbeaconerr, + priv->stats.txresumed, + netif_queue_stopped(dev), + priv->stats.txoverflow, + atomic_read(&(priv->tx_pending[VI_PRIORITY])), + atomic_read(&(priv->tx_pending[VO_PRIORITY])), + atomic_read(&(priv->tx_pending[BE_PRIORITY])), + atomic_read(&(priv->tx_pending[BK_PRIORITY])), + priv->stats.txvidrop, + priv->stats.txvodrop, + priv->stats.txbedrop, + priv->stats.txbkdrop, + priv->stats.txdatapkt + ); + + return 0; +} + +static int rtl8192_usb_stats_rx_show(struct seq_file *m, void *v) +{ + struct net_device *dev = m->private; + struct r8192_priv *priv = ieee80211_priv(dev); + + seq_printf(m, + "RX packets: %lu\n" + "RX urb status error: %lu\n" + "RX invalid urb error: %lu\n", + priv->stats.rxoktotal, + priv->stats.rxstaterr, + priv->stats.rxurberr); + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(rtl8192_usb_stats_rx); +DEFINE_SHOW_ATTRIBUTE(rtl8192_usb_stats_tx); +DEFINE_SHOW_ATTRIBUTE(rtl8192_usb_stats_ap); +DEFINE_SHOW_ATTRIBUTE(rtl8192_usb_registers); + +void rtl8192_debugfs_init_one(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + struct dentry *parent_dir = debugfs_lookup(KBUILD_MODNAME, NULL); + struct dentry *dir = debugfs_create_dir(dev->name, parent_dir); + + debugfs_create_file("stats-rx", 0444, dir, dev, &rtl8192_usb_stats_rx_fops); + debugfs_create_file("stats-tx", 0444, dir, dev, &rtl8192_usb_stats_tx_fops); + debugfs_create_file("stats-ap", 0444, dir, dev, &rtl8192_usb_stats_ap_fops); + debugfs_create_file("registers", 0444, dir, dev, &rtl8192_usb_registers_fops); + + priv->debugfs_dir = dir; +} + +void rtl8192_debugfs_exit_one(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + + debugfs_remove_recursive(priv->debugfs_dir); +} + +void rtl8192_debugfs_rename_one(struct net_device *dev) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + struct dentry *parent_dir = debugfs_lookup(KBUILD_MODNAME, NULL); + + debugfs_rename(parent_dir, priv->debugfs_dir, parent_dir, dev->name); +} + +void rtl8192_debugfs_init(void) +{ + debugfs_create_dir(KBUILD_MODNAME, NULL); +} + +void rtl8192_debugfs_exit(void) +{ + debugfs_remove_recursive(debugfs_lookup(KBUILD_MODNAME, NULL)); +} diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 4a93839bf947..132afbf49dde 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -66,16 +66,16 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) { struct ethhdr etherhdr; struct iphdr ip_hdr; - u16 UserPriority = 0; + u16 user_priority = 0; _r8712_open_pktfile(ppktfile->pkt, ppktfile); _r8712_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); - /* get UserPriority from IP hdr*/ + /* get user_priority from IP hdr*/ if (pattrib->ether_type == 0x0800) { _r8712_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); - /*UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3 ;*/ - UserPriority = ip_hdr.tos >> 5; + /*user_priority = (ntohs(ip_hdr.tos) >> 5) & 0x3 ;*/ + user_priority = ip_hdr.tos >> 5; } else { /* "When priority processing of data frames is supported, * a STA's SME should send EAPOL-Key frames at the highest @@ -83,9 +83,9 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) */ if (pattrib->ether_type == 0x888e) - UserPriority = 7; + user_priority = 7; } - pattrib->priority = UserPriority; + pattrib->priority = user_priority; pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN; pattrib->subtype = WIFI_QOS_DATA_TYPE; } @@ -140,7 +140,7 @@ void r8712_xmit_complete(struct _adapter *padapter, struct xmit_frame *pxframe) pxframe->pkt = NULL; } -int r8712_xmit_entry(_pkt *pkt, struct net_device *netdev) +netdev_tx_t r8712_xmit_entry(_pkt *pkt, struct net_device *netdev) { struct xmit_frame *xmitframe = NULL; struct _adapter *adapter = netdev_priv(netdev); @@ -165,11 +165,11 @@ int r8712_xmit_entry(_pkt *pkt, struct net_device *netdev) } xmitpriv->tx_pkts++; xmitpriv->tx_bytes += xmitframe->attrib.last_txcmdsz; - return 0; + return NETDEV_TX_OK; _xmit_entry_drop: if (xmitframe) r8712_free_xmitframe(xmitpriv, xmitframe); xmitpriv->tx_drop++; dev_kfree_skb_any(pkt); - return 0; + return NETDEV_TX_OK; } diff --git a/drivers/staging/rtl8712/xmit_osdep.h b/drivers/staging/rtl8712/xmit_osdep.h index b76021b568f8..1ad42658c883 100644 --- a/drivers/staging/rtl8712/xmit_osdep.h +++ b/drivers/staging/rtl8712/xmit_osdep.h @@ -34,7 +34,7 @@ struct sta_xmit_priv; struct xmit_frame; struct xmit_buf; -int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev); +netdev_tx_t r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev); void r8712_SetFilter(struct work_struct *work); int r8712_xmit_resource_alloc(struct _adapter *padapter, struct xmit_buf *pxmitbuf); diff --git a/drivers/staging/rtl8723bs/Makefile b/drivers/staging/rtl8723bs/Makefile index 159ca1b9016b..590bde02058c 100644 --- a/drivers/staging/rtl8723bs/Makefile +++ b/drivers/staging/rtl8723bs/Makefile @@ -10,7 +10,6 @@ r8723bs-y = \ core/rtw_ieee80211.o \ core/rtw_mlme.o \ core/rtw_mlme_ext.o \ - core/rtw_odm.o \ core/rtw_pwrctrl.o \ core/rtw_recv.o \ core/rtw_rf.o \ @@ -33,7 +32,6 @@ r8723bs-y = \ hal/odm_DynamicTxPower.o \ hal/odm_EdcaTurboCheck.o \ hal/odm_HWConfig.o \ - hal/odm_NoiseMonitor.o \ hal/odm_RegConfig8723B.o \ hal/rtl8723b_cmd.o \ hal/rtl8723b_dm.o \ diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index b4170f64d118..d3f10a3cf972 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -161,8 +161,6 @@ static struct cmd_hdl wlancmds[] = { int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { - int res = 0; - init_completion(&pcmdpriv->cmd_queue_comp); init_completion(&pcmdpriv->terminate_cmdthread_comp); @@ -175,18 +173,16 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) pcmdpriv->cmd_allocated_buf = rtw_zmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ); - if (!pcmdpriv->cmd_allocated_buf) { - res = -ENOMEM; - goto exit; - } + if (!pcmdpriv->cmd_allocated_buf) + return -ENOMEM; pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((SIZE_PTR)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); pcmdpriv->rsp_allocated_buf = rtw_zmalloc(MAX_RSPSZ + 4); if (!pcmdpriv->rsp_allocated_buf) { - res = -ENOMEM; - goto exit; + kfree(pcmdpriv->cmd_allocated_buf); + return -ENOMEM; } pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((SIZE_PTR)(pcmdpriv->rsp_allocated_buf) & 3); @@ -196,8 +192,8 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) pcmdpriv->rsp_cnt = 0; mutex_init(&pcmdpriv->sctx_mutex); -exit: - return res; + + return 0; } static void c2h_wk_callback(struct work_struct *work); @@ -593,35 +589,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, return res; } -u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) -{ - struct cmd_obj *ph2c; - struct setdatarate_parm *pbsetdataratepara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); - if (!pbsetdataratepara) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate)); - pbsetdataratepara->mac_id = 5; - memcpy(pbsetdataratepara->datarates, rateset, NumRates); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - return res; -} - void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { /* rtw_free_cmd_obj(pcmd); */ @@ -1140,61 +1107,6 @@ exit: return res; } -u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconfig) -{ - struct cmd_obj *pcmdobj; - struct SetChannelPlan_param *setChannelPlan_param; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - /* check if allow software config */ - if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter)) { - res = _FAIL; - goto exit; - } - - /* check input parameter */ - if (!rtw_is_channel_plan_valid(chplan)) { - res = _FAIL; - goto exit; - } - - /* prepare cmd parameter */ - setChannelPlan_param = rtw_zmalloc(sizeof(struct SetChannelPlan_param)); - if (!setChannelPlan_param) { - res = _FAIL; - goto exit; - } - setChannelPlan_param->channel_plan = chplan; - - if (enqueue) { - /* need enqueue, prepare cmd_obj and enqueue */ - pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj)); - if (!pcmdobj) { - kfree(setChannelPlan_param); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan)); - res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - } else { - /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param) != H2C_SUCCESS) - res = _FAIL; - - kfree(setChannelPlan_param); - } - - /* do something based on res... */ - if (res == _SUCCESS) - padapter->mlmepriv.ChannelPlan = chplan; - -exit: - return res; -} - static void collect_traffic_statistics(struct adapter *padapter) { struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 68e41d99679d..3d8a64f69448 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -634,23 +634,6 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie } } -u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) -{ - u8 match = false; - u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - if (!ie_ptr) - return match; - - eid = ie_ptr[0]; - - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { - *wps_ielen = ie_ptr[1]+2; - match = true; - } - return match; -} - /** * rtw_get_wps_ie - Search WPS IE from a series of IEs * @in_ie: Address of IEs to search diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index f2242cf2dfb4..6498fd17e1d3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2521,7 +2521,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr { u8 issued; int priority; - struct sta_info *psta = NULL; + struct sta_info *psta; struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 bmcst = IS_MCAST(pattrib->ra); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index f878b04076d8..8e74b4f47b94 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -5945,27 +5945,6 @@ int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset return connect_allow ? _SUCCESS : _FAIL; } -/* Find union about ch, bw, ch_offset of all linked/linking interfaces */ -int rtw_get_ch_setting_union(struct adapter *adapter, u8 *ch, u8 *bw, u8 *offset) -{ - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct adapter *iface; - - if (ch) - *ch = 0; - if (bw) - *bw = CHANNEL_WIDTH_20; - if (offset) - *offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - iface = dvobj->padapters; - - if (!check_fwstate(&iface->mlmepriv, _FW_LINKED|_FW_UNDER_LINKING)) - return 0; - - return 1; -} - u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) { struct set_ch_parm *set_ch_parm; diff --git a/drivers/staging/rtl8723bs/core/rtw_odm.c b/drivers/staging/rtl8723bs/core/rtw_odm.c deleted file mode 100644 index f6b73a2a0270..000000000000 --- a/drivers/staging/rtl8723bs/core/rtw_odm.c +++ /dev/null @@ -1,195 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2013 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include <drv_types.h> -#include <rtw_debug.h> -#include <rtw_odm.h> -#include <hal_data.h> - -static const char * const odm_comp_str[] = { - /* BIT0 */"ODM_COMP_DIG", - /* BIT1 */"ODM_COMP_RA_MASK", - /* BIT2 */"ODM_COMP_DYNAMIC_TXPWR", - /* BIT3 */"ODM_COMP_FA_CNT", - /* BIT4 */"ODM_COMP_RSSI_MONITOR", - /* BIT5 */"ODM_COMP_CCK_PD", - /* BIT6 */"ODM_COMP_ANT_DIV", - /* BIT7 */"ODM_COMP_PWR_SAVE", - /* BIT8 */"ODM_COMP_PWR_TRAIN", - /* BIT9 */"ODM_COMP_RATE_ADAPTIVE", - /* BIT10 */"ODM_COMP_PATH_DIV", - /* BIT11 */"ODM_COMP_PSD", - /* BIT12 */"ODM_COMP_DYNAMIC_PRICCA", - /* BIT13 */"ODM_COMP_RXHP", - /* BIT14 */"ODM_COMP_MP", - /* BIT15 */"ODM_COMP_DYNAMIC_ATC", - /* BIT16 */"ODM_COMP_EDCA_TURBO", - /* BIT17 */"ODM_COMP_EARLY_MODE", - /* BIT18 */NULL, - /* BIT19 */NULL, - /* BIT20 */NULL, - /* BIT21 */NULL, - /* BIT22 */NULL, - /* BIT23 */NULL, - /* BIT24 */"ODM_COMP_TX_PWR_TRACK", - /* BIT25 */"ODM_COMP_RX_GAIN_TRACK", - /* BIT26 */"ODM_COMP_CALIBRATION", - /* BIT27 */NULL, - /* BIT28 */NULL, - /* BIT29 */NULL, - /* BIT30 */"ODM_COMP_COMMON", - /* BIT31 */"ODM_COMP_INIT", -}; - -#define RTW_ODM_COMP_MAX 32 - -static const char * const odm_ability_str[] = { - /* BIT0 */"ODM_BB_DIG", - /* BIT1 */"ODM_BB_RA_MASK", - /* BIT2 */"ODM_BB_DYNAMIC_TXPWR", - /* BIT3 */"ODM_BB_FA_CNT", - /* BIT4 */"ODM_BB_RSSI_MONITOR", - /* BIT5 */"ODM_BB_CCK_PD", - /* BIT6 */"ODM_BB_ANT_DIV", - /* BIT7 */"ODM_BB_PWR_SAVE", - /* BIT8 */"ODM_BB_PWR_TRAIN", - /* BIT9 */"ODM_BB_RATE_ADAPTIVE", - /* BIT10 */"ODM_BB_PATH_DIV", - /* BIT11 */"ODM_BB_PSD", - /* BIT12 */"ODM_BB_RXHP", - /* BIT13 */"ODM_BB_ADAPTIVITY", - /* BIT14 */"ODM_BB_DYNAMIC_ATC", - /* BIT15 */NULL, - /* BIT16 */"ODM_MAC_EDCA_TURBO", - /* BIT17 */"ODM_MAC_EARLY_MODE", - /* BIT18 */NULL, - /* BIT19 */NULL, - /* BIT20 */NULL, - /* BIT21 */NULL, - /* BIT22 */NULL, - /* BIT23 */NULL, - /* BIT24 */"ODM_RF_TX_PWR_TRACK", - /* BIT25 */"ODM_RF_RX_GAIN_TRACK", - /* BIT26 */"ODM_RF_CALIBRATION", -}; - -#define RTW_ODM_ABILITY_MAX 27 - -static const char * const odm_dbg_level_str[] = { - NULL, - "ODM_DBG_OFF", - "ODM_DBG_SERIOUS", - "ODM_DBG_WARNING", - "ODM_DBG_LOUD", - "ODM_DBG_TRACE", -}; - -#define RTW_ODM_DBG_LEVEL_NUM 6 - -void rtw_odm_dbg_comp_msg(struct adapter *adapter) -{ - u64 dbg_comp; - int i; - - rtw_hal_get_def_var(adapter, HW_DEF_ODM_DBG_FLAG, &dbg_comp); - netdev_dbg(adapter->pnetdev, "odm.DebugComponents = 0x%016llx\n", - dbg_comp); - for (i = 0; i < RTW_ODM_COMP_MAX; i++) { - if (odm_comp_str[i]) - netdev_dbg(adapter->pnetdev, "%cBIT%-2d %s\n", - (BIT0 << i) & dbg_comp ? '+' : ' ', i, - odm_comp_str[i]); - } -} - -inline void rtw_odm_dbg_comp_set(struct adapter *adapter, u64 comps) -{ - rtw_hal_set_def_var(adapter, HW_DEF_ODM_DBG_FLAG, &comps); -} - -void rtw_odm_dbg_level_msg(void *sel, struct adapter *adapter) -{ - u32 dbg_level; - int i; - - rtw_hal_get_def_var(adapter, HW_DEF_ODM_DBG_LEVEL, &dbg_level); - netdev_dbg(adapter->pnetdev, "odm.DebugLevel = %u\n", dbg_level); - for (i = 0; i < RTW_ODM_DBG_LEVEL_NUM; i++) { - if (odm_dbg_level_str[i]) - netdev_dbg(adapter->pnetdev, "%u %s\n", i, - odm_dbg_level_str[i]); - } -} - -inline void rtw_odm_dbg_level_set(struct adapter *adapter, u32 level) -{ - rtw_hal_set_def_var(adapter, HW_DEF_ODM_DBG_LEVEL, &level); -} - -void rtw_odm_ability_msg(void *sel, struct adapter *adapter) -{ - u32 ability = 0; - int i; - - rtw_hal_get_hwreg(adapter, HW_VAR_DM_FLAG, (u8 *)&ability); - netdev_dbg(adapter->pnetdev, "odm.SupportAbility = 0x%08x\n", ability); - for (i = 0; i < RTW_ODM_ABILITY_MAX; i++) { - if (odm_ability_str[i]) - netdev_dbg(adapter->pnetdev, "%cBIT%-2d %s\n", - (BIT0 << i) & ability ? '+' : ' ', i, - odm_ability_str[i]); - } -} - -inline void rtw_odm_ability_set(struct adapter *adapter, u32 ability) -{ - rtw_hal_set_hwreg(adapter, HW_VAR_DM_FLAG, (u8 *)&ability); -} - -void rtw_odm_adaptivity_parm_msg(void *sel, struct adapter *adapter) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(adapter); - struct dm_odm_t *odm = &pHalData->odmpriv; - - netdev_dbg(adapter->pnetdev, "%10s %16s %8s %10s %11s %14s\n", - "TH_L2H_ini", "TH_EDCCA_HL_diff", "IGI_Base", "ForceEDCCA", - "AdapEn_RSSI", "IGI_LowerBound"); - netdev_dbg(adapter->pnetdev, - "0x%-8x %-16d 0x%-6x %-10d %-11u %-14u\n", - (u8)odm->TH_L2H_ini, - odm->TH_EDCCA_HL_diff, - odm->IGI_Base, - odm->ForceEDCCA, - odm->AdapEn_RSSI, - odm->IGI_LowerBound); -} - -void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini, - s8 TH_EDCCA_HL_diff, s8 IGI_Base, - bool ForceEDCCA, u8 AdapEn_RSSI, - u8 IGI_LowerBound) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(adapter); - struct dm_odm_t *odm = &pHalData->odmpriv; - - odm->TH_L2H_ini = TH_L2H_ini; - odm->TH_EDCCA_HL_diff = TH_EDCCA_HL_diff; - odm->IGI_Base = IGI_Base; - odm->ForceEDCCA = ForceEDCCA; - odm->AdapEn_RSSI = AdapEn_RSSI; - odm->IGI_LowerBound = IGI_LowerBound; -} - -void rtw_odm_get_perpkt_rssi(void *sel, struct adapter *adapter) -{ - struct hal_com_data *hal_data = GET_HAL_DATA(adapter); - struct dm_odm_t *odm = &hal_data->odmpriv; - - netdev_dbg(adapter->pnetdev, - "RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n", - HDATA_RATE(odm->RxRate), odm->RSSI_A, odm->RSSI_B); -} diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index d8d394b67eeb..2825375bff94 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -203,22 +203,12 @@ signed int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *q } /* -signed int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) -{ - return rtw_free_recvframe(precvframe, queue); -} -*/ - - - - -/* -caller : defrag ; recvframe_chk_defrag in recv_thread (passive) -pframequeue: defrag_queue : will be accessed in recv_thread (passive) - -using spinlock to protect - -*/ + * caller : defrag ; recvframe_chk_defrag in recv_thread (passive) + * pframequeue: defrag_queue : will be accessed in recv_thread (passive) + * + * using spinlock to protect + * + */ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) { @@ -245,6 +235,7 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) { u32 cnt = 0; union recv_frame *pending_frame; + while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); cnt++; @@ -397,6 +388,7 @@ static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *p if (prxattrib->encrypt > 0) { u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen; + prxattrib->key_index = (((iv[3])>>6)&0x3); if (prxattrib->key_index > WEP_KEYS) { @@ -882,6 +874,7 @@ static signed int sta2ap_data_frame(struct adapter *adapter, union recv_frame *p } } else { u8 *myhwaddr = myid(&adapter->eeprompriv); + if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { ret = RTW_RX_HANDLED; goto exit; @@ -1125,6 +1118,7 @@ static union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union re psta = rtw_get_stainfo(pstapriv, psta_addr); if (!psta) { u8 type = GetFrameType(pfhdr->rx_data); + if (type != WIFI_DATA_TYPE) { psta = rtw_get_bcmc_stainfo(padapter); pdefrag_q = &psta->sta_recvpriv.defrag_q; @@ -1207,6 +1201,7 @@ static signed int validate_recv_mgnt_frame(struct adapter *padapter, union recv_ { /* for rx pkt statistics */ struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->u.hdr.rx_data)); + if (psta) { psta->sta_stats.rx_mgnt_pkts++; if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_BEACON) @@ -1374,9 +1369,8 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame /* actual management data frame body */ data_len = pattrib->pkt_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; mgmt_DATA = rtw_zmalloc(data_len); - if (!mgmt_DATA) { + if (!mgmt_DATA) goto validate_80211w_fail; - } precv_frame = decryptor(adapter, precv_frame); /* save actual management data frame body */ memcpy(mgmt_DATA, ptr+pattrib->hdrlen+pattrib->iv_len, data_len); @@ -1385,9 +1379,8 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame /* remove the iv and icv length */ pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len; kfree(mgmt_DATA); - if (!precv_frame) { + if (!precv_frame) goto validate_80211w_fail; - } } else if (IS_MCAST(GetAddr1Ptr(ptr)) && (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) { signed int BIP_ret = _SUCCESS; @@ -1480,6 +1473,7 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame retval = validate_recv_data_frame(adapter, precv_frame); if (retval == _FAIL) { struct recv_priv *precvpriv = &adapter->recvpriv; + precvpriv->rx_drop++; } else if (retval == _SUCCESS) { #ifdef DBG_RX_DUMP_EAP @@ -1651,14 +1645,12 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) & 0xFFF;/* 4096; */ /* Rx Reorder initialize condition. */ - if (preorder_ctrl->indicate_seq == 0xFFFF) { + if (preorder_ctrl->indicate_seq == 0xFFFF) preorder_ctrl->indicate_seq = seq_num; - } /* Drop out the packet which SeqNum is smaller than WinStart */ - if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) { + if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) return false; - } /* */ /* Sliding window manipulation. Conditions includes: */ @@ -2084,10 +2076,8 @@ s32 rtw_recv_entry(union recv_frame *precvframe) precvpriv = &padapter->recvpriv; ret = recv_func(padapter, precvframe); - if (ret == _FAIL) { + if (ret == _FAIL) goto _recv_entry_drop; - } - precvpriv->rx_pkts++; diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 9acd49323c7c..e36f8c369a04 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -1283,11 +1283,6 @@ s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return (s32)GLBtCoexist.btInfo.bBtCtrlAggBufSize; } -void hal_btcoex_SetManualControl(struct adapter *padapter, u8 bmanual) -{ - GLBtCoexist.bManualControl = bmanual; -} - bool hal_btcoex_IsBtControlLps(struct adapter *padapter) { if (!hal_btcoex_IsBtExist(padapter)) diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 909b37bcc897..e42556d03bce 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -861,25 +861,6 @@ bool eqNByte(u8 *str1, u8 *str2, u32 num) /* */ /* Description: */ -/* Return true if chTmp is represent for hex digit and */ -/* false otherwise. */ -/* */ -/* */ -bool IsHexDigit(char chTmp) -{ - if ( - (chTmp >= '0' && chTmp <= '9') || - (chTmp >= 'a' && chTmp <= 'f') || - (chTmp >= 'A' && chTmp <= 'F') - ) - return true; - else - return false; -} - - -/* */ -/* Description: */ /* Translate a character to hex digit. */ /* */ u32 MapCharToHexDigit(char chTmp) @@ -894,106 +875,6 @@ u32 MapCharToHexDigit(char chTmp) return 0; } - - -/* Description: */ -/* Parse hex number from the string pucStr. */ -bool GetHexValueFromString(char *szStr, u32 *pu4bVal, u32 *pu4bMove) -{ - char *szScan = szStr; - - /* Check input parameter. */ - if (!szStr || !pu4bVal || !pu4bMove) - return false; - - /* Initialize output. */ - *pu4bMove = 0; - *pu4bVal = 0; - - /* Skip leading space. */ - while (*szScan != '\0' && (*szScan == ' ' || *szScan == '\t')) { - szScan++; - (*pu4bMove)++; - } - - /* Skip leading '0x' or '0X'. */ - if (*szScan == '0' && (*(szScan+1) == 'x' || *(szScan+1) == 'X')) { - szScan += 2; - (*pu4bMove) += 2; - } - - /* Check if szScan is now pointer to a character for hex digit, */ - /* if not, it means this is not a valid hex number. */ - if (!IsHexDigit(*szScan)) - return false; - - /* Parse each digit. */ - do { - (*pu4bVal) <<= 4; - *pu4bVal += MapCharToHexDigit(*szScan); - - szScan++; - (*pu4bMove)++; - } while (IsHexDigit(*szScan)); - - return true; -} - -bool GetFractionValueFromString( - char *szStr, u8 *pInteger, u8 *pFraction, u32 *pu4bMove -) -{ - char *szScan = szStr; - - /* Initialize output. */ - *pu4bMove = 0; - *pInteger = 0; - *pFraction = 0; - - /* Skip leading space. */ - while (*szScan != '\0' && (*szScan == ' ' || *szScan == '\t')) { - ++szScan; - ++(*pu4bMove); - } - - /* Parse each digit. */ - do { - (*pInteger) *= 10; - *pInteger += (*szScan - '0'); - - ++szScan; - ++(*pu4bMove); - - if (*szScan == '.') { - ++szScan; - ++(*pu4bMove); - - if (*szScan < '0' || *szScan > '9') - return false; - else { - *pFraction = *szScan - '0'; - ++szScan; - ++(*pu4bMove); - return true; - } - } - } while (*szScan >= '0' && *szScan <= '9'); - - return true; -} - -/* */ -/* Description: */ -/* Return true if szStr is comment out with leading "//". */ -/* */ -bool IsCommentString(char *szStr) -{ - if (*szStr == '/' && *(szStr+1) == '/') - return true; - else - return false; -} - bool GetU1ByteIntegerFromStringInDecimal(char *Str, u8 *pInt) { u16 i = 0; diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c index 94ecefb9113d..6bb0ff8d7c78 100644 --- a/drivers/staging/rtl8723bs/hal/hal_intf.c +++ b/drivers/staging/rtl8723bs/hal/hal_intf.c @@ -400,11 +400,6 @@ c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter) return adapter->HalFunc.c2h_id_filter_ccx; } -s32 rtw_hal_is_disable_sw_channel_plan(struct adapter *padapter) -{ - return GET_HAL_DATA(padapter)->bDisableSWChannelPlan; -} - s32 rtw_hal_macid_sleep(struct adapter *padapter, u32 macid) { u8 support; diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h index 19cfc2915458..fe9782d2d4fd 100644 --- a/drivers/staging/rtl8723bs/hal/odm.h +++ b/drivers/staging/rtl8723bs/hal/odm.h @@ -14,7 +14,6 @@ #include "odm_DynamicBBPowerSaving.h" #include "odm_DynamicTxPower.h" #include "odm_CfoTracking.h" -#include "odm_NoiseMonitor.h" #define TP_MODE 0 #define RSSI_MODE 1 @@ -863,7 +862,6 @@ struct dm_odm_t { /* DM_Out_Source_Dynamic_Mechanism_Structure */ u8 Adaptivity_IGI_upper; u8 NHM_cnt_0; - struct odm_noise_monitor noise_level;/* ODM_MAX_CHANNEL_NUM]; */ /* */ /* 2 Define STA info. */ /* _ODM_STA_INFO */ diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index 7e92c373cddb..07edf74ccfe5 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -309,63 +309,6 @@ void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI) } -void odm_PauseDIG( - void *pDM_VOID, - enum ODM_Pause_DIG_TYPE PauseType, - u8 IGIValue -) -{ - struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID; - struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable; - static bool bPaused; - - if ( - (pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY) && - pDM_Odm->TxHangFlg == true - ) { - return; - } - - if ( - !bPaused && (!(pDM_Odm->SupportAbility & ODM_BB_DIG) || - !(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) - ){ - return; - } - - switch (PauseType) { - /* 1 Pause DIG */ - case ODM_PAUSE_DIG: - /* 2 Disable DIG */ - ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pDM_Odm->SupportAbility & (~ODM_BB_DIG)); - - /* 2 Backup IGI value */ - if (!bPaused) { - pDM_DigTable->IGIBackup = pDM_DigTable->CurIGValue; - bPaused = true; - } - - /* 2 Write new IGI value */ - ODM_Write_DIG(pDM_Odm, IGIValue); - break; - - /* 1 Resume DIG */ - case ODM_RESUME_DIG: - if (bPaused) { - /* 2 Write backup IGI value */ - ODM_Write_DIG(pDM_Odm, pDM_DigTable->IGIBackup); - bPaused = false; - - /* 2 Enable DIG */ - ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pDM_Odm->SupportAbility | ODM_BB_DIG); - } - break; - - default: - break; - } -} - bool odm_DigAbort(void *pDM_VOID) { struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID; diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.h b/drivers/staging/rtl8723bs/hal/odm_DIG.h index 88cfd542df16..a5b041101c89 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.h +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.h @@ -141,8 +141,6 @@ void odm_Adaptivity(void *pDM_VOID, u8 IGI); void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI); -void odm_PauseDIG(void *pDM_VOID, enum ODM_Pause_DIG_TYPE PauseType, u8 IGIValue); - void odm_DIGInit(void *pDM_VOID); void odm_DIG(void *pDM_VOID); diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c deleted file mode 100644 index 392cc8a398f5..000000000000 --- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c +++ /dev/null @@ -1,130 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" - -/* This function is for inband noise test utility only */ -/* To obtain the inband noise level(dbm), do the following. */ -/* 1. disable DIG and Power Saving */ -/* 2. Set initial gain = 0x1a */ -/* 3. Stop updating idle time pwer report (for driver read) */ -/* - 0x80c[25] */ - -#define Valid_Min -35 -#define Valid_Max 10 -#define ValidCnt 5 - -static s16 odm_InbandNoise_Monitor_NSeries( - struct dm_odm_t *pDM_Odm, - u8 bPauseDIG, - u8 IGIValue, - u32 max_time -) -{ - u32 tmp4b; - u8 max_rf_path = 0, rf_path; - u8 reg_c50, reg_c58, valid_done = 0; - struct noise_level noise_data; - u32 start = 0; - - pDM_Odm->noise_level.noise_all = 0; - - max_rf_path = 1; - - memset(&noise_data, 0, sizeof(struct noise_level)); - - /* */ - /* Step 1. Disable DIG && Set initial gain. */ - /* */ - - if (bPauseDIG) - odm_PauseDIG(pDM_Odm, ODM_PAUSE_DIG, IGIValue); - /* */ - /* Step 2. Disable all power save for read registers */ - /* */ - /* dcmd_DebugControlPowerSave(padapter, PSDisable); */ - - /* */ - /* Step 3. Get noise power level */ - /* */ - start = jiffies; - while (1) { - - /* Stop updating idle time pwer report (for driver read) */ - PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_TxGainStage, BIT25, 1); - - /* Read Noise Floor Report */ - tmp4b = PHY_QueryBBReg(pDM_Odm->Adapter, 0x8f8, bMaskDWord); - - /* PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XAAGCCore1, bMaskByte0, TestInitialGain); */ - /* if (max_rf_path == 2) */ - /* PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XBAGCCore1, bMaskByte0, TestInitialGain); */ - - /* update idle time pwer report per 5us */ - PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_TxGainStage, BIT25, 0); - - noise_data.value[RF_PATH_A] = (u8)(tmp4b&0xff); - noise_data.value[RF_PATH_B] = (u8)((tmp4b&0xff00)>>8); - - for (rf_path = RF_PATH_A; rf_path < max_rf_path; rf_path++) { - noise_data.sval[rf_path] = (s8)noise_data.value[rf_path]; - noise_data.sval[rf_path] /= 2; - } - /* mdelay(10); */ - /* msleep(10); */ - - for (rf_path = RF_PATH_A; rf_path < max_rf_path; rf_path++) { - if ((noise_data.valid_cnt[rf_path] < ValidCnt) && (noise_data.sval[rf_path] < Valid_Max && noise_data.sval[rf_path] >= Valid_Min)) { - noise_data.valid_cnt[rf_path]++; - noise_data.sum[rf_path] += noise_data.sval[rf_path]; - if (noise_data.valid_cnt[rf_path] == ValidCnt) { - valid_done++; - } - - } - - } - - /* printk("####### valid_done:%d #############\n", valid_done); */ - if ((valid_done == max_rf_path) || (jiffies_to_msecs(jiffies - start) > max_time)) { - for (rf_path = RF_PATH_A; rf_path < max_rf_path; rf_path++) { - /* printk("%s PATH_%d - sum = %d, valid_cnt = %d\n", __func__, rf_path, noise_data.sum[rf_path], noise_data.valid_cnt[rf_path]); */ - if (noise_data.valid_cnt[rf_path]) - noise_data.sum[rf_path] /= noise_data.valid_cnt[rf_path]; - else - noise_data.sum[rf_path] = 0; - } - break; - } - } - reg_c50 = (s32)PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XAAGCCore1, bMaskByte0); - reg_c50 &= ~BIT7; - pDM_Odm->noise_level.noise[RF_PATH_A] = -110 + reg_c50 + noise_data.sum[RF_PATH_A]; - pDM_Odm->noise_level.noise_all += pDM_Odm->noise_level.noise[RF_PATH_A]; - - if (max_rf_path == 2) { - reg_c58 = (s32)PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XBAGCCore1, bMaskByte0); - reg_c58 &= ~BIT7; - pDM_Odm->noise_level.noise[RF_PATH_B] = -110 + reg_c58 + noise_data.sum[RF_PATH_B]; - pDM_Odm->noise_level.noise_all += pDM_Odm->noise_level.noise[RF_PATH_B]; - } - pDM_Odm->noise_level.noise_all /= max_rf_path; - - /* */ - /* Step 4. Recover the Dig */ - /* */ - if (bPauseDIG) - odm_PauseDIG(pDM_Odm, ODM_RESUME_DIG, IGIValue); - - return pDM_Odm->noise_level.noise_all; - -} - -s16 ODM_InbandNoise_Monitor(void *pDM_VOID, u8 bPauseDIG, u8 IGIValue, u32 max_time) -{ - return odm_InbandNoise_Monitor_NSeries(pDM_VOID, bPauseDIG, IGIValue, max_time); -} diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h deleted file mode 100644 index ab114543f39c..000000000000 --- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - *****************************************************************************/ -#ifndef __ODMNOISEMONITOR_H__ -#define __ODMNOISEMONITOR_H__ - -#define ODM_MAX_CHANNEL_NUM 38/* 14+24 */ -struct noise_level { - /* u8 value_a, value_b; */ - u8 value[MAX_RF_PATH]; - /* s8 sval_a, sval_b; */ - s8 sval[MAX_RF_PATH]; - - /* s32 noise_a = 0, noise_b = 0, sum_a = 0, sum_b = 0; */ - /* s32 noise[ODM_RF_PATH_MAX]; */ - s32 sum[MAX_RF_PATH]; - /* u8 valid_cnt_a = 0, valid_cnt_b = 0, */ - u8 valid[MAX_RF_PATH]; - u8 valid_cnt[MAX_RF_PATH]; - -}; - - -struct odm_noise_monitor { - s8 noise[MAX_RF_PATH]; - s16 noise_all; -}; - -s16 ODM_InbandNoise_Monitor( - void *pDM_VOID, - u8 bPauseDIG, - u8 IGIValue, - u32 max_time -); - -#endif diff --git a/drivers/staging/rtl8723bs/hal/odm_precomp.h b/drivers/staging/rtl8723bs/hal/odm_precomp.h index edce506022a5..2987857a8761 100644 --- a/drivers/staging/rtl8723bs/hal/odm_precomp.h +++ b/drivers/staging/rtl8723bs/hal/odm_precomp.h @@ -33,7 +33,6 @@ #include "odm_DynamicBBPowerSaving.h" #include "odm_DynamicTxPower.h" #include "odm_CfoTracking.h" -#include "odm_NoiseMonitor.h" #include "HalPhyRf.h" #include "HalPhyRf_8723B.h"/* for IQK, LCK, Power-tracking */ #include "rtl8723b_hal.h" diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index 0bbbdebdf157..82159e1c7f9b 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -50,7 +50,6 @@ #include <rtw_mlme_ext.h> #include <rtw_ap.h> #include <rtw_version.h> -#include <rtw_odm.h> #include "ioctl_cfg80211.h" @@ -493,8 +492,6 @@ static inline u8 *myid(struct eeprom_priv *peepriv) #include <rtw_btcoex.h> -int rtw_change_ifname(struct adapter *padapter, const char *ifname); - extern char *rtw_initmac; extern int rtw_mc2u_disable; extern int rtw_ht_enable; diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h index 78599d3521bf..fb167642da01 100644 --- a/drivers/staging/rtl8723bs/include/hal_btcoex.h +++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h @@ -45,7 +45,6 @@ void hal_btcoex_HaltNotify(struct adapter *padapter); void hal_btcoex_Handler(struct adapter *padapter); s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter); -void hal_btcoex_SetManualControl(struct adapter *padapter, u8 bmanual); bool hal_btcoex_IsBtControlLps(struct adapter *padapter); bool hal_btcoex_IsLpsOn(struct adapter *padapter); u8 hal_btcoex_RpwmVal(struct adapter *); diff --git a/drivers/staging/rtl8723bs/include/hal_com.h b/drivers/staging/rtl8723bs/include/hal_com.h index 7be0ea20bca4..6356b8c2ef81 100644 --- a/drivers/staging/rtl8723bs/include/hal_com.h +++ b/drivers/staging/rtl8723bs/include/hal_com.h @@ -147,17 +147,8 @@ u8 GetHalDefVar(struct adapter *adapter, enum hal_def_variable variable, bool eqNByte(u8 *str1, u8 *str2, u32 num); -bool IsHexDigit(char chTmp); - u32 MapCharToHexDigit(char chTmp); -bool GetHexValueFromString(char *szStr, u32 *pu4bVal, u32 *pu4bMove); - -bool GetFractionValueFromString(char *szStr, u8 *pInteger, u8 *pFraction, - u32 *pu4bMove); - -bool IsCommentString(char *szStr); - bool ParseQualifiedString(char *In, u32 *Start, char *Out, char LeftQualifier, char RightQualifier); diff --git a/drivers/staging/rtl8723bs/include/hal_intf.h b/drivers/staging/rtl8723bs/include/hal_intf.h index 45bebbadb7ca..5cffab2d06ff 100644 --- a/drivers/staging/rtl8723bs/include/hal_intf.h +++ b/drivers/staging/rtl8723bs/include/hal_intf.h @@ -353,8 +353,6 @@ bool rtw_hal_c2h_valid(struct adapter *adapter, u8 *buf); s32 rtw_hal_c2h_handler(struct adapter *adapter, u8 *c2h_evt); c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter); -s32 rtw_hal_is_disable_sw_channel_plan(struct adapter *padapter); - s32 rtw_hal_macid_sleep(struct adapter *padapter, u32 macid); s32 rtw_hal_macid_wakeup(struct adapter *padapter, u32 macid); diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 1e627dc0044d..9041d8dc5fb1 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -746,7 +746,6 @@ int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwi void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); -u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr); u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content); diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h index 1bf030cbbbbe..fe1b03101203 100644 --- a/drivers/staging/rtl8723bs/include/rtw_cmd.h +++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h @@ -591,7 +591,6 @@ extern u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 extern u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork); u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue); extern u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infrastructure networktype, bool enqueue); -extern u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset); extern u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode); extern u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset, u8 *pval); @@ -613,8 +612,6 @@ extern u8 rtw_ps_cmd(struct adapter *padapter); u8 rtw_chk_hi_queue_cmd(struct adapter *padapter); -extern u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconfig); - extern u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length); extern u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt); diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h index 89b389d4c44b..65e138a5238f 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -662,7 +662,6 @@ extern void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint extern u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer); int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset); -int rtw_get_ch_setting_union(struct adapter *adapter, u8 *ch, u8 *bw, u8 *offset); struct cmd_hdl { uint parmsize; diff --git a/drivers/staging/rtl8723bs/include/rtw_odm.h b/drivers/staging/rtl8723bs/include/rtw_odm.h deleted file mode 100644 index 94fc68a5c424..000000000000 --- a/drivers/staging/rtl8723bs/include/rtw_odm.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2013 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_ODM_H__ -#define __RTW_ODM_H__ - -#include <drv_types.h> - -/* -* This file provides utilities/wrappers for rtw driver to use ODM -*/ - -void rtw_odm_dbg_comp_msg(struct adapter *adapter); -void rtw_odm_dbg_comp_set(struct adapter *adapter, u64 comps); -void rtw_odm_dbg_level_msg(void *sel, struct adapter *adapter); -void rtw_odm_dbg_level_set(struct adapter *adapter, u32 level); - -void rtw_odm_ability_msg(void *sel, struct adapter *adapter); -void rtw_odm_ability_set(struct adapter *adapter, u32 ability); - -void rtw_odm_adaptivity_parm_msg(void *sel, struct adapter *adapter); -void rtw_odm_adaptivity_parm_set(struct adapter *adapter, s8 TH_L2H_ini, s8 TH_EDCCA_HL_diff, - s8 IGI_Base, bool ForceEDCCA, u8 AdapEn_RSSI, u8 IGI_LowerBound); -void rtw_odm_get_perpkt_rssi(void *sel, struct adapter *adapter); -#endif /* __RTW_ODM_H__ */ diff --git a/drivers/staging/rtl8723bs/include/xmit_osdep.h b/drivers/staging/rtl8723bs/include/xmit_osdep.h index e781cd5dfd01..8704dced593a 100644 --- a/drivers/staging/rtl8723bs/include/xmit_osdep.h +++ b/drivers/staging/rtl8723bs/include/xmit_osdep.h @@ -25,8 +25,8 @@ struct sta_xmit_priv; struct xmit_frame; struct xmit_buf; -extern int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); -extern int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); +extern void _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); +extern netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); void rtw_os_xmit_schedule(struct adapter *padapter); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 2d09be6425d5..6aeb169c6ebf 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -198,7 +198,7 @@ static int rtw_ieee80211_channel_to_frequency(int chan, int band) if (band == NL80211_BAND_2GHZ) { if (chan == 14) return 2484; - else if (chan < 14) + else if (chan < 14) return 2407 + chan * 5; } @@ -810,7 +810,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); - padapter->securitypriv.binstallGrpkey = true; + padapter->securitypriv.binstallGrpkey = true; padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1, true); @@ -920,9 +920,9 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, ret = rtw_cfg80211_ap_set_encryption(ndev, param, param_len); } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true - || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { - ret = rtw_cfg80211_set_encryption(ndev, param, param_len); - } + || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + ret = rtw_cfg80211_set_encryption(ndev, param, param_len); + } addkey_end: kfree(param); @@ -1066,7 +1066,7 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, } } - if (_FAIL == rtw_pwr_wakeup(padapter)) { + if (rtw_pwr_wakeup(padapter) == _FAIL) { ret = -EPERM; goto exit; } @@ -1240,7 +1240,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy } rtw_ps_deny(padapter, PS_DENY_SCAN); - if (_FAIL == rtw_pwr_wakeup(padapter)) { + if (rtw_pwr_wakeup(padapter) == _FAIL) { need_indicate_scan_done = true; goto check_need_indicate_scan_done; } @@ -1500,49 +1500,49 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel pairwise_cipher = WPA_CIPHER_NONE; switch (group_cipher) { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot118021XGrpPrivacy = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; + case WPA_CIPHER_NONE: + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot118021XGrpPrivacy = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; } switch (pairwise_cipher) { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; + case WPA_CIPHER_NONE: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; } {/* handle wps_ie */ @@ -1583,7 +1583,7 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int ret = 0; - if (_FAIL == rtw_pwr_wakeup(padapter)) { + if (rtw_pwr_wakeup(padapter) == _FAIL) { ret = -EPERM; goto exit; } @@ -1674,7 +1674,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, } rtw_ps_deny(padapter, PS_DENY_JOIN); - if (_FAIL == rtw_pwr_wakeup(padapter)) { + if (rtw_pwr_wakeup(padapter) == _FAIL) { ret = -EPERM; goto exit; } @@ -1849,6 +1849,7 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy, inline bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter) { struct rtw_wdev_priv *rtw_wdev_priv = adapter_wdev_data(adapter); + return rtw_wdev_priv->power_mgmt; } @@ -1954,6 +1955,7 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, { struct station_info sinfo = {}; u8 ie_offset; + if (GetFrameSubType(pmgmt_frame) == WIFI_ASSOCREQ) ie_offset = _ASOCREQ_IE_OFFSET_; else /* WIFI_REASSOCREQ */ @@ -2085,7 +2087,8 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc memcpy(pdata + sizeof(dst_mac_addr), src_mac_addr, sizeof(src_mac_addr)); /* Use the real net device to transmit the packet */ - return _rtw_xmit_entry(skb, padapter->pnetdev); + _rtw_xmit_entry(skb, padapter->pnetdev); + return NETDEV_TX_OK; } else if ((frame_control & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)) == (IEEE80211_FTYPE_MGMT|IEEE80211_STYPE_ACTION)) { @@ -2348,7 +2351,7 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, - struct cfg80211_beacon_data *info) + struct cfg80211_beacon_data *info) { struct adapter *adapter = rtw_netdev_priv(ndev); @@ -2467,7 +2470,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *nde spin_lock_bh(&pstapriv->asoc_list_lock); psta = rtw_sta_info_get_by_idx(idx, pstapriv); spin_unlock_bh(&pstapriv->asoc_list_lock); - if (NULL == psta) { + if (psta == NULL) { ret = -ENOENT; goto exit; } @@ -2602,7 +2605,7 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, goto exit; rtw_ps_deny(padapter, PS_DENY_MGNT_TX); - if (_FAIL == rtw_pwr_wakeup(padapter)) { + if (rtw_pwr_wakeup(padapter) == _FAIL) { ret = -EFAULT; goto cancel_ps_deny; } diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 380d8c9e1239..68bba3c0e757 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -664,51 +664,36 @@ void rtw_reset_drv_sw(struct adapter *padapter) u8 rtw_init_drv_sw(struct adapter *padapter) { - u8 ret8 = _SUCCESS; - rtw_init_default_value(padapter); rtw_init_hal_com_default_value(padapter); - if (rtw_init_cmd_priv(&padapter->cmdpriv)) { - ret8 = _FAIL; - goto exit; - } + if (rtw_init_cmd_priv(&padapter->cmdpriv)) + return _FAIL; padapter->cmdpriv.padapter = padapter; - if (rtw_init_evt_priv(&padapter->evtpriv)) { - ret8 = _FAIL; - goto exit; - } + if (rtw_init_evt_priv(&padapter->evtpriv)) + goto free_cmd_priv; - - if (rtw_init_mlme_priv(padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } + if (rtw_init_mlme_priv(padapter) == _FAIL) + goto free_evt_priv; init_mlme_ext_priv(padapter); - if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } + if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) + goto free_mlme_ext; - if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } + if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) + goto free_xmit_priv; /* add for CONFIG_IEEE80211W, none 11w also can use */ spin_lock_init(&padapter->security_key_mutex); /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ /* memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); */ - if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) { - ret8 = _FAIL; - goto exit; - } + if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) + goto free_recv_priv; padapter->stapriv.padapter = padapter; padapter->setband = GHZ24_50; @@ -719,9 +704,26 @@ u8 rtw_init_drv_sw(struct adapter *padapter) rtw_hal_dm_init(padapter); -exit: + return _SUCCESS; + +free_recv_priv: + _rtw_free_recv_priv(&padapter->recvpriv); + +free_xmit_priv: + _rtw_free_xmit_priv(&padapter->xmitpriv); + +free_mlme_ext: + free_mlme_ext_priv(&padapter->mlmeextpriv); - return ret8; + rtw_free_mlme_priv(&padapter->mlmepriv); + +free_evt_priv: + rtw_free_evt_priv(&padapter->evtpriv); + +free_cmd_priv: + rtw_free_cmd_priv(&padapter->cmdpriv); + + return _FAIL; } void rtw_cancel_all_timer(struct adapter *padapter) diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 4fbfa75c05d7..f09c1324c39c 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -108,56 +108,6 @@ RETURN: return; } -int rtw_change_ifname(struct adapter *padapter, const char *ifname) -{ - struct net_device *pnetdev; - struct net_device *cur_pnetdev; - struct rereg_nd_name_data *rereg_priv; - int ret; - - if (!padapter) - goto error; - - cur_pnetdev = padapter->pnetdev; - rereg_priv = &padapter->rereg_nd_name_priv; - - /* free the old_pnetdev */ - if (rereg_priv->old_pnetdev) { - free_netdev(rereg_priv->old_pnetdev); - rereg_priv->old_pnetdev = NULL; - } - - if (!rtnl_is_locked()) - unregister_netdev(cur_pnetdev); - else - unregister_netdevice(cur_pnetdev); - - rereg_priv->old_pnetdev = cur_pnetdev; - - pnetdev = rtw_init_netdev(padapter); - if (!pnetdev) - goto error; - - SET_NETDEV_DEV(pnetdev, dvobj_to_dev(adapter_to_dvobj(padapter))); - - rtw_init_netdev_name(pnetdev, ifname); - - eth_hw_addr_set(pnetdev, padapter->eeprompriv.mac_addr); - - if (!rtnl_is_locked()) - ret = register_netdev(pnetdev); - else - ret = register_netdevice(pnetdev); - - if (ret != 0) - goto error; - - return 0; - -error: - return -1; -} - void rtw_buf_free(u8 **buf, u32 *buf_len) { if (!buf || !buf_len) diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index 530e7a6c67c5..1eeabfffd6d2 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -181,7 +181,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) return true; } -int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) +void _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) { struct adapter *padapter = rtw_netdev_priv(pnetdev); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -202,7 +202,7 @@ int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) { res = rtw_mlcst2unicst(padapter, pkt); if (res) - goto exit; + return; } } @@ -210,22 +210,17 @@ int _rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) if (res < 0) goto drop_packet; - goto exit; + return; drop_packet: pxmitpriv->tx_drop++; dev_kfree_skb_any(pkt); - -exit: - return 0; } -int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) +netdev_tx_t rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) { - int ret = 0; - if (pkt) - ret = _rtw_xmit_entry(pkt, pnetdev); + _rtw_xmit_entry(pkt, pnetdev); - return ret; + return NETDEV_TX_OK; } diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index ce04c38f6afd..168ae2e9005d 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -387,7 +387,8 @@ static int lynxfb_ops_set_par(struct fb_info *info) ret = lynxfb_set_color_offsets(info); - var->height = var->width = -1; + var->height = -1; + var->width = -1; var->accel_flags = 0;/*FB_ACCELF_TEXT;*/ if (ret) { @@ -499,7 +500,8 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var, return ret; } - var->height = var->width = -1; + var->height = -1; + var->width = -1; var->accel_flags = 0;/* FB_ACCELF_TEXT; */ /* check if current fb's video memory big enough to hold the onscreen*/ @@ -724,7 +726,8 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) 0x800f0 + (int)crtc->channel * 0x140; pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio); - crtc->cursor.max_h = crtc->cursor.max_w = 64; + crtc->cursor.max_h = 64; + crtc->cursor.max_w = 64; crtc->cursor.size = crtc->cursor.max_h * crtc->cursor.max_w * 2 / 8; crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset; @@ -1022,7 +1025,8 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, if (!sm750_dev) return err; - sm750_dev->fbinfo[0] = sm750_dev->fbinfo[1] = NULL; + sm750_dev->fbinfo[0] = NULL; + sm750_dev->fbinfo[1] = NULL; sm750_dev->devid = pdev->device; sm750_dev->revid = pdev->revision; sm750_dev->pdev = pdev; diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c index 956476213241..020e0b3bce64 100644 --- a/drivers/staging/vme_user/vme_tsi148.c +++ b/drivers/staging/vme_user/vme_tsi148.c @@ -125,8 +125,8 @@ static u32 tsi148_MB_irqhandler(struct vme_bridge *tsi148_bridge, u32 stat) for (i = 0; i < 4; i++) { if (stat & TSI148_LCSR_INTS_MBS[i]) { val = ioread32be(bridge->base + TSI148_GCSR_MBOX[i]); - dev_err(tsi148_bridge->parent, "VME Mailbox %d received" - ": 0x%x\n", i, val); + dev_err(tsi148_bridge->parent, "VME Mailbox %d received: 0x%x\n", + i, val); serviced |= TSI148_LCSR_INTC_MBC[i]; } } @@ -143,14 +143,12 @@ static u32 tsi148_PERR_irqhandler(struct vme_bridge *tsi148_bridge) bridge = tsi148_bridge->driver_priv; - dev_err(tsi148_bridge->parent, "PCI Exception at address: 0x%08x:%08x, " - "attributes: %08x\n", + dev_err(tsi148_bridge->parent, "PCI Exception at address: 0x%08x:%08x, attributes: %08x\n", ioread32be(bridge->base + TSI148_LCSR_EDPAU), ioread32be(bridge->base + TSI148_LCSR_EDPAL), ioread32be(bridge->base + TSI148_LCSR_EDPAT)); - dev_err(tsi148_bridge->parent, "PCI-X attribute reg: %08x, PCI-X split " - "completion reg: %08x\n", + dev_err(tsi148_bridge->parent, "PCI-X attribute reg: %08x, PCI-X split completion reg: %08x\n", ioread32be(bridge->base + TSI148_LCSR_EDPXA), ioread32be(bridge->base + TSI148_LCSR_EDPXS)); @@ -180,10 +178,8 @@ static u32 tsi148_VERR_irqhandler(struct vme_bridge *tsi148_bridge) reg_join(error_addr_high, error_addr_low, &error_addr); /* Check for exception register overflow (we have lost error data) */ - if (error_attrib & TSI148_LCSR_VEAT_VEOF) { - dev_err(tsi148_bridge->parent, "VME Bus Exception Overflow " - "Occurred\n"); - } + if (error_attrib & TSI148_LCSR_VEAT_VEOF) + dev_err(tsi148_bridge->parent, "VME Bus Exception Overflow Occurred\n"); if (err_chk) vme_bus_error_handler(tsi148_bridge, error_addr, error_am); @@ -317,8 +313,8 @@ static int tsi148_irq_init(struct vme_bridge *tsi148_bridge) IRQF_SHARED, driver_name, tsi148_bridge); if (result) { - dev_err(tsi148_bridge->parent, "Can't get assigned pci irq " - "vector %02X\n", pdev->irq); + dev_err(tsi148_bridge->parent, "Can't get assigned pci irq vector %02X\n", + pdev->irq); return result; } @@ -529,8 +525,7 @@ static int tsi148_slave_set(struct vme_slave_resource *image, int enabled, return -EINVAL; } if (pci_offset_low & (granularity - 1)) { - dev_err(tsi148_bridge->parent, "Invalid PCI Offset " - "alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI Offset alignment\n"); return -EINVAL; } @@ -588,7 +583,7 @@ static int tsi148_slave_set(struct vme_slave_resource *image, int enabled, temp_ctl &= ~0xF; if (cycle & VME_SUPER) - temp_ctl |= TSI148_LCSR_ITAT_SUPR ; + temp_ctl |= TSI148_LCSR_ITAT_SUPR; if (cycle & VME_USER) temp_ctl |= TSI148_LCSR_ITAT_NPRIV; if (cycle & VME_PROG) @@ -762,8 +757,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, &image->bus_resource, size, 0x10000, PCIBIOS_MIN_MEM, 0, NULL, NULL); if (retval) { - dev_err(tsi148_bridge->parent, "Failed to allocate mem " - "resource for window %d size 0x%lx start 0x%lx\n", + dev_err(tsi148_bridge->parent, "Failed to allocate mem resource for window %d size 0x%lx start 0x%lx\n", image->number, (unsigned long)size, (unsigned long)image->bus_resource.start); goto err_resource; @@ -827,15 +821,13 @@ static int tsi148_master_set(struct vme_master_resource *image, int enabled, /* Verify input data */ if (vme_base & 0xFFFF) { - dev_err(tsi148_bridge->parent, "Invalid VME Window " - "alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME Window alignment\n"); retval = -EINVAL; goto err_window; } if ((size == 0) && (enabled != 0)) { - dev_err(tsi148_bridge->parent, "Size must be non-zero for " - "enabled windows\n"); + dev_err(tsi148_bridge->parent, "Size must be non-zero for enabled windows\n"); retval = -EINVAL; goto err_window; } @@ -849,8 +841,7 @@ static int tsi148_master_set(struct vme_master_resource *image, int enabled, retval = tsi148_alloc_resource(image, size); if (retval) { spin_unlock(&image->lock); - dev_err(tsi148_bridge->parent, "Unable to allocate memory for " - "resource\n"); + dev_err(tsi148_bridge->parent, "Unable to allocate memory for resource\n"); goto err_res; } @@ -890,8 +881,7 @@ static int tsi148_master_set(struct vme_master_resource *image, int enabled, } if (vme_offset_low & 0xFFFF) { spin_unlock(&image->lock); - dev_err(tsi148_bridge->parent, "Invalid VME Offset " - "alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME Offset alignment\n"); retval = -EINVAL; goto err_gran; } @@ -937,8 +927,7 @@ static int tsi148_master_set(struct vme_master_resource *image, int enabled, temp_ctl |= TSI148_LCSR_OTAT_TM_2eSST; } if (cycle & VME_2eSSTB) { - dev_warn(tsi148_bridge->parent, "Currently not setting " - "Broadcast Select Registers\n"); + dev_warn(tsi148_bridge->parent, "Currently not setting Broadcast Select Registers\n"); temp_ctl &= ~TSI148_LCSR_OTAT_TM_M; temp_ctl |= TSI148_LCSR_OTAT_TM_2eSSTB; } @@ -1451,8 +1440,7 @@ static int tsi148_dma_set_vme_src_attributes(struct device *dev, __be32 *attr, val |= TSI148_LCSR_DSAT_TM_2eSST; if (cycle & VME_2eSSTB) { - dev_err(dev, "Currently not setting Broadcast Select " - "Registers\n"); + dev_err(dev, "Currently not setting Broadcast Select Registers\n"); val |= TSI148_LCSR_DSAT_TM_2eSSTB; } @@ -1550,8 +1538,7 @@ static int tsi148_dma_set_vme_dest_attributes(struct device *dev, __be32 *attr, val |= TSI148_LCSR_DDAT_TM_2eSST; if (cycle & VME_2eSSTB) { - dev_err(dev, "Currently not setting Broadcast Select " - "Registers\n"); + dev_err(dev, "Currently not setting Broadcast Select Registers\n"); val |= TSI148_LCSR_DDAT_TM_2eSSTB; } @@ -1639,8 +1626,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, /* Test descriptor alignment */ if ((unsigned long)&entry->descriptor & 0x7) { - dev_err(tsi148_bridge->parent, "Descriptor not aligned to 8 " - "byte boundary as required: %p\n", + dev_err(tsi148_bridge->parent, "Descriptor not aligned to 8 byte boundary as required: %p\n", &entry->descriptor); retval = -EINVAL; goto err_align; @@ -1827,10 +1813,10 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list) /* Need to add to pending here */ mutex_unlock(&ctrlr->mtx); return -EBUSY; - } else { - list_add(&list->list, &ctrlr->running); } + list_add(&list->list, &ctrlr->running); + /* Get first bus address and write into registers */ entry = list_first_entry(&list->entries, struct tsi148_dma_entry, list); @@ -1935,8 +1921,7 @@ static int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, for (i = 0; i < lm->monitors; i++) { if (bridge->lm_callback[i]) { mutex_unlock(&lm->mtx); - dev_err(tsi148_bridge->parent, "Location monitor " - "callback attached, can't reset\n"); + dev_err(tsi148_bridge->parent, "Location monitor callback attached, can't reset\n"); return -EBUSY; } } @@ -1961,7 +1946,7 @@ static int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, } if (cycle & VME_SUPER) - lm_ctl |= TSI148_LCSR_LMAT_SUPR ; + lm_ctl |= TSI148_LCSR_LMAT_SUPR; if (cycle & VME_USER) lm_ctl |= TSI148_LCSR_LMAT_NPRIV; if (cycle & VME_PROG) @@ -2051,8 +2036,7 @@ static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, lm_ctl = ioread32be(bridge->base + TSI148_LCSR_LMAT); if ((lm_ctl & (TSI148_LCSR_LMAT_PGM | TSI148_LCSR_LMAT_DATA)) == 0) { mutex_unlock(&lm->mtx); - dev_err(tsi148_bridge->parent, "Location monitor not properly " - "configured\n"); + dev_err(tsi148_bridge->parent, "Location monitor not properly configured\n"); return -EINVAL; } @@ -2196,8 +2180,7 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, VME_CRCSR_BUF_SIZE, &bridge->crcsr_bus, GFP_KERNEL); if (!bridge->crcsr_kernel) { - dev_err(tsi148_bridge->parent, "Failed to allocate memory for " - "CR/CSR image\n"); + dev_err(tsi148_bridge->parent, "Failed to allocate memory for CR/CSR image\n"); return -ENOMEM; } @@ -2237,8 +2220,7 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, (vstat * 0x80000), 0x80000, VME_CRCSR, VME_SCT, VME_D16); if (retval) - dev_err(tsi148_bridge->parent, "Configuring flush image" - " failed\n"); + dev_err(tsi148_bridge->parent, "Configuring flush image failed\n"); } return 0; diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 5de841cb776c..6ce41983dcf4 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -2083,7 +2083,7 @@ bool bb_vt3253_init(struct vnt_private *priv) priv->dbm_threshold[2] = 0; priv->dbm_threshold[3] = 0; /* Fix VT3226 DFC system timing issue */ - MACvSetRFLE_LatchBase(iobase); + vt6655_mac_word_reg_bits_on(iobase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT); /* {{ RobertYu: 20050104 */ } else { /* No VGA Table now */ diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 846469cc06bb..c680925b9c92 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -55,9 +55,15 @@ static const unsigned short cwRXBCNTSFOff[MAX_RATE] = { /*--------------------- Static Functions --------------------------*/ -static void s_vCalculateOFDMRParameter(unsigned char rate, u8 bb_type, - unsigned char *pbyTxRate, - unsigned char *pbyRsvTime); +static void vt6655_mac_set_bb_type(void __iomem *iobase, u32 mask) +{ + u32 reg_value; + + reg_value = ioread32(iobase + MAC_REG_ENCFG); + reg_value = reg_value & ~ENCFG_BBTYPE_MASK; + reg_value = reg_value | mask; + iowrite32(reg_value, iobase + MAC_REG_ENCFG); +} /*--------------------- Export Functions --------------------------*/ @@ -186,21 +192,21 @@ bool CARDbSetPhyParameter(struct vnt_private *priv, u8 bb_type) /* Set SIFS, DIFS, EIFS, SlotTime, CwMin */ if (bb_type == BB_TYPE_11A) { - MACvSetBBType(priv->port_offset, BB_TYPE_11A); + vt6655_mac_set_bb_type(priv->port_offset, BB_TYPE_11A); bb_write_embedded(priv, 0x88, 0x03); bySlot = C_SLOT_SHORT; bySIFS = C_SIFS_A; byDIFS = C_SIFS_A + 2 * C_SLOT_SHORT; byCWMaxMin = 0xA4; } else if (bb_type == BB_TYPE_11B) { - MACvSetBBType(priv->port_offset, BB_TYPE_11B); + vt6655_mac_set_bb_type(priv->port_offset, BB_TYPE_11B); bb_write_embedded(priv, 0x88, 0x02); bySlot = C_SLOT_LONG; bySIFS = C_SIFS_BG; byDIFS = C_SIFS_BG + 2 * C_SLOT_LONG; byCWMaxMin = 0xA5; } else { /* PK_TYPE_11GA & PK_TYPE_11GB */ - MACvSetBBType(priv->port_offset, BB_TYPE_11G); + vt6655_mac_set_bb_type(priv->port_offset, BB_TYPE_11G); bb_write_embedded(priv, 0x88, 0x08); bySIFS = C_SIFS_BG; @@ -403,9 +409,9 @@ void CARDvSafeResetTx(struct vnt_private *priv) } /* set MAC TD pointer */ - MACvSetCurrTXDescAddr(TYPE_TXDMA0, priv, priv->td0_pool_dma); + vt6655_mac_set_curr_tx_desc_addr(TYPE_TXDMA0, priv, priv->td0_pool_dma); - MACvSetCurrTXDescAddr(TYPE_AC0DMA, priv, priv->td1_pool_dma); + vt6655_mac_set_curr_tx_desc_addr(TYPE_AC0DMA, priv, priv->td1_pool_dma); /* set MAC Beacon TX pointer */ iowrite32((u32)priv->tx_beacon_dma, priv->port_offset + MAC_REG_BCNDMAPTR); @@ -452,9 +458,9 @@ void CARDvSafeResetRx(struct vnt_private *priv) iowrite32(RX_PERPKT, priv->port_offset + MAC_REG_RXDMACTL0); iowrite32(RX_PERPKT, priv->port_offset + MAC_REG_RXDMACTL1); /* set MAC RD pointer */ - MACvSetCurrRx0DescAddr(priv, priv->rd0_pool_dma); + vt6655_mac_set_curr_rx_0_desc_addr(priv, priv->rd0_pool_dma); - MACvSetCurrRx1DescAddr(priv, priv->rd1_pool_dma); + vt6655_mac_set_curr_rx_1_desc_addr(priv, priv->rd1_pool_dma); } /* @@ -539,7 +545,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) spin_lock_irqsave(&priv->lock, flags); /* Set to Page1 */ - MACvSelectPage1(priv->port_offset); + VT6655_MAC_SELECT_PAGE1(priv->port_offset); /* RSPINF_b_1 */ vnt_get_phy_field(priv, 14, @@ -637,7 +643,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_72); /* Set to Page0 */ - MACvSelectPage0(priv->port_offset); + VT6655_MAC_SELECT_PAGE0(priv->port_offset); spin_unlock_irqrestore(&priv->lock, flags); } diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index e926f9829a15..4122875ebcaa 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -116,12 +116,12 @@ bool set_channel(struct vnt_private *priv, struct ieee80211_channel *ch) spin_lock_irqsave(&priv->lock, flags); /* set HW default power register */ - MACvSelectPage1(priv->port_offset); + VT6655_MAC_SELECT_PAGE1(priv->port_offset); RFbSetPower(priv, RATE_1M, priv->byCurrentCh); iowrite8(priv->byCurPwr, priv->port_offset + MAC_REG_PWRCCK); RFbSetPower(priv, RATE_6M, priv->byCurrentCh); iowrite8(priv->byCurPwr, priv->port_offset + MAC_REG_PWROFDM); - MACvSelectPage0(priv->port_offset); + VT6655_MAC_SELECT_PAGE0(priv->port_offset); spin_unlock_irqrestore(&priv->lock, flags); } diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index bab08a40fe66..56c3cf3ba53d 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -205,6 +205,55 @@ static void vt6655_mac_read_ether_addr(void __iomem *iobase, u8 *mac_addr) iowrite8(0, iobase + MAC_REG_PAGE1SEL); } +static void vt6655_mac_dma_ctl(void __iomem *iobase, u8 reg_index) +{ + u32 reg_value; + + reg_value = ioread32(iobase + reg_index); + if (reg_value & DMACTL_RUN) + iowrite32(DMACTL_WAKE, iobase + reg_index); + else + iowrite32(DMACTL_RUN, iobase + reg_index); +} + +static void vt6655_mac_set_bits(void __iomem *iobase, u32 mask) +{ + u32 reg_value; + + reg_value = ioread32(iobase + MAC_REG_ENCFG); + reg_value = reg_value | mask; + iowrite32(reg_value, iobase + MAC_REG_ENCFG); +} + +static void vt6655_mac_clear_bits(void __iomem *iobase, u32 mask) +{ + u32 reg_value; + + reg_value = ioread32(iobase + MAC_REG_ENCFG); + reg_value = reg_value & ~mask; + iowrite32(reg_value, iobase + MAC_REG_ENCFG); +} + +static void vt6655_mac_en_protect_md(void __iomem *iobase) +{ + vt6655_mac_set_bits(iobase, ENCFG_PROTECTMD); +} + +static void vt6655_mac_dis_protect_md(void __iomem *iobase) +{ + vt6655_mac_clear_bits(iobase, ENCFG_PROTECTMD); +} + +static void vt6655_mac_en_barker_preamble_md(void __iomem *iobase) +{ + vt6655_mac_set_bits(iobase, ENCFG_BARKERPREAM); +} + +static void vt6655_mac_dis_barker_preamble_md(void __iomem *iobase) +{ + vt6655_mac_clear_bits(iobase, ENCFG_BARKERPREAM); +} + /* * Initialisation of MAC & BBP registers */ @@ -351,11 +400,11 @@ static void device_init_registers(struct vnt_private *priv) } if (priv->local_id > REV_ID_VT3253_B1) { - MACvSelectPage1(priv->port_offset); + VT6655_MAC_SELECT_PAGE1(priv->port_offset); iowrite8(MSRCTL1_TXPWR | MSRCTL1_CSAPAREN, priv->port_offset + MAC_REG_MSRCTL + 1); - MACvSelectPage0(priv->port_offset); + VT6655_MAC_SELECT_PAGE0(priv->port_offset); } /* use relative tx timeout and 802.11i D4 */ @@ -363,7 +412,7 @@ static void device_init_registers(struct vnt_private *priv) (CFG_TKIPOPT | CFG_NOTXTIMEOUT)); /* set performance parameter by registry */ - MACvSetShortRetryLimit(priv, priv->byShortRetryLimit); + vt6655_mac_set_short_retry_limit(priv, priv->byShortRetryLimit); MACvSetLongRetryLimit(priv, priv->byLongRetryLimit); /* reset TSF counter */ @@ -420,8 +469,8 @@ static void device_init_registers(struct vnt_private *priv) vt6655_mac_reg_bits_on(priv->port_offset, MAC_REG_RCR, RCR_WPAERR); /* Turn On Rx DMA */ - MACvReceive0(priv->port_offset); - MACvReceive1(priv->port_offset); + vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL0); + vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL1); /* start the adapter */ iowrite8(HOSTCR_MACEN | HOSTCR_RXON | HOSTCR_TXON, priv->port_offset + MAC_REG_HOSTCR); @@ -537,13 +586,12 @@ static void device_free_rings(struct vnt_private *priv) priv->opts.tx_descs[1] * sizeof(struct vnt_tx_desc), priv->aRD0Ring, priv->pool_dma); - if (priv->tx0_bufs) - dma_free_coherent(&priv->pcid->dev, - priv->opts.tx_descs[0] * PKT_BUF_SZ + - priv->opts.tx_descs[1] * PKT_BUF_SZ + - CB_BEACON_BUF_SIZE + - CB_MAX_BUF_SIZE, - priv->tx0_bufs, priv->tx_bufs_dma0); + dma_free_coherent(&priv->pcid->dev, + priv->opts.tx_descs[0] * PKT_BUF_SZ + + priv->opts.tx_descs[1] * PKT_BUF_SZ + + CB_BEACON_BUF_SIZE + + CB_MAX_BUF_SIZE, + priv->tx0_bufs, priv->tx_bufs_dma0); } static int device_init_rd0_ring(struct vnt_private *priv) @@ -583,7 +631,7 @@ err_free_rd: kfree(desc->rd_info); err_free_desc: - while (--i) { + while (i--) { desc = &priv->aRD0Ring[i]; device_free_rx_buf(priv, desc); kfree(desc->rd_info); @@ -629,7 +677,7 @@ err_free_rd: kfree(desc->rd_info); err_free_desc: - while (--i) { + while (i--) { desc = &priv->aRD1Ring[i]; device_free_rx_buf(priv, desc); kfree(desc->rd_info); @@ -694,7 +742,7 @@ static int device_init_td0_ring(struct vnt_private *priv) return 0; err_free_desc: - while (--i) { + while (i--) { desc = &priv->apTD0Rings[i]; kfree(desc->td_info); } @@ -734,7 +782,7 @@ static int device_init_td1_ring(struct vnt_private *priv) return 0; err_free_desc: - while (--i) { + while (i--) { desc = &priv->apTD1Rings[i]; kfree(desc->td_info); } @@ -1135,8 +1183,8 @@ static void vnt_interrupt_process(struct vnt_private *priv) isr = ioread32(priv->port_offset + MAC_REG_ISR); - MACvReceive0(priv->port_offset); - MACvReceive1(priv->port_offset); + vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL0); + vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_RXDMACTL1); if (max_count > priv->opts.int_works) break; @@ -1218,9 +1266,9 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) wmb(); /* second memory barrier */ if (head_td->td_info->flags & TD_FLAGS_NETIF_SKB) - MACvTransmitAC0(priv->port_offset); + vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_AC0DMACTL); else - MACvTransmit0(priv->port_offset); + vt6655_mac_dma_ctl(priv->port_offset, MAC_REG_TXDMACTL0); priv->iTDUsed[dma_idx]++; @@ -1440,19 +1488,19 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, if (changed & BSS_CHANGED_ERP_PREAMBLE) { if (conf->use_short_preamble) { - MACvEnableBarkerPreambleMd(priv->port_offset); + vt6655_mac_en_barker_preamble_md(priv->port_offset); priv->preamble_type = true; } else { - MACvDisableBarkerPreambleMd(priv->port_offset); + vt6655_mac_dis_barker_preamble_md(priv->port_offset); priv->preamble_type = false; } } if (changed & BSS_CHANGED_ERP_CTS_PROT) { if (conf->use_cts_prot) - MACvEnableProtectMD(priv->port_offset); + vt6655_mac_en_protect_md(priv->port_offset); else - MACvDisableProtectMD(priv->port_offset); + vt6655_mac_dis_protect_md(priv->port_offset); } if (changed & BSS_CHANGED_ERP_SLOT) { @@ -1538,21 +1586,21 @@ static void vnt_configure(struct ieee80211_hw *hw, spin_lock_irqsave(&priv->lock, flags); if (priv->mc_list_count > 2) { - MACvSelectPage1(priv->port_offset); + VT6655_MAC_SELECT_PAGE1(priv->port_offset); iowrite32(0xffffffff, priv->port_offset + MAC_REG_MAR0); iowrite32(0xffffffff, priv->port_offset + MAC_REG_MAR0 + 4); - MACvSelectPage0(priv->port_offset); + VT6655_MAC_SELECT_PAGE0(priv->port_offset); } else { - MACvSelectPage1(priv->port_offset); + VT6655_MAC_SELECT_PAGE1(priv->port_offset); multicast = le64_to_cpu(multicast); iowrite32((u32)multicast, priv->port_offset + MAC_REG_MAR0); iowrite32((u32)(multicast >> 32), priv->port_offset + MAC_REG_MAR0 + 4); - MACvSelectPage0(priv->port_offset); + VT6655_MAC_SELECT_PAGE0(priv->port_offset); } spin_unlock_irqrestore(&priv->lock, flags); diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index dcc649532737..b4ebc7d31961 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -10,17 +10,16 @@ * Date: May 21, 1996 * * Functions: - * MACbIsRegBitsOff - Test if All test Bits Off - * MACbIsIntDisable - Test if MAC interrupt disable - * MACvSetShortRetryLimit - Set 802.11 Short Retry limit + * vt6655_mac_is_reg_bits_off - Test if All test Bits Off + * vt6655_mac_set_short_retry_limit - Set 802.11 Short Retry limit * MACvSetLongRetryLimit - Set 802.11 Long Retry limit - * MACvSetLoopbackMode - Set MAC Loopback Mode - * MACvSaveContext - Save Context of MAC Registers - * MACvRestoreContext - Restore Context of MAC Registers + * vt6655_mac_set_loopback_mode - Set MAC Loopback Mode + * vt6655_mac_save_context - Save Context of MAC Registers + * vt6655_mac_restore_context - Restore Context of MAC Registers * MACbSoftwareReset - Software Reset MAC - * MACbSafeRxOff - Turn Off MAC Rx - * MACbSafeTxOff - Turn Off MAC Tx - * MACbSafeStop - Stop MAC function + * vt6655_mac_safe_rx_off - Turn Off MAC Rx + * vt6655_mac_safe_tx_off - Turn Off MAC Tx + * vt6655_mac_safe_stop - Stop MAC function * MACbShutdown - Shut down MAC * MACvInitialize - Initialize MAC * MACvSetCurrRxDescAddr - Set Rx Descriptors Address @@ -86,43 +85,21 @@ static void vt6655_mac_clear_stck_ds(void __iomem *iobase) * Parameters: * In: * io_base - Base Address for MAC - * byRegOfs - Offset of MAC Register - * byTestBits - Test bits + * reg_offset - Offset of MAC Register + * mask - Test bits * Out: * none * * Return Value: true if all test bits Off; otherwise false * */ -bool MACbIsRegBitsOff(struct vnt_private *priv, unsigned char byRegOfs, - unsigned char byTestBits) +static bool vt6655_mac_is_reg_bits_off(struct vnt_private *priv, + unsigned char reg_offset, + unsigned char mask) { void __iomem *io_base = priv->port_offset; - return !(ioread8(io_base + byRegOfs) & byTestBits); -} - -/* - * Description: - * Test if MAC interrupt disable - * - * Parameters: - * In: - * io_base - Base Address for MAC - * Out: - * none - * - * Return Value: true if interrupt is disable; otherwise false - * - */ -bool MACbIsIntDisable(struct vnt_private *priv) -{ - void __iomem *io_base = priv->port_offset; - - if (ioread32(io_base + MAC_REG_IMR)) - return false; - - return true; + return !(ioread8(io_base + reg_offset) & mask); } /* @@ -132,19 +109,18 @@ bool MACbIsIntDisable(struct vnt_private *priv) * Parameters: * In: * io_base - Base Address for MAC - * byRetryLimit- Retry Limit + * retry_limit - Retry Limit * Out: * none * * Return Value: none * */ -void MACvSetShortRetryLimit(struct vnt_private *priv, - unsigned char byRetryLimit) +void vt6655_mac_set_short_retry_limit(struct vnt_private *priv, unsigned char retry_limit) { void __iomem *io_base = priv->port_offset; /* set SRT */ - iowrite8(byRetryLimit, io_base + MAC_REG_SRT); + iowrite8(retry_limit, io_base + MAC_REG_SRT); } /* @@ -176,21 +152,20 @@ void MACvSetLongRetryLimit(struct vnt_private *priv, * Parameters: * In: * io_base - Base Address for MAC - * byLoopbackMode - Loopback Mode + * loopback_mode - Loopback Mode * Out: * none * * Return Value: none * */ -void MACvSetLoopbackMode(struct vnt_private *priv, unsigned char byLoopbackMode) +static void vt6655_mac_set_loopback_mode(struct vnt_private *priv, u8 loopback_mode) { void __iomem *io_base = priv->port_offset; - byLoopbackMode <<= 6; + loopback_mode <<= 6; /* set TCR */ - iowrite8((ioread8(io_base + MAC_REG_TEST) & 0x3f) | byLoopbackMode, - io_base + MAC_REG_TEST); + iowrite8((ioread8(io_base + MAC_REG_TEST) & 0x3f) | loopback_mode, io_base + MAC_REG_TEST); } /* @@ -206,20 +181,20 @@ void MACvSetLoopbackMode(struct vnt_private *priv, unsigned char byLoopbackMode) * Return Value: none * */ -void MACvSaveContext(struct vnt_private *priv, unsigned char *cxt_buf) +static void vt6655_mac_save_context(struct vnt_private *priv, u8 *cxt_buf) { void __iomem *io_base = priv->port_offset; /* read page0 register */ memcpy_fromio(cxt_buf, io_base, MAC_MAX_CONTEXT_SIZE_PAGE0); - MACvSelectPage1(io_base); + VT6655_MAC_SELECT_PAGE1(io_base); /* read page1 register */ memcpy_fromio(cxt_buf + MAC_MAX_CONTEXT_SIZE_PAGE0, io_base, MAC_MAX_CONTEXT_SIZE_PAGE1); - MACvSelectPage0(io_base); + VT6655_MAC_SELECT_PAGE0(io_base); } /* @@ -236,16 +211,16 @@ void MACvSaveContext(struct vnt_private *priv, unsigned char *cxt_buf) * Return Value: none * */ -void MACvRestoreContext(struct vnt_private *priv, unsigned char *cxt_buf) +static void vt6655_mac_restore_context(struct vnt_private *priv, u8 *cxt_buf) { void __iomem *io_base = priv->port_offset; - MACvSelectPage1(io_base); + VT6655_MAC_SELECT_PAGE1(io_base); /* restore page1 */ memcpy_toio(io_base, cxt_buf + MAC_MAX_CONTEXT_SIZE_PAGE0, MAC_MAX_CONTEXT_SIZE_PAGE1); - MACvSelectPage0(io_base); + VT6655_MAC_SELECT_PAGE0(io_base); /* restore RCR,TCR,IMR... */ memcpy_toio(io_base + MAC_REG_RCR, cxt_buf + MAC_REG_RCR, @@ -318,23 +293,20 @@ bool MACbSoftwareReset(struct vnt_private *priv) * Return Value: true if success; otherwise false * */ -bool MACbSafeSoftwareReset(struct vnt_private *priv) +static void vt6655_mac_save_soft_reset(struct vnt_private *priv) { - unsigned char abyTmpRegData[MAC_MAX_CONTEXT_SIZE_PAGE0 + MAC_MAX_CONTEXT_SIZE_PAGE1]; - bool bRetVal; + u8 tmp_reg_data[MAC_MAX_CONTEXT_SIZE_PAGE0 + MAC_MAX_CONTEXT_SIZE_PAGE1]; /* PATCH.... * save some important register's value, then do * reset, then restore register's value */ /* save MAC context */ - MACvSaveContext(priv, abyTmpRegData); + vt6655_mac_save_context(priv, tmp_reg_data); /* do reset */ - bRetVal = MACbSoftwareReset(priv); + MACbSoftwareReset(priv); /* restore MAC context, except CR0 */ - MACvRestoreContext(priv, abyTmpRegData); - - return bRetVal; + vt6655_mac_restore_context(priv, tmp_reg_data); } /* @@ -350,7 +322,7 @@ bool MACbSafeSoftwareReset(struct vnt_private *priv) * Return Value: true if success; otherwise false * */ -bool MACbSafeRxOff(struct vnt_private *priv) +static bool vt6655_mac_safe_rx_off(struct vnt_private *priv) { void __iomem *io_base = priv->port_offset; unsigned short ww; @@ -404,7 +376,7 @@ bool MACbSafeRxOff(struct vnt_private *priv) * Return Value: true if success; otherwise false * */ -bool MACbSafeTxOff(struct vnt_private *priv) +static bool vt6655_mac_safe_tx_off(struct vnt_private *priv) { void __iomem *io_base = priv->port_offset; unsigned short ww; @@ -460,20 +432,20 @@ bool MACbSafeTxOff(struct vnt_private *priv) * Return Value: true if success; otherwise false * */ -bool MACbSafeStop(struct vnt_private *priv) +static bool vt6655_mac_safe_stop(struct vnt_private *priv) { void __iomem *io_base = priv->port_offset; vt6655_mac_reg_bits_off(io_base, MAC_REG_TCR, TCR_AUTOBCNTX); - if (!MACbSafeRxOff(priv)) { - pr_debug(" MACbSafeRxOff == false)\n"); - MACbSafeSoftwareReset(priv); + if (!vt6655_mac_safe_rx_off(priv)) { + pr_debug(" vt6655_mac_safe_rx_off == false)\n"); + vt6655_mac_save_soft_reset(priv); return false; } - if (!MACbSafeTxOff(priv)) { - pr_debug(" MACbSafeTxOff == false)\n"); - MACbSafeSoftwareReset(priv); + if (!vt6655_mac_safe_tx_off(priv)) { + pr_debug(" vt6655_mac_safe_tx_off == false)\n"); + vt6655_mac_save_soft_reset(priv); return false; } @@ -500,13 +472,13 @@ bool MACbShutdown(struct vnt_private *priv) void __iomem *io_base = priv->port_offset; /* disable MAC IMR */ iowrite32(0, io_base + MAC_REG_IMR); - MACvSetLoopbackMode(priv, MAC_LB_INTERNAL); + vt6655_mac_set_loopback_mode(priv, MAC_LB_INTERNAL); /* stop the adapter */ - if (!MACbSafeStop(priv)) { - MACvSetLoopbackMode(priv, MAC_LB_NONE); + if (!vt6655_mac_safe_stop(priv)) { + vt6655_mac_set_loopback_mode(priv, MAC_LB_NONE); return false; } - MACvSetLoopbackMode(priv, MAC_LB_NONE); + vt6655_mac_set_loopback_mode(priv, MAC_LB_NONE); return true; } @@ -555,7 +527,7 @@ void MACvInitialize(struct vnt_private *priv) * Return Value: none * */ -void MACvSetCurrRx0DescAddr(struct vnt_private *priv, u32 curr_desc_addr) +void vt6655_mac_set_curr_rx_0_desc_addr(struct vnt_private *priv, u32 curr_desc_addr) { void __iomem *io_base = priv->port_offset; unsigned short ww; @@ -589,7 +561,7 @@ void MACvSetCurrRx0DescAddr(struct vnt_private *priv, u32 curr_desc_addr) * Return Value: none * */ -void MACvSetCurrRx1DescAddr(struct vnt_private *priv, u32 curr_desc_addr) +void vt6655_mac_set_curr_rx_1_desc_addr(struct vnt_private *priv, u32 curr_desc_addr) { void __iomem *io_base = priv->port_offset; unsigned short ww; @@ -623,8 +595,7 @@ void MACvSetCurrRx1DescAddr(struct vnt_private *priv, u32 curr_desc_addr) * Return Value: none * */ -void MACvSetCurrTx0DescAddrEx(struct vnt_private *priv, - u32 curr_desc_addr) +static void vt6655_mac_set_curr_tx_0_desc_addr_ex(struct vnt_private *priv, u32 curr_desc_addr) { void __iomem *io_base = priv->port_offset; unsigned short ww; @@ -659,8 +630,7 @@ void MACvSetCurrTx0DescAddrEx(struct vnt_private *priv, * */ /* TxDMA1 = AC0DMA */ -void MACvSetCurrAC0DescAddrEx(struct vnt_private *priv, - u32 curr_desc_addr) +static void vt6655_mac_set_curr_ac_0_desc_addr_ex(struct vnt_private *priv, u32 curr_desc_addr) { void __iomem *io_base = priv->port_offset; unsigned short ww; @@ -681,13 +651,12 @@ void MACvSetCurrAC0DescAddrEx(struct vnt_private *priv, iowrite8(DMACTL_RUN, io_base + MAC_REG_AC0DMACTL); } -void MACvSetCurrTXDescAddr(int iTxType, struct vnt_private *priv, - u32 curr_desc_addr) +void vt6655_mac_set_curr_tx_desc_addr(int tx_type, struct vnt_private *priv, u32 curr_desc_addr) { - if (iTxType == TYPE_AC0DMA) - MACvSetCurrAC0DescAddrEx(priv, curr_desc_addr); - else if (iTxType == TYPE_TXDMA0) - MACvSetCurrTx0DescAddrEx(priv, curr_desc_addr); + if (tx_type == TYPE_AC0DMA) + vt6655_mac_set_curr_ac_0_desc_addr_ex(priv, curr_desc_addr); + else if (tx_type == TYPE_TXDMA0) + vt6655_mac_set_curr_tx_0_desc_addr_ex(priv, curr_desc_addr); } /* @@ -767,7 +736,7 @@ bool MACbPSWakeup(struct vnt_private *priv) void __iomem *io_base = priv->port_offset; unsigned int ww; /* Read PSCTL */ - if (MACbIsRegBitsOff(priv, MAC_REG_PSCTL, PSCTL_PS)) + if (vt6655_mac_is_reg_bits_off(priv, MAC_REG_PSCTL, PSCTL_PS)) return true; /* Disable PS */ diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 0122c4603c66..acf931c3f5fd 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -12,7 +12,7 @@ * Revision History: * 07-01-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. * 08-25-2003 Kyle Hsu: Porting MAC functions from sim53. - * 09-03-2003 Bryan YC Fan: Add MACvDisableProtectMD & MACvEnableProtectMD + * 09-03-2003 Bryan YC Fan: Add vt6655_mac_dis_protect_md & vt6655_mac_en_protect_md */ #ifndef __MAC_H__ @@ -537,95 +537,9 @@ /*--------------------- Export Macros ------------------------------*/ -#define MACvReceive0(iobase) \ -do { \ - unsigned long dwData; \ - dwData = ioread32(iobase + MAC_REG_RXDMACTL0); \ - if (dwData & DMACTL_RUN) \ - iowrite32(DMACTL_WAKE, iobase + MAC_REG_RXDMACTL0); \ - else \ - iowrite32(DMACTL_RUN, iobase + MAC_REG_RXDMACTL0); \ -} while (0) - -#define MACvReceive1(iobase) \ -do { \ - unsigned long dwData; \ - dwData = ioread32(iobase + MAC_REG_RXDMACTL1); \ - if (dwData & DMACTL_RUN) \ - iowrite32(DMACTL_WAKE, iobase + MAC_REG_RXDMACTL1); \ - else \ - iowrite32(DMACTL_RUN, iobase + MAC_REG_RXDMACTL1); \ -} while (0) - -#define MACvTransmit0(iobase) \ -do { \ - unsigned long dwData; \ - dwData = ioread32(iobase + MAC_REG_TXDMACTL0); \ - if (dwData & DMACTL_RUN) \ - iowrite32(DMACTL_WAKE, iobase + MAC_REG_TXDMACTL0); \ - else \ - iowrite32(DMACTL_RUN, iobase + MAC_REG_TXDMACTL0); \ -} while (0) - -#define MACvTransmitAC0(iobase) \ -do { \ - unsigned long dwData; \ - dwData = ioread32(iobase + MAC_REG_AC0DMACTL); \ - if (dwData & DMACTL_RUN) \ - iowrite32(DMACTL_WAKE, iobase + MAC_REG_AC0DMACTL); \ - else \ - iowrite32(DMACTL_RUN, iobase + MAC_REG_AC0DMACTL); \ -} while (0) - -#define MACvSelectPage0(iobase) \ - iowrite8(0, iobase + MAC_REG_PAGE1SEL) - -#define MACvSelectPage1(iobase) \ - iowrite8(1, iobase + MAC_REG_PAGE1SEL) - -#define MACvEnableProtectMD(iobase) \ -do { \ - unsigned long dwOrgValue; \ - dwOrgValue = ioread32(iobase + MAC_REG_ENCFG); \ - dwOrgValue = dwOrgValue | ENCFG_PROTECTMD; \ - iowrite32((u32)dwOrgValue, iobase + MAC_REG_ENCFG); \ -} while (0) - -#define MACvDisableProtectMD(iobase) \ -do { \ - unsigned long dwOrgValue; \ - dwOrgValue = ioread32(iobase + MAC_REG_ENCFG); \ - dwOrgValue = dwOrgValue & ~ENCFG_PROTECTMD; \ - iowrite32((u32)dwOrgValue, iobase + MAC_REG_ENCFG); \ -} while (0) - -#define MACvEnableBarkerPreambleMd(iobase) \ -do { \ - unsigned long dwOrgValue; \ - dwOrgValue = ioread32(iobase + MAC_REG_ENCFG); \ - dwOrgValue = dwOrgValue | ENCFG_BARKERPREAM; \ - iowrite32((u32)dwOrgValue, iobase + MAC_REG_ENCFG); \ -} while (0) - -#define MACvDisableBarkerPreambleMd(iobase) \ -do { \ - unsigned long dwOrgValue; \ - dwOrgValue = ioread32(iobase + MAC_REG_ENCFG); \ - dwOrgValue = dwOrgValue & ~ENCFG_BARKERPREAM; \ - iowrite32((u32)dwOrgValue, iobase + MAC_REG_ENCFG); \ -} while (0) - -#define MACvSetBBType(iobase, byTyp) \ -do { \ - unsigned long dwOrgValue; \ - dwOrgValue = ioread32(iobase + MAC_REG_ENCFG); \ - dwOrgValue = dwOrgValue & ~ENCFG_BBTYPE_MASK; \ - dwOrgValue = dwOrgValue | (unsigned long)byTyp; \ - iowrite32((u32)dwOrgValue, iobase + MAC_REG_ENCFG); \ -} while (0) - -#define MACvSetRFLE_LatchBase(iobase) \ - vt6655_mac_word_reg_bits_on(iobase, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_RFLEOPT) +#define VT6655_MAC_SELECT_PAGE0(iobase) iowrite8(0, iobase + MAC_REG_PAGE1SEL) + +#define VT6655_MAC_SELECT_PAGE1(iobase) iowrite8(1, iobase + MAC_REG_PAGE1SEL) #define MAKEWORD(lb, hb) \ ((unsigned short)(((unsigned char)(lb)) | (((unsigned short)((unsigned char)(hb))) << 8))) @@ -635,38 +549,16 @@ void vt6655_mac_word_reg_bits_on(void __iomem *iobase, const u8 reg_offset, cons void vt6655_mac_reg_bits_off(void __iomem *iobase, const u8 reg_offset, const u8 bit_mask); void vt6655_mac_word_reg_bits_off(void __iomem *iobase, const u8 reg_offset, const u16 bit_mask); -bool MACbIsRegBitsOff(struct vnt_private *priv, unsigned char byRegOfs, - unsigned char byTestBits); - -bool MACbIsIntDisable(struct vnt_private *priv); - -void MACvSetShortRetryLimit(struct vnt_private *priv, - unsigned char byRetryLimit); +void vt6655_mac_set_short_retry_limit(struct vnt_private *priv, unsigned char retry_limit); void MACvSetLongRetryLimit(struct vnt_private *priv, unsigned char byRetryLimit); -void MACvSetLoopbackMode(struct vnt_private *priv, unsigned char byLoopbackMode); - -void MACvSaveContext(struct vnt_private *priv, unsigned char *cxt_buf); -void MACvRestoreContext(struct vnt_private *priv, unsigned char *cxt_buf); - bool MACbSoftwareReset(struct vnt_private *priv); -bool MACbSafeSoftwareReset(struct vnt_private *priv); -bool MACbSafeRxOff(struct vnt_private *priv); -bool MACbSafeTxOff(struct vnt_private *priv); -bool MACbSafeStop(struct vnt_private *priv); bool MACbShutdown(struct vnt_private *priv); void MACvInitialize(struct vnt_private *priv); -void MACvSetCurrRx0DescAddr(struct vnt_private *priv, - u32 curr_desc_addr); -void MACvSetCurrRx1DescAddr(struct vnt_private *priv, - u32 curr_desc_addr); -void MACvSetCurrTXDescAddr(int iTxType, struct vnt_private *priv, - u32 curr_desc_addr); -void MACvSetCurrTx0DescAddrEx(struct vnt_private *priv, - u32 curr_desc_addr); -void MACvSetCurrAC0DescAddrEx(struct vnt_private *priv, - u32 curr_desc_addr); +void vt6655_mac_set_curr_rx_0_desc_addr(struct vnt_private *priv, u32 curr_desc_addr); +void vt6655_mac_set_curr_rx_1_desc_addr(struct vnt_private *priv, u32 curr_desc_addr); +void vt6655_mac_set_curr_tx_desc_addr(int tx_type, struct vnt_private *priv, u32 curr_desc_addr); void MACvSetCurrSyncDescAddrEx(struct vnt_private *priv, u32 curr_desc_addr); void MACvSetCurrATIMDescAddrEx(struct vnt_private *priv, diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h index 5654dc54ae91..1cee51a1075e 100644 --- a/drivers/staging/wlan-ng/p80211netdev.h +++ b/drivers/staging/wlan-ng/p80211netdev.h @@ -137,8 +137,6 @@ struct p80211_frmrx { /* called by /proc/net/wireless */ struct iw_statistics *p80211wext_get_wireless_stats(struct net_device *dev); -/* wireless extensions' ioctls */ -extern struct iw_handler_def p80211wext_handler_def; /* WEP stuff */ #define NUM_WEPKEYS 4 |