aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00queue.h
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-08-04 10:37:44 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 16:29:58 -0400
commit2bb057d07a0bc17475a7bf897fc41667ab08b73f (patch)
tree55461e52caa34a45a67aaf9e3f1c608f96c77d59 /drivers/net/wireless/rt2x00/rt2x00queue.h
parent8e7cdbb6333ef7654e708bd60e50a123688dcd7b (diff)
rt2x00: Implement HW encryption
Various rt2x00 devices support hardware encryption. Most of them require the IV/EIV to be generated by mac80211, but require it to be provided seperately instead of within the frame itself. This means that rt2x00lib should extract the data from the frame and place it in the frame descriptor. During RX the IV/EIV is provided in the descriptor by the hardware which means that it should be inserted into the frame by rt2x00lib. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00queue.h')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.h73
1 files changed, 66 insertions, 7 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.h b/drivers/net/wireless/rt2x00/rt2x00queue.h
index ff78e52ce43c..37f3f98d58a2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.h
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
@@ -87,10 +87,13 @@ enum data_queue_qid {
87 * 87 *
88 * @SKBDESC_DMA_MAPPED_RX: &skb_dma field has been mapped for RX 88 * @SKBDESC_DMA_MAPPED_RX: &skb_dma field has been mapped for RX
89 * @SKBDESC_DMA_MAPPED_TX: &skb_dma field has been mapped for TX 89 * @SKBDESC_DMA_MAPPED_TX: &skb_dma field has been mapped for TX
90 * @FRAME_DESC_IV_STRIPPED: Frame contained a IV/EIV provided by
91 * mac80211 but was stripped for processing by the driver.
90 */ 92 */
91enum skb_frame_desc_flags { 93enum skb_frame_desc_flags {
92 SKBDESC_DMA_MAPPED_RX = (1 << 0), 94 SKBDESC_DMA_MAPPED_RX = 1 << 0,
93 SKBDESC_DMA_MAPPED_TX = (1 << 1), 95 SKBDESC_DMA_MAPPED_TX = 1 << 1,
96 FRAME_DESC_IV_STRIPPED = 1 << 2,
94}; 97};
95 98
96/** 99/**
@@ -104,6 +107,8 @@ enum skb_frame_desc_flags {
104 * @desc: Pointer to descriptor part of the frame. 107 * @desc: Pointer to descriptor part of the frame.
105 * Note that this pointer could point to something outside 108 * Note that this pointer could point to something outside
106 * of the scope of the skb->data pointer. 109 * of the scope of the skb->data pointer.
110 * @iv: IV data used during encryption/decryption.
111 * @eiv: EIV data used during encryption/decryption.
107 * @skb_dma: (PCI-only) the DMA address associated with the sk buffer. 112 * @skb_dma: (PCI-only) the DMA address associated with the sk buffer.
108 * @entry: The entry to which this sk buffer belongs. 113 * @entry: The entry to which this sk buffer belongs.
109 */ 114 */
@@ -113,6 +118,9 @@ struct skb_frame_desc {
113 unsigned int desc_len; 118 unsigned int desc_len;
114 void *desc; 119 void *desc;
115 120
121 __le32 iv;
122 __le32 eiv;
123
116 dma_addr_t skb_dma; 124 dma_addr_t skb_dma;
117 125
118 struct queue_entry *entry; 126 struct queue_entry *entry;
@@ -152,7 +160,11 @@ enum rxdone_entry_desc_flags {
152 * @size: Data size of the received frame. 160 * @size: Data size of the received frame.
153 * @flags: MAC80211 receive flags (See &enum mac80211_rx_flags). 161 * @flags: MAC80211 receive flags (See &enum mac80211_rx_flags).
154 * @dev_flags: Ralink receive flags (See &enum rxdone_entry_desc_flags). 162 * @dev_flags: Ralink receive flags (See &enum rxdone_entry_desc_flags).
155 163 * @cipher: Cipher type used during decryption.
164 * @cipher_status: Decryption status.
165 * @iv: IV data used during decryption.
166 * @eiv: EIV data used during decryption.
167 * @icv: ICV data used during decryption.
156 */ 168 */
157struct rxdone_entry_desc { 169struct rxdone_entry_desc {
158 u64 timestamp; 170 u64 timestamp;
@@ -161,6 +173,12 @@ struct rxdone_entry_desc {
161 int size; 173 int size;
162 int flags; 174 int flags;
163 int dev_flags; 175 int dev_flags;
176 u8 cipher;
177 u8 cipher_status;
178
179 __le32 iv;
180 __le32 eiv;
181 __le32 icv;
164}; 182};
165 183
166/** 184/**
@@ -206,6 +224,10 @@ struct txdone_entry_desc {
206 * @ENTRY_TXD_BURST: This frame belongs to the same burst event. 224 * @ENTRY_TXD_BURST: This frame belongs to the same burst event.
207 * @ENTRY_TXD_ACK: An ACK is required for this frame. 225 * @ENTRY_TXD_ACK: An ACK is required for this frame.
208 * @ENTRY_TXD_RETRY_MODE: When set, the long retry count is used. 226 * @ENTRY_TXD_RETRY_MODE: When set, the long retry count is used.
227 * @ENTRY_TXD_ENCRYPT: This frame should be encrypted.
228 * @ENTRY_TXD_ENCRYPT_PAIRWISE: Use pairwise key table (instead of shared).
229 * @ENTRY_TXD_ENCRYPT_IV: Generate IV/EIV in hardware.
230 * @ENTRY_TXD_ENCRYPT_MMIC: Generate MIC in hardware.
209 */ 231 */
210enum txentry_desc_flags { 232enum txentry_desc_flags {
211 ENTRY_TXD_RTS_FRAME, 233 ENTRY_TXD_RTS_FRAME,
@@ -218,6 +240,10 @@ enum txentry_desc_flags {
218 ENTRY_TXD_BURST, 240 ENTRY_TXD_BURST,
219 ENTRY_TXD_ACK, 241 ENTRY_TXD_ACK,
220 ENTRY_TXD_RETRY_MODE, 242 ENTRY_TXD_RETRY_MODE,
243 ENTRY_TXD_ENCRYPT,
244 ENTRY_TXD_ENCRYPT_PAIRWISE,
245 ENTRY_TXD_ENCRYPT_IV,
246 ENTRY_TXD_ENCRYPT_MMIC,
221}; 247};
222 248
223/** 249/**
@@ -236,6 +262,9 @@ enum txentry_desc_flags {
236 * @ifs: IFS value. 262 * @ifs: IFS value.
237 * @cw_min: cwmin value. 263 * @cw_min: cwmin value.
238 * @cw_max: cwmax value. 264 * @cw_max: cwmax value.
265 * @cipher: Cipher type used for encryption.
266 * @key_idx: Key index used for encryption.
267 * @iv_offset: Position where IV should be inserted by hardware.
239 */ 268 */
240struct txentry_desc { 269struct txentry_desc {
241 unsigned long flags; 270 unsigned long flags;
@@ -252,6 +281,10 @@ struct txentry_desc {
252 short ifs; 281 short ifs;
253 short cw_min; 282 short cw_min;
254 short cw_max; 283 short cw_max;
284
285 enum cipher cipher;
286 u16 key_idx;
287 u16 iv_offset;
255}; 288};
256 289
257/** 290/**
@@ -484,25 +517,51 @@ static inline int rt2x00queue_threshold(struct data_queue *queue)
484} 517}
485 518
486/** 519/**
487 * rt2x00_desc_read - Read a word from the hardware descriptor. 520 * _rt2x00_desc_read - Read a word from the hardware descriptor.
521 * @desc: Base descriptor address
522 * @word: Word index from where the descriptor should be read.
523 * @value: Address where the descriptor value should be written into.
524 */
525static inline void _rt2x00_desc_read(__le32 *desc, const u8 word, __le32 *value)
526{
527 *value = desc[word];
528}
529
530/**
531 * rt2x00_desc_read - Read a word from the hardware descriptor, this
532 * function will take care of the byte ordering.
488 * @desc: Base descriptor address 533 * @desc: Base descriptor address
489 * @word: Word index from where the descriptor should be read. 534 * @word: Word index from where the descriptor should be read.
490 * @value: Address where the descriptor value should be written into. 535 * @value: Address where the descriptor value should be written into.
491 */ 536 */
492static inline void rt2x00_desc_read(__le32 *desc, const u8 word, u32 *value) 537static inline void rt2x00_desc_read(__le32 *desc, const u8 word, u32 *value)
493{ 538{
494 *value = le32_to_cpu(desc[word]); 539 __le32 tmp;
540 _rt2x00_desc_read(desc, word, &tmp);
541 *value = le32_to_cpu(tmp);
542}
543
544/**
545 * rt2x00_desc_write - write a word to the hardware descriptor, this
546 * function will take care of the byte ordering.
547 * @desc: Base descriptor address
548 * @word: Word index from where the descriptor should be written.
549 * @value: Value that should be written into the descriptor.
550 */
551static inline void _rt2x00_desc_write(__le32 *desc, const u8 word, __le32 value)
552{
553 desc[word] = value;
495} 554}
496 555
497/** 556/**
498 * rt2x00_desc_write - wrote a word to the hardware descriptor. 557 * rt2x00_desc_write - write a word to the hardware descriptor.
499 * @desc: Base descriptor address 558 * @desc: Base descriptor address
500 * @word: Word index from where the descriptor should be written. 559 * @word: Word index from where the descriptor should be written.
501 * @value: Value that should be written into the descriptor. 560 * @value: Value that should be written into the descriptor.
502 */ 561 */
503static inline void rt2x00_desc_write(__le32 *desc, const u8 word, u32 value) 562static inline void rt2x00_desc_write(__le32 *desc, const u8 word, u32 value)
504{ 563{
505 desc[word] = cpu_to_le32(value); 564 _rt2x00_desc_write(desc, word, cpu_to_le32(value));
506} 565}
507 566
508#endif /* RT2X00QUEUE_H */ 567#endif /* RT2X00QUEUE_H */