Skip to content

Commit 095f481

Browse files
srj102tapashdas
andauthored
[Orchagent] Vxlanorch and Portsorch changes for EVPN VXLAN (sonic-net#1264)
* https://github.com/Azure/SONiC/pull/437/commits 1. Existing code supports a single mapper type to be created. Either BRIDGE or VRF type mappers are supported. Change to support multiple mapper type creations is being added. 2. Changes to support P2P tunnel creation and deletion. A refcnt is maintained per resource type (IMR or IP prefix) and based on this a P2P tunnel is created or deleted. 3. Changes to support handling of VXLAN_REMOTE_VNI table. Interfaces with portsorch to create a Port object of type TUNNEL on tunnel discovery. 4. SAI interface function changes to support P2P tunnels. 5. EVPN NVO table handling. Signed-off-by: Rajesh Sankaran <rajesh.sankaran@broadcom.com> Co-authored-by: Tapash Das <tapash.das@broadcom.com>
1 parent a1d6300 commit 095f481

File tree

7 files changed

+1692
-116
lines changed

7 files changed

+1692
-116
lines changed

orchagent/orchdaemon.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,20 @@ bool OrchDaemon::init()
135135
CoppOrch *copp_orch = new CoppOrch(m_applDb, APP_COPP_TABLE_NAME);
136136
TunnelDecapOrch *tunnel_decap_orch = new TunnelDecapOrch(m_applDb, APP_TUNNEL_DECAP_TABLE_NAME);
137137

138-
VxlanTunnelOrch *vxlan_tunnel_orch = new VxlanTunnelOrch(m_applDb, APP_VXLAN_TUNNEL_TABLE_NAME);
138+
VxlanTunnelOrch *vxlan_tunnel_orch = new VxlanTunnelOrch(m_stateDb, m_applDb, APP_VXLAN_TUNNEL_TABLE_NAME);
139139
gDirectory.set(vxlan_tunnel_orch);
140140
VxlanTunnelMapOrch *vxlan_tunnel_map_orch = new VxlanTunnelMapOrch(m_applDb, APP_VXLAN_TUNNEL_MAP_TABLE_NAME);
141141
gDirectory.set(vxlan_tunnel_map_orch);
142142
VxlanVrfMapOrch *vxlan_vrf_orch = new VxlanVrfMapOrch(m_applDb, APP_VXLAN_VRF_TABLE_NAME);
143143
gDirectory.set(vxlan_vrf_orch);
144144

145+
EvpnRemoteVniOrch* evpn_remote_vni_orch = new EvpnRemoteVniOrch(m_applDb, APP_VXLAN_REMOTE_VNI_TABLE_NAME);
146+
gDirectory.set(evpn_remote_vni_orch);
147+
148+
EvpnNvoOrch* evpn_nvo_orch = new EvpnNvoOrch(m_applDb, APP_VXLAN_EVPN_NVO_TABLE_NAME);
149+
gDirectory.set(evpn_nvo_orch);
150+
151+
145152
vector<string> qos_tables = {
146153
CFG_TC_TO_QUEUE_MAP_TABLE_NAME,
147154
CFG_SCHEDULER_TABLE_NAME,
@@ -274,7 +281,9 @@ bool OrchDaemon::init()
274281
m_orchList.push_back(chassis_frontend_orch);
275282
m_orchList.push_back(vrf_orch);
276283
m_orchList.push_back(vxlan_tunnel_orch);
284+
m_orchList.push_back(evpn_nvo_orch);
277285
m_orchList.push_back(vxlan_tunnel_map_orch);
286+
m_orchList.push_back(evpn_remote_vni_orch);
278287
m_orchList.push_back(vxlan_vrf_orch);
279288
m_orchList.push_back(cfg_vnet_rt_orch);
280289
m_orchList.push_back(vnet_orch);

orchagent/port.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ extern "C" {
2020
*/
2121
#define DEFAULT_MTU 1492
2222

23+
#define VNID_NONE 0xFFFFFFFF
24+
2325
namespace swss {
2426

2527
struct VlanMemberEntry
@@ -46,6 +48,7 @@ class Port
4648
LOOPBACK,
4749
VLAN,
4850
LAG,
51+
TUNNEL,
4952
SUBPORT,
5053
UNKNOWN
5154
} ;
@@ -89,6 +92,7 @@ class Port
8992
sai_object_id_t m_hif_id = 0;
9093
sai_object_id_t m_lag_id = 0;
9194
sai_object_id_t m_lag_member_id = 0;
95+
sai_object_id_t m_tunnel_id = 0;
9296
sai_object_id_t m_ingress_acl_table_group_id = 0;
9397
sai_object_id_t m_egress_acl_table_group_id = 0;
9498
vlan_members_t m_vlan_members;
@@ -100,8 +104,10 @@ class Port
100104
std::vector<sai_object_id_t> m_queue_ids;
101105
std::vector<sai_object_id_t> m_priority_group_ids;
102106
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
103-
uint8_t m_pfc_bitmask = 0;
104-
uint32_t m_nat_zone_id = 0;
107+
uint8_t m_pfc_bitmask = 0;
108+
uint32_t m_nat_zone_id = 0;
109+
uint32_t m_vnid = VNID_NONE;
110+
uint32_t m_fdb_count = 0;
105111

106112
/*
107113
* Following two bit vectors are used to lock

orchagent/portsorch.cpp

+101-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "bufferorch.h"
44
#include "neighorch.h"
55
#include "gearboxutils.h"
6+
#include "vxlanorch.h"
7+
#include "directory.h"
68

79
#include <inttypes.h>
810
#include <cassert>
@@ -42,6 +44,7 @@ extern NeighOrch *gNeighOrch;
4244
extern CrmOrch *gCrmOrch;
4345
extern BufferOrch *gBufferOrch;
4446
extern FdbOrch *gFdbOrch;
47+
extern Directory<Orch*> gDirectory;
4548

4649
#define VLAN_PREFIX "Vlan"
4750
#define DEFAULT_VLAN_ID 1
@@ -1284,6 +1287,12 @@ bool PortsOrch::setPortPvid(Port &port, sai_uint32_t pvid)
12841287
{
12851288
SWSS_LOG_ENTER();
12861289

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+
12871296
if (port.m_rif_id)
12881297
{
12891298
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)
13481357
SWSS_LOG_ENTER();
13491358
vector<Port> portv;
13501359

1360+
if(port.m_type == Port::TUNNEL)
1361+
{
1362+
return true;
1363+
}
1364+
13511365
/*
13521366
* Before SAI_HOSTIF_VLAN_TAG_ORIGINAL is supported by libsai from all asic vendors,
13531367
* 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
17171731
{
17181732
SWSS_LOG_ENTER();
17191733

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+
17201741
vector<FieldValueTuple> tuples;
17211742
FieldValueTuple tuple("oper_status", oper_status_strings.at(status));
17221743
tuples.push_back(tuple);
@@ -1809,7 +1830,7 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
18091830
/* Determine if the port has already been initialized before */
18101831
if (m_portList.find(alias) != m_portList.end() && m_portList[alias].m_port_id == id)
18111832
{
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());
18131834
}
18141835
else
18151836
{
@@ -1853,7 +1874,7 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
18531874

18541875
m_portList[alias].m_init = true;
18551876

1856-
SWSS_LOG_NOTICE("Initialized port %s", alias.c_str());
1877+
SWSS_LOG_ERROR("Initialized port %s", alias.c_str());
18571878
}
18581879
else
18591880
{
@@ -3333,26 +3354,46 @@ bool PortsOrch::addBridgePort(Port &port)
33333354
sai_attribute_t attr;
33343355
vector<sai_attribute_t> attrs;
33353356

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;
33413357
if (port.m_type == Port::PHY)
33423358
{
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;
33433364
attr.value.oid = port.m_port_id;
3365+
attrs.push_back(attr);
33443366
}
33453367
else if (port.m_type == Port::LAG)
33463368
{
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;
33473374
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);
33483390
}
33493391
else
33503392
{
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",
33523394
port.m_alias.c_str(), port.m_type);
33533395
return false;
33543396
}
3355-
attrs.push_back(attr);
33563397

33573398
/* Create a bridge port with admin status set to UP */
33583399
attr.id = SAI_BRIDGE_PORT_ATTR_ADMIN_STATE;
@@ -3522,6 +3563,14 @@ bool PortsOrch::removeVlan(Port vlan)
35223563
return false;
35233564
}
35243565

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+
35253574
sai_status_t status = sai_vlan_api->remove_vlan(vlan.m_vlan_info.vlan_oid);
35263575
if (status != SAI_STATUS_SUCCESS)
35273576
{
@@ -3660,6 +3709,14 @@ bool PortsOrch::removeVlanMember(Port &vlan, Port &port)
36603709
return true;
36613710
}
36623711

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+
36633720
bool PortsOrch::addLag(string lag_alias)
36643721
{
36653722
SWSS_LOG_ENTER();
@@ -3908,6 +3965,36 @@ bool PortsOrch::setDistributionOnLagMember(Port &lagMember, bool enableDistribut
39083965
return true;
39093966
}
39103967

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+
39113998
void PortsOrch::generateQueueMap()
39123999
{
39134000
if (m_isQueueMapGenerated)
@@ -4116,6 +4203,11 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
41164203
}
41174204
port.m_oper_status = status;
41184205

4206+
if(port.m_type == Port::TUNNEL)
4207+
{
4208+
return;
4209+
}
4210+
41194211
bool isUp = status == SAI_PORT_OPER_STATUS_UP;
41204212
if (port.m_type == Port::PHY)
41214213
{

orchagent/portsorch.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ class PortsOrch : public Orch, public Subject
128128
void getLagMember(Port &lag, vector<Port> &portv);
129129
void updateChildPortsMtu(const Port &p, const uint32_t mtu);
130130

131+
bool addTunnel(string tunnel,sai_object_id_t, bool learning=true);
132+
bool removeTunnel(Port tunnel);
133+
bool addBridgePort(Port &port);
134+
bool removeBridgePort(Port &port);
135+
bool addVlanMember(Port &vlan, Port &port, string& tagging_mode);
136+
bool removeVlanMember(Port &vlan, Port &port);
137+
bool isVlanMember(Port &vlan, Port &port);
138+
139+
131140
private:
132141
unique_ptr<Table> m_counterTable;
133142
unique_ptr<Table> m_counterLagTable;
@@ -216,14 +225,10 @@ class PortsOrch : public Orch, public Subject
216225
bool addHostIntfs(Port &port, string alias, sai_object_id_t &host_intfs_id);
217226
bool setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip);
218227

219-
bool addBridgePort(Port &port);
220-
bool removeBridgePort(Port &port);
221228
bool setBridgePortLearnMode(Port &port, string learn_mode);
222229

223230
bool addVlan(string vlan);
224231
bool removeVlan(Port vlan);
225-
bool addVlanMember(Port &vlan, Port &port, string& tagging_mode);
226-
bool removeVlanMember(Port &vlan, Port &port);
227232

228233
bool addLag(string lag);
229234
bool removeLag(Port lag);
@@ -278,6 +283,7 @@ class PortsOrch : public Orch, public Subject
278283
sai_acl_bind_point_type_t &sai_acl_bind_type);
279284
void initGearbox();
280285
bool initGearboxPort(Port &port);
286+
281287
};
282288
#endif /* SWSS_PORTSORCH_H */
283289

0 commit comments

Comments
 (0)