Lines Matching refs:lif
39 static void ionic_link_status_check(struct ionic_lif *lif);
40 static void ionic_lif_handle_fw_down(struct ionic_lif *lif);
41 static void ionic_lif_handle_fw_up(struct ionic_lif *lif);
42 static void ionic_lif_set_netdev_info(struct ionic_lif *lif);
44 static void ionic_txrx_deinit(struct ionic_lif *lif);
45 static int ionic_txrx_init(struct ionic_lif *lif);
46 static int ionic_start_queues(struct ionic_lif *lif);
47 static void ionic_stop_queues(struct ionic_lif *lif);
48 static void ionic_lif_queue_identify(struct ionic_lif *lif);
50 static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif);
60 struct ionic_lif *lif; in ionic_dim_work() local
70 lif = q->lif; in ionic_dim_work()
71 new_coal = ionic_coal_usec_to_hw(lif->ionic, cur_moder.usec); in ionic_dim_work()
78 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_dim_work()
87 struct ionic_lif *lif = container_of(work, struct ionic_lif, deferred.work); in ionic_lif_deferred_work() local
88 struct ionic_deferred *def = &lif->deferred; in ionic_lif_deferred_work()
105 ionic_lif_rx_mode(lif); in ionic_lif_deferred_work()
108 ionic_link_status_check(lif); in ionic_lif_deferred_work()
112 ionic_lif_handle_fw_up(lif); in ionic_lif_deferred_work()
114 ionic_lif_handle_fw_down(lif); in ionic_lif_deferred_work()
120 mod_timer(&lif->ionic->watchdog_timer, jiffies + 1); in ionic_lif_deferred_work()
131 void ionic_lif_deferred_enqueue(struct ionic_lif *lif, in ionic_lif_deferred_enqueue() argument
134 spin_lock_bh(&lif->deferred.lock); in ionic_lif_deferred_enqueue()
135 list_add_tail(&work->list, &lif->deferred.list); in ionic_lif_deferred_enqueue()
136 spin_unlock_bh(&lif->deferred.lock); in ionic_lif_deferred_enqueue()
137 queue_work(lif->ionic->wq, &lif->deferred.work); in ionic_lif_deferred_enqueue()
140 static void ionic_link_status_check(struct ionic_lif *lif) in ionic_link_status_check() argument
142 struct net_device *netdev = lif->netdev; in ionic_link_status_check()
146 if (!test_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state)) in ionic_link_status_check()
150 if (test_bit(IONIC_LIF_F_BROKEN, lif->state)) { in ionic_link_status_check()
151 clear_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check()
155 link_status = le16_to_cpu(lif->info->status.link_status); in ionic_link_status_check()
162 mutex_lock(&lif->queue_lock); in ionic_link_status_check()
163 err = ionic_start_queues(lif); in ionic_link_status_check()
167 set_bit(IONIC_LIF_F_BROKEN, lif->state); in ionic_link_status_check()
168 netif_carrier_off(lif->netdev); in ionic_link_status_check()
170 mutex_unlock(&lif->queue_lock); in ionic_link_status_check()
174 ionic_port_identify(lif->ionic); in ionic_link_status_check()
176 le32_to_cpu(lif->info->status.link_speed) / 1000); in ionic_link_status_check()
181 lif->link_down_count++; in ionic_link_status_check()
187 mutex_lock(&lif->queue_lock); in ionic_link_status_check()
188 ionic_stop_queues(lif); in ionic_link_status_check()
189 mutex_unlock(&lif->queue_lock); in ionic_link_status_check()
193 clear_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check()
196 void ionic_link_status_check_request(struct ionic_lif *lif, bool can_sleep) in ionic_link_status_check_request() argument
201 if (test_and_set_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state)) in ionic_link_status_check_request()
207 clear_bit(IONIC_LIF_F_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check_request()
212 ionic_lif_deferred_enqueue(lif, work); in ionic_link_status_check_request()
214 ionic_link_status_check(lif); in ionic_link_status_check_request()
227 static int ionic_request_irq(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_request_irq() argument
230 struct device *dev = lif->ionic->dev; in ionic_request_irq()
234 if (lif->registered) in ionic_request_irq()
235 name = netdev_name(lif->netdev); in ionic_request_irq()
246 static int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr) in ionic_intr_alloc() argument
248 struct ionic *ionic = lif->ionic; in ionic_intr_alloc()
253 netdev_warn(lif->netdev, "%s: no intr, index=%d nintrs=%d\n", in ionic_intr_alloc()
285 struct ionic_lif *lif = q->lif; in ionic_qcq_enable() local
293 .lif_index = cpu_to_le16(lif->index), in ionic_qcq_enable()
301 idev = &lif->ionic->idev; in ionic_qcq_enable()
302 dev = lif->ionic->dev; in ionic_qcq_enable()
310 ret = ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_enable()
327 static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int fw_err) in ionic_qcq_disable() argument
340 netdev_err(lif->netdev, "%s: bad qcq\n", __func__); in ionic_qcq_disable()
347 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_disable()
349 if (lif->doorbell_wa) in ionic_qcq_disable()
366 ctx.cmd.q_control.lif_index = cpu_to_le16(lif->index); in ionic_qcq_disable()
369 dev_dbg(lif->ionic->dev, "q_disable.index %d q_disable.qtype %d\n", in ionic_qcq_disable()
372 return ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_disable()
375 static void ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_qcq_deinit() argument
377 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_qcq_deinit()
395 static void ionic_qcq_intr_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_intr_free() argument
401 devm_free_irq(lif->ionic->dev, qcq->intr.vector, &qcq->napi); in ionic_qcq_intr_free()
403 ionic_intr_free(lif->ionic, qcq->intr.index); in ionic_qcq_intr_free()
407 static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_free() argument
409 struct device *dev = lif->ionic->dev; in ionic_qcq_free()
424 ionic_put_cmb(lif, qcq->cmb_pgid, qcq->cmb_order); in ionic_qcq_free()
446 ionic_qcq_intr_free(lif, qcq); in ionic_qcq_free()
451 void ionic_qcqs_free(struct ionic_lif *lif) in ionic_qcqs_free() argument
453 struct device *dev = lif->ionic->dev; in ionic_qcqs_free()
457 if (lif->notifyqcq) { in ionic_qcqs_free()
458 ionic_qcq_free(lif, lif->notifyqcq); in ionic_qcqs_free()
459 devm_kfree(dev, lif->notifyqcq); in ionic_qcqs_free()
460 lif->notifyqcq = NULL; in ionic_qcqs_free()
463 if (lif->adminqcq) { in ionic_qcqs_free()
464 spin_lock_irqsave(&lif->adminq_lock, irqflags); in ionic_qcqs_free()
465 adminqcq = READ_ONCE(lif->adminqcq); in ionic_qcqs_free()
466 lif->adminqcq = NULL; in ionic_qcqs_free()
467 spin_unlock_irqrestore(&lif->adminq_lock, irqflags); in ionic_qcqs_free()
469 ionic_qcq_free(lif, adminqcq); in ionic_qcqs_free()
474 if (lif->rxqcqs) { in ionic_qcqs_free()
475 devm_kfree(dev, lif->rxqstats); in ionic_qcqs_free()
476 lif->rxqstats = NULL; in ionic_qcqs_free()
477 devm_kfree(dev, lif->rxqcqs); in ionic_qcqs_free()
478 lif->rxqcqs = NULL; in ionic_qcqs_free()
481 if (lif->txqcqs) { in ionic_qcqs_free()
482 devm_kfree(dev, lif->txqstats); in ionic_qcqs_free()
483 lif->txqstats = NULL; in ionic_qcqs_free()
484 devm_kfree(dev, lif->txqcqs); in ionic_qcqs_free()
485 lif->txqcqs = NULL; in ionic_qcqs_free()
496 static int ionic_alloc_qcq_interrupt(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_alloc_qcq_interrupt() argument
506 err = ionic_intr_alloc(lif, &qcq->intr); in ionic_alloc_qcq_interrupt()
508 netdev_warn(lif->netdev, "no intr for %s: %d\n", in ionic_alloc_qcq_interrupt()
513 err = ionic_bus_get_irq(lif->ionic, qcq->intr.index); in ionic_alloc_qcq_interrupt()
515 netdev_warn(lif->netdev, "no vector for %s: %d\n", in ionic_alloc_qcq_interrupt()
520 ionic_intr_mask_assert(lif->ionic->idev.intr_ctrl, qcq->intr.index, in ionic_alloc_qcq_interrupt()
523 err = ionic_request_irq(lif, qcq); in ionic_alloc_qcq_interrupt()
525 netdev_warn(lif->netdev, "irq request failed %d\n", err); in ionic_alloc_qcq_interrupt()
530 affinity_mask = &lif->ionic->affinity_masks[qcq->intr.index]; in ionic_alloc_qcq_interrupt()
535 dev_to_node(lif->ionic->dev)); in ionic_alloc_qcq_interrupt()
544 netdev_dbg(lif->netdev, "%s: Interrupt index %d\n", qcq->q.name, qcq->intr.index); in ionic_alloc_qcq_interrupt()
548 ionic_intr_free(lif->ionic, qcq->intr.index); in ionic_alloc_qcq_interrupt()
553 static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, in ionic_qcq_alloc() argument
563 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_alloc()
564 struct device *dev = lif->ionic->dev; in ionic_qcq_alloc()
572 netdev_err(lif->netdev, "Cannot allocate queue structure\n"); in ionic_qcq_alloc()
582 netdev_err(lif->netdev, "Cannot allocate queue info\n"); in ionic_qcq_alloc()
593 .dev = lif->ionic->dev, in ionic_qcq_alloc()
597 .netdev = lif->netdev, in ionic_qcq_alloc()
605 netdev_err(lif->netdev, "Cannot create page_pool\n"); in ionic_qcq_alloc()
613 new->q.max_sg_elems = lif->qtype_info[type].max_sg_elems; in ionic_qcq_alloc()
615 err = ionic_q_init(lif, idev, &new->q, index, name, num_descs, in ionic_qcq_alloc()
618 netdev_err(lif->netdev, "Cannot initialize queue\n"); in ionic_qcq_alloc()
622 err = ionic_alloc_qcq_interrupt(lif, new); in ionic_qcq_alloc()
626 err = ionic_cq_init(lif, &new->cq, &new->intr, num_descs, cq_desc_size); in ionic_qcq_alloc()
628 netdev_err(lif->netdev, "Cannot initialize completion queue\n"); in ionic_qcq_alloc()
645 netdev_err(lif->netdev, "Cannot allocate qcq DMA memory\n"); in ionic_qcq_alloc()
662 netdev_err(lif->netdev, "Cannot allocate queue DMA memory\n"); in ionic_qcq_alloc()
674 err = ionic_get_cmb(lif, &new->cmb_pgid, &new->cmb_q_base_pa, in ionic_qcq_alloc()
677 netdev_err(lif->netdev, in ionic_qcq_alloc()
685 netdev_err(lif->netdev, "Cannot map queue from cmb\n"); in ionic_qcq_alloc()
686 ionic_put_cmb(lif, new->cmb_pgid, new->cmb_order); in ionic_qcq_alloc()
701 netdev_err(lif->netdev, "Cannot allocate cq DMA memory\n"); in ionic_qcq_alloc()
715 netdev_err(lif->netdev, "Cannot allocate sg DMA memory\n"); in ionic_qcq_alloc()
725 if (lif->doorbell_wa) in ionic_qcq_alloc()
737 ionic_put_cmb(lif, new->cmb_pgid, new->cmb_order); in ionic_qcq_alloc()
743 ionic_intr_free(lif->ionic, new->intr.index); in ionic_qcq_alloc()
756 static int ionic_qcqs_alloc(struct ionic_lif *lif) in ionic_qcqs_alloc() argument
758 struct device *dev = lif->ionic->dev; in ionic_qcqs_alloc()
763 err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags, in ionic_qcqs_alloc()
769 lif->kern_pid, NULL, &lif->adminqcq); in ionic_qcqs_alloc()
772 ionic_debugfs_add_qcq(lif, lif->adminqcq); in ionic_qcqs_alloc()
774 if (lif->ionic->nnqs_per_lif) { in ionic_qcqs_alloc()
776 err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notifyq", in ionic_qcqs_alloc()
782 lif->kern_pid, NULL, &lif->notifyqcq); in ionic_qcqs_alloc()
785 ionic_debugfs_add_qcq(lif, lif->notifyqcq); in ionic_qcqs_alloc()
788 ionic_link_qcq_interrupts(lif->adminqcq, lif->notifyqcq); in ionic_qcqs_alloc()
792 lif->txqcqs = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif, in ionic_qcqs_alloc()
793 sizeof(*lif->txqcqs), GFP_KERNEL); in ionic_qcqs_alloc()
794 if (!lif->txqcqs) in ionic_qcqs_alloc()
796 lif->rxqcqs = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif, in ionic_qcqs_alloc()
797 sizeof(*lif->rxqcqs), GFP_KERNEL); in ionic_qcqs_alloc()
798 if (!lif->rxqcqs) in ionic_qcqs_alloc()
801 lif->txqstats = devm_kcalloc(dev, lif->ionic->ntxqs_per_lif + 1, in ionic_qcqs_alloc()
802 sizeof(*lif->txqstats), GFP_KERNEL); in ionic_qcqs_alloc()
803 if (!lif->txqstats) in ionic_qcqs_alloc()
805 lif->rxqstats = devm_kcalloc(dev, lif->ionic->nrxqs_per_lif + 1, in ionic_qcqs_alloc()
806 sizeof(*lif->rxqstats), GFP_KERNEL); in ionic_qcqs_alloc()
807 if (!lif->rxqstats) in ionic_qcqs_alloc()
813 ionic_qcqs_free(lif); in ionic_qcqs_alloc()
830 static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_txq_init() argument
832 struct device *dev = lif->ionic->dev; in ionic_lif_txq_init()
839 .lif_index = cpu_to_le16(lif->index), in ionic_lif_txq_init()
841 .ver = lif->qtype_info[q->type].version, in ionic_lif_txq_init()
873 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_txq_init()
887 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_lif_txq_init()
888 netif_napi_add(lif->netdev, &qcq->napi, ionic_tx_napi); in ionic_lif_txq_init()
895 static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_rxq_init() argument
897 struct device *dev = lif->ionic->dev; in ionic_lif_rxq_init()
904 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rxq_init()
906 .ver = lif->qtype_info[q->type].version, in ionic_lif_rxq_init()
920 q->partner = &lif->txqcqs[q->index]->q; in ionic_lif_rxq_init()
923 if (!lif->xdp_prog || in ionic_lif_rxq_init()
924 (lif->xdp_prog->aux && lif->xdp_prog->aux->xdp_has_frags)) in ionic_lif_rxq_init()
942 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rxq_init()
956 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_lif_rxq_init()
957 netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi); in ionic_lif_rxq_init()
959 netif_napi_add(lif->netdev, &qcq->napi, ionic_txrx_napi); in ionic_lif_rxq_init()
971 int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) in ionic_lif_create_hwstamp_txq() argument
979 if (lif->hwstamp_txq) in ionic_lif_create_hwstamp_txq()
988 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_lif_create_hwstamp_txq()
989 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == sizeof(struct ionic_txq_sg_desc_v1)) in ionic_lif_create_hwstamp_txq()
994 txq_i = lif->ionic->ntxqs_per_lif; in ionic_lif_create_hwstamp_txq()
997 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, txq_i, "hwstamp_tx", flags, in ionic_lif_create_hwstamp_txq()
1000 lif->kern_pid, NULL, &txq); in ionic_lif_create_hwstamp_txq()
1006 ionic_link_qcq_interrupts(lif->adminqcq, txq); in ionic_lif_create_hwstamp_txq()
1007 ionic_debugfs_add_qcq(lif, txq); in ionic_lif_create_hwstamp_txq()
1009 lif->hwstamp_txq = txq; in ionic_lif_create_hwstamp_txq()
1011 if (netif_running(lif->netdev)) { in ionic_lif_create_hwstamp_txq()
1012 err = ionic_lif_txq_init(lif, txq); in ionic_lif_create_hwstamp_txq()
1016 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_create_hwstamp_txq()
1026 ionic_lif_qcq_deinit(lif, txq); in ionic_lif_create_hwstamp_txq()
1028 lif->hwstamp_txq = NULL; in ionic_lif_create_hwstamp_txq()
1030 ionic_qcq_free(lif, txq); in ionic_lif_create_hwstamp_txq()
1031 devm_kfree(lif->ionic->dev, txq); in ionic_lif_create_hwstamp_txq()
1036 int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) in ionic_lif_create_hwstamp_rxq() argument
1044 if (lif->hwstamp_rxq) in ionic_lif_create_hwstamp_rxq()
1054 rxq_i = lif->ionic->nrxqs_per_lif; in ionic_lif_create_hwstamp_rxq()
1057 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, rxq_i, "hwstamp_rx", flags, in ionic_lif_create_hwstamp_rxq()
1060 lif->kern_pid, NULL, &rxq); in ionic_lif_create_hwstamp_rxq()
1066 ionic_link_qcq_interrupts(lif->adminqcq, rxq); in ionic_lif_create_hwstamp_rxq()
1067 ionic_debugfs_add_qcq(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1069 lif->hwstamp_rxq = rxq; in ionic_lif_create_hwstamp_rxq()
1071 if (netif_running(lif->netdev)) { in ionic_lif_create_hwstamp_rxq()
1072 err = ionic_lif_rxq_init(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1076 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_create_hwstamp_rxq()
1087 ionic_lif_qcq_deinit(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1089 lif->hwstamp_rxq = NULL; in ionic_lif_create_hwstamp_rxq()
1091 ionic_qcq_free(lif, rxq); in ionic_lif_create_hwstamp_rxq()
1092 devm_kfree(lif->ionic->dev, rxq); in ionic_lif_create_hwstamp_rxq()
1097 int ionic_lif_config_hwstamp_rxq_all(struct ionic_lif *lif, bool rx_all) in ionic_lif_config_hwstamp_rxq_all() argument
1101 ionic_init_queue_params(lif, &qparam); in ionic_lif_config_hwstamp_rxq_all()
1109 if (!netif_running(lif->netdev)) { in ionic_lif_config_hwstamp_rxq_all()
1110 lif->rxq_features = qparam.rxq_features; in ionic_lif_config_hwstamp_rxq_all()
1114 return ionic_reconfigure_queues(lif, &qparam); in ionic_lif_config_hwstamp_rxq_all()
1117 int ionic_lif_set_hwstamp_txmode(struct ionic_lif *lif, u16 txstamp_mode) in ionic_lif_set_hwstamp_txmode() argument
1123 .index = cpu_to_le16(lif->index), in ionic_lif_set_hwstamp_txmode()
1129 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_hwstamp_txmode()
1132 static void ionic_lif_del_hwstamp_rxfilt(struct ionic_lif *lif) in ionic_lif_del_hwstamp_rxfilt() argument
1138 .lif_index = cpu_to_le16(lif->index), in ionic_lif_del_hwstamp_rxfilt()
1145 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1147 f = ionic_rx_filter_rxsteer(lif); in ionic_lif_del_hwstamp_rxfilt()
1149 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1154 ionic_rx_filter_free(lif, f); in ionic_lif_del_hwstamp_rxfilt()
1156 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_del_hwstamp_rxfilt()
1158 netdev_dbg(lif->netdev, "rx_filter del RXSTEER (id %d)\n", filter_id); in ionic_lif_del_hwstamp_rxfilt()
1162 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_del_hwstamp_rxfilt()
1164 netdev_dbg(lif->netdev, "failed to delete rx_filter RXSTEER (id %d)\n", filter_id); in ionic_lif_del_hwstamp_rxfilt()
1167 static int ionic_lif_add_hwstamp_rxfilt(struct ionic_lif *lif, u64 pkt_class) in ionic_lif_add_hwstamp_rxfilt() argument
1173 .lif_index = cpu_to_le16(lif->index), in ionic_lif_add_hwstamp_rxfilt()
1182 if (!lif->hwstamp_rxq) in ionic_lif_add_hwstamp_rxfilt()
1185 qtype = lif->hwstamp_rxq->q.type; in ionic_lif_add_hwstamp_rxfilt()
1188 qid = lif->hwstamp_rxq->q.index; in ionic_lif_add_hwstamp_rxfilt()
1191 netdev_dbg(lif->netdev, "rx_filter add RXSTEER\n"); in ionic_lif_add_hwstamp_rxfilt()
1192 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_add_hwstamp_rxfilt()
1196 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_add_hwstamp_rxfilt()
1197 err = ionic_rx_filter_save(lif, 0, qid, 0, &ctx, IONIC_FILTER_STATE_SYNCED); in ionic_lif_add_hwstamp_rxfilt()
1198 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_add_hwstamp_rxfilt()
1203 int ionic_lif_set_hwstamp_rxfilt(struct ionic_lif *lif, u64 pkt_class) in ionic_lif_set_hwstamp_rxfilt() argument
1205 ionic_lif_del_hwstamp_rxfilt(lif); in ionic_lif_set_hwstamp_rxfilt()
1210 return ionic_lif_add_hwstamp_rxfilt(lif, pkt_class); in ionic_lif_set_hwstamp_rxfilt()
1216 struct ionic_lif *lif = napi_to_cq(napi)->lif; in ionic_adminq_napi() local
1217 struct ionic_dev *idev = &lif->ionic->idev; in ionic_adminq_napi()
1227 if (lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED) in ionic_adminq_napi()
1228 n_work = ionic_cq_service(&lif->notifyqcq->cq, budget, in ionic_adminq_napi()
1231 spin_lock_irqsave(&lif->adminq_lock, irqflags); in ionic_adminq_napi()
1232 if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED) in ionic_adminq_napi()
1233 a_work = ionic_cq_service(&lif->adminqcq->cq, budget, in ionic_adminq_napi()
1236 spin_unlock_irqrestore(&lif->adminq_lock, irqflags); in ionic_adminq_napi()
1238 if (lif->hwstamp_rxq) in ionic_adminq_napi()
1239 rx_work = ionic_cq_service(&lif->hwstamp_rxq->cq, budget, in ionic_adminq_napi()
1242 if (lif->hwstamp_txq) in ionic_adminq_napi()
1243 tx_work = ionic_tx_cq_service(&lif->hwstamp_txq->cq, budget, !!budget); in ionic_adminq_napi()
1257 if (lif->doorbell_wa) { in ionic_adminq_napi()
1259 ionic_adminq_poke_doorbell(&lif->adminqcq->q); in ionic_adminq_napi()
1260 if (lif->hwstamp_rxq && !rx_work) in ionic_adminq_napi()
1261 ionic_rxq_poke_doorbell(&lif->hwstamp_rxq->q); in ionic_adminq_napi()
1262 if (lif->hwstamp_txq && !tx_work) in ionic_adminq_napi()
1263 ionic_txq_poke_doorbell(&lif->hwstamp_txq->q); in ionic_adminq_napi()
1272 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_stats64() local
1276 ls = &lif->info->stats; in ionic_get_stats64()
1336 void ionic_lif_rx_mode(struct ionic_lif *lif) in ionic_lif_rx_mode() argument
1338 struct net_device *netdev = lif->netdev; in ionic_lif_rx_mode()
1346 mutex_lock(&lif->config_lock); in ionic_lif_rx_mode()
1358 ionic_rx_filter_sync(lif); in ionic_lif_rx_mode()
1366 nfilters = le32_to_cpu(lif->identity->eth.max_ucast_filters); in ionic_lif_rx_mode()
1368 if (((lif->nucast + lif->nmcast) >= nfilters) || in ionic_lif_rx_mode()
1369 (lif->max_vlans && lif->nvlans >= lif->max_vlans)) { in ionic_lif_rx_mode()
1380 lif->rx_mode, rx_mode); in ionic_lif_rx_mode()
1393 netdev_dbg(netdev, "lif%d %s\n", lif->index, buf); in ionic_lif_rx_mode()
1395 if (lif->rx_mode != rx_mode) { in ionic_lif_rx_mode()
1400 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rx_mode()
1406 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rx_mode()
1411 lif->rx_mode = rx_mode; in ionic_lif_rx_mode()
1414 mutex_unlock(&lif->config_lock); in ionic_lif_rx_mode()
1419 struct ionic_lif *lif = netdev_priv(netdev); in ionic_ndo_set_rx_mode() local
1431 netdev_err(lif->netdev, "rxmode change dropped\n"); in ionic_ndo_set_rx_mode()
1435 netdev_dbg(lif->netdev, "deferred: rx_mode\n"); in ionic_ndo_set_rx_mode()
1436 ionic_lif_deferred_enqueue(lif, work); in ionic_ndo_set_rx_mode()
1479 static int ionic_set_nic_features(struct ionic_lif *lif, in ionic_set_nic_features() argument
1482 struct device *dev = lif->ionic->dev; in ionic_set_nic_features()
1487 .index = cpu_to_le16(lif->index), in ionic_set_nic_features()
1499 if (lif->phc) in ionic_set_nic_features()
1502 err = ionic_adminq_post_wait(lif, &ctx); in ionic_set_nic_features()
1506 old_hw_features = lif->hw_features; in ionic_set_nic_features()
1507 lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features & in ionic_set_nic_features()
1510 if ((old_hw_features ^ lif->hw_features) & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1511 ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL); in ionic_set_nic_features()
1515 dev_info_once(lif->ionic->dev, "NIC is not supporting vlan offload, likely in SmartNIC mode\n"); in ionic_set_nic_features()
1517 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_set_nic_features()
1519 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_set_nic_features()
1521 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_set_nic_features()
1523 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1525 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_set_nic_features()
1527 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_set_nic_features()
1529 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_set_nic_features()
1531 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_set_nic_features()
1533 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_set_nic_features()
1535 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_set_nic_features()
1537 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_set_nic_features()
1539 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_set_nic_features()
1541 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_set_nic_features()
1543 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_set_nic_features()
1545 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_set_nic_features()
1547 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_set_nic_features()
1549 if (lif->hw_features & IONIC_ETH_HW_TIMESTAMP) in ionic_set_nic_features()
1555 static int ionic_init_nic_features(struct ionic_lif *lif) in ionic_init_nic_features() argument
1557 struct net_device *netdev = lif->netdev; in ionic_init_nic_features()
1578 if (lif->nxqs > 1) in ionic_init_nic_features()
1581 err = ionic_set_nic_features(lif, features); in ionic_init_nic_features()
1588 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_init_nic_features()
1590 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_init_nic_features()
1592 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_init_nic_features()
1594 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_init_nic_features()
1596 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_init_nic_features()
1599 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_init_nic_features()
1601 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_init_nic_features()
1603 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_init_nic_features()
1605 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_init_nic_features()
1607 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_init_nic_features()
1609 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_init_nic_features()
1611 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_init_nic_features()
1613 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_init_nic_features()
1615 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_init_nic_features()
1617 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_init_nic_features()
1619 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_init_nic_features()
1641 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_features() local
1645 __func__, (u64)lif->netdev->features, (u64)features); in ionic_set_features()
1647 err = ionic_set_nic_features(lif, features); in ionic_set_features()
1652 static int ionic_set_attr_mac(struct ionic_lif *lif, u8 *mac) in ionic_set_attr_mac() argument
1658 .index = cpu_to_le16(lif->index), in ionic_set_attr_mac()
1664 return ionic_adminq_post_wait(lif, &ctx); in ionic_set_attr_mac()
1667 static int ionic_get_attr_mac(struct ionic_lif *lif, u8 *mac_addr) in ionic_get_attr_mac() argument
1673 .index = cpu_to_le16(lif->index), in ionic_get_attr_mac()
1679 err = ionic_adminq_post_wait(lif, &ctx); in ionic_get_attr_mac()
1687 static int ionic_program_mac(struct ionic_lif *lif, u8 *mac) in ionic_program_mac() argument
1692 err = ionic_set_attr_mac(lif, mac); in ionic_program_mac()
1696 err = ionic_get_attr_mac(lif, get_mac); in ionic_program_mac()
1712 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_mac_address() local
1721 err = ionic_program_mac(lif, mac); in ionic_set_mac_address()
1745 void ionic_stop_queues_reconfig(struct ionic_lif *lif) in ionic_stop_queues_reconfig() argument
1748 netif_device_detach(lif->netdev); in ionic_stop_queues_reconfig()
1749 ionic_stop_queues(lif); in ionic_stop_queues_reconfig()
1750 ionic_txrx_deinit(lif); in ionic_stop_queues_reconfig()
1753 static int ionic_start_queues_reconfig(struct ionic_lif *lif) in ionic_start_queues_reconfig() argument
1765 err = ionic_txrx_init(lif); in ionic_start_queues_reconfig()
1766 ionic_link_status_check_request(lif, CAN_NOT_SLEEP); in ionic_start_queues_reconfig()
1767 netif_device_attach(lif->netdev); in ionic_start_queues_reconfig()
1772 static bool ionic_xdp_is_valid_mtu(struct ionic_lif *lif, u32 mtu, in ionic_xdp_is_valid_mtu() argument
1789 struct ionic_lif *lif = netdev_priv(netdev); in ionic_change_mtu() local
1794 .index = cpu_to_le16(lif->index), in ionic_change_mtu()
1802 xdp_prog = READ_ONCE(lif->xdp_prog); in ionic_change_mtu()
1803 if (!ionic_xdp_is_valid_mtu(lif, new_mtu, xdp_prog)) in ionic_change_mtu()
1806 err = ionic_adminq_post_wait(lif, &ctx); in ionic_change_mtu()
1816 mutex_lock(&lif->queue_lock); in ionic_change_mtu()
1817 ionic_stop_queues_reconfig(lif); in ionic_change_mtu()
1819 err = ionic_start_queues_reconfig(lif); in ionic_change_mtu()
1820 mutex_unlock(&lif->queue_lock); in ionic_change_mtu()
1827 struct ionic_lif *lif = container_of(ws, struct ionic_lif, tx_timeout_work); in ionic_tx_timeout_work() local
1830 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_tx_timeout_work()
1836 if (!netif_running(lif->netdev)) in ionic_tx_timeout_work()
1839 mutex_lock(&lif->queue_lock); in ionic_tx_timeout_work()
1840 ionic_stop_queues_reconfig(lif); in ionic_tx_timeout_work()
1841 err = ionic_start_queues_reconfig(lif); in ionic_tx_timeout_work()
1842 mutex_unlock(&lif->queue_lock); in ionic_tx_timeout_work()
1845 dev_err(lif->ionic->dev, "%s: Restarting queues failed\n", __func__); in ionic_tx_timeout_work()
1850 struct ionic_lif *lif = netdev_priv(netdev); in ionic_tx_timeout() local
1852 netdev_info(lif->netdev, "Tx Timeout triggered - txq %d\n", txqueue); in ionic_tx_timeout()
1853 schedule_work(&lif->tx_timeout_work); in ionic_tx_timeout()
1859 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_add_vid() local
1862 err = ionic_lif_vlan_add(lif, vid); in ionic_vlan_rx_add_vid()
1866 ionic_lif_rx_mode(lif); in ionic_vlan_rx_add_vid()
1874 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_kill_vid() local
1877 err = ionic_lif_vlan_del(lif, vid); in ionic_vlan_rx_kill_vid()
1881 ionic_lif_rx_mode(lif); in ionic_vlan_rx_kill_vid()
1886 int ionic_lif_rss_config(struct ionic_lif *lif, const u16 types, in ionic_lif_rss_config() argument
1894 .rss.addr = cpu_to_le64(lif->rss_ind_tbl_pa), in ionic_lif_rss_config()
1899 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) { in ionic_lif_rss_config()
1900 lif->rss_types = types; in ionic_lif_rss_config()
1905 memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_config()
1908 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_config()
1910 lif->rss_ind_tbl[i] = indir[i]; in ionic_lif_rss_config()
1913 memcpy(ctx.cmd.lif_setattr.rss.key, lif->rss_hash_key, in ionic_lif_rss_config()
1916 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rss_config()
1919 static int ionic_lif_rss_init(struct ionic_lif *lif) in ionic_lif_rss_init() argument
1924 lif->rss_types = IONIC_RSS_TYPE_IPV4 | in ionic_lif_rss_init()
1932 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_init()
1934 lif->rss_ind_tbl[i] = ethtool_rxfh_indir_default(i, lif->nxqs); in ionic_lif_rss_init()
1936 return ionic_lif_rss_config(lif, lif->rss_types, NULL, NULL); in ionic_lif_rss_init()
1939 static void ionic_lif_rss_deinit(struct ionic_lif *lif) in ionic_lif_rss_deinit() argument
1943 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_deinit()
1944 memset(lif->rss_ind_tbl, 0, tbl_sz); in ionic_lif_rss_deinit()
1945 memset(lif->rss_hash_key, 0, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_deinit()
1947 ionic_lif_rss_config(lif, 0x0, NULL, NULL); in ionic_lif_rss_deinit()
1950 static void ionic_lif_quiesce(struct ionic_lif *lif) in ionic_lif_quiesce() argument
1956 .index = cpu_to_le16(lif->index), in ionic_lif_quiesce()
1963 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_quiesce()
1965 netdev_dbg(lif->netdev, "lif quiesce failed %d\n", err); in ionic_lif_quiesce()
1968 static void ionic_txrx_disable(struct ionic_lif *lif) in ionic_txrx_disable() argument
1973 if (lif->txqcqs) { in ionic_txrx_disable()
1974 for (i = 0; i < lif->nxqs; i++) in ionic_txrx_disable()
1975 err = ionic_qcq_disable(lif, lif->txqcqs[i], err); in ionic_txrx_disable()
1978 if (lif->hwstamp_txq) in ionic_txrx_disable()
1979 err = ionic_qcq_disable(lif, lif->hwstamp_txq, err); in ionic_txrx_disable()
1981 if (lif->rxqcqs) { in ionic_txrx_disable()
1982 for (i = 0; i < lif->nxqs; i++) in ionic_txrx_disable()
1983 err = ionic_qcq_disable(lif, lif->rxqcqs[i], err); in ionic_txrx_disable()
1986 if (lif->hwstamp_rxq) in ionic_txrx_disable()
1987 err = ionic_qcq_disable(lif, lif->hwstamp_rxq, err); in ionic_txrx_disable()
1989 ionic_lif_quiesce(lif); in ionic_txrx_disable()
1992 static void ionic_txrx_deinit(struct ionic_lif *lif) in ionic_txrx_deinit() argument
1996 if (lif->txqcqs) { in ionic_txrx_deinit()
1997 for (i = 0; i < lif->nxqs && lif->txqcqs[i]; i++) { in ionic_txrx_deinit()
1998 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_deinit()
1999 ionic_tx_flush(&lif->txqcqs[i]->cq); in ionic_txrx_deinit()
2000 ionic_tx_empty(&lif->txqcqs[i]->q); in ionic_txrx_deinit()
2004 if (lif->rxqcqs) { in ionic_txrx_deinit()
2005 for (i = 0; i < lif->nxqs && lif->rxqcqs[i]; i++) { in ionic_txrx_deinit()
2006 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); in ionic_txrx_deinit()
2007 ionic_rx_empty(&lif->rxqcqs[i]->q); in ionic_txrx_deinit()
2010 lif->rx_mode = 0; in ionic_txrx_deinit()
2012 if (lif->hwstamp_txq) { in ionic_txrx_deinit()
2013 ionic_lif_qcq_deinit(lif, lif->hwstamp_txq); in ionic_txrx_deinit()
2014 ionic_tx_flush(&lif->hwstamp_txq->cq); in ionic_txrx_deinit()
2015 ionic_tx_empty(&lif->hwstamp_txq->q); in ionic_txrx_deinit()
2018 if (lif->hwstamp_rxq) { in ionic_txrx_deinit()
2019 ionic_lif_qcq_deinit(lif, lif->hwstamp_rxq); in ionic_txrx_deinit()
2020 ionic_rx_empty(&lif->hwstamp_rxq->q); in ionic_txrx_deinit()
2024 void ionic_txrx_free(struct ionic_lif *lif) in ionic_txrx_free() argument
2028 if (lif->txqcqs) { in ionic_txrx_free()
2029 for (i = 0; i < lif->ionic->ntxqs_per_lif && lif->txqcqs[i]; i++) { in ionic_txrx_free()
2030 ionic_qcq_free(lif, lif->txqcqs[i]); in ionic_txrx_free()
2031 devm_kfree(lif->ionic->dev, lif->txqcqs[i]); in ionic_txrx_free()
2032 lif->txqcqs[i] = NULL; in ionic_txrx_free()
2036 if (lif->rxqcqs) { in ionic_txrx_free()
2037 for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { in ionic_txrx_free()
2038 ionic_qcq_free(lif, lif->rxqcqs[i]); in ionic_txrx_free()
2039 devm_kfree(lif->ionic->dev, lif->rxqcqs[i]); in ionic_txrx_free()
2040 lif->rxqcqs[i] = NULL; in ionic_txrx_free()
2044 if (lif->hwstamp_txq) { in ionic_txrx_free()
2045 ionic_qcq_free(lif, lif->hwstamp_txq); in ionic_txrx_free()
2046 devm_kfree(lif->ionic->dev, lif->hwstamp_txq); in ionic_txrx_free()
2047 lif->hwstamp_txq = NULL; in ionic_txrx_free()
2050 if (lif->hwstamp_rxq) { in ionic_txrx_free()
2051 ionic_qcq_free(lif, lif->hwstamp_rxq); in ionic_txrx_free()
2052 devm_kfree(lif->ionic->dev, lif->hwstamp_rxq); in ionic_txrx_free()
2053 lif->hwstamp_rxq = NULL; in ionic_txrx_free()
2057 static int ionic_txrx_alloc(struct ionic_lif *lif) in ionic_txrx_alloc() argument
2063 num_desc = lif->ntxq_descs; in ionic_txrx_alloc()
2067 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_txrx_alloc()
2068 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == in ionic_txrx_alloc()
2076 if (test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state)) in ionic_txrx_alloc()
2079 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_txrx_alloc()
2082 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
2083 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_txrx_alloc()
2086 lif->kern_pid, NULL, &lif->txqcqs[i]); in ionic_txrx_alloc()
2091 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
2092 lif->txqcqs[i]->intr.index, in ionic_txrx_alloc()
2093 lif->tx_coalesce_hw); in ionic_txrx_alloc()
2094 if (test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state)) in ionic_txrx_alloc()
2095 lif->txqcqs[i]->intr.dim_coal_hw = lif->tx_coalesce_hw; in ionic_txrx_alloc()
2098 ionic_debugfs_add_qcq(lif, lif->txqcqs[i]); in ionic_txrx_alloc()
2103 if (test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state)) in ionic_txrx_alloc()
2106 num_desc = lif->nrxq_descs; in ionic_txrx_alloc()
2111 if (lif->rxq_features & IONIC_Q_F_2X_CQ_DESC) in ionic_txrx_alloc()
2114 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
2115 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_txrx_alloc()
2118 lif->kern_pid, lif->xdp_prog, in ionic_txrx_alloc()
2119 &lif->rxqcqs[i]); in ionic_txrx_alloc()
2123 lif->rxqcqs[i]->q.features = lif->rxq_features; in ionic_txrx_alloc()
2125 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
2126 lif->rxqcqs[i]->intr.index, in ionic_txrx_alloc()
2127 lif->rx_coalesce_hw); in ionic_txrx_alloc()
2128 if (test_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state)) in ionic_txrx_alloc()
2129 lif->rxqcqs[i]->intr.dim_coal_hw = lif->rx_coalesce_hw; in ionic_txrx_alloc()
2131 if (!test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) in ionic_txrx_alloc()
2132 ionic_link_qcq_interrupts(lif->rxqcqs[i], in ionic_txrx_alloc()
2133 lif->txqcqs[i]); in ionic_txrx_alloc()
2135 ionic_debugfs_add_qcq(lif, lif->rxqcqs[i]); in ionic_txrx_alloc()
2141 ionic_txrx_free(lif); in ionic_txrx_alloc()
2146 static int ionic_txrx_init(struct ionic_lif *lif) in ionic_txrx_init() argument
2151 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_init()
2152 err = ionic_lif_txq_init(lif, lif->txqcqs[i]); in ionic_txrx_init()
2156 err = ionic_lif_rxq_init(lif, lif->rxqcqs[i]); in ionic_txrx_init()
2158 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_init()
2163 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_txrx_init()
2164 ionic_lif_rss_init(lif); in ionic_txrx_init()
2166 ionic_lif_rx_mode(lif); in ionic_txrx_init()
2172 ionic_lif_qcq_deinit(lif, lif->txqcqs[i]); in ionic_txrx_init()
2173 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]); in ionic_txrx_init()
2179 static int ionic_txrx_enable(struct ionic_lif *lif) in ionic_txrx_enable() argument
2184 ionic_xdp_rxqs_prog_update(lif); in ionic_txrx_enable()
2186 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_enable()
2187 if (!(lif->rxqcqs[i] && lif->txqcqs[i])) { in ionic_txrx_enable()
2188 dev_err(lif->ionic->dev, "%s: bad qcq %d\n", __func__, i); in ionic_txrx_enable()
2193 ionic_rx_fill(&lif->rxqcqs[i]->q, in ionic_txrx_enable()
2194 READ_ONCE(lif->rxqcqs[i]->q.xdp_prog)); in ionic_txrx_enable()
2195 err = ionic_qcq_enable(lif->rxqcqs[i]); in ionic_txrx_enable()
2199 err = ionic_qcq_enable(lif->txqcqs[i]); in ionic_txrx_enable()
2201 derr = ionic_qcq_disable(lif, lif->rxqcqs[i], err); in ionic_txrx_enable()
2206 if (lif->hwstamp_rxq) { in ionic_txrx_enable()
2207 ionic_rx_fill(&lif->hwstamp_rxq->q, NULL); in ionic_txrx_enable()
2208 err = ionic_qcq_enable(lif->hwstamp_rxq); in ionic_txrx_enable()
2213 if (lif->hwstamp_txq) { in ionic_txrx_enable()
2214 err = ionic_qcq_enable(lif->hwstamp_txq); in ionic_txrx_enable()
2222 if (lif->hwstamp_rxq) in ionic_txrx_enable()
2223 derr = ionic_qcq_disable(lif, lif->hwstamp_rxq, derr); in ionic_txrx_enable()
2225 i = lif->nxqs; in ionic_txrx_enable()
2228 derr = ionic_qcq_disable(lif, lif->txqcqs[i], derr); in ionic_txrx_enable()
2229 derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr); in ionic_txrx_enable()
2232 ionic_xdp_rxqs_prog_update(lif); in ionic_txrx_enable()
2237 static int ionic_start_queues(struct ionic_lif *lif) in ionic_start_queues() argument
2241 if (test_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_start_queues()
2244 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_start_queues()
2247 if (test_and_set_bit(IONIC_LIF_F_UP, lif->state)) in ionic_start_queues()
2250 err = ionic_txrx_enable(lif); in ionic_start_queues()
2252 clear_bit(IONIC_LIF_F_UP, lif->state); in ionic_start_queues()
2255 netif_tx_wake_all_queues(lif->netdev); in ionic_start_queues()
2262 struct ionic_lif *lif = netdev_priv(netdev); in ionic_open() local
2266 if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_open()
2269 mutex_lock(&lif->queue_lock); in ionic_open()
2271 err = ionic_txrx_alloc(lif); in ionic_open()
2275 err = ionic_txrx_init(lif); in ionic_open()
2279 err = netif_set_real_num_tx_queues(netdev, lif->nxqs); in ionic_open()
2283 err = netif_set_real_num_rx_queues(netdev, lif->nxqs); in ionic_open()
2289 err = ionic_start_queues(lif); in ionic_open()
2297 ionic_lif_hwstamp_recreate_queues(lif); in ionic_open()
2299 mutex_unlock(&lif->queue_lock); in ionic_open()
2304 ionic_txrx_deinit(lif); in ionic_open()
2306 ionic_txrx_free(lif); in ionic_open()
2308 mutex_unlock(&lif->queue_lock); in ionic_open()
2312 static void ionic_stop_queues(struct ionic_lif *lif) in ionic_stop_queues() argument
2314 if (!test_and_clear_bit(IONIC_LIF_F_UP, lif->state)) in ionic_stop_queues()
2317 netif_tx_disable(lif->netdev); in ionic_stop_queues()
2318 ionic_txrx_disable(lif); in ionic_stop_queues()
2323 struct ionic_lif *lif = netdev_priv(netdev); in ionic_stop() local
2325 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_stop()
2328 mutex_lock(&lif->queue_lock); in ionic_stop()
2329 ionic_stop_queues(lif); in ionic_stop()
2330 ionic_txrx_deinit(lif); in ionic_stop()
2331 ionic_txrx_free(lif); in ionic_stop()
2332 mutex_unlock(&lif->queue_lock); in ionic_stop()
2339 struct ionic_lif *lif = netdev_priv(netdev); in ionic_eth_ioctl() local
2343 return ionic_lif_hwstamp_set(lif, ifr); in ionic_eth_ioctl()
2345 return ionic_lif_hwstamp_get(lif, ifr); in ionic_eth_ioctl()
2354 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_vf_config() local
2355 struct ionic *ionic = lif->ionic; in ionic_get_vf_config()
2385 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_vf_stats() local
2386 struct ionic *ionic = lif->ionic; in ionic_get_vf_stats()
2422 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_mac() local
2423 struct ionic *ionic = lif->ionic; in ionic_set_vf_mac()
2454 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_vlan() local
2455 struct ionic *ionic = lif->ionic; in ionic_set_vf_vlan()
2493 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_rate() local
2494 struct ionic *ionic = lif->ionic; in ionic_set_vf_rate()
2525 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_spoofchk() local
2526 struct ionic *ionic = lif->ionic; in ionic_set_vf_spoofchk()
2553 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_trust() local
2554 struct ionic *ionic = lif->ionic; in ionic_set_vf_trust()
2581 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_vf_link_state() local
2582 struct ionic *ionic = lif->ionic; in ionic_set_vf_link_state()
2621 static void ionic_vf_attr_replay(struct ionic_lif *lif) in ionic_vf_attr_replay() argument
2624 struct ionic *ionic = lif->ionic; in ionic_vf_attr_replay()
2714 err = xdp_rxq_info_reg(rxq_info, q->lif->netdev, q->index, napi_id); in ionic_register_rxq_info()
2716 netdev_err(q->lif->netdev, "q%d xdp_rxq_info_reg failed, err %d\n", in ionic_register_rxq_info()
2723 netdev_err(q->lif->netdev, "q%d xdp_rxq_info_reg_mem_model failed, err %d\n", in ionic_register_rxq_info()
2738 static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif) in ionic_xdp_rxqs_prog_update() argument
2743 if (!lif->rxqcqs) in ionic_xdp_rxqs_prog_update()
2746 xdp_prog = READ_ONCE(lif->xdp_prog); in ionic_xdp_rxqs_prog_update()
2747 for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) { in ionic_xdp_rxqs_prog_update()
2748 struct ionic_queue *q = &lif->rxqcqs[i]->q; in ionic_xdp_rxqs_prog_update()
2756 struct ionic_lif *lif = netdev_priv(netdev); in ionic_xdp_config() local
2760 if (test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state)) { in ionic_xdp_config()
2763 netdev_info(lif->netdev, XDP_ERR_SPLIT); in ionic_xdp_config()
2767 if (!ionic_xdp_is_valid_mtu(lif, netdev->mtu, bpf->prog)) { in ionic_xdp_config()
2770 netdev_info(lif->netdev, XDP_ERR_MTU); in ionic_xdp_config()
2774 maxfs = __le32_to_cpu(lif->identity->eth.max_frame_size) - VLAN_ETH_HLEN; in ionic_xdp_config()
2780 old_prog = xchg(&lif->xdp_prog, bpf->prog); in ionic_xdp_config()
2781 } else if (lif->xdp_prog && bpf->prog) { in ionic_xdp_config()
2782 old_prog = xchg(&lif->xdp_prog, bpf->prog); in ionic_xdp_config()
2783 ionic_xdp_rxqs_prog_update(lif); in ionic_xdp_config()
2787 ionic_init_queue_params(lif, &qparams); in ionic_xdp_config()
2789 mutex_lock(&lif->queue_lock); in ionic_xdp_config()
2790 ionic_reconfigure_queues(lif, &qparams); in ionic_xdp_config()
2791 old_prog = xchg(&lif->xdp_prog, bpf->prog); in ionic_xdp_config()
2792 mutex_unlock(&lif->queue_lock); in ionic_xdp_config()
2837 static int ionic_cmb_reconfig(struct ionic_lif *lif, in ionic_cmb_reconfig() argument
2850 ionic_init_queue_params(lif, &start_qparams); in ionic_cmb_reconfig()
2853 ionic_stop_queues_reconfig(lif); in ionic_cmb_reconfig()
2854 ionic_txrx_free(lif); in ionic_cmb_reconfig()
2857 ionic_set_queue_params(lif, qparam); in ionic_cmb_reconfig()
2859 if (netif_running(lif->netdev)) { in ionic_cmb_reconfig()
2861 err = ionic_txrx_alloc(lif); in ionic_cmb_reconfig()
2863 dev_warn(lif->ionic->dev, in ionic_cmb_reconfig()
2867 ionic_set_queue_params(lif, &start_qparams); in ionic_cmb_reconfig()
2868 err = ionic_txrx_alloc(lif); in ionic_cmb_reconfig()
2870 dev_err(lif->ionic->dev, in ionic_cmb_reconfig()
2876 err = ionic_start_queues_reconfig(lif); in ionic_cmb_reconfig()
2878 dev_err(lif->ionic->dev, in ionic_cmb_reconfig()
2886 netif_device_attach(lif->netdev); in ionic_cmb_reconfig()
2932 ionic_debugfs_add_qcq(a->q.lif, a); in ionic_swap_queues()
2935 int ionic_reconfigure_queues(struct ionic_lif *lif, in ionic_reconfigure_queues() argument
2945 if ((test_bit(IONIC_LIF_F_CMB_TX_RINGS, lif->state) && qparam->cmb_tx) || in ionic_reconfigure_queues()
2946 (test_bit(IONIC_LIF_F_CMB_RX_RINGS, lif->state) && qparam->cmb_rx)) in ionic_reconfigure_queues()
2947 return ionic_cmb_reconfig(lif, qparam); in ionic_reconfigure_queues()
2950 if (qparam->nxqs != lif->nxqs || qparam->ntxq_descs != lif->ntxq_descs) { in ionic_reconfigure_queues()
2951 tx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->ntxqs_per_lif, in ionic_reconfigure_queues()
2958 if (qparam->nxqs != lif->nxqs || in ionic_reconfigure_queues()
2959 qparam->nrxq_descs != lif->nrxq_descs || in ionic_reconfigure_queues()
2960 qparam->rxq_features != lif->rxq_features || in ionic_reconfigure_queues()
2961 qparam->xdp_prog != lif->xdp_prog) { in ionic_reconfigure_queues()
2962 rx_qcqs = devm_kcalloc(lif->ionic->dev, lif->ionic->nrxqs_per_lif, in ionic_reconfigure_queues()
2978 if (lif->qtype_info[IONIC_QTYPE_TXQ].version >= 1 && in ionic_reconfigure_queues()
2979 lif->qtype_info[IONIC_QTYPE_TXQ].sg_desc_sz == in ionic_reconfigure_queues()
2987 if (!lif->txqcqs[i]) { in ionic_reconfigure_queues()
2989 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_reconfigure_queues()
2992 lif->kern_pid, NULL, &lif->txqcqs[i]); in ionic_reconfigure_queues()
2997 flags = lif->txqcqs[i]->flags & ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
2998 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_reconfigure_queues()
3001 lif->kern_pid, NULL, &tx_qcqs[i]); in ionic_reconfigure_queues()
3018 if (!lif->rxqcqs[i]) { in ionic_reconfigure_queues()
3020 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_reconfigure_queues()
3023 lif->kern_pid, NULL, &lif->rxqcqs[i]); in ionic_reconfigure_queues()
3028 flags = lif->rxqcqs[i]->flags & ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3029 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_reconfigure_queues()
3032 lif->kern_pid, qparam->xdp_prog, &rx_qcqs[i]); in ionic_reconfigure_queues()
3042 ionic_stop_queues_reconfig(lif); in ionic_reconfigure_queues()
3044 if (qparam->nxqs != lif->nxqs) { in ionic_reconfigure_queues()
3045 err = netif_set_real_num_tx_queues(lif->netdev, qparam->nxqs); in ionic_reconfigure_queues()
3048 err = netif_set_real_num_rx_queues(lif->netdev, qparam->nxqs); in ionic_reconfigure_queues()
3050 netif_set_real_num_tx_queues(lif->netdev, lif->nxqs); in ionic_reconfigure_queues()
3057 lif->ntxq_descs = qparam->ntxq_descs; in ionic_reconfigure_queues()
3059 ionic_swap_queues(lif->txqcqs[i], tx_qcqs[i]); in ionic_reconfigure_queues()
3063 lif->nrxq_descs = qparam->nrxq_descs; in ionic_reconfigure_queues()
3065 ionic_swap_queues(lif->rxqcqs[i], rx_qcqs[i]); in ionic_reconfigure_queues()
3069 if (qparam->intr_split != test_bit(IONIC_LIF_F_SPLIT_INTR, lif->state) || in ionic_reconfigure_queues()
3070 qparam->nxqs != lif->nxqs) { in ionic_reconfigure_queues()
3072 set_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); in ionic_reconfigure_queues()
3074 clear_bit(IONIC_LIF_F_SPLIT_INTR, lif->state); in ionic_reconfigure_queues()
3075 lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; in ionic_reconfigure_queues()
3076 lif->tx_coalesce_hw = lif->rx_coalesce_hw; in ionic_reconfigure_queues()
3083 for (i = 0; i < lif->ionic->ntxqs_per_lif; i++) { in ionic_reconfigure_queues()
3084 if (lif->txqcqs[i]) in ionic_reconfigure_queues()
3085 ionic_qcq_intr_free(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3086 if (lif->rxqcqs[i]) in ionic_reconfigure_queues()
3087 ionic_qcq_intr_free(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3092 lif->rxqcqs[i]->flags |= IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3093 err = ionic_alloc_qcq_interrupt(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3094 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_reconfigure_queues()
3095 lif->rxqcqs[i]->intr.index, in ionic_reconfigure_queues()
3096 lif->rx_coalesce_hw); in ionic_reconfigure_queues()
3099 lif->txqcqs[i]->flags |= IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3100 err = ionic_alloc_qcq_interrupt(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3101 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_reconfigure_queues()
3102 lif->txqcqs[i]->intr.index, in ionic_reconfigure_queues()
3103 lif->tx_coalesce_hw); in ionic_reconfigure_queues()
3104 if (test_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state)) in ionic_reconfigure_queues()
3105 lif->txqcqs[i]->intr.dim_coal_hw = lif->tx_coalesce_hw; in ionic_reconfigure_queues()
3107 lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3108 ionic_link_qcq_interrupts(lif->rxqcqs[i], lif->txqcqs[i]); in ionic_reconfigure_queues()
3116 ionic_debugfs_del_qcq(lif->txqcqs[i]); in ionic_reconfigure_queues()
3117 ionic_debugfs_add_qcq(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3123 ionic_debugfs_del_qcq(lif->rxqcqs[i]); in ionic_reconfigure_queues()
3124 ionic_debugfs_add_qcq(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3128 swap(lif->nxqs, qparam->nxqs); in ionic_reconfigure_queues()
3129 swap(lif->rxq_features, qparam->rxq_features); in ionic_reconfigure_queues()
3134 ionic_start_queues_reconfig(lif); in ionic_reconfigure_queues()
3136 err = ionic_start_queues_reconfig(lif); in ionic_reconfigure_queues()
3143 ionic_qcq_free(lif, tx_qcqs[i]); in ionic_reconfigure_queues()
3144 devm_kfree(lif->ionic->dev, tx_qcqs[i]); in ionic_reconfigure_queues()
3149 ionic_qcq_free(lif, rx_qcqs[i]); in ionic_reconfigure_queues()
3150 devm_kfree(lif->ionic->dev, rx_qcqs[i]); in ionic_reconfigure_queues()
3157 devm_kfree(lif->ionic->dev, rx_qcqs); in ionic_reconfigure_queues()
3161 devm_kfree(lif->ionic->dev, tx_qcqs); in ionic_reconfigure_queues()
3168 for (i = lif->nxqs; i < lif->ionic->ntxqs_per_lif; i++) { in ionic_reconfigure_queues()
3169 if (lif->txqcqs && lif->txqcqs[i]) { in ionic_reconfigure_queues()
3170 lif->txqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3171 ionic_qcq_free(lif, lif->txqcqs[i]); in ionic_reconfigure_queues()
3174 if (lif->rxqcqs && lif->rxqcqs[i]) { in ionic_reconfigure_queues()
3175 lif->rxqcqs[i]->flags &= ~IONIC_QCQ_F_INTR; in ionic_reconfigure_queues()
3176 ionic_qcq_free(lif, lif->rxqcqs[i]); in ionic_reconfigure_queues()
3181 netdev_info(lif->netdev, "%s: failed %d\n", __func__, err); in ionic_reconfigure_queues()
3229 struct ionic_lif *lif; in ionic_lif_alloc() local
3237 netdev = alloc_etherdev_mqs(sizeof(*lif), in ionic_lif_alloc()
3247 lif = netdev_priv(netdev); in ionic_lif_alloc()
3248 lif->netdev = netdev; in ionic_lif_alloc()
3249 ionic->lif = lif; in ionic_lif_alloc()
3250 lif->ionic = ionic; in ionic_lif_alloc()
3257 lif->identity = lid; in ionic_lif_alloc()
3258 lif->lif_type = IONIC_LIF_TYPE_CLASSIC; in ionic_lif_alloc()
3259 err = ionic_lif_identify(ionic, lif->lif_type, lif->identity); in ionic_lif_alloc()
3262 lif->lif_type, err); in ionic_lif_alloc()
3265 lif->netdev->min_mtu = max_t(unsigned int, ETH_MIN_MTU, in ionic_lif_alloc()
3266 le32_to_cpu(lif->identity->eth.min_frame_size)); in ionic_lif_alloc()
3267 lif->netdev->max_mtu = in ionic_lif_alloc()
3268 le32_to_cpu(lif->identity->eth.max_frame_size) - ETH_HLEN - VLAN_HLEN; in ionic_lif_alloc()
3270 lif->neqs = ionic->neqs_per_lif; in ionic_lif_alloc()
3271 lif->nxqs = ionic->ntxqs_per_lif; in ionic_lif_alloc()
3273 lif->index = 0; in ionic_lif_alloc()
3276 lif->ntxq_descs = IONIC_MIN_TXRX_DESC; in ionic_lif_alloc()
3277 lif->nrxq_descs = IONIC_MIN_TXRX_DESC; in ionic_lif_alloc()
3279 lif->ntxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
3280 lif->nrxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
3284 lif->rx_coalesce_usecs = IONIC_ITR_COAL_USEC_DEFAULT; in ionic_lif_alloc()
3285 lif->rx_coalesce_hw = ionic_coal_usec_to_hw(lif->ionic, in ionic_lif_alloc()
3286 lif->rx_coalesce_usecs); in ionic_lif_alloc()
3287 lif->tx_coalesce_usecs = lif->rx_coalesce_usecs; in ionic_lif_alloc()
3288 lif->tx_coalesce_hw = lif->rx_coalesce_hw; in ionic_lif_alloc()
3289 set_bit(IONIC_LIF_F_RX_DIM_INTR, lif->state); in ionic_lif_alloc()
3290 set_bit(IONIC_LIF_F_TX_DIM_INTR, lif->state); in ionic_lif_alloc()
3292 snprintf(lif->name, sizeof(lif->name), "lif%u", lif->index); in ionic_lif_alloc()
3294 mutex_init(&lif->queue_lock); in ionic_lif_alloc()
3295 mutex_init(&lif->config_lock); in ionic_lif_alloc()
3297 spin_lock_init(&lif->adminq_lock); in ionic_lif_alloc()
3299 spin_lock_init(&lif->deferred.lock); in ionic_lif_alloc()
3300 INIT_LIST_HEAD(&lif->deferred.list); in ionic_lif_alloc()
3301 INIT_WORK(&lif->deferred.work, ionic_lif_deferred_work); in ionic_lif_alloc()
3304 lif->info_sz = ALIGN(sizeof(*lif->info), PAGE_SIZE); in ionic_lif_alloc()
3305 lif->info = dma_alloc_coherent(dev, lif->info_sz, in ionic_lif_alloc()
3306 &lif->info_pa, GFP_KERNEL); in ionic_lif_alloc()
3307 if (!lif->info) { in ionic_lif_alloc()
3313 ionic_debugfs_add_lif(lif); in ionic_lif_alloc()
3320 ionic_lif_queue_identify(lif); in ionic_lif_alloc()
3321 err = ionic_qcqs_alloc(lif); in ionic_lif_alloc()
3326 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_alloc()
3327 lif->rss_ind_tbl_sz = sizeof(*lif->rss_ind_tbl) * tbl_sz; in ionic_lif_alloc()
3328 lif->rss_ind_tbl = dma_alloc_coherent(dev, lif->rss_ind_tbl_sz, in ionic_lif_alloc()
3329 &lif->rss_ind_tbl_pa, in ionic_lif_alloc()
3332 if (!lif->rss_ind_tbl) { in ionic_lif_alloc()
3337 netdev_rss_key_fill(lif->rss_hash_key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_alloc()
3339 ionic_lif_alloc_phc(lif); in ionic_lif_alloc()
3344 ionic_qcqs_free(lif); in ionic_lif_alloc()
3346 ionic_affinity_masks_free(lif->ionic); in ionic_lif_alloc()
3348 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_alloc()
3349 lif->info = NULL; in ionic_lif_alloc()
3350 lif->info_pa = 0; in ionic_lif_alloc()
3352 mutex_destroy(&lif->config_lock); in ionic_lif_alloc()
3353 mutex_destroy(&lif->queue_lock); in ionic_lif_alloc()
3355 free_netdev(lif->netdev); in ionic_lif_alloc()
3356 lif = NULL; in ionic_lif_alloc()
3363 static void ionic_lif_reset(struct ionic_lif *lif) in ionic_lif_reset() argument
3365 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_reset()
3370 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
3371 ionic_dev_cmd_lif_reset(idev, lif->index); in ionic_lif_reset()
3372 ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_reset()
3373 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
3376 static void ionic_lif_handle_fw_down(struct ionic_lif *lif) in ionic_lif_handle_fw_down() argument
3378 struct ionic *ionic = lif->ionic; in ionic_lif_handle_fw_down()
3380 if (test_and_set_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_handle_fw_down()
3385 netif_device_detach(lif->netdev); in ionic_lif_handle_fw_down()
3387 mutex_lock(&lif->queue_lock); in ionic_lif_handle_fw_down()
3388 if (test_bit(IONIC_LIF_F_UP, lif->state)) { in ionic_lif_handle_fw_down()
3390 ionic_stop_queues(lif); in ionic_lif_handle_fw_down()
3393 if (netif_running(lif->netdev)) { in ionic_lif_handle_fw_down()
3394 ionic_txrx_deinit(lif); in ionic_lif_handle_fw_down()
3395 ionic_txrx_free(lif); in ionic_lif_handle_fw_down()
3397 ionic_lif_deinit(lif); in ionic_lif_handle_fw_down()
3399 ionic_qcqs_free(lif); in ionic_lif_handle_fw_down()
3401 mutex_unlock(&lif->queue_lock); in ionic_lif_handle_fw_down()
3403 clear_bit(IONIC_LIF_F_FW_STOPPING, lif->state); in ionic_lif_handle_fw_down()
3407 int ionic_restart_lif(struct ionic_lif *lif) in ionic_restart_lif() argument
3409 struct ionic *ionic = lif->ionic; in ionic_restart_lif()
3412 mutex_lock(&lif->queue_lock); in ionic_restart_lif()
3414 if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state)) in ionic_restart_lif()
3417 err = ionic_qcqs_alloc(lif); in ionic_restart_lif()
3421 err = ionic_lif_init(lif); in ionic_restart_lif()
3425 ionic_vf_attr_replay(lif); in ionic_restart_lif()
3427 if (lif->registered) in ionic_restart_lif()
3428 ionic_lif_set_netdev_info(lif); in ionic_restart_lif()
3430 ionic_rx_filter_replay(lif); in ionic_restart_lif()
3432 if (netif_running(lif->netdev)) { in ionic_restart_lif()
3433 err = ionic_txrx_alloc(lif); in ionic_restart_lif()
3437 err = ionic_txrx_init(lif); in ionic_restart_lif()
3442 mutex_unlock(&lif->queue_lock); in ionic_restart_lif()
3444 clear_bit(IONIC_LIF_F_FW_RESET, lif->state); in ionic_restart_lif()
3445 ionic_link_status_check_request(lif, CAN_SLEEP); in ionic_restart_lif()
3446 netif_device_attach(lif->netdev); in ionic_restart_lif()
3452 ionic_txrx_free(lif); in ionic_restart_lif()
3454 ionic_lif_deinit(lif); in ionic_restart_lif()
3456 ionic_qcqs_free(lif); in ionic_restart_lif()
3458 mutex_unlock(&lif->queue_lock); in ionic_restart_lif()
3463 static void ionic_lif_handle_fw_up(struct ionic_lif *lif) in ionic_lif_handle_fw_up() argument
3465 struct ionic *ionic = lif->ionic; in ionic_lif_handle_fw_up()
3468 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_handle_fw_up()
3489 err = ionic_restart_lif(lif); in ionic_lif_handle_fw_up()
3496 ionic_lif_hwstamp_replay(lif); in ionic_lif_handle_fw_up()
3504 void ionic_lif_free(struct ionic_lif *lif) in ionic_lif_free() argument
3506 struct device *dev = lif->ionic->dev; in ionic_lif_free()
3508 ionic_lif_free_phc(lif); in ionic_lif_free()
3511 dma_free_coherent(dev, lif->rss_ind_tbl_sz, lif->rss_ind_tbl, in ionic_lif_free()
3512 lif->rss_ind_tbl_pa); in ionic_lif_free()
3513 lif->rss_ind_tbl = NULL; in ionic_lif_free()
3514 lif->rss_ind_tbl_pa = 0; in ionic_lif_free()
3517 ionic_qcqs_free(lif); in ionic_lif_free()
3518 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_free()
3519 ionic_lif_reset(lif); in ionic_lif_free()
3521 ionic_affinity_masks_free(lif->ionic); in ionic_lif_free()
3524 kfree(lif->identity); in ionic_lif_free()
3525 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_free()
3526 lif->info = NULL; in ionic_lif_free()
3527 lif->info_pa = 0; in ionic_lif_free()
3530 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_free()
3531 lif->kern_dbpage = NULL; in ionic_lif_free()
3533 mutex_destroy(&lif->config_lock); in ionic_lif_free()
3534 mutex_destroy(&lif->queue_lock); in ionic_lif_free()
3537 ionic_debugfs_del_lif(lif); in ionic_lif_free()
3538 free_netdev(lif->netdev); in ionic_lif_free()
3541 void ionic_lif_deinit(struct ionic_lif *lif) in ionic_lif_deinit() argument
3543 if (!test_and_clear_bit(IONIC_LIF_F_INITED, lif->state)) in ionic_lif_deinit()
3546 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { in ionic_lif_deinit()
3547 cancel_work_sync(&lif->deferred.work); in ionic_lif_deinit()
3548 cancel_work_sync(&lif->tx_timeout_work); in ionic_lif_deinit()
3549 ionic_rx_filters_deinit(lif); in ionic_lif_deinit()
3550 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_lif_deinit()
3551 ionic_lif_rss_deinit(lif); in ionic_lif_deinit()
3554 napi_disable(&lif->adminqcq->napi); in ionic_lif_deinit()
3555 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_deinit()
3556 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_deinit()
3558 ionic_lif_reset(lif); in ionic_lif_deinit()
3561 static int ionic_lif_adminq_init(struct ionic_lif *lif) in ionic_lif_adminq_init() argument
3563 struct device *dev = lif->ionic->dev; in ionic_lif_adminq_init()
3570 idev = &lif->ionic->idev; in ionic_lif_adminq_init()
3571 qcq = lif->adminqcq; in ionic_lif_adminq_init()
3574 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
3575 ionic_dev_cmd_adminq_init(idev, qcq, lif->index, qcq->intr.index); in ionic_lif_adminq_init()
3576 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_adminq_init()
3578 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
3580 netdev_err(lif->netdev, "adminq init failed %d\n", err); in ionic_lif_adminq_init()
3594 netif_napi_add(lif->netdev, &qcq->napi, ionic_adminq_napi); in ionic_lif_adminq_init()
3610 static int ionic_lif_notifyq_init(struct ionic_lif *lif) in ionic_lif_notifyq_init() argument
3612 struct ionic_qcq *qcq = lif->notifyqcq; in ionic_lif_notifyq_init()
3613 struct device *dev = lif->ionic->dev; in ionic_lif_notifyq_init()
3621 .lif_index = cpu_to_le16(lif->index), in ionic_lif_notifyq_init()
3623 .ver = lif->qtype_info[q->type].version, in ionic_lif_notifyq_init()
3627 .intr_index = cpu_to_le16(lif->adminqcq->intr.index), in ionic_lif_notifyq_init()
3639 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_notifyq_init()
3643 lif->last_eid = 0; in ionic_lif_notifyq_init()
3652 q->admin_info[0].ctx = lif; in ionic_lif_notifyq_init()
3659 static int ionic_station_set(struct ionic_lif *lif) in ionic_station_set() argument
3661 struct net_device *netdev = lif->netdev; in ionic_station_set()
3666 .index = cpu_to_le16(lif->index), in ionic_station_set()
3674 err = ionic_adminq_post_wait(lif, &ctx); in ionic_station_set()
3677 netdev_dbg(lif->netdev, "found initial MAC addr %pM\n", in ionic_station_set()
3686 err = ionic_program_mac(lif, mac_address); in ionic_station_set()
3704 ionic_lif_addr_add(lif, netdev->dev_addr); in ionic_station_set()
3711 netdev_warn(lif->netdev, "ignoring bad MAC addr from NIC %pM - err %d\n", in ionic_station_set()
3719 netdev_dbg(lif->netdev, "adding station MAC addr %pM\n", in ionic_station_set()
3721 ionic_lif_addr_add(lif, netdev->dev_addr); in ionic_station_set()
3726 int ionic_lif_init(struct ionic_lif *lif) in ionic_lif_init() argument
3728 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_init()
3729 struct device *dev = lif->ionic->dev; in ionic_lif_init()
3734 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
3735 ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa); in ionic_lif_init()
3736 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_init()
3738 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
3742 lif->hw_index = le16_to_cpu(comp.hw_index); in ionic_lif_init()
3745 lif->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif); in ionic_lif_init()
3746 if (!lif->dbid_count) { in ionic_lif_init()
3751 lif->kern_pid = 0; in ionic_lif_init()
3752 dbpage_num = ionic_db_page_num(lif, lif->kern_pid); in ionic_lif_init()
3753 lif->kern_dbpage = ionic_bus_map_dbpage(lif->ionic, dbpage_num); in ionic_lif_init()
3754 if (!lif->kern_dbpage) { in ionic_lif_init()
3759 err = ionic_lif_adminq_init(lif); in ionic_lif_init()
3763 if (lif->ionic->nnqs_per_lif) { in ionic_lif_init()
3764 err = ionic_lif_notifyq_init(lif); in ionic_lif_init()
3769 if (test_bit(IONIC_LIF_F_FW_RESET, lif->state)) in ionic_lif_init()
3770 err = ionic_set_nic_features(lif, lif->netdev->features); in ionic_lif_init()
3772 err = ionic_init_nic_features(lif); in ionic_lif_init()
3776 if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state)) { in ionic_lif_init()
3777 err = ionic_rx_filters_init(lif); in ionic_lif_init()
3782 err = ionic_station_set(lif); in ionic_lif_init()
3786 lif->rx_copybreak = IONIC_RX_COPYBREAK_DEFAULT; in ionic_lif_init()
3787 lif->doorbell_wa = ionic_doorbell_wa(lif->ionic); in ionic_lif_init()
3789 set_bit(IONIC_LIF_F_INITED, lif->state); in ionic_lif_init()
3791 INIT_WORK(&lif->tx_timeout_work, ionic_tx_timeout_work); in ionic_lif_init()
3796 napi_disable(&lif->adminqcq->napi); in ionic_lif_init()
3797 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_init()
3799 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_init()
3800 ionic_lif_reset(lif); in ionic_lif_init()
3801 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_init()
3802 lif->kern_dbpage = NULL; in ionic_lif_init()
3811 static void ionic_lif_set_netdev_info(struct ionic_lif *lif) in ionic_lif_set_netdev_info() argument
3817 .index = cpu_to_le16(lif->index), in ionic_lif_set_netdev_info()
3822 strscpy(ctx.cmd.lif_setattr.name, netdev_name(lif->netdev), in ionic_lif_set_netdev_info()
3825 ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_netdev_info()
3841 struct ionic_lif *lif = ionic_netdev_lif(ndev); in ionic_lif_notify() local
3843 if (!lif || lif->ionic != ionic) in ionic_lif_notify()
3848 ionic_lif_set_netdev_info(lif); in ionic_lif_notify()
3855 int ionic_lif_register(struct ionic_lif *lif) in ionic_lif_register() argument
3859 ionic_lif_register_phc(lif); in ionic_lif_register()
3861 INIT_WORK(&lif->ionic->nb_work, ionic_lif_notify_work); in ionic_lif_register()
3863 lif->ionic->nb.notifier_call = ionic_lif_notify; in ionic_lif_register()
3865 err = register_netdevice_notifier(&lif->ionic->nb); in ionic_lif_register()
3867 lif->ionic->nb.notifier_call = NULL; in ionic_lif_register()
3870 err = register_netdev(lif->netdev); in ionic_lif_register()
3872 dev_err(lif->ionic->dev, "Cannot register net device: %d, aborting\n", err); in ionic_lif_register()
3873 ionic_lif_unregister(lif); in ionic_lif_register()
3877 ionic_link_status_check_request(lif, CAN_SLEEP); in ionic_lif_register()
3878 lif->registered = true; in ionic_lif_register()
3879 ionic_lif_set_netdev_info(lif); in ionic_lif_register()
3884 void ionic_lif_unregister(struct ionic_lif *lif) in ionic_lif_unregister() argument
3886 if (lif->ionic->nb.notifier_call) { in ionic_lif_unregister()
3887 unregister_netdevice_notifier(&lif->ionic->nb); in ionic_lif_unregister()
3888 cancel_work_sync(&lif->ionic->nb_work); in ionic_lif_unregister()
3889 lif->ionic->nb.notifier_call = NULL; in ionic_lif_unregister()
3892 if (lif->netdev->reg_state == NETREG_REGISTERED) in ionic_lif_unregister()
3893 unregister_netdev(lif->netdev); in ionic_lif_unregister()
3895 ionic_lif_unregister_phc(lif); in ionic_lif_unregister()
3897 lif->registered = false; in ionic_lif_unregister()
3900 static void ionic_lif_queue_identify(struct ionic_lif *lif) in ionic_lif_queue_identify() argument
3903 struct ionic *ionic = lif->ionic; in ionic_lif_queue_identify()
3909 idev = &lif->ionic->idev; in ionic_lif_queue_identify()
3913 struct ionic_qtype_info *qti = &lif->qtype_info[qtype]; in ionic_lif_queue_identify()
3929 ionic_dev_cmd_queue_identify(idev, lif->lif_type, qtype, in ionic_lif_queue_identify()
4042 lc = &ident->lif.eth.config; in ionic_lif_size()
4044 neqs_per_lif = le32_to_cpu(ident->lif.rdma.eq_qtype.qid_count); in ionic_lif_size()