@@ -158,6 +158,10 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
158158 return ICE_ERR_PARAM ;
159159 hw = pi -> hw ;
160160
161+ if (report_mode == ICE_AQC_REPORT_DFLT_CFG &&
162+ !ice_fw_supports_report_dflt_cfg (hw ))
163+ return ICE_ERR_PARAM ;
164+
161165 ice_fill_dflt_direct_cmd_desc (& desc , ice_aqc_opc_get_phy_caps );
162166
163167 if (qual_mods )
@@ -191,7 +195,7 @@ ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
191195 ice_debug (hw , ICE_DBG_LINK , " module_type[2] = 0x%x\n" ,
192196 pcaps -> module_type [2 ]);
193197
194- if (!status && report_mode == ICE_AQC_REPORT_TOPO_CAP ) {
198+ if (!status && report_mode == ICE_AQC_REPORT_TOPO_CAP_MEDIA ) {
195199 pi -> phy .phy_type_low = le64_to_cpu (pcaps -> phy_type_low );
196200 pi -> phy .phy_type_high = le64_to_cpu (pcaps -> phy_type_high );
197201 memcpy (pi -> phy .link_info .module_type , & pcaps -> module_type ,
@@ -922,7 +926,8 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
922926
923927 /* Initialize port_info struct with PHY capabilities */
924928 status = ice_aq_get_phy_caps (hw -> port_info , false,
925- ICE_AQC_REPORT_TOPO_CAP , pcaps , NULL );
929+ ICE_AQC_REPORT_TOPO_CAP_MEDIA , pcaps ,
930+ NULL );
926931 devm_kfree (ice_hw_to_dev (hw ), pcaps );
927932 if (status )
928933 dev_warn (ice_hw_to_dev (hw ), "Get PHY capabilities failed status = %d, continuing anyway\n" ,
@@ -1292,6 +1297,85 @@ const struct ice_ctx_ele ice_tlan_ctx_info[] = {
12921297 */
12931298DEFINE_MUTEX (ice_global_cfg_lock_sw );
12941299
1300+ /**
1301+ * ice_should_retry_sq_send_cmd
1302+ * @opcode: AQ opcode
1303+ *
1304+ * Decide if we should retry the send command routine for the ATQ, depending
1305+ * on the opcode.
1306+ */
1307+ static bool ice_should_retry_sq_send_cmd (u16 opcode )
1308+ {
1309+ switch (opcode ) {
1310+ case ice_aqc_opc_get_link_topo :
1311+ case ice_aqc_opc_lldp_stop :
1312+ case ice_aqc_opc_lldp_start :
1313+ case ice_aqc_opc_lldp_filter_ctrl :
1314+ return true;
1315+ }
1316+
1317+ return false;
1318+ }
1319+
1320+ /**
1321+ * ice_sq_send_cmd_retry - send command to Control Queue (ATQ)
1322+ * @hw: pointer to the HW struct
1323+ * @cq: pointer to the specific Control queue
1324+ * @desc: prefilled descriptor describing the command
1325+ * @buf: buffer to use for indirect commands (or NULL for direct commands)
1326+ * @buf_size: size of buffer for indirect commands (or 0 for direct commands)
1327+ * @cd: pointer to command details structure
1328+ *
1329+ * Retry sending the FW Admin Queue command, multiple times, to the FW Admin
1330+ * Queue if the EBUSY AQ error is returned.
1331+ */
1332+ static enum ice_status
1333+ ice_sq_send_cmd_retry (struct ice_hw * hw , struct ice_ctl_q_info * cq ,
1334+ struct ice_aq_desc * desc , void * buf , u16 buf_size ,
1335+ struct ice_sq_cd * cd )
1336+ {
1337+ struct ice_aq_desc desc_cpy ;
1338+ enum ice_status status ;
1339+ bool is_cmd_for_retry ;
1340+ u8 * buf_cpy = NULL ;
1341+ u8 idx = 0 ;
1342+ u16 opcode ;
1343+
1344+ opcode = le16_to_cpu (desc -> opcode );
1345+ is_cmd_for_retry = ice_should_retry_sq_send_cmd (opcode );
1346+ memset (& desc_cpy , 0 , sizeof (desc_cpy ));
1347+
1348+ if (is_cmd_for_retry ) {
1349+ if (buf ) {
1350+ buf_cpy = kzalloc (buf_size , GFP_KERNEL );
1351+ if (!buf_cpy )
1352+ return ICE_ERR_NO_MEMORY ;
1353+ }
1354+
1355+ memcpy (& desc_cpy , desc , sizeof (desc_cpy ));
1356+ }
1357+
1358+ do {
1359+ status = ice_sq_send_cmd (hw , cq , desc , buf , buf_size , cd );
1360+
1361+ if (!is_cmd_for_retry || !status ||
1362+ hw -> adminq .sq_last_status != ICE_AQ_RC_EBUSY )
1363+ break ;
1364+
1365+ if (buf_cpy )
1366+ memcpy (buf , buf_cpy , buf_size );
1367+
1368+ memcpy (desc , & desc_cpy , sizeof (desc_cpy ));
1369+
1370+ mdelay (ICE_SQ_SEND_DELAY_TIME_MS );
1371+
1372+ } while (++ idx < ICE_SQ_SEND_MAX_EXECUTE );
1373+
1374+ kfree (buf_cpy );
1375+
1376+ return status ;
1377+ }
1378+
12951379/**
12961380 * ice_aq_send_cmd - send FW Admin Queue command to FW Admin Queue
12971381 * @hw: pointer to the HW struct
@@ -1333,7 +1417,7 @@ ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf,
13331417 break ;
13341418 }
13351419
1336- status = ice_sq_send_cmd (hw , & hw -> adminq , desc , buf , buf_size , cd );
1420+ status = ice_sq_send_cmd_retry (hw , & hw -> adminq , desc , buf , buf_size , cd );
13371421 if (lock_acquired )
13381422 mutex_unlock (& ice_global_cfg_lock_sw );
13391423
@@ -2655,7 +2739,7 @@ enum ice_status ice_update_link_info(struct ice_port_info *pi)
26552739 if (!pcaps )
26562740 return ICE_ERR_NO_MEMORY ;
26572741
2658- status = ice_aq_get_phy_caps (pi , false, ICE_AQC_REPORT_TOPO_CAP ,
2742+ status = ice_aq_get_phy_caps (pi , false, ICE_AQC_REPORT_TOPO_CAP_MEDIA ,
26592743 pcaps , NULL );
26602744
26612745 devm_kfree (ice_hw_to_dev (hw ), pcaps );
@@ -2815,8 +2899,8 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
28152899 return ICE_ERR_NO_MEMORY ;
28162900
28172901 /* Get the current PHY config */
2818- status = ice_aq_get_phy_caps (pi , false, ICE_AQC_REPORT_SW_CFG , pcaps ,
2819- NULL );
2902+ status = ice_aq_get_phy_caps (pi , false, ICE_AQC_REPORT_ACTIVE_CFG ,
2903+ pcaps , NULL );
28202904 if (status ) {
28212905 * aq_failures = ICE_SET_FC_AQ_FAIL_GET ;
28222906 goto out ;
@@ -2929,17 +3013,6 @@ ice_copy_phy_caps_to_cfg(struct ice_port_info *pi,
29293013 cfg -> link_fec_opt = caps -> link_fec_options ;
29303014 cfg -> module_compliance_enforcement =
29313015 caps -> module_compliance_enforcement ;
2932-
2933- if (ice_fw_supports_link_override (pi -> hw )) {
2934- struct ice_link_default_override_tlv tlv ;
2935-
2936- if (ice_get_link_default_override (& tlv , pi ))
2937- return ;
2938-
2939- if (tlv .options & ICE_LINK_OVERRIDE_STRICT_MODE )
2940- cfg -> module_compliance_enforcement |=
2941- ICE_LINK_OVERRIDE_STRICT_MODE ;
2942- }
29433016}
29443017
29453018/**
@@ -2954,16 +3027,21 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
29543027{
29553028 struct ice_aqc_get_phy_caps_data * pcaps ;
29563029 enum ice_status status ;
3030+ struct ice_hw * hw ;
29573031
29583032 if (!pi || !cfg )
29593033 return ICE_ERR_BAD_PTR ;
29603034
3035+ hw = pi -> hw ;
3036+
29613037 pcaps = kzalloc (sizeof (* pcaps ), GFP_KERNEL );
29623038 if (!pcaps )
29633039 return ICE_ERR_NO_MEMORY ;
29643040
2965- status = ice_aq_get_phy_caps (pi , false, ICE_AQC_REPORT_TOPO_CAP , pcaps ,
2966- NULL );
3041+ status = ice_aq_get_phy_caps (pi , false,
3042+ (ice_fw_supports_report_dflt_cfg (hw ) ?
3043+ ICE_AQC_REPORT_DFLT_CFG :
3044+ ICE_AQC_REPORT_TOPO_CAP_MEDIA ), pcaps , NULL );
29673045 if (status )
29683046 goto out ;
29693047
@@ -3002,7 +3080,8 @@ ice_cfg_phy_fec(struct ice_port_info *pi, struct ice_aqc_set_phy_cfg_data *cfg,
30023080 break ;
30033081 }
30043082
3005- if (fec == ICE_FEC_AUTO && ice_fw_supports_link_override (pi -> hw )) {
3083+ if (fec == ICE_FEC_AUTO && ice_fw_supports_link_override (hw ) &&
3084+ !ice_fw_supports_report_dflt_cfg (hw )) {
30063085 struct ice_link_default_override_tlv tlv ;
30073086
30083087 if (ice_get_link_default_override (& tlv , pi ))
@@ -4412,3 +4491,23 @@ ice_lldp_fltr_add_remove(struct ice_hw *hw, u16 vsi_num, bool add)
44124491
44134492 return ice_aq_send_cmd (hw , & desc , NULL , 0 , NULL );
44144493}
4494+
4495+ /**
4496+ * ice_fw_supports_report_dflt_cfg
4497+ * @hw: pointer to the hardware structure
4498+ *
4499+ * Checks if the firmware supports report default configuration
4500+ */
4501+ bool ice_fw_supports_report_dflt_cfg (struct ice_hw * hw )
4502+ {
4503+ if (hw -> api_maj_ver == ICE_FW_API_REPORT_DFLT_CFG_MAJ ) {
4504+ if (hw -> api_min_ver > ICE_FW_API_REPORT_DFLT_CFG_MIN )
4505+ return true;
4506+ if (hw -> api_min_ver == ICE_FW_API_REPORT_DFLT_CFG_MIN &&
4507+ hw -> api_patch >= ICE_FW_API_REPORT_DFLT_CFG_PATCH )
4508+ return true;
4509+ } else if (hw -> api_maj_ver > ICE_FW_API_REPORT_DFLT_CFG_MAJ ) {
4510+ return true;
4511+ }
4512+ return false;
4513+ }
0 commit comments