Lines Matching refs:lif

67 static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,  in ionic_lif_hwstamp_set_ts_config()  argument
70 struct ionic *ionic = lif->ionic; in ionic_lif_hwstamp_set_ts_config()
79 if (!lif->phc || !lif->phc->ptp) in ionic_lif_hwstamp_set_ts_config()
82 mutex_lock(&lif->phc->config_lock); in ionic_lif_hwstamp_set_ts_config()
94 memcpy(config, &lif->phc->ts_config, sizeof(*config)); in ionic_lif_hwstamp_set_ts_config()
95 memset(&lif->phc->ts_config, 0, sizeof(lif->phc->ts_config)); in ionic_lif_hwstamp_set_ts_config()
96 lif->phc->ts_config_tx_mode = 0; in ionic_lif_hwstamp_set_ts_config()
97 lif->phc->ts_config_rx_filt = 0; in ionic_lif_hwstamp_set_ts_config()
107 if ((ionic->ident.lif.eth.hwstamp_tx_modes & mask) != mask) { in ionic_lif_hwstamp_set_ts_config()
116 if ((ionic->ident.lif.eth.hwstamp_rx_filters & mask) != mask) { in ionic_lif_hwstamp_set_ts_config()
126 err = ionic_lif_create_hwstamp_txq(lif); in ionic_lif_hwstamp_set_ts_config()
132 err = ionic_lif_create_hwstamp_rxq(lif); in ionic_lif_hwstamp_set_ts_config()
137 if (tx_mode != lif->phc->ts_config_tx_mode) { in ionic_lif_hwstamp_set_ts_config()
138 err = ionic_lif_set_hwstamp_txmode(lif, tx_mode); in ionic_lif_hwstamp_set_ts_config()
143 if (rx_filt != lif->phc->ts_config_rx_filt) { in ionic_lif_hwstamp_set_ts_config()
144 err = ionic_lif_set_hwstamp_rxfilt(lif, rx_filt); in ionic_lif_hwstamp_set_ts_config()
149 if (rx_all != (lif->phc->ts_config.rx_filter == HWTSTAMP_FILTER_ALL)) { in ionic_lif_hwstamp_set_ts_config()
150 err = ionic_lif_config_hwstamp_rxq_all(lif, rx_all); in ionic_lif_hwstamp_set_ts_config()
155 memcpy(&lif->phc->ts_config, config, sizeof(*config)); in ionic_lif_hwstamp_set_ts_config()
156 lif->phc->ts_config_rx_filt = rx_filt; in ionic_lif_hwstamp_set_ts_config()
157 lif->phc->ts_config_tx_mode = tx_mode; in ionic_lif_hwstamp_set_ts_config()
159 mutex_unlock(&lif->phc->config_lock); in ionic_lif_hwstamp_set_ts_config()
164 if (rx_filt != lif->phc->ts_config_rx_filt) { in ionic_lif_hwstamp_set_ts_config()
165 rx_filt = lif->phc->ts_config_rx_filt; in ionic_lif_hwstamp_set_ts_config()
166 err2 = ionic_lif_set_hwstamp_rxfilt(lif, rx_filt); in ionic_lif_hwstamp_set_ts_config()
172 if (tx_mode != lif->phc->ts_config_tx_mode) { in ionic_lif_hwstamp_set_ts_config()
173 tx_mode = lif->phc->ts_config_tx_mode; in ionic_lif_hwstamp_set_ts_config()
174 err2 = ionic_lif_set_hwstamp_txmode(lif, tx_mode); in ionic_lif_hwstamp_set_ts_config()
182 mutex_unlock(&lif->phc->config_lock); in ionic_lif_hwstamp_set_ts_config()
186 int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) in ionic_lif_hwstamp_set() argument
191 if (!lif->phc || !lif->phc->ptp) in ionic_lif_hwstamp_set()
197 mutex_lock(&lif->queue_lock); in ionic_lif_hwstamp_set()
198 err = ionic_lif_hwstamp_set_ts_config(lif, &config); in ionic_lif_hwstamp_set()
199 mutex_unlock(&lif->queue_lock); in ionic_lif_hwstamp_set()
201 netdev_info(lif->netdev, "hwstamp set failed: %d\n", err); in ionic_lif_hwstamp_set()
211 void ionic_lif_hwstamp_replay(struct ionic_lif *lif) in ionic_lif_hwstamp_replay() argument
215 if (!lif->phc || !lif->phc->ptp) in ionic_lif_hwstamp_replay()
218 mutex_lock(&lif->queue_lock); in ionic_lif_hwstamp_replay()
219 err = ionic_lif_hwstamp_set_ts_config(lif, NULL); in ionic_lif_hwstamp_replay()
220 mutex_unlock(&lif->queue_lock); in ionic_lif_hwstamp_replay()
222 netdev_info(lif->netdev, "hwstamp replay failed: %d\n", err); in ionic_lif_hwstamp_replay()
225 void ionic_lif_hwstamp_recreate_queues(struct ionic_lif *lif) in ionic_lif_hwstamp_recreate_queues() argument
229 if (!lif->phc || !lif->phc->ptp) in ionic_lif_hwstamp_recreate_queues()
232 mutex_lock(&lif->phc->config_lock); in ionic_lif_hwstamp_recreate_queues()
234 if (lif->phc->ts_config_tx_mode) { in ionic_lif_hwstamp_recreate_queues()
235 err = ionic_lif_create_hwstamp_txq(lif); in ionic_lif_hwstamp_recreate_queues()
237 netdev_info(lif->netdev, "hwstamp recreate txq failed: %d\n", err); in ionic_lif_hwstamp_recreate_queues()
240 if (lif->phc->ts_config_rx_filt) { in ionic_lif_hwstamp_recreate_queues()
241 err = ionic_lif_create_hwstamp_rxq(lif); in ionic_lif_hwstamp_recreate_queues()
243 netdev_info(lif->netdev, "hwstamp recreate rxq failed: %d\n", err); in ionic_lif_hwstamp_recreate_queues()
246 mutex_unlock(&lif->phc->config_lock); in ionic_lif_hwstamp_recreate_queues()
249 int ionic_lif_hwstamp_get(struct ionic_lif *lif, struct ifreq *ifr) in ionic_lif_hwstamp_get() argument
253 if (!lif->phc || !lif->phc->ptp) in ionic_lif_hwstamp_get()
256 mutex_lock(&lif->phc->config_lock); in ionic_lif_hwstamp_get()
257 memcpy(&config, &lif->phc->ts_config, sizeof(config)); in ionic_lif_hwstamp_get()
258 mutex_unlock(&lif->phc->config_lock); in ionic_lif_hwstamp_get()
296 struct ionic *ionic = phc->lif->ionic; in ionic_cc_read()
306 ctx->cmd.lif_setphc.lif_index = cpu_to_le16(phc->lif->index); in ionic_setphc_cmd()
314 return ionic_adminq_post(phc->lif, ctx); in ionic_setphc_cmd()
326 if (test_bit(IONIC_LIF_F_FW_RESET, phc->lif->state)) in ionic_phc_adjfine()
351 return ionic_adminq_wait(phc->lif, &ctx, err, true); in ionic_phc_adjfine()
362 if (test_bit(IONIC_LIF_F_FW_RESET, phc->lif->state)) in ionic_phc_adjtime()
376 return ionic_adminq_wait(phc->lif, &ctx, err, true); in ionic_phc_adjtime()
389 if (test_bit(IONIC_LIF_F_FW_RESET, phc->lif->state)) in ionic_phc_settime64()
405 return ionic_adminq_wait(phc->lif, &ctx, err, true); in ionic_phc_settime64()
413 struct ionic *ionic = phc->lif->ionic; in ionic_phc_gettimex64()
418 if (test_bit(IONIC_LIF_F_FW_RESET, phc->lif->state)) in ionic_phc_gettimex64()
447 if (test_bit(IONIC_LIF_F_FW_RESET, phc->lif->state)) in ionic_phc_aux_work()
462 ionic_adminq_wait(phc->lif, &ctx, err, true); in ionic_phc_aux_work()
467 ktime_t ionic_lif_phc_ktime(struct ionic_lif *lif, u64 tick) in ionic_lif_phc_ktime() argument
472 if (!lif->phc) in ionic_lif_phc_ktime()
475 spin_lock_irqsave(&lif->phc->lock, irqflags); in ionic_lif_phc_ktime()
476 ns = timecounter_cyc2time(&lif->phc->tc, tick); in ionic_lif_phc_ktime()
477 spin_unlock_irqrestore(&lif->phc->lock, irqflags); in ionic_lif_phc_ktime()
492 void ionic_lif_register_phc(struct ionic_lif *lif) in ionic_lif_register_phc() argument
494 if (!lif->phc || !(lif->hw_features & IONIC_ETH_HW_TIMESTAMP)) in ionic_lif_register_phc()
497 lif->phc->ptp = ptp_clock_register(&lif->phc->ptp_info, lif->ionic->dev); in ionic_lif_register_phc()
499 if (IS_ERR(lif->phc->ptp)) { in ionic_lif_register_phc()
500 dev_warn(lif->ionic->dev, "Cannot register phc device: %ld\n", in ionic_lif_register_phc()
501 PTR_ERR(lif->phc->ptp)); in ionic_lif_register_phc()
503 lif->phc->ptp = NULL; in ionic_lif_register_phc()
506 if (lif->phc->ptp) in ionic_lif_register_phc()
507 ptp_schedule_worker(lif->phc->ptp, lif->phc->aux_work_delay); in ionic_lif_register_phc()
510 void ionic_lif_unregister_phc(struct ionic_lif *lif) in ionic_lif_unregister_phc() argument
512 if (!lif->phc || !lif->phc->ptp) in ionic_lif_unregister_phc()
515 ptp_clock_unregister(lif->phc->ptp); in ionic_lif_unregister_phc()
517 lif->phc->ptp = NULL; in ionic_lif_unregister_phc()
520 void ionic_lif_alloc_phc(struct ionic_lif *lif) in ionic_lif_alloc_phc() argument
522 struct ionic *ionic = lif->ionic; in ionic_lif_alloc_phc()
532 features = le64_to_cpu(ionic->ident.lif.eth.config.features); in ionic_lif_alloc_phc()
540 phc->lif = lif; in ionic_lif_alloc_phc()
548 dev_err(lif->ionic->dev, in ionic_lif_alloc_phc()
551 devm_kfree(lif->ionic->dev, phc); in ionic_lif_alloc_phc()
552 lif->phc = NULL; in ionic_lif_alloc_phc()
556 dev_dbg(lif->ionic->dev, "Device PHC mask %#llx mult %u shift %u\n", in ionic_lif_alloc_phc()
613 dev_dbg(lif->ionic->dev, "Initial PHC mask %#llx mult %u shift %u\n", in ionic_lif_alloc_phc()
624 dev_dbg(lif->ionic->dev, "Work delay %llu ms\n", delay / NSEC_PER_MSEC); in ionic_lif_alloc_phc()
635 lif->phc = phc; in ionic_lif_alloc_phc()
638 void ionic_lif_free_phc(struct ionic_lif *lif) in ionic_lif_free_phc() argument
640 if (!lif->phc) in ionic_lif_free_phc()
643 mutex_destroy(&lif->phc->config_lock); in ionic_lif_free_phc()
645 devm_kfree(lif->ionic->dev, lif->phc); in ionic_lif_free_phc()
646 lif->phc = NULL; in ionic_lif_free_phc()