aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2009-01-24 09:13:32 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 16:01:44 -0500
commit018697d178717d63f668b9e5f3b473f4e37f6304 (patch)
tree6e4868a1b74b1ce3a648446b446e89ea0c346c43 /drivers/net
parent99590ffefc803caaf6ba923da092cde739269c06 (diff)
airo: clean up and clarify micinit()
Fix some endian issues too. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/airo.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 49872db89514..c047580e52dd 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1302,6 +1302,29 @@ static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
1302static void emmh32_final(emmh32_context *context, u8 digest[4]); 1302static void emmh32_final(emmh32_context *context, u8 digest[4]);
1303static int flashpchar(struct airo_info *ai,int byte,int dwelltime); 1303static int flashpchar(struct airo_info *ai,int byte,int dwelltime);
1304 1304
1305static void age_mic_context(miccntx *cur, miccntx *old, u8 *key, int key_len,
1306 struct crypto_cipher *tfm)
1307{
1308 /* If the current MIC context is valid and its key is the same as
1309 * the MIC register, there's nothing to do.
1310 */
1311 if (cur->valid && (memcmp(cur->key, key, key_len) == 0))
1312 return;
1313
1314 /* Age current mic Context */
1315 memcpy(old, cur, sizeof(*cur));
1316
1317 /* Initialize new context */
1318 memcpy(cur->key, key, key_len);
1319 cur->window = 33; /* Window always points to the middle */
1320 cur->rx = 0; /* Rx Sequence numbers */
1321 cur->tx = 0; /* Tx sequence numbers */
1322 cur->valid = 1; /* Key is now valid */
1323
1324 /* Give key to mic seed */
1325 emmh32_setseed(&cur->seed, key, key_len, tfm);
1326}
1327
1305/* micinit - Initialize mic seed */ 1328/* micinit - Initialize mic seed */
1306 1329
1307static void micinit(struct airo_info *ai) 1330static void micinit(struct airo_info *ai)
@@ -1312,49 +1335,26 @@ static void micinit(struct airo_info *ai)
1312 PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0); 1335 PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0);
1313 up(&ai->sem); 1336 up(&ai->sem);
1314 1337
1315 ai->micstats.enabled = (mic_rid.state & 0x00FF) ? 1 : 0; 1338 ai->micstats.enabled = (le16_to_cpu(mic_rid.state) & 0x00FF) ? 1 : 0;
1316 1339 if (!ai->micstats.enabled) {
1317 if (ai->micstats.enabled) { 1340 /* So next time we have a valid key and mic is enabled, we will
1318 /* Key must be valid and different */ 1341 * update the sequence number if the key is the same as before.
1319 if (mic_rid.multicastValid && (!ai->mod[0].mCtx.valid || 1342 */
1320 (memcmp (ai->mod[0].mCtx.key, mic_rid.multicast,
1321 sizeof(ai->mod[0].mCtx.key)) != 0))) {
1322 /* Age current mic Context */
1323 memcpy(&ai->mod[1].mCtx,&ai->mod[0].mCtx,sizeof(miccntx));
1324 /* Initialize new context */
1325 memcpy(&ai->mod[0].mCtx.key,mic_rid.multicast,sizeof(mic_rid.multicast));
1326 ai->mod[0].mCtx.window = 33; //Window always points to the middle
1327 ai->mod[0].mCtx.rx = 0; //Rx Sequence numbers
1328 ai->mod[0].mCtx.tx = 0; //Tx sequence numbers
1329 ai->mod[0].mCtx.valid = 1; //Key is now valid
1330
1331 /* Give key to mic seed */
1332 emmh32_setseed(&ai->mod[0].mCtx.seed,mic_rid.multicast,sizeof(mic_rid.multicast), ai->tfm);
1333 }
1334
1335 /* Key must be valid and different */
1336 if (mic_rid.unicastValid && (!ai->mod[0].uCtx.valid ||
1337 (memcmp(ai->mod[0].uCtx.key, mic_rid.unicast,
1338 sizeof(ai->mod[0].uCtx.key)) != 0))) {
1339 /* Age current mic Context */
1340 memcpy(&ai->mod[1].uCtx,&ai->mod[0].uCtx,sizeof(miccntx));
1341 /* Initialize new context */
1342 memcpy(&ai->mod[0].uCtx.key,mic_rid.unicast,sizeof(mic_rid.unicast));
1343
1344 ai->mod[0].uCtx.window = 33; //Window always points to the middle
1345 ai->mod[0].uCtx.rx = 0; //Rx Sequence numbers
1346 ai->mod[0].uCtx.tx = 0; //Tx sequence numbers
1347 ai->mod[0].uCtx.valid = 1; //Key is now valid
1348
1349 //Give key to mic seed
1350 emmh32_setseed(&ai->mod[0].uCtx.seed, mic_rid.unicast, sizeof(mic_rid.unicast), ai->tfm);
1351 }
1352 } else {
1353 /* So next time we have a valid key and mic is enabled, we will update
1354 * the sequence number if the key is the same as before.
1355 */
1356 ai->mod[0].uCtx.valid = 0; 1343 ai->mod[0].uCtx.valid = 0;
1357 ai->mod[0].mCtx.valid = 0; 1344 ai->mod[0].mCtx.valid = 0;
1345 return;
1346 }
1347
1348 if (mic_rid.multicastValid) {
1349 age_mic_context(&ai->mod[0].mCtx, &ai->mod[1].mCtx,
1350 mic_rid.multicast, sizeof(mic_rid.multicast),
1351 ai->tfm);
1352 }
1353
1354 if (mic_rid.unicastValid) {
1355 age_mic_context(&ai->mod[0].uCtx, &ai->mod[1].uCtx,
1356 mic_rid.unicast, sizeof(mic_rid.unicast),
1357 ai->tfm);
1358 } 1358 }
1359} 1359}
1360 1360