Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threshold feature #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = proto tam-buffers thresholdmgr
6 changes: 6 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

libtoolize --force --copy &&
autoreconf --force --install -I m4
rm -Rf autom4te.cache

88 changes: 88 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
AC_INIT([sonic-tam],[1.0.0])
AC_CONFIG_SRCDIR([])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([foreign])
AC_LANG_C
AC_LANG([C++])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_HEADER_STDC
PKG_CHECK_MODULES(PROTOBUF, protobuf >= 2.4.0)
AC_SUBST(PROTOBUF_LIBS)
AC_SUBST(PROTOBUF_CFLAGS)
AC_SUBST(PROTOBUF_VERSION)

AC_CHECK_LIB([hiredis], [redisConnect],,
AC_MSG_ERROR([libhiredis is not installed.]))

#AC_CHECK_LIB([nl-genl-3], [genl_connect])

AC_CHECK_PROG([PROTOC], [protoc], [protoc])
AS_IF([test "x${PROTOC}" == "x"],
[AC_MSG_ERROR(["protoc" not found.])])

AC_ARG_ENABLE(debug,
[ --enable-debug Compile with debugging flags],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)

AC_ARG_ENABLE(gtest,
[ --enable-gtest Compile with googletest flags],
[case "${enableval}" in
yes) gtest=true ;;
no) gtest=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gtest) ;;
esac],[gtest=false])
AM_CONDITIONAL(GTEST, test x$gtest = xtrue)

CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3 -I/usr/include/swss"

CFLAGS_COMMON+=" -Werror"
CFLAGS_COMMON+=" -Wno-reorder"
CFLAGS_COMMON+=" -Wcast-align"
CFLAGS_COMMON+=" -Wcast-qual"
CFLAGS_COMMON+=" -Wdisabled-optimization"
CFLAGS_COMMON+=" -Wextra"
CFLAGS_COMMON+=" -Wfloat-equal"
CFLAGS_COMMON+=" -Wimport"
CFLAGS_COMMON+=" -Winit-self"
CFLAGS_COMMON+=" -Winvalid-pch"
CFLAGS_COMMON+=" -Wlong-long"
CFLAGS_COMMON+=" -Wmissing-field-initializers"
CFLAGS_COMMON+=" -Wno-aggregate-return"
CFLAGS_COMMON+=" -Wno-padded"
CFLAGS_COMMON+=" -Wno-switch-enum"
CFLAGS_COMMON+=" -Wno-unused-parameter"
CFLAGS_COMMON+=" -Wpacked"
CFLAGS_COMMON+=" -Wpointer-arith"
CFLAGS_COMMON+=" -Wredundant-decls"
CFLAGS_COMMON+=" -Wstack-protector"
CFLAGS_COMMON+=" -Wstrict-aliasing=3"
CFLAGS_COMMON+=" -Wswitch"
CFLAGS_COMMON+=" -Wswitch-default"
CFLAGS_COMMON+=" -Wunreachable-code"
CFLAGS_COMMON+=" -Wunused"
CFLAGS_COMMON+=" -Wvariadic-macros"
CFLAGS_COMMON+=" -Wno-switch-default"
CFLAGS_COMMON+=" -Wno-long-long"
CFLAGS_COMMON+=" -Wno-redundant-decls"
CFLAGS_COMMON+=" -Wno-misleading-indentation"

PROTOBUF_CFLAGS = `pkg-config --cflags --libs protobuf`

AC_SUBST(CFLAGS_COMMON)

AC_CONFIG_FILES([
proto/Makefile
tam-buffers/Makefile
thresholdmgr/Makefile
Makefile
])

AC_OUTPUT
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sonic (1.0.0) stable; urgency=medium

* Initial release.

-- TAM <@broadcom.com> Mon, 10 June 2019 12:00:00 -0800

1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
18 changes: 18 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Source: sonic
Maintainer: Broadcom
Section: net
Priority: optional
Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev
Standards-Version: 1.0.0

Package: tam
Architecture: any
Depends: ${shlibs:Depends}
Description: This package contains TAM for SONiC project.

Package: tam-dbg
Architecture: any
Section: debug
Priority: extra
Depends: tam (=${binary:Version})
Description: debugging symbols for tam
40 changes: 40 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


# main packaging script based on dh7 syntax
%:
dh $@ --with autotools-dev

# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_configure:
dh_auto_configure --

override_dh_auto_install:
dh_auto_install --destdir=debian/tam
ifeq ($(SONIC_COVERAGE_ON),y)
find . -name "*.gcno" | sed 's|.*|tar -uvf debian/gcov_tam_$(shell date '+%y%m%d_%H%M').tar &|g'|sh
endif

override_dh_strip:
dh_strip --dbg-package=tam-dbg
11 changes: 11 additions & 0 deletions proto/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

%.pb.cc %.pb.h: %.proto
$(PROTOC) --proto_path=$(srcdir) -I /usr/include --cpp_out=$(srcdir) $^

dist_noinst_DATA = sai_tam_main.proto sai_tam_buffer_stats.proto sai_tam_event_threshold_breach.proto sai_tam_event.proto sai_tam_event_flow_learning.proto

nodist_proto_SOURCES = $(srcdir)/proto/sai_tam_main.pb.cc $(srcdir)/proto/sai_tam_buffer_stats.pb.cc $(srcdir)/proto/sai_tam_event_threshold_breach.pb.cc $(srcdir)/proto/sai_tam_event.pb.cc $(srcdir)/proto/sai_tam_event_flow_learning.pb.cc

BUILT_SOURCES = sai_tam_main.pb.h sai_tam_buffer_stats.pb.h sai_tam_event_threshold_breach.pb.h sai_tam_event.pb.h sai_tam_event_flow_learning.pb.h

MOSTLYCLEANFILES = sai_tam_main.pb.h sai_tam_main.pb.cc sai_tam_buffer_stats.pb.h sai_tam_buffer_stats.pb.cc sai_tam_event_threshold_breach.pb.h sai_tam_event_threshold_breach.pb.cc sai_tam_event.pb.h sai_tam_event.pb.cc sai_tam_event_flow_learning.pb.h sai_tam_event_flow_learning.pb.cc
77 changes: 77 additions & 0 deletions proto/sai_tam_buffer_stats.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2017 Broadcom. The term "Broadcom" refers
* to Broadcom Limited and/or its subsidiaries.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

syntax = "proto2";

import "sai_tam_main.proto";

message BufferStatistics {
// Counter: the total number of dropped bytes
optional uint64 drop_bytes = 1 [(telemetry_options).is_counter = true];

// Peak: the max measured buffer depth, in bytes, across all measurements since boot.
optional uint64 peak_buffer_occupancy_bytes = 2 [(telemetry_options).is_gauge = true];

// Peak: the max measured buffer depth, in percent, across all measurements since boot.
optional uint32 peak_buffer_occupancy_percent = 3 [(telemetry_options).is_gauge = true];
}

enum QueueType {
QUEUE_UNICAST = 1; //Unicast Queue
QUEUE_MULTICAST = 2; // Multicast Queue
}

message QueueStatistics {
required uint64 queue_oid = 1; //Queue
required QueueType queue_type = 2; // Unicast or Multicast ?
required BufferStatistics stats = 3; // Buffer Statistics
}

enum IPGType {
IPG_SHARED = 1; //IPG Shared
IPG_XOFF = 2; // IPG Headroom
}

message IPGStatistics {
required uint64 ipg_oid = 1; // IPG Index
required IPGType ipg_type = 2; // Shared or Headroom
required BufferStatistics stats = 3; // Buffer Statistics
}

enum BufferPoolType {
BUFFERPOOL_INGRESS = 1; // Ingress pool
BUFFERPOOL_EGRESS = 2; // Egress pool
}

message BufferPoolStatistics {
required uint64 pool_oid = 1; // Pool index
required BufferPoolType pool_type = 2; // Ingress or Egress ?
required BufferStatistics stats = 3; // Buffer statistics
}

message InterfaceBufferStatistics {
required uint64 port_oid = 1; // Interface Name as known in the system
repeated QueueStatistics queue_stats = 2; // Queue statistics for this port
repeated IPGStatistics ipg_stats = 3; // IPG statistics for this port
repeated BufferPoolStatistics pool_stats = 4; // Pool statistics for this port
}

message SwitchBufferStats {
repeated BufferPoolStatistics pool_stats = 1; // Global Pool Statistics
repeated InterfaceBufferStatistics intf_buffer_stats = 2; // Per-port statistics
}

50 changes: 50 additions & 0 deletions proto/sai_tam_event.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2017 Broadcom. The term "Broadcom" refers
* to Broadcom Limited and/or its subsidiaries.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

syntax = "proto2";

import "sai_tam_event_flow_learning.proto";
import "sai_tam_event_threshold_breach.proto";
import "sai_tam_buffer_stats.proto";

message Event {
required uint64 timestamp = 1;

oneof EventType {
Drop drop_event = 2;
FlowLearning flow_event = 3;
ThresholdBreach threshold_event = 4;
SwitchBufferStats switch_buffer_event = 5;
}
}

message Drop {
optional uint32 dummy = 1;
}

message GenEvent {
required string system_id = 1;
optional uint32 component_id = 2;
optional uint32 sub_component_id= 3;
repeated EventPair eventpair = 4;
optional string hostname = 5;
}

message EventPair {
repeated Event event = 1;
repeated Flow flow = 2;
}
48 changes: 48 additions & 0 deletions proto/sai_tam_event_flow_learning.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2017 Broadcom. The term "Broadcom" refers
* to Broadcom Limited and/or its subsidiaries.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

syntax = "proto2";

message FlowLearning {
enum FL_STATE {
FL_INVALID = 0;
FL_LEARN = 1;
FL_AGING = 2;
FL_EXPORT = 3;
FL_TABLE_FULL = 4; /* Atomic event, no other information need to be send */
}
optional FL_STATE fl_state = 1;
}

message Flow {
optional uint32 proto = 1;
optional uint32 sip = 2;
optional uint32 dip = 3;

optional uint32 l4_sport = 4;
optional uint32 l4_dport = 5;
optional uint32 vnid = 6;
optional uint32 inner_proto = 7;
optional uint32 inner_sip = 8;
optional uint32 inner_dip = 9;

optional uint32 inner_l4_sport = 10;
optional uint32 inner_l4_dport = 11;
optional bytes custom_key = 12;
optional uint32 group_id = 13;
optional bytes packet = 14;
}
Loading