summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/cp/av/sta/action/test/utest/Makefile2
-rw-r--r--cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h21
-rw-r--r--cesar/cp/av/sta/action/test/utest/override/hal/arch/platform.h19
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/arch_stub.c21
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/msg_stub.c10
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/scenario_actions.c2
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/vs.c101
-rw-r--r--cesar/cp/defs.h6
-rw-r--r--cesar/cp/sta/action/src/vs.c58
-rw-r--r--cesar/cp/sta/action/vs.h9
10 files changed, 247 insertions, 2 deletions
diff --git a/cesar/cp/av/sta/action/test/utest/Makefile b/cesar/cp/av/sta/action/test/utest/Makefile
index ca1d30eda7..78dfa099c6 100644
--- a/cesar/cp/av/sta/action/test/utest/Makefile
+++ b/cesar/cp/av/sta/action/test/utest/Makefile
@@ -8,7 +8,7 @@ test_sta_action_SOURCES = test_sta_action.c assoc.c drv.c info.c key.c \
msg_stub.c dataplane_stub.c fsm_stub.c \
core_stub.c beacon_stub.c cp_stub.c \
cco_stub.c scenario_actions.c vs.c ce_stub.c \
- mac_sar_interface_stub.c
+ mac_sar_interface_stub.c arch_stub.c
test_sta_action_MODULES = lib lib/scenario cp/av/sta/action cp/av/sta/mgr \
cp/av/fsm/stub cp/secu mac/common cl/stub cl \
diff --git a/cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h b/cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h
index e8eb4ee8c5..c08770019e 100644
--- a/cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h
@@ -169,7 +169,8 @@
vs__started__vs_get_snr_req, \
vs_get_snr_cnf_send, \
vs__started__vs_get_ce_stats_req, \
- vs__started__vs_get_pb_stats_req
+ vs__started__vs_get_pb_stats_req, \
+ vs__started__vs_get_attenuation_list_req
/* Actions without parameter. */
#define __0(action) \
@@ -279,6 +280,7 @@ __n (vs_get_snr_cnf_send, phy_chandata_t * chan_data,
u16 tm_ber, bool success)
__m (vs__started__vs_get_ce_stats_req)
__m (vs__started__vs_get_pb_stats_req)
+__m (vs__started__vs_get_attenuation_list_req)
__0 (poweron_start)
__0 (poweron_stop)
@@ -360,6 +362,9 @@ __0 (whoru_timeout_process)
/* Scenario events. */
#define SCENARIO_DEFS_EVENTS \
+ \
+ arch_is_spc300, \
+ \
cp_msg_cc_who_ru_req_send, \
cp_msg_cc_who_ru_req_receive, \
cp_msg_cc_who_ru_cnf_send, \
@@ -499,6 +504,11 @@ __0 (whoru_timeout_process)
cp_msg_vs_get_link_stats_req_receive, \
cp_msg_vs_get_link_stats_cnf_send, \
\
+ cp_msg_vs_get_attenuation_list_req_receive, \
+ cp_msg_vs_get_attenuation_list_cnf_send_begin, \
+ cp_msg_vs_get_attenuation_list_cnf_send_entry, \
+ cp_msg_vs_get_attenuation_list_cnf_send_end, \
+ \
cp_msg_imac_get_discover_list_req_receive, \
cp_msg_imac_get_discover_list_cnf_send_begin, \
cp_msg_imac_get_discover_list_cnf_send, \
@@ -798,6 +808,13 @@ __ms (cp_msg_vs_get_snr_cnf_send,
tonemap_intervals_t *intervals,
u16 tm_ber, u8 carrier_gr, u32 *snr)
+__mr (cp_msg_vs_get_attenuation_list_req_receive)
+__ms (cp_msg_vs_get_attenuation_list_cnf_send_begin, uint nb)
+__msc (cp_msg_vs_get_attenuation_list_cnf_send_entry,
+ mac_t mac, cp_tei_t tei,
+ vs_get_attenuation_list_att_status_t status, s8 attenuation_db)
+__msc (cp_msg_vs_get_attenuation_list_cnf_send_end)
+
__mr (cp_msg_imac_get_discover_list_req_receive)
__ms (cp_msg_imac_get_discover_list_cnf_send_begin,
cp_msg_imac_get_discover_list_cnf_result_t result,
@@ -844,6 +861,8 @@ typedef struct \
PREPROC_FOR_EACH (__p_, ## param) \
} scenario_event_ ## event ## _t;
+__er (arch_is_spc300)
+
__e (cp_fsm_event_bare_new, cp_fsm_event_type_t type)
__e (cp_fsm_event_mme_new, cp_fsm_event_type_t type)
__e (cp_fsm_branch, cp_fsm_branch_t branch)
diff --git a/cesar/cp/av/sta/action/test/utest/override/hal/arch/platform.h b/cesar/cp/av/sta/action/test/utest/override/hal/arch/platform.h
new file mode 100644
index 0000000000..850711274a
--- /dev/null
+++ b/cesar/cp/av/sta/action/test/utest/override/hal/arch/platform.h
@@ -0,0 +1,19 @@
+#ifndef hal_arch_platform_h
+#define hal_arch_platform_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/test/utest/hal/arch/platform.h
+ * \brief Platform specific functions.
+ * \ingroup cp_av_sta_action
+ */
+
+bool
+arch_is_spc300 (void);
+
+#endif /* hal_arch_platform_h */
diff --git a/cesar/cp/av/sta/action/test/utest/src/arch_stub.c b/cesar/cp/av/sta/action/test/utest/src/arch_stub.c
new file mode 100644
index 0000000000..c3a4ce438e
--- /dev/null
+++ b/cesar/cp/av/sta/action/test/utest/src/arch_stub.c
@@ -0,0 +1,21 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/test/utest/src/arch_stub.c
+ * \brief arch stub.
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+#include "lib/scenario/scenario.h"
+
+bool
+arch_is_spc300 (void)
+{
+ scenario_event (arch_is_spc300, param);
+ return param->ok;
+}
diff --git a/cesar/cp/av/sta/action/test/utest/src/msg_stub.c b/cesar/cp/av/sta/action/test/utest/src/msg_stub.c
index 17b458f870..23f409be71 100644
--- a/cesar/cp/av/sta/action/test/utest/src/msg_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/msg_stub.c
@@ -601,6 +601,16 @@ __mrd (cp_msg_vs_get_link_stats_req_receive, cp_msg_vs_get_link_stats_req_t,
(cp_msg_vs_get_link_stats_req_mgmtflag_t, Mgmt_Flag, assign),
(mac_t, dasa, assign))
+__mr (cp_msg_vs_get_attenuation_list_req_receive)
+__mscb (cp_msg_vs_get_attenuation_list_cnf_send_begin,
+ (uint, nb, assign))
+__msc (cp_msg_vs_get_attenuation_list_cnf_send_entry,
+ (mac_t, mac, assign),
+ (cp_tei_t, tei, assign),
+ (vs_get_attenuation_list_att_status_t, status, assign),
+ (s8, attenuation_db, assign))
+__msc (cp_msg_vs_get_attenuation_list_cnf_send_end)
+
__mr (cp_msg_imac_get_discover_list_req_receive)
__mscb (cp_msg_imac_get_discover_list_cnf_send_begin,
(const cp_msg_imac_get_discover_list_cnf_result_t, result, assign),
diff --git a/cesar/cp/av/sta/action/test/utest/src/scenario_actions.c b/cesar/cp/av/sta/action/test/utest/src/scenario_actions.c
index ace9e57a69..c25dbabd56 100644
--- a/cesar/cp/av/sta/action/test/utest/src/scenario_actions.c
+++ b/cesar/cp/av/sta/action/test/utest/src/scenario_actions.c
@@ -264,5 +264,7 @@ __m (vs__started__vs_get_tonemap_req)
__m (vs__started__vs_get_link_stats_req)
__m (vs__started__imac_get_discover_list_req)
+__m (vs__started__vs_get_attenuation_list_req)
+
__m (vs__started__vs_get_ce_stats_req)
__m (vs__started__vs_get_pb_stats_req)
diff --git a/cesar/cp/av/sta/action/test/utest/src/vs.c b/cesar/cp/av/sta/action/test/utest/src/vs.c
index 966d7fc05b..dc7c83720b 100644
--- a/cesar/cp/av/sta/action/test/utest/src/vs.c
+++ b/cesar/cp/av/sta/action/test/utest/src/vs.c
@@ -971,6 +971,106 @@ vs_get_pb_stats_test_case (test_t t)
}
void
+vs_get_attenuation_list_test_case (test_t test)
+{
+ test_case_begin (test, "VS_GET_ATTENUATION_LIST");
+
+ test_sta_action_t ctx;
+
+ /* Init globals. */
+ scenario_globals_t globals =
+ {
+ .cp = &ctx.cp,
+ };
+
+ cp_mme_peer_t peer = CP_MME_PEER (0x112233445577ull, 5);
+ cp_mme_tx_t mme_to_send;
+ globals.mme = &mme_to_send;
+
+ test_sta_action_init (&ctx);
+
+ test_begin (test, "basic behavior")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (vs__started__vs_get_attenuation_list_req,
+ .peer = peer),
+ SCENARIO_EVENT (cp_msg_vs_get_attenuation_list_req_receive,
+ .ok = false),
+ SCENARIO_ACTION (vs__started__vs_get_attenuation_list_req,
+ .peer = peer),
+ SCENARIO_EVENT (cp_msg_vs_get_attenuation_list_req_receive,
+ .ok = true),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_begin,
+ .peer = peer,
+ .nb = 0),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_end),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ } test_end;
+
+ /* Add the AVLN. */
+ cp_sta_own_data_set_tei (&ctx.cp, 1);
+ cp_net_t *net = cp_sta_mgr_add_avln (&ctx.cp, 1, 1);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx.cp, net, 2, 2);
+ sta_t *mac_sta = mac_store_sta_get (ctx.cp.mac_store, 2);
+ mac_sta->agc_gain = 29;
+ mac_sta->agc_gain_valid = VS_GET_ATTENUATION_LIST_ATT_VALID;
+ test_begin (test, "Send the MMe with the attenuation of a station")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (vs__started__vs_get_attenuation_list_req,
+ .peer = peer),
+ SCENARIO_EVENT (cp_msg_vs_get_attenuation_list_req_receive,
+ .ok = true),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_begin,
+ .peer = peer,
+ .nb = 1),
+ SCENARIO_EVENT (arch_is_spc300, .ok = true),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_entry,
+ .mac = cp_sta_get_mac_address (sta),
+ .tei = cp_sta_get_tei (sta),
+ .status = VS_GET_ATTENUATION_LIST_ATT_VALID,
+ .attenuation_db =
+ mac_sta->agc_gain + CP_AGC_SPC300_ATTENUATION_OFFSET
+ - CP_AV_AGC_GAIN_OFFSET),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_end),
+ SCENARIO_ACTION (vs__started__vs_get_attenuation_list_req,
+ .peer = peer),
+ SCENARIO_EVENT (cp_msg_vs_get_attenuation_list_req_receive,
+ .ok = true),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_begin,
+ .peer = peer,
+ .nb = 1),
+ SCENARIO_EVENT (arch_is_spc300, .ok = false),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_entry,
+ .mac = cp_sta_get_mac_address (sta),
+ .tei = cp_sta_get_tei (sta),
+ .status = VS_GET_ATTENUATION_LIST_ATT_VALID,
+ .attenuation_db =
+ mac_sta->agc_gain - CP_AV_AGC_GAIN_OFFSET),
+ SCENARIO_EVENT (
+ cp_msg_vs_get_attenuation_list_cnf_send_end),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ } test_end;
+ slab_release (sta);
+ blk_release (mac_sta);
+ test_sta_action_uninit (&ctx);
+}
+
+void
vs_test_suite (test_t t)
{
test_suite_begin (t, "vs");
@@ -980,6 +1080,7 @@ vs_test_suite (test_t t)
vs_get_snr_test_case (t);
vs_get_ce_stats_test_case (t);
vs_get_pb_stats_test_case (t);
+ vs_get_attenuation_list_test_case (t);
test_case_begin (t, "memory");
test_begin (t, "memory")
{
diff --git a/cesar/cp/defs.h b/cesar/cp/defs.h
index 977f05dd63..e94c13f6a2 100644
--- a/cesar/cp/defs.h
+++ b/cesar/cp/defs.h
@@ -151,4 +151,10 @@
#define CP_TIMER_OFFSET_CCO MAC_MS_TO_TCK(20)
#define CP_TIMER_OFFSET_STA MAC_MS_TO_TCK(5)
+/** Attenuation offset for SPC300 */
+#define CP_AGC_SPC300_ATTENUATION_OFFSET 14
+
+/** Attenuation offset for AV boards. */
+#define CP_AV_AGC_GAIN_OFFSET 6
+
#endif /* cp_defs_h */
diff --git a/cesar/cp/sta/action/src/vs.c b/cesar/cp/sta/action/src/vs.c
index 3934bb465b..d3050d9482 100644
--- a/cesar/cp/sta/action/src/vs.c
+++ b/cesar/cp/sta/action/src/vs.c
@@ -12,6 +12,7 @@
*/
#include "common/std.h"
+#include "hal/arch/platform.h"
#include "mac/common/store.h"
#include "cp/msg/msg.h"
#include "cp/sta/mgr/sta.h"
@@ -663,3 +664,60 @@ cp_sta_action_vs__started__vs_get_mactotei_req (cp_t *ctx, cp_mme_rx_t *mme)
cp_msg_vs_get_mactotei_cnf_send_end (ctx, mme_tx);
}
}
+
+void
+cp_sta_action_vs__started__vs_get_attenuation_list_req (
+ cp_t *ctx, cp_mme_rx_t *mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ if (cp_msg_vs_get_attenuation_list_req_receive (ctx, mme))
+ {
+ cp_mme_tx_t *mme_tx;
+ cp_net_t *net = NULL;
+ uint nb_stations = 0;
+ cp_sta_t *sta;
+ cp_tei_t tei;
+ sta_t *mac_sta;
+ s8 attenuation_db;
+
+ /* To get our AVLN it must be at least associated i.e. Have a TEI. */
+ if (MAC_TEI_IS_STA (cp_sta_own_data_get_tei (ctx)))
+ {
+ net = cp_sta_mgr_get_our_avln (ctx);
+ nb_stations = cp_net_num_sta_associated (ctx, net);
+ }
+ else
+ nb_stations = 0;
+
+ mme_tx = cp_msg_vs_get_attenuation_list_cnf_send_begin (
+ ctx, &mme->peer, nb_stations);
+
+ /* If no station is associated in the AVLN or the plug is not
+ * associated, there is no need to processed anything, just send an
+ * empty MME. */
+ if (nb_stations)
+ {
+ s8 attenuation_offset_db =
+ arch_is_spc300 () ? CP_AGC_SPC300_ATTENUATION_OFFSET : 0;
+
+ for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
+ sta;
+ sta = cp_net_sta_get_next (ctx, net, sta))
+ {
+ tei = cp_sta_get_tei (sta);
+ mac_sta = mac_store_sta_get (ctx->mac_store, tei);
+ dbg_assert (mac_sta);
+ attenuation_db = mac_sta->agc_gain + attenuation_offset_db
+ - CP_AV_AGC_GAIN_OFFSET;
+ blk_release (mac_sta);
+ cp_msg_vs_get_attenuation_list_cnf_send_entry (
+ ctx, mme_tx, cp_sta_get_mac_address (sta),
+ tei, mac_sta->agc_gain_valid, attenuation_db);
+ }
+ }
+
+ cp_msg_vs_get_attenuation_list_cnf_send_end (ctx, mme_tx);
+ }
+}
diff --git a/cesar/cp/sta/action/vs.h b/cesar/cp/sta/action/vs.h
index 4ab9016f03..fa615d258f 100644
--- a/cesar/cp/sta/action/vs.h
+++ b/cesar/cp/sta/action/vs.h
@@ -98,6 +98,15 @@ void
cp_sta_action_vs__started__imac_get_discover_list_req (cp_t *ctx,
cp_mme_rx_t *mme);
+/**
+ * Handle STARTED => VS_GET_ATTENUATION_LIST.REQ.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ */
+void
+cp_sta_action_vs__started__vs_get_attenuation_list_req (
+ cp_t *ctx, cp_mme_rx_t *mme);
+
END_DECLS
#endif /* cp_sta_action_vs_h */