From 5ab96126078cb9166356beaff3458404664274ed Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 3 Jan 2017 11:57:59 +0100 Subject: 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. --- src/ipcpd/ipcp.c | 2 +- src/ipcpd/local/main.c | 7 ++--- src/ipcpd/normal/flow_alloc.proto | 2 +- src/ipcpd/normal/fmgr.c | 11 ++++---- src/ipcpd/shim-eth-llc/main.c | 24 ++++++++++------ src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto | 3 +- src/ipcpd/shim-udp/main.c | 32 ++++++++++++++-------- src/ipcpd/shim-udp/shim_udp_messages.proto | 17 ++++++------ 8 files changed, 57 insertions(+), 41 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 8c0bd0bf..a2dc9e8f 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -198,7 +198,7 @@ static void * ipcp_main_loop(void * o) ipcpi.ops->ipcp_flow_alloc(fd, msg->dst_name, msg->src_ae_name, - msg->qos_cube); + msg->qoscube); break; case IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP: if (ipcpi.ops->ipcp_flow_alloc_resp == NULL) { diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index dc4e84ca..de8c72c2 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -219,13 +219,10 @@ static int ipcp_local_name_query(char * name) static int ipcp_local_flow_alloc(int fd, char * dst_name, char * src_ae_name, - qoscube_t qos) + qoscube_t cube) { int out_fd = -1; - /* This ipcpd has all QoS */ - (void) qos; - LOG_DBG("Allocating flow to %s on fd %d.", dst_name, fd); assert(dst_name); @@ -241,7 +238,7 @@ static int ipcp_local_flow_alloc(int fd, pthread_rwlock_wrlock(&local_data.lock); - out_fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name); + out_fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name, cube); local_data.in_out[fd] = out_fd; local_data.in_out[out_fd] = fd; diff --git a/src/ipcpd/normal/flow_alloc.proto b/src/ipcpd/normal/flow_alloc.proto index 5041d31a..02be47a0 100644 --- a/src/ipcpd/normal/flow_alloc.proto +++ b/src/ipcpd/normal/flow_alloc.proto @@ -32,6 +32,6 @@ message flow_alloc_msg { required flow_alloc_code code = 1; optional string dst_name = 2; optional string src_ae_name = 3; - optional uint32 qos_cube = 4; + optional uint32 qoscube = 4; optional sint32 response = 5; }; diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index d8190572..4b24d5a1 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -351,7 +351,7 @@ int fmgr_fini() int fmgr_np1_alloc(int fd, char * dst_ap_name, char * src_ae_name, - qoscube_t qos) + qoscube_t cube) { cep_id_t cep_id; buffer_t buf; @@ -391,8 +391,8 @@ int fmgr_np1_alloc(int fd, msg.code = FLOW_ALLOC_CODE__FLOW_REQ; msg.dst_name = dst_ap_name; msg.src_ae_name = src_ae_name; - msg.qos_cube = qos; - msg.has_qos_cube = true; + msg.has_qoscube = true; + msg.qoscube = cube; buf.len = flow_alloc_msg__get_packed_size(&msg); if (buf.len == 0) { @@ -410,7 +410,7 @@ int fmgr_np1_alloc(int fd, pthread_rwlock_wrlock(&fmgr.np1_flows_lock); - cep_id = frct_i_create(addr, &buf, qos); + cep_id = frct_i_create(addr, &buf, cube); if (cep_id == INVALID_CEP_ID) { free(ro_data); free(buf.data); @@ -535,7 +535,8 @@ int fmgr_np1_post_buf(cep_id_t cep_id, buffer_t * buf) case FLOW_ALLOC_CODE__FLOW_REQ: fd = ipcp_flow_req_arr(getpid(), msg->dst_name, - msg->src_ae_name); + msg->src_ae_name, + msg->qoscube); if (fd < 0) { flow_alloc_msg__free_unpacked(msg, NULL); LOG_ERR("Failed to get fd for flow."); diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index da0bf97e..ab25ffb1 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -315,7 +315,8 @@ static int eth_llc_ipcp_send_mgmt_frame(shim_eth_llc_msg_t * msg, static int eth_llc_ipcp_sap_alloc(uint8_t * dst_addr, uint8_t ssap, char * dst_name, - char * src_ae_name) + char * src_ae_name, + qoscube_t cube) { shim_eth_llc_msg_t msg = SHIM_ETH_LLC_MSG__INIT; @@ -324,6 +325,8 @@ static int eth_llc_ipcp_sap_alloc(uint8_t * dst_addr, msg.ssap = ssap; msg.dst_name = dst_name; msg.src_ae_name = src_ae_name; + msg.has_qoscube = true; + msg.qoscube = cube; return eth_llc_ipcp_send_mgmt_frame(&msg, dst_addr); } @@ -349,7 +352,8 @@ static int eth_llc_ipcp_sap_alloc_resp(uint8_t * dst_addr, static int eth_llc_ipcp_sap_req(uint8_t r_sap, uint8_t * r_addr, char * dst_name, - char * src_ae_name) + char * src_ae_name, + qoscube_t cube) { int fd; @@ -357,7 +361,7 @@ static int eth_llc_ipcp_sap_req(uint8_t r_sap, pthread_rwlock_wrlock(ð_llc_data.flows_lock); /* reply to IRM */ - fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name); + fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name, cube); if (fd < 0) { pthread_rwlock_unlock(ð_llc_data.flows_lock); pthread_rwlock_unlock(&ipcpi.state_lock); @@ -464,7 +468,8 @@ static int eth_llc_ipcp_mgmt_frame(uint8_t * buf, size_t len, uint8_t * r_addr) eth_llc_ipcp_sap_req(msg->ssap, r_addr, msg->dst_name, - msg->src_ae_name); + msg->src_ae_name, + msg->qoscube); } break; case SHIM_ETH_LLC_MSG_CODE__FLOW_REPLY: @@ -934,7 +939,7 @@ static int eth_llc_ipcp_name_query(char * name) static int eth_llc_ipcp_flow_alloc(int fd, char * dst_name, char * src_ae_name, - qoscube_t qos) + qoscube_t cube) { uint8_t ssap = 0; uint8_t r_addr[MAC_SIZE]; @@ -945,8 +950,10 @@ static int eth_llc_ipcp_flow_alloc(int fd, if (dst_name == NULL || src_ae_name == NULL) return -1; - if (qos != QOS_CUBE_BE) - LOG_DBG("QoS requested. Ethernet LLC can't do that. For now."); + if (cube != QOS_CUBE_BE && cube != QOS_CUBE_FRC) { + LOG_DBG("Unsupported QoS requested."); + return -1; + } pthread_rwlock_rdlock(&ipcpi.state_lock); @@ -983,7 +990,8 @@ static int eth_llc_ipcp_flow_alloc(int fd, if (eth_llc_ipcp_sap_alloc(r_addr, ssap, dst_name, - src_ae_name) < 0) { + src_ae_name, + cube) < 0) { pthread_rwlock_rdlock(&ipcpi.state_lock); pthread_rwlock_wrlock(ð_llc_data.flows_lock); bmp_release(eth_llc_data.saps, eth_llc_data.fd_to_ef[fd].sap); diff --git a/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto b/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto index 9eebf610..63ab4519 100644 --- a/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto +++ b/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto @@ -35,5 +35,6 @@ message shim_eth_llc_msg { optional string src_ae_name = 3; optional uint32 ssap = 4; optional uint32 dsap = 5; - optional sint32 response = 6; + optional uint32 qoscube = 6; + optional sint32 response = 7; }; diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index cdd02c49..12f586f0 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -196,10 +196,11 @@ static int send_shim_udp_msg(shim_udp_msg_t * msg, uint32_t dst_ip_addr) return 0; } -static int ipcp_udp_port_alloc(uint32_t dst_ip_addr, - uint16_t src_udp_port, - char * dst_name, - char * src_ae_name) +static int ipcp_udp_port_alloc(uint32_t dst_ip_addr, + uint16_t src_udp_port, + char * dst_name, + char * src_ae_name, + qoscube_t cube) { shim_udp_msg_t msg = SHIM_UDP_MSG__INIT; @@ -207,6 +208,8 @@ static int ipcp_udp_port_alloc(uint32_t dst_ip_addr, msg.src_udp_port = src_udp_port; msg.dst_name = dst_name; msg.src_ae_name = src_ae_name; + msg.has_qoscube = true; + msg.qoscube = cube; return send_shim_udp_msg(&msg, dst_ip_addr); } @@ -229,8 +232,9 @@ static int ipcp_udp_port_alloc_resp(uint32_t dst_ip_addr, } static int ipcp_udp_port_req(struct sockaddr_in * c_saddr, - char * dst_name, - char * src_ae_name) + char * dst_name, + char * src_ae_name, + qoscube_t cube) { int skfd; int fd; @@ -273,7 +277,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr, pthread_rwlock_wrlock(&udp_data.flows_lock); /* reply to IRM */ - fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name); + fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name, cube); if (fd < 0) { pthread_rwlock_unlock(&udp_data.flows_lock); pthread_rwlock_unlock(&ipcpi.state_lock); @@ -395,7 +399,8 @@ static void * ipcp_udp_listener(void * o) c_saddr.sin_port = msg->src_udp_port; ipcp_udp_port_req(&c_saddr, msg->dst_name, - msg->src_ae_name); + msg->src_ae_name, + msg->qoscube); break; case SHIM_UDP_MSG_CODE__FLOW_REPLY: ipcp_udp_port_alloc_reply(msg->src_udp_port, @@ -947,7 +952,7 @@ static int ipcp_udp_name_query(char * name) static int ipcp_udp_flow_alloc(int fd, char * dst_name, char * src_ae_name, - qoscube_t qos) + qoscube_t cube) { struct sockaddr_in r_saddr; /* server address */ struct sockaddr_in f_saddr; /* flow */ @@ -966,8 +971,10 @@ static int ipcp_udp_flow_alloc(int fd, return -1; } - if (qos != QOS_CUBE_BE) - LOG_DBG("QoS requested. UDP/IP can't do that."); + if (cube != QOS_CUBE_BE && cube != QOS_CUBE_FRC) { + LOG_DBG("Unsupported QoS requested."); + return -1; + } skfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); @@ -1030,7 +1037,8 @@ static int ipcp_udp_flow_alloc(int fd, if (ipcp_udp_port_alloc(ip_addr, f_saddr.sin_port, dst_name, - src_ae_name) < 0) { + src_ae_name, + cube) < 0) { pthread_rwlock_rdlock(&ipcpi.state_lock); pthread_rwlock_wrlock(&udp_data.flows_lock); diff --git a/src/ipcpd/shim-udp/shim_udp_messages.proto b/src/ipcpd/shim-udp/shim_udp_messages.proto index f5a23b82..cc535a60 100644 --- a/src/ipcpd/shim-udp/shim_udp_messages.proto +++ b/src/ipcpd/shim-udp/shim_udp_messages.proto @@ -23,15 +23,16 @@ syntax = "proto2"; enum shim_udp_msg_code { - FLOW_REQ = 1; - FLOW_REPLY = 2; + FLOW_REQ = 1; + FLOW_REPLY = 2; }; message shim_udp_msg { - required shim_udp_msg_code code = 1; - optional string dst_name = 2; - optional string src_ae_name = 4; - required uint32 src_udp_port = 5; - optional uint32 dst_udp_port = 6; - optional sint32 response = 7; + required shim_udp_msg_code code = 1; + optional string dst_name = 2; + optional string src_ae_name = 4; + required uint32 src_udp_port = 5; + optional uint32 dst_udp_port = 6; + optional uint32 qoscube = 7; + optional sint32 response = 8; }; -- cgit v1.2.3