@@ -1919,7 +1919,7 @@ bool PortsOrch::setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_p
1919
1919
return true ;
1920
1920
}
1921
1921
1922
- bool PortsOrch::setPortSpeed (Port &port, sai_uint32_t speed)
1922
+ task_process_status PortsOrch::setPortSpeed (Port &port, sai_uint32_t speed)
1923
1923
{
1924
1924
sai_attribute_t attr;
1925
1925
sai_status_t status;
@@ -1932,15 +1932,11 @@ bool PortsOrch::setPortSpeed(Port &port, sai_uint32_t speed)
1932
1932
status = sai_port_api->set_port_attribute (port.m_port_id , &attr);
1933
1933
if (status != SAI_STATUS_SUCCESS)
1934
1934
{
1935
- task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
1936
- if (handle_status != task_success)
1937
- {
1938
- return parseHandleSaiStatusFailure (handle_status);
1939
- }
1935
+ return handleSaiSetStatus (SAI_API_PORT, status);
1940
1936
}
1941
1937
1942
1938
setGearboxPortsAttr (port, SAI_PORT_ATTR_SPEED, &speed);
1943
- return true ;
1939
+ return task_success ;
1944
1940
}
1945
1941
1946
1942
bool PortsOrch::getPortSpeed (sai_object_id_t id, sai_uint32_t &speed)
@@ -1973,7 +1969,7 @@ bool PortsOrch::getPortSpeed(sai_object_id_t id, sai_uint32_t &speed)
1973
1969
return true ;
1974
1970
}
1975
1971
1976
- bool PortsOrch::setPortAdvSpeeds (sai_object_id_t port_id, std::vector<sai_uint32_t >& speed_list)
1972
+ task_process_status PortsOrch::setPortAdvSpeeds (sai_object_id_t port_id, std::vector<sai_uint32_t >& speed_list)
1977
1973
{
1978
1974
SWSS_LOG_ENTER ();
1979
1975
sai_attribute_t attr;
@@ -1984,11 +1980,15 @@ bool PortsOrch::setPortAdvSpeeds(sai_object_id_t port_id, std::vector<sai_uint32
1984
1980
attr.value .u32list .count = static_cast <uint32_t >(speed_list.size ());
1985
1981
1986
1982
status = sai_port_api->set_port_attribute (port_id, &attr);
1983
+ if (status != SAI_STATUS_SUCCESS)
1984
+ {
1985
+ return handleSaiSetStatus (SAI_API_PORT, status);
1986
+ }
1987
1987
1988
- return status == SAI_STATUS_SUCCESS ;
1988
+ return task_success ;
1989
1989
}
1990
1990
1991
- bool PortsOrch::setPortInterfaceType (sai_object_id_t port_id, sai_port_interface_type_t interface_type)
1991
+ task_process_status PortsOrch::setPortInterfaceType (sai_object_id_t port_id, sai_port_interface_type_t interface_type)
1992
1992
{
1993
1993
SWSS_LOG_ENTER ();
1994
1994
sai_attribute_t attr;
@@ -1998,11 +1998,15 @@ bool PortsOrch::setPortInterfaceType(sai_object_id_t port_id, sai_port_interface
1998
1998
attr.value .u32 = static_cast <uint32_t >(interface_type);
1999
1999
2000
2000
status = sai_port_api->set_port_attribute (port_id, &attr);
2001
+ if (status != SAI_STATUS_SUCCESS)
2002
+ {
2003
+ return handleSaiSetStatus (SAI_API_PORT, status);
2004
+ }
2001
2005
2002
- return status == SAI_STATUS_SUCCESS ;
2006
+ return task_success ;
2003
2007
}
2004
2008
2005
- bool PortsOrch::setPortAdvInterfaceTypes (sai_object_id_t port_id, std::vector<uint32_t > &interface_types)
2009
+ task_process_status PortsOrch::setPortAdvInterfaceTypes (sai_object_id_t port_id, std::vector<uint32_t > &interface_types)
2006
2010
{
2007
2011
SWSS_LOG_ENTER ();
2008
2012
sai_attribute_t attr;
@@ -2015,14 +2019,10 @@ bool PortsOrch::setPortAdvInterfaceTypes(sai_object_id_t port_id, std::vector<ui
2015
2019
status = sai_port_api->set_port_attribute (port_id, &attr);
2016
2020
if (status != SAI_STATUS_SUCCESS)
2017
2021
{
2018
- task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
2019
- if (handle_status != task_success)
2020
- {
2021
- return parseHandleSaiStatusFailure (handle_status);
2022
- }
2022
+ return handleSaiSetStatus (SAI_API_PORT, status);
2023
2023
}
2024
2024
2025
- return true ;
2025
+ return task_success ;
2026
2026
}
2027
2027
2028
2028
bool PortsOrch::getQueueTypeAndIndex (sai_object_id_t queue_id, string &type, uint8_t &index)
@@ -2065,33 +2065,22 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin
2065
2065
return true ;
2066
2066
}
2067
2067
2068
- bool PortsOrch::setPortAutoNeg (sai_object_id_t id, int an)
2068
+ task_process_status PortsOrch::setPortAutoNeg (sai_object_id_t id, int an)
2069
2069
{
2070
2070
SWSS_LOG_ENTER ();
2071
2071
2072
2072
sai_attribute_t attr;
2073
2073
attr.id = SAI_PORT_ATTR_AUTO_NEG_MODE;
2074
- switch (an) {
2075
- case 1 :
2076
- attr.value .booldata = true ;
2077
- break ;
2078
- default :
2079
- attr.value .booldata = false ;
2080
- break ;
2081
- }
2074
+ attr.value .booldata = (an == 1 ? true : false );
2082
2075
2083
2076
sai_status_t status = sai_port_api->set_port_attribute (id, &attr);
2084
2077
if (status != SAI_STATUS_SUCCESS)
2085
2078
{
2086
2079
SWSS_LOG_ERROR (" Failed to set AutoNeg %u to port pid:%" PRIx64, attr.value .booldata , id);
2087
- task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
2088
- if (handle_status != task_success)
2089
- {
2090
- return parseHandleSaiStatusFailure (handle_status);
2091
- }
2080
+ return handleSaiSetStatus (SAI_API_PORT, status);
2092
2081
}
2093
2082
SWSS_LOG_INFO (" Set AutoNeg %u to port pid:%" PRIx64, attr.value .booldata , id);
2094
- return true ;
2083
+ return task_success ;
2095
2084
}
2096
2085
2097
2086
bool PortsOrch::setHostIntfsOperStatus (const Port& port, bool isUp) const
@@ -2827,18 +2816,23 @@ void PortsOrch::doPortTask(Consumer &consumer)
2827
2816
m_portList[alias] = p;
2828
2817
}
2829
2818
2830
- if (setPortAutoNeg (p.m_port_id , an))
2831
- {
2832
- SWSS_LOG_NOTICE (" Set port %s AutoNeg from %d to %d" , alias.c_str (), p.m_autoneg , an);
2833
- p.m_autoneg = an;
2834
- m_portList[alias] = p;
2835
- }
2836
- else
2819
+ auto status = setPortAutoNeg (p.m_port_id , an);
2820
+ if (status != task_success)
2837
2821
{
2838
2822
SWSS_LOG_ERROR (" Failed to set port %s AN from %d to %d" , alias.c_str (), p.m_autoneg , an);
2839
- it++;
2823
+ if (status == task_need_retry)
2824
+ {
2825
+ it++;
2826
+ }
2827
+ else
2828
+ {
2829
+ it = consumer.m_toSync .erase (it);
2830
+ }
2840
2831
continue ;
2841
2832
}
2833
+ SWSS_LOG_NOTICE (" Set port %s AutoNeg from %d to %d" , alias.c_str (), p.m_autoneg , an);
2834
+ p.m_autoneg = an;
2835
+ m_portList[alias] = p;
2842
2836
}
2843
2837
}
2844
2838
@@ -2869,10 +2863,18 @@ void PortsOrch::doPortTask(Consumer &consumer)
2869
2863
m_portList[alias] = p;
2870
2864
}
2871
2865
2872
- if (!setPortSpeed (p, speed))
2866
+ auto status = setPortSpeed (p, speed);
2867
+ if (status != task_success)
2873
2868
{
2874
2869
SWSS_LOG_ERROR (" Failed to set port %s speed from %u to %u" , alias.c_str (), p.m_speed , speed);
2875
- it++;
2870
+ if (status == task_need_retry)
2871
+ {
2872
+ it++;
2873
+ }
2874
+ else
2875
+ {
2876
+ it = consumer.m_toSync .erase (it);
2877
+ }
2876
2878
continue ;
2877
2879
}
2878
2880
@@ -2914,13 +2916,21 @@ void PortsOrch::doPortTask(Consumer &consumer)
2914
2916
}
2915
2917
2916
2918
auto ori_adv_speeds = swss::join (' ,' , p.m_adv_speeds .begin (), p.m_adv_speeds .end ());
2917
- if (!setPortAdvSpeeds (p.m_port_id , adv_speeds))
2919
+ auto status = setPortAdvSpeeds (p.m_port_id , adv_speeds);
2920
+ if (status != task_success)
2918
2921
{
2919
2922
2920
2923
SWSS_LOG_ERROR (" Failed to set port %s advertised speed from %s to %s" , alias.c_str (),
2921
2924
ori_adv_speeds.c_str (),
2922
2925
adv_speeds_str.c_str ());
2923
- it++;
2926
+ if (status == task_need_retry)
2927
+ {
2928
+ it++;
2929
+ }
2930
+ else
2931
+ {
2932
+ it = consumer.m_toSync .erase (it);
2933
+ }
2924
2934
continue ;
2925
2935
}
2926
2936
SWSS_LOG_NOTICE (" Set port %s advertised speed from %s to %s" , alias.c_str (),
@@ -2957,10 +2967,18 @@ void PortsOrch::doPortTask(Consumer &consumer)
2957
2967
m_portList[alias] = p;
2958
2968
}
2959
2969
2960
- if (!setPortInterfaceType (p.m_port_id , interface_type))
2970
+ auto status = setPortInterfaceType (p.m_port_id , interface_type);
2971
+ if (status != task_success)
2961
2972
{
2962
2973
SWSS_LOG_ERROR (" Failed to set port %s interface type to %s" , alias.c_str (), interface_type_str.c_str ());
2963
- it++;
2974
+ if (status == task_need_retry)
2975
+ {
2976
+ it++;
2977
+ }
2978
+ else
2979
+ {
2980
+ it = consumer.m_toSync .erase (it);
2981
+ }
2964
2982
continue ;
2965
2983
}
2966
2984
@@ -2996,10 +3014,18 @@ void PortsOrch::doPortTask(Consumer &consumer)
2996
3014
m_portList[alias] = p;
2997
3015
}
2998
3016
2999
- if (!setPortAdvInterfaceTypes (p.m_port_id , adv_interface_types))
3017
+ auto status = setPortAdvInterfaceTypes (p.m_port_id , adv_interface_types);
3018
+ if (status != task_success)
3000
3019
{
3001
3020
SWSS_LOG_ERROR (" Failed to set port %s advertised interface type to %s" , alias.c_str (), adv_interface_types_str.c_str ());
3002
- it++;
3021
+ if (status == task_need_retry)
3022
+ {
3023
+ it++;
3024
+ }
3025
+ else
3026
+ {
3027
+ it = consumer.m_toSync .erase (it);
3028
+ }
3003
3029
continue ;
3004
3030
}
3005
3031
0 commit comments