Lines Matching full: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);
55 struct ionic_lif *lif; in ionic_dim_work() local
60 lif = qcq->q.lif; in ionic_dim_work()
61 new_coal = ionic_coal_usec_to_hw(lif->ionic, cur_moder.usec); in ionic_dim_work()
68 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, 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()
310 static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fw_err) in ionic_qcq_disable() argument
323 netdev_err(lif->netdev, "%s: bad qcq\n", __func__); in ionic_qcq_disable()
330 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_disable()
347 ctx.cmd.q_control.lif_index = cpu_to_le16(lif->index); in ionic_qcq_disable()
350 dev_dbg(lif->ionic->dev, "q_disable.index %d q_disable.qtype %d\n", in ionic_qcq_disable()
353 return ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_disable()
356 static void ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_qcq_deinit() argument
358 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_qcq_deinit()
375 static void ionic_qcq_intr_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_intr_free() argument
381 devm_free_irq(lif->ionic->dev, qcq->intr.vector, &qcq->napi); in ionic_qcq_intr_free()
383 ionic_intr_free(lif->ionic, qcq->intr.index); in ionic_qcq_intr_free()
387 static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_free() argument
389 struct device *dev = lif->ionic->dev; in ionic_qcq_free()
404 ionic_put_cmb(lif, qcq->cmb_pgid, qcq->cmb_order); in ionic_qcq_free()
423 ionic_qcq_intr_free(lif, qcq); in ionic_qcq_free()
435 void ionic_qcqs_free(struct ionic_lif *lif) in ionic_qcqs_free() argument
437 struct device *dev = lif->ionic->dev; in ionic_qcqs_free()
441 if (lif->notifyqcq) { in ionic_qcqs_free()
442 ionic_qcq_free(lif, lif->notifyqcq); in ionic_qcqs_free()
443 devm_kfree(dev, lif->notifyqcq); in ionic_qcqs_free()
444 lif->notifyqcq = NULL; in ionic_qcqs_free()
447 if (lif->adminqcq) { in ionic_qcqs_free()
448 spin_lock_irqsave(&lif->adminq_lock, irqflags); in ionic_qcqs_free()
449 adminqcq = READ_ONCE(lif->adminqcq); in ionic_qcqs_free()
450 lif->adminqcq = NULL; in ionic_qcqs_free()
451 spin_unlock_irqrestore(&lif->adminq_lock, irqflags); in ionic_qcqs_free()
453 ionic_qcq_free(lif, adminqcq); in ionic_qcqs_free()
458 if (lif->rxqcqs) { in ionic_qcqs_free()
459 devm_kfree(dev, lif->rxqstats); in ionic_qcqs_free()
460 lif->rxqstats = NULL; in ionic_qcqs_free()
461 devm_kfree(dev, lif->rxqcqs); in ionic_qcqs_free()
462 lif->rxqcqs = NULL; in ionic_qcqs_free()
465 if (lif->txqcqs) { in ionic_qcqs_free()
466 devm_kfree(dev, lif->txqstats); in ionic_qcqs_free()
467 lif->txqstats = NULL; in ionic_qcqs_free()
468 devm_kfree(dev, lif->txqcqs); in ionic_qcqs_free()
469 lif->txqcqs = NULL; in ionic_qcqs_free()
481 static int ionic_alloc_qcq_interrupt(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_alloc_qcq_interrupt() argument
490 err = ionic_intr_alloc(lif, &qcq->intr); in ionic_alloc_qcq_interrupt()
492 netdev_warn(lif->netdev, "no intr for %s: %d\n", in ionic_alloc_qcq_interrupt()
497 err = ionic_bus_get_irq(lif->ionic, qcq->intr.index); in ionic_alloc_qcq_interrupt()
499 netdev_warn(lif->netdev, "no vector for %s: %d\n", in ionic_alloc_qcq_interrupt()
504 ionic_intr_mask_assert(lif->ionic->idev.intr_ctrl, qcq->intr.index, in ionic_alloc_qcq_interrupt()
507 err = ionic_request_irq(lif, qcq); in ionic_alloc_qcq_interrupt()
509 netdev_warn(lif->netdev, "irq request failed %d\n", err); in ionic_alloc_qcq_interrupt()
515 dev_to_node(lif->ionic->dev)); in ionic_alloc_qcq_interrupt()
519 netdev_dbg(lif->netdev, "%s: Interrupt index %d\n", qcq->q.name, qcq->intr.index); in ionic_alloc_qcq_interrupt()
523 ionic_intr_free(lif->ionic, qcq->intr.index); in ionic_alloc_qcq_interrupt()
528 static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, in ionic_qcq_alloc() argument
536 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_alloc()
537 struct device *dev = lif->ionic->dev; in ionic_qcq_alloc()
549 netdev_err(lif->netdev, "Cannot allocate queue structure\n"); in ionic_qcq_alloc()
559 netdev_err(lif->netdev, "Cannot allocate queue info\n"); in ionic_qcq_alloc()
565 new->q.max_sg_elems = lif->qtype_info[type].max_sg_elems; in ionic_qcq_alloc()
567 err = ionic_q_init(lif, idev, &new->q, index, name, num_descs, in ionic_qcq_alloc()
570 netdev_err(lif->netdev, "Cannot initialize queue\n"); in ionic_qcq_alloc()
574 err = ionic_alloc_qcq_interrupt(lif, new); in ionic_qcq_alloc()
580 netdev_err(lif->netdev, "Cannot allocate completion queue info\n"); in ionic_qcq_alloc()
585 err = ionic_cq_init(lif, &new->cq, &new->intr, num_descs, cq_desc_size); in ionic_qcq_alloc()
587 netdev_err(lif->netdev, "Cannot initialize completion queue\n"); in ionic_qcq_alloc()
604 netdev_err(lif->netdev, "Cannot allocate qcq DMA memory\n"); in ionic_qcq_alloc()
622 netdev_err(lif->netdev, "Cannot allocate queue DMA memory\n"); in ionic_qcq_alloc()
635 err = ionic_get_cmb(lif, &new->cmb_pgid, &new->cmb_q_base_pa, in ionic_qcq_alloc()
638 netdev_err(lif->netdev, in ionic_qcq_alloc()
646 netdev_err(lif->netdev, "Cannot map queue from cmb\n"); in ionic_qcq_alloc()
647 ionic_put_cmb(lif, new->cmb_pgid, new->cmb_order); in ionic_qcq_alloc()
661 netdev_err(lif->netdev, "Cannot allocate cq DMA memory\n"); in ionic_qcq_alloc()
676 netdev_err(lif->netdev, "Cannot allocate sg DMA memory\n"); in ionic_qcq_alloc()
697 ionic_put_cmb(lif, new->cmb_pgid, new->cmb_order); in ionic_qcq_alloc()
705 ionic_intr_free(lif->ionic, new->intr.index); in ionic_qcq_alloc()
716 static int ionic_qcqs_alloc(struct ionic_lif *lif) in ionic_qcqs_alloc() argument
718 struct device *dev = lif->ionic->dev; in ionic_qcqs_alloc()
723 err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags, in ionic_qcqs_alloc()
727 0, lif->kern_pid, &lif->adminqcq); in ionic_qcqs_alloc()
730 ionic_debugfs_add_qcq(lif, lif->adminqcq); in ionic_qcqs_alloc()
732 if (lif->ionic->nnqs_per_lif) { in ionic_qcqs_alloc()
734 err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notifyq", in ionic_qcqs_alloc()
738 0, lif->kern_pid, &lif->notifyqcq); in ionic_qcqs_alloc()
741 ionic_debugfs_add_qcq(lif, lif->notifyqcq); in ionic_qcqs_alloc()
744 ionic_link_qcq_interrupts(lif->adminqcq, lif->notifyqcq); in ionic_qcqs_alloc()
748 lif->txqcqs = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif, in ionic_qcqs_alloc()
749 sizeof(*lif->txqcqs), GFP_KERNEL); in ionic_qcqs_alloc()
750 if (!lif->txqcqs) in ionic_qcqs_alloc()
752 lif->rxqcqs = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif, in ionic_qcqs_alloc()
753 sizeof(*lif->rxqcqs), GFP_KERNEL); in ionic_qcqs_alloc()
754 if (!lif->rxqcqs) in ionic_qcqs_alloc()
757 lif->txqstats = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif + 1, in ionic_qcqs_alloc()
758 sizeof(*lif->txqstats), GFP_KERNEL); in ionic_qcqs_alloc()
759 if (!lif->txqstats) in ionic_qcqs_alloc()
761 lif->rxqstats = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif + 1, in ionic_qcqs_alloc()
762 sizeof(*lif->rxqstats), GFP_KERNEL); in ionic_qcqs_alloc()
763 if (!lif->rxqstats) in ionic_qcqs_alloc()
769 ionic_qcqs_free(lif); in ionic_qcqs_alloc()
786 static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_txq_init() argument
788 struct device *dev = lif->ionic->dev; in ionic_lif_txq_init()
795 .lif_index = cpu_to_le16(lif->index), in ionic_lif_txq_init()
797 .ver = lif->qtype_info[q->type].version, in ionic_lif_txq_init()
829 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_txq_init()
843 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) { in ionic_lif_txq_init()
844 netif_napi_add(lif->netdev, &qcq->napi, ionic_tx_napi); in ionic_lif_txq_init()
854 static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_rxq_init() argument
856 struct device *dev = lif->ionic->dev; in ionic_lif_rxq_init()
863 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rxq_init()
865 .ver = lif->qtype_info[q->type].version, in ionic_lif_rxq_init()
895 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rxq_init()
909 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_lif_rxq_init()
910 netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi); in ionic_lif_rxq_init()
912 netif_napi_add(lif->netdev, &qcq->napi, ionic_txrx_napi); in ionic_lif_rxq_init()
922 int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) in ionic_lif_create_hwstamp_txq() argument
930 if (lif->hwstamp_txq) in ionic_lif_create_hwstamp_txq()
939 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_lif_create_hwstamp_txq()
940 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == sizeof(struct ionic_txq_sg_desc_v1)) in ionic_lif_create_hwstamp_txq()
945 txq_i = lif->ionic->ntxqs_per_lif; in ionic_lif_create_hwstamp_txq()
948 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, txq_i, "hwstamp_tx", flags, in ionic_lif_create_hwstamp_txq()
950 lif->kern_pid, &txq); in ionic_lif_create_hwstamp_txq()
956 ionic_link_qcq_interrupts(lif->adminqcq, txq); in ionic_lif_create_hwstamp_txq()
957 ionic_debugfs_add_qcq(lif, txq); in ionic_lif_create_hwstamp_txq()
959 lif->hwstamp_txq = txq; in ionic_lif_create_hwstamp_txq()
961 if (netif_running(lif->netdev)) { in ionic_lif_create_hwstamp_txq()
962 err = ionic_lif_txq_init(lif, txq); in ionic_lif_create_hwstamp_txq()
966 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_create_hwstamp_txq()
976 ionic_lif_qcq_deinit(lif, txq); in ionic_lif_create_hwstamp_txq()
978 lif->hwstamp_txq = NULL; in ionic_lif_create_hwstamp_txq()
980 ionic_qcq_free(lif, txq); in ionic_lif_create_hwstamp_txq()
981 devm_kfree(lif->ionic->dev, txq); in ionic_lif_create_hwstamp_txq()
986 int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) in ionic_lif_create_hwstamp_rxq() argument
994 if (lif->hwstamp_rxq) in ionic_lif_create_hwstamp_rxq()
1004 rxq_i = lif->ionic->nrxqs_per_lif; in ionic_lif_create_hwstamp_rxq()
1007 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, rxq_i, "hwstamp_rx", flags, in ionic_lif_create_hwstamp_rxq()
1009 lif->kern_pid, &rxq); in ionic_lif_create_hwstamp_rxq()
1015 ionic_link_qcq_interrupts(lif->adminqcq, rxq); in ionic_lif_create_hwstamp_rxq()
1016 ionic_debugfs_add_qcq(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1018 lif->hwstamp_rxq = rxq; in ionic_lif_create_hwstamp_rxq()
1020 if (netif_running(lif->netdev)) { in ionic_lif_create_hwstamp_rxq()
1021 err = ionic_lif_rxq_init(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1025 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_create_hwstamp_rxq()
1036 ionic_lif_qcq_deinit(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1038 lif->hwstamp_rxq = NULL; in ionic_lif_create_hwstamp_rxq()
1040 ionic_qcq_free(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1041 devm_kfree(lif->ionic->dev, rxq); in ionic_lif_create_hwstamp_rxq()
1046 int ionic_lif_config_hwstamp_rxq_all(struct ionic_lif *lif, bool rx_all) in ionic_lif_config_hwstamp_rxq_all() argument
1050 ionic_init_queue_params(lif, &qparam); in ionic_lif_config_hwstamp_rxq_all()
1058 if (!netif_running(lif->netdev)) { in ionic_lif_config_hwstamp_rxq_all()
1059 lif->rxq_features = qparam.rxq_features; in ionic_lif_config_hwstamp_rxq_all()
1063 return ionic_reconfigure_queues(lif, &qparam); in ionic_lif_config_hwstamp_rxq_all()
1066 int ionic_lif_set_hwstamp_txmode(struct ionic_lif *lif, u16 txstamp_mode) in ionic_lif_set_hwstamp_txmode() argument
1072 .index = cpu_to_le16(lif->index), in ionic_lif_set_hwstamp_txmode()
1078 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_hwstamp_txmode()
1081 static void ionic_lif_del_hwstamp_rxfilt(struct ionic_lif *lif) in ionic_lif_del_hwstamp_rxfilt() argument
1087 .lif_index = cpu_to_le16(lif->index), in ionic_lif_del_hwstamp_rxfilt()
1094 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1096 f = ionic_rx_filter_rxsteer(lif); in ionic_lif_del_hwstamp_rxfilt()
1098 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1103 ionic_rx_filter_free(lif, f); in ionic_lif_del_hwstamp_rxfilt()
1105 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1107 netdev_dbg(lif->netdev, "rx_filter del RXSTEER (id %d)\n", filter_id); in ionic_lif_del_hwstamp_rxfilt()
1111 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_del_hwstamp_rxfilt()
1113 netdev_dbg(lif->netdev, "failed to delete rx_filter RXSTEER (id %d)\n", filter_id); in ionic_lif_del_hwstamp_rxfilt()
1116 static int ionic_lif_add_hwstamp_rxfilt(struct ionic_lif *lif, u64 pkt_class) in ionic_lif_add_hwstamp_rxfilt() argument
1122 .lif_index = cpu_to_le16(lif->index), in ionic_lif_add_hwstamp_rxfilt()
1131 if (!lif->hwstamp_rxq) in ionic_lif_add_hwstamp_rxfilt()
1134 qtype = lif->hwstamp_rxq->q.type; in ionic_lif_add_hwstamp_rxfilt()
1137 qid = lif->hwstamp_rxq->q.index; in ionic_lif_add_hwstamp_rxfilt()
1140 netdev_dbg(lif->netdev, "rx_filter add RXSTEER\n"); in ionic_lif_add_hwstamp_rxfilt()
1141 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_add_hwstamp_rxfilt()
1145 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_add_hwstamp_rxfilt()
1146 err = ionic_rx_filter_save(lif, 0, qid, 0, &ctx, IONIC_FILTER_STATE_SYNCED); in ionic_lif_add_hwstamp_rxfilt()
1147 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_add_hwstamp_rxfilt()
1152 int ionic_lif_set_hwstamp_rxfilt(struct ionic_lif *lif, u64 pkt_class) in ionic_lif_set_hwstamp_rxfilt() argument
1154 ionic_lif_del_hwstamp_rxfilt(lif); in ionic_lif_set_hwstamp_rxfilt()
1159 return ionic_lif_add_hwstamp_rxfilt(lif, pkt_class); in ionic_lif_set_hwstamp_rxfilt()
1169 struct ionic_lif *lif; in ionic_notifyq_service() local
1173 lif = q->info[0].cb_arg; in ionic_notifyq_service()
1174 netdev = lif->netdev; in ionic_notifyq_service()
1178 if ((s64)(eid - lif->last_eid) <= 0) in ionic_notifyq_service()
1181 lif->last_eid = eid; in ionic_notifyq_service()
1183 dev_dbg(lif->ionic->dev, "notifyq event:\n"); in ionic_notifyq_service()
1189 ionic_link_status_check_request(lif, CAN_NOT_SLEEP); in ionic_notifyq_service()
1192 if (lif->ionic->idev.fw_status_ready && in ionic_notifyq_service()
1193 !test_bit(IONIC_LIF_F_FW_RESET, lif->state) && in ionic_notifyq_service()
1194 !test_and_set_bit(IONIC_LIF_F_FW_STOPPING, lif->state)) { in ionic_notifyq_service()
1197 netdev_err(lif->netdev, "Reset event dropped\n"); in ionic_notifyq_service()
1198 clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); in ionic_notifyq_service()
1201 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_notifyq_service()
1230 struct ionic_lif *lif = napi_to_cq(napi)->lif; in ionic_adminq_napi() local
1231 struct ionic_dev *idev = &lif->ionic->idev; in ionic_adminq_napi()
1242 if (lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED) in ionic_adminq_napi()
1243 n_work = ionic_cq_service(&lif->notifyqcq->cq, budget, in ionic_adminq_napi()
1246 spin_lock_irqsave(&lif->adminq_lock, irqflags); in ionic_adminq_napi()
1247 if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED) in ionic_adminq_napi()
1248 a_work = ionic_cq_service(&lif->adminqcq->cq, budget, in ionic_adminq_napi()
1250 spin_unlock_irqrestore(&lif->adminq_lock, irqflags); in ionic_adminq_napi()
1252 if (lif->hwstamp_rxq) in ionic_adminq_napi()
1253 rx_work = ionic_cq_service(&lif->hwstamp_rxq->cq, budget, in ionic_adminq_napi()
1256 if (lif->hwstamp_txq) in ionic_adminq_napi()
1257 tx_work = ionic_cq_service(&lif->hwstamp_txq->cq, budget, in ionic_adminq_napi()
1272 if (!a_work && ionic_adminq_poke_doorbell(&lif->adminqcq->q)) in ionic_adminq_napi()
1274 if (lif->hwstamp_rxq && !rx_work && ionic_rxq_poke_doorbell(&lif->hwstamp_rxq->q)) in ionic_adminq_napi()
1276 if (lif->hwstamp_txq && !tx_work && ionic_txq_poke_doorbell(&lif->hwstamp_txq->q)) in ionic_adminq_napi()
1279 mod_timer(&lif->adminqcq->napi_deadline, in ionic_adminq_napi()
1288 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_stats64() local
1292 ls = &lif->info->stats; in ionic_get_stats64()
1352 void ionic_lif_rx_mode(struct ionic_lif *lif) in ionic_lif_rx_mode() argument
1354 struct net_device *netdev = lif->netdev; in ionic_lif_rx_mode()
1362 mutex_lock(&lif->config_lock); in ionic_lif_rx_mode()
1374 ionic_rx_filter_sync(lif); in ionic_lif_rx_mode()
1382 nfilters = le32_to_cpu(lif->identity->eth.max_ucast_filters); in ionic_lif_rx_mode()
1384 if (((lif->nucast + lif->nmcast) >= nfilters) || in ionic_lif_rx_mode()
1385 (lif->max_vlans && lif->nvlans >= lif->max_vlans)) { in ionic_lif_rx_mode()
1396 lif->rx_mode, rx_mode); in ionic_lif_rx_mode()
1409 netdev_dbg(netdev, "lif%d %s\n", lif->index, buf); in ionic_lif_rx_mode()
1411 if (lif->rx_mode != rx_mode) { in ionic_lif_rx_mode()
1416 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rx_mode()
1422 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rx_mode()
1427 lif->rx_mode = rx_mode; in ionic_lif_rx_mode()
1430 mutex_unlock(&lif->config_lock); in ionic_lif_rx_mode()
1435 struct ionic_lif *lif = netdev_priv(netdev); in ionic_ndo_set_rx_mode() local
1447 netdev_err(lif->netdev, "rxmode change dropped\n"); in ionic_ndo_set_rx_mode()
1451 netdev_dbg(lif->netdev, "deferred: rx_mode\n"); in ionic_ndo_set_rx_mode()
1452 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_ndo_set_rx_mode()
1495 static int ionic_set_nic_features(struct ionic_lif *lif, in ionic_set_nic_features() argument
1498 struct device *dev = lif->ionic->dev; in ionic_set_nic_features()
1503 .index = cpu_to_le16(lif->index), in ionic_set_nic_features()
1515 if (lif->phc) in ionic_set_nic_features()
1518 err = ionic_adminq_post_wait(lif, &ctx); in ionic_set_nic_features()
1522 old_hw_features = lif->hw_features; in ionic_set_nic_features()
1523 lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features & in ionic_set_nic_features()
1526 if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1527 ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL); in ionic_set_nic_features()
1531 dev_info_once(lif->ionic->dev, "NIC is not supporting vlan offload, likely in SmartNIC mode\n"); in ionic_set_nic_features()
1533 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_set_nic_features()
1535 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_set_nic_features()
1537 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_set_nic_features()
1539 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1541 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_set_nic_features()
1543 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_set_nic_features()
1545 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_set_nic_features()
1547 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_set_nic_features()
1549 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_set_nic_features()
1551 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_set_nic_features()
1553 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_set_nic_features()
1555 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_set_nic_features()
1557 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_set_nic_features()
1559 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_set_nic_features()
1561 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_set_nic_features()
1563 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_set_nic_features()
1565 if (lif->hw_features & IONIC_ETH_HW_TIMESTAMP) in ionic_set_nic_features()
1571 static int ionic_init_nic_features(struct ionic_lif *lif) in ionic_init_nic_features() argument
1573 struct net_device *netdev = lif->netdev; in ionic_init_nic_features()
1594 if (lif->nxqs > 1) in ionic_init_nic_features()
1597 err = ionic_set_nic_features(lif, features); in ionic_init_nic_features()
1604 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_init_nic_features()
1606 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_init_nic_features()
1608 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_init_nic_features()
1610 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_init_nic_features()
1612 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_init_nic_features()
1615 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_init_nic_features()
1617 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_init_nic_features()
1619 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_init_nic_features()
1621 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_init_nic_features()
1623 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_init_nic_features()
1625 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_init_nic_features()
1627 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_init_nic_features()
1629 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_init_nic_features()
1631 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_init_nic_features()
1633 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_init_nic_features()
1635 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_init_nic_features()
1651 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_features() local
1654 netdev_dbg(netdev, "%s: lif->features=0x%08llx new_features=0x%08llx\n", in ionic_set_features()
1655 __func__, (u64)lif->netdev->features, (u64)features); in ionic_set_features()
1657 err = ionic_set_nic_features(lif, features); in ionic_set_features()
1662 static int ionic_set_attr_mac(struct ionic_lif *lif, u8 *mac) in ionic_set_attr_mac() argument
1668 .index = cpu_to_le16(lif->index), in ionic_set_attr_mac()
1674 return ionic_adminq_post_wait(lif, &ctx); in ionic_set_attr_mac()
1677 static int ionic_get_attr_mac(struct ionic_lif *lif, u8 *mac_addr) in ionic_get_attr_mac() argument
1683 .index = cpu_to_le16(lif->index), in ionic_get_attr_mac()
1689 err = ionic_adminq_post_wait(lif, &ctx); in ionic_get_attr_mac()
1697 static int ionic_program_mac(struct ionic_lif *lif, u8 *mac) in ionic_program_mac() argument
1702 err = ionic_set_attr_mac(lif, mac); in ionic_program_mac()
1706 err = ionic_get_attr_mac(lif, get_mac); in ionic_program_mac()
1722 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_mac_address() local
1731 err = ionic_program_mac(lif, mac); in ionic_set_mac_address()
1755 void ionic_stop_queues_reconfig(struct ionic_lif *lif) in ionic_stop_queues_reconfig() argument
1758 netif_device_detach(lif->netdev); in ionic_stop_queues_reconfig()
1759 ionic_stop_queues(lif); in ionic_stop_queues_reconfig()
1760 ionic_txrx_deinit(lif); in ionic_stop_queues_reconfig()
1763 static int ionic_start_queues_reconfig(struct ionic_lif *lif) in ionic_start_queues_reconfig() argument
1775 err = ionic_txrx_init(lif); in ionic_start_queues_reconfig()
1776 ionic_link_status_check_request(lif, CAN_NOT_SLEEP); in ionic_start_queues_reconfig()
1777 netif_device_attach(lif->netdev); in ionic_start_queues_reconfig()
1784 struct ionic_lif *lif = netdev_priv(netdev); in ionic_change_mtu() local
1789 .index = cpu_to_le16(lif->index), in ionic_change_mtu()
1796 err = ionic_adminq_post_wait(lif, &ctx); in ionic_change_mtu()
1806 mutex_lock(&lif->queue_lock); in ionic_change_mtu()
1807 ionic_stop_queues_reconfig(lif); in ionic_change_mtu()
1809 err = ionic_start_queues_reconfig(lif); in ionic_change_mtu()
1810 mutex_unlock(&lif->queue_lock); in ionic_change_mtu()
1817 struct ionic_lif *lif = container_of(ws, struct ionic_lif, tx_timeout_work); in ionic_tx_timeout_work() local
1820 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_tx_timeout_work()
1826 if (!netif_running(lif->netdev)) in ionic_tx_timeout_work()
1829 mutex_lock(&lif->queue_lock); in ionic_tx_timeout_work()
1830 ionic_stop_queues_reconfig(lif); in ionic_tx_timeout_work()
1831 err = ionic_start_queues_reconfig(lif); in ionic_tx_timeout_work()
1832 mutex_unlock(&lif->queue_lock); in ionic_tx_timeout_work()
1835 dev_err(lif->ionic->dev, "%s: Restarting queues failed\n", __func__); in ionic_tx_timeout_work()
1840 struct ionic_lif *lif = netdev_priv(netdev); in ionic_tx_timeout() local
1842 netdev_info(lif->netdev, "Tx Timeout triggered - txq %d\n", txqueue); in ionic_tx_timeout()
1843 schedule_work(&lif->tx_timeout_work); in ionic_tx_timeout()
1849 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_add_vid() local
1852 err = ionic_lif_vlan_add(lif, vid); in ionic_vlan_rx_add_vid()
1856 ionic_lif_rx_mode(lif); in ionic_vlan_rx_add_vid()
1864 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_kill_vid() local
1867 err = ionic_lif_vlan_del(lif, vid); in ionic_vlan_rx_kill_vid()
1871 ionic_lif_rx_mode(lif); in ionic_vlan_rx_kill_vid()
1876 int ionic_lif_rss_config(struct ionic_lif *lif, const u16 types, in ionic_lif_rss_config() argument
1884 .rss.addr = cpu_to_le64(lif->rss_ind_tbl_pa), in ionic_lif_rss_config()
1889 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) { in ionic_lif_rss_config()
1890 lif->rss_types = types; in ionic_lif_rss_config()
1895 memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_config()
1898 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_config()
1900 lif->rss_ind_tbl[i] = indir[i]; in ionic_lif_rss_config()
1903 memcpy(ctx.cmd.lif_setattr.rss.key, lif->rss_hash_key, in ionic_lif_rss_config()
1906 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rss_config()
1909 static int ionic_lif_rss_init(struct ionic_lif *lif) in ionic_lif_rss_init() argument
1914 lif->rss_types = IONIC_RSS_TYPE_IPV4 | in ionic_lif_rss_init()
1922 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_init()
1924 lif->rss_ind_tbl[i] = ethtool_rxfh_indir_default(i, lif->nxqs); in ionic_lif_rss_init()
1926 return ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL); in ionic_lif_rss_init()
1929 static void ionic_lif_rss_deinit(struct ionic_lif *lif) in ionic_lif_rss_deinit() argument
1933 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_deinit()
1934 memset(lif->rss_ind_tbl, 0, tbl_sz); in ionic_lif_rss_deinit()
1935 memset(lif->rss_hash_key, 0, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_deinit()
1937 ionic_lif_rss_config(lif, 0x0, NULL, NULL); in ionic_lif_rss_deinit()
1940 static void ionic_lif_quiesce(struct ionic_lif *lif) in ionic_lif_quiesce() argument
1946 .index = cpu_to_le16(lif->index), in ionic_lif_quiesce()
1953 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_quiesce()
1955 netdev_dbg(lif->netdev, "lif quiesce failed %d\n", err); in ionic_lif_quiesce()
1958 static void ionic_txrx_disable(struct ionic_lif *lif) in ionic_txrx_disable() argument
1963 if (lif->txqcqs) { in ionic_txrx_disable()
1964 for (i = 0; i < lif->nxqs; i++) in ionic_txrx_disable()
1965 err = ionic_qcq_disable(lif, lif->txqcqs[i], err); in ionic_txrx_disable()
1968 if (lif->hwstamp_txq) in ionic_txrx_disable()
1969 err = ionic_qcq_disable(lif, lif->hwstamp_txq, err); in ionic_txrx_disable()
1971 if (lif->rxqcqs) { in ionic_txrx_disable()
1972 for (i = 0; i < lif->nxqs; i++) in ionic_txrx_disable()
1973 err = ionic_qcq_disable(lif, lif->rxqcqs[i], err); in ionic_txrx_disable()
1976 if (lif->hwstamp_rxq) in ionic_txrx_disable()
1977 err = ionic_qcq_disable(lif, lif->hwstamp_rxq, err); in ionic_txrx_disable()
1979 ionic_lif_quiesce(lif); in ionic_txrx_disable()
1982 static void ionic_txrx_deinit(struct ionic_lif *lif) in ionic_txrx_deinit() argument
1986 if (lif->txqcqs) { in ionic_txrx_deinit()
1987 for (i = 0; i < lif->nxqs && lif->txqcqs[i]; i++) { in ionic_txrx_deinit()
1988 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_deinit()
1989 ionic_tx_flush(&lif->txqcqs[i]->cq); in ionic_txrx_deinit()
1990 ionic_tx_empty(&lif->txqcqs[i]->q); in ionic_txrx_deinit()
1994 if (lif->rxqcqs) { in ionic_txrx_deinit()
1995 for (i = 0; i < lif->nxqs && lif->rxqcqs[i]; i++) { in ionic_txrx_deinit()
1996 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); in ionic_txrx_deinit()
1997 ionic_rx_empty(&lif->rxqcqs[i]->q); in ionic_txrx_deinit()
2000 lif->rx_mode = 0; in ionic_txrx_deinit()
2002 if (lif->hwstamp_txq) { in ionic_txrx_deinit()
2003 ionic_lif_qcq_deinit(lif, lif->hwstamp_txq); in ionic_txrx_deinit()
2004 ionic_tx_flush(&lif->hwstamp_txq->cq); in ionic_txrx_deinit()
2005 ionic_tx_empty(&lif->hwstamp_txq->q); in ionic_txrx_deinit()
2008 if (lif->hwstamp_rxq) { in ionic_txrx_deinit()
2009 ionic_lif_qcq_deinit(lif, lif->hwstamp_rxq); in ionic_txrx_deinit()
2010 ionic_rx_empty(&lif->hwstamp_rxq->q); in ionic_txrx_deinit()
2014 void ionic_txrx_free(struct ionic_lif *lif) in ionic_txrx_free() argument
2018 if (lif->txqcqs) { in ionic_txrx_free()
2019 for (i = 0; i < lif->ionic->ntxqs_per_lif && lif->txqcqs[i]; i++) { in ionic_txrx_free()
2020 ionic_qcq_free(lif, lif->txqcqs[i]); in ionic_txrx_free()
2021 devm_kfree(lif->ionic->dev, lif->txqcqs[i]); in ionic_txrx_free()
2022 lif->txqcqs[i] = NULL; in ionic_txrx_free()
2026 if (lif->rxqcqs) { in ionic_txrx_free()
2027 for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { in ionic_txrx_free()
2028 ionic_qcq_free(lif, lif->rxqcqs[i]); in ionic_txrx_free()
2029 devm_kfree(lif->ionic->dev, lif->rxqcqs[i]); in ionic_txrx_free()
2030 lif->rxqcqs[i] = NULL; in ionic_txrx_free()
2034 if (lif->hwstamp_txq) { in ionic_txrx_free()
2035 ionic_qcq_free(lif, lif->hwstamp_txq); in ionic_txrx_free()
2036 devm_kfree(lif->ionic->dev, lif->hwstamp_txq); in ionic_txrx_free()
2037 lif->hwstamp_txq = NULL; in ionic_txrx_free()
2040 if (lif->hwstamp_rxq) { in ionic_txrx_free()
2041 ionic_qcq_free(lif, lif->hwstamp_rxq); in ionic_txrx_free()
2042 devm_kfree(lif->ionic->dev, lif->hwstamp_rxq); in ionic_txrx_free()
2043 lif->hwstamp_rxq = NULL; in ionic_txrx_free()
2047 static int ionic_txrx_alloc(struct ionic_lif *lif) in ionic_txrx_alloc() argument
2053 num_desc = lif->ntxq_descs; in ionic_txrx_alloc()
2057 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_txrx_alloc()
2058 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == in ionic_txrx_alloc()
2066 if (test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state)) in ionic_txrx_alloc()
2069 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_txrx_alloc()
2072 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
2073 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_txrx_alloc()
2075 lif->kern_pid, &lif->txqcqs[i]); in ionic_txrx_alloc()
2080 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
2081 lif->txqcqs[i]->intr.index, in ionic_txrx_alloc()
2082 lif->tx_coalesce_hw); in ionic_txrx_alloc()
2083 if (test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state)) in ionic_txrx_alloc()
2084 lif->txqcqs[i]->intr.dim_coal_hw = lif->tx_coalesce_hw; in ionic_txrx_alloc()
2087 ionic_debugfs_add_qcq(lif, lif->txqcqs[i]); in ionic_txrx_alloc()
2092 if (test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state)) in ionic_txrx_alloc()
2095 num_desc = lif->nrxq_descs; in ionic_txrx_alloc()
2100 if (lif->rxq_features & IONIC_Q_F_2X_CQ_DESC) in ionic_txrx_alloc()
2103 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
2104 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_txrx_alloc()
2106 lif->kern_pid, &lif->rxqcqs[i]); in ionic_txrx_alloc()
2110 lif->rxqcqs[i]->q.features = lif->rxq_features; in ionic_txrx_alloc()
2112 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
2113 lif->rxqcqs[i]->intr.index, in ionic_txrx_alloc()
2114 lif->rx_coalesce_hw); in ionic_txrx_alloc()
2115 if (test_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state)) in ionic_txrx_alloc()
2116 lif->rxqcqs[i]->intr.dim_coal_hw = lif->rx_coalesce_hw; in ionic_txrx_alloc()
2118 if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_txrx_alloc()
2119 ionic_link_qcq_interrupts(lif->rxqcqs[i], in ionic_txrx_alloc()
2120 lif->txqcqs[i]); in ionic_txrx_alloc()
2122 ionic_debugfs_add_qcq(lif, lif->rxqcqs[i]); in ionic_txrx_alloc()
2128 ionic_txrx_free(lif); in ionic_txrx_alloc()
2133 static int ionic_txrx_init(struct ionic_lif *lif) in ionic_txrx_init() argument
2138 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_init()
2139 err = ionic_lif_txq_init(lif, lif->txqcqs[i]); in ionic_txrx_init()
2143 err = ionic_lif_rxq_init(lif, lif->rxqcqs[i]); in ionic_txrx_init()
2145 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_init()
2150 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_txrx_init()
2151 ionic_lif_rss_init(lif); in ionic_txrx_init()
2153 ionic_lif_rx_mode(lif); in ionic_txrx_init()
2159 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_init()
2160 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); in ionic_txrx_init()
2166 static int ionic_txrx_enable(struct ionic_lif *lif) in ionic_txrx_enable() argument
2171 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_enable()
2172 if (!(lif->rxqcqs[i] && lif->txqcqs[i])) { in ionic_txrx_enable()
2173 dev_err(lif->ionic->dev, "%s: bad qcq %d\n", __func__, i); in ionic_txrx_enable()
2178 ionic_rx_fill(&lif->rxqcqs[i]->q); in ionic_txrx_enable()
2179 err = ionic_qcq_enable(lif->rxqcqs[i]); in ionic_txrx_enable()
2183 err = ionic_qcq_enable(lif->txqcqs[i]); in ionic_txrx_enable()
2185 derr = ionic_qcq_disable(lif, lif->rxqcqs[i], err); in ionic_txrx_enable()
2190 if (lif->hwstamp_rxq) { in ionic_txrx_enable()
2191 ionic_rx_fill(&lif->hwstamp_rxq->q); in ionic_txrx_enable()
2192 err = ionic_qcq_enable(lif->hwstamp_rxq); in ionic_txrx_enable()
2197 if (lif->hwstamp_txq) { in ionic_txrx_enable()
2198 err = ionic_qcq_enable(lif->hwstamp_txq); in ionic_txrx_enable()
2206 if (lif->hwstamp_rxq) in ionic_txrx_enable()
2207 derr = ionic_qcq_disable(lif, lif->hwstamp_rxq, derr); in ionic_txrx_enable()
2209 i = lif->nxqs; in ionic_txrx_enable()
2212 derr = ionic_qcq_disable(lif, lif->txqcqs[i], derr); in ionic_txrx_enable()
2213 derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr); in ionic_txrx_enable()
2219 static int ionic_start_queues(struct ionic_lif *lif) in ionic_start_queues() argument
2223 if (test_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_start_queues()
2226 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_start_queues()
2229 if (test_and_set_bit(IONIC_LIF_F_UP, lif->state)) in ionic_start_queues()
2232 err = ionic_txrx_enable(lif); in ionic_start_queues()
2234 clear_bit(IONIC_LIF_F_UP, lif->state); in ionic_start_queues()
2237 netif_tx_wake_all_queues(lif->netdev); in ionic_start_queues()
2244 struct ionic_lif *lif = netdev_priv(netdev); in ionic_open() local
2248 if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_open()
2251 mutex_lock(&lif->queue_lock); in ionic_open()
2253 err = ionic_txrx_alloc(lif); in ionic_open()
2257 err = ionic_txrx_init(lif); in ionic_open()
2261 err = netif_set_real_num_tx_queues(netdev, lif->nxqs); in ionic_open()
2265 err = netif_set_real_num_rx_queues(netdev, lif->nxqs); in ionic_open()
2271 err = ionic_start_queues(lif); in ionic_open()
2279 ionic_lif_hwstamp_recreate_queues(lif); in ionic_open()
2281 mutex_unlock(&lif->queue_lock); in ionic_open()
2286 ionic_txrx_deinit(lif); in ionic_open()
2288 ionic_txrx_free(lif); in ionic_open()
2290 mutex_unlock(&lif->queue_lock); in ionic_open()
2294 static void ionic_stop_queues(struct ionic_lif *lif) in ionic_stop_queues() argument
2296 if (!test_and_clear_bit(IONIC_LIF_F_UP, lif->state)) in ionic_stop_queues()
2299 netif_tx_disable(lif->netdev); in ionic_stop_queues()
2300 ionic_txrx_disable(lif); in ionic_stop_queues()
2305 struct ionic_lif *lif = netdev_priv(netdev); in ionic_stop() local
2307 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_stop()
2310 mutex_lock(&lif->queue_lock); in ionic_stop()
2311 ionic_stop_queues(lif); in ionic_stop()
2312 ionic_txrx_deinit(lif); in ionic_stop()
2313 ionic_txrx_free(lif); in ionic_stop()
2314 mutex_unlock(&lif->queue_lock); in ionic_stop()
2321 struct ionic_lif *lif = netdev_priv(netdev); in ionic_eth_ioctl() local
2325 return ionic_lif_hwstamp_set(lif, ifr); in ionic_eth_ioctl()
2327 return ionic_lif_hwstamp_get(lif, ifr); in ionic_eth_ioctl()
2406 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_vf_config() local
2407 struct ionic *ionic = lif->ionic; in ionic_get_vf_config()
2440 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_vf_stats() local
2441 struct ionic *ionic = lif->ionic; in ionic_get_vf_stats()
2477 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_mac() local
2478 struct ionic *ionic = lif->ionic; in ionic_set_vf_mac()
2509 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_vlan() local
2510 struct ionic *ionic = lif->ionic; in ionic_set_vf_vlan()
2548 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_rate() local
2549 struct ionic *ionic = lif->ionic; in ionic_set_vf_rate()
2580 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_spoofchk() local
2581 struct ionic *ionic = lif->ionic; in ionic_set_vf_spoofchk()
2608 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_trust() local
2609 struct ionic *ionic = lif->ionic; in ionic_set_vf_trust()
2636 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_link_state() local
2637 struct ionic *ionic = lif->ionic; in ionic_set_vf_link_state()
2676 static void ionic_vf_attr_replay(struct ionic_lif *lif) in ionic_vf_attr_replay() argument
2679 struct ionic *ionic = lif->ionic; in ionic_vf_attr_replay()
2770 static int ionic_cmb_reconfig(struct ionic_lif *lif, in ionic_cmb_reconfig() argument
2783 ionic_init_queue_params(lif, &start_qparams); in ionic_cmb_reconfig()
2786 ionic_stop_queues_reconfig(lif); in ionic_cmb_reconfig()
2787 ionic_txrx_free(lif); in ionic_cmb_reconfig()
2790 ionic_set_queue_params(lif, qparam); in ionic_cmb_reconfig()
2792 if (netif_running(lif->netdev)) { in ionic_cmb_reconfig()
2794 err = ionic_txrx_alloc(lif); in ionic_cmb_reconfig()
2796 dev_warn(lif->ionic->dev, in ionic_cmb_reconfig()
2800 ionic_set_queue_params(lif, &start_qparams); in ionic_cmb_reconfig()
2801 err = ionic_txrx_alloc(lif); in ionic_cmb_reconfig()
2803 dev_err(lif->ionic->dev, in ionic_cmb_reconfig()
2809 err = ionic_start_queues_reconfig(lif); in ionic_cmb_reconfig()
2811 dev_err(lif->ionic->dev, in ionic_cmb_reconfig()
2819 netif_device_attach(lif->netdev); in ionic_cmb_reconfig()
2854 ionic_debugfs_add_qcq(a->q.lif, a); in ionic_swap_queues()
2857 int ionic_reconfigure_queues(struct ionic_lif *lif, in ionic_reconfigure_queues() argument
2867 if ((test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state) && qparam->cmb_tx) || in ionic_reconfigure_queues()
2868 (test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state) && qparam->cmb_rx)) in ionic_reconfigure_queues()
2869 return ionic_cmb_reconfig(lif, qparam); in ionic_reconfigure_queues()
2872 if (qparam->nxqs != lif->nxqs || qparam->ntxq_descs != lif->ntxq_descs) { in ionic_reconfigure_queues()
2873 tx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->ntxqs_per_lif, in ionic_reconfigure_queues()
2880 if (qparam->nxqs != lif->nxqs || in ionic_reconfigure_queues()
2881 qparam->nrxq_descs != lif->nrxq_descs || in ionic_reconfigure_queues()
2882 qparam->rxq_features != lif->rxq_features) { in ionic_reconfigure_queues()
2883 rx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->nrxqs_per_lif, in ionic_reconfigure_queues()
2899 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_reconfigure_queues()
2900 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == in ionic_reconfigure_queues()
2908 if (!lif->txqcqs[i]) { in ionic_reconfigure_queues()
2910 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_reconfigure_queues()
2912 lif->kern_pid, &lif->txqcqs[i]); in ionic_reconfigure_queues()
2917 flags = lif->txqcqs[i]->flags & ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
2918 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_reconfigure_queues()
2920 lif->kern_pid, &tx_qcqs[i]); in ionic_reconfigure_queues()
2937 if (!lif->rxqcqs[i]) { in ionic_reconfigure_queues()
2939 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_reconfigure_queues()
2941 lif->kern_pid, &lif->rxqcqs[i]); in ionic_reconfigure_queues()
2946 flags = lif->rxqcqs[i]->flags & ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
2947 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_reconfigure_queues()
2949 lif->kern_pid, &rx_qcqs[i]); in ionic_reconfigure_queues()
2958 ionic_stop_queues_reconfig(lif); in ionic_reconfigure_queues()
2960 if (qparam->nxqs != lif->nxqs) { in ionic_reconfigure_queues()
2961 err = netif_set_real_num_tx_queues(lif->netdev, qparam->nxqs); in ionic_reconfigure_queues()
2964 err = netif_set_real_num_rx_queues(lif->netdev, qparam->nxqs); in ionic_reconfigure_queues()
2966 netif_set_real_num_tx_queues(lif->netdev, lif->nxqs); in ionic_reconfigure_queues()
2973 lif->ntxq_descs = qparam->ntxq_descs; in ionic_reconfigure_queues()
2975 ionic_swap_queues(lif->txqcqs[i], tx_qcqs[i]); in ionic_reconfigure_queues()
2979 lif->nrxq_descs = qparam->nrxq_descs; in ionic_reconfigure_queues()
2981 ionic_swap_queues(lif->rxqcqs[i], rx_qcqs[i]); in ionic_reconfigure_queues()
2985 if (qparam->intr_split != test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state) || in ionic_reconfigure_queues()
2986 qparam->nxqs != lif->nxqs) { in ionic_reconfigure_queues()
2988 set_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); in ionic_reconfigure_queues()
2990 clear_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); in ionic_reconfigure_queues()
2991 lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; in ionic_reconfigure_queues()
2992 lif->tx_coalesce_hw = lif->rx_coalesce_hw; in ionic_reconfigure_queues()
2999 for (i = 0; i < lif->ionic->ntxqs_per_lif; i++) { in ionic_reconfigure_queues()
3000 if (lif->txqcqs[i]) in ionic_reconfigure_queues()
3001 ionic_qcq_intr_free(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3002 if (lif->rxqcqs[i]) in ionic_reconfigure_queues()
3003 ionic_qcq_intr_free(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3008 lif->rxqcqs[i]->flags |= IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3009 err = ionic_alloc_qcq_interrupt(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3010 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_reconfigure_queues()
3011 lif->rxqcqs[i]->intr.index, in ionic_reconfigure_queues()
3012 lif->rx_coalesce_hw); in ionic_reconfigure_queues()
3015 lif->txqcqs[i]->flags |= IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3016 err = ionic_alloc_qcq_interrupt(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3017 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_reconfigure_queues()
3018 lif->txqcqs[i]->intr.index, in ionic_reconfigure_queues()
3019 lif->tx_coalesce_hw); in ionic_reconfigure_queues()
3020 if (test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state)) in ionic_reconfigure_queues()
3021 lif->txqcqs[i]->intr.dim_coal_hw = lif->tx_coalesce_hw; in ionic_reconfigure_queues()
3023 lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3024 ionic_link_qcq_interrupts(lif->rxqcqs[i], lif->txqcqs[i]); in ionic_reconfigure_queues()
3032 ionic_debugfs_del_qcq(lif->txqcqs[i]); in ionic_reconfigure_queues()
3033 ionic_debugfs_add_qcq(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3039 ionic_debugfs_del_qcq(lif->rxqcqs[i]); in ionic_reconfigure_queues()
3040 ionic_debugfs_add_qcq(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3044 swap(lif->nxqs, qparam->nxqs); in ionic_reconfigure_queues()
3045 swap(lif->rxq_features, qparam->rxq_features); in ionic_reconfigure_queues()
3050 ionic_start_queues_reconfig(lif); in ionic_reconfigure_queues()
3052 err = ionic_start_queues_reconfig(lif); in ionic_reconfigure_queues()
3059 ionic_qcq_free(lif, tx_qcqs[i]); in ionic_reconfigure_queues()
3060 devm_kfree(lif->ionic->dev, tx_qcqs[i]); in ionic_reconfigure_queues()
3065 ionic_qcq_free(lif, rx_qcqs[i]); in ionic_reconfigure_queues()
3066 devm_kfree(lif->ionic->dev, rx_qcqs[i]); in ionic_reconfigure_queues()
3073 devm_kfree(lif->ionic->dev, rx_qcqs); in ionic_reconfigure_queues()
3077 devm_kfree(lif->ionic->dev, tx_qcqs); in ionic_reconfigure_queues()
3084 for (i = lif->nxqs; i < lif->ionic->ntxqs_per_lif; i++) { in ionic_reconfigure_queues()
3085 if (lif->txqcqs && lif->txqcqs[i]) { in ionic_reconfigure_queues()
3086 lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3087 ionic_qcq_free(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3090 if (lif->rxqcqs && lif->rxqcqs[i]) { in ionic_reconfigure_queues()
3091 lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3092 ionic_qcq_free(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3097 netdev_info(lif->netdev, "%s: failed %d\n", __func__, err); in ionic_reconfigure_queues()
3107 struct ionic_lif *lif; in ionic_lif_alloc() local
3115 netdev = alloc_etherdev_mqs(sizeof(*lif), in ionic_lif_alloc()
3125 lif = netdev_priv(netdev); in ionic_lif_alloc()
3126 lif->netdev = netdev; in ionic_lif_alloc()
3127 ionic->lif = lif; in ionic_lif_alloc()
3134 lif->identity = lid; in ionic_lif_alloc()
3135 lif->lif_type = IONIC_LIF_TYPE_CLASSIC; in ionic_lif_alloc()
3136 err = ionic_lif_identify(ionic, lif->lif_type, lif->identity); in ionic_lif_alloc()
3139 lif->lif_type, err); in ionic_lif_alloc()
3142 lif->netdev->min_mtu = max_t(unsigned int, ETH_MIN_MTU, in ionic_lif_alloc()
3143 le32_to_cpu(lif->identity->eth.min_frame_size)); in ionic_lif_alloc()
3144 lif->netdev->max_mtu = in ionic_lif_alloc()
3145 le32_to_cpu(lif->identity->eth.max_frame_size) - ETH_HLEN - VLAN_HLEN; in ionic_lif_alloc()
3147 lif->neqs = ionic->neqs_per_lif; in ionic_lif_alloc()
3148 lif->nxqs = ionic->ntxqs_per_lif; in ionic_lif_alloc()
3150 lif->ionic = ionic; in ionic_lif_alloc()
3151 lif->index = 0; in ionic_lif_alloc()
3154 lif->ntxq_descs = IONIC_MIN_TXRX_DESC; in ionic_lif_alloc()
3155 lif->nrxq_descs = IONIC_MIN_TXRX_DESC; in ionic_lif_alloc()
3157 lif->ntxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
3158 lif->nrxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
3162 lif->rx_coalesce_usecs = IONIC_ITR_COAL_USEC_DEFAULT; in ionic_lif_alloc()
3163 lif->rx_coalesce_hw = ionic_coal_usec_to_hw(lif->ionic, in ionic_lif_alloc()
3164 lif->rx_coalesce_usecs); in ionic_lif_alloc()
3165 lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; in ionic_lif_alloc()
3166 lif->tx_coalesce_hw = lif->rx_coalesce_hw; in ionic_lif_alloc()
3167 set_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state); in ionic_lif_alloc()
3168 set_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state); in ionic_lif_alloc()
3170 snprintf(lif->name, sizeof(lif->name), "lif%u", lif->index); in ionic_lif_alloc()
3172 mutex_init(&lif->queue_lock); in ionic_lif_alloc()
3173 mutex_init(&lif->config_lock); in ionic_lif_alloc()
3175 spin_lock_init(&lif->adminq_lock); in ionic_lif_alloc()
3177 spin_lock_init(&lif->deferred.lock); in ionic_lif_alloc()
3178 INIT_LIST_HEAD(&lif->deferred.list); in ionic_lif_alloc()
3179 INIT_WORK(&lif->deferred.work, ionic_lif_deferred_work); in ionic_lif_alloc()
3181 /* allocate lif info */ in ionic_lif_alloc()
3182 lif->info_sz = ALIGN(sizeof(*lif->info), PAGE_SIZE); in ionic_lif_alloc()
3183 lif->info = dma_alloc_coherent(dev, lif->info_sz, in ionic_lif_alloc()
3184 &lif->info_pa, GFP_KERNEL); in ionic_lif_alloc()
3185 if (!lif->info) { in ionic_lif_alloc()
3186 dev_err(dev, "Failed to allocate lif info, aborting\n"); in ionic_lif_alloc()
3191 ionic_debugfs_add_lif(lif); in ionic_lif_alloc()
3194 ionic_lif_queue_identify(lif); in ionic_lif_alloc()
3195 err = ionic_qcqs_alloc(lif); in ionic_lif_alloc()
3200 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_alloc()
3201 lif->rss_ind_tbl_sz = sizeof(*lif->rss_ind_tbl) * tbl_sz; in ionic_lif_alloc()
3202 lif->rss_ind_tbl = dma_alloc_coherent(dev, lif->rss_ind_tbl_sz, in ionic_lif_alloc()
3203 &lif->rss_ind_tbl_pa, in ionic_lif_alloc()
3206 if (!lif->rss_ind_tbl) { in ionic_lif_alloc()
3211 netdev_rss_key_fill(lif->rss_hash_key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_alloc()
3213 ionic_lif_alloc_phc(lif); in ionic_lif_alloc()
3218 ionic_qcqs_free(lif); in ionic_lif_alloc()
3220 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_alloc()
3221 lif->info = NULL; in ionic_lif_alloc()
3222 lif->info_pa = 0; in ionic_lif_alloc()
3224 mutex_destroy(&lif->config_lock); in ionic_lif_alloc()
3225 mutex_destroy(&lif->queue_lock); in ionic_lif_alloc()
3227 free_netdev(lif->netdev); in ionic_lif_alloc()
3228 lif = NULL; in ionic_lif_alloc()
3235 static void ionic_lif_reset(struct ionic_lif *lif) in ionic_lif_reset() argument
3237 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_reset()
3242 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
3243 ionic_dev_cmd_lif_reset(idev, lif->index); in ionic_lif_reset()
3244 ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_reset()
3245 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
3248 static void ionic_lif_handle_fw_down(struct ionic_lif *lif) in ionic_lif_handle_fw_down() argument
3250 struct ionic *ionic = lif->ionic; in ionic_lif_handle_fw_down()
3252 if (test_and_set_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_handle_fw_down()
3257 netif_device_detach(lif->netdev); in ionic_lif_handle_fw_down()
3259 mutex_lock(&lif->queue_lock); in ionic_lif_handle_fw_down()
3260 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_handle_fw_down()
3262 ionic_stop_queues(lif); in ionic_lif_handle_fw_down()
3265 if (netif_running(lif->netdev)) { in ionic_lif_handle_fw_down()
3266 ionic_txrx_deinit(lif); in ionic_lif_handle_fw_down()
3267 ionic_txrx_free(lif); in ionic_lif_handle_fw_down()
3269 ionic_lif_deinit(lif); in ionic_lif_handle_fw_down()
3271 ionic_qcqs_free(lif); in ionic_lif_handle_fw_down()
3273 mutex_unlock(&lif->queue_lock); in ionic_lif_handle_fw_down()
3275 clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); in ionic_lif_handle_fw_down()
3279 int ionic_restart_lif(struct ionic_lif *lif) in ionic_restart_lif() argument
3281 struct ionic *ionic = lif->ionic; in ionic_restart_lif()
3284 mutex_lock(&lif->queue_lock); in ionic_restart_lif()
3286 if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_restart_lif()
3289 err = ionic_qcqs_alloc(lif); in ionic_restart_lif()
3293 err = ionic_lif_init(lif); in ionic_restart_lif()
3297 ionic_vf_attr_replay(lif); in ionic_restart_lif()
3299 if (lif->registered) in ionic_restart_lif()
3300 ionic_lif_set_netdev_info(lif); in ionic_restart_lif()
3302 ionic_rx_filter_replay(lif); in ionic_restart_lif()
3304 if (netif_running(lif->netdev)) { in ionic_restart_lif()
3305 err = ionic_txrx_alloc(lif); in ionic_restart_lif()
3309 err = ionic_txrx_init(lif); in ionic_restart_lif()
3314 mutex_unlock(&lif->queue_lock); in ionic_restart_lif()
3316 clear_bit(IONIC_LIF_F_FW_RESET, lif->state); in ionic_restart_lif()
3317 ionic_link_status_check_request(lif, CAN_SLEEP); in ionic_restart_lif()
3318 netif_device_attach(lif->netdev); in ionic_restart_lif()
3323 ionic_txrx_free(lif); in ionic_restart_lif()
3325 ionic_lif_deinit(lif); in ionic_restart_lif()
3327 ionic_qcqs_free(lif); in ionic_restart_lif()
3329 mutex_unlock(&lif->queue_lock); in ionic_restart_lif()
3334 static void ionic_lif_handle_fw_up(struct ionic_lif *lif) in ionic_lif_handle_fw_up() argument
3336 struct ionic *ionic = lif->ionic; in ionic_lif_handle_fw_up()
3339 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_handle_fw_up()
3345 * probe time because the LIF already exists so we in ionic_lif_handle_fw_up()
3359 err = ionic_restart_lif(lif); in ionic_lif_handle_fw_up()
3366 ionic_lif_hwstamp_replay(lif); in ionic_lif_handle_fw_up()
3374 void ionic_lif_free(struct ionic_lif *lif) in ionic_lif_free() argument
3376 struct device *dev = lif->ionic->dev; in ionic_lif_free()
3378 ionic_lif_free_phc(lif); in ionic_lif_free()
3381 dma_free_coherent(dev, lif->rss_ind_tbl_sz, lif->rss_ind_tbl, in ionic_lif_free()
3382 lif->rss_ind_tbl_pa); in ionic_lif_free()
3383 lif->rss_ind_tbl = NULL; in ionic_lif_free()
3384 lif->rss_ind_tbl_pa = 0; in ionic_lif_free()
3387 ionic_qcqs_free(lif); in ionic_lif_free()
3388 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_free()
3389 ionic_lif_reset(lif); in ionic_lif_free()
3391 /* free lif info */ in ionic_lif_free()
3392 kfree(lif->identity); in ionic_lif_free()
3393 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_free()
3394 lif->info = NULL; in ionic_lif_free()
3395 lif->info_pa = 0; in ionic_lif_free()
3398 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_free()
3399 lif->kern_dbpage = NULL; in ionic_lif_free()
3401 mutex_destroy(&lif->config_lock); in ionic_lif_free()
3402 mutex_destroy(&lif->queue_lock); in ionic_lif_free()
3404 /* free netdev & lif */ in ionic_lif_free()
3405 ionic_debugfs_del_lif(lif); in ionic_lif_free()
3406 free_netdev(lif->netdev); in ionic_lif_free()
3409 void ionic_lif_deinit(struct ionic_lif *lif) in ionic_lif_deinit() argument
3411 if (!test_and_clear_bit(IONIC_LIF_F_INITED, lif->state)) in ionic_lif_deinit()
3414 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { in ionic_lif_deinit()
3415 cancel_work_sync(&lif->deferred.work); in ionic_lif_deinit()
3416 cancel_work_sync(&lif->tx_timeout_work); in ionic_lif_deinit()
3417 ionic_rx_filters_deinit(lif); in ionic_lif_deinit()
3418 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_lif_deinit()
3419 ionic_lif_rss_deinit(lif); in ionic_lif_deinit()
3422 napi_disable(&lif->adminqcq->napi); in ionic_lif_deinit()
3423 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_deinit()
3424 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_deinit()
3426 ionic_lif_reset(lif); in ionic_lif_deinit()
3429 static int ionic_lif_adminq_init(struct ionic_lif *lif) in ionic_lif_adminq_init() argument
3431 struct device *dev = lif->ionic->dev; in ionic_lif_adminq_init()
3438 idev = &lif->ionic->idev; in ionic_lif_adminq_init()
3439 qcq = lif->adminqcq; in ionic_lif_adminq_init()
3442 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
3443 ionic_dev_cmd_adminq_init(idev, qcq, lif->index, qcq->intr.index); in ionic_lif_adminq_init()
3444 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_adminq_init()
3446 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
3448 netdev_err(lif->netdev, "adminq init failed %d\n", err); in ionic_lif_adminq_init()
3462 netif_napi_add(lif->netdev, &qcq->napi, ionic_adminq_napi); in ionic_lif_adminq_init()
3481 static int ionic_lif_notifyq_init(struct ionic_lif *lif) in ionic_lif_notifyq_init() argument
3483 struct ionic_qcq *qcq = lif->notifyqcq; in ionic_lif_notifyq_init()
3484 struct device *dev = lif->ionic->dev; in ionic_lif_notifyq_init()
3492 .lif_index = cpu_to_le16(lif->index), in ionic_lif_notifyq_init()
3494 .ver = lif->qtype_info[q->type].version, in ionic_lif_notifyq_init()
3498 .intr_index = cpu_to_le16(lif->adminqcq->intr.index), in ionic_lif_notifyq_init()
3510 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_notifyq_init()
3514 lif->last_eid = 0; in ionic_lif_notifyq_init()
3523 q->info[0].cb_arg = lif; in ionic_lif_notifyq_init()
3530 static int ionic_station_set(struct ionic_lif *lif) in ionic_station_set() argument
3532 struct net_device *netdev = lif->netdev; in ionic_station_set()
3537 .index = cpu_to_le16(lif->index), in ionic_station_set()
3545 err = ionic_adminq_post_wait(lif, &ctx); in ionic_station_set()
3548 netdev_dbg(lif->netdev, "found initial MAC addr %pM\n", in ionic_station_set()
3557 err = ionic_program_mac(lif, mac_address); in ionic_station_set()
3575 ionic_lif_addr_add(lif, netdev->dev_addr); in ionic_station_set()
3582 netdev_warn(lif->netdev, "ignoring bad MAC addr from NIC %pM - err %d\n", in ionic_station_set()
3590 netdev_dbg(lif->netdev, "adding station MAC addr %pM\n", in ionic_station_set()
3592 ionic_lif_addr_add(lif, netdev->dev_addr); in ionic_station_set()
3597 int ionic_lif_init(struct ionic_lif *lif) in ionic_lif_init() argument
3599 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_init()
3600 struct device *dev = lif->ionic->dev; in ionic_lif_init()
3605 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
3606 ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa); in ionic_lif_init()
3607 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_init()
3609 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
3613 lif->hw_index = le16_to_cpu(comp.hw_index); in ionic_lif_init()
3616 lif->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif); in ionic_lif_init()
3617 if (!lif->dbid_count) { in ionic_lif_init()
3622 lif->kern_pid = 0; in ionic_lif_init()
3623 dbpage_num = ionic_db_page_num(lif, lif->kern_pid); in ionic_lif_init()
3624 lif->kern_dbpage = ionic_bus_map_dbpage(lif->ionic, dbpage_num); in ionic_lif_init()
3625 if (!lif->kern_dbpage) { in ionic_lif_init()
3630 err = ionic_lif_adminq_init(lif); in ionic_lif_init()
3634 if (lif->ionic->nnqs_per_lif) { in ionic_lif_init()
3635 err = ionic_lif_notifyq_init(lif); in ionic_lif_init()
3640 err = ionic_init_nic_features(lif); in ionic_lif_init()
3644 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { in ionic_lif_init()
3645 err = ionic_rx_filters_init(lif); in ionic_lif_init()
3650 err = ionic_station_set(lif); in ionic_lif_init()
3654 lif->rx_copybreak = IONIC_RX_COPYBREAK_DEFAULT; in ionic_lif_init()
3656 set_bit(IONIC_LIF_F_INITED, lif->state); in ionic_lif_init()
3658 INIT_WORK(&lif->tx_timeout_work, ionic_tx_timeout_work); in ionic_lif_init()
3663 napi_disable(&lif->adminqcq->napi); in ionic_lif_init()
3664 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_init()
3666 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_init()
3667 ionic_lif_reset(lif); in ionic_lif_init()
3668 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_init()
3669 lif->kern_dbpage = NULL; in ionic_lif_init()
3678 static void ionic_lif_set_netdev_info(struct ionic_lif *lif) in ionic_lif_set_netdev_info() argument
3684 .index = cpu_to_le16(lif->index), in ionic_lif_set_netdev_info()
3689 strscpy(ctx.cmd.lif_setattr.name, lif->netdev->name, in ionic_lif_set_netdev_info()
3692 ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_netdev_info()
3708 struct ionic_lif *lif = ionic_netdev_lif(ndev); in ionic_lif_notify() local
3710 if (!lif || lif->ionic != ionic) in ionic_lif_notify()
3715 ionic_lif_set_netdev_info(lif); in ionic_lif_notify()
3722 int ionic_lif_register(struct ionic_lif *lif) in ionic_lif_register() argument
3726 ionic_lif_register_phc(lif); in ionic_lif_register()
3728 INIT_WORK(&lif->ionic->nb_work, ionic_lif_notify_work); in ionic_lif_register()
3730 lif->ionic->nb.notifier_call = ionic_lif_notify; in ionic_lif_register()
3732 err = register_netdevice_notifier(&lif->ionic->nb); in ionic_lif_register()
3734 lif->ionic->nb.notifier_call = NULL; in ionic_lif_register()
3737 err = register_netdev(lif->netdev); in ionic_lif_register()
3739 dev_err(lif->ionic->dev, "Cannot register net device: %d, aborting\n", err); in ionic_lif_register()
3740 ionic_lif_unregister(lif); in ionic_lif_register()
3744 ionic_link_status_check_request(lif, CAN_SLEEP); in ionic_lif_register()
3745 lif->registered = true; in ionic_lif_register()
3746 ionic_lif_set_netdev_info(lif); in ionic_lif_register()
3751 void ionic_lif_unregister(struct ionic_lif *lif) in ionic_lif_unregister() argument
3753 if (lif->ionic->nb.notifier_call) { in ionic_lif_unregister()
3754 unregister_netdevice_notifier(&lif->ionic->nb); in ionic_lif_unregister()
3755 cancel_work_sync(&lif->ionic->nb_work); in ionic_lif_unregister()
3756 lif->ionic->nb.notifier_call = NULL; in ionic_lif_unregister()
3759 if (lif->netdev->reg_state == NETREG_REGISTERED) in ionic_lif_unregister()
3760 unregister_netdev(lif->netdev); in ionic_lif_unregister()
3762 ionic_lif_unregister_phc(lif); in ionic_lif_unregister()
3764 lif->registered = false; in ionic_lif_unregister()
3767 static void ionic_lif_queue_identify(struct ionic_lif *lif) in ionic_lif_queue_identify() argument
3770 struct ionic *ionic = lif->ionic; in ionic_lif_queue_identify()
3775 idev = &lif->ionic->idev; in ionic_lif_queue_identify()
3779 struct ionic_qtype_info *qti = &lif->qtype_info[qtype]; in ionic_lif_queue_identify()
3795 ionic_dev_cmd_queue_identify(idev, lif->lif_type, qtype, in ionic_lif_queue_identify()
3897 lc = &ident->lif.eth.config; in ionic_lif_size()
3899 neqs_per_lif = le32_to_cpu(ident->lif.rdma.eq_qtype.qid_count); in ionic_lif_size()
3929 * 1 for master lif adminq/notifyq in ionic_lif_size()
3930 * 1 for each CPU for master lif TxRx queue pairs in ionic_lif_size()