From 5e894799742c08db6e63866e0a01d10216bf23f2 Mon Sep 17 00:00:00 2001 From: Filippo Mutta Date: Fri, 5 Jul 2024 11:03:10 +0200 Subject: [PATCH] Made sure not to alter the first few event types for legacy systems, and instead new event types will go at the end of the enum --- include/XLink/XLinkPrivateDefines.h | 18 ++++++++++-------- src/shared/XLinkDispatcher.c | 22 ++++++++++++++-------- src/shared/XLinkDispatcherImpl.c | 7 +++++-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/include/XLink/XLinkPrivateDefines.h b/include/XLink/XLinkPrivateDefines.h index aa42c15..9b9e92f 100644 --- a/include/XLink/XLinkPrivateDefines.h +++ b/include/XLink/XLinkPrivateDefines.h @@ -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 diff --git a/src/shared/XLinkDispatcher.c b/src/shared/XLinkDispatcher.c index 4ca84ee..01aec98 100644 --- a/src/shared/XLinkDispatcher.c +++ b/src/shared/XLinkDispatcher.c @@ -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; } @@ -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) @@ -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)); diff --git a/src/shared/XLinkDispatcherImpl.c b/src/shared/XLinkDispatcherImpl.c index 9a96d27..3696942 100644 --- a/src/shared/XLinkDispatcherImpl.c +++ b/src/shared/XLinkDispatcherImpl.c @@ -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) {