DeviceQueue: changed signature of setup
authorRoni Häcki <roni.haecki@inf.ethz.ch>
Wed, 14 Sep 2016 13:07:12 +0000 (15:07 +0200)
committerRoni Häcki <roni.haecki@inf.ethz.ch>
Wed, 14 Sep 2016 13:07:12 +0000 (15:07 +0200)
Signed-off-by: Roni Häcki <roni.haecki@inf.ethz.ch>

if/devif_ctrl.if
include/devif/loopback_device.h
include/devif/queue_interface.h
lib/devif/loopback_device.c
lib/devif/queue_interface.c
usr/drivers/solarflare/sfn5122f_cdriver.c
usr/tests/devif/queue_interface.c

index 4fa4480..fd6419a 100644 (file)
 
 interface devif_ctrl "Device Queue Interface Control Plane" {
     /* Setup before we can create the queue on both sides */
-    rpc setup(out uint64 features, out uint32 default_qsize,
-              out uint32 default_bufsize, out bool reconnect,
-              out String name[256]);
+    // in coreid is the coreid of the client side
+    // 
+    rpc setup(in uint32 coreid, in uint64 flags, out uint64 features, 
+              out uint32 default_qsize, out uint32 default_bufsiz,      
+              out bool reconnect, out String reconnect_name[256]);
 
     /* Create a device queue */
-    rpc create(in cap rx, in cap tx, in uint64 flags, in uint64 size,
-               out errval err);
+    rpc create(in cap rx, in cap tx, in uint64 flags,
+               in uint64 size, out errval err);
 
     
     /* Destroy a device queue */
index 5a48ba2..7e07e33 100644 (file)
@@ -14,9 +14,9 @@
 #include "queue_interface.h"
 
 // Loopback device functions
-errval_t devq_loopback_setup(uint64_t *features, uint32_t* default_qsize, 
-                             uint32_t* default_bufsize, bool* reconnect, 
-                             char* name);
+errval_t devq_loopback_setup(uint32_t coreid, uint64_t flags, uint64_t *features, 
+                             uint32_t* default_qsize, uint32_t* default_bufsize, 
+                             bool* reconnect, char* name);
 errval_t devq_loopback_destroy(struct devq *q);
 
 errval_t devq_loopback_create(struct devq *q, uint64_t flags);   
index b35c187..3d84879 100644 (file)
@@ -28,6 +28,7 @@
 #define DEVQ_BUF_FLAG_TX 0x1
 #define DEVQ_BUF_FLAG_RX 0x2
 #define DEVQ_BUF_FLAG_TX_LAST 0x4
+#define DEVQ_SETUP_FLAGS_DIRECT 0x1
 
 #define DEVQ_FEATURE_DIRECT 0x1
 
@@ -56,6 +57,8 @@ struct devq_buf{
  /**
   * @brief Setup function called on the device side
   *
+  * @param coreid           The core the client side is running on
+  * @param flags            Flags to prepare for create
   * @param features         Return pointer to the features of the device
   * @param default_qsize    Return pointer to the default hardware device 
   *                         queue size
@@ -68,7 +71,8 @@ struct devq_buf{
   *
   * @returns error on failure or SYS_ERR_OK on success
   */
-typedef errval_t (*devq_setup_t)(uint64_t *features, uint32_t* default_qsize, 
+typedef errval_t (*devq_setup_t)(uint32_t coreid, uint64_t flags,
+                                 uint64_t *features, uint32_t* default_qsize, 
                                  uint32_t* default_bufsize, bool* reconnect, char* name);
 
  /**
index d8f88d7..01b143e 100644 (file)
@@ -14,7 +14,8 @@
 
 
 // Loopback device functions
-errval_t devq_loopback_setup(uint64_t *features, uint32_t* default_qsize, 
+errval_t devq_loopback_setup(uint32_t coreid, uint64_t flags,   
+                             uint64_t *features, uint32_t* default_qsize, 
                              uint32_t* default_bufsize, bool* reconnect, 
                              char* name)
 {
index 0e22456..50558e5 100644 (file)
@@ -84,14 +84,15 @@ static errval_t devq_init_descqs(struct devq *q, struct capref rx,
 // Message Passing functions
 // ...
 
-static void mp_setup_request(struct devif_ctrl_binding* b)
+static void mp_setup_request(struct devif_ctrl_binding* b, uint32_t coreid,
+                             uint64_t flags)
 {
-    DQI_DEBUG("setup_request\n");
+    DQI_DEBUG("setup_request coreid=%d flags=%lu\n", coreid, flags);
     errval_t err;
     uint64_t features;
     uint32_t default_qsize, default_bufsize;
-    bool reconnect;
-    char name[MAX_DEVICE_NAME];
+    char reconnect_name[MAX_DEVICE_NAME];
+    bool reconnect = false;
 
     struct endpoint_state* state = (struct endpoint_state*) b->st;
 
@@ -101,15 +102,14 @@ static void mp_setup_request(struct devif_ctrl_binding* b)
         reconnect = false;
     } else {
 
-        err = state->f.setup(&features, &default_qsize, &default_bufsize, 
-                             &reconnect, name);
+        err = state->f.setup(coreid, flags, &features, &default_qsize, 
+                             &default_bufsize, &reconnect, reconnect_name);
         assert(err_is_ok(err));    
     }
 
 
     err = b->tx_vtbl.setup_response(b, NOP_CONT, features, default_qsize,
-                                    default_bufsize, reconnect, 
-                                    name);
+                                    default_bufsize, reconnect, reconnect_name);
     assert(err_is_ok(err));
 
 }
@@ -568,6 +568,7 @@ errval_t devq_create(struct devq **q,
             tmp->data = tmp->end->data;
             break;
         case ENDPOINT_TYPE_DIRECT:
+            flags = flags | DEVQ_SETUP_FLAGS_DIRECT;
             err = devq_init_direct(tmp, flags);
             if (err_is_fail(err)) {
                 return err;
@@ -787,7 +788,8 @@ static errval_t devq_init_user(struct devq *q,
         return err;
     }
 
-    err = q->ctrl_rpc->vtbl.setup(q->ctrl_rpc, &q->end->features, &q->q_size, 
+    err = q->ctrl_rpc->vtbl.setup(q->ctrl_rpc, disp_get_core_id(), flags,
+                                  &q->end->features, &q->q_size, 
                                   &q->buf_size, &q->reconnect, q->reconnect_name);
     if (err_is_fail(err)) {
         return err;
@@ -815,15 +817,14 @@ static errval_t devq_init_user(struct devq *q,
         }
     }
 
-
-    q->state = DEVQ_STATE_CONNECTED;
-
-    err = q->ctrl_rpc->vtbl.create(q->ctrl_rpc, rx, tx, flags, DESCQ_DEFAULT_SIZE,
-                                   &q->err);
+    err = q->ctrl_rpc->vtbl.create(q->ctrl_rpc, rx, tx, flags, 
+                                   DESCQ_DEFAULT_SIZE, &q->err);
     if (err_is_fail(err) || err_is_fail(q->err)) {
         return err_is_fail(err) ? err: q->err;
     }
 
+    q->state = DEVQ_STATE_CONNECTED;
+
     return SYS_ERR_OK;
 }
 
@@ -856,7 +857,8 @@ static errval_t devq_init_direct(struct devq *q,
         return err;
     }
 
-    err = q->ctrl_rpc->vtbl.setup(q->ctrl_rpc, &q->end->features, &q->q_size, 
+    err = q->ctrl_rpc->vtbl.setup(q->ctrl_rpc, disp_get_core_id(),
+                                  flags, &q->end->features, &q->q_size, 
                                   &q->buf_size, &q->reconnect, q->reconnect_name);
     if (err_is_fail(err)) {
         return err;
index 2fb6857..1f37db1 100644 (file)
@@ -1534,16 +1534,23 @@ static errval_t connect_devif_cb(void *st, struct sfn5122f_devif_binding *b)
 }
 
 
-static errval_t sfn5122f_setup(uint64_t *features, uint32_t* default_qsize, 
-                               uint32_t* default_bufsize, bool* reconnect, 
-                               char* name)
+static errval_t sfn5122f_setup(uint32_t coreid, uint64_t flag,
+                               uint64_t *features, uint32_t* default_qsize, 
+                               uint32_t* default_bufsize, bool* reconnect,
+                               char* reconnect_name)
 {
     DEBUG("Setup called\n");
     *features = DEVQ_FEATURE_DIRECT;
     *default_qsize = TX_ENTRIES;
     *default_bufsize = MTU_MAX;
-    *reconnect = false;
-    name = "";
+    if (!(flag & DEVQ_SETUP_FLAGS_DIRECT)) {
+       // TODO start queue driver, findbetter recon_name
+        sprintf(reconnect_name, "sfn5122f_devif_qdriver_%d", coreid);
+        *reconnect = true;
+    } else {
+        *reconnect = false;
+        reconnect_name = "";
+    }
     return SYS_ERR_OK;
 }
 
index 206a88c..850eec5 100644 (file)
@@ -402,7 +402,6 @@ static void test_sfn5122f_device(void)
 
     uint16_t tx_bufs = 0;
     while (tx_bufs < NUM_ROUNDS) {
-        printf("Dequeue %d \n", tx_bufs);
         err = devq_dequeue(q, &rid, &addr, &len, &ids[tx_bufs], &flags);
         if (err_is_fail(err)){
             USER_PANIC("Devq dequeue failed \n");