@@ -968,6 +968,36 @@ bool PortsOrch::setPortMtu(sai_object_id_t id, sai_uint32_t mtu)
968968 return true ;
969969}
970970
971+
972+ bool PortsOrch::setPortTpid (sai_object_id_t id, sai_uint16_t tpid)
973+ {
974+ SWSS_LOG_ENTER ();
975+ sai_status_t status = SAI_STATUS_SUCCESS;
976+ sai_attribute_t attr;
977+
978+ attr.id = SAI_PORT_ATTR_TPID;
979+
980+ attr.value .u16 = (uint16_t )tpid;
981+
982+ status = sai_port_api->set_port_attribute (id, &attr);
983+ if (status != SAI_STATUS_SUCCESS)
984+ {
985+ SWSS_LOG_ERROR (" Failed to set TPID 0x%x to port pid:%" PRIx64 " , rv:%d" ,
986+ attr.value .u16 , id, status);
987+ task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
988+ if (handle_status != task_success)
989+ {
990+ return parseHandleSaiStatusFailure (handle_status);
991+ }
992+ }
993+ else
994+ {
995+ SWSS_LOG_NOTICE (" Set TPID 0x%x to port pid:%" PRIx64, attr.value .u16 , id);
996+ }
997+ return true ;
998+ }
999+
1000+
9711001bool PortsOrch::setPortFec (Port &port, sai_port_fec_mode_t mode)
9721002{
9731003 SWSS_LOG_ENTER ();
@@ -2451,6 +2481,8 @@ void PortsOrch::doPortTask(Consumer &consumer)
24512481 vector<uint32_t > adv_speeds;
24522482 sai_port_interface_type_t interface_type;
24532483 vector<uint32_t > adv_interface_types;
2484+ string tpid_string;
2485+ uint16_t tpid = 0 ;
24542486
24552487 for (auto i : kfvFieldsValues (t))
24562488 {
@@ -2482,6 +2514,15 @@ void PortsOrch::doPortTask(Consumer &consumer)
24822514 {
24832515 mtu = (uint32_t )stoul (fvValue (i));
24842516 }
2517+ /* Set port TPID */
2518+ if (fvField (i) == " tpid" )
2519+ {
2520+ tpid_string = fvValue (i);
2521+ // Need to get rid of the leading 0x
2522+ tpid_string.erase (0 ,2 );
2523+ tpid = (uint16_t )stoi (tpid_string, 0 , 16 );
2524+ SWSS_LOG_DEBUG (" Handling TPID to 0x%x, string value:%s" , tpid, tpid_string.c_str ());
2525+ }
24852526 /* Set port speed */
24862527 else if (fvField (i) == " speed" )
24872528 {
@@ -2914,6 +2955,22 @@ void PortsOrch::doPortTask(Consumer &consumer)
29142955 }
29152956 }
29162957
2958+ if (tpid != 0 && tpid != p.m_tpid )
2959+ {
2960+ SWSS_LOG_DEBUG (" Set port %s TPID to 0x%x" , alias.c_str (), tpid);
2961+ if (setPortTpid (p.m_port_id , tpid))
2962+ {
2963+ p.m_tpid = tpid;
2964+ m_portList[alias] = p;
2965+ }
2966+ else
2967+ {
2968+ SWSS_LOG_ERROR (" Failed to set port %s TPID to 0x%x" , alias.c_str (), tpid);
2969+ it++;
2970+ continue ;
2971+ }
2972+ }
2973+
29172974 if (!fec_mode.empty ())
29182975 {
29192976 if (fec_mode_map.find (fec_mode) != fec_mode_map.end ())
@@ -3366,6 +3423,8 @@ void PortsOrch::doLagTask(Consumer &consumer)
33663423 string operation_status;
33673424 uint32_t lag_id = 0 ;
33683425 int32_t switch_id = -1 ;
3426+ string tpid_string;
3427+ uint16_t tpid = 0 ;
33693428
33703429 for (auto i : kfvFieldsValues (t))
33713430 {
@@ -3395,6 +3454,14 @@ void PortsOrch::doLagTask(Consumer &consumer)
33953454 {
33963455 switch_id = stoi (fvValue (i));
33973456 }
3457+ else if (fvField (i) == " tpid" )
3458+ {
3459+ tpid_string = fvValue (i);
3460+ // Need to get rid of the leading 0x
3461+ tpid_string.erase (0 ,2 );
3462+ tpid = (uint16_t )stoi (tpid_string, 0 , 16 );
3463+ SWSS_LOG_DEBUG (" reading TPID string:%s to uint16: 0x%x" , tpid_string.c_str (), tpid);
3464+ }
33983465 }
33993466
34003467 if (table_name == CHASSIS_APP_LAG_TABLE_NAME)
@@ -3451,6 +3518,23 @@ void PortsOrch::doLagTask(Consumer &consumer)
34513518 updateChildPortsMtu (l, mtu);
34523519 }
34533520
3521+ if (tpid != 0 )
3522+ {
3523+ if (tpid != l.m_tpid )
3524+ {
3525+ if (!setLagTpid (l.m_lag_id , tpid))
3526+ {
3527+ SWSS_LOG_ERROR (" Failed to set LAG %s TPID 0x%x" , alias.c_str (), tpid);
3528+ }
3529+ else
3530+ {
3531+ SWSS_LOG_DEBUG (" Set LAG %s TPID to 0x%x" , alias.c_str (), tpid);
3532+ l.m_tpid = tpid;
3533+ m_portList[alias] = l;
3534+ }
3535+ }
3536+ }
3537+
34543538 if (!learn_mode.empty () && (l.m_learn_mode != learn_mode))
34553539 {
34563540 if (l.m_bridge_port_id != SAI_NULL_OBJECT_ID)
@@ -4656,6 +4740,35 @@ bool PortsOrch::removeLagMember(Port &lag, Port &port)
46564740 return true ;
46574741}
46584742
4743+ bool PortsOrch::setLagTpid (sai_object_id_t id, sai_uint16_t tpid)
4744+ {
4745+ SWSS_LOG_ENTER ();
4746+ sai_status_t status = SAI_STATUS_SUCCESS;
4747+ sai_attribute_t attr;
4748+
4749+ attr.id = SAI_LAG_ATTR_TPID;
4750+
4751+ attr.value .u16 = (uint16_t )tpid;
4752+
4753+ status = sai_lag_api->set_lag_attribute (id, &attr);
4754+ if (status != SAI_STATUS_SUCCESS)
4755+ {
4756+ SWSS_LOG_ERROR (" Failed to set TPID 0x%x to LAG pid:%" PRIx64 " , rv:%d" ,
4757+ attr.value .u16 , id, status);
4758+ task_process_status handle_status = handleSaiSetStatus (SAI_API_LAG, status);
4759+ if (handle_status != task_success)
4760+ {
4761+ return parseHandleSaiStatusFailure (handle_status);
4762+ }
4763+ }
4764+ else
4765+ {
4766+ SWSS_LOG_NOTICE (" Set TPID 0x%x to LAG pid:%" PRIx64 , attr.value .u16 , id);
4767+ }
4768+ return true ;
4769+ }
4770+
4771+
46594772bool PortsOrch::setCollectionOnLagMember (Port &lagMember, bool enableCollection)
46604773{
46614774 /* Port must be LAG member */
0 commit comments