Lines Matching refs:p_hwfn

43 		struct qed_hwfn *p_hwfn = &cdev->hwfns[i];  in qed_init_dp()  local
45 p_hwfn->dp_level = dp_level; in qed_init_dp()
46 p_hwfn->dp_module = dp_module; in qed_init_dp()
55 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_init_struct() local
57 p_hwfn->cdev = cdev; in qed_init_struct()
58 p_hwfn->my_id = i; in qed_init_struct()
59 p_hwfn->b_active = false; in qed_init_struct()
61 mutex_init(&p_hwfn->dmae_info.mutex); in qed_init_struct()
71 static void qed_qm_info_free(struct qed_hwfn *p_hwfn) in qed_qm_info_free() argument
73 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_qm_info_free()
93 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_free() local
95 kfree(p_hwfn->p_tx_cids); in qed_resc_free()
96 p_hwfn->p_tx_cids = NULL; in qed_resc_free()
97 kfree(p_hwfn->p_rx_cids); in qed_resc_free()
98 p_hwfn->p_rx_cids = NULL; in qed_resc_free()
102 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_free() local
104 qed_cxt_mngr_free(p_hwfn); in qed_resc_free()
105 qed_qm_info_free(p_hwfn); in qed_resc_free()
106 qed_spq_free(p_hwfn); in qed_resc_free()
107 qed_eq_free(p_hwfn, p_hwfn->p_eq); in qed_resc_free()
108 qed_consq_free(p_hwfn, p_hwfn->p_consq); in qed_resc_free()
109 qed_int_free(p_hwfn); in qed_resc_free()
110 qed_dmae_info_free(p_hwfn); in qed_resc_free()
114 static int qed_init_qm_info(struct qed_hwfn *p_hwfn) in qed_init_qm_info() argument
116 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_info()
124 num_vports = (u8)RESC_NUM(p_hwfn, QED_VPORT); in qed_init_qm_info()
127 if (num_pqs > RESC_NUM(p_hwfn, QED_PQ)) { in qed_init_qm_info()
128 DP_ERR(p_hwfn, in qed_init_qm_info()
130 num_pqs, RESC_NUM(p_hwfn, QED_PQ)); in qed_init_qm_info()
151 vport_id = (u8)RESC_START(p_hwfn, QED_VPORT); in qed_init_qm_info()
158 params->tc_id = p_hwfn->hw_info.non_offload_tc; in qed_init_qm_info()
164 qm_info->qm_pq_params[i].vport_id = (u8)RESC_START(p_hwfn, QED_VPORT); in qed_init_qm_info()
174 num_ports = p_hwfn->cdev->num_ports_in_engines; in qed_init_qm_info()
185 qm_info->start_pq = (u16)RESC_START(p_hwfn, QED_PQ); in qed_init_qm_info()
187 qm_info->start_vport = (u8)RESC_START(p_hwfn, QED_VPORT); in qed_init_qm_info()
196 DP_NOTICE(p_hwfn, "Failed to allocate memory for QM params\n"); in qed_init_qm_info()
216 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_alloc() local
218 RESC_NUM(p_hwfn, QED_L2_QUEUE); in qed_resc_alloc()
220 RESC_NUM(p_hwfn, QED_L2_QUEUE); in qed_resc_alloc()
222 p_hwfn->p_tx_cids = kzalloc(tx_size, GFP_KERNEL); in qed_resc_alloc()
223 if (!p_hwfn->p_tx_cids) { in qed_resc_alloc()
224 DP_NOTICE(p_hwfn, in qed_resc_alloc()
230 p_hwfn->p_rx_cids = kzalloc(rx_size, GFP_KERNEL); in qed_resc_alloc()
231 if (!p_hwfn->p_rx_cids) { in qed_resc_alloc()
232 DP_NOTICE(p_hwfn, in qed_resc_alloc()
240 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_alloc() local
243 rc = qed_cxt_mngr_alloc(p_hwfn); in qed_resc_alloc()
250 rc = qed_cxt_set_pf_params(p_hwfn); in qed_resc_alloc()
255 rc = qed_init_qm_info(p_hwfn); in qed_resc_alloc()
260 rc = qed_cxt_cfg_ilt_compute(p_hwfn); in qed_resc_alloc()
267 rc = qed_cxt_tables_alloc(p_hwfn); in qed_resc_alloc()
272 rc = qed_spq_alloc(p_hwfn); in qed_resc_alloc()
277 p_hwfn->p_dpc_ptt = qed_get_reserved_ptt(p_hwfn, in qed_resc_alloc()
280 rc = qed_int_alloc(p_hwfn, p_hwfn->p_main_ptt); in qed_resc_alloc()
285 p_eq = qed_eq_alloc(p_hwfn, 256); in qed_resc_alloc()
290 p_hwfn->p_eq = p_eq; in qed_resc_alloc()
292 p_consq = qed_consq_alloc(p_hwfn); in qed_resc_alloc()
297 p_hwfn->p_consq = p_consq; in qed_resc_alloc()
300 rc = qed_dmae_info_alloc(p_hwfn); in qed_resc_alloc()
302 DP_NOTICE(p_hwfn, in qed_resc_alloc()
327 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_setup() local
329 qed_cxt_mngr_setup(p_hwfn); in qed_resc_setup()
330 qed_spq_setup(p_hwfn); in qed_resc_setup()
331 qed_eq_setup(p_hwfn, p_hwfn->p_eq); in qed_resc_setup()
332 qed_consq_setup(p_hwfn, p_hwfn->p_consq); in qed_resc_setup()
335 qed_mcp_read_mb(p_hwfn, p_hwfn->p_main_ptt); in qed_resc_setup()
336 memcpy(p_hwfn->mcp_info->mfw_mb_shadow, in qed_resc_setup()
337 p_hwfn->mcp_info->mfw_mb_cur, in qed_resc_setup()
338 p_hwfn->mcp_info->mfw_mb_length); in qed_resc_setup()
340 qed_int_setup(p_hwfn, p_hwfn->p_main_ptt); in qed_resc_setup()
351 int qed_final_cleanup(struct qed_hwfn *p_hwfn, in qed_final_cleanup() argument
366 if (REG_RD(p_hwfn, addr)) { in qed_final_cleanup()
368 p_hwfn, in qed_final_cleanup()
370 REG_WR(p_hwfn, addr, 0); in qed_final_cleanup()
373 DP_VERBOSE(p_hwfn, QED_MSG_IOV, in qed_final_cleanup()
377 qed_wr(p_hwfn, p_ptt, XSDM_REG_OPERATION_GEN, command); in qed_final_cleanup()
380 while (!REG_RD(p_hwfn, addr) && count--) in qed_final_cleanup()
383 if (REG_RD(p_hwfn, addr)) in qed_final_cleanup()
386 DP_NOTICE(p_hwfn, in qed_final_cleanup()
390 REG_WR(p_hwfn, addr, 0); in qed_final_cleanup()
395 static void qed_calc_hw_mode(struct qed_hwfn *p_hwfn) in qed_calc_hw_mode() argument
401 switch (p_hwfn->cdev->num_ports_in_engines) { in qed_calc_hw_mode()
412 DP_NOTICE(p_hwfn, "num_ports_in_engine = %d not supported\n", in qed_calc_hw_mode()
413 p_hwfn->cdev->num_ports_in_engines); in qed_calc_hw_mode()
417 switch (p_hwfn->cdev->mf_mode) { in qed_calc_hw_mode()
428 DP_NOTICE(p_hwfn, "Unsupported MF mode, init as SF\n"); in qed_calc_hw_mode()
434 p_hwfn->hw_info.hw_mode = hw_mode; in qed_calc_hw_mode()
444 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_init_cau_rt_data() local
449 p_igu_info = p_hwfn->hw_info.p_igu_info; in qed_init_cau_rt_data()
457 qed_init_cau_sb_entry(p_hwfn, &sb_entry, in qed_init_cau_rt_data()
460 STORE_RT_REG_AGG(p_hwfn, offset + sb_id * 2, in qed_init_cau_rt_data()
466 static int qed_hw_init_common(struct qed_hwfn *p_hwfn, in qed_hw_init_common() argument
470 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_hw_init_common()
472 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_init_common()
478 qed_gtt_init(p_hwfn); in qed_hw_init_common()
480 if (p_hwfn->mcp_info) { in qed_hw_init_common()
481 if (p_hwfn->mcp_info->func_info.bandwidth_max) in qed_hw_init_common()
483 if (p_hwfn->mcp_info->func_info.bandwidth_min) in qed_hw_init_common()
488 params.max_ports_per_engine = p_hwfn->cdev->num_ports_in_engines; in qed_hw_init_common()
496 qed_qm_common_rt_init(p_hwfn, &params); in qed_hw_init_common()
498 qed_cxt_hw_init_common(p_hwfn); in qed_hw_init_common()
505 qed_wr(p_hwfn, p_ptt, NIG_REG_RX_BRB_OUT_EN, 0); in qed_hw_init_common()
506 qed_wr(p_hwfn, p_ptt, NIG_REG_STORM_OUT_EN, 0); in qed_hw_init_common()
507 qed_port_pretend(p_hwfn, p_ptt, p_hwfn->port_id ^ 1); in qed_hw_init_common()
508 qed_wr(p_hwfn, p_ptt, NIG_REG_RX_BRB_OUT_EN, 0); in qed_hw_init_common()
509 qed_wr(p_hwfn, p_ptt, NIG_REG_STORM_OUT_EN, 0); in qed_hw_init_common()
510 qed_port_unpretend(p_hwfn, p_ptt); in qed_hw_init_common()
512 rc = qed_init_run(p_hwfn, p_ptt, PHASE_ENGINE, ANY_PHASE_ID, hw_mode); in qed_hw_init_common()
516 qed_wr(p_hwfn, p_ptt, PSWRQ2_REG_L2P_VALIDATE_VFID, 0); in qed_hw_init_common()
517 qed_wr(p_hwfn, p_ptt, PGLUE_B_REG_USE_CLIENTID_IN_TAG, 1); in qed_hw_init_common()
520 qed_wr(p_hwfn, p_ptt, 0x20b4, in qed_hw_init_common()
521 qed_rd(p_hwfn, p_ptt, 0x20b4) & ~0x10); in qed_hw_init_common()
526 static int qed_hw_init_port(struct qed_hwfn *p_hwfn, in qed_hw_init_port() argument
532 rc = qed_init_run(p_hwfn, p_ptt, PHASE_PORT, p_hwfn->port_id, in qed_hw_init_port()
537 static int qed_hw_init_pf(struct qed_hwfn *p_hwfn, in qed_hw_init_pf() argument
544 u8 rel_pf_id = p_hwfn->rel_pf_id; in qed_hw_init_pf()
547 if (p_hwfn->mcp_info) { in qed_hw_init_pf()
550 p_info = &p_hwfn->mcp_info->func_info; in qed_hw_init_pf()
552 p_hwfn->qm_info.pf_wfq = p_info->bandwidth_min; in qed_hw_init_pf()
555 p_hwfn->qm_info.pf_rl = 100; in qed_hw_init_pf()
558 qed_cxt_hw_init_pf(p_hwfn); in qed_hw_init_pf()
560 qed_int_igu_init_rt(p_hwfn); in qed_hw_init_pf()
564 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, "Configuring LLH_FUNC_TAG\n"); in qed_hw_init_pf()
565 STORE_RT_REG(p_hwfn, NIG_REG_LLH_FUNC_TAG_EN_RT_OFFSET, 1); in qed_hw_init_pf()
566 STORE_RT_REG(p_hwfn, NIG_REG_LLH_FUNC_TAG_VALUE_RT_OFFSET, in qed_hw_init_pf()
567 p_hwfn->hw_info.ovlan); in qed_hw_init_pf()
572 DP_VERBOSE(p_hwfn, NETIF_MSG_HW, in qed_hw_init_pf()
574 STORE_RT_REG(p_hwfn, in qed_hw_init_pf()
579 STORE_RT_REG(p_hwfn, PRS_REG_SEARCH_TCP_RT_OFFSET, 0); in qed_hw_init_pf()
580 STORE_RT_REG(p_hwfn, PRS_REG_SEARCH_FCOE_RT_OFFSET, 0); in qed_hw_init_pf()
581 STORE_RT_REG(p_hwfn, PRS_REG_SEARCH_ROCE_RT_OFFSET, 0); in qed_hw_init_pf()
584 rc = qed_final_cleanup(p_hwfn, p_ptt, rel_pf_id); in qed_hw_init_pf()
589 rc = qed_init_run(p_hwfn, p_ptt, PHASE_PF, rel_pf_id, hw_mode); in qed_hw_init_pf()
594 rc = qed_init_run(p_hwfn, p_ptt, PHASE_QM_PF, rel_pf_id, hw_mode); in qed_hw_init_pf()
599 qed_int_igu_init_pure_rt(p_hwfn, p_ptt, true, true); in qed_hw_init_pf()
603 qed_int_igu_enable(p_hwfn, p_ptt, int_mode); in qed_hw_init_pf()
606 rc = qed_sp_pf_start(p_hwfn, p_hwfn->cdev->mf_mode); in qed_hw_init_pf()
608 DP_NOTICE(p_hwfn, "Function start ramrod failed\n"); in qed_hw_init_pf()
613 static int qed_change_pci_hwfn(struct qed_hwfn *p_hwfn, in qed_change_pci_hwfn() argument
620 qed_wr(p_hwfn, p_ptt, in qed_change_pci_hwfn()
625 val = qed_rd(p_hwfn, p_ptt, in qed_change_pci_hwfn()
634 DP_NOTICE(p_hwfn, in qed_change_pci_hwfn()
642 static void qed_reset_mb_shadow(struct qed_hwfn *p_hwfn, in qed_reset_mb_shadow() argument
646 qed_mcp_read_mb(p_hwfn, p_main_ptt); in qed_reset_mb_shadow()
647 memcpy(p_hwfn->mcp_info->mfw_mb_shadow, in qed_reset_mb_shadow()
648 p_hwfn->mcp_info->mfw_mb_cur, in qed_reset_mb_shadow()
649 p_hwfn->mcp_info->mfw_mb_length); in qed_reset_mb_shadow()
668 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_hw_init() local
670 rc = qed_fw_vport(p_hwfn, 0, &fw_vport); in qed_hw_init()
675 rc = qed_change_pci_hwfn(p_hwfn, p_hwfn->p_main_ptt, true); in qed_hw_init()
677 qed_calc_hw_mode(p_hwfn); in qed_hw_init()
679 rc = qed_mcp_load_req(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
682 DP_NOTICE(p_hwfn, "Failed sending LOAD_REQ command\n"); in qed_hw_init()
686 qed_reset_mb_shadow(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_init()
688 DP_VERBOSE(p_hwfn, QED_MSG_SP, in qed_hw_init()
692 p_hwfn->first_on_engine = (load_code == in qed_hw_init()
697 rc = qed_hw_init_common(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
698 p_hwfn->hw_info.hw_mode); in qed_hw_init()
703 rc = qed_hw_init_port(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
704 p_hwfn->hw_info.hw_mode); in qed_hw_init()
710 rc = qed_hw_init_pf(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
711 p_hwfn->hw_info.hw_mode, in qed_hw_init()
721 DP_NOTICE(p_hwfn, in qed_hw_init()
726 mfw_rc = qed_mcp_cmd(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
732 DP_NOTICE(p_hwfn, "Failed sending LOAD_DONE command\n"); in qed_hw_init()
736 p_hwfn->hw_init_done = true; in qed_hw_init()
739 p_stat = &p_hwfn->storm_stats; in qed_hw_init()
754 TSTORM_PORT_STAT_OFFSET(MFW_PORT(p_hwfn)); in qed_hw_init()
768 struct qed_hwfn *p_hwfn = &cdev->hwfns[j]; in qed_hw_stop() local
769 struct qed_ptt *p_ptt = p_hwfn->p_main_ptt; in qed_hw_stop()
771 DP_VERBOSE(p_hwfn, NETIF_MSG_IFDOWN, "Stopping hw/fw\n"); in qed_hw_stop()
774 p_hwfn->hw_init_done = false; in qed_hw_stop()
776 rc = qed_sp_pf_stop(p_hwfn); in qed_hw_stop()
780 qed_wr(p_hwfn, p_ptt, in qed_hw_stop()
783 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_TCP, 0x0); in qed_hw_stop()
784 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_UDP, 0x0); in qed_hw_stop()
785 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_FCOE, 0x0); in qed_hw_stop()
786 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_ROCE, 0x0); in qed_hw_stop()
787 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_OPENFLOW, 0x0); in qed_hw_stop()
789 qed_wr(p_hwfn, p_ptt, TM_REG_PF_ENABLE_CONN, 0x0); in qed_hw_stop()
790 qed_wr(p_hwfn, p_ptt, TM_REG_PF_ENABLE_TASK, 0x0); in qed_hw_stop()
792 if ((!qed_rd(p_hwfn, p_ptt, in qed_hw_stop()
794 (!qed_rd(p_hwfn, p_ptt, in qed_hw_stop()
801 DP_NOTICE(p_hwfn, in qed_hw_stop()
803 (u8)qed_rd(p_hwfn, p_ptt, in qed_hw_stop()
805 (u8)qed_rd(p_hwfn, p_ptt, in qed_hw_stop()
809 qed_int_igu_disable_int(p_hwfn, p_ptt); in qed_hw_stop()
811 qed_wr(p_hwfn, p_ptt, IGU_REG_LEADING_EDGE_LATCH, 0); in qed_hw_stop()
812 qed_wr(p_hwfn, p_ptt, IGU_REG_TRAILING_EDGE_LATCH, 0); in qed_hw_stop()
814 qed_int_igu_init_pure_rt(p_hwfn, p_ptt, false, true); in qed_hw_stop()
838 struct qed_hwfn *p_hwfn = &cdev->hwfns[j]; in qed_hw_stop_fastpath() local
839 struct qed_ptt *p_ptt = p_hwfn->p_main_ptt; in qed_hw_stop_fastpath()
841 DP_VERBOSE(p_hwfn, in qed_hw_stop_fastpath()
845 qed_wr(p_hwfn, p_ptt, in qed_hw_stop_fastpath()
848 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_TCP, 0x0); in qed_hw_stop_fastpath()
849 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_UDP, 0x0); in qed_hw_stop_fastpath()
850 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_FCOE, 0x0); in qed_hw_stop_fastpath()
851 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_ROCE, 0x0); in qed_hw_stop_fastpath()
852 qed_wr(p_hwfn, p_ptt, PRS_REG_SEARCH_OPENFLOW, 0x0); in qed_hw_stop_fastpath()
854 qed_wr(p_hwfn, p_ptt, TM_REG_PF_ENABLE_CONN, 0x0); in qed_hw_stop_fastpath()
855 qed_wr(p_hwfn, p_ptt, TM_REG_PF_ENABLE_TASK, 0x0); in qed_hw_stop_fastpath()
857 if ((!qed_rd(p_hwfn, p_ptt, in qed_hw_stop_fastpath()
859 (!qed_rd(p_hwfn, p_ptt, in qed_hw_stop_fastpath()
866 DP_NOTICE(p_hwfn, in qed_hw_stop_fastpath()
868 (u8)qed_rd(p_hwfn, p_ptt, in qed_hw_stop_fastpath()
870 (u8)qed_rd(p_hwfn, p_ptt, in qed_hw_stop_fastpath()
873 qed_int_igu_init_pure_rt(p_hwfn, p_ptt, false, false); in qed_hw_stop_fastpath()
880 void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn) in qed_hw_start_fastpath() argument
883 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_start_fastpath()
909 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_hw_reset() local
911 DP_VERBOSE(p_hwfn, NETIF_MSG_IFDOWN, "Resetting hw/fw\n"); in qed_hw_reset()
914 qed_reg_assert(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_reset()
916 qed_reg_assert(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_reset()
920 qed_wr(p_hwfn, p_hwfn->p_main_ptt, DORQ_REG_PF_DB_ENABLE, 0); in qed_hw_reset()
921 qed_wr(p_hwfn, p_hwfn->p_main_ptt, QM_REG_PF_EN, 0); in qed_hw_reset()
922 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_reset()
924 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_reset()
928 rc = qed_mcp_cmd(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_reset()
933 DP_NOTICE(p_hwfn, "qed_hw_reset: UNLOAD_REQ failed\n"); in qed_hw_reset()
937 rc = qed_mcp_cmd(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_reset()
941 DP_NOTICE(p_hwfn, "qed_hw_reset: UNLOAD_DONE failed\n"); in qed_hw_reset()
950 static void qed_hw_hwfn_free(struct qed_hwfn *p_hwfn) in qed_hw_hwfn_free() argument
952 qed_ptt_pool_free(p_hwfn); in qed_hw_hwfn_free()
953 kfree(p_hwfn->hw_info.p_igu_info); in qed_hw_hwfn_free()
957 static int qed_hw_hwfn_prepare(struct qed_hwfn *p_hwfn) in qed_hw_hwfn_prepare() argument
962 rc = qed_ptt_pool_alloc(p_hwfn); in qed_hw_hwfn_prepare()
967 p_hwfn->p_main_ptt = qed_get_reserved_ptt(p_hwfn, RESERVED_PTT_MAIN); in qed_hw_hwfn_prepare()
970 qed_wr(p_hwfn, p_hwfn->p_main_ptt, PGLUE_B_REG_PGL_ADDR_88_F0, 0); in qed_hw_hwfn_prepare()
971 qed_wr(p_hwfn, p_hwfn->p_main_ptt, PGLUE_B_REG_PGL_ADDR_8C_F0, 0); in qed_hw_hwfn_prepare()
972 qed_wr(p_hwfn, p_hwfn->p_main_ptt, PGLUE_B_REG_PGL_ADDR_90_F0, 0); in qed_hw_hwfn_prepare()
973 qed_wr(p_hwfn, p_hwfn->p_main_ptt, PGLUE_B_REG_PGL_ADDR_94_F0, 0); in qed_hw_hwfn_prepare()
976 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
978 1 << p_hwfn->abs_pf_id); in qed_hw_hwfn_prepare()
981 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
987 static void get_function_id(struct qed_hwfn *p_hwfn) in get_function_id() argument
990 p_hwfn->hw_info.opaque_fid = (u16)REG_RD(p_hwfn, PXP_PF_ME_OPAQUE_ADDR); in get_function_id()
992 p_hwfn->hw_info.concrete_fid = REG_RD(p_hwfn, PXP_PF_ME_CONCRETE_ADDR); in get_function_id()
994 p_hwfn->abs_pf_id = (p_hwfn->hw_info.concrete_fid >> 16) & 0xf; in get_function_id()
995 p_hwfn->rel_pf_id = GET_FIELD(p_hwfn->hw_info.concrete_fid, in get_function_id()
997 p_hwfn->port_id = GET_FIELD(p_hwfn->hw_info.concrete_fid, in get_function_id()
1001 static void qed_hw_set_feat(struct qed_hwfn *p_hwfn) in qed_hw_set_feat() argument
1003 u32 *feat_num = p_hwfn->hw_info.feat_num; in qed_hw_set_feat()
1006 feat_num[QED_PF_L2_QUE] = min_t(u32, RESC_NUM(p_hwfn, QED_SB) / in qed_hw_set_feat()
1008 RESC_NUM(p_hwfn, QED_L2_QUEUE)); in qed_hw_set_feat()
1009 DP_VERBOSE(p_hwfn, NETIF_MSG_PROBE, in qed_hw_set_feat()
1011 feat_num[QED_PF_L2_QUE], RESC_NUM(p_hwfn, QED_SB), in qed_hw_set_feat()
1015 static void qed_hw_get_resc(struct qed_hwfn *p_hwfn) in qed_hw_get_resc() argument
1017 u32 *resc_start = p_hwfn->hw_info.resc_start; in qed_hw_get_resc()
1018 u32 *resc_num = p_hwfn->hw_info.resc_num; in qed_hw_get_resc()
1021 num_funcs = IS_MF(p_hwfn) ? MAX_NUM_PFS_BB in qed_hw_get_resc()
1022 : p_hwfn->cdev->num_ports_in_engines; in qed_hw_get_resc()
1026 qed_int_get_num_sbs(p_hwfn, NULL)); in qed_hw_get_resc()
1038 resc_start[i] = resc_num[i] * p_hwfn->rel_pf_id; in qed_hw_get_resc()
1040 qed_hw_set_feat(p_hwfn); in qed_hw_get_resc()
1042 DP_VERBOSE(p_hwfn, NETIF_MSG_PROBE, in qed_hw_get_resc()
1052 p_hwfn->hw_info.resc_num[QED_SB], in qed_hw_get_resc()
1053 p_hwfn->hw_info.resc_start[QED_SB], in qed_hw_get_resc()
1054 p_hwfn->hw_info.resc_num[QED_L2_QUEUE], in qed_hw_get_resc()
1055 p_hwfn->hw_info.resc_start[QED_L2_QUEUE], in qed_hw_get_resc()
1056 p_hwfn->hw_info.resc_num[QED_VPORT], in qed_hw_get_resc()
1057 p_hwfn->hw_info.resc_start[QED_VPORT], in qed_hw_get_resc()
1058 p_hwfn->hw_info.resc_num[QED_PQ], in qed_hw_get_resc()
1059 p_hwfn->hw_info.resc_start[QED_PQ], in qed_hw_get_resc()
1060 p_hwfn->hw_info.resc_num[QED_RL], in qed_hw_get_resc()
1061 p_hwfn->hw_info.resc_start[QED_RL], in qed_hw_get_resc()
1062 p_hwfn->hw_info.resc_num[QED_MAC], in qed_hw_get_resc()
1063 p_hwfn->hw_info.resc_start[QED_MAC], in qed_hw_get_resc()
1064 p_hwfn->hw_info.resc_num[QED_VLAN], in qed_hw_get_resc()
1065 p_hwfn->hw_info.resc_start[QED_VLAN], in qed_hw_get_resc()
1066 p_hwfn->hw_info.resc_num[QED_ILT], in qed_hw_get_resc()
1067 p_hwfn->hw_info.resc_start[QED_ILT]); in qed_hw_get_resc()
1070 static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn, in qed_hw_get_nvm_info() argument
1078 nvm_cfg_addr = qed_rd(p_hwfn, p_ptt, MISC_REG_GEN_PURP_CR0); in qed_hw_get_nvm_info()
1082 DP_NOTICE(p_hwfn, "Shared memory not initialized\n"); in qed_hw_get_nvm_info()
1087 nvm_cfg1_offset = qed_rd(p_hwfn, p_ptt, nvm_cfg_addr + 4); in qed_hw_get_nvm_info()
1093 p_hwfn->hw_info.vendor_id = qed_rd(p_hwfn, p_ptt, addr) & in qed_hw_get_nvm_info()
1100 core_cfg = qed_rd(p_hwfn, p_ptt, addr); in qed_hw_get_nvm_info()
1105 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_2X40G; in qed_hw_get_nvm_info()
1108 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_2X50G; in qed_hw_get_nvm_info()
1111 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_1X100G; in qed_hw_get_nvm_info()
1114 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_4X10G_F; in qed_hw_get_nvm_info()
1117 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_4X10G_E; in qed_hw_get_nvm_info()
1120 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_4X20G; in qed_hw_get_nvm_info()
1123 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_1X40G; in qed_hw_get_nvm_info()
1126 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_2X25G; in qed_hw_get_nvm_info()
1129 p_hwfn->hw_info.port_mode = QED_PORT_MODE_DE_1X25G; in qed_hw_get_nvm_info()
1132 DP_NOTICE(p_hwfn, "Unknown port mode in 0x%08x\n", in qed_hw_get_nvm_info()
1138 offsetof(struct nvm_cfg1, func[MCP_PF_ID(p_hwfn)]) + in qed_hw_get_nvm_info()
1140 val = qed_rd(p_hwfn, p_ptt, addr); in qed_hw_get_nvm_info()
1142 if (IS_MF(p_hwfn)) { in qed_hw_get_nvm_info()
1143 p_hwfn->hw_info.device_id = in qed_hw_get_nvm_info()
1147 p_hwfn->hw_info.device_id = in qed_hw_get_nvm_info()
1153 link = &p_hwfn->mcp_info->link_input; in qed_hw_get_nvm_info()
1155 offsetof(struct nvm_cfg1, port[MFW_PORT(p_hwfn)]); in qed_hw_get_nvm_info()
1156 link_temp = qed_rd(p_hwfn, p_ptt, in qed_hw_get_nvm_info()
1162 p_hwfn->mcp_info->link_capabilities.speed_capabilities = in qed_hw_get_nvm_info()
1165 link_temp = qed_rd(p_hwfn, p_ptt, in qed_hw_get_nvm_info()
1192 DP_NOTICE(p_hwfn, "Unknown Speed in 0x%08x\n", in qed_hw_get_nvm_info()
1206 DP_VERBOSE(p_hwfn, NETIF_MSG_LINK, in qed_hw_get_nvm_info()
1216 generic_cont0 = qed_rd(p_hwfn, p_ptt, addr); in qed_hw_get_nvm_info()
1223 p_hwfn->cdev->mf_mode = MF_OVLAN; in qed_hw_get_nvm_info()
1226 p_hwfn->cdev->mf_mode = MF_NPAR; in qed_hw_get_nvm_info()
1229 p_hwfn->cdev->mf_mode = SF; in qed_hw_get_nvm_info()
1232 DP_INFO(p_hwfn, "Multi function mode is %08x\n", in qed_hw_get_nvm_info()
1233 p_hwfn->cdev->mf_mode); in qed_hw_get_nvm_info()
1235 return qed_mcp_fill_shmem_func_info(p_hwfn, p_ptt); in qed_hw_get_nvm_info()
1239 qed_get_hw_info(struct qed_hwfn *p_hwfn, in qed_get_hw_info() argument
1247 port_mode = qed_rd(p_hwfn, p_ptt, in qed_get_hw_info()
1251 p_hwfn->cdev->num_ports_in_engines = 1; in qed_get_hw_info()
1253 p_hwfn->cdev->num_ports_in_engines = 2; in qed_get_hw_info()
1255 DP_NOTICE(p_hwfn, "PORT MODE: %d not supported\n", in qed_get_hw_info()
1256 p_hwfn->cdev->num_ports_in_engines); in qed_get_hw_info()
1259 p_hwfn->cdev->num_ports_in_engines = 1; in qed_get_hw_info()
1262 qed_hw_get_nvm_info(p_hwfn, p_ptt); in qed_get_hw_info()
1264 rc = qed_int_igu_read_cam(p_hwfn, p_ptt); in qed_get_hw_info()
1268 if (qed_mcp_is_init(p_hwfn)) in qed_get_hw_info()
1269 ether_addr_copy(p_hwfn->hw_info.hw_mac_addr, in qed_get_hw_info()
1270 p_hwfn->mcp_info->func_info.mac); in qed_get_hw_info()
1272 eth_random_addr(p_hwfn->hw_info.hw_mac_addr); in qed_get_hw_info()
1274 if (qed_mcp_is_init(p_hwfn)) { in qed_get_hw_info()
1275 if (p_hwfn->mcp_info->func_info.ovlan != QED_MCP_VLAN_UNSET) in qed_get_hw_info()
1276 p_hwfn->hw_info.ovlan = in qed_get_hw_info()
1277 p_hwfn->mcp_info->func_info.ovlan; in qed_get_hw_info()
1279 qed_mcp_cmd_port_init(p_hwfn, p_ptt); in qed_get_hw_info()
1282 if (qed_mcp_is_init(p_hwfn)) { in qed_get_hw_info()
1285 protocol = p_hwfn->mcp_info->func_info.protocol; in qed_get_hw_info()
1286 p_hwfn->hw_info.personality = protocol; in qed_get_hw_info()
1289 qed_hw_get_resc(p_hwfn); in qed_get_hw_info()
1328 static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn, in qed_hw_prepare_single() argument
1336 p_hwfn->regview = p_regview; in qed_hw_prepare_single()
1337 p_hwfn->doorbells = p_doorbells; in qed_hw_prepare_single()
1340 if (REG_RD(p_hwfn, PXP_PF_ME_OPAQUE_ADDR) == 0xffffffff) { in qed_hw_prepare_single()
1341 DP_ERR(p_hwfn, in qed_hw_prepare_single()
1346 get_function_id(p_hwfn); in qed_hw_prepare_single()
1348 rc = qed_hw_hwfn_prepare(p_hwfn); in qed_hw_prepare_single()
1350 DP_NOTICE(p_hwfn, "Failed to prepare hwfn's hw\n"); in qed_hw_prepare_single()
1355 if (!p_hwfn->my_id) in qed_hw_prepare_single()
1356 qed_get_dev_info(p_hwfn->cdev); in qed_hw_prepare_single()
1359 rc = qed_mcp_cmd_init(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_prepare_single()
1361 DP_NOTICE(p_hwfn, "Failed initializing mcp command\n"); in qed_hw_prepare_single()
1366 rc = qed_get_hw_info(p_hwfn, p_hwfn->p_main_ptt, personality); in qed_hw_prepare_single()
1368 DP_NOTICE(p_hwfn, "Failed to get HW information\n"); in qed_hw_prepare_single()
1373 rc = qed_init_alloc(p_hwfn); in qed_hw_prepare_single()
1375 DP_NOTICE(p_hwfn, "Failed to allocate the init array\n"); in qed_hw_prepare_single()
1381 qed_mcp_free(p_hwfn); in qed_hw_prepare_single()
1383 qed_hw_hwfn_free(p_hwfn); in qed_hw_prepare_single()
1388 static u32 qed_hw_bar_size(struct qed_hwfn *p_hwfn, in qed_hw_bar_size() argument
1393 u32 val = qed_rd(p_hwfn, p_hwfn->p_main_ptt, bar_reg); in qed_hw_bar_size()
1402 struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); in qed_hw_prepare() local
1409 rc = qed_hw_prepare_single(p_hwfn, in qed_hw_prepare()
1415 personality = p_hwfn->hw_info.personality; in qed_hw_prepare()
1423 addr = cdev->regview + qed_hw_bar_size(p_hwfn, 0) / 2; in qed_hw_prepare()
1427 addr = cdev->doorbells + qed_hw_bar_size(p_hwfn, 1) / 2; in qed_hw_prepare()
1438 qed_init_free(p_hwfn); in qed_hw_prepare()
1439 qed_mcp_free(p_hwfn); in qed_hw_prepare()
1440 qed_hw_hwfn_free(p_hwfn); in qed_hw_prepare()
1452 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_hw_remove() local
1454 qed_init_free(p_hwfn); in qed_hw_remove()
1455 qed_hw_hwfn_free(p_hwfn); in qed_hw_remove()
1456 qed_mcp_free(p_hwfn); in qed_hw_remove()
1547 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in __qed_get_vport_stats() local
1553 struct qed_ptt *p_ptt = qed_ptt_acquire(p_hwfn); in __qed_get_vport_stats()
1556 DP_ERR(p_hwfn, "Failed to acquire ptt\n"); in __qed_get_vport_stats()
1561 qed_memcpy_from(p_hwfn, p_ptt, &mstats, in __qed_get_vport_stats()
1562 p_hwfn->storm_stats.mstats.address, in __qed_get_vport_stats()
1563 p_hwfn->storm_stats.mstats.len); in __qed_get_vport_stats()
1566 qed_memcpy_from(p_hwfn, p_ptt, &ustats, in __qed_get_vport_stats()
1567 p_hwfn->storm_stats.ustats.address, in __qed_get_vport_stats()
1568 p_hwfn->storm_stats.ustats.len); in __qed_get_vport_stats()
1571 qed_memcpy_from(p_hwfn, p_ptt, &pstats, in __qed_get_vport_stats()
1572 p_hwfn->storm_stats.pstats.address, in __qed_get_vport_stats()
1573 p_hwfn->storm_stats.pstats.len); in __qed_get_vport_stats()
1576 qed_memcpy_from(p_hwfn, p_ptt, &tstats, in __qed_get_vport_stats()
1577 p_hwfn->storm_stats.tstats.address, in __qed_get_vport_stats()
1578 p_hwfn->storm_stats.tstats.len); in __qed_get_vport_stats()
1582 if (p_hwfn->mcp_info) in __qed_get_vport_stats()
1583 qed_memcpy_from(p_hwfn, p_ptt, &port_stats, in __qed_get_vport_stats()
1584 p_hwfn->mcp_info->port_addr + in __qed_get_vport_stats()
1587 qed_ptt_release(p_hwfn, p_ptt); in __qed_get_vport_stats()
1715 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_reset_vport_stats() local
1719 struct qed_ptt *p_ptt = qed_ptt_acquire(p_hwfn); in qed_reset_vport_stats()
1722 DP_ERR(p_hwfn, "Failed to acquire ptt\n"); in qed_reset_vport_stats()
1727 qed_memcpy_to(p_hwfn, p_ptt, in qed_reset_vport_stats()
1728 p_hwfn->storm_stats.mstats.address, in qed_reset_vport_stats()
1730 p_hwfn->storm_stats.mstats.len); in qed_reset_vport_stats()
1733 qed_memcpy_to(p_hwfn, p_ptt, in qed_reset_vport_stats()
1734 p_hwfn->storm_stats.ustats.address, in qed_reset_vport_stats()
1736 p_hwfn->storm_stats.ustats.len); in qed_reset_vport_stats()
1739 qed_memcpy_to(p_hwfn, p_ptt, in qed_reset_vport_stats()
1740 p_hwfn->storm_stats.pstats.address, in qed_reset_vport_stats()
1742 p_hwfn->storm_stats.pstats.len); in qed_reset_vport_stats()
1744 qed_ptt_release(p_hwfn, p_ptt); in qed_reset_vport_stats()
1756 int qed_fw_l2_queue(struct qed_hwfn *p_hwfn, in qed_fw_l2_queue() argument
1759 if (src_id >= RESC_NUM(p_hwfn, QED_L2_QUEUE)) { in qed_fw_l2_queue()
1762 min = (u16)RESC_START(p_hwfn, QED_L2_QUEUE); in qed_fw_l2_queue()
1763 max = min + RESC_NUM(p_hwfn, QED_L2_QUEUE); in qed_fw_l2_queue()
1764 DP_NOTICE(p_hwfn, in qed_fw_l2_queue()
1771 *dst_id = RESC_START(p_hwfn, QED_L2_QUEUE) + src_id; in qed_fw_l2_queue()
1776 int qed_fw_vport(struct qed_hwfn *p_hwfn, in qed_fw_vport() argument
1779 if (src_id >= RESC_NUM(p_hwfn, QED_VPORT)) { in qed_fw_vport()
1782 min = (u8)RESC_START(p_hwfn, QED_VPORT); in qed_fw_vport()
1783 max = min + RESC_NUM(p_hwfn, QED_VPORT); in qed_fw_vport()
1784 DP_NOTICE(p_hwfn, in qed_fw_vport()
1791 *dst_id = RESC_START(p_hwfn, QED_VPORT) + src_id; in qed_fw_vport()
1796 int qed_fw_rss_eng(struct qed_hwfn *p_hwfn, in qed_fw_rss_eng() argument
1799 if (src_id >= RESC_NUM(p_hwfn, QED_RSS_ENG)) { in qed_fw_rss_eng()
1802 min = (u8)RESC_START(p_hwfn, QED_RSS_ENG); in qed_fw_rss_eng()
1803 max = min + RESC_NUM(p_hwfn, QED_RSS_ENG); in qed_fw_rss_eng()
1804 DP_NOTICE(p_hwfn, in qed_fw_rss_eng()
1811 *dst_id = RESC_START(p_hwfn, QED_RSS_ENG) + src_id; in qed_fw_rss_eng()