Lines Matching +full:hsi +full:- +full:mac
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
11 #include <linux/dma-mapping.h>
72 db_entry->db_addr, in qed_db_recovery_dp_entry()
73 db_entry->db_data, in qed_db_recovery_dp_entry()
74 db_entry->db_width == DB_REC_WIDTH_32B ? "32b" : "64b", in qed_db_recovery_dp_entry()
75 db_entry->db_space == DB_REC_USER ? "user" : "kernel", in qed_db_recovery_dp_entry()
76 db_entry->hwfn_idx); in qed_db_recovery_dp_entry()
88 if (db_addr < cdev->doorbells || in qed_db_rec_sanity()
90 (u8 __iomem *)cdev->doorbells + cdev->db_size) { in qed_db_rec_sanity()
94 cdev->doorbells, in qed_db_rec_sanity()
95 (u8 __iomem *)cdev->doorbells + cdev->db_size); in qed_db_rec_sanity()
115 if (cdev->num_hwfns > 1) in qed_db_rec_find_hwfn()
116 p_hwfn = db_addr < cdev->hwfns[1].doorbells ? in qed_db_rec_find_hwfn()
117 &cdev->hwfns[0] : &cdev->hwfns[1]; in qed_db_rec_find_hwfn()
137 QED_MSG_IOV, "db recovery - skipping VF doorbell\n"); in qed_db_recovery_add()
143 return -EINVAL; in qed_db_recovery_add()
152 return -ENOMEM; in qed_db_recovery_add()
156 db_entry->db_addr = db_addr; in qed_db_recovery_add()
157 db_entry->db_data = db_data; in qed_db_recovery_add()
158 db_entry->db_width = db_width; in qed_db_recovery_add()
159 db_entry->db_space = db_space; in qed_db_recovery_add()
160 db_entry->hwfn_idx = p_hwfn->my_id; in qed_db_recovery_add()
166 spin_lock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_add()
167 list_add_tail(&db_entry->list_entry, &p_hwfn->db_recovery_info.list); in qed_db_recovery_add()
168 spin_unlock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_add()
179 int rc = -EINVAL; in qed_db_recovery_del()
184 QED_MSG_IOV, "db recovery - skipping VF doorbell\n"); in qed_db_recovery_del()
192 spin_lock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_del()
194 &p_hwfn->db_recovery_info.list, list_entry) { in qed_db_recovery_del()
196 if (db_entry->db_data == db_data) { in qed_db_recovery_del()
198 list_del(&db_entry->list_entry); in qed_db_recovery_del()
204 spin_unlock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_del()
206 if (rc == -EINVAL) in qed_db_recovery_del()
223 if (!p_hwfn->cdev->db_size) { in qed_db_recovery_setup()
224 DP_ERR(p_hwfn->cdev, "db_size not set\n"); in qed_db_recovery_setup()
225 return -EINVAL; in qed_db_recovery_setup()
228 INIT_LIST_HEAD(&p_hwfn->db_recovery_info.list); in qed_db_recovery_setup()
229 spin_lock_init(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_setup()
230 p_hwfn->db_recovery_info.db_recovery_counter = 0; in qed_db_recovery_setup()
241 if (!list_empty(&p_hwfn->db_recovery_info.list)) { in qed_db_recovery_teardown()
245 while (!list_empty(&p_hwfn->db_recovery_info.list)) { in qed_db_recovery_teardown()
247 list_first_entry(&p_hwfn->db_recovery_info.list, in qed_db_recovery_teardown()
251 list_del(&db_entry->list_entry); in qed_db_recovery_teardown()
255 p_hwfn->db_recovery_info.db_recovery_counter = 0; in qed_db_recovery_teardown()
265 p_hwfn->db_recovery_info.db_recovery_counter); in qed_db_recovery_dp()
268 spin_lock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_dp()
270 &p_hwfn->db_recovery_info.list, list_entry) { in qed_db_recovery_dp()
274 spin_unlock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_dp()
282 if (db_entry->db_width == DB_REC_WIDTH_32B) { in qed_db_recovery_ring()
285 db_entry->db_addr, in qed_db_recovery_ring()
286 *(u32 *)db_entry->db_data); in qed_db_recovery_ring()
290 db_entry->db_addr, in qed_db_recovery_ring()
291 *(u64 *)(db_entry->db_data)); in qed_db_recovery_ring()
295 if (!qed_db_rec_sanity(p_hwfn->cdev, db_entry->db_addr, in qed_db_recovery_ring()
296 db_entry->db_width, db_entry->db_data)) in qed_db_recovery_ring()
306 if (db_entry->db_width == DB_REC_WIDTH_32B) in qed_db_recovery_ring()
307 DIRECT_REG_WR(db_entry->db_addr, in qed_db_recovery_ring()
308 *(u32 *)(db_entry->db_data)); in qed_db_recovery_ring()
310 DIRECT_REG_WR64(db_entry->db_addr, in qed_db_recovery_ring()
311 *(u64 *)(db_entry->db_data)); in qed_db_recovery_ring()
325 p_hwfn->db_recovery_info.db_recovery_counter); in qed_db_recovery_execute()
328 p_hwfn->db_recovery_info.db_recovery_counter++; in qed_db_recovery_execute()
331 spin_lock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_execute()
333 &p_hwfn->db_recovery_info.list, list_entry) in qed_db_recovery_execute()
335 spin_unlock_bh(&p_hwfn->db_recovery_info.lock); in qed_db_recovery_execute()
358 struct qed_llh_mac_filter mac; member
385 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in qed_llh_free()
389 if (p_llh_info->pp_filters) in qed_llh_free()
390 for (i = 0; i < p_llh_info->num_ppfid; i++) in qed_llh_free()
391 kfree(p_llh_info->pp_filters[i]); in qed_llh_free()
393 kfree(p_llh_info->pp_filters); in qed_llh_free()
397 cdev->p_llh_info = NULL; in qed_llh_free()
407 return -ENOMEM; in qed_llh_alloc()
408 cdev->p_llh_info = p_llh_info; in qed_llh_alloc()
411 if (!(cdev->ppfid_bitmap & (0x1 << i))) in qed_llh_alloc()
414 p_llh_info->ppfid_array[p_llh_info->num_ppfid] = i; in qed_llh_alloc()
416 p_llh_info->num_ppfid, i); in qed_llh_alloc()
417 p_llh_info->num_ppfid++; in qed_llh_alloc()
420 size = p_llh_info->num_ppfid * sizeof(*p_llh_info->pp_filters); in qed_llh_alloc()
421 p_llh_info->pp_filters = kzalloc(size, GFP_KERNEL); in qed_llh_alloc()
422 if (!p_llh_info->pp_filters) in qed_llh_alloc()
423 return -ENOMEM; in qed_llh_alloc()
426 sizeof(**p_llh_info->pp_filters); in qed_llh_alloc()
427 for (i = 0; i < p_llh_info->num_ppfid; i++) { in qed_llh_alloc()
428 p_llh_info->pp_filters[i] = kzalloc(size, GFP_KERNEL); in qed_llh_alloc()
429 if (!p_llh_info->pp_filters[i]) in qed_llh_alloc()
430 return -ENOMEM; in qed_llh_alloc()
439 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in qed_llh_shadow_sanity()
441 if (ppfid >= p_llh_info->num_ppfid) { in qed_llh_shadow_sanity()
444 action, ppfid, p_llh_info->num_ppfid); in qed_llh_shadow_sanity()
445 return -EINVAL; in qed_llh_shadow_sanity()
452 return -EINVAL; in qed_llh_shadow_sanity()
465 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in qed_llh_shadow_search_filter()
476 p_filters = p_llh_info->pp_filters[ppfid]; in qed_llh_shadow_search_filter()
491 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in qed_llh_shadow_get_free_idx()
502 p_filters = p_llh_info->pp_filters[ppfid]; in qed_llh_shadow_get_free_idx()
520 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in __qed_llh_shadow_add_filter()
528 p_filters = p_llh_info->pp_filters[ppfid]; in __qed_llh_shadow_add_filter()
567 return -EINVAL; in qed_llh_shadow_add_filter()
578 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in __qed_llh_shadow_remove_filter()
586 p_filters = p_llh_info->pp_filters[ppfid]; in __qed_llh_shadow_remove_filter()
590 return -EINVAL; in __qed_llh_shadow_remove_filter()
593 *p_ref_cnt = --p_filters[filter_idx].ref_cnt; in __qed_llh_shadow_remove_filter()
616 return -EINVAL; in qed_llh_shadow_remove_filter()
625 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in qed_llh_abs_ppfid()
627 if (ppfid >= p_llh_info->num_ppfid) { in qed_llh_abs_ppfid()
630 ppfid, p_llh_info->num_ppfid - 1); in qed_llh_abs_ppfid()
632 return -EINVAL; in qed_llh_abs_ppfid()
635 *p_abs_ppfid = p_llh_info->ppfid_array[ppfid]; in qed_llh_abs_ppfid()
643 struct qed_dev *cdev = p_hwfn->cdev; in qed_llh_set_engine_affin()
649 if (rc != 0 && rc != -EOPNOTSUPP) { in qed_llh_set_engine_affin()
657 eng = cdev->fir_affin ? QED_ENG1 : QED_ENG0; in qed_llh_set_engine_affin()
674 eng = cdev->fir_affin ? QED_ENG1 : QED_ENG0; in qed_llh_set_engine_affin()
678 for (ppfid = 0; ppfid < cdev->p_llh_info->num_ppfid; ppfid++) { in qed_llh_set_engine_affin()
689 "LLH: Set the engine affinity of non-RoCE packets as %d\n", in qed_llh_set_engine_affin()
698 struct qed_dev *cdev = p_hwfn->cdev; in qed_llh_hw_init_pf()
702 for (ppfid = 0; ppfid < cdev->p_llh_info->num_ppfid; ppfid++) { in qed_llh_hw_init_pf()
710 qed_wr(p_hwfn, p_ptt, addr, p_hwfn->rel_pf_id); in qed_llh_hw_init_pf()
713 if (test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits) && in qed_llh_hw_init_pf()
716 p_hwfn->hw_info.hw_mac_addr); in qed_llh_hw_init_pf()
719 "Failed to add an LLH filter with the primary MAC\n"); in qed_llh_hw_init_pf()
733 return cdev->p_llh_info->num_ppfid; in qed_llh_get_num_ppfid()
750 return -EAGAIN; in qed_llh_set_ppfid_affinity()
771 rc = -EINVAL; in qed_llh_set_ppfid_affinity()
782 cdev->iwarp_affin = (eng == QED_ENG1) ? 1 : 0; in qed_llh_set_ppfid_affinity()
798 return -EAGAIN; in qed_llh_set_roce_affinity()
817 rc = -EINVAL; in qed_llh_set_roce_affinity()
821 for (ppfid = 0; ppfid < cdev->p_llh_info->num_ppfid; ppfid++) { in qed_llh_set_roce_affinity()
861 * The calculation of PPFID->PFID in AH is based on the relative index in qed_llh_access_filter()
865 if (QED_IS_BB(p_hwfn->cdev)) in qed_llh_access_filter()
868 pfid = abs_ppfid * p_hwfn->cdev->num_ports_in_engine + in qed_llh_access_filter()
871 /* Filter enable - should be done first when removing a filter */ in qed_llh_access_filter()
872 if (!p_details->enable) { in qed_llh_access_filter()
877 qed_wr(p_hwfn, p_ptt, addr, p_details->enable); in qed_llh_access_filter()
880 p_hwfn->rel_pf_id << in qed_llh_access_filter()
891 (u64)(uintptr_t)&p_details->value, in qed_llh_access_filter()
902 qed_wr(p_hwfn, p_ptt, addr, p_details->mode); in qed_llh_access_filter()
906 qed_wr(p_hwfn, p_ptt, addr, p_details->protocol_type); in qed_llh_access_filter()
910 qed_wr(p_hwfn, p_ptt, addr, p_details->hdr_sel); in qed_llh_access_filter()
912 /* Filter enable - should be done last when adding a filter */ in qed_llh_access_filter()
913 if (p_details->enable) { in qed_llh_access_filter()
915 qed_wr(p_hwfn, p_ptt, addr, p_details->enable); in qed_llh_access_filter()
919 p_hwfn->rel_pf_id << in qed_llh_access_filter()
937 /* Mode: 0: MAC-address classification 1: protocol classification */ in qed_llh_add_filter()
965 return -EAGAIN; in qed_llh_add_mac_filter()
967 if (!test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits)) in qed_llh_add_mac_filter()
970 memcpy(filter.mac.addr, mac_addr, ETH_ALEN); in qed_llh_add_mac_filter()
994 "LLH: Added MAC filter [%pM] to ppfid %hhd [abs %hhd] at idx %hhd [ref_cnt %d]\n", in qed_llh_add_mac_filter()
1000 "LLH: Failed to add MAC filter [%pM] to ppfid %hhd\n", in qed_llh_add_mac_filter()
1044 return -EINVAL; in qed_llh_protocol_filter_stringify()
1078 return -EINVAL; in qed_llh_protocol_filter_to_hilo()
1098 return -EAGAIN; in qed_llh_add_protocol_filter()
1100 if (!test_bit(QED_MF_LLH_PROTO_CLSS, &cdev->mf_bits)) in qed_llh_add_protocol_filter()
1167 if (!test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits)) in qed_llh_remove_mac_filter()
1173 ether_addr_copy(filter.mac.addr, mac_addr); in qed_llh_remove_mac_filter()
1193 "LLH: Removed MAC filter [%pM] from ppfid %hhd [abs %hhd] at idx %hhd [ref_cnt %d]\n", in qed_llh_remove_mac_filter()
1199 "LLH: Failed to remove MAC filter [%pM] from ppfid %hhd\n", in qed_llh_remove_mac_filter()
1220 if (!test_bit(QED_MF_LLH_PROTO_CLSS, &cdev->mf_bits)) in qed_llh_remove_protocol_filter()
1263 /******************************* NIG LLH - End ********************************/
1275 if (IS_VF(p_hwfn->cdev)) in qed_hw_bar_size()
1283 if (p_hwfn->cdev->num_hwfns > 1) { in qed_hw_bar_size()
1298 cdev->dp_level = dp_level; in qed_init_dp()
1299 cdev->dp_module = dp_module; in qed_init_dp()
1301 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_init_dp()
1303 p_hwfn->dp_level = dp_level; in qed_init_dp()
1304 p_hwfn->dp_module = dp_module; in qed_init_dp()
1313 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_init_struct()
1315 p_hwfn->cdev = cdev; in qed_init_struct()
1316 p_hwfn->my_id = i; in qed_init_struct()
1317 p_hwfn->b_active = false; in qed_init_struct()
1319 mutex_init(&p_hwfn->dmae_info.mutex); in qed_init_struct()
1323 cdev->hwfns[0].b_active = true; in qed_init_struct()
1326 cdev->cache_shift = 7; in qed_init_struct()
1331 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_qm_info_free()
1333 kfree(qm_info->qm_pq_params); in qed_qm_info_free()
1334 qm_info->qm_pq_params = NULL; in qed_qm_info_free()
1335 kfree(qm_info->qm_vport_params); in qed_qm_info_free()
1336 qm_info->qm_vport_params = NULL; in qed_qm_info_free()
1337 kfree(qm_info->qm_port_params); in qed_qm_info_free()
1338 qm_info->qm_port_params = NULL; in qed_qm_info_free()
1339 kfree(qm_info->wfq_data); in qed_qm_info_free()
1340 qm_info->wfq_data = NULL; in qed_qm_info_free()
1345 kfree(p_hwfn->dbg_user_info); in qed_dbg_user_data_free()
1346 p_hwfn->dbg_user_info = NULL; in qed_dbg_user_data_free()
1357 qed_l2_free(&cdev->hwfns[i]); in qed_resc_free()
1361 kfree(cdev->fw_data); in qed_resc_free()
1362 cdev->fw_data = NULL; in qed_resc_free()
1364 kfree(cdev->reset_stats); in qed_resc_free()
1365 cdev->reset_stats = NULL; in qed_resc_free()
1370 p_hwfn = cdev->hwfns + i; in qed_resc_free()
1371 rdma_info = p_hwfn->p_rdma_info; in qed_resc_free()
1382 if (p_hwfn->hw_info.personality == QED_PCI_FCOE) in qed_resc_free()
1385 if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { in qed_resc_free()
1390 if (p_hwfn->hw_info.personality == QED_PCI_NVMETCP) { in qed_resc_free()
1396 qed_spq_unregister_async_cb(p_hwfn, rdma_info->proto); in qed_resc_free()
1406 qed_fw_overlay_mem_free(p_hwfn, &p_hwfn->fw_overlay_mem); in qed_resc_free()
1426 if (IS_QED_SRIOV(p_hwfn->cdev)) in qed_get_pq_flags()
1430 switch (p_hwfn->hw_info.personality) { in qed_get_pq_flags()
1452 "unknown personality %d\n", p_hwfn->hw_info.personality); in qed_get_pq_flags()
1462 return p_hwfn->hw_info.num_hw_tc; in qed_init_qm_get_num_tcs()
1467 return IS_QED_SRIOV(p_hwfn->cdev) ? in qed_init_qm_get_num_vfs()
1468 p_hwfn->cdev->p_iov_info->total_vfs : 0; in qed_init_qm_get_num_vfs()
1496 num_pf_rls -= num_vfs + NUM_DEFAULT_RLS; in qed_init_qm_get_num_pf_rls()
1533 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_params()
1537 qm_info->start_pq = (u16)RESC_START(p_hwfn, QED_PQ); in qed_init_qm_params()
1538 qm_info->start_vport = (u8)RESC_START(p_hwfn, QED_VPORT); in qed_init_qm_params()
1541 qm_info->vport_rl_en = true; in qed_init_qm_params()
1542 qm_info->vport_wfq_en = true; in qed_init_qm_params()
1545 four_port = p_hwfn->cdev->num_ports_in_engine == MAX_NUM_PORTS_K2; in qed_init_qm_params()
1548 qm_info->max_phys_tcs_per_port = four_port ? NUM_PHYS_TCS_4PORT_K2 : in qed_init_qm_params()
1552 * AH 4-port and 4 otherwise. in qed_init_qm_params()
1554 if (!qm_info->ooo_tc) in qed_init_qm_params()
1555 qm_info->ooo_tc = four_port ? DCBX_TCP_OOO_K2_4PORT_TC : in qed_init_qm_params()
1562 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_vport_params()
1567 qm_info->qm_vport_params[i].wfq = 1; in qed_init_qm_vport_params()
1574 u8 i, active_phys_tcs, num_ports = p_hwfn->cdev->num_ports_in_engine; in qed_init_qm_port_params()
1575 struct qed_dev *cdev = p_hwfn->cdev; in qed_init_qm_port_params()
1584 &p_hwfn->qm_info.qm_port_params[i]; in qed_init_qm_port_params()
1587 p_qm_port->active = 1; in qed_init_qm_port_params()
1588 p_qm_port->active_phys_tcs = active_phys_tcs; in qed_init_qm_port_params()
1590 p_qm_port->num_pbf_cmd_lines = pbf_max_cmd_lines / num_ports; in qed_init_qm_port_params()
1591 p_qm_port->num_btb_blocks = NUM_OF_BTB_BLOCKS(cdev) / num_ports; in qed_init_qm_port_params()
1603 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_reset_params()
1605 qm_info->num_pqs = 0; in qed_init_qm_reset_params()
1606 qm_info->num_vports = 0; in qed_init_qm_reset_params()
1607 qm_info->num_pf_rls = 0; in qed_init_qm_reset_params()
1608 qm_info->num_vf_pqs = 0; in qed_init_qm_reset_params()
1609 qm_info->first_vf_pq = 0; in qed_init_qm_reset_params()
1610 qm_info->first_mcos_pq = 0; in qed_init_qm_reset_params()
1611 qm_info->first_rl_pq = 0; in qed_init_qm_reset_params()
1616 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_advance_vport()
1618 qm_info->num_vports++; in qed_init_qm_advance_vport()
1620 if (qm_info->num_vports > qed_init_qm_get_num_vports(p_hwfn)) in qed_init_qm_advance_vport()
1622 "vport overflow! qm_info->num_vports %d, qm_init_get_num_vports() %d\n", in qed_init_qm_advance_vport()
1623 qm_info->num_vports, qed_init_qm_get_num_vports(p_hwfn)); in qed_init_qm_advance_vport()
1643 p_info->offload_tc = tc; in qed_hw_info_set_offload_tc()
1644 p_info->offload_tc_set = true; in qed_hw_info_set_offload_tc()
1649 return p_hwfn->hw_info.offload_tc_set; in qed_is_offload_tc_set()
1655 return p_hwfn->hw_info.offload_tc; in qed_get_offload_tc()
1664 u16 pq_idx = qm_info->num_pqs, max_pq = qed_init_qm_get_num_pqs(p_hwfn); in qed_init_qm_pq()
1671 qm_info->qm_pq_params[pq_idx].port_id = p_hwfn->port_id; in qed_init_qm_pq()
1672 qm_info->qm_pq_params[pq_idx].vport_id = qm_info->start_vport + in qed_init_qm_pq()
1673 qm_info->num_vports; in qed_init_qm_pq()
1674 qm_info->qm_pq_params[pq_idx].tc_id = tc; in qed_init_qm_pq()
1675 qm_info->qm_pq_params[pq_idx].wrr_group = PQ_INIT_DEFAULT_WRR_GROUP; in qed_init_qm_pq()
1676 qm_info->qm_pq_params[pq_idx].rl_valid = in qed_init_qm_pq()
1680 qm_info->num_pqs++; in qed_init_qm_pq()
1682 qm_info->num_vports++; in qed_init_qm_pq()
1685 qm_info->num_pf_rls++; in qed_init_qm_pq()
1687 if (qm_info->num_vports > qed_init_qm_get_num_vports(p_hwfn)) in qed_init_qm_pq()
1689 "vport overflow! qm_info->num_vports %d, qm_init_get_num_vports() %d\n", in qed_init_qm_pq()
1690 qm_info->num_vports, qed_init_qm_get_num_vports(p_hwfn)); in qed_init_qm_pq()
1692 if (qm_info->num_pf_rls > qed_init_qm_get_num_pf_rls(p_hwfn)) in qed_init_qm_pq()
1694 "rl overflow! qm_info->num_pf_rls %d, qm_init_get_num_pf_rls() %d\n", in qed_init_qm_pq()
1695 qm_info->num_pf_rls, qed_init_qm_get_num_pf_rls(p_hwfn)); in qed_init_qm_pq()
1702 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_get_idx_from_flags()
1718 return &qm_info->first_rl_pq; in qed_init_qm_get_idx_from_flags()
1720 return &qm_info->first_mcos_pq; in qed_init_qm_get_idx_from_flags()
1722 return &qm_info->pure_lb_pq; in qed_init_qm_get_idx_from_flags()
1724 return &qm_info->ooo_pq; in qed_init_qm_get_idx_from_flags()
1726 return &qm_info->pure_ack_pq; in qed_init_qm_get_idx_from_flags()
1728 return &qm_info->first_ofld_pq; in qed_init_qm_get_idx_from_flags()
1730 return &qm_info->first_llt_pq; in qed_init_qm_get_idx_from_flags()
1732 return &qm_info->first_vf_pq; in qed_init_qm_get_idx_from_flags()
1738 return &qm_info->start_pq; in qed_init_qm_get_idx_from_flags()
1747 *base_pq_idx = p_hwfn->qm_info.start_pq + pq_val; in qed_init_qm_set_idx()
1765 return p_hwfn->qm_info.start_pq; in qed_get_cm_pq_idx_mcos()
1781 return p_hwfn->qm_info.start_pq; in qed_get_cm_pq_idx_vf()
1815 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_lb_pq()
1820 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_LB, qm_info->num_pqs); in qed_init_qm_lb_pq()
1826 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_ooo_pq()
1831 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_OOO, qm_info->num_pqs); in qed_init_qm_ooo_pq()
1832 qed_init_qm_pq(p_hwfn, qm_info, qm_info->ooo_tc, PQ_INIT_SHARE_VPORT); in qed_init_qm_ooo_pq()
1837 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_pure_ack_pq()
1842 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_ACK, qm_info->num_pqs); in qed_init_qm_pure_ack_pq()
1850 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_mtc_pqs()
1857 p_hwfn->hw_info.offload_tc : tc, in qed_init_qm_mtc_pqs()
1863 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_offload_pq()
1868 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_OFLD, qm_info->num_pqs); in qed_init_qm_offload_pq()
1874 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_low_latency_pq()
1879 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_LLT, qm_info->num_pqs); in qed_init_qm_low_latency_pq()
1885 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_mcos_pqs()
1891 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_MCOS, qm_info->num_pqs); in qed_init_qm_mcos_pqs()
1898 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_vf_pqs()
1904 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_VFS, qm_info->num_pqs); in qed_init_qm_vf_pqs()
1905 qm_info->num_vf_pqs = num_vfs; in qed_init_qm_vf_pqs()
1914 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_init_qm_rl_pqs()
1919 qed_init_qm_set_idx(p_hwfn, PQ_FLAGS_RLS, qm_info->num_pqs); in qed_init_qm_rl_pqs()
1960 return -EINVAL; in qed_init_qm_sanity()
1967 p_hwfn->hw_info.multi_tc_roce_en = false; in qed_init_qm_sanity()
1969 "multi-tc roce was disabled to reduce requested amount of pqs\n"); in qed_init_qm_sanity()
1975 return -EINVAL; in qed_init_qm_sanity()
1980 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_dp_init_qm_params()
1990 qm_info->start_pq, in qed_dp_init_qm_params()
1991 qm_info->start_vport, in qed_dp_init_qm_params()
1992 qm_info->pure_lb_pq, in qed_dp_init_qm_params()
1993 qm_info->first_ofld_pq, in qed_dp_init_qm_params()
1994 qm_info->first_llt_pq, in qed_dp_init_qm_params()
1995 qm_info->pure_ack_pq); in qed_dp_init_qm_params()
1999 qm_info->ooo_pq, in qed_dp_init_qm_params()
2000 qm_info->first_vf_pq, in qed_dp_init_qm_params()
2001 qm_info->num_pqs, in qed_dp_init_qm_params()
2002 qm_info->num_vf_pqs, in qed_dp_init_qm_params()
2003 qm_info->num_vports, qm_info->max_phys_tcs_per_port); in qed_dp_init_qm_params()
2007 qm_info->pf_rl_en, in qed_dp_init_qm_params()
2008 qm_info->pf_wfq_en, in qed_dp_init_qm_params()
2009 qm_info->vport_rl_en, in qed_dp_init_qm_params()
2010 qm_info->vport_wfq_en, in qed_dp_init_qm_params()
2011 qm_info->pf_wfq, in qed_dp_init_qm_params()
2012 qm_info->pf_rl, in qed_dp_init_qm_params()
2013 qm_info->num_pf_rls, qed_get_pq_flags(p_hwfn)); in qed_dp_init_qm_params()
2016 for (i = 0; i < p_hwfn->cdev->num_ports_in_engine; i++) { in qed_dp_init_qm_params()
2017 port = &(qm_info->qm_port_params[i]); in qed_dp_init_qm_params()
2022 port->active, in qed_dp_init_qm_params()
2023 port->active_phys_tcs, in qed_dp_init_qm_params()
2024 port->num_pbf_cmd_lines, in qed_dp_init_qm_params()
2025 port->num_btb_blocks, port->reserved); in qed_dp_init_qm_params()
2029 for (i = 0; i < qm_info->num_vports; i++) { in qed_dp_init_qm_params()
2030 vport = &(qm_info->qm_vport_params[i]); in qed_dp_init_qm_params()
2034 qm_info->start_vport + i, vport->wfq); in qed_dp_init_qm_params()
2038 "%d ", vport->first_tx_pq_id[tc]); in qed_dp_init_qm_params()
2043 for (i = 0; i < qm_info->num_pqs; i++) { in qed_dp_init_qm_params()
2044 pq = &(qm_info->qm_pq_params[i]); in qed_dp_init_qm_params()
2048 qm_info->start_pq + i, in qed_dp_init_qm_params()
2049 pq->port_id, in qed_dp_init_qm_params()
2050 pq->vport_id, in qed_dp_init_qm_params()
2051 pq->tc_id, pq->wrr_group, pq->rl_valid, pq->rl_id); in qed_dp_init_qm_params()
2086 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_qm_reconf()
2096 qm_info->start_pq, qm_info->num_pqs); in qed_qm_reconf()
2099 return -EINVAL; in qed_qm_reconf()
2105 rc = qed_init_run(p_hwfn, p_ptt, PHASE_QM_PF, p_hwfn->rel_pf_id, in qed_qm_reconf()
2106 p_hwfn->hw_info.hw_mode); in qed_qm_reconf()
2113 qm_info->start_pq, qm_info->num_pqs); in qed_qm_reconf()
2116 return -EINVAL; in qed_qm_reconf()
2123 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_alloc_qm_data()
2130 qm_info->qm_pq_params = kcalloc(qed_init_qm_get_num_pqs(p_hwfn), in qed_alloc_qm_data()
2131 sizeof(*qm_info->qm_pq_params), in qed_alloc_qm_data()
2133 if (!qm_info->qm_pq_params) in qed_alloc_qm_data()
2136 qm_info->qm_vport_params = kcalloc(qed_init_qm_get_num_vports(p_hwfn), in qed_alloc_qm_data()
2137 sizeof(*qm_info->qm_vport_params), in qed_alloc_qm_data()
2139 if (!qm_info->qm_vport_params) in qed_alloc_qm_data()
2142 qm_info->qm_port_params = kcalloc(p_hwfn->cdev->num_ports_in_engine, in qed_alloc_qm_data()
2143 sizeof(*qm_info->qm_port_params), in qed_alloc_qm_data()
2145 if (!qm_info->qm_port_params) in qed_alloc_qm_data()
2148 qm_info->wfq_data = kcalloc(qed_init_qm_get_num_vports(p_hwfn), in qed_alloc_qm_data()
2149 sizeof(*qm_info->wfq_data), in qed_alloc_qm_data()
2151 if (!qm_info->wfq_data) in qed_alloc_qm_data()
2159 return -ENOMEM; in qed_alloc_qm_data()
2170 rc = qed_l2_alloc(&cdev->hwfns[i]); in qed_resc_alloc()
2177 cdev->fw_data = kzalloc(sizeof(*cdev->fw_data), GFP_KERNEL); in qed_resc_alloc()
2178 if (!cdev->fw_data) in qed_resc_alloc()
2179 return -ENOMEM; in qed_resc_alloc()
2182 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_alloc()
2213 "too many ILT lines; re-computing with less lines\n"); in qed_resc_alloc()
2215 * number of RDMA tasks and re-compute. in qed_resc_alloc()
2222 rdma_tasks = RDMA_MAX_TIDS - excess_tasks; in qed_resc_alloc()
2250 p_hwfn->p_dpc_ptt = qed_get_reserved_ptt(p_hwfn, in qed_resc_alloc()
2253 rc = qed_int_alloc(p_hwfn, p_hwfn->p_main_ptt); in qed_resc_alloc()
2262 n_eqes = qed_chain_get_capacity(&p_hwfn->p_spq->chain); in qed_resc_alloc()
2279 } else if (p_hwfn->hw_info.personality == QED_PCI_ISCSI || in qed_resc_alloc()
2280 p_hwfn->hw_info.personality == QED_PCI_NVMETCP) { in qed_resc_alloc()
2308 if (p_hwfn->using_ll2) { in qed_resc_alloc()
2315 if (p_hwfn->hw_info.personality == QED_PCI_FCOE) { in qed_resc_alloc()
2321 if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { in qed_resc_alloc()
2330 if (p_hwfn->hw_info.personality == QED_PCI_NVMETCP) { in qed_resc_alloc()
2355 rc = qed_dbg_alloc_user_data(p_hwfn, &p_hwfn->dbg_user_info); in qed_resc_alloc()
2367 cdev->reset_stats = kzalloc(sizeof(*cdev->reset_stats), GFP_KERNEL); in qed_resc_alloc()
2368 if (!cdev->reset_stats) in qed_resc_alloc()
2374 rc = -ENOMEM; in qed_resc_alloc()
2388 if (data->err_data.recovery_scope == ERR_SCOPE_FUNC && in qed_fw_err_handler()
2389 le16_to_cpu(data->err_data.entity_id) >= MAX_NUM_PFS) { in qed_fw_err_handler()
2390 qed_sriov_vfpf_malicious(p_hwfn, &data->err_data); in qed_fw_err_handler()
2398 return -EINVAL; in qed_fw_err_handler()
2417 DP_INFO(p_hwfn->cdev, "Unknown eqe event 0x%02x, echo 0x%x\n", in qed_common_eqe_event()
2419 return -EINVAL; in qed_common_eqe_event()
2429 qed_l2_setup(&cdev->hwfns[i]); in qed_resc_setup()
2434 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_resc_setup()
2442 qed_mcp_read_mb(p_hwfn, p_hwfn->p_main_ptt); in qed_resc_setup()
2443 memcpy(p_hwfn->mcp_info->mfw_mb_shadow, in qed_resc_setup()
2444 p_hwfn->mcp_info->mfw_mb_cur, in qed_resc_setup()
2445 p_hwfn->mcp_info->mfw_mb_length); in qed_resc_setup()
2447 qed_int_setup(p_hwfn, p_hwfn->p_main_ptt); in qed_resc_setup()
2454 if (p_hwfn->using_ll2) in qed_resc_setup()
2457 if (p_hwfn->hw_info.personality == QED_PCI_FCOE) in qed_resc_setup()
2460 if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { in qed_resc_setup()
2465 if (p_hwfn->hw_info.personality == QED_PCI_NVMETCP) { in qed_resc_setup()
2478 int rc = -EBUSY; in qed_final_cleanup()
2481 USTORM_FLR_FINAL_ACK, p_hwfn->rel_pf_id); in qed_final_cleanup()
2505 while (!REG_RD(p_hwfn, addr) && count--) in qed_final_cleanup()
2524 if (QED_IS_BB_B0(p_hwfn->cdev)) { in qed_calc_hw_mode()
2526 } else if (QED_IS_AH(p_hwfn->cdev)) { in qed_calc_hw_mode()
2530 p_hwfn->cdev->type); in qed_calc_hw_mode()
2531 return -EINVAL; in qed_calc_hw_mode()
2534 switch (p_hwfn->cdev->num_ports_in_engine) { in qed_calc_hw_mode()
2546 p_hwfn->cdev->num_ports_in_engine); in qed_calc_hw_mode()
2547 return -EINVAL; in qed_calc_hw_mode()
2550 if (test_bit(QED_MF_OVLAN_CLSS, &p_hwfn->cdev->mf_bits)) in qed_calc_hw_mode()
2557 if (p_hwfn->cdev->num_hwfns > 1) in qed_calc_hw_mode()
2560 p_hwfn->hw_info.hw_mode = hw_mode; in qed_calc_hw_mode()
2564 p_hwfn->hw_info.hw_mode); in qed_calc_hw_mode()
2576 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_init_cau_rt_data()
2581 p_igu_info = p_hwfn->hw_info.p_igu_info; in qed_init_cau_rt_data()
2585 p_block = &p_igu_info->entry[igu_sb_id]; in qed_init_cau_rt_data()
2587 if (!p_block->is_pf) in qed_init_cau_rt_data()
2591 p_block->function_id, 0, 0); in qed_init_cau_rt_data()
2656 struct qed_qm_info *qm_info = &p_hwfn->qm_info; in qed_hw_init_common()
2658 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_init_common()
2666 DP_NOTICE(p_hwfn->cdev, in qed_hw_init_common()
2669 return -ENOMEM; in qed_hw_init_common()
2677 if (p_hwfn->mcp_info) { in qed_hw_init_common()
2678 if (p_hwfn->mcp_info->func_info.bandwidth_max) in qed_hw_init_common()
2679 qm_info->pf_rl_en = true; in qed_hw_init_common()
2680 if (p_hwfn->mcp_info->func_info.bandwidth_min) in qed_hw_init_common()
2681 qm_info->pf_wfq_en = true; in qed_hw_init_common()
2684 params->max_ports_per_engine = p_hwfn->cdev->num_ports_in_engine; in qed_hw_init_common()
2685 params->max_phys_tcs_per_port = qm_info->max_phys_tcs_per_port; in qed_hw_init_common()
2686 params->pf_rl_en = qm_info->pf_rl_en; in qed_hw_init_common()
2687 params->pf_wfq_en = qm_info->pf_wfq_en; in qed_hw_init_common()
2688 params->global_rl_en = qm_info->vport_rl_en; in qed_hw_init_common()
2689 params->vport_wfq_en = qm_info->vport_wfq_en; in qed_hw_init_common()
2690 params->port_params = qm_info->qm_port_params; in qed_hw_init_common()
2705 if (QED_IS_BB(p_hwfn->cdev)) { in qed_hw_init_common()
2706 num_pfs = NUM_OF_ENG_PFS(p_hwfn->cdev); in qed_hw_init_common()
2713 qed_fid_pretend(p_hwfn, p_ptt, p_hwfn->rel_pf_id); in qed_hw_init_common()
2726 qed_fid_pretend(p_hwfn, p_ptt, p_hwfn->rel_pf_id); in qed_hw_init_common()
2745 dpi_page_size = (dpi_page_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); in qed_hw_init_dpi_size()
2749 min_dpis = p_hwfn->pf_params.rdma_pf_params.min_dpis; in qed_hw_init_dpi_size()
2752 p_hwfn->dpi_size = dpi_page_size; in qed_hw_init_dpi_size()
2753 p_hwfn->dpi_count = dpi_count; in qed_hw_init_dpi_size()
2758 return -EINVAL; in qed_hw_init_dpi_size()
2771 if (p_hwfn->dcbx_no_edpm || p_hwfn->db_bar_no_edpm) in qed_edpm_enabled()
2789 if (p_hwfn->cdev->num_hwfns > 1) in qed_hw_init_pf_doorbell_bar()
2800 pwm_regsize = db_bar_size - norm_regsize; in qed_hw_init_pf_doorbell_bar()
2804 DP_ERR(p_hwfn->cdev, in qed_hw_init_pf_doorbell_bar()
2807 return -EINVAL; in qed_hw_init_pf_doorbell_bar()
2811 DP_ERR(p_hwfn->cdev, in qed_hw_init_pf_doorbell_bar()
2815 return -EINVAL; in qed_hw_init_pf_doorbell_bar()
2819 roce_edpm_mode = p_hwfn->pf_params.rdma_pf_params.roce_edpm_mode; in qed_hw_init_pf_doorbell_bar()
2831 if (cond || p_hwfn->dcbx_no_edpm) { in qed_hw_init_pf_doorbell_bar()
2843 p_hwfn->wid_count = (u16)n_cpus; in qed_hw_init_pf_doorbell_bar()
2849 p_hwfn->dpi_size, in qed_hw_init_pf_doorbell_bar()
2850 p_hwfn->dpi_count, in qed_hw_init_pf_doorbell_bar()
2857 p_hwfn->dpi_count, in qed_hw_init_pf_doorbell_bar()
2858 p_hwfn->pf_params.rdma_pf_params.min_dpis); in qed_hw_init_pf_doorbell_bar()
2859 return -EINVAL; in qed_hw_init_pf_doorbell_bar()
2862 p_hwfn->dpi_start_offset = norm_regsize; in qed_hw_init_pf_doorbell_bar()
2878 if (!QED_IS_CMT(p_hwfn->cdev) || !IS_LEAD_HWFN(p_hwfn)) in qed_hw_init_port()
2881 rc = qed_init_run(p_hwfn, p_ptt, PHASE_PORT, p_hwfn->port_id, hw_mode); in qed_hw_init_port()
2898 u8 rel_pf_id = p_hwfn->rel_pf_id; in qed_hw_init_pf()
2901 if (p_hwfn->mcp_info) { in qed_hw_init_pf()
2904 p_info = &p_hwfn->mcp_info->func_info; in qed_hw_init_pf()
2905 if (p_info->bandwidth_min) in qed_hw_init_pf()
2906 p_hwfn->qm_info.pf_wfq = p_info->bandwidth_min; in qed_hw_init_pf()
2909 p_hwfn->qm_info.pf_rl = 100000; in qed_hw_init_pf()
2921 p_hwfn->hw_info.ovlan); in qed_hw_init_pf()
2929 /* Enable classification by MAC if needed */ in qed_hw_init_pf()
2939 ((p_hwfn->hw_info.personality == QED_PCI_ISCSI) || in qed_hw_init_pf()
2940 (p_hwfn->hw_info.personality == QED_PCI_NVMETCP)) ? 1 : 0); in qed_hw_init_pf()
2942 (p_hwfn->hw_info.personality == QED_PCI_FCOE) ? 1 : 0); in qed_hw_init_pf()
2960 qed_fw_overlay_init_ram(p_hwfn, p_ptt, p_hwfn->fw_overlay_mem); in qed_hw_init_pf()
2962 /* Pure runtime initializations - directly to the HW */ in qed_hw_init_pf()
2987 if (p_hwfn->hw_info.personality == QED_PCI_FCOE) { in qed_hw_init_pf()
3005 /* Wait until value is set - try for 1 second every 50us */ in qed_pglueb_set_pfid_enable()
3018 return -EAGAIN; in qed_pglueb_set_pfid_enable()
3029 memcpy(p_hwfn->mcp_info->mfw_mb_shadow, in qed_reset_mb_shadow()
3030 p_hwfn->mcp_info->mfw_mb_cur, p_hwfn->mcp_info->mfw_mb_length); in qed_reset_mb_shadow()
3039 p_load_req->drv_role = p_drv_load->is_crash_kernel ? in qed_fill_load_req_params()
3041 p_load_req->timeout_val = p_drv_load->mfw_timeout_val; in qed_fill_load_req_params()
3042 p_load_req->avoid_eng_reset = p_drv_load->avoid_eng_reset; in qed_fill_load_req_params()
3043 p_load_req->override_force_load = p_drv_load->override_force_load; in qed_fill_load_req_params()
3049 if (p_params->p_tunn) { in qed_vf_start()
3050 qed_vf_set_vf_start_tunn_update_param(p_params->p_tunn); in qed_vf_start()
3051 qed_vf_pf_tunnel_param_update(p_hwfn, p_params->p_tunn); in qed_vf_start()
3054 p_hwfn->b_int_enabled = true; in qed_vf_start()
3062 BIT(p_hwfn->abs_pf_id)); in qed_pglueb_clear_err()
3076 if ((p_params->int_mode == QED_INT_MODE_MSI) && (cdev->num_hwfns > 1)) { in qed_hw_init()
3078 return -EINVAL; in qed_hw_init()
3082 rc = qed_init_fw_data(cdev, p_params->bin_fw_data); in qed_hw_init()
3088 p_hwfn = &cdev->hwfns[i]; in qed_hw_init()
3091 if (!p_hwfn->hw_info.mtu) { in qed_hw_init()
3092 p_hwfn->hw_info.mtu = 1500; in qed_hw_init()
3102 p_hwfn->mcp_info->mcp_handling_status = 0; in qed_hw_init()
3109 &cdev->mf_bits) || in qed_hw_init()
3111 &cdev->mf_bits))) { in qed_hw_init()
3112 if (test_bit(QED_MF_8021Q_TAGGING, &cdev->mf_bits)) in qed_hw_init()
3127 p_params->p_drv_load_params); in qed_hw_init()
3128 rc = qed_mcp_load_req(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3143 cdev->recov_in_prog = false; in qed_hw_init()
3145 qed_mcp_set_capabilities(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_init()
3147 qed_reset_mb_shadow(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_init()
3154 rc = qed_final_cleanup(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3155 p_hwfn->rel_pf_id, false); in qed_hw_init()
3157 qed_hw_err_notify(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3165 qed_pglueb_rbc_attn_handler(p_hwfn, p_hwfn->p_main_ptt, true); in qed_hw_init()
3168 rc = qed_pglueb_set_pfid_enable(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3178 qed_pglueb_clear_err(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_init()
3180 fw_overlays = cdev->fw_data->fw_overlays; in qed_hw_init()
3181 fw_overlays_len = cdev->fw_data->fw_overlays_len; in qed_hw_init()
3182 p_hwfn->fw_overlay_mem = in qed_hw_init()
3185 if (!p_hwfn->fw_overlay_mem) { in qed_hw_init()
3188 rc = -ENOMEM; in qed_hw_init()
3194 rc = qed_hw_init_common(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3195 p_hwfn->hw_info.hw_mode); in qed_hw_init()
3200 rc = qed_hw_init_port(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3201 p_hwfn->hw_info.hw_mode); in qed_hw_init()
3207 rc = qed_hw_init_pf(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3208 p_params->p_tunn, in qed_hw_init()
3209 p_hwfn->hw_info.hw_mode, in qed_hw_init()
3210 p_params->b_hw_start, in qed_hw_init()
3211 p_params->int_mode, in qed_hw_init()
3212 p_params->allow_npar_tx_switch); in qed_hw_init()
3217 rc = -EINVAL; in qed_hw_init()
3228 rc = qed_mcp_load_done(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_init()
3236 rc = qed_mcp_cmd(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3246 p_hwfn->hw_init_done = true; in qed_hw_init()
3252 /* Get pre-negotiated values for stag, bandwidth etc. */ in qed_hw_init()
3257 rc = qed_mcp_cmd(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3265 rc = qed_mcp_cmd(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3272 rc = qed_mcp_ov_update_mtu(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3273 p_hwfn->hw_info.mtu); in qed_hw_init()
3280 p_hwfn->p_main_ptt, in qed_hw_init()
3285 rc = qed_mcp_ov_update_eswitch(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_init()
3296 qed_mcp_load_done(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_init()
3310 if (cdev->recov_in_prog) in qed_hw_timers_stop()
3339 struct qed_hwfn *p_hwfn = &cdev->hwfns[j]; in qed_hw_timers_stop_all()
3340 struct qed_ptt *p_ptt = p_hwfn->p_main_ptt; in qed_hw_timers_stop_all()
3354 p_hwfn = &cdev->hwfns[j]; in qed_hw_stop()
3355 p_ptt = p_hwfn->p_main_ptt; in qed_hw_stop()
3366 rc2 = -EINVAL; in qed_hw_stop()
3372 p_hwfn->hw_init_done = false; in qed_hw_stop()
3375 if (!cdev->recov_in_prog) { in qed_hw_stop()
3381 rc2 = -EINVAL; in qed_hw_stop()
3395 rc2 = -EINVAL; in qed_hw_stop()
3425 test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits) && in qed_hw_stop()
3428 p_hwfn->hw_info.hw_mac_addr); in qed_hw_stop()
3430 if (!cdev->recov_in_prog) { in qed_hw_stop()
3436 rc2 = -EINVAL; in qed_hw_stop()
3441 if (IS_PF(cdev) && !cdev->recov_in_prog) { in qed_hw_stop()
3443 p_ptt = QED_LEADING_HWFN(cdev)->p_main_ptt; in qed_hw_stop()
3446 * In CMT this should only be done for first hw-function, and in qed_hw_stop()
3448 * hw-functions. in qed_hw_stop()
3455 rc2 = -EINVAL; in qed_hw_stop()
3467 struct qed_hwfn *p_hwfn = &cdev->hwfns[j]; in qed_hw_stop_fastpath()
3476 return -EAGAIN; in qed_hw_stop_fastpath()
3504 if (IS_VF(p_hwfn->cdev)) in qed_hw_start_fastpath()
3509 return -EAGAIN; in qed_hw_start_fastpath()
3511 if (p_hwfn->p_rdma_info && in qed_hw_start_fastpath()
3512 p_hwfn->p_rdma_info->active && p_hwfn->b_rdma_enabled_in_prs) in qed_hw_start_fastpath()
3513 qed_wr(p_hwfn, p_ptt, p_hwfn->rdma_prs_search_reg, 0x1); in qed_hw_start_fastpath()
3515 /* Re-open incoming traffic */ in qed_hw_start_fastpath()
3526 kfree(p_hwfn->hw_info.p_igu_info); in qed_hw_hwfn_free()
3527 p_hwfn->hw_info.p_igu_info = NULL; in qed_hw_hwfn_free()
3534 if (QED_IS_AH(p_hwfn->cdev)) { in qed_hw_hwfn_prepare()
3535 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3537 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3539 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3541 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3544 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3546 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3548 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3550 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3555 qed_pglueb_clear_err(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_hwfn_prepare()
3557 /* enable internal target-read */ in qed_hw_hwfn_prepare()
3558 qed_wr(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_hwfn_prepare()
3565 p_hwfn->hw_info.opaque_fid = (u16)REG_RD(p_hwfn, in get_function_id()
3568 p_hwfn->hw_info.concrete_fid = REG_RD(p_hwfn, PXP_PF_ME_CONCRETE_ADDR); in get_function_id()
3570 p_hwfn->abs_pf_id = (p_hwfn->hw_info.concrete_fid >> 16) & 0xf; in get_function_id()
3571 p_hwfn->rel_pf_id = GET_FIELD(p_hwfn->hw_info.concrete_fid, in get_function_id()
3573 p_hwfn->port_id = GET_FIELD(p_hwfn->hw_info.concrete_fid, in get_function_id()
3578 p_hwfn->hw_info.concrete_fid, p_hwfn->hw_info.opaque_fid); in get_function_id()
3583 u32 *feat_num = p_hwfn->hw_info.feat_num; in qed_hw_set_feat()
3608 sb_cnt.cnt - non_l2_sbs, in qed_hw_set_feat()
3610 QED_L2_QUEUE) - in qed_hw_set_feat()
3656 return "MAC"; in qed_hw_get_resc_name()
3726 DP_ERR(cdev, "Unexpected HSI definition type [%d]\n", type); in qed_get_hsi_def_val()
3756 NUM_OF_RDMA_STATISTIC_COUNTERS(p_hwfn->cdev); in qed_hw_set_soft_resc_size()
3777 return -EINVAL; in qed_hw_set_soft_resc_size()
3788 u8 num_funcs = p_hwfn->num_funcs_on_engine; in qed_hw_get_dflt_resc()
3789 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_get_dflt_resc()
3810 /* Each VFC resource can accommodate both a MAC and a VLAN */ in qed_hw_get_dflt_resc()
3831 if (p_hwfn->hw_info.personality != QED_PCI_ISCSI && in qed_hw_get_dflt_resc()
3832 p_hwfn->hw_info.personality != QED_PCI_FCOE && in qed_hw_get_dflt_resc()
3833 p_hwfn->hw_info.personality != QED_PCI_NVMETCP) in qed_hw_get_dflt_resc()
3845 return -EINVAL; in qed_hw_get_dflt_resc()
3852 else if (p_hwfn->cdev->num_ports_in_engine == 4) in qed_hw_get_dflt_resc()
3853 *p_resc_start = p_hwfn->port_id; in qed_hw_get_dflt_resc()
3854 else if (p_hwfn->hw_info.personality == QED_PCI_ISCSI || in qed_hw_get_dflt_resc()
3855 p_hwfn->hw_info.personality == QED_PCI_NVMETCP) in qed_hw_get_dflt_resc()
3856 *p_resc_start = p_hwfn->port_id; in qed_hw_get_dflt_resc()
3857 else if (p_hwfn->hw_info.personality == QED_PCI_FCOE) in qed_hw_get_dflt_resc()
3858 *p_resc_start = p_hwfn->port_id + 2; in qed_hw_get_dflt_resc()
3861 *p_resc_start = *p_resc_num * p_hwfn->enabled_func_idx; in qed_hw_get_dflt_resc()
3887 rc = qed_mcp_get_resc_info(p_hwfn, p_hwfn->p_main_ptt, res_id, in __qed_hw_set_resc_info()
3897 * - The resource allocation MB command is not supported by the MFW in __qed_hw_set_resc_info()
3898 * - There is an internal error in the MFW while processing the request in __qed_hw_set_resc_info()
3899 * - The resource ID is unknown to the MFW in __qed_hw_set_resc_info()
3918 "PQs need to align by 8; Number %08x --> %08x, Start %08x --> %08x\n", in __qed_hw_set_resc_info()
3946 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_get_ppfid_bitmap()
3952 native_ppfid_idx = p_hwfn->rel_pf_id; in qed_hw_get_ppfid_bitmap()
3954 native_ppfid_idx = p_hwfn->rel_pf_id / in qed_hw_get_ppfid_bitmap()
3955 cdev->num_ports_in_engine; in qed_hw_get_ppfid_bitmap()
3958 if (rc != 0 && rc != -EOPNOTSUPP) in qed_hw_get_ppfid_bitmap()
3960 else if (rc == -EOPNOTSUPP) in qed_hw_get_ppfid_bitmap()
3961 cdev->ppfid_bitmap = 0x1 << native_ppfid_idx; in qed_hw_get_ppfid_bitmap()
3963 if (!(cdev->ppfid_bitmap & (0x1 << native_ppfid_idx))) { in qed_hw_get_ppfid_bitmap()
3966 native_ppfid_idx, cdev->ppfid_bitmap); in qed_hw_get_ppfid_bitmap()
3967 cdev->ppfid_bitmap = 0x1 << native_ppfid_idx; in qed_hw_get_ppfid_bitmap()
3977 bool b_ah = QED_IS_AH(p_hwfn->cdev); in qed_hw_get_resc()
3983 * run in parallel - a resource lock is needed. in qed_hw_get_resc()
3985 * supported - skip the max values setting, release the lock if in qed_hw_get_resc()
3993 if (rc && rc != -EINVAL) { in qed_hw_get_resc()
3995 } else if (rc == -EINVAL) { in qed_hw_get_resc()
4001 return -EBUSY; in qed_hw_get_resc()
4004 if (rc && rc != -EINVAL) { in qed_hw_get_resc()
4008 } else if (rc == -EINVAL) { in qed_hw_get_resc()
4042 RESC_END(p_hwfn, QED_ILT) - 1); in qed_hw_get_resc()
4043 return -EINVAL; in qed_hw_get_resc()
4048 return -EINVAL; in qed_hw_get_resc()
4081 return -EINVAL; in qed_hw_get_nvm_info()
4118 link = &p_hwfn->mcp_info->link_input; in qed_hw_get_nvm_info()
4119 p_caps = &p_hwfn->mcp_info->link_capabilities; in qed_hw_get_nvm_info()
4126 link->speed.advertised_speeds = link_temp; in qed_hw_get_nvm_info()
4128 p_caps->speed_capabilities = link->speed.advertised_speeds; in qed_hw_get_nvm_info()
4136 link->speed.autoneg = true; in qed_hw_get_nvm_info()
4139 link->speed.forced_speed = 1000; in qed_hw_get_nvm_info()
4142 link->speed.forced_speed = 10000; in qed_hw_get_nvm_info()
4145 link->speed.forced_speed = 20000; in qed_hw_get_nvm_info()
4148 link->speed.forced_speed = 25000; in qed_hw_get_nvm_info()
4151 link->speed.forced_speed = 40000; in qed_hw_get_nvm_info()
4154 link->speed.forced_speed = 50000; in qed_hw_get_nvm_info()
4157 link->speed.forced_speed = 100000; in qed_hw_get_nvm_info()
4163 p_caps->default_speed_autoneg = link->speed.autoneg; in qed_hw_get_nvm_info()
4166 link->pause.autoneg = !!(fld & NVM_CFG1_PORT_DRV_FLOW_CONTROL_AUTONEG); in qed_hw_get_nvm_info()
4167 link->pause.forced_rx = !!(fld & NVM_CFG1_PORT_DRV_FLOW_CONTROL_RX); in qed_hw_get_nvm_info()
4168 link->pause.forced_tx = !!(fld & NVM_CFG1_PORT_DRV_FLOW_CONTROL_TX); in qed_hw_get_nvm_info()
4169 link->loopback_mode = 0; in qed_hw_get_nvm_info()
4171 if (p_hwfn->mcp_info->capabilities & in qed_hw_get_nvm_info()
4176 p_caps->fec_default |= QED_FEC_MODE_NONE; in qed_hw_get_nvm_info()
4179 p_caps->fec_default |= QED_FEC_MODE_FIRECODE; in qed_hw_get_nvm_info()
4182 p_caps->fec_default |= QED_FEC_MODE_RS; in qed_hw_get_nvm_info()
4185 p_caps->fec_default |= QED_FEC_MODE_AUTO; in qed_hw_get_nvm_info()
4192 p_caps->fec_default = QED_FEC_MODE_UNSUPPORTED; in qed_hw_get_nvm_info()
4195 link->fec = p_caps->fec_default; in qed_hw_get_nvm_info()
4197 if (p_hwfn->mcp_info->capabilities & FW_MB_PARAM_FEATURE_SUPPORT_EEE) { in qed_hw_get_nvm_info()
4202 p_caps->default_eee = QED_MCP_EEE_ENABLED; in qed_hw_get_nvm_info()
4203 link->eee.enable = true; in qed_hw_get_nvm_info()
4206 p_caps->default_eee = QED_MCP_EEE_DISABLED; in qed_hw_get_nvm_info()
4207 link->eee.enable = false; in qed_hw_get_nvm_info()
4210 p_caps->eee_lpi_timer = EEE_TX_TIMER_USEC_BALANCED_TIME; in qed_hw_get_nvm_info()
4213 p_caps->eee_lpi_timer = in qed_hw_get_nvm_info()
4217 p_caps->eee_lpi_timer = EEE_TX_TIMER_USEC_LATENCY_TIME; in qed_hw_get_nvm_info()
4221 link->eee.tx_lpi_timer = p_caps->eee_lpi_timer; in qed_hw_get_nvm_info()
4222 link->eee.tx_lpi_enable = link->eee.enable; in qed_hw_get_nvm_info()
4223 link->eee.adv_caps = QED_EEE_1G_ADV | QED_EEE_10G_ADV; in qed_hw_get_nvm_info()
4225 p_caps->default_eee = QED_MCP_EEE_UNSUPPORTED; in qed_hw_get_nvm_info()
4228 if (p_hwfn->mcp_info->capabilities & in qed_hw_get_nvm_info()
4230 ext_speed = &link->ext_speed; in qed_hw_get_nvm_info()
4239 ext_speed->autoneg = true; in qed_hw_get_nvm_info()
4241 ext_speed->forced_speed = 0; in qed_hw_get_nvm_info()
4243 ext_speed->forced_speed |= QED_EXT_SPEED_1G; in qed_hw_get_nvm_info()
4245 ext_speed->forced_speed |= QED_EXT_SPEED_10G; in qed_hw_get_nvm_info()
4247 ext_speed->forced_speed |= QED_EXT_SPEED_20G; in qed_hw_get_nvm_info()
4249 ext_speed->forced_speed |= QED_EXT_SPEED_25G; in qed_hw_get_nvm_info()
4251 ext_speed->forced_speed |= QED_EXT_SPEED_40G; in qed_hw_get_nvm_info()
4253 ext_speed->forced_speed |= QED_EXT_SPEED_50G_R; in qed_hw_get_nvm_info()
4255 ext_speed->forced_speed |= QED_EXT_SPEED_50G_R2; in qed_hw_get_nvm_info()
4257 ext_speed->forced_speed |= QED_EXT_SPEED_100G_R2; in qed_hw_get_nvm_info()
4259 ext_speed->forced_speed |= QED_EXT_SPEED_100G_R4; in qed_hw_get_nvm_info()
4261 ext_speed->forced_speed |= QED_EXT_SPEED_100G_P4; in qed_hw_get_nvm_info()
4266 ext_speed->advertised_speeds = 0; in qed_hw_get_nvm_info()
4268 ext_speed->advertised_speeds |= QED_EXT_SPEED_MASK_RES; in qed_hw_get_nvm_info()
4270 ext_speed->advertised_speeds |= QED_EXT_SPEED_MASK_1G; in qed_hw_get_nvm_info()
4272 ext_speed->advertised_speeds |= QED_EXT_SPEED_MASK_10G; in qed_hw_get_nvm_info()
4274 ext_speed->advertised_speeds |= QED_EXT_SPEED_MASK_20G; in qed_hw_get_nvm_info()
4276 ext_speed->advertised_speeds |= QED_EXT_SPEED_MASK_25G; in qed_hw_get_nvm_info()
4278 ext_speed->advertised_speeds |= QED_EXT_SPEED_MASK_40G; in qed_hw_get_nvm_info()
4280 ext_speed->advertised_speeds |= in qed_hw_get_nvm_info()
4283 ext_speed->advertised_speeds |= in qed_hw_get_nvm_info()
4286 ext_speed->advertised_speeds |= in qed_hw_get_nvm_info()
4289 ext_speed->advertised_speeds |= in qed_hw_get_nvm_info()
4292 ext_speed->advertised_speeds |= in qed_hw_get_nvm_info()
4299 link->ext_fec_mode = link_temp; in qed_hw_get_nvm_info()
4301 p_caps->default_ext_speed_caps = ext_speed->advertised_speeds; in qed_hw_get_nvm_info()
4302 p_caps->default_ext_speed = ext_speed->forced_speed; in qed_hw_get_nvm_info()
4303 p_caps->default_ext_autoneg = ext_speed->autoneg; in qed_hw_get_nvm_info()
4304 p_caps->default_ext_fec = link->ext_fec_mode; in qed_hw_get_nvm_info()
4308 ext_speed->forced_speed, in qed_hw_get_nvm_info()
4309 ext_speed->advertised_speeds, ext_speed->autoneg, in qed_hw_get_nvm_info()
4310 p_caps->default_ext_fec); in qed_hw_get_nvm_info()
4315 link->speed.forced_speed, link->speed.advertised_speeds, in qed_hw_get_nvm_info()
4316 link->speed.autoneg, link->pause.autoneg, in qed_hw_get_nvm_info()
4317 p_caps->default_eee, p_caps->eee_lpi_timer, in qed_hw_get_nvm_info()
4318 p_caps->fec_default); in qed_hw_get_nvm_info()
4321 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_get_nvm_info()
4323 /* Read Multi-function information from shmem */ in qed_hw_get_nvm_info()
4335 cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS); in qed_hw_get_nvm_info()
4338 cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS) | in qed_hw_get_nvm_info()
4345 cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS) | in qed_hw_get_nvm_info()
4351 cdev->mf_bits = BIT(QED_MF_LLH_MAC_CLSS) | in qed_hw_get_nvm_info()
4358 cdev->mf_bits = BIT(QED_MF_LLH_MAC_CLSS) | in qed_hw_get_nvm_info()
4361 if (QED_IS_BB(p_hwfn->cdev)) in qed_hw_get_nvm_info()
4362 cdev->mf_bits |= BIT(QED_MF_NEED_DEF_PF); in qed_hw_get_nvm_info()
4367 cdev->mf_bits); in qed_hw_get_nvm_info()
4375 cdev->mf_bits |= BIT(QED_MF_DISABLE_ARFS); in qed_hw_get_nvm_info()
4379 p_hwfn->cdev->mf_bits); in qed_hw_get_nvm_info()
4389 &p_hwfn->hw_info.device_capabilities); in qed_hw_get_nvm_info()
4392 &p_hwfn->hw_info.device_capabilities); in qed_hw_get_nvm_info()
4395 &p_hwfn->hw_info.device_capabilities); in qed_hw_get_nvm_info()
4398 &p_hwfn->hw_info.device_capabilities); in qed_hw_get_nvm_info()
4406 p_hwfn->hw_info.part_num[i] = qed_rd(p_hwfn, p_ptt, addr + i * 4); in qed_hw_get_nvm_info()
4413 u8 num_funcs, enabled_func_idx = p_hwfn->rel_pf_id; in qed_get_num_funcs()
4415 struct qed_dev *cdev = p_hwfn->cdev; in qed_get_num_funcs()
4421 * Bits 1-15 are for functions 1-15, respectively, and their value is in qed_get_num_funcs()
4431 if (QED_PATH_ID(p_hwfn) && cdev->num_hwfns == 1) { in qed_get_num_funcs()
4452 low_pfs_mask = (0x1 << p_hwfn->abs_pf_id) - 1; in qed_get_num_funcs()
4456 enabled_func_idx--; in qed_get_num_funcs()
4461 p_hwfn->num_funcs_on_engine = num_funcs; in qed_get_num_funcs()
4462 p_hwfn->enabled_func_idx = enabled_func_idx; in qed_get_num_funcs()
4467 p_hwfn->rel_pf_id, in qed_get_num_funcs()
4468 p_hwfn->abs_pf_id, in qed_get_num_funcs()
4469 p_hwfn->enabled_func_idx, p_hwfn->num_funcs_on_engine); in qed_get_num_funcs()
4475 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_info_port_num()
4478 if (cdev->num_hwfns > 1) { in qed_hw_info_port_num()
4479 cdev->num_ports_in_engine = 1; in qed_hw_info_port_num()
4480 cdev->num_ports = 1; in qed_hw_info_port_num()
4488 cdev->num_ports_in_engine = 1; in qed_hw_info_port_num()
4491 cdev->num_ports_in_engine = 2; in qed_hw_info_port_num()
4494 cdev->num_ports_in_engine = 4; in qed_hw_info_port_num()
4498 cdev->num_ports_in_engine = 1; /* Default to something */ in qed_hw_info_port_num()
4503 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base, in qed_hw_info_port_num()
4508 cdev->num_ports = (u8)qed_rd(p_hwfn, p_ptt, addr); in qed_hw_info_port_num()
4516 p_caps = &p_hwfn->mcp_info->link_capabilities; in qed_get_eee_caps()
4517 if (p_caps->default_eee == QED_MCP_EEE_UNSUPPORTED) in qed_get_eee_caps()
4520 p_caps->eee_speed_caps = 0; in qed_get_eee_caps()
4521 eee_status = qed_rd(p_hwfn, p_ptt, p_hwfn->mcp_info->port_addr + in qed_get_eee_caps()
4527 p_caps->eee_speed_caps |= QED_EEE_1G_ADV; in qed_get_eee_caps()
4529 p_caps->eee_speed_caps |= QED_EEE_10G_ADV; in qed_get_eee_caps()
4558 ether_addr_copy(p_hwfn->hw_info.hw_mac_addr, in qed_get_hw_info()
4559 p_hwfn->mcp_info->func_info.mac); in qed_get_hw_info()
4561 eth_random_addr(p_hwfn->hw_info.hw_mac_addr); in qed_get_hw_info()
4564 if (p_hwfn->mcp_info->func_info.ovlan != QED_MCP_VLAN_UNSET) in qed_get_hw_info()
4565 p_hwfn->hw_info.ovlan = in qed_get_hw_info()
4566 p_hwfn->mcp_info->func_info.ovlan; in qed_get_hw_info()
4578 protocol = p_hwfn->mcp_info->func_info.protocol; in qed_get_hw_info()
4579 p_hwfn->hw_info.personality = protocol; in qed_get_hw_info()
4583 p_hwfn->hw_info.multi_tc_roce_en = true; in qed_get_hw_info()
4585 p_hwfn->hw_info.num_hw_tc = NUM_PHYS_TCS_4PORT_K2; in qed_get_hw_info()
4586 p_hwfn->hw_info.num_active_tc = 1; in qed_get_hw_info()
4591 p_hwfn->hw_info.mtu = p_hwfn->mcp_info->func_info.mtu; in qed_get_hw_info()
4598 struct qed_dev *cdev = p_hwfn->cdev; in qed_get_dev_info()
4603 pci_read_config_word(cdev->pdev, PCI_VENDOR_ID, &cdev->vendor_id); in qed_get_dev_info()
4604 pci_read_config_word(cdev->pdev, PCI_DEVICE_ID, &cdev->device_id); in qed_get_dev_info()
4607 device_id_mask = cdev->device_id & QED_DEV_ID_MASK; in qed_get_dev_info()
4610 cdev->type = QED_DEV_TYPE_BB; in qed_get_dev_info()
4613 cdev->type = QED_DEV_TYPE_AH; in qed_get_dev_info()
4616 DP_NOTICE(p_hwfn, "Unknown device id 0x%x\n", cdev->device_id); in qed_get_dev_info()
4617 return -EBUSY; in qed_get_dev_info()
4620 cdev->chip_num = (u16)qed_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_NUM); in qed_get_dev_info()
4621 cdev->chip_rev = (u16)qed_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_REV); in qed_get_dev_info()
4623 MASK_FIELD(CHIP_REV, cdev->chip_rev); in qed_get_dev_info()
4625 /* Learn number of HW-functions */ in qed_get_dev_info()
4628 if (tmp & (1 << p_hwfn->rel_pf_id)) { in qed_get_dev_info()
4629 DP_NOTICE(cdev->hwfns, "device in CMT mode\n"); in qed_get_dev_info()
4630 cdev->num_hwfns = 2; in qed_get_dev_info()
4632 cdev->num_hwfns = 1; in qed_get_dev_info()
4635 cdev->chip_bond_id = qed_rd(p_hwfn, p_ptt, in qed_get_dev_info()
4637 MASK_FIELD(CHIP_BOND_ID, cdev->chip_bond_id); in qed_get_dev_info()
4638 cdev->chip_metal = (u16)qed_rd(p_hwfn, p_ptt, MISCS_REG_CHIP_METAL); in qed_get_dev_info()
4639 MASK_FIELD(CHIP_METAL, cdev->chip_metal); in qed_get_dev_info()
4641 DP_INFO(cdev->hwfns, in qed_get_dev_info()
4642 "Chip details - %s %c%d, Num: %04x Rev: %04x Bond id: %04x Metal: %04x\n", in qed_get_dev_info()
4644 'A' + cdev->chip_rev, in qed_get_dev_info()
4645 (int)cdev->chip_metal, in qed_get_dev_info()
4646 cdev->chip_num, cdev->chip_rev, in qed_get_dev_info()
4647 cdev->chip_bond_id, cdev->chip_metal); in qed_get_dev_info()
4658 struct qed_dev *cdev = p_hwfn->cdev; in qed_hw_prepare_single()
4662 p_hwfn->regview = p_regview; in qed_hw_prepare_single()
4663 p_hwfn->doorbells = p_doorbells; in qed_hw_prepare_single()
4664 p_hwfn->db_phys_addr = db_phys_addr; in qed_hw_prepare_single()
4666 if (IS_VF(p_hwfn->cdev)) in qed_hw_prepare_single()
4673 return -EINVAL; in qed_hw_prepare_single()
4684 p_hwfn->p_main_ptt = qed_get_reserved_ptt(p_hwfn, RESERVED_PTT_MAIN); in qed_hw_prepare_single()
4687 if (!p_hwfn->my_id) { in qed_hw_prepare_single()
4688 rc = qed_get_dev_info(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_prepare_single()
4696 rc = qed_mcp_cmd_init(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_prepare_single()
4703 rc = qed_get_hw_info(p_hwfn, p_hwfn->p_main_ptt, personality); in qed_hw_prepare_single()
4712 if (IS_LEAD_HWFN(p_hwfn) && !cdev->recov_in_prog) { in qed_hw_prepare_single()
4713 rc = qed_mcp_initiate_pf_flr(p_hwfn, p_hwfn->p_main_ptt); in qed_hw_prepare_single()
4728 /* Allocate the init RT array and initialize the init-ops engine */ in qed_hw_prepare_single()
4739 qed_iov_free_hw_info(p_hwfn->cdev); in qed_hw_prepare_single()
4757 /* Initialize the first hwfn - will learn number of hwfns */ in qed_hw_prepare()
4759 cdev->regview, in qed_hw_prepare()
4760 cdev->doorbells, in qed_hw_prepare()
4761 cdev->db_phys_addr, in qed_hw_prepare()
4766 personality = p_hwfn->hw_info.personality; in qed_hw_prepare()
4769 if (cdev->num_hwfns > 1) { in qed_hw_prepare()
4775 offset = qed_hw_bar_size(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_prepare()
4777 p_regview = cdev->regview + offset; in qed_hw_prepare()
4779 offset = qed_hw_bar_size(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_prepare()
4782 p_doorbell = cdev->doorbells + offset; in qed_hw_prepare()
4784 db_phys_addr = cdev->db_phys_addr + offset; in qed_hw_prepare()
4787 rc = qed_hw_prepare_single(&cdev->hwfns[1], p_regview, in qed_hw_prepare()
4813 qed_mcp_ov_update_driver_state(p_hwfn, p_hwfn->p_main_ptt, in qed_hw_remove()
4817 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_hw_remove()
4842 "l2_queue id [%d] is not valid, available indices [%d - %d]\n", in qed_fw_l2_queue()
4845 return -EINVAL; in qed_fw_l2_queue()
4861 "vport id [%d] is not valid, available indices [%d - %d]\n", in qed_fw_vport()
4864 return -EINVAL; in qed_fw_vport()
4880 "rss_eng id [%d] is not valid, available indices [%d - %d]\n", in qed_fw_rss_eng()
4883 return -EINVAL; in qed_fw_rss_eng()
4897 if (p_hwfn->cdev->int_coalescing_mode != QED_COAL_MODE_ENABLE) { in qed_set_coalesce()
4899 return -EINVAL; in qed_set_coalesce()
4904 SET_FIELD(p_coal_timeset->value, COALESCING_TIMESET_TIMESET, timeset); in qed_set_coalesce()
4905 SET_FIELD(p_coal_timeset->value, COALESCING_TIMESET_VALID, 1); in qed_set_coalesce()
4918 p_hwfn = p_cid->p_owner; in qed_set_queue_coalesce()
4920 if (IS_VF(p_hwfn->cdev)) in qed_set_queue_coalesce()
4925 return -EAGAIN; in qed_set_queue_coalesce()
4931 p_hwfn->cdev->rx_coalesce_usecs = rx_coal; in qed_set_queue_coalesce()
4938 p_hwfn->cdev->tx_coalesce_usecs = tx_coal; in qed_set_queue_coalesce()
4954 /* Coalesce = (timeset << timer-resolution), timeset is 7bit wide */ in qed_set_rxq_coalesce()
4962 DP_ERR(p_hwfn, "Invalid coalesce value - %d\n", coalesce); in qed_set_rxq_coalesce()
4963 return -EINVAL; in qed_set_rxq_coalesce()
4968 p_cid->sb_igu_id, false); in qed_set_rxq_coalesce()
4973 USTORM_ETH_QUEUE_ZONE_GTT_OFFSET(p_cid->abs.queue_id); in qed_set_rxq_coalesce()
4993 /* Coalesce = (timeset << timer-resolution), timeset is 7bit wide */ in qed_set_txq_coalesce()
5001 DP_ERR(p_hwfn, "Invalid coalesce value - %d\n", coalesce); in qed_set_txq_coalesce()
5002 return -EINVAL; in qed_set_txq_coalesce()
5007 p_cid->sb_igu_id, true); in qed_set_txq_coalesce()
5012 XSTORM_ETH_QUEUE_ZONE_GTT_OFFSET(p_cid->abs.queue_id); in qed_set_txq_coalesce()
5031 vport_params = p_hwfn->qm_info.qm_vport_params; in qed_configure_wfq_for_all_vports()
5033 for (i = 0; i < p_hwfn->qm_info.num_vports; i++) { in qed_configure_wfq_for_all_vports()
5034 u32 wfq_speed = p_hwfn->qm_info.wfq_data[i].min_speed; in qed_configure_wfq_for_all_vports()
5050 for (i = 0; i < p_hwfn->qm_info.num_vports; i++) in qed_init_wfq_default_param()
5051 p_hwfn->qm_info.qm_vport_params[i].wfq = 1; in qed_init_wfq_default_param()
5061 vport_params = p_hwfn->qm_info.qm_vport_params; in qed_disable_wfq_for_all_vports()
5063 for (i = 0; i < p_hwfn->qm_info.num_vports; i++) { in qed_disable_wfq_for_all_vports()
5084 num_vports = p_hwfn->qm_info.num_vports; in qed_init_wfq_param()
5088 return -EINVAL; in qed_init_wfq_param()
5096 p_hwfn->qm_info.wfq_data[i].configured) { in qed_init_wfq_param()
5098 tmp_speed = p_hwfn->qm_info.wfq_data[i].min_speed; in qed_init_wfq_param()
5106 non_requested_count = num_vports - req_count; in qed_init_wfq_param()
5110 …"Vport [%d] - Requested rate[%d Mbps] is less than one percent of configured PF min rate[%d Mbps]\… in qed_init_wfq_param()
5112 return -EINVAL; in qed_init_wfq_param()
5119 return -EINVAL; in qed_init_wfq_param()
5126 return -EINVAL; in qed_init_wfq_param()
5129 total_left_rate = min_pf_rate - total_req_min_rate; in qed_init_wfq_param()
5136 return -EINVAL; in qed_init_wfq_param()
5139 p_hwfn->qm_info.wfq_data[vport_id].min_speed = req_rate; in qed_init_wfq_param()
5140 p_hwfn->qm_info.wfq_data[vport_id].configured = true; in qed_init_wfq_param()
5143 if (p_hwfn->qm_info.wfq_data[i].configured) in qed_init_wfq_param()
5146 p_hwfn->qm_info.wfq_data[i].min_speed = left_rate_per_vp; in qed_init_wfq_param()
5158 p_link = &p_hwfn->cdev->hwfns[0].mcp_info->link_output; in __qed_configure_vport_wfq()
5160 if (!p_link->min_pf_rate) { in __qed_configure_vport_wfq()
5161 p_hwfn->qm_info.wfq_data[vp_id].min_speed = rate; in __qed_configure_vport_wfq()
5162 p_hwfn->qm_info.wfq_data[vp_id].configured = true; in __qed_configure_vport_wfq()
5166 rc = qed_init_wfq_param(p_hwfn, vp_id, rate, p_link->min_pf_rate); in __qed_configure_vport_wfq()
5170 p_link->min_pf_rate); in __qed_configure_vport_wfq()
5187 for (i = 0; i < p_hwfn->qm_info.num_vports; i++) { in __qed_configure_vp_wfq_on_link_change()
5190 if (!p_hwfn->qm_info.wfq_data[i].configured) in __qed_configure_vp_wfq_on_link_change()
5193 rate = p_hwfn->qm_info.wfq_data[i].min_speed; in __qed_configure_vp_wfq_on_link_change()
5213 * vp_id - vport id in PF Range[0 - (total_num_vports_per_pf - 1)]
5214 * rate - Speed in Mbps needs to be assigned to a given vport.
5218 int i, rc = -EINVAL; in qed_configure_vport_wfq()
5221 if (cdev->num_hwfns > 1) { in qed_configure_vport_wfq()
5228 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_configure_vport_wfq()
5233 return -EBUSY; in qed_configure_vport_wfq()
5254 if (cdev->num_hwfns > 1) { in qed_configure_vp_wfq_on_link_change()
5262 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_configure_vp_wfq_on_link_change()
5276 p_hwfn->mcp_info->func_info.bandwidth_max = max_bw; in __qed_configure_pf_max_bandwidth()
5278 if (!p_link->line_speed && (max_bw != 100)) in __qed_configure_pf_max_bandwidth()
5281 p_link->speed = (p_link->line_speed * max_bw) / 100; in __qed_configure_pf_max_bandwidth()
5282 p_hwfn->qm_info.pf_rl = p_link->speed; in __qed_configure_pf_max_bandwidth()
5284 /* Since the limiter also affects Tx-switched traffic, we don't want it in __qed_configure_pf_max_bandwidth()
5289 p_hwfn->qm_info.pf_rl = 100000; in __qed_configure_pf_max_bandwidth()
5291 rc = qed_init_pf_rl(p_hwfn, p_ptt, p_hwfn->rel_pf_id, in __qed_configure_pf_max_bandwidth()
5292 p_hwfn->qm_info.pf_rl); in __qed_configure_pf_max_bandwidth()
5296 p_link->speed); in __qed_configure_pf_max_bandwidth()
5301 /* Main API to configure PF max bandwidth where bw range is [1 - 100] */
5304 int i, rc = -EINVAL; in qed_configure_pf_max_bandwidth()
5307 DP_NOTICE(cdev, "PF max bw valid range is [1-100]\n"); in qed_configure_pf_max_bandwidth()
5312 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_configure_pf_max_bandwidth()
5317 p_link = &p_lead->mcp_info->link_output; in qed_configure_pf_max_bandwidth()
5321 return -EBUSY; in qed_configure_pf_max_bandwidth()
5342 p_hwfn->mcp_info->func_info.bandwidth_min = min_bw; in __qed_configure_pf_min_bandwidth()
5343 p_hwfn->qm_info.pf_wfq = min_bw; in __qed_configure_pf_min_bandwidth()
5345 if (!p_link->line_speed) in __qed_configure_pf_min_bandwidth()
5348 p_link->min_pf_rate = (p_link->line_speed * min_bw) / 100; in __qed_configure_pf_min_bandwidth()
5350 rc = qed_init_pf_wfq(p_hwfn, p_ptt, p_hwfn->rel_pf_id, min_bw); in __qed_configure_pf_min_bandwidth()
5354 p_link->min_pf_rate); in __qed_configure_pf_min_bandwidth()
5359 /* Main API to configure PF min bandwidth where bw range is [1-100] */
5362 int i, rc = -EINVAL; in qed_configure_pf_min_bandwidth()
5365 DP_NOTICE(cdev, "PF min bw valid range is [1-100]\n"); in qed_configure_pf_min_bandwidth()
5370 struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; in qed_configure_pf_min_bandwidth()
5375 p_link = &p_lead->mcp_info->link_output; in qed_configure_pf_min_bandwidth()
5379 return -EBUSY; in qed_configure_pf_min_bandwidth()
5388 if (p_link->min_pf_rate) { in qed_configure_pf_min_bandwidth()
5389 u32 min_rate = p_link->min_pf_rate; in qed_configure_pf_min_bandwidth()
5406 p_link = &p_hwfn->mcp_info->link_output; in qed_clean_wfq_db()
5408 if (p_link->min_pf_rate) in qed_clean_wfq_db()
5410 p_link->min_pf_rate); in qed_clean_wfq_db()
5412 memset(p_hwfn->qm_info.wfq_data, 0, in qed_clean_wfq_db()
5413 sizeof(*p_hwfn->qm_info.wfq_data) * p_hwfn->qm_info.num_vports); in qed_clean_wfq_db()
5418 return cdev->num_ports; in qed_device_num_ports()
5422 __le16 *fw_mid, __le16 *fw_lsb, u8 *mac) in qed_set_fw_mac_addr() argument
5424 ((u8 *)fw_msb)[0] = mac[1]; in qed_set_fw_mac_addr()
5425 ((u8 *)fw_msb)[1] = mac[0]; in qed_set_fw_mac_addr()
5426 ((u8 *)fw_mid)[0] = mac[3]; in qed_set_fw_mac_addr()
5427 ((u8 *)fw_mid)[1] = mac[2]; in qed_set_fw_mac_addr()
5428 ((u8 *)fw_lsb)[0] = mac[5]; in qed_set_fw_mac_addr()
5429 ((u8 *)fw_lsb)[1] = mac[4]; in qed_set_fw_mac_addr()
5434 struct qed_llh_info *p_llh_info = cdev->p_llh_info; in qed_llh_shadow_remove_all_filters()
5442 p_filters = p_llh_info->pp_filters[ppfid]; in qed_llh_shadow_remove_all_filters()
5459 if (!test_bit(QED_MF_LLH_PROTO_CLSS, &cdev->mf_bits) && in qed_llh_clear_ppfid_filters()
5460 !test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits)) in qed_llh_clear_ppfid_filters()
5514 if (!test_bit(QED_MF_LLH_PROTO_CLSS, &cdev->mf_bits) && in qed_llh_clear_all_filters()
5515 !test_bit(QED_MF_LLH_MAC_CLSS, &cdev->mf_bits)) in qed_llh_clear_all_filters()
5518 for (ppfid = 0; ppfid < cdev->p_llh_info->num_ppfid; ppfid++) in qed_llh_clear_all_filters()