drivers/net/ethernet/pensando/ionic/ionic_phc.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/pensando/ionic/ionic_phc.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/pensando/ionic/ionic_phc.c
Extension
.c
Size
17838 bytes
Lines
662
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

if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Error creating TX timestamp queue");
			goto err_queues;
		}
	}

	if (rx_filt) {
		err = ionic_lif_create_hwstamp_rxq(lif);
		if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Error creating RX timestamp queue");
			goto err_queues;
		}
	}

	if (tx_mode != lif->phc->ts_config_tx_mode) {
		err = ionic_lif_set_hwstamp_txmode(lif, tx_mode);
		if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Error enabling TX timestamp mode");
			goto err_txmode;
		}
	}

	if (rx_filt != lif->phc->ts_config_rx_filt) {
		err = ionic_lif_set_hwstamp_rxfilt(lif, rx_filt);
		if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Error enabling RX timestamp mode");
			goto err_rxfilt;
		}
	}

	if (rx_all != (lif->phc->ts_config.rx_filter == HWTSTAMP_FILTER_ALL)) {
		err = ionic_lif_config_hwstamp_rxq_all(lif, rx_all);
		if (err) {
			NL_SET_ERR_MSG_MOD(extack,
					   "Error enabling RX timestamp mode");
			goto err_rxall;
		}
	}

	memcpy(&lif->phc->ts_config, config, sizeof(*config));
	lif->phc->ts_config_rx_filt = rx_filt;
	lif->phc->ts_config_tx_mode = tx_mode;

	mutex_unlock(&lif->phc->config_lock);

	return 0;

err_rxall:
	if (rx_filt != lif->phc->ts_config_rx_filt) {
		rx_filt = lif->phc->ts_config_rx_filt;
		err2 = ionic_lif_set_hwstamp_rxfilt(lif, rx_filt);
		if (err2)
			dev_err(ionic->dev,
				"Failed to revert rx timestamp filter: %d\n", err2);
	}
err_rxfilt:
	if (tx_mode != lif->phc->ts_config_tx_mode) {
		tx_mode = lif->phc->ts_config_tx_mode;
		err2 = ionic_lif_set_hwstamp_txmode(lif, tx_mode);
		if (err2)
			dev_err(ionic->dev,
				"Failed to revert tx timestamp mode: %d\n", err2);
	}
err_txmode:
	/* special queues remain allocated, just unused */
err_queues:
	mutex_unlock(&lif->phc->config_lock);
	return err;
}

int ionic_hwstamp_set(struct net_device *netdev,
		      struct kernel_hwtstamp_config *config,
		      struct netlink_ext_ack *extack)
{
	struct ionic_lif *lif = netdev_priv(netdev);
	int err;

	if (!lif->phc || !lif->phc->ptp)
		return -EOPNOTSUPP;

	mutex_lock(&lif->queue_lock);
	err = ionic_lif_hwstamp_set_ts_config(lif, config, extack);
	mutex_unlock(&lif->queue_lock);
	if (err) {
		netdev_info(lif->netdev, "hwstamp set failed: %d\n", err);
		return err;

Annotation

Implementation Notes