summaryrefslogtreecommitdiff
path: root/cesar/mac
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac')
-rw-r--r--cesar/mac/common/mfs.h2
-rw-r--r--cesar/mac/common/src/mfs.c1
-rw-r--r--cesar/mac/pbproc/src/prep_mpdu.c22
-rw-r--r--cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c83
4 files changed, 88 insertions, 20 deletions
diff --git a/cesar/mac/common/mfs.h b/cesar/mac/common/mfs.h
index 7d731c83a5..632cdebe56 100644
--- a/cesar/mac/common/mfs.h
+++ b/cesar/mac/common/mfs.h
@@ -175,6 +175,8 @@ struct mfs_tx_t
/** Number of holes in the MFS, i.e. number of acknowledged or canceled
* segment in the MFS. */
u16 holes_seg_nb;
+ /** Difference between the Tx ssn_min and the Rx ssn_min. */
+ u16 delta_between_ssn_min;
/** Channel Access Priority. */
uint cap;
diff --git a/cesar/mac/common/src/mfs.c b/cesar/mac/common/src/mfs.c
index a16a10994c..9cb8202965 100644
--- a/cesar/mac/common/src/mfs.c
+++ b/cesar/mac/common/src/mfs.c
@@ -108,6 +108,7 @@ mfs_tx_init (mfs_tx_t *mfs, bool bcast, bool mme, uint lid, uint tei)
mfs->window_size = mme ? mfs_window_size[MFS_WINDOW_SIZE_MME]
: mfs_window_size[MFS_DEFAULT_WINDOW_SIZE_DATA_TX];
mfs->holes_seg_nb = 0;
+ mfs->delta_between_ssn_min = 0;
if (mme)
mfs->cap = 2;
else
diff --git a/cesar/mac/pbproc/src/prep_mpdu.c b/cesar/mac/pbproc/src/prep_mpdu.c
index 87f4839a71..15b21d5fbd 100644
--- a/cesar/mac/pbproc/src/prep_mpdu.c
+++ b/cesar/mac/pbproc/src/prep_mpdu.c
@@ -137,14 +137,14 @@ pbproc_prep_beacon (pbproc_t *ctx, mfs_tx_t *mfs)
prep->wack = false;
prep->unassociated = false;
prep->rts_cts = false;
+ prep->burst_mpdu_nb = 1;
+ prep->mpdu_count = 0;
+ prep->current = &prep->mpdu[0];
#if CONFIG_MAC_PBPROC_EOC_FC
prep->fc_mode = PHY_FC_MODE (false, ctx->config->fc_symbols_nb);
#else
prep->fc_mode = PHY_FC_MODE (true, ctx->config->fc_symbols_nb);
#endif
- prep->burst_mpdu_nb = 1;
- prep->mpdu_count = 0;
- prep->current = &prep->mpdu[0];
prep->sound_reason_code = TONEMAP_SRC_NULL;
prep->bypass_aes = true;
/* Modulation. */
@@ -463,11 +463,13 @@ pbproc_prep_mpdu (pbproc_t *ctx, mfs_tx_t *mfs)
if (mfs->ca_state == CA_MFS_STATE_REMOVED)
max_seg_nb = 0;
else if (mfs->fsm_state == MFS_FSM_CMD_RE_SYNC
- || mfs->window_size <= mfs->holes_seg_nb)
+ || mfs->window_size <= (mfs->holes_seg_nb
+ + mfs->delta_between_ssn_min))
max_seg_nb = MIN (mfs->seg_nb, 1);
else
max_seg_nb = MIN (mfs->seg_nb, (int) (mfs->window_size
- - mfs->holes_seg_nb - prep->burst_seg_nb));
+ - mfs->holes_seg_nb - prep->burst_seg_nb
+ - mfs->delta_between_ssn_min));
#endif
}
@@ -1631,6 +1633,8 @@ pbproc_prep_mpdu_commit_burst (pbproc_t *ctx)
if (prep->main_commit_return_head)
{
prep->min_rx_ssn = prep->main_commit_return_head->header.ssn;
+ if (!prep->main_commit_return_head->header.opsf)
+ mfs->delta_between_ssn_min = 0;
/* If the MFS has been removed or if the last sent PB has expired,
* do not give PB back. Do not put more than one PB in a beacon MFS. */
bool expire_return =
@@ -1663,6 +1667,8 @@ pbproc_prep_mpdu_commit_burst (pbproc_t *ctx)
mfs->seg_nb += prep->main_commit_return_seg_nb_reserved;
prep->main_commit_return_seg_nb_reserved = 0;
}
+ else
+ mfs->delta_between_ssn_min = 0;
/* Update number of holes in the MFS. */
if (prep->main_commit_return_seg_nb)
{
@@ -1695,6 +1701,12 @@ pbproc_prep_mpdu_commit_burst (pbproc_t *ctx)
else
mfs->holes_seg_nb = 0;
}
+ /* Update synchronization between tx and rx ssn_min. */
+ if (mfs->ca_state != CA_MFS_STATE_REMOVED)
+ {
+ u16 min_tx_ssn = mfs->head ? mfs->head->header.ssn : mfs->next_ssn;
+ mfs->delta_between_ssn_min += min_tx_ssn - prep->min_rx_ssn;
+ }
#if !CONFIG_MAC_PBPROC_EOC_FC
/* Commit FSM change. */
pbproc_prep_mpdu_commit_fsm (ctx);
diff --git a/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c b/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c
index 95ac99efc2..72083ed432 100644
--- a/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c
+++ b/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c
@@ -106,6 +106,10 @@ struct prep_mpdu_test_t
bool mfs_fsm_state_test;
/* Expected MFS FSM state after SACK reception. */
mfs_fsm_cmd_t expected_mfs_fsm_state;
+ /* Initial delta between RX and TX ssn min. */
+ u16 min_ssn_delta;
+ /* Expected delta between RX and TX ssn min. */
+ u16 expected_delta;
};
#define prep_mpdu_test(t, tp, date, params...) \
@@ -191,6 +195,7 @@ prep_mpdu_test_f (test_t t, test_pbproc_t *tp, u32 date,
/* Setup receiver window size */
if (params->window_size)
mfs->window_size = mfs_window_size[params->window_size];
+ mfs->delta_between_ssn_min = params->min_ssn_delta;
/* Encrypted? */
utils_prepare_encryption (tp, params->encrypted, !params->bcast, dtei, 0);
/* Setup an access. */
@@ -531,6 +536,8 @@ prep_mpdu_test_f (test_t t, test_pbproc_t *tp, u32 date,
}
/* Test update of number of holes in the MFS. */
test_fail_unless (mfs->holes_seg_nb == expected_holes_nb);
+ /* Test update of delta between RX and TX min ssn. */
+ test_fail_unless (mfs->delta_between_ssn_min == params->expected_delta);
/* Test update of MFS FSM state in case of expiration. */
if (params->mfs_fsm_state_test)
test_fail_unless (mfs->fsm_state == params->expected_mfs_fsm_state);
@@ -1106,51 +1113,54 @@ prep_mpdu_expiration_test_case (test_t t)
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .duration_symb_nb = 50,
.symb_nb = 25, .main_seg_nb_total = 40, .seg_nb_pending = 1,
.expiration_date = 20 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 0, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .duration_symb_nb = 50,
.symb_nb = 25, .main_seg_nb_total = 40, .seg_nb_pending = 1,
.expiration_date = 50 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 40, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .duration_symb_nb = 50,
.symb_nb = 25, .main_seg_nb_total = 40, .seg_nb_pending = 1,
.crc = true, .crc_error = { 0x0fa5c03a, 0x15 },
.expiration_date = 50 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 39, .tmi = 5, .tm_mod = 10);
} test_end;
test_begin (t, "expiration on chaining")
{
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 200, .duration_symb_nb = 50,
.symb_nb = 50, .main_seg_nb_total = 83, .seg_nb_pending = 0,
.expiration_date = 80 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 0, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 200, .duration_symb_nb = 50,
.symb_nb = 50, .main_seg_nb_total = 83, .seg_nb_pending = 0,
.expiration_date = 150 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 147, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 200, .duration_symb_nb = 50,
.symb_nb = 50, .main_seg_nb_total = 83, .seg_nb_pending = 0,
.expiration_date = 250 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 147, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 200, .duration_symb_nb = 50,
.symb_nb = 50, .main_seg_nb_total = 83, .seg_nb_pending = 0,
.crc = true, .crc_error = { 0x0fa5c03a, 0x15, 0x7ff00 },
.expiration_date = 150 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 146, .tmi = 5, .tm_mod = 10);
} test_end;
test_begin (t, "expiration with cancel")
{
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .duration_symb_nb = 50,
.symb_nb = 25, .main_seg_nb_total = 40, .seg_nb_pending = 1,
.expiration_date = 3 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .no_access_conf = true, .tmi = 5, .tm_mod = 10);
+ .no_access_conf = true, .expected_delta = 0,
+ .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .duration_symb_nb = 50,
.symb_nb = 25, .main_seg_nb_total = 40, .seg_nb_pending = 1,
.expiration_date = 50 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .no_access_conf = true, .tmi = 5, .tm_mod = 10);
+ .no_access_conf = true, .expected_delta = 4,
+ .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .duration_symb_nb = 50,
.symb_nb = 25, .main_seg_nb_total = 40, .seg_nb_pending = 1,
.expiration_date = 200 * UTILS_MFS_EXPIRATION_NTB_STEP,
- .no_access_conf = true, .tmi = 5, .tm_mod = 10);
+ .no_access_conf = true, .expected_delta = 4,
+ .tmi = 5, .tm_mod = 10);
} test_end;
test_pbproc_uninit (&tp);
}
@@ -1239,35 +1249,37 @@ prep_mpdu_window_size_test_case (test_t t)
.symb_nb = 12, .main_seg_nb_total = 19, .seg_nb_pending = 0,
.expiration_date = 22 * UTILS_MFS_EXPIRATION_NTB_STEP,
.expected_mfs_fsm_state = MFS_FSM_CMD_IN_SYNC,
- .all_ok = true, .tmi = 5, .tm_mod = 10);
+ .expected_delta = 3, .all_ok = true, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 30, .mfs_holes_bitmap = 0xAA,
.window_size = MFS_WINDOW_SIZE_24, .duration_symb_nb = 50,
.symb_nb = 13, .main_seg_nb_total = 20, .seg_nb_pending = 1,
.crc = true, .crc_error = { 0x00021084 },
.expiration_date = 15 * UTILS_MFS_EXPIRATION_NTB_STEP,
.expected_mfs_fsm_state = MFS_FSM_CMD_IN_SYNC,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 0, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 30, .mfs_holes_bitmap = 0xAA,
.window_size = MFS_WINDOW_SIZE_24, .duration_symb_nb = 50,
.symb_nb = 13, .main_seg_nb_total = 20, .seg_nb_pending = 1,
.crc = true, .crc_error = { 0x00021084 },
.expiration_date = 22 * UTILS_MFS_EXPIRATION_NTB_STEP,
.expected_mfs_fsm_state = MFS_FSM_CMD_IN_SYNC,
- .tmi = 5, .tm_mod = 10);
+ .expected_delta = 22, .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 30, .mfs_holes_bitmap = 0xAA,
.window_size = MFS_WINDOW_SIZE_24, .duration_symb_nb = 50,
.symb_nb = 13, .main_seg_nb_total = 20, .seg_nb_pending = 1,
.crc = true, .crc_error = { 0x00021084 },
.expiration_date = 50 * UTILS_MFS_EXPIRATION_NTB_STEP,
.expected_mfs_fsm_state = MFS_FSM_CMD_RE_SYNC,
- .mfs_fsm_state_test = true, .tmi = 5, .tm_mod = 10);
+ .mfs_fsm_state_test = true, .expected_delta = 30,
+ .tmi = 5, .tm_mod = 10);
prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 200, .mfs_holes_bitmap = 0xAA,
.window_size = MFS_WINDOW_SIZE_24, .duration_symb_nb = 50,
.symb_nb = 13, .main_seg_nb_total = 20, .seg_nb_pending = 1,
.crc = true, .crc_error = { 0x00021084 },
.expiration_date = 100 * UTILS_MFS_EXPIRATION_NTB_STEP,
.expected_mfs_fsm_state = MFS_FSM_CMD_RE_SYNC,
- .mfs_fsm_state_test = true, .tmi = 5, .tm_mod = 10);
+ .mfs_fsm_state_test = true, .expected_delta = 84,
+ .tmi = 5, .tm_mod = 10);
} test_end;
test_begin (t, "no access conf")
{
@@ -1280,6 +1292,47 @@ prep_mpdu_window_size_test_case (test_t t)
.symb_nb = 13, .main_seg_nb_total = 20, .seg_nb_pending = 1,
.no_access_conf = true, .tmi = 5, .tm_mod = 10);
} test_end;
+ test_begin (t, "RX/TX ssn min delta")
+ {
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 25, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 16, .main_seg_nb_total = 25, .seg_nb_pending = 1,
+ .min_ssn_delta = 4, .expected_delta = 0,
+ .all_ok = true, .tmi = 5, .tm_mod = 10);
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 18, .main_seg_nb_total = 28, .seg_nb_pending = 1,
+ .min_ssn_delta = 4, .expected_delta = 0,
+ .all_ok = true, .tmi = 5, .tm_mod = 10);
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 18, .main_seg_nb_total = 28, .seg_nb_pending = 1,
+ .min_ssn_delta = 4, .expected_delta = 0,
+ .crc = true, .crc_error = { 0x00021084 },
+ .tmi = 5, .tm_mod = 10);
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 18, .main_seg_nb_total = 28, .seg_nb_pending = 1,
+ .expiration_date = 33 * UTILS_MFS_EXPIRATION_NTB_STEP,
+ .min_ssn_delta = 4, .expected_delta = 5,
+ .all_ok = true, .tmi = 5, .tm_mod = 10);
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 18, .main_seg_nb_total = 28, .seg_nb_pending = 1,
+ .min_ssn_delta = 4, .expected_delta = 4, .tmi = 5, .tm_mod = 10);
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 18, .main_seg_nb_total = 28, .seg_nb_pending = 1,
+ .min_ssn_delta = 4, .expected_delta = 4,
+ .crc = true, .crc_error = { 0x00000001 },
+ .tmi = 5, .tm_mod = 10);
+ prep_mpdu_test (t, &tp, 0, .mfs_seg_nb = 40, .mfs_holes_bitmap = 0,
+ .window_size = MFS_WINDOW_SIZE_32, .duration_symb_nb = 50,
+ .symb_nb = 18, .main_seg_nb_total = 28, .seg_nb_pending = 1,
+ .expiration_date = 33 * UTILS_MFS_EXPIRATION_NTB_STEP,
+ .min_ssn_delta = 4, .expected_delta = 37,
+ .tmi = 5, .tm_mod = 10);
+ } test_end;
test_pbproc_uninit (&tp);
}