drivers/net/can/usb/etas_es58x/es58x_fd.c
Source file repositories/reference/linux-study-clean/drivers/net/can/usb/etas_es58x/es58x_fd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/usb/etas_es58x/es58x_fd.c- Extension
.c- Size
- 17903 bytes
- Lines
- 566
- 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/kernel.hlinux/units.hes58x_core.hes58x_fd.h
Detected Declarations
function es58x_fd_cmd_typefunction es58x_fd_get_msg_lenfunction es58x_fd_echo_msgfunction es58x_fd_rx_can_msgfunction es58x_fd_rx_event_msgfunction es58x_fd_rx_cmd_ret_u32function es58x_fd_tx_ack_msgfunction es58x_fd_can_cmd_idfunction es58x_fd_device_cmd_idfunction es58x_fd_handle_urb_cmdfunction es58x_fd_fill_urb_headerfunction es58x_fd_tx_can_msgfunction es58x_fd_convert_bittimingfunction es58x_fd_enable_channelfunction es58x_fd_disable_channelfunction es58x_fd_get_timestamp
Annotated Snippet
if ((u8)rcv_packet_idx != echo_msg[i].packet_idx) {
netdev_err(netdev, "Packet idx jumped from %u to %u\n",
(u8)rcv_packet_idx - 1,
echo_msg[i].packet_idx);
return -EBADMSG;
}
tstamps[i] = get_unaligned_le64(&echo_msg[i].timestamp);
rcv_packet_idx++;
}
return es58x_can_get_echo_skb(netdev, priv->tx_tail, tstamps, num_element);
}
static int es58x_fd_rx_can_msg(struct net_device *netdev,
const struct es58x_fd_urb_cmd *es58x_fd_urb_cmd)
{
struct es58x_device *es58x_dev = es58x_priv(netdev)->es58x_dev;
const u8 *rx_can_msg_buf = es58x_fd_urb_cmd->rx_can_msg_buf;
u16 rx_can_msg_buf_len = get_unaligned_le16(&es58x_fd_urb_cmd->msg_len);
int pkts, ret;
ret = es58x_check_msg_max_len(es58x_dev->dev,
es58x_fd_urb_cmd->rx_can_msg_buf,
rx_can_msg_buf_len);
if (ret)
return ret;
for (pkts = 0; rx_can_msg_buf_len > 0; pkts++) {
const struct es58x_fd_rx_can_msg *rx_can_msg =
(const struct es58x_fd_rx_can_msg *)rx_can_msg_buf;
bool is_can_fd = !!(rx_can_msg->flags & ES58X_FLAG_FD_DATA);
/* rx_can_msg_len is the length of the rx_can_msg
* buffer. Not to be confused with rx_can_msg->len
* which is the length of the CAN payload
* rx_can_msg->data.
*/
u16 rx_can_msg_len = es58x_fd_sizeof_rx_tx_msg(*rx_can_msg);
if (rx_can_msg_len > rx_can_msg_buf_len) {
netdev_err(netdev,
"%s: Expected a rx_can_msg of size %d but only %d bytes are left in rx_can_msg_buf\n",
__func__,
rx_can_msg_len, rx_can_msg_buf_len);
return -EMSGSIZE;
}
if (rx_can_msg->len > CANFD_MAX_DLEN) {
netdev_err(netdev,
"%s: Data length is %d but maximum should be %d\n",
__func__, rx_can_msg->len, CANFD_MAX_DLEN);
return -EMSGSIZE;
}
if (netif_running(netdev)) {
u64 tstamp = get_unaligned_le64(&rx_can_msg->timestamp);
canid_t can_id = get_unaligned_le32(&rx_can_msg->can_id);
u8 dlc;
if (is_can_fd)
dlc = can_fd_len2dlc(rx_can_msg->len);
else
dlc = rx_can_msg->dlc;
ret = es58x_rx_can_msg(netdev, tstamp, rx_can_msg->data,
can_id, rx_can_msg->flags, dlc);
if (ret)
break;
}
rx_can_msg_buf_len -= rx_can_msg_len;
rx_can_msg_buf += rx_can_msg_len;
}
if (!netif_running(netdev)) {
if (net_ratelimit())
netdev_info(netdev,
"%s: %s is down, dropping %d rx packets\n",
__func__, netdev->name, pkts);
netdev->stats.rx_dropped += pkts;
}
return ret;
}
static int es58x_fd_rx_event_msg(struct net_device *netdev,
const struct es58x_fd_urb_cmd *es58x_fd_urb_cmd)
{
struct es58x_device *es58x_dev = es58x_priv(netdev)->es58x_dev;
u16 msg_len = get_unaligned_le16(&es58x_fd_urb_cmd->msg_len);
const struct es58x_fd_rx_event_msg *rx_event_msg;
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/kernel.h`, `linux/units.h`, `es58x_core.h`, `es58x_fd.h`.
- Detected declarations: `function es58x_fd_cmd_type`, `function es58x_fd_get_msg_len`, `function es58x_fd_echo_msg`, `function es58x_fd_rx_can_msg`, `function es58x_fd_rx_event_msg`, `function es58x_fd_rx_cmd_ret_u32`, `function es58x_fd_tx_ack_msg`, `function es58x_fd_can_cmd_id`, `function es58x_fd_device_cmd_id`, `function es58x_fd_handle_urb_cmd`.
- 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.