drivers/net/dsa/qca/qca8k-8xxx.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/qca/qca8k-8xxx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/qca/qca8k-8xxx.c- Extension
.c- Size
- 56421 bytes
- Lines
- 2238
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/phy.hlinux/netdevice.hlinux/bitfield.hlinux/regmap.hnet/dsa.hlinux/of_net.hlinux/of_mdio.hlinux/of_platform.hlinux/mdio.hlinux/phylink.hlinux/gpio/consumer.hlinux/etherdevice.hlinux/dsa/tag_qca.hqca8k.hqca8k_leds.h
Detected Declarations
function Copyrightfunction qca8k_mii_write_lofunction qca8k_mii_write_hifunction qca8k_mii_read_lofunction qca8k_mii_read_hifunction qca8k_mii_read32function qca8k_mii_write32function qca8k_set_pagefunction qca8k_rw_reg_ack_handlerfunction qca8k_mdio_header_fill_seq_numfunction qca8k_read_ethfunction qca8k_write_ethfunction qca8k_regmap_update_bits_ethfunction qca8k_read_miifunction qca8k_write_miifunction qca8k_regmap_update_bits_miifunction qca8k_bulk_readfunction qca8k_bulk_gather_writefunction qca8k_bulk_writefunction qca8k_regmap_update_bitsfunction qca8k_phy_eth_busy_waitfunction qca8k_phy_eth_commandfunction qca8k_mdio_busy_waitfunction qca8k_mdio_writefunction qca8k_mdio_readfunction qca8k_internal_mdio_writefunction qca8k_internal_mdio_readfunction qca8k_legacy_mdio_writefunction qca8k_legacy_mdio_readfunction qca8k_mdio_registerfunction qca8k_setup_mdio_busfunction for_each_available_child_of_nodefunction qca8k_setup_mac_pwr_selfunction qca8k_find_cpu_portfunction qca8k_setup_of_pws_regfunction qca8k_parse_port_configfunction qca8k_mac_config_setup_internal_delayfunction qca8k_phylink_mac_select_pcsfunction qca8k_phylink_mac_configfunction qca8k_phylink_get_capsfunction qca8k_phylink_mac_link_downfunction qca8k_phylink_mac_link_upfunction qca8k_pcs_get_statefunction qca8k_pcs_configfunction qca8k_pcs_an_restartfunction qca8k_setup_pcsfunction qca8k_mib_autocast_handlerfunction qca8k_get_ethtool_stats_eth
Annotated Snippet
if (len > QCA_HDR_MGMT_DATA1_LEN) {
__le32 *data2 = (__le32 *)skb->data;
int data_len = min_t(int, QCA_HDR_MGMT_DATA2_LEN,
len - QCA_HDR_MGMT_DATA1_LEN);
val++;
for (i = sizeof(u32); i <= data_len; i += sizeof(u32)) {
*val = get_unaligned_le32(data2);
val++;
data2++;
}
}
}
complete(&mgmt_eth_data->rw_done);
}
static struct sk_buff *qca8k_alloc_mdio_header(enum mdio_cmd cmd, u32 reg, u32 *val,
int priority, unsigned int len)
{
struct qca_mgmt_ethhdr *mgmt_ethhdr;
unsigned int real_len;
struct sk_buff *skb;
__le32 *data2;
u32 command;
u16 hdr;
int i;
skb = dev_alloc_skb(QCA_HDR_MGMT_PKT_LEN);
if (!skb)
return NULL;
/* Hdr mgmt length value is in step of word size.
* As an example to process 4 byte of data the correct length to set is 2.
* To process 8 byte 4, 12 byte 6, 16 byte 8...
*
* Odd values will always return the next size on the ack packet.
* (length of 3 (6 byte) will always return 8 bytes of data)
*
* This means that a value of 15 (0xf) actually means reading/writing 32 bytes
* of data.
*
* To correctly calculate the length we devide the requested len by word and
* round up.
* On the ack function we can skip the odd check as we already handle the
* case here.
*/
real_len = DIV_ROUND_UP(len, sizeof(u16));
/* We check if the result len is odd and we round up another time to
* the next size. (length of 3 will be increased to 4 as switch will always
* return 8 bytes)
*/
if (real_len % sizeof(u16) != 0)
real_len++;
/* Max reg value is 0xf(15) but switch will always return the next size (32 byte) */
if (real_len == 16)
real_len--;
skb_reset_mac_header(skb);
skb_set_network_header(skb, skb->len);
mgmt_ethhdr = skb_push(skb, QCA_HDR_MGMT_HEADER_LEN + QCA_HDR_LEN);
hdr = FIELD_PREP(QCA_HDR_XMIT_VERSION, QCA_HDR_VERSION);
hdr |= FIELD_PREP(QCA_HDR_XMIT_PRIORITY, priority);
hdr |= QCA_HDR_XMIT_FROM_CPU;
hdr |= FIELD_PREP(QCA_HDR_XMIT_DP_BIT, BIT(0));
hdr |= FIELD_PREP(QCA_HDR_XMIT_CONTROL, QCA_HDR_XMIT_TYPE_RW_REG);
command = FIELD_PREP(QCA_HDR_MGMT_ADDR, reg);
command |= FIELD_PREP(QCA_HDR_MGMT_LENGTH, real_len);
command |= FIELD_PREP(QCA_HDR_MGMT_CMD, cmd);
command |= FIELD_PREP(QCA_HDR_MGMT_CHECK_CODE,
QCA_HDR_MGMT_CHECK_CODE_VAL);
put_unaligned_le32(command, &mgmt_ethhdr->command);
if (cmd == MDIO_WRITE)
put_unaligned_le32(*val, &mgmt_ethhdr->mdio_data);
mgmt_ethhdr->hdr = htons(hdr);
data2 = skb_put_zero(skb, QCA_HDR_MGMT_DATA2_LEN + QCA_HDR_MGMT_PADDING_LEN);
if (cmd == MDIO_WRITE && len > QCA_HDR_MGMT_DATA1_LEN) {
int data_len = min_t(int, QCA_HDR_MGMT_DATA2_LEN,
len - QCA_HDR_MGMT_DATA1_LEN);
Annotation
- Immediate include surface: `linux/module.h`, `linux/phy.h`, `linux/netdevice.h`, `linux/bitfield.h`, `linux/regmap.h`, `net/dsa.h`, `linux/of_net.h`, `linux/of_mdio.h`.
- Detected declarations: `function Copyright`, `function qca8k_mii_write_lo`, `function qca8k_mii_write_hi`, `function qca8k_mii_read_lo`, `function qca8k_mii_read_hi`, `function qca8k_mii_read32`, `function qca8k_mii_write32`, `function qca8k_set_page`, `function qca8k_rw_reg_ack_handler`, `function qca8k_mdio_header_fill_seq_num`.
- 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.