Skip to content

Commit

Permalink
[pyext] Use SAI autogenerated saiswig.i (#837)
Browse files Browse the repository at this point in the history
No more need to manual translation of each SAI api structure. SAI metadata is now generating this automatically.
  • Loading branch information
kcudnik authored Jun 24, 2021
1 parent 9949c48 commit 76d28a6
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 505 deletions.
57 changes: 0 additions & 57 deletions pyext/fdb.h

This file was deleted.

10 changes: 0 additions & 10 deletions pyext/getapi.h

This file was deleted.

57 changes: 0 additions & 57 deletions pyext/lag.h

This file was deleted.

25 changes: 0 additions & 25 deletions pyext/nexthop.h

This file was deleted.

98 changes: 0 additions & 98 deletions pyext/pysairedis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,104 +65,6 @@ sai_status_t sai_api_initialize(
return sai_api_initialize(flags, &g_smt);
}

sai_status_t sai_get_switch_api(sai_switch_api_t* out)
{
sai_switch_api_t* api;

sai_status_t status = sai_api_query(SAI_API_SWITCH, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_status_t sai_get_lag_api(sai_lag_api_t* out)
{
sai_lag_api_t* api;

sai_status_t status = sai_api_query(SAI_API_LAG, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_status_t sai_get_router_interface_api(sai_router_interface_api_t* out)
{
sai_router_interface_api_t* api;

sai_status_t status = sai_api_query(SAI_API_ROUTER_INTERFACE, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_status_t sai_get_next_hop_api(sai_next_hop_api_t* out)
{
sai_next_hop_api_t* api;

sai_status_t status = sai_api_query(SAI_API_NEXT_HOP, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_status_t sai_get_route_api(sai_route_api_t* out)
{
sai_route_api_t* api;

sai_status_t status = sai_api_query(SAI_API_ROUTE, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_status_t sai_get_vlan_api(sai_vlan_api_t* out)
{
sai_vlan_api_t* api;

sai_status_t status = sai_api_query(SAI_API_VLAN, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_status_t sai_get_fdb_api(sai_fdb_api_t* out)
{
sai_fdb_api_t* api;

sai_status_t status = sai_api_query(SAI_API_FDB, (void**)&api);

if (status == SAI_STATUS_SUCCESS)
{
*out = *api;
}

return status;
}

sai_mac_t* sai_mac_t_from_string(const std::string& s)
{
sai_mac_t *mac = (sai_mac_t*)calloc(1, sizeof(sai_mac_t));
Expand Down
1 change: 0 additions & 1 deletion pyext/pysairedis.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

extern "C" {
#include "sai.h"
#include "getapi.h"
}

#include <map>
Expand Down
34 changes: 3 additions & 31 deletions pyext/pysairedis.i
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
%module pysairedis

%include "cpointer.i"
%include "carrays.i"

Expand All @@ -8,7 +7,7 @@

extern "C"{
#include "sai.h"
#include "getapi.h"
#include "saiextensions.h"
}

#include "sairedis.h"
Expand All @@ -26,36 +25,9 @@ namespace std {

%include "saitypes.h"
%include "sai.h"
%include "saiextensions.h"

%include "getapi.h"

%include "switch.h"
%include "lag.h"
%include "routerinterface.h"
%include "nexthop.h"
%include "route.h"
%include "vlan.h"
%include "fdb.h"

%ignore sai_switch_api_t;
%ignore sai_lag_api_t;
%ignore sai_router_interface_api_t;
%ignore sai_next_hop_api_t;
%ignore sai_route_api_t;
%ignore sai_vlan_api_t;
%ignore sai_fdb_api_t;

%include "saiswitch.h"
%include "sailag.h"
%include "sairouterinterface.h"
%include "sainexthop.h"
%include "sairoute.h"
%include "saivlan.h"
%include "saifdb.h"
%include "saiport.h"
%include "saibfd.h"
%include "saiqueue.h"

%include "../SAI/meta/saiswig.i"

%include "sairedis.h"

Expand Down
52 changes: 0 additions & 52 deletions pyext/route.h

This file was deleted.

Loading

0 comments on commit 76d28a6

Please sign in to comment.