summaryrefslogtreecommitdiff
path: root/cesar/mac/common
diff options
context:
space:
mode:
authorNicolas Schodet2011-12-16 12:06:10 +0100
committerNicolas Schodet2011-12-16 17:29:32 +0100
commit32b6b1f6d7f0ac04d00f1fe2160c91ba6cdf3b8e (patch)
tree1ee99b8ee00ff053ffe9f318c696cf28dede7dce /cesar/mac/common
parentbe77867268daecdbd4f5b67504f886276c2e045f (diff)
cesar/mac/common: shorten store travel by remembering maximum LIDs, refs #2834
Diffstat (limited to 'cesar/mac/common')
-rw-r--r--cesar/mac/common/src/store.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/cesar/mac/common/src/store.c b/cesar/mac/common/src/store.c
index 91e4b29211..724ab1827c 100644
--- a/cesar/mac/common/src/store.c
+++ b/cesar/mac/common/src/store.c
@@ -43,6 +43,8 @@ struct mac_store_sta_t
/** LLID MFS for RX from this STA. Only allocated when really needed, the
* first four pointers are not used. */
mfs_t **rx_llid;
+ /** Maximum RX LLID ever created, used for optimization. */
+ uint rx_llid_max;
};
typedef struct mac_store_sta_t mac_store_sta_t;
@@ -59,6 +61,10 @@ struct mac_store_t
* - 0x80-0xf7: TX/RX GLID
* - 0xf8-0xfd: unused & discover and central beacons */
mfs_t *lglid[MAC_LID_BEACON_MAX + 1];
+ /** Maximum TX LLID ever created, used for optimization. */
+ uint tx_llid_max;
+ /** Maximum GLID ever created, used for optimization. */
+ uint glid_max;
/** Peers, indexed by TEI. */
mac_store_sta_t *sta[MAC_TEI_STA_MAX + 1];
/** Unassociated MFS. */
@@ -80,6 +86,8 @@ mac_store_init (void)
ctx->bcast_tx_mme = NULL;
for (i = 0; i < COUNT (ctx->lglid); i++)
ctx->lglid[i] = NULL;
+ ctx->tx_llid_max = 0;
+ ctx->glid_max = 0;
for (i = 0; i < COUNT (ctx->sta); i++)
ctx->sta[i] = NULL;
list_init (&ctx->unassociated);
@@ -134,10 +142,18 @@ mac_store_mfs_slot_get (mac_store_t *ctx, bool tx, bool bcast, bool mme,
return NULL;
}
else
+ {
+ if (add && lid <= MAC_GLID_MAX)
+ ctx->glid_max = MAX (ctx->glid_max, lid);
return &ctx->lglid[lid];
+ }
}
else if (!mme && (tx && lid >= MAC_LLID_MIN))
+ {
+ if (add)
+ ctx->tx_llid_max = MAX (ctx->tx_llid_max, lid);
return &ctx->lglid[lid];
+ }
else if (tx && bcast && !mme && MAC_LID_IS_PLID (lid))
return &ctx->bcast_tx_plid[lid];
else if (tx && bcast && mme)
@@ -155,6 +171,8 @@ mac_store_mfs_slot_get (mac_store_t *ctx, bool tx, bool bcast, bool mme,
if (!mme && lid >= MAC_LLID_MIN)
{
dbg_blame (!tx && lid <= MAC_LLID_MAX);
+ if (add)
+ sta->rx_llid_max = MAX (sta->rx_llid_max, lid);
if (!sta->rx_llid)
{
if (add)
@@ -265,6 +283,7 @@ mac_store_mfs_alias_ (mac_store_t *ctx, mfs_t *mfs, uint glid __FL)
dbg_blame (ctx->lglid[glid] == NULL);
arch_dsr_lock ();
blk_addref_ (mfs __fl);
+ ctx->glid_max = MAX (ctx->glid_max, glid);
ctx->lglid[glid] = mfs;
/* Modify the MFS. */
mfs->common.lid_alias = mfs->common.lid;
@@ -347,7 +366,7 @@ mac_store_mfs_travel (mac_store_t *ctx, mac_store_travel_t travel,
void *user)
{
/* Will unlock DSR between each MFS fetch to reduce DSR latency. */
- int i;
+ uint i;
dbg_assert (ctx);
dbg_assert (travel);
/* First travel local MFS. */
@@ -366,7 +385,16 @@ mac_store_mfs_travel (mac_store_t *ctx, mac_store_travel_t travel,
mac_store_mfs_travel_mfs_and_unlock (ctx, ctx->bcast_tx_mme, travel,
user);
}
- for (i = MAC_LLID_MIN; i < MAC_LID_NB; i++)
+ for (i = MAC_LLID_MIN; i <= ctx->tx_llid_max; i++)
+ {
+ if (ctx->lglid[i])
+ {
+ arch_dsr_lock ();
+ mac_store_mfs_travel_mfs_and_unlock (ctx, ctx->lglid[i], travel,
+ user);
+ }
+ }
+ for (i = MAC_GLID_MIN; i <= ctx->glid_max; i++)
{
if (ctx->lglid[i])
{
@@ -454,7 +482,7 @@ mac_store_mfs_travel_by_tei (mac_store_t *ctx, uint tei,
{
blk_addref (rx_llid);
arch_dsr_unlock ();
- for (i = MAC_LLID_MIN; i <= MAC_LLID_MAX; i++)
+ for (i = MAC_LLID_MIN; i <= sta->rx_llid_max; i++)
{
if (rx_llid[i])
{
@@ -517,6 +545,7 @@ mac_store_sta_add_ (mac_store_t *ctx, uint tei __FL)
sta->mme[i] = NULL;
}
sta->rx_llid = NULL;
+ sta->rx_llid_max = 0;
/* Done, ready to be used (order is important). */
arch_reorder_barrier ();
ctx->sta[tei] = sta;