include/linux/can/dev.h

Source file repositories/reference/linux-study-clean/include/linux/can/dev.h

File Facts

System
Linux kernel
Corpus path
include/linux/can/dev.h
Extension
.h
Size
5895 bytes
Lines
202
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct can_priv {
	struct net_device *dev;
	struct can_device_stats can_stats;

	const struct can_bittiming_const *bittiming_const;
	struct can_bittiming bittiming;
	struct data_bittiming_params fd, xl;
	unsigned int bitrate_const_cnt;
	const u32 *bitrate_const;
	u32 bitrate_max;
	struct can_clock clock;

	unsigned int termination_const_cnt;
	const u16 *termination_const;
	u16 termination;
	struct gpio_desc *termination_gpio;
	u16 termination_gpio_ohms[CAN_TERMINATION_GPIO_MAX];

	unsigned int echo_skb_max;
	struct sk_buff **echo_skb;

	enum can_state state;

	/* CAN controller features - see include/uapi/linux/can/netlink.h */
	u32 ctrlmode;		/* current options setting */
	u32 ctrlmode_supported;	/* options that can be modified by netlink */

	int restart_ms;
	struct delayed_work restart_work;

	int (*do_set_bittiming)(struct net_device *dev);
	int (*do_set_mode)(struct net_device *dev, enum can_mode mode);
	int (*do_set_termination)(struct net_device *dev, u16 term);
	int (*do_get_state)(const struct net_device *dev,
			    enum can_state *state);
	int (*do_get_berr_counter)(const struct net_device *dev,
				   struct can_berr_counter *bec);
};

static inline bool can_fd_tdc_is_enabled(const struct can_priv *priv)
{
	return !!(priv->ctrlmode & CAN_CTRLMODE_FD_TDC_MASK);
}

static inline bool can_xl_tdc_is_enabled(const struct can_priv *priv)
{
	return !!(priv->ctrlmode & CAN_CTRLMODE_XL_TDC_MASK);
}

static inline u32 can_get_static_ctrlmode(struct can_priv *priv)
{
	return priv->ctrlmode & ~priv->ctrlmode_supported;
}

static inline bool can_is_canxl_dev_mtu(unsigned int mtu)
{
	return (mtu >= CANXL_MIN_MTU && mtu <= CANXL_MAX_MTU);
}

void can_setup(struct net_device *dev);

struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
				    unsigned int txqs, unsigned int rxqs);
#define alloc_candev(sizeof_priv, echo_skb_max) \
	alloc_candev_mqs(sizeof_priv, echo_skb_max, 1, 1)
#define alloc_candev_mq(sizeof_priv, echo_skb_max, count) \
	alloc_candev_mqs(sizeof_priv, echo_skb_max, count, count)
void free_candev(struct net_device *dev);

/* a candev safe wrapper around netdev_priv */
struct can_priv *safe_candev_priv(struct net_device *dev);

int open_candev(struct net_device *dev);
void close_candev(struct net_device *dev);
void can_set_default_mtu(struct net_device *dev);
void can_set_cap_info(struct net_device *dev);
int __must_check can_set_static_ctrlmode(struct net_device *dev,
					 u32 static_mode);
int can_hwtstamp_get(struct net_device *netdev,
		     struct kernel_hwtstamp_config *cfg);
int can_hwtstamp_set(struct net_device *netdev,
		     struct kernel_hwtstamp_config *cfg,
		     struct netlink_ext_ack *extack);
int can_ethtool_op_get_ts_info_hwts(struct net_device *dev,
				    struct kernel_ethtool_ts_info *info);

int register_candev(struct net_device *dev);
void unregister_candev(struct net_device *dev);

int can_restart_now(struct net_device *dev);

Annotation

Implementation Notes