drivers/net/dsa/realtek/rtl8365mb_table.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/realtek/rtl8365mb_table.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/realtek/rtl8365mb_table.c- Extension
.c- Size
- 6270 bytes
- Lines
- 215
- 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
rtl8365mb_table.hlinux/regmap.h
Detected Declarations
function Copyrightfunction rtl8365mb_table_query
Annotated Snippet
switch (method) {
case RTL8365MB_TABLE_L2_METHOD_MAC:
/*
* Method MAC requires as input the same L2 table format
* you'll get as result. However, it might only use mac
* address and FID/VID fields.
*/
write_data = true;
/* METHOD_MAC does not use addr as input, but may return
* the matched index.
*/
addr_as_input = false;
break;
case RTL8365MB_TABLE_L2_METHOD_ADDR:
case RTL8365MB_TABLE_L2_METHOD_ADDR_NEXT:
case RTL8365MB_TABLE_L2_METHOD_ADDR_NEXT_UC:
case RTL8365MB_TABLE_L2_METHOD_ADDR_NEXT_MC:
break;
case RTL8365MB_TABLE_L2_METHOD_ADDR_NEXT_UC_PORT:
cmd |= FIELD_PREP(RTL8365MB_TABLE_CTRL_PORT_MASK, port);
break;
default:
return -EINVAL;
}
} else if (op == RTL8365MB_TABLE_OP_WRITE) {
write_data = true;
/* Writing to L2 does not use addr as input, as the table index
* is derived from key fields.
*/
if (table == RTL8365MB_TABLE_L2)
addr_as_input = false;
}
/* To prevent concurrent access to the look-up tables, take the regmap
* lock manually and access via the map_nolock regmap.
*/
mutex_lock(&priv->map_lock);
/* Protect from a busy table access (i.e. previous access timeouts) */
ret = rtl8365mb_table_poll_busy(priv);
if (ret)
goto out;
/* Write entry data if writing to the table (or L2_METHOD_MAC) */
if (write_data) {
/* bulk write data up to 9th word */
ret = regmap_bulk_write(priv->map_nolock,
RTL8365MB_TABLE_WRITE_BASE,
data,
min_t(size_t, size,
RTL8365MB_TABLE_ENTRY_MAX_SIZE -
1));
if (ret)
goto out;
/* 10th register uses only 4 least significant bits */
if (size == RTL8365MB_TABLE_ENTRY_MAX_SIZE) {
val = FIELD_PREP(RTL8365MB_TABLE_10TH_DATA_MASK,
data[size - 1]);
ret = regmap_update_bits(priv->map_nolock,
RTL8365MB_TABLE_WRITE_10TH_REG,
RTL8365MB_TABLE_10TH_DATA_MASK,
val);
}
if (ret)
goto out;
}
/* Write address (if needed) */
if (addr_as_input) {
ret = regmap_write(priv->map_nolock,
RTL8365MB_TABLE_ACCESS_ADDR_REG,
FIELD_PREP(RTL8365MB_TABLE_ADDR_MASK,
*addr));
if (ret)
goto out;
}
/* Execute */
ret = regmap_write(priv->map_nolock, RTL8365MB_TABLE_CTRL_REG, cmd);
if (ret)
goto out;
/* Poll for completion */
ret = rtl8365mb_table_poll_busy(priv);
if (ret)
Annotation
- Immediate include surface: `rtl8365mb_table.h`, `linux/regmap.h`.
- Detected declarations: `function Copyright`, `function rtl8365mb_table_query`.
- 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.