summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorschodet2010-03-24 10:21:44 +0000
committerschodet2010-03-24 10:21:44 +0000
commiteef3e94fb9964100cfaaeb5922d945dc6096064c (patch)
tree2a2637ed6bb8fecd7aee3c743036f92d37d7cde3 /cesar
parentf445e774f8ce2da10deac23f1253d2060bfbe946 (diff)
cesar/tools/sniffer_phy: add beacon payload support, refs #1256
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6848 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/tools/sniffer_phy/inc/lowlevel.h2
-rw-r--r--cesar/tools/sniffer_phy/src/lowlevel.c121
2 files changed, 113 insertions, 10 deletions
diff --git a/cesar/tools/sniffer_phy/inc/lowlevel.h b/cesar/tools/sniffer_phy/inc/lowlevel.h
index 16e65ef27f..b21b2d30f2 100644
--- a/cesar/tools/sniffer_phy/inc/lowlevel.h
+++ b/cesar/tools/sniffer_phy/inc/lowlevel.h
@@ -77,6 +77,8 @@ struct lowlevel_t
lowlevel_rx_desc_t *rx_tail;
/* Current tonemask. */
tonemask_info_t *tonemask_info;
+ /** MPDU being received. */
+ lowlevel_rx_desc_t *rxing;
};
typedef struct lowlevel_t lowlevel_t;
diff --git a/cesar/tools/sniffer_phy/src/lowlevel.c b/cesar/tools/sniffer_phy/src/lowlevel.c
index 10ea02e64e..73a576cf1f 100644
--- a/cesar/tools/sniffer_phy/src/lowlevel.c
+++ b/cesar/tools/sniffer_phy/src/lowlevel.c
@@ -19,16 +19,74 @@
#include "hal/phy/phy.h"
#include "hal/arch/arch.h"
#include "lib/slist.h"
+#include "mac/pbproc/inc/fc.h"
#include "inc/context.h"
+/** MPDU informations. */
+struct lowlevel_mpdu_t
+{
+ /** Number of PB. */
+ uint pb_nb;
+ /** Number of symbols. */
+ uint symbol_nb;
+ /** PB size. */
+ phy_pb_size_t pb_size;
+ /** Tonemap. */
+ tonemap_t *tm;
+};
+typedef struct lowlevel_mpdu_t lowlevel_mpdu_t;
+
+static void ARCH_ILRAM
+lowlevel_fc_analyse (sniffer_phy_t *ctx, const u32 *fc_av,
+ lowlevel_mpdu_t *mpdu)
+{
+ pbproc_fc_t *fc = (pbproc_fc_t *) fc_av;
+ if (!fc_av
+ || ctx->lowlevel.pool_size <= 1)
+ {
+ mpdu->pb_nb = 0;
+ }
+ else
+ {
+ /* Decode FC. */
+ switch (fc->generic.dt_av)
+ {
+ case PBPROC_FC_DT_BEACON:
+ mpdu->pb_nb = 1;
+ mpdu->pb_size = PHY_PB_SIZE_136;
+ mpdu->tm =
+ &ctx->lowlevel.tonemask_info->tonemap_robo[PHY_MOD_MINI_ROBO];
+ break;
+ default:
+ mpdu->pb_nb = 0;
+ }
+ /* Adjust PB and symbol number. */
+ mpdu->pb_nb = MIN (mpdu->pb_nb, ctx->lowlevel.pool_size - 1);
+ if (mpdu->pb_nb)
+ {
+ uint bits_per_pb = mpdu->tm->bits_per_pb[mpdu->pb_size];
+ mpdu->symbol_nb = (1 * bits_per_pb + mpdu->tm->bits_per_symbol -
+ 1) / mpdu->tm->bits_per_symbol;
+ }
+ }
+}
+
static bool ARCH_ILRAM
lowlevel_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
{
sniffer_phy_t *ctx = user;
+ lowlevel_mpdu_t mpdu;
dbg_assert (ctx);
+ /* Analyse preamble. */
+ lowlevel_fc_analyse (ctx, fc_av, &mpdu);
/* Prepare hardware. */
- phy_rx_prepare_short (ctx->lowlevel.phy);
+ if (mpdu.pb_nb == 0)
+ phy_rx_prepare_short (ctx->lowlevel.phy);
+ else
+ phy_rx_prepare (ctx->lowlevel.phy, mpdu.pb_nb,
+ mpdu.tm->phy_combo_params[mpdu.pb_size], mpdu.tm->gil,
+ mpdu.symbol_nb, mpdu.tm->tcc_halfit);
/* Take a block to record the FC. */
if (ctx->lowlevel.pool_size)
{
@@ -55,13 +113,38 @@ lowlevel_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
rx->fc[3] = (u32) -1;
rx->fc_bad_crc = true;
}
- /* Enlist RX descriptor. */
- slist_push_back (ctx->lowlevel.rx_, desc);
+ /* Enlist RX descriptor if finished or wait until DMA end. */
+ if (mpdu.pb_nb == 0)
+ {
+ rx->pb_head = NULL;
+ slist_push_back (ctx->lowlevel.rx_, desc);
+ }
+ else
+ {
+ pb_t *head = PARENT_OF (pb_t, blk, ctx->lowlevel.pool_head);
+ rx->pb_head = head;
+ ctx->lowlevel.rxing = desc;
+ phy_pbdma_start (ctx->lowlevel.phy, true, NULL, mpdu.pb_nb,
+ mpdu.pb_nb, mpdu.pb_nb, &head->phy_pb, NULL,
+ true);
+ }
+ rx->pb_nb = mpdu.pb_nb;
+ rx->pb_size = mpdu.pb_size;
+ dbg_invalid_ptr (rx->pb_tail);
+ }
+ /* Next. */
+ if (mpdu.pb_nb == 0)
+ {
+ /* Restart RX now. */
+ phy_rx_activate (ctx->lowlevel.phy, true, 0, true);
+ /* Ask a DSR. */
+ return true;
+ }
+ else
+ {
+ /* No DSR, wait for PBDMA interrupt. */
+ return false;
}
- /* Restart RX now. */
- phy_rx_activate (ctx->lowlevel.phy, true, 0, true);
- /* Ask a DSR. */
- return true;
}
static bool
@@ -83,9 +166,21 @@ lowlevel_access_conf_cb (void *user)
static bool ARCH_ILRAM
lowlevel_pbdma_cb (void *user, u32 status_word)
{
- /* This interrupt is not used yet in sniffer. */
- dbg_assert_default ();
- return false;
+ sniffer_phy_t *ctx = user;
+ dbg_assert (ctx);
+ lowlevel_rx_t *rx = ctx->lowlevel.rxing->rx;
+ dbg_assert (rx);
+ /* Find end of list and update pool and MPDU info. */
+ phy_pb_t *tail = phy_pbdma_get_tail (ctx->lowlevel.phy);
+ slist_slice (ctx->lowlevel.pool_, &tail->blk, rx->pb_nb, paste_size);
+ rx->pb_tail = PARENT_OF (pb_t, phy_pb, tail);
+ /* Enlist RX descriptor. */
+ slist_push_back (ctx->lowlevel.rx_, ctx->lowlevel.rxing);
+ ctx->lowlevel.rxing = NULL;
+ /* Restart RX now. */
+ phy_rx_activate (ctx->lowlevel.phy, true, 0, true);
+ /* Ask a DSR. */
+ return true;
}
static bool
@@ -111,6 +206,11 @@ lowlevel_deferred_cb (void *user)
/* Give to MME layer. */
mme_report_mpdu (ctx, desc->rx);
/* Release. */
+ if (desc->rx->pb_nb)
+ slist_push_back_range (ctx->lowlevel.pool_,
+ &desc->rx->pb_head->blk,
+ &desc->rx->pb_tail->blk, desc->rx->pb_nb,
+ paste_size);
slist_push_back (ctx->lowlevel.pool_, &desc->blk, paste_size);
}
}
@@ -123,6 +223,7 @@ lowlevel_init (sniffer_phy_t *ctx)
/* Initialise context. */
slist_init (ctx->lowlevel.pool_, paste_size);
slist_init (ctx->lowlevel.rx_, paste);
+ ctx->lowlevel.rxing = NULL;
/* Initialise tonemask information. */
ctx->lowlevel.tonemask_info = &tonemask_info;
tonemask_default (ctx->lowlevel.tonemask_info->tonemask);