summaryrefslogtreecommitdiff
path: root/cesar/mac
diff options
context:
space:
mode:
authorMilenko Jelisavcic2013-04-10 16:50:55 +0200
committerMilenko Jelisavcic2013-05-17 17:06:56 +0200
commit3b6f33dbbc2aaaa16b611ab7e2a7988f2a10e1bb (patch)
tree9a665cb389d3f266fc9efedb051dbed8d6615310 /cesar/mac
parentc4af9ed1b61707fab13f3f6900a2b963ecec563e (diff)
cesar/mac/pbproc: use access confirmation in rts-cts, refs #3976
Diffstat (limited to 'cesar/mac')
-rw-r--r--cesar/mac/pbproc/inc/fsm.h3
-rw-r--r--cesar/mac/pbproc/inc/fsm_tx_rts_cts.h34
-rw-r--r--cesar/mac/pbproc/src/fsm.c3
-rw-r--r--cesar/mac/pbproc/src/fsm_tx_rts_cts.c63
-rw-r--r--cesar/mac/pbproc/test/pbproc/src/tx_rts_cts.c80
5 files changed, 139 insertions, 44 deletions
diff --git a/cesar/mac/pbproc/inc/fsm.h b/cesar/mac/pbproc/inc/fsm.h
index 6743ff4eba..217ecaca07 100644
--- a/cesar/mac/pbproc/inc/fsm.h
+++ b/cesar/mac/pbproc/inc/fsm.h
@@ -28,7 +28,8 @@ enum pbproc_fsm_state_t
PBPROC_FSM_STATE_RX_BURST,
PBPROC_FSM_STATE_RX_BEACON,
PBPROC_FSM_STATE_RX_SOUND,
- PBPROC_FSM_STATE_TX_WAIT_CTS,
+ PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_ACCESS_CONF,
+ PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_CTS,
PBPROC_FSM_STATE_TX_WAIT_ACCESS_CONF,
PBPROC_FSM_STATE_TX_WAIT_SACKD,
PBPROC_FSM_STATE_TX_WAIT_TX_END,
diff --git a/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h b/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h
index f73c888728..fe5c047a4a 100644
--- a/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h
+++ b/cesar/mac/pbproc/inc/fsm_tx_rts_cts.h
@@ -30,21 +30,45 @@ void
pbproc_ftrc__handle (pbproc_t *ctx);
/**
- * TX WAIT CTS =RX=FC=>.
+ * TX RTS CTS WAIT ACCESS CONF =ACCESS=CONF=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftrc__tx_rts_cts_wait_access_conf__access_conf (pbproc_t *ctx);
+
+/**
+ * TX RTS CTS WAIT ACCESS CONF =RX=FC=>.
+ * \param ctx pbproc context
+ * \param rx_date start of preamble date
+ * \param fc_av frame control, or NULL if FCCS error
+ */
+void
+pbproc_ftrc__tx_rts_cts_wait_access_conf__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
+
+/**
+ * TX RTS CTS WAIT ACCESS CONF =ACCESS=>.
+ * \param ctx pbproc context
+ */
+void
+pbproc_ftrc__tx_rts_cts_wait_access_conf__access (pbproc_t *ctx);
+
+/**
+ * TX RTS CTS WAIT CTS =RX=FC=>.
* \param ctx pbproc context
* \param rx_date start of preamble date
* \param fc_av frame control, or NULL if FCCS error
*/
void
-pbproc_ftrc__tx_wait_cts__rx_fc (pbproc_t *ctx, u32 rx_date,
- const pbproc_fc_t *fc_av);
+pbproc_ftrc__tx_rts_cts_wait_cts__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av);
/**
- * TX WAIT CTS =ACCESS=>.
+ * TX RTS CTS WAIT CTS =ACCESS=>.
* \param ctx pbproc context
*/
void
-pbproc_ftrc__tx_wait_cts__access (pbproc_t *ctx);
+pbproc_ftrc__tx_rts_cts_wait_cts__access (pbproc_t *ctx);
END_DECLS
diff --git a/cesar/mac/pbproc/src/fsm.c b/cesar/mac/pbproc/src/fsm.c
index 2270690f91..b036768935 100644
--- a/cesar/mac/pbproc/src/fsm.c
+++ b/cesar/mac/pbproc/src/fsm.c
@@ -253,7 +253,8 @@ pbproc_fsm_state_name (pbproc_fsm_state_t state)
"RX_BURST",
"RX_BEACON",
"RX_SOUND",
- "TX_WAIT_CTS",
+ "TX_RTS_CTS_WAIT_ACCESS_CONF",
+ "TX_RTS_CTS_WAIT_CTS",
"TX_WAIT_ACCESS_CONF",
"TX_WAIT_SACKD",
"TX_WAIT_TX_END",
diff --git a/cesar/mac/pbproc/src/fsm_tx_rts_cts.c b/cesar/mac/pbproc/src/fsm_tx_rts_cts.c
index 00aa587f08..cb878ae634 100644
--- a/cesar/mac/pbproc/src/fsm_tx_rts_cts.c
+++ b/cesar/mac/pbproc/src/fsm_tx_rts_cts.c
@@ -20,6 +20,7 @@
#include "mac/pbproc/inc/fsm_tx_sound.h"
#include "mac/pbproc/inc/fsm_handle_fc.h"
#include "mac/pbproc/inc/prep_mpdu.h"
+#include "inc/pbproc.h"
#include "mac/pbproc/inc/fsm_tx_rts_cts.h"
@@ -27,13 +28,19 @@ void
pbproc_ftrc_init (pbproc_t *ctx)
{
dbg_assert (ctx);
- ctx->fsm.states[PBPROC_FSM_STATE_TX_WAIT_CTS].rx_fc_cb =
- CALLBACK (pbproc_ftrc__tx_wait_cts__rx_fc);
- ctx->fsm.states[PBPROC_FSM_STATE_TX_WAIT_CTS].access_cb =
- CALLBACK (pbproc_ftrc__tx_wait_cts__access);
+ ctx->fsm.states[PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_ACCESS_CONF].rx_fc_cb =
+ CALLBACK (pbproc_ftrc__tx_rts_cts_wait_access_conf__rx_fc);
+ ctx->fsm.states[PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_ACCESS_CONF].access_cb =
+ CALLBACK (pbproc_ftrc__tx_rts_cts_wait_access_conf__access);
+ ctx->fsm.states[PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_ACCESS_CONF].access_conf_cb =
+ CALLBACK (pbproc_ftrc__tx_rts_cts_wait_access_conf__access_conf);
+ ctx->fsm.states[PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_CTS].rx_fc_cb =
+ CALLBACK (pbproc_ftrc__tx_rts_cts_wait_cts__rx_fc);
+ ctx->fsm.states[PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_CTS].access_cb =
+ CALLBACK (pbproc_ftrc__tx_rts_cts_wait_cts__access);
}
-void ARCH_ILRAM
+void ARCH_ILRAM_PRIO (2)
pbproc_ftrc__handle (pbproc_t *ctx)
{
dbg_claim (ctx);
@@ -41,13 +48,10 @@ pbproc_ftrc__handle (pbproc_t *ctx)
phy_tx_fc10 (ctx->phy, ctx->prep_mpdu.rts_tx_date,
ctx->prep_mpdu.fc10);
phy_tx_param_short (ctx->phy, ctx->prep_mpdu.fc_mode);
- phy_tx_frame (ctx->phy, ctx->prep_mpdu.rts_tx_date, false, true,
+ phy_tx_frame (ctx->phy, ctx->prep_mpdu.rts_tx_date, true, true,
ctx->prep_mpdu.rts_fc_av.words);
ca_access_vcs_restart_eifs (ctx->ca, ctx->prep_mpdu.rts_tx_date);
- phy_rx_activate (ctx->phy, false,
- ctx->prep_mpdu.rts_tx_date
- + ctx->times.rts_rcg_tck, true);
- pbproc_fsm_change_state (ctx, PBPROC_FSM_STATE_TX_WAIT_CTS);
+ pbproc_fsm_change_state (ctx, PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_ACCESS_CONF);
}
static void
@@ -63,8 +67,39 @@ pbproc_ftrc_tx_cancel (pbproc_t *ctx)
}
void ARCH_ILRAM_PRIO (2)
-pbproc_ftrc__tx_wait_cts__rx_fc (pbproc_t *ctx, u32 rx_date,
- const pbproc_fc_t *fc_av)
+pbproc_ftrc__tx_rts_cts_wait_access_conf__access_conf (pbproc_t *ctx)
+{
+ dbg_claim (ctx);
+ phy_rx_activate (ctx->phy, false,
+ ctx->prep_mpdu.rts_tx_date + ctx->times.rts_rcg_tck, true);
+ pbproc_fsm_change_state (ctx, PBPROC_FSM_STATE_TX_RTS_CTS_WAIT_CTS);
+}
+
+void ARCH_ILRAM_PRIO (3)
+pbproc_ftrc__tx_rts_cts_wait_access_conf__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av)
+{
+ dbg_claim (ctx);
+ /* Update backoff. */
+ pbproc_backoff_lost (ctx);
+ /* Handle FC. */
+ pbproc_fhfc_handle_fc (ctx, rx_date, fc_av);
+ /* Now, we have time, cancel transmission. */
+ pbproc_ftrc_tx_cancel (ctx);
+}
+
+void ARCH_ILRAM_PRIO (3)
+pbproc_ftrc__tx_rts_cts_wait_access_conf__access (pbproc_t *ctx)
+{
+ dbg_claim (ctx);
+ /* Cancel the transmission. */
+ pbproc_ftrc_tx_cancel (ctx);
+ pbproc_ftop__idle__access (ctx);
+}
+
+void ARCH_ILRAM_PRIO (2)
+pbproc_ftrc__tx_rts_cts_wait_cts__rx_fc (pbproc_t *ctx, u32 rx_date,
+ const pbproc_fc_t *fc_av)
{
dbg_claim (ctx);
/* Is it our CTS. */
@@ -99,8 +134,8 @@ pbproc_ftrc__tx_wait_cts__rx_fc (pbproc_t *ctx, u32 rx_date,
}
}
-void ARCH_ILRAM_PRIO (2)
-pbproc_ftrc__tx_wait_cts__access (pbproc_t *ctx)
+void ARCH_ILRAM_PRIO (3)
+pbproc_ftrc__tx_rts_cts_wait_cts__access (pbproc_t *ctx)
{
dbg_claim (ctx);
/* Cancel the transmission. */
diff --git a/cesar/mac/pbproc/test/pbproc/src/tx_rts_cts.c b/cesar/mac/pbproc/test/pbproc/src/tx_rts_cts.c
index 1a93f36c7e..e49093e989 100644
--- a/cesar/mac/pbproc/test/pbproc/src/tx_rts_cts.c
+++ b/cesar/mac/pbproc/test/pbproc/src/tx_rts_cts.c
@@ -25,6 +25,8 @@ enum rts_cts_test_t
RTS_CTS_TEST_CTS_LATE,
RTS_CTS_TEST_CTS_NFU,
RTS_CTS_TEST_CTS_NO,
+ RTS_CTS_TEST_ACCESS_CONF_NO,
+ RTS_CTS_TEST_ACCESS_CONF_FC,
};
typedef enum rts_cts_test_t rts_cts_test_t;
@@ -58,13 +60,15 @@ tx_rts_cts_test (test_t t, test_pbproc_t *tp, u32 date, uint mfs_seg_nb,
.prp = true,
.cfp = false,
};
+ bool nfu_frame = type == RTS_CTS_TEST_CTS_NFU
+ || type == RTS_CTS_TEST_ACCESS_CONF_FC;
/* CTS. */
pbproc_fc_rts_cts_t rts_cts_fc = {
.dt_av = PBPROC_FC_DT_RTS_CTS,
.access = false,
.snid = tp->snid,
.dtei = stei,
- .stei = ack_dtei + (type == RTS_CTS_TEST_CTS_NFU ? 2 : 0),
+ .stei = ack_dtei + nfu_frame,
.rtsf = false,
.lid = lid,
.mnbf = false,
@@ -98,12 +102,16 @@ tx_rts_cts_test (test_t t, test_pbproc_t *tp, u32 date, uint mfs_seg_nb,
+ MAC_PAYLOAD_TCK (symb_nb, MAC_DX417_TCK) + rifs_tck;
const uint rts_cts_rcg_tck = pre_fcs_tck + MAC_RCG_TCK;
/* Short scenario. Frame are not sent.*/
- bool rts_fail = type == RTS_CTS_TEST_CTS_LATE ||
- type == RTS_CTS_TEST_CTS_NO || type == RTS_CTS_TEST_CTS_NFU;
+ bool access_conf_no = type == RTS_CTS_TEST_ACCESS_CONF_NO;
+ bool access_conf_fc = type == RTS_CTS_TEST_ACCESS_CONF_FC;
+ bool access_conf_fail = access_conf_no || access_conf_fc;
bool no_cts = type == RTS_CTS_TEST_CTS_NO;
+ bool late_frame = type == RTS_CTS_TEST_CTS_LATE;
+ bool no_frame = access_conf_no || no_cts;
+ bool rts_fail = late_frame || nfu_frame || no_frame;
uint date2 = date + tp->pbproc->times.rts_rcg_cts_cmg_tck;
uint date3 = date + rts_cts_rcg_tck +
- (type == RTS_CTS_TEST_CTS_LATE ? MAC_TOLERANCE_TCK + 100 : 0);
+ (late_frame ? MAC_TOLERANCE_TCK + 100 : 0);
/* Scenarios. */
scenario_entry_t entries_long[] = {
/* Send RTS. */
@@ -114,9 +122,10 @@ tx_rts_cts_test (test_t t, test_pbproc_t *tp, u32 date, uint mfs_seg_nb,
SCENARIO_EVENT_COND (hybrid, phy_tx_fc10, .date = date,
.fc10 = 0x200000),
SCENARIO_EVENT (phy_tx_param_short, .fc_mode = fc_mode),
- SCENARIO_EVENT (phy_tx_frame, .date = date, .want_conf = false,
+ SCENARIO_EVENT (phy_tx_frame, .date = date, .want_conf = true,
.stop_tx_on_prp_lost = true),
SCENARIO_EVENT (ca_access_vcs_restart_eifs, .start_date = date),
+ SCENARIO_ACTION (phy_access_conf),
SCENARIO_EVENT (phy_rx_activate, .now = false,
.date = date + rts_cts_rcg_tck,
.pre_detection = true),
@@ -165,32 +174,34 @@ tx_rts_cts_test (test_t t, test_pbproc_t *tp, u32 date, uint mfs_seg_nb,
SCENARIO_EVENT_COND (hybrid, phy_tx_fc10, .date = date,
.fc10 = 0x200000),
SCENARIO_EVENT (phy_tx_param_short, .fc_mode = fc_mode),
- SCENARIO_EVENT (phy_tx_frame, .date = date, .want_conf = false,
+ SCENARIO_EVENT (phy_tx_frame, .date = date, .want_conf = true,
.stop_tx_on_prp_lost = true),
SCENARIO_EVENT (ca_access_vcs_restart_eifs, .start_date = date),
- SCENARIO_EVENT (phy_rx_activate, .now = false,
+ SCENARIO_ACTION_COND (!access_conf_fail, phy_access_conf),
+ SCENARIO_EVENT_COND (!access_conf_fail, phy_rx_activate, .now = false,
.date = date + rts_cts_rcg_tck,
.pre_detection = true),
/* Receive CTS. */
- SCENARIO_ACTION_COND (!no_cts, phy_rx_fc, .rx_date = date3,
+ SCENARIO_ACTION_COND (!no_frame, phy_rx_fc, .rx_date = date3,
.fc_av = (u32 *) &rts_cts_fc, .slot_count = 15),
- SCENARIO_EVENT_COND (!no_cts, phy_tx_cancel),
- SCENARIO_EVENT_COND (!no_cts, ca_access_hold),
- SCENARIO_EVENT_COND (!no_cts, phy_rx_prepare_short),
- SCENARIO_EVENT_COND (!no_cts, ca_access_vcs_restart_eifs,
+ SCENARIO_EVENT_COND (access_conf_fc, ca_backoff_cancel),
+ SCENARIO_EVENT_COND (!no_frame, phy_tx_cancel),
+ SCENARIO_EVENT_COND (!no_frame, ca_access_hold),
+ SCENARIO_EVENT_COND (!no_frame, phy_rx_prepare_short),
+ SCENARIO_EVENT_COND (!no_frame, ca_access_vcs_restart_eifs,
.start_date = date3 + rts_cts_rcg_tck),
- SCENARIO_EVENT_COND (!no_cts, phy_rx_activate, .now = false,
+ SCENARIO_EVENT_COND (!no_frame, phy_rx_activate, .now = false,
.date = date3 + rts_cts_rcg_tck,
.pre_detection = true),
- SCENARIO_EVENT_COND (!no_cts, ca_access_done),
+ SCENARIO_EVENT_COND (!no_frame, ca_access_done),
/* Timeout. Access timer activated. */
- SCENARIO_ACTION_COND (no_cts, phy_access, .prp_won = true,
+ SCENARIO_ACTION_COND (no_frame, phy_access, .prp_won = true,
.access_param = &access, .slot_count = 600),
- SCENARIO_EVENT_COND (no_cts, ca_access_done),
- SCENARIO_EVENT_COND (no_cts, ca_access_hold),
- SCENARIO_EVENT_COND (no_cts, ca_access_get_mfs),
- SCENARIO_EVENT_COND (no_cts, ca_access_done),
- SCENARIO_EVENT_COND (no_cts, ca_access_defer, .date = date),
+ SCENARIO_EVENT_COND (no_frame, ca_access_done),
+ SCENARIO_EVENT_COND (no_frame, ca_access_hold),
+ SCENARIO_EVENT_COND (no_frame, ca_access_get_mfs),
+ SCENARIO_EVENT_COND (no_frame, ca_access_done),
+ SCENARIO_EVENT_COND (no_frame, ca_access_defer, .date = date),
SCENARIO_END
};
scenario_globals_t globals = {
@@ -203,9 +214,10 @@ tx_rts_cts_test (test_t t, test_pbproc_t *tp, u32 date, uint mfs_seg_nb,
.tx_data_wack = rts_fail ? 0 : 1,
.tx_data_wack_ack = rts_fail ? 0 : 1,
.rts_fail = rts_fail ? 1 : 0,
- .rx_handle_fc = rts_fail && !no_cts ? 1 : 0,
- .tx_invalid = no_cts ? 1 : 0,
- .rx_nfu = rts_fail && !no_cts ? 1 : 0);
+ .prp_lost = access_conf_fc ? 1 : 0,
+ .rx_handle_fc = rts_fail && !no_frame ? 1 : 0,
+ .tx_invalid = no_frame ? 1 : 0,
+ .rx_nfu = rts_fail && !no_frame ? 1 : 0);
test_fail_unless (mfs->fsm_state == MFS_FSM_CMD_NOP);
test_fail_unless (mfs->stats.num_mpdus == (rts_fail ? 0 : 1));
test_fail_unless (mfs->stats.num_bursts == (rts_fail ? 0 : 1));
@@ -266,6 +278,28 @@ tx_rts_cts_test_case (test_t t)
+ MAC_PREAMBLE_TCK + MAC_FC_AV_TCK + MAC_RCG_TCK,
19, 1, PHY_MOD_ROBO, RTS_CTS_TEST_CTS_NO, false);
} test_end;
+ test_begin (t, "access conf no -> access")
+ {
+ tx_rts_cts_test (t, &tp, 5462132, 40,
+ MAC_PREAMBLE_TCK + MAC_FC_AV_TCK
+ + MAC_PAYLOAD_TCK (50, MAC_DX417_TCK)
+ + MAC_RIFS_DEFAULT_TCK
+ + MAC_PREAMBLE_TCK + MAC_FC_AV_TCK + MAC_CMG_TCK
+ + MAC_PREAMBLE_TCK + MAC_FC_AV_TCK + MAC_RCG_TCK,
+ 19, 1, PHY_MOD_ROBO, RTS_CTS_TEST_ACCESS_CONF_NO,
+ false);
+ } test_end;
+ test_begin (t, "access conf no -> fc")
+ {
+ tx_rts_cts_test (t, &tp, 5462132, 40,
+ MAC_PREAMBLE_TCK + MAC_FC_AV_TCK
+ + MAC_PAYLOAD_TCK (50, MAC_DX417_TCK)
+ + MAC_RIFS_DEFAULT_TCK
+ + MAC_PREAMBLE_TCK + MAC_FC_AV_TCK + MAC_CMG_TCK
+ + MAC_PREAMBLE_TCK + MAC_FC_AV_TCK + MAC_RCG_TCK,
+ 19, 1, PHY_MOD_ROBO, RTS_CTS_TEST_ACCESS_CONF_FC,
+ false);
+ } test_end;
test_begin (t, "data hybrid")
{
tx_rts_cts_test (t, &tp, 5462132, 30,