Lines Matching +full:x +full:- +full:rc

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.
34 qed_wr(_p_hwfn, _p_ptt, (_p_hwfn->mcp_info->_ptr + (_offset)), \
38 qed_rd(_p_hwfn, _p_ptt, (_p_hwfn->mcp_info->_ptr + (_offset)))
55 if (!p_hwfn->mcp_info || !p_hwfn->mcp_info->public_base) in qed_mcp_is_init()
62 u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base, in qed_mcp_cmd_port_init()
66 p_hwfn->mcp_info->port_addr = SECTION_ADDR(mfw_mb_offsize, in qed_mcp_cmd_port_init()
69 "port_addr = 0x%x, port_id 0x%02x\n", in qed_mcp_cmd_port_init()
70 p_hwfn->mcp_info->port_addr, MFW_PORT(p_hwfn)); in qed_mcp_cmd_port_init()
75 u32 length = MFW_DRV_MSG_MAX_DWORDS(p_hwfn->mcp_info->mfw_mb_length); in qed_mcp_read_mb()
78 if (!p_hwfn->mcp_info->public_base) in qed_mcp_read_mb()
83 p_hwfn->mcp_info->mfw_mb_addr + in qed_mcp_read_mb()
87 ((u32 *)p_hwfn->mcp_info->mfw_mb_cur)[i] = in qed_mcp_read_mb()
111 p_cmd_elem->p_mb_params = p_mb_params; in qed_mcp_cmd_add_elem()
112 p_cmd_elem->expected_seq_num = expected_seq_num; in qed_mcp_cmd_add_elem()
113 list_add(&p_cmd_elem->list, &p_hwfn->mcp_info->cmd_list); in qed_mcp_cmd_add_elem()
122 list_del(&p_cmd_elem->list); in qed_mcp_cmd_del_elem()
132 list_for_each_entry(p_cmd_elem, &p_hwfn->mcp_info->cmd_list, list) { in qed_mcp_cmd_get_elem()
133 if (p_cmd_elem->expected_seq_num == seq_num) in qed_mcp_cmd_get_elem()
142 if (p_hwfn->mcp_info) { in qed_mcp_free()
145 kfree(p_hwfn->mcp_info->mfw_mb_cur); in qed_mcp_free()
146 kfree(p_hwfn->mcp_info->mfw_mb_shadow); in qed_mcp_free()
148 spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); in qed_mcp_free()
151 &p_hwfn->mcp_info->cmd_list, list) { in qed_mcp_free()
154 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in qed_mcp_free()
157 kfree(p_hwfn->mcp_info); in qed_mcp_free()
158 p_hwfn->mcp_info = NULL; in qed_mcp_free()
169 struct qed_mcp_info *p_info = p_hwfn->mcp_info; in qed_load_mcp_offsets()
175 p_info->public_base = qed_rd(p_hwfn, p_ptt, MISC_REG_SHARED_MEM_ADDR); in qed_load_mcp_offsets()
176 if (!p_info->public_base) { in qed_load_mcp_offsets()
178 "The address of the MCP scratch-pad is not configured\n"); in qed_load_mcp_offsets()
179 return -EINVAL; in qed_load_mcp_offsets()
182 p_info->public_base |= GRCBASE_MCP; in qed_load_mcp_offsets()
186 SECTION_OFFSIZE_ADDR(p_info->public_base, in qed_load_mcp_offsets()
188 p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id); in qed_load_mcp_offsets()
189 p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt, in qed_load_mcp_offsets()
190 p_info->mfw_mb_addr + in qed_load_mcp_offsets()
199 while (!p_info->mfw_mb_length && --cnt) { in qed_load_mcp_offsets()
201 p_info->mfw_mb_length = in qed_load_mcp_offsets()
203 p_info->mfw_mb_addr + in qed_load_mcp_offsets()
211 return -EBUSY; in qed_load_mcp_offsets()
216 SECTION_OFFSIZE_ADDR(p_info->public_base, in qed_load_mcp_offsets()
218 p_info->drv_mb_addr = SECTION_ADDR(drv_mb_offsize, mcp_pf_id); in qed_load_mcp_offsets()
220 "drv_mb_offsiz = 0x%x, drv_mb_addr = 0x%x mcp_pf_id = 0x%x\n", in qed_load_mcp_offsets()
221 drv_mb_offsize, p_info->drv_mb_addr, mcp_pf_id); in qed_load_mcp_offsets()
226 p_info->drv_mb_seq = DRV_MB_RD(p_hwfn, p_ptt, drv_mb_header) & in qed_load_mcp_offsets()
230 p_info->drv_pulse_seq = DRV_MB_RD(p_hwfn, p_ptt, drv_pulse_mb) & in qed_load_mcp_offsets()
233 p_info->mcp_hist = qed_rd(p_hwfn, p_ptt, MISCS_REG_GENERIC_POR_0); in qed_load_mcp_offsets()
244 p_hwfn->mcp_info = kzalloc(sizeof(*p_hwfn->mcp_info), GFP_KERNEL); in qed_mcp_cmd_init()
245 if (!p_hwfn->mcp_info) in qed_mcp_cmd_init()
247 p_info = p_hwfn->mcp_info; in qed_mcp_cmd_init()
250 spin_lock_init(&p_info->cmd_lock); in qed_mcp_cmd_init()
251 spin_lock_init(&p_info->link_lock); in qed_mcp_cmd_init()
252 spin_lock_init(&p_info->unload_lock); in qed_mcp_cmd_init()
254 INIT_LIST_HEAD(&p_info->cmd_list); in qed_mcp_cmd_init()
264 size = MFW_DRV_MSG_MAX_DWORDS(p_info->mfw_mb_length) * sizeof(u32); in qed_mcp_cmd_init()
265 p_info->mfw_mb_cur = kzalloc(size, GFP_KERNEL); in qed_mcp_cmd_init()
266 p_info->mfw_mb_shadow = kzalloc(size, GFP_KERNEL); in qed_mcp_cmd_init()
267 if (!p_info->mfw_mb_cur || !p_info->mfw_mb_shadow) in qed_mcp_cmd_init()
274 return -ENOMEM; in qed_mcp_cmd_init()
285 if (p_hwfn->mcp_info->mcp_hist != generic_por_0) { in qed_mcp_reread_offsets()
288 "Rereading MCP offsets [mcp_hist 0x%08x, generic_por_0 0x%08x]\n", in qed_mcp_reread_offsets()
289 p_hwfn->mcp_info->mcp_hist, generic_por_0); in qed_mcp_reread_offsets()
299 int rc = 0; in qed_mcp_reset() local
301 if (p_hwfn->mcp_info->b_block_cmd) { in qed_mcp_reset()
304 return -EBUSY; in qed_mcp_reset()
308 spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); in qed_mcp_reset()
314 seq = ++p_hwfn->mcp_info->drv_mb_seq; in qed_mcp_reset()
331 rc = -EAGAIN; in qed_mcp_reset()
334 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in qed_mcp_reset()
336 return rc; in qed_mcp_reset()
345 * exists - it is placed at the HEAD of the list. in qed_mcp_has_pending_cmd()
347 if (!list_empty(&p_hwfn->mcp_info->cmd_list)) { in qed_mcp_has_pending_cmd()
348 p_cmd_elem = list_first_entry(&p_hwfn->mcp_info->cmd_list, in qed_mcp_has_pending_cmd()
350 return !p_cmd_elem->b_is_completed; in qed_mcp_has_pending_cmd()
368 /* Return if no new non-handled response has been received */ in qed_mcp_update_pending_cmd()
369 if (seq_num != p_hwfn->mcp_info->drv_mb_seq) in qed_mcp_update_pending_cmd()
370 return -EAGAIN; in qed_mcp_update_pending_cmd()
377 return -EINVAL; in qed_mcp_update_pending_cmd()
380 p_mb_params = p_cmd_elem->p_mb_params; in qed_mcp_update_pending_cmd()
383 p_mb_params->mcp_resp = mcp_resp; in qed_mcp_update_pending_cmd()
386 p_mb_params->mcp_param = DRV_MB_RD(p_hwfn, p_ptt, fw_mb_param); in qed_mcp_update_pending_cmd()
389 if (p_mb_params->p_data_dst && p_mb_params->data_dst_size) { in qed_mcp_update_pending_cmd()
390 u32 union_data_addr = p_hwfn->mcp_info->drv_mb_addr + in qed_mcp_update_pending_cmd()
393 qed_memcpy_from(p_hwfn, p_ptt, p_mb_params->p_data_dst, in qed_mcp_update_pending_cmd()
394 union_data_addr, p_mb_params->data_dst_size); in qed_mcp_update_pending_cmd()
397 p_cmd_elem->b_is_completed = true; in qed_mcp_update_pending_cmd()
412 union_data_addr = p_hwfn->mcp_info->drv_mb_addr + in __qed_mcp_cmd_and_union()
415 if (p_mb_params->p_data_src && p_mb_params->data_src_size) in __qed_mcp_cmd_and_union()
416 memcpy(&union_data, p_mb_params->p_data_src, in __qed_mcp_cmd_and_union()
417 p_mb_params->data_src_size); in __qed_mcp_cmd_and_union()
422 DRV_MB_WR(p_hwfn, p_ptt, drv_mb_param, p_mb_params->param); in __qed_mcp_cmd_and_union()
425 DRV_MB_WR(p_hwfn, p_ptt, drv_mb_header, (p_mb_params->cmd | seq_num)); in __qed_mcp_cmd_and_union()
428 "MFW mailbox: command 0x%08x param 0x%08x\n", in __qed_mcp_cmd_and_union()
429 (p_mb_params->cmd | seq_num), p_mb_params->param); in __qed_mcp_cmd_and_union()
434 p_hwfn->mcp_info->b_block_cmd = block_cmd; in qed_mcp_cmd_set_blocking()
455 "MCP CPU info: mode 0x%08x, state 0x%08x, pc {0x%08x, 0x%08x, 0x%08x}\n", in qed_mcp_print_cpu_info()
468 int rc = 0; in _qed_mcp_cmd_and_union() local
470 /* Wait until the mailbox is non-occupied */ in _qed_mcp_cmd_and_union()
477 spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
482 rc = qed_mcp_update_pending_cmd(p_hwfn, p_ptt); in _qed_mcp_cmd_and_union()
483 if (!rc) in _qed_mcp_cmd_and_union()
485 else if (rc != -EAGAIN) in _qed_mcp_cmd_and_union()
488 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
498 …FW mailbox is occupied by an uncompleted command. Failed to send command 0x%08x [param 0x%08x].\n", in _qed_mcp_cmd_and_union()
499 p_mb_params->cmd, p_mb_params->param); in _qed_mcp_cmd_and_union()
500 return -EAGAIN; in _qed_mcp_cmd_and_union()
505 seq_num = ++p_hwfn->mcp_info->drv_mb_seq; in _qed_mcp_cmd_and_union()
508 rc = -ENOMEM; in _qed_mcp_cmd_and_union()
513 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
527 spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
529 if (p_cmd_elem->b_is_completed) in _qed_mcp_cmd_and_union()
532 rc = qed_mcp_update_pending_cmd(p_hwfn, p_ptt); in _qed_mcp_cmd_and_union()
533 if (!rc) in _qed_mcp_cmd_and_union()
535 else if (rc != -EAGAIN) in _qed_mcp_cmd_and_union()
538 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
543 "The MFW failed to respond to command 0x%08x [param 0x%08x].\n", in _qed_mcp_cmd_and_union()
544 p_mb_params->cmd, p_mb_params->param); in _qed_mcp_cmd_and_union()
547 spin_lock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
549 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
556 return -EAGAIN; in _qed_mcp_cmd_and_union()
560 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
564 "MFW mailbox: response 0x%08x param 0x%08x [after %d.%03d ms]\n", in _qed_mcp_cmd_and_union()
565 p_mb_params->mcp_resp, in _qed_mcp_cmd_and_union()
566 p_mb_params->mcp_param, in _qed_mcp_cmd_and_union()
570 p_mb_params->mcp_resp &= FW_MSG_CODE_MASK; in _qed_mcp_cmd_and_union()
575 spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock); in _qed_mcp_cmd_and_union()
576 return rc; in _qed_mcp_cmd_and_union()
590 return -EBUSY; in qed_mcp_cmd_and_union()
593 if (p_hwfn->mcp_info->b_block_cmd) { in qed_mcp_cmd_and_union()
595 "The MFW is not responsive. Avoid sending mailbox command 0x%08x [param 0x%08x].\n", in qed_mcp_cmd_and_union()
596 p_mb_params->cmd, p_mb_params->param); in qed_mcp_cmd_and_union()
597 return -EBUSY; in qed_mcp_cmd_and_union()
600 if (p_mb_params->data_src_size > union_data_size || in qed_mcp_cmd_and_union()
601 p_mb_params->data_dst_size > union_data_size) { in qed_mcp_cmd_and_union()
604 p_mb_params->data_src_size, in qed_mcp_cmd_and_union()
605 p_mb_params->data_dst_size, union_data_size); in qed_mcp_cmd_and_union()
606 return -EINVAL; in qed_mcp_cmd_and_union()
627 int rc; in _qed_mcp_cmd() local
634 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in _qed_mcp_cmd()
635 if (rc) in _qed_mcp_cmd()
636 return rc; in _qed_mcp_cmd()
675 int rc; in qed_mcp_nvm_wr_cmd() local
682 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_nvm_wr_cmd()
683 if (rc) in qed_mcp_nvm_wr_cmd()
684 return rc; in qed_mcp_nvm_wr_cmd()
690 p_hwfn->nvm_info.valid = false; in qed_mcp_nvm_wr_cmd()
705 int rc; in qed_mcp_nvm_rd_cmd() local
717 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_nvm_rd_cmd()
718 if (rc) in qed_mcp_nvm_rd_cmd()
719 return rc; in qed_mcp_nvm_rd_cmd()
759 int rc; in qed_mcp_cancel_load_req() local
761 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_CANCEL_LOAD_REQ, 0, in qed_mcp_cancel_load_req()
763 if (rc) in qed_mcp_cancel_load_req()
765 "Failed to send cancel load request, rc = %d\n", rc); in qed_mcp_cancel_load_req()
767 return rc; in qed_mcp_cancel_load_req()
835 int rc; in __qed_mcp_load_req() local
838 load_req.drv_ver_0 = p_in_params->drv_ver_0; in __qed_mcp_load_req()
839 load_req.drv_ver_1 = p_in_params->drv_ver_1; in __qed_mcp_load_req()
840 load_req.fw_ver = p_in_params->fw_ver; in __qed_mcp_load_req()
841 QED_MFW_SET_FIELD(load_req.misc0, LOAD_REQ_ROLE, p_in_params->drv_role); in __qed_mcp_load_req()
843 p_in_params->timeout_val); in __qed_mcp_load_req()
845 p_in_params->force_cmd); in __qed_mcp_load_req()
847 p_in_params->avoid_eng_reset); in __qed_mcp_load_req()
849 hsi_ver = (p_in_params->hsi_ver == QED_LOAD_REQ_HSI_VER_DEFAULT) ? in __qed_mcp_load_req()
851 (p_in_params->hsi_ver << DRV_ID_MCP_HSI_VER_SHIFT); in __qed_mcp_load_req()
855 mb_params.param = PDA_COMP | hsi_ver | p_hwfn->cdev->drv_type; in __qed_mcp_load_req()
863 "Load Request: param 0x%08x [init_hw %d, drv_type %d, hsi_ver %d, pda 0x%04x]\n", in __qed_mcp_load_req()
870 if (p_in_params->hsi_ver != QED_LOAD_REQ_HSI_VER_1) { in __qed_mcp_load_req()
872 …"Load Request: drv_ver 0x%08x_0x%08x, fw_ver 0x%08x, misc0 0x%08x [role %d, timeout %d, force %d, … in __qed_mcp_load_req()
884 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in __qed_mcp_load_req()
885 if (rc) { in __qed_mcp_load_req()
886 DP_NOTICE(p_hwfn, "Failed to send load request, rc = %d\n", rc); in __qed_mcp_load_req()
887 return rc; in __qed_mcp_load_req()
891 "Load Response: resp 0x%08x\n", mb_params.mcp_resp); in __qed_mcp_load_req()
892 p_out_params->load_code = mb_params.mcp_resp; in __qed_mcp_load_req()
894 if (p_in_params->hsi_ver != QED_LOAD_REQ_HSI_VER_1 && in __qed_mcp_load_req()
895 p_out_params->load_code != FW_MSG_CODE_DRV_LOAD_REFUSED_HSI_1) { in __qed_mcp_load_req()
898 …"Load Response: exist_drv_ver 0x%08x_0x%08x, exist_fw_ver 0x%08x, misc0 0x%08x [exist_role %d, mfw… in __qed_mcp_load_req()
907 p_out_params->exist_drv_ver_0 = load_rsp.drv_ver_0; in __qed_mcp_load_req()
908 p_out_params->exist_drv_ver_1 = load_rsp.drv_ver_1; in __qed_mcp_load_req()
909 p_out_params->exist_fw_ver = load_rsp.fw_ver; in __qed_mcp_load_req()
910 p_out_params->exist_drv_role = in __qed_mcp_load_req()
912 p_out_params->mfw_hsi_ver = in __qed_mcp_load_req()
914 p_out_params->drv_exists = in __qed_mcp_load_req()
935 return -EINVAL; in eocre_get_mfw_drv_role()
971 int rc; in qed_mcp_load_req() local
977 rc = eocre_get_mfw_drv_role(p_hwfn, p_params->drv_role, &mfw_drv_role); in qed_mcp_load_req()
978 if (rc) in qed_mcp_load_req()
979 return rc; in qed_mcp_load_req()
982 in_params.timeout_val = p_params->timeout_val; in qed_mcp_load_req()
987 in_params.avoid_eng_reset = p_params->avoid_eng_reset; in qed_mcp_load_req()
990 rc = __qed_mcp_load_req(p_hwfn, p_ptt, &in_params, &out_params); in qed_mcp_load_req()
991 if (rc) in qed_mcp_load_req()
992 return rc; in qed_mcp_load_req()
995 * - MFW expects the old interface [HSI version = 1] in qed_mcp_load_req()
996 * - MFW responds that a force load request is required in qed_mcp_load_req()
1004 rc = __qed_mcp_load_req(p_hwfn, p_ptt, &in_params, &out_params); in qed_mcp_load_req()
1005 if (rc) in qed_mcp_load_req()
1006 return rc; in qed_mcp_load_req()
1011 p_params->override_force_load)) { in qed_mcp_load_req()
1013 …equired [{role, fw_ver, drv_ver}: loading={%d, 0x%08x, x%08x_0x%08x}, existing={%d, 0x%08x, 0x%08x… in qed_mcp_load_req()
1027 rc = __qed_mcp_load_req(p_hwfn, p_ptt, &in_params, in qed_mcp_load_req()
1029 if (rc) in qed_mcp_load_req()
1030 return rc; in qed_mcp_load_req()
1033 …uired [{role, fw_ver, drv_ver}: loading={%d, 0x%08x, x%08x_0x%08x}, existing={%d, 0x%08x, 0x%08x_0… in qed_mcp_load_req()
1044 return -EBUSY; in qed_mcp_load_req()
1063 return -EINVAL; in qed_mcp_load_req()
1068 "Unexpected refusal to load request [resp 0x%08x]. Aborting.\n", in qed_mcp_load_req()
1070 return -EBUSY; in qed_mcp_load_req()
1073 p_params->load_code = out_params.load_code; in qed_mcp_load_req()
1081 int rc; in qed_mcp_load_done() local
1083 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_LOAD_DONE, 0, &resp, in qed_mcp_load_done()
1085 if (rc) { in qed_mcp_load_done()
1087 "Failed to send a LOAD_DONE command, rc = %d\n", rc); in qed_mcp_load_done()
1088 return rc; in qed_mcp_load_done()
1091 /* Check if there is a DID mismatch between nvm-cfg/efuse */ in qed_mcp_load_done()
1107 int rc; in qed_mcp_unload_req() local
1109 switch (p_hwfn->cdev->wol_config) { in qed_mcp_unload_req()
1118 "Unknown WoL configuration %02x\n", in qed_mcp_unload_req()
1119 p_hwfn->cdev->wol_config); in qed_mcp_unload_req()
1130 spin_lock_bh(&p_hwfn->mcp_info->unload_lock); in qed_mcp_unload_req()
1132 &p_hwfn->mcp_info->mcp_handling_status); in qed_mcp_unload_req()
1133 spin_unlock_bh(&p_hwfn->mcp_info->unload_lock); in qed_mcp_unload_req()
1135 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_unload_req()
1138 &p_hwfn->mcp_info->mcp_handling_status) && --cnt) in qed_mcp_unload_req()
1146 return rc; in qed_mcp_unload_req()
1158 if (p_hwfn->cdev->wol_config == QED_OV_WOL_ENABLED) { in qed_mcp_unload_done()
1159 u8 *p_mac = p_hwfn->cdev->wol_mac; in qed_mcp_unload_done()
1168 "Setting WoL MAC: %pM --> [%08x,%08x]\n", in qed_mcp_unload_done()
1181 u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base, in qed_mcp_handle_vf_flr()
1191 "Reading Disabled VF information from [offset %08x], path_addr %08x\n", in qed_mcp_handle_vf_flr()
1201 "FLR-ed VFs [%08x,...,%08x] - %08x\n", in qed_mcp_handle_vf_flr()
1202 i * 32, (i + 1) * 32 - 1, disabled_vfs[i]); in qed_mcp_handle_vf_flr()
1212 u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base, in qed_mcp_ack_vf_flr()
1218 int rc; in qed_mcp_ack_vf_flr() local
1223 "Acking VFs [%08x,...,%08x] - %08x\n", in qed_mcp_ack_vf_flr()
1224 i * 32, (i + 1) * 32 - 1, vfs_to_ack[i]); in qed_mcp_ack_vf_flr()
1230 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_ack_vf_flr()
1231 if (rc) { in qed_mcp_ack_vf_flr()
1233 return -EBUSY; in qed_mcp_ack_vf_flr()
1243 return rc; in qed_mcp_ack_vf_flr()
1252 p_hwfn->mcp_info->port_addr + in qed_mcp_handle_transceiver_change()
1258 "Received transceiver state update [0x%08x] from mfw [Addr 0x%x]\n", in qed_mcp_handle_transceiver_change()
1260 (u32)(p_hwfn->mcp_info->port_addr + in qed_mcp_handle_transceiver_change()
1278 p_link->eee_adv_caps = 0; in qed_mcp_read_eee_config()
1279 p_link->eee_lp_adv_caps = 0; in qed_mcp_read_eee_config()
1282 p_hwfn->mcp_info->port_addr + in qed_mcp_read_eee_config()
1284 p_link->eee_active = !!(eee_status & EEE_ACTIVE_BIT); in qed_mcp_read_eee_config()
1287 p_link->eee_adv_caps |= QED_EEE_1G_ADV; in qed_mcp_read_eee_config()
1289 p_link->eee_adv_caps |= QED_EEE_10G_ADV; in qed_mcp_read_eee_config()
1292 p_link->eee_lp_adv_caps |= QED_EEE_1G_ADV; in qed_mcp_read_eee_config()
1294 p_link->eee_lp_adv_caps |= QED_EEE_10G_ADV; in qed_mcp_read_eee_config()
1301 u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base, in qed_mcp_get_shmem_func()
1322 p_info = &p_hwfn->mcp_info->func_info; in qed_read_pf_bandwidth()
1324 p_info->bandwidth_min = QED_MFW_GET_FIELD(p_shmem_info->config, in qed_read_pf_bandwidth()
1326 if (p_info->bandwidth_min < 1 || p_info->bandwidth_min > 100) { in qed_read_pf_bandwidth()
1328 "bandwidth minimum out of bounds [%02x]. Set to 1\n", in qed_read_pf_bandwidth()
1329 p_info->bandwidth_min); in qed_read_pf_bandwidth()
1330 p_info->bandwidth_min = 1; in qed_read_pf_bandwidth()
1333 p_info->bandwidth_max = QED_MFW_GET_FIELD(p_shmem_info->config, in qed_read_pf_bandwidth()
1335 if (p_info->bandwidth_max < 1 || p_info->bandwidth_max > 100) { in qed_read_pf_bandwidth()
1337 "bandwidth maximum out of bounds [%02x]. Set to 100\n", in qed_read_pf_bandwidth()
1338 p_info->bandwidth_max); in qed_read_pf_bandwidth()
1339 p_info->bandwidth_max = 100; in qed_read_pf_bandwidth()
1351 spin_lock_bh(&p_hwfn->mcp_info->link_lock); in qed_mcp_handle_link_change()
1353 p_link = &p_hwfn->mcp_info->link_output; in qed_mcp_handle_link_change()
1357 p_hwfn->mcp_info->port_addr + in qed_mcp_handle_link_change()
1360 "Received link update [0x%08x] from mfw [Addr 0x%x]\n", in qed_mcp_handle_link_change()
1362 (u32)(p_hwfn->mcp_info->port_addr + in qed_mcp_handle_link_change()
1370 if (p_hwfn->b_drv_link_init) { in qed_mcp_handle_link_change()
1371 /* Link indication with modern MFW arrives as per-PF in qed_mcp_handle_link_change()
1374 if (p_hwfn->mcp_info->capabilities & in qed_mcp_handle_link_change()
1380 p_link->link_up = !!(shmem_info.status & in qed_mcp_handle_link_change()
1384 "Virtual link_up = %d\n", p_link->link_up); in qed_mcp_handle_link_change()
1386 p_link->link_up = !!(status & LINK_STATUS_LINK_UP); in qed_mcp_handle_link_change()
1388 "Physical link_up = %d\n", p_link->link_up); in qed_mcp_handle_link_change()
1391 p_link->link_up = false; in qed_mcp_handle_link_change()
1394 p_link->full_duplex = true; in qed_mcp_handle_link_change()
1397 p_link->speed = 100000; in qed_mcp_handle_link_change()
1400 p_link->speed = 50000; in qed_mcp_handle_link_change()
1403 p_link->speed = 40000; in qed_mcp_handle_link_change()
1406 p_link->speed = 25000; in qed_mcp_handle_link_change()
1409 p_link->speed = 20000; in qed_mcp_handle_link_change()
1412 p_link->speed = 10000; in qed_mcp_handle_link_change()
1415 p_link->full_duplex = false; in qed_mcp_handle_link_change()
1418 p_link->speed = 1000; in qed_mcp_handle_link_change()
1421 p_link->speed = 0; in qed_mcp_handle_link_change()
1422 p_link->link_up = 0; in qed_mcp_handle_link_change()
1425 if (p_link->link_up && p_link->speed) in qed_mcp_handle_link_change()
1426 p_link->line_speed = p_link->speed; in qed_mcp_handle_link_change()
1428 p_link->line_speed = 0; in qed_mcp_handle_link_change()
1430 max_bw = p_hwfn->mcp_info->func_info.bandwidth_max; in qed_mcp_handle_link_change()
1431 min_bw = p_hwfn->mcp_info->func_info.bandwidth_min; in qed_mcp_handle_link_change()
1438 qed_configure_vp_wfq_on_link_change(p_hwfn->cdev, p_ptt, in qed_mcp_handle_link_change()
1439 p_link->min_pf_rate); in qed_mcp_handle_link_change()
1441 p_link->an = !!(status & LINK_STATUS_AUTO_NEGOTIATE_ENABLED); in qed_mcp_handle_link_change()
1442 p_link->an_complete = !!(status & in qed_mcp_handle_link_change()
1444 p_link->parallel_detection = !!(status & in qed_mcp_handle_link_change()
1446 p_link->pfc_enabled = !!(status & LINK_STATUS_PFC_ENABLED); in qed_mcp_handle_link_change()
1448 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1451 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1454 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1457 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1460 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1463 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1466 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1469 p_link->partner_adv_speed |= in qed_mcp_handle_link_change()
1473 p_link->partner_tx_flow_ctrl_en = in qed_mcp_handle_link_change()
1475 p_link->partner_rx_flow_ctrl_en = in qed_mcp_handle_link_change()
1480 p_link->partner_adv_pause = QED_LINK_PARTNER_SYMMETRIC_PAUSE; in qed_mcp_handle_link_change()
1483 p_link->partner_adv_pause = QED_LINK_PARTNER_ASYMMETRIC_PAUSE; in qed_mcp_handle_link_change()
1486 p_link->partner_adv_pause = QED_LINK_PARTNER_BOTH_PAUSE; in qed_mcp_handle_link_change()
1489 p_link->partner_adv_pause = 0; in qed_mcp_handle_link_change()
1492 p_link->sfp_tx_fault = !!(status & LINK_STATUS_SFP_TX_FAULT); in qed_mcp_handle_link_change()
1494 if (p_hwfn->mcp_info->capabilities & FW_MB_PARAM_FEATURE_SUPPORT_EEE) in qed_mcp_handle_link_change()
1497 if (p_hwfn->mcp_info->capabilities & in qed_mcp_handle_link_change()
1501 p_link->fec_active = QED_FEC_MODE_NONE; in qed_mcp_handle_link_change()
1504 p_link->fec_active = QED_FEC_MODE_FIRECODE; in qed_mcp_handle_link_change()
1507 p_link->fec_active = QED_FEC_MODE_RS; in qed_mcp_handle_link_change()
1510 p_link->fec_active = QED_FEC_MODE_AUTO; in qed_mcp_handle_link_change()
1513 p_link->fec_active = QED_FEC_MODE_UNSUPPORTED; in qed_mcp_handle_link_change()
1518 spin_unlock_bh(&p_hwfn->mcp_info->link_lock); in qed_mcp_handle_link_change()
1523 struct qed_mcp_link_params *params = &p_hwfn->mcp_info->link_input; in qed_mcp_set_link()
1528 int rc = 0; in qed_mcp_set_link() local
1533 if (!params->speed.autoneg) in qed_mcp_set_link()
1534 phy_cfg.speed = params->speed.forced_speed; in qed_mcp_set_link()
1535 phy_cfg.pause |= (params->pause.autoneg) ? ETH_PAUSE_AUTONEG : 0; in qed_mcp_set_link()
1536 phy_cfg.pause |= (params->pause.forced_rx) ? ETH_PAUSE_RX : 0; in qed_mcp_set_link()
1537 phy_cfg.pause |= (params->pause.forced_tx) ? ETH_PAUSE_TX : 0; in qed_mcp_set_link()
1538 phy_cfg.adv_speed = params->speed.advertised_speeds; in qed_mcp_set_link()
1539 phy_cfg.loopback_mode = params->loopback_mode; in qed_mcp_set_link()
1546 if ((p_hwfn->mcp_info->capabilities & in qed_mcp_set_link()
1547 FW_MB_PARAM_FEATURE_SUPPORT_EEE) && params->eee.enable) { in qed_mcp_set_link()
1549 if (params->eee.tx_lpi_enable) in qed_mcp_set_link()
1551 if (params->eee.adv_caps & QED_EEE_1G_ADV) in qed_mcp_set_link()
1553 if (params->eee.adv_caps & QED_EEE_10G_ADV) in qed_mcp_set_link()
1555 phy_cfg.eee_cfg |= (params->eee.tx_lpi_timer << in qed_mcp_set_link()
1560 if (p_hwfn->mcp_info->capabilities & in qed_mcp_set_link()
1562 if (params->fec & QED_FEC_MODE_NONE) in qed_mcp_set_link()
1564 else if (params->fec & QED_FEC_MODE_FIRECODE) in qed_mcp_set_link()
1566 else if (params->fec & QED_FEC_MODE_RS) in qed_mcp_set_link()
1568 else if (params->fec & QED_FEC_MODE_AUTO) in qed_mcp_set_link()
1574 if (p_hwfn->mcp_info->capabilities & in qed_mcp_set_link()
1577 if (params->ext_speed.autoneg) in qed_mcp_set_link()
1580 val = params->ext_speed.forced_speed; in qed_mcp_set_link()
1605 val = params->ext_speed.advertised_speeds; in qed_mcp_set_link()
1628 params->ext_fec_mode); in qed_mcp_set_link()
1631 p_hwfn->b_drv_link_init = b_up; in qed_mcp_set_link()
1635 …"Configuring Link: Speed 0x%08x, Pause 0x%08x, Adv. Speed 0x%08x, Loopback 0x%08x, FEC 0x%08x, Ext… in qed_mcp_set_link()
1647 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_set_link()
1650 if (rc) { in qed_mcp_set_link()
1652 return rc; in qed_mcp_set_link()
1655 /* Mimic link-change attention, done for several reasons: in qed_mcp_set_link()
1656 * - On reset, there's no guarantee MFW would trigger in qed_mcp_set_link()
1658 * - On initialization, older MFWs might not indicate link change in qed_mcp_set_link()
1671 if (IS_VF(p_hwfn->cdev)) in qed_get_process_kill_counter()
1672 return -EINVAL; in qed_get_process_kill_counter()
1674 path_offsize_addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base, in qed_get_process_kill_counter()
1690 struct qed_dev *cdev = p_hwfn->cdev; in qed_mcp_handle_process_kill()
1694 * and till its load phase, during which they will be re-enabled. in qed_mcp_handle_process_kill()
1706 if (cdev->recov_in_prog) { in qed_mcp_handle_process_kill()
1712 cdev->recov_in_prog = true; in qed_mcp_handle_process_kill()
1751 qed_get_protocol_stats(p_hwfn->cdev, stats_type, &stats); in qed_mcp_send_protocol_stats()
1771 p_info = &p_hwfn->mcp_info->func_info; in qed_mcp_update_bw()
1773 qed_configure_pf_min_bandwidth(p_hwfn->cdev, p_info->bandwidth_min); in qed_mcp_update_bw()
1774 qed_configure_pf_max_bandwidth(p_hwfn->cdev, p_info->bandwidth_max); in qed_mcp_update_bw()
1788 p_hwfn->mcp_info->func_info.ovlan = (u16)shmem_info.ovlan_stag & in qed_mcp_update_stag()
1790 p_hwfn->hw_info.ovlan = p_hwfn->mcp_info->func_info.ovlan; in qed_mcp_update_stag()
1791 if (test_bit(QED_MF_OVLAN_CLSS, &p_hwfn->cdev->mf_bits)) { in qed_mcp_update_stag()
1792 if (p_hwfn->hw_info.ovlan != QED_MCP_VLAN_UNSET) { in qed_mcp_update_stag()
1794 p_hwfn->hw_info.ovlan); in qed_mcp_update_stag()
1800 p_hwfn->hw_info.ovlan); in qed_mcp_update_stag()
1811 DP_VERBOSE(p_hwfn, QED_MSG_SP, "ovlan = %d hw_mode = 0x%x\n", in qed_mcp_update_stag()
1812 p_hwfn->mcp_info->func_info.ovlan, p_hwfn->hw_info.hw_mode); in qed_mcp_update_stag()
1823 if (p_hwfn != QED_LEADING_HWFN(p_hwfn->cdev)) in qed_mcp_handle_fan_failure()
1845 int rc; in qed_mcp_mdump_cmd() local
1849 mb_params.param = p_mdump_cmd_params->cmd; in qed_mcp_mdump_cmd()
1850 mb_params.p_data_src = p_mdump_cmd_params->p_data_src; in qed_mcp_mdump_cmd()
1851 mb_params.data_src_size = p_mdump_cmd_params->data_src_size; in qed_mcp_mdump_cmd()
1852 mb_params.p_data_dst = p_mdump_cmd_params->p_data_dst; in qed_mcp_mdump_cmd()
1853 mb_params.data_dst_size = p_mdump_cmd_params->data_dst_size; in qed_mcp_mdump_cmd()
1854 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_mdump_cmd()
1855 if (rc) in qed_mcp_mdump_cmd()
1856 return rc; in qed_mcp_mdump_cmd()
1858 p_mdump_cmd_params->mcp_resp = mb_params.mcp_resp; in qed_mcp_mdump_cmd()
1860 if (p_mdump_cmd_params->mcp_resp == FW_MSG_CODE_MDUMP_INVALID_CMD) { in qed_mcp_mdump_cmd()
1862 "The mdump sub command is unsupported by the MFW [mdump_cmd 0x%x]\n", in qed_mcp_mdump_cmd()
1863 p_mdump_cmd_params->cmd); in qed_mcp_mdump_cmd()
1864 rc = -EOPNOTSUPP; in qed_mcp_mdump_cmd()
1865 } else if (p_mdump_cmd_params->mcp_resp == FW_MSG_CODE_UNSUPPORTED) { in qed_mcp_mdump_cmd()
1868 rc = -EOPNOTSUPP; in qed_mcp_mdump_cmd()
1871 return rc; in qed_mcp_mdump_cmd()
1890 int rc; in qed_mcp_mdump_get_retain() local
1897 rc = qed_mcp_mdump_cmd(p_hwfn, p_ptt, &mdump_cmd_params); in qed_mcp_mdump_get_retain()
1898 if (rc) in qed_mcp_mdump_get_retain()
1899 return rc; in qed_mcp_mdump_get_retain()
1903 "Failed to get the mdump retained data [mcp_resp 0x%x]\n", in qed_mcp_mdump_get_retain()
1905 return -EINVAL; in qed_mcp_mdump_get_retain()
1915 int rc; in qed_mcp_handle_critical_error() local
1917 /* In CMT mode - no need for more than a single acknowledgment to the in qed_mcp_handle_critical_error()
1920 if (p_hwfn != QED_LEADING_HWFN(p_hwfn->cdev)) in qed_mcp_handle_critical_error()
1923 rc = qed_mcp_mdump_get_retain(p_hwfn, p_ptt, &mdump_retain); in qed_mcp_handle_critical_error()
1924 if (rc == 0 && mdump_retain.valid) in qed_mcp_handle_critical_error()
1926 …FW notified that a critical error occurred in the device [epoch 0x%08x, pf 0x%x, status 0x%08x]\n", in qed_mcp_handle_critical_error()
1945 if (!test_bit(QED_MF_UFP_SPECIFIC, &p_hwfn->cdev->mf_bits)) in qed_mcp_read_ufp_config()
1948 memset(&p_hwfn->ufp_info, 0, sizeof(p_hwfn->ufp_info)); in qed_mcp_read_ufp_config()
1949 port_cfg = qed_rd(p_hwfn, p_ptt, p_hwfn->mcp_info->port_addr + in qed_mcp_read_ufp_config()
1955 "Incorrect UFP Channel type %d port_id 0x%02x\n", in qed_mcp_read_ufp_config()
1960 p_hwfn->ufp_info.mode = QED_UFP_MODE_ETS; in qed_mcp_read_ufp_config()
1962 p_hwfn->ufp_info.mode = QED_UFP_MODE_VNIC_BW; in qed_mcp_read_ufp_config()
1964 p_hwfn->ufp_info.mode = QED_UFP_MODE_UNKNOWN; in qed_mcp_read_ufp_config()
1966 "Unknown UFP scheduling mode %d port_id 0x%02x\n", in qed_mcp_read_ufp_config()
1973 p_hwfn->ufp_info.tc = (u8)val; in qed_mcp_read_ufp_config()
1977 p_hwfn->ufp_info.pri_type = QED_UFP_PRI_VNIC; in qed_mcp_read_ufp_config()
1979 p_hwfn->ufp_info.pri_type = QED_UFP_PRI_OS; in qed_mcp_read_ufp_config()
1981 p_hwfn->ufp_info.pri_type = QED_UFP_PRI_UNKNOWN; in qed_mcp_read_ufp_config()
1983 "Unknown Host priority control %d port_id 0x%02x\n", in qed_mcp_read_ufp_config()
1988 "UFP shmem config: mode = %d tc = %d pri_type = %d port_id 0x%02x\n", in qed_mcp_read_ufp_config()
1989 p_hwfn->ufp_info.mode, p_hwfn->ufp_info.tc, in qed_mcp_read_ufp_config()
1990 p_hwfn->ufp_info.pri_type, MFW_PORT(p_hwfn)); in qed_mcp_read_ufp_config()
1998 if (p_hwfn->ufp_info.mode == QED_UFP_MODE_VNIC_BW) { in qed_mcp_handle_ufp_event()
1999 p_hwfn->qm_info.ooo_tc = p_hwfn->ufp_info.tc; in qed_mcp_handle_ufp_event()
2000 qed_hw_info_set_offload_tc(&p_hwfn->hw_info, in qed_mcp_handle_ufp_event()
2001 p_hwfn->ufp_info.tc); in qed_mcp_handle_ufp_event()
2004 } else if (p_hwfn->ufp_info.mode == QED_UFP_MODE_ETS) { in qed_mcp_handle_ufp_event()
2010 return -EINVAL; in qed_mcp_handle_ufp_event()
2025 struct qed_mcp_info *info = p_hwfn->mcp_info; in qed_mcp_handle_events()
2026 int rc = 0; in qed_mcp_handle_events() local
2036 for (i = 0; i < info->mfw_mb_length; i++) { in qed_mcp_handle_events()
2037 if (info->mfw_mb_cur[i] == info->mfw_mb_shadow[i]) in qed_mcp_handle_events()
2043 "Msg [%d] - old CMD 0x%02x, new CMD 0x%02x\n", in qed_mcp_handle_events()
2044 i, info->mfw_mb_shadow[i], info->mfw_mb_cur[i]); in qed_mcp_handle_events()
2046 spin_lock_bh(&p_hwfn->mcp_info->unload_lock); in qed_mcp_handle_events()
2048 &p_hwfn->mcp_info->mcp_handling_status)) { in qed_mcp_handle_events()
2049 spin_unlock_bh(&p_hwfn->mcp_info->unload_lock); in qed_mcp_handle_events()
2056 &p_hwfn->mcp_info->mcp_handling_status); in qed_mcp_handle_events()
2057 spin_unlock_bh(&p_hwfn->mcp_info->unload_lock); in qed_mcp_handle_events()
2110 rc = -EINVAL; in qed_mcp_handle_events()
2114 &p_hwfn->mcp_info->mcp_handling_status); in qed_mcp_handle_events()
2118 for (i = 0; i < MFW_DRV_MSG_MAX_DWORDS(info->mfw_mb_length); i++) { in qed_mcp_handle_events()
2119 __be32 val = cpu_to_be32(((u32 *)info->mfw_mb_cur)[i]); in qed_mcp_handle_events()
2123 info->mfw_mb_addr + sizeof(u32) + in qed_mcp_handle_events()
2124 MFW_DRV_MSG_MAX_DWORDS(info->mfw_mb_length) * in qed_mcp_handle_events()
2132 rc = -EINVAL; in qed_mcp_handle_events()
2136 memcpy(info->mfw_mb_shadow, info->mfw_mb_cur, info->mfw_mb_length); in qed_mcp_handle_events()
2138 return rc; in qed_mcp_handle_events()
2147 if (IS_VF(p_hwfn->cdev)) { in qed_mcp_get_mfw_ver()
2148 if (p_hwfn->vf_iov_info) { in qed_mcp_get_mfw_ver()
2151 p_resp = &p_hwfn->vf_iov_info->acquire_resp; in qed_mcp_get_mfw_ver()
2152 *p_mfw_ver = p_resp->pfdev_info.mfw_ver; in qed_mcp_get_mfw_ver()
2158 return -EINVAL; in qed_mcp_get_mfw_ver()
2162 public_base = p_hwfn->mcp_info->public_base; in qed_mcp_get_mfw_ver()
2186 if (IS_VF(p_hwfn->cdev)) in qed_mcp_get_mbi_ver()
2187 return -EINVAL; in qed_mcp_get_mbi_ver()
2193 return -EINVAL; in qed_mcp_get_mbi_ver()
2216 if (IS_VF(p_hwfn->cdev)) in qed_mcp_get_media_type()
2217 return -EINVAL; in qed_mcp_get_media_type()
2221 return -EBUSY; in qed_mcp_get_media_type()
2226 return -EINVAL; in qed_mcp_get_media_type()
2230 p_hwfn->mcp_info->port_addr + in qed_mcp_get_media_type()
2247 if (IS_VF(p_hwfn->cdev)) in qed_mcp_get_transceiver_data()
2248 return -EINVAL; in qed_mcp_get_transceiver_data()
2252 return -EBUSY; in qed_mcp_get_transceiver_data()
2256 p_hwfn->mcp_info->port_addr + in qed_mcp_get_transceiver_data()
2298 return -EINVAL; in qed_mcp_trans_speed_mask()
2390 DP_INFO(p_hwfn, "Unknown transceiver type 0x%x\n", in qed_mcp_trans_speed_mask()
2404 if (IS_VF(p_hwfn->cdev)) in qed_mcp_get_board_config()
2405 return -EINVAL; in qed_mcp_get_board_config()
2409 return -EBUSY; in qed_mcp_get_board_config()
2413 return -EINVAL; in qed_mcp_get_board_config()
2436 if (test_bit(QED_DEV_CAP_ROCE, &p_hwfn->hw_info.device_capabilities)) in qed_mcp_get_shmem_proto_legacy()
2442 "According to Legacy capabilities, L2 personality is %08x\n", in qed_mcp_get_shmem_proto_legacy()
2452 int rc; in qed_mcp_get_shmem_proto_mfw() local
2454 rc = qed_mcp_cmd(p_hwfn, p_ptt, in qed_mcp_get_shmem_proto_mfw()
2456 if (rc) in qed_mcp_get_shmem_proto_mfw()
2457 return rc; in qed_mcp_get_shmem_proto_mfw()
2460 "MFW lacks support for command; Returns %08x\n", in qed_mcp_get_shmem_proto_mfw()
2462 return -EINVAL; in qed_mcp_get_shmem_proto_mfw()
2480 "MFW answers GET_PF_RDMA_PROTOCOL but param is %08x\n", in qed_mcp_get_shmem_proto_mfw()
2482 return -EINVAL; in qed_mcp_get_shmem_proto_mfw()
2487 "According to capabilities, L2 personality is %08x [resp %08x param %08x]\n", in qed_mcp_get_shmem_proto_mfw()
2498 int rc = 0; in qed_mcp_get_shmem_proto() local
2500 switch (p_info->config & FUNC_MF_CFG_PROTOCOL_MASK) { in qed_mcp_get_shmem_proto()
2517 rc = -EINVAL; in qed_mcp_get_shmem_proto()
2520 return rc; in qed_mcp_get_shmem_proto()
2530 info = &p_hwfn->mcp_info->func_info; in qed_mcp_fill_shmem_func_info()
2532 info->pause_on_host = (shmem_info.config & in qed_mcp_fill_shmem_func_info()
2536 &info->protocol)) { in qed_mcp_fill_shmem_func_info()
2537 DP_ERR(p_hwfn, "Unknown personality %08x\n", in qed_mcp_fill_shmem_func_info()
2539 return -EINVAL; in qed_mcp_fill_shmem_func_info()
2545 info->mac[0] = (u8)(shmem_info.mac_upper >> 8); in qed_mcp_fill_shmem_func_info()
2546 info->mac[1] = (u8)(shmem_info.mac_upper); in qed_mcp_fill_shmem_func_info()
2547 info->mac[2] = (u8)(shmem_info.mac_lower >> 24); in qed_mcp_fill_shmem_func_info()
2548 info->mac[3] = (u8)(shmem_info.mac_lower >> 16); in qed_mcp_fill_shmem_func_info()
2549 info->mac[4] = (u8)(shmem_info.mac_lower >> 8); in qed_mcp_fill_shmem_func_info()
2550 info->mac[5] = (u8)(shmem_info.mac_lower); in qed_mcp_fill_shmem_func_info()
2553 memcpy(&p_hwfn->cdev->wol_mac, info->mac, ETH_ALEN); in qed_mcp_fill_shmem_func_info()
2558 info->wwn_port = (u64)shmem_info.fcoe_wwn_port_name_lower | in qed_mcp_fill_shmem_func_info()
2560 info->wwn_node = (u64)shmem_info.fcoe_wwn_node_name_lower | in qed_mcp_fill_shmem_func_info()
2563 info->ovlan = (u16)(shmem_info.ovlan_stag & FUNC_MF_CFG_OV_STAG_MASK); in qed_mcp_fill_shmem_func_info()
2565 info->mtu = (u16)shmem_info.mtu_size; in qed_mcp_fill_shmem_func_info()
2567 p_hwfn->hw_info.b_wol_support = QED_WOL_SUPPORT_NONE; in qed_mcp_fill_shmem_func_info()
2568 p_hwfn->cdev->wol_config = (u8)QED_OV_WOL_DEFAULT; in qed_mcp_fill_shmem_func_info()
2571 int rc; in qed_mcp_fill_shmem_func_info() local
2573 rc = qed_mcp_cmd(p_hwfn, p_ptt, in qed_mcp_fill_shmem_func_info()
2575 if (rc) in qed_mcp_fill_shmem_func_info()
2576 return rc; in qed_mcp_fill_shmem_func_info()
2578 p_hwfn->hw_info.b_wol_support = QED_WOL_SUPPORT_PME; in qed_mcp_fill_shmem_func_info()
2582 …tion from shmem: pause_on_host %02x protocol %02x BW [%02x - %02x] MAC %pM wwn port %llx node %llx… in qed_mcp_fill_shmem_func_info()
2583 info->pause_on_host, info->protocol, in qed_mcp_fill_shmem_func_info()
2584 info->bandwidth_min, info->bandwidth_max, in qed_mcp_fill_shmem_func_info()
2585 info->mac, in qed_mcp_fill_shmem_func_info()
2586 info->wwn_port, info->wwn_node, in qed_mcp_fill_shmem_func_info()
2587 info->ovlan, (u8)p_hwfn->hw_info.b_wol_support); in qed_mcp_fill_shmem_func_info()
2595 if (!p_hwfn || !p_hwfn->mcp_info) in qed_mcp_get_link_params()
2597 return &p_hwfn->mcp_info->link_input; in qed_mcp_get_link_params()
2603 if (!p_hwfn || !p_hwfn->mcp_info) in qed_mcp_get_link_state()
2605 return &p_hwfn->mcp_info->link_output; in qed_mcp_get_link_state()
2611 if (!p_hwfn || !p_hwfn->mcp_info) in qed_mcp_get_link_capabilities()
2613 return &p_hwfn->mcp_info->link_capabilities; in qed_mcp_get_link_capabilities()
2619 int rc; in qed_mcp_drain() local
2621 rc = qed_mcp_cmd(p_hwfn, p_ptt, in qed_mcp_drain()
2627 return rc; in qed_mcp_drain()
2635 if (IS_VF(p_hwfn->cdev)) in qed_mcp_get_flash_size()
2636 return -EINVAL; in qed_mcp_get_flash_size()
2650 struct qed_dev *cdev = p_hwfn->cdev; in qed_start_recovery_process()
2652 if (cdev->recov_in_prog) { in qed_start_recovery_process()
2655 return -EAGAIN; in qed_start_recovery_process()
2669 struct qed_ptt *p_ptt = p_hwfn->p_main_ptt; in qed_recovery_prolog()
2670 int rc; in qed_recovery_prolog() local
2676 rc = qed_pglueb_set_pfid_enable(p_hwfn, p_ptt, false); in qed_recovery_prolog()
2677 if (rc) in qed_recovery_prolog()
2679 "qed_pglueb_set_pfid_enable() failed. rc = %d.\n", in qed_recovery_prolog()
2680 rc); in qed_recovery_prolog()
2682 return rc; in qed_recovery_prolog()
2690 int rc; in qed_mcp_config_vf_msix_bb() local
2695 num *= p_hwfn->cdev->num_hwfns; in qed_mcp_config_vf_msix_bb()
2702 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_CFG_VF_MSIX, param, in qed_mcp_config_vf_msix_bb()
2706 DP_NOTICE(p_hwfn, "VF[%d]: MFW failed to set MSI-X\n", vf_id); in qed_mcp_config_vf_msix_bb()
2707 rc = -EINVAL; in qed_mcp_config_vf_msix_bb()
2710 "Requested 0x%02x MSI-x interrupts from VF 0x%02x\n", in qed_mcp_config_vf_msix_bb()
2714 return rc; in qed_mcp_config_vf_msix_bb()
2722 int rc; in qed_mcp_config_vf_msix_ah() local
2724 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_CFG_PF_VFS_MSIX, in qed_mcp_config_vf_msix_ah()
2728 DP_NOTICE(p_hwfn, "MFW failed to set MSI-X for VFs\n"); in qed_mcp_config_vf_msix_ah()
2729 rc = -EINVAL; in qed_mcp_config_vf_msix_ah()
2732 "Requested 0x%02x MSI-x interrupts for VFs\n", num); in qed_mcp_config_vf_msix_ah()
2735 return rc; in qed_mcp_config_vf_msix_ah()
2741 if (QED_IS_BB(p_hwfn->cdev)) in qed_mcp_config_vf_msix()
2756 int rc; in qed_mcp_send_drv_version() local
2759 drv_version.version = p_ver->version; in qed_mcp_send_drv_version()
2760 for (i = 0; i < (MCP_DRV_VER_STR_SIZE - 4) / sizeof(u32); i++) { in qed_mcp_send_drv_version()
2761 val = cpu_to_be32(*((u32 *)&p_ver->name[i * sizeof(u32)])); in qed_mcp_send_drv_version()
2769 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_send_drv_version()
2770 if (rc) in qed_mcp_send_drv_version()
2773 return rc; in qed_mcp_send_drv_version()
2783 int rc; in qed_mcp_halt() local
2785 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_MCP_HALT, 0, &resp, in qed_mcp_halt()
2787 if (rc) { in qed_mcp_halt()
2789 return rc; in qed_mcp_halt()
2801 "Failed to halt the MCP [CPU_MODE = 0x%08x, CPU_STATE = 0x%08x]\n", in qed_mcp_halt()
2803 return -EBUSY; in qed_mcp_halt()
2827 "Failed to resume the MCP [CPU_MODE = 0x%08x, CPU_STATE = 0x%08x]\n", in qed_mcp_resume()
2829 return -EBUSY; in qed_mcp_resume()
2843 int rc; in qed_mcp_ov_update_current_config() local
2857 return -EINVAL; in qed_mcp_ov_update_current_config()
2860 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_OV_UPDATE_CURR_CFG, in qed_mcp_ov_update_current_config()
2862 if (rc) in qed_mcp_ov_update_current_config()
2865 return rc; in qed_mcp_ov_update_current_config()
2874 int rc; in qed_mcp_ov_update_driver_state() local
2888 return -EINVAL; in qed_mcp_ov_update_driver_state()
2891 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_OV_UPDATE_DRIVER_STATE, in qed_mcp_ov_update_driver_state()
2893 if (rc) in qed_mcp_ov_update_driver_state()
2896 return rc; in qed_mcp_ov_update_driver_state()
2904 int rc; in qed_mcp_ov_update_mtu() local
2907 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_OV_UPDATE_MTU, in qed_mcp_ov_update_mtu()
2909 if (rc) in qed_mcp_ov_update_mtu()
2910 DP_ERR(p_hwfn, "Failed to send mtu value, rc = %d\n", rc); in qed_mcp_ov_update_mtu()
2912 return rc; in qed_mcp_ov_update_mtu()
2920 int rc; in qed_mcp_ov_update_mac() local
2929 * in 32-bit granularity. in qed_mcp_ov_update_mac()
2938 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_ov_update_mac()
2939 if (rc) in qed_mcp_ov_update_mac()
2940 DP_ERR(p_hwfn, "Failed to send mac address, rc = %d\n", rc); in qed_mcp_ov_update_mac()
2943 memcpy(p_hwfn->cdev->wol_mac, mac, ETH_ALEN); in qed_mcp_ov_update_mac()
2945 return rc; in qed_mcp_ov_update_mac()
2953 int rc; in qed_mcp_ov_update_wol() local
2955 if (p_hwfn->hw_info.b_wol_support == QED_WOL_SUPPORT_NONE) { in qed_mcp_ov_update_wol()
2958 return -EINVAL; in qed_mcp_ov_update_wol()
2973 return -EINVAL; in qed_mcp_ov_update_wol()
2976 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_OV_UPDATE_WOL, in qed_mcp_ov_update_wol()
2978 if (rc) in qed_mcp_ov_update_wol()
2979 DP_ERR(p_hwfn, "Failed to send wol mode, rc = %d\n", rc); in qed_mcp_ov_update_wol()
2982 p_hwfn->cdev->wol_config = (u8)wol; in qed_mcp_ov_update_wol()
2984 return rc; in qed_mcp_ov_update_wol()
2993 int rc; in qed_mcp_ov_update_eswitch() local
3007 return -EINVAL; in qed_mcp_ov_update_eswitch()
3010 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_OV_UPDATE_ESWITCH_MODE, in qed_mcp_ov_update_eswitch()
3012 if (rc) in qed_mcp_ov_update_eswitch()
3013 DP_ERR(p_hwfn, "Failed to send eswitch mode, rc = %d\n", rc); in qed_mcp_ov_update_eswitch()
3015 return rc; in qed_mcp_ov_update_eswitch()
3022 int rc; in qed_mcp_set_led() local
3036 return -EINVAL; in qed_mcp_set_led()
3039 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_SET_LED_MODE, in qed_mcp_set_led()
3042 return rc; in qed_mcp_set_led()
3049 int rc; in qed_mcp_mask_parities() local
3051 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_MASK_PARITIES, in qed_mcp_mask_parities()
3054 if (rc) { in qed_mcp_mask_parities()
3060 rc = -EINVAL; in qed_mcp_mask_parities()
3063 return rc; in qed_mcp_mask_parities()
3072 int rc = 0; in qed_mcp_nvm_read() local
3076 return -EBUSY; in qed_mcp_nvm_read()
3081 rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt, in qed_mcp_nvm_read()
3090 if (rc || (resp != FW_MSG_CODE_NVM_OK)) { in qed_mcp_nvm_read()
3091 DP_NOTICE(cdev, "MCP command rc = %d\n", rc); in qed_mcp_nvm_read()
3099 (bytes_left - read_len) % 0x1000) in qed_mcp_nvm_read()
3103 bytes_left -= read_len; in qed_mcp_nvm_read()
3106 cdev->mcp_nvm_resp = resp; in qed_mcp_nvm_read()
3109 return rc; in qed_mcp_nvm_read()
3119 return -EBUSY; in qed_mcp_nvm_resp()
3121 memcpy(p_buf, &cdev->mcp_nvm_resp, sizeof(cdev->mcp_nvm_resp)); in qed_mcp_nvm_resp()
3133 int rc = -EINVAL; in qed_mcp_nvm_write() local
3137 return -EBUSY; in qed_mcp_nvm_write()
3150 DP_NOTICE(p_hwfn, "Invalid nvm write command 0x%x\n", cmd); in qed_mcp_nvm_write()
3151 rc = -EINVAL; in qed_mcp_nvm_write()
3155 buf_size = min_t(u32, (len - buf_idx), MCP_DRV_NVM_BUF_LEN); in qed_mcp_nvm_write()
3163 rc = qed_mcp_nvm_wr_cmd(p_hwfn, p_ptt, nvm_cmd, nvm_offset, in qed_mcp_nvm_write()
3166 if (rc) { in qed_mcp_nvm_write()
3167 DP_NOTICE(cdev, "nvm write failed, rc = %d\n", rc); in qed_mcp_nvm_write()
3176 "nvm write failed, resp = 0x%08x\n", resp); in qed_mcp_nvm_write()
3177 rc = -EINVAL; in qed_mcp_nvm_write()
3182 * isn't pre-emptable. Sleep a bit to prevent CPU hogging. in qed_mcp_nvm_write()
3199 buf_size = min_t(u32, (len - buf_idx), in qed_mcp_nvm_write()
3204 cdev->mcp_nvm_resp = resp; in qed_mcp_nvm_write()
3208 return rc; in qed_mcp_nvm_write()
3216 int rc; in qed_mcp_phy_sfp_read() local
3237 rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt, in qed_mcp_phy_sfp_read()
3241 if (rc) { in qed_mcp_phy_sfp_read()
3243 "Failed to send a transceiver read command to the MFW. rc = %d.\n", in qed_mcp_phy_sfp_read()
3244 rc); in qed_mcp_phy_sfp_read()
3245 return rc; in qed_mcp_phy_sfp_read()
3249 return -ENODEV; in qed_mcp_phy_sfp_read()
3251 return -EINVAL; in qed_mcp_phy_sfp_read()
3254 bytes_left -= buf_size; in qed_mcp_phy_sfp_read()
3263 int rc = 0; in qed_mcp_bist_register_test() local
3268 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_BIST_TEST, in qed_mcp_bist_register_test()
3271 if (rc) in qed_mcp_bist_register_test()
3272 return rc; in qed_mcp_bist_register_test()
3276 rc = -EAGAIN; in qed_mcp_bist_register_test()
3278 return rc; in qed_mcp_bist_register_test()
3284 int rc = 0; in qed_mcp_bist_clock_test() local
3289 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_BIST_TEST, in qed_mcp_bist_clock_test()
3292 if (rc) in qed_mcp_bist_clock_test()
3293 return rc; in qed_mcp_bist_clock_test()
3297 rc = -EAGAIN; in qed_mcp_bist_clock_test()
3299 return rc; in qed_mcp_bist_clock_test()
3307 int rc = 0; in qed_mcp_bist_nvm_get_num_images() local
3312 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_BIST_TEST, in qed_mcp_bist_nvm_get_num_images()
3314 if (rc) in qed_mcp_bist_nvm_get_num_images()
3315 return rc; in qed_mcp_bist_nvm_get_num_images()
3318 rc = -EINVAL; in qed_mcp_bist_nvm_get_num_images()
3320 return rc; in qed_mcp_bist_nvm_get_num_images()
3329 int rc; in qed_mcp_bist_nvm_get_image_att() local
3335 rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt, in qed_mcp_bist_nvm_get_image_att()
3340 if (rc) in qed_mcp_bist_nvm_get_image_att()
3341 return rc; in qed_mcp_bist_nvm_get_image_att()
3344 (p_image_att->return_code != 1)) in qed_mcp_bist_nvm_get_image_att()
3345 rc = -EINVAL; in qed_mcp_bist_nvm_get_image_att()
3347 return rc; in qed_mcp_bist_nvm_get_image_att()
3354 int rc; in qed_mcp_nvm_info_populate() local
3357 if (p_hwfn->nvm_info.valid) in qed_mcp_nvm_info_populate()
3363 return -EBUSY; in qed_mcp_nvm_info_populate()
3368 rc = qed_mcp_bist_nvm_get_num_images(p_hwfn, in qed_mcp_nvm_info_populate()
3370 if (rc == -EOPNOTSUPP) { in qed_mcp_nvm_info_populate()
3373 } else if (rc || !nvm_info.num_images) { in qed_mcp_nvm_info_populate()
3382 rc = -ENOMEM; in qed_mcp_nvm_info_populate()
3388 rc = qed_mcp_bist_nvm_get_image_att(p_hwfn, p_ptt, in qed_mcp_nvm_info_populate()
3390 if (rc) { in qed_mcp_nvm_info_populate()
3396 DP_VERBOSE(p_hwfn, QED_MSG_SP, "image index %d, size %x\n", i, in qed_mcp_nvm_info_populate()
3402 p_hwfn->nvm_info.num_images = nvm_info.num_images; in qed_mcp_nvm_info_populate()
3403 kfree(p_hwfn->nvm_info.image_att); in qed_mcp_nvm_info_populate()
3404 p_hwfn->nvm_info.image_att = nvm_info.image_att; in qed_mcp_nvm_info_populate()
3405 p_hwfn->nvm_info.valid = true; in qed_mcp_nvm_info_populate()
3415 return rc; in qed_mcp_nvm_info_populate()
3420 kfree(p_hwfn->nvm_info.image_att); in qed_mcp_nvm_info_free()
3421 p_hwfn->nvm_info.image_att = NULL; in qed_mcp_nvm_info_free()
3422 p_hwfn->nvm_info.valid = false; in qed_mcp_nvm_info_free()
3431 int rc; in qed_mcp_get_nvm_image_att() local
3455 DP_NOTICE(p_hwfn, "Unknown request of image_id %08x\n", in qed_mcp_get_nvm_image_att()
3457 return -EINVAL; in qed_mcp_get_nvm_image_att()
3460 rc = qed_mcp_nvm_info_populate(p_hwfn); in qed_mcp_get_nvm_image_att()
3461 if (rc) in qed_mcp_get_nvm_image_att()
3462 return rc; in qed_mcp_get_nvm_image_att()
3464 for (i = 0; i < p_hwfn->nvm_info.num_images; i++) in qed_mcp_get_nvm_image_att()
3465 if (type == p_hwfn->nvm_info.image_att[i].image_type) in qed_mcp_get_nvm_image_att()
3467 if (i == p_hwfn->nvm_info.num_images) { in qed_mcp_get_nvm_image_att()
3469 "Failed to find nvram image of type %08x\n", in qed_mcp_get_nvm_image_att()
3471 return -ENOENT; in qed_mcp_get_nvm_image_att()
3474 p_image_att->start_addr = p_hwfn->nvm_info.image_att[i].nvm_start_addr; in qed_mcp_get_nvm_image_att()
3475 p_image_att->length = p_hwfn->nvm_info.image_att[i].len; in qed_mcp_get_nvm_image_att()
3485 int rc; in qed_mcp_get_nvm_image() local
3489 rc = qed_mcp_get_nvm_image_att(p_hwfn, image_id, &image_att); in qed_mcp_get_nvm_image()
3490 if (rc) in qed_mcp_get_nvm_image()
3491 return rc; in qed_mcp_get_nvm_image()
3493 /* Validate sizes - both the image's and the supplied buffer's */ in qed_mcp_get_nvm_image()
3496 "Image [%d] is too small - only %d bytes\n", in qed_mcp_get_nvm_image()
3498 return -EINVAL; in qed_mcp_get_nvm_image()
3504 "Image [%d] is too big - %08x bytes where only %08x are available\n", in qed_mcp_get_nvm_image()
3506 return -ENOMEM; in qed_mcp_get_nvm_image()
3509 return qed_mcp_nvm_read(p_hwfn->cdev, image_att.start_addr, in qed_mcp_get_nvm_image()
3600 int rc; in qed_mcp_resc_allocation_msg() local
3604 mfw_resc_info.res_id = qed_mcp_get_mfw_res_id(p_in_params->res_id); in qed_mcp_resc_allocation_msg()
3608 p_in_params->res_id, in qed_mcp_resc_allocation_msg()
3609 qed_hw_get_resc_name(p_in_params->res_id)); in qed_mcp_resc_allocation_msg()
3610 return -EINVAL; in qed_mcp_resc_allocation_msg()
3613 switch (p_in_params->cmd) { in qed_mcp_resc_allocation_msg()
3615 mfw_resc_info.size = p_in_params->resc_max_val; in qed_mcp_resc_allocation_msg()
3620 DP_ERR(p_hwfn, "Unexpected resource alloc command [0x%08x]\n", in qed_mcp_resc_allocation_msg()
3621 p_in_params->cmd); in qed_mcp_resc_allocation_msg()
3622 return -EINVAL; in qed_mcp_resc_allocation_msg()
3626 mb_params.cmd = p_in_params->cmd; in qed_mcp_resc_allocation_msg()
3635 "Resource message request: cmd 0x%08x, res_id %d [%s], hsi_version %d.%d, val 0x%x\n", in qed_mcp_resc_allocation_msg()
3636 p_in_params->cmd, in qed_mcp_resc_allocation_msg()
3637 p_in_params->res_id, in qed_mcp_resc_allocation_msg()
3638 qed_hw_get_resc_name(p_in_params->res_id), in qed_mcp_resc_allocation_msg()
3643 p_in_params->resc_max_val); in qed_mcp_resc_allocation_msg()
3645 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_resc_allocation_msg()
3646 if (rc) in qed_mcp_resc_allocation_msg()
3647 return rc; in qed_mcp_resc_allocation_msg()
3649 p_out_params->mcp_resp = mb_params.mcp_resp; in qed_mcp_resc_allocation_msg()
3650 p_out_params->mcp_param = mb_params.mcp_param; in qed_mcp_resc_allocation_msg()
3651 p_out_params->resc_num = mfw_resc_info.size; in qed_mcp_resc_allocation_msg()
3652 p_out_params->resc_start = mfw_resc_info.offset; in qed_mcp_resc_allocation_msg()
3653 p_out_params->vf_resc_num = mfw_resc_info.vf_size; in qed_mcp_resc_allocation_msg()
3654 p_out_params->vf_resc_start = mfw_resc_info.vf_offset; in qed_mcp_resc_allocation_msg()
3655 p_out_params->flags = mfw_resc_info.flags; in qed_mcp_resc_allocation_msg()
3659 …e message response: mfw_hsi_version %d.%d, num 0x%x, start 0x%x, vf_num 0x%x, vf_start 0x%x, flags… in qed_mcp_resc_allocation_msg()
3660 QED_MFW_GET_FIELD(p_out_params->mcp_param, in qed_mcp_resc_allocation_msg()
3662 QED_MFW_GET_FIELD(p_out_params->mcp_param, in qed_mcp_resc_allocation_msg()
3664 p_out_params->resc_num, in qed_mcp_resc_allocation_msg()
3665 p_out_params->resc_start, in qed_mcp_resc_allocation_msg()
3666 p_out_params->vf_resc_num, in qed_mcp_resc_allocation_msg()
3667 p_out_params->vf_resc_start, p_out_params->flags); in qed_mcp_resc_allocation_msg()
3680 int rc; in qed_mcp_set_resc_max_val() local
3687 rc = qed_mcp_resc_allocation_msg(p_hwfn, p_ptt, &in_params, in qed_mcp_set_resc_max_val()
3689 if (rc) in qed_mcp_set_resc_max_val()
3690 return rc; in qed_mcp_set_resc_max_val()
3705 int rc; in qed_mcp_get_resc_info() local
3711 rc = qed_mcp_resc_allocation_msg(p_hwfn, p_ptt, &in_params, in qed_mcp_get_resc_info()
3713 if (rc) in qed_mcp_get_resc_info()
3714 return rc; in qed_mcp_get_resc_info()
3738 int rc; in qed_mcp_resource_cmd() local
3740 rc = qed_mcp_cmd_nosleep(p_hwfn, p_ptt, DRV_MSG_CODE_RESOURCE_CMD, in qed_mcp_resource_cmd()
3742 if (rc) in qed_mcp_resource_cmd()
3743 return rc; in qed_mcp_resource_cmd()
3748 return -EINVAL; in qed_mcp_resource_cmd()
3755 "The resource command is unknown to the MFW [param 0x%08x, opcode %d]\n", in qed_mcp_resource_cmd()
3757 return -EINVAL; in qed_mcp_resource_cmd()
3760 return rc; in qed_mcp_resource_cmd()
3770 int rc; in __qed_mcp_resc_lock() local
3772 switch (p_params->timeout) { in __qed_mcp_resc_lock()
3775 p_params->timeout = 0; in __qed_mcp_resc_lock()
3779 p_params->timeout = 0; in __qed_mcp_resc_lock()
3786 QED_MFW_SET_FIELD(param, RESOURCE_CMD_REQ_RESC, p_params->resource); in __qed_mcp_resc_lock()
3788 QED_MFW_SET_FIELD(param, RESOURCE_CMD_REQ_AGE, p_params->timeout); in __qed_mcp_resc_lock()
3792 "Resource lock request: param 0x%08x [age %d, opcode %d, resource %d]\n", in __qed_mcp_resc_lock()
3793 param, p_params->timeout, opcode, p_params->resource); in __qed_mcp_resc_lock()
3796 rc = qed_mcp_resource_cmd(p_hwfn, p_ptt, param, &mcp_resp, &mcp_param); in __qed_mcp_resc_lock()
3797 if (rc) in __qed_mcp_resc_lock()
3798 return rc; in __qed_mcp_resc_lock()
3801 p_params->owner = QED_MFW_GET_FIELD(mcp_param, RESOURCE_CMD_RSP_OWNER); in __qed_mcp_resc_lock()
3806 "Resource lock response: mcp_param 0x%08x [opcode %d, owner %d]\n", in __qed_mcp_resc_lock()
3807 mcp_param, opcode, p_params->owner); in __qed_mcp_resc_lock()
3811 p_params->b_granted = true; in __qed_mcp_resc_lock()
3814 p_params->b_granted = false; in __qed_mcp_resc_lock()
3818 "Unexpected opcode in resource lock response [mcp_param 0x%08x, opcode %d]\n", in __qed_mcp_resc_lock()
3820 return -EINVAL; in __qed_mcp_resc_lock()
3831 int rc; in qed_mcp_resc_lock() local
3836 if (p_params->sleep_b4_retry) { in qed_mcp_resc_lock()
3838 DIV_ROUND_UP(p_params->retry_interval, in qed_mcp_resc_lock()
3843 udelay(p_params->retry_interval); in qed_mcp_resc_lock()
3847 rc = __qed_mcp_resc_lock(p_hwfn, p_ptt, p_params); in qed_mcp_resc_lock()
3848 if (rc) in qed_mcp_resc_lock()
3849 return rc; in qed_mcp_resc_lock()
3851 if (p_params->b_granted) in qed_mcp_resc_lock()
3853 } while (retry_cnt++ < p_params->retry_num); in qed_mcp_resc_lock()
3865 int rc; in qed_mcp_resc_unlock() local
3867 opcode = p_params->b_force ? RESOURCE_OPCODE_FORCE_RELEASE in qed_mcp_resc_unlock()
3869 QED_MFW_SET_FIELD(param, RESOURCE_CMD_REQ_RESC, p_params->resource); in qed_mcp_resc_unlock()
3873 "Resource unlock request: param 0x%08x [opcode %d, resource %d]\n", in qed_mcp_resc_unlock()
3874 param, opcode, p_params->resource); in qed_mcp_resc_unlock()
3877 rc = qed_mcp_resource_cmd(p_hwfn, p_ptt, param, &mcp_resp, &mcp_param); in qed_mcp_resc_unlock()
3878 if (rc) in qed_mcp_resc_unlock()
3879 return rc; in qed_mcp_resc_unlock()
3885 "Resource unlock response: mcp_param 0x%08x [opcode %d]\n", in qed_mcp_resc_unlock()
3892 p_params->resource); in qed_mcp_resc_unlock()
3895 p_params->b_released = true; in qed_mcp_resc_unlock()
3898 p_params->b_released = false; in qed_mcp_resc_unlock()
3902 "Unexpected opcode in resource unlock response [mcp_param 0x%08x, opcode %d]\n", in qed_mcp_resc_unlock()
3904 return -EINVAL; in qed_mcp_resc_unlock()
3923 p_lock->timeout = QED_MCP_RESC_LOCK_TO_NONE; in qed_mcp_resc_lock_default_init()
3925 p_lock->retry_num = QED_MCP_RESC_LOCK_RETRY_CNT_DFLT; in qed_mcp_resc_lock_default_init()
3926 p_lock->retry_interval = in qed_mcp_resc_lock_default_init()
3928 p_lock->sleep_b4_retry = true; in qed_mcp_resc_lock_default_init()
3931 p_lock->resource = resource; in qed_mcp_resc_lock_default_init()
3936 p_unlock->resource = resource; in qed_mcp_resc_lock_default_init()
3942 return !!(p_hwfn->mcp_info->capabilities & in qed_mcp_is_smart_an_supported()
3949 int rc; in qed_mcp_get_capabilities() local
3951 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_GET_MFW_FEATURE_SUPPORT, in qed_mcp_get_capabilities()
3952 0, &mcp_resp, &p_hwfn->mcp_info->capabilities); in qed_mcp_get_capabilities()
3953 if (!rc) in qed_mcp_get_capabilities()
3955 "MFW supported features: %08x\n", in qed_mcp_get_capabilities()
3956 p_hwfn->mcp_info->capabilities); in qed_mcp_get_capabilities()
3958 return rc; in qed_mcp_get_capabilities()
3976 struct qed_dev *cdev = p_hwfn->cdev; in qed_mcp_get_engine_config()
3978 int rc; in qed_mcp_get_engine_config() local
3981 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_get_engine_config()
3982 if (rc) in qed_mcp_get_engine_config()
3983 return rc; in qed_mcp_get_engine_config()
3988 return -EOPNOTSUPP; in qed_mcp_get_engine_config()
3994 cdev->fir_affin = in qed_mcp_get_engine_config()
4001 cdev->l2_affin_hint = in qed_mcp_get_engine_config()
4007 fir_valid, cdev->fir_affin, l2_valid, cdev->l2_affin_hint); in qed_mcp_get_engine_config()
4015 struct qed_dev *cdev = p_hwfn->cdev; in qed_mcp_get_ppfid_bitmap()
4016 int rc; in qed_mcp_get_ppfid_bitmap() local
4019 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in qed_mcp_get_ppfid_bitmap()
4020 if (rc) in qed_mcp_get_ppfid_bitmap()
4021 return rc; in qed_mcp_get_ppfid_bitmap()
4026 return -EOPNOTSUPP; in qed_mcp_get_ppfid_bitmap()
4029 cdev->ppfid_bitmap = QED_MFW_GET_FIELD(mb_params.mcp_param, in qed_mcp_get_ppfid_bitmap()
4032 DP_VERBOSE(p_hwfn, QED_MSG_SP, "PPFID bitmap 0x%hhx\n", in qed_mcp_get_ppfid_bitmap()
4033 cdev->ppfid_bitmap); in qed_mcp_get_ppfid_bitmap()
4043 int rc; in qed_mcp_nvm_get_cfg() local
4060 rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt, in qed_mcp_nvm_get_cfg()
4065 return rc; in qed_mcp_nvm_get_cfg()
4103 (QED_MCP_DBG_DATA_MAX_SIZE - QED_MCP_DBG_DATA_MAX_HEADER_SIZE)
4110 int rc; in __qed_mcp_send_debug_data() local
4116 return -EINVAL; in __qed_mcp_send_debug_data()
4124 rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params); in __qed_mcp_send_debug_data()
4125 if (rc) in __qed_mcp_send_debug_data()
4126 return rc; in __qed_mcp_send_debug_data()
4131 return -EOPNOTSUPP; in __qed_mcp_send_debug_data()
4134 return -EBUSY; in __qed_mcp_send_debug_data()
4137 "Failed to send debug data to the MFW [resp 0x%08x]\n", in __qed_mcp_send_debug_data()
4139 return -EINVAL; in __qed_mcp_send_debug_data()
4171 int rc; in qed_mcp_send_debug_data() local
4176 seq = (u16)atomic_inc_return(&p_hwfn->mcp_info->dbg_data_seq); in qed_mcp_send_debug_data()
4185 SET_MFW_FIELD(*p_header, QED_MCP_DBG_DATA_HDR_PF, p_hwfn->abs_pf_id); in qed_mcp_send_debug_data()
4189 rc = __qed_mcp_send_debug_data(p_hwfn, p_ptt, raw_data, in qed_mcp_send_debug_data()
4191 if (rc) in qed_mcp_send_debug_data()
4192 return rc; in qed_mcp_send_debug_data()
4202 tmp_size -= QED_MCP_DBG_DATA_MAX_PAYLOAD_SIZE; in qed_mcp_send_debug_data()
4226 return !!(p_hwfn->mcp_info->capabilities & in qed_mcp_is_esl_supported()
4233 int rc; in qed_mcp_get_esl_status() local
4235 rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_GET_MANAGEMENT_STATUS, 0, &resp, &param); in qed_mcp_get_esl_status()
4236 if (rc) { in qed_mcp_get_esl_status()
4237 DP_NOTICE(p_hwfn, "Failed to send ESL command, rc = %d\n", rc); in qed_mcp_get_esl_status()
4238 return rc; in qed_mcp_get_esl_status()