Lines Matching refs:lif

38 static void ionic_link_status_check(struct ionic_lif *lif);
39 static void ionic_lif_handle_fw_down(struct ionic_lif *lif);
40 static void ionic_lif_handle_fw_up(struct ionic_lif *lif);
41 static void ionic_lif_set_netdev_info(struct ionic_lif *lif);
43 static void ionic_txrx_deinit(struct ionic_lif *lif);
44 static int ionic_txrx_init(struct ionic_lif *lif);
45 static int ionic_start_queues(struct ionic_lif *lif);
46 static void ionic_stop_queues(struct ionic_lif *lif);
47 static void ionic_lif_queue_identify(struct ionic_lif *lif);
58 new_coal = ionic_coal_usec_to_hw(qcq->q.lif->ionic, cur_moder.usec); in ionic_dim_work()
63 struct ionic_lif *lif = qcq->q.lif; in ionic_dim_work() local
67 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_dim_work()
68 lif->rxqcqs[qi]->intr.index, in ionic_dim_work()
77 struct ionic_lif *lif = container_of(work, struct ionic_lif, deferred.work); in ionic_lif_deferred_work() local
78 struct ionic_deferred *def = &lif->deferred; in ionic_lif_deferred_work()
95 ionic_lif_rx_mode(lif); in ionic_lif_deferred_work()
98 ionic_link_status_check(lif); in ionic_lif_deferred_work()
102 ionic_lif_handle_fw_up(lif); in ionic_lif_deferred_work()
104 ionic_lif_handle_fw_down(lif); in ionic_lif_deferred_work()
110 mod_timer(&lif->ionic->watchdog_timer, jiffies + 1); in ionic_lif_deferred_work()
130 static void ionic_link_status_check(struct ionic_lif *lif) in ionic_link_status_check() argument
132 struct net_device *netdev = lif->netdev; in ionic_link_status_check()
136 if (!test_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state)) in ionic_link_status_check()
140 if (test_bit(IONIC_LIF_F_BROKEN, lif->state)) { in ionic_link_status_check()
141 clear_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check()
145 link_status = le16_to_cpu(lif->info->status.link_status); in ionic_link_status_check()
152 mutex_lock(&lif->queue_lock); in ionic_link_status_check()
153 err = ionic_start_queues(lif); in ionic_link_status_check()
157 set_bit(IONIC_LIF_F_BROKEN, lif->state); in ionic_link_status_check()
158 netif_carrier_off(lif->netdev); in ionic_link_status_check()
160 mutex_unlock(&lif->queue_lock); in ionic_link_status_check()
164 ionic_port_identify(lif->ionic); in ionic_link_status_check()
166 le32_to_cpu(lif->info->status.link_speed) / 1000); in ionic_link_status_check()
171 lif->link_down_count++; in ionic_link_status_check()
177 mutex_lock(&lif->queue_lock); in ionic_link_status_check()
178 ionic_stop_queues(lif); in ionic_link_status_check()
179 mutex_unlock(&lif->queue_lock); in ionic_link_status_check()
183 clear_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check()
186 void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep) in ionic_link_status_check_request() argument
191 if (test_and_set_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state)) in ionic_link_status_check_request()
197 clear_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check_request()
202 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_link_status_check_request()
204 ionic_link_status_check(lif); in ionic_link_status_check_request()
224 static int ionic_request_irq(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_request_irq() argument
227 struct device *dev = lif->ionic->dev; in ionic_request_irq()
231 if (lif->registered) in ionic_request_irq()
232 name = lif->netdev->name; in ionic_request_irq()
243 static int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr) in ionic_intr_alloc() argument
245 struct ionic *ionic = lif->ionic; in ionic_intr_alloc()
250 netdev_warn(lif->netdev, "%s: no intr, index=%d nintrs=%d\n", in ionic_intr_alloc()
270 struct ionic_lif *lif = q->lif; in ionic_qcq_enable() local
278 .lif_index = cpu_to_le16(lif->index), in ionic_qcq_enable()
286 idev = &lif->ionic->idev; in ionic_qcq_enable()
287 dev = lif->ionic->dev; in ionic_qcq_enable()
295 ret = ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_enable()
312 static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fw_err) in ionic_qcq_disable() argument
325 netdev_err(lif->netdev, "%s: bad qcq\n", __func__); in ionic_qcq_disable()
332 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_disable()
349 ctx.cmd.q_control.lif_index = cpu_to_le16(lif->index); in ionic_qcq_disable()
352 dev_dbg(lif->ionic->dev, "q_disable.index %d q_disable.qtype %d\n", in ionic_qcq_disable()
355 return ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_disable()
358 static void ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_qcq_deinit() argument
360 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_qcq_deinit()
377 static void ionic_qcq_intr_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_intr_free() argument
383 devm_free_irq(lif->ionic->dev, qcq->intr.vector, &qcq->napi); in ionic_qcq_intr_free()
385 ionic_intr_free(lif->ionic, qcq->intr.index); in ionic_qcq_intr_free()
389 static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_free() argument
391 struct device *dev = lif->ionic->dev; in ionic_qcq_free()
406 ionic_put_cmb(lif, qcq->cmb_pgid, qcq->cmb_order); in ionic_qcq_free()
425 ionic_qcq_intr_free(lif, qcq); in ionic_qcq_free()
437 void ionic_qcqs_free(struct ionic_lif *lif) in ionic_qcqs_free() argument
439 struct device *dev = lif->ionic->dev; in ionic_qcqs_free()
443 if (lif->notifyqcq) { in ionic_qcqs_free()
444 ionic_qcq_free(lif, lif->notifyqcq); in ionic_qcqs_free()
445 devm_kfree(dev, lif->notifyqcq); in ionic_qcqs_free()
446 lif->notifyqcq = NULL; in ionic_qcqs_free()
449 if (lif->adminqcq) { in ionic_qcqs_free()
450 spin_lock_irqsave(&lif->adminq_lock, irqflags); in ionic_qcqs_free()
451 adminqcq = READ_ONCE(lif->adminqcq); in ionic_qcqs_free()
452 lif->adminqcq = NULL; in ionic_qcqs_free()
453 spin_unlock_irqrestore(&lif->adminq_lock, irqflags); in ionic_qcqs_free()
455 ionic_qcq_free(lif, adminqcq); in ionic_qcqs_free()
460 if (lif->rxqcqs) { in ionic_qcqs_free()
461 devm_kfree(dev, lif->rxqstats); in ionic_qcqs_free()
462 lif->rxqstats = NULL; in ionic_qcqs_free()
463 devm_kfree(dev, lif->rxqcqs); in ionic_qcqs_free()
464 lif->rxqcqs = NULL; in ionic_qcqs_free()
467 if (lif->txqcqs) { in ionic_qcqs_free()
468 devm_kfree(dev, lif->txqstats); in ionic_qcqs_free()
469 lif->txqstats = NULL; in ionic_qcqs_free()
470 devm_kfree(dev, lif->txqcqs); in ionic_qcqs_free()
471 lif->txqcqs = NULL; in ionic_qcqs_free()
483 static int ionic_alloc_qcq_interrupt(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_alloc_qcq_interrupt() argument
492 err = ionic_intr_alloc(lif, &qcq->intr); in ionic_alloc_qcq_interrupt()
494 netdev_warn(lif->netdev, "no intr for %s: %d\n", in ionic_alloc_qcq_interrupt()
499 err = ionic_bus_get_irq(lif->ionic, qcq->intr.index); in ionic_alloc_qcq_interrupt()
501 netdev_warn(lif->netdev, "no vector for %s: %d\n", in ionic_alloc_qcq_interrupt()
506 ionic_intr_mask_assert(lif->ionic->idev.intr_ctrl, qcq->intr.index, in ionic_alloc_qcq_interrupt()
509 err = ionic_request_irq(lif, qcq); in ionic_alloc_qcq_interrupt()
511 netdev_warn(lif->netdev, "irq request failed %d\n", err); in ionic_alloc_qcq_interrupt()
517 dev_to_node(lif->ionic->dev)); in ionic_alloc_qcq_interrupt()
521 netdev_dbg(lif->netdev, "%s: Interrupt index %d\n", qcq->q.name, qcq->intr.index); in ionic_alloc_qcq_interrupt()
525 ionic_intr_free(lif->ionic, qcq->intr.index); in ionic_alloc_qcq_interrupt()
530 static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, in ionic_qcq_alloc() argument
538 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_alloc()
539 struct device *dev = lif->ionic->dev; in ionic_qcq_alloc()
551 netdev_err(lif->netdev, "Cannot allocate queue structure\n"); in ionic_qcq_alloc()
561 netdev_err(lif->netdev, "Cannot allocate queue info\n"); in ionic_qcq_alloc()
567 new->q.max_sg_elems = lif->qtype_info[type].max_sg_elems; in ionic_qcq_alloc()
569 err = ionic_q_init(lif, idev, &new->q, index, name, num_descs, in ionic_qcq_alloc()
572 netdev_err(lif->netdev, "Cannot initialize queue\n"); in ionic_qcq_alloc()
576 err = ionic_alloc_qcq_interrupt(lif, new); in ionic_qcq_alloc()
582 netdev_err(lif->netdev, "Cannot allocate completion queue info\n"); in ionic_qcq_alloc()
587 err = ionic_cq_init(lif, &new->cq, &new->intr, num_descs, cq_desc_size); in ionic_qcq_alloc()
589 netdev_err(lif->netdev, "Cannot initialize completion queue\n"); in ionic_qcq_alloc()
606 netdev_err(lif->netdev, "Cannot allocate qcq DMA memory\n"); in ionic_qcq_alloc()
624 netdev_err(lif->netdev, "Cannot allocate queue DMA memory\n"); in ionic_qcq_alloc()
637 err = ionic_get_cmb(lif, &new->cmb_pgid, &new->cmb_q_base_pa, in ionic_qcq_alloc()
640 netdev_err(lif->netdev, in ionic_qcq_alloc()
648 netdev_err(lif->netdev, "Cannot map queue from cmb\n"); in ionic_qcq_alloc()
649 ionic_put_cmb(lif, new->cmb_pgid, new->cmb_order); in ionic_qcq_alloc()
663 netdev_err(lif->netdev, "Cannot allocate cq DMA memory\n"); in ionic_qcq_alloc()
678 netdev_err(lif->netdev, "Cannot allocate sg DMA memory\n"); in ionic_qcq_alloc()
699 ionic_put_cmb(lif, new->cmb_pgid, new->cmb_order); in ionic_qcq_alloc()
707 ionic_intr_free(lif->ionic, new->intr.index); in ionic_qcq_alloc()
718 static int ionic_qcqs_alloc(struct ionic_lif *lif) in ionic_qcqs_alloc() argument
720 struct device *dev = lif->ionic->dev; in ionic_qcqs_alloc()
725 err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags, in ionic_qcqs_alloc()
729 0, lif->kern_pid, &lif->adminqcq); in ionic_qcqs_alloc()
732 ionic_debugfs_add_qcq(lif, lif->adminqcq); in ionic_qcqs_alloc()
734 if (lif->ionic->nnqs_per_lif) { in ionic_qcqs_alloc()
736 err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notifyq", in ionic_qcqs_alloc()
740 0, lif->kern_pid, &lif->notifyqcq); in ionic_qcqs_alloc()
743 ionic_debugfs_add_qcq(lif, lif->notifyqcq); in ionic_qcqs_alloc()
746 ionic_link_qcq_interrupts(lif->adminqcq, lif->notifyqcq); in ionic_qcqs_alloc()
750 lif->txqcqs = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif, in ionic_qcqs_alloc()
751 sizeof(*lif->txqcqs), GFP_KERNEL); in ionic_qcqs_alloc()
752 if (!lif->txqcqs) in ionic_qcqs_alloc()
754 lif->rxqcqs = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif, in ionic_qcqs_alloc()
755 sizeof(*lif->rxqcqs), GFP_KERNEL); in ionic_qcqs_alloc()
756 if (!lif->rxqcqs) in ionic_qcqs_alloc()
759 lif->txqstats = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif + 1, in ionic_qcqs_alloc()
760 sizeof(*lif->txqstats), GFP_KERNEL); in ionic_qcqs_alloc()
761 if (!lif->txqstats) in ionic_qcqs_alloc()
763 lif->rxqstats = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif + 1, in ionic_qcqs_alloc()
764 sizeof(*lif->rxqstats), GFP_KERNEL); in ionic_qcqs_alloc()
765 if (!lif->rxqstats) in ionic_qcqs_alloc()
771 ionic_qcqs_free(lif); in ionic_qcqs_alloc()
788 static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_txq_init() argument
790 struct device *dev = lif->ionic->dev; in ionic_lif_txq_init()
797 .lif_index = cpu_to_le16(lif->index), in ionic_lif_txq_init()
799 .ver = lif->qtype_info[q->type].version, in ionic_lif_txq_init()
831 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_txq_init()
845 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) { in ionic_lif_txq_init()
846 netif_napi_add(lif->netdev, &qcq->napi, ionic_tx_napi); in ionic_lif_txq_init()
856 static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_rxq_init() argument
858 struct device *dev = lif->ionic->dev; in ionic_lif_rxq_init()
865 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rxq_init()
867 .ver = lif->qtype_info[q->type].version, in ionic_lif_rxq_init()
897 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rxq_init()
911 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_lif_rxq_init()
912 netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi); in ionic_lif_rxq_init()
914 netif_napi_add(lif->netdev, &qcq->napi, ionic_txrx_napi); in ionic_lif_rxq_init()
924 int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) in ionic_lif_create_hwstamp_txq() argument
932 if (lif->hwstamp_txq) in ionic_lif_create_hwstamp_txq()
941 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_lif_create_hwstamp_txq()
942 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == sizeof(struct ionic_txq_sg_desc_v1)) in ionic_lif_create_hwstamp_txq()
947 txq_i = lif->ionic->ntxqs_per_lif; in ionic_lif_create_hwstamp_txq()
950 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, txq_i, "hwstamp_tx", flags, in ionic_lif_create_hwstamp_txq()
952 lif->kern_pid, &txq); in ionic_lif_create_hwstamp_txq()
958 ionic_link_qcq_interrupts(lif->adminqcq, txq); in ionic_lif_create_hwstamp_txq()
959 ionic_debugfs_add_qcq(lif, txq); in ionic_lif_create_hwstamp_txq()
961 lif->hwstamp_txq = txq; in ionic_lif_create_hwstamp_txq()
963 if (netif_running(lif->netdev)) { in ionic_lif_create_hwstamp_txq()
964 err = ionic_lif_txq_init(lif, txq); in ionic_lif_create_hwstamp_txq()
968 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_create_hwstamp_txq()
978 ionic_lif_qcq_deinit(lif, txq); in ionic_lif_create_hwstamp_txq()
980 lif->hwstamp_txq = NULL; in ionic_lif_create_hwstamp_txq()
982 ionic_qcq_free(lif, txq); in ionic_lif_create_hwstamp_txq()
983 devm_kfree(lif->ionic->dev, txq); in ionic_lif_create_hwstamp_txq()
988 int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) in ionic_lif_create_hwstamp_rxq() argument
996 if (lif->hwstamp_rxq) in ionic_lif_create_hwstamp_rxq()
1006 rxq_i = lif->ionic->nrxqs_per_lif; in ionic_lif_create_hwstamp_rxq()
1009 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, rxq_i, "hwstamp_rx", flags, in ionic_lif_create_hwstamp_rxq()
1011 lif->kern_pid, &rxq); in ionic_lif_create_hwstamp_rxq()
1017 ionic_link_qcq_interrupts(lif->adminqcq, rxq); in ionic_lif_create_hwstamp_rxq()
1018 ionic_debugfs_add_qcq(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1020 lif->hwstamp_rxq = rxq; in ionic_lif_create_hwstamp_rxq()
1022 if (netif_running(lif->netdev)) { in ionic_lif_create_hwstamp_rxq()
1023 err = ionic_lif_rxq_init(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1027 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_create_hwstamp_rxq()
1038 ionic_lif_qcq_deinit(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1040 lif->hwstamp_rxq = NULL; in ionic_lif_create_hwstamp_rxq()
1042 ionic_qcq_free(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1043 devm_kfree(lif->ionic->dev, rxq); in ionic_lif_create_hwstamp_rxq()
1048 int ionic_lif_config_hwstamp_rxq_all(struct ionic_lif *lif, bool rx_all) in ionic_lif_config_hwstamp_rxq_all() argument
1052 ionic_init_queue_params(lif, &qparam); in ionic_lif_config_hwstamp_rxq_all()
1060 if (!netif_running(lif->netdev)) { in ionic_lif_config_hwstamp_rxq_all()
1061 lif->rxq_features = qparam.rxq_features; in ionic_lif_config_hwstamp_rxq_all()
1065 return ionic_reconfigure_queues(lif, &qparam); in ionic_lif_config_hwstamp_rxq_all()
1068 int ionic_lif_set_hwstamp_txmode(struct ionic_lif *lif, u16 txstamp_mode) in ionic_lif_set_hwstamp_txmode() argument
1074 .index = cpu_to_le16(lif->index), in ionic_lif_set_hwstamp_txmode()
1080 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_hwstamp_txmode()
1083 static void ionic_lif_del_hwstamp_rxfilt(struct ionic_lif *lif) in ionic_lif_del_hwstamp_rxfilt() argument
1089 .lif_index = cpu_to_le16(lif->index), in ionic_lif_del_hwstamp_rxfilt()
1096 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1098 f = ionic_rx_filter_rxsteer(lif); in ionic_lif_del_hwstamp_rxfilt()
1100 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1105 ionic_rx_filter_free(lif, f); in ionic_lif_del_hwstamp_rxfilt()
1107 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1109 netdev_dbg(lif->netdev, "rx_filter del RXSTEER (id %d)\n", filter_id); in ionic_lif_del_hwstamp_rxfilt()
1113 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_del_hwstamp_rxfilt()
1115 netdev_dbg(lif->netdev, "failed to delete rx_filter RXSTEER (id %d)\n", filter_id); in ionic_lif_del_hwstamp_rxfilt()
1118 static int ionic_lif_add_hwstamp_rxfilt(struct ionic_lif *lif, u64 pkt_class) in ionic_lif_add_hwstamp_rxfilt() argument
1124 .lif_index = cpu_to_le16(lif->index), in ionic_lif_add_hwstamp_rxfilt()
1133 if (!lif->hwstamp_rxq) in ionic_lif_add_hwstamp_rxfilt()
1136 qtype = lif->hwstamp_rxq->q.type; in ionic_lif_add_hwstamp_rxfilt()
1139 qid = lif->hwstamp_rxq->q.index; in ionic_lif_add_hwstamp_rxfilt()
1142 netdev_dbg(lif->netdev, "rx_filter add RXSTEER\n"); in ionic_lif_add_hwstamp_rxfilt()
1143 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_add_hwstamp_rxfilt()
1147 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_add_hwstamp_rxfilt()
1148 err = ionic_rx_filter_save(lif, 0, qid, 0, &ctx, IONIC_FILTER_STATE_SYNCED); in ionic_lif_add_hwstamp_rxfilt()
1149 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_add_hwstamp_rxfilt()
1154 int ionic_lif_set_hwstamp_rxfilt(struct ionic_lif *lif, u64 pkt_class) in ionic_lif_set_hwstamp_rxfilt() argument
1156 ionic_lif_del_hwstamp_rxfilt(lif); in ionic_lif_set_hwstamp_rxfilt()
1161 return ionic_lif_add_hwstamp_rxfilt(lif, pkt_class); in ionic_lif_set_hwstamp_rxfilt()
1171 struct ionic_lif *lif; in ionic_notifyq_service() local
1175 lif = q->info[0].cb_arg; in ionic_notifyq_service()
1176 netdev = lif->netdev; in ionic_notifyq_service()
1180 if ((s64)(eid - lif->last_eid) <= 0) in ionic_notifyq_service()
1183 lif->last_eid = eid; in ionic_notifyq_service()
1185 dev_dbg(lif->ionic->dev, "notifyq event:\n"); in ionic_notifyq_service()
1191 ionic_link_status_check_request(lif, CAN_NOT_SLEEP); in ionic_notifyq_service()
1194 if (lif->ionic->idev.fw_status_ready && in ionic_notifyq_service()
1195 !test_bit(IONIC_LIF_F_FW_RESET, lif->state) && in ionic_notifyq_service()
1196 !test_and_set_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { in ionic_notifyq_service()
1199 netdev_err(lif->netdev, "Reset event dropped\n"); in ionic_notifyq_service()
1200 clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); in ionic_notifyq_service()
1203 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_notifyq_service()
1232 struct ionic_lif *lif = napi_to_cq(napi)->lif; in ionic_adminq_napi() local
1233 struct ionic_dev *idev = &lif->ionic->idev; in ionic_adminq_napi()
1244 if (lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED) in ionic_adminq_napi()
1245 n_work = ionic_cq_service(&lif->notifyqcq->cq, budget, in ionic_adminq_napi()
1248 spin_lock_irqsave(&lif->adminq_lock, irqflags); in ionic_adminq_napi()
1249 if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED) in ionic_adminq_napi()
1250 a_work = ionic_cq_service(&lif->adminqcq->cq, budget, in ionic_adminq_napi()
1252 spin_unlock_irqrestore(&lif->adminq_lock, irqflags); in ionic_adminq_napi()
1254 if (lif->hwstamp_rxq) in ionic_adminq_napi()
1255 rx_work = ionic_cq_service(&lif->hwstamp_rxq->cq, budget, in ionic_adminq_napi()
1258 if (lif->hwstamp_txq) in ionic_adminq_napi()
1259 tx_work = ionic_cq_service(&lif->hwstamp_txq->cq, budget, in ionic_adminq_napi()
1274 if (!a_work && ionic_adminq_poke_doorbell(&lif->adminqcq->q)) in ionic_adminq_napi()
1276 if (lif->hwstamp_rxq && !rx_work && ionic_rxq_poke_doorbell(&lif->hwstamp_rxq->q)) in ionic_adminq_napi()
1278 if (lif->hwstamp_txq && !tx_work && ionic_txq_poke_doorbell(&lif->hwstamp_txq->q)) in ionic_adminq_napi()
1281 mod_timer(&lif->adminqcq->napi_deadline, in ionic_adminq_napi()
1290 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_stats64() local
1294 ls = &lif->info->stats; in ionic_get_stats64()
1354 void ionic_lif_rx_mode(struct ionic_lif *lif) in ionic_lif_rx_mode() argument
1356 struct net_device *netdev = lif->netdev; in ionic_lif_rx_mode()
1364 mutex_lock(&lif->config_lock); in ionic_lif_rx_mode()
1376 ionic_rx_filter_sync(lif); in ionic_lif_rx_mode()
1384 nfilters = le32_to_cpu(lif->identity->eth.max_ucast_filters); in ionic_lif_rx_mode()
1386 if (((lif->nucast + lif->nmcast) >= nfilters) || in ionic_lif_rx_mode()
1387 (lif->max_vlans && lif->nvlans >= lif->max_vlans)) { in ionic_lif_rx_mode()
1398 lif->rx_mode, rx_mode); in ionic_lif_rx_mode()
1411 netdev_dbg(netdev, "lif%d %s\n", lif->index, buf); in ionic_lif_rx_mode()
1413 if (lif->rx_mode != rx_mode) { in ionic_lif_rx_mode()
1418 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rx_mode()
1424 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rx_mode()
1429 lif->rx_mode = rx_mode; in ionic_lif_rx_mode()
1432 mutex_unlock(&lif->config_lock); in ionic_lif_rx_mode()
1437 struct ionic_lif *lif = netdev_priv(netdev); in ionic_ndo_set_rx_mode() local
1449 netdev_err(lif->netdev, "rxmode change dropped\n"); in ionic_ndo_set_rx_mode()
1453 netdev_dbg(lif->netdev, "deferred: rx_mode\n"); in ionic_ndo_set_rx_mode()
1454 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_ndo_set_rx_mode()
1497 static int ionic_set_nic_features(struct ionic_lif *lif, in ionic_set_nic_features() argument
1500 struct device *dev = lif->ionic->dev; in ionic_set_nic_features()
1505 .index = cpu_to_le16(lif->index), in ionic_set_nic_features()
1517 if (lif->phc) in ionic_set_nic_features()
1520 err = ionic_adminq_post_wait(lif, &ctx); in ionic_set_nic_features()
1524 old_hw_features = lif->hw_features; in ionic_set_nic_features()
1525 lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features & in ionic_set_nic_features()
1528 if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1529 ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL); in ionic_set_nic_features()
1533 dev_info_once(lif->ionic->dev, "NIC is not supporting vlan offload, likely in SmartNIC mode\n"); in ionic_set_nic_features()
1535 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_set_nic_features()
1537 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_set_nic_features()
1539 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_set_nic_features()
1541 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1543 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_set_nic_features()
1545 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_set_nic_features()
1547 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_set_nic_features()
1549 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_set_nic_features()
1551 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_set_nic_features()
1553 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_set_nic_features()
1555 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_set_nic_features()
1557 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_set_nic_features()
1559 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_set_nic_features()
1561 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_set_nic_features()
1563 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_set_nic_features()
1565 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_set_nic_features()
1567 if (lif->hw_features & IONIC_ETH_HW_TIMESTAMP) in ionic_set_nic_features()
1573 static int ionic_init_nic_features(struct ionic_lif *lif) in ionic_init_nic_features() argument
1575 struct net_device *netdev = lif->netdev; in ionic_init_nic_features()
1596 if (lif->nxqs > 1) in ionic_init_nic_features()
1599 err = ionic_set_nic_features(lif, features); in ionic_init_nic_features()
1606 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_init_nic_features()
1608 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_init_nic_features()
1610 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_init_nic_features()
1612 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_init_nic_features()
1614 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_init_nic_features()
1617 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_init_nic_features()
1619 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_init_nic_features()
1621 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_init_nic_features()
1623 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_init_nic_features()
1625 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_init_nic_features()
1627 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_init_nic_features()
1629 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_init_nic_features()
1631 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_init_nic_features()
1633 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_init_nic_features()
1635 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_init_nic_features()
1637 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_init_nic_features()
1653 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_features() local
1657 __func__, (u64)lif->netdev->features, (u64)features); in ionic_set_features()
1659 err = ionic_set_nic_features(lif, features); in ionic_set_features()
1664 static int ionic_set_attr_mac(struct ionic_lif *lif, u8 *mac) in ionic_set_attr_mac() argument
1670 .index = cpu_to_le16(lif->index), in ionic_set_attr_mac()
1676 return ionic_adminq_post_wait(lif, &ctx); in ionic_set_attr_mac()
1679 static int ionic_get_attr_mac(struct ionic_lif *lif, u8 *mac_addr) in ionic_get_attr_mac() argument
1685 .index = cpu_to_le16(lif->index), in ionic_get_attr_mac()
1691 err = ionic_adminq_post_wait(lif, &ctx); in ionic_get_attr_mac()
1699 static int ionic_program_mac(struct ionic_lif *lif, u8 *mac) in ionic_program_mac() argument
1704 err = ionic_set_attr_mac(lif, mac); in ionic_program_mac()
1708 err = ionic_get_attr_mac(lif, get_mac); in ionic_program_mac()
1724 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_mac_address() local
1733 err = ionic_program_mac(lif, mac); in ionic_set_mac_address()
1757 void ionic_stop_queues_reconfig(struct ionic_lif *lif) in ionic_stop_queues_reconfig() argument
1760 netif_device_detach(lif->netdev); in ionic_stop_queues_reconfig()
1761 ionic_stop_queues(lif); in ionic_stop_queues_reconfig()
1762 ionic_txrx_deinit(lif); in ionic_stop_queues_reconfig()
1765 static int ionic_start_queues_reconfig(struct ionic_lif *lif) in ionic_start_queues_reconfig() argument
1777 err = ionic_txrx_init(lif); in ionic_start_queues_reconfig()
1778 ionic_link_status_check_request(lif, CAN_NOT_SLEEP); in ionic_start_queues_reconfig()
1779 netif_device_attach(lif->netdev); in ionic_start_queues_reconfig()
1786 struct ionic_lif *lif = netdev_priv(netdev); in ionic_change_mtu() local
1791 .index = cpu_to_le16(lif->index), in ionic_change_mtu()
1798 err = ionic_adminq_post_wait(lif, &ctx); in ionic_change_mtu()
1808 mutex_lock(&lif->queue_lock); in ionic_change_mtu()
1809 ionic_stop_queues_reconfig(lif); in ionic_change_mtu()
1811 err = ionic_start_queues_reconfig(lif); in ionic_change_mtu()
1812 mutex_unlock(&lif->queue_lock); in ionic_change_mtu()
1819 struct ionic_lif *lif = container_of(ws, struct ionic_lif, tx_timeout_work); in ionic_tx_timeout_work() local
1822 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_tx_timeout_work()
1828 if (!netif_running(lif->netdev)) in ionic_tx_timeout_work()
1831 mutex_lock(&lif->queue_lock); in ionic_tx_timeout_work()
1832 ionic_stop_queues_reconfig(lif); in ionic_tx_timeout_work()
1833 err = ionic_start_queues_reconfig(lif); in ionic_tx_timeout_work()
1834 mutex_unlock(&lif->queue_lock); in ionic_tx_timeout_work()
1837 dev_err(lif->ionic->dev, "%s: Restarting queues failed\n", __func__); in ionic_tx_timeout_work()
1842 struct ionic_lif *lif = netdev_priv(netdev); in ionic_tx_timeout() local
1844 netdev_info(lif->netdev, "Tx Timeout triggered - txq %d\n", txqueue); in ionic_tx_timeout()
1845 schedule_work(&lif->tx_timeout_work); in ionic_tx_timeout()
1851 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_add_vid() local
1854 err = ionic_lif_vlan_add(lif, vid); in ionic_vlan_rx_add_vid()
1858 ionic_lif_rx_mode(lif); in ionic_vlan_rx_add_vid()
1866 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_kill_vid() local
1869 err = ionic_lif_vlan_del(lif, vid); in ionic_vlan_rx_kill_vid()
1873 ionic_lif_rx_mode(lif); in ionic_vlan_rx_kill_vid()
1878 int ionic_lif_rss_config(struct ionic_lif *lif, const u16 types, in ionic_lif_rss_config() argument
1886 .rss.addr = cpu_to_le64(lif->rss_ind_tbl_pa), in ionic_lif_rss_config()
1891 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) { in ionic_lif_rss_config()
1892 lif->rss_types = types; in ionic_lif_rss_config()
1897 memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_config()
1900 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_config()
1902 lif->rss_ind_tbl[i] = indir[i]; in ionic_lif_rss_config()
1905 memcpy(ctx.cmd.lif_setattr.rss.key, lif->rss_hash_key, in ionic_lif_rss_config()
1908 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rss_config()
1911 static int ionic_lif_rss_init(struct ionic_lif *lif) in ionic_lif_rss_init() argument
1916 lif->rss_types = IONIC_RSS_TYPE_IPV4 | in ionic_lif_rss_init()
1924 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_init()
1926 lif->rss_ind_tbl[i] = ethtool_rxfh_indir_default(i, lif->nxqs); in ionic_lif_rss_init()
1928 return ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL); in ionic_lif_rss_init()
1931 static void ionic_lif_rss_deinit(struct ionic_lif *lif) in ionic_lif_rss_deinit() argument
1935 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_deinit()
1936 memset(lif->rss_ind_tbl, 0, tbl_sz); in ionic_lif_rss_deinit()
1937 memset(lif->rss_hash_key, 0, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_deinit()
1939 ionic_lif_rss_config(lif, 0x0, NULL, NULL); in ionic_lif_rss_deinit()
1942 static void ionic_lif_quiesce(struct ionic_lif *lif) in ionic_lif_quiesce() argument
1948 .index = cpu_to_le16(lif->index), in ionic_lif_quiesce()
1955 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_quiesce()
1957 netdev_dbg(lif->netdev, "lif quiesce failed %d\n", err); in ionic_lif_quiesce()
1960 static void ionic_txrx_disable(struct ionic_lif *lif) in ionic_txrx_disable() argument
1965 if (lif->txqcqs) { in ionic_txrx_disable()
1966 for (i = 0; i < lif->nxqs; i++) in ionic_txrx_disable()
1967 err = ionic_qcq_disable(lif, lif->txqcqs[i], err); in ionic_txrx_disable()
1970 if (lif->hwstamp_txq) in ionic_txrx_disable()
1971 err = ionic_qcq_disable(lif, lif->hwstamp_txq, err); in ionic_txrx_disable()
1973 if (lif->rxqcqs) { in ionic_txrx_disable()
1974 for (i = 0; i < lif->nxqs; i++) in ionic_txrx_disable()
1975 err = ionic_qcq_disable(lif, lif->rxqcqs[i], err); in ionic_txrx_disable()
1978 if (lif->hwstamp_rxq) in ionic_txrx_disable()
1979 err = ionic_qcq_disable(lif, lif->hwstamp_rxq, err); in ionic_txrx_disable()
1981 ionic_lif_quiesce(lif); in ionic_txrx_disable()
1984 static void ionic_txrx_deinit(struct ionic_lif *lif) in ionic_txrx_deinit() argument
1988 if (lif->txqcqs) { in ionic_txrx_deinit()
1989 for (i = 0; i < lif->nxqs && lif->txqcqs[i]; i++) { in ionic_txrx_deinit()
1990 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_deinit()
1991 ionic_tx_flush(&lif->txqcqs[i]->cq); in ionic_txrx_deinit()
1992 ionic_tx_empty(&lif->txqcqs[i]->q); in ionic_txrx_deinit()
1996 if (lif->rxqcqs) { in ionic_txrx_deinit()
1997 for (i = 0; i < lif->nxqs && lif->rxqcqs[i]; i++) { in ionic_txrx_deinit()
1998 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); in ionic_txrx_deinit()
1999 ionic_rx_empty(&lif->rxqcqs[i]->q); in ionic_txrx_deinit()
2002 lif->rx_mode = 0; in ionic_txrx_deinit()
2004 if (lif->hwstamp_txq) { in ionic_txrx_deinit()
2005 ionic_lif_qcq_deinit(lif, lif->hwstamp_txq); in ionic_txrx_deinit()
2006 ionic_tx_flush(&lif->hwstamp_txq->cq); in ionic_txrx_deinit()
2007 ionic_tx_empty(&lif->hwstamp_txq->q); in ionic_txrx_deinit()
2010 if (lif->hwstamp_rxq) { in ionic_txrx_deinit()
2011 ionic_lif_qcq_deinit(lif, lif->hwstamp_rxq); in ionic_txrx_deinit()
2012 ionic_rx_empty(&lif->hwstamp_rxq->q); in ionic_txrx_deinit()
2016 void ionic_txrx_free(struct ionic_lif *lif) in ionic_txrx_free() argument
2020 if (lif->txqcqs) { in ionic_txrx_free()
2021 for (i = 0; i < lif->ionic->ntxqs_per_lif && lif->txqcqs[i]; i++) { in ionic_txrx_free()
2022 ionic_qcq_free(lif, lif->txqcqs[i]); in ionic_txrx_free()
2023 devm_kfree(lif->ionic->dev, lif->txqcqs[i]); in ionic_txrx_free()
2024 lif->txqcqs[i] = NULL; in ionic_txrx_free()
2028 if (lif->rxqcqs) { in ionic_txrx_free()
2029 for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { in ionic_txrx_free()
2030 ionic_qcq_free(lif, lif->rxqcqs[i]); in ionic_txrx_free()
2031 devm_kfree(lif->ionic->dev, lif->rxqcqs[i]); in ionic_txrx_free()
2032 lif->rxqcqs[i] = NULL; in ionic_txrx_free()
2036 if (lif->hwstamp_txq) { in ionic_txrx_free()
2037 ionic_qcq_free(lif, lif->hwstamp_txq); in ionic_txrx_free()
2038 devm_kfree(lif->ionic->dev, lif->hwstamp_txq); in ionic_txrx_free()
2039 lif->hwstamp_txq = NULL; in ionic_txrx_free()
2042 if (lif->hwstamp_rxq) { in ionic_txrx_free()
2043 ionic_qcq_free(lif, lif->hwstamp_rxq); in ionic_txrx_free()
2044 devm_kfree(lif->ionic->dev, lif->hwstamp_rxq); in ionic_txrx_free()
2045 lif->hwstamp_rxq = NULL; in ionic_txrx_free()
2049 static int ionic_txrx_alloc(struct ionic_lif *lif) in ionic_txrx_alloc() argument
2055 num_desc = lif->ntxq_descs; in ionic_txrx_alloc()
2059 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_txrx_alloc()
2060 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == in ionic_txrx_alloc()
2068 if (test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state)) in ionic_txrx_alloc()
2071 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_txrx_alloc()
2074 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
2075 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_txrx_alloc()
2077 lif->kern_pid, &lif->txqcqs[i]); in ionic_txrx_alloc()
2082 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
2083 lif->txqcqs[i]->intr.index, in ionic_txrx_alloc()
2084 lif->tx_coalesce_hw); in ionic_txrx_alloc()
2085 if (test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state)) in ionic_txrx_alloc()
2086 lif->txqcqs[i]->intr.dim_coal_hw = lif->tx_coalesce_hw; in ionic_txrx_alloc()
2089 ionic_debugfs_add_qcq(lif, lif->txqcqs[i]); in ionic_txrx_alloc()
2094 if (test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state)) in ionic_txrx_alloc()
2097 num_desc = lif->nrxq_descs; in ionic_txrx_alloc()
2102 if (lif->rxq_features & IONIC_Q_F_2X_CQ_DESC) in ionic_txrx_alloc()
2105 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
2106 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_txrx_alloc()
2108 lif->kern_pid, &lif->rxqcqs[i]); in ionic_txrx_alloc()
2112 lif->rxqcqs[i]->q.features = lif->rxq_features; in ionic_txrx_alloc()
2114 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
2115 lif->rxqcqs[i]->intr.index, in ionic_txrx_alloc()
2116 lif->rx_coalesce_hw); in ionic_txrx_alloc()
2117 if (test_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state)) in ionic_txrx_alloc()
2118 lif->rxqcqs[i]->intr.dim_coal_hw = lif->rx_coalesce_hw; in ionic_txrx_alloc()
2120 if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_txrx_alloc()
2121 ionic_link_qcq_interrupts(lif->rxqcqs[i], in ionic_txrx_alloc()
2122 lif->txqcqs[i]); in ionic_txrx_alloc()
2124 ionic_debugfs_add_qcq(lif, lif->rxqcqs[i]); in ionic_txrx_alloc()
2130 ionic_txrx_free(lif); in ionic_txrx_alloc()
2135 static int ionic_txrx_init(struct ionic_lif *lif) in ionic_txrx_init() argument
2140 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_init()
2141 err = ionic_lif_txq_init(lif, lif->txqcqs[i]); in ionic_txrx_init()
2145 err = ionic_lif_rxq_init(lif, lif->rxqcqs[i]); in ionic_txrx_init()
2147 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_init()
2152 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_txrx_init()
2153 ionic_lif_rss_init(lif); in ionic_txrx_init()
2155 ionic_lif_rx_mode(lif); in ionic_txrx_init()
2161 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_init()
2162 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); in ionic_txrx_init()
2168 static int ionic_txrx_enable(struct ionic_lif *lif) in ionic_txrx_enable() argument
2173 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_enable()
2174 if (!(lif->rxqcqs[i] && lif->txqcqs[i])) { in ionic_txrx_enable()
2175 dev_err(lif->ionic->dev, "%s: bad qcq %d\n", __func__, i); in ionic_txrx_enable()
2180 ionic_rx_fill(&lif->rxqcqs[i]->q); in ionic_txrx_enable()
2181 err = ionic_qcq_enable(lif->rxqcqs[i]); in ionic_txrx_enable()
2185 err = ionic_qcq_enable(lif->txqcqs[i]); in ionic_txrx_enable()
2187 derr = ionic_qcq_disable(lif, lif->rxqcqs[i], err); in ionic_txrx_enable()
2192 if (lif->hwstamp_rxq) { in ionic_txrx_enable()
2193 ionic_rx_fill(&lif->hwstamp_rxq->q); in ionic_txrx_enable()
2194 err = ionic_qcq_enable(lif->hwstamp_rxq); in ionic_txrx_enable()
2199 if (lif->hwstamp_txq) { in ionic_txrx_enable()
2200 err = ionic_qcq_enable(lif->hwstamp_txq); in ionic_txrx_enable()
2208 if (lif->hwstamp_rxq) in ionic_txrx_enable()
2209 derr = ionic_qcq_disable(lif, lif->hwstamp_rxq, derr); in ionic_txrx_enable()
2211 i = lif->nxqs; in ionic_txrx_enable()
2214 derr = ionic_qcq_disable(lif, lif->txqcqs[i], derr); in ionic_txrx_enable()
2215 derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr); in ionic_txrx_enable()
2221 static int ionic_start_queues(struct ionic_lif *lif) in ionic_start_queues() argument
2225 if (test_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_start_queues()
2228 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_start_queues()
2231 if (test_and_set_bit(IONIC_LIF_F_UP, lif->state)) in ionic_start_queues()
2234 err = ionic_txrx_enable(lif); in ionic_start_queues()
2236 clear_bit(IONIC_LIF_F_UP, lif->state); in ionic_start_queues()
2239 netif_tx_wake_all_queues(lif->netdev); in ionic_start_queues()
2246 struct ionic_lif *lif = netdev_priv(netdev); in ionic_open() local
2250 if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_open()
2253 mutex_lock(&lif->queue_lock); in ionic_open()
2255 err = ionic_txrx_alloc(lif); in ionic_open()
2259 err = ionic_txrx_init(lif); in ionic_open()
2263 err = netif_set_real_num_tx_queues(netdev, lif->nxqs); in ionic_open()
2267 err = netif_set_real_num_rx_queues(netdev, lif->nxqs); in ionic_open()
2273 err = ionic_start_queues(lif); in ionic_open()
2281 ionic_lif_hwstamp_recreate_queues(lif); in ionic_open()
2283 mutex_unlock(&lif->queue_lock); in ionic_open()
2288 ionic_txrx_deinit(lif); in ionic_open()
2290 ionic_txrx_free(lif); in ionic_open()
2292 mutex_unlock(&lif->queue_lock); in ionic_open()
2296 static void ionic_stop_queues(struct ionic_lif *lif) in ionic_stop_queues() argument
2298 if (!test_and_clear_bit(IONIC_LIF_F_UP, lif->state)) in ionic_stop_queues()
2301 netif_tx_disable(lif->netdev); in ionic_stop_queues()
2302 ionic_txrx_disable(lif); in ionic_stop_queues()
2307 struct ionic_lif *lif = netdev_priv(netdev); in ionic_stop() local
2309 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_stop()
2312 mutex_lock(&lif->queue_lock); in ionic_stop()
2313 ionic_stop_queues(lif); in ionic_stop()
2314 ionic_txrx_deinit(lif); in ionic_stop()
2315 ionic_txrx_free(lif); in ionic_stop()
2316 mutex_unlock(&lif->queue_lock); in ionic_stop()
2323 struct ionic_lif *lif = netdev_priv(netdev); in ionic_eth_ioctl() local
2327 return ionic_lif_hwstamp_set(lif, ifr); in ionic_eth_ioctl()
2329 return ionic_lif_hwstamp_get(lif, ifr); in ionic_eth_ioctl()
2408 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_vf_config() local
2409 struct ionic *ionic = lif->ionic; in ionic_get_vf_config()
2442 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_vf_stats() local
2443 struct ionic *ionic = lif->ionic; in ionic_get_vf_stats()
2479 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_mac() local
2480 struct ionic *ionic = lif->ionic; in ionic_set_vf_mac()
2511 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_vlan() local
2512 struct ionic *ionic = lif->ionic; in ionic_set_vf_vlan()
2550 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_rate() local
2551 struct ionic *ionic = lif->ionic; in ionic_set_vf_rate()
2582 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_spoofchk() local
2583 struct ionic *ionic = lif->ionic; in ionic_set_vf_spoofchk()
2610 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_trust() local
2611 struct ionic *ionic = lif->ionic; in ionic_set_vf_trust()
2638 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_link_state() local
2639 struct ionic *ionic = lif->ionic; in ionic_set_vf_link_state()
2678 static void ionic_vf_attr_replay(struct ionic_lif *lif) in ionic_vf_attr_replay() argument
2681 struct ionic *ionic = lif->ionic; in ionic_vf_attr_replay()
2772 static int ionic_cmb_reconfig(struct ionic_lif *lif, in ionic_cmb_reconfig() argument
2785 ionic_init_queue_params(lif, &start_qparams); in ionic_cmb_reconfig()
2788 ionic_stop_queues_reconfig(lif); in ionic_cmb_reconfig()
2789 ionic_txrx_free(lif); in ionic_cmb_reconfig()
2792 ionic_set_queue_params(lif, qparam); in ionic_cmb_reconfig()
2794 if (netif_running(lif->netdev)) { in ionic_cmb_reconfig()
2796 err = ionic_txrx_alloc(lif); in ionic_cmb_reconfig()
2798 dev_warn(lif->ionic->dev, in ionic_cmb_reconfig()
2802 ionic_set_queue_params(lif, &start_qparams); in ionic_cmb_reconfig()
2803 err = ionic_txrx_alloc(lif); in ionic_cmb_reconfig()
2805 dev_err(lif->ionic->dev, in ionic_cmb_reconfig()
2811 err = ionic_start_queues_reconfig(lif); in ionic_cmb_reconfig()
2813 dev_err(lif->ionic->dev, in ionic_cmb_reconfig()
2821 netif_device_attach(lif->netdev); in ionic_cmb_reconfig()
2856 ionic_debugfs_add_qcq(a->q.lif, a); in ionic_swap_queues()
2859 int ionic_reconfigure_queues(struct ionic_lif *lif, in ionic_reconfigure_queues() argument
2869 if ((test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state) && qparam->cmb_tx) || in ionic_reconfigure_queues()
2870 (test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state) && qparam->cmb_rx)) in ionic_reconfigure_queues()
2871 return ionic_cmb_reconfig(lif, qparam); in ionic_reconfigure_queues()
2874 if (qparam->nxqs != lif->nxqs || qparam->ntxq_descs != lif->ntxq_descs) { in ionic_reconfigure_queues()
2875 tx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->ntxqs_per_lif, in ionic_reconfigure_queues()
2882 if (qparam->nxqs != lif->nxqs || in ionic_reconfigure_queues()
2883 qparam->nrxq_descs != lif->nrxq_descs || in ionic_reconfigure_queues()
2884 qparam->rxq_features != lif->rxq_features) { in ionic_reconfigure_queues()
2885 rx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->nrxqs_per_lif, in ionic_reconfigure_queues()
2901 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_reconfigure_queues()
2902 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == in ionic_reconfigure_queues()
2910 if (!lif->txqcqs[i]) { in ionic_reconfigure_queues()
2912 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_reconfigure_queues()
2914 lif->kern_pid, &lif->txqcqs[i]); in ionic_reconfigure_queues()
2919 flags = lif->txqcqs[i]->flags & ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
2920 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_reconfigure_queues()
2922 lif->kern_pid, &tx_qcqs[i]); in ionic_reconfigure_queues()
2939 if (!lif->rxqcqs[i]) { in ionic_reconfigure_queues()
2941 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_reconfigure_queues()
2943 lif->kern_pid, &lif->rxqcqs[i]); in ionic_reconfigure_queues()
2948 flags = lif->rxqcqs[i]->flags & ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
2949 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_reconfigure_queues()
2951 lif->kern_pid, &rx_qcqs[i]); in ionic_reconfigure_queues()
2960 ionic_stop_queues_reconfig(lif); in ionic_reconfigure_queues()
2962 if (qparam->nxqs != lif->nxqs) { in ionic_reconfigure_queues()
2963 err = netif_set_real_num_tx_queues(lif->netdev, qparam->nxqs); in ionic_reconfigure_queues()
2966 err = netif_set_real_num_rx_queues(lif->netdev, qparam->nxqs); in ionic_reconfigure_queues()
2968 netif_set_real_num_tx_queues(lif->netdev, lif->nxqs); in ionic_reconfigure_queues()
2975 lif->ntxq_descs = qparam->ntxq_descs; in ionic_reconfigure_queues()
2977 ionic_swap_queues(lif->txqcqs[i], tx_qcqs[i]); in ionic_reconfigure_queues()
2981 lif->nrxq_descs = qparam->nrxq_descs; in ionic_reconfigure_queues()
2983 ionic_swap_queues(lif->rxqcqs[i], rx_qcqs[i]); in ionic_reconfigure_queues()
2987 if (qparam->intr_split != test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state) || in ionic_reconfigure_queues()
2988 qparam->nxqs != lif->nxqs) { in ionic_reconfigure_queues()
2990 set_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); in ionic_reconfigure_queues()
2992 clear_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); in ionic_reconfigure_queues()
2993 lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; in ionic_reconfigure_queues()
2994 lif->tx_coalesce_hw = lif->rx_coalesce_hw; in ionic_reconfigure_queues()
3001 for (i = 0; i < lif->ionic->ntxqs_per_lif; i++) { in ionic_reconfigure_queues()
3002 if (lif->txqcqs[i]) in ionic_reconfigure_queues()
3003 ionic_qcq_intr_free(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3004 if (lif->rxqcqs[i]) in ionic_reconfigure_queues()
3005 ionic_qcq_intr_free(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3010 lif->rxqcqs[i]->flags |= IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3011 err = ionic_alloc_qcq_interrupt(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3012 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_reconfigure_queues()
3013 lif->rxqcqs[i]->intr.index, in ionic_reconfigure_queues()
3014 lif->rx_coalesce_hw); in ionic_reconfigure_queues()
3017 lif->txqcqs[i]->flags |= IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3018 err = ionic_alloc_qcq_interrupt(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3019 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_reconfigure_queues()
3020 lif->txqcqs[i]->intr.index, in ionic_reconfigure_queues()
3021 lif->tx_coalesce_hw); in ionic_reconfigure_queues()
3022 if (test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state)) in ionic_reconfigure_queues()
3023 lif->txqcqs[i]->intr.dim_coal_hw = lif->tx_coalesce_hw; in ionic_reconfigure_queues()
3025 lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3026 ionic_link_qcq_interrupts(lif->rxqcqs[i], lif->txqcqs[i]); in ionic_reconfigure_queues()
3034 ionic_debugfs_del_qcq(lif->txqcqs[i]); in ionic_reconfigure_queues()
3035 ionic_debugfs_add_qcq(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3041 ionic_debugfs_del_qcq(lif->rxqcqs[i]); in ionic_reconfigure_queues()
3042 ionic_debugfs_add_qcq(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3046 swap(lif->nxqs, qparam->nxqs); in ionic_reconfigure_queues()
3047 swap(lif->rxq_features, qparam->rxq_features); in ionic_reconfigure_queues()
3052 ionic_start_queues_reconfig(lif); in ionic_reconfigure_queues()
3054 err = ionic_start_queues_reconfig(lif); in ionic_reconfigure_queues()
3061 ionic_qcq_free(lif, tx_qcqs[i]); in ionic_reconfigure_queues()
3062 devm_kfree(lif->ionic->dev, tx_qcqs[i]); in ionic_reconfigure_queues()
3067 ionic_qcq_free(lif, rx_qcqs[i]); in ionic_reconfigure_queues()
3068 devm_kfree(lif->ionic->dev, rx_qcqs[i]); in ionic_reconfigure_queues()
3075 devm_kfree(lif->ionic->dev, rx_qcqs); in ionic_reconfigure_queues()
3079 devm_kfree(lif->ionic->dev, tx_qcqs); in ionic_reconfigure_queues()
3086 for (i = lif->nxqs; i < lif->ionic->ntxqs_per_lif; i++) { in ionic_reconfigure_queues()
3087 if (lif->txqcqs && lif->txqcqs[i]) { in ionic_reconfigure_queues()
3088 lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3089 ionic_qcq_free(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3092 if (lif->rxqcqs && lif->rxqcqs[i]) { in ionic_reconfigure_queues()
3093 lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3094 ionic_qcq_free(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3099 netdev_info(lif->netdev, "%s: failed %d\n", __func__, err); in ionic_reconfigure_queues()
3109 struct ionic_lif *lif; in ionic_lif_alloc() local
3117 netdev = alloc_etherdev_mqs(sizeof(*lif), in ionic_lif_alloc()
3127 lif = netdev_priv(netdev); in ionic_lif_alloc()
3128 lif->netdev = netdev; in ionic_lif_alloc()
3129 ionic->lif = lif; in ionic_lif_alloc()
3136 lif->identity = lid; in ionic_lif_alloc()
3137 lif->lif_type = IONIC_LIF_TYPE_CLASSIC; in ionic_lif_alloc()
3138 err = ionic_lif_identify(ionic, lif->lif_type, lif->identity); in ionic_lif_alloc()
3141 lif->lif_type, err); in ionic_lif_alloc()
3144 lif->netdev->min_mtu = max_t(unsigned int, ETH_MIN_MTU, in ionic_lif_alloc()
3145 le32_to_cpu(lif->identity->eth.min_frame_size)); in ionic_lif_alloc()
3146 lif->netdev->max_mtu = in ionic_lif_alloc()
3147 le32_to_cpu(lif->identity->eth.max_frame_size) - ETH_HLEN - VLAN_HLEN; in ionic_lif_alloc()
3149 lif->neqs = ionic->neqs_per_lif; in ionic_lif_alloc()
3150 lif->nxqs = ionic->ntxqs_per_lif; in ionic_lif_alloc()
3152 lif->ionic = ionic; in ionic_lif_alloc()
3153 lif->index = 0; in ionic_lif_alloc()
3156 lif->ntxq_descs = IONIC_MIN_TXRX_DESC; in ionic_lif_alloc()
3157 lif->nrxq_descs = IONIC_MIN_TXRX_DESC; in ionic_lif_alloc()
3159 lif->ntxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
3160 lif->nrxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
3164 lif->rx_coalesce_usecs = IONIC_ITR_COAL_USEC_DEFAULT; in ionic_lif_alloc()
3165 lif->rx_coalesce_hw = ionic_coal_usec_to_hw(lif->ionic, in ionic_lif_alloc()
3166 lif->rx_coalesce_usecs); in ionic_lif_alloc()
3167 lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; in ionic_lif_alloc()
3168 lif->tx_coalesce_hw = lif->rx_coalesce_hw; in ionic_lif_alloc()
3169 set_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state); in ionic_lif_alloc()
3170 set_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state); in ionic_lif_alloc()
3172 snprintf(lif->name, sizeof(lif->name), "lif%u", lif->index); in ionic_lif_alloc()
3174 mutex_init(&lif->queue_lock); in ionic_lif_alloc()
3175 mutex_init(&lif->config_lock); in ionic_lif_alloc()
3177 spin_lock_init(&lif->adminq_lock); in ionic_lif_alloc()
3179 spin_lock_init(&lif->deferred.lock); in ionic_lif_alloc()
3180 INIT_LIST_HEAD(&lif->deferred.list); in ionic_lif_alloc()
3181 INIT_WORK(&lif->deferred.work, ionic_lif_deferred_work); in ionic_lif_alloc()
3184 lif->info_sz = ALIGN(sizeof(*lif->info), PAGE_SIZE); in ionic_lif_alloc()
3185 lif->info = dma_alloc_coherent(dev, lif->info_sz, in ionic_lif_alloc()
3186 &lif->info_pa, GFP_KERNEL); in ionic_lif_alloc()
3187 if (!lif->info) { in ionic_lif_alloc()
3193 ionic_debugfs_add_lif(lif); in ionic_lif_alloc()
3196 ionic_lif_queue_identify(lif); in ionic_lif_alloc()
3197 err = ionic_qcqs_alloc(lif); in ionic_lif_alloc()
3202 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_alloc()
3203 lif->rss_ind_tbl_sz = sizeof(*lif->rss_ind_tbl) * tbl_sz; in ionic_lif_alloc()
3204 lif->rss_ind_tbl = dma_alloc_coherent(dev, lif->rss_ind_tbl_sz, in ionic_lif_alloc()
3205 &lif->rss_ind_tbl_pa, in ionic_lif_alloc()
3208 if (!lif->rss_ind_tbl) { in ionic_lif_alloc()
3213 netdev_rss_key_fill(lif->rss_hash_key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_alloc()
3215 ionic_lif_alloc_phc(lif); in ionic_lif_alloc()
3220 ionic_qcqs_free(lif); in ionic_lif_alloc()
3222 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_alloc()
3223 lif->info = NULL; in ionic_lif_alloc()
3224 lif->info_pa = 0; in ionic_lif_alloc()
3226 mutex_destroy(&lif->config_lock); in ionic_lif_alloc()
3227 mutex_destroy(&lif->queue_lock); in ionic_lif_alloc()
3229 free_netdev(lif->netdev); in ionic_lif_alloc()
3230 lif = NULL; in ionic_lif_alloc()
3237 static void ionic_lif_reset(struct ionic_lif *lif) in ionic_lif_reset() argument
3239 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_reset()
3241 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
3242 ionic_dev_cmd_lif_reset(idev, lif->index); in ionic_lif_reset()
3243 ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_reset()
3244 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
3247 static void ionic_lif_handle_fw_down(struct ionic_lif *lif) in ionic_lif_handle_fw_down() argument
3249 struct ionic *ionic = lif->ionic; in ionic_lif_handle_fw_down()
3251 if (test_and_set_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_handle_fw_down()
3256 netif_device_detach(lif->netdev); in ionic_lif_handle_fw_down()
3258 mutex_lock(&lif->queue_lock); in ionic_lif_handle_fw_down()
3259 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_handle_fw_down()
3261 ionic_stop_queues(lif); in ionic_lif_handle_fw_down()
3264 if (netif_running(lif->netdev)) { in ionic_lif_handle_fw_down()
3265 ionic_txrx_deinit(lif); in ionic_lif_handle_fw_down()
3266 ionic_txrx_free(lif); in ionic_lif_handle_fw_down()
3268 ionic_lif_deinit(lif); in ionic_lif_handle_fw_down()
3270 ionic_qcqs_free(lif); in ionic_lif_handle_fw_down()
3272 mutex_unlock(&lif->queue_lock); in ionic_lif_handle_fw_down()
3274 clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); in ionic_lif_handle_fw_down()
3278 int ionic_restart_lif(struct ionic_lif *lif) in ionic_restart_lif() argument
3280 struct ionic *ionic = lif->ionic; in ionic_restart_lif()
3283 mutex_lock(&lif->queue_lock); in ionic_restart_lif()
3285 if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_restart_lif()
3288 err = ionic_qcqs_alloc(lif); in ionic_restart_lif()
3292 err = ionic_lif_init(lif); in ionic_restart_lif()
3296 ionic_vf_attr_replay(lif); in ionic_restart_lif()
3298 if (lif->registered) in ionic_restart_lif()
3299 ionic_lif_set_netdev_info(lif); in ionic_restart_lif()
3301 ionic_rx_filter_replay(lif); in ionic_restart_lif()
3303 if (netif_running(lif->netdev)) { in ionic_restart_lif()
3304 err = ionic_txrx_alloc(lif); in ionic_restart_lif()
3308 err = ionic_txrx_init(lif); in ionic_restart_lif()
3313 mutex_unlock(&lif->queue_lock); in ionic_restart_lif()
3315 clear_bit(IONIC_LIF_F_FW_RESET, lif->state); in ionic_restart_lif()
3316 ionic_link_status_check_request(lif, CAN_SLEEP); in ionic_restart_lif()
3317 netif_device_attach(lif->netdev); in ionic_restart_lif()
3322 ionic_txrx_free(lif); in ionic_restart_lif()
3324 ionic_lif_deinit(lif); in ionic_restart_lif()
3326 ionic_qcqs_free(lif); in ionic_restart_lif()
3328 mutex_unlock(&lif->queue_lock); in ionic_restart_lif()
3333 static void ionic_lif_handle_fw_up(struct ionic_lif *lif) in ionic_lif_handle_fw_up() argument
3335 struct ionic *ionic = lif->ionic; in ionic_lif_handle_fw_up()
3338 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_handle_fw_up()
3358 err = ionic_restart_lif(lif); in ionic_lif_handle_fw_up()
3365 ionic_lif_hwstamp_replay(lif); in ionic_lif_handle_fw_up()
3373 void ionic_lif_free(struct ionic_lif *lif) in ionic_lif_free() argument
3375 struct device *dev = lif->ionic->dev; in ionic_lif_free()
3377 ionic_lif_free_phc(lif); in ionic_lif_free()
3380 dma_free_coherent(dev, lif->rss_ind_tbl_sz, lif->rss_ind_tbl, in ionic_lif_free()
3381 lif->rss_ind_tbl_pa); in ionic_lif_free()
3382 lif->rss_ind_tbl = NULL; in ionic_lif_free()
3383 lif->rss_ind_tbl_pa = 0; in ionic_lif_free()
3386 ionic_qcqs_free(lif); in ionic_lif_free()
3387 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_free()
3388 ionic_lif_reset(lif); in ionic_lif_free()
3391 kfree(lif->identity); in ionic_lif_free()
3392 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_free()
3393 lif->info = NULL; in ionic_lif_free()
3394 lif->info_pa = 0; in ionic_lif_free()
3397 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_free()
3398 lif->kern_dbpage = NULL; in ionic_lif_free()
3400 mutex_destroy(&lif->config_lock); in ionic_lif_free()
3401 mutex_destroy(&lif->queue_lock); in ionic_lif_free()
3404 ionic_debugfs_del_lif(lif); in ionic_lif_free()
3405 free_netdev(lif->netdev); in ionic_lif_free()
3408 void ionic_lif_deinit(struct ionic_lif *lif) in ionic_lif_deinit() argument
3410 if (!test_and_clear_bit(IONIC_LIF_F_INITED, lif->state)) in ionic_lif_deinit()
3413 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { in ionic_lif_deinit()
3414 cancel_work_sync(&lif->deferred.work); in ionic_lif_deinit()
3415 cancel_work_sync(&lif->tx_timeout_work); in ionic_lif_deinit()
3416 ionic_rx_filters_deinit(lif); in ionic_lif_deinit()
3417 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_lif_deinit()
3418 ionic_lif_rss_deinit(lif); in ionic_lif_deinit()
3421 napi_disable(&lif->adminqcq->napi); in ionic_lif_deinit()
3422 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_deinit()
3423 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_deinit()
3425 ionic_lif_reset(lif); in ionic_lif_deinit()
3428 static int ionic_lif_adminq_init(struct ionic_lif *lif) in ionic_lif_adminq_init() argument
3430 struct device *dev = lif->ionic->dev; in ionic_lif_adminq_init()
3437 idev = &lif->ionic->idev; in ionic_lif_adminq_init()
3438 qcq = lif->adminqcq; in ionic_lif_adminq_init()
3441 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
3442 ionic_dev_cmd_adminq_init(idev, qcq, lif->index, qcq->intr.index); in ionic_lif_adminq_init()
3443 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_adminq_init()
3445 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
3447 netdev_err(lif->netdev, "adminq init failed %d\n", err); in ionic_lif_adminq_init()
3461 netif_napi_add(lif->netdev, &qcq->napi, ionic_adminq_napi); in ionic_lif_adminq_init()
3477 static int ionic_lif_notifyq_init(struct ionic_lif *lif) in ionic_lif_notifyq_init() argument
3479 struct ionic_qcq *qcq = lif->notifyqcq; in ionic_lif_notifyq_init()
3480 struct device *dev = lif->ionic->dev; in ionic_lif_notifyq_init()
3488 .lif_index = cpu_to_le16(lif->index), in ionic_lif_notifyq_init()
3490 .ver = lif->qtype_info[q->type].version, in ionic_lif_notifyq_init()
3494 .intr_index = cpu_to_le16(lif->adminqcq->intr.index), in ionic_lif_notifyq_init()
3506 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_notifyq_init()
3510 lif->last_eid = 0; in ionic_lif_notifyq_init()
3519 q->info[0].cb_arg = lif; in ionic_lif_notifyq_init()
3526 static int ionic_station_set(struct ionic_lif *lif) in ionic_station_set() argument
3528 struct net_device *netdev = lif->netdev; in ionic_station_set()
3533 .index = cpu_to_le16(lif->index), in ionic_station_set()
3541 err = ionic_adminq_post_wait(lif, &ctx); in ionic_station_set()
3544 netdev_dbg(lif->netdev, "found initial MAC addr %pM\n", in ionic_station_set()
3553 err = ionic_program_mac(lif, mac_address); in ionic_station_set()
3571 ionic_lif_addr_add(lif, netdev->dev_addr); in ionic_station_set()
3578 netdev_warn(lif->netdev, "ignoring bad MAC addr from NIC %pM - err %d\n", in ionic_station_set()
3586 netdev_dbg(lif->netdev, "adding station MAC addr %pM\n", in ionic_station_set()
3588 ionic_lif_addr_add(lif, netdev->dev_addr); in ionic_station_set()
3593 int ionic_lif_init(struct ionic_lif *lif) in ionic_lif_init() argument
3595 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_init()
3596 struct device *dev = lif->ionic->dev; in ionic_lif_init()
3601 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
3602 ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa); in ionic_lif_init()
3603 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_init()
3605 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
3609 lif->hw_index = le16_to_cpu(comp.hw_index); in ionic_lif_init()
3612 lif->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif); in ionic_lif_init()
3613 if (!lif->dbid_count) { in ionic_lif_init()
3618 lif->kern_pid = 0; in ionic_lif_init()
3619 dbpage_num = ionic_db_page_num(lif, lif->kern_pid); in ionic_lif_init()
3620 lif->kern_dbpage = ionic_bus_map_dbpage(lif->ionic, dbpage_num); in ionic_lif_init()
3621 if (!lif->kern_dbpage) { in ionic_lif_init()
3626 err = ionic_lif_adminq_init(lif); in ionic_lif_init()
3630 if (lif->ionic->nnqs_per_lif) { in ionic_lif_init()
3631 err = ionic_lif_notifyq_init(lif); in ionic_lif_init()
3636 err = ionic_init_nic_features(lif); in ionic_lif_init()
3640 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { in ionic_lif_init()
3641 err = ionic_rx_filters_init(lif); in ionic_lif_init()
3646 err = ionic_station_set(lif); in ionic_lif_init()
3650 lif->rx_copybreak = IONIC_RX_COPYBREAK_DEFAULT; in ionic_lif_init()
3652 set_bit(IONIC_LIF_F_INITED, lif->state); in ionic_lif_init()
3654 INIT_WORK(&lif->tx_timeout_work, ionic_tx_timeout_work); in ionic_lif_init()
3659 napi_disable(&lif->adminqcq->napi); in ionic_lif_init()
3660 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_init()
3662 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_init()
3663 ionic_lif_reset(lif); in ionic_lif_init()
3664 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_init()
3665 lif->kern_dbpage = NULL; in ionic_lif_init()
3674 static void ionic_lif_set_netdev_info(struct ionic_lif *lif) in ionic_lif_set_netdev_info() argument
3680 .index = cpu_to_le16(lif->index), in ionic_lif_set_netdev_info()
3685 strscpy(ctx.cmd.lif_setattr.name, lif->netdev->name, in ionic_lif_set_netdev_info()
3688 ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_netdev_info()
3704 struct ionic_lif *lif = ionic_netdev_lif(ndev); in ionic_lif_notify() local
3706 if (!lif || lif->ionic != ionic) in ionic_lif_notify()
3711 ionic_lif_set_netdev_info(lif); in ionic_lif_notify()
3718 int ionic_lif_register(struct ionic_lif *lif) in ionic_lif_register() argument
3722 ionic_lif_register_phc(lif); in ionic_lif_register()
3724 INIT_WORK(&lif->ionic->nb_work, ionic_lif_notify_work); in ionic_lif_register()
3726 lif->ionic->nb.notifier_call = ionic_lif_notify; in ionic_lif_register()
3728 err = register_netdevice_notifier(&lif->ionic->nb); in ionic_lif_register()
3730 lif->ionic->nb.notifier_call = NULL; in ionic_lif_register()
3733 err = register_netdev(lif->netdev); in ionic_lif_register()
3735 dev_err(lif->ionic->dev, "Cannot register net device, aborting\n"); in ionic_lif_register()
3736 ionic_lif_unregister_phc(lif); in ionic_lif_register()
3740 ionic_link_status_check_request(lif, CAN_SLEEP); in ionic_lif_register()
3741 lif->registered = true; in ionic_lif_register()
3742 ionic_lif_set_netdev_info(lif); in ionic_lif_register()
3747 void ionic_lif_unregister(struct ionic_lif *lif) in ionic_lif_unregister() argument
3749 if (lif->ionic->nb.notifier_call) { in ionic_lif_unregister()
3750 unregister_netdevice_notifier(&lif->ionic->nb); in ionic_lif_unregister()
3751 cancel_work_sync(&lif->ionic->nb_work); in ionic_lif_unregister()
3752 lif->ionic->nb.notifier_call = NULL; in ionic_lif_unregister()
3755 if (lif->netdev->reg_state == NETREG_REGISTERED) in ionic_lif_unregister()
3756 unregister_netdev(lif->netdev); in ionic_lif_unregister()
3758 ionic_lif_unregister_phc(lif); in ionic_lif_unregister()
3760 lif->registered = false; in ionic_lif_unregister()
3763 static void ionic_lif_queue_identify(struct ionic_lif *lif) in ionic_lif_queue_identify() argument
3766 struct ionic *ionic = lif->ionic; in ionic_lif_queue_identify()
3771 idev = &lif->ionic->idev; in ionic_lif_queue_identify()
3775 struct ionic_qtype_info *qti = &lif->qtype_info[qtype]; in ionic_lif_queue_identify()
3791 ionic_dev_cmd_queue_identify(idev, lif->lif_type, qtype, in ionic_lif_queue_identify()
3893 lc = &ident->lif.eth.config; in ionic_lif_size()
3895 neqs_per_lif = le32_to_cpu(ident->lif.rdma.eq_qtype.qid_count); in ionic_lif_size()