summaryrefslogtreecommitdiff
path: root/cp
diff options
context:
space:
mode:
authorchertier2008-03-27 18:21:42 +0000
committerchertier2008-03-27 18:21:42 +0000
commitc933dd52c097d7c7a5a424d6b23a2b535ab11e85 (patch)
tree0579bab7a1b1e641bca468b1b6689061c090c581 /cp
parent46ab8271f51137ecc208b64b3294690acc4bc0fc (diff)
1st try of full station integration with CP+DP and new interface/sniffer module
- using message context / beacon context / station context - added or modified debugging traces - init new interface/sniffer module - manage MME Tx buffers - adding callback functions associated to new interface/sniffer module and dedicated to - receive MME Tx buffers from HLE (used later to send MMEs), - receive MMEs - receive beacons git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1671 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cp')
-rw-r--r--cp/interf/src/interf.c306
1 files changed, 287 insertions, 19 deletions
diff --git a/cp/interf/src/interf.c b/cp/interf/src/interf.c
index 6b1e1024f7..b07380b98f 100644
--- a/cp/interf/src/interf.c
+++ b/cp/interf/src/interf.c
@@ -12,6 +12,12 @@
*/
#include "common/std.h"
+
+#include "cp/beacon/inc/bentry.h"
+#include "cp/beacon/inc/beacons_ctx.h"
+#include "cp/beacon/forward.h"
+#include "cp/beacon/inc/beacons_work.h"
+
#include "cp/interf/interf.h"
#include "cp/interf/inc/interf_private.h"
@@ -33,6 +39,40 @@ static cyg_mbox buf_rel_mbox;
// delay in ticks for the frag MMI timeout
static cyg_tick_count_t frag_MMI_time_out_delay;
+#if 1
+
+extern cp_sta_t cp_sta_global;
+
+int mme_buffer_count = 0;
+int mme_buffer_first = 0;
+int mme_buffer_last = -1;
+u8 * mme_tx_buffer[MME_BUFFER_MAXCOUNT];
+
+#define NEW_INTERFACE_WITH_DATA_PLANE
+#ifndef NEW_INTERFACE_WITH_DATA_PLANE
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv);
+#else
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv, bool encryption);
+void
+cp_beacon_recv(void *user_data, pb_beacon_t *beacon);
+#endif
+
+void cp_mme_get (void *user, u8 *buffer);
+
+#else
+
+/* External functions */
+
+extern void cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv);
+
+extern void cp_mme_get (void *user, u8 *buffer);
+
+#endif
/***************************************************************/
/***************************************************************/
@@ -164,23 +204,28 @@ interf_buf_to_release (void)
/***************************************************************/
/***************************************************************/
+#ifndef NEW_INTERFACE_WITH_DATA_PLANE
+E_ErrCode
+interf_init (cl_t *interf_cl_ctx)
+#else
E_ErrCode
-interf_init (void)
+interf_init (cl_t *interf_cl_ctx)
+#endif
{
unsigned int i;
#if DEBUG
// check parameters
if (sizeof(pool[0].msg) != ETH_PACKET_MAX_SIZE )
{
- printf("wrong mmentry size : %lu octets instead of %i\n", sizeof(pool[0].msg), ETH_PACKET_MAX_SIZE);
- printf(" osa : %lu\n", sizeof(pool[0].msg.osa));
- printf(" oda : %lu\n", sizeof(pool[0].msg.oda));
- //printf(" v_lan_tag : %lu\n", sizeof(pool[0].msg.v_lan_tag));
- printf(" m_type : %lu\n", sizeof(pool[0].msg.m_type));
- printf(" mmv; : %lu\n", sizeof(pool[0].msg.mmv));
- printf(" mm_type; : %lu\n", sizeof(pool[0].msg.mm_type));
- printf(" fmi; : %lu\n", sizeof(pool[0].msg.fmi));
- printf(" mm_entry : %lu\n", sizeof(pool[0].msg.mm_entry));
+ printf("%u %s() : wrong mmentry size : %lu octets instead of %i\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg), ETH_PACKET_MAX_SIZE);
+ printf("%u %s() : osa : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.osa));
+ printf("%u %s() : oda : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.oda));
+ //printf("%u %s() : v_lan_tag : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.v_lan_tag));
+ printf("%u %s() : m_type : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.m_type));
+ printf("%u %s() : mmv : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.mmv));
+ printf("%u %s() : mm_type : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.mm_type));
+ printf("%u %s() : fmi : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.fmi));
+ printf("%u %s() : mm_entry : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.mm_entry));
}
#endif
@@ -206,57 +251,134 @@ interf_init (void)
// init of mailboxes
cyg_mbox_create( & incoming_mbox_handle, & incoming_mbox);
cyg_mbox_create( & buf_rel_mbox_handle, & buf_rel_mbox);
- // init SAR layer
+#if 0
+ // init CL layer
interf_cl_layer_init();
+#else
+ printf("%u %s() : Configure the CP-DP interface...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+# ifdef NEW_INTERFACE_WITH_DATA_PLANE
+ /* Configure the interface module between Control-Plane and Data-Plane */
+ interface_callback_init (cp_sta_global.interface, cp_mme_recv, cp_mme_get, cp_beacon_recv, NULL);
+# else
+ /* Configure the CP-CL interface */
+ cl_mme_recv_init (interf_cl_ctx, cp_mme_recv, NULL);
+ cl_mme_init_buffer_add_cb (interf_cl_ctx, cp_mme_get, NULL);
+# endif
+ printf("%u %s() : CP-CL interface configuration done.\n",cyg_hal_sys_getpid(),__FUNCTION__);
+#endif
// TODO : give one buffer to the CL
return Success;
}
+msg_ctx_t my_msg_ctx;
//void
//interf_receive (const msg_mme_t *msg)
void
interf_receive (void *user, mfs_rx_t *mfs, u8 *buffer, uint length, cl_mme_recv_t *mme_recv)
{
+ uint i, j;
msg_mme_t *msg = (msg_mme_t *) buffer;
+ msg_ctx_t *msg_ctx = &my_msg_ctx;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+
+ //msg_ctx = blk_alloc();
+ msg_ctx->user = user;
+ msg_ctx->mfs = mfs;
+ msg_ctx->buffer = buffer;
+ msg_ctx->length = length;
+ //msg_ctx->mme_recv = mme_recv;
+ msg_ctx->cl_mme_data = (void*)mme_recv;
+
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+ printf ("%u /* STA : %d CP : RECEIVING AN MME (len = %u bytes)...\n",cyg_hal_sys_getpid(),
+ /*cp_sta_global.mac_config->tei*/0,
+ length);
+ printf ("%u /* buffer = 0x%08lX ; msg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)buffer,(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ if (length > 0)
+ {
+ j = 0;
+ printf("%u /* ",cyg_hal_sys_getpid());
+ for (i = 0; i < (length / 16); i++)
+ {
+ for (j = 0; j < 16; j++) printf ("%02x.",buffer[(i*16)+j]);
+ printf("\n");
+ printf("%u /* ",cyg_hal_sys_getpid());
+ }
+ for (i = 0; i < (length % 16); i++)
+ {
+ printf ("%02x.",buffer[(j*16)+i]);
+ }
+ printf("\n");
+ }
+ else
+ {
+ printf("%u /*\n",cyg_hal_sys_getpid());
+ }
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+
+ printf ("%u /* AVANT cyg_mbox_put() : msg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+
dbg_assert ( !msg_check_wrong_mme_const_values (msg));
#if DEBUG
- dbg_assert(cyg_mbox_tryput(incoming_mbox_handle, (void *) msg));
+ printf("%u /* ON PASSE dans le cas DEBUG...*/\n",cyg_hal_sys_getpid());
+ //dbg_assert(cyg_mbox_tryput(incoming_mbox_handle, (void *) msg));
+ dbg_assert(cyg_mbox_tryput(incoming_mbox_handle, (void *) msg_ctx));
#else
- cyg_mbox_put (incoming_mbox_handle, (void *) msg);
+ //cyg_mbox_put (incoming_mbox_handle, msg);
+ printf ("%u /* AVANT cyg_mbox_put() : msg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ cyg_mbox_put (incoming_mbox_handle, msg_ctx);
#endif
// set the event flag for the station
+ printf ("%u /* AVANT cyg_flag_setbits() : @station_flag=0x%08lx ; station_flag=0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)&station_flag,(unsigned long)*((u32*)&station_flag));
cyg_flag_setbits (&station_flag, STATION_FLAG_MSG_RCV);
+ printf ("%u /* APRES cyg_flag_setbits() : @station_flag=0x%08lx ; station_flag=0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)&station_flag,(unsigned long)*((u32*)&station_flag));
}
-void
+void
interf_received (void)
{
+ msg_ctx_t * msg_ctx;
msg_mme_t * msg;
+ msg_mme_b_t * msg_b;
+ printf ("%u %s() : AVANT while(cyg_mbox_tryget)...\n",cyg_hal_sys_getpid(),__FUNCTION__);
// as we have msg in the mailbox
- while ( (msg = cyg_mbox_tryget (incoming_mbox_handle)) != NULL )
+ while ( (msg_ctx = cyg_mbox_tryget (incoming_mbox_handle)) != NULL )
{
+ //printf ("%u %s() : DANS while(cyg_mbox_tryget)...",cyg_hal_sys_getpid(),__FUNCTION__);
+ //printf ("\t\tmsg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ printf ("%u %s() : DANS while(cyg_mbox_tryget)...\t\tmsg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
// check that the message is really an mme
- if(msg_check_wrong_mme_const_values (msg))
+ //{int k; for (k=0;k<60;k++)printf("%02x.",msg_ctx->buffer[k]);printf("\n");}
+ if(msg_check_wrong_mme_const_values (msg_ctx->buffer))
{
// in debug we should ask why we received a wrong message...
dbg_assert(0);
// discard it and process the next msg
- interf_release_buf(msg);
+ interf_release_buf(msg_ctx->buffer);
continue;
}
+ msg = (msg_mme_t *)msg_ctx->buffer;
// TODO : vérifier que l'ODA est bien celle de la station
// check if message is complete
- if (msg->fmi.nf_mi != 0)
+ printf("%u test msg->fmi.nf_mi != 0 ?\n",cyg_hal_sys_getpid());
+ msg_b = (msg_mme_b_t *)msg;
+ if (
+ ((msg->m_type == MSG_MTYPE_IEEE_ETHERTYPE) && (msg->fmi.nf_mi != 0))
+ ||
+ ((msg_b->m_type == MSG_MTYPE_IEEE_ETHERTYPE) && (msg_b->fmi.nf_mi != 0))
+ )
{
msg = interf_received_frag (msg);
// if message not complete, process the next one
if ( ! msg) continue;
}
// the message is complete, so we process it
- msg_dispatch(msg);
+ msg_dispatch(msg_ctx);
}
+ printf ("%u %s() : APRES while(cyg_mbox_tryget)... => (achieved op.)\n",cyg_hal_sys_getpid(),__FUNCTION__);
// give another buffer to the CL
// TODO : give one buffer to the CL
}
@@ -270,6 +392,8 @@ interf_send (
)
{
uint size;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
dbg_assert ( !msg_check_wrong_mme_const_values (msg));
dbg_assert (msg_size <= ETH_PACKET_MAX_SIZE);
@@ -292,6 +416,7 @@ interf_msg_get_next_part (const msg_mme_t *msg)
void
interf_release_buf (void *msg)
{
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
dbg_assert ( !msg_check_wrong_mme_const_values (msg));
#if DEBUG
@@ -311,6 +436,7 @@ interf_give_buf (void)
msg_mme_t *msg;
uint i;
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
for (i=0 ; i < sizeof(pool) ; i++)
{
if (pool[i].size == 0)
@@ -330,6 +456,8 @@ interf_msg_purge (void)
{
int i, j;
cyg_tick_count_t time_out_date;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
dbg_assert (frag_MMI_time_out_delay >= 1);
// calculate the date before which messages has expired
time_out_date = cyg_current_time ();
@@ -369,3 +497,143 @@ interf_ms_to_cyg_tick (const uint ms)
return_value /= resolution.dividend;
return return_value;
}
+
+/*************/
+
+#if 1
+
+/**
+ * \brief Get a buffer from HLE (such a buffer is used to send MME to HLE or over PWL).
+ *
+ * \param user pointer to user context
+ * \param buffer buffer pointer
+ */
+void cp_mme_get (void *user, u8 *buffer)
+{
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+ printf ("%u /* STA : %d CP : OBTAINING AN MME BUFFER...\n",cyg_hal_sys_getpid(),
+ cp_sta_global.mac_config->tei);
+ printf ("%u ### AVANT maj mme_buffer_count (first = %d ; last = %d ; count = %d) ###\n",cyg_hal_sys_getpid(),
+ mme_buffer_first, mme_buffer_last, mme_buffer_count);
+ if (mme_buffer_count < MME_BUFFER_MAXCOUNT)
+ {
+ mme_buffer_last = (mme_buffer_last + 1) % MME_BUFFER_MAXCOUNT;
+ mme_tx_buffer[mme_buffer_last] = buffer;
+ mme_buffer_count++;
+ if (mme_buffer_count == MME_BUFFER_MAXCOUNT)
+ {
+ printf ("%u /* STA : %d OK, BUT CP WILL NOT ACCEPT\n",cyg_hal_sys_getpid(),
+ cp_sta_global.mac_config->tei);
+ printf ("%u /* ANOTHER MME BUFFER.\n",cyg_hal_sys_getpid());
+ printf ("%u /* (MME_BUFFER_MAXCOUNT reached)\n",cyg_hal_sys_getpid());
+ }
+ }
+ else
+ {
+ printf ("%u /* STA : %d WARNING, CP CANNOT ACCEPT\n",cyg_hal_sys_getpid(),
+ cp_sta_global.mac_config->tei);
+ printf ("%u /* ANOTHER MME BUFFER !\n",cyg_hal_sys_getpid());
+ printf ("%u /* (MME_BUFFER_MAXCOUNT reached)\n",cyg_hal_sys_getpid());
+ }
+ printf ("%u ### APRES maj mme_buffer_count (first = %d ; last = %d ; count = %d) ###\n",cyg_hal_sys_getpid(),
+ mme_buffer_first, mme_buffer_last, mme_buffer_count);
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+}
+
+/**
+ * \brief Receive an MME message from CL.
+ *
+ * \param user a specific user context
+ * \param mfs the mfs used
+ * \param buffer the buffer containing the message being received
+ * \param length the length of message being received
+ * \param mme_recv
+ * \return status of memory blocks check
+ */
+#ifndef NEW_INTERFACE_WITH_DATA_PLANE
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length, cl_mme_recv_t *mme_recv)
+#else
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length, cl_mme_recv_t *mme_recv, bool encryption)
+#endif
+{
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ interf_receive (user, mfs, buffer, length, mme_recv);
+}
+
+#if 0
+/** Beacon PB descriptor. */
+union pb_beacon_t
+{
+ /** Common block descriptor. */
+ blk_t blk;
+ /** Hardware descriptor. */
+ phy_pb_t phy_pb;
+ struct
+ {
+ /** Pointer to next descriptor. */
+ union pb_t *next;
+ /** Pointer to data. */
+ u8 *data;
+ /** First four bytes of the beacon payload. */
+ u32 first_data_word;
+ };
+};
+typedef union pb_beacon_t pb_beacon_t;
+#endif
+
+/**
+ * \brief Receive a beacon.
+ *
+ * \param user a specific user context
+ * \param beacon the received beacon buffer reference
+ *
+ */
+void
+cp_beacon_recv(void *user_data, pb_beacon_t *beacon)
+{
+#define BEACON_DATA_MAXSIZE 132
+ uint i, j;
+ u8 *buffer;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ dbg_assert (beacon);
+
+
+ // TODO : to be removed (Hexdump of beacon is for debug purpose only)
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+ printf ("%u /* STA : %d CP : RECEIVING A BEACON...\n",cyg_hal_sys_getpid(),
+ /*cp_sta_global.mac_config->tei*/0);
+ printf ("%u /* @beacon_descriptor = 0x%08lx\n",cyg_hal_sys_getpid(),
+ (unsigned long)beacon);
+ {
+ j = 0;
+ printf("%u /* ",cyg_hal_sys_getpid());
+ buffer = (u8 *)&(beacon->first_data_word);
+ for (i = 0; i < (BEACON_DATA_MAXSIZE / 16); i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ if (((j*16)+i) == 4) buffer = beacon->data;
+ printf ("%02x.",buffer[(i*16)+j]);
+ }
+ printf("\n");
+ printf("%u /* ",cyg_hal_sys_getpid());
+ }
+ for (i = 0; i < (BEACON_DATA_MAXSIZE % 16); i++)
+ {
+ printf ("%02x.",buffer[(j*16)+i]);
+ }
+ printf("\n");
+ }
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+
+
+ // TODO : generate beacon receive event for Control-Plane FSM
+ // and use this beacon
+
+}
+
+#endif