Lines Matching refs:lif
20 static void ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int rx_mode);
21 static int ionic_lif_addr_add(struct ionic_lif *lif, const u8 *addr);
22 static int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr);
23 static void ionic_link_status_check(struct ionic_lif *lif);
27 struct ionic_lif *lif = container_of(work, struct ionic_lif, deferred.work); in ionic_lif_deferred_work() local
28 struct ionic_deferred *def = &lif->deferred; in ionic_lif_deferred_work()
42 ionic_lif_rx_mode(lif, w->rx_mode); in ionic_lif_deferred_work()
45 ionic_lif_addr_add(lif, w->addr); in ionic_lif_deferred_work()
48 ionic_lif_addr_del(lif, w->addr); in ionic_lif_deferred_work()
51 ionic_link_status_check(lif); in ionic_lif_deferred_work()
70 static void ionic_link_status_check(struct ionic_lif *lif) in ionic_link_status_check() argument
72 struct net_device *netdev = lif->netdev; in ionic_link_status_check()
76 link_status = le16_to_cpu(lif->info->status.link_status); in ionic_link_status_check()
85 le32_to_cpu(lif->info->status.link_speed) / 1000); in ionic_link_status_check()
87 if (test_bit(IONIC_LIF_UP, lif->state)) { in ionic_link_status_check()
88 netif_tx_wake_all_queues(lif->netdev); in ionic_link_status_check()
96 if (test_bit(IONIC_LIF_UP, lif->state)) in ionic_link_status_check()
101 clear_bit(IONIC_LIF_LINK_CHECK_REQUESTED, lif->state); in ionic_link_status_check()
104 static void ionic_link_status_check_request(struct ionic_lif *lif) in ionic_link_status_check_request() argument
109 if (test_and_set_bit(IONIC_LIF_LINK_CHECK_REQUESTED, lif->state)) in ionic_link_status_check_request()
118 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_link_status_check_request()
120 ionic_link_status_check(lif); in ionic_link_status_check_request()
133 static int ionic_request_irq(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_request_irq() argument
136 struct device *dev = lif->ionic->dev; in ionic_request_irq()
140 if (lif->registered) in ionic_request_irq()
141 name = lif->netdev->name; in ionic_request_irq()
152 static int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr) in ionic_intr_alloc() argument
154 struct ionic *ionic = lif->ionic; in ionic_intr_alloc()
159 netdev_warn(lif->netdev, "%s: no intr, index=%d nintrs=%d\n", in ionic_intr_alloc()
170 static void ionic_intr_free(struct ionic_lif *lif, int index) in ionic_intr_free() argument
172 if (index != INTR_INDEX_NOT_ASSIGNED && index < lif->ionic->nintrs) in ionic_intr_free()
173 clear_bit(index, lif->ionic->intrs); in ionic_intr_free()
179 struct ionic_lif *lif = q->lif; in ionic_qcq_enable() local
187 .lif_index = cpu_to_le16(lif->index), in ionic_qcq_enable()
194 idev = &lif->ionic->idev; in ionic_qcq_enable()
195 dev = lif->ionic->dev; in ionic_qcq_enable()
209 return ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_enable()
215 struct ionic_lif *lif = q->lif; in ionic_qcq_disable() local
223 .lif_index = cpu_to_le16(lif->index), in ionic_qcq_disable()
230 idev = &lif->ionic->idev; in ionic_qcq_disable()
231 dev = lif->ionic->dev; in ionic_qcq_disable()
244 return ionic_adminq_post_wait(lif, &ctx); in ionic_qcq_disable()
247 static void ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_qcq_deinit() argument
249 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_qcq_deinit()
250 struct device *dev = lif->ionic->dev; in ionic_lif_qcq_deinit()
270 static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_qcq_free() argument
272 struct device *dev = lif->ionic->dev; in ionic_qcq_free()
282 ionic_intr_free(lif, qcq->intr.index); in ionic_qcq_free()
291 static void ionic_qcqs_free(struct ionic_lif *lif) in ionic_qcqs_free() argument
293 struct device *dev = lif->ionic->dev; in ionic_qcqs_free()
296 if (lif->notifyqcq) { in ionic_qcqs_free()
297 ionic_qcq_free(lif, lif->notifyqcq); in ionic_qcqs_free()
298 lif->notifyqcq = NULL; in ionic_qcqs_free()
301 if (lif->adminqcq) { in ionic_qcqs_free()
302 ionic_qcq_free(lif, lif->adminqcq); in ionic_qcqs_free()
303 lif->adminqcq = NULL; in ionic_qcqs_free()
306 for (i = 0; i < lif->nxqs; i++) in ionic_qcqs_free()
307 if (lif->rxqcqs[i].stats) in ionic_qcqs_free()
308 devm_kfree(dev, lif->rxqcqs[i].stats); in ionic_qcqs_free()
310 devm_kfree(dev, lif->rxqcqs); in ionic_qcqs_free()
311 lif->rxqcqs = NULL; in ionic_qcqs_free()
313 for (i = 0; i < lif->nxqs; i++) in ionic_qcqs_free()
314 if (lif->txqcqs[i].stats) in ionic_qcqs_free()
315 devm_kfree(dev, lif->txqcqs[i].stats); in ionic_qcqs_free()
317 devm_kfree(dev, lif->txqcqs); in ionic_qcqs_free()
318 lif->txqcqs = NULL; in ionic_qcqs_free()
325 ionic_intr_free(n_qcq->cq.lif, n_qcq->intr.index); in ionic_link_qcq_interrupts()
333 static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, in ionic_qcq_alloc() argument
341 struct ionic_dev *idev = &lif->ionic->idev; in ionic_qcq_alloc()
343 struct device *dev = lif->ionic->dev; in ionic_qcq_alloc()
370 netdev_err(lif->netdev, "Cannot allocate queue structure\n"); in ionic_qcq_alloc()
380 netdev_err(lif->netdev, "Cannot allocate queue info\n"); in ionic_qcq_alloc()
387 err = ionic_q_init(lif, idev, &new->q, index, name, num_descs, in ionic_qcq_alloc()
390 netdev_err(lif->netdev, "Cannot initialize queue\n"); in ionic_qcq_alloc()
395 err = ionic_intr_alloc(lif, &new->intr); in ionic_qcq_alloc()
397 netdev_warn(lif->netdev, "no intr for %s: %d\n", in ionic_qcq_alloc()
402 err = ionic_bus_get_irq(lif->ionic, new->intr.index); in ionic_qcq_alloc()
404 netdev_warn(lif->netdev, "no vector for %s: %d\n", in ionic_qcq_alloc()
423 netdev_err(lif->netdev, "Cannot allocate completion queue info\n"); in ionic_qcq_alloc()
428 err = ionic_cq_init(lif, &new->cq, &new->intr, num_descs, cq_desc_size); in ionic_qcq_alloc()
430 netdev_err(lif->netdev, "Cannot initialize completion queue\n"); in ionic_qcq_alloc()
437 netdev_err(lif->netdev, "Cannot allocate queue DMA memory\n"); in ionic_qcq_alloc()
466 ionic_intr_free(lif, new->intr.index); in ionic_qcq_alloc()
472 static int ionic_qcqs_alloc(struct ionic_lif *lif) in ionic_qcqs_alloc() argument
474 struct device *dev = lif->ionic->dev; in ionic_qcqs_alloc()
481 err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags, in ionic_qcqs_alloc()
485 0, lif->kern_pid, &lif->adminqcq); in ionic_qcqs_alloc()
489 if (lif->ionic->nnqs_per_lif) { in ionic_qcqs_alloc()
491 err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notifyq", in ionic_qcqs_alloc()
495 0, lif->kern_pid, &lif->notifyqcq); in ionic_qcqs_alloc()
500 ionic_link_qcq_interrupts(lif->adminqcq, lif->notifyqcq); in ionic_qcqs_alloc()
503 q_list_size = sizeof(*lif->txqcqs) * lif->nxqs; in ionic_qcqs_alloc()
505 lif->txqcqs = devm_kzalloc(dev, q_list_size, GFP_KERNEL); in ionic_qcqs_alloc()
506 if (!lif->txqcqs) in ionic_qcqs_alloc()
508 for (i = 0; i < lif->nxqs; i++) { in ionic_qcqs_alloc()
509 lif->txqcqs[i].stats = devm_kzalloc(dev, in ionic_qcqs_alloc()
512 if (!lif->txqcqs[i].stats) in ionic_qcqs_alloc()
516 lif->rxqcqs = devm_kzalloc(dev, q_list_size, GFP_KERNEL); in ionic_qcqs_alloc()
517 if (!lif->rxqcqs) in ionic_qcqs_alloc()
519 for (i = 0; i < lif->nxqs; i++) { in ionic_qcqs_alloc()
520 lif->rxqcqs[i].stats = devm_kzalloc(dev, in ionic_qcqs_alloc()
523 if (!lif->rxqcqs[i].stats) in ionic_qcqs_alloc()
530 for (i = 0; i < lif->nxqs; i++) in ionic_qcqs_alloc()
531 if (lif->rxqcqs[i].stats) in ionic_qcqs_alloc()
532 devm_kfree(dev, lif->rxqcqs[i].stats); in ionic_qcqs_alloc()
533 devm_kfree(dev, lif->rxqcqs); in ionic_qcqs_alloc()
534 lif->rxqcqs = NULL; in ionic_qcqs_alloc()
536 for (i = 0; i < lif->nxqs; i++) in ionic_qcqs_alloc()
537 if (lif->txqcqs[i].stats) in ionic_qcqs_alloc()
538 devm_kfree(dev, lif->txqcqs[i].stats); in ionic_qcqs_alloc()
539 devm_kfree(dev, lif->txqcqs); in ionic_qcqs_alloc()
540 lif->txqcqs = NULL; in ionic_qcqs_alloc()
542 if (lif->notifyqcq) { in ionic_qcqs_alloc()
543 ionic_qcq_free(lif, lif->notifyqcq); in ionic_qcqs_alloc()
544 lif->notifyqcq = NULL; in ionic_qcqs_alloc()
547 ionic_qcq_free(lif, lif->adminqcq); in ionic_qcqs_alloc()
548 lif->adminqcq = NULL; in ionic_qcqs_alloc()
553 static int ionic_lif_txq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_txq_init() argument
555 struct device *dev = lif->ionic->dev; in ionic_lif_txq_init()
562 .lif_index = cpu_to_le16(lif->index), in ionic_lif_txq_init()
567 .intr_index = cpu_to_le16(lif->rxqcqs[q->index].qcq->intr.index), in ionic_lif_txq_init()
582 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_txq_init()
595 ionic_debugfs_add_qcq(lif, qcq); in ionic_lif_txq_init()
600 static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq) in ionic_lif_rxq_init() argument
602 struct device *dev = lif->ionic->dev; in ionic_lif_rxq_init()
609 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rxq_init()
627 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rxq_init()
638 netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi, in ionic_lif_rxq_init()
641 err = ionic_request_irq(lif, qcq); in ionic_lif_rxq_init()
649 ionic_debugfs_add_qcq(lif, qcq); in ionic_lif_rxq_init()
660 struct ionic_lif *lif; in ionic_notifyq_service() local
664 lif = q->info[0].cb_arg; in ionic_notifyq_service()
665 netdev = lif->netdev; in ionic_notifyq_service()
669 if (eid <= lif->last_eid) in ionic_notifyq_service()
672 lif->last_eid = eid; in ionic_notifyq_service()
674 dev_dbg(lif->ionic->dev, "notifyq event:\n"); in ionic_notifyq_service()
680 ionic_link_status_check_request(lif); in ionic_notifyq_service()
698 static int ionic_notifyq_clean(struct ionic_lif *lif, int budget) in ionic_notifyq_clean() argument
700 struct ionic_dev *idev = &lif->ionic->idev; in ionic_notifyq_clean()
701 struct ionic_cq *cq = &lif->notifyqcq->cq; in ionic_notifyq_clean()
728 struct ionic_lif *lif = napi_to_cq(napi)->lif; in ionic_adminq_napi() local
732 if (likely(lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED)) in ionic_adminq_napi()
733 n_work = ionic_notifyq_clean(lif, budget); in ionic_adminq_napi()
742 struct ionic_lif *lif = netdev_priv(netdev); in ionic_get_stats64() local
746 ls = &lif->info->stats; in ionic_get_stats64()
792 static int ionic_lif_addr_add(struct ionic_lif *lif, const u8 *addr) in ionic_lif_addr_add() argument
798 .lif_index = cpu_to_le16(lif->index), in ionic_lif_addr_add()
806 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_addr_add()
807 f = ionic_rx_filter_by_addr(lif, addr); in ionic_lif_addr_add()
808 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_addr_add()
812 netdev_dbg(lif->netdev, "rx_filter add ADDR %pM (id %d)\n", addr, in ionic_lif_addr_add()
816 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_addr_add()
820 return ionic_rx_filter_save(lif, 0, IONIC_RXQ_INDEX_ANY, 0, &ctx); in ionic_lif_addr_add()
823 static int ionic_lif_addr_del(struct ionic_lif *lif, const u8 *addr) in ionic_lif_addr_del() argument
829 .lif_index = cpu_to_le16(lif->index), in ionic_lif_addr_del()
835 spin_lock_bh(&lif->rx_filters.lock); in ionic_lif_addr_del()
836 f = ionic_rx_filter_by_addr(lif, addr); in ionic_lif_addr_del()
838 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_addr_del()
843 ionic_rx_filter_free(lif, f); in ionic_lif_addr_del()
844 spin_unlock_bh(&lif->rx_filters.lock); in ionic_lif_addr_del()
846 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_addr_del()
850 netdev_dbg(lif->netdev, "rx_filter del ADDR %pM (id %d)\n", addr, in ionic_lif_addr_del()
856 static int ionic_lif_addr(struct ionic_lif *lif, const u8 *addr, bool add) in ionic_lif_addr() argument
858 struct ionic *ionic = lif->ionic; in ionic_lif_addr()
868 nmfilters = le32_to_cpu(ionic->ident.lif.eth.max_mcast_filters); in ionic_lif_addr()
869 nufilters = le32_to_cpu(ionic->ident.lif.eth.max_ucast_filters); in ionic_lif_addr()
871 if ((is_multicast_ether_addr(addr) && lif->nmcast < nmfilters)) in ionic_lif_addr()
872 lif->nmcast++; in ionic_lif_addr()
874 lif->nucast < nufilters) in ionic_lif_addr()
875 lif->nucast++; in ionic_lif_addr()
879 if (is_multicast_ether_addr(addr) && lif->nmcast) in ionic_lif_addr()
880 lif->nmcast--; in ionic_lif_addr()
881 else if (!is_multicast_ether_addr(addr) && lif->nucast) in ionic_lif_addr()
882 lif->nucast--; in ionic_lif_addr()
888 netdev_err(lif->netdev, "%s OOM\n", __func__); in ionic_lif_addr()
894 netdev_dbg(lif->netdev, "deferred: rx_filter %s %pM\n", in ionic_lif_addr()
896 ionic_lif_deferred_enqueue(&lif->deferred, work); in ionic_lif_addr()
898 netdev_dbg(lif->netdev, "rx_filter %s %pM\n", in ionic_lif_addr()
901 return ionic_lif_addr_add(lif, addr); in ionic_lif_addr()
903 return ionic_lif_addr_del(lif, addr); in ionic_lif_addr()
919 static void ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int rx_mode) in ionic_lif_rx_mode() argument
925 .lif_index = cpu_to_le16(lif->index), in ionic_lif_rx_mode()
935 lif->rx_mode, rx_mode); in ionic_lif_rx_mode()
946 netdev_dbg(lif->netdev, "lif%d %s\n", lif->index, buf); in ionic_lif_rx_mode()
948 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rx_mode()
950 netdev_warn(lif->netdev, "set rx_mode 0x%04x failed: %d\n", in ionic_lif_rx_mode()
953 lif->rx_mode = rx_mode; in ionic_lif_rx_mode()
956 static void _ionic_lif_rx_mode(struct ionic_lif *lif, unsigned int rx_mode) in _ionic_lif_rx_mode() argument
963 netdev_err(lif->netdev, "%s OOM\n", __func__); in _ionic_lif_rx_mode()
968 netdev_dbg(lif->netdev, "deferred: rx_mode\n"); in _ionic_lif_rx_mode()
969 ionic_lif_deferred_enqueue(&lif->deferred, work); in _ionic_lif_rx_mode()
971 ionic_lif_rx_mode(lif, rx_mode); in _ionic_lif_rx_mode()
977 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_rx_mode() local
982 ident = &lif->ionic->ident; in ionic_set_rx_mode()
998 nfilters = le32_to_cpu(ident->lif.eth.max_ucast_filters); in ionic_set_rx_mode()
1001 lif->uc_overflow = true; in ionic_set_rx_mode()
1002 } else if (lif->uc_overflow) { in ionic_set_rx_mode()
1003 lif->uc_overflow = false; in ionic_set_rx_mode()
1010 nfilters = le32_to_cpu(ident->lif.eth.max_mcast_filters); in ionic_set_rx_mode()
1013 lif->mc_overflow = true; in ionic_set_rx_mode()
1014 } else if (lif->mc_overflow) { in ionic_set_rx_mode()
1015 lif->mc_overflow = false; in ionic_set_rx_mode()
1020 if (lif->rx_mode != rx_mode) in ionic_set_rx_mode()
1021 _ionic_lif_rx_mode(lif, rx_mode); in ionic_set_rx_mode()
1064 static int ionic_set_nic_features(struct ionic_lif *lif, in ionic_set_nic_features() argument
1067 struct device *dev = lif->ionic->dev; in ionic_set_nic_features()
1072 .index = cpu_to_le16(lif->index), in ionic_set_nic_features()
1082 err = ionic_adminq_post_wait(lif, &ctx); in ionic_set_nic_features()
1086 lif->hw_features = le64_to_cpu(ctx.cmd.lif_setattr.features & in ionic_set_nic_features()
1091 dev_info_once(lif->ionic->dev, "NIC is not supporting vlan offload, likely in SmartNIC mode\n"); in ionic_set_nic_features()
1093 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_set_nic_features()
1095 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_set_nic_features()
1097 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_set_nic_features()
1099 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_set_nic_features()
1101 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_set_nic_features()
1103 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_set_nic_features()
1105 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_set_nic_features()
1107 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_set_nic_features()
1109 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_set_nic_features()
1111 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_set_nic_features()
1113 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_set_nic_features()
1115 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_set_nic_features()
1117 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_set_nic_features()
1119 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_set_nic_features()
1121 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_set_nic_features()
1123 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_set_nic_features()
1129 static int ionic_init_nic_features(struct ionic_lif *lif) in ionic_init_nic_features() argument
1131 struct net_device *netdev = lif->netdev; in ionic_init_nic_features()
1147 err = ionic_set_nic_features(lif, features); in ionic_init_nic_features()
1154 if (lif->hw_features & IONIC_ETH_HW_VLAN_TX_TAG) in ionic_init_nic_features()
1156 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_STRIP) in ionic_init_nic_features()
1158 if (lif->hw_features & IONIC_ETH_HW_VLAN_RX_FILTER) in ionic_init_nic_features()
1160 if (lif->hw_features & IONIC_ETH_HW_RX_HASH) in ionic_init_nic_features()
1162 if (lif->hw_features & IONIC_ETH_HW_TX_SG) in ionic_init_nic_features()
1165 if (lif->hw_features & IONIC_ETH_HW_TX_CSUM) in ionic_init_nic_features()
1167 if (lif->hw_features & IONIC_ETH_HW_RX_CSUM) in ionic_init_nic_features()
1169 if (lif->hw_features & IONIC_ETH_HW_TSO) in ionic_init_nic_features()
1171 if (lif->hw_features & IONIC_ETH_HW_TSO_IPV6) in ionic_init_nic_features()
1173 if (lif->hw_features & IONIC_ETH_HW_TSO_ECN) in ionic_init_nic_features()
1175 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE) in ionic_init_nic_features()
1177 if (lif->hw_features & IONIC_ETH_HW_TSO_GRE_CSUM) in ionic_init_nic_features()
1179 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP4) in ionic_init_nic_features()
1181 if (lif->hw_features & IONIC_ETH_HW_TSO_IPXIP6) in ionic_init_nic_features()
1183 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP) in ionic_init_nic_features()
1185 if (lif->hw_features & IONIC_ETH_HW_TSO_UDP_CSUM) in ionic_init_nic_features()
1199 struct ionic_lif *lif = netdev_priv(netdev); in ionic_set_features() local
1203 __func__, (u64)lif->netdev->features, (u64)features); in ionic_set_features()
1205 err = ionic_set_nic_features(lif, features); in ionic_set_features()
1238 struct ionic_lif *lif = netdev_priv(netdev); in ionic_change_mtu() local
1243 .index = cpu_to_le16(lif->index), in ionic_change_mtu()
1250 err = ionic_adminq_post_wait(lif, &ctx); in ionic_change_mtu()
1255 err = ionic_reset_queues(lif); in ionic_change_mtu()
1262 struct ionic_lif *lif = container_of(ws, struct ionic_lif, tx_timeout_work); in ionic_tx_timeout_work() local
1264 netdev_info(lif->netdev, "Tx Timeout recovery\n"); in ionic_tx_timeout_work()
1267 ionic_reset_queues(lif); in ionic_tx_timeout_work()
1273 struct ionic_lif *lif = netdev_priv(netdev); in ionic_tx_timeout() local
1275 schedule_work(&lif->tx_timeout_work); in ionic_tx_timeout()
1281 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_add_vid() local
1286 .lif_index = cpu_to_le16(lif->index), in ionic_vlan_rx_add_vid()
1293 err = ionic_adminq_post_wait(lif, &ctx); in ionic_vlan_rx_add_vid()
1300 return ionic_rx_filter_save(lif, 0, IONIC_RXQ_INDEX_ANY, 0, &ctx); in ionic_vlan_rx_add_vid()
1306 struct ionic_lif *lif = netdev_priv(netdev); in ionic_vlan_rx_kill_vid() local
1311 .lif_index = cpu_to_le16(lif->index), in ionic_vlan_rx_kill_vid()
1316 spin_lock_bh(&lif->rx_filters.lock); in ionic_vlan_rx_kill_vid()
1318 f = ionic_rx_filter_by_vlan(lif, vid); in ionic_vlan_rx_kill_vid()
1320 spin_unlock_bh(&lif->rx_filters.lock); in ionic_vlan_rx_kill_vid()
1328 ionic_rx_filter_free(lif, f); in ionic_vlan_rx_kill_vid()
1329 spin_unlock_bh(&lif->rx_filters.lock); in ionic_vlan_rx_kill_vid()
1331 return ionic_adminq_post_wait(lif, &ctx); in ionic_vlan_rx_kill_vid()
1334 int ionic_lif_rss_config(struct ionic_lif *lif, const u16 types, in ionic_lif_rss_config() argument
1343 .rss.addr = cpu_to_le64(lif->rss_ind_tbl_pa), in ionic_lif_rss_config()
1348 lif->rss_types = types; in ionic_lif_rss_config()
1351 memcpy(lif->rss_hash_key, key, IONIC_RSS_HASH_KEY_SIZE); in ionic_lif_rss_config()
1354 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_config()
1356 lif->rss_ind_tbl[i] = indir[i]; in ionic_lif_rss_config()
1359 memcpy(ctx.cmd.lif_setattr.rss.key, lif->rss_hash_key, in ionic_lif_rss_config()
1362 return ionic_adminq_post_wait(lif, &ctx); in ionic_lif_rss_config()
1365 static int ionic_lif_rss_init(struct ionic_lif *lif) in ionic_lif_rss_init() argument
1373 lif->rss_types = IONIC_RSS_TYPE_IPV4 | in ionic_lif_rss_init()
1381 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_rss_init()
1383 lif->rss_ind_tbl[i] = ethtool_rxfh_indir_default(i, lif->nxqs); in ionic_lif_rss_init()
1385 return ionic_lif_rss_config(lif, lif->rss_types, rss_key, NULL); in ionic_lif_rss_init()
1388 static int ionic_lif_rss_deinit(struct ionic_lif *lif) in ionic_lif_rss_deinit() argument
1390 return ionic_lif_rss_config(lif, 0x0, NULL, NULL); in ionic_lif_rss_deinit()
1393 static void ionic_txrx_disable(struct ionic_lif *lif) in ionic_txrx_disable() argument
1397 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_disable()
1398 ionic_qcq_disable(lif->txqcqs[i].qcq); in ionic_txrx_disable()
1399 ionic_qcq_disable(lif->rxqcqs[i].qcq); in ionic_txrx_disable()
1403 static void ionic_txrx_deinit(struct ionic_lif *lif) in ionic_txrx_deinit() argument
1407 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_deinit()
1408 ionic_lif_qcq_deinit(lif, lif->txqcqs[i].qcq); in ionic_txrx_deinit()
1409 ionic_tx_flush(&lif->txqcqs[i].qcq->cq); in ionic_txrx_deinit()
1411 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i].qcq); in ionic_txrx_deinit()
1412 ionic_rx_flush(&lif->rxqcqs[i].qcq->cq); in ionic_txrx_deinit()
1413 ionic_rx_empty(&lif->rxqcqs[i].qcq->q); in ionic_txrx_deinit()
1417 static void ionic_txrx_free(struct ionic_lif *lif) in ionic_txrx_free() argument
1421 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_free()
1422 ionic_qcq_free(lif, lif->txqcqs[i].qcq); in ionic_txrx_free()
1423 lif->txqcqs[i].qcq = NULL; in ionic_txrx_free()
1425 ionic_qcq_free(lif, lif->rxqcqs[i].qcq); in ionic_txrx_free()
1426 lif->rxqcqs[i].qcq = NULL; in ionic_txrx_free()
1430 static int ionic_txrx_alloc(struct ionic_lif *lif) in ionic_txrx_alloc() argument
1438 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
1439 err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, i, "tx", flags, in ionic_txrx_alloc()
1440 lif->ntxq_descs, in ionic_txrx_alloc()
1444 lif->kern_pid, &lif->txqcqs[i].qcq); in ionic_txrx_alloc()
1448 lif->txqcqs[i].qcq->stats = lif->txqcqs[i].stats; in ionic_txrx_alloc()
1452 coal = ionic_coal_usec_to_hw(lif->ionic, lif->rx_coalesce_usecs); in ionic_txrx_alloc()
1453 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_alloc()
1454 err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, i, "rx", flags, in ionic_txrx_alloc()
1455 lif->nrxq_descs, in ionic_txrx_alloc()
1458 0, lif->kern_pid, &lif->rxqcqs[i].qcq); in ionic_txrx_alloc()
1462 lif->rxqcqs[i].qcq->stats = lif->rxqcqs[i].stats; in ionic_txrx_alloc()
1464 ionic_intr_coal_init(lif->ionic->idev.intr_ctrl, in ionic_txrx_alloc()
1465 lif->rxqcqs[i].qcq->intr.index, coal); in ionic_txrx_alloc()
1466 ionic_link_qcq_interrupts(lif->rxqcqs[i].qcq, in ionic_txrx_alloc()
1467 lif->txqcqs[i].qcq); in ionic_txrx_alloc()
1473 ionic_txrx_free(lif); in ionic_txrx_alloc()
1478 static int ionic_txrx_init(struct ionic_lif *lif) in ionic_txrx_init() argument
1483 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_init()
1484 err = ionic_lif_txq_init(lif, lif->txqcqs[i].qcq); in ionic_txrx_init()
1488 err = ionic_lif_rxq_init(lif, lif->rxqcqs[i].qcq); in ionic_txrx_init()
1490 ionic_lif_qcq_deinit(lif, lif->txqcqs[i].qcq); in ionic_txrx_init()
1495 if (lif->netdev->features & NETIF_F_RXHASH) in ionic_txrx_init()
1496 ionic_lif_rss_init(lif); in ionic_txrx_init()
1498 ionic_set_rx_mode(lif->netdev); in ionic_txrx_init()
1504 ionic_lif_qcq_deinit(lif, lif->txqcqs[i].qcq); in ionic_txrx_init()
1505 ionic_lif_qcq_deinit(lif, lif->rxqcqs[i].qcq); in ionic_txrx_init()
1511 static int ionic_txrx_enable(struct ionic_lif *lif) in ionic_txrx_enable() argument
1515 for (i = 0; i < lif->nxqs; i++) { in ionic_txrx_enable()
1516 err = ionic_qcq_enable(lif->txqcqs[i].qcq); in ionic_txrx_enable()
1520 ionic_rx_fill(&lif->rxqcqs[i].qcq->q); in ionic_txrx_enable()
1521 err = ionic_qcq_enable(lif->rxqcqs[i].qcq); in ionic_txrx_enable()
1523 ionic_qcq_disable(lif->txqcqs[i].qcq); in ionic_txrx_enable()
1532 ionic_qcq_disable(lif->rxqcqs[i].qcq); in ionic_txrx_enable()
1533 ionic_qcq_disable(lif->txqcqs[i].qcq); in ionic_txrx_enable()
1541 struct ionic_lif *lif = netdev_priv(netdev); in ionic_open() local
1546 err = ionic_txrx_alloc(lif); in ionic_open()
1550 err = ionic_txrx_init(lif); in ionic_open()
1554 err = ionic_txrx_enable(lif); in ionic_open()
1558 netif_set_real_num_tx_queues(netdev, lif->nxqs); in ionic_open()
1559 netif_set_real_num_rx_queues(netdev, lif->nxqs); in ionic_open()
1561 set_bit(IONIC_LIF_UP, lif->state); in ionic_open()
1563 ionic_link_status_check_request(lif); in ionic_open()
1570 ionic_txrx_deinit(lif); in ionic_open()
1572 ionic_txrx_free(lif); in ionic_open()
1578 struct ionic_lif *lif = netdev_priv(netdev); in ionic_stop() local
1581 if (!test_bit(IONIC_LIF_UP, lif->state)) { in ionic_stop()
1582 dev_dbg(lif->ionic->dev, "%s: %s state=DOWN\n", in ionic_stop()
1583 __func__, lif->name); in ionic_stop()
1586 dev_dbg(lif->ionic->dev, "%s: %s state=UP\n", __func__, lif->name); in ionic_stop()
1587 clear_bit(IONIC_LIF_UP, lif->state); in ionic_stop()
1594 ionic_txrx_disable(lif); in ionic_stop()
1595 ionic_txrx_deinit(lif); in ionic_stop()
1596 ionic_txrx_free(lif); in ionic_stop()
1616 int ionic_reset_queues(struct ionic_lif *lif) in ionic_reset_queues() argument
1622 netif_trans_update(lif->netdev); in ionic_reset_queues()
1624 if (!ionic_wait_for_bit(lif, IONIC_LIF_QUEUE_RESET)) in ionic_reset_queues()
1627 running = netif_running(lif->netdev); in ionic_reset_queues()
1629 err = ionic_stop(lif->netdev); in ionic_reset_queues()
1631 ionic_open(lif->netdev); in ionic_reset_queues()
1633 clear_bit(IONIC_LIF_QUEUE_RESET, lif->state); in ionic_reset_queues()
1642 struct ionic_lif *lif; in ionic_lif_alloc() local
1647 netdev = alloc_etherdev_mqs(sizeof(*lif), in ionic_lif_alloc()
1656 lif = netdev_priv(netdev); in ionic_lif_alloc()
1657 lif->netdev = netdev; in ionic_lif_alloc()
1658 ionic->master_lif = lif; in ionic_lif_alloc()
1666 lif->neqs = ionic->neqs_per_lif; in ionic_lif_alloc()
1667 lif->nxqs = ionic->ntxqs_per_lif; in ionic_lif_alloc()
1669 lif->ionic = ionic; in ionic_lif_alloc()
1670 lif->index = index; in ionic_lif_alloc()
1671 lif->ntxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
1672 lif->nrxq_descs = IONIC_DEF_TXRX_DESC; in ionic_lif_alloc()
1675 coal = ionic_coal_usec_to_hw(lif->ionic, IONIC_ITR_COAL_USEC_DEFAULT); in ionic_lif_alloc()
1676 lif->rx_coalesce_usecs = ionic_coal_hw_to_usec(lif->ionic, coal); in ionic_lif_alloc()
1678 snprintf(lif->name, sizeof(lif->name), "lif%u", index); in ionic_lif_alloc()
1680 spin_lock_init(&lif->adminq_lock); in ionic_lif_alloc()
1682 spin_lock_init(&lif->deferred.lock); in ionic_lif_alloc()
1683 INIT_LIST_HEAD(&lif->deferred.list); in ionic_lif_alloc()
1684 INIT_WORK(&lif->deferred.work, ionic_lif_deferred_work); in ionic_lif_alloc()
1687 lif->info_sz = ALIGN(sizeof(*lif->info), PAGE_SIZE); in ionic_lif_alloc()
1688 lif->info = dma_alloc_coherent(dev, lif->info_sz, in ionic_lif_alloc()
1689 &lif->info_pa, GFP_KERNEL); in ionic_lif_alloc()
1690 if (!lif->info) { in ionic_lif_alloc()
1697 err = ionic_qcqs_alloc(lif); in ionic_lif_alloc()
1702 tbl_sz = le16_to_cpu(lif->ionic->ident.lif.eth.rss_ind_tbl_sz); in ionic_lif_alloc()
1703 lif->rss_ind_tbl_sz = sizeof(*lif->rss_ind_tbl) * tbl_sz; in ionic_lif_alloc()
1704 lif->rss_ind_tbl = dma_alloc_coherent(dev, lif->rss_ind_tbl_sz, in ionic_lif_alloc()
1705 &lif->rss_ind_tbl_pa, in ionic_lif_alloc()
1708 if (!lif->rss_ind_tbl) { in ionic_lif_alloc()
1714 list_add_tail(&lif->list, &ionic->lifs); in ionic_lif_alloc()
1716 return lif; in ionic_lif_alloc()
1719 ionic_qcqs_free(lif); in ionic_lif_alloc()
1721 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_alloc()
1722 lif->info = NULL; in ionic_lif_alloc()
1723 lif->info_pa = 0; in ionic_lif_alloc()
1725 free_netdev(lif->netdev); in ionic_lif_alloc()
1726 lif = NULL; in ionic_lif_alloc()
1733 struct ionic_lif *lif; in ionic_lifs_alloc() local
1739 lif = ionic_lif_alloc(ionic, 0); in ionic_lifs_alloc()
1741 return PTR_ERR_OR_ZERO(lif); in ionic_lifs_alloc()
1744 static void ionic_lif_reset(struct ionic_lif *lif) in ionic_lif_reset() argument
1746 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_reset()
1748 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
1749 ionic_dev_cmd_lif_reset(idev, lif->index); in ionic_lif_reset()
1750 ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_reset()
1751 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_reset()
1754 static void ionic_lif_free(struct ionic_lif *lif) in ionic_lif_free() argument
1756 struct device *dev = lif->ionic->dev; in ionic_lif_free()
1759 dma_free_coherent(dev, lif->rss_ind_tbl_sz, lif->rss_ind_tbl, in ionic_lif_free()
1760 lif->rss_ind_tbl_pa); in ionic_lif_free()
1761 lif->rss_ind_tbl = NULL; in ionic_lif_free()
1762 lif->rss_ind_tbl_pa = 0; in ionic_lif_free()
1765 ionic_qcqs_free(lif); in ionic_lif_free()
1766 ionic_lif_reset(lif); in ionic_lif_free()
1769 dma_free_coherent(dev, lif->info_sz, lif->info, lif->info_pa); in ionic_lif_free()
1770 lif->info = NULL; in ionic_lif_free()
1771 lif->info_pa = 0; in ionic_lif_free()
1774 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_free()
1775 lif->kern_dbpage = NULL; in ionic_lif_free()
1776 kfree(lif->dbid_inuse); in ionic_lif_free()
1777 lif->dbid_inuse = NULL; in ionic_lif_free()
1780 ionic_debugfs_del_lif(lif); in ionic_lif_free()
1781 list_del(&lif->list); in ionic_lif_free()
1782 free_netdev(lif->netdev); in ionic_lif_free()
1788 struct ionic_lif *lif; in ionic_lifs_free() local
1791 lif = list_entry(cur, struct ionic_lif, list); in ionic_lifs_free()
1793 ionic_lif_free(lif); in ionic_lifs_free()
1797 static void ionic_lif_deinit(struct ionic_lif *lif) in ionic_lif_deinit() argument
1799 if (!test_bit(IONIC_LIF_INITED, lif->state)) in ionic_lif_deinit()
1802 clear_bit(IONIC_LIF_INITED, lif->state); in ionic_lif_deinit()
1804 ionic_rx_filters_deinit(lif); in ionic_lif_deinit()
1805 ionic_lif_rss_deinit(lif); in ionic_lif_deinit()
1807 napi_disable(&lif->adminqcq->napi); in ionic_lif_deinit()
1808 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_deinit()
1809 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_deinit()
1811 ionic_lif_reset(lif); in ionic_lif_deinit()
1817 struct ionic_lif *lif; in ionic_lifs_deinit() local
1820 lif = list_entry(cur, struct ionic_lif, list); in ionic_lifs_deinit()
1821 ionic_lif_deinit(lif); in ionic_lifs_deinit()
1825 static int ionic_lif_adminq_init(struct ionic_lif *lif) in ionic_lif_adminq_init() argument
1827 struct device *dev = lif->ionic->dev; in ionic_lif_adminq_init()
1834 idev = &lif->ionic->idev; in ionic_lif_adminq_init()
1835 qcq = lif->adminqcq; in ionic_lif_adminq_init()
1838 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
1839 ionic_dev_cmd_adminq_init(idev, qcq, lif->index, qcq->intr.index); in ionic_lif_adminq_init()
1840 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_adminq_init()
1842 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_adminq_init()
1844 netdev_err(lif->netdev, "adminq init failed %d\n", err); in ionic_lif_adminq_init()
1855 netif_napi_add(lif->netdev, &qcq->napi, ionic_adminq_napi, in ionic_lif_adminq_init()
1858 err = ionic_request_irq(lif, qcq); in ionic_lif_adminq_init()
1860 netdev_warn(lif->netdev, "adminq irq request failed %d\n", err); in ionic_lif_adminq_init()
1873 ionic_debugfs_add_qcq(lif, qcq); in ionic_lif_adminq_init()
1878 static int ionic_lif_notifyq_init(struct ionic_lif *lif) in ionic_lif_notifyq_init() argument
1880 struct ionic_qcq *qcq = lif->notifyqcq; in ionic_lif_notifyq_init()
1881 struct device *dev = lif->ionic->dev; in ionic_lif_notifyq_init()
1889 .lif_index = cpu_to_le16(lif->index), in ionic_lif_notifyq_init()
1894 .intr_index = cpu_to_le16(lif->adminqcq->intr.index), in ionic_lif_notifyq_init()
1906 err = ionic_adminq_post_wait(lif, &ctx); in ionic_lif_notifyq_init()
1918 q->info[0].cb_arg = lif; in ionic_lif_notifyq_init()
1922 ionic_debugfs_add_qcq(lif, qcq); in ionic_lif_notifyq_init()
1927 static int ionic_station_set(struct ionic_lif *lif) in ionic_station_set() argument
1929 struct net_device *netdev = lif->netdev; in ionic_station_set()
1934 .index = cpu_to_le16(lif->index), in ionic_station_set()
1941 err = ionic_adminq_post_wait(lif, &ctx); in ionic_station_set()
1952 netdev_dbg(lif->netdev, "deleting station MAC addr %pM\n", in ionic_station_set()
1954 ionic_lif_addr(lif, netdev->dev_addr, false); in ionic_station_set()
1958 netdev_dbg(lif->netdev, "adding station MAC addr %pM\n", in ionic_station_set()
1960 ionic_lif_addr(lif, netdev->dev_addr, true); in ionic_station_set()
1965 static int ionic_lif_init(struct ionic_lif *lif) in ionic_lif_init() argument
1967 struct ionic_dev *idev = &lif->ionic->idev; in ionic_lif_init()
1968 struct device *dev = lif->ionic->dev; in ionic_lif_init()
1973 ionic_debugfs_add_lif(lif); in ionic_lif_init()
1975 mutex_lock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
1976 ionic_dev_cmd_lif_init(idev, lif->index, lif->info_pa); in ionic_lif_init()
1977 err = ionic_dev_cmd_wait(lif->ionic, DEVCMD_TIMEOUT); in ionic_lif_init()
1979 mutex_unlock(&lif->ionic->dev_cmd_lock); in ionic_lif_init()
1983 lif->hw_index = le16_to_cpu(comp.hw_index); in ionic_lif_init()
1986 lif->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif); in ionic_lif_init()
1987 if (!lif->dbid_count) { in ionic_lif_init()
1992 lif->dbid_inuse = bitmap_alloc(lif->dbid_count, GFP_KERNEL); in ionic_lif_init()
1993 if (!lif->dbid_inuse) { in ionic_lif_init()
1999 set_bit(0, lif->dbid_inuse); in ionic_lif_init()
2000 lif->kern_pid = 0; in ionic_lif_init()
2002 dbpage_num = ionic_db_page_num(lif, lif->kern_pid); in ionic_lif_init()
2003 lif->kern_dbpage = ionic_bus_map_dbpage(lif->ionic, dbpage_num); in ionic_lif_init()
2004 if (!lif->kern_dbpage) { in ionic_lif_init()
2010 err = ionic_lif_adminq_init(lif); in ionic_lif_init()
2014 if (lif->ionic->nnqs_per_lif) { in ionic_lif_init()
2015 err = ionic_lif_notifyq_init(lif); in ionic_lif_init()
2020 err = ionic_init_nic_features(lif); in ionic_lif_init()
2024 err = ionic_rx_filters_init(lif); in ionic_lif_init()
2028 err = ionic_station_set(lif); in ionic_lif_init()
2032 lif->rx_copybreak = IONIC_RX_COPYBREAK_DEFAULT; in ionic_lif_init()
2034 set_bit(IONIC_LIF_INITED, lif->state); in ionic_lif_init()
2036 INIT_WORK(&lif->tx_timeout_work, ionic_tx_timeout_work); in ionic_lif_init()
2041 ionic_lif_qcq_deinit(lif, lif->notifyqcq); in ionic_lif_init()
2043 ionic_lif_qcq_deinit(lif, lif->adminqcq); in ionic_lif_init()
2044 ionic_lif_reset(lif); in ionic_lif_init()
2045 ionic_bus_unmap_dbpage(lif->ionic, lif->kern_dbpage); in ionic_lif_init()
2046 lif->kern_dbpage = NULL; in ionic_lif_init()
2048 kfree(lif->dbid_inuse); in ionic_lif_init()
2049 lif->dbid_inuse = NULL; in ionic_lif_init()
2057 struct ionic_lif *lif; in ionic_lifs_init() local
2061 lif = list_entry(cur, struct ionic_lif, list); in ionic_lifs_init()
2062 err = ionic_lif_init(lif); in ionic_lifs_init()
2074 static void ionic_lif_set_netdev_info(struct ionic_lif *lif) in ionic_lif_set_netdev_info() argument
2080 .index = cpu_to_le16(lif->index), in ionic_lif_set_netdev_info()
2085 strlcpy(ctx.cmd.lif_setattr.name, lif->netdev->name, in ionic_lif_set_netdev_info()
2088 ionic_adminq_post_wait(lif, &ctx); in ionic_lif_set_netdev_info()
2104 struct ionic_lif *lif = ionic_netdev_lif(ndev); in ionic_lif_notify() local
2106 if (!lif || lif->ionic != ionic) in ionic_lif_notify()
2111 ionic_lif_set_netdev_info(lif); in ionic_lif_notify()
2216 lc = &ident->lif.eth.config; in ionic_lifs_size()
2218 neqs_per_lif = le32_to_cpu(ident->lif.rdma.eq_qtype.qid_count); in ionic_lifs_size()