Skip to content

Commit c37dd67

Browse files
pkitszelanguy11
authored andcommitted
ice: c827: move wait for FW to ice_init_hw()
Move call to ice_wait_for_fw() from ice_init_dev() into ice_init_hw(), where it fits better. This requires also to move ice_wait_for_fw() to ice_common.c. ice_is_pf_c827() is now used only in ice_common.c, so it could be static. CC: Arkadiusz Kubalewski <[email protected]> Reviewed-by: Marcin Szycik <[email protected]> Signed-off-by: Przemek Kitszel <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 9c7ad35 commit c37dd67

File tree

3 files changed

+75
-73
lines changed

3 files changed

+75
-73
lines changed

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 75 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,42 @@ bool ice_is_e825c(struct ice_hw *hw)
308308
}
309309
}
310310

311+
/**
312+
* ice_is_pf_c827 - check if pf contains c827 phy
313+
* @hw: pointer to the hw struct
314+
*
315+
* Return: true if the device has c827 phy.
316+
*/
317+
static bool ice_is_pf_c827(struct ice_hw *hw)
318+
{
319+
struct ice_aqc_get_link_topo cmd = {};
320+
u8 node_part_number;
321+
u16 node_handle;
322+
int status;
323+
324+
if (hw->mac_type != ICE_MAC_E810)
325+
return false;
326+
327+
if (hw->device_id != ICE_DEV_ID_E810C_QSFP)
328+
return true;
329+
330+
cmd.addr.topo_params.node_type_ctx =
331+
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_TYPE_M, ICE_AQC_LINK_TOPO_NODE_TYPE_PHY) |
332+
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_CTX_M, ICE_AQC_LINK_TOPO_NODE_CTX_PORT);
333+
cmd.addr.topo_params.index = 0;
334+
335+
status = ice_aq_get_netlist_node(hw, &cmd, &node_part_number,
336+
&node_handle);
337+
338+
if (status || node_part_number != ICE_AQC_GET_LINK_TOPO_NODE_NR_C827)
339+
return false;
340+
341+
if (node_handle == E810C_QSFP_C827_0_HANDLE || node_handle == E810C_QSFP_C827_1_HANDLE)
342+
return true;
343+
344+
return false;
345+
}
346+
311347
/**
312348
* ice_clear_pf_cfg - Clear PF configuration
313349
* @hw: pointer to the hardware structure
@@ -1025,6 +1061,33 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
10251061
}
10261062
}
10271063

1064+
/**
1065+
* ice_wait_for_fw - wait for full FW readiness
1066+
* @hw: pointer to the hardware structure
1067+
* @timeout: milliseconds that can elapse before timing out
1068+
*
1069+
* Return: 0 on success, -ETIMEDOUT on timeout.
1070+
*/
1071+
static int ice_wait_for_fw(struct ice_hw *hw, u32 timeout)
1072+
{
1073+
int fw_loading;
1074+
u32 elapsed = 0;
1075+
1076+
while (elapsed <= timeout) {
1077+
fw_loading = rd32(hw, GL_MNG_FWSM) & GL_MNG_FWSM_FW_LOADING_M;
1078+
1079+
/* firmware was not yet loaded, we have to wait more */
1080+
if (fw_loading) {
1081+
elapsed += 100;
1082+
msleep(100);
1083+
continue;
1084+
}
1085+
return 0;
1086+
}
1087+
1088+
return -ETIMEDOUT;
1089+
}
1090+
10281091
/**
10291092
* ice_init_hw - main hardware initialization routine
10301093
* @hw: pointer to the hardware structure
@@ -1174,8 +1237,19 @@ int ice_init_hw(struct ice_hw *hw)
11741237
mutex_init(&hw->tnl_lock);
11751238
ice_init_chk_recipe_reuse_support(hw);
11761239

1177-
return 0;
1240+
/* Some cards require longer initialization times
1241+
* due to necessity of loading FW from an external source.
1242+
* This can take even half a minute.
1243+
*/
1244+
if (ice_is_pf_c827(hw)) {
1245+
status = ice_wait_for_fw(hw, 30000);
1246+
if (status) {
1247+
dev_err(ice_hw_to_dev(hw), "ice_wait_for_fw timed out");
1248+
goto err_unroll_fltr_mgmt_struct;
1249+
}
1250+
}
11781251

1252+
return 0;
11791253
err_unroll_fltr_mgmt_struct:
11801254
ice_cleanup_fltr_mgmt_struct(hw);
11811255
err_unroll_sched:
@@ -2728,40 +2802,6 @@ ice_parse_dev_caps(struct ice_hw *hw, struct ice_hw_dev_caps *dev_p,
27282802
ice_recalc_port_limited_caps(hw, &dev_p->common_cap);
27292803
}
27302804

2731-
/**
2732-
* ice_is_pf_c827 - check if pf contains c827 phy
2733-
* @hw: pointer to the hw struct
2734-
*/
2735-
bool ice_is_pf_c827(struct ice_hw *hw)
2736-
{
2737-
struct ice_aqc_get_link_topo cmd = {};
2738-
u8 node_part_number;
2739-
u16 node_handle;
2740-
int status;
2741-
2742-
if (hw->mac_type != ICE_MAC_E810)
2743-
return false;
2744-
2745-
if (hw->device_id != ICE_DEV_ID_E810C_QSFP)
2746-
return true;
2747-
2748-
cmd.addr.topo_params.node_type_ctx =
2749-
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_TYPE_M, ICE_AQC_LINK_TOPO_NODE_TYPE_PHY) |
2750-
FIELD_PREP(ICE_AQC_LINK_TOPO_NODE_CTX_M, ICE_AQC_LINK_TOPO_NODE_CTX_PORT);
2751-
cmd.addr.topo_params.index = 0;
2752-
2753-
status = ice_aq_get_netlist_node(hw, &cmd, &node_part_number,
2754-
&node_handle);
2755-
2756-
if (status || node_part_number != ICE_AQC_GET_LINK_TOPO_NODE_NR_C827)
2757-
return false;
2758-
2759-
if (node_handle == E810C_QSFP_C827_0_HANDLE || node_handle == E810C_QSFP_C827_1_HANDLE)
2760-
return true;
2761-
2762-
return false;
2763-
}
2764-
27652805
/**
27662806
* ice_is_phy_rclk_in_netlist
27672807
* @hw: pointer to the hw struct

drivers/net/ethernet/intel/ice/ice_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ int
112112
ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
113113
struct ice_aqc_get_phy_caps_data *caps,
114114
struct ice_sq_cd *cd);
115-
bool ice_is_pf_c827(struct ice_hw *hw);
116115
bool ice_is_phy_rclk_in_netlist(struct ice_hw *hw);
117116
bool ice_is_clock_mux_in_netlist(struct ice_hw *hw);
118117
bool ice_is_cgu_in_netlist(struct ice_hw *hw);

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,31 +4749,6 @@ static void ice_decfg_netdev(struct ice_vsi *vsi)
47494749
vsi->netdev = NULL;
47504750
}
47514751

4752-
/**
4753-
* ice_wait_for_fw - wait for full FW readiness
4754-
* @hw: pointer to the hardware structure
4755-
* @timeout: milliseconds that can elapse before timing out
4756-
*/
4757-
static int ice_wait_for_fw(struct ice_hw *hw, u32 timeout)
4758-
{
4759-
int fw_loading;
4760-
u32 elapsed = 0;
4761-
4762-
while (elapsed <= timeout) {
4763-
fw_loading = rd32(hw, GL_MNG_FWSM) & GL_MNG_FWSM_FW_LOADING_M;
4764-
4765-
/* firmware was not yet loaded, we have to wait more */
4766-
if (fw_loading) {
4767-
elapsed += 100;
4768-
msleep(100);
4769-
continue;
4770-
}
4771-
return 0;
4772-
}
4773-
4774-
return -ETIMEDOUT;
4775-
}
4776-
47774752
int ice_init_dev(struct ice_pf *pf)
47784753
{
47794754
struct device *dev = ice_pf_to_dev(pf);
@@ -4786,18 +4761,6 @@ int ice_init_dev(struct ice_pf *pf)
47864761
return err;
47874762
}
47884763

4789-
/* Some cards require longer initialization times
4790-
* due to necessity of loading FW from an external source.
4791-
* This can take even half a minute.
4792-
*/
4793-
if (ice_is_pf_c827(hw)) {
4794-
err = ice_wait_for_fw(hw, 30000);
4795-
if (err) {
4796-
dev_err(dev, "ice_wait_for_fw timed out");
4797-
return err;
4798-
}
4799-
}
4800-
48014764
ice_init_feature_support(pf);
48024765

48034766
err = ice_init_ddp_config(hw, pf);

0 commit comments

Comments
 (0)