summaryrefslogtreecommitdiff
path: root/cesar/hle/src/hle.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hle/src/hle.c')
-rw-r--r--cesar/hle/src/hle.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/cesar/hle/src/hle.c b/cesar/hle/src/hle.c
index 71e2eb48a8..60080f0acd 100644
--- a/cesar/hle/src/hle.c
+++ b/cesar/hle/src/hle.c
@@ -20,6 +20,7 @@
#include "hle/inc/context.h"
#include "hle/inc/trace.h"
#include "mac/common/ntb.h"
+#include "lib/seq_check.h"
#include "common/module.h"
@@ -27,6 +28,48 @@
static hle_t hle_global;
/**
+ * Callback when the lib sequencer detect a wrong sequencing, input from
+ * Linux.
+ * \param user user data
+ * \param vlan the VLAN id
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the actual sequence number found in the packet
+ */
+void
+hle_lib_seq_check_cb_in (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+/**
+ * Callback when the lib sequencer detect a wrong sequencing, output to
+ * Linux.
+ * \param user user data
+ * \param vlan the VLAN id
+ * \param seq_expected the sequence number expected
+ * \param seq_actual the actual sequence number found in the packet
+ */
+void
+hle_lib_seq_check_cb_out (void *user, uint vlan, uint seq_expected,
+ uint seq_actual);
+
+void
+hle_lib_seq_check_cb_in (void *user, uint vlan, uint seq_expected,
+ uint seq_actual)
+{
+ dbg_assert (user);
+ trace_do (hle_t *ctx = (hle_t *) user);
+ HLE_TRACE (SEQ_CHECK_IN, vlan, seq_expected, seq_actual);
+}
+
+void
+hle_lib_seq_check_cb_out (void *user, uint vlan, uint seq_expected,
+ uint seq_actual)
+{
+ dbg_assert (user);
+ trace_do (hle_t *ctx = (hle_t *) user);
+ HLE_TRACE (SEQ_CHECK_OUT, vlan, seq_expected, seq_actual);
+}
+
+/**
* Send a data to the Convergence Layer to be sent over the PWL.
* \param hle the hle context.
* \param buffer the buffer containing the data to send.
@@ -40,6 +83,10 @@ hle_data_send (hle_t *ctx, u8 *buffer, uint length, uint tag,
{
dbg_assert (buffer);
dbg_assert (length <= ETH_PACKET_MAX_SIZE);
+
+ /* Check sequence. */
+ lib_seq_check_packet (&ctx->seq_in, buffer, length);
+
if (length < ETH_PACKET_MIN_SIZE_ALLOWED)
{
hle_send_done (ctx, buffer);
@@ -69,6 +116,9 @@ hle_data_recv (hle_t *ctx, u8 *buffer, uint length)
/* Tracing data. */
HLE_TRACE (DATA_RECV, phy_date (), length, buffer);
+ /* Check sequence. */
+ lib_seq_check_packet (&ctx->seq_out, buffer, length);
+
word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_DATA),
(MSG_LENGTH, 1), (PARAM_MSG_TYPE, 0),
(PARAM_MSG_LENGTH, length));
@@ -250,6 +300,9 @@ hle_init (cl_t *cl)
#endif
/* Tracing */
HLE_TRACE (INIT, phy_date ());
+ /* Sequence check initialization. */
+ lib_seq_check_init (&ctx->seq_in, hle_lib_seq_check_cb_in, &hle_global);
+ lib_seq_check_init (&ctx->seq_out, hle_lib_seq_check_cb_out, &hle_global);
return &hle_global;
}