drivers/net/ethernet/netronome/nfp/nfp_asm.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfp_asm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfp_asm.c- Extension
.c- Size
- 7495 bytes
- Lines
- 321
- 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/bitops.hlinux/errno.hlinux/kernel.hlinux/string.hlinux/types.hnfp_asm.h
Detected Declarations
function unreg_is_immfunction br_get_offsetfunction br_set_offsetfunction br_add_offsetfunction immed_can_modifyfunction immed_get_valuefunction immed_set_valuefunction immed_add_valuefunction nfp_swreg_to_unregfunction swreg_to_unrestrictedfunction nfp_swreg_to_reregfunction swreg_to_restrictedfunction parityfunction nfp_ustore_check_valid_no_eccfunction nfp_ustore_calc_ecc_insn
Annotated Snippet
FIELD_GET(OP_IMMED_WIDTH, instr) != IMMED_WIDTH_ALL) {
pr_err("Can't decode/encode immed!\n");
return false;
}
return true;
}
u16 immed_get_value(u64 instr)
{
u16 reg;
if (!immed_can_modify(instr))
return 0;
reg = FIELD_GET(OP_IMMED_A_SRC, instr);
if (!unreg_is_imm(reg))
reg = FIELD_GET(OP_IMMED_B_SRC, instr);
return (reg & 0xff) | FIELD_GET(OP_IMMED_IMM, instr) << 8;
}
void immed_set_value(u64 *instr, u16 immed)
{
if (!immed_can_modify(*instr))
return;
if (unreg_is_imm(FIELD_GET(OP_IMMED_A_SRC, *instr))) {
*instr &= ~FIELD_PREP(OP_IMMED_A_SRC, 0xff);
*instr |= FIELD_PREP(OP_IMMED_A_SRC, immed & 0xff);
} else {
*instr &= ~FIELD_PREP(OP_IMMED_B_SRC, 0xff);
*instr |= FIELD_PREP(OP_IMMED_B_SRC, immed & 0xff);
}
*instr &= ~OP_IMMED_IMM;
*instr |= FIELD_PREP(OP_IMMED_IMM, immed >> 8);
}
void immed_add_value(u64 *instr, u16 offset)
{
u16 val;
if (!immed_can_modify(*instr))
return;
val = immed_get_value(*instr);
immed_set_value(instr, val + offset);
}
static u16 nfp_swreg_to_unreg(swreg reg, bool is_dst)
{
bool lm_id, lm_dec = false;
u16 val = swreg_value(reg);
switch (swreg_type(reg)) {
case NN_REG_GPR_A:
case NN_REG_GPR_B:
case NN_REG_GPR_BOTH:
return val;
case NN_REG_NNR:
return UR_REG_NN | val;
case NN_REG_XFER:
return UR_REG_XFR | val;
case NN_REG_LMEM:
lm_id = swreg_lm_idx(reg);
switch (swreg_lm_mode(reg)) {
case NN_LM_MOD_NONE:
if (val & ~UR_REG_LM_IDX_MAX) {
pr_err("LM offset too large\n");
return 0;
}
return UR_REG_LM | FIELD_PREP(UR_REG_LM_IDX, lm_id) |
val;
case NN_LM_MOD_DEC:
lm_dec = true;
fallthrough;
case NN_LM_MOD_INC:
if (val) {
pr_err("LM offset in inc/dev mode\n");
return 0;
}
return UR_REG_LM | UR_REG_LM_POST_MOD |
FIELD_PREP(UR_REG_LM_IDX, lm_id) |
FIELD_PREP(UR_REG_LM_POST_MOD_DEC, lm_dec);
default:
pr_err("bad LM mode for unrestricted operands %d\n",
swreg_lm_mode(reg));
return 0;
}
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/errno.h`, `linux/kernel.h`, `linux/string.h`, `linux/types.h`, `nfp_asm.h`.
- Detected declarations: `function unreg_is_imm`, `function br_get_offset`, `function br_set_offset`, `function br_add_offset`, `function immed_can_modify`, `function immed_get_value`, `function immed_set_value`, `function immed_add_value`, `function nfp_swreg_to_unreg`, `function swreg_to_unrestricted`.
- 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.