summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/mac/pbproc/Config1
-rw-r--r--cesar/mac/pbproc/src/prep_mpdu.c41
-rw-r--r--cesar/mac/pbproc/test/pbproc/Config1
-rw-r--r--cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c48
4 files changed, 81 insertions, 10 deletions
diff --git a/cesar/mac/pbproc/Config b/cesar/mac/pbproc/Config
index 6d8e591baa..39ca0616a6 100644
--- a/cesar/mac/pbproc/Config
+++ b/cesar/mac/pbproc/Config
@@ -2,3 +2,4 @@ CONFIG_GPIO_LED_TRAFFIC = n
CONFIG_GPIO_LED_TRAFFIC_GPIO = 2
CONFIG_GPIO_LED_PBPROC_ALIVE = n
CONFIG_GPIO_LED_PBPROC_ALIVE_GPIO = 3
+CONFIG_MAC_PBPROC_BEACON_RTSCTS = n
diff --git a/cesar/mac/pbproc/src/prep_mpdu.c b/cesar/mac/pbproc/src/prep_mpdu.c
index a6b0055801..871638eee9 100644
--- a/cesar/mac/pbproc/src/prep_mpdu.c
+++ b/cesar/mac/pbproc/src/prep_mpdu.c
@@ -20,6 +20,7 @@
#include "inc/sacki_dec.h"
#include "inc/mfs.h"
+#include "config/mac/pbproc.h"
#include <string.h>
@@ -144,12 +145,11 @@ pbproc_prep_beacon (pbproc_t *ctx, mfs_tx_t *mfs)
if (!mfs->seg_nb)
return;
/* Fill easy fields. */
- prep->stei = 0;
+ prep->stei = ctx->config->tei;
prep->dtei = MAC_TEI_BCAST;
prep->lid = MAC_LID_NONE;
prep->wack = false;
prep->unassociated = false;
- prep->rts_cts = false;
prep->burst_mpdu_nb = 1;
prep->mpdu_count = 0;
prep->current = &prep->mpdu[0];
@@ -163,8 +163,32 @@ pbproc_prep_beacon (pbproc_t *ctx, mfs_tx_t *mfs)
prep->phy_combo_params = tm->phy_combo_params[PHY_PB_SIZE_136];
prep->gil = tm->gil;
prep->tonemap = tm->tmdma_desc_head;
+ uint access_duration_tck = access->duration_tck;
+ uint rts_cts_dur_tck, ack_dtei;
+
+ if (CONFIG_MAC_PBPROC_BEACON_RTSCTS)
+ {
+ pbproc_times_t * const times = &ctx->times;
+ ack_dtei = ctx->config->partial_ack_tei_default;
+ rts_cts_dur_tck = times->rts_rcg_cts_cmg_tck;
+ prep->rts_cts = MAC_TEI_IS_STA (ack_dtei)
+ && access_duration_tck > rts_cts_dur_tck;
+ /* Prepare start dates and raw access duration. */
+ if (prep->rts_cts)
+ {
+ prep->rts_tx_date = access->access_date;
+ prep->tx_date = prep->rts_tx_date + rts_cts_dur_tck;
+ access_duration_tck -= rts_cts_dur_tck;
+ }
+ else
+ prep->tx_date = access->access_date;
+ }
+ else
+ {
+ prep->rts_cts = false;
+ prep->tx_date = access->access_date;
+ }
/* Compute number of symbols. */
- prep->tx_date = access->access_date;
u32 symb_nb = (1 * tm->bits_per_pb[PHY_PB_SIZE_136]
+ tm->bits_per_symbol - 1) / tm->bits_per_symbol;
u32 data_tck = MAC_PAYLOAD_TCK (symb_nb, ctx->symbol_tck[tm->gil]);
@@ -174,8 +198,17 @@ pbproc_prep_beacon (pbproc_t *ctx, mfs_tx_t *mfs)
prep->flp_tck = pre_fcs_tck + data_tck + MAC_B2BIFS_TCK;
prep->symb_nb = symb_nb;
/* Does it fit? */
- if (prep->flp_tck > access->duration_tck)
+ if (prep->flp_tck > access_duration_tck)
return;
+ /* Prepare RTS FC. */
+ if (prep->rts_cts && CONFIG_MAC_PBPROC_BEACON_RTSCTS)
+ {
+ uint duration_tck = rts_cts_dur_tck + prep->flp_tck;
+ pbproc_prep_rts_cts_fc (ctx, mfs, ack_dtei, prep, access->cfp,
+ duration_tck);
+ /* Invalid FC 1.0, HP 1.0 stations will defer (20 symbols and ROBO). */
+ prep->rts_fc10 = 0x200000;
+ }
/* Get beacon PB. */
pb_t *seg;
seg = mfs->head;
diff --git a/cesar/mac/pbproc/test/pbproc/Config b/cesar/mac/pbproc/test/pbproc/Config
index 214e0dced9..278c1cc24c 100644
--- a/cesar/mac/pbproc/test/pbproc/Config
+++ b/cesar/mac/pbproc/test/pbproc/Config
@@ -1,3 +1,4 @@
CONFIG_TRACE = y
CONFIG_STATS = n
CONFIG_DEBUG_FATAL_CATCH = y
+CONFIG_MAC_PBPROC_BEACON_RTSCTS = y
diff --git a/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c b/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c
index 852feac5df..fdb9bd1d29 100644
--- a/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c
+++ b/cesar/mac/pbproc/test/pbproc/src/prep_mpdu.c
@@ -1507,7 +1507,7 @@ prep_mpdu_window_size_test_case (test_t t)
void
prep_beacon_test (test_t t, test_pbproc_t *tp, u32 date, bool prepared,
- uint duration_symb_nb, uint symb_nb)
+ uint duration_symb_nb, uint symb_nb, bool rts_cts)
{
test_within (t);
dbg_assert (tp);
@@ -1537,21 +1537,26 @@ prep_beacon_test (test_t t, test_pbproc_t *tp, u32 date, bool prepared,
+ MAC_B2BIFS_TCK;
access->prp = false;
access->cfp = true;
+ tp->config.partial_ack_tei_default = rts_cts ? 55 : MAC_TEI_BCAST;
+ /* Move start time. */
+ uint rts_cts_dur_tck = tp->pbproc->times.rts_rcg_cts_cmg_tck;
+ if (rts_cts)
+ date += rts_cts_dur_tck;
/* Prepare beacon. */
pbproc_prep_beacon (tp->pbproc, mfs);
/* Check result. */
pbproc_prep_mpdu_t *prep = &tp->pbproc->prep_mpdu;
- test_fail_unless (prep->stei == 0);
+ test_fail_unless (prep->stei == tp->config.tei);
test_fail_unless (prep->dtei == MAC_TEI_BCAST);
test_fail_unless (prep->lid == MAC_LID_NONE);
test_fail_unless (!prep->wack);
test_fail_unless (!prep->unassociated);
- test_fail_unless (!prep->rts_cts);
test_fail_unless (prep->burst_mpdu_nb == 1);
test_fail_unless (prep->mpdu_count == 0);
test_fail_unless (prep->current == &prep->mpdu[0]);
if (symb_nb)
{
+ test_fail_unless (prep->rts_cts == rts_cts);
test_fail_unless (prep->valid);
test_fail_unless (prep->main_mfs == mfs);
test_fail_unless (prep->tx_date == date);
@@ -1605,6 +1610,25 @@ prep_beacon_test (test_t t, test_pbproc_t *tp, u32 date, bool prepared,
test_fail_unless (mfs->head == seg);
test_fail_unless (mfs->tail == seg);
test_fail_unless (!mfs->holes_seg_nb);
+ /* Check rts_cts FC. */
+ if (prep->rts_cts)
+ {
+ pbproc_fc_rts_cts_t * rts = &prep->rts_fc_av.rts_cts;
+ test_fail_unless (rts->dt_av == PBPROC_FC_DT_RTS_CTS);
+ test_fail_unless (rts->access == false);
+ test_fail_unless (rts->snid == tp->snid);
+ test_fail_unless (!rts->mnbf);
+ test_fail_unless (rts->mcf);
+ test_fail_unless (rts->lid == prep->lid);
+ test_fail_unless (rts->rtsf);
+ test_fail_unless (rts->dtei
+ == tp->config.partial_ack_tei_default);
+ uint dur = MAC_TCK_TO_FL (rts_cts_dur_tck + prep->flp_tck);
+ test_fail_unless (rts->dur == dur);
+ test_fail_unless (rts->reserved0 == 0);
+ test_fail_unless (rts->reserved1 == 0);
+ test_fail_unless (rts->reserved2 == 0);
+ }
}
else
{
@@ -1638,15 +1662,27 @@ prep_mpdu_beacon_test_case (test_t t)
test_pbproc_init (&tp);
test_begin (t, "valid")
{
- prep_beacon_test (t, &tp, 123456, true, 6, 6);
+ prep_beacon_test (t, &tp, 123456, true, 6, 6, false);
} test_end;
test_begin (t, "unvalid")
{
- prep_beacon_test (t, &tp, 54321, true, 5, 0);
+ prep_beacon_test (t, &tp, 54321, true, 5, 0, false);
} test_end;
test_begin (t, "no seg")
{
- prep_beacon_test (t, &tp, 54321, false, 6, 0);
+ prep_beacon_test (t, &tp, 54321, false, 6, 0, false);
+ } test_end;
+ test_begin (t, "valid, cts_rts")
+ {
+ prep_beacon_test (t, &tp, 54321, true, 20, 6, true);
+ } test_end;
+ test_begin (t, "invalid, cts_rts")
+ {
+ prep_beacon_test (t, &tp, 54321, true, 10, 0, true);
+ } test_end;
+ test_begin (t, "no_seg, cts_rts")
+ {
+ prep_beacon_test (t, &tp, 54321, false, 20, 0, true);
} test_end;
test_pbproc_uninit (&tp);
}