Skip to content

Commit

Permalink
[Orchagent] Vxlanorch and Portsorch changes for EVPN VXLAN (sonic-net…
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
srj102 and tapashdas authored Dec 2, 2020
1 parent a1d6300 commit 095f481
Show file tree
Hide file tree
Showing 7 changed files with 1,692 additions and 116 deletions.
11 changes: 10 additions & 1 deletion orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,20 @@ bool OrchDaemon::init()
CoppOrch *copp_orch = new CoppOrch(m_applDb, APP_COPP_TABLE_NAME);
TunnelDecapOrch *tunnel_decap_orch = new TunnelDecapOrch(m_applDb, APP_TUNNEL_DECAP_TABLE_NAME);

VxlanTunnelOrch *vxlan_tunnel_orch = new VxlanTunnelOrch(m_applDb, APP_VXLAN_TUNNEL_TABLE_NAME);
VxlanTunnelOrch *vxlan_tunnel_orch = new VxlanTunnelOrch(m_stateDb, m_applDb, APP_VXLAN_TUNNEL_TABLE_NAME);
gDirectory.set(vxlan_tunnel_orch);
VxlanTunnelMapOrch *vxlan_tunnel_map_orch = new VxlanTunnelMapOrch(m_applDb, APP_VXLAN_TUNNEL_MAP_TABLE_NAME);
gDirectory.set(vxlan_tunnel_map_orch);
VxlanVrfMapOrch *vxlan_vrf_orch = new VxlanVrfMapOrch(m_applDb, APP_VXLAN_VRF_TABLE_NAME);
gDirectory.set(vxlan_vrf_orch);

EvpnRemoteVniOrch* evpn_remote_vni_orch = new EvpnRemoteVniOrch(m_applDb, APP_VXLAN_REMOTE_VNI_TABLE_NAME);
gDirectory.set(evpn_remote_vni_orch);

EvpnNvoOrch* evpn_nvo_orch = new EvpnNvoOrch(m_applDb, APP_VXLAN_EVPN_NVO_TABLE_NAME);
gDirectory.set(evpn_nvo_orch);


vector<string> qos_tables = {
CFG_TC_TO_QUEUE_MAP_TABLE_NAME,
CFG_SCHEDULER_TABLE_NAME,
Expand Down Expand Up @@ -274,7 +281,9 @@ bool OrchDaemon::init()
m_orchList.push_back(chassis_frontend_orch);
m_orchList.push_back(vrf_orch);
m_orchList.push_back(vxlan_tunnel_orch);
m_orchList.push_back(evpn_nvo_orch);
m_orchList.push_back(vxlan_tunnel_map_orch);
m_orchList.push_back(evpn_remote_vni_orch);
m_orchList.push_back(vxlan_vrf_orch);
m_orchList.push_back(cfg_vnet_rt_orch);
m_orchList.push_back(vnet_orch);
Expand Down
10 changes: 8 additions & 2 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern "C" {
*/
#define DEFAULT_MTU 1492

#define VNID_NONE 0xFFFFFFFF

namespace swss {

struct VlanMemberEntry
Expand All @@ -46,6 +48,7 @@ class Port
LOOPBACK,
VLAN,
LAG,
TUNNEL,
SUBPORT,
UNKNOWN
} ;
Expand Down Expand Up @@ -89,6 +92,7 @@ class Port
sai_object_id_t m_hif_id = 0;
sai_object_id_t m_lag_id = 0;
sai_object_id_t m_lag_member_id = 0;
sai_object_id_t m_tunnel_id = 0;
sai_object_id_t m_ingress_acl_table_group_id = 0;
sai_object_id_t m_egress_acl_table_group_id = 0;
vlan_members_t m_vlan_members;
Expand All @@ -100,8 +104,10 @@ class Port
std::vector<sai_object_id_t> m_queue_ids;
std::vector<sai_object_id_t> m_priority_group_ids;
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
uint8_t m_pfc_bitmask = 0;
uint32_t m_nat_zone_id = 0;
uint8_t m_pfc_bitmask = 0;
uint32_t m_nat_zone_id = 0;
uint32_t m_vnid = VNID_NONE;
uint32_t m_fdb_count = 0;

/*
* Following two bit vectors are used to lock
Expand Down
110 changes: 101 additions & 9 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "bufferorch.h"
#include "neighorch.h"
#include "gearboxutils.h"
#include "vxlanorch.h"
#include "directory.h"

#include <inttypes.h>
#include <cassert>
Expand Down Expand Up @@ -42,6 +44,7 @@ extern NeighOrch *gNeighOrch;
extern CrmOrch *gCrmOrch;
extern BufferOrch *gBufferOrch;
extern FdbOrch *gFdbOrch;
extern Directory<Orch*> gDirectory;

#define VLAN_PREFIX "Vlan"
#define DEFAULT_VLAN_ID 1
Expand Down Expand Up @@ -1284,6 +1287,12 @@ bool PortsOrch::setPortPvid(Port &port, sai_uint32_t pvid)
{
SWSS_LOG_ENTER();

if(port.m_type == Port::TUNNEL)
{
SWSS_LOG_ERROR("pvid setting for tunnel %s is not allowed", port.m_alias.c_str());
return true;
}

if (port.m_rif_id)
{
SWSS_LOG_ERROR("pvid setting for router interface %s is not allowed", port.m_alias.c_str());
Expand Down Expand Up @@ -1348,6 +1357,11 @@ bool PortsOrch::setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip)
SWSS_LOG_ENTER();
vector<Port> portv;

if(port.m_type == Port::TUNNEL)
{
return true;
}

/*
* Before SAI_HOSTIF_VLAN_TAG_ORIGINAL is supported by libsai from all asic vendors,
* the VLAN tag on hostif is explicitly controlled with SAI_HOSTIF_VLAN_TAG_STRIP &
Expand Down Expand Up @@ -1717,6 +1731,13 @@ void PortsOrch::updateDbPortOperStatus(const Port& port, sai_port_oper_status_t
{
SWSS_LOG_ENTER();

if(port.m_type == Port::TUNNEL)
{
VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();
tunnel_orch->updateDbTunnelOperStatus(port.m_alias, status);
return;
}

vector<FieldValueTuple> tuples;
FieldValueTuple tuple("oper_status", oper_status_strings.at(status));
tuples.push_back(tuple);
Expand Down Expand Up @@ -1809,7 +1830,7 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l
/* Determine if the port has already been initialized before */
if (m_portList.find(alias) != m_portList.end() && m_portList[alias].m_port_id == id)
{
SWSS_LOG_DEBUG("Port has already been initialized before alias:%s", alias.c_str());
SWSS_LOG_INFO("Port has already been initialized before alias:%s", alias.c_str());
}
else
{
Expand Down Expand Up @@ -1853,7 +1874,7 @@ bool PortsOrch::initPort(const string &alias, const int index, const set<int> &l

m_portList[alias].m_init = true;

SWSS_LOG_NOTICE("Initialized port %s", alias.c_str());
SWSS_LOG_ERROR("Initialized port %s", alias.c_str());
}
else
{
Expand Down Expand Up @@ -3333,26 +3354,46 @@ bool PortsOrch::addBridgePort(Port &port)
sai_attribute_t attr;
vector<sai_attribute_t> attrs;

attr.id = SAI_BRIDGE_PORT_ATTR_TYPE;
attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT;
attrs.push_back(attr);

attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
if (port.m_type == Port::PHY)
{
attr.id = SAI_BRIDGE_PORT_ATTR_TYPE;
attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT;
attrs.push_back(attr);

attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
attr.value.oid = port.m_port_id;
attrs.push_back(attr);
}
else if (port.m_type == Port::LAG)
{
attr.id = SAI_BRIDGE_PORT_ATTR_TYPE;
attr.value.s32 = SAI_BRIDGE_PORT_TYPE_PORT;
attrs.push_back(attr);

attr.id = SAI_BRIDGE_PORT_ATTR_PORT_ID;
attr.value.oid = port.m_lag_id;
attrs.push_back(attr);
}
else if (port.m_type == Port::TUNNEL)
{
attr.id = SAI_BRIDGE_PORT_ATTR_TYPE;
attr.value.s32 = SAI_BRIDGE_PORT_TYPE_TUNNEL;
attrs.push_back(attr);

attr.id = SAI_BRIDGE_PORT_ATTR_TUNNEL_ID;
attr.value.oid = port.m_tunnel_id;
attrs.push_back(attr);

attr.id = SAI_BRIDGE_PORT_ATTR_BRIDGE_ID;
attr.value.oid = m_default1QBridge;
attrs.push_back(attr);
}
else
{
SWSS_LOG_ERROR("Failed to add bridge port %s to default 1Q bridge, invalid porty type %d",
SWSS_LOG_ERROR("Failed to add bridge port %s to default 1Q bridge, invalid port type %d",
port.m_alias.c_str(), port.m_type);
return false;
}
attrs.push_back(attr);

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

// Fail VLAN removal if there is a vnid associated
if (vlan.m_vnid != VNID_NONE)
{
SWSS_LOG_ERROR("VLAN-VNI mapping not yet removed. VLAN %s VNI %d",
vlan.m_alias.c_str(), vlan.m_vnid);
return false;
}

sai_status_t status = sai_vlan_api->remove_vlan(vlan.m_vlan_info.vlan_oid);
if (status != SAI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -3660,6 +3709,14 @@ bool PortsOrch::removeVlanMember(Port &vlan, Port &port)
return true;
}

bool PortsOrch::isVlanMember(Port &vlan, Port &port)
{
if (vlan.m_members.find(port.m_alias) == vlan.m_members.end())
return false;

return true;
}

bool PortsOrch::addLag(string lag_alias)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -3908,6 +3965,36 @@ bool PortsOrch::setDistributionOnLagMember(Port &lagMember, bool enableDistribut
return true;
}

bool PortsOrch::addTunnel(string tunnel_alias, sai_object_id_t tunnel_id, bool hwlearning)
{
SWSS_LOG_ENTER();

Port tunnel(tunnel_alias, Port::TUNNEL);
tunnel.m_tunnel_id = tunnel_id;
if (hwlearning)
{
tunnel.m_learn_mode = "hardware";
}
else
{
tunnel.m_learn_mode = "disable";
}
m_portList[tunnel_alias] = tunnel;

SWSS_LOG_INFO("addTunnel:: %" PRIx64, tunnel_id);

return true;
}

bool PortsOrch::removeTunnel(Port tunnel)
{
SWSS_LOG_ENTER();

m_portList.erase(tunnel.m_alias);

return true;
}

void PortsOrch::generateQueueMap()
{
if (m_isQueueMapGenerated)
Expand Down Expand Up @@ -4116,6 +4203,11 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
}
port.m_oper_status = status;

if(port.m_type == Port::TUNNEL)
{
return;
}

bool isUp = status == SAI_PORT_OPER_STATUS_UP;
if (port.m_type == Port::PHY)
{
Expand Down
14 changes: 10 additions & 4 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ class PortsOrch : public Orch, public Subject
void getLagMember(Port &lag, vector<Port> &portv);
void updateChildPortsMtu(const Port &p, const uint32_t mtu);

bool addTunnel(string tunnel,sai_object_id_t, bool learning=true);
bool removeTunnel(Port tunnel);
bool addBridgePort(Port &port);
bool removeBridgePort(Port &port);
bool addVlanMember(Port &vlan, Port &port, string& tagging_mode);
bool removeVlanMember(Port &vlan, Port &port);
bool isVlanMember(Port &vlan, Port &port);


private:
unique_ptr<Table> m_counterTable;
unique_ptr<Table> m_counterLagTable;
Expand Down Expand Up @@ -216,14 +225,10 @@ class PortsOrch : public Orch, public Subject
bool addHostIntfs(Port &port, string alias, sai_object_id_t &host_intfs_id);
bool setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip);

bool addBridgePort(Port &port);
bool removeBridgePort(Port &port);
bool setBridgePortLearnMode(Port &port, string learn_mode);

bool addVlan(string vlan);
bool removeVlan(Port vlan);
bool addVlanMember(Port &vlan, Port &port, string& tagging_mode);
bool removeVlanMember(Port &vlan, Port &port);

bool addLag(string lag);
bool removeLag(Port lag);
Expand Down Expand Up @@ -278,6 +283,7 @@ class PortsOrch : public Orch, public Subject
sai_acl_bind_point_type_t &sai_acl_bind_type);
void initGearbox();
bool initGearboxPort(Port &port);

};
#endif /* SWSS_PORTSORCH_H */

Loading

0 comments on commit 095f481

Please sign in to comment.