summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Jourdan2011-05-10 11:29:03 +0200
committerCyril Jourdan2011-07-27 09:28:47 +0200
commit995546db79268510d50d2d8baab78c462e42691f (patch)
tree18b7afd838f869240129a9c6a54b8135b62644d1
parentf9d2fa175bfd7783ce60312204024a0a7eb31511 (diff)
cesar/mac/common: change window size value management, closes #2499
The RX window size is changed from 200 to 256 to be compliant with the HPAV specification. The function mfs_rx_window_size_encode is replaced by a global conversion table between indexes used in RxWSz field of the FCs and actual values of window size. This makes the access to the values easier and prevent from using non-standard values.
-rw-r--r--cesar/mac/common/mfs.h35
-rw-r--r--cesar/mac/common/src/mfs.c36
-rw-r--r--cesar/mac/pbproc/test/pbproc/src/rx_data.c13
3 files changed, 49 insertions, 35 deletions
diff --git a/cesar/mac/common/mfs.h b/cesar/mac/common/mfs.h
index 316a1a659b..de3a932680 100644
--- a/cesar/mac/common/mfs.h
+++ b/cesar/mac/common/mfs.h
@@ -52,6 +52,29 @@ enum mfs_fsm_rsp_t
};
typedef enum mfs_fsm_rsp_t mfs_fsm_rsp_t;
+/** Window size indexes. */
+enum mfs_window_size_idx_t
+{
+ MFS_WINDOW_SIZE_4,
+ MFS_WINDOW_SIZE_8,
+ MFS_WINDOW_SIZE_16,
+ MFS_WINDOW_SIZE_24,
+ MFS_WINDOW_SIZE_32,
+ MFS_WINDOW_SIZE_48,
+ MFS_WINDOW_SIZE_64,
+ MFS_WINDOW_SIZE_80,
+ MFS_WINDOW_SIZE_96,
+ MFS_WINDOW_SIZE_112,
+ MFS_WINDOW_SIZE_128,
+ MFS_WINDOW_SIZE_144,
+ MFS_WINDOW_SIZE_160,
+ MFS_WINDOW_SIZE_192,
+ MFS_WINDOW_SIZE_224,
+ MFS_WINDOW_SIZE_256,
+ MFS_WINDOW_SIZE_NB
+};
+typedef enum mfs_window_size_idx_t mfs_window_size_idx_t;
+
/** Common fields for TX and RX. */
struct mfs_common_t
{
@@ -208,6 +231,10 @@ typedef union mfs_t mfs_t;
BEGIN_DECLS
+/** Window size values table (values of the RxWSz field of the FCs in which
+ * it is included). */
+extern const u16 mfs_window_size[MFS_WINDOW_SIZE_NB];
+
/**
* Initialise a RX MFS, called from MAC store.
* \param mfs MFS to initialise
@@ -265,14 +292,6 @@ mfs_tx_init (mfs_tx_t *mfs, bool bcast, bool mme, uint lid, uint tei);
void
mfs_tx_init_unassociated (mfs_tx_t *mfs, bool bcast, bool mme, uint lid, uint tei);
-/**
- * Encode window size.
- * \param window_size decoded window size
- * \return encoded window size
- */
-u8
-mfs_rx_window_size_encode (u16 window_size);
-
END_DECLS
#endif /* mac_common_mfs_h */
diff --git a/cesar/mac/common/src/mfs.c b/cesar/mac/common/src/mfs.c
index 2a4fbfe4bd..d61c1b5e3d 100644
--- a/cesar/mac/common/src/mfs.c
+++ b/cesar/mac/common/src/mfs.c
@@ -16,11 +16,19 @@
#include "mac/common/defs.h"
#include "mac/common/timings.h"
-/** MFS MME window size. */
-#define MFS_WINDOW_SIZE_MME 8
+/** MFS MME window size (fixed). */
+#define MFS_WINDOW_SIZE_MME MFS_WINDOW_SIZE_8
-/** MFS DATA window size. */
-#define MFS_WINDOW_SIZE_DATA 200
+/** RX MFS DATA window size (fixed). */
+#define MFS_WINDOW_SIZE_DATA_RX MFS_WINDOW_SIZE_256
+
+/** Default TX MFS DATA window size (actual value is fixed by the receiver). */
+#define MFS_DEFAULT_WINDOW_SIZE_DATA_TX MFS_WINDOW_SIZE_16
+
+/** Window size values table (values of the RxWSz field of the FCs in which
+ * it is included). */
+const u16 mfs_window_size[MFS_WINDOW_SIZE_NB] = { 4, 8, 16, 24, 32, 48, 64, 80,
+ 96, 112, 128, 144, 160, 192, 224, 256 };
static void
mfs_common_init (mfs_common_t *mfs_common, bool tx, bool bcast, bool mme, uint
@@ -54,8 +62,8 @@ mfs_rx_init (mfs_rx_t *mfs, bool bcast, bool mme, uint lid, uint tei)
mfs_common_init (&mfs->common, false, bcast, mme, lid, tei);
mfs->head = NULL;
mfs->ssn_min = 0;
- mfs->window_size = mme ? MFS_WINDOW_SIZE_MME : MFS_WINDOW_SIZE_DATA;
- mfs->window_size_encoded = mfs_rx_window_size_encode (mfs->window_size);
+ mfs->window_size_encoded = mme ? MFS_WINDOW_SIZE_MME : MFS_WINDOW_SIZE_DATA_RX;
+ mfs->window_size = mfs_window_size[mfs->window_size_encoded];
mfs->release = false;
link_stats_rx_reset (&mfs->stats);
}
@@ -87,8 +95,8 @@ mfs_tx_init (mfs_tx_t *mfs, bool bcast, bool mme, uint lid, uint tei)
mfs->pending_seg_nb = 0;
mfs->fsm_state = bcast ? MFS_FSM_CMD_NOP : MFS_FSM_CMD_INIT;
mfs->min_ssn = 0;
- mfs->window_size = mme ? MFS_WINDOW_SIZE_MME : MFS_WINDOW_SIZE_DATA;
- mfs->window_holes_seg_nb = 0;
+ mfs->window_size = mme ? mfs_window_size[MFS_WINDOW_SIZE_MME]
+ : mfs_window_size[MFS_DEFAULT_WINDOW_SIZE_DATA_TX];
if (mme)
mfs->cap = 2;
else
@@ -112,15 +120,3 @@ mfs_tx_init_unassociated (mfs_tx_t *mfs, bool bcast, bool mme, uint lid,
mfs->fsm_state = MFS_FSM_CMD_NOP;
}
-u8
-mfs_rx_window_size_encode (u16 window_size)
-{
- uint i;
- static u16 encode_table[] = { 4, 8, 16, 24, 32, 48, 64, 80, 96, 112, 128,
- 144, 160, 192, 224, 256 };
- dbg_assert (window_size >= 4 && window_size <= 256);
- DICHOTOMY_SEARCH (0, COUNT (encode_table), i,
- window_size < encode_table[i]);
- return i - 1;
-}
-
diff --git a/cesar/mac/pbproc/test/pbproc/src/rx_data.c b/cesar/mac/pbproc/test/pbproc/src/rx_data.c
index 89a023692e..7233e07419 100644
--- a/cesar/mac/pbproc/test/pbproc/src/rx_data.c
+++ b/cesar/mac/pbproc/test/pbproc/src/rx_data.c
@@ -68,7 +68,7 @@ struct rx_data_burst_desc_t
/** Multi-network broadcast. */
bool multi_net_bcast;
/** Window size. */
- u16 window_size;
+ uint window_size_encoded;
/** Number of PB in the PB pool. */
uint pool_pb_nb;
/** Number of channel data. */
@@ -428,15 +428,14 @@ rx_data_burst_test_f (test_t t, test_pbproc_t *tp,
PARENT_OF (pb_t, blk, last), ctx.pool_size);
/* Create an MFS if window_size is not default. */
mfs_rx_t *mfs = NULL;
- if (burst->window_size)
+ if (burst->window_size_encoded)
{
bool added;
mfs = mac_store_mfs_add_rx (tp->store, burst->bcast, false,
burst->lid, ctx.stei, &added);
dbg_assert (added);
- mfs->window_size = burst->window_size;
- mfs->window_size_encoded =
- mfs_rx_window_size_encode (mfs->window_size);
+ mfs->window_size_encoded = burst->window_size_encoded;
+ mfs->window_size = mfs_window_size[burst->window_size_encoded];
ctx.window_size_encoded = mfs->window_size_encoded;
}
else
@@ -579,11 +578,11 @@ rx_data_basic_test_case (test_t t)
MPDU ((.symb_nb = 95, .pb_nb = 5, .tmi = PHY_MOD_ROBO)));
rx_data_burst_test (
t, &tp, .prp_won = false, .pool_pb_nb = 5, .wack = true,
- .lid = 1, .window_size = 160,
+ .lid = 1, .window_size_encoded = MFS_WINDOW_SIZE_160,
MPDU ((.symb_nb = 95, .pb_nb = 5, .tmi = PHY_MOD_ROBO)));
rx_data_burst_test (
t, &tp, .prp_won = false, .pool_pb_nb = 5, .wack = true,
- .lid = 5, .window_size = 160,
+ .lid = 5, .window_size_encoded = MFS_WINDOW_SIZE_160,
MPDU ((.symb_nb = 95, .pb_nb = 5, .tmi = PHY_MOD_ROBO)));
} test_end;
test_begin (t, "robo unicast chandata")