drivers/net/can/usb/kvaser_usb/kvaser_usb.h

Source file repositories/reference/linux-study-clean/drivers/net/can/usb/kvaser_usb/kvaser_usb.h

File Facts

System
Linux kernel
Corpus path
drivers/net/can/usb/kvaser_usb/kvaser_usb.h
Extension
.h
Size
8817 bytes
Lines
273
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct kvaser_usb_dev_card_data_hydra {
	u8 channel_to_he[KVASER_USB_MAX_NET_DEVICES];
	u8 sysdbg_he;
	spinlock_t transid_lock; /* lock for transid */
	u16 transid;
	/* lock for usb_rx_leftover and usb_rx_leftover_len */
	spinlock_t usb_rx_leftover_lock;
	u8 usb_rx_leftover[KVASER_USB_HYDRA_MAX_CMD_LEN];
	u8 usb_rx_leftover_len;
};
struct kvaser_usb_dev_card_data {
	u32 ctrlmode_supported;
	u32 capabilities;
	struct kvaser_usb_dev_card_data_hydra hydra;
	u32 usbcan_timestamp_msb;
};

/* Context for an outstanding, not yet ACKed, transmission */
struct kvaser_usb_tx_urb_context {
	struct kvaser_usb_net_priv *priv;
	u32 echo_index;
};

struct kvaser_usb_fw_version {
	u8 major;
	u8 minor;
	u16 build;
};

struct kvaser_usb_busparams {
	__le32 bitrate;
	u8 tseg1;
	u8 tseg2;
	u8 sjw;
	u8 nsamples;
} __packed;

struct kvaser_usb {
	struct usb_device *udev;
	struct usb_interface *intf;
	struct kvaser_usb_net_priv *nets[KVASER_USB_MAX_NET_DEVICES];
	const struct kvaser_usb_driver_info *driver_info;
	const struct kvaser_usb_dev_cfg *cfg;

	struct usb_endpoint_descriptor *bulk_in, *bulk_out;
	struct usb_anchor rx_submitted;

	u32 ean[2];
	u32 serial_number;
	struct kvaser_usb_fw_version fw_version;
	u8 hw_revision;
	unsigned int nchannels;
	/* @max_tx_urbs: Firmware-reported maximum number of outstanding,
	 * not yet ACKed, transmissions on this device. This value is
	 * also used as a sentinel for marking free tx contexts.
	 */
	unsigned int max_tx_urbs;
	struct kvaser_usb_dev_card_data card_data;

	bool rxinitdone;
	void *rxbuf[KVASER_USB_MAX_RX_URBS];
	dma_addr_t rxbuf_dma[KVASER_USB_MAX_RX_URBS];
};

struct kvaser_usb_net_priv {
	struct can_priv can;
	struct devlink_port devlink_port;
	struct can_berr_counter bec;

	/* subdriver-specific data */
	void *sub_priv;

	struct kvaser_usb *dev;
	struct net_device *netdev;
	int channel;

	struct completion start_comp, stop_comp, flush_comp,
			  get_busparams_comp;
	struct usb_anchor tx_submitted;

	struct kvaser_usb_busparams busparams_nominal, busparams_data;

	spinlock_t tx_contexts_lock; /* lock for active_tx_contexts */
	int active_tx_contexts;
	struct kvaser_usb_tx_urb_context tx_contexts[];
};

/**
 * struct kvaser_usb_dev_ops - Device specific functions
 * @dev_set_mode:		used for can.do_set_mode

Annotation

Implementation Notes