diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-01-03 11:57:59 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-01-03 12:12:49 +0100 |
commit | 5ab96126078cb9166356beaff3458404664274ed (patch) | |
tree | 4734c9872a5b9b4b4cb12e9fab82bdb255a6591a /src/lib | |
parent | 4ccd3e2c8af00963ac6d88aac587de016300ed90 (diff) | |
download | ouroboros-5ab96126078cb9166356beaff3458404664274ed.tar.gz ouroboros-5ab96126078cb9166356beaff3458404664274ed.zip |
lib, ipcpd, irmd: Proof of concept QoS
Now correctly relays the qoscube end-to-end in the stack.
A simple function specifying the cube in the spec is used for initial
testing.
The translation is now done in dev.c, but it could be moved elsewhere
when qos cabability matures and the need arises.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dev.c | 60 | ||||
-rw-r--r-- | src/lib/ipcpd_messages.proto | 2 | ||||
-rw-r--r-- | src/lib/irmd_messages.proto | 9 |
3 files changed, 48 insertions, 23 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index 3a1df16d..91fc3c0a 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -133,7 +133,7 @@ struct flow { struct shm_flow_set * set; int port_id; int oflags; - qoscube_t qos; + qoscube_t cube; pid_t api; @@ -158,6 +158,23 @@ struct { pthread_rwlock_t flows_lock; } ai; +/* FIXME: translate real spec to cube */ +static qoscube_t spec_to_cube(qosspec_t * spec) +{ + if (spec == NULL) + return QOS_CUBE_BE; + + return spec->cube; +} + +/* FIXME: fill real spec */ +static void fill_qosspec(qosspec_t * spec, qoscube_t cube) +{ + assert(spec); + + spec->cube = cube; +} + static int api_announce(char * ap_name) { irm_msg_t msg = IRM_MSG__INIT; @@ -214,7 +231,7 @@ static void reset_flow(int fd) ai.flows[fd].oflags = 0; ai.flows[fd].api = -1; ai.flows[fd].timesout = false; - ai.flows[fd].qos = QOS_CUBE_BE; + ai.flows[fd].cube = QOS_CUBE_BE; } int ap_init(char * ap_name) @@ -269,7 +286,7 @@ int ap_init(char * ap_name) ai.flows[i].oflags = 0; ai.flows[i].api = -1; ai.flows[i].timesout = false; - ai.flows[i].qos = QOS_CUBE_BE; + ai.flows[i].cube = QOS_CUBE_BE; } ai.ports = malloc(sizeof(*ai.ports) * IRMD_MAX_FLOWS); @@ -340,14 +357,12 @@ void ap_fini() pthread_rwlock_destroy(&ai.data_lock); } -int flow_accept(char ** ae_name, qosspec_t * qos) +int flow_accept(char ** ae_name, qosspec_t * spec) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int fd = -1; - (void) qos; - msg.code = IRM_MSG_CODE__IRM_FLOW_ACCEPT; msg.has_api = true; @@ -420,6 +435,10 @@ int flow_accept(char ** ae_name, qosspec_t * qos) ai.flows[fd].port_id = recv_msg->port_id; ai.flows[fd].oflags = FLOW_O_DEFAULT; ai.flows[fd].api = recv_msg->api; + ai.flows[fd].cube = recv_msg->qoscube; + + if (spec != NULL) + fill_qosspec(spec, ai.flows[fd].cube); ai.ports[recv_msg->port_id].fd = fd; ai.ports[recv_msg->port_id].state = PORT_ID_ASSIGNED; @@ -479,15 +498,12 @@ int flow_alloc_resp(int fd, int response) return ret; } -int flow_alloc(char * dst_name, char * src_ae_name, qosspec_t * qos) +int flow_alloc(char * dst_name, char * src_ae_name, qosspec_t * spec) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int fd = -1; - /* FIXME: add qos support */ - (void) qos; - if (dst_name == NULL) return -EINVAL; @@ -498,6 +514,8 @@ int flow_alloc(char * dst_name, char * src_ae_name, qosspec_t * qos) msg.dst_name = dst_name; msg.ae_name = src_ae_name; msg.has_api = true; + msg.has_qoscube = true; + msg.qoscube = spec_to_cube(spec); pthread_rwlock_rdlock(&ai.data_lock); @@ -553,6 +571,7 @@ int flow_alloc(char * dst_name, char * src_ae_name, qosspec_t * qos) ai.flows[fd].port_id = recv_msg->port_id; ai.flows[fd].oflags = FLOW_O_DEFAULT; ai.flows[fd].api = recv_msg->api; + ai.flows[fd].cube = recv_msg->qoscube; ai.ports[recv_msg->port_id].fd = fd; ai.ports[recv_msg->port_id].state = PORT_ID_ASSIGNED; @@ -779,7 +798,7 @@ int flow_get_qosspec(int fd, qosspec_t * spec) return -ENOTALLOC; } - /* FIXME: map cube to spec */ + fill_qosspec(spec, ai.flows[fd].cube); pthread_rwlock_unlock(&ai.flows_lock); pthread_rwlock_unlock(&ai.data_lock); @@ -1201,7 +1220,10 @@ int ipcp_create_r(pid_t api) return ret; } -int ipcp_flow_req_arr(pid_t api, char * dst_name, char * src_ae_name) +int ipcp_flow_req_arr(pid_t api, + char * dst_name, + char * src_ae_name, + qoscube_t cube) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; @@ -1211,11 +1233,13 @@ int ipcp_flow_req_arr(pid_t api, char * dst_name, char * src_ae_name) if (dst_name == NULL || src_ae_name == NULL) return -EINVAL; - msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR; - msg.has_api = true; - msg.api = api; - msg.dst_name = dst_name; - msg.ae_name = src_ae_name; + msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR; + msg.has_api = true; + msg.api = api; + msg.dst_name = dst_name; + msg.ae_name = src_ae_name; + msg.has_qoscube = true; + msg.qoscube = cube; pthread_rwlock_rdlock(&ai.data_lock); pthread_rwlock_wrlock(&ai.flows_lock); @@ -1432,7 +1456,7 @@ int ipcp_flow_get_qoscube(int fd, qoscube_t * cube) return -ENOTALLOC; } - *cube = ai.flows[fd].qos; + *cube = ai.flows[fd].cube; pthread_rwlock_unlock(&ai.flows_lock); pthread_rwlock_unlock(&ai.data_lock); diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto index b5dd5370..09e959fa 100644 --- a/src/lib/ipcpd_messages.proto +++ b/src/lib/ipcpd_messages.proto @@ -45,7 +45,7 @@ message ipcp_msg { optional sint32 port_id = 6; optional string dst_name = 7; optional string src_ae_name = 8; - optional sint32 qos_cube = 9; + optional sint32 qoscube = 9; optional dif_config_msg conf = 10; optional sint32 fd = 11; optional sint32 api = 12; diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto index fad6fbf1..74d08f9b 100644 --- a/src/lib/irmd_messages.proto +++ b/src/lib/irmd_messages.proto @@ -59,8 +59,9 @@ message irm_msg { optional sint32 response = 8; optional string dst_name = 9; optional sint32 port_id = 10; - optional dif_config_msg conf = 11; - optional uint32 opts = 12; - repeated sint32 apis = 13; - optional sint32 result = 14; + optional sint32 qoscube = 11; + optional dif_config_msg conf = 12; + optional uint32 opts = 13; + repeated sint32 apis = 14; + optional sint32 result = 15; }; |