summaryrefslogtreecommitdiff
path: root/mac
diff options
context:
space:
mode:
authorschodet2007-11-23 14:34:01 +0000
committerschodet2007-11-23 14:34:01 +0000
commit9f7433d20988fbe46159eb56038112161a2ca0a6 (patch)
tree72b410655a49dc77b050f7a50268e7087bc66686 /mac
parent6e216bd08ae1730849276bc0b1ed52c0595883bd (diff)
* mac/ca:
- handle hybrid mode for RX. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1042 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'mac')
-rw-r--r--mac/ca/ca.h14
-rw-r--r--mac/ca/inc/alloc.h17
-rw-r--r--mac/ca/inc/context.h2
-rw-r--r--mac/ca/src/access.c11
-rw-r--r--mac/ca/test/ca/src/test_access.c30
-rw-r--r--mac/ca/test/ca/src/test_alloc.c8
-rw-r--r--mac/common/defs.h4
-rw-r--r--mac/common/src/store.c4
8 files changed, 69 insertions, 21 deletions
diff --git a/mac/ca/ca.h b/mac/ca/ca.h
index d8494466f9..d79aaf5b3c 100644
--- a/mac/ca/ca.h
+++ b/mac/ca/ca.h
@@ -125,6 +125,17 @@ struct ca_access_param_t
};
typedef struct ca_access_param_t ca_access_param_t;
+/** Allocation parameters for current allocation.
+ * This structure is read by BP Processing to setup RX. */
+struct ca_access_alloc_param_t
+{
+ /** Coexistence mode. */
+ mac_coexistence_mode_t coexistence_mode;
+ /** Hybrid frame control. */
+ bool hybrid;
+};
+typedef struct ca_access_alloc_param_t ca_access_alloc_param_t;
+
BEGIN_DECLS
/**
@@ -207,8 +218,9 @@ ca_access_defer (ca_t *ctx, u32 date, uint anticipation_tck);
/**
* Called at the AIFS start in order to set up access for next allocation.
* \param ctx ca context
+ * \return pointer to internal new allocation parameters
*/
-void
+const ca_access_alloc_param_t *
ca_access_aifs (ca_t *ctx);
/**
diff --git a/mac/ca/inc/alloc.h b/mac/ca/inc/alloc.h
index 8245c1cd18..47524d248b 100644
--- a/mac/ca/inc/alloc.h
+++ b/mac/ca/inc/alloc.h
@@ -22,17 +22,20 @@
|| (lid) == MAC_LID_LOCAL_CSMA)
/** Is the specified LID usable for transmission? */
-#define CA_ALLOC_IS_USABLE(lid) (MAC_LID_IS_GLID (lid) \
- || CA_ALLOC_IS_CSMA (lid))
+#define CA_ALLOC_IS_USABLE(lid) ((lid) != MAC_LID_SPC_HOLE \
+ && (lid) != MAC_LID_CFPI)
/** Should transmissions in the specified allocation use hybrid frame
- * controls according to the specified coexistence mode. */
+ * controls according to the specified coexistence mode. An additional test
+ * should be done for proxy beacon MFS. */
#define CA_ALLOC_IS_HYBRID(coex, lid) \
- (lid == MAC_LID_DISCOVER \
+ (coex == MAC_COEXISTENCE_FULL_HYBRID_MODE \
+ || coex == MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE \
|| ((lid) == MAC_LID_SHARED_CSMA \
- && coex != MAC_COEXISTENCE_AV_ONLY_MODE) \
- || coex == MAC_COEXISTENCE_FULL_HYBRID_MODE \
- || coex == MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE)
+ && coex == MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE) \
+ || lid == MAC_LID_SPC_HOLE \
+ || lid == MAC_LID_SPC_CENTRAL \
+ || lid == MAC_LID_DISCOVER)
/**
* Find the beacon period index corresponding to the given date.
diff --git a/mac/ca/inc/context.h b/mac/ca/inc/context.h
index 0096042cdf..7b6c9b7d02 100644
--- a/mac/ca/inc/context.h
+++ b/mac/ca/inc/context.h
@@ -57,6 +57,8 @@ struct ca_t
uint current_beacon_period;
/** Current allocation index in current schedule. */
uint current_allocation_index;
+ /** Current allocation parameters. */
+ ca_access_alloc_param_t current_allocation_param;
/** Priority sorted MFS heap. */
heap_t mfs_heap;
/** List of CFP MFS held until the next beacon period. */
diff --git a/mac/ca/src/access.c b/mac/ca/src/access.c
index 7cdec9a7b8..c33f79c885 100644
--- a/mac/ca/src/access.c
+++ b/mac/ca/src/access.c
@@ -151,7 +151,8 @@ ca_access_vcs_restart (ca_t *ctx, u32 start_date, uint length_tck,
if (mfs && mfs->ca_state != CA_MFS_STATE_UNKNOWN)
{
bool cfp = !CA_ALLOC_IS_CSMA (glid);
- bool hybrid = CA_ALLOC_IS_HYBRID (sched->coexistence_mode, glid);
+ bool hybrid = CA_ALLOC_IS_HYBRID (sched->coexistence_mode, glid)
+ || mfs->beacon;
u32 access_date = start_date + length_tck;
if (!(cfp || eifs))
{
@@ -261,7 +262,7 @@ ca_access_defer (ca_t *ctx, u32 date, uint anticipation_tck)
ctx->anticipation_tck = anticipation_tck;
}
-void
+const ca_access_alloc_param_t *
ca_access_aifs (ca_t *ctx)
{
dbg_assert (ctx);
@@ -293,6 +294,12 @@ ca_access_aifs (ca_t *ctx)
ctx->current_allocation_index = alloc_i;
/* Reschedule. */
ca_access_vcs_restart (ctx, access_date, 0, ctx->anticipation_tck, false);
+ /* Return current allocation parameters. */
+ ctx->current_allocation_param.coexistence_mode = sched->coexistence_mode;
+ ctx->current_allocation_param.hybrid = CA_ALLOC_IS_HYBRID (
+ sched->coexistence_mode,
+ sched->allocations[ctx->current_allocation_index].glid);
+ return &ctx->current_allocation_param;
}
const ca_access_param_t *
diff --git a/mac/ca/test/ca/src/test_access.c b/mac/ca/test/ca/src/test_access.c
index 700a35776c..04704bb783 100644
--- a/mac/ca/test/ca/src/test_access.c
+++ b/mac/ca/test/ca/src/test_access.c
@@ -78,7 +78,7 @@ access_random_schedule (lib_rnd_t *rnd, ca_schedule_t *sched, uint length_tck)
void
access_check_vcs_restart (test_t t, ca_t *ca, u32 date, uint duration_tck,
- bool eifs)
+ bool eifs, const ca_access_alloc_param_t *ap)
{
test_within (t);
dbg_assert (ca);
@@ -95,6 +95,13 @@ access_check_vcs_restart (test_t t, ca_t *ca, u32 date, uint duration_tck,
test_fail_unless (lesseq_mod2p32 (a->access_date, bp->start_date +
alloc->end_offset_tck - MAC_AIFS_TCK));
test_fail_unless (lesseq_mod2p32 (date, a->access_date));
+ if (ap)
+ {
+ /* Check current allocation parameters. */
+ test_fail_unless (ap->coexistence_mode == sched->coexistence_mode);
+ test_fail_unless (ap->hybrid == CA_ALLOC_IS_HYBRID
+ (sched->coexistence_mode, alloc->glid));
+ }
if (a->mfs)
{
/* MFS scheduled. */
@@ -121,13 +128,15 @@ access_check_vcs_restart (test_t t, ca_t *ca, u32 date, uint duration_tck,
void
access_check_defer (test_t t, ca_t *ca, u32 date)
{
- access_check_vcs_restart (t, ca, date, 0, false);
+ access_check_vcs_restart (t, ca, date, 0, false, NULL);
}
void
-access_check_aifs (test_t t, ca_t *ca, u32 date)
+access_check_aifs (test_t t, ca_t *ca, u32 date,
+ const ca_access_alloc_param_t *ap)
{
- access_check_vcs_restart (t, ca, date + MAC_AIFS_TCK, 0, false);
+ dbg_assert_ptr (ap);
+ access_check_vcs_restart (t, ca, date + MAC_AIFS_TCK, 0, false, ap);
}
void
@@ -197,7 +206,7 @@ access_basic_test_case (test_t t)
if (i == 0)
{
ca_access_vcs_restart (ca, phy->date, 0, 0, false);
- access_check_vcs_restart (t, ca, phy->date, 0, false);
+ access_check_vcs_restart (t, ca, phy->date, 0, false, NULL);
}
while (less_mod2p32 (phy->date, bps[1].start_date))
{
@@ -226,7 +235,8 @@ access_basic_test_case (test_t t)
ca_access_vcs_restart (ca, phy->date,
MAC_EIFS_10_TCK, 0, true);
access_check_vcs_restart (t, ca, phy->date,
- MAC_EIFS_10_TCK, true);
+ MAC_EIFS_10_TCK, true,
+ NULL);
if (seg_sent)
{
mfs->seg_nb -= seg_sent;
@@ -234,14 +244,16 @@ access_basic_test_case (test_t t)
ca_access_vcs_restart (ca, phy->date, fl_tck,
0, false);
access_check_vcs_restart (t, ca, phy->date,
- fl_tck, false);
+ fl_tck, false,
+ NULL);
}
}
}
else
{
- ca_access_aifs (ca);
- access_check_aifs (t, ca, phy->date);
+ const ca_access_alloc_param_t *ap =
+ ca_access_aifs (ca);
+ access_check_aifs (t, ca, phy->date, ap);
}
}
else
diff --git a/mac/ca/test/ca/src/test_alloc.c b/mac/ca/test/ca/src/test_alloc.c
index b98ebe66a1..91fae3fe1a 100644
--- a/mac/ca/test/ca/src/test_alloc.c
+++ b/mac/ca/test/ca/src/test_alloc.c
@@ -64,6 +64,14 @@ alloc_basic_test_case (test_t t)
{ MAC_LID_LOCAL_CSMA, MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE, false },
{ MAC_LID_LOCAL_CSMA, MAC_COEXISTENCE_FULL_HYBRID_MODE, true },
{ MAC_LID_LOCAL_CSMA, MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE, true },
+ { MAC_LID_DISCOVER, MAC_COEXISTENCE_AV_ONLY_MODE, true },
+ { MAC_LID_DISCOVER, MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE, true },
+ { MAC_LID_DISCOVER, MAC_COEXISTENCE_FULL_HYBRID_MODE, true },
+ { MAC_LID_DISCOVER, MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE, true },
+ { MAC_LID_SPC_CENTRAL, MAC_COEXISTENCE_AV_ONLY_MODE, true },
+ { MAC_LID_SPC_CENTRAL, MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE, true },
+ { MAC_LID_SPC_CENTRAL, MAC_COEXISTENCE_FULL_HYBRID_MODE, true },
+ { MAC_LID_SPC_CENTRAL, MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE, true },
// { MAC_LID_CFPI, ? },
};
for (i = 0; i < COUNT (is_hybrid_tab); i++)
diff --git a/mac/common/defs.h b/mac/common/defs.h
index 937680c43d..39ad35c3e0 100644
--- a/mac/common/defs.h
+++ b/mac/common/defs.h
@@ -85,7 +85,9 @@ enum mac_tei_t
#define MAC_TEI_IS_STA(tei) \
((tei) >= MAC_TEI_STA_MIN && (tei) <= MAC_TEI_STA_MAX)
-/** Coexistence modes. */
+/** Coexistence modes.
+ * \warning Full Hybrid mode is also used in CSMA-Only with HomePlug 1.0
+ * compatible frame length. This maps directly to beacon HM field. */
enum mac_coexistence_mode_t
{
MAC_COEXISTENCE_AV_ONLY_MODE,
diff --git a/mac/common/src/store.c b/mac/common/src/store.c
index 8b6ba1f7a5..93be2948c8 100644
--- a/mac/common/src/store.c
+++ b/mac/common/src/store.c
@@ -117,7 +117,9 @@ mac_store_mfs_slot_get (mac_store_t *ctx, bool tx, bool bcast, bool mme,
|| (!mme && (MAC_LID_IS_XLID (lid)
|| lid == MAC_LID_DISCOVER
|| lid == MAC_LID_SPC_CENTRAL)));
- dbg_assert ((MAC_LID_IS_GLID (lid) && tei == 0)
+ dbg_assert (((MAC_LID_IS_GLID (lid) /* Needed when tei is unknown. */
+ || lid == MAC_LID_DISCOVER
+ || lid == MAC_LID_SPC_CENTRAL) && tei == 0)
|| (bcast && tx && tei == MAC_TEI_BCAST)
|| (!(bcast && tx) && MAC_TEI_IS_STA (tei)));
if (!mme && (lid >= MAC_GLID_MIN))