|
3 | 3 | #include "bufferorch.h"
|
4 | 4 | #include "neighorch.h"
|
5 | 5 | #include "gearboxutils.h"
|
| 6 | +#include "vxlanorch.h" |
| 7 | +#include "directory.h" |
6 | 8 |
|
7 | 9 | #include <inttypes.h>
|
8 | 10 | #include <cassert>
|
@@ -42,6 +44,7 @@ extern NeighOrch *gNeighOrch;
|
42 | 44 | extern CrmOrch *gCrmOrch;
|
43 | 45 | extern BufferOrch *gBufferOrch;
|
44 | 46 | extern FdbOrch *gFdbOrch;
|
| 47 | +extern Directory<Orch*> gDirectory; |
45 | 48 |
|
46 | 49 | #define VLAN_PREFIX "Vlan"
|
47 | 50 | #define DEFAULT_VLAN_ID 1
|
@@ -1284,6 +1287,12 @@ bool PortsOrch::setPortPvid(Port &port, sai_uint32_t pvid)
|
1284 | 1287 | {
|
1285 | 1288 | SWSS_LOG_ENTER();
|
1286 | 1289 |
|
| 1290 | + if(port.m_type == Port::TUNNEL) |
| 1291 | + { |
| 1292 | + SWSS_LOG_ERROR("pvid setting for tunnel %s is not allowed", port.m_alias.c_str()); |
| 1293 | + return true; |
| 1294 | + } |
| 1295 | + |
1287 | 1296 | if (port.m_rif_id)
|
1288 | 1297 | {
|
1289 | 1298 | SWSS_LOG_ERROR("pvid setting for router interface %s is not allowed", port.m_alias.c_str());
|
@@ -1348,6 +1357,11 @@ bool PortsOrch::setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip)
|
1348 | 1357 | SWSS_LOG_ENTER();
|
1349 | 1358 | vector<Port> portv;
|
1350 | 1359 |
|
| 1360 | + if(port.m_type == Port::TUNNEL) |
| 1361 | + { |
| 1362 | + return true; |
| 1363 | + } |
| 1364 | + |
1351 | 1365 | /*
|
1352 | 1366 | * Before SAI_HOSTIF_VLAN_TAG_ORIGINAL is supported by libsai from all asic vendors,
|
1353 | 1367 | * the VLAN tag on hostif is explicitly controlled with SAI_HOSTIF_VLAN_TAG_STRIP &
|
@@ -1717,6 +1731,13 @@ void PortsOrch::updateDbPortOperStatus(const Port& port, sai_port_oper_status_t
|
1717 | 1731 | {
|
1718 | 1732 | SWSS_LOG_ENTER();
|
1719 | 1733 |
|
| 1734 | + if(port.m_type == Port::TUNNEL) |
| 1735 | + { |
| 1736 | + VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>(); |
| 1737 | + tunnel_orch->updateDbTunnelOperStatus(port.m_alias, status); |
| 1738 | + return; |
| 1739 | + } |
| 1740 | + |
1720 | 1741 | vector<FieldValueTuple> tuples;
|
1721 | 1742 | FieldValueTuple tuple("oper_status", oper_status_strings.at(status));
|
1722 | 1743 | tuples.push_back(tuple);
|
@@ -1809,7 +1830,7 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
|
1809 | 1830 | /* Determine if the port has already been initialized before */
|
1810 | 1831 | if (m_portList.find(alias) != m_portList.end() && m_portList[alias].m_port_id == id)
|
1811 | 1832 | {
|
1812 |
| - SWSS_LOG_DEBUG("Port has already been initialized before alias:%s", alias.c_str()); |
| 1833 | + SWSS_LOG_INFO("Port has already been initialized before alias:%s", alias.c_str()); |
1813 | 1834 | }
|
1814 | 1835 | else
|
1815 | 1836 | {
|
@@ -1853,7 +1874,7 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
|
1853 | 1874 |
|
1854 | 1875 | m_portList[alias].m_init = true;
|
1855 | 1876 |
|
1856 |
| - SWSS_LOG_NOTICE("Initialized port %s", alias.c_str()); |
| 1877 | + SWSS_LOG_ERROR("Initialized port %s", alias.c_str()); |
1857 | 1878 | }
|
1858 | 1879 | else
|
1859 | 1880 | {
|
@@ -3333,26 +3354,46 @@ bool PortsOrch::addBridgePort(Port &port)
|
3333 | 3354 | sai_attribute_t attr;
|
3334 | 3355 | vector<sai_attribute_t> attrs;
|
3335 | 3356 |
|
3336 |
| - attr.id = SAI_BRIDGE_PORT_ATTR_TYPE; |
3337 |
| - attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT; |
3338 |
| - attrs.push_back(attr); |
3339 |
| - |
3340 |
| - attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID; |
3341 | 3357 | if (port.m_type == Port::PHY)
|
3342 | 3358 | {
|
| 3359 | + attr.id = SAI_BRIDGE_PORT_ATTR_TYPE; |
| 3360 | + attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT; |
| 3361 | + attrs.push_back(attr); |
| 3362 | + |
| 3363 | + attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID; |
3343 | 3364 | attr.value.oid = port.m_port_id;
|
| 3365 | + attrs.push_back(attr); |
3344 | 3366 | }
|
3345 | 3367 | else if (port.m_type == Port::LAG)
|
3346 | 3368 | {
|
| 3369 | + attr.id = SAI_BRIDGE_PORT_ATTR_TYPE; |
| 3370 | + attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT; |
| 3371 | + attrs.push_back(attr); |
| 3372 | + |
| 3373 | + attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID; |
3347 | 3374 | attr.value.oid = port.m_lag_id;
|
| 3375 | + attrs.push_back(attr); |
| 3376 | + } |
| 3377 | + else if (port.m_type == Port::TUNNEL) |
| 3378 | + { |
| 3379 | + attr.id = SAI_BRIDGE_PORT_ATTR_TYPE; |
| 3380 | + attr.value.s32 = SAI_BRIDGE_PORT_TYPE_TUNNEL; |
| 3381 | + attrs.push_back(attr); |
| 3382 | + |
| 3383 | + attr.id = SAI_BRIDGE_PORT_ATTR_TUNNEL_ID; |
| 3384 | + attr.value.oid = port.m_tunnel_id; |
| 3385 | + attrs.push_back(attr); |
| 3386 | + |
| 3387 | + attr.id = SAI_BRIDGE_PORT_ATTR_BRIDGE_ID; |
| 3388 | + attr.value.oid = m_default1QBridge; |
| 3389 | + attrs.push_back(attr); |
3348 | 3390 | }
|
3349 | 3391 | else
|
3350 | 3392 | {
|
3351 |
| - SWSS_LOG_ERROR("Failed to add bridge port %s to default 1Q bridge, invalid porty type %d", |
| 3393 | + SWSS_LOG_ERROR("Failed to add bridge port %s to default 1Q bridge, invalid port type %d", |
3352 | 3394 | port.m_alias.c_str(), port.m_type);
|
3353 | 3395 | return false;
|
3354 | 3396 | }
|
3355 |
| - attrs.push_back(attr); |
3356 | 3397 |
|
3357 | 3398 | /* Create a bridge port with admin status set to UP */
|
3358 | 3399 | attr.id = SAI_BRIDGE_PORT_ATTR_ADMIN_STATE;
|
@@ -3522,6 +3563,14 @@ bool PortsOrch::removeVlan(Port vlan)
|
3522 | 3563 | return false;
|
3523 | 3564 | }
|
3524 | 3565 |
|
| 3566 | + // Fail VLAN removal if there is a vnid associated |
| 3567 | + if (vlan.m_vnid != VNID_NONE) |
| 3568 | + { |
| 3569 | + SWSS_LOG_ERROR("VLAN-VNI mapping not yet removed. VLAN %s VNI %d", |
| 3570 | + vlan.m_alias.c_str(), vlan.m_vnid); |
| 3571 | + return false; |
| 3572 | + } |
| 3573 | + |
3525 | 3574 | sai_status_t status = sai_vlan_api->remove_vlan(vlan.m_vlan_info.vlan_oid);
|
3526 | 3575 | if (status != SAI_STATUS_SUCCESS)
|
3527 | 3576 | {
|
@@ -3660,6 +3709,14 @@ bool PortsOrch::removeVlanMember(Port &vlan, Port &port)
|
3660 | 3709 | return true;
|
3661 | 3710 | }
|
3662 | 3711 |
|
| 3712 | +bool PortsOrch::isVlanMember(Port &vlan, Port &port) |
| 3713 | +{ |
| 3714 | + if (vlan.m_members.find(port.m_alias) == vlan.m_members.end()) |
| 3715 | + return false; |
| 3716 | + |
| 3717 | + return true; |
| 3718 | +} |
| 3719 | + |
3663 | 3720 | bool PortsOrch::addLag(string lag_alias)
|
3664 | 3721 | {
|
3665 | 3722 | SWSS_LOG_ENTER();
|
@@ -3908,6 +3965,36 @@ bool PortsOrch::setDistributionOnLagMember(Port &lagMember, bool enableDistribut
|
3908 | 3965 | return true;
|
3909 | 3966 | }
|
3910 | 3967 |
|
| 3968 | +bool PortsOrch::addTunnel(string tunnel_alias, sai_object_id_t tunnel_id, bool hwlearning) |
| 3969 | +{ |
| 3970 | + SWSS_LOG_ENTER(); |
| 3971 | + |
| 3972 | + Port tunnel(tunnel_alias, Port::TUNNEL); |
| 3973 | + tunnel.m_tunnel_id = tunnel_id; |
| 3974 | + if (hwlearning) |
| 3975 | + { |
| 3976 | + tunnel.m_learn_mode = "hardware"; |
| 3977 | + } |
| 3978 | + else |
| 3979 | + { |
| 3980 | + tunnel.m_learn_mode = "disable"; |
| 3981 | + } |
| 3982 | + m_portList[tunnel_alias] = tunnel; |
| 3983 | + |
| 3984 | + SWSS_LOG_INFO("addTunnel:: %" PRIx64, tunnel_id); |
| 3985 | + |
| 3986 | + return true; |
| 3987 | +} |
| 3988 | + |
| 3989 | +bool PortsOrch::removeTunnel(Port tunnel) |
| 3990 | +{ |
| 3991 | + SWSS_LOG_ENTER(); |
| 3992 | + |
| 3993 | + m_portList.erase(tunnel.m_alias); |
| 3994 | + |
| 3995 | + return true; |
| 3996 | +} |
| 3997 | + |
3911 | 3998 | void PortsOrch::generateQueueMap()
|
3912 | 3999 | {
|
3913 | 4000 | if (m_isQueueMapGenerated)
|
@@ -4116,6 +4203,11 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
|
4116 | 4203 | }
|
4117 | 4204 | port.m_oper_status = status;
|
4118 | 4205 |
|
| 4206 | + if(port.m_type == Port::TUNNEL) |
| 4207 | + { |
| 4208 | + return; |
| 4209 | + } |
| 4210 | + |
4119 | 4211 | bool isUp = status == SAI_PORT_OPER_STATUS_UP;
|
4120 | 4212 | if (port.m_type == Port::PHY)
|
4121 | 4213 | {
|
|
0 commit comments