b43: Add key memory dumping
authorMichael Buesch <mb@bu3sch.de>
Fri, 19 Dec 2008 19:24:30 +0000 (20:24 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 19 Dec 2008 20:24:06 +0000 (15:24 -0500)
This adds an option to dump all crypto related memory to
the kernel log.
Obviously, it should not be enabled on productive systems. ;)

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/debugfs.c
drivers/net/wireless/b43/debugfs.h
drivers/net/wireless/b43/main.c

index 06a01da801604c91dcf92408871f622e2ccd947d..e04fc91f569ea573f3c9d3dfad8551b710d98c32 100644 (file)
@@ -731,6 +731,7 @@ static void b43_add_dynamic_debug(struct b43_wldev *dev)
        add_dyn_dbg("debug_pwork_stop", B43_DBG_PWORK_STOP, 0);
        add_dyn_dbg("debug_lo", B43_DBG_LO, 0);
        add_dyn_dbg("debug_firmware", B43_DBG_FIRMWARE, 0);
+       add_dyn_dbg("debug_keys", B43_DBG_KEYS, 0);
 
 #undef add_dyn_dbg
 }
index 22ffd02ba554806a8625319b5c2fd2aeae1cdcba..7886cbe2d1d19276f22e3a974dd4d7e44a55347b 100644 (file)
@@ -12,6 +12,7 @@ enum b43_dyndbg {             /* Dynamic debugging features */
        B43_DBG_PWORK_STOP,
        B43_DBG_LO,
        B43_DBG_FIRMWARE,
+       B43_DBG_KEYS,
        __B43_NR_DYNDBG,
 };
 
index 07dc9886d9688cf473ba33ed395b048ff39c483a..7b31a327b24a33e643be1021360af7fdcb8273da 100644 (file)
@@ -992,6 +992,52 @@ static void b43_clear_keys(struct b43_wldev *dev)
                b43_key_clear(dev, i);
 }
 
+static void b43_dump_keymemory(struct b43_wldev *dev)
+{
+       unsigned int i, index, offset;
+       DECLARE_MAC_BUF(macbuf);
+       u8 mac[ETH_ALEN];
+       u16 algo;
+       u32 rcmta0;
+       u16 rcmta1;
+       u64 hf;
+       struct b43_key *key;
+
+       if (!b43_debug(dev, B43_DBG_KEYS))
+               return;
+
+       hf = b43_hf_read(dev);
+       b43dbg(dev->wl, "Hardware key memory dump:  USEDEFKEYS=%u\n",
+              !!(hf & B43_HF_USEDEFKEYS));
+       for (index = 0; index < dev->max_nr_keys; index++) {
+               key = &(dev->key[index]);
+               printk(KERN_DEBUG "Key slot %02u: %s",
+                      index, (key->keyconf == NULL) ? " " : "*");
+               offset = dev->ktp + (index * B43_SEC_KEYSIZE);
+               for (i = 0; i < B43_SEC_KEYSIZE; i += 2) {
+                       u16 tmp = b43_shm_read16(dev, B43_SHM_SHARED, offset + i);
+                       printk("%02X%02X", (tmp & 0xFF), ((tmp >> 8) & 0xFF));
+               }
+
+               algo = b43_shm_read16(dev, B43_SHM_SHARED,
+                                     B43_SHM_SH_KEYIDXBLOCK + (index * 2));
+               printk("   Algo: %04X/%02X", algo, key->algorithm);
+
+               if (index >= 4) {
+                       rcmta0 = b43_shm_read32(dev, B43_SHM_RCMTA,
+                                               ((index - 4) * 2) + 0);
+                       rcmta1 = b43_shm_read16(dev, B43_SHM_RCMTA,
+                                               ((index - 4) * 2) + 1);
+                       *((__le32 *)(&mac[0])) = cpu_to_le32(rcmta0);
+                       *((__le16 *)(&mac[4])) = cpu_to_le16(rcmta1);
+                       printk("   MAC: %s",
+                              print_mac(macbuf, mac));
+               } else
+                       printk("   DEFAULT KEY");
+               printk("\n");
+       }
+}
+
 void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags)
 {
        u32 macctl;
@@ -3565,15 +3611,18 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        default:
                B43_WARN_ON(1);
        }
+
 out_unlock:
-       spin_unlock_irqrestore(&wl->irq_lock, flags);
-       mutex_unlock(&wl->mutex);
        if (!err) {
                b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
                       "mac: %pM\n",
                       cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
                       addr);
+               b43_dump_keymemory(dev);
        }
+       spin_unlock_irqrestore(&wl->irq_lock, flags);
+       mutex_unlock(&wl->mutex);
+
        return err;
 }