Skip to content

Commit 5ef1764

Browse files
kirankellalguohan
authored andcommitted
Changes in sonic-sairedis repo to support the NAT feature. (sonic-net#519)
* Changes in sonic-sairedis repo to support the NAT feature. Signed-off-by: [email protected]
1 parent 5337490 commit 5ef1764

23 files changed

+743
-1
lines changed

lib/inc/sai_redis.h

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ extern const sai_virtual_router_api_t redis_virtual_router_api;
113113
extern const sai_vlan_api_t redis_vlan_api;
114114
extern const sai_wred_api_t redis_wred_api;
115115
extern const sai_debug_counter_api_t redis_debug_counter_api;
116+
extern const sai_nat_api_t redis_nat_api;
116117

117118
#define UNREFERENCED_PARAMETER(X)
118119

@@ -194,6 +195,7 @@ REDIS_ENTRY_QUAD(l2mc_entry);
194195
REDIS_ENTRY_QUAD(mcast_fdb_entry);
195196
REDIS_ENTRY_QUAD(neighbor_entry);
196197
REDIS_ENTRY_QUAD(route_entry);
198+
REDIS_ENTRY_QUAD(nat_entry);
197199

198200
// BULK
199201

lib/src/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ libsairedis_la_SOURCES = \
5050
sai_redis_virtual_router.cpp \
5151
sai_redis_vlan.cpp \
5252
sai_redis_wred.cpp \
53+
sai_redis_nat.cpp \
5354
sai_redis_generic_create.cpp \
5455
sai_redis_generic_remove.cpp \
5556
sai_redis_generic_set.cpp \

lib/src/sai_redis_generic_create.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,4 @@ REDIS_ENTRY_CREATE(L2MC_ENTRY,l2mc_entry);
412412
REDIS_ENTRY_CREATE(MCAST_FDB_ENTRY,mcast_fdb_entry);
413413
REDIS_ENTRY_CREATE(NEIGHBOR_ENTRY,neighbor_entry);
414414
REDIS_ENTRY_CREATE(ROUTE_ENTRY,route_entry);
415+
REDIS_ENTRY_CREATE(NAT_ENTRY,nat_entry);

lib/src/sai_redis_generic_get.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,4 @@ REDIS_ENTRY_GET(L2MC_ENTRY,l2mc_entry);
285285
REDIS_ENTRY_GET(MCAST_FDB_ENTRY,mcast_fdb_entry);
286286
REDIS_ENTRY_GET(NEIGHBOR_ENTRY,neighbor_entry);
287287
REDIS_ENTRY_GET(ROUTE_ENTRY,route_entry);
288+
REDIS_ENTRY_GET(NAT_ENTRY,nat_entry);

lib/src/sai_redis_generic_remove.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,4 @@ REDIS_ENTRY_REMOVE(L2MC_ENTRY,l2mc_entry);
156156
REDIS_ENTRY_REMOVE(MCAST_FDB_ENTRY,mcast_fdb_entry);
157157
REDIS_ENTRY_REMOVE(NEIGHBOR_ENTRY,neighbor_entry);
158158
REDIS_ENTRY_REMOVE(ROUTE_ENTRY,route_entry);
159+
REDIS_ENTRY_REMOVE(NAT_ENTRY,nat_entry);

lib/src/sai_redis_generic_set.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,4 @@ REDIS_ENTRY_SET(L2MC_ENTRY,l2mc_entry);
226226
REDIS_ENTRY_SET(MCAST_FDB_ENTRY,mcast_fdb_entry);
227227
REDIS_ENTRY_SET(NEIGHBOR_ENTRY,neighbor_entry);
228228
REDIS_ENTRY_SET(ROUTE_ENTRY,route_entry);
229+
REDIS_ENTRY_SET(NAT_ENTRY,nat_entry);

lib/src/sai_redis_interfacequery.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ sai_status_t sai_api_query(
255255
API_CASE(VLAN,vlan);
256256
API_CASE(WRED,wred);
257257
API_CASE(DEBUG_COUNTER,debug_counter);
258+
API_CASE(NAT,nat);
258259

259260
default:
260261
SWSS_LOG_ERROR("Invalid API type %d", sai_api_id);

lib/src/sai_redis_nat.cpp

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include "sai_redis.h"
2+
3+
sai_status_t sai_bulk_create_nat_entry(
4+
_In_ uint32_t object_count,
5+
_In_ const sai_nat_entry_t *nat_entry,
6+
_In_ const uint32_t *attr_count,
7+
_In_ const sai_attribute_t **attr_list,
8+
_In_ sai_bulk_op_error_mode_t mode,
9+
_Out_ sai_status_t *object_statuses)
10+
{
11+
MUTEX();
12+
SWSS_LOG_ENTER();
13+
14+
return SAI_STATUS_NOT_IMPLEMENTED;
15+
}
16+
17+
sai_status_t sai_bulk_remove_nat_entry(
18+
_In_ uint32_t object_count,
19+
_In_ const sai_nat_entry_t *nat_entry,
20+
_In_ sai_bulk_op_error_mode_t mode,
21+
_Out_ sai_status_t *object_statuses)
22+
{
23+
MUTEX();
24+
SWSS_LOG_ENTER();
25+
26+
return SAI_STATUS_NOT_IMPLEMENTED;
27+
28+
}
29+
30+
sai_status_t sai_bulk_set_nat_entry_attribute(
31+
_In_ uint32_t object_count,
32+
_In_ const sai_nat_entry_t *nat_entry,
33+
_In_ const sai_attribute_t *attr_list,
34+
_In_ sai_bulk_op_error_mode_t mode,
35+
_Out_ sai_status_t *object_statuses)
36+
{
37+
MUTEX();
38+
SWSS_LOG_ENTER();
39+
40+
return SAI_STATUS_NOT_IMPLEMENTED;
41+
42+
}
43+
44+
sai_status_t sai_bulk_get_nat_entry_attribute(
45+
_In_ uint32_t object_count,
46+
_In_ const sai_nat_entry_t *nat_entry,
47+
_In_ const uint32_t *attr_count,
48+
_Inout_ sai_attribute_t **attr_list,
49+
_In_ sai_bulk_op_error_mode_t mode,
50+
_Out_ sai_status_t *object_statuses)
51+
{
52+
MUTEX();
53+
SWSS_LOG_ENTER();
54+
55+
return SAI_STATUS_NOT_IMPLEMENTED;
56+
57+
}
58+
59+
REDIS_GENERIC_QUAD_ENTRY(NAT_ENTRY,nat_entry);
60+
REDIS_GENERIC_QUAD(NAT_ZONE_COUNTER,nat_zone_counter);
61+
62+
const sai_nat_api_t redis_nat_api = {
63+
64+
REDIS_GENERIC_QUAD_API(nat_entry)
65+
66+
sai_bulk_create_nat_entry,
67+
sai_bulk_remove_nat_entry,
68+
sai_bulk_set_nat_entry_attribute,
69+
sai_bulk_get_nat_entry_attribute,
70+
71+
REDIS_GENERIC_QUAD_API(nat_zone_counter)
72+
};

0 commit comments

Comments
 (0)