Skip to content

Commit

Permalink
Made sure not to alter the first few event types for legacy systems, …
Browse files Browse the repository at this point in the history
…and instead new event types will go at the end of the enum
  • Loading branch information
TheMutta committed Jul 5, 2024
1 parent f017c1a commit 5e89479
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
18 changes: 10 additions & 8 deletions include/XLink/XLinkPrivateDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,44 @@ typedef enum
{
/*USB-X_LINK_PCIE related events*/
XLINK_WRITE_REQ,
XLINK_WRITE_FD_REQ, // only for the shared mem protocol
XLINK_READ_REQ,
XLINK_READ_REL_REQ,
XLINK_READ_REL_SPEC_REQ,
XLINK_CREATE_STREAM_REQ,
XLINK_CLOSE_STREAM_REQ,
XLINK_PING_REQ,
XLINK_RESET_REQ,

XLINK_REQUEST_LAST,
XLINK_STATIC_REQUEST_LAST,
//note that is important to separate request and response
XLINK_WRITE_RESP,
XLINK_WRITE_FD_RESP, // only for the shared mem protocol
XLINK_READ_RESP,
XLINK_READ_REL_RESP,
XLINK_READ_REL_SPEC_RESP,
XLINK_CREATE_STREAM_RESP,
XLINK_CLOSE_STREAM_RESP,
XLINK_PING_RESP,
XLINK_RESET_RESP,

XLINK_RESP_LAST,
XLINK_STATIC_RESP_LAST,

/*X_LINK_IPC related events*/
IPC_WRITE_REQ,
IPC_WRITE_FD_REQ,
IPC_READ_REQ,
IPC_CREATE_STREAM_REQ,
IPC_CLOSE_STREAM_REQ,

//
IPC_WRITE_RESP,
IPC_WRITE_FD_RESP,
IPC_READ_RESP,
IPC_CREATE_STREAM_RESP,
IPC_CLOSE_STREAM_RESP,

XLINK_READ_REL_SPEC_REQ,
XLINK_WRITE_FD_REQ, // only for the shared mem protocol
XLINK_REQUEST_LAST,

XLINK_READ_REL_SPEC_RESP,
XLINK_WRITE_FD_RESP, // only for the shared mem protocol
XLINK_RESP_LAST,
} xLinkEventType_t;

typedef enum
Expand Down
22 changes: 14 additions & 8 deletions src/shared/XLinkDispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,25 +502,28 @@ char* TypeToStr(int type)
switch(type)
{
case XLINK_WRITE_REQ: return "XLINK_WRITE_REQ";
case XLINK_WRITE_FD_REQ: return "XLINK_WRITE_FD_REQ";
case XLINK_READ_REQ: return "XLINK_READ_REQ";
case XLINK_READ_REL_REQ: return "XLINK_READ_REL_REQ";
case XLINK_READ_REL_SPEC_REQ: return "XLINK_READ_REL_SPEC_REQ";
case XLINK_CREATE_STREAM_REQ:return "XLINK_CREATE_STREAM_REQ";
case XLINK_CLOSE_STREAM_REQ: return "XLINK_CLOSE_STREAM_REQ";
case XLINK_PING_REQ: return "XLINK_PING_REQ";
case XLINK_RESET_REQ: return "XLINK_RESET_REQ";
case XLINK_REQUEST_LAST: return "XLINK_REQUEST_LAST";
case XLINK_WRITE_RESP: return "XLINK_WRITE_RESP";
case XLINK_WRITE_FD_RESP: return "XLINK_WRITE_FD_REQ";
case XLINK_STATIC_REQUEST_LAST: return "XLINK_STATIC_REQUEST_LAST";
case XLINK_READ_RESP: return "XLINK_READ_RESP";
case XLINK_WRITE_RESP: return "XLINK_WRITE_RESP";
case XLINK_READ_REL_RESP: return "XLINK_READ_REL_RESP";
case XLINK_READ_REL_SPEC_RESP: return "XLINK_READ_REL_SPEC_RESP";
case XLINK_CREATE_STREAM_RESP: return "XLINK_CREATE_STREAM_RESP";
case XLINK_CLOSE_STREAM_RESP: return "XLINK_CLOSE_STREAM_RESP";
case XLINK_PING_RESP: return "XLINK_PING_RESP";
case XLINK_RESET_RESP: return "XLINK_RESET_RESP";
case XLINK_STATIC_RESP_LAST: return "XLINK_STATIC_RESP_LAST";
case XLINK_READ_REL_SPEC_REQ: return "XLINK_READ_REL_SPEC_REQ";
case XLINK_WRITE_FD_REQ: return "XLINK_WRITE_FD_REQ";
case XLINK_REQUEST_LAST: return "XLINK_REQUEST_LAST";
case XLINK_READ_REL_SPEC_RESP: return "XLINK_READ_REL_SPEC_RESP";
case XLINK_WRITE_FD_RESP: return "XLINK_WRITE_FD_REQ";
case XLINK_RESP_LAST: return "XLINK_RESP_LAST";

default:
break;
}
Expand Down Expand Up @@ -798,7 +801,9 @@ static void* eventSchedulerRun(void* ctx)

static int isEventTypeRequest(xLinkEventPriv_t* event)
{
return event->packet.header.type < XLINK_REQUEST_LAST;
return (event->packet.header.type < XLINK_STATIC_REQUEST_LAST ||
(event->packet.header.type >= XLINK_READ_REL_SPEC_REQ &&
event->packet.header.type < XLINK_REQUEST_LAST));
}

static void postAndMarkEventServed(xLinkEventPriv_t *event)
Expand Down Expand Up @@ -899,7 +904,8 @@ static int dispatcherResponseServe(xLinkEventPriv_t * event, xLinkSchedulerState

if (curr->lQueue.q[i].isServed == EVENT_PENDING &&
header->id == evHeader->id &&
header->type == evHeader->type - XLINK_REQUEST_LAST -1)
((header->type == evHeader->type - XLINK_STATIC_REQUEST_LAST - 1) ||
(header->type == evHeader->type - XLINK_REQUEST_LAST - 1 + XLINK_READ_REL_SPEC_REQ)))
{
mvLog(MVLOG_DEBUG,"----------------------ISserved %s\n",
TypeToStr(header->type));
Expand Down
7 changes: 5 additions & 2 deletions src/shared/XLinkDispatcherImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,12 @@ int handleIncomingEvent(xLinkEvent_t* event, XLinkTimespec treceive) {
//specific actions to this peer
mvLog(MVLOG_DEBUG, "%s, size %u, streamId %u.\n", TypeToStr(event->header.type), event->header.size, event->header.streamId);

ASSERT_XLINK(event->header.type >= XLINK_WRITE_REQ
ASSERT_XLINK((event->header.type >= XLINK_WRITE_REQ
&& event->header.type != XLINK_STATIC_REQUEST_LAST
&& event->header.type < XLINK_STATIC_RESP_LAST) ||
(event->header.type >= XLINK_READ_REL_SPEC_REQ
&& event->header.type != XLINK_REQUEST_LAST
&& event->header.type < XLINK_RESP_LAST);
&& event->header.type < XLINK_RESP_LAST));

// Then read the data buffer, which is contained only in the XLINK_WRITE_REQ event
if(event->header.type != XLINK_WRITE_REQ && event->header.type != XLINK_WRITE_FD_REQ) {
Expand Down

0 comments on commit 5e89479

Please sign in to comment.