summaryrefslogtreecommitdiff
path: root/mac/sar/test/maximus_test
diff options
context:
space:
mode:
authorlaranjeiro2007-09-21 15:01:36 +0000
committerlaranjeiro2007-09-21 15:01:36 +0000
commit9926e455632e46ceb92b91ff9ad0be44ab80ab1d (patch)
treeb012fd7174ed391844cfc1316c629a2df4ad8c43 /mac/sar/test/maximus_test
parent4edce63f9d0e798a0dd7e94d45f8afc529e2ba4d (diff)
Generic Functional test of the SAR on maximus.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@729 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'mac/sar/test/maximus_test')
-rw-r--r--mac/sar/test/maximus_test/Makefile3
-rw-r--r--mac/sar/test/maximus_test/inc/blk_t.h4
-rw-r--r--mac/sar/test/maximus_test/inc/max_job.h7
-rw-r--r--mac/sar/test/maximus_test/src/Maximus_sar.cpp302
-rw-r--r--mac/sar/test/maximus_test/src/Sta_sar.c1035
5 files changed, 704 insertions, 647 deletions
diff --git a/mac/sar/test/maximus_test/Makefile b/mac/sar/test/maximus_test/Makefile
index e8c6436776..4905ad6405 100644
--- a/mac/sar/test/maximus_test/Makefile
+++ b/mac/sar/test/maximus_test/Makefile
@@ -8,6 +8,7 @@ Maximus_sar_MODULES = maximus
TARGET_PROGRAMS = Sta_sar
Sta_sar_SOURCES = Sta_sar.c
-Sta_sar_MODULES = lib mac/sar mac/common host hal/phy/maximus
+Sta_sar_MODULES = lib mac/sar mac/common host hal/phy/maximus mac/pbproc
+mac_pbproc_MODULE_SOURCES = mfs.c
include $(BASE)/common/make/top.mk \ No newline at end of file
diff --git a/mac/sar/test/maximus_test/inc/blk_t.h b/mac/sar/test/maximus_test/inc/blk_t.h
index bf1ed35915..eebbb60c15 100644
--- a/mac/sar/test/maximus_test/inc/blk_t.h
+++ b/mac/sar/test/maximus_test/inc/blk_t.h
@@ -18,8 +18,8 @@
struct blk_t
{
unsigned int qte;
- unsigned char pbs[5][1024];
- unsigned int header[5];
+ unsigned char pbs[50][1024];
+ unsigned int header[50];
};
typedef struct blk_t blk_t;
diff --git a/mac/sar/test/maximus_test/inc/max_job.h b/mac/sar/test/maximus_test/inc/max_job.h
index 3707ff734f..7c1b0d2c2c 100644
--- a/mac/sar/test/maximus_test/inc/max_job.h
+++ b/mac/sar/test/maximus_test/inc/max_job.h
@@ -13,17 +13,18 @@
* \brief <brief>
* \ingroup mac/sar/test/maximus_test/inc
*
- */
+ */
struct sar_max_job_t
{
struct sar_max_job_t *next;
unsigned char lid;
- unsigned char tei;
+ unsigned char tei_src;
+ unsigned char tei_dest;
bool bcast;
unsigned char mf_type;
unsigned char packet_id;
};
-typedef struct sar_max_job_t sar_max_job_t;
+typedef struct sar_max_job_t sar_max_job_t;
#endif /*MAX_JOB_H_*/
diff --git a/mac/sar/test/maximus_test/src/Maximus_sar.cpp b/mac/sar/test/maximus_test/src/Maximus_sar.cpp
index 07e086c444..315df24d7b 100644
--- a/mac/sar/test/maximus_test/src/Maximus_sar.cpp
+++ b/mac/sar/test/maximus_test/src/Maximus_sar.cpp
@@ -89,28 +89,6 @@ bool reassembly (Maximus *maximus, Sta *station, station_cb_t sta_cb,
sar_max_job_t *sar_max_job) throw();
/**
- * Launch the test on one shoot mode.
- *
- * \param argc the quantity of arguments provided
- * \param argv the char array containing the arguments
- * \param sar_max_job the job to process.
- *
- * \return the end value
- */
-int one_shoot (int argc, char *argv[], sar_max_job_t *sar_max_job);
-
-/**
- * Launch the test on multiple shoot mode.
- *
- * \param argc the quantity of arguments provided
- * \param argv the char array containing the arguments
- * \param iter the quantity of iteration the multiple shoot should do.
- *
- * \return the end value
- */
-int multiple_shoot (int argc, char *argv[], int iter);
-
-/**
* Launch the procedure with n segmentation and one reassembly
*
* \param argc the quantity of arguments provided
@@ -128,197 +106,61 @@ bool test_fail;
int fifo_blk[2];
-int main (int argc, char *argv[])
-{
- /* create the fifo */
- if (pipe (fifo_blk) < 0)
- {
- printf ("Can not create the pipe for the PBs communication\n");
- exit (-1);
- }
-
- sar_max_job_t *sar_max_job;
-
- sar_max_job = (sar_max_job_t *) malloc (sizeof(sar_max_job_t));
- // sar_max_job->next = (sar_max_job_t *) malloc (sizeof (sar_max_job_t));
- // sar_max_job->next->next = NULL;
-
- sar_max_job->next = NULL;
-
- sar_max_job->lid = 1;
- sar_max_job->tei = 2;
- sar_max_job->bcast = false;
- sar_max_job->mf_type = 2;
- sar_max_job->packet_id = 0;
-
- // sar_max_job->next->lid = 1;
- // sar_max_job->next->tei = 2;
- // sar_max_job->next->bcast = false;
- // sar_max_job->next->mf_type = 2;
- // sar_max_job->next->packet_id = 1;
-
- return one_shoot (argc, argv, sar_max_job);
- //return multiple_shoot (argc, argv, 2);
-
- //return launch_x_segs (argc, argv, sar_max_job);
-}
+int max_jobs_qte;
-/**
- * Launch the test on one shoot mode.
- *
- * \param argc the quantity of arguments provided
- * \param argv the char array containing the arguments
- * \param sar_max_job the job to process.
- *
- * \return the end value
- */
-int one_shoot (int argc, char *argv[], sar_max_job_t *sar_max_job)
+int main (int argc, char *argv[])
{
- bool logs;
+ sar_max_job_t *sar_max_job = NULL;
try
{
- test_fail = false;
- station1_rsp = false;
- station2_rsp = false;
-
- Maximus maximus;
- maximus.init (argc, argv);
+ station1_rsp = 0;
+ station2_rsp = 0;
- Sta station1 = maximus.create_sta ();
- //station1.debug ();
- Sta station2 = maximus.create_sta ();
- //station2.debug ();
-
- // activate the sta 1 logs
- Msg fc = maximus.create_fc ("activate_logs");
- logs = true;
- fc.add_param ("debug", sizeof(unsigned char), (unsigned char *) &logs);
- fc.send (station2);
- fc.send (station1);
-
- segmentation (&maximus, &station1, station1_cb, sar_max_job);
-
- while (!station1_rsp)
- {
- maximus.process ();
- }
-
- if (test_fail)
- return 0;
-
- sar_max_job->tei = 1;
- if (!reassembly (&maximus, &station2, station2_cb, sar_max_job))
- {
- printf ("Error on reassembly process\n");
- exit (-1);
- }
-
- while (!station2_rsp)
- {
- maximus.process ();
- }
+ /* create the fifo */
+ if (pipe (fifo_blk) < 0)
+ {
+ printf ("Can not create the pipe for the PBs communication\n");
+ exit (-1);
+ }
- maximus.wait (10000);
+ sar_max_job = (sar_max_job_t *) malloc (sizeof (sar_max_job_t));
+ sar_max_job->next = (sar_max_job_t *) malloc (sizeof (sar_max_job_t));
+ sar_max_job->next->next = NULL;
+
+ /* Init job 1 */
+ sar_max_job->lid = 1;
+ sar_max_job->tei_src = 1;
+ sar_max_job->tei_dest = 2;
+ sar_max_job->bcast = false;
+ sar_max_job->mf_type = 2;
+ sar_max_job->packet_id = 0;
+
+ /* Init job 2 */
+ sar_max_job->next->lid = 1;
+ sar_max_job->next->tei_src = 1;
+ sar_max_job->next->tei_dest = 2;
+ sar_max_job->next->bcast = false;
+ sar_max_job->next->mf_type = 2;
+ sar_max_job->packet_id = 0;
+
+ max_jobs_qte = 2;
+
+ return launch_x_segs (argc, argv, sar_max_job);
}
- catch (Error &e)
+ catch (Error &e)
{
- exit (-1);
+ sar_max_job_t *sar_max_job_curr;
+ while (sar_max_job)
+ {
+ sar_max_job_curr = sar_max_job;
+ sar_max_job = sar_max_job->next;
+ free (sar_max_job_curr);
+ }
}
-
- return 0;
}
/**
- * Launch the test on multiple shoot mode.
- *
- * \param argc the quantity of arguments provided
- * \param argv the char array containing the arguments
- * \param iter the quantity of iteration the multiple shoot should do.
- *
- * \return the end value
- */
-//int multiple_shoot (int argc, char *argv[], int iter)
-//{
-// unsigned char lid;
-// unsigned char tei;
-// bool bcast;
-// unsigned char mf_type;
-// unsigned char packet[1];
-// bool logs;
-// int i;
-//
-// test_fail = false;
-// station1_rsp = false;
-// station2_rsp = false;
-//
-// maximus.init (argc, argv);
-//
-// Sta station1 = maximus.create_sta ();
-// //station1.debug ();
-// Sta station2 = maximus.create_sta ();
-// //station2.debug ();
-//
-// // activate the sta 1 logs
-// Msg fc = maximus.create_fc ("activate_logs");
-// logs = true;
-// fc.add_param ("debug", sizeof(unsigned char), (unsigned char *) &logs);
-// fc.send (station2);
-// fc.send (station1);
-//
-// while (iter)
-// {
-// iter --;
-// station1_rsp = false;
-// station2_rsp = false;
-//
-// printf ("ITER : %d\n", iter);
-//
-// lid = 1;
-// tei = 2;
-// bcast = false;
-// mf_type = 2;
-// packet[0] = 0;
-// segmentation (&station1, station1_cb, lid, tei, bcast, mf_type,
-// packet);
-//
-// i = 0;
-// while (!station1_rsp || test_fail)
-// {
-// maximus.process ();
-// i++;
-//
-// if (i == 100)
-// {
-// test_fail = true;
-// }
-// }
-//
-// if (test_fail)
-// return 0;
-//
-// tei = 1;
-// reassembly (&station2, station2_cb, lid, tei, bcast, mf_type, packet);
-//
-// i = 0;
-// while (!station2_rsp)
-// {
-// maximus.process ();
-// i++;
-//
-// if (i == 100)
-// {
-// test_fail = true;
-// }
-// }
-//
-// maximus.wait (1000);
-// }
-//
-// return 0;
-//}
-
-/**
* Launch the procedure with n segmentation and one reassembly
*
* \param argc the quantity of arguments provided
@@ -332,64 +174,60 @@ int launch_x_segs (int argc, char *argv[], sar_max_job_t *sar_max_job)
{
bool logs;
int i;
-
test_fail = false;
- station1_rsp = false;
- station2_rsp = false;
Maximus maximus;
maximus.init (argc, argv);
Sta station1 = maximus.create_sta ();
- station1.debug ();
- //Sta station2 = maximus.create_sta ();
+ //station1.debug ();
+ Sta station2 = maximus.create_sta ();
//station2.debug ();
// activate the sta 1 logs
Msg fc = maximus.create_fc ("activate_logs");
logs = true;
- fc.add_param ("init", sizeof(unsigned char), (unsigned char *) &logs);
- //fc.send (station2);
+ fc.add_param ("debug", sizeof(unsigned char), (unsigned char *) &logs);
fc.send (station1);
-
- station1_rsp = false;
- station2_rsp = false;
+ fc.send (station2);
segmentation (&maximus, &station1, station1_cb, sar_max_job);
i = 0;
- while (!station1_rsp || test_fail)
+ while (!station1_rsp && !test_fail)
{
- maximus.process ();
+ if (i > 50)
+ {
+ test_fail = true;
+ }
i++;
- if (i == 100)
+ maximus.process ();
+ }
+
+ if (test_fail)
+ return -1;
+
+ reassembly (&maximus, &station2, &station2_cb, sar_max_job);
+
+ i = 0;
+ while (!station2_rsp && !test_fail)
+ {
+ if (i > 50)
{
test_fail = true;
}
+ i++;
+
+ maximus.process ();
}
+
+ maximus.wait (100);
if (test_fail)
+ return -1;
+ else
return 0;
-
- // tei = 1;
- // reassembly (&station2, station2_cb, lid, tei, bcast, mf_type, row_list);
- //
- // i = 0;
- // while (!station2_rsp)
- // {
- // maximus.process ();
- // i++;
- //
- // if (i == 100)
- // {
- // test_fail = true;
- // }
- // }
-
- maximus.wait (1000);
-
- return 0;
}
/**
diff --git a/mac/sar/test/maximus_test/src/Sta_sar.c b/mac/sar/test/maximus_test/src/Sta_sar.c
index fdcc6f9b2a..b38c2c8cd1 100644
--- a/mac/sar/test/maximus_test/src/Sta_sar.c
+++ b/mac/sar/test/maximus_test/src/Sta_sar.c
@@ -84,11 +84,38 @@ int reassembly (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
void *data);
/**
+ * Fill the mac store if necessary
+ *
+ * \param tx if it is a tx mfs (segmentation)
+ * \param job_curr current request.
+ *
+ */
+void fill_mac_store (bool tx, sar_max_job_t *job_curr);
+
+/**
+ * Verify the data
+ * \param the way
+ * \param job_curr the current sar_max_job to verify the lid and tei
+ *
+ */
+bool verify_data_recivied (bool tx, sar_max_job_t *job_curr);
+
+/**
* The bridge dma function call back.
*/
bool bridge_dma_interruption_station (void *user, u32 status_word);
/**
+ * bridge dma segmentation call back.
+ */
+bool bridge_dma_interruption_seg (sar_job_mfs_t *sar_job);
+
+/**
+ * bridge dma segmentation call back.
+ */
+bool bridge_dma_interruption_rea (sar_job_mfs_t *sar_job);
+
+/**
* A function to simulate the pbprocessing.
* It only modify the PBs order.
*/
@@ -97,6 +124,14 @@ u16 mix_up_pbs (pb_t **first, pb_t **last);
extern station_ctx_t my_station;
unsigned short msg_id;
+unsigned char lid;
+unsigned char tei_src;
+unsigned char tei_dest;
+
+unsigned int seg_counter;
+unsigned int rea_counter;
+unsigned int mf_qte;
+
/** Debuging data */
/** Debug info, print all the kind of logs */
bool debug_info;
@@ -188,121 +223,57 @@ int activate_logs (fcall_ctx_t *fcall, fcall_param_t **param,
}
/**
- * The function call used by maximus to launch a segmentation process to the STA.
+ * Fill the mac store if necessary
+ *
+ * \param tx if it is a tx mfs (segmentation)
+ * \param job_curr current request.
*
*/
-int segmentation (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
- void *data)
+void fill_mac_store (bool tx, sar_max_job_t *job_curr)
{
- u8 jobs_qte;
- sta_t *sta;
- mfs_tx_t *mfs;
+ sta_t *sta= NULL;
bool added;
- u8 i;
- u8 id[5];
- u8 val[2];
-
- sar_max_job_t *jobs= NULL;
- sar_max_job_t *job_curr= NULL;
-
- msg_id = (*param)->msg_id;
-
- fcall_param_bind (*param, *msg, "qte", sizeof(u8), &jobs_qte);
-
- for (i = 0; i < jobs_qte; i++)
- {
- if (!jobs)
- {
- jobs = (sar_max_job_t *) malloc (sizeof(sar_max_job_t));
- job_curr = jobs;
- }
- else
- {
- job_curr->next = (sar_max_job_t *) malloc (sizeof(sar_max_job_t));
- job_curr = job_curr->next;
- }
- job_curr->next = NULL;
-
- sprintf (val, "%d", i);
- strcpy (id, "job");
- strcat (id, val);
- fcall_param_bind (*param, *msg, id, sizeof(sar_max_job_t), job_curr);
- }
- for (job_curr = jobs; job_curr; job_curr = job_curr->next)
+ if (tx)
{
- if (log_init_info)
- {
- diag_printf ("[INIT SEG] lid : %d\n", job_curr->lid);
- diag_printf ("[INIT SEG] tei : %d\n", job_curr->tei);
- diag_printf ("[INIT SEG] mf_type : %d\n", job_curr->mf_type);
- diag_printf ("[INIT SEG] bcast : %d\n", job_curr->bcast);
- diag_printf ("[INIT SEG] packet : %d\n", job_curr->packet_id);
- }
-
- /* Verifying the data received */
- if (job_curr->lid == 0)
- {
- job_curr->lid = MAC_LID_NONE;
-
- if (log_init_info)
- diag_printf ("[INIT SEG] lid had been modified to MAC_LID_NONE\n");
- }
-
- if (job_curr->bcast && job_curr->tei != MAC_TEI_BCAST)
- {
- job_curr->tei = MAC_TEI_BCAST;
-
- if (log_init_info)
- diag_printf ("[INIT SEG] tei had been modified to MAC_TEI_BCAST\n");
- }
-
- /* Verify if the type of the MF is compatible with the lid */
- if (job_curr->mf_type != 3&& job_curr->lid == MAC_LID_NONE)
- {
- if (log_init_info)
- diag_printf ("[INIT SEG] lid is a mme lid and the MF type is not a mme type\n");
- return -1;
- }
-
- fcall_param_set_async (*param, 1);
-
- if (MAC_TEI_IS_STA (job_curr->tei))
+ mfs_tx_t *mfs;
+ if (MAC_TEI_IS_STA (job_curr->tei_dest))
{
sta = mac_store_sta_get (sar_ctx.expiration.mfs_store,
- job_curr->tei);
+ job_curr->tei_dest);
}
- if (!sta && MAC_TEI_IS_STA (job_curr->tei))
+ if (!sta && MAC_TEI_IS_STA (job_curr->tei_dest))
{
if (log_init_info)
{
diag_printf (
"[INIT SEG] Adding the STA to the mac store, tei : %d\n",
- job_curr->tei);
+ job_curr->tei_dest);
}
/* Add the sta to the mac store */
- mac_store_sta_add (sar_ctx.expiration.mfs_store, job_curr->tei);
+ mac_store_sta_add (sar_ctx.expiration.mfs_store,
+ job_curr->tei_dest);
if (log_init_info)
{
diag_printf (
"[INIT SEG] Adding the MFS to the mac store, lid : %d, tei : %d, bcast : %d\n",
- job_curr->lid, job_curr->tei, job_curr->bcast);
+ job_curr->lid, job_curr->tei_dest, job_curr->bcast);
}
/* Add the MFS to the mac store */
if (job_curr->lid != MAC_LID_NONE)
{
mfs = mac_store_mfs_add_tx (sar_ctx.expiration.mfs_store,
- job_curr->bcast, false, job_curr->lid, job_curr->tei,
- &added);
+ job_curr->bcast, false, job_curr->lid,
+ job_curr->tei_dest, &added);
}
else
{
mfs = mac_store_mfs_add_tx (sar_ctx.expiration.mfs_store,
- job_curr->bcast, true, job_curr->lid, job_curr->tei,
- &added);
+ job_curr->bcast, true, job_curr->lid,
+ job_curr->tei_dest, &added);
}
dbg_assert (added);
@@ -314,13 +285,15 @@ int segmentation (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
/* Get the MFS from the Store */
if (job_curr->lid != MAC_LID_NONE)
{
- mfs = mac_store_mfs_get_tx (sar_ctx.expiration.mfs_store,
- job_curr->bcast, false, job_curr->lid, job_curr->tei);
+ mfs= mac_store_mfs_get_tx (sar_ctx.expiration.mfs_store,
+ job_curr->bcast, false, job_curr->lid,
+ job_curr->tei_dest);
}
else
{
mfs = mac_store_mfs_get_tx (sar_ctx.expiration.mfs_store,
- job_curr->bcast, true, job_curr->lid, job_curr->tei);
+ job_curr->bcast, true, job_curr->lid,
+ job_curr->tei_dest);
}
if (!mfs)
@@ -330,12 +303,13 @@ int segmentation (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
{
diag_printf (
"[INIT-SEG] Adding the MFS to the mac store, lid : %d, tei : %d, bcast : %d\n",
- job_curr->lid, job_curr->tei, job_curr->bcast);
+ job_curr->lid, job_curr->tei_dest,
+ job_curr->bcast);
}
mfs = mac_store_mfs_add_tx (sar_ctx.expiration.mfs_store,
- job_curr->bcast, false, job_curr->lid, job_curr->tei,
- &added);
+ job_curr->bcast, false, job_curr->lid,
+ job_curr->tei_dest, &added);
dbg_assert (added);
mfs->head = NULL;
@@ -345,52 +319,300 @@ int segmentation (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
}
}
+ }
+ else
+ {
+ if (!sta && MAC_TEI_IS_STA (job_curr->tei_src))
+ {
+ mfs_rx_t * mfs;
+
+ if (log_init_info)
+ {
+ diag_printf (
+ "[INIT-REA] Add the STA to the mac store, tei : %d\n",
+ job_curr->tei_src);
+ }
+ /* Add the sta to the store */
+ mac_store_sta_add (sar_ctx.expiration.mfs_store,
+ job_curr->tei_src);
+
+ if (log_init_info)
+ {
+ diag_printf (
+ "[INIT-REA] Add the data MFS to the mac store, lid : %d, tei : %d\n",
+ job_curr->lid, job_curr->tei_src);
+ diag_printf ("[INIT-REA] Add the data MFS to SAR expiration mechanism\n");
+ }
- if (log_seg_info)
+ /* Add the mfs to the store */
+ mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store, false,
+ false, job_curr->lid, job_curr->tei_src, &added);
+ dbg_assert (added);
+
+ /* Add the mfs to the SAR expiration */
+ mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx) + 100;
+ sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
+
+ if (log_init_info)
+ {
+ diag_printf (
+ "[INIT-REA] Add the mme MFS to the mac store, lid : %d, tei : %d\n",
+ job_curr->lid, job_curr->tei_src);
+ diag_printf ("[INIT-REA] Add the mme MFS to SAR expiration mechanism\n");
+ }
+ /* Add the MME MFS to the store */
+ mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store, false,
+ true, MAC_LID_NONE, job_curr->tei_src, &added);
+ dbg_assert (added);
+
+ /* Add the mfs to the sar expiration */
+ mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx) + 100;
+ sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
+ }
+ else
{
- diag_printf ("[SEG] Adding an msdu \n");
- diag_printf ("[SEG] packet number : %d\n", job_curr->packet_id);
- diag_printf ("[SEG] msdu type : %d\n", job_curr->mf_type);
- diag_printf ("[SEG] packet len : %d\n",
- packets_len[job_curr->packet_id]- 1);
- diag_printf ("[SEG] ATS : %x\n", 0x12345678);
- diag_printf ("[SEG] mfs @ : %p\n", mfs);
- diag_printf ("[SEG] lid : %d\n", mfs->common.lid);
- diag_printf ("[SEG] tei : %d\n", mfs->common.tei);
- diag_printf ("[SEG] bcast : %d\n", mfs->common.bcast);
+ /* Verify if the lid is a plid one */
+ if (!MAC_LID_IS_PLID (job_curr->lid))
+ {
+ mfs_rx_t * mfs;
+
+ /* Add the mfs to the store */
+ mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store,
+ job_curr->bcast, false, job_curr->lid,
+ job_curr->tei_src);
+
+ if (!mfs)
+ {
+ if (log_init_info)
+ {
+ diag_printf (
+ "[INIT-REA] Add the data MFS to the mac store, lid : %d, tei : %d\n",
+ job_curr->lid, job_curr->tei_src);
+ diag_printf ("[INIT-REA] Add the data MFS to SAR expiration mechanism\n");
+ }
+ /* Add the mfs to the store */
+ mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store,
+ job_curr->bcast, false, job_curr->lid,
+ job_curr->tei_src, &added);
+ dbg_assert (added);
+
+ /* Add the mfs to the SAR expiration */
+ mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx)
+ + 100;
+ sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
+ }
+
+ /* Verifies the MME mfs */
+ mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store,
+ job_curr->bcast, true, MAC_LID_NONE,
+ job_curr->tei_src);
+
+ if (!mfs)
+ {
+ if (log_init_info)
+ {
+ diag_printf (
+ "[INIT-REA] Add the mme MFS to the mac store, lid : %d, tei : %d\n",
+ job_curr->lid, job_curr->tei_src);
+ diag_printf ("[INIT-REA] Add the mme MFS to SAR expiration mechanism\n");
+ }
+
+ /* Add the MME MFS to the store */
+ mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store,
+ job_curr->bcast, true, MAC_LID_NONE,
+ job_curr->tei_src, &added);
+ dbg_assert (added);
+
+ /* Add the mfs to the sar expiration */
+ mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx)
+ + 100;
+ sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
+ }
+ }
}
- sar_msdu_add (&sar_ctx, packets[job_curr->packet_id],
- job_curr->mf_type, packets_len[job_curr->packet_id],
- 0x12345678, mfs);
+ }
+}
- /** Launch the SAR to segment the msdu **/
- sar_launch (0);
+/**
+ * Verify the data
+ * \param the way
+ * \param job_curr the current sar_max_job to verify the lid and tei
+ *
+ */
+bool verify_data_recivied (bool tx, sar_max_job_t *job_curr)
+{
+ /* Verifying the data received */
+ if (job_curr->lid == 0)
+ {
+ job_curr->lid = MAC_LID_NONE;
- if (log_seg_info)
- diag_printf ("[SEG] MSDU segmented\n");
+ if (log_init_info && tx)
+ diag_printf ("[INIT SEG] lid had been modified to MAC_LID_NONE\n");
+ else
+ diag_printf ("[INIT REA] lid had been modified to MAC_LID_NONE\n");
+ }
+ /* Verify if the type of the MF is compatible with the lid */
+ if (job_curr->mf_type != 3&& job_curr->lid == MAC_LID_NONE)
+ {
+ if (log_init_info)
+ diag_printf ("[INIT SEG] lid is a mme lid and the MF type is not a mme type\n");
+ return false;
}
+
+ if (tx && job_curr->bcast&& job_curr->tei_dest != MAC_TEI_BCAST)
+ {
+ job_curr->tei_dest = MAC_TEI_BCAST;
+
+ if (log_init_info)
+ diag_printf ("[INIT SEG] tei had been modified to MAC_TEI_BCAST\n");
+ }
+ else if (!tx && job_curr->bcast&& job_curr->tei_src != MAC_TEI_BCAST)
+ {
+ job_curr->tei_src = MAC_TEI_BCAST;
+
+ if (log_init_info)
+ diag_printf ("[INIT REA] tei had been modified to MAC_TEI_BCAST\n");
+ }
+
return true;
}
/**
- * The function call used by maximus to reassembly a Ethernet packet.
+ * The function call used by maximus to launch a segmentation process to the STA.
+ *
*/
+int segmentation (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
+ void *data)
+{
+ u8 jobs_qte;
+ mfs_tx_t *mfs;
+ u8 i;
+ u8 id[5];
+ u8 val[2];
+ bool mme;
+
+ sar_max_job_t *jobs= NULL;
+ sar_max_job_t *job_curr= NULL;
+
+ msg_id = (*param)->msg_id;
+
+ fcall_param_bind (*param, *msg, "qte", sizeof(u8), &jobs_qte);
+
+ seg_counter = 0;
+ mf_qte = jobs_qte;
+
+ for (i = 0; i < jobs_qte; i++)
+ {
+ if (!jobs)
+ {
+ jobs = (sar_max_job_t *) malloc (sizeof(sar_max_job_t));
+ job_curr = jobs;
+ }
+ else
+ {
+ job_curr->next = (sar_max_job_t *) malloc (sizeof(sar_max_job_t));
+ job_curr = job_curr->next;
+ }
+ job_curr->next = NULL;
+
+ sprintf (val, "%d", i);
+ strcpy (id, "job");
+ strcat (id, val);
+ fcall_param_bind (*param, *msg, id, sizeof(sar_max_job_t), job_curr);
+ }
+
+ /** store the lid and tei in the STA
+ * If it is not done, the fcall answer will be false
+ * All the jobs must be to the same MFS.
+ * */
+ lid = jobs->lid;
+ tei_dest = jobs->tei_dest;
+
+ for (job_curr = jobs; job_curr; job_curr = job_curr->next)
+ {
+ if (log_init_info)
+ {
+ diag_printf ("[INIT SEG] lid : %d\n", job_curr->lid);
+ diag_printf ("[INIT SEG] tei : %d\n", job_curr->tei_dest);
+ diag_printf ("[INIT SEG] mf_type : %d\n", job_curr->mf_type);
+ diag_printf ("[INIT SEG] bcast : %d\n", job_curr->bcast);
+ diag_printf ("[INIT SEG] packet : %d\n", job_curr->packet_id);
+ }
+
+ fill_mac_store (true, job_curr);
+
+ if (lid == job_curr->lid&& tei_dest == job_curr->tei_dest
+ && verify_data_recivied (true, job_curr))
+ {
+
+ /* Get the MFS from the store */
+ if (job_curr->mf_type == 3)
+ mme = true;
+ else
+ mme = false;
+
+ mfs = mac_store_mfs_get_tx (sar_ctx.expiration.mfs_store,
+ job_curr->bcast, mme, job_curr->lid, job_curr->tei_dest);
+
+ if (log_init_info)
+ {
+ diag_printf ("[SEG] Adding an msdu \n");
+ diag_printf ("[SEG] packet number : %d\n",
+ job_curr->packet_id);
+ diag_printf ("[SEG] msdu type : %d\n", job_curr->mf_type);
+ diag_printf ("[SEG] packet len : %d\n",
+ packets_len[job_curr->packet_id]- 1);
+ diag_printf ("[SEG] ATS : %x\n", 0x12345678);
+ diag_printf ("[SEG] mfs @ : %p\n", mfs);
+ diag_printf ("[SEG] lid : %d\n", mfs->common.lid);
+ diag_printf ("[SEG] tei : %d\n", mfs->common.tei);
+ diag_printf ("[SEG] bcast : %d\n", mfs->common.bcast);
+ }
+
+ sar_msdu_add (&sar_ctx, packets[job_curr->packet_id],
+ job_curr->mf_type, packets_len[job_curr->packet_id],
+ 0x12345678, mfs);
+
+ /** Launch the SAR to segment the msdu **/
+ sar_launch (0);
+
+ if (log_seg_info)
+ diag_printf ("[SEG] MSDU segmented\n");
+
+ }
+ }
+
+ for (job_curr = jobs; jobs; job_curr = jobs)
+ {
+ jobs = job_curr->next;
+ free (job_curr);
+ }
+
+ fcall_param_set_async (*param, 1);
+
+ return true;
+}
+
+///**
+// * The function call used by maximus to reassembly a Ethernet packet.
+// */
int reassembly (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
void *data)
{
- bool added;
- sta_t * sta;
u32 pb_nb;
u32 i;
u8 value [3];
u8 id [5];
+ u8 jobs_qte;
+
u8 param_buffer[1024];
- mfs_rx_t *data_mfs;
- mfs_rx_t *msg_mfs;
+
+ mfs_rx_t *mfs;
+ bool mme;
pbproc_rx_params_t rx_params;
+
u16 mf_length;
- u8 jobs_qte;
/* buffer aligned for the reassembly process */
u8 *sar_buffer __attribute__((aligned(2048)));
@@ -401,7 +623,12 @@ int reassembly (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
sar_max_job_t *sar_max_jobs= NULL;
sar_max_job_t *sar_max_job_curr= NULL;
+ rea_counter = 0;
+
+ msg_id = (*param)->msg_id;
+
fcall_param_bind (*param, *msg, "job_qte", sizeof(u8), &jobs_qte);
+ mf_qte = jobs_qte;
for (i = 0; i < jobs_qte; i++)
{
@@ -425,124 +652,31 @@ int reassembly (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
sar_max_job_curr);
}
+ /** store the lid and tei in the STA
+ * If it is not done, the fcall answer will be false
+ * All the jobs must be to the same MFS.
+ * */
+ lid = sar_max_jobs->lid;
+ tei_src = sar_max_jobs->tei_src;
+
if (log_init_info)
{
diag_printf ("[INIT-REA] lid : %d\n", sar_max_job_curr->lid);
- diag_printf ("[INIT-REA] tei : %d\n", sar_max_job_curr->tei);
+ diag_printf ("[INIT-REA] tei : %d\n", sar_max_job_curr->tei_src);
diag_printf ("[INIT-REA] bcast : %d\n", sar_max_job_curr->bcast);
diag_printf ("[INIT-REA] packet : %d\n", sar_max_job_curr->packet_id);
}
- // fcall_param_set_async (*param, 1);
-
- /* try to get the sta from the store */
- /* Verify if the sta exists, if it does not exist the sta is created */
- if (!sta && MAC_TEI_IS_STA (sar_max_job_curr->tei))
- {
- mfs_rx_t * mfs;
-
- if (log_init_info)
- {
- diag_printf (
- "[INIT-REA] Add the STA to the mac store, tei : %d\n",
- sar_max_job_curr->tei);
- }
- /* Add the sta to the store */
- mac_store_sta_add (sar_ctx.expiration.mfs_store,
- sar_max_job_curr->tei);
-
- if (log_init_info)
- {
- diag_printf (
- "[INIT-REA] Add the data MFS to the mac store, lid : %d, tei : %d\n",
- sar_max_job_curr->lid, sar_max_job_curr->tei);
- diag_printf ("[INIT-REA] Add the data MFS to SAR expiration mechanism\n");
- }
-
- /* Add the mfs to the store */
- mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store, false,
- false, sar_max_job_curr->lid, sar_max_job_curr->tei, &added);
- dbg_assert (added);
-
- /* Add the mfs to the SAR expiration */
- mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx) + 100;
- sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
+ verify_data_recivied (false, sar_max_job_curr);
+ fill_mac_store (false, sar_max_job_curr);
- if (log_init_info)
- {
- diag_printf (
- "[INIT-REA] Add the mme MFS to the mac store, lid : %d, tei : %d\n",
- sar_max_job_curr->lid, sar_max_job_curr->tei);
- diag_printf ("[INIT-REA] Add the mme MFS to SAR expiration mechanism\n");
- }
- /* Add the MME MFS to the store */
- mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store, false,
- true, MAC_LID_NONE, sar_max_job_curr->tei, &added);
- dbg_assert (added);
-
- /* Add the mfs to the sar expiration */
- mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx) + 100;
- sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
- }
+ if (sar_max_job_curr->mf_type > 2)
+ mme = true;
else
- {
- /* Verify if the lid is a plid one */
- if (!MAC_LID_IS_PLID (sar_max_job_curr->lid))
- {
- mfs_rx_t * mfs;
-
- /* Add the mfs to the store */
- mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store,
- sar_max_job_curr->bcast, false, sar_max_job_curr->lid,
- sar_max_job_curr->tei);
-
- if (!mfs)
- {
- if (log_init_info)
- {
- diag_printf (
- "[INIT-REA] Add the data MFS to the mac store, lid : %d, tei : %d\n",
- sar_max_job_curr->lid, sar_max_job_curr->tei);
- diag_printf ("[INIT-REA] Add the data MFS to SAR expiration mechanism\n");
- }
- /* Add the mfs to the store */
- mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store,
- sar_max_job_curr->bcast, false,
- sar_max_job_curr->lid, sar_max_job_curr->tei, &added);
- dbg_assert (added);
-
- /* Add the mfs to the SAR expiration */
- mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx)+ 100;
- sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
- }
-
- /* Verifies the MME mfs */
- mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store,
- sar_max_job_curr->bcast, true, MAC_LID_NONE,
- sar_max_job_curr->tei);
-
- if (!mfs)
- {
- if (log_init_info)
- {
- diag_printf (
- "[INIT-REA] Add the mme MFS to the mac store, lid : %d, tei : %d\n",
- sar_max_job_curr->lid, sar_max_job_curr->tei);
- diag_printf ("[INIT-REA] Add the mme MFS to SAR expiration mechanism\n");
- }
+ mme = false;
- /* Add the MME MFS to the store */
- mfs = mac_store_mfs_add_rx (sar_ctx.expiration.mfs_store,
- sar_max_job_curr->bcast, true, MAC_LID_NONE,
- sar_max_job_curr->tei, &added);
- dbg_assert (added);
-
- /* Add the mfs to the sar expiration */
- mfs->common.expiration_date = phy_date (sar_ctx.phy_ctx)+ 100;
- sar_mfs_add (&sar_ctx, (mfs_t *) mfs);
- }
- }
- }
+ mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store,
+ sar_max_job_curr->bcast, mme, lid, tei_src);
/* Getting the PBs from Maximus */
fcall_param_bind (*param, *msg, "pb_qte", sizeof(u32), &pb_nb);
@@ -604,67 +738,76 @@ int reassembly (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
if (mf_length != packets_len[sar_max_job_curr->packet_id])
{
+ if (debug_info)
+ {
+ int deb;
+
+ diag_printf ("[DEBUG - RX] data : ");
+ for (deb = 0; deb < 6; deb++)
+ {
+ diag_printf ("%02x ", pb_head->data[deb]);
+ }
+ diag_printf ("\n");
+ }
return -1;
}
- /* add the buffer to the sar for the reassembly */
- sar_buffer = (u8 *) malloc (2048 * sizeof(u8));
+ rx_params.tei = tei_src;
+ rx_params.lid = lid;
+ rx_params.bcast = sar_max_job_curr->bcast;
if (log_rea_info)
{
- diag_printf ("[REA] buffer added : %p\n", sar_buffer);
- }
- sar_buffer_add (&sar_ctx.data_ctx, sar_buffer);
- sar_launch (0);
+ diag_printf ("[REA] MFS : %p\n", mfs);
+ if (mfs && debug_info)
+ {
+ diag_printf ("[DEBUG-REA] data MFS, lid : %d, tei : %d\n",
+ mfs->common.lid, mfs->common.tei);
+ }
- /* add the mpdu to the sar and launch the process */
- if (!sar_max_job_curr->bcast)
- {
- msg_mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store, false,
- true, MAC_LID_NONE, sar_max_job_curr->tei);
- data_mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store, false,
- false, sar_max_job_curr->lid, sar_max_job_curr->tei);
- }
- else
- {
- msg_mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store, true,
- true, MAC_LID_NONE, sar_max_job_curr->tei);
- data_mfs = mac_store_mfs_get_rx (sar_ctx.expiration.mfs_store, true,
- false, sar_max_job_curr->lid, sar_max_job_curr->tei);
- }
+ diag_printf ("[REA] lid : %d\n", rx_params.lid);
+ diag_printf ("[REA] tei : %d\n", rx_params.tei);
+ diag_printf ("[REA] bcast : %d\n", rx_params.bcast);
- rx_params.tei = sar_max_job_curr->tei;
- rx_params.lid = sar_max_job_curr->lid;
- rx_params.bcast = sar_max_job_curr->bcast;
+ diag_printf ("[REA] Launching the reassembly process...\n");
+ }
- if (log_rea_info)
+ for (i = 0; i < mf_qte; i++)
{
- diag_printf ("[REA] data MFS : %p\n", data_mfs);
- if (data_mfs && debug_info)
+ /* add the buffer to the sar for the reassembly */
+ sar_buffer = (u8 *) malloc (2048 * sizeof(u8));
+
+ if (log_rea_info)
{
- diag_printf ("[DEBUG-REA] data MFS, lid : %d, tei : %d\n",
- data_mfs->common.lid, data_mfs->common.tei);
+ diag_printf ("[REA] buffer added : %p\n", sar_buffer);
}
+ sar_buffer_add (&sar_ctx.data_ctx, sar_buffer);
+ sar_launch (0);
- diag_printf ("[REA] mme MFS : %p\n", msg_mfs);
- if (msg_mfs && debug_info)
+ if (mfs && mfs->common.mme)
+ {
+ sar_mpdu_add (&sar_ctx, NULL, (mfs_t *) mfs, &rx_params, pb_head,
+ pb_tail, pb_nb, NULL);
+ }
+ else if (mfs)
{
- diag_printf ("[DEBUG-REA] mme MFS, tei : %d\n",
- msg_mfs->common.tei);
+ sar_mpdu_add (&sar_ctx, (mfs_t *)mfs, NULL, &rx_params, pb_head,
+ pb_tail, pb_nb, NULL);
}
- diag_printf ("[REA] lid : %d\n", rx_params.lid);
- diag_printf ("[REA] tei : %d\n", rx_params.tei);
- diag_printf ("[REA] bcast : %d\n", rx_params.bcast);
+ sar_launch (0);
+ if (log_rea_info)
+ diag_printf ("[REA] Reassembly process executed\n");
+ }
- diag_printf ("[REA] Launching the reassembly process...\n");
+ for (sar_max_job_curr = sar_max_jobs; sar_max_jobs; sar_max_job_curr
+ = sar_max_jobs)
+ {
+ sar_max_jobs = sar_max_job_curr->next;
+ free (sar_max_job_curr);
}
- sar_mpdu_add (&sar_ctx, (mfs_t *)data_mfs, (mfs_t *) msg_mfs, &rx_params,
- pb_head, pb_tail, pb_nb, NULL);
- sar_launch (0);
- if (log_rea_info)
- diag_printf ("[REA] Reassembly process executed\n");
+ fcall_param_set_async (*param, 1);
return true;
}
@@ -674,199 +817,273 @@ int reassembly (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
*/
bool bridge_dma_interruption_station (void *user, u32 status_word)
{
+ sar_job_mfs_t *sar_job;
+
+ sar_job = bridge_dma_get_head (&sar_ctx.bridge_dma_jobs);
+ dbg_assert (sar_job);
+
+ if (sar_job->job.direction == 0)
+ {
+ return bridge_dma_interruption_seg (sar_job);
+ }
+ else
+ {
+ return bridge_dma_interruption_rea (sar_job);
+ }
+}
+
+/**
+ * bridge dma segmentation call back.
+ */
+bool bridge_dma_interruption_seg (sar_job_mfs_t *sar_job)
+{
static fcall_param_t return_param;
static sci_msg_t return_msg;
static unsigned char return_buffer[SCI_MSG_MAX_SIZE];
- sar_job_mfs_t *sar_job;
bool error = false;
u16 pb_qte;
- sar_job = bridge_dma_get_head (&sar_ctx.bridge_dma_jobs);
dbg_assert (sar_job);
- /** init structures **/
- fcall_param_init (&return_param, "seg_complete_done", msg_id);
- sci_msg_init (&return_msg, return_buffer, SCI_MSG_MAX_SIZE);
+ pb_qte = mf_get_quantity_of_pb ((pb_t *) sar_job->job.first_pb_desc,
+ sar_job->job.first_pb_offset);
- /** reset the param list **/
- fcall_param_reset (&return_param);
-
- if (sar_job->job.direction == 0)
+ if (debug_info)
{
- /* Caculate the quantity of PB the segmentation should have */
- pb_qte = mf_get_quantity_of_pb ((pb_t *) sar_job->job.first_pb_desc,
+ diag_printf ("\t[BRIDGE - TX] sar_job @ %p\n", sar_job);
+ diag_printf ("\t[BRIDGE - TX] job->data_addr : %p\n",
+ sar_job->job.data_addr);
+ diag_printf ("\t[BRIDGE - TX] job->first_pb_desc : %p\n",
+ sar_job->job.first_pb_desc);
+ diag_printf ("\t[BRIDGE - TX] job->first_pb_offset : %d\n",
sar_job->job.first_pb_offset);
+ diag_printf ("\t[BRIDGE - TX] job->pb_quantity : %d\n",
+ sar_job->pb_quantity);
+ diag_printf ("\t[BRIDGE - TX] job->data_addr : %p\n",
+ sar_job->job.data_addr);
+ diag_printf ("\t[BRIDGE - TX] job->data_len : %d\n",
+ sar_job->job.data_len);
+ diag_printf ("\t[BRIDGE - TX] MF len : %d\n", mf_get_length (
+ (pb_t *)sar_job->job.first_pb_desc,
+ sar_job->job.first_pb_offset, false));
+ diag_printf ("\t[BRIDGE - TX] MF qte PB : %d\n",
+ mf_get_quantity_of_pb ((pb_t *)sar_job->job.first_pb_desc,
+ sar_job->job.first_pb_offset));
+ diag_printf ("\t[BRIDGE - TX] job @ : %p\n", sar_job);
if (debug_info)
{
- diag_printf ("\t[BRIDGE - TX] sar_job @ %p\n", sar_job);
- diag_printf ("\t[BRIDGE - TX] job->data_addr : %p\n",
- sar_job->job.data_addr);
- diag_printf ("\t[BRIDGE - TX] job->first_pb_desc : %p\n",
- sar_job->job.first_pb_desc);
- diag_printf ("\t[BRIDGE - TX] job->first_pb_offset : %d\n",
- sar_job->job.first_pb_offset);
- diag_printf ("\t[BRIDGE - TX] job->pb_quantity : %d\n",
- sar_job->pb_quantity);
- diag_printf ("\t[BRIDGE - TX] job->data_addr : %p\n",
- sar_job->job.data_addr);
- diag_printf ("\t[BRIDGE - TX] job->data_len : %d\n",
- sar_job->job.data_len);
- diag_printf ("\t[BRIDGE - TX] MF len : %d\n", mf_get_length (
- (pb_t *)sar_job->job.first_pb_desc,
- sar_job->job.first_pb_offset, false));
- diag_printf ("\t[BRIDGE - TX] MF qte PB : %d\n",
- mf_get_quantity_of_pb (
- (pb_t *)sar_job->job.first_pb_desc,
- sar_job->job.first_pb_offset));
- diag_printf ("\t[BRIDGE - TX] job @ : %p\n", sar_job);
+ int deb;
+ diag_printf ("[DEBUG - TX] PB data header : ");
+ for (deb = 0; deb < 6; deb++)
+ {
+ diag_printf (
+ "%02x ",
+ ((pb_t *)sar_job->job.first_pb_desc)->data[deb + sar_job->job.first_pb_offset]);
+ }
+ diag_printf ("\n");
}
+ }
- if (!sar_job->mfs->tx.head || pb_qte != sar_job->pb_quantity)
- {
- fcall_param_add (&return_param, &return_msg, "ERROR", 20
- * sizeof(u8), (unsigned char *) "seg fail");
+ if (!(pb_qte == sar_job->pb_quantity&& sar_job->mfs->tx.head))
+ {
+ diag_printf ("/***********************************************************/\n");
+ diag_printf (" :( [Segmentation] FAIL :(\n");
+ diag_printf ("/***********************************************************/\n");
- diag_printf ("/***********************************************************/\n");
- diag_printf (" :( [Segmentation] FAIL :(\n");
- diag_printf ("/***********************************************************/\n");
- }
- else
- {
- u8 id [5];
- u8 value [3];
- u8 i;
- pb_t *pb_curr;
+ blk_release (sar_job->mfs);
+ blk_release (sar_job);
- fcall_param_add (&return_param, &return_msg, "type", 4
- * sizeof(u8), (unsigned char *) "SEG");
+ return false;
+ }
- fcall_param_add_long (&return_param, &return_msg, "qte",
- (unsigned char *) &sar_job->pb_quantity);
+ diag_printf ("/***********************************************************/\n");
+ diag_printf (" ^^ [Segmentation] SUCCESS ^^\n");
+ diag_printf ("/***********************************************************/\n");
+ blk_release (sar_job->mfs);
+ blk_release (sar_job);
- for (i = 0, pb_curr = (pb_t *) sar_job->job.first_pb_desc; i
- < sar_job->pb_quantity; i++)
+ seg_counter ++;
+
+ /** Create the return call back function */
+ if (seg_counter == mf_qte)
+ {
+ int _pb_qte;
+
+ /** init structures **/
+ fcall_param_init (&return_param, "seg_complete_done", msg_id);
+ sci_msg_init (&return_msg, return_buffer, SCI_MSG_MAX_SIZE);
+
+ /** reset the param list **/
+ fcall_param_reset (&return_param);
+
+ u8 id [5];
+ u8 value [3];
+ u8 i;
+ pb_t *pb_curr;
+
+ fcall_param_add (&return_param, &return_msg, "type", 4* sizeof(u8),
+ (unsigned char *) "SEG");
+
+ _pb_qte = 0;
+ for (i = 0, pb_curr = (pb_t *) sar_job->job.first_pb_desc; i
+ < sar_job->pb_quantity; i++)
+ {
+ _pb_qte += sar_job->pb_quantity;
+
+ sprintf (value, "%d", i);
+
+ if (debug_info)
{
- sprintf (value, "%d", i);
+ diag_printf ("[DEBUG - TX] ssn : %d\n", pb_curr->header.ssn);
+ }
- if (debug_info)
+ if (i == sar_job->pb_quantity - 1)
+ {
+ sar_job->mfs->tx.head = pb_free (sar_job->mfs->tx.head);
+ if (sar_job->mfs->tx.head == NULL)
{
- diag_printf ("[DEBUG - TX] ssn : %d\n",
- pb_curr->header.ssn);
+ sar_job->mfs->tx.last_seg_offset = 0;
+ sar_job->mfs->tx.tail = NULL;
}
-
- if (i == sar_job->pb_quantity - 1)
+ else
{
- sar_job->mfs->tx.head = pb_free (sar_job->mfs->tx.head);
- if (sar_job->mfs->tx.head == NULL)
- {
- sar_job->mfs->tx.last_seg_offset = 0;
- sar_job->mfs->tx.tail = NULL;
- }
- else
- {
- sar_job->mfs->tx.last_seg_offset
- = sar_job->mfs->tx.head->header.mfbo;
- }
+ sar_job->mfs->tx.last_seg_offset
+ = sar_job->mfs->tx.head->header.mfbo;
}
+ }
- strcpy (id, "pbh");
- strcat (id, value);
- fcall_param_add_long (&return_param, &return_msg, id,
- &pb_curr->header);
-
- strcpy (id, "pb");
- strcat (id, value);
- fcall_param_add (&return_param, &return_msg, id, BLK_SIZE,
- (unsigned char *) pb_curr->data);
+ strcpy (id, "pbh");
+ strcat (id, value);
+ fcall_param_add_long (&return_param, &return_msg, id,
+ &pb_curr->header);
- pb_curr = pb_free (pb_curr);
- }
+ strcpy (id, "pb");
+ strcat (id, value);
+ fcall_param_add (&return_param, &return_msg, id, BLK_SIZE,
+ (unsigned char *) pb_curr->data);
- diag_printf ("/***********************************************************/\n");
- diag_printf (" ^^ [Segmentation] SUCCESS ^^\n");
- diag_printf ("/***********************************************************/\n");
+ pb_curr = pb_free (pb_curr);
}
+
+ fcall_param_add_long (&return_param, &return_msg, "qte",
+ (unsigned char *) &_pb_qte);
+
+ /* return */
+ fcall_return (my_station.fcall, &return_param, &return_msg);
}
- else
- {
- u16 i;
- u16 mf_length;
- u8 packet_nb;
- dbg_assert (sar_job->pb_quantity);
- mf_length = mf_get_length ((pb_t *)sar_job->job.first_pb_desc,
- sar_job->job.first_pb_offset, true);
+ return !error;
+}
- for (packet_nb = 0; packet_nb < PACKETS_QTE && mf_length
- != packets_len[packet_nb]; packet_nb++)
- ;
+/**
+ * bridge dma segmentation call back.
+ */
+bool bridge_dma_interruption_rea (sar_job_mfs_t *sar_job)
+{
+ static fcall_param_t return_param;
+ static sci_msg_t return_msg;
+ static unsigned char return_buffer[SCI_MSG_MAX_SIZE];
- if (debug_info)
- {
- diag_printf ("\t[BRIDGE - RX] sar_job @ %p\n", sar_job);
- diag_printf ("\t[BRIDGE - RX] job->data_addr : %p\n",
- sar_job->job.data_addr);
- diag_printf ("\t[BRIDGE - RX] job->first_pb_desc : %p\n",
- sar_job->job.first_pb_desc);
- diag_printf ("\t[BRIDGE - RX] job->first_pb_offset : %d\n",
- sar_job->job.first_pb_offset);
- diag_printf ("\t[BRIDGE - RX] job->pb_quantity : %d\n",
- sar_job->pb_quantity);
- diag_printf ("\t[BRIDGE - RX] job->data_addr : %p\n",
- sar_job->job.data_addr);
- diag_printf ("\t[BRIDGE - RX] job->data_len : %d\n",
- sar_job->job.data_len);
- diag_printf ("\t[BRIDGE - RX] MF len : %d\n", mf_get_length (
- (pb_t *)sar_job->job.first_pb_desc,
- sar_job->job.first_pb_offset, false));
- diag_printf ("\t[BRIDGE - RX] MF qte PB : %d\n",
- mf_get_quantity_of_pb (
- (pb_t *)sar_job->job.first_pb_desc,
- sar_job->job.first_pb_offset));
- diag_printf ("\t[BRIDGE - RX] job @ : %p\n", sar_job);
- }
+ uint i;
+ u16 mf_length;
+ u8 packet_nb;
+ bool error = false;
- for (i = 0; i < packets_len[packet_nb]&& !error; i++)
- {
- if (packets[packet_nb][i] != sar_job->job.data_addr[i])
- {
- error = true;
- }
- }
+ dbg_assert (sar_job->pb_quantity);
- if (packet_nb == PACKETS_QTE || error)
- {
- error = true;
+ mf_length = mf_get_length ((pb_t *)sar_job->job.first_pb_desc,
+ sar_job->job.first_pb_offset, true);
- diag_printf ("/***********************************************************/\n");
- diag_printf (" :( [Reassembly] FAIL :(\n");
- diag_printf ("/***********************************************************/\n");
- }
- else
+ if (debug_info)
+ {
+ uint deb;
+ diag_printf ("[DEBUG - RX] PB data header : ");
+ for (deb = 0; deb < 6; deb++)
{
- diag_printf ("/***********************************************************/\n");
- diag_printf (" ^^ [Reassembly] SUCCESS ^^\n");
- diag_printf ("/***********************************************************/\n");
+ diag_printf ("%02x ", ((pb_t *)sar_job->job.first_pb_desc)->data[deb]);
}
+ diag_printf ("\n");
+ }
+
+ for (packet_nb = 0; packet_nb < PACKETS_QTE && mf_length
+ != packets_len[packet_nb]; packet_nb++)
+ ;
+
+ if (debug_info)
+ {
+ diag_printf ("\t[BRIDGE - RX] sar_job @ %p\n", sar_job);
+ diag_printf ("\t[BRIDGE - RX] job->data_addr : %p\n",
+ sar_job->job.data_addr);
+ diag_printf ("\t[BRIDGE - RX] job->first_pb_desc : %p\n",
+ sar_job->job.first_pb_desc);
+ diag_printf ("\t[BRIDGE - RX] job->first_pb_offset : %d\n",
+ sar_job->job.first_pb_offset);
+ diag_printf ("\t[BRIDGE - RX] job->pb_quantity : %d\n",
+ sar_job->pb_quantity);
+ diag_printf ("\t[BRIDGE - RX] job->data_addr : %p\n",
+ sar_job->job.data_addr);
+ diag_printf ("\t[BRIDGE - RX] job->data_len : %d\n",
+ sar_job->job.data_len);
+ diag_printf ("\t[BRIDGE - RX] MF len : %d\n", mf_get_length (
+ (pb_t *)sar_job->job.first_pb_desc,
+ sar_job->job.first_pb_offset, false));
+ diag_printf ("\t[BRIDGE - RX] MF qte PB : %d\n",
+ mf_get_quantity_of_pb ((pb_t *)sar_job->job.first_pb_desc,
+ sar_job->job.first_pb_offset));
+ diag_printf ("\t[BRIDGE - RX] job @ : %p\n", sar_job);
+ }
- for (i = 0; i < sar_job->pb_quantity; i++)
+ for (i = 0; i < packets_len[packet_nb]&& !error; i++)
+ {
+ if (packets[packet_nb][i] != sar_job->job.data_addr[i])
{
- sar_job->job.first_pb_desc
- = (blk_t *) pb_free ((pb_t *) sar_job->job.first_pb_desc);
+ error = true;
}
+ }
- blk_release (sar_job->mfs);
- free (sar_job->job.data_addr);
- blk_release (sar_job);
+ if (packet_nb == PACKETS_QTE || error)
+ {
+ error = true;
- fcall_param_add (&return_param, &return_msg, "type", 4* sizeof(u8),
- (unsigned char *) "REA");
+ diag_printf ("/***********************************************************/\n");
+ diag_printf (" :( [Reassembly] FAIL :(\n");
+ diag_printf ("/***********************************************************/\n");
+ }
+ else
+ {
+ diag_printf ("/***********************************************************/\n");
+ diag_printf (" ^^ [Reassembly] SUCCESS ^^\n");
+ diag_printf ("/***********************************************************/\n");
}
- /* return */
- fcall_return (my_station.fcall, &return_param, &return_msg);
+ for (i = 0; i < sar_job->pb_quantity; i++)
+ {
+ sar_job->job.first_pb_desc
+ = (blk_t *) pb_free ((pb_t *) sar_job->job.first_pb_desc);
+ }
+
+ blk_release (sar_job->mfs);
+ free (sar_job->job.data_addr);
+ blk_release (sar_job);
+
+ rea_counter ++;
+
+ if (rea_counter == mf_qte)
+ {
+ /** init structures **/
+ fcall_param_init (&return_param, "rea_complete_done", msg_id);
+ sci_msg_init (&return_msg, return_buffer, SCI_MSG_MAX_SIZE);
+
+ /** reset the param list **/
+ fcall_param_reset (&return_param);
+
+ fcall_param_add (&return_param, &return_msg, "type", 4* sizeof(u8),
+ (unsigned char*) "REA");
+
+ fcall_return (my_station.fcall, &return_param, &return_msg);
+ }
return !error;
}