summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Carré2013-04-24 17:36:36 +0200
committerThierry Carré2013-04-26 17:03:20 +0200
commit0fe0af0214b8c073bde08527614a9d635e129b76 (patch)
tree4d84f4ea1426f9a4e2f98e1020eb93cdcda3e6fc
parent6162df52d45db0b1ac71d58cbd6ff44b2485caac (diff)
cesar/cp/av/{fsm, action}: add role forced behavior, refs #3789
-rw-r--r--cesar/cp/av/fsm/src/fsm/cp.fsm43
-rw-r--r--cesar/cp/av/sta/action/Module2
-rw-r--r--cesar/cp/av/sta/action/action.h1
-rw-r--r--cesar/cp/av/sta/action/poweron_role_forced.h26
-rw-r--r--cesar/cp/av/sta/action/src/poweron.c36
-rw-r--r--cesar/cp/av/sta/action/src/poweron_role_forced.c31
-rw-r--r--cesar/cp/av/sta/action/test/utest/Makefile2
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/poweron.c46
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/test_sta_action.c1
9 files changed, 155 insertions, 33 deletions
diff --git a/cesar/cp/av/fsm/src/fsm/cp.fsm b/cesar/cp/av/fsm/src/fsm/cp.fsm
index c62d563f3f..9ed8148fe8 100644
--- a/cesar/cp/av/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/av/fsm/src/fsm/cp.fsm
@@ -47,6 +47,12 @@ States:
CCO_LEAVING_HOIP
UNASSOCIATING [enter=cp_av_sta_action_unassoc__unassoc__enter]
+ STA_FORCED
+ Same as STA, without simple connect & Homeplug AV poweron process.
+ CCO_FORCED [enter=cp_av_cco_action_ucco_start]
+ Same as CCO, without simple connect & Homeplug AV poweron process.
+ CCO_FORCED_STOPPING
+
SC_USTA
Same as USTA, but the STA is doing SC procedure at the same time.
SC_USTA_JOINING
@@ -420,7 +426,9 @@ STOPPING:
sta_status_changed -> . [cp_sta_action_drv__drv_sta_status_ind_send]
IDLE:
- to_poweron -> POWERON [cp_sta_action_poweron__idle__to_poweron]
+ to_poweron: homeplug_av -> POWERON [cp_sta_action_poweron__idle__to_poweron]
+ to_poweron: cco_forced -> CCO_FORCED
+ to_poweron: sta_forced -> STA_FORCED
POWERON:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
@@ -507,6 +515,13 @@ SC_UCCO:
CC_ASSOC_REQ:nok -> . [cp_av_cco_action_sc_ucco__cc_assoc_req]
CC_ASSOC_REQ:ok -> CCO
+STA_FORCED:
+ BEACON: nid match -> . [cp_av_sta_action_poweron__sta_forced__beacon]
+ BEACON: no nid match -> .
+ BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
+ CC_WHO_RU_CNF -> . [cp_sta_action_process_cc_who_ru_cnf]
+ to_stop -> UNASSOCIATING [cp_av_sta_action_assoc_leave]
+
STA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
avln_failure -> POWERON [NULL]
@@ -529,8 +544,23 @@ SC_STA:
sc_failed -> STA [NULL]
sc_succeed -> STA [NULL]
-CCO:
+CCO_FORCED_STOPPING:
+ to_stop -> IDLE [cp_sta_action_poweron__many__to_idle]
+
+CCO_FORCED:
+ to_stop -> CCO_FORCED_STOPPING [cp_av_cco_action_ucco__to_stop]
+
+CCO_FORCED, CCO:
+ CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
+ CC_ASSOC_REQ -> . [cp_av_cco_action_cco__cc_assoc_req]
+ CM_GET_KEY_REQ_PID0 -> . [cp_av_cco_action_cco__cm_get_key_req_pid0]
+ CM_GET_KEY_REQ_PID1 -> . [cp_av_cco_action_cco__cm_get_key_req_pid1]
+ CC_LEAVE_REQ -> . [cp_av_cco_action_cco__cc_leave_req]
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
+ cco__nek_change -> . [cp_av_cco_action_cco__cco_nek_change]
+ cco__snid_conflict -> . [cp_av_cco_action_cco__cco_snid_conflict]
+
+CCO:
BEACON_WITH_SAME_NID -> . [cp_av_cco_action_beacon_with_same_nid]
join_timeout: sta -> . [cp_av_sta_action_poweron__cco__join_timeout]
join_timeout: no sta avln -> USTA
@@ -538,17 +568,8 @@ CCO:
cco__all_sta_leaved -> UCCO [cp_av_cco_action_cco__to_ucco]
to_stop -> CCO_LEAVING [cp_av_cco_action_drv_mac_stop]
discover_info_updated -> . [cp_av_cco_action_cco__cc_discover_list_req]
-
- cco__nek_change -> . [cp_av_cco_action_cco__cco_nek_change]
- cco__snid_conflict -> . [cp_av_cco_action_cco__cco_snid_conflict]
cco_leave_merge_avln -> USTA [cp_av_cco_action_cco__unassoc_stop]
- CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- CC_ASSOC_REQ -> . [cp_av_cco_action_cco__cc_assoc_req]
- CM_GET_KEY_REQ_PID0 -> . [cp_av_cco_action_cco__cm_get_key_req_pid0]
- CM_GET_KEY_REQ_PID1 -> . [cp_av_cco_action_cco__cm_get_key_req_pid1]
- CC_LEAVE_REQ -> . [cp_av_cco_action_cco__cc_leave_req]
-
HANDOVER_DISCOVER_PROCESS_DONE:sta -> HANDOVER_CCO [cp_av_cco_action_handover__discover_done]
HANDOVER_DISCOVER_PROCESS_DONE:no_sta -> .
diff --git a/cesar/cp/av/sta/action/Module b/cesar/cp/av/sta/action/Module
index 79370ecb2e..7642efc6cf 100644
--- a/cesar/cp/av/sta/action/Module
+++ b/cesar/cp/av/sta/action/Module
@@ -1,4 +1,4 @@
SOURCES := sc.c drv.c misc.c handover.c poweron.c action.c assoc.c info.c \
- key.c
+ key.c poweron_role_forced.c
MODULES := cp/sta/action
diff --git a/cesar/cp/av/sta/action/action.h b/cesar/cp/av/sta/action/action.h
index c230025749..7975f0595c 100644
--- a/cesar/cp/av/sta/action/action.h
+++ b/cesar/cp/av/sta/action/action.h
@@ -17,6 +17,7 @@
#include "cp/mme.h"
#include "cp/sta/action/action.h"
+#include "cp/av/sta/action/poweron_role_forced.h"
#include "cp/av/sta/action/sc.h"
#include "cp/av/sta/action/handover.h"
#include "cp/av/sta/action/poweron.h"
diff --git a/cesar/cp/av/sta/action/poweron_role_forced.h b/cesar/cp/av/sta/action/poweron_role_forced.h
new file mode 100644
index 0000000000..73ad773d06
--- /dev/null
+++ b/cesar/cp/av/sta/action/poweron_role_forced.h
@@ -0,0 +1,26 @@
+#ifndef cp_av_sta_action_poweron_role_forced_h
+#define cp_av_sta_action_poweron_role_forced_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2013 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/poweron_role_forced.h
+ * \ingroup cp_av_sta_action
+ */
+#include "cp/inc/context.h"
+#include "bsu/bsu.h"
+
+BEGIN_DECLS
+
+void
+cp_av_sta_action_poweron__sta_forced__beacon (
+ cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta);
+
+END_DECLS
+
+#endif /* cp_av_sta_action_poweron_role_forced_h */
diff --git a/cesar/cp/av/sta/action/src/poweron.c b/cesar/cp/av/sta/action/src/poweron.c
index 91a270cc6d..a46a86b892 100644
--- a/cesar/cp/av/sta/action/src/poweron.c
+++ b/cesar/cp/av/sta/action/src/poweron.c
@@ -54,6 +54,8 @@ cp_av_sta_action_poweron__many__to_idle (cp_t *ctx)
void
cp_av_sta_action_poweron__idle__to_poweron (cp_t *ctx)
{
+ cp_sta_own_data_t *own;
+
cp_beacon_poweron_init (ctx);
bsu_power_on (ctx->bsu, cp_sta_own_data_get_snid (ctx));
/* Update beacon data program a timer is a wrong values beacon ACLF is
@@ -62,6 +64,31 @@ cp_av_sta_action_poweron__idle__to_poweron (cp_t *ctx)
cp_beacon_reconfigure_timer (ctx, false);
sar_activate (ctx->sar, true);
pbproc_activate (ctx->pbproc, true);
+
+ if (ctx->sta_action.poweron.enter.need_set)
+ {
+ cp_sta_own_data_set_nid (ctx, ctx->sta_action.poweron.enter.nid);
+ cp_sta_own_data_set_nmk (ctx, ctx->sta_action.poweron.enter.nmk,
+ ctx->sta_action.poweron.enter.type);
+
+ ctx->sta_action.poweron.enter.need_set = false;
+ }
+
+ own = cp_sta_mgr_get_sta_own_data (ctx);
+ switch (own->force_role)
+ {
+ case MAC_FORCE_ROLE_STA:
+ cp_fsm_branch (ctx, IDLE, to_poweron, sta_forced);
+ break;
+
+ case MAC_FORCE_ROLE_CCO:
+ cp_fsm_branch (ctx, IDLE, to_poweron, cco_forced);
+ break;
+
+ default:
+ cp_fsm_branch (ctx, IDLE, to_poweron, homeplug_av);
+ break;
+ }
}
void
@@ -131,15 +158,6 @@ cp_av_sta_action_poweron__poweron__enter (cp_t *ctx)
/* USTT timer. */
cp_av_sta_action_poweron_ustt_start (ctx, CP_USTA_IND_INTERVAL_MS);
- if (ctx->sta_action.poweron.enter.need_set)
- {
- cp_sta_own_data_set_nid (ctx, ctx->sta_action.poweron.enter.nid);
- cp_sta_own_data_set_nmk (ctx, ctx->sta_action.poweron.enter.nmk,
- ctx->sta_action.poweron.enter.type);
-
- ctx->sta_action.poweron.enter.need_set = false;
- }
-
bsu_beacon_t beacon;
cp_beacon_fill (ctx, &beacon);
/* Act as STA, for BSU corresponds to only hear the central beacon from
diff --git a/cesar/cp/av/sta/action/src/poweron_role_forced.c b/cesar/cp/av/sta/action/src/poweron_role_forced.c
new file mode 100644
index 0000000000..b1b41e447c
--- /dev/null
+++ b/cesar/cp/av/sta/action/src/poweron_role_forced.c
@@ -0,0 +1,31 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2013 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/src/poweron_role_forced.c
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+
+#include "cp/av/sta/action/poweron_role_forced.h"
+#include "cp/fsm/fsm.h"
+#include "cp/av/sta/action/inc/action.h"
+
+void
+cp_av_sta_action_poweron__sta_forced__beacon (
+ cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon);
+ dbg_assert (net);
+ dbg_assert (sta);
+ cp_av_sta_action_beacon_match_and_join (
+ ctx, beacon, net, sta, false /* not in SC */,
+ CP_FSM_BRANCH (STA_FORCED, BEACON, nid_match),
+ CP_FSM_BRANCH (STA_FORCED, BEACON, no_nid_match));
+}
diff --git a/cesar/cp/av/sta/action/test/utest/Makefile b/cesar/cp/av/sta/action/test/utest/Makefile
index 78dfa099c6..604e38c8c2 100644
--- a/cesar/cp/av/sta/action/test/utest/Makefile
+++ b/cesar/cp/av/sta/action/test/utest/Makefile
@@ -4,7 +4,7 @@ INCLUDES = cp/av/sta/action/test/utest cp/av/sta/action/test/utest/override
HOST_PROGRAMS = test_sta_action
test_sta_action_SOURCES = test_sta_action.c assoc.c drv.c info.c key.c \
- bridge.c handover.c \
+ bridge.c handover.c poweron.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 \
diff --git a/cesar/cp/av/sta/action/test/utest/src/poweron.c b/cesar/cp/av/sta/action/test/utest/src/poweron.c
index 49df7066d9..e45dd844ba 100644
--- a/cesar/cp/av/sta/action/test/utest/src/poweron.c
+++ b/cesar/cp/av/sta/action/test/utest/src/poweron.c
@@ -28,6 +28,7 @@ poweron_test_cases (test_t t)
cp_nid_t nid = 0x111111111111ull;
cp_net_t *net = NULL;
cp_sta_t *sta = NULL;
+ cp_sta_own_data_t *own = NULL;
bsu_beacon_t beacon;
test_sta_action_beacon_create (&beacon, nid, 0, 1, 0);
/* Poweron start. */
@@ -35,20 +36,43 @@ poweron_test_cases (test_t t)
test_sta_action_reset (&ctx);
cp_av_sta_action_init (cp);
+ own = cp_sta_mgr_get_sta_own_data (cp);
+
test_begin (t, "start")
{
- scenario_entry_t entries[] = {
- SCENARIO_ACTION (poweron_start),
- SCENARIO_EVENT (cp_fsm_event_bare_new,
- .type = CP_FSM_EVENT_TYPE_to_poweron),
- SCENARIO_ACTION (poweron__idle__to_poweron),
- SCENARIO_EVENT (cp_beacon_reconfigure_timer),
- SCENARIO_EVENT (sar_activate, .flag = true),
- SCENARIO_EVENT (pbproc_activate, .flag = true),
- SCENARIO_END
- };
- scenario_run (t, entries, &globals);
+ for (own->force_role = MAC_FORCE_ROLE_AUTO;
+ own->force_role < MAC_FORCE_ROLE_NB;
+ own->force_role ++)
+ {
+ cp_fsm_branch_t branch_to;
+
+ if (own->force_role == MAC_FORCE_ROLE_AUTO)
+ branch_to = CP_FSM_BRANCH (IDLE, to_poweron,
+ homeplug_av);
+ else if (own->force_role == MAC_FORCE_ROLE_CCO)
+ branch_to = CP_FSM_BRANCH (IDLE, to_poweron,
+ cco_forced);
+ else if (own->force_role == MAC_FORCE_ROLE_STA)
+ branch_to = CP_FSM_BRANCH (IDLE, to_poweron,
+ sta_forced);
+
+ scenario_entry_t entries[] = {
+ SCENARIO_ACTION (poweron_start),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_to_poweron),
+ SCENARIO_ACTION (poweron__idle__to_poweron),
+ SCENARIO_EVENT (cp_beacon_reconfigure_timer),
+ SCENARIO_EVENT (sar_activate, .flag = true),
+ SCENARIO_EVENT (pbproc_activate, .flag = true),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = branch_to),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ }
+
} test_end;
+ own->force_role = MAC_FORCE_ROLE_AUTO;
/* POWERON timers. */
test_case_begin (t, "poweron");
test_sta_action_reset (&ctx);
diff --git a/cesar/cp/av/sta/action/test/utest/src/test_sta_action.c b/cesar/cp/av/sta/action/test/utest/src/test_sta_action.c
index 2cec42d3b9..3980ceda77 100644
--- a/cesar/cp/av/sta/action/test/utest/src/test_sta_action.c
+++ b/cesar/cp/av/sta/action/test/utest/src/test_sta_action.c
@@ -110,6 +110,7 @@ main (int argc, char **argv)
vs_test_suite (t);
bridge_test_suite (t);
handover_test_suite (t);
+ poweron_test_suite (t);
test_result (t);
return test_nb_failed (t) == 0 ? 0 : 1;
}