~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/ipxe/src/drivers/net/ath/ath_key.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2009 Atheros Communications Inc.
 
3
 * Copyright (c) 2010 Bruno Randolf <br1@einfach.org>
 
4
 *
 
5
 * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
 
6
 * Original from Linux kernel 3.0.1
 
7
 *
 
8
 * Permission to use, copy, modify, and/or distribute this software for any
 
9
 * purpose with or without fee is hereby granted, provided that the above
 
10
 * copyright notice and this permission notice appear in all copies.
 
11
 *
 
12
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 
13
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 
14
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 
15
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
16
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 
17
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 
18
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
19
 */
 
20
 
 
21
#include "ath.h"
 
22
#include "reg.h"
 
23
 
 
24
#define REG_READ                        (common->ops->read)
 
25
#define REG_WRITE(_ah, _reg, _val)      (common->ops->write)(_ah, _val, _reg)
 
26
#define ENABLE_REGWRITE_BUFFER(_ah)                     \
 
27
        if (common->ops->enable_write_buffer)           \
 
28
                common->ops->enable_write_buffer((_ah));
 
29
 
 
30
#define REGWRITE_BUFFER_FLUSH(_ah)                      \
 
31
        if (common->ops->write_flush)                   \
 
32
                common->ops->write_flush((_ah));
 
33
 
 
34
 
 
35
#define IEEE80211_WEP_NKID      4       /* number of key ids */
 
36
 
 
37
/************************/
 
38
/* Key Cache Management */
 
39
/************************/
 
40
 
 
41
int ath_hw_keyreset(struct ath_common *common, u16 entry)
 
42
{
 
43
        u32 keyType;
 
44
        void *ah = common->ah;
 
45
 
 
46
        if (entry >= common->keymax) {
 
47
                DBG("ath: keycache entry %d out of range\n", entry);
 
48
                return 0;
 
49
        }
 
50
 
 
51
        keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry));
 
52
 
 
53
        ENABLE_REGWRITE_BUFFER(ah);
 
54
 
 
55
        REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0);
 
56
        REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0);
 
57
        REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0);
 
58
        REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0);
 
59
        REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0);
 
60
        REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR);
 
61
        REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0);
 
62
        REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0);
 
63
 
 
64
        if (keyType == AR_KEYTABLE_TYPE_TKIP) {
 
65
                u16 micentry = entry + 64;
 
66
 
 
67
                REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0);
 
68
                REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
 
69
                REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0);
 
70
                REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
 
71
                if (common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED) {
 
72
                        REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
 
73
                        REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
 
74
                                  AR_KEYTABLE_TYPE_CLR);
 
75
                }
 
76
 
 
77
        }
 
78
 
 
79
        REGWRITE_BUFFER_FLUSH(ah);
 
80
 
 
81
        return 1;
 
82
}