drivers/net/can/rcar/rcar_can.c
Source file repositories/reference/linux-study-clean/drivers/net/can/rcar/rcar_can.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/rcar/rcar_can.c- Extension
.c- Size
- 27122 bytes
- Lines
- 918
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bits.hlinux/module.hlinux/kernel.hlinux/types.hlinux/interrupt.hlinux/errno.hlinux/ethtool.hlinux/netdevice.hlinux/platform_device.hlinux/can/dev.hlinux/clk.hlinux/of.hlinux/pm_runtime.h
Detected Declarations
struct rcar_can_mbox_regsstruct rcar_can_regsstruct rcar_can_privenum CLKRfunction tx_failure_cleanupfunction rcar_can_errorfunction rcar_can_tx_donefunction rcar_can_interruptfunction rcar_can_set_bittimingfunction rcar_can_startfunction rcar_can_openfunction rcar_can_stopfunction rcar_can_closefunction rcar_can_start_xmitfunction rcar_can_rx_pktfunction rcar_can_rx_pollfunction rcar_can_do_set_modefunction rcar_can_get_berr_counterfunction rcar_can_probefunction rcar_can_removefunction rcar_can_suspendfunction rcar_can_resume
Annotated Snippet
static const struct net_device_ops rcar_can_netdev_ops = {
.ndo_open = rcar_can_open,
.ndo_stop = rcar_can_close,
.ndo_start_xmit = rcar_can_start_xmit,
};
static const struct ethtool_ops rcar_can_ethtool_ops = {
.get_ts_info = ethtool_op_get_ts_info,
};
static void rcar_can_rx_pkt(struct rcar_can_priv *priv)
{
struct net_device_stats *stats = &priv->ndev->stats;
struct can_frame *cf;
struct sk_buff *skb;
u32 data;
u8 dlc;
skb = alloc_can_skb(priv->ndev, &cf);
if (!skb) {
stats->rx_dropped++;
return;
}
data = readl(&priv->regs->mb[RCAR_CAN_RX_FIFO_MBX].id);
if (data & RCAR_CAN_IDE)
cf->can_id = FIELD_GET(RCAR_CAN_EID, data) | CAN_EFF_FLAG;
else
cf->can_id = FIELD_GET(RCAR_CAN_SID, data);
dlc = readb(&priv->regs->mb[RCAR_CAN_RX_FIFO_MBX].dlc);
cf->len = can_cc_dlc2len(dlc);
if (data & RCAR_CAN_RTR) {
cf->can_id |= CAN_RTR_FLAG;
} else {
for (dlc = 0; dlc < cf->len; dlc++)
cf->data[dlc] =
readb(&priv->regs->mb[RCAR_CAN_RX_FIFO_MBX].data[dlc]);
stats->rx_bytes += cf->len;
}
stats->rx_packets++;
netif_receive_skb(skb);
}
static int rcar_can_rx_poll(struct napi_struct *napi, int quota)
{
struct rcar_can_priv *priv = container_of(napi,
struct rcar_can_priv, napi);
int num_pkts;
for (num_pkts = 0; num_pkts < quota; num_pkts++) {
u8 rfcr, isr;
isr = readb(&priv->regs->isr);
/* Clear interrupt bit */
if (isr & RCAR_CAN_ISR_RXFF)
writeb(isr & ~RCAR_CAN_ISR_RXFF, &priv->regs->isr);
rfcr = readb(&priv->regs->rfcr);
if (rfcr & RCAR_CAN_RFCR_RFEST)
break;
rcar_can_rx_pkt(priv);
/* Write 0xff to the RFPCR register to increment
* the CPU-side pointer for the receive FIFO
* to the next mailbox location
*/
writeb(0xff, &priv->regs->rfpcr);
}
/* All packets processed */
if (num_pkts < quota) {
napi_complete_done(napi, num_pkts);
priv->ier |= RCAR_CAN_IER_RXFIE;
writeb(priv->ier, &priv->regs->ier);
}
return num_pkts;
}
static int rcar_can_do_set_mode(struct net_device *ndev, enum can_mode mode)
{
switch (mode) {
case CAN_MODE_START:
rcar_can_start(ndev);
netif_wake_queue(ndev);
return 0;
default:
return -EOPNOTSUPP;
}
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/interrupt.h`, `linux/errno.h`, `linux/ethtool.h`.
- Detected declarations: `struct rcar_can_mbox_regs`, `struct rcar_can_regs`, `struct rcar_can_priv`, `enum CLKR`, `function tx_failure_cleanup`, `function rcar_can_error`, `function rcar_can_tx_done`, `function rcar_can_interrupt`, `function rcar_can_set_bittiming`, `function rcar_can_start`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.