network,port manager: turning messages into rpcs
authorAdam Turowski <adam.turowski@inf.ethz.ch>
Thu, 2 Mar 2017 12:38:58 +0000 (13:38 +0100)
committerAdam Turowski <adam.turowski@inf.ethz.ch>
Fri, 3 Mar 2017 10:03:34 +0000 (11:03 +0100)
Signed-off-by: Adam Turowski <adam.turowski@inf.ethz.ch>

if/e10k.if
if/sfn5122f.if
lib/net_device_manager/Hakefile
lib/net_device_manager/e10k_filt_cl_impl.c
lib/net_device_manager/port_management_support.h
lib/net_device_manager/port_service_impl.c
lib/net_device_manager/sfn5122f_filt_cl_impl.c
lib/net_device_manager/soft_filt_cl_impl.c
usr/drivers/e10k/e10k_cdriver.c
usr/drivers/e10k/e10k_qdriver.c
usr/drivers/solarflare/sfn5122f_cdriver.c

index 0be8352..bec521b 100644 (file)
@@ -46,25 +46,19 @@ interface e10k "e10k queue management interface" {
     message write_queue_tails();
 
     /* Called by queue manager if it is done, and is going to terminate. */
-    message terminate_queue(qid id);
-    message queue_terminated();
+    rpc terminate_queue(in qid id);
 
     /*****************************************************
      * Filter management (used by device  manager library)
      *****************************************************/
 
-    message register_port_filter(uint64    buf_id_rx,
-                              uint64    buf_id_tx,
-                              qid       queue,
-                              port_type type,
-                              uint16    port);
-    message filter_registered(uint64    buf_id_rx,
-                               uint64    buf_id_tx,
-                               errval err,
-                               uint64 filter);
+    rpc register_port_filter(in uint64    buf_id_rx,
+                              in uint64    buf_id_tx,
+                              in qid       queue,
+                              in port_type type,
+                              in uint16    port,
+                              out errval rerr,
+                              out uint64 filter);
 
-    message unregister_filter(uint64 filter);
-    message filter_unregistered(uint64 filter, errval err);
-
-                            
+    rpc unregister_filter(in uint64 filter, out errval rerr);
 };
index 15c1944..0c9f042 100644 (file)
@@ -26,7 +26,7 @@ interface sfn5122f "sfn5122f queue management interface" {
                                cap    rx,
                                cap    ev,
                                uint32 rxbufsz,
-                               bool   use_irq, 
+                               bool   use_irq,
                                bool   userspace,
                                uint8 vector,
                                uint16 core);
@@ -39,23 +39,19 @@ interface sfn5122f "sfn5122f queue management interface" {
     message write_queue_tails();
 
     /* Called by queue manager if it is done, and is going to terminate. */
-    message terminate_queue(qid id);
-    message queue_terminated();
+    rpc terminate_queue(in qid id);
 
     /*****************************************************
      * Filter management (used by device  manager library)
      *****************************************************/
 
-    message register_port_filter(uint64    buf_id_rx,
-                              uint64    buf_id_tx,
-                              qid       queue,
-                              port_type type,
-                              uint16    port);
-    message filter_registered(uint64    buf_id_rx,
-                              uint64    buf_id_tx,
-                              errval err,
-                              uint64 filter);
-
-    message unregister_filter(uint64 filter);
-    message filter_unregistered(uint64 filter, errval err);
+    rpc register_port_filter(in uint64    buf_id_rx,
+                              in uint64    buf_id_tx,
+                              in qid       queue,
+                              in port_type type,
+                              in uint16    port,
+                              out errval rerr,
+                              out uint64 filter);
+
+    rpc unregister_filter(in uint64 filter, out errval rerr);
 };
index 959e786..48e5d3b 100644 (file)
@@ -17,7 +17,7 @@
                   flounderBindings = [ "net_soft_filters", "net_ports",
                                        "e10k", "sfn5122f" ],
                   flounderExtraBindings = [ ("net_soft_filters", ["rpcclient"])],
-                  addLibraries = [ "bfdmuxtools", "trace", "contmng"
+                  addLibraries = [ "bfdmuxtools", "trace"
 -- try to get rid of "lwip" as it is only used for hton[s/l]
                     , "lwip"
                   ]
index 9a03ddc..7221502 100644 (file)
@@ -13,7 +13,6 @@
 #include <barrelfish/barrelfish.h>
 #include <barrelfish/waitset.h>
 #include <barrelfish/nameservice_client.h>
-#include <contmng/contmng.h>
 #include <ipv4/lwip/inet.h>
 
 #include <if/e10k_defs.h>
 /** Connection to e10k management service */
 struct e10k_binding *binding = NULL;
 
-struct cont_queue *c_queue = NULL;
-
-
 /******************************************************************************
  * Operations for filter interface
  ******************************************************************************/
 
-// Callback from e10k
-static void idc_filter_registered(struct e10k_binding *b,
-                                  uint64_t buf_id_rx,
-                                  uint64_t buf_id_tx,
-                                  errval_t err,
-                                  uint64_t filter)
-{
-    NDM_DEBUG("e10k_idc_filter_registered(f=%"PRIu64" rx=%"PRIu64" tx=%"PRIu64
-            ")\n", filter, buf_id_rx, buf_id_tx);
-    handle_filter_response(filter, err, filter, buf_id_rx, buf_id_tx, 1);
-}
-
-// Callback from e10k
-static void idc_filter_unregistered(struct e10k_binding *b,
-                                    uint64_t filter,
-                                    errval_t err)
-{
-    NDM_DEBUG("e10k_idc_filter_unregistered(%"PRIu64")\n", filter);
-}
-
-static errval_t send_register_port_filter(struct q_entry e)
-{
-    if (binding->can_send(binding)) {
-        return binding->tx_vtbl.register_port_filter(
-                binding, MKCONT(cont_queue_callback, c_queue),
-                e.plist[0], e.plist[1], e.plist[2], e.plist[3], e.plist[4]);
-    } else {
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-}
-
-/** Register filter with e10k card driver */
-static void idc_register_port_filter(uint64_t buf_id_rx,
-                                     uint64_t buf_id_tx,
-                                     uint8_t queue,
-                                     e10k_port_type_t type,
-                                     uint16_t port)
-{
-    struct q_entry entry;
-    NDM_DEBUG("e10k_idc_register_port_filter(q=%d p=%d rx=%"PRIu64" tx=%"
-            PRIu64")\n", queue, port, buf_id_rx, buf_id_tx);
-
-    memset(&entry, 0, sizeof(struct q_entry));
-
-    entry.handler = send_register_port_filter;
-    entry.binding_ptr = binding;
-    entry.plist[0] = buf_id_rx;
-    entry.plist[1] = buf_id_tx;
-    entry.plist[2] = queue;
-    entry.plist[3] = type;
-    entry.plist[4] = port;
-
-    enqueue_cont_q(c_queue, &entry);
-}
-
-static errval_t send_unregister_filter(struct q_entry e)
-{
-    if (binding->can_send(binding)) {
-        return binding->tx_vtbl.unregister_filter(
-                binding, MKCONT(cont_queue_callback, c_queue),
-                e.plist[0]);
-    } else {
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-}
-
-/** Unregister filter with e10k card driver */
-static void idc_unregister_filter(uint64_t filter)
-{
-    struct q_entry entry;
-    memset(&entry, 0, sizeof(struct q_entry));
-
-    entry.handler = send_unregister_filter;
-    entry.binding_ptr = binding;
-    entry.plist[0] = filter;
-
-    enqueue_cont_q(c_queue, &entry);
-}
-
-static struct e10k_rx_vtbl rx_vtbl = {
-    .filter_registered = idc_filter_registered,
-    .filter_unregistered = idc_filter_unregistered,
-};
-
 // Callback for bind
 static void bind_cb(void *st, errval_t err, struct e10k_binding *b)
 {
@@ -128,10 +40,8 @@ static void bind_cb(void *st, errval_t err, struct e10k_binding *b)
 
     NDM_DEBUG("Sucessfully connected to management interface\n");
 
-    b->rx_vtbl = rx_vtbl;
-
     binding = b;
-    c_queue = create_cont_q("e10k_filters");
+    e10k_rpc_client_init(binding);
 }
 
 /** Open connection to management interface */
@@ -187,7 +97,8 @@ static errval_t reg_filters(uint16_t port,
                             bufid_t buffer_id_rx,
                             bufid_t buffer_id_tx,
                             appid_t appid,
-                            qid_t qid)
+                            qid_t qid,
+                            uint64_t *id, errval_t *rerr, uint64_t *filter_id)
 {
     e10k_port_type_t t;
     assert(binding != NULL);
@@ -199,18 +110,22 @@ static errval_t reg_filters(uint16_t port,
     } else {
         t = e10k_PORT_UDP;
     }
+    errval_t err;
+    err = binding->rpc_tx_vtbl.register_port_filter(binding, buffer_id_rx, buffer_id_tx, qid, t, port, rerr, filter_id);
 
-    idc_register_port_filter(buffer_id_rx, buffer_id_tx, qid, t, port);
-
-    return SYS_ERR_OK;
+    return err;
 }
 
-static void unreg_filters(uint64_t filter_id, qid_t qid)
+static errval_t unreg_filters(uint64_t filter_id, qid_t qid)
 {
     assert(binding != NULL);
 
     NDM_DEBUG("e10k_unreg_filters()\n");
-    idc_unregister_filter(filter_id);
+    errval_t err, rerr;
+    err = binding->rpc_tx_vtbl.unregister_filter(binding, qid, &rerr);
+    assert(err_is_ok(err));
+    
+    return rerr;
 }
 
 
@@ -230,5 +145,3 @@ struct filters_tx_vtbl *get_e10k_filt_mng_sign(void)
 {
     return &e10k_filts_mng;
 }
-
-
index 8b6e632..fd59eda 100755 (executable)
@@ -29,8 +29,9 @@ typedef errval_t (*register_filter_t)(uint16_t port,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t qid);
-typedef void (*deregister_filter_t)(uint64_t filter_id, qid_t qid);
+                    qid_t qid,
+                    uint64_t *id, errval_t *rerr, uint64_t *filter_id);
+typedef errval_t (*deregister_filter_t)(uint64_t filter_id, qid_t qid);
 
 
 // Struct to capture the signature of different filter managers
@@ -60,8 +61,8 @@ int init_ports_service(char *dev_name);
 
 // based on the response received from queue_manager,
 // report the success/failure of the call to an application
-void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
-        uint64_t buffer_id_rx, uint64_t buffer_id_tx, uint64_t ftype);
+//void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
+//        uint64_t buffer_id_rx, uint64_t buffer_id_tx, uint64_t ftype);
 
 
 // *****************************************************************
@@ -144,4 +145,3 @@ struct net_user *registerd_app_list;
 
 
 #endif // PORT_MNG_SUPPORT_H_
-
index b1cf604..12fcaaa 100644 (file)
@@ -14,9 +14,6 @@
 #include <if/net_soft_filters_defs.h>
 #include <if/net_ports_defs.h>
 
-// for handling contiuations
-#include <contmng/contmng.h>
-
 // standard libraries
 #include <stdio.h>
 #include <string.h>
@@ -45,20 +42,12 @@ static bool port_service_exported = false;
 struct net_user *registerd_app_list = NULL;
 
 /*****************************************************************
-// House-keeping prototypes
-*****************************************************************/
-
-static void wrapper_get_port_response(struct net_ports_binding *cc,
-                errval_t err, uint16_t port_no);
-static void wrapper_bind_port_response(struct net_ports_binding *cc,
-        errval_t err);
-static void wrapper_close_port_response(struct net_ports_binding *cc,
-            errval_t err);
-
-/*****************************************************************
 * Prototypes
 *****************************************************************/
 
+static void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
+        uint64_t buffer_id_rx, uint64_t buffer_id_tx, uint64_t ftype);
+
 static struct buffer_port_translation *find_filter_id(
             struct buffer_port_translation *port_list,
             uint16_t port_no, uint64_t type);
@@ -75,12 +64,14 @@ static struct buffer_port_translation *find_filter_id(
 //   *. Insert appropriate filter
 //   *. Once you get ack for filter being inserted successfully,
 //          send back the response (done by another funcation)
-static void get_port(struct net_ports_binding *cc,
+static errval_t get_port(struct net_ports_binding *cc,
                     port_type_t type,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t queueid);
+                    qid_t queueid,
+                    errval_t *err,
+                    uint16_t *port);
 
 // Allocates the specified port number to the application
 // To be used on server side who wants to listen on perticular port number
@@ -92,13 +83,14 @@ static void get_port(struct net_ports_binding *cc,
 //   *. Insert appropriate filter
 //   *. Once you get ack for filter being inserted successfully,
 //          send back the response (done by another funcation)
-static void bind_port(struct net_ports_binding *cc,
+static errval_t bind_port(struct net_ports_binding *cc,
                     port_type_t type,
                     uint16_t port_no,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t queueid);
+                    qid_t queueid,
+                    errval_t *err);
 
 
 // Close the specified port number
@@ -108,18 +100,19 @@ static void bind_port(struct net_ports_binding *cc,
 //   *. Send request to remove the filter
 //   *. Once you get ack for filter being removed successfully,
 //          send back the response (done by another funcation)
-static void close_port(struct net_ports_binding *cc,
+static errval_t close_port(struct net_ports_binding *cc,
                     port_type_t type,
                     uint16_t port_no,
                     uint64_t appid,
-                    uint64_t queueid);
+                    uint64_t queueid,
+                    errval_t *err);
 
 
 // Get the mac address for given machine
-static void get_mac_address(struct net_ports_binding *cc);
+static errval_t get_mac_address(struct net_ports_binding *cc, uint64_t *hwaddr);
 
 // service mappings
-static struct net_ports_rx_vtbl rx_net_ports_vtbl = {
+static struct net_ports_rpc_rx_vtbl rx_net_ports_vtbl = {
 //    .get_ip_info_call = get_ip_info,
     .get_mac_address_call = get_mac_address,
     .get_port_call = get_port,
@@ -150,8 +143,7 @@ static errval_t connect_ports_cb(void *st, struct net_ports_binding *b)
     registerd_app_list = new_net_app;
     b->st = (void *) new_net_app;
 
-    new_net_app->q = create_cont_q("NDM2APP");
-    b->rx_vtbl = rx_net_ports_vtbl;
+    b->rpc_rx_vtbl = rx_net_ports_vtbl;
     return err;
 } // end function: connect_ports_cb
 
@@ -279,10 +271,14 @@ static errval_t res_port(struct net_ports_binding *cc,
     // add this flow to the list of all flows for this app
     bp->next = this_net_app->open_ports;
     this_net_app->open_ports = bp;
-
+    
+    uint64_t id;
+    errval_t rerr;
+    uint64_t filter_id;
+    
     // FIXME: qlist[queueid].insert_rule();
     err = qlist[queueid].filt_mng->reg_filters(port, type, buffer_id_rx,
-            buffer_id_tx, appid, queueid);
+            buffer_id_tx, appid, queueid, &id, &rerr, &filter_id);
     if (err_is_fail(err)) {
         // close the port which was allocated
         free_port(port, type);
@@ -291,6 +287,8 @@ static errval_t res_port(struct net_ports_binding *cc,
         return err;
     } // end if: err
 
+    handle_filter_response(id, rerr, filter_id, buffer_id_rx, buffer_id_tx, type);
+            
     NDM_DEBUG("res_port: waiting for response\n");
     return err;
 } // end function: res_port
@@ -307,42 +305,43 @@ static errval_t res_port(struct net_ports_binding *cc,
 //   *. Insert appropriate filter
 //   *. Once you get ack for filter being inserted successfully,
 //          send back the response (done by another funcation)
-static void get_port(struct net_ports_binding *cc,
+static errval_t get_port(struct net_ports_binding *cc,
                     port_type_t type,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t queueid)
+                    qid_t queueid,
+                    errval_t *err,
+                    uint16_t *port)
 {
     NDM_DEBUG("get_port called\n");
 
-    errval_t err = SYS_ERR_OK;
-    uint16_t port;
+    *err = SYS_ERR_OK;
 
     /* FIXME: get free port from portalloc system */
     if (type == net_ports_PORT_TCP) {
-        port = alloc_tcp_port();
+        *port = alloc_tcp_port();
     } else {
-        port = alloc_udp_port();
+        *port = alloc_udp_port();
     }
 
     // If could not allocate the port
-    if (port == 0) {
-        err = PORT_ERR_NO_MORE_PORT;
+    if (*port == 0) {
+        *err = PORT_ERR_NO_MORE_PORT;
         NDM_DEBUG("all the ports for this user are allocated!\n");
-        wrapper_get_port_response(cc, err, 0);
-        return;
+        return SYS_ERR_OK;
     }
 
-    err = res_port(cc, port, type, buffer_id_rx, buffer_id_tx, appid, queueid,
+    *err = res_port(cc, *port, type, buffer_id_rx, buffer_id_tx, appid, queueid,
             false);
-    if (err_is_fail(err)) {
-        wrapper_get_port_response(cc, err, 0);
-        return;
+    if (err_is_fail(*err))
+    {
+        *port = 0;
+        return SYS_ERR_OK;
     }
 
     NDM_DEBUG("get_port: waiting for response\n");
-    return;
+    return SYS_ERR_OK;
 } // end function: get_port
 
 
@@ -356,17 +355,18 @@ static void get_port(struct net_ports_binding *cc,
 //   *. Insert appropriate filter
 //   *. Once you get ack for filter being inserted successfully,
 //          send back the response (done by another funcation)
-static void bind_port(struct net_ports_binding *cc,
+static errval_t bind_port(struct net_ports_binding *cc,
                     port_type_t type,
                     uint16_t port_no,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t queueid)
+                    qid_t queueid,
+                    errval_t *err)
 {
     // FIXME: too much of code repetation in get_port and bind_port. FIX it.
     NDM_DEBUG("bind_port called\n");
-    errval_t err = SYS_ERR_OK;
+    *err = SYS_ERR_OK;
     uint16_t port;
 
     NDM_DEBUG("bind_port: called for port %" PRIu16 " with RX[%" PRIu64
@@ -375,21 +375,16 @@ static void bind_port(struct net_ports_binding *cc,
     port = (uint64_t) alloc_specific_port((uint16_t) port_no, type);
 
     if (port == 0) {
-        err = PORT_ERR_IN_USE;
+        *err = PORT_ERR_IN_USE;
         NDM_DEBUG("Requested port is in use!\n");
-        wrapper_bind_port_response(cc, err);
-        return;
+        return SYS_ERR_OK;
     }
 
-    err = res_port(cc, port, type, buffer_id_rx, buffer_id_tx, appid, queueid,
+    *err = res_port(cc, port, type, buffer_id_rx, buffer_id_tx, appid, queueid,
             true);
-    if (err_is_fail(err)) {
-        wrapper_bind_port_response(cc, err);
-        return;
-    }
     NDM_DEBUG("bind_port: exiting\n");
 
-    return;
+    return SYS_ERR_OK;
 } // end function: bind_port
 
 
@@ -401,15 +396,16 @@ static void bind_port(struct net_ports_binding *cc,
 //   *. Send request to remove the filter
 //   *. Once you get ack for filter being removed successfully,
 //          send back the response (done by another funcation)
-static void close_port(struct net_ports_binding *cc,
+static errval_t close_port(struct net_ports_binding *cc,
                     port_type_t type,
                     uint16_t port_no,
                     uint64_t appid,
-                    uint64_t queueid)
+                    uint64_t queueid,
+                    errval_t *err)
 {
     NDM_DEBUG("close_port called\n");
 
-    errval_t err = SYS_ERR_OK;
+    *err = SYS_ERR_OK;
 
     NDM_DEBUG("close_port: called\n");
     struct buffer_port_translation *bp;
@@ -427,20 +423,19 @@ static void close_port(struct net_ports_binding *cc,
         // free(bp);
     } else {
         NDM_DEBUG("close_port: port not found\n");
-        err = PORT_ERR_NOT_FOUND;
-        wrapper_close_port_response(cc, err);
+        *err = PORT_ERR_NOT_FOUND;
     }
 
-    return;
+    return SYS_ERR_OK;
 } // end function: close_port
 
 
 // Get the mac address for given machine
-static void get_mac_address(struct net_ports_binding *cc)
+static errval_t get_mac_address(struct net_ports_binding *cc, uint64_t *hwaddr)
 {
     NDM_DEBUG("get_mac_address called\n");
     assert(!"get_mac_address: NYI");
-    return;
+    return SYS_ERR_OK;
 } // end function: get_mac_address
 
 
@@ -475,7 +470,7 @@ static struct buffer_port_translation *find_filter_id(struct
         status. It is some kind of IDC forwarding mechanism.
         (or a gateway for that matter)
 */
-void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
+static void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
         uint64_t buffer_id_rx, uint64_t buffer_id_tx, uint64_t ftype)
 {
     // FIXME: This is very ugly way to lookup the the request to be processed.
@@ -526,9 +521,9 @@ void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
                     assert(!"NYI filter redirect");
                     // idc_redirect_response(bp->st, err);
                 } else if (bp->bind) {
-                    wrapper_bind_port_response(bp->st, err);
+                    //// wrapper_bind_port_response(bp->st, err);
                 } else {
-                    wrapper_get_port_response(bp->st, err, bp->local_port);
+                    //// wrapper_get_port_response(bp->st, err);
                 }
 
                 // cleaning up
@@ -562,143 +557,3 @@ void handle_filter_response(uint64_t id, errval_t err, uint64_t filter_id,
     USER_PANIC("client buffer_id not found");
 
 } // end function: handle_filter_response
-
-
-
-/*****************************************************************
-* housekeeping functions
-* FIXME: move them in separate file
-*****************************************************************/
-#include <contmng/contmng.h>
-// get_port response: helper functions
-static errval_t send_new_port(struct q_entry e)
-{
-    struct net_ports_binding *b = (struct net_ports_binding *) e.binding_ptr;
-    struct net_user *nu = (struct net_user *) b->st;
-    assert(nu != NULL);
-
-    if (b->can_send(b)) {
-        return b->tx_vtbl.get_port_response(b,
-                            MKCONT(cont_queue_callback, nu->q),
-                            e.plist[0], e.plist[1]);
-        /*  e.err, e.port_no */
-    } else {
-        NDM_DEBUG("send_new_port: Flounder busy,rtry++\n");
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-
-}
-
-static void wrapper_get_port_response(struct net_ports_binding *cc,
-                errval_t err, uint16_t port_no)
-{
-
-    NDM_DEBUG("wrapper_get_port_response: called\n");
-    struct q_entry entry;
-
-    memset(&entry, 0, sizeof(struct q_entry));
-    entry.handler = send_new_port;
-    entry.binding_ptr = (void *) cc;
-
-    entry.plist[0] = err;
-    entry.plist[1] = port_no;
-
-    /*      e.plist[0], e.plist[1]
-       e.err,     e.port_no  */
-
-    struct net_user *nu = (struct net_user *) cc->st;
-    assert(nu != NULL);
-    enqueue_cont_q(nu->q, &entry);
-
-    NDM_DEBUG("wrapper_get_port_response: terminated\n");
-} // end function: wrapper_get_port_response
-
-
-// bind_port response: helper functions
-static errval_t send_bound_port(struct q_entry e)
-{
-    struct net_ports_binding *b = (struct net_ports_binding *) e.binding_ptr;
-    struct net_user *nu = (struct net_user *) b->st;
-
-    if (b->can_send(b)) {
-        return b->tx_vtbl.bind_port_response(b,
-                                             MKCONT(cont_queue_callback, nu->q),
-                                             e.plist[0]);
-        /* entry.err */
-    } else {
-        NDM_DEBUG("send_bound_port: Flounder busy,rtry++\n");
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-
-}
-
-static void wrapper_bind_port_response(struct net_ports_binding *cc,
-        errval_t err)
-{
-
-    NDM_DEBUG("idc_bound_port: called\n");
-
-    struct q_entry entry;
-
-    memset(&entry, 0, sizeof(struct q_entry));
-    entry.handler = send_bound_port;
-    entry.binding_ptr = (void *) cc;
-
-    entry.plist[0] = err;
-
-    /* plist[0]
-     * entry.err
-     */
-
-    struct net_user *nu = (struct net_user *) cc->st;
-    assert(nu != NULL);
-
-    enqueue_cont_q(nu->q, &entry);
-
-    NDM_DEBUG("idc_bound_port: terminated\n");
-}
-
-
-// close_port response: helper functions
-static errval_t send_close_port_response(struct q_entry e)
-{
-    struct net_ports_binding *b = (struct net_ports_binding *) e.binding_ptr;
-    struct net_user *nu = (struct net_user *) b->st;
-
-    if (b->can_send(b)) {
-        return b->tx_vtbl.close_port_response(b,
-                                              MKCONT(cont_queue_callback,
-                                                     nu->q), e.plist[0]);
-        /*  e.err */
-    } else {
-        NDM_DEBUG("send_close_port_response: Flounder busy,rtry++\n");
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-
-} // end function: send_close_port_response
-
-static void wrapper_close_port_response(struct net_ports_binding *cc,
-            errval_t err)
-{
-
-    NDM_DEBUG("wrapper_close_port_response: called\n");
-    struct q_entry entry;
-
-    memset(&entry, 0, sizeof(struct q_entry));
-    entry.handler = send_close_port_response;
-    entry.binding_ptr = (void *) cc;
-
-    entry.plist[0] = err;
-
-    /*  e.plist[0]
-       e.err    */
-
-    struct net_user *nu = (struct net_user *) cc->st;
-
-    enqueue_cont_q(nu->q, &entry);
-
-    NDM_DEBUG("wrapper_close_port_response: terminated\n");
-}
-
-
-
index 9ec92ed..568f3e1 100644 (file)
@@ -13,7 +13,6 @@
 #include <barrelfish/barrelfish.h>
 #include <barrelfish/waitset.h>
 #include <barrelfish/nameservice_client.h>
-#include <contmng/contmng.h>
 #include <ipv4/lwip/inet.h>
 
 #include <if/sfn5122f_defs.h>
 /** Connection to sfn5122f management service */
 struct sfn5122f_binding *sfn5122f_binding = NULL;
 
-struct cont_queue *sfn5122f_c_queue = NULL;
-
-
 /******************************************************************************
  * Operations for filter interface
  ******************************************************************************/
 
-// Callback from sfn5122f
-static void idc_filter_registered(struct sfn5122f_binding *b,
-                                  uint64_t buf_id_rx,
-                                  uint64_t buf_id_tx,
-                                  errval_t err,
-                                  uint64_t filter)
-{
-    NDM_DEBUG("sfn5122f_idc_filter_registered(f=%"PRIu64" rx=%"PRIu64" tx=%"PRIu64
-            ")\n", filter, buf_id_rx, buf_id_tx);
-    handle_filter_response(filter, err, filter, buf_id_rx, buf_id_tx, 1);
-}
-
-// Callback from sfn5122f
-static void idc_filter_unregistered(struct sfn5122f_binding *b,
-                                    uint64_t filter,
-                                    errval_t err)
-{
-    NDM_DEBUG("sfn5122f_idc_filter_unregistered(%"PRIu64")\n", filter);
-}
-
-static errval_t send_register_port_filter(struct q_entry e)
-{
-    if (sfn5122f_binding->can_send(sfn5122f_binding)) {
-        return sfn5122f_binding->tx_vtbl.register_port_filter(
-                sfn5122f_binding, MKCONT(cont_queue_callback, sfn5122f_c_queue),
-                e.plist[0], e.plist[1], e.plist[2], e.plist[3], e.plist[4]);
-    } else {
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-}
-
-/** Register filter with sfn5122f card driver */
-static void idc_register_port_filter(uint64_t buf_id_rx,
-                                     uint64_t buf_id_tx,
-                                     uint16_t queue,
-                                     sfn5122f_port_type_t type,
-                                     uint16_t port)
-{
-    struct q_entry entry;
-    NDM_DEBUG("sfn5122f_idc_register_port_filter(q=%d p=%d rx=%"PRIu64" tx=%"
-            PRIu64")\n", queue, port, buf_id_rx, buf_id_tx);
-
-    memset(&entry, 0, sizeof(struct q_entry));
-
-    entry.handler = send_register_port_filter;
-    entry.binding_ptr = sfn5122f_binding;
-    entry.plist[0] = buf_id_rx;
-    entry.plist[1] = buf_id_tx;
-    entry.plist[2] = queue;
-    entry.plist[3] = type;
-    entry.plist[4] = port;
-
-    enqueue_cont_q(sfn5122f_c_queue, &entry);
-}
-
-static errval_t send_unregister_filter(struct q_entry e)
-{
-    if (sfn5122f_binding->can_send(sfn5122f_binding)) {
-        return sfn5122f_binding->tx_vtbl.unregister_filter(
-                sfn5122f_binding, MKCONT(cont_queue_callback, sfn5122f_c_queue),
-                e.plist[0]);
-    } else {
-        return FLOUNDER_ERR_TX_BUSY;
-    }
-}
-
-/** Unregister filter with sfn5122f card driver */
-static void idc_unregister_filter(uint64_t filter)
-{
-    struct q_entry entry;
-    memset(&entry, 0, sizeof(struct q_entry));
-
-    entry.handler = send_unregister_filter;
-    entry.binding_ptr = sfn5122f_binding;
-    entry.plist[0] = filter;
-
-    enqueue_cont_q(sfn5122f_c_queue, &entry);
-}
-
-static struct sfn5122f_rx_vtbl rx_vtbl = {
-    .filter_registered = idc_filter_registered,
-    .filter_unregistered = idc_filter_unregistered,
-};
-
 // Callback for bind
 static void bind_cb(void *st, errval_t err, struct sfn5122f_binding *b)
 {
@@ -128,10 +40,8 @@ static void bind_cb(void *st, errval_t err, struct sfn5122f_binding *b)
 
     NDM_DEBUG("Sucessfully connected to management interface\n");
 
-    b->rx_vtbl = rx_vtbl;
-
     sfn5122f_binding = b;
-    sfn5122f_c_queue = create_cont_q("sfn5122f_filters");
+    sfn5122f_rpc_client_init(sfn5122f_binding);
 }
 
 /** Open connection to management interface */
@@ -187,7 +97,8 @@ static errval_t reg_filters(uint16_t port,
                             bufid_t buffer_id_rx,
                             bufid_t buffer_id_tx,
                             appid_t appid,
-                            qid_t qid)
+                            qid_t qid,
+                            uint64_t *id, errval_t *rerr, uint64_t *filter_id)
 {
     sfn5122f_port_type_t t;
     assert(sfn5122f_binding != NULL);
@@ -199,18 +110,22 @@ static errval_t reg_filters(uint16_t port,
     } else {
         t = sfn5122f_PORT_UDP;
     }
-
-    idc_register_port_filter(buffer_id_rx, buffer_id_tx, qid, t, port);
+    errval_t err;
+    err = sfn5122f_binding->rpc_tx_vtbl.register_port_filter(sfn5122f_binding, buffer_id_rx, buffer_id_tx, qid, t, port, rerr, filter_id);
 
     return SYS_ERR_OK;
 }
 
-static void unreg_filters(uint64_t filter_id, qid_t qid)
+static errval_t unreg_filters(uint64_t filter_id, qid_t qid)
 {
     assert(sfn5122f_binding != NULL);
 
     NDM_DEBUG("sfn5122f_unreg_filters()\n");
-    idc_unregister_filter(filter_id);
+    errval_t err, rerr;
+    err = sfn5122f_binding->rpc_tx_vtbl.unregister_filter(sfn5122f_binding, filter_id, &rerr);
+    assert(err_is_ok(err));
+    
+    return rerr;
 }
 
 
@@ -230,5 +145,3 @@ struct filters_tx_vtbl *get_sfn5122f_filt_mng_sign(void)
 {
     return &sfn5122f_filts_mng;
 }
-
-
index af44afb..8c2e60b 100755 (executable)
@@ -66,14 +66,15 @@ static void connect_soft_filters_service(char *dev_name, qid_t qid);
 static void register_arp_soft_filter(uint64_t id, uint64_t len_rx,
                                     uint64_t len_tx);
 
-errval_t register_soft_filt_impl(uint16_t port,
+static errval_t register_soft_filt_impl(uint16_t port,
                     port_type_t type,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t qid);
+                    qid_t qid,
+                    uint64_t *id, errval_t *rerr, uint64_t *filter_id);
 
-static void unregister_soft_filter(uint64_t filter_id, qid_t qid);
+static errval_t unregister_soft_filter(uint64_t filter_id, qid_t qid);
 
 static struct filters_tx_vtbl soft_filts_mng = {
     .type = "Soft_filters",
@@ -91,7 +92,8 @@ static void sf_mac_lookup(void);
 
 static void send_soft_filter(uint64_t id, uint64_t len_rx, uint64_t len_tx,
                                 uint64_t buffer_id_rx, uint64_t buffer_id_tx,
-                                uint8_t ftype, uint8_t paused);
+                                uint8_t ftype, uint8_t paused,
+                                errval_t *rerr, uint64_t *filter_id);
 
 // *****************************************************************
 // * Get signature of this service
@@ -107,12 +109,13 @@ struct filters_tx_vtbl *get_soft_filt_mng_sign(void)
 // *****************************************************************
 
 
-errval_t register_soft_filt_impl(uint16_t port,
+static errval_t register_soft_filt_impl(uint16_t port,
                     port_type_t type,
                     bufid_t buffer_id_rx,
                     bufid_t buffer_id_tx,
                     appid_t appid,
-                    qid_t qid)
+                    qid_t qid,
+                    uint64_t *id, errval_t *rerr, uint64_t *filter_id)
 {
     int32_t len_rx, len_tx;
     /* NOTE: check if someone else is using the filter location */
@@ -126,14 +129,14 @@ errval_t register_soft_filt_impl(uint16_t port,
     /* create rx, tx filter around that port */
     filter_mem_lock = true;     /* NOTE: filter memory is in use
                                    till "registered_filter" is called by filter_manager */
-    uint64_t id = populate_rx_tx_filter_mem(port, type, &len_rx, &len_tx);
+    *id = populate_rx_tx_filter_mem(port, type, &len_rx, &len_tx);
 
     /* Register the filter with soft_filters */
     NDM_DEBUG("get_port: trying to register the filter with id %" PRIu64 "\n",
-               id);
-    send_soft_filter(id, len_rx, len_tx, buffer_id_rx, buffer_id_tx,
-                        NORMAL_FILTER, 0);
-
+               *id);
+    send_soft_filter(*id, len_rx, len_tx, buffer_id_rx, buffer_id_tx,
+                        NORMAL_FILTER, 0, rerr, filter_id);
+                    
     return SYS_ERR_OK;
 }
 
@@ -302,18 +305,18 @@ static void sf_mac_lookup(void)
 static void send_soft_filter(uint64_t id, uint64_t len_rx,
                                 uint64_t len_tx, uint64_t buffer_id_rx,
                                 uint64_t buffer_id_tx, uint8_t ftype,
-                                uint8_t paused)
+                                uint8_t paused,
+                                errval_t *rerr, uint64_t *filter_id)
 {
     NDM_DEBUG("send_soft_filter: called for id %" PRIu64
                " and type %x, paused = %d\n", id, ftype, paused);
 
     struct net_soft_filters_binding *b = soft_filters_connection;
 
-    errval_t err, rerr;
-    uint64_t filter_id;
-    err = b->rpc_tx_vtbl.register_filter(b, id, len_rx, len_tx, buffer_id_rx, buffer_id_tx, ftype, paused, &rerr, &filter_id);
+    errval_t err;
+    err = b->rpc_tx_vtbl.register_filter(b, id, len_rx, len_tx, buffer_id_rx, buffer_id_tx, ftype, paused, rerr, filter_id);
     assert(err_is_ok(err));
-    assert(err_is_ok(rerr));
+    assert(err_is_ok(*rerr));
     NDM_DEBUG("filter at id [%" PRIu64 "] type[%" PRIu64
                "] registered with filt_id %" PRIu64 ".\n", id, ftype,
                filter_id);
@@ -323,16 +326,13 @@ static void send_soft_filter(uint64_t id, uint64_t len_rx,
     assert(err_is_ok(err));
 
     filter_mem_lock = false; // NOTE: filter memory can be used by others now
-
-    handle_filter_response(id, err, filter_id, buffer_id_rx, buffer_id_tx,
-            ftype);
 } // end function: send_soft_filter
 
 /**
  * \brief sends the filterID for de-registration to network driver.
  *
  */
-static void unregister_soft_filter(uint64_t filter_id, qid_t qid)
+static errval_t unregister_soft_filter(uint64_t filter_id, qid_t qid)
 {
     struct net_soft_filters_binding *b = soft_filters_connection;
 
@@ -340,6 +340,7 @@ static void unregister_soft_filter(uint64_t filter_id, qid_t qid)
     err = b->rpc_tx_vtbl.deregister_filter(b, filter_id, &rerr);
     assert(err_is_ok(err));
     assert(err_is_ok(rerr));
+    return rerr;
 } // end function: unregister_soft_filter
 
 /**
index 957066e..407160e 100644 (file)
@@ -1203,42 +1203,6 @@ static void idc_write_queue_tails(struct e10k_binding *b)
     assert(err_is_ok(r));
 }
 
-#ifndef LIBRARY
-/** Signal queue driver that the queue is stopped. */
-static void idc_queue_terminated(struct e10k_binding *b)
-{
-    errval_t r;
-    r = e10k_queue_terminated__tx(b, NOP_CONT);
-    // TODO: handle busy
-    assert(err_is_ok(r));
-}
-
-/** Send response about filter registration to device manager */
-static void idc_filter_registered(struct e10k_binding *b,
-                                  uint64_t buf_id_rx,
-                                  uint64_t buf_id_tx,
-                                  errval_t err,
-                                  uint64_t filter)
-{
-    errval_t r;
-    r = e10k_filter_registered__tx(b, NOP_CONT, buf_id_rx, buf_id_tx, err,
-                                   filter);
-    // TODO: handle busy
-    assert(err_is_ok(r));
-}
-
-/** Send response about filter deregistration to device manager */
-static void idc_filter_unregistered(struct e10k_binding *b,
-                                    uint64_t filter,
-                                    errval_t err)
-{
-    errval_t r;
-    r = e10k_filter_unregistered__tx(b, NOP_CONT, filter, err);
-    // TODO: handle busy
-    assert(err_is_ok(r));
-}
-#endif
-
 /** Request from queue driver for register memory cap */
 void cd_request_device_info(struct e10k_binding *b)
 {
@@ -1341,7 +1305,7 @@ void cd_set_interrupt_rate(struct e10k_binding *b,
  * Request from queue driver to stop hardware queue and free everything
  * associated with that queue.
  */
-static void idc_terminate_queue(struct e10k_binding *b, uint8_t n)
+static errval_t idc_terminate_queue(struct e10k_binding *b, uint8_t n)
 {
     DEBUG("idc_terminate_queue(q=%d)\n", n);
 
@@ -1351,15 +1315,17 @@ static void idc_terminate_queue(struct e10k_binding *b, uint8_t n)
     queues[n].binding = NULL;
 
     // TODO: Do we have to free the frame caps, or destroy the binding?
-    idc_queue_terminated(b);
+    return SYS_ERR_OK;
 }
 
-static void idc_register_port_filter(struct e10k_binding *b,
+static errval_t idc_register_port_filter(struct e10k_binding *b,
                                      uint64_t buf_id_rx,
                                      uint64_t buf_id_tx,
                                      uint8_t queue,
                                      e10k_port_type_t type,
-                                     uint16_t port)
+                                     uint16_t port,
+                                     errval_t *err,
+                                     uint64_t *filter)
 {
     struct e10k_filter f = {
         .dst_port = port,
@@ -1368,33 +1334,34 @@ static void idc_register_port_filter(struct e10k_binding *b,
         .priority = 1,
         .queue = queue,
     };
-    errval_t err;
-    uint64_t fid = -1ULL;
+    *filter = -1ULL;
 
     DEBUG("idc_register_port_filter: called (q=%d t=%d p=%d)\n",
             queue, type, port);
 
-    err = reg_ftfq_filter(&f, &fid);
-    DEBUG("filter registered: err=%"PRIu64", fid=%"PRIu64"\n", err, fid);
-
-    idc_filter_registered(b, buf_id_rx, buf_id_tx, err, fid);
+    *err = reg_ftfq_filter(&f, filter);
+    DEBUG("filter registered: err=%"PRIu64", fid=%"PRIu64"\n", *err, *filter);
+    return SYS_ERR_OK;
 }
 
-static void idc_unregister_filter(struct e10k_binding *b,
-                                  uint64_t filter)
+static errval_t idc_unregister_filter(struct e10k_binding *b,
+                                  uint64_t filter, errval_t *err)
 {
     DEBUG("unregister_filter: called (%"PRIx64")\n", filter);
-    idc_filter_unregistered(b, filter, LIB_ERR_NOT_IMPLEMENTED);
+    *err = LIB_ERR_NOT_IMPLEMENTED;
+    return SYS_ERR_OK;
 }
 
 static struct e10k_rx_vtbl rx_vtbl = {
     .request_device_info = cd_request_device_info,
     .register_queue_memory = cd_register_queue_memory,
     .set_interrupt_rate = cd_set_interrupt_rate,
-    .terminate_queue = idc_terminate_queue,
+};
 
-    .register_port_filter = idc_register_port_filter,
-    .unregister_filter = idc_unregister_filter,
+static struct e10k_rpc_rx_vtbl rpc_rx_vtbl = {
+    .terminate_queue_call = idc_terminate_queue,
+    .register_port_filter_call = idc_register_port_filter,
+    .unregister_filter_call = idc_unregister_filter,
 };
 
 
@@ -1417,6 +1384,7 @@ static errval_t connect_cb(void *st, struct e10k_binding *b)
 {
     DEBUG("New connection on management interface\n");
     b->rx_vtbl = rx_vtbl;
+    b->rpc_rx_vtbl = rpc_rx_vtbl;
     return SYS_ERR_OK;
 }
 
index a54707a..6f0bb3f 100644 (file)
@@ -133,7 +133,7 @@ static bool standalone = false;
 static struct e10k_binding *binding = NULL;
 
 /** Queue index for this manager instance */
-int qi = -1;
+int queue_index = -1;
 
 /** Mackerel handle for device */
 #ifndef VF
@@ -143,7 +143,7 @@ static e10k_vf_t *d = NULL;
 #endif
 
 /** Queue handle for queue management library */
-static e10k_queue_t *q;
+static e10k_queue_t *queue_handle;
 
 /** MAC address to be used */
 static uint64_t mac_address = 0;
@@ -178,7 +178,7 @@ static bool use_rsc = false;
 static bool use_msix = false;
 
 /** Indicates whether or the VT-d should be used for DMA remapping.*/
-static bool use_vtd = false; 
+static bool use_vtd = false;
 
 /** Minimal delay between interrupts in us */
 static uint16_t interrupt_delay = 0;
@@ -212,7 +212,7 @@ static void queue_debug(const char* fmt, ...)
 {
     va_list va;
     va_start(va, fmt);
-    printf("e10k.q%d: ", qi);
+    printf("e10k.queue_handle%d: ", queue_index);
     vprintf(fmt, va);
     va_end(va);
 }
@@ -387,11 +387,11 @@ bool e1000n_queue_empty(void)
     uint32_t tail, head;
 
 #ifndef VF
-    tail = e10k_tdt_rd(d, qi);
-    head = e10k_tdh_rd(d, qi);
+    tail = e10k_tdt_rd(d, queue_index);
+    head = e10k_tdh_rd(d, queue_index);
 #else
-    tail = e10k_vf_vftdt_rd(d, qi);
-    head = e10k_vf_vftdh_rd(d, qi);
+    tail = e10k_vf_vftdt_rd(d, queue_index);
+    head = e10k_vf_vftdh_rd(d, queue_index);
 #endif
 
     return (head == tail);
@@ -432,13 +432,13 @@ static errval_t transmit_pbuf_list_fn(struct driver_buffer *buffers,
             l4t = e10k_q_udp;
             l4len = UDPHDR_LEN;
         }
-        e10k_queue_add_txcontext(q, 0, ETHHDR_LEN, IPHDR_LEN, l4len, l4t);
+        e10k_queue_add_txcontext(queue_handle, 0, ETHHDR_LEN, IPHDR_LEN, l4len, l4t);
 
        if (use_vtd) {
-           e10k_queue_add_txbuf_ctx(q, (lvaddr_t)buffers[0].va, buffers[0].len,
+           e10k_queue_add_txbuf_ctx(queue_handle, (lvaddr_t)buffers[0].va, buffers[0].len,
                                     buffers[0].opaque, 1, (count == 1), totallen, 0, true, l4len != 0);
        } else {
-            e10k_queue_add_txbuf_ctx(q, buffers[0].pa, buffers[0].len,
+            e10k_queue_add_txbuf_ctx(queue_handle, buffers[0].pa, buffers[0].len,
                 buffers[0].opaque, 1, (count == 1), totallen, 0, true, l4len != 0);
         }
         start++;
@@ -446,15 +446,15 @@ static errval_t transmit_pbuf_list_fn(struct driver_buffer *buffers,
 
     for (i = start; i < count; i++) {
         if (use_vtd) {
-           e10k_queue_add_txbuf(q, (lvaddr_t)buffers[i].va, buffers[i].len,
+           e10k_queue_add_txbuf(queue_handle, (lvaddr_t)buffers[i].va, buffers[i].len,
                                 buffers[i].opaque, (i == 0), (i == count - 1), totallen);
        } else {
-            e10k_queue_add_txbuf(q, buffers[i].pa, buffers[i].len,
+            e10k_queue_add_txbuf(queue_handle, buffers[i].pa, buffers[i].len,
                 buffers[i].opaque, (i == 0), (i == count - 1), totallen);
         }
     }
 
-    e10k_queue_bump_txtail(q);
+    e10k_queue_bump_txtail(queue_handle);
 #if TRACE_ETHERSRV_MODE
     trace_event(TRACE_SUBSYS_NNET, TRACE_EVENT_NNET_DRV_SEE, 0);
 #endif // TRACE_ETHERSRV_MODE
@@ -465,14 +465,14 @@ static errval_t transmit_pbuf_list_fn(struct driver_buffer *buffers,
 
 static uint64_t find_tx_free_slot_count_fn(void)
 {
-    return e10k_queue_free_txslots(q);
+    return e10k_queue_free_txslots(queue_handle);
 }
 
 static bool handle_free_tx_slot_fn(void)
 {
     void *op;
 
-    if (e10k_queue_get_txbuf(q, &op) != 0) {
+    if (e10k_queue_get_txbuf(queue_handle, &op) != 0) {
         return false;
     }
 
@@ -510,11 +510,11 @@ static errval_t register_rx_buffer_fn(uint64_t paddr, void *vaddr, void *opaque)
     /* printf("Got %p from stack\n", opaque); */
     DEBUG("register_rx_buffer_fn: called\n");
     if (use_vtd) {
-        e10k_queue_add_rxbuf(q, (lvaddr_t)vaddr, opaque);
+        e10k_queue_add_rxbuf(queue_handle, (lvaddr_t)vaddr, opaque);
     } else {
-        e10k_queue_add_rxbuf(q, paddr, opaque);
+        e10k_queue_add_rxbuf(queue_handle, paddr, opaque);
     }
-    e10k_queue_bump_rxtail(q);
+    e10k_queue_bump_rxtail(queue_handle);
 
     DEBUG("register_rx_buffer_fn: terminated\n");
     return SYS_ERR_OK;
@@ -522,7 +522,7 @@ static errval_t register_rx_buffer_fn(uint64_t paddr, void *vaddr, void *opaque)
 
 static uint64_t find_rx_free_slot_count_fn(void)
 {
-    return e10k_queue_free_rxslots(q);
+    return e10k_queue_free_rxslots(queue_handle);
 }
 
 static size_t check_for_new_packets(int num)
@@ -559,8 +559,8 @@ static size_t check_for_new_packets(int num)
 #ifndef VF
 #if 0
     // Check if queue runs too full
-    int rdtp = e10k_rdt_1_rd(d, qi);
-    int rdhp = e10k_rdh_1_rd(d, qi);
+    int rdtp = e10k_rdt_1_rd(d, queue_index);
+    int rdhp = e10k_rdh_1_rd(d, queue_index);
     if(rdtp < rdhp) {
         if(NRXDESCS - (rdhp - rdtp) < 10) {
             printf("Running low on receive buffers! rdhp = %u, rdtp = %u\n", rdhp, rdtp);
@@ -578,7 +578,7 @@ static size_t check_for_new_packets(int num)
     count = 0;
     pkt_cnt = 0;
     
-    while ((res = e10k_queue_get_rxbuf(q, &op, &len, &last, &flags)) == 0 ||
+    while ((res = e10k_queue_get_rxbuf(queue_handle, &op, &len, &last, &flags)) == 0 ||
            pkt_cnt != 0)
     {
         if (res != 0) continue;
@@ -587,7 +587,7 @@ static size_t check_for_new_packets(int num)
 #endif // TRACE_ETHERSRV_MODE
 
 
-        DEBUG("New packet (q=%d f=%"PRIx64")\n", qi, flags);
+        DEBUG("New packet (queue_handle=%d f=%"PRIx64")\n", queue_index, flags);
 
         buf[pkt_cnt].opaque = op;
         buf[pkt_cnt].len = len;
@@ -607,7 +607,7 @@ static size_t check_for_new_packets(int num)
         flags = 0;
     }
 
-    if (count > 0) e10k_queue_bump_rxtail(q);
+    if (count > 0) e10k_queue_bump_rxtail(queue_handle);
     return count;
 }
 
@@ -624,9 +624,9 @@ static errval_t update_txtail(void *opaque, size_t tail)
     assert(d != NULL);
 
 #ifndef VF
-    e10k_tdt_wr(d, qi, tail);
+    e10k_tdt_wr(d, queue_index, tail);
 #else
-    e10k_vf_vftdt_wr(d, qi, tail);
+    e10k_vf_vftdt_wr(d, queue_index, tail);
 #endif
     return SYS_ERR_OK;
 }
@@ -636,9 +636,9 @@ static errval_t update_rxtail(void *opaque, size_t tail)
     assert(d != NULL);
 
 #ifndef VF
-    e10k_rdt_1_wr(d, qi, tail);
+    e10k_rdt_1_wr(d, queue_index, tail);
 #else
-    e10k_vf_vfrdt_wr(d, qi, tail);
+    e10k_vf_vfrdt_wr(d, queue_index, tail);
 #endif
     return SYS_ERR_OK;
 }
@@ -704,7 +704,7 @@ static void setup_queue(void)
     }
 
     // Initialize queue manager
-    q = e10k_queue_init(tx_virt, NTXDESCS, txhwb_virt, rx_virt, NRXDESCS, &ops,
+    queue_handle = e10k_queue_init(tx_virt, NTXDESCS, txhwb_virt, rx_virt, NRXDESCS, &ops,
                         NULL);
 
 
@@ -732,11 +732,11 @@ static void setup_queue(void)
     }
 
     if (use_vtd) {
-        idc_register_queue_memory(qi, tx_frame, txhwb_frame, rx_frame, RXBUFSZ,
+        idc_register_queue_memory(queue_index, tx_frame, txhwb_frame, rx_frame, RXBUFSZ,
                                   vector, core, (lvaddr_t)tx_virt, (lvaddr_t)rx_virt,
                                   (lvaddr_t)txhwb_virt);
     } else {
-        idc_register_queue_memory(qi, tx_frame, txhwb_frame, rx_frame, RXBUFSZ,
+        idc_register_queue_memory(queue_index, tx_frame, txhwb_frame, rx_frame, RXBUFSZ,
                                   vector, core, 0, 0, 0);
     }
 }
@@ -744,7 +744,7 @@ static void setup_queue(void)
 /** Hardware queue initialized in card driver */
 static void hwqueue_initialized(void)
 {
-    idc_set_interrupt_rate(qi, interrupt_delay);
+    idc_set_interrupt_rate(queue_index, interrupt_delay);
 }
 
 /** Terminate this queue driver */
@@ -830,16 +830,37 @@ static void idc_set_interrupt_rate(uint8_t queue, uint16_t rate)
 /** Tell card driver to stop this queue. */
 static void idc_terminate_queue(void)
 {
-    errval_t r;
     INITDEBUG("idc_terminate_queue()\n");
 
     if (!standalone) {
         USER_PANIC("Terminating monolithic driver is not a good idea");
     }
 
-    r = e10k_terminate_queue__tx(binding, NOP_CONT, qi);
+    errval_t err;
+    err = binding->rpc_tx_vtbl.terminate_queue(binding, queue_index);
+    assert(err_is_ok(err));
     // TODO: handle busy
-    assert(err_is_ok(r));
+
+    INITDEBUG("idc_queue_terminated()\n");
+
+    // Free memory for hardware ring buffers
+    err = vspace_unmap(queue_handle->tx_ring);
+    assert(err_is_ok(err));
+    err = vspace_unmap(queue_handle->rx_ring);
+    assert(err_is_ok(err));
+    err = cap_delete(tx_frame);
+    assert(err_is_ok(err));
+    err = cap_delete(rx_frame);
+    assert(err_is_ok(err));
+
+    if (!capref_is_null(txhwb_frame)) {
+        err = vspace_unmap(queue_handle->tx_hwb);
+        assert(err_is_ok(err));
+        err = cap_delete(txhwb_frame);
+        assert(err_is_ok(err));
+    }
+
+    exit(0);
 }
 
 // Callback from device manager
@@ -881,12 +902,12 @@ void qd_queue_memory_registered(struct e10k_binding *b)
 
     // Register queue with queue_mgr library
 #ifndef LIBRARY
-    ethersrv_init((char*) service_name, qi, get_mac_addr_fn, terminate_queue_fn,
+    ethersrv_init((char*) service_name, queue_index, get_mac_addr_fn, terminate_queue_fn,
         transmit_pbuf_list_fn, find_tx_free_slot_count_fn,
         handle_free_tx_slot_fn, RXBUFSZ, register_rx_buffer_fn,
         find_rx_free_slot_count_fn);
 #else
-    ethernetif_backend_init((char*) service_name, qi, get_mac_addr_fn, terminate_queue_fn,
+    ethernetif_backend_init((char*) service_name, queue_index, get_mac_addr_fn, terminate_queue_fn,
         transmit_pbuf_list_fn, find_tx_free_slot_count_fn,
         handle_free_tx_slot_fn, RXBUFSZ, register_rx_buffer_fn,
         find_rx_free_slot_count_fn);
@@ -898,43 +919,16 @@ void qd_write_queue_tails(struct e10k_binding *b)
 {
     INITDEBUG("idc_write_queue_tails()\n");
 
-    e10k_queue_bump_rxtail(q);
-    e10k_queue_bump_txtail(q);
+    e10k_queue_bump_rxtail(queue_handle);
+    e10k_queue_bump_txtail(queue_handle);
 }
 
 #ifndef LIBRARY
-// Callback from device manager
-static void idc_queue_terminated(struct e10k_binding *b)
-{
-    errval_t err;
-
-    INITDEBUG("idc_queue_terminated()\n");
-
-    // Free memory for hardware ring buffers
-    err = vspace_unmap(q->tx_ring);
-    assert(err_is_ok(err));
-    err = vspace_unmap(q->rx_ring);
-    assert(err_is_ok(err));
-    err = cap_delete(tx_frame);
-    assert(err_is_ok(err));
-    err = cap_delete(rx_frame);
-    assert(err_is_ok(err));
-
-    if (!capref_is_null(txhwb_frame)) {
-        err = vspace_unmap(q->tx_hwb);
-        assert(err_is_ok(err));
-        err = cap_delete(txhwb_frame);
-        assert(err_is_ok(err));
-    }
-
-    exit(0);
-}
 
 static struct e10k_rx_vtbl rx_vtbl = {
     .queue_init_data = qd_queue_init_data,
     .queue_memory_registered = qd_queue_memory_registered,
     .write_queue_tails = qd_write_queue_tails,
-    .queue_terminated = idc_queue_terminated,
 };
 
 static void bind_cb(void *st, errval_t err, struct e10k_binding *b)
@@ -989,7 +983,7 @@ void qd_argument(const char *arg)
         service_name = arg + strlen("cardname=");
         ethersrv_argument(arg);
     } else if (strncmp(arg, "queue=", strlen("queue=") - 1) == 0) {
-        qi = atol(arg + strlen("queue="));
+        queue_index = atol(arg + strlen("queue="));
         ethersrv_argument(arg);
     } else if (strncmp(arg, "cache_coherence=",
                        strlen("cache_coherence=") - 1) == 0) {
@@ -1121,7 +1115,7 @@ void qd_interrupt(bool is_rx, bool is_tx)
 void qd_main(void)
 {
     // Validate some settings
-    if (qi == -1) {
+    if (queue_index == -1) {
         USER_PANIC("For queue driver the queue= parameter has to be specified "
                    "on the command line!");
     }
index 48f5f91..37c5d07 100644 (file)
@@ -147,7 +147,7 @@ struct sfn5122f_filter_ip {
     uint16_t dst_port;
 
     uint16_t type_ip;
-    uint16_t hash;   
+    uint16_t hash;
 };
 
 /*
@@ -156,7 +156,7 @@ struct sfn5122f_filter_mac {
     bool wildcard_match;
     bool scatter;
     bool rss;
-    bool ip_override;    
+    bool ip_override;
 
     uint8_t queue;
 
@@ -164,7 +164,7 @@ struct sfn5122f_filter_mac {
     uint16_t vlan_id;
 
     uint16_t type_mac;
-    uint16_t hash;   
+    uint16_t hash;
 };
 */
 
@@ -229,9 +229,9 @@ static void sfn5122f_filter_port_setup(int idx, struct sfn5122f_filter_ip* filte
     if (filter->type_ip == sfn5122f_PORT_UDP) {
 
         // Add destination IP
-        filter_hi = sfn5122f_rx_filter_tbl_hi_dest_ip_insert(filter_hi, 
+        filter_hi = sfn5122f_rx_filter_tbl_hi_dest_ip_insert(filter_hi,
                                                              filter->dst_ip);
-        filter_lo = sfn5122f_rx_filter_tbl_lo_src_ip_insert(filter_lo, 
+        filter_lo = sfn5122f_rx_filter_tbl_lo_src_ip_insert(filter_lo,
                                                             0);
         filter_hi = sfn5122f_rx_filter_tbl_hi_tcp_udp_insert(filter_hi, 1);
         filter_lo = sfn5122f_rx_filter_tbl_lo_src_tcp_dest_udp_insert(
@@ -240,8 +240,8 @@ static void sfn5122f_filter_port_setup(int idx, struct sfn5122f_filter_ip* filte
         filter_hi = sfn5122f_rx_filter_tbl_hi_rss_en_insert(filter_hi, 0);
         filter_hi = sfn5122f_rx_filter_tbl_hi_scatter_en_insert(filter_hi, 0);
         DEBUG("UPD filter index %d: ip_dst %x port_dst %d ip_src %x port_src %d"
-               " queue %d \n", 
-               idx, filter->dst_ip, filter->dst_port, 
+               " queue %d \n",
+               idx, filter->dst_ip, filter->dst_port,
                filter->src_ip, filter->src_port, filter->queue);
     }
 
@@ -249,16 +249,16 @@ static void sfn5122f_filter_port_setup(int idx, struct sfn5122f_filter_ip* filte
         // Add dst IP and port
         filter_hi = sfn5122f_rx_filter_tbl_hi_dest_ip_insert(filter_hi,
                                                              filter->dst_ip);
-        filter_lo = sfn5122f_rx_filter_tbl_lo_src_ip_insert(filter_lo, 
+        filter_lo = sfn5122f_rx_filter_tbl_lo_src_ip_insert(filter_lo,
                                                             filter->src_ip);
-        filter_lo = sfn5122f_rx_filter_tbl_lo_dest_port_tcp_insert(filter_lo, 
+        filter_lo = sfn5122f_rx_filter_tbl_lo_dest_port_tcp_insert(filter_lo,
                                                                    filter->dst_port);
         filter_hi = sfn5122f_rx_filter_tbl_hi_tcp_udp_insert(filter_hi, 0);
         filter_hi = sfn5122f_rx_filter_tbl_hi_rss_en_insert(filter_hi, 0);
         filter_hi = sfn5122f_rx_filter_tbl_hi_scatter_en_insert(filter_hi, 0);
         DEBUG("TCP filter index %d: ip_dst %x port_dst %d ip_src %x port_src %d"
-               " queue %d \n", 
-               idx, filter->dst_ip, filter->dst_port, 
+               " queue %d \n",
+               idx, filter->dst_ip, filter->dst_port,
                filter->src_ip, filter->src_port, filter->queue);
     }
 
@@ -311,16 +311,16 @@ static uint16_t filter_hash(uint32_t key)
     return tmp ^ tmp >> 9;
 }
 
-static bool filter_equals(struct sfn5122f_filter_ip* f1, 
+static bool filter_equals(struct sfn5122f_filter_ip* f1,
                           struct sfn5122f_filter_ip* f2)
 {
     if (f1->type_ip != f2->type_ip) {
         return false;
     } else if ((f1->src_ip != f2->src_ip) ||
-               (f1->dst_ip != f2->dst_ip) || 
+               (f1->dst_ip != f2->dst_ip) ||
                (f1->queue != f2->queue)) {
         return false;
-    } else if ((f1->src_port != f2->src_port) && 
+    } else if ((f1->src_port != f2->src_port) &&
                (f2->dst_port != f1->dst_port)) {
         return false;
     } else {
@@ -351,7 +351,7 @@ static int ftqf_alloc(struct sfn5122f_filter_ip* f)
             return key;
         } else if (filter_equals(&filters_rx_ip[key], f)){
             return key;
-        } 
+        }
         
         if (depth > 3) {
             return -1;
@@ -422,13 +422,13 @@ static void handle_assertions(void)
     uint8_t in[4];
     uint8_t out[140];
     uint32_t outlen = 0;
-    errval_t err;   
+    errval_t err;
 
     memset(in, 0, sizeof(in));
     in[CMD_GET_ASSERTS_IN_CLEAR_OFFSET] = 0;
 
     err = mcdi_rpc(CMD_GET_ASSERTS, in , CMD_GET_ASSERTS_IN_LEN, out,
-                   CMD_GET_ASSERTS_OUT_LEN, &outlen, pci_function, d);    
+                   CMD_GET_ASSERTS_OUT_LEN, &outlen, pci_function, d);
     assert(err_is_ok(err));
 
     if(out[0] != 0x1){
@@ -436,7 +436,7 @@ static void handle_assertions(void)
          printf("THERE WERE ASSERTIONS: %"PRIu8" \n ", out[0]);
          /* exit assertions -> special reboot*/
          in[0] = 0x1;
-         err = mcdi_rpc(CMD_REBOOT, in, CMD_REBOOT_IN_LEN , 
+         err = mcdi_rpc(CMD_REBOOT, in, CMD_REBOOT_IN_LEN ,
                         NULL, 0, NULL, pci_function, d);
          assert(err_is_ok(err));
     }
@@ -457,7 +457,7 @@ static void get_link(uint8_t port)
     memcpy(&fcntl[port], out+CMD_GET_LINK_OUT_FCNTL_OFFSET, 4);
     memcpy(&flags[port], out+CMD_GET_LINK_OUT_FLAGS_OFFSET, 4);
    
-    decode_link(fcntl[port], flags[port], speed[port]);     
+    decode_link(fcntl[port], flags[port], speed[port]);
 
 }
 
@@ -472,7 +472,7 @@ static void init_port(uint8_t port)
     memcpy(in + CMD_SET_MAC_IN_ADR_OFFSET, &d_mac[port], 6 );
     /* linux driver sets these bits */
     in[14] = 0xFF;
-    in[15] = 0xFF; 
+    in[15] = 0xFF;
     /* set MTU */
     reg = MTU_MAX;
     memcpy(in + CMD_SET_MAC_IN_MTU_OFFSET , &reg, 4);
@@ -510,27 +510,27 @@ static void start_port(uint8_t port)
     assert(err_is_ok(err));
 
     /* mac address */
-    memcpy(in + CMD_SET_MAC_IN_ADR_OFFSET, &d_mac[port], 6 ); 
-    /* seems like the linux driver sets all bits not set 
+    memcpy(in + CMD_SET_MAC_IN_ADR_OFFSET, &d_mac[port], 6 );
+    /* seems like the linux driver sets all bits not set
        from the MAC address to 1*/
     in[14] = 0xFF;
-    in[15] = 0xFF; 
+    in[15] = 0xFF;
     /* set MTU*/
-    reg = MTU_MAX; 
+    reg = MTU_MAX;
     memcpy(in + CMD_SET_MAC_IN_MTU_OFFSET , &reg, 4);
     in[CMD_SET_MAC_IN_DRAIN_OFFSET] = 0;
     /* Reject unicast packets ?  */
     in[CMD_SET_MAC_IN_REJECT_OFFSET] = 1;
-    /* Set wanted functionality (flow control) of card -> set to 2 for RX/TX 
+    /* Set wanted functionality (flow control) of card -> set to 2 for RX/TX
        And on*/
     in[CMD_SET_MAC_IN_FCTNL_OFFSET] = 2;
     err = mcdi_rpc(CMD_SET_MAC, in, CMD_SET_MAC_IN_LEN, NULL, 0, NULL, port, d);
-    assert(err_is_ok(err));   
+    assert(err_is_ok(err));
 
     err = mcdi_rpc(CMD_SET_MCAST_HASH, mc_hash , CMD_SET_MCAST_HASH_IN_LEN,
                    NULL, 0 , NULL, port, d);
 
-    assert(err_is_ok(err));   
+    assert(err_is_ok(err));
 }
 
 /******************************************************************************
@@ -538,7 +538,7 @@ static void start_port(uint8_t port)
  *****************************************************************************/
 
 static void probe_all(void)
-{   
+{
     uint32_t offset = 0;
     uint32_t outlen = 0;
     
@@ -551,7 +551,7 @@ static void probe_all(void)
     errval_t r;
 
     // init MCDI
-    init_mcdi_mutex();  
+    init_mcdi_mutex();
     // Test and clear MC-reboot flag for port/function
     offset = MCDI_REBOOT_OFFSET(pci_function);
     reg =  sfn5122f_mc_treg_smem_rd(d,offset);
@@ -576,7 +576,7 @@ static void probe_all(void)
     // driver is operating / + update
     in[0] = 0x1;
     in[4] = 0x1;
-    r = mcdi_rpc(CMD_DRV_ATTACH, in, CMD_DRV_ATTACH_IN_LEN, out, 
+    r = mcdi_rpc(CMD_DRV_ATTACH, in, CMD_DRV_ATTACH_IN_LEN, out,
                  CMD_DRV_ATTACH_OUT_LEN, &outlen, pci_function, d);
     assert(err_is_ok(r));
 
@@ -584,8 +584,8 @@ static void probe_all(void)
     r = mcdi_rpc(CMD_PORT_RESET, NULL, 0, NULL, 0, NULL, pci_function, d);
     assert(err_is_ok(r));
 
-    // init WoL Filter 
-    if(mcdi_rpc(CMD_WOL_FILTER_GET, NULL, 0, out, CMD_WOL_FILTER_GET_OUT_LEN, 
+    // init WoL Filter
+    if(mcdi_rpc(CMD_WOL_FILTER_GET, NULL, 0, out, CMD_WOL_FILTER_GET_OUT_LEN,
        &outlen, pci_function, d) == SYS_ERR_OK) {
         memcpy(&wol_filter_id, out , 4);
     } else {
@@ -593,21 +593,21 @@ static void probe_all(void)
       mcdi_rpc(CMD_WOL_FILTER_RESET, NULL, 0, NULL, 0, NULL, pci_function, d);
     }
  
-    //  memory for INT_KER 
-    int_ker_virt = alloc_map_frame(VREGION_FLAGS_READ_WRITE, 
+    //  memory for INT_KER
+    int_ker_virt = alloc_map_frame(VREGION_FLAGS_READ_WRITE,
                                    2*sizeof(uint64_t), &int_ker);
     memset(int_ker_virt, 0, 2*sizeof(uint64_t));
     // Read in non volatile configuration
     memset(&out, 0, sizeof(out));
     r = mcdi_rpc(CMD_GET_BOARD_CONFIG, NULL, 0, out,
-                 CMD_GET_BOARD_CONFIG_OUT_LEN, &outlen, pci_function, d); 
+                 CMD_GET_BOARD_CONFIG_OUT_LEN, &outlen, pci_function, d);
     assert(err_is_ok(r));
 
-    memcpy(&d_mac[0], out+MCDI_MAC_PORT_OFFSET(0) ,6);  
-    memcpy(&d_mac[1], out+MCDI_MAC_PORT_OFFSET(1) ,6);  
+    memcpy(&d_mac[0], out+MCDI_MAC_PORT_OFFSET(0) ,6);
+    memcpy(&d_mac[1], out+MCDI_MAC_PORT_OFFSET(1) ,6);
     
-    // read phy configuration  
-    r = mcdi_rpc(CMD_GET_PHY_CFG, NULL, 0, out, CMD_GET_PHY_CFG_OUT_LEN, &outlen, 
+    // read phy configuration
+    r = mcdi_rpc(CMD_GET_PHY_CFG, NULL, 0, out, CMD_GET_PHY_CFG_OUT_LEN, &outlen,
                  pci_function, d);
     assert(err_is_ok(r));
 
@@ -616,7 +616,7 @@ static void probe_all(void)
     memcpy(&phy_media[pci_function], out+CMD_GET_PHY_CFG_OUT_MEDIA_OFFSET, 4);
 
     // get loopback modes
-    r = mcdi_rpc(CMD_GET_LOOPBACK_MODES, NULL, 0, out, 
+    r = mcdi_rpc(CMD_GET_LOOPBACK_MODES, NULL, 0, out,
                  CMD_GET_LOOPBACK_MODES_OUT_LEN, &outlen, pci_function, d);
     assert(err_is_ok(r));
     memcpy(&phy_loopback_mode, out+CMD_GET_LOOPBACK_MODES_SUGGESTED_OFFSET,4);
@@ -625,8 +625,8 @@ static void probe_all(void)
    
 
     // MAC STATS INIT
-    mac_virt = alloc_map_frame(VREGION_FLAGS_READ_WRITE, 
-                               NUM_MAC_STATS*sizeof(uint64_t), 
+    mac_virt = alloc_map_frame(VREGION_FLAGS_READ_WRITE,
+                               NUM_MAC_STATS*sizeof(uint64_t),
                                &mac_stats);
 
     assert(mac_virt != NULL);
@@ -640,11 +640,11 @@ static void probe_all(void)
     memcpy(in, &mac_phys, 8);
 
      // Settings for DMA of MAC stats
-    in[CMD_MAC_STATS_IN_CMD_OFFSET] = 0x6;    
+    in[CMD_MAC_STATS_IN_CMD_OFFSET] = 0x6;
     in[CMD_MAC_STATS_IN_DMA_LEN_OFFSET] = 8;
     in[CMD_MAC_STATS_IN_DMA_LEN_OFFSET+1] = 3;
-    r = mcdi_rpc(CMD_MAC_STATS, in, CMD_MAC_STATS_IN_LEN, NULL, 0, NULL, 
-                pci_function, d); 
+    r = mcdi_rpc(CMD_MAC_STATS, in, CMD_MAC_STATS_IN_LEN, NULL, 0, NULL,
+                pci_function, d);
     assert(err_is_ok(r));
 
 }
@@ -656,7 +656,7 @@ static void init_rx_filter_config(void)
 {
     uint64_t reg_hi, reg_lo;
 
-    for (int i = 0; i < NUM_FILTERS_IP; i++) {   
+    for (int i = 0; i < NUM_FILTERS_IP; i++) {
         sfn5122f_rx_filter_tbl_lo_wr(d, i, 0);
         sfn5122f_rx_filter_tbl_hi_wr(d, i, 0);
     }
@@ -689,7 +689,7 @@ static void device_init(void)
     errval_t r;
     struct frame_identity frameid = { .base = 0, .bytes = 0 };
     uint64_t reg, reg2; // tmp_key = 0;
-    uint8_t in[24]; // set length to biggest in length needed 
+    uint8_t in[24]; // set length to biggest in length needed
 
     memset(&in, 0, sizeof(in));
 
@@ -712,7 +712,7 @@ static void device_init(void)
     reg = sfn5122f_rx_cfg_reg_lo_rd(d);
     // unset bit and set other bit which are not in documentation (43 and 47)
     reg = sfn5122f_rx_cfg_reg_lo_rx_desc_push_en_insert(reg, 0) ;
-    reg = sfn5122f_rx_cfg_reg_lo_rx_ingr_en_insert(reg, 1); 
+    reg = sfn5122f_rx_cfg_reg_lo_rx_ingr_en_insert(reg, 1);
     reg = sfn5122f_rx_cfg_reg_lo_rx_usr_buf_size_insert(reg, (MTU_MAX-256) >> 5);
     //reg = sfn5122f_rx_cfg_reg_lo_rx_usr_buf_size_insert(reg, 4096 >> 5);
     //reg = sfn5122f_rx_cfg_reg_lo_rx_ownerr_ctl_insert(reg, 1);
@@ -724,8 +724,8 @@ static void device_init(void)
     /* enable event logging, no UART
       Event destination is queue 0 */
     in[0] = 0x2;
-    r = mcdi_rpc(CMD_LOG_CTRL, in, CMD_LOG_CTRL_IN_LEN, 
-                 NULL, 0, NULL, pci_function, d);    
+    r = mcdi_rpc(CMD_LOG_CTRL, in, CMD_LOG_CTRL_IN_LEN,
+                 NULL, 0, NULL, pci_function, d);
     assert(err_is_ok(r));
 
     /* Set destination of TX/RX flush event */
@@ -734,11 +734,11 @@ static void device_init(void)
     sfn5122f_dp_ctrl_reg_hi_wr(d, sfn5122f_dp_ctrl_reg_hi_rd(d));
   
     /* Disalbe user events for now     */
-    sfn5122f_usr_ev_cfg_lo_usrev_dis_wrf(d , 1);  
-    sfn5122f_usr_ev_cfg_hi_wr(d, sfn5122f_usr_ev_cfg_hi_rd(d));    
+    sfn5122f_usr_ev_cfg_lo_usrev_dis_wrf(d , 1);
+    sfn5122f_usr_ev_cfg_hi_wr(d, sfn5122f_usr_ev_cfg_hi_rd(d));
 
 
-    // This seems to be not device specific i.e. works for other 
+    // This seems to be not device specific i.e. works for other
     // Solarflare cards
     /* Set position of descriptor caches in SRAM */
     sfn5122f_srm_tx_dc_cfg_reg_lo_wr(d, TX_DC_BASE);
@@ -781,8 +781,8 @@ static void device_init(void)
    
     /* Enable all the genuinley fatal interrupts */
     reg = sfn5122f_fatal_intr_reg_ker_lo_ill_adr_int_ker_en_insert(reg, 1);
-    /* Enable rxbuf/txbuf interrupt  fields not documented. 
-       Set bits 39 and 38*/           
+    /* Enable rxbuf/txbuf interrupt  fields not documented.
+       Set bits 39 and 38*/
     reg = sfn5122f_fatal_intr_reg_ker_lo_rxbuf_own_int_ker_en_insert(reg, 1);
     reg = sfn5122f_fatal_intr_reg_ker_lo_txbuf_own_int_ker_en_insert(reg, 1);
     
@@ -800,7 +800,7 @@ static void device_init(void)
      * controlled by the RX FIFO fill level. Set arbitration to one pkt/Q.
       (from linux driver) */
     reg = sfn5122f_tx_reserved_reg_lo_rd(d);
-    reg = sfn5122f_tx_reserved_reg_lo_tx_rx_spacer_en_insert(reg, 1);  
+    reg = sfn5122f_tx_reserved_reg_lo_tx_rx_spacer_en_insert(reg, 1);
     reg = sfn5122f_tx_reserved_reg_lo_tx_one_pkt_per_q_insert(reg, 1);
     reg = sfn5122f_tx_reserved_reg_lo_tx_dis_non_ip_ev_insert(reg, 1);
 
@@ -816,7 +816,7 @@ static void device_init(void)
     reg2 = sfn5122f_tx_reserved_reg_hi_rd(d);
     reg2 = sfn5122f_tx_reserved_reg_hi_tx_push_en_insert(reg2, 0);
     reg2 = sfn5122f_tx_reserved_reg_hi_tx_push_chk_dis_insert(reg2, 0);
-    reg2 = sfn5122f_tx_reserved_reg_hi_tx_rx_spacer_insert(reg2, 0xfe); 
+    reg2 = sfn5122f_tx_reserved_reg_hi_tx_rx_spacer_insert(reg2, 0xfe);
     sfn5122f_tx_reserved_reg_lo_wr(d, reg);
     sfn5122f_tx_reserved_reg_hi_wr(d, reg2);
 
@@ -829,7 +829,7 @@ static void start_all(void)
 {
     uint64_t reg;
     uint8_t in[CMD_MAC_STATS_IN_LEN];
-    unsigned long long* stats = (unsigned long long *) mac_virt;    
+    unsigned long long* stats = (unsigned long long *) mac_virt;
     uint8_t* pointer;
  
     start_port(pci_function);
@@ -854,15 +854,15 @@ static void start_all(void)
     /* Start MAC stats            */
     memset(in, 0, sizeof(in));
     stats[0x60] = (unsigned long long) (-1);
-    memcpy(in, &mac_phys, 8);  
+    memcpy(in, &mac_phys, 8);
     pointer = (uint8_t *) &mac_phys;
     in[CMD_MAC_STATS_IN_CMD_OFFSET] = 0xD;
     in[10] = 0xE8;
     in[11] = 3;
     in[CMD_MAC_STATS_IN_DMA_LEN_OFFSET] = 8;
     in[CMD_MAC_STATS_IN_DMA_LEN_OFFSET+1] = 3;
-    errval_t err = mcdi_rpc(CMD_MAC_STATS, in, CMD_MAC_STATS_IN_LEN, 
-                            NULL, 0, NULL, pci_function, d); 
+    errval_t err = mcdi_rpc(CMD_MAC_STATS, in, CMD_MAC_STATS_IN_LEN,
+                            NULL, 0, NULL, pci_function, d);
     assert(err_is_ok(err));
 }
 
@@ -898,14 +898,14 @@ static void queue_hw_stop(uint16_t n)
     /*Free RX queue tbl entries*/
     reg = 0;
     reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_cmd_insert(reg, 1);
-    reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_start_id_insert(reg, 
+    reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_start_id_insert(reg,
                                               queues[n].rx_buf_tbl);
 
     if (queues[n].userspace) {
-       reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_end_id_insert(reg, 
+       reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_end_id_insert(reg,
                                   queues[n].rx_buf_tbl + NUM_ENT_RX_USR);
     } else {
-        reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_end_id_insert(reg, 
+        reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_end_id_insert(reg,
                                        queues[n].rx_buf_tbl + NUM_ENT_RX);
     }
 
@@ -914,7 +914,7 @@ static void queue_hw_stop(uint16_t n)
     reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_cmd_insert(reg, 1);
     reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_end_id_insert(reg,
                               queues[n].tx_buf_tbl + NUM_ENT_TX );
-    reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_start_id_insert(reg, 
+    reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_start_id_insert(reg,
                                               queues[n].tx_buf_tbl);
 
     /*Free EV queue tbl entries*/
@@ -922,7 +922,7 @@ static void queue_hw_stop(uint16_t n)
     reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_cmd_insert(reg, 1);
     reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_end_id_insert(reg,
                               queues[n].ev_buf_tbl + NUM_ENT_EVQ );
-    reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_start_id_insert(reg, 
+    reg = sfn5122f_buf_tbl_upd_reg_lo_buf_clr_start_id_insert(reg,
                                              queues[n].ev_buf_tbl);
 }
 
@@ -931,7 +931,7 @@ static void queue_hw_stop(uint16_t n)
 static uint32_t init_evq(uint16_t n, lpaddr_t phys)
 {
 
-    //errval_t r; 
+    //errval_t r;
     //struct frame_identity frameid = { .base = 0, .bytes = 0 };
     uint64_t reg, buffer_offset;
     reg = 0;
@@ -945,7 +945,7 @@ static uint32_t init_evq(uint16_t n, lpaddr_t phys)
         reg = sfn5122f_timer_tbl_lo_int_armd_insert(reg, 0);
         reg = sfn5122f_timer_tbl_lo_host_notify_mode_insert(reg, 1);
     }
-    // timer mode disabled 
+    // timer mode disabled
     reg = sfn5122f_timer_tbl_lo_timer_mode_insert(reg, 0);
     sfn5122f_timer_tbl_lo_wr(d, n, reg);
     sfn5122f_timer_tbl_hi_wr(d, n, sfn5122f_timer_tbl_hi_rd(d, n));
@@ -967,18 +967,18 @@ static uint32_t init_evq(uint16_t n, lpaddr_t phys)
     reg = sfn5122f_evq_ptr_tbl_lo_evq_en_insert(reg, 1);
     reg = sfn5122f_evq_ptr_tbl_lo_evq_size_insert(reg, 3);
     reg = sfn5122f_evq_ptr_tbl_lo_evq_buf_base_id_insert(reg,
-           buffer_offset);   
+           buffer_offset);
 
     sfn5122f_evq_ptr_tbl_lo_wr(d, n, reg);
     sfn5122f_evq_ptr_tbl_hi_wr(d, n, sfn5122f_evq_ptr_tbl_hi_rd(d, n));
 
-    /* No write collection for this register   */ 
+    /* No write collection for this register   */
     reg = sfn5122f_timer_command_reg_lo_rd(d,n);
     reg = sfn5122f_timer_command_reg_lo_tc_timer_val_insert(reg, 0);
     if (use_msix) {
-        reg = sfn5122f_timer_command_reg_lo_tc_timer_mode_insert(reg, 0); 
+        reg = sfn5122f_timer_command_reg_lo_tc_timer_mode_insert(reg, 0);
     } else {
-        reg = sfn5122f_timer_command_reg_lo_tc_timer_mode_insert(reg, 0); 
+        reg = sfn5122f_timer_command_reg_lo_tc_timer_mode_insert(reg, 0);
     }
 
     sfn5122f_timer_command_reg_lo_wr(d, n, reg);
@@ -1004,7 +1004,7 @@ static uint32_t init_rxq(uint16_t n, lpaddr_t phys, bool userspace)
     r = invoke_frame_identify(queues[n].rx_frame, &frameid);
     assert(err_is_ok(r));
     rx_phys = frameid.base;
-    rx_size = frameid.bytes;  
+    rx_size = frameid.bytes;
     */
     if (userspace) {
         num_ent_rx = NUM_ENT_RX_USR;
@@ -1019,7 +1019,7 @@ static uint32_t init_rxq(uint16_t n, lpaddr_t phys, bool userspace)
        return -1;
     }
 
-    DEBUG("RX_QUEUE_%d: buf_off %ld, phys %lx, size %lx \n", n, 
+    DEBUG("RX_QUEUE_%d: buf_off %ld, phys %lx, size %lx \n", n,
           buffer_offset, phys, rx_size);
     /* setup RX queue */
     reg_lo = sfn5122f_rx_desc_ptr_tbl_lo_rd(d, n);
@@ -1052,7 +1052,7 @@ static uint32_t init_rxq(uint16_t n, lpaddr_t phys, bool userspace)
    
     /*   Hardware verifies data digest  */
     reg_hi = sfn5122f_rx_desc_ptr_tbl_hi_rx_iscsi_ddig_en_insert(reg_hi, 1);
-    reg_hi = sfn5122f_rx_desc_ptr_tbl_hi_rx_iscsi_hdig_en_insert(reg_hi, 1);  
+    reg_hi = sfn5122f_rx_desc_ptr_tbl_hi_rx_iscsi_hdig_en_insert(reg_hi, 1);
 
     sfn5122f_rx_desc_ptr_tbl_lo_wr(d, n, reg_lo);
     sfn5122f_rx_desc_ptr_tbl_hi_wr(d, n, reg_hi);
@@ -1061,13 +1061,13 @@ static uint32_t init_rxq(uint16_t n, lpaddr_t phys, bool userspace)
 }
 
 
-static uint32_t init_txq(uint16_t n, uint64_t phys,                        
+static uint32_t init_txq(uint16_t n, uint64_t phys,
                          bool csum, bool userspace)
 {
 
     //errval_t r;
     //struct frame_identity frameid = { .base = 0, .bytes = 0 };
-    uint64_t reg, reg1, buffer_offset;    
+    uint64_t reg, reg1, buffer_offset;
   
     buffer_offset = alloc_buf_tbl_entries(phys, NUM_ENT_TX, 0, 0, d);
     
@@ -1114,7 +1114,7 @@ static uint32_t init_txq(uint16_t n, uint64_t phys,
     sfn5122f_tx_desc_ptr_tbl_lo_wr(d, n, reg);
     sfn5122f_tx_desc_ptr_tbl_hi_wr(d, n, reg1);
  
-    return buffer_offset; 
+    return buffer_offset;
 }
 
 
@@ -1143,22 +1143,22 @@ static void global_interrupt_handler(void* arg)
     //uint64_t reg;
     uint32_t queue;
     errval_t syserr;
-    uint8_t* net_ivec_fatal = (uint8_t *) int_ker_virt;    
+    uint8_t* net_ivec_fatal = (uint8_t *) int_ker_virt;
 
-    // bit 64 is indicator for a fatal event 
+    // bit 64 is indicator for a fatal event
     syserr = (net_ivec_fatal[8] & 0x1);
     if (syserr) {
         // TODO handle fatal interrupt
-        USER_PANIC("FATAL INTERRUPT");   
+        USER_PANIC("FATAL INTERRUPT");
     } else {
 
     }
 
     queue = sfn5122f_int_isr0_reg_lo_rd(d);
     DEBUG("AN INTERRUPT OCCURED %d \n", queue);
-    // Don't need to start event queues because we're already polling 
+    // Don't need to start event queues because we're already polling
 
-} 
+}
 /******************************************************************************/
 /* Management interface implemetation */
 
@@ -1196,15 +1196,6 @@ static void idc_write_queue_tails(struct sfn5122f_binding *b)
     assert(err_is_ok(r));
 }
 
-/** Signal queue driver that the queue is stopped. */
-static void idc_queue_terminated(struct sfn5122f_binding *b)
-{
-    errval_t r;
-    r = sfn5122f_queue_terminated__tx(b, NOP_CONT);
-    // TODO: handle busy
-    assert(err_is_ok(r));
-}
-
 /** Request from queue driver for register memory cap */
 void cd_request_device_info(struct sfn5122f_binding *b)
 {
@@ -1222,14 +1213,14 @@ void cd_register_queue_memory(struct sfn5122f_binding *b,
                               struct capref rx_frame,
                               struct capref ev_frame,
                               uint32_t rxbufsz,
-                              bool use_irq, 
+                              bool use_irq,
                               bool userspace,
                               uint8_t vector,
                               uint16_t core)
 {
     // Save state so we can restore the configuration in case we need to do a
     // reset
-    errval_t err;    
+    errval_t err;
 
     bool failed = 0;
     queues[n].enabled = false;
@@ -1269,7 +1260,7 @@ void cd_register_queue_memory(struct sfn5122f_binding *b,
        failed = 1;
        DEBUG("Allocating queue failed \n");
        return;
-    }      
+    }
 
     queues[n].enabled = true;
 
@@ -1279,10 +1270,10 @@ void cd_register_queue_memory(struct sfn5122f_binding *b,
                 setup_interrupt(&queues[n].msix_index, queues[n].msix_intdest,
                                 queues[n].msix_intvec);
             }
-        } 
+        }
     }
 
-    idc_write_queue_tails(queues[n].binding);     
+    idc_write_queue_tails(queues[n].binding);
 
     if (b == NULL) {
         qd_queue_memory_registered(b);
@@ -1297,7 +1288,7 @@ void cd_register_queue_memory(struct sfn5122f_binding *b,
     }
 }
 
-static void idc_terminate_queue(struct sfn5122f_binding *b, uint16_t n)
+static errval_t idc_terminate_queue(struct sfn5122f_binding *b, uint16_t n)
 {
   DEBUG("idc_terminate_queue(q=%d) \n", n);
   
@@ -1306,44 +1297,19 @@ static void idc_terminate_queue(struct sfn5122f_binding *b, uint16_t n)
   queues[n].enabled = false;
   queues[n].binding = NULL;
 
-  idc_queue_terminated(b);
-
+  return SYS_ERR_OK;
 }
 
 
 
-/** Send response about filter registration to device manager */
-static void idc_filter_registered(struct sfn5122f_binding *b,
-                                  uint64_t buf_id_rx,
-                                  uint64_t buf_id_tx,
-                                  errval_t err,
-                                  uint64_t filter)
-{
-    errval_t r;
-    r = sfn5122f_filter_registered__tx(b, NOP_CONT, buf_id_rx, buf_id_tx, err,
-                                   filter);
-    // TODO: handle busy
-    assert(err_is_ok(r));
-}
-
-/** Send response about filter deregistration to device manager */
-static void idc_filter_unregistered(struct sfn5122f_binding *b,
-                                    uint64_t filter,
-                                    errval_t err)
-{
-    errval_t r;
-    r = sfn5122f_filter_unregistered__tx(b, NOP_CONT, filter, err);
-    // TODO: handle busy
-    assert(err_is_ok(r));
-}
-
-
-static void idc_register_port_filter(struct sfn5122f_binding *b,
+static errval_t idc_register_port_filter(struct sfn5122f_binding *b,
                                      uint64_t buf_id_rx,
                                      uint64_t buf_id_tx,
                                      uint16_t queue,
                                      sfn5122f_port_type_t type,
-                                     uint16_t port)
+                                     uint16_t port,
+                                     errval_t *err,
+                                     uint64_t *fid)
 {
     DEBUG("idc_register_port_filter: called (q=%d t=%d p=%d)\n",
             queue, type, port);
@@ -1364,33 +1330,35 @@ static void idc_register_port_filter(struct sfn5122f_binding *b,
             .queue = queue,
     };
 
-    errval_t err;
-    uint64_t fid = -1ULL;
 
-    err = reg_port_filter(&f, &fid);
-    DEBUG("filter registered: err=%"PRIu64", fid=%"PRIu64"\n", err, fid);
+    *err = reg_port_filter(&f, fid);
+    DEBUG("filter registered: err=%"PRIu64", fid=%"PRIu64"\n", *err, *fid);
 
-    idc_filter_registered(b, buf_id_rx, buf_id_tx, err, fid);
+    return SYS_ERR_OK;
 }
 
 
-static void idc_unregister_filter(struct sfn5122f_binding *b,
-                                  uint64_t filter)
+static errval_t idc_unregister_filter(struct sfn5122f_binding *b,
+                                  uint64_t filter, errval_t *err)
 {
     DEBUG("unregister_filter: called (%"PRIx64")\n", filter);
-    idc_filter_unregistered(b, filter, LIB_ERR_NOT_IMPLEMENTED);
+    *err = LIB_ERR_NOT_IMPLEMENTED;
+    return SYS_ERR_OK;
 }
 
 static struct sfn5122f_rx_vtbl rx_vtbl = {
     .request_device_info = cd_request_device_info,
     .register_queue_memory = cd_register_queue_memory,
-    .terminate_queue = idc_terminate_queue,
-    .register_port_filter = idc_register_port_filter,
-    .unregister_filter = idc_unregister_filter, 
+};
+
+static struct sfn5122f_rpc_rx_vtbl rpc_rx_vtbl = {
+    .terminate_queue_call = idc_terminate_queue,
+    .register_port_filter_call = idc_register_port_filter,
+    .unregister_filter_call = idc_unregister_filter,
 };
 
 static void cd_create_queue(struct sfn5122f_devif_binding *b, struct capref frame,
-                            bool user, bool interrupt, uint8_t core, uint8_t msix_vector) 
+                            bool user, bool interrupt, uint8_t core, uint8_t msix_vector)
 {
     DEBUG("cd_create_queue \n");
     errval_t err;
@@ -1430,7 +1398,7 @@ static void cd_create_queue(struct sfn5122f_devif_binding *b, struct capref fram
                 setup_interrupt(&queues[n].msix_index, queues[n].msix_intdest,
                                 queues[n].msix_intvec);
             }
-        } 
+        }
     }
 
     err = invoke_frame_identify(frame, &id);
@@ -1447,7 +1415,7 @@ static void cd_create_queue(struct sfn5122f_devif_binding *b, struct capref fram
         //err = b->tx_vtbl.create_queue_response(b, NOP_CONT, 0, err);
         err = b->tx_vtbl.create_queue_response(b, NOP_CONT, 0, NULL_CAP, err);
         assert(err_is_ok(err));
-    }      
+    }
 
     queues[n].enabled = true;
     DEBUG("created queue %d \n", n);
@@ -1464,12 +1432,12 @@ static void cd_create_queue(struct sfn5122f_devif_binding *b, struct capref fram
     DEBUG("cd_create_queue end\n");
 }
 
-static void cd_register_region(struct sfn5122f_devif_binding *b, uint16_t qid, 
-                               struct capref region) 
+static void cd_register_region(struct sfn5122f_devif_binding *b, uint16_t qid,
+                               struct capref region)
 {
     errval_t err;
     struct frame_identity id;
-    uint64_t buffer_offset = 0;    
+    uint64_t buffer_offset = 0;
 
     err = invoke_frame_identify(region, &id);
     if (err_is_fail(err)) {
@@ -1493,7 +1461,7 @@ static void cd_register_region(struct sfn5122f_devif_binding *b, uint16_t qid,
 
 
 static void cd_deregister_region(struct sfn5122f_devif_binding *b, uint64_t buftbl_id,
-                                 uint64_t size) 
+                                 uint64_t size)
 {
     errval_t err;
     free_buf_tbl_entries(buftbl_id, size/BUF_SIZE, d);
@@ -1512,7 +1480,7 @@ static void cd_destroy_queue(struct sfn5122f_devif_binding *b, uint16_t qid)
 
     err = b->tx_vtbl.destroy_queue_response(b, NOP_CONT, SYS_ERR_OK);
     assert(err_is_ok(err));
-} 
+}
 
 
 static struct sfn5122f_devif_rx_vtbl rx_vtbl_devif = {
@@ -1542,6 +1510,7 @@ static errval_t connect_cb(void *st, struct sfn5122f_binding *b)
 {
     DEBUG("New connection on management interface\n");
     b->rx_vtbl = rx_vtbl;
+    b->rpc_rx_vtbl = rpc_rx_vtbl;
     return SYS_ERR_OK;
 }
 
@@ -1677,12 +1646,12 @@ static void pci_init_card(struct device_mem* bar_info, int bar_count)
     /* Get all information needed  */
     probe_all();
     /* Initialize hardware registers etc. */
-    /* Start interrups / mac_stats etc.  */   
+    /* Start interrups / mac_stats etc.  */
     device_init();
     /* Init rx filters */
     init_rx_filter_config();
     /* initalize managemnt interface   */
-    initialize_mngif();  
+    initialize_mngif();
     initialized = true;
 
     if (first){
@@ -1744,9 +1713,9 @@ int main(int argc, char** argv)
     r = pci_client_connect();
     assert(err_is_ok(r));
     r = pci_register_driver_irq(pci_init_card, PCI_CLASS_ETHERNET,
-                                PCI_DONT_CARE, PCI_DONT_CARE, 
+                                PCI_DONT_CARE, PCI_DONT_CARE,
                                 PCI_VENDOR_SOLARFLARE, DEVICE_ID,
-                                pci_bus, pci_device, pci_function, 
+                                pci_bus, pci_device, pci_function,
                                 global_interrupt_handler, NULL);
 
     while (!initialized) {