forked from gatsby/datalink_repo
rewrite schedule pool.
This commit is contained in:
@@ -22,13 +22,12 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "linklayer814_types.h"
|
#include "linklayer814_types.h"
|
||||||
#include "node_list.h"
|
#include "node_list.h"
|
||||||
|
#include "schdevent.h"
|
||||||
#include "rtt.h"
|
#include "rtt.h"
|
||||||
#include "../bit_array/bit_array.h"
|
#include "../bit_array/bit_array.h"
|
||||||
#include "../phy_ctrl/phy_ctrl.h"
|
#include "../phy_ctrl/phy_ctrl.h"
|
||||||
#include "../time_ctrl/time_ctrl.h"
|
#include "../time_ctrl/time_ctrl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************** Constant Definitions *****************************/
|
/************************** Constant Definitions *****************************/
|
||||||
#define DATA_STORE_INTERVAL 100 // 250ms
|
#define DATA_STORE_INTERVAL 100 // 250ms
|
||||||
|
|
||||||
@@ -60,8 +59,7 @@ typedef struct {
|
|||||||
L2_CONFIG config;
|
L2_CONFIG config;
|
||||||
L2_NODE_INFO myInfo;
|
L2_NODE_INFO myInfo;
|
||||||
NODE_LIST* nodeList;
|
NODE_LIST* nodeList;
|
||||||
L2_SCHD_EVENT* l2SchdEventPool[L2_SCHD_EVENT_MAX];
|
L2_SCHD_POOL* schdEventPool;
|
||||||
uint32_t schdEventCnt;
|
|
||||||
uint32_t netStartTime;
|
uint32_t netStartTime;
|
||||||
bool isEnable; // if the node is connected to the network
|
bool isEnable; // if the node is connected to the network
|
||||||
bool dataAvail; // if there is a valid received frame data in rx buffer
|
bool dataAvail; // if there is a valid received frame data in rx buffer
|
||||||
@@ -109,17 +107,12 @@ int32_t Linklayer_EventHandler(L2_INST* instPtr, const L2_EVENT* l2Event);
|
|||||||
int32_t Linklayer_PktHandler(L2_INST* instPtr, L2_FRAME_TYPE frameType);
|
int32_t Linklayer_PktHandler(L2_INST* instPtr, L2_FRAME_TYPE frameType);
|
||||||
int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType);
|
int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType);
|
||||||
|
|
||||||
// Event
|
// Scheduling Event
|
||||||
bool L2_isEventScheduled(L2_SCHD_EVENT* schdEvent);
|
void L2_EventPoolHandler(L2_INST* instPtr);
|
||||||
int32_t L2_CancelEvent(L2_SCHD_EVENT* schdEvent);
|
|
||||||
int32_t L2_SchdEventAppendMsg(L2_SCHD_EVENT* schdEvent, void* msg);
|
|
||||||
L2_SCHD_EVENT* L2_CreatNewSchdEvent(L2_INST* instPtr, L2_EVENT_TYPE event);
|
|
||||||
int32_t L2_DeletSchdEvent(L2_INST* instPtr, int32_t eventId);
|
|
||||||
void L2_ClearSchdEvent(L2_INST* instPtr);
|
|
||||||
int32_t L2_ScheduleEventAt(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t frameNo, uint32_t slotNo);
|
int32_t L2_ScheduleEventAt(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t frameNo, uint32_t slotNo);
|
||||||
int32_t L2_ScheduleEventAfter(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t numSlots);
|
int32_t L2_ScheduleEventAfter(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t numSlots);
|
||||||
int32_t L2_RecheduleEventAt(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t frameNo, uint32_t slotNo);
|
int32_t L2_RescheduleEventAt(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t frameNo, uint32_t slotNo);
|
||||||
int32_t L2_RecheduleEventAfter(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t numSlots);
|
int32_t L2_RescheduleEventAfter(L2_INST* instPtr, L2_SCHD_EVENT* schdEvent, uint32_t numSlots);
|
||||||
|
|
||||||
// Framing
|
// Framing
|
||||||
void L2_FrameStateUpdate(L2_INST* instPtr);
|
void L2_FrameStateUpdate(L2_INST* instPtr);
|
||||||
|
|||||||
@@ -51,9 +51,6 @@
|
|||||||
#define NUM_SLOTS_5MS 1
|
#define NUM_SLOTS_5MS 1
|
||||||
#define NUM_SLOTS_SKIP 0
|
#define NUM_SLOTS_SKIP 0
|
||||||
|
|
||||||
// Common schedule event definition
|
|
||||||
#define L2_SCHD_EVENT_MAX 16
|
|
||||||
|
|
||||||
/**************************** Type Definitions *******************************/
|
/**************************** Type Definitions *******************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -109,6 +106,7 @@ typedef enum {
|
|||||||
L2_EV_MGMT_PROC_DONE = 2,
|
L2_EV_MGMT_PROC_DONE = 2,
|
||||||
L2_EV_NET_SETUP_DONE = 3,
|
L2_EV_NET_SETUP_DONE = 3,
|
||||||
L2_EV_TIME_SYNC = 4,
|
L2_EV_TIME_SYNC = 4,
|
||||||
|
L2_EV_RTT_RECV_UPDATE = 5,
|
||||||
L2_EV_LINK_SET_REQ = 6,
|
L2_EV_LINK_SET_REQ = 6,
|
||||||
L2_EV_LOST_CXN = 7,
|
L2_EV_LOST_CXN = 7,
|
||||||
L2_EV_LOST_NODE = 8,
|
L2_EV_LOST_NODE = 8,
|
||||||
@@ -127,17 +125,6 @@ typedef struct {
|
|||||||
void* msg;
|
void* msg;
|
||||||
} L2_EVENT;
|
} L2_EVENT;
|
||||||
|
|
||||||
/** @name L2 event
|
|
||||||
* A definition of L2 event instance.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
uint8_t eventId;
|
|
||||||
bool isSchd;
|
|
||||||
L2_EVENT l2Event;
|
|
||||||
uint32_t schdFrame;
|
|
||||||
uint32_t schdSlot;
|
|
||||||
} L2_SCHD_EVENT;
|
|
||||||
|
|
||||||
/** @name Slot types
|
/** @name Slot types
|
||||||
* A definition of different slots.
|
* A definition of different slots.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/**
|
||||||
|
* Description: Event scheduling implementation
|
||||||
|
*
|
||||||
|
* Date: 2023-12-21 13:32
|
||||||
|
* LastEditors: Fan Hao
|
||||||
|
* LastEditTime: 2023-12-21 13:32
|
||||||
|
* Revisions: Rev 0.0
|
||||||
|
* History:
|
||||||
|
* [2023-12-21]: Initial version.
|
||||||
|
*
|
||||||
|
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||||
|
* Lab of Communication and Networking
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef SCHDEVENT_H_
|
||||||
|
#define SCHDEVENT_H_
|
||||||
|
|
||||||
|
#define SCHDEVENT_ID_NONE UINT32_MAX
|
||||||
|
/***************************** Include Files *********************************/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "linklayer814_types.h"
|
||||||
|
#include "../error.h"
|
||||||
|
#include "../util/list.h"
|
||||||
|
/***************** Macros (Inline Functions) Definitions *********************/
|
||||||
|
/**************************** Type Definitions *******************************/
|
||||||
|
/** @name L2 event
|
||||||
|
* A definition of L2 event instance.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
bool isSchd;
|
||||||
|
bool isVolatile;
|
||||||
|
L2_EVENT l2Event;
|
||||||
|
uint32_t eventId;
|
||||||
|
uint32_t ocurrCnt;
|
||||||
|
uint32_t schdFrame;
|
||||||
|
uint32_t schdSlot;
|
||||||
|
} L2_SCHD_EVENT;
|
||||||
|
|
||||||
|
/** @name L2 event
|
||||||
|
* A definition of L2 event instance.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
list_t* schdList;
|
||||||
|
uint32_t envCnt;
|
||||||
|
} L2_SCHD_POOL;
|
||||||
|
|
||||||
|
/************************** Variable Definitions *****************************/
|
||||||
|
/************************** Function Prototypes ******************************/
|
||||||
|
// Scheduling Event
|
||||||
|
int32_t L2_CreateSchedEventPool(L2_SCHD_POOL** schdPool);
|
||||||
|
void L2_ClearSchedEventPool(L2_SCHD_POOL* schdPool);
|
||||||
|
void L2_DestroySchedEventPool(L2_SCHD_POOL* schdPool);
|
||||||
|
|
||||||
|
L2_SCHD_EVENT* L2_CreatNewSchdEvent(L2_SCHD_POOL* schdPool, L2_EVENT_TYPE event, bool isVolatile);
|
||||||
|
L2_SCHD_EVENT* L2_GetEventById(L2_SCHD_POOL* schdPool, uint32_t id);
|
||||||
|
int32_t L2_DeleteSchdEventById(L2_SCHD_POOL* schdPool, uint32_t id);
|
||||||
|
|
||||||
|
void L2_SchdEventAppendMsg(L2_SCHD_EVENT* schdEvent, void* msg);
|
||||||
|
bool L2_isEventScheduled(const L2_SCHD_EVENT* schdEvent);
|
||||||
|
int32_t L2_CancelEvent(L2_SCHD_EVENT* schdEvent);
|
||||||
|
|
||||||
|
#endif //SCHDEVENT_H_
|
||||||
Reference in New Issue
Block a user