diff options
author | Sergio Paracuellos <sergio.paracuellos@gmail.com> | 2018-05-04 07:16:06 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-07 04:58:36 +0300 |
commit | 57c6f08dfe27b81cf39f4b7d1d4a24bb1f49477b (patch) | |
tree | cd445730008243dec8e250b550832647e70e861c /drivers/staging/ks7010/ks_wlan.h | |
parent | a0a954b151d037e8cbf8822eb56a1a79c4caed30 (diff) | |
download | linux-57c6f08dfe27b81cf39f4b7d1d4a24bb1f49477b.tar.xz |
staging: ks7010: move tx and rx queues definitions into ks_wlan.h header
There are some definitions for rx and tx queues in ks7010_sdio
which is not the best place to put them. Changing them into the
ks_wlan header file there is no need to explicity include ks7010_sdio.h
which makes no sense at all and can be resolved easily using
forward declarations. The functions related with the queues circular
buffers have been moved also into this header.
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ks7010/ks_wlan.h')
-rw-r--r-- | drivers/staging/ks7010/ks_wlan.h | 112 |
1 files changed, 110 insertions, 2 deletions
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 5070af86115f..d73f6222973b 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -10,14 +10,13 @@ #define _KS_WLAN_H #include <linux/atomic.h> /* struct atomic_t */ +#include <linux/circ_buf.h> #include <linux/completion.h> /* struct completion */ #include <linux/netdevice.h> /* struct net_device_stats, struct sk_buff */ #include <linux/sched.h> /* wait_queue_head_t */ #include <linux/spinlock.h> /* spinlock_t */ #include <linux/wireless.h> -#include "ks7010_sdio.h" - struct ks_wlan_parameter { u8 operation_mode; /* Operation Mode */ u8 channel; /* Channel */ @@ -366,6 +365,71 @@ struct wps_status { u8 ie[255]; }; +/* Tx Device struct */ +#define TX_DEVICE_BUFF_SIZE 1024 + +struct ks_wlan_private; + +/** + * struct tx_device_buffer - Queue item for the tx queue. + * @sendp: Pointer to the send request data. + * @size: Size of @sendp data. + * @complete_handler: Function called once data write to device is complete. + * @arg1: First argument to @complete_handler. + * @arg2: Second argument to @complete_handler. + */ +struct tx_device_buffer { + unsigned char *sendp; + unsigned int size; + void (*complete_handler)(struct ks_wlan_private *priv, + struct sk_buff *skb); + struct sk_buff *skb; +}; + +/** + * struct tx_device - Tx buffer queue. + * @tx_device_buffer: Queue buffer. + * @qhead: Head of tx queue. + * @qtail: Tail of tx queue. + * @tx_dev_lock: Queue lock. + */ +struct tx_device { + struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; + spinlock_t tx_dev_lock; /* protect access to the queue */ +}; + +/* Rx Device struct */ +#define RX_DATA_SIZE (2 + 2 + 2347 + 1) +#define RX_DEVICE_BUFF_SIZE 32 + +/** + * struct rx_device_buffer - Queue item for the rx queue. + * @data: rx data. + * @size: Size of @data. + */ +struct rx_device_buffer { + unsigned char data[RX_DATA_SIZE]; + unsigned int size; +}; + +/** + * struct rx_device - Rx buffer queue. + * @rx_device_buffer: Queue buffer. + * @qhead: Head of rx queue. + * @qtail: Tail of rx queue. + * @rx_dev_lock: Queue lock. + */ +struct rx_device { + struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; + spinlock_t rx_dev_lock; /* protect access to the queue */ +}; + +struct ks_sdio_card; + struct ks_wlan_private { /* hardware information */ struct ks_sdio_card *ks_sdio_card; @@ -452,6 +516,50 @@ struct ks_wlan_private { uint wakeup_count; /* for detect wakeup loop */ }; +static inline void inc_txqhead(struct ks_wlan_private *priv) +{ + priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE; +} + +static inline void inc_txqtail(struct ks_wlan_private *priv) +{ + priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE; +} + +static inline bool txq_has_space(struct ks_wlan_private *priv) +{ + return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail, + TX_DEVICE_BUFF_SIZE) > 0); +} + +static inline void inc_rxqhead(struct ks_wlan_private *priv) +{ + priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE; +} + +static inline void inc_rxqtail(struct ks_wlan_private *priv) +{ + priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE; +} + +static inline bool rxq_has_space(struct ks_wlan_private *priv) +{ + return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail, + RX_DEVICE_BUFF_SIZE) > 0); +} + +static inline unsigned int txq_count(struct ks_wlan_private *priv) +{ + return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail, + TX_DEVICE_BUFF_SIZE); +} + +static inline unsigned int rxq_count(struct ks_wlan_private *priv) +{ + return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail, + RX_DEVICE_BUFF_SIZE); +} + int ks_wlan_net_start(struct net_device *dev); int ks_wlan_net_stop(struct net_device *dev); bool is_connect_status(u32 status); |