drivers/net/can/spi/mcp251xfd/mcp251xfd-tx.c
Source file repositories/reference/linux-study-clean/drivers/net/can/spi/mcp251xfd/mcp251xfd-tx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/spi/mcp251xfd/mcp251xfd-tx.c- Extension
.c- Size
- 6273 bytes
- Lines
- 245
- 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/unaligned.hlinux/bitfield.hmcp251xfd.h
Detected Declarations
function mcp251xfd_tx_obj_from_skbfunction mcp251xfd_tx_failure_dropfunction mcp251xfd_tx_obj_write_syncfunction mcp251xfd_tx_obj_writefunction mcp251xfd_tx_busyfunction mcp251xfd_work_busyfunction mcp251xfd_start_xmit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// mcp251xfd - Microchip MCP251xFD Family CAN controller driver
//
// Copyright (c) 2019, 2020, 2021 Pengutronix,
// Marc Kleine-Budde <kernel@pengutronix.de>
//
// Based on:
//
// CAN bus driver for Microchip 25XXFD CAN Controller with SPI Interface
//
// Copyright (c) 2019 Martin Sperl <kernel@martin.sperl.org>
//
#include <linux/unaligned.h>
#include <linux/bitfield.h>
#include "mcp251xfd.h"
static inline struct
mcp251xfd_tx_obj *mcp251xfd_get_tx_obj_next(struct mcp251xfd_tx_ring *tx_ring)
{
u8 tx_head;
tx_head = mcp251xfd_get_tx_head(tx_ring);
return &tx_ring->obj[tx_head];
}
static void
mcp251xfd_tx_obj_from_skb(const struct mcp251xfd_priv *priv,
struct mcp251xfd_tx_obj *tx_obj,
const struct sk_buff *skb,
unsigned int seq)
{
const struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
struct mcp251xfd_hw_tx_obj_raw *hw_tx_obj;
union mcp251xfd_tx_obj_load_buf *load_buf;
u8 dlc;
u32 id, flags;
int len_sanitized = 0, len;
if (cfd->can_id & CAN_EFF_FLAG) {
u32 sid, eid;
sid = FIELD_GET(MCP251XFD_REG_FRAME_EFF_SID_MASK, cfd->can_id);
eid = FIELD_GET(MCP251XFD_REG_FRAME_EFF_EID_MASK, cfd->can_id);
id = FIELD_PREP(MCP251XFD_OBJ_ID_EID_MASK, eid) |
FIELD_PREP(MCP251XFD_OBJ_ID_SID_MASK, sid);
flags = MCP251XFD_OBJ_FLAGS_IDE;
} else {
id = FIELD_PREP(MCP251XFD_OBJ_ID_SID_MASK, cfd->can_id);
flags = 0;
}
/* Use the MCP2518FD mask even on the MCP2517FD. It doesn't
* harm, only the lower 7 bits will be transferred into the
* TEF object.
*/
flags |= FIELD_PREP(MCP251XFD_OBJ_FLAGS_SEQ_MCP2518FD_MASK, seq);
if (cfd->can_id & CAN_RTR_FLAG)
flags |= MCP251XFD_OBJ_FLAGS_RTR;
else
len_sanitized = canfd_sanitize_len(cfd->len);
/* CANFD */
if (can_is_canfd_skb(skb)) {
if (cfd->flags & CANFD_ESI)
flags |= MCP251XFD_OBJ_FLAGS_ESI;
flags |= MCP251XFD_OBJ_FLAGS_FDF;
if (cfd->flags & CANFD_BRS)
flags |= MCP251XFD_OBJ_FLAGS_BRS;
dlc = can_fd_len2dlc(cfd->len);
} else {
dlc = can_get_cc_dlc((struct can_frame *)cfd,
priv->can.ctrlmode);
}
flags |= FIELD_PREP(MCP251XFD_OBJ_FLAGS_DLC_MASK, dlc);
load_buf = &tx_obj->buf;
if (priv->devtype_data.quirks & MCP251XFD_QUIRK_CRC_TX)
hw_tx_obj = &load_buf->crc.hw_tx_obj;
else
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/bitfield.h`, `mcp251xfd.h`.
- Detected declarations: `function mcp251xfd_tx_obj_from_skb`, `function mcp251xfd_tx_failure_drop`, `function mcp251xfd_tx_obj_write_sync`, `function mcp251xfd_tx_obj_write`, `function mcp251xfd_tx_busy`, `function mcp251xfd_work_busy`, `function mcp251xfd_start_xmit`.
- 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.