Lines Matching +full:fw +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018-2023, Intel Corporation. */
88 * ice_dump_phy_type - helper function to dump phy_type
115 * ice_set_mac_type - Sets MAC type
123 if (hw->vendor_id != PCI_VENDOR_ID_INTEL) in ice_set_mac_type()
124 return -ENODEV; in ice_set_mac_type()
126 switch (hw->device_id) { in ice_set_mac_type()
133 hw->mac_type = ICE_MAC_E810; in ice_set_mac_type()
154 hw->mac_type = ICE_MAC_GENERIC; in ice_set_mac_type()
160 hw->mac_type = ICE_MAC_E830; in ice_set_mac_type()
163 hw->mac_type = ICE_MAC_UNKNOWN; in ice_set_mac_type()
167 ice_debug(hw, ICE_DBG_INIT, "mac_type: %d\n", hw->mac_type); in ice_set_mac_type()
179 return hw->mac_type == ICE_MAC_E810; in ice_is_e810()
190 switch (hw->device_id) { in ice_is_e810t()
192 switch (hw->subsystem_device_id) { in ice_is_e810t()
203 switch (hw->subsystem_device_id) { in ice_is_e810t()
221 * returns true if the device is E823-L or E823-C based, false if not.
225 switch (hw->device_id) { in ice_is_e823()
243 * ice_clear_pf_cfg - Clear PF configuration
259 * ice_aq_manage_mac_read - manage MAC address read command
287 return -EINVAL; in ice_aq_manage_mac_read()
296 flags = le16_to_cpu(cmd->flags) & ICE_AQC_MAN_MAC_READ_M; in ice_aq_manage_mac_read()
300 return -EIO; in ice_aq_manage_mac_read()
304 for (i = 0; i < cmd->num_addr; i++) in ice_aq_manage_mac_read()
306 ether_addr_copy(hw->port_info->mac.lan_addr, in ice_aq_manage_mac_read()
308 ether_addr_copy(hw->port_info->mac.perm_addr, in ice_aq_manage_mac_read()
317 * ice_aq_get_phy_caps - returns PHY capabilities
341 return -EINVAL; in ice_aq_get_phy_caps()
342 hw = pi->hw; in ice_aq_get_phy_caps()
346 return -EINVAL; in ice_aq_get_phy_caps()
351 cmd->param0 |= cpu_to_le16(ICE_AQC_GET_PHY_RQM); in ice_aq_get_phy_caps()
353 cmd->param0 |= cpu_to_le16(report_mode); in ice_aq_get_phy_caps()
375 ice_dump_phy_type(hw, le64_to_cpu(pcaps->phy_type_low), in ice_aq_get_phy_caps()
376 le64_to_cpu(pcaps->phy_type_high), prefix); in ice_aq_get_phy_caps()
380 ice_debug(hw, ICE_DBG_LINK, "%s: caps = 0x%x\n", prefix, pcaps->caps); in ice_aq_get_phy_caps()
382 pcaps->low_power_ctrl_an); in ice_aq_get_phy_caps()
384 pcaps->eee_cap); in ice_aq_get_phy_caps()
386 pcaps->eeer_value); in ice_aq_get_phy_caps()
388 pcaps->link_fec_options); in ice_aq_get_phy_caps()
390 prefix, pcaps->module_compliance_enforcement); in ice_aq_get_phy_caps()
392 prefix, pcaps->extended_compliance_code); in ice_aq_get_phy_caps()
394 pcaps->module_type[0]); in ice_aq_get_phy_caps()
396 pcaps->module_type[1]); in ice_aq_get_phy_caps()
398 pcaps->module_type[2]); in ice_aq_get_phy_caps()
401 pi->phy.phy_type_low = le64_to_cpu(pcaps->phy_type_low); in ice_aq_get_phy_caps()
402 pi->phy.phy_type_high = le64_to_cpu(pcaps->phy_type_high); in ice_aq_get_phy_caps()
403 memcpy(pi->phy.link_info.module_type, &pcaps->module_type, in ice_aq_get_phy_caps()
404 sizeof(pi->phy.link_info.module_type)); in ice_aq_get_phy_caps()
411 * ice_aq_get_link_topo_handle - get link topology node return status
420 * connection type is backplane or BASE-T.
433 cmd->addr.topo_params.node_type_ctx = in ice_aq_get_link_topo_handle()
438 cmd->addr.topo_params.node_type_ctx |= in ice_aq_get_link_topo_handle()
441 return ice_aq_send_cmd(pi->hw, &desc, NULL, 0, cd); in ice_aq_get_link_topo_handle()
449 * media type is backplane or BASE-T.
455 * connection type is backplane or BASE-T. in ice_is_media_cage_present()
463 * ice_get_media_type - Gets media type
473 hw_link_info = &pi->phy.link_info; in ice_get_media_type()
474 if (hw_link_info->phy_type_low && hw_link_info->phy_type_high) in ice_get_media_type()
478 if (hw_link_info->phy_type_low) { in ice_get_media_type()
484 if (hw_link_info->phy_type_low == ICE_PHY_TYPE_LOW_1G_SGMII && in ice_get_media_type()
485 (hw_link_info->module_type[ICE_AQC_MOD_TYPE_IDENT] == in ice_get_media_type()
487 hw_link_info->module_type[ICE_AQC_MOD_TYPE_IDENT] == in ice_get_media_type()
491 switch (hw_link_info->phy_type_low) { in ice_get_media_type()
563 switch (hw_link_info->phy_type_high) { in ice_get_media_type()
583 * @link: pointer to link status structure - optional
604 return -EINVAL; in ice_aq_get_link_info()
605 hw = pi->hw; in ice_aq_get_link_info()
606 li_old = &pi->phy.link_info_old; in ice_aq_get_link_info()
607 hw_media_type = &pi->phy.media_type; in ice_aq_get_link_info()
608 li = &pi->phy.link_info; in ice_aq_get_link_info()
609 hw_fc_info = &pi->fc; in ice_aq_get_link_info()
614 resp->cmd_flags = cpu_to_le16(cmd_flags); in ice_aq_get_link_info()
615 resp->lport_num = pi->lport; in ice_aq_get_link_info()
626 li->link_speed = le16_to_cpu(link_data.link_speed); in ice_aq_get_link_info()
627 li->phy_type_low = le64_to_cpu(link_data.phy_type_low); in ice_aq_get_link_info()
628 li->phy_type_high = le64_to_cpu(link_data.phy_type_high); in ice_aq_get_link_info()
630 li->link_info = link_data.link_info; in ice_aq_get_link_info()
631 li->link_cfg_err = link_data.link_cfg_err; in ice_aq_get_link_info()
632 li->an_info = link_data.an_info; in ice_aq_get_link_info()
633 li->ext_info = link_data.ext_info; in ice_aq_get_link_info()
634 li->max_frame_size = le16_to_cpu(link_data.max_frame_size); in ice_aq_get_link_info()
635 li->fec_info = link_data.cfg & ICE_AQ_FEC_MASK; in ice_aq_get_link_info()
636 li->topo_media_conflict = link_data.topo_media_conflict; in ice_aq_get_link_info()
637 li->pacing = link_data.cfg & (ICE_AQ_CFG_PACING_M | in ice_aq_get_link_info()
644 hw_fc_info->current_mode = ICE_FC_FULL; in ice_aq_get_link_info()
646 hw_fc_info->current_mode = ICE_FC_TX_PAUSE; in ice_aq_get_link_info()
648 hw_fc_info->current_mode = ICE_FC_RX_PAUSE; in ice_aq_get_link_info()
650 hw_fc_info->current_mode = ICE_FC_NONE; in ice_aq_get_link_info()
652 li->lse_ena = !!(resp->cmd_flags & cpu_to_le16(ICE_AQ_LSE_IS_ENABLED)); in ice_aq_get_link_info()
655 ice_debug(hw, ICE_DBG_LINK, " link_speed = 0x%x\n", li->link_speed); in ice_aq_get_link_info()
657 (unsigned long long)li->phy_type_low); in ice_aq_get_link_info()
659 (unsigned long long)li->phy_type_high); in ice_aq_get_link_info()
661 ice_debug(hw, ICE_DBG_LINK, " link_info = 0x%x\n", li->link_info); in ice_aq_get_link_info()
662 ice_debug(hw, ICE_DBG_LINK, " link_cfg_err = 0x%x\n", li->link_cfg_err); in ice_aq_get_link_info()
663 ice_debug(hw, ICE_DBG_LINK, " an_info = 0x%x\n", li->an_info); in ice_aq_get_link_info()
664 ice_debug(hw, ICE_DBG_LINK, " ext_info = 0x%x\n", li->ext_info); in ice_aq_get_link_info()
665 ice_debug(hw, ICE_DBG_LINK, " fec_info = 0x%x\n", li->fec_info); in ice_aq_get_link_info()
666 ice_debug(hw, ICE_DBG_LINK, " lse_ena = 0x%x\n", li->lse_ena); in ice_aq_get_link_info()
668 li->max_frame_size); in ice_aq_get_link_info()
669 ice_debug(hw, ICE_DBG_LINK, " pacing = 0x%x\n", li->pacing); in ice_aq_get_link_info()
676 pi->phy.get_link_info = false; in ice_aq_get_link_info()
684 * @cmd: pointer to MAC cfg structure
705 if (hw->mac_type == ICE_MAC_E830) { in ice_fill_tx_timer_and_fc_thresh()
708 cmd->tx_tmr_value = in ice_fill_tx_timer_and_fc_thresh()
718 cmd->tx_tmr_value = in ice_fill_tx_timer_and_fc_thresh()
727 cmd->fc_refresh_threshold = le16_encode_bits(val, fc_thres_m); in ice_fill_tx_timer_and_fc_thresh()
747 return -EINVAL; in ice_aq_set_mac_cfg()
751 cmd->max_frame_size = cpu_to_le16(max_frame_size); in ice_aq_set_mac_cfg()
759 * ice_init_fltr_mgmt_struct - initializes filter management list and locks
767 hw->switch_info = devm_kzalloc(ice_hw_to_dev(hw), in ice_init_fltr_mgmt_struct()
768 sizeof(*hw->switch_info), GFP_KERNEL); in ice_init_fltr_mgmt_struct()
769 sw = hw->switch_info; in ice_init_fltr_mgmt_struct()
772 return -ENOMEM; in ice_init_fltr_mgmt_struct()
774 INIT_LIST_HEAD(&sw->vsi_list_map_head); in ice_init_fltr_mgmt_struct()
775 sw->prof_res_bm_init = 0; in ice_init_fltr_mgmt_struct()
779 devm_kfree(ice_hw_to_dev(hw), hw->switch_info); in ice_init_fltr_mgmt_struct()
786 * ice_cleanup_fltr_mgmt_struct - cleanup filter management list and locks
791 struct ice_switch_info *sw = hw->switch_info; in ice_cleanup_fltr_mgmt_struct()
797 list_for_each_entry_safe(v_pos_map, v_tmp_map, &sw->vsi_list_map_head, in ice_cleanup_fltr_mgmt_struct()
799 list_del(&v_pos_map->list_entry); in ice_cleanup_fltr_mgmt_struct()
802 recps = sw->recp_list; in ice_cleanup_fltr_mgmt_struct()
809 list_del(&rg_entry->l_entry); in ice_cleanup_fltr_mgmt_struct()
821 list_del(&lst_itr->list_entry); in ice_cleanup_fltr_mgmt_struct()
822 devm_kfree(ice_hw_to_dev(hw), lst_itr->lkups); in ice_cleanup_fltr_mgmt_struct()
832 list_del(&lst_itr->list_entry); in ice_cleanup_fltr_mgmt_struct()
839 devm_kfree(ice_hw_to_dev(hw), sw->recp_list); in ice_cleanup_fltr_mgmt_struct()
844 * ice_get_fw_log_cfg - get FW logging configuration
857 return -ENOMEM; in ice_get_fw_log_cfg()
865 /* Save FW logging information into the HW structure */ in ice_get_fw_log_cfg()
874 hw->fw_log.evnts[m].cur = flgs; in ice_get_fw_log_cfg()
884 * ice_cfg_fw_log - configure FW logging
886 * @enable: enable certain FW logging events if true, disable all if false
888 * This function enables/disables the FW logging via Rx CQ events and a UART
889 * port based on predetermined configurations. FW logging via the Rx CQ can be
890 * enabled/disabled for individual PF's. However, FW logging via the UART can
893 * To enable overall FW logging, the "cq_en" and "uart_en" enable bits in
894 * hw->fw_log need to be set accordingly, e.g. based on user-provided input,
897 * When re/configuring FW logging, callers need to update the "cfg" elements of
898 * the hw->fw_log.evnts array with the desired logging event configurations for
899 * modules of interest. When disabling FW logging completely, the callers can
901 * update the "cur" element of the hw->fw_log.evnts array with the resulting
902 * logging event configurations of the modules that are being re/configured. FW
906 * Before resetting the device, it is recommended that the driver disables FW
907 * logging before shutting down the control queue. When disabling FW logging
908 * ("enable" = false), the latest configurations of FW logging events stored in
909 * hw->fw_log.evnts[] are not overridden to allow them to be reconfigured after
912 * When enabling FW logging to emit log messages via the Rx CQ during the
914 * needs to be used to extract FW log messages from the Rx CQ periodically and
916 * messages from FW to SW. Interrupts are typically disabled during the device's
929 if (!hw->fw_log.cq_en && !hw->fw_log.uart_en) in ice_cfg_fw_log()
932 /* Disable FW logging only when the control queue is still responsive */ in ice_cfg_fw_log()
934 (!hw->fw_log.actv_evnts || !ice_check_sq_alive(hw, &hw->adminq))) in ice_cfg_fw_log()
937 /* Get current FW log settings */ in ice_cfg_fw_log()
946 if (hw->fw_log.cq_en) in ice_cfg_fw_log()
947 cmd->log_ctrl_valid |= ICE_AQC_FW_LOG_AQ_VALID; in ice_cfg_fw_log()
949 if (hw->fw_log.uart_en) in ice_cfg_fw_log()
950 cmd->log_ctrl_valid |= ICE_AQC_FW_LOG_UART_VALID; in ice_cfg_fw_log()
953 /* Fill in an array of entries with FW logging modules and in ice_cfg_fw_log()
960 actv_evnts |= hw->fw_log.evnts[i].cfg; in ice_cfg_fw_log()
962 if (hw->fw_log.evnts[i].cfg == hw->fw_log.evnts[i].cur) in ice_cfg_fw_log()
971 return -ENOMEM; in ice_cfg_fw_log()
975 val |= hw->fw_log.evnts[i].cfg << ICE_AQC_FW_LOG_EN_S; in ice_cfg_fw_log()
979 /* Only enable FW logging if at least one module is specified. in ice_cfg_fw_log()
980 * If FW logging is currently enabled but all modules are not in ice_cfg_fw_log()
981 * enabled to emit log messages, disable FW logging altogether. in ice_cfg_fw_log()
988 if (hw->fw_log.cq_en) in ice_cfg_fw_log()
989 cmd->log_ctrl |= ICE_AQC_FW_LOG_AQ_EN; in ice_cfg_fw_log()
991 if (hw->fw_log.uart_en) in ice_cfg_fw_log()
992 cmd->log_ctrl |= ICE_AQC_FW_LOG_UART_EN; in ice_cfg_fw_log()
1003 * hw->fw_log.cq_en and hw->fw_log.uart_en indicate if the FW in ice_cfg_fw_log()
1010 hw->fw_log.actv_evnts = actv_evnts; in ice_cfg_fw_log()
1015 /* When disabling all FW logging events as part in ice_cfg_fw_log()
1016 * of device's de-initialization, the original in ice_cfg_fw_log()
1018 * to reconfigure FW logging later if the device in ice_cfg_fw_log()
1019 * is re-initialized. in ice_cfg_fw_log()
1021 hw->fw_log.evnts[i].cur = 0; in ice_cfg_fw_log()
1027 hw->fw_log.evnts[m].cur = hw->fw_log.evnts[m].cfg; in ice_cfg_fw_log()
1043 * Formats a FW Log message and outputs it via the standard driver logs.
1047 ice_debug(hw, ICE_DBG_FW_LOG, "[ FW Log Msg Start ]\n"); in ice_output_fw_log()
1049 le16_to_cpu(desc->datalen)); in ice_output_fw_log()
1050 ice_debug(hw, ICE_DBG_FW_LOG, "[ FW Log Msg End ]\n"); in ice_output_fw_log()
1058 * bandwidth according to the device's configuration during power-on.
1070 hw->itr_gran = ICE_ITR_GRAN_ABOVE_25; in ice_get_itr_intrl_gran()
1071 hw->intrl_gran = ICE_INTRL_GRAN_ABOVE_25; in ice_get_itr_intrl_gran()
1074 hw->itr_gran = ICE_ITR_GRAN_MAX_25; in ice_get_itr_intrl_gran()
1075 hw->intrl_gran = ICE_INTRL_GRAN_MAX_25; in ice_get_itr_intrl_gran()
1081 * ice_init_hw - main hardware initialization routine
1096 hw->pf_id = (u8)(rd32(hw, PF_FUNC_RID) & in ice_init_hw()
1110 /* Enable FW logging. Not fatal if this fails. */ in ice_init_hw()
1113 ice_debug(hw, ICE_DBG_INIT, "Failed to enable FW logging.\n"); in ice_init_hw()
1121 INIT_LIST_HEAD(&hw->fdir_list_head); in ice_init_hw()
1133 if (!hw->port_info) in ice_init_hw()
1134 hw->port_info = devm_kzalloc(ice_hw_to_dev(hw), in ice_init_hw()
1135 sizeof(*hw->port_info), in ice_init_hw()
1137 if (!hw->port_info) { in ice_init_hw()
1138 status = -ENOMEM; in ice_init_hw()
1143 hw->port_info->hw = hw; in ice_init_hw()
1150 hw->evb_veb = true; in ice_init_hw()
1153 xa_init_flags(&hw->port_info->sched_node_ids, XA_FLAGS_ALLOC); in ice_init_hw()
1164 status = ice_sched_init_port(hw->port_info); in ice_init_hw()
1170 status = -ENOMEM; in ice_init_hw()
1175 status = ice_aq_get_phy_caps(hw->port_info, false, in ice_init_hw()
1184 status = ice_aq_get_link_info(hw->port_info, false, NULL, NULL); in ice_init_hw()
1189 if (!hw->sw_entry_point_layer) { in ice_init_hw()
1191 status = -EIO; in ice_init_hw()
1194 INIT_LIST_HEAD(&hw->agg_list); in ice_init_hw()
1196 if (!hw->max_burst_size) in ice_init_hw()
1211 status = -ENOMEM; in ice_init_hw()
1225 status = ice_alloc_fd_res_cntr(hw, &hw->fd_ctr_base); in ice_init_hw()
1231 mutex_init(&hw->tnl_lock); in ice_init_hw()
1239 devm_kfree(ice_hw_to_dev(hw), hw->port_info); in ice_init_hw()
1246 * ice_deinit_hw - unroll initialization operations done by ice_init_hw
1255 ice_free_fd_res_cntr(hw, hw->fd_ctr_base); in ice_deinit_hw()
1262 mutex_destroy(&hw->tnl_lock); in ice_deinit_hw()
1264 /* Attempt to disable FW logging before shutting down control queues */ in ice_deinit_hw()
1273 * ice_check_reset - Check to see if a global reset is complete
1296 return -EIO; in ice_check_reset()
1307 uld_mask = ICE_RESET_DONE_MASK | (hw->func_caps.common_cap.rdma ? in ice_check_reset()
1323 return -EIO; in ice_check_reset()
1330 * ice_pf_reset - Reset the PF
1349 return -EIO; in ice_pf_reset()
1374 return -EIO; in ice_pf_reset()
1381 * ice_reset - Perform different types of reset
1408 return -EINVAL; in ice_reset()
1415 /* wait for the FW to be ready */ in ice_reset()
1433 return -EINVAL; in ice_copy_rxq_ctx_to_hw()
1436 return -EINVAL; in ice_copy_rxq_ctx_to_hw()
1493 return -EINVAL; in ice_write_rxq_ctx()
1495 rlan_ctx->prefena = 1; in ice_write_rxq_ctx()
1538 * ice_sbq_send_cmd - send Sideband Queue command to Sideband Queue
1554 * ice_sbq_rw_reg - Fill Sideband Queue command
1567 msg.dest_dev = in->dest_dev; in ice_sbq_rw_reg()
1568 msg.opcode = in->opcode; in ice_sbq_rw_reg()
1571 msg.msg_addr_low = cpu_to_le16(in->msg_addr_low); in ice_sbq_rw_reg()
1572 msg.msg_addr_high = cpu_to_le32(in->msg_addr_high); in ice_sbq_rw_reg()
1574 if (in->opcode) in ice_sbq_rw_reg()
1575 msg.data = cpu_to_le32(in->data); in ice_sbq_rw_reg()
1580 msg_len -= sizeof(msg.data); in ice_sbq_rw_reg()
1586 if (!status && !in->opcode) in ice_sbq_rw_reg()
1587 in->data = le32_to_cpu in ice_sbq_rw_reg()
1588 (((struct ice_sbq_msg_cmpl *)&msg)->data); in ice_sbq_rw_reg()
1592 /* FW Admin Queue command wrappers */
1596 * of AQ commands from being sent to FW
1621 * ice_sq_send_cmd_retry - send command to Control Queue (ATQ)
1629 * Retry sending the FW Admin Queue command, multiple times, to the FW Admin
1643 opcode = le16_to_cpu(desc->opcode); in ice_sq_send_cmd_retry()
1658 hw->adminq.sq_last_status != ICE_AQ_RC_EBUSY) in ice_sq_send_cmd_retry()
1671 * ice_aq_send_cmd - send FW Admin Queue command to FW Admin Queue
1678 * Helper function to send FW Admin Queue commands to the FW Admin Queue.
1684 struct ice_aqc_req_res *cmd = &desc->params.res_owner; in ice_aq_send_cmd()
1698 switch (le16_to_cpu(desc->opcode)) { in ice_aq_send_cmd()
1713 if (le16_to_cpu(cmd->res_id) == ICE_AQC_RES_ID_GLBL_LOCK) in ice_aq_send_cmd()
1722 status = ice_sq_send_cmd_retry(hw, &hw->adminq, desc, buf, buf_size, cd); in ice_aq_send_cmd()
1749 hw->fw_branch = resp->fw_branch; in ice_aq_get_fw_ver()
1750 hw->fw_maj_ver = resp->fw_major; in ice_aq_get_fw_ver()
1751 hw->fw_min_ver = resp->fw_minor; in ice_aq_get_fw_ver()
1752 hw->fw_patch = resp->fw_patch; in ice_aq_get_fw_ver()
1753 hw->fw_build = le32_to_cpu(resp->fw_build); in ice_aq_get_fw_ver()
1754 hw->api_branch = resp->api_branch; in ice_aq_get_fw_ver()
1755 hw->api_maj_ver = resp->api_major; in ice_aq_get_fw_ver()
1756 hw->api_min_ver = resp->api_minor; in ice_aq_get_fw_ver()
1757 hw->api_patch = resp->api_patch; in ice_aq_get_fw_ver()
1782 return -EINVAL; in ice_aq_send_driver_ver()
1787 cmd->major_ver = dv->major_ver; in ice_aq_send_driver_ver()
1788 cmd->minor_ver = dv->minor_ver; in ice_aq_send_driver_ver()
1789 cmd->build_ver = dv->build_ver; in ice_aq_send_driver_ver()
1790 cmd->subbuild_ver = dv->subbuild_ver; in ice_aq_send_driver_ver()
1793 while (len < sizeof(dv->driver_string) && in ice_aq_send_driver_ver()
1794 isascii(dv->driver_string[len]) && dv->driver_string[len]) in ice_aq_send_driver_ver()
1797 return ice_aq_send_cmd(hw, &desc, dv->driver_string, len, cd); in ice_aq_send_driver_ver()
1818 cmd->driver_unloading = ICE_AQC_DRIVER_UNLOADING; in ice_aq_q_shutdown()
1835 * 1) 0 - acquired lock, and can perform download package
1836 * 2) -EIO - did not get lock, driver should fail to load
1837 * 3) -EALREADY - did not get lock, but another driver has
1843 * phase of operation, it is possible that the FW may detect a timeout and issue
1862 cmd_resp->res_id = cpu_to_le16(res); in ice_aq_req_res()
1863 cmd_resp->access_type = cpu_to_le16(access); in ice_aq_req_res()
1864 cmd_resp->res_number = cpu_to_le32(sdp_number); in ice_aq_req_res()
1865 cmd_resp->timeout = cpu_to_le32(*timeout); in ice_aq_req_res()
1882 if (le16_to_cpu(cmd_resp->status) == ICE_AQ_RES_GLBL_SUCCESS) { in ice_aq_req_res()
1883 *timeout = le32_to_cpu(cmd_resp->timeout); in ice_aq_req_res()
1885 } else if (le16_to_cpu(cmd_resp->status) == in ice_aq_req_res()
1887 *timeout = le32_to_cpu(cmd_resp->timeout); in ice_aq_req_res()
1888 return -EIO; in ice_aq_req_res()
1889 } else if (le16_to_cpu(cmd_resp->status) == in ice_aq_req_res()
1891 return -EALREADY; in ice_aq_req_res()
1894 /* invalid FW response, force a timeout immediately */ in ice_aq_req_res()
1896 return -EIO; in ice_aq_req_res()
1903 if (!status || hw->adminq.sq_last_status == ICE_AQ_RC_EBUSY) in ice_aq_req_res()
1904 *timeout = le32_to_cpu(cmd_resp->timeout); in ice_aq_req_res()
1929 cmd->res_id = cpu_to_le16(res); in ice_aq_release_res()
1930 cmd->res_number = cpu_to_le32(sdp_number); in ice_aq_release_res()
1955 /* A return code of -EALREADY means that another driver has in ice_acquire_res()
1960 if (status == -EALREADY) in ice_acquire_res()
1970 timeout = (timeout > delay) ? timeout - delay : 0; in ice_acquire_res()
1973 if (status == -EALREADY) in ice_acquire_res()
1981 if (status && status != -EALREADY) in ice_acquire_res()
1985 if (status == -EALREADY) { in ice_acquire_res()
1989 ice_debug(hw, ICE_DBG_RES, "Warning: -EALREADY not expected\n"); in ice_acquire_res()
2012 if (status != -EIO) in ice_release_res()
2019 * ice_aq_alloc_free_res - command to allocate/free resources
2037 return -EINVAL; in ice_aq_alloc_free_res()
2043 cmd->num_entries = cpu_to_le16(1); in ice_aq_alloc_free_res()
2049 * ice_alloc_hw_res - allocate resource
2066 return -ENOMEM; in ice_alloc_hw_res()
2069 buf->num_elems = cpu_to_le16(num); in ice_alloc_hw_res()
2070 buf->res_type = cpu_to_le16(type | ICE_AQC_RES_TYPE_FLAG_DEDICATED | in ice_alloc_hw_res()
2073 buf->res_type |= cpu_to_le16(ICE_AQC_RES_TYPE_FLAG_SCAN_BOTTOM); in ice_alloc_hw_res()
2079 memcpy(res, buf->elem, sizeof(*buf->elem) * num); in ice_alloc_hw_res()
2087 * ice_free_hw_res - free allocated HW resource
2102 return -ENOMEM; in ice_free_hw_res()
2105 buf->num_elems = cpu_to_le16(num); in ice_free_hw_res()
2106 buf->res_type = cpu_to_le16(type); in ice_free_hw_res()
2107 memcpy(buf->elem, res, sizeof(*buf->elem) * num); in ice_free_hw_res()
2118 * ice_get_num_per_func - determine number of resources per PF
2131 funcs = hweight8(hw->dev_caps.common_cap.valid_functions & in ice_get_num_per_func()
2141 * ice_parse_common_caps - parse common device/function capabilities
2157 u32 logical_id = le32_to_cpu(elem->logical_id); in ice_parse_common_caps()
2158 u32 phys_id = le32_to_cpu(elem->phys_id); in ice_parse_common_caps()
2159 u32 number = le32_to_cpu(elem->number); in ice_parse_common_caps()
2160 u16 cap = le16_to_cpu(elem->cap); in ice_parse_common_caps()
2165 caps->valid_functions = number; in ice_parse_common_caps()
2167 caps->valid_functions); in ice_parse_common_caps()
2170 caps->sr_iov_1_1 = (number == 1); in ice_parse_common_caps()
2172 caps->sr_iov_1_1); in ice_parse_common_caps()
2175 caps->dcb = (number == 1); in ice_parse_common_caps()
2176 caps->active_tc_bitmap = logical_id; in ice_parse_common_caps()
2177 caps->maxtc = phys_id; in ice_parse_common_caps()
2178 ice_debug(hw, ICE_DBG_INIT, "%s: dcb = %d\n", prefix, caps->dcb); in ice_parse_common_caps()
2180 caps->active_tc_bitmap); in ice_parse_common_caps()
2181 ice_debug(hw, ICE_DBG_INIT, "%s: maxtc = %d\n", prefix, caps->maxtc); in ice_parse_common_caps()
2184 caps->rss_table_size = number; in ice_parse_common_caps()
2185 caps->rss_table_entry_width = logical_id; in ice_parse_common_caps()
2187 caps->rss_table_size); in ice_parse_common_caps()
2189 caps->rss_table_entry_width); in ice_parse_common_caps()
2192 caps->num_rxq = number; in ice_parse_common_caps()
2193 caps->rxq_first_id = phys_id; in ice_parse_common_caps()
2195 caps->num_rxq); in ice_parse_common_caps()
2197 caps->rxq_first_id); in ice_parse_common_caps()
2200 caps->num_txq = number; in ice_parse_common_caps()
2201 caps->txq_first_id = phys_id; in ice_parse_common_caps()
2203 caps->num_txq); in ice_parse_common_caps()
2205 caps->txq_first_id); in ice_parse_common_caps()
2208 caps->num_msix_vectors = number; in ice_parse_common_caps()
2209 caps->msix_vector_first_id = phys_id; in ice_parse_common_caps()
2211 caps->num_msix_vectors); in ice_parse_common_caps()
2213 caps->msix_vector_first_id); in ice_parse_common_caps()
2216 caps->nvm_update_pending_nvm = true; in ice_parse_common_caps()
2220 caps->nvm_update_pending_orom = true; in ice_parse_common_caps()
2224 caps->nvm_update_pending_netlist = true; in ice_parse_common_caps()
2228 caps->nvm_unified_update = in ice_parse_common_caps()
2232 caps->nvm_unified_update); in ice_parse_common_caps()
2235 caps->rdma = (number == 1); in ice_parse_common_caps()
2236 ice_debug(hw, ICE_DBG_INIT, "%s: rdma = %d\n", prefix, caps->rdma); in ice_parse_common_caps()
2239 caps->max_mtu = number; in ice_parse_common_caps()
2241 prefix, caps->max_mtu); in ice_parse_common_caps()
2244 caps->pcie_reset_avoidance = (number > 0); in ice_parse_common_caps()
2247 caps->pcie_reset_avoidance); in ice_parse_common_caps()
2250 caps->reset_restrict_support = (number == 1); in ice_parse_common_caps()
2253 caps->reset_restrict_support); in ice_parse_common_caps()
2256 caps->roce_lag = !!(number & ICE_AQC_BIT_ROCEV2_LAG); in ice_parse_common_caps()
2258 prefix, caps->roce_lag); in ice_parse_common_caps()
2259 caps->sriov_lag = !!(number & ICE_AQC_BIT_SRIOV_LAG); in ice_parse_common_caps()
2261 prefix, caps->sriov_lag); in ice_parse_common_caps()
2272 * ice_recalc_port_limited_caps - Recalculate port limited capabilities
2276 * Re-calculate the capabilities that are dependent on the number of physical
2286 if (hw->dev_caps.num_funcs > 4) { in ice_recalc_port_limited_caps()
2288 caps->maxtc = 4; in ice_recalc_port_limited_caps()
2290 caps->maxtc); in ice_recalc_port_limited_caps()
2291 if (caps->rdma) { in ice_recalc_port_limited_caps()
2293 caps->rdma = 0; in ice_recalc_port_limited_caps()
2299 if (caps == &hw->dev_caps.common_cap) in ice_recalc_port_limited_caps()
2305 * ice_parse_vf_func_caps - Parse ICE_AQC_CAPS_VF function caps
2316 u32 logical_id = le32_to_cpu(cap->logical_id); in ice_parse_vf_func_caps()
2317 u32 number = le32_to_cpu(cap->number); in ice_parse_vf_func_caps()
2319 func_p->num_allocd_vfs = number; in ice_parse_vf_func_caps()
2320 func_p->vf_base_id = logical_id; in ice_parse_vf_func_caps()
2322 func_p->num_allocd_vfs); in ice_parse_vf_func_caps()
2324 func_p->vf_base_id); in ice_parse_vf_func_caps()
2328 * ice_parse_vsi_func_caps - Parse ICE_AQC_CAPS_VSI function caps
2339 func_p->guar_num_vsi = ice_get_num_per_func(hw, ICE_MAX_VSI); in ice_parse_vsi_func_caps()
2340 ice_debug(hw, ICE_DBG_INIT, "func caps: guar_num_vsi (fw) = %d\n", in ice_parse_vsi_func_caps()
2341 le32_to_cpu(cap->number)); in ice_parse_vsi_func_caps()
2343 func_p->guar_num_vsi); in ice_parse_vsi_func_caps()
2347 * ice_parse_1588_func_caps - Parse ICE_AQC_CAPS_1588 function caps
2358 struct ice_ts_func_info *info = &func_p->ts_func_info; in ice_parse_1588_func_caps()
2359 u32 number = le32_to_cpu(cap->number); in ice_parse_1588_func_caps()
2361 info->ena = ((number & ICE_TS_FUNC_ENA_M) != 0); in ice_parse_1588_func_caps()
2362 func_p->common_cap.ieee_1588 = info->ena; in ice_parse_1588_func_caps()
2364 info->src_tmr_owned = ((number & ICE_TS_SRC_TMR_OWND_M) != 0); in ice_parse_1588_func_caps()
2365 info->tmr_ena = ((number & ICE_TS_TMR_ENA_M) != 0); in ice_parse_1588_func_caps()
2366 info->tmr_index_owned = ((number & ICE_TS_TMR_IDX_OWND_M) != 0); in ice_parse_1588_func_caps()
2367 info->tmr_index_assoc = ((number & ICE_TS_TMR_IDX_ASSOC_M) != 0); in ice_parse_1588_func_caps()
2369 info->clk_freq = (number & ICE_TS_CLK_FREQ_M) >> ICE_TS_CLK_FREQ_S; in ice_parse_1588_func_caps()
2370 info->clk_src = ((number & ICE_TS_CLK_SRC_M) != 0); in ice_parse_1588_func_caps()
2372 if (info->clk_freq < NUM_ICE_TIME_REF_FREQ) { in ice_parse_1588_func_caps()
2373 info->time_ref = (enum ice_time_ref_freq)info->clk_freq; in ice_parse_1588_func_caps()
2376 * default to avoid out-of-bounds look ups of frequency in ice_parse_1588_func_caps()
2380 info->clk_freq); in ice_parse_1588_func_caps()
2381 info->time_ref = ICE_TIME_REF_FREQ_25_000; in ice_parse_1588_func_caps()
2385 func_p->common_cap.ieee_1588); in ice_parse_1588_func_caps()
2387 info->src_tmr_owned); in ice_parse_1588_func_caps()
2389 info->tmr_ena); in ice_parse_1588_func_caps()
2391 info->tmr_index_owned); in ice_parse_1588_func_caps()
2393 info->tmr_index_assoc); in ice_parse_1588_func_caps()
2395 info->clk_freq); in ice_parse_1588_func_caps()
2397 info->clk_src); in ice_parse_1588_func_caps()
2401 * ice_parse_fdir_func_caps - Parse ICE_AQC_CAPS_FD function caps
2413 switch (hw->mac_type) { in ice_parse_fdir_func_caps()
2423 func_p->fd_fltr_guar = ice_get_num_per_func(hw, gsize); in ice_parse_fdir_func_caps()
2424 func_p->fd_fltr_best_effort = bsize; in ice_parse_fdir_func_caps()
2427 func_p->fd_fltr_guar); in ice_parse_fdir_func_caps()
2429 func_p->fd_fltr_best_effort); in ice_parse_fdir_func_caps()
2433 * ice_parse_func_caps - Parse function capabilities
2461 found = ice_parse_common_caps(hw, &func_p->common_cap, in ice_parse_func_caps()
2486 ice_recalc_port_limited_caps(hw, &func_p->common_cap); in ice_parse_func_caps()
2490 * ice_parse_valid_functions_cap - Parse ICE_AQC_CAPS_VALID_FUNCTIONS caps
2501 u32 number = le32_to_cpu(cap->number); in ice_parse_valid_functions_cap()
2503 dev_p->num_funcs = hweight32(number); in ice_parse_valid_functions_cap()
2505 dev_p->num_funcs); in ice_parse_valid_functions_cap()
2509 * ice_parse_vf_dev_caps - Parse ICE_AQC_CAPS_VF device caps
2520 u32 number = le32_to_cpu(cap->number); in ice_parse_vf_dev_caps()
2522 dev_p->num_vfs_exposed = number; in ice_parse_vf_dev_caps()
2524 dev_p->num_vfs_exposed); in ice_parse_vf_dev_caps()
2528 * ice_parse_vsi_dev_caps - Parse ICE_AQC_CAPS_VSI device caps
2539 u32 number = le32_to_cpu(cap->number); in ice_parse_vsi_dev_caps()
2541 dev_p->num_vsi_allocd_to_host = number; in ice_parse_vsi_dev_caps()
2543 dev_p->num_vsi_allocd_to_host); in ice_parse_vsi_dev_caps()
2547 * ice_parse_1588_dev_caps - Parse ICE_AQC_CAPS_1588 device caps
2558 struct ice_ts_dev_info *info = &dev_p->ts_dev_info; in ice_parse_1588_dev_caps()
2559 u32 logical_id = le32_to_cpu(cap->logical_id); in ice_parse_1588_dev_caps()
2560 u32 phys_id = le32_to_cpu(cap->phys_id); in ice_parse_1588_dev_caps()
2561 u32 number = le32_to_cpu(cap->number); in ice_parse_1588_dev_caps()
2563 info->ena = ((number & ICE_TS_DEV_ENA_M) != 0); in ice_parse_1588_dev_caps()
2564 dev_p->common_cap.ieee_1588 = info->ena; in ice_parse_1588_dev_caps()
2566 info->tmr0_owner = number & ICE_TS_TMR0_OWNR_M; in ice_parse_1588_dev_caps()
2567 info->tmr0_owned = ((number & ICE_TS_TMR0_OWND_M) != 0); in ice_parse_1588_dev_caps()
2568 info->tmr0_ena = ((number & ICE_TS_TMR0_ENA_M) != 0); in ice_parse_1588_dev_caps()
2570 info->tmr1_owner = (number & ICE_TS_TMR1_OWNR_M) >> ICE_TS_TMR1_OWNR_S; in ice_parse_1588_dev_caps()
2571 info->tmr1_owned = ((number & ICE_TS_TMR1_OWND_M) != 0); in ice_parse_1588_dev_caps()
2572 info->tmr1_ena = ((number & ICE_TS_TMR1_ENA_M) != 0); in ice_parse_1588_dev_caps()
2574 info->ts_ll_read = ((number & ICE_TS_LL_TX_TS_READ_M) != 0); in ice_parse_1588_dev_caps()
2576 info->ena_ports = logical_id; in ice_parse_1588_dev_caps()
2577 info->tmr_own_map = phys_id; in ice_parse_1588_dev_caps()
2580 dev_p->common_cap.ieee_1588); in ice_parse_1588_dev_caps()
2582 info->tmr0_owner); in ice_parse_1588_dev_caps()
2584 info->tmr0_owned); in ice_parse_1588_dev_caps()
2586 info->tmr0_ena); in ice_parse_1588_dev_caps()
2588 info->tmr1_owner); in ice_parse_1588_dev_caps()
2590 info->tmr1_owned); in ice_parse_1588_dev_caps()
2592 info->tmr1_ena); in ice_parse_1588_dev_caps()
2594 info->ts_ll_read); in ice_parse_1588_dev_caps()
2596 info->ena_ports); in ice_parse_1588_dev_caps()
2598 info->tmr_own_map); in ice_parse_1588_dev_caps()
2602 * ice_parse_fdir_dev_caps - Parse ICE_AQC_CAPS_FD device caps
2613 u32 number = le32_to_cpu(cap->number); in ice_parse_fdir_dev_caps()
2615 dev_p->num_flow_director_fltr = number; in ice_parse_fdir_dev_caps()
2617 dev_p->num_flow_director_fltr); in ice_parse_fdir_dev_caps()
2621 * ice_parse_dev_caps - Parse device capabilities
2649 found = ice_parse_common_caps(hw, &dev_p->common_cap, in ice_parse_dev_caps()
2677 ice_recalc_port_limited_caps(hw, &dev_p->common_cap); in ice_parse_dev_caps()
2697 return -EIO; in ice_aq_get_netlist_node()
2708 * ice_is_pf_c827 - check if pf contains c827 phy
2718 if (hw->mac_type != ICE_MAC_E810) in ice_is_pf_c827()
2721 if (hw->device_id != ICE_DEV_ID_E810C_QSFP) in ice_is_pf_c827()
2742 * ice_aq_list_caps - query function/device capabilities
2772 return -EINVAL; in ice_aq_list_caps()
2778 *cap_count = le32_to_cpu(cmd->count); in ice_aq_list_caps()
2784 * ice_discover_dev_caps - Read and extract device capabilities
2800 return -ENOMEM; in ice_discover_dev_caps()
2818 * ice_discover_func_caps - Read and extract function capabilities
2834 return -ENOMEM; in ice_discover_func_caps()
2852 * ice_set_safe_mode_caps - Override dev/func capabilities when in safe mode
2857 struct ice_hw_func_caps *func_caps = &hw->func_caps; in ice_set_safe_mode_caps()
2858 struct ice_hw_dev_caps *dev_caps = &hw->dev_caps; in ice_set_safe_mode_caps()
2863 cached_caps = func_caps->common_cap; in ice_set_safe_mode_caps()
2869 func_caps->common_cap.name = cached_caps.name in ice_set_safe_mode_caps()
2883 func_caps->common_cap.num_rxq = 1; in ice_set_safe_mode_caps()
2884 func_caps->common_cap.num_txq = 1; in ice_set_safe_mode_caps()
2887 func_caps->common_cap.num_msix_vectors = 2; in ice_set_safe_mode_caps()
2888 func_caps->guar_num_vsi = 1; in ice_set_safe_mode_caps()
2891 cached_caps = dev_caps->common_cap; in ice_set_safe_mode_caps()
2892 num_funcs = dev_caps->num_funcs; in ice_set_safe_mode_caps()
2898 dev_caps->common_cap.name = cached_caps.name in ice_set_safe_mode_caps()
2910 dev_caps->num_funcs = num_funcs; in ice_set_safe_mode_caps()
2913 dev_caps->common_cap.num_rxq = num_funcs; in ice_set_safe_mode_caps()
2914 dev_caps->common_cap.num_txq = num_funcs; in ice_set_safe_mode_caps()
2917 dev_caps->common_cap.num_msix_vectors = 2 * num_funcs; in ice_set_safe_mode_caps()
2921 * ice_get_caps - get info about the HW
2928 status = ice_discover_dev_caps(hw, &hw->dev_caps); in ice_get_caps()
2932 return ice_discover_func_caps(hw, &hw->func_caps); in ice_get_caps()
2936 * ice_aq_manage_mac_write - manage MAC address write command
2954 cmd->flags = flags; in ice_aq_manage_mac_write()
2955 ether_addr_copy(cmd->mac_addr, mac_addr); in ice_aq_manage_mac_write()
2977 * ice_clear_pxe_mode - clear pxe operations mode
2981 * like descriptor fetch/write-back mode.
2985 if (ice_check_sq_alive(hw, &hw->adminq)) in ice_clear_pxe_mode()
2990 * ice_aq_set_port_params - set physical port parameters.
3003 struct ice_hw *hw = pi->hw; in ice_aq_set_port_params()
3012 cmd->cmd_flags = cpu_to_le16(cmd_flags); in ice_aq_set_port_params()
3026 switch (hw->device_id) { in ice_is_100m_speed_supported()
3038 * ice_get_link_speed_based_on_phy_type - returns link speed
3177 * [ice_aqc_get_link_status->link_speed]. Caller can pass in
3217 * @cfg: structure with PHY configuration data to be set
3227 struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd) in ice_aq_set_phy_cfg() argument
3232 if (!cfg) in ice_aq_set_phy_cfg()
3233 return -EINVAL; in ice_aq_set_phy_cfg()
3235 /* Ensure that only valid bits of cfg->caps can be turned on. */ in ice_aq_set_phy_cfg()
3236 if (cfg->caps & ~ICE_AQ_PHY_ENA_VALID_MASK) { in ice_aq_set_phy_cfg()
3237 ice_debug(hw, ICE_DBG_PHY, "Invalid bit is set in ice_aqc_set_phy_cfg_data->caps : 0x%x\n", in ice_aq_set_phy_cfg()
3238 cfg->caps); in ice_aq_set_phy_cfg()
3240 cfg->caps &= ICE_AQ_PHY_ENA_VALID_MASK; in ice_aq_set_phy_cfg()
3244 desc.params.set_phy.lport_num = pi->lport; in ice_aq_set_phy_cfg()
3247 ice_debug(hw, ICE_DBG_LINK, "set phy cfg\n"); in ice_aq_set_phy_cfg()
3249 (unsigned long long)le64_to_cpu(cfg->phy_type_low)); in ice_aq_set_phy_cfg()
3251 (unsigned long long)le64_to_cpu(cfg->phy_type_high)); in ice_aq_set_phy_cfg()
3252 ice_debug(hw, ICE_DBG_LINK, " caps = 0x%x\n", cfg->caps); in ice_aq_set_phy_cfg()
3254 cfg->low_power_ctrl_an); in ice_aq_set_phy_cfg()
3255 ice_debug(hw, ICE_DBG_LINK, " eee_cap = 0x%x\n", cfg->eee_cap); in ice_aq_set_phy_cfg()
3256 ice_debug(hw, ICE_DBG_LINK, " eeer_value = 0x%x\n", cfg->eeer_value); in ice_aq_set_phy_cfg()
3258 cfg->link_fec_opt); in ice_aq_set_phy_cfg()
3260 status = ice_aq_send_cmd(hw, &desc, cfg, sizeof(*cfg), cd); in ice_aq_set_phy_cfg()
3261 if (hw->adminq.sq_last_status == ICE_AQ_RC_EMODE) in ice_aq_set_phy_cfg()
3265 pi->phy.curr_user_phy_cfg = *cfg; in ice_aq_set_phy_cfg()
3271 * ice_update_link_info - update status of the HW network link
3280 return -EINVAL; in ice_update_link_info()
3282 li = &pi->phy.link_info; in ice_update_link_info()
3288 if (li->link_info & ICE_AQ_MEDIA_AVAILABLE) { in ice_update_link_info()
3292 hw = pi->hw; in ice_update_link_info()
3296 return -ENOMEM; in ice_update_link_info()
3325 pi->phy.curr_user_fc_req = cache_data.data.curr_user_fc_req; in ice_cache_phy_user_req()
3328 pi->phy.curr_user_speed_req = in ice_cache_phy_user_req()
3332 pi->phy.curr_user_fec_req = cache_data.data.curr_user_fec_req; in ice_cache_phy_user_req()
3387 * ice_cfg_phy_fc - Configure PHY FC data based on FC mode
3389 * @cfg: PHY configuration data to set FC mode
3393 ice_cfg_phy_fc(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, in ice_cfg_phy_fc() argument
3399 if (!pi || !cfg) in ice_cfg_phy_fc()
3400 return -EINVAL; in ice_cfg_phy_fc()
3418 cfg->caps &= ~(ICE_AQC_PHY_EN_TX_LINK_PAUSE | in ice_cfg_phy_fc()
3422 cfg->caps |= pause_mask; in ice_cfg_phy_fc()
3442 struct ice_aqc_set_phy_cfg_data cfg = { 0 }; in ice_set_fc() local
3448 return -EINVAL; in ice_set_fc()
3451 hw = pi->hw; in ice_set_fc()
3455 return -ENOMEM; in ice_set_fc()
3465 ice_copy_phy_caps_to_cfg(pi, pcaps, &cfg); in ice_set_fc()
3468 status = ice_cfg_phy_fc(pi, &cfg, pi->fc.req_mode); in ice_set_fc()
3473 if (cfg.caps != pcaps->caps) { in ice_set_fc()
3478 cfg.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_set_fc()
3480 status = ice_aq_set_phy_cfg(hw, pi, &cfg, NULL); in ice_set_fc()
3533 if (phy_caps->phy_type_low != phy_cfg->phy_type_low || in ice_phy_caps_equals_cfg()
3534 phy_caps->phy_type_high != phy_cfg->phy_type_high || in ice_phy_caps_equals_cfg()
3535 ((phy_caps->caps & caps_mask) != (phy_cfg->caps & cfg_mask)) || in ice_phy_caps_equals_cfg()
3536 phy_caps->low_power_ctrl_an != phy_cfg->low_power_ctrl_an || in ice_phy_caps_equals_cfg()
3537 phy_caps->eee_cap != phy_cfg->eee_cap || in ice_phy_caps_equals_cfg()
3538 phy_caps->eeer_value != phy_cfg->eeer_value || in ice_phy_caps_equals_cfg()
3539 phy_caps->link_fec_options != phy_cfg->link_fec_opt) in ice_phy_caps_equals_cfg()
3546 * ice_copy_phy_caps_to_cfg - Copy PHY ability data to configuration data
3549 * @cfg: PHY configuration structure to copy data to
3557 struct ice_aqc_set_phy_cfg_data *cfg) in ice_copy_phy_caps_to_cfg() argument
3559 if (!pi || !caps || !cfg) in ice_copy_phy_caps_to_cfg()
3562 memset(cfg, 0, sizeof(*cfg)); in ice_copy_phy_caps_to_cfg()
3563 cfg->phy_type_low = caps->phy_type_low; in ice_copy_phy_caps_to_cfg()
3564 cfg->phy_type_high = caps->phy_type_high; in ice_copy_phy_caps_to_cfg()
3565 cfg->caps = caps->caps; in ice_copy_phy_caps_to_cfg()
3566 cfg->low_power_ctrl_an = caps->low_power_ctrl_an; in ice_copy_phy_caps_to_cfg()
3567 cfg->eee_cap = caps->eee_cap; in ice_copy_phy_caps_to_cfg()
3568 cfg->eeer_value = caps->eeer_value; in ice_copy_phy_caps_to_cfg()
3569 cfg->link_fec_opt = caps->link_fec_options; in ice_copy_phy_caps_to_cfg()
3570 cfg->module_compliance_enforcement = in ice_copy_phy_caps_to_cfg()
3571 caps->module_compliance_enforcement; in ice_copy_phy_caps_to_cfg()
3575 * ice_cfg_phy_fec - Configure PHY FEC data based on FEC mode
3577 * @cfg: PHY configuration data to set FEC mode
3581 ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg, in ice_cfg_phy_fec() argument
3588 if (!pi || !cfg) in ice_cfg_phy_fec()
3589 return -EINVAL; in ice_cfg_phy_fec()
3591 hw = pi->hw; in ice_cfg_phy_fec()
3595 return -ENOMEM; in ice_cfg_phy_fec()
3604 cfg->caps |= pcaps->caps & ICE_AQC_PHY_EN_AUTO_FEC; in ice_cfg_phy_fec()
3605 cfg->link_fec_opt = pcaps->link_fec_options; in ice_cfg_phy_fec()
3609 /* Clear RS bits, and AND BASE-R ability in ice_cfg_phy_fec()
3612 cfg->link_fec_opt &= ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN | in ice_cfg_phy_fec()
3614 cfg->link_fec_opt |= ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ | in ice_cfg_phy_fec()
3618 /* Clear BASE-R bits, and AND RS ability in ice_cfg_phy_fec()
3621 cfg->link_fec_opt &= ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN; in ice_cfg_phy_fec()
3622 cfg->link_fec_opt |= ICE_AQC_PHY_FEC_25G_RS_528_REQ | in ice_cfg_phy_fec()
3627 cfg->link_fec_opt &= ~ICE_AQC_PHY_FEC_MASK; in ice_cfg_phy_fec()
3631 cfg->caps &= ICE_AQC_PHY_CAPS_MASK; in ice_cfg_phy_fec()
3632 cfg->link_fec_opt |= pcaps->link_fec_options; in ice_cfg_phy_fec()
3635 status = -EINVAL; in ice_cfg_phy_fec()
3649 cfg->link_fec_opt = tlv.fec_options; in ice_cfg_phy_fec()
3659 * ice_get_link_status - get status of the HW network link
3673 return -EINVAL; in ice_get_link_status()
3675 phy_info = &pi->phy; in ice_get_link_status()
3677 if (phy_info->get_link_info) { in ice_get_link_status()
3681 ice_debug(pi->hw, ICE_DBG_LINK, "get link status error, status = %d\n", in ice_get_link_status()
3685 *link_up = phy_info->link_info.link_info & ICE_AQ_LINK_UP; in ice_get_link_status()
3696 * Sets up the link and restarts the Auto-Negotiation over the link.
3709 cmd->cmd_flags = ICE_AQC_RESTART_AN_LINK_RESTART; in ice_aq_set_link_restart_an()
3710 cmd->lport_num = pi->lport; in ice_aq_set_link_restart_an()
3712 cmd->cmd_flags |= ICE_AQC_RESTART_AN_LINK_ENABLE; in ice_aq_set_link_restart_an()
3714 cmd->cmd_flags &= ~ICE_AQC_RESTART_AN_LINK_ENABLE; in ice_aq_set_link_restart_an()
3716 return ice_aq_send_cmd(pi->hw, &desc, NULL, 0, cd); in ice_aq_set_link_restart_an()
3739 cmd->lport_num = port_num; in ice_aq_set_event_mask()
3741 cmd->event_mask = cpu_to_le16(mask); in ice_aq_set_event_mask()
3763 cmd->lb_mode = ICE_AQ_MAC_LB_EN; in ice_aq_set_mac_loopback()
3771 * @is_orig_mode: is this LED set to original mode (by the net-list)
3781 struct ice_hw *hw = pi->hw; in ice_aq_set_port_id_led()
3789 cmd->ident_mode = ICE_AQC_PORT_IDENT_LED_ORIG; in ice_aq_set_port_id_led()
3791 cmd->ident_mode = ICE_AQC_PORT_IDENT_LED_BLINK; in ice_aq_set_port_id_led()
3800 * @option_count: input - size of the buffer in port options structures,
3801 * output - number of returned port options
3803 * @lport_valid: when false, FW uses port owned by the PF instead of lport,
3826 return -EINVAL; in ice_aq_get_port_options()
3832 cmd->lport_num = lport; in ice_aq_get_port_options()
3833 cmd->lport_num_valid = lport_valid; in ice_aq_get_port_options()
3840 /* verify direct FW response & set output parameters */ in ice_aq_get_port_options()
3842 cmd->port_options_count); in ice_aq_get_port_options()
3845 cmd->port_options); in ice_aq_get_port_options()
3848 cmd->port_options); in ice_aq_get_port_options()
3849 if (*active_option_idx > (*option_count - 1)) in ice_aq_get_port_options()
3850 return -EIO; in ice_aq_get_port_options()
3856 cmd->pending_port_option_status); in ice_aq_get_port_options()
3859 cmd->pending_port_option_status); in ice_aq_get_port_options()
3860 if (*pending_option_idx > (*option_count - 1)) in ice_aq_get_port_options()
3861 return -EIO; in ice_aq_get_port_options()
3883 * @lport_valid: when false, FW uses port owned by the PF instead of lport,
3897 return -EINVAL; in ice_aq_set_port_option()
3903 cmd->lport_num = lport; in ice_aq_set_port_option()
3905 cmd->lport_num_valid = lport_valid; in ice_aq_set_port_option()
3906 cmd->selected_port_option = new_option; in ice_aq_set_port_option()
3920 * @length: 1-16 for read, 1 for write.
3936 return -EINVAL; in ice_aq_sff_eeprom()
3941 cmd->lport_num = (u8)(lport & 0xff); in ice_aq_sff_eeprom()
3942 cmd->lport_num_valid = (u8)((lport >> 8) & 0x01); in ice_aq_sff_eeprom()
3943 cmd->i2c_bus_addr = cpu_to_le16(((bus_addr >> 1) & in ice_aq_sff_eeprom()
3948 cmd->i2c_mem_addr = cpu_to_le16(mem_addr & 0xff); in ice_aq_sff_eeprom()
3949 cmd->eeprom_page = cpu_to_le16((u16)page << ICE_AQC_SFF_EEPROM_PAGE_S); in ice_aq_sff_eeprom()
3951 cmd->i2c_bus_addr |= cpu_to_le16(ICE_AQC_SFF_IS_WRITE); in ice_aq_sff_eeprom()
3997 u16 opcode, vsi_id, vsi_handle = params->vsi_handle, glob_lut_idx = 0; in __ice_aq_get_set_rss_lut()
3998 enum ice_lut_type lut_type = params->lut_type; in __ice_aq_get_set_rss_lut()
4003 u8 *lut = params->lut; in __ice_aq_get_set_rss_lut()
4007 return -EINVAL; in __ice_aq_get_set_rss_lut()
4010 if (lut_size > params->lut_size) in __ice_aq_get_set_rss_lut()
4011 return -EINVAL; in __ice_aq_get_set_rss_lut()
4012 else if (set && lut_size != params->lut_size) in __ice_aq_get_set_rss_lut()
4013 return -EINVAL; in __ice_aq_get_set_rss_lut()
4022 desc_params->vsi_id = cpu_to_le16(vsi_id | ICE_AQC_RSS_VSI_VALID); in __ice_aq_get_set_rss_lut()
4026 params->global_lut_id); in __ice_aq_get_set_rss_lut()
4029 desc_params->flags = cpu_to_le16(flags); in __ice_aq_get_set_rss_lut()
4063 * @vsi_id: VSI FW index
4085 desc_params->vsi_id = cpu_to_le16(vsi_id | ICE_AQC_RSS_VSI_VALID); in __ice_aq_get_set_rss_key()
4103 return -EINVAL; in ice_aq_get_rss_key()
4122 return -EINVAL; in ice_aq_set_rss_key()
4164 return -EINVAL; in ice_aq_add_lan_txq()
4167 return -EINVAL; in ice_aq_add_lan_txq()
4170 sum_size += struct_size(list, txqs, list->num_txqs); in ice_aq_add_lan_txq()
4171 list = (struct ice_aqc_add_tx_qgrp *)(list->txqs + in ice_aq_add_lan_txq()
4172 list->num_txqs); in ice_aq_add_lan_txq()
4176 return -EINVAL; in ice_aq_add_lan_txq()
4180 cmd->num_qgrps = num_qgrps; in ice_aq_add_lan_txq()
4214 return -EINVAL; in ice_aq_dis_lan_txq()
4217 return -EINVAL; in ice_aq_dis_lan_txq()
4219 cmd->num_entries = num_qgrps; in ice_aq_dis_lan_txq()
4221 cmd->vmvf_and_timeout = cpu_to_le16((5 << ICE_AQC_Q_DIS_TIMEOUT_S) & in ice_aq_dis_lan_txq()
4226 cmd->cmd_type = ICE_AQC_Q_DIS_CMD_VM_RESET; in ice_aq_dis_lan_txq()
4227 cmd->vmvf_and_timeout |= in ice_aq_dis_lan_txq()
4231 cmd->cmd_type = ICE_AQC_Q_DIS_CMD_VF_RESET; in ice_aq_dis_lan_txq()
4232 /* In this case, FW expects vmvf_num to be absolute VF ID */ in ice_aq_dis_lan_txq()
4233 cmd->vmvf_and_timeout |= in ice_aq_dis_lan_txq()
4234 cpu_to_le16((vmvf_num + hw->func_caps.vf_base_id) & in ice_aq_dis_lan_txq()
4243 cmd->cmd_type |= ICE_AQC_Q_DIS_CMD_FLUSH_PIPE; in ice_aq_dis_lan_txq()
4254 u16 item_size = struct_size(item, q_id, item->num_qs); in ice_aq_dis_lan_txq()
4257 if ((item->num_qs % 2) == 0) in ice_aq_dis_lan_txq()
4266 return -EINVAL; in ice_aq_dis_lan_txq()
4273 vmvf_num, hw->adminq.sq_last_status); in ice_aq_dis_lan_txq()
4277 hw->adminq.sq_last_status); in ice_aq_dis_lan_txq()
4311 return -EINVAL; in ice_aq_cfg_lan_txq()
4313 cmd->cmd_type = ICE_AQC_Q_CFG_TC_CHNG; in ice_aq_cfg_lan_txq()
4314 cmd->num_qs = num_qs; in ice_aq_cfg_lan_txq()
4315 cmd->port_num_chng = (oldport & ICE_AQC_Q_CFG_SRC_PRT_M); in ice_aq_cfg_lan_txq()
4316 cmd->port_num_chng |= (newport << ICE_AQC_Q_CFG_DST_PRT_S) & in ice_aq_cfg_lan_txq()
4318 cmd->time_out = (5 << ICE_AQC_Q_CFG_TIMEOUT_S) & in ice_aq_cfg_lan_txq()
4320 cmd->blocked_cgds = 0; in ice_aq_cfg_lan_txq()
4325 hw->adminq.sq_last_status); in ice_aq_cfg_lan_txq()
4354 return -EINVAL; in ice_aq_add_rdma_qsets()
4357 u16 num_qsets = le16_to_cpu(list->num_qsets); in ice_aq_add_rdma_qsets()
4360 list = (struct ice_aqc_add_rdma_qset_data *)(list->rdma_qsets + in ice_aq_add_rdma_qsets()
4365 return -EINVAL; in ice_aq_add_rdma_qsets()
4369 cmd->num_qset_grps = num_qset_grps; in ice_aq_add_rdma_qsets()
4374 /* End of FW Admin Queue command wrappers */
4377 * ice_write_byte - write a byte to a packed context structure
4390 from = src_ctx + ce_info->offset; in ice_write_byte()
4393 shift_width = ce_info->lsb % 8; in ice_write_byte()
4394 mask = (u8)(BIT(ce_info->width) - 1); in ice_write_byte()
4404 dest = dest_ctx + (ce_info->lsb / 8); in ice_write_byte()
4416 * ice_write_word - write a word to a packed context structure
4430 from = src_ctx + ce_info->offset; in ice_write_word()
4433 shift_width = ce_info->lsb % 8; in ice_write_word()
4434 mask = BIT(ce_info->width) - 1; in ice_write_word()
4447 dest = dest_ctx + (ce_info->lsb / 8); in ice_write_word()
4459 * ice_write_dword - write a dword to a packed context structure
4473 from = src_ctx + ce_info->offset; in ice_write_dword()
4476 shift_width = ce_info->lsb % 8; in ice_write_dword()
4482 if (ce_info->width < 32) in ice_write_dword()
4483 mask = BIT(ce_info->width) - 1; in ice_write_dword()
4498 dest = dest_ctx + (ce_info->lsb / 8); in ice_write_dword()
4510 * ice_write_qword - write a qword to a packed context structure
4524 from = src_ctx + ce_info->offset; in ice_write_qword()
4527 shift_width = ce_info->lsb % 8; in ice_write_qword()
4533 if (ce_info->width < 64) in ice_write_qword()
4534 mask = BIT_ULL(ce_info->width) - 1; in ice_write_qword()
4549 dest = dest_ctx + (ce_info->lsb / 8); in ice_write_qword()
4561 * ice_set_ctx - set context bits in packed structure
4563 * @src_ctx: pointer to a generic non-packed context structure
4574 /* We have to deal with each element of the FW response in ice_set_ctx()
4597 return -EINVAL; in ice_set_ctx()
4605 * ice_get_lan_q_ctx - get the LAN queue context for the given VSI and TC
4620 if (q_handle >= vsi->num_lan_q_entries[tc]) in ice_get_lan_q_ctx()
4622 if (!vsi->lan_q_ctx[tc]) in ice_get_lan_q_ctx()
4624 q_ctx = vsi->lan_q_ctx[tc]; in ice_get_lan_q_ctx()
4652 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) in ice_ena_vsi_txq()
4653 return -EIO; in ice_ena_vsi_txq()
4655 if (num_qgrps > 1 || buf->num_txqs > 1) in ice_ena_vsi_txq()
4656 return -ENOSPC; in ice_ena_vsi_txq()
4658 hw = pi->hw; in ice_ena_vsi_txq()
4661 return -EINVAL; in ice_ena_vsi_txq()
4663 mutex_lock(&pi->sched_lock); in ice_ena_vsi_txq()
4669 status = -EINVAL; in ice_ena_vsi_txq()
4677 status = -EINVAL; in ice_ena_vsi_txq()
4681 buf->parent_teid = parent->info.node_teid; in ice_ena_vsi_txq()
4682 node.parent_teid = parent->info.node_teid; in ice_ena_vsi_txq()
4685 * - Scheduling mode is Bytes Per Second (BPS), indicated by Bit 0. in ice_ena_vsi_txq()
4686 * - 0 priority among siblings, indicated by Bit 1-3. in ice_ena_vsi_txq()
4687 * - WFQ, indicated by Bit 4. in ice_ena_vsi_txq()
4688 * - 0 Adjustment value is used in PSM credit update flow, indicated by in ice_ena_vsi_txq()
4689 * Bit 5-6. in ice_ena_vsi_txq()
4690 * - Bit 7 is reserved. in ice_ena_vsi_txq()
4694 buf->txqs[0].info.valid_sections = in ice_ena_vsi_txq()
4697 buf->txqs[0].info.generic = 0; in ice_ena_vsi_txq()
4698 buf->txqs[0].info.cir_bw.bw_profile_idx = in ice_ena_vsi_txq()
4700 buf->txqs[0].info.cir_bw.bw_alloc = in ice_ena_vsi_txq()
4702 buf->txqs[0].info.eir_bw.bw_profile_idx = in ice_ena_vsi_txq()
4704 buf->txqs[0].info.eir_bw.bw_alloc = in ice_ena_vsi_txq()
4711 le16_to_cpu(buf->txqs[0].txq_id), in ice_ena_vsi_txq()
4712 hw->adminq.sq_last_status); in ice_ena_vsi_txq()
4716 node.node_teid = buf->txqs[0].q_teid; in ice_ena_vsi_txq()
4718 q_ctx->q_handle = q_handle; in ice_ena_vsi_txq()
4719 q_ctx->q_teid = le32_to_cpu(node.node_teid); in ice_ena_vsi_txq()
4722 status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node, NULL); in ice_ena_vsi_txq()
4727 mutex_unlock(&pi->sched_lock); in ice_ena_vsi_txq()
4754 int status = -ENOENT; in ice_dis_vsi_txq()
4758 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) in ice_dis_vsi_txq()
4759 return -EIO; in ice_dis_vsi_txq()
4761 hw = pi->hw; in ice_dis_vsi_txq()
4771 return -EIO; in ice_dis_vsi_txq()
4777 return -ENOMEM; in ice_dis_vsi_txq()
4779 mutex_lock(&pi->sched_lock); in ice_dis_vsi_txq()
4784 node = ice_sched_find_node_by_teid(pi->root, q_teids[i]); in ice_dis_vsi_txq()
4793 if (q_ctx->q_handle != q_handles[i]) { in ice_dis_vsi_txq()
4795 q_ctx->q_handle, q_handles[i]); in ice_dis_vsi_txq()
4798 qg_list->parent_teid = node->info.parent_teid; in ice_dis_vsi_txq()
4799 qg_list->num_qs = 1; in ice_dis_vsi_txq()
4800 qg_list->q_id[0] = cpu_to_le16(q_ids[i]); in ice_dis_vsi_txq()
4807 q_ctx->q_handle = ICE_INVAL_Q_HANDLE; in ice_dis_vsi_txq()
4808 q_ctx->q_teid = ICE_INVAL_TEID; in ice_dis_vsi_txq()
4810 mutex_unlock(&pi->sched_lock); in ice_dis_vsi_txq()
4816 * ice_cfg_vsi_qs - configure the new/existing VSI queues
4832 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) in ice_cfg_vsi_qs()
4833 return -EIO; in ice_cfg_vsi_qs()
4835 if (!ice_is_vsi_valid(pi->hw, vsi_handle)) in ice_cfg_vsi_qs()
4836 return -EINVAL; in ice_cfg_vsi_qs()
4838 mutex_lock(&pi->sched_lock); in ice_cfg_vsi_qs()
4851 mutex_unlock(&pi->sched_lock); in ice_cfg_vsi_qs()
4856 * ice_cfg_vsi_lan - configure VSI LAN queues
4873 * ice_cfg_vsi_rdma - configure the VSI RDMA queues
4911 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) in ice_ena_vsi_rdma_qset()
4912 return -EIO; in ice_ena_vsi_rdma_qset()
4913 hw = pi->hw; in ice_ena_vsi_rdma_qset()
4916 return -EINVAL; in ice_ena_vsi_rdma_qset()
4921 return -ENOMEM; in ice_ena_vsi_rdma_qset()
4922 mutex_lock(&pi->sched_lock); in ice_ena_vsi_rdma_qset()
4927 ret = -EINVAL; in ice_ena_vsi_rdma_qset()
4930 buf->parent_teid = parent->info.node_teid; in ice_ena_vsi_rdma_qset()
4931 node.parent_teid = parent->info.node_teid; in ice_ena_vsi_rdma_qset()
4933 buf->num_qsets = cpu_to_le16(num_qsets); in ice_ena_vsi_rdma_qset()
4935 buf->rdma_qsets[i].tx_qset_id = cpu_to_le16(rdma_qset[i]); in ice_ena_vsi_rdma_qset()
4936 buf->rdma_qsets[i].info.valid_sections = in ice_ena_vsi_rdma_qset()
4939 buf->rdma_qsets[i].info.generic = 0; in ice_ena_vsi_rdma_qset()
4940 buf->rdma_qsets[i].info.cir_bw.bw_profile_idx = in ice_ena_vsi_rdma_qset()
4942 buf->rdma_qsets[i].info.cir_bw.bw_alloc = in ice_ena_vsi_rdma_qset()
4944 buf->rdma_qsets[i].info.eir_bw.bw_profile_idx = in ice_ena_vsi_rdma_qset()
4946 buf->rdma_qsets[i].info.eir_bw.bw_alloc = in ice_ena_vsi_rdma_qset()
4956 node.node_teid = buf->rdma_qsets[i].qset_teid; in ice_ena_vsi_rdma_qset()
4957 ret = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, in ice_ena_vsi_rdma_qset()
4964 mutex_unlock(&pi->sched_lock); in ice_ena_vsi_rdma_qset()
4970 * ice_dis_vsi_rdma_qset - free RDMA resources
4986 if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY) in ice_dis_vsi_rdma_qset()
4987 return -EIO; in ice_dis_vsi_rdma_qset()
4989 hw = pi->hw; in ice_dis_vsi_rdma_qset()
4994 return -ENOMEM; in ice_dis_vsi_rdma_qset()
4996 mutex_lock(&pi->sched_lock); in ice_dis_vsi_rdma_qset()
5001 node = ice_sched_find_node_by_teid(pi->root, qset_teid[i]); in ice_dis_vsi_rdma_qset()
5005 qg_list->parent_teid = node->info.parent_teid; in ice_dis_vsi_rdma_qset()
5006 qg_list->num_qs = 1; in ice_dis_vsi_rdma_qset()
5007 qg_list->q_id[0] = in ice_dis_vsi_rdma_qset()
5019 mutex_unlock(&pi->sched_lock); in ice_dis_vsi_rdma_qset()
5025 * ice_replay_pre_init - replay pre initialization
5032 struct ice_switch_info *sw = hw->switch_info; in ice_replay_pre_init()
5042 list_replace_init(&sw->recp_list[i].filt_rules, in ice_replay_pre_init()
5043 &sw->recp_list[i].filt_replay_rules); in ice_replay_pre_init()
5050 * ice_replay_vsi - replay VSI configuration
5062 return -EINVAL; in ice_replay_vsi()
5064 /* Replay pre-initialization if there is any */ in ice_replay_vsi()
5082 * ice_replay_post - post replay configuration cleanup
5095 * ice_stat_update40 - read 40 bit stat from the chip and update stat values
5106 u64 new_data = rd64(hw, reg) & (BIT_ULL(40) - 1); in ice_stat_update40()
5122 *cur_stat += new_data - *prev_stat; in ice_stat_update40()
5124 /* to manage the potential roll-over */ in ice_stat_update40()
5125 *cur_stat += (new_data + BIT_ULL(40)) - *prev_stat; in ice_stat_update40()
5132 * ice_stat_update32 - read 32 bit stat from the chip and update stat values
5161 *cur_stat += new_data - *prev_stat; in ice_stat_update32()
5163 /* to manage the potential roll-over */ in ice_stat_update32()
5164 *cur_stat += (new_data + BIT_ULL(32)) - *prev_stat; in ice_stat_update32()
5171 * ice_sched_query_elem - query element information from HW
5187 buf->node_teid = cpu_to_le32(node_teid); in ice_sched_query_elem()
5199 * @bus_addr: 7-bit I2C bus address
5201 * @params: I2C parameters: bit [7] - Repeated start,
5203 * bit [4] - I2C address type,
5204 * bits [3:0] - data size to read (0-16 bytes)
5224 return -EINVAL; in ice_aq_read_i2c()
5228 cmd->i2c_bus_addr = cpu_to_le16(bus_addr); in ice_aq_read_i2c()
5229 cmd->topo_addr = topo_addr; in ice_aq_read_i2c()
5230 cmd->i2c_params = params; in ice_aq_read_i2c()
5231 cmd->i2c_addr = addr; in ice_aq_read_i2c()
5240 *data = resp->i2c_data[i]; in ice_aq_read_i2c()
5252 * @bus_addr: 7-bit I2C bus address
5254 * @params: I2C parameters: bit [4] - I2C address type, bits [3:0] - data size to write (0-7 bytes)
5261 * * 0 - Successful write to the i2c device
5262 * * -EINVAL - Data size greater than 4 bytes
5263 * * -EIO - FW error
5281 return -EINVAL; in ice_aq_write_i2c()
5283 cmd->i2c_bus_addr = cpu_to_le16(bus_addr); in ice_aq_write_i2c()
5284 cmd->topo_addr = topo_addr; in ice_aq_write_i2c()
5285 cmd->i2c_params = params; in ice_aq_write_i2c()
5286 cmd->i2c_addr = addr; in ice_aq_write_i2c()
5288 memcpy(cmd->i2c_data, data, data_size); in ice_aq_write_i2c()
5294 * ice_aq_set_driver_param - Set driver parameter to share via firmware
5316 return -EIO; in ice_aq_set_driver_param()
5322 cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_SET; in ice_aq_set_driver_param()
5323 cmd->param_indx = idx; in ice_aq_set_driver_param()
5324 cmd->param_val = cpu_to_le32(value); in ice_aq_set_driver_param()
5330 * ice_aq_get_driver_param - Get driver parameter shared via firmware
5350 return -EIO; in ice_aq_get_driver_param()
5356 cmd->set_or_get_op = ICE_AQC_DRIVER_PARAM_GET; in ice_aq_get_driver_param()
5357 cmd->param_indx = idx; in ice_aq_get_driver_param()
5363 *value = le32_to_cpu(cmd->param_val); in ice_aq_get_driver_param()
5387 cmd->gpio_ctrl_handle = cpu_to_le16(gpio_ctrl_handle); in ice_aq_set_gpio()
5388 cmd->gpio_num = pin_idx; in ice_aq_set_gpio()
5389 cmd->gpio_val = value ? 1 : 0; in ice_aq_set_gpio()
5415 cmd->gpio_ctrl_handle = cpu_to_le16(gpio_ctrl_handle); in ice_aq_get_gpio()
5416 cmd->gpio_num = pin_idx; in ice_aq_get_gpio()
5422 *value = !!cmd->gpio_val; in ice_aq_get_gpio()
5437 if (hw->api_maj_ver == maj) { in ice_is_fw_api_min_ver()
5438 if (hw->api_min_ver > min) in ice_is_fw_api_min_ver()
5440 if (hw->api_min_ver == min && hw->api_patch >= patch) in ice_is_fw_api_min_ver()
5442 } else if (hw->api_maj_ver > maj) { in ice_is_fw_api_min_ver()
5474 struct ice_hw *hw = pi->hw; in ice_get_link_default_override()
5485 tlv_start = tlv + pi->lport * ICE_SR_PFA_LINK_OVERRIDE_WORDS + in ice_get_link_default_override()
5494 ldo->options = buf & ICE_LINK_OVERRIDE_OPT_M; in ice_get_link_default_override()
5495 ldo->phy_config = (buf & ICE_LINK_OVERRIDE_PHY_CFG_M) >> in ice_get_link_default_override()
5505 ldo->fec_options = buf & ICE_LINK_OVERRIDE_FEC_OPT_M; in ice_get_link_default_override()
5516 ldo->phy_type_low |= ((u64)buf << (i * 16)); in ice_get_link_default_override()
5529 ldo->phy_type_high |= ((u64)buf << (i * 16)); in ice_get_link_default_override()
5536 * ice_is_phy_caps_an_enabled - check if PHY capabilities autoneg is enabled
5541 if (caps->caps & ICE_AQC_PHY_AN_MODE || in ice_is_phy_caps_an_enabled()
5542 caps->low_power_ctrl_an & (ICE_AQC_PHY_AN_EN_CLAUSE28 | in ice_is_phy_caps_an_enabled()
5551 * ice_aq_set_lldp_mib - Set the LLDP MIB
5554 * @buf: pointer to the caller-supplied buffer to store the MIB block
5570 return -EINVAL; in ice_aq_set_lldp_mib()
5577 cmd->type = mib_type; in ice_aq_set_lldp_mib()
5578 cmd->length = cpu_to_le16(buf_size); in ice_aq_set_lldp_mib()
5584 * ice_fw_supports_lldp_fltr_ctrl - check NVM version supports lldp_fltr_ctrl
5589 if (hw->mac_type != ICE_MAC_E810) in ice_fw_supports_lldp_fltr_ctrl()
5598 * ice_lldp_fltr_add_remove - add or remove a LLDP Rx switch filter
5614 cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_ADD; in ice_lldp_fltr_add_remove()
5616 cmd->cmd_flags = ICE_AQC_LLDP_FILTER_ACTION_DELETE; in ice_lldp_fltr_add_remove()
5618 cmd->vsi_num = cpu_to_le16(vsi_num); in ice_lldp_fltr_add_remove()
5624 * ice_lldp_execute_pending_mib - execute LLDP pending MIB request
5655 * by [fls(speed) - 1]
5672 * ice_get_link_speed - get integer speed from table
5673 * @index: array index from fls(aq speed) - 1