From 84e1bbf1f4c126dae336126fb8f7ea4dd41ec0a3 Mon Sep 17 00:00:00 2001
From: sverma <saurabh.verma@iopsys.eu>
Date: Thu, 10 Dec 2020 17:41:53 +0530
Subject: [PATCH] map-controller: Added 'hysteresis' parameter in config file
 (17.2.12 TLV).

---
 src/controller.conf            | 2 ++
 src/core/cntlr_tlv_generator.c | 3 ++-
 src/core/config.c              | 8 ++++++++
 src/core/config.h              | 1 +
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/controller.conf b/src/controller.conf
index e34cb611..15501534 100644
--- a/src/controller.conf
+++ b/src/controller.conf
@@ -52,6 +52,7 @@ config agent-policy
 	option report_metric_periodic '0'          # 0, or 1 - 255 in secs
 	option report_rcpi_threshold '0'           # 0, or 1 - 220
 	option report_util_threshold '0'           # 0, or  channel-util value
+	option rcpi_hysteresis_margin '0'          # 0, or > 0 - hysteresis margin
 	option include_sta_stats '0'               # sta stats in AP metric resp
 	option include_sta_metric '0'              # sta metric in AP metric resp
 	option pvid '100'                          # primary vlan id
@@ -72,6 +73,7 @@ config agent-policy
 	option report_metric_periodic '0'          # 0, or 1 - 255 in secs
 	option report_rcpi_threshold '0'           # 0, or 1 - 220
 	option report_util_threshold '0'           # 0, or  channel-util value
+	option rcpi_hysteresis_margin '0'          # 0, or > 0 - hysteresis margin
 	option include_sta_stats '0'               # sta stats in AP metric resp
 	option include_sta_metric '0'              # sta metric in AP metric resp
 	option pvid '100'                          # primary vlan id
diff --git a/src/core/cntlr_tlv_generator.c b/src/core/cntlr_tlv_generator.c
index 2c8b11c5..558492cb 100644
--- a/src/core/cntlr_tlv_generator.c
+++ b/src/core/cntlr_tlv_generator.c
@@ -397,7 +397,8 @@ struct tlv_metric_report_policy *cntlr_gen_metric_report_policy(
 		memcpy(p->metric_reporting_policy[i].radio_id, &radiolist[i*6], 6);
 		p->metric_reporting_policy[i].rcpi_thres =
 						a->report_rcpi_threshold;
-		p->metric_reporting_policy[i].rcpi_hysteresis_margin; //FIXME
+		p->metric_reporting_policy[i].rcpi_hysteresis_margin =
+						a->rcpi_hysteresis_margin;
 		p->metric_reporting_policy[i].channel_utilization_thres =
 						a->report_util_threshold;
 		p->metric_reporting_policy[i].is_assoc_sta_traffic_stats =
diff --git a/src/core/config.c b/src/core/config.c
index 293494f6..08db6bd4 100644
--- a/src/core/config.c
+++ b/src/core/config.c
@@ -91,6 +91,7 @@ void cntlr_config_dump(struct controller_config *c)
 	dbg("  Report metric         : %d\n", c->apolicy.report_metric_periodic);
 	dbg("  Report RCPI-thresh    : %d\n", c->apolicy.report_rcpi_threshold);
 	dbg("  Report Util-thresh    : %d\n", c->apolicy.report_util_threshold);
+	dbg("  RCPI hysteresis margin: %d\n", c->apolicy.rcpi_hysteresis_margin);
 	dbg("  Include STA stats     : %d\n", c->apolicy.include_sta_stats);
 	dbg("  Include STA metric    : %d\n", c->apolicy.include_sta_metric);
 	dbg("  Primary VLAN ID       : %d\n", c->apolicy.pvid);
@@ -259,6 +260,7 @@ static int cntlr_config_get_agent_policy(struct controller_config *c,
 		POL_RPT_METRIC_PERIODIC,
 		POL_RPT_RCPI_TH,
 		POL_RPT_UTIL_TH,
+		POL_RPT_HYS_MARGIN,
 		POL_INC_STA_STATS,
 		POL_INC_STA_METRIC,
 		POL_PVID,
@@ -280,6 +282,7 @@ static int cntlr_config_get_agent_policy(struct controller_config *c,
 		{ .name = "report_metric_periodic", .type = UCI_TYPE_STRING },
 		{ .name = "report_rcpi_threshold", .type = UCI_TYPE_STRING },
 		{ .name = "report_util_threshold", .type = UCI_TYPE_STRING },
+		{ .name = "rcpi_hysteresis_margin", .type = UCI_TYPE_STRING },
 		{ .name = "include_sta_stats", .type = UCI_TYPE_STRING },
 		{ .name = "include_sta_metric", .type = UCI_TYPE_STRING },
 		{ .name = "pvid", .type = UCI_TYPE_STRING },
@@ -358,6 +361,11 @@ static int cntlr_config_get_agent_policy(struct controller_config *c,
 				atoi(tb[POL_RPT_UTIL_TH]->v.string);
 	}
 
+	if (tb[POL_RPT_HYS_MARGIN]) {
+		a->rcpi_hysteresis_margin =
+				atoi(tb[POL_RPT_HYS_MARGIN]->v.string);
+	}
+
 	if (tb[POL_INC_STA_STATS]) {
 		a->include_sta_stats =
 			atoi(tb[POL_INC_STA_STATS]->v.string) == 1 ?
diff --git a/src/core/config.h b/src/core/config.h
index 75c0af2a..b4aa7029 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -72,6 +72,7 @@ struct agent_policy {
 	uint8_t report_metric_periodic;   /* 0 = disable, else 1 - 255 in secs */
 	uint8_t report_rcpi_threshold;    /* 0, or 1 - 220 */
 	uint8_t report_util_threshold;    /* 0, or channel utilization value */
+	uint8_t rcpi_hysteresis_margin;   /* 0, or > 0 - hysteresis margin */
 	bool include_sta_stats;           /* sta stats in AP metric response */
 	bool include_sta_metric;          /* sta metric in AP metric response */
 	uint16_t pvid;                    /* primary vlan id */
-- 
GitLab