diff options
Diffstat (limited to 'drivers/net/wireless/ath/hw.c')
-rw-r--r-- | drivers/net/wireless/ath/hw.c | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/drivers/net/wireless/ath/hw.c b/drivers/net/wireless/ath/hw.c index a8f81ea09f14..3f508e59f146 100644 --- a/drivers/net/wireless/ath/hw.c +++ b/drivers/net/wireless/ath/hw.c | |||
@@ -43,7 +43,7 @@ | |||
43 | * set of ~ ( MAC XOR BSSID ) for all bssids we handle. | 43 | * set of ~ ( MAC XOR BSSID ) for all bssids we handle. |
44 | * | 44 | * |
45 | * When you do this you are essentially computing the common bits of all your | 45 | * When you do this you are essentially computing the common bits of all your |
46 | * BSSes. Later it is assumed the harware will "and" (&) the BSSID mask with | 46 | * BSSes. Later it is assumed the hardware will "and" (&) the BSSID mask with |
47 | * the MAC address to obtain the relevant bits and compare the result with | 47 | * the MAC address to obtain the relevant bits and compare the result with |
48 | * (frame's BSSID & mask) to see if they match. | 48 | * (frame's BSSID & mask) to see if they match. |
49 | * | 49 | * |
@@ -71,8 +71,8 @@ | |||
71 | * On loop iteration for BSSID-02: | 71 | * On loop iteration for BSSID-02: |
72 | * bssid_mask &= ~(0001 ^ 1001) | 72 | * bssid_mask &= ~(0001 ^ 1001) |
73 | * bssid_mask = (1010) & ~(0001 ^ 1001) | 73 | * bssid_mask = (1010) & ~(0001 ^ 1001) |
74 | * bssid_mask = (1010) & ~(1001) | 74 | * bssid_mask = (1010) & ~(1000) |
75 | * bssid_mask = (1010) & (0110) | 75 | * bssid_mask = (1010) & (0111) |
76 | * bssid_mask = 0010 | 76 | * bssid_mask = 0010 |
77 | * | 77 | * |
78 | * A bssid_mask of 0010 means "only pay attention to the second least | 78 | * A bssid_mask of 0010 means "only pay attention to the second least |
@@ -86,7 +86,7 @@ | |||
86 | * IFRAME-01: 0110 | 86 | * IFRAME-01: 0110 |
87 | * | 87 | * |
88 | * An easy eye-inspeciton of this already should tell you that this frame | 88 | * An easy eye-inspeciton of this already should tell you that this frame |
89 | * will not pass our check. This is beacuse the bssid_mask tells the | 89 | * will not pass our check. This is because the bssid_mask tells the |
90 | * hardware to only look at the second least significant bit and the | 90 | * hardware to only look at the second least significant bit and the |
91 | * common bit amongst the MAC and BSSIDs is 0, this frame has the 2nd LSB | 91 | * common bit amongst the MAC and BSSIDs is 0, this frame has the 2nd LSB |
92 | * as 1, which does not match 0. | 92 | * as 1, which does not match 0. |
@@ -102,11 +102,9 @@ | |||
102 | * | 102 | * |
103 | * IFRAME-02: 0001 (we should allow) | 103 | * IFRAME-02: 0001 (we should allow) |
104 | * | 104 | * |
105 | * allow = (0001 & 1010) == 1010 | ||
106 | * | ||
107 | * allow = (IFRAME-02 & bssid_mask) == (bssid_mask & MAC) ? 1 : 0; | 105 | * allow = (IFRAME-02 & bssid_mask) == (bssid_mask & MAC) ? 1 : 0; |
108 | * --> allow = (0001 & 0010) == (0010 & 0001) ? 1 :0; | 106 | * --> allow = (0001 & 0010) == (0010 & 0001) ? 1 :0; |
109 | * --> allow = (0010) == (0010) | 107 | * --> allow = (0000) == (0000) |
110 | * --> allow = 1 | 108 | * --> allow = 1 |
111 | * | 109 | * |
112 | * Other examples: | 110 | * Other examples: |
@@ -124,3 +122,62 @@ void ath_hw_setbssidmask(struct ath_common *common) | |||
124 | REG_WRITE(ah, get_unaligned_le16(common->bssidmask + 4), AR_BSSMSKU); | 122 | REG_WRITE(ah, get_unaligned_le16(common->bssidmask + 4), AR_BSSMSKU); |
125 | } | 123 | } |
126 | EXPORT_SYMBOL(ath_hw_setbssidmask); | 124 | EXPORT_SYMBOL(ath_hw_setbssidmask); |
125 | |||
126 | |||
127 | /** | ||
128 | * ath_hw_cycle_counters_update - common function to update cycle counters | ||
129 | * | ||
130 | * @common: the ath_common struct for the device. | ||
131 | * | ||
132 | * This function is used to update all cycle counters in one place. | ||
133 | * It has to be called while holding common->cc_lock! | ||
134 | */ | ||
135 | void ath_hw_cycle_counters_update(struct ath_common *common) | ||
136 | { | ||
137 | u32 cycles, busy, rx, tx; | ||
138 | void *ah = common->ah; | ||
139 | |||
140 | /* freeze */ | ||
141 | REG_WRITE(ah, AR_MIBC_FMC, AR_MIBC); | ||
142 | |||
143 | /* read */ | ||
144 | cycles = REG_READ(ah, AR_CCCNT); | ||
145 | busy = REG_READ(ah, AR_RCCNT); | ||
146 | rx = REG_READ(ah, AR_RFCNT); | ||
147 | tx = REG_READ(ah, AR_TFCNT); | ||
148 | |||
149 | /* clear */ | ||
150 | REG_WRITE(ah, 0, AR_CCCNT); | ||
151 | REG_WRITE(ah, 0, AR_RFCNT); | ||
152 | REG_WRITE(ah, 0, AR_RCCNT); | ||
153 | REG_WRITE(ah, 0, AR_TFCNT); | ||
154 | |||
155 | /* unfreeze */ | ||
156 | REG_WRITE(ah, 0, AR_MIBC); | ||
157 | |||
158 | /* update all cycle counters here */ | ||
159 | common->cc_ani.cycles += cycles; | ||
160 | common->cc_ani.rx_busy += busy; | ||
161 | common->cc_ani.rx_frame += rx; | ||
162 | common->cc_ani.tx_frame += tx; | ||
163 | |||
164 | common->cc_survey.cycles += cycles; | ||
165 | common->cc_survey.rx_busy += busy; | ||
166 | common->cc_survey.rx_frame += rx; | ||
167 | common->cc_survey.tx_frame += tx; | ||
168 | } | ||
169 | EXPORT_SYMBOL(ath_hw_cycle_counters_update); | ||
170 | |||
171 | int32_t ath_hw_get_listen_time(struct ath_common *common) | ||
172 | { | ||
173 | struct ath_cycle_counters *cc = &common->cc_ani; | ||
174 | int32_t listen_time; | ||
175 | |||
176 | listen_time = (cc->cycles - cc->rx_frame - cc->tx_frame) / | ||
177 | (common->clockrate * 1000); | ||
178 | |||
179 | memset(cc, 0, sizeof(*cc)); | ||
180 | |||
181 | return listen_time; | ||
182 | } | ||
183 | EXPORT_SYMBOL(ath_hw_get_listen_time); | ||