drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeon_ep/octep_main.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/marvell/octeon_ep/octep_main.c
Extension
.c
Size
44331 bytes
Lines
1709
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct net_device_ops octep_netdev_ops = {
	.ndo_open                = octep_open,
	.ndo_stop                = octep_stop,
	.ndo_start_xmit          = octep_start_xmit,
	.ndo_get_stats64         = octep_get_stats64,
	.ndo_tx_timeout          = octep_tx_timeout,
	.ndo_set_mac_address     = octep_set_mac,
	.ndo_change_mtu          = octep_change_mtu,
	.ndo_set_features        = octep_set_features,
	.ndo_get_vf_config       = octep_get_vf_config,
	.ndo_set_vf_mac          = octep_set_vf_mac
};

/**
 * octep_intr_poll_task - work queue task to process non-ioq interrupts.
 *
 * @work: pointer to mbox work_struct
 *
 * Process non-ioq interrupts to handle control mailbox, pfvf mailbox.
 **/
static void octep_intr_poll_task(struct work_struct *work)
{
	struct octep_device *oct = container_of(work, struct octep_device,
						intr_poll_task.work);

	if (!oct->poll_non_ioq_intr) {
		dev_info(&oct->pdev->dev, "Interrupt poll task stopped.\n");
		return;
	}

	oct->hw_ops.poll_non_ioq_interrupts(oct);
	queue_delayed_work(octep_wq, &oct->intr_poll_task,
			   msecs_to_jiffies(OCTEP_INTR_POLL_TIME_MSECS));
}

/**
 * octep_hb_timeout_task - work queue task to check firmware heartbeat.
 *
 * @work: pointer to hb work_struct
 *
 * Check for heartbeat miss count. Uninitialize oct device if miss count
 * exceeds configured max heartbeat miss count.
 *
 **/
static void octep_hb_timeout_task(struct work_struct *work)
{
	struct octep_device *oct = container_of(work, struct octep_device,
						hb_task.work);

	int miss_cnt;

	miss_cnt = atomic_inc_return(&oct->hb_miss_cnt);
	if (miss_cnt < oct->conf->fw_info.hb_miss_count) {
		queue_delayed_work(octep_wq, &oct->hb_task,
				   msecs_to_jiffies(oct->conf->fw_info.hb_interval));
		return;
	}

	dev_err(&oct->pdev->dev, "Missed %u heartbeats. Uninitializing\n",
		miss_cnt);
	rtnl_lock();
	if (netif_running(oct->netdev))
		dev_close(oct->netdev);
	rtnl_unlock();
}

/**
 * octep_ctrl_mbox_task - work queue task to handle ctrl mbox messages.
 *
 * @work: pointer to ctrl mbox work_struct
 *
 * Poll ctrl mbox message queue and handle control messages from firmware.
 **/
static void octep_ctrl_mbox_task(struct work_struct *work)
{
	struct octep_device *oct = container_of(work, struct octep_device,
						ctrl_mbox_task);

	octep_ctrl_net_recv_fw_messages(oct);
}

static const char *octep_devid_to_str(struct octep_device *oct)
{
	switch (oct->chip_id) {
	case OCTEP_PCI_DEVICE_ID_CN98_PF:
		return "CN98XX";
	case OCTEP_PCI_DEVICE_ID_CN93_PF:
		return "CN93XX";
	case OCTEP_PCI_DEVICE_ID_CNF95N_PF:
		return "CNF95N";

Annotation

Implementation Notes