drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.c- Extension
.c- Size
- 1725 bytes
- Lines
- 85
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/unaligned.hlinux/math.hlinux/string.hlinux/bug.hxtlv.h
Detected Declarations
function Copyrightfunction brcmf_xtlv_data_sizefunction brcmf_xtlv_pack_header
Annotated Snippet
// SPDX-License-Identifier: ISC
/*
* Copyright (c) 2019 Broadcom
*/
#include <linux/unaligned.h>
#include <linux/math.h>
#include <linux/string.h>
#include <linux/bug.h>
#include "xtlv.h"
static int brcmf_xtlv_header_size(u16 opts)
{
int len = (int)offsetof(struct brcmf_xtlv, data);
if (opts & BRCMF_XTLV_OPTION_IDU8)
--len;
if (opts & BRCMF_XTLV_OPTION_LENU8)
--len;
return len;
}
int brcmf_xtlv_data_size(int dlen, u16 opts)
{
int hsz;
hsz = brcmf_xtlv_header_size(opts);
if (opts & BRCMF_XTLV_OPTION_ALIGN32)
return roundup(dlen + hsz, 4);
return dlen + hsz;
}
void brcmf_xtlv_pack_header(struct brcmf_xtlv *xtlv, u16 id, u16 len,
const u8 *data, u16 opts)
{
u8 *data_buf;
u16 mask = BRCMF_XTLV_OPTION_IDU8 | BRCMF_XTLV_OPTION_LENU8;
if (!(opts & mask)) {
u8 *idp = (u8 *)xtlv;
u8 *lenp = idp + sizeof(xtlv->id);
put_unaligned_le16(id, idp);
put_unaligned_le16(len, lenp);
data_buf = lenp + sizeof(u16);
} else if ((opts & mask) == mask) { /* u8 id and u8 len */
u8 *idp = (u8 *)xtlv;
u8 *lenp = idp + 1;
*idp = (u8)id;
*lenp = (u8)len;
data_buf = lenp + sizeof(u8);
} else if (opts & BRCMF_XTLV_OPTION_IDU8) { /* u8 id, u16 len */
u8 *idp = (u8 *)xtlv;
u8 *lenp = idp + 1;
*idp = (u8)id;
put_unaligned_le16(len, lenp);
data_buf = lenp + sizeof(u16);
} else if (opts & BRCMF_XTLV_OPTION_LENU8) { /* u16 id, u8 len */
u8 *idp = (u8 *)xtlv;
u8 *lenp = idp + sizeof(u16);
put_unaligned_le16(id, idp);
*lenp = (u8)len;
data_buf = lenp + sizeof(u8);
} else {
WARN(true, "Unexpected xtlv option");
return;
}
if (opts & BRCMF_XTLV_OPTION_LENU8) {
WARN_ON(len > 0x00ff);
len &= 0xff;
}
if (data)
memcpy(data_buf, data, len);
}
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/math.h`, `linux/string.h`, `linux/bug.h`, `xtlv.h`.
- Detected declarations: `function Copyright`, `function brcmf_xtlv_data_size`, `function brcmf_xtlv_pack_header`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.