@@ -2365,7 +2365,13 @@ ice_get_set_tx_topo(struct ice_hw *hw, u8 *buf, u16 buf_size,
23652365 * The function will apply the new Tx topology from the package buffer
23662366 * if available.
23672367 *
2368- * Return: zero when update was successful, negative values otherwise.
2368+ * Return:
2369+ * * 0 - Successfully applied topology configuration.
2370+ * * -EBUSY - Failed to acquire global configuration lock.
2371+ * * -EEXIST - Topology configuration has already been applied.
2372+ * * -EIO - Unable to apply topology configuration.
2373+ * * -ENODEV - Failed to re-initialize device after applying configuration.
2374+ * * Other negative error codes indicate unexpected failures.
23692375 */
23702376int ice_cfg_tx_topo (struct ice_hw * hw , const void * buf , u32 len )
23712377{
@@ -2398,7 +2404,7 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
23982404
23992405 if (status ) {
24002406 ice_debug (hw , ICE_DBG_INIT , "Get current topology is failed\n" );
2401- return status ;
2407+ return - EIO ;
24022408 }
24032409
24042410 /* Is default topology already applied ? */
@@ -2485,31 +2491,45 @@ int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len)
24852491 ICE_GLOBAL_CFG_LOCK_TIMEOUT );
24862492 if (status ) {
24872493 ice_debug (hw , ICE_DBG_INIT , "Failed to acquire global lock\n" );
2488- return status ;
2494+ return - EBUSY ;
24892495 }
24902496
24912497 /* Check if reset was triggered already. */
24922498 reg = rd32 (hw , GLGEN_RSTAT );
24932499 if (reg & GLGEN_RSTAT_DEVSTATE_M ) {
2494- /* Reset is in progress, re-init the HW again */
24952500 ice_debug (hw , ICE_DBG_INIT , "Reset is in progress. Layer topology might be applied already\n" );
24962501 ice_check_reset (hw );
2497- return 0 ;
2502+ /* Reset is in progress, re-init the HW again */
2503+ goto reinit_hw ;
24982504 }
24992505
25002506 /* Set new topology */
25012507 status = ice_get_set_tx_topo (hw , new_topo , size , NULL , NULL , true);
25022508 if (status ) {
2503- ice_debug (hw , ICE_DBG_INIT , "Failed setting Tx topology\n" );
2504- return status ;
2509+ ice_debug (hw , ICE_DBG_INIT , "Failed to set Tx topology, status %pe\n" ,
2510+ ERR_PTR (status ));
2511+ /* only report -EIO here as the caller checks the error value
2512+ * and reports an informational error message informing that
2513+ * the driver failed to program Tx topology.
2514+ */
2515+ status = - EIO ;
25052516 }
25062517
2507- /* New topology is updated, delay 1 second before issuing the CORER */
2518+ /* Even if Tx topology config failed, we need to CORE reset here to
2519+ * clear the global configuration lock. Delay 1 second to allow
2520+ * hardware to settle then issue a CORER
2521+ */
25082522 msleep (1000 );
25092523 ice_reset (hw , ICE_RESET_CORER );
2510- /* CORER will clear the global lock, so no explicit call
2511- * required for release.
2512- */
2524+ ice_check_reset (hw );
2525+
2526+ reinit_hw :
2527+ /* Since we triggered a CORER, re-initialize hardware */
2528+ ice_deinit_hw (hw );
2529+ if (ice_init_hw (hw )) {
2530+ ice_debug (hw , ICE_DBG_INIT , "Failed to re-init hardware after setting Tx topology\n" );
2531+ return - ENODEV ;
2532+ }
25132533
2514- return 0 ;
2534+ return status ;
25152535}
0 commit comments