Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef B43legacy_PIO_H_
0003 #define B43legacy_PIO_H_
0004 
0005 #include "b43legacy.h"
0006 
0007 #include <linux/interrupt.h>
0008 #include <linux/list.h>
0009 #include <linux/skbuff.h>
0010 
0011 
0012 #define B43legacy_PIO_TXCTL     0x00
0013 #define B43legacy_PIO_TXDATA        0x02
0014 #define B43legacy_PIO_TXQBUFSIZE    0x04
0015 #define B43legacy_PIO_RXCTL     0x08
0016 #define B43legacy_PIO_RXDATA        0x0A
0017 
0018 #define B43legacy_PIO_TXCTL_WRITELO (1 << 0)
0019 #define B43legacy_PIO_TXCTL_WRITEHI (1 << 1)
0020 #define B43legacy_PIO_TXCTL_COMPLETE    (1 << 2)
0021 #define B43legacy_PIO_TXCTL_INIT    (1 << 3)
0022 #define B43legacy_PIO_TXCTL_SUSPEND (1 << 7)
0023 
0024 #define B43legacy_PIO_RXCTL_DATAAVAILABLE   (1 << 0)
0025 #define B43legacy_PIO_RXCTL_READY       (1 << 1)
0026 
0027 /* PIO constants */
0028 #define B43legacy_PIO_MAXTXDEVQPACKETS  31
0029 #define B43legacy_PIO_TXQADJUST     80
0030 
0031 /* PIO tuning knobs */
0032 #define B43legacy_PIO_MAXTXPACKETS  256
0033 
0034 
0035 
0036 #ifdef CONFIG_B43LEGACY_PIO
0037 
0038 
0039 struct b43legacy_pioqueue;
0040 struct b43legacy_xmitstatus;
0041 
0042 struct b43legacy_pio_txpacket {
0043     struct b43legacy_pioqueue *queue;
0044     struct sk_buff *skb;
0045     struct list_head list;
0046 };
0047 
0048 #define pio_txpacket_getindex(packet) ((int)((packet) - \
0049                   (packet)->queue->tx_packets_cache))
0050 
0051 struct b43legacy_pioqueue {
0052     struct b43legacy_wldev *dev;
0053     u16 mmio_base;
0054 
0055     bool tx_suspended;
0056     bool tx_frozen;
0057     bool need_workarounds; /* Workarounds needed for core.rev < 3 */
0058 
0059     /* Adjusted size of the device internal TX buffer. */
0060     u16 tx_devq_size;
0061     /* Used octets of the device internal TX buffer. */
0062     u16 tx_devq_used;
0063     /* Used packet slots in the device internal TX buffer. */
0064     u8 tx_devq_packets;
0065     /* Packets from the txfree list can
0066      * be taken on incoming TX requests.
0067      */
0068     struct list_head txfree;
0069     unsigned int nr_txfree;
0070     /* Packets on the txqueue are queued,
0071      * but not completely written to the chip, yet.
0072      */
0073     struct list_head txqueue;
0074     /* Packets on the txrunning queue are completely
0075      * posted to the device. We are waiting for the txstatus.
0076      */
0077     struct list_head txrunning;
0078     struct tasklet_struct txtask;
0079     struct b43legacy_pio_txpacket
0080              tx_packets_cache[B43legacy_PIO_MAXTXPACKETS];
0081 };
0082 
0083 static inline
0084 u16 b43legacy_pio_read(struct b43legacy_pioqueue *queue,
0085              u16 offset)
0086 {
0087     return b43legacy_read16(queue->dev, queue->mmio_base + offset);
0088 }
0089 
0090 static inline
0091 void b43legacy_pio_write(struct b43legacy_pioqueue *queue,
0092                u16 offset, u16 value)
0093 {
0094     b43legacy_write16(queue->dev, queue->mmio_base + offset, value);
0095 }
0096 
0097 
0098 int b43legacy_pio_init(struct b43legacy_wldev *dev);
0099 void b43legacy_pio_free(struct b43legacy_wldev *dev);
0100 
0101 int b43legacy_pio_tx(struct b43legacy_wldev *dev,
0102            struct sk_buff *skb);
0103 void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
0104                  const struct b43legacy_txstatus *status);
0105 void b43legacy_pio_rx(struct b43legacy_pioqueue *queue);
0106 
0107 /* Suspend TX queue in hardware. */
0108 void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue);
0109 void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue);
0110 /* Suspend (freeze) the TX tasklet (software level). */
0111 void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev);
0112 void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev);
0113 
0114 #else /* CONFIG_B43LEGACY_PIO */
0115 
0116 static inline
0117 int b43legacy_pio_init(struct b43legacy_wldev *dev)
0118 {
0119     return 0;
0120 }
0121 static inline
0122 void b43legacy_pio_free(struct b43legacy_wldev *dev)
0123 {
0124 }
0125 static inline
0126 int b43legacy_pio_tx(struct b43legacy_wldev *dev,
0127            struct sk_buff *skb)
0128 {
0129     return 0;
0130 }
0131 static inline
0132 void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
0133                  const struct b43legacy_txstatus *status)
0134 {
0135 }
0136 static inline
0137 void b43legacy_pio_rx(struct b43legacy_pioqueue *queue)
0138 {
0139 }
0140 static inline
0141 void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue *queue)
0142 {
0143 }
0144 static inline
0145 void b43legacy_pio_tx_resume(struct b43legacy_pioqueue *queue)
0146 {
0147 }
0148 static inline
0149 void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev *dev)
0150 {
0151 }
0152 static inline
0153 void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev *dev)
0154 {
0155 }
0156 
0157 #endif /* CONFIG_B43LEGACY_PIO */
0158 #endif /* B43legacy_PIO_H_ */