-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PoC implementation of DENT SAI agent
This agent application handles Netlink IPC requests from `swdevsai_nl` Netlink driver and configure hardware via SAI interface accordingly to IPC message. SAI events are translated into Netlink events and sent to switchdev driver. features supported: - switch init - dot1q bridge - port admin state - port oper link events tests - add test to verify IPC compatibility doc - Add README file describing: - how to build and run the agent - how to build and load Netlink driver driver headers - prestera driver headers are imported into source tree to be able to compile the agent and those headers should be in-sync. Signed-off-by: Volodymyr Mytnyk <[email protected]>
- Loading branch information
0 parents
commit 1a32a7f
Showing
32 changed files
with
3,320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Makefile | ||
saiagent | ||
compile | ||
configure | ||
depcomp | ||
install-sh | ||
missing | ||
stamp-h1 | ||
test-driver | ||
tests/check_saiagent | ||
tests/check_*.log | ||
tests/check_*.trs | ||
tests/*.log | ||
config.* | ||
.deps | ||
*.cache | ||
*.m4 | ||
*.o | ||
*.in | ||
*.swp | ||
*.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SUBDIRS = src tests | ||
dist_doc_DATA = README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Supported distro/kernel | ||
======================= | ||
- Debian 10 | ||
- Linux 5.15.x | ||
|
||
Install deps | ||
============ | ||
|
||
sudo apt install libnl-3-dev libnl-genl-3-dev | ||
|
||
Build steps | ||
=========== | ||
|
||
./bootstrap.sh | ||
./configure \ | ||
LIBSAI_CFLAGS="-I<SAI_REPO_DIR>/inc -I<SAI_REPO_DIR>/sai/experimental" \ | ||
LIBSAI_LDFLAGS="-L<SAI_LIB_DIR>" | ||
make | ||
make check | ||
|
||
where, | ||
|
||
SAI_REPO_DIR - SAI headers location | ||
SAI_LIB_DIR - SAI library location | ||
|
||
Build Prestera driver | ||
===================== | ||
|
||
Clone DENT Linux kernel sources (or just download to save some time) | ||
|
||
git clone https://github.com/PLVision/dent-linux.git -b dent-linux-5.15.y-netlink | ||
|
||
or | ||
|
||
wget https://github.com/PLVision/dent-linux/archive/refs/heads/dent-linux-5.15.y-netlink.zip | ||
unzip dent-linux-5.15.y-netlink.zip | ||
|
||
Install deps | ||
|
||
sudo apt-get install build-essential bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison | ||
|
||
Install 5.15x kernel headers (refer to distro documentation) | ||
|
||
Build | ||
|
||
cd dent-linux/drivers/net/ethernet/marvell/prestera/ | ||
export CONFIG_PRESTERA=m | ||
export CONFIG_SWDEVSAI_NL=m | ||
make -C /lib/modules/`uname -r`/build M=$PWD modules | ||
|
||
Execute SAI agent | ||
================= | ||
|
||
Load Prestera driver | ||
|
||
cd dent-linux/drivers/net/ethernet/marvell/prestera | ||
sudo insmod prestera.ko | ||
sudo insmod swdevsai_nl.ko | ||
|
||
Run SAI Agent | ||
|
||
<SAIAGENT_DIR>/src/saiagent -p <SAI_PROFILE> | ||
|
||
where, | ||
SAI_PROFILE - is SAI profile, usually 'sai.profile' file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
autoreconf --install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
AC_INIT([saiagent], [1.0]) | ||
AM_INIT_AUTOMAKE([-Wall -Werror foreign]) | ||
AC_PROG_CC | ||
AC_CONFIG_HEADERS([config.h]) | ||
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile]) | ||
AC_PATH_TOOL(PKG_CONFIG, pkg-config) | ||
PKG_CHECK_MODULES([CHECK], [check]) | ||
|
||
# prestera driver headers | ||
AC_SUBST(PRESTERA_INC_DIR) | ||
PRESTERA_INC_DIR="linux/prestera" | ||
|
||
# libnl/genl | ||
AC_SUBST(LIBNL_LIBS) | ||
AC_SUBST(LIBNL_CFLAGS) | ||
LIBNL_CFLAGS=`$PKG_CONFIG --cflags libnl-genl-3.0` | ||
LIBNL_LIBS=`$PKG_CONFIG --libs libnl-genl-3.0` | ||
|
||
# SAI | ||
AC_ARG_VAR([LIBSAI_CPPFLAGS], [Preprocessor flags for libsai]) | ||
AC_ARG_VAR([LIBSAI_CFLAGS], [Compiler flags for libsai]) | ||
AC_ARG_VAR([LIBSAI_LDFLAGS], [Linker flags for libsai]) | ||
AC_ARG_VAR([LIBSAI_LIBS], [Libraries to link for libsai]) | ||
|
||
if test "x$LIBSAI_CFLAGS" = "x"; then | ||
LIBSAI_CFLAGS="-I/usr/include/sai" | ||
fi | ||
if test "x$LIBSAI_CPPFLAGS" = "x"; then | ||
LIBSAI_CPPFLAGS=$LIBSAI_CFLAGS | ||
fi | ||
|
||
SAVE_CPPFLAGS="$CPPFLAGS" | ||
CPPFLAGS="$LIBSAI_CPPFLAGS $CPPFLAGS" | ||
SAVE_CFLAGS="$CFLAGS" | ||
CFLAGS="$LIBSAI_CFLAGS $CFLAGS" | ||
AC_CHECK_HEADER([sai.h]) | ||
CPPFLAGS="$SAVE_CPPFLAGS" | ||
CFLAGS="$SAVE_CFLAGS" | ||
|
||
if test "x$ac_cv_header_sai_h" = "xyes"; then | ||
SAVE_LIBS="$LIBS" | ||
LIBS="$LIBSAI_LIBS $LIBS" | ||
SAVE_LDFLAGS="$LDFLAGS" | ||
LDFLAGS="$LIBSAI_LDFLAGS $LDFLAGS" | ||
SAVE_CPPFLAGS="$CPPFLAGS" | ||
CPPFLAGS="$LIBSAI_CPPFLAGS $CPPFLAGS" | ||
SAVE_CFLAGS="$CFLAGS" | ||
CFLAGS="$LIBSAI_CFLAGS $CFLAGS" | ||
AC_CHECK_LIB([sai], [sai_api_initialize]) | ||
LIBS="$SAVE_LIBS" | ||
LDFLAGS="$SAVE_LDFLAGS" | ||
CPPFLAGS="$SAVE_CPPFLAGS" | ||
CFLAGS="$SAVE_CFLAGS" | ||
fi | ||
|
||
if test "x$ac_cv_lib_sai_sai_api_initialize" != "xyes" || test "x$ac_cv_header_sai_h" != "xyes"; then | ||
AC_MSG_ERROR([SAI headers/library not found]) | ||
fi | ||
|
||
AC_SUBST(LIBSAI_CFLAGS) | ||
AC_SUBST(LIBSAI_CPPFLAGS) | ||
AC_SUBST(LIBSAI_LDFLAGS) | ||
AC_SUBST(LIBSAI_LIBS) | ||
|
||
AC_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Those files are sync with Prestera driver used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ | ||
|
||
#ifndef _PRESTERA_EVENT_H_ | ||
#define _PRESTERA_EVENT_H_ | ||
|
||
#include <linux/types.h> | ||
#ifdef __KERNEL__ | ||
#include <uapi/linux/if_ether.h> | ||
#endif | ||
|
||
enum prestera_event_type { | ||
PRESTERA_EVENT_TYPE_UNSPEC, | ||
PRESTERA_EVENT_TYPE_PORT, | ||
PRESTERA_EVENT_TYPE_FDB, | ||
PRESTERA_EVENT_TYPE_RXTX, | ||
PRESTERA_EVENT_TYPE_FW_LOG, | ||
PRESTERA_EVENT_TYPE_PULSE, | ||
|
||
PRESTERA_EVENT_TYPE_MAX, | ||
}; | ||
|
||
enum prestera_rxtx_event_id { | ||
PRESTERA_RXTX_EVENT_UNSPEC, | ||
|
||
PRESTERA_RXTX_EVENT_RCV_PKT, | ||
|
||
PRESTERA_RXTX_EVENT_MAX, | ||
}; | ||
|
||
enum prestera_port_event_id { | ||
PRESTERA_PORT_EVENT_UNSPEC, | ||
PRESTERA_PORT_EVENT_MAC_STATE_CHANGED, | ||
|
||
PRESTERA_PORT_EVENT_MAX, | ||
}; | ||
|
||
enum prestera_fdb_event_id { | ||
PRESTERA_FDB_EVENT_UNSPEC, | ||
PRESTERA_FDB_EVENT_LEARNED, | ||
PRESTERA_FDB_EVENT_AGED, | ||
|
||
PRESTERA_FDB_EVENT_MAX, | ||
}; | ||
|
||
enum prestera_fdb_entry_type { | ||
PRESTERA_FDB_ENTRY_TYPE_REG_PORT, | ||
PRESTERA_FDB_ENTRY_TYPE_LAG, | ||
PRESTERA_FDB_ENTRY_TYPE_TEP, | ||
PRESTERA_FDB_ENTRY_TYPE_MAX | ||
}; | ||
|
||
struct prestera_fdb_event { | ||
enum prestera_fdb_entry_type type; | ||
union { | ||
u32 port_id; | ||
u16 lag_id; | ||
} dest; | ||
u32 vid; | ||
union { | ||
u8 mac[ETH_ALEN]; | ||
} data; | ||
}; | ||
|
||
struct prestera_port_event { | ||
u32 port_id; | ||
union { | ||
struct { | ||
u8 oper; | ||
u32 mode; | ||
u32 speed; | ||
u8 duplex; | ||
u8 fc; | ||
u8 fec; | ||
} mac; | ||
struct { | ||
u8 mdix; | ||
u64 lmode_bmap; | ||
struct { | ||
bool pause; | ||
bool asym_pause; | ||
} remote_fc; | ||
} phy; | ||
} data; | ||
}; | ||
|
||
struct prestera_fw_log_event { | ||
u32 log_len; | ||
u8 *data; | ||
}; | ||
|
||
struct prestera_event { | ||
u16 id; | ||
union { | ||
struct prestera_port_event port_evt; | ||
struct prestera_fdb_event fdb_evt; | ||
struct prestera_fw_log_event fw_log_evt; | ||
}; | ||
}; | ||
|
||
#endif /* _PRESTERA_EVENT_H_ */ |
Oops, something went wrong.