drivers/net/can/flexcan/flexcan-ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/can/flexcan/flexcan-ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/can/flexcan/flexcan-ethtool.c- Extension
.c- Size
- 2972 bytes
- Lines
- 111
- 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/can/dev.hlinux/ethtool.hlinux/kernel.hlinux/netdevice.hlinux/platform_device.hflexcan.h
Detected Declarations
function flexcan_get_ringparamfunction flexcan_get_stringsfunction flexcan_get_priv_flagsfunction flexcan_set_priv_flagsfunction flexcan_get_sset_count
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/* Copyright (c) 2022 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
* Copyright (c) 2022 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
*
*/
#include <linux/can/dev.h>
#include <linux/ethtool.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/platform_device.h>
#include "flexcan.h"
static const char flexcan_priv_flags_strings[][ETH_GSTRING_LEN] = {
#define FLEXCAN_PRIV_FLAGS_RX_RTR BIT(0)
"rx-rtr",
};
static void
flexcan_get_ringparam(struct net_device *ndev, struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
struct netlink_ext_ack *ext_ack)
{
const struct flexcan_priv *priv = netdev_priv(ndev);
ring->rx_max_pending = priv->mb_count;
ring->tx_max_pending = priv->mb_count;
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_USE_RX_MAILBOX)
ring->rx_pending = priv->offload.mb_last -
priv->offload.mb_first + 1;
else
ring->rx_pending = 6; /* RX-FIFO depth is fixed */
/* the drive currently supports only on TX buffer */
ring->tx_pending = 1;
}
static void
flexcan_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
{
switch (stringset) {
case ETH_SS_PRIV_FLAGS:
memcpy(data, flexcan_priv_flags_strings,
sizeof(flexcan_priv_flags_strings));
}
}
static u32 flexcan_get_priv_flags(struct net_device *ndev)
{
const struct flexcan_priv *priv = netdev_priv(ndev);
u32 priv_flags = 0;
if (flexcan_active_rx_rtr(priv))
priv_flags |= FLEXCAN_PRIV_FLAGS_RX_RTR;
return priv_flags;
}
static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags)
{
struct flexcan_priv *priv = netdev_priv(ndev);
u32 quirks = priv->devtype_data.quirks;
if (priv_flags & FLEXCAN_PRIV_FLAGS_RX_RTR) {
if (flexcan_supports_rx_mailbox_rtr(priv))
quirks |= FLEXCAN_QUIRK_USE_RX_MAILBOX;
else if (flexcan_supports_rx_fifo(priv))
quirks &= ~FLEXCAN_QUIRK_USE_RX_MAILBOX;
else
quirks |= FLEXCAN_QUIRK_USE_RX_MAILBOX;
} else {
if (flexcan_supports_rx_mailbox(priv))
quirks |= FLEXCAN_QUIRK_USE_RX_MAILBOX;
else
quirks &= ~FLEXCAN_QUIRK_USE_RX_MAILBOX;
}
if (quirks != priv->devtype_data.quirks && netif_running(ndev))
return -EBUSY;
priv->devtype_data.quirks = quirks;
if (!(priv_flags & FLEXCAN_PRIV_FLAGS_RX_RTR) &&
!flexcan_active_rx_rtr(priv))
netdev_info(ndev,
"Activating RX mailbox mode, cannot receive RTR frames.\n");
return 0;
Annotation
- Immediate include surface: `linux/can/dev.h`, `linux/ethtool.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/platform_device.h`, `flexcan.h`.
- Detected declarations: `function flexcan_get_ringparam`, `function flexcan_get_strings`, `function flexcan_get_priv_flags`, `function flexcan_set_priv_flags`, `function flexcan_get_sset_count`.
- 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.