Lines Matching refs:oct

47 static int octep_alloc_ioq_vectors(struct octep_device *oct)  in octep_alloc_ioq_vectors()  argument
52 for (i = 0; i < oct->num_oqs; i++) { in octep_alloc_ioq_vectors()
53 oct->ioq_vector[i] = vzalloc(sizeof(*oct->ioq_vector[i])); in octep_alloc_ioq_vectors()
54 if (!oct->ioq_vector[i]) in octep_alloc_ioq_vectors()
57 ioq_vector = oct->ioq_vector[i]; in octep_alloc_ioq_vectors()
58 ioq_vector->iq = oct->iq[i]; in octep_alloc_ioq_vectors()
59 ioq_vector->oq = oct->oq[i]; in octep_alloc_ioq_vectors()
60 ioq_vector->octep_dev = oct; in octep_alloc_ioq_vectors()
63 dev_info(&oct->pdev->dev, "Allocated %d IOQ vectors\n", oct->num_oqs); in octep_alloc_ioq_vectors()
69 vfree(oct->ioq_vector[i]); in octep_alloc_ioq_vectors()
70 oct->ioq_vector[i] = NULL; in octep_alloc_ioq_vectors()
80 static void octep_free_ioq_vectors(struct octep_device *oct) in octep_free_ioq_vectors() argument
84 for (i = 0; i < oct->num_oqs; i++) { in octep_free_ioq_vectors()
85 if (oct->ioq_vector[i]) { in octep_free_ioq_vectors()
86 vfree(oct->ioq_vector[i]); in octep_free_ioq_vectors()
87 oct->ioq_vector[i] = NULL; in octep_free_ioq_vectors()
90 netdev_info(oct->netdev, "Freed IOQ Vectors\n"); in octep_free_ioq_vectors()
104 static int octep_enable_msix_range(struct octep_device *oct) in octep_enable_msix_range() argument
110 num_msix = oct->num_oqs + CFG_GET_NON_IOQ_MSIX(oct->conf); in octep_enable_msix_range()
111 oct->msix_entries = kcalloc(num_msix, in octep_enable_msix_range()
113 if (!oct->msix_entries) in octep_enable_msix_range()
117 oct->msix_entries[i].entry = i; in octep_enable_msix_range()
119 msix_allocated = pci_enable_msix_range(oct->pdev, oct->msix_entries, in octep_enable_msix_range()
122 dev_err(&oct->pdev->dev, in octep_enable_msix_range()
127 oct->num_irqs = msix_allocated; in octep_enable_msix_range()
128 dev_info(&oct->pdev->dev, "MSI-X enabled successfully\n"); in octep_enable_msix_range()
134 pci_disable_msix(oct->pdev); in octep_enable_msix_range()
135 kfree(oct->msix_entries); in octep_enable_msix_range()
136 oct->msix_entries = NULL; in octep_enable_msix_range()
148 static void octep_disable_msix(struct octep_device *oct) in octep_disable_msix() argument
150 pci_disable_msix(oct->pdev); in octep_disable_msix()
151 kfree(oct->msix_entries); in octep_disable_msix()
152 oct->msix_entries = NULL; in octep_disable_msix()
153 dev_info(&oct->pdev->dev, "Disabled MSI-X\n"); in octep_disable_msix()
166 struct octep_device *oct = data; in octep_non_ioq_intr_handler() local
168 return oct->hw_ops.non_ioq_intr_handler(oct); in octep_non_ioq_intr_handler()
183 struct octep_device *oct = ioq_vector->octep_dev; in octep_ioq_intr_handler() local
185 return oct->hw_ops.ioq_intr_handler(ioq_vector); in octep_ioq_intr_handler()
198 static int octep_request_irqs(struct octep_device *oct) in octep_request_irqs() argument
200 struct net_device *netdev = oct->netdev; in octep_request_irqs()
207 num_non_ioq_msix = CFG_GET_NON_IOQ_MSIX(oct->conf); in octep_request_irqs()
208 non_ioq_msix_names = CFG_GET_NON_IOQ_MSIX_NAMES(oct->conf); in octep_request_irqs()
210 oct->non_ioq_irq_names = kcalloc(num_non_ioq_msix, in octep_request_irqs()
212 if (!oct->non_ioq_irq_names) in octep_request_irqs()
219 irq_name = &oct->non_ioq_irq_names[i * OCTEP_MSIX_NAME_SIZE]; in octep_request_irqs()
220 msix_entry = &oct->msix_entries[i]; in octep_request_irqs()
226 irq_name, oct); in octep_request_irqs()
236 for (j = 0; j < oct->num_oqs; j++) { in octep_request_irqs()
237 ioq_vector = oct->ioq_vector[j]; in octep_request_irqs()
238 msix_entry = &oct->msix_entries[j + num_non_ioq_msix]; in octep_request_irqs()
262 ioq_vector = oct->ioq_vector[j]; in octep_request_irqs()
263 msix_entry = &oct->msix_entries[j + num_non_ioq_msix]; in octep_request_irqs()
271 free_irq(oct->msix_entries[i].vector, oct); in octep_request_irqs()
273 kfree(oct->non_ioq_irq_names); in octep_request_irqs()
274 oct->non_ioq_irq_names = NULL; in octep_request_irqs()
286 static void octep_free_irqs(struct octep_device *oct) in octep_free_irqs() argument
291 for (i = 0; i < CFG_GET_NON_IOQ_MSIX(oct->conf); i++) in octep_free_irqs()
292 free_irq(oct->msix_entries[i].vector, oct); in octep_free_irqs()
293 kfree(oct->non_ioq_irq_names); in octep_free_irqs()
296 for (i = CFG_GET_NON_IOQ_MSIX(oct->conf); i < oct->num_irqs; i++) { in octep_free_irqs()
297 irq_set_affinity_hint(oct->msix_entries[i].vector, NULL); in octep_free_irqs()
298 free_irq(oct->msix_entries[i].vector, in octep_free_irqs()
299 oct->ioq_vector[i - CFG_GET_NON_IOQ_MSIX(oct->conf)]); in octep_free_irqs()
301 netdev_info(oct->netdev, "IRQs freed\n"); in octep_free_irqs()
315 static int octep_setup_irqs(struct octep_device *oct) in octep_setup_irqs() argument
317 if (octep_alloc_ioq_vectors(oct)) in octep_setup_irqs()
320 if (octep_enable_msix_range(oct)) in octep_setup_irqs()
323 if (octep_request_irqs(oct)) in octep_setup_irqs()
329 octep_disable_msix(oct); in octep_setup_irqs()
331 octep_free_ioq_vectors(oct); in octep_setup_irqs()
341 static void octep_clean_irqs(struct octep_device *oct) in octep_clean_irqs() argument
343 octep_free_irqs(oct); in octep_clean_irqs()
344 octep_disable_msix(oct); in octep_clean_irqs()
345 octep_free_ioq_vectors(oct); in octep_clean_irqs()
406 static void octep_napi_add(struct octep_device *oct) in octep_napi_add() argument
410 for (i = 0; i < oct->num_oqs; i++) { in octep_napi_add()
411 netdev_dbg(oct->netdev, "Adding NAPI on Q-%d\n", i); in octep_napi_add()
412 netif_napi_add(oct->netdev, &oct->ioq_vector[i]->napi, in octep_napi_add()
414 oct->oq[i]->napi = &oct->ioq_vector[i]->napi; in octep_napi_add()
423 static void octep_napi_delete(struct octep_device *oct) in octep_napi_delete() argument
427 for (i = 0; i < oct->num_oqs; i++) { in octep_napi_delete()
428 netdev_dbg(oct->netdev, "Deleting NAPI on Q-%d\n", i); in octep_napi_delete()
429 netif_napi_del(&oct->ioq_vector[i]->napi); in octep_napi_delete()
430 oct->oq[i]->napi = NULL; in octep_napi_delete()
439 static void octep_napi_enable(struct octep_device *oct) in octep_napi_enable() argument
443 for (i = 0; i < oct->num_oqs; i++) { in octep_napi_enable()
444 netdev_dbg(oct->netdev, "Enabling NAPI on Q-%d\n", i); in octep_napi_enable()
445 napi_enable(&oct->ioq_vector[i]->napi); in octep_napi_enable()
454 static void octep_napi_disable(struct octep_device *oct) in octep_napi_disable() argument
458 for (i = 0; i < oct->num_oqs; i++) { in octep_napi_disable()
459 netdev_dbg(oct->netdev, "Disabling NAPI on Q-%d\n", i); in octep_napi_disable()
460 napi_disable(&oct->ioq_vector[i]->napi); in octep_napi_disable()
483 struct octep_device *oct = netdev_priv(netdev); in octep_open() local
489 oct->hw_ops.reset_io_queues(oct); in octep_open()
491 if (octep_setup_iqs(oct)) in octep_open()
493 if (octep_setup_oqs(oct)) in octep_open()
495 if (octep_setup_irqs(oct)) in octep_open()
498 err = netif_set_real_num_tx_queues(netdev, oct->num_oqs); in octep_open()
501 err = netif_set_real_num_rx_queues(netdev, oct->num_iqs); in octep_open()
505 octep_napi_add(oct); in octep_open()
506 octep_napi_enable(oct); in octep_open()
508 oct->link_info.admin_up = 1; in octep_open()
509 octep_set_rx_state(oct, true); in octep_open()
511 ret = octep_get_link_status(oct); in octep_open()
513 octep_set_link_status(oct, true); in octep_open()
516 oct->hw_ops.enable_io_queues(oct); in octep_open()
519 oct->hw_ops.enable_interrupts(oct); in octep_open()
521 octep_oq_dbell_init(oct); in octep_open()
523 ret = octep_get_link_status(oct); in octep_open()
530 octep_clean_irqs(oct); in octep_open()
532 octep_free_oqs(oct); in octep_open()
534 octep_free_iqs(oct); in octep_open()
549 struct octep_device *oct = netdev_priv(netdev); in octep_stop() local
558 octep_set_link_status(oct, false); in octep_stop()
559 octep_set_rx_state(oct, false); in octep_stop()
561 oct->link_info.admin_up = 0; in octep_stop()
562 oct->link_info.oper_up = 0; in octep_stop()
564 oct->hw_ops.disable_interrupts(oct); in octep_stop()
565 octep_napi_disable(oct); in octep_stop()
566 octep_napi_delete(oct); in octep_stop()
568 octep_clean_irqs(oct); in octep_stop()
569 octep_clean_iqs(oct); in octep_stop()
571 oct->hw_ops.disable_io_queues(oct); in octep_stop()
572 oct->hw_ops.reset_io_queues(oct); in octep_stop()
573 octep_free_oqs(oct); in octep_stop()
574 octep_free_iqs(oct); in octep_stop()
621 struct octep_device *oct = netdev_priv(netdev); in octep_start_xmit() local
633 if (q_no >= oct->num_iqs) { in octep_start_xmit()
635 q_no = q_no % oct->num_iqs; in octep_start_xmit()
638 iq = oct->iq[q_no]; in octep_start_xmit()
656 ih->pkind = oct->pkind; in octep_start_xmit()
754 struct octep_device *oct = netdev_priv(netdev); in octep_get_stats64() local
757 octep_get_if_stats(oct); in octep_get_stats64()
762 for (q = 0; q < oct->num_oqs; q++) { in octep_get_stats64()
763 struct octep_iq *iq = oct->iq[q]; in octep_get_stats64()
764 struct octep_oq *oq = oct->oq[q]; in octep_get_stats64()
775 stats->multicast = oct->iface_rx_stats.mcast_pkts; in octep_get_stats64()
776 stats->rx_errors = oct->iface_rx_stats.err_pkts; in octep_get_stats64()
777 stats->collisions = oct->iface_tx_stats.xscol; in octep_get_stats64()
778 stats->tx_fifo_errors = oct->iface_tx_stats.undflw; in octep_get_stats64()
792 struct octep_device *oct = container_of(work, struct octep_device, in octep_tx_timeout_task() local
794 struct net_device *netdev = oct->netdev; in octep_tx_timeout_task()
814 struct octep_device *oct = netdev_priv(netdev); in octep_tx_timeout() local
816 queue_work(octep_wq, &oct->tx_timeout_task); in octep_tx_timeout()
821 struct octep_device *oct = netdev_priv(netdev); in octep_set_mac() local
828 err = octep_set_mac_addr(oct, addr->sa_data); in octep_set_mac()
832 memcpy(oct->mac_addr, addr->sa_data, ETH_ALEN); in octep_set_mac()
840 struct octep_device *oct = netdev_priv(netdev); in octep_change_mtu() local
844 link_info = &oct->link_info; in octep_change_mtu()
848 err = octep_set_mtu(oct, new_mtu); in octep_change_mtu()
850 oct->link_info.mtu = new_mtu; in octep_change_mtu()
876 struct octep_device *oct = container_of(work, struct octep_device, in octep_ctrl_mbox_task() local
878 struct net_device *netdev = oct->netdev; in octep_ctrl_mbox_task()
885 ret = octep_ctrl_mbox_recv(&oct->ctrl_mbox, &msg); in octep_ctrl_mbox_task()
893 dev_info(&oct->pdev->dev, "netif_carrier_on\n"); in octep_ctrl_mbox_task()
896 dev_info(&oct->pdev->dev, "netif_carrier_off\n"); in octep_ctrl_mbox_task()
915 int octep_device_setup(struct octep_device *oct) in octep_device_setup() argument
918 struct pci_dev *pdev = oct->pdev; in octep_device_setup()
922 oct->conf = kzalloc(sizeof(*oct->conf), GFP_KERNEL); in octep_device_setup()
923 if (!oct->conf) in octep_device_setup()
928 oct->mmio[i].hw_addr = in octep_device_setup()
929 ioremap(pci_resource_start(oct->pdev, i * 2), in octep_device_setup()
930 pci_resource_len(oct->pdev, i * 2)); in octep_device_setup()
931 oct->mmio[i].mapped = 1; in octep_device_setup()
934 oct->chip_id = pdev->device; in octep_device_setup()
935 oct->rev_id = pdev->revision; in octep_device_setup()
938 switch (oct->chip_id) { in octep_device_setup()
942 OCTEP_MAJOR_REV(oct), OCTEP_MINOR_REV(oct)); in octep_device_setup()
943 octep_device_setup_cn93_pf(oct); in octep_device_setup()
951 oct->pkind = CFG_GET_IQ_PKIND(oct->conf); in octep_device_setup()
954 ctrl_mbox = &oct->ctrl_mbox; in octep_device_setup()
955 ctrl_mbox->barmem = CFG_GET_CTRL_MBOX_MEM_ADDR(oct->conf); in octep_device_setup()
961 oct->ctrl_mbox_ifstats_offset = OCTEP_CTRL_MBOX_SZ(ctrl_mbox->h2fq.elem_sz, in octep_device_setup()
970 iounmap(oct->mmio[i].hw_addr); in octep_device_setup()
972 kfree(oct->conf); in octep_device_setup()
983 static void octep_device_cleanup(struct octep_device *oct) in octep_device_cleanup() argument
987 dev_info(&oct->pdev->dev, "Cleaning up Octeon Device ...\n"); in octep_device_cleanup()
990 vfree(oct->mbox[i]); in octep_device_cleanup()
991 oct->mbox[i] = NULL; in octep_device_cleanup()
994 octep_ctrl_mbox_uninit(&oct->ctrl_mbox); in octep_device_cleanup()
996 oct->hw_ops.soft_reset(oct); in octep_device_cleanup()
998 if (oct->mmio[i].mapped) in octep_device_cleanup()
999 iounmap(oct->mmio[i].hw_addr); in octep_device_cleanup()
1002 kfree(oct->conf); in octep_device_cleanup()
1003 oct->conf = NULL; in octep_device_cleanup()
1113 struct octep_device *oct = pci_get_drvdata(pdev); in octep_remove() local
1116 if (!oct) in octep_remove()
1119 cancel_work_sync(&oct->tx_timeout_task); in octep_remove()
1120 cancel_work_sync(&oct->ctrl_mbox_task); in octep_remove()
1121 netdev = oct->netdev; in octep_remove()
1125 octep_device_cleanup(oct); in octep_remove()