drivers/net/dsa/qca/ar9331.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/qca/ar9331.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/qca/ar9331.c- Extension
.c- Size
- 32794 bytes
- Lines
- 1143
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitfield.hlinux/module.hlinux/of_irq.hlinux/of_mdio.hlinux/regmap.hlinux/reset.hnet/dsa.h
Detected Declarations
struct ar9331_sw_stats_rawstruct ar9331_sw_portstruct ar9331_sw_privfunction ar9331_sw_resetfunction ar9331_sw_mbus_writefunction ar9331_sw_mbus_readfunction ar9331_sw_mbus_initfunction ar9331_sw_setup_portfunction ar9331_sw_setupfunction ar9331_sw_port_disablefunction ar9331_sw_get_tag_protocolfunction ar9331_sw_phylink_get_capsfunction ar9331_sw_phylink_mac_configfunction ar9331_sw_phylink_mac_link_downfunction ar9331_sw_phylink_mac_link_upfunction ar9331_read_statsfunction ar9331_do_stats_pollfunction ar9331_get_stats64function ar9331_get_pause_statsfunction ar9331_sw_irqfunction ar9331_sw_mask_irqfunction ar9331_sw_unmask_irqfunction ar9331_sw_irq_bus_lockfunction ar9331_sw_irq_bus_sync_unlockfunction ar9331_sw_irq_mapfunction ar9331_sw_irq_unmapfunction ar9331_sw_irq_initfunction __ar9331_mdio_writefunction __ar9331_mdio_readfunction ar9331_mdio_readfunction ar9331_mdio_writefunction ar9331_sw_bus_writefunction ar9331_sw_probefunction ar9331_sw_removefunction ar9331_sw_shutdown
Annotated Snippet
struct ar9331_sw_stats_raw {
u32 rxbroad; /* 0x00 */
u32 rxpause; /* 0x04 */
u32 rxmulti; /* 0x08 */
u32 rxfcserr; /* 0x0c */
u32 rxalignerr; /* 0x10 */
u32 rxrunt; /* 0x14 */
u32 rxfragment; /* 0x18 */
u32 rx64byte; /* 0x1c */
u32 rx128byte; /* 0x20 */
u32 rx256byte; /* 0x24 */
u32 rx512byte; /* 0x28 */
u32 rx1024byte; /* 0x2c */
u32 rx1518byte; /* 0x30 */
u32 rxmaxbyte; /* 0x34 */
u32 rxtoolong; /* 0x38 */
u32 rxgoodbyte; /* 0x3c */
u32 rxgoodbyte_hi;
u32 rxbadbyte; /* 0x44 */
u32 rxbadbyte_hi;
u32 rxoverflow; /* 0x4c */
u32 filtered; /* 0x50 */
u32 txbroad; /* 0x54 */
u32 txpause; /* 0x58 */
u32 txmulti; /* 0x5c */
u32 txunderrun; /* 0x60 */
u32 tx64byte; /* 0x64 */
u32 tx128byte; /* 0x68 */
u32 tx256byte; /* 0x6c */
u32 tx512byte; /* 0x70 */
u32 tx1024byte; /* 0x74 */
u32 tx1518byte; /* 0x78 */
u32 txmaxbyte; /* 0x7c */
u32 txoversize; /* 0x80 */
u32 txbyte; /* 0x84 */
u32 txbyte_hi;
u32 txcollision; /* 0x8c */
u32 txabortcol; /* 0x90 */
u32 txmulticol; /* 0x94 */
u32 txsinglecol; /* 0x98 */
u32 txexcdefer; /* 0x9c */
u32 txdefer; /* 0xa0 */
u32 txlatecol; /* 0xa4 */
};
struct ar9331_sw_port {
int idx;
struct delayed_work mib_read;
struct rtnl_link_stats64 stats;
struct ethtool_pause_stats pause_stats;
struct spinlock stats_lock;
};
struct ar9331_sw_priv {
struct device *dev;
struct dsa_switch ds;
struct dsa_switch_ops ops;
struct irq_domain *irqdomain;
u32 irq_mask;
struct mutex lock_irq;
struct mii_bus *mbus; /* mdio master */
struct mii_bus *sbus; /* mdio slave */
struct regmap *regmap;
struct reset_control *sw_reset;
struct ar9331_sw_port port[AR9331_SW_PORTS];
};
static struct ar9331_sw_priv *ar9331_sw_port_to_priv(struct ar9331_sw_port *port)
{
struct ar9331_sw_port *p = port - port->idx;
return (struct ar9331_sw_priv *)((void *)p -
offsetof(struct ar9331_sw_priv, port));
}
/* Warning: switch reset will reset last AR9331_SW_MDIO_PHY_MODE_PAGE request
* If some kind of optimization is used, the request should be repeated.
*/
static int ar9331_sw_reset(struct ar9331_sw_priv *priv)
{
int ret;
ret = reset_control_assert(priv->sw_reset);
if (ret)
goto error;
/* AR9331 doc do not provide any information about proper reset
* sequence. The AR8136 (the closes switch to the AR9331) doc says:
* reset duration should be greater than 10ms. So, let's use this value
* for now.
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/module.h`, `linux/of_irq.h`, `linux/of_mdio.h`, `linux/regmap.h`, `linux/reset.h`, `net/dsa.h`.
- Detected declarations: `struct ar9331_sw_stats_raw`, `struct ar9331_sw_port`, `struct ar9331_sw_priv`, `function ar9331_sw_reset`, `function ar9331_sw_mbus_write`, `function ar9331_sw_mbus_read`, `function ar9331_sw_mbus_init`, `function ar9331_sw_setup_port`, `function ar9331_sw_setup`, `function ar9331_sw_port_disable`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.