Skip to content

Commit 1ccda8d

Browse files
authored
[vslib]: MACsec in Gearbox (sonic-net#993)
Add the placeholders of MACsec SAI in Gearbox BCM81724. We don't really implement the MACsec in Gearbox but just make all MACsec related APIs in SAI that can be called successfully in SWSS.
1 parent 7a2b824 commit 1ccda8d

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

vslib/SwitchBCM81724.cpp

+101
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,77 @@ sai_status_t SwitchBCM81724::initialize_default_objects(
6969

7070
CHECK_STATUS(set_switch_default_attributes());
7171
CHECK_STATUS(create_default_trap_group());
72+
CHECK_STATUS(set_acl_entry_min_prio());
7273

7374
return SAI_STATUS_SUCCESS;
7475
}
7576

77+
sai_status_t SwitchBCM81724::set(
78+
_In_ sai_object_type_t objectType,
79+
_In_ sai_object_id_t objectId,
80+
_In_ const sai_attribute_t* attr)
81+
{
82+
SWSS_LOG_ENTER();
83+
84+
return SwitchStateBase::set(objectType, objectId, attr);
85+
}
86+
87+
sai_status_t SwitchBCM81724::create(
88+
_In_ sai_object_type_t object_type,
89+
_In_ const std::string &serializedObjectId,
90+
_In_ sai_object_id_t switch_id,
91+
_In_ uint32_t attr_count,
92+
_In_ const sai_attribute_t *attr_list)
93+
{
94+
SWSS_LOG_ENTER();
95+
96+
// Bypass MACsec creating because the existing implementation of MACsec cannot be directly used by Gearbox
97+
if (is_macsec_type(object_type))
98+
{
99+
SWSS_LOG_INFO("Bypass creating %s", sai_serialize_object_type(object_type));
100+
101+
return create_internal(object_type, serializedObjectId, switch_id, attr_count, attr_list);
102+
}
103+
104+
return SwitchStateBase::create(object_type, serializedObjectId, switch_id, attr_count, attr_list);
105+
}
106+
107+
sai_status_t SwitchBCM81724::remove(
108+
_In_ sai_object_type_t object_type,
109+
_In_ const std::string &serializedObjectId)
110+
{
111+
SWSS_LOG_ENTER();
112+
113+
// Bypass MACsec removing because the existing implementation of MACsec cannot be directly used by Gearbox
114+
if (is_macsec_type(object_type))
115+
{
116+
SWSS_LOG_INFO("Bypass removing %s", sai_serialize_object_type(object_type));
117+
118+
return remove_internal(object_type, serializedObjectId);
119+
}
120+
121+
return SwitchStateBase::remove(object_type, serializedObjectId);
122+
}
123+
124+
sai_status_t SwitchBCM81724::set(
125+
_In_ sai_object_type_t objectType,
126+
_In_ const std::string &serializedObjectId,
127+
_In_ const sai_attribute_t* attr)
128+
{
129+
SWSS_LOG_ENTER();
130+
131+
// Bypass MACsec setting because the existing implementation of MACsec cannot be directly used by Gearbox
132+
if (is_macsec_type(objectType) ||
133+
(objectType == SAI_OBJECT_TYPE_ACL_ENTRY && attr && attr->id == SAI_ACL_ENTRY_ATTR_ACTION_MACSEC_FLOW))
134+
{
135+
SWSS_LOG_INFO("Bypass setting %s", sai_serialize_object_type(objectType));
136+
137+
return set_internal(objectType, serializedObjectId, attr);;
138+
}
139+
140+
return SwitchStateBase::set(objectType, serializedObjectId, attr);
141+
}
142+
76143
sai_status_t SwitchBCM81724::refresh_port_list(
77144
_In_ const sai_attr_metadata_t *meta)
78145
{
@@ -183,6 +250,10 @@ sai_status_t SwitchBCM81724::refresh_read_only(
183250
case SAI_SWITCH_ATTR_DEFAULT_TRAP_GROUP:
184251
case SAI_SWITCH_ATTR_FIRMWARE_MAJOR_VERSION:
185252
return SAI_STATUS_SUCCESS;
253+
254+
case SAI_SWITCH_ATTR_ACL_ENTRY_MINIMUM_PRIORITY:
255+
case SAI_SWITCH_ATTR_ACL_ENTRY_MAXIMUM_PRIORITY:
256+
return SAI_STATUS_SUCCESS;
186257
}
187258
}
188259

@@ -211,6 +282,16 @@ sai_status_t SwitchBCM81724::refresh_read_only(
211282
return SAI_STATUS_SUCCESS; // XXX not sure for gearbox
212283
}
213284

285+
if (meta->objecttype == SAI_OBJECT_TYPE_MACSEC && meta->attrid == SAI_MACSEC_ATTR_SCI_IN_INGRESS_MACSEC_ACL)
286+
{
287+
return refresh_macsec_sci_in_ingress_macsec_acl(object_id);
288+
}
289+
290+
if (meta->objecttype == SAI_OBJECT_TYPE_MACSEC_SA)
291+
{
292+
return refresh_macsec_sa_stat(object_id);
293+
}
294+
214295
auto mmeta = m_meta.lock();
215296

216297
if (mmeta)
@@ -254,3 +335,23 @@ sai_status_t SwitchBCM81724::warm_boot_initialize_objects()
254335

255336
return SAI_STATUS_NOT_IMPLEMENTED;
256337
}
338+
339+
bool SwitchBCM81724::is_macsec_type(_In_ sai_object_type_t object_type)
340+
{
341+
SWSS_LOG_ENTER();
342+
343+
switch(object_type)
344+
{
345+
case SAI_OBJECT_TYPE_MACSEC_PORT:
346+
347+
case SAI_OBJECT_TYPE_MACSEC_SC:
348+
349+
case SAI_OBJECT_TYPE_MACSEC_SA:
350+
351+
return true;
352+
353+
default: break;
354+
}
355+
356+
return false;
357+
}

vslib/SwitchBCM81724.h

+29
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ namespace saivs
2929

3030
virtual sai_status_t create_default_trap_group() override;
3131

32+
protected:
33+
34+
virtual sai_status_t set(
35+
_In_ sai_object_type_t objectType,
36+
_In_ sai_object_id_t objectId,
37+
_In_ const sai_attribute_t* attr);
38+
39+
public:
40+
41+
virtual sai_status_t create(
42+
_In_ sai_object_type_t object_type,
43+
_In_ const std::string &serializedObjectId,
44+
_In_ sai_object_id_t switch_id,
45+
_In_ uint32_t attr_count,
46+
_In_ const sai_attribute_t *attr_list) override;
47+
48+
virtual sai_status_t remove(
49+
_In_ sai_object_type_t object_type,
50+
_In_ const std::string &serializedObjectId) override;
51+
52+
virtual sai_status_t set(
53+
_In_ sai_object_type_t objectType,
54+
_In_ const std::string &serializedObjectId,
55+
_In_ const sai_attribute_t* attr) override;
56+
3257
protected : // refresh
3358

3459
virtual sai_status_t refresh_port_list(
@@ -49,5 +74,9 @@ namespace saivs
4974
_In_ const sai_attribute_t *attr_list) override;
5075

5176
virtual sai_status_t warm_boot_initialize_objects() override;
77+
78+
private:
79+
80+
bool is_macsec_type(_In_ sai_object_type_t object_type);
5281
};
5382
}

0 commit comments

Comments
 (0)