drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/fm10k/fm10k_tlv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/fm10k/fm10k_tlv.c- Extension
.c- Size
- 24344 bytes
- Lines
- 851
- 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
fm10k_tlv.h
Detected Declarations
function fm10k_tlv_msg_initfunction fm10k_tlv_attr_put_null_stringfunction fm10k_tlv_attr_get_null_stringfunction fm10k_tlv_attr_put_mac_vlanfunction fm10k_tlv_attr_get_mac_vlanfunction fm10k_tlv_attr_put_boolfunction fm10k_tlv_attr_put_valuefunction fm10k_tlv_attr_get_valuefunction fm10k_tlv_attr_put_le_structfunction fm10k_tlv_attr_get_le_structfunction fm10k_tlv_attr_nest_stopfunction fm10k_tlv_attr_validatefunction fm10k_tlv_attr_parsefunction fm10k_tlv_msg_parsefunction fm10k_tlv_msg_errorfunction fm10k_tlv_msg_test_generate_datafunction fm10k_tlv_msg_test_createfunction fm10k_tlv_msg_test
Annotated Snippet
if (len && !(len % 4)) {
attr[len / 4] = attr_data;
attr_data = 0;
}
/* record character to offset location */
attr_data |= (u32)(*string) << (8 * (len % 4));
len++;
/* test for NULL and then increment */
} while (*(string++));
/* write last piece of data to message */
attr[(len + 3) / 4] = attr_data;
/* record attribute header, update message length */
len <<= FM10K_TLV_LEN_SHIFT;
attr[0] = len | attr_id;
/* add header length to length */
len += FM10K_TLV_HDR_LEN << FM10K_TLV_LEN_SHIFT;
*msg += FM10K_TLV_LEN_ALIGN(len);
return 0;
}
/**
* fm10k_tlv_attr_get_null_string - Get null terminated string from attribute
* @attr: Pointer to attribute
* @string: Pointer to location of destination string
*
* This function pulls the string back out of the attribute and will place
* it in the array pointed by string. It will return success if provided
* with a valid pointers.
**/
static s32 fm10k_tlv_attr_get_null_string(u32 *attr, unsigned char *string)
{
u32 len;
/* verify pointers are not NULL */
if (!string || !attr)
return FM10K_ERR_PARAM;
len = *attr >> FM10K_TLV_LEN_SHIFT;
attr++;
while (len--)
string[len] = (u8)(attr[len / 4] >> (8 * (len % 4)));
return 0;
}
/**
* fm10k_tlv_attr_put_mac_vlan - Store MAC/VLAN attribute in message
* @msg: Pointer to message block
* @attr_id: Attribute ID
* @mac_addr: MAC address to be stored
* @vlan: VLAN to be stored
*
* This function will reorder a MAC address to be CPU endian and store it
* in the attribute buffer. It will return success if provided with a
* valid pointers.
**/
s32 fm10k_tlv_attr_put_mac_vlan(u32 *msg, u16 attr_id,
const u8 *mac_addr, u16 vlan)
{
u32 len = ETH_ALEN << FM10K_TLV_LEN_SHIFT;
u32 *attr;
/* verify pointers are not NULL */
if (!msg || !mac_addr)
return FM10K_ERR_PARAM;
attr = &msg[FM10K_TLV_DWORD_LEN(*msg)];
/* record attribute header, update message length */
attr[0] = len | attr_id;
/* copy value into local variable and then write to msg */
attr[1] = le32_to_cpu(*(const __le32 *)&mac_addr[0]);
attr[2] = le16_to_cpu(*(const __le16 *)&mac_addr[4]);
attr[2] |= (u32)vlan << 16;
/* add header length to length */
len += FM10K_TLV_HDR_LEN << FM10K_TLV_LEN_SHIFT;
*msg += FM10K_TLV_LEN_ALIGN(len);
return 0;
}
Annotation
- Immediate include surface: `fm10k_tlv.h`.
- Detected declarations: `function fm10k_tlv_msg_init`, `function fm10k_tlv_attr_put_null_string`, `function fm10k_tlv_attr_get_null_string`, `function fm10k_tlv_attr_put_mac_vlan`, `function fm10k_tlv_attr_get_mac_vlan`, `function fm10k_tlv_attr_put_bool`, `function fm10k_tlv_attr_put_value`, `function fm10k_tlv_attr_get_value`, `function fm10k_tlv_attr_put_le_struct`, `function fm10k_tlv_attr_get_le_struct`.
- 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.