drivers/net/wireless/silabs/wfx/key.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/silabs/wfx/key.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/silabs/wfx/key.c- Extension
.c- Size
- 7619 bytes
- Lines
- 228
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/etherdevice.hnet/mac80211.hkey.hwfx.hhif_tx_mib.h
Detected Declarations
function Copyrightfunction wfx_free_keyfunction fill_wep_pairfunction fill_wep_groupfunction fill_tkip_pairfunction fill_tkip_groupfunction fill_ccmp_pairfunction fill_ccmp_groupfunction fill_sms4_pairfunction fill_sms4_groupfunction fill_aes_cmac_groupfunction wfx_add_keyfunction wfx_remove_keyfunction wfx_set_key
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Key management related functions.
*
* Copyright (c) 2017-2020, Silicon Laboratories, Inc.
* Copyright (c) 2010, ST-Ericsson
*/
#include <linux/etherdevice.h>
#include <net/mac80211.h>
#include "key.h"
#include "wfx.h"
#include "hif_tx_mib.h"
static int wfx_alloc_key(struct wfx_dev *wdev)
{
int idx;
idx = ffs(~wdev->key_map) - 1;
if (idx < 0 || idx >= MAX_KEY_ENTRIES)
return -1;
wdev->key_map |= BIT(idx);
return idx;
}
static void wfx_free_key(struct wfx_dev *wdev, int idx)
{
WARN(!(wdev->key_map & BIT(idx)), "inconsistent key allocation");
wdev->key_map &= ~BIT(idx);
}
static u8 fill_wep_pair(struct wfx_hif_wep_pairwise_key *msg,
struct ieee80211_key_conf *key, u8 *peer_addr)
{
WARN(key->keylen > sizeof(msg->key_data), "inconsistent data");
msg->key_length = key->keylen;
memcpy(msg->key_data, key->key, key->keylen);
ether_addr_copy(msg->peer_address, peer_addr);
return HIF_KEY_TYPE_WEP_PAIRWISE;
}
static u8 fill_wep_group(struct wfx_hif_wep_group_key *msg,
struct ieee80211_key_conf *key)
{
WARN(key->keylen > sizeof(msg->key_data), "inconsistent data");
msg->key_id = key->keyidx;
msg->key_length = key->keylen;
memcpy(msg->key_data, key->key, key->keylen);
return HIF_KEY_TYPE_WEP_DEFAULT;
}
static u8 fill_tkip_pair(struct wfx_hif_tkip_pairwise_key *msg,
struct ieee80211_key_conf *key, u8 *peer_addr)
{
u8 *keybuf = key->key;
WARN(key->keylen != sizeof(msg->tkip_key_data) + sizeof(msg->tx_mic_key) +
sizeof(msg->rx_mic_key), "inconsistent data");
memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data));
keybuf += sizeof(msg->tkip_key_data);
memcpy(msg->tx_mic_key, keybuf, sizeof(msg->tx_mic_key));
keybuf += sizeof(msg->tx_mic_key);
memcpy(msg->rx_mic_key, keybuf, sizeof(msg->rx_mic_key));
ether_addr_copy(msg->peer_address, peer_addr);
return HIF_KEY_TYPE_TKIP_PAIRWISE;
}
static u8 fill_tkip_group(struct wfx_hif_tkip_group_key *msg, struct ieee80211_key_conf *key,
struct ieee80211_key_seq *seq, enum nl80211_iftype iftype)
{
u8 *keybuf = key->key;
WARN(key->keylen != sizeof(msg->tkip_key_data) + 2 * sizeof(msg->rx_mic_key),
"inconsistent data");
msg->key_id = key->keyidx;
memcpy(msg->rx_sequence_counter, &seq->tkip.iv16, sizeof(seq->tkip.iv16));
memcpy(msg->rx_sequence_counter + sizeof(u16), &seq->tkip.iv32, sizeof(seq->tkip.iv32));
memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data));
keybuf += sizeof(msg->tkip_key_data);
if (iftype == NL80211_IFTYPE_AP)
/* Use Tx MIC Key */
memcpy(msg->rx_mic_key, keybuf + 0, sizeof(msg->rx_mic_key));
else
/* Use Rx MIC Key */
memcpy(msg->rx_mic_key, keybuf + 8, sizeof(msg->rx_mic_key));
return HIF_KEY_TYPE_TKIP_GROUP;
}
static u8 fill_ccmp_pair(struct wfx_hif_aes_pairwise_key *msg,
Annotation
- Immediate include surface: `linux/etherdevice.h`, `net/mac80211.h`, `key.h`, `wfx.h`, `hif_tx_mib.h`.
- Detected declarations: `function Copyright`, `function wfx_free_key`, `function fill_wep_pair`, `function fill_wep_group`, `function fill_tkip_pair`, `function fill_tkip_group`, `function fill_ccmp_pair`, `function fill_ccmp_group`, `function fill_sms4_pair`, `function fill_sms4_group`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.