Lines Matching refs:cdev
258 static void qed_free_pci(struct qed_dev *cdev) in qed_free_pci() argument
260 struct pci_dev *pdev = cdev->pdev; in qed_free_pci()
264 if (cdev->doorbells && cdev->db_size) in qed_free_pci()
265 iounmap(cdev->doorbells); in qed_free_pci()
266 if (cdev->regview) in qed_free_pci()
267 iounmap(cdev->regview); in qed_free_pci()
279 static int qed_init_pci(struct qed_dev *cdev, struct pci_dev *pdev) in qed_init_pci() argument
284 cdev->pdev = pdev; in qed_init_pci()
288 DP_NOTICE(cdev, "Cannot enable PCI device\n"); in qed_init_pci()
293 DP_NOTICE(cdev, "No memory region found in bar #0\n"); in qed_init_pci()
298 if (IS_PF(cdev) && !(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { in qed_init_pci()
299 DP_NOTICE(cdev, "No memory region found in bar #2\n"); in qed_init_pci()
307 DP_NOTICE(cdev, in qed_init_pci()
317 DP_NOTICE(cdev, in qed_init_pci()
324 DP_NOTICE(cdev, "The bus is not PCI Express\n"); in qed_init_pci()
329 cdev->pci_params.pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); in qed_init_pci()
330 if (IS_PF(cdev) && !cdev->pci_params.pm_cap) in qed_init_pci()
331 DP_NOTICE(cdev, "Cannot find power management capability\n"); in qed_init_pci()
333 rc = dma_set_mask_and_coherent(&cdev->pdev->dev, DMA_BIT_MASK(64)); in qed_init_pci()
335 DP_NOTICE(cdev, "Can't request DMA addresses\n"); in qed_init_pci()
340 cdev->pci_params.mem_start = pci_resource_start(pdev, 0); in qed_init_pci()
341 cdev->pci_params.mem_end = pci_resource_end(pdev, 0); in qed_init_pci()
342 cdev->pci_params.irq = pdev->irq; in qed_init_pci()
344 cdev->regview = pci_ioremap_bar(pdev, 0); in qed_init_pci()
345 if (!cdev->regview) { in qed_init_pci()
346 DP_NOTICE(cdev, "Cannot map register space, aborting\n"); in qed_init_pci()
351 cdev->db_phys_addr = pci_resource_start(cdev->pdev, 2); in qed_init_pci()
352 cdev->db_size = pci_resource_len(cdev->pdev, 2); in qed_init_pci()
353 if (!cdev->db_size) { in qed_init_pci()
354 if (IS_PF(cdev)) { in qed_init_pci()
355 DP_NOTICE(cdev, "No Doorbell bar available\n"); in qed_init_pci()
362 cdev->doorbells = ioremap_wc(cdev->db_phys_addr, cdev->db_size); in qed_init_pci()
364 if (!cdev->doorbells) { in qed_init_pci()
365 DP_NOTICE(cdev, "Cannot map doorbell space\n"); in qed_init_pci()
372 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_init_pci()
385 int qed_fill_dev_info(struct qed_dev *cdev, in qed_fill_dev_info() argument
388 struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); in qed_fill_dev_info()
390 struct qed_tunnel_info *tun = &cdev->tunnel; in qed_fill_dev_info()
409 dev_info->num_hwfns = cdev->num_hwfns; in qed_fill_dev_info()
410 dev_info->pci_mem_start = cdev->pci_params.mem_start; in qed_fill_dev_info()
411 dev_info->pci_mem_end = cdev->pci_params.mem_end; in qed_fill_dev_info()
412 dev_info->pci_irq = cdev->pci_params.irq; in qed_fill_dev_info()
414 dev_info->dev_type = cdev->type; in qed_fill_dev_info()
417 if (IS_PF(cdev)) { in qed_fill_dev_info()
423 &cdev->mf_bits); in qed_fill_dev_info()
424 if (!test_bit(QED_MF_DISABLE_ARFS, &cdev->mf_bits)) in qed_fill_dev_info()
433 dev_info->abs_pf_id = QED_LEADING_HWFN(cdev)->abs_pf_id; in qed_fill_dev_info()
435 qed_vf_get_fw_version(&cdev->hwfns[0], &dev_info->fw_major, in qed_fill_dev_info()
440 if (IS_PF(cdev)) { in qed_fill_dev_info()
441 ptt = qed_ptt_acquire(QED_LEADING_HWFN(cdev)); in qed_fill_dev_info()
443 qed_mcp_get_mfw_ver(QED_LEADING_HWFN(cdev), ptt, in qed_fill_dev_info()
446 qed_mcp_get_mbi_ver(QED_LEADING_HWFN(cdev), ptt, in qed_fill_dev_info()
449 qed_mcp_get_flash_size(QED_LEADING_HWFN(cdev), ptt, in qed_fill_dev_info()
452 qed_ptt_release(QED_LEADING_HWFN(cdev), ptt); in qed_fill_dev_info()
455 qed_mcp_get_mfw_ver(QED_LEADING_HWFN(cdev), NULL, in qed_fill_dev_info()
460 cdev->common_dev_info = *dev_info; in qed_fill_dev_info()
465 static void qed_free_cdev(struct qed_dev *cdev) in qed_free_cdev() argument
467 kfree((void *)cdev); in qed_free_cdev()
472 struct qed_dev *cdev; in qed_alloc_cdev() local
474 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); in qed_alloc_cdev()
475 if (!cdev) in qed_alloc_cdev()
476 return cdev; in qed_alloc_cdev()
478 qed_init_struct(cdev); in qed_alloc_cdev()
480 return cdev; in qed_alloc_cdev()
484 static int qed_set_power_state(struct qed_dev *cdev, pci_power_t state) in qed_set_power_state() argument
486 if (!cdev) in qed_set_power_state()
489 DP_VERBOSE(cdev, NETIF_MSG_DRV, "Omitting Power state change\n"); in qed_set_power_state()
497 struct qed_dev *cdev; in qed_probe() local
500 cdev = qed_alloc_cdev(pdev); in qed_probe()
501 if (!cdev) in qed_probe()
504 cdev->drv_type = DRV_ID_DRV_TYPE_LINUX; in qed_probe()
505 cdev->protocol = params->protocol; in qed_probe()
508 cdev->b_is_vf = true; in qed_probe()
510 qed_init_dp(cdev, params->dp_module, params->dp_level); in qed_probe()
512 cdev->recov_in_prog = params->recov_in_prog; in qed_probe()
514 rc = qed_init_pci(cdev, pdev); in qed_probe()
516 DP_ERR(cdev, "init pci failed\n"); in qed_probe()
519 DP_INFO(cdev, "PCI init completed successfully\n"); in qed_probe()
521 rc = qed_hw_prepare(cdev, QED_PCI_DEFAULT); in qed_probe()
523 DP_ERR(cdev, "hw prepare failed\n"); in qed_probe()
527 DP_INFO(cdev, "%s completed successfully\n", __func__); in qed_probe()
529 return cdev; in qed_probe()
532 qed_free_pci(cdev); in qed_probe()
534 qed_free_cdev(cdev); in qed_probe()
539 static void qed_remove(struct qed_dev *cdev) in qed_remove() argument
541 if (!cdev) in qed_remove()
544 qed_hw_remove(cdev); in qed_remove()
546 qed_free_pci(cdev); in qed_remove()
548 qed_set_power_state(cdev, PCI_D3hot); in qed_remove()
550 qed_free_cdev(cdev); in qed_remove()
553 static void qed_disable_msix(struct qed_dev *cdev) in qed_disable_msix() argument
555 if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { in qed_disable_msix()
556 pci_disable_msix(cdev->pdev); in qed_disable_msix()
557 kfree(cdev->int_params.msix_table); in qed_disable_msix()
558 } else if (cdev->int_params.out.int_mode == QED_INT_MODE_MSI) { in qed_disable_msix()
559 pci_disable_msi(cdev->pdev); in qed_disable_msix()
562 memset(&cdev->int_params.out, 0, sizeof(struct qed_int_param)); in qed_disable_msix()
565 static int qed_enable_msix(struct qed_dev *cdev, in qed_enable_msix() argument
575 rc = pci_enable_msix_range(cdev->pdev, int_params->msix_table, in qed_enable_msix()
578 (rc % cdev->num_hwfns)) { in qed_enable_msix()
579 pci_disable_msix(cdev->pdev); in qed_enable_msix()
585 cnt = (rc / cdev->num_hwfns) * cdev->num_hwfns; in qed_enable_msix()
586 DP_NOTICE(cdev, in qed_enable_msix()
589 rc = pci_enable_msix_exact(cdev->pdev, int_params->msix_table, in qed_enable_msix()
600 if ((IS_PF(cdev) && rc > 0) || (IS_VF(cdev) && rc == cnt)) { in qed_enable_msix()
606 DP_NOTICE(cdev, in qed_enable_msix()
615 static int qed_set_int_mode(struct qed_dev *cdev, bool force_mode) in qed_set_int_mode() argument
617 struct qed_int_params *int_params = &cdev->int_params; in qed_set_int_mode()
632 rc = qed_enable_msix(cdev, int_params); in qed_set_int_mode()
636 DP_NOTICE(cdev, "Failed to enable MSI-X\n"); in qed_set_int_mode()
643 if (cdev->num_hwfns == 1) { in qed_set_int_mode()
644 rc = pci_enable_msi(cdev->pdev); in qed_set_int_mode()
650 DP_NOTICE(cdev, "Failed to enable MSI\n"); in qed_set_int_mode()
661 DP_NOTICE(cdev, "Unknown int_mode value %d\n", in qed_set_int_mode()
668 DP_INFO(cdev, "Using %s interrupts\n", in qed_set_int_mode()
672 cdev->int_coalescing_mode = QED_COAL_MODE_ENABLE; in qed_set_int_mode()
677 static void qed_simd_handler_config(struct qed_dev *cdev, void *token, in qed_simd_handler_config() argument
680 struct qed_hwfn *hwfn = &cdev->hwfns[index % cdev->num_hwfns]; in qed_simd_handler_config()
681 int relative_idx = index / cdev->num_hwfns; in qed_simd_handler_config()
687 static void qed_simd_handler_clean(struct qed_dev *cdev, int index) in qed_simd_handler_clean() argument
689 struct qed_hwfn *hwfn = &cdev->hwfns[index % cdev->num_hwfns]; in qed_simd_handler_clean()
690 int relative_idx = index / cdev->num_hwfns; in qed_simd_handler_clean()
704 struct qed_dev *cdev = (struct qed_dev *)dev_instance; in qed_single_int() local
710 for (i = 0; i < cdev->num_hwfns; i++) { in qed_single_int()
711 status = qed_int_igu_read_sisr_reg(&cdev->hwfns[i]); in qed_single_int()
716 hwfn = &cdev->hwfns[i]; in qed_single_int()
754 struct qed_dev *cdev = hwfn->cdev; in qed_slowpath_irq_req() local
759 int_mode = cdev->int_params.out.int_mode; in qed_slowpath_irq_req()
763 id, cdev->pdev->bus->number, in qed_slowpath_irq_req()
764 PCI_SLOT(cdev->pdev->devfn), hwfn->abs_pf_id); in qed_slowpath_irq_req()
765 rc = request_irq(cdev->int_params.msix_table[id].vector, in qed_slowpath_irq_req()
770 snprintf(cdev->name, NAME_SIZE, "%02x:%02x.%02x", in qed_slowpath_irq_req()
771 cdev->pdev->bus->number, PCI_SLOT(cdev->pdev->devfn), in qed_slowpath_irq_req()
772 PCI_FUNC(cdev->pdev->devfn)); in qed_slowpath_irq_req()
774 if (cdev->int_params.out.int_mode == QED_INT_MODE_INTA) in qed_slowpath_irq_req()
777 rc = request_irq(cdev->pdev->irq, qed_single_int, in qed_slowpath_irq_req()
778 flags, cdev->name, cdev); in qed_slowpath_irq_req()
782 DP_NOTICE(cdev, "request_irq failed, rc = %d\n", rc); in qed_slowpath_irq_req()
805 struct qed_dev *cdev = p_hwfn->cdev; in qed_slowpath_irq_sync() local
809 int_mode = cdev->int_params.out.int_mode; in qed_slowpath_irq_sync()
811 synchronize_irq(cdev->int_params.msix_table[id].vector); in qed_slowpath_irq_sync()
813 synchronize_irq(cdev->pdev->irq); in qed_slowpath_irq_sync()
818 static void qed_slowpath_irq_free(struct qed_dev *cdev) in qed_slowpath_irq_free() argument
822 if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { in qed_slowpath_irq_free()
823 for_each_hwfn(cdev, i) { in qed_slowpath_irq_free()
824 if (!cdev->hwfns[i].b_int_requested) in qed_slowpath_irq_free()
826 free_irq(cdev->int_params.msix_table[i].vector, in qed_slowpath_irq_free()
827 &cdev->hwfns[i].sp_dpc); in qed_slowpath_irq_free()
830 if (QED_LEADING_HWFN(cdev)->b_int_requested) in qed_slowpath_irq_free()
831 free_irq(cdev->pdev->irq, cdev); in qed_slowpath_irq_free()
833 qed_int_disable_post_isr_release(cdev); in qed_slowpath_irq_free()
836 static int qed_nic_stop(struct qed_dev *cdev) in qed_nic_stop() argument
840 rc = qed_hw_stop(cdev); in qed_nic_stop()
842 for (i = 0; i < cdev->num_hwfns; i++) { in qed_nic_stop()
843 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_nic_stop()
848 DP_VERBOSE(cdev, NETIF_MSG_IFDOWN, in qed_nic_stop()
854 qed_dbg_pf_exit(cdev); in qed_nic_stop()
859 static int qed_nic_setup(struct qed_dev *cdev) in qed_nic_setup() argument
864 if (QED_LEADING_HWFN(cdev)->hw_info.personality != QED_PCI_ETH) { in qed_nic_setup()
865 for (i = 0; i < cdev->num_hwfns; i++) { in qed_nic_setup()
866 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_nic_setup()
872 rc = qed_resc_alloc(cdev); in qed_nic_setup()
876 DP_INFO(cdev, "Allocated qed resources\n"); in qed_nic_setup()
878 qed_resc_setup(cdev); in qed_nic_setup()
883 static int qed_set_int_fp(struct qed_dev *cdev, u16 cnt) in qed_set_int_fp() argument
888 cdev->int_params.fp_initialized = cnt ? true : false; in qed_set_int_fp()
890 if (cdev->int_params.out.int_mode != QED_INT_MODE_MSIX) in qed_set_int_fp()
891 limit = cdev->num_hwfns * 63; in qed_set_int_fp()
892 else if (cdev->int_params.fp_msix_cnt) in qed_set_int_fp()
893 limit = cdev->int_params.fp_msix_cnt; in qed_set_int_fp()
901 static int qed_get_int_fp(struct qed_dev *cdev, struct qed_int_info *info) in qed_get_int_fp() argument
905 if (!cdev->int_params.fp_initialized) { in qed_get_int_fp()
906 DP_INFO(cdev, in qed_get_int_fp()
914 if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { in qed_get_int_fp()
915 int msix_base = cdev->int_params.fp_msix_base; in qed_get_int_fp()
917 info->msix_cnt = cdev->int_params.fp_msix_cnt; in qed_get_int_fp()
918 info->msix = &cdev->int_params.msix_table[msix_base]; in qed_get_int_fp()
924 static int qed_slowpath_setup_int(struct qed_dev *cdev, in qed_slowpath_setup_int() argument
932 if ((int_mode == QED_INT_MODE_MSI) && (cdev->num_hwfns > 1)) { in qed_slowpath_setup_int()
933 DP_NOTICE(cdev, "MSI mode is not supported for CMT devices\n"); in qed_slowpath_setup_int()
937 memset(&cdev->int_params, 0, sizeof(struct qed_int_params)); in qed_slowpath_setup_int()
938 cdev->int_params.in.int_mode = int_mode; in qed_slowpath_setup_int()
939 for_each_hwfn(cdev, i) { in qed_slowpath_setup_int()
941 qed_int_get_num_sbs(&cdev->hwfns[i], &sb_cnt_info); in qed_slowpath_setup_int()
942 cdev->int_params.in.num_vectors += sb_cnt_info.cnt; in qed_slowpath_setup_int()
943 cdev->int_params.in.num_vectors++; /* slowpath */ in qed_slowpath_setup_int()
947 cdev->int_params.in.min_msix_cnt = cdev->num_hwfns * 2; in qed_slowpath_setup_int()
950 DP_INFO(cdev, in qed_slowpath_setup_int()
952 cdev->int_params.in.min_msix_cnt); in qed_slowpath_setup_int()
953 cdev->int_params.in.num_vectors = in qed_slowpath_setup_int()
954 cdev->int_params.in.min_msix_cnt; in qed_slowpath_setup_int()
957 rc = qed_set_int_mode(cdev, false); in qed_slowpath_setup_int()
959 DP_ERR(cdev, "%s ERR\n", __func__); in qed_slowpath_setup_int()
963 cdev->int_params.fp_msix_base = cdev->num_hwfns; in qed_slowpath_setup_int()
964 cdev->int_params.fp_msix_cnt = cdev->int_params.out.num_vectors - in qed_slowpath_setup_int()
965 cdev->num_hwfns; in qed_slowpath_setup_int()
968 !QED_IS_RDMA_PERSONALITY(QED_LEADING_HWFN(cdev))) in qed_slowpath_setup_int()
971 for_each_hwfn(cdev, i) in qed_slowpath_setup_int()
972 num_l2_queues += FEAT_NUM(&cdev->hwfns[i], QED_PF_L2_QUE); in qed_slowpath_setup_int()
974 DP_VERBOSE(cdev, QED_MSG_RDMA, in qed_slowpath_setup_int()
976 cdev->int_params.fp_msix_cnt, num_l2_queues); in qed_slowpath_setup_int()
978 if (cdev->int_params.fp_msix_cnt > num_l2_queues) { in qed_slowpath_setup_int()
979 cdev->int_params.rdma_msix_cnt = in qed_slowpath_setup_int()
980 (cdev->int_params.fp_msix_cnt - num_l2_queues) in qed_slowpath_setup_int()
981 / cdev->num_hwfns; in qed_slowpath_setup_int()
982 cdev->int_params.rdma_msix_base = in qed_slowpath_setup_int()
983 cdev->int_params.fp_msix_base + num_l2_queues; in qed_slowpath_setup_int()
984 cdev->int_params.fp_msix_cnt = num_l2_queues; in qed_slowpath_setup_int()
986 cdev->int_params.rdma_msix_cnt = 0; in qed_slowpath_setup_int()
989 DP_VERBOSE(cdev, QED_MSG_RDMA, "roce_msix_cnt=%d roce_msix_base=%d\n", in qed_slowpath_setup_int()
990 cdev->int_params.rdma_msix_cnt, in qed_slowpath_setup_int()
991 cdev->int_params.rdma_msix_base); in qed_slowpath_setup_int()
996 static int qed_slowpath_vf_setup_int(struct qed_dev *cdev) in qed_slowpath_vf_setup_int() argument
1000 memset(&cdev->int_params, 0, sizeof(struct qed_int_params)); in qed_slowpath_vf_setup_int()
1001 cdev->int_params.in.int_mode = QED_INT_MODE_MSIX; in qed_slowpath_vf_setup_int()
1003 qed_vf_get_num_rxqs(QED_LEADING_HWFN(cdev), in qed_slowpath_vf_setup_int()
1004 &cdev->int_params.in.num_vectors); in qed_slowpath_vf_setup_int()
1005 if (cdev->num_hwfns > 1) { in qed_slowpath_vf_setup_int()
1008 qed_vf_get_num_rxqs(&cdev->hwfns[1], &vectors); in qed_slowpath_vf_setup_int()
1009 cdev->int_params.in.num_vectors += vectors; in qed_slowpath_vf_setup_int()
1013 cdev->int_params.in.min_msix_cnt = cdev->num_hwfns; in qed_slowpath_vf_setup_int()
1015 rc = qed_set_int_mode(cdev, true); in qed_slowpath_vf_setup_int()
1019 cdev->int_params.fp_msix_base = 0; in qed_slowpath_vf_setup_int()
1020 cdev->int_params.fp_msix_cnt = cdev->int_params.out.num_vectors; in qed_slowpath_vf_setup_int()
1055 static int qed_alloc_stream_mem(struct qed_dev *cdev) in qed_alloc_stream_mem() argument
1060 for_each_hwfn(cdev, i) { in qed_alloc_stream_mem()
1061 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_alloc_stream_mem()
1076 static void qed_free_stream_mem(struct qed_dev *cdev) in qed_free_stream_mem() argument
1080 for_each_hwfn(cdev, i) { in qed_free_stream_mem()
1081 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_free_stream_mem()
1091 static void qed_update_pf_params(struct qed_dev *cdev, in qed_update_pf_params() argument
1104 if (cdev->num_hwfns > 1 || IS_VF(cdev)) in qed_update_pf_params()
1111 if (QED_IS_RDMA_PERSONALITY(QED_LEADING_HWFN(cdev))) { in qed_update_pf_params()
1118 for (i = 0; i < cdev->num_hwfns; i++) { in qed_update_pf_params()
1119 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_update_pf_params()
1161 static void qed_slowpath_wq_stop(struct qed_dev *cdev) in qed_slowpath_wq_stop() argument
1165 if (IS_VF(cdev)) in qed_slowpath_wq_stop()
1168 for_each_hwfn(cdev, i) { in qed_slowpath_wq_stop()
1169 if (!cdev->hwfns[i].slowpath_wq) in qed_slowpath_wq_stop()
1173 cdev->hwfns[i].slowpath_wq_active = false; in qed_slowpath_wq_stop()
1175 cancel_delayed_work(&cdev->hwfns[i].slowpath_task); in qed_slowpath_wq_stop()
1176 destroy_workqueue(cdev->hwfns[i].slowpath_wq); in qed_slowpath_wq_stop()
1201 if (hwfn->cdev->recov_in_prog || !hwfn->slowpath_wq_active) in qed_slowpath_task()
1215 static int qed_slowpath_wq_start(struct qed_dev *cdev) in qed_slowpath_wq_start() argument
1221 if (IS_VF(cdev)) in qed_slowpath_wq_start()
1224 for_each_hwfn(cdev, i) { in qed_slowpath_wq_start()
1225 hwfn = &cdev->hwfns[i]; in qed_slowpath_wq_start()
1228 cdev->pdev->bus->number, in qed_slowpath_wq_start()
1229 PCI_SLOT(cdev->pdev->devfn), hwfn->abs_pf_id); in qed_slowpath_wq_start()
1244 static int qed_slowpath_start(struct qed_dev *cdev, in qed_slowpath_start() argument
1256 if (qed_iov_wq_start(cdev)) in qed_slowpath_start()
1259 if (qed_slowpath_wq_start(cdev)) in qed_slowpath_start()
1262 if (IS_PF(cdev)) { in qed_slowpath_start()
1263 rc = request_firmware(&cdev->firmware, QED_FW_FILE_NAME, in qed_slowpath_start()
1264 &cdev->pdev->dev); in qed_slowpath_start()
1266 DP_NOTICE(cdev, in qed_slowpath_start()
1272 if (cdev->num_hwfns == 1) { in qed_slowpath_start()
1273 p_ptt = qed_ptt_acquire(QED_LEADING_HWFN(cdev)); in qed_slowpath_start()
1275 QED_LEADING_HWFN(cdev)->p_arfs_ptt = p_ptt; in qed_slowpath_start()
1277 DP_NOTICE(cdev, in qed_slowpath_start()
1285 cdev->rx_coalesce_usecs = QED_DEFAULT_RX_USECS; in qed_slowpath_start()
1286 rc = qed_nic_setup(cdev); in qed_slowpath_start()
1290 if (IS_PF(cdev)) in qed_slowpath_start()
1291 rc = qed_slowpath_setup_int(cdev, params->int_mode); in qed_slowpath_start()
1293 rc = qed_slowpath_vf_setup_int(cdev); in qed_slowpath_start()
1297 if (IS_PF(cdev)) { in qed_slowpath_start()
1299 rc = qed_alloc_stream_mem(cdev); in qed_slowpath_start()
1304 data = cdev->firmware->data + sizeof(u32); in qed_slowpath_start()
1306 qed_dbg_pf_init(cdev); in qed_slowpath_start()
1324 hw_init_params.int_mode = cdev->int_params.out.int_mode; in qed_slowpath_start()
1335 rc = qed_hw_init(cdev, &hw_init_params); in qed_slowpath_start()
1339 DP_INFO(cdev, in qed_slowpath_start()
1342 if (IS_PF(cdev)) { in qed_slowpath_start()
1343 cdev->tunn_feature_mask = (BIT(QED_MODE_VXLAN_TUNN) | in qed_slowpath_start()
1351 if (QED_LEADING_HWFN(cdev)->using_ll2) { in qed_slowpath_start()
1352 rc = qed_ll2_alloc_if(cdev); in qed_slowpath_start()
1356 if (IS_PF(cdev)) { in qed_slowpath_start()
1357 hwfn = QED_LEADING_HWFN(cdev); in qed_slowpath_start()
1367 DP_NOTICE(cdev, "Failed sending drv version command\n"); in qed_slowpath_start()
1372 qed_reset_vport_stats(cdev); in qed_slowpath_start()
1377 qed_ll2_dealloc_if(cdev); in qed_slowpath_start()
1379 qed_hw_stop(cdev); in qed_slowpath_start()
1381 qed_hw_timers_stop_all(cdev); in qed_slowpath_start()
1382 if (IS_PF(cdev)) in qed_slowpath_start()
1383 qed_slowpath_irq_free(cdev); in qed_slowpath_start()
1384 qed_free_stream_mem(cdev); in qed_slowpath_start()
1385 qed_disable_msix(cdev); in qed_slowpath_start()
1387 qed_resc_free(cdev); in qed_slowpath_start()
1389 if (IS_PF(cdev)) in qed_slowpath_start()
1390 release_firmware(cdev->firmware); in qed_slowpath_start()
1392 if (IS_PF(cdev) && (cdev->num_hwfns == 1) && in qed_slowpath_start()
1393 QED_LEADING_HWFN(cdev)->p_arfs_ptt) in qed_slowpath_start()
1394 qed_ptt_release(QED_LEADING_HWFN(cdev), in qed_slowpath_start()
1395 QED_LEADING_HWFN(cdev)->p_arfs_ptt); in qed_slowpath_start()
1397 qed_iov_wq_stop(cdev, false); in qed_slowpath_start()
1399 qed_slowpath_wq_stop(cdev); in qed_slowpath_start()
1404 static int qed_slowpath_stop(struct qed_dev *cdev) in qed_slowpath_stop() argument
1406 if (!cdev) in qed_slowpath_stop()
1409 qed_slowpath_wq_stop(cdev); in qed_slowpath_stop()
1411 qed_ll2_dealloc_if(cdev); in qed_slowpath_stop()
1413 if (IS_PF(cdev)) { in qed_slowpath_stop()
1414 if (cdev->num_hwfns == 1) in qed_slowpath_stop()
1415 qed_ptt_release(QED_LEADING_HWFN(cdev), in qed_slowpath_stop()
1416 QED_LEADING_HWFN(cdev)->p_arfs_ptt); in qed_slowpath_stop()
1417 qed_free_stream_mem(cdev); in qed_slowpath_stop()
1418 if (IS_QED_ETH_IF(cdev)) in qed_slowpath_stop()
1419 qed_sriov_disable(cdev, true); in qed_slowpath_stop()
1422 qed_nic_stop(cdev); in qed_slowpath_stop()
1424 if (IS_PF(cdev)) in qed_slowpath_stop()
1425 qed_slowpath_irq_free(cdev); in qed_slowpath_stop()
1427 qed_disable_msix(cdev); in qed_slowpath_stop()
1429 qed_resc_free(cdev); in qed_slowpath_stop()
1431 qed_iov_wq_stop(cdev, true); in qed_slowpath_stop()
1433 if (IS_PF(cdev)) in qed_slowpath_stop()
1434 release_firmware(cdev->firmware); in qed_slowpath_stop()
1439 static void qed_set_name(struct qed_dev *cdev, char name[NAME_SIZE]) in qed_set_name() argument
1443 memcpy(cdev->name, name, NAME_SIZE); in qed_set_name()
1444 for_each_hwfn(cdev, i) in qed_set_name()
1445 snprintf(cdev->hwfns[i].name, NAME_SIZE, "%s-%d", name, i); in qed_set_name()
1448 static u32 qed_sb_init(struct qed_dev *cdev, in qed_sb_init() argument
1461 p_hwfn = &cdev->hwfns[sb_id % cdev->num_hwfns]; in qed_sb_init()
1462 rel_sb_id = sb_id / cdev->num_hwfns; in qed_sb_init()
1464 p_hwfn = QED_AFFIN_HWFN(cdev); in qed_sb_init()
1468 DP_VERBOSE(cdev, NETIF_MSG_INTR, in qed_sb_init()
1472 if (IS_PF(p_hwfn->cdev)) { in qed_sb_init()
1488 static u32 qed_sb_release(struct qed_dev *cdev, in qed_sb_release() argument
1499 p_hwfn = &cdev->hwfns[sb_id % cdev->num_hwfns]; in qed_sb_release()
1500 rel_sb_id = sb_id / cdev->num_hwfns; in qed_sb_release()
1502 p_hwfn = QED_AFFIN_HWFN(cdev); in qed_sb_release()
1506 DP_VERBOSE(cdev, NETIF_MSG_INTR, in qed_sb_release()
1515 static bool qed_can_link_change(struct qed_dev *cdev) in qed_can_link_change() argument
1661 static int qed_set_link(struct qed_dev *cdev, struct qed_link_params *params) in qed_set_link() argument
1671 if (!cdev) in qed_set_link()
1675 hwfn = &cdev->hwfns[0]; in qed_set_link()
1681 if (IS_VF(cdev)) { in qed_set_link()
1820 if (!IS_PF(hwfn->cdev)) { in qed_get_link_data()
1865 DP_VERBOSE(hwfn->cdev, NETIF_MSG_DRV, in qed_fill_link_capability()
2053 DP_VERBOSE(hwfn->cdev, QED_MSG_DEBUG, in qed_fill_link_capability()
2093 dev_warn(&hwfn->cdev->pdev->dev, "no link data available\n"); in qed_fill_link()
2101 if (IS_PF(hwfn->cdev) && qed_mcp_is_ext_speed_supported(hwfn)) { in qed_fill_link()
2190 static void qed_get_current_link(struct qed_dev *cdev, in qed_get_current_link() argument
2197 hwfn = &cdev->hwfns[0]; in qed_get_current_link()
2198 if (IS_PF(cdev)) { in qed_get_current_link()
2210 for_each_hwfn(cdev, i) in qed_get_current_link()
2211 qed_inform_vf_link_state(&cdev->hwfns[i]); in qed_get_current_link()
2216 void *cookie = hwfn->cdev->ops_cookie; in qed_link_update()
2217 struct qed_common_cb_ops *op = hwfn->cdev->protocol_ops.common; in qed_link_update()
2229 void *cookie = hwfn->cdev->ops_cookie; in qed_bw_update()
2230 struct qed_common_cb_ops *op = hwfn->cdev->protocol_ops.common; in qed_bw_update()
2236 static int qed_drain(struct qed_dev *cdev) in qed_drain() argument
2242 if (IS_VF(cdev)) in qed_drain()
2245 for_each_hwfn(cdev, i) { in qed_drain()
2246 hwfn = &cdev->hwfns[i]; in qed_drain()
2261 static u32 qed_nvm_flash_image_access_crc(struct qed_dev *cdev, in qed_nvm_flash_image_access_crc() argument
2274 rc = qed_mcp_nvm_read(cdev, nvm_image->start_addr, in qed_nvm_flash_image_access_crc()
2277 DP_ERR(cdev, "Failed reading image from nvm\n"); in qed_nvm_flash_image_access_crc()
2310 static int qed_nvm_flash_image_access(struct qed_dev *cdev, const u8 **data, in qed_nvm_flash_image_access() argument
2322 p_hwfn = QED_LEADING_HWFN(cdev); in qed_nvm_flash_image_access()
2327 DP_ERR(cdev, "Failed to find nvram image of type %08x\n", in qed_nvm_flash_image_access()
2335 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_image_access()
2347 rc = qed_nvm_flash_image_access_crc(cdev, &nvm_image, &crc); in qed_nvm_flash_image_access()
2349 DP_ERR(cdev, "Failed calculating CRC, rc = %d\n", rc); in qed_nvm_flash_image_access()
2353 rc = qed_mcp_nvm_write(cdev, QED_NVM_WRITE_NVRAM, in qed_nvm_flash_image_access()
2357 DP_ERR(cdev, "Failed writing to %08x, rc = %d\n", in qed_nvm_flash_image_access()
2374 rc = qed_mcp_nvm_read(cdev, nvm_image.start_addr + offset, buf, in qed_nvm_flash_image_access()
2377 DP_ERR(cdev, "Failed reading from %08x\n", in qed_nvm_flash_image_access()
2383 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_image_access()
2388 rc = qed_mcp_nvm_write(cdev, QED_NVM_WRITE_NVRAM, in qed_nvm_flash_image_access()
2392 DP_ERR(cdev, "Failed writing to %08x\n", in qed_nvm_flash_image_access()
2412 static int qed_nvm_flash_image_file_start(struct qed_dev *cdev, in qed_nvm_flash_image_file_start() argument
2423 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_image_file_start()
2430 rc = qed_mcp_nvm_write(cdev, QED_PUT_FILE_BEGIN, file_type, in qed_nvm_flash_image_file_start()
2448 static int qed_nvm_flash_image_file_data(struct qed_dev *cdev, in qed_nvm_flash_image_file_data() argument
2462 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_image_file_data()
2466 rc = qed_mcp_nvm_write(cdev, QED_PUT_FILE_DATA, offset, in qed_nvm_flash_image_file_data()
2480 static int qed_nvm_flash_image_validate(struct qed_dev *cdev, in qed_nvm_flash_image_validate() argument
2488 DP_ERR(cdev, "Image is too short [%08x]\n", (u32)image->size); in qed_nvm_flash_image_validate()
2495 DP_ERR(cdev, "Wrong signature '%08x'\n", signature); in qed_nvm_flash_image_validate()
2503 DP_ERR(cdev, "Size mismatch: internal = %08x image = %08x\n", in qed_nvm_flash_image_validate()
2511 DP_ERR(cdev, "File contains unsupported commands [Need %04x]\n", in qed_nvm_flash_image_validate()
2535 static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) in qed_nvm_flash_cfg_write() argument
2537 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_nvm_flash_cfg_write()
2554 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_cfg_write()
2585 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_cfg_write()
2591 DP_ERR(cdev, "Error %d configuring %d\n", rc, cfg_id); in qed_nvm_flash_cfg_write()
2602 static int qed_nvm_flash_cfg_len(struct qed_dev *cdev, u32 cmd) in qed_nvm_flash_cfg_len() argument
2604 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_nvm_flash_cfg_len()
2617 DP_ERR(cdev, "Error %d reading %d\n", rc, cmd); in qed_nvm_flash_cfg_len()
2626 static int qed_nvm_flash_cfg_read(struct qed_dev *cdev, u8 **data, in qed_nvm_flash_cfg_read() argument
2629 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_nvm_flash_cfg_read()
2638 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash_cfg_read()
2643 DP_ERR(cdev, "Error %d reading %d\n", rc, cmd); in qed_nvm_flash_cfg_read()
2650 static int qed_nvm_flash(struct qed_dev *cdev, const char *name) in qed_nvm_flash() argument
2657 rc = request_firmware(&image, name, &cdev->pdev->dev); in qed_nvm_flash()
2659 DP_ERR(cdev, "Failed to find '%s'\n", name); in qed_nvm_flash()
2663 DP_VERBOSE(cdev, NETIF_MSG_DRV, in qed_nvm_flash()
2669 rc = qed_nvm_flash_image_validate(cdev, image, &data); in qed_nvm_flash()
2680 rc = qed_nvm_flash_image_file_data(cdev, &data, in qed_nvm_flash()
2684 rc = qed_nvm_flash_image_file_start(cdev, &data, in qed_nvm_flash()
2688 rc = qed_nvm_flash_image_access(cdev, &data, in qed_nvm_flash()
2692 rc = qed_nvm_flash_cfg_write(cdev, &data); in qed_nvm_flash()
2695 DP_ERR(cdev, "Unknown command %08x\n", cmd_type); in qed_nvm_flash()
2701 DP_ERR(cdev, "Command %08x failed\n", cmd_type); in qed_nvm_flash()
2709 if (qed_mcp_nvm_resp(cdev, (u8 *)&mcp_response)) { in qed_nvm_flash()
2710 DP_ERR(cdev, "Failed getting MCP response\n"); in qed_nvm_flash()
2722 DP_ERR(cdev, "MFW returns error: %08x\n", in qed_nvm_flash()
2736 static int qed_nvm_get_image(struct qed_dev *cdev, enum qed_nvm_images type, in qed_nvm_get_image() argument
2739 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_nvm_get_image()
2746 struct qed_common_cb_ops *ops = p_hwfn->cdev->protocol_ops.common; in qed_schedule_recovery_handler()
2747 void *cookie = p_hwfn->cdev->ops_cookie; in qed_schedule_recovery_handler()
2766 struct qed_common_cb_ops *ops = p_hwfn->cdev->protocol_ops.common; in qed_hw_error_occurred()
2767 void *cookie = p_hwfn->cdev->ops_cookie; in qed_hw_error_occurred()
2783 qed_int_attn_clr_enable(p_hwfn->cdev, true); in qed_hw_error_occurred()
2786 static int qed_set_coalesce(struct qed_dev *cdev, u16 rx_coal, u16 tx_coal, in qed_set_coalesce() argument
2792 static int qed_set_led(struct qed_dev *cdev, enum qed_led_mode mode) in qed_set_led() argument
2794 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_set_led()
2809 int qed_recovery_process(struct qed_dev *cdev) in qed_recovery_process() argument
2811 struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); in qed_recovery_process()
2826 static int qed_update_wol(struct qed_dev *cdev, bool enabled) in qed_update_wol() argument
2828 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_update_wol()
2832 if (IS_VF(cdev)) in qed_update_wol()
2850 static int qed_update_drv_state(struct qed_dev *cdev, bool active) in qed_update_drv_state() argument
2852 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_update_drv_state()
2856 if (IS_VF(cdev)) in qed_update_drv_state()
2872 static int qed_update_mac(struct qed_dev *cdev, const u8 *mac) in qed_update_mac() argument
2874 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_update_mac()
2878 if (IS_VF(cdev)) in qed_update_mac()
2896 static int qed_update_mtu(struct qed_dev *cdev, u16 mtu) in qed_update_mtu() argument
2898 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_update_mtu()
2902 if (IS_VF(cdev)) in qed_update_mtu()
2921 qed_get_sb_info(struct qed_dev *cdev, struct qed_sb_info *sb, in qed_get_sb_info() argument
2924 struct qed_hwfn *hwfn = &cdev->hwfns[qid % cdev->num_hwfns]; in qed_get_sb_info()
2928 if (IS_VF(cdev)) in qed_get_sb_info()
2944 static int qed_read_module_eeprom(struct qed_dev *cdev, char *buf, in qed_read_module_eeprom() argument
2947 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_read_module_eeprom()
2951 if (IS_VF(cdev)) in qed_read_module_eeprom()
2966 static int qed_set_grc_config(struct qed_dev *cdev, u32 cfg_id, u32 val) in qed_set_grc_config() argument
2968 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_set_grc_config()
2972 if (IS_VF(cdev)) in qed_set_grc_config()
2986 static __printf(2, 3) void qed_mfw_report(struct qed_dev *cdev, char *fmt, ...) in qed_mfw_report() argument
2997 if (IS_PF(cdev)) { in qed_mfw_report()
2998 p_hwfn = QED_LEADING_HWFN(cdev); in qed_mfw_report()
3007 static u8 qed_get_affin_hwfn_idx(struct qed_dev *cdev) in qed_get_affin_hwfn_idx() argument
3009 return QED_AFFIN_HWFN_IDX(cdev); in qed_get_affin_hwfn_idx()
3012 static int qed_get_esl_status(struct qed_dev *cdev, bool *esl_active) in qed_get_esl_status() argument
3014 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); in qed_get_esl_status()
3020 if (IS_VF(cdev)) in qed_get_esl_status()
3094 void qed_get_protocol_stats(struct qed_dev *cdev, in qed_get_protocol_stats() argument
3104 qed_get_vport_stats(cdev, ð_stats); in qed_get_protocol_stats()
3112 qed_get_protocol_stats_fcoe(cdev, &stats->fcoe_stats); in qed_get_protocol_stats()
3115 qed_get_protocol_stats_iscsi(cdev, &stats->iscsi_stats); in qed_get_protocol_stats()
3118 DP_VERBOSE(cdev, QED_MSG_SP, in qed_get_protocol_stats()
3126 DP_VERBOSE(hwfn->cdev, NETIF_MSG_DRV, in qed_mfw_tlv_req()
3140 qed_fill_generic_tlv_data(struct qed_dev *cdev, struct qed_mfw_tlv_generic *tlv) in qed_fill_generic_tlv_data() argument
3142 struct qed_common_cb_ops *op = cdev->protocol_ops.common; in qed_fill_generic_tlv_data()
3149 op->get_generic_tlv_data(cdev->ops_cookie, &gen_tlvs); in qed_fill_generic_tlv_data()
3164 qed_get_vport_stats(cdev, &stats); in qed_fill_generic_tlv_data()
3183 struct qed_dev *cdev = hwfn->cdev; in qed_mfw_fill_tlv_data() local
3186 ops = cdev->protocol_ops.common; in qed_mfw_fill_tlv_data()
3194 qed_fill_generic_tlv_data(hwfn->cdev, &tlv_buf->generic); in qed_mfw_fill_tlv_data()
3197 ops->get_protocol_tlv_data(cdev->ops_cookie, &tlv_buf->eth); in qed_mfw_fill_tlv_data()
3200 ops->get_protocol_tlv_data(cdev->ops_cookie, &tlv_buf->fcoe); in qed_mfw_fill_tlv_data()
3203 ops->get_protocol_tlv_data(cdev->ops_cookie, &tlv_buf->iscsi); in qed_mfw_fill_tlv_data()