Devq: changed interface and adapted backends/tests
authorRoni Häcki <roni.haecki@inf.ethz.ch>
Wed, 1 Mar 2017 11:59:06 +0000 (12:59 +0100)
committerRoni Häcki <roni.haecki@inf.ethz.ch>
Wed, 1 Mar 2017 11:59:06 +0000 (12:59 +0100)
Signed-off-by: Roni Häcki <roni.haecki@inf.ethz.ch>

15 files changed:
include/devif/queue_interface.h
lib/blk/blk_ahci/blk_ahci.h
lib/blk/blk_ahci/device_impl.c
lib/devif/backends/idc/desc_queue.c
lib/devif/backends/net/e10k/devif_backend_e10k.c
lib/devif/backends/net/e10k/e10k_devif_vf.c
lib/devif/backends/net/e10k/e10k_queue.h
lib/devif/backends/net/solarflare/devif_backend_solarflare.c
lib/devif/backends/net/solarflare/hw_queue.h
lib/devif/queue_interface.c
lib/devif/queue_interface_internal.h
usr/drivers/ahcid/test.c
usr/drivers/solarflare/sfn5122f_cdriver.c
usr/tests/devif/idc_endpoint.c
usr/tests/devif/queue_interface.c

index 0c37842..27e8390 100644 (file)
@@ -14,6 +14,7 @@
 
 typedef uint32_t regionid_t;
 typedef uint32_t bufferid_t;
+typedef uint64_t genoffset_t;
 
 
 struct devq;
@@ -21,11 +22,12 @@ struct region_pool;
 
 // For convinience reason buffer descritpion in one struct
 struct devq_buf{
-    regionid_t rid; // 4
-    bufferid_t bid; // 8
-    lpaddr_t addr; // 16
-    size_t len; // 24
-    uint64_t flags; // 32
+    genoffset_t offset; // 8 
+    genoffset_t length; // 16
+    genoffset_t valid_data; // 24 
+    genoffset_t valid_length; // 32 
+    uint64_t flags; // 40
+    regionid_t rid; // 44
 };
 
 /*
@@ -39,21 +41,24 @@ struct devq_buf{
  *
  * @param q             The device queue to call the operation on
  * @param region_id     Id of the memory region the buffer belongs to
- * @param base          Physical address of the start of the enqueued buffer
+ * @param offset        Offset into the region i.e. where the buffer starts
+ *                      that is enqueued
  * @param lenght        Lenght of the enqueued buffer
+ * @param valid_data    Offset into the region where the valid data of this buffer
+ *                      starts
+ * @param valid_length  Length of the valid data of this buffer
  * @param misc_flags    Any other argument that makes sense to the device queue
- * @param buffer_id     Return pointer to buffer id of the enqueued buffer 
- *                      buffer_id is assigned by the interface
  *
  * @returns error on failure or SYS_ERR_OK on success
  *
  */
 errval_t devq_enqueue(struct devq *q,
                       regionid_t region_id,
-                      lpaddr_t base,
-                      size_t length,
-                      uint64_t misc_flags,
-                      bufferid_t* buffer_id);
+                      genoffset_t offset,
+                      genoffset_t lenght,
+                      genoffset_t valid_data,
+                      genoffset_t valid_lenght,
+                      uint64_t misc_flags);
 
 /**
  * @brief dequeue a buffer from the device queue
@@ -61,21 +66,24 @@ errval_t devq_enqueue(struct devq *q,
  * @param q             The device queue to call the operation on
  * @param region_id     Return pointer to the id of the memory 
  *                      region the buffer belongs to
- * @param base          Return pointer to the physical address of 
- *                      the of the buffer
+ * @param region_offset Return pointer to the offset into the region where
+ *                      this buffer starts.
  * @param lenght        Return pointer to the lenght of the dequeue buffer
- * @param buffer_id     Reutrn pointer to the buffer id of the dequeued buffer 
+ * @param valid_data    Return pointer to an offset into the region where the
+ *                      valid data of this buffer starts
+ * @param valid_length  Return pointer to the length of the valid data of 
+ *                      this buffer
  * @param misc_flags    Return value from other endpoint
  *
  * @returns error on failure or SYS_ERR_OK on success
  *
  */
-
 errval_t devq_dequeue(struct devq *q,
                       regionid_t* region_id,
-                      lpaddr_t* base,
-                      size_t* length,
-                      bufferid_t* buffer_id,
+                      genoffset_t* offset,
+                      genoffset_t* langht,
+                      genoffset_t* valid_data,
+                      genoffset_t* valid_length,
                       uint64_t* misc_flags);
 
 /*
index 6b116ea..1e19bea 100644 (file)
@@ -67,11 +67,10 @@ struct dev_queue_request {
     struct dma_mem region;
     uint64_t command_slot;
 
-    lpaddr_t base;
-    size_t length;
-    // TODO change back to buffer_t
-    //bufferid_t buffer_id;
-    uint32_t buffer_id;
+    genpaddr_t offset;
+    genpaddr_t length;
+    genpaddr_t valid_data;
+    genpaddr_t valid_length;
 
     errval_t error;
     enum RequestStatus status;
index a9a6d73..d83a965 100644 (file)
@@ -66,12 +66,14 @@ static errval_t init_queue(struct ahci_queue** dq) {
     return SYS_ERR_OK;
 }
 
-static bool slice_is_in_range(struct dma_mem *mem, lpaddr_t base, size_t length)
+static bool slice_is_in_range(struct dma_mem *mem, genpaddr_t offset, size_t length)
 {
-    bool lower_bound = mem->paddr <= base;
-    bool upper_bound = mem->paddr+mem->bytes >= base+length;
-
-    return lower_bound && upper_bound;
+    // do not have to check lower bound since it is unsigned
+    bool upper_bound = (mem->bytes >= length);
+    bool upper_bound2 = (mem->paddr + offset + length) <= (mem->paddr + mem->bytes);
+   // printf("mem->paddr %lx, mem->bytes %lx, offset %lx, length %lx \n",
+   //        mem->paddr, mem->bytes, offset, length);
+    return upper_bound2 && upper_bound;
 }
 
 static uint64_t flags_get_block(uint64_t flags)
@@ -110,20 +112,20 @@ errval_t ahci_destroy(struct ahci_queue *q)
 
 static errval_t ahci_enqueue(struct devq *q, 
                              regionid_t region_id, 
-                             bufferid_t buffer_id, 
-                             lpaddr_t base, 
-                             size_t length, 
+                             genoffset_t offset,
+                             genoffset_t length,
+                             genoffset_t valid_data,
+                             genoffset_t valid_length,
                              uint64_t flags)
 {
     struct ahci_queue *queue = (struct ahci_queue*) q;
     
     assert(is_valid_buffer(queue, (region_id % MAX_BUFFERS)));
-    assert(base != 0);
     assert(length >= 512);
 
     struct dma_mem* mem = &queue->buffers[(region_id % MAX_BUFFERS)];
 
-    if (!slice_is_in_range(mem, base, length)) {
+    if (!slice_is_in_range(mem, offset, length)) {
         return DEV_ERR_INVALID_BUFFER_ARGS;
     }
 
@@ -136,29 +138,34 @@ static errval_t ahci_enqueue(struct devq *q,
 
     struct dev_queue_request *dqr = &queue->requests[slot];
     dqr->status = RequestStatus_InProgress;
-    dqr->buffer_id = buffer_id;
-    dqr->base = base;
+    dqr->region_id = region_id;
+    dqr->offset = offset;
     dqr->length = length;
-    dqr->region_id = region_id ;
+    dqr->valid_data = valid_data;
+    dqr->valid_length = valid_length;
     dqr->command_slot = slot;
 
     uint64_t block = flags_get_block(flags);
     bool write = flags_is_write(flags);
 
-    err = blk_ahci_port_dma_async(queue->port, slot, block, base, length, write);
+    err = blk_ahci_port_dma_async(queue->port, slot, block, mem->paddr+offset, 
+                                  length, write);
     return err;
 }
 
 static errval_t ahci_dequeue(struct devq* q,
                              regionid_t* region_id,
-                             bufferid_t* buffer_id,
-                             lpaddr_t* base,
-                             size_t* length,
+                             genoffset_t* offset,
+                             genoffset_t* length,
+                             genoffset_t* valid_data,
+                             genoffset_t* valid_length,
                              uint64_t* misc_flags)
 {
     assert(q != NULL);
     assert(region_id != NULL);
-    assert(base != NULL);
+    assert(offset != NULL);
+    assert(valid_data != NULL);
+    assert(valid_length != NULL);
     assert(length != NULL);
 
     struct ahci_queue *queue = (struct ahci_queue*) q;
@@ -166,10 +173,11 @@ static errval_t ahci_dequeue(struct devq* q,
     for (size_t i=0; i < queue->port->ncs; i++) {
         struct dev_queue_request *dqr = &queue->requests[i];
         if (dqr->status == RequestStatus_Done) {
-            *base = dqr->base;
-            *length = dqr->length;
-            *buffer_id = dqr->buffer_id;
             *region_id = dqr->region_id;
+            *offset = dqr->offset;
+            *length = dqr->length;
+            *valid_data = dqr->valid_data;
+            *valid_length = dqr->valid_length;
             dqr->status = RequestStatus_Unused;
             return dqr->error;
         }
index 9748e78..abab5cc 100644 (file)
 #include <devif/backends/descq.h>
 #include <if/descq_data_defs.h>
 #include <if/descq_ctrl_defs.h>
-#include <if/descq_ctrl_defs.h>
 #include "../../queue_interface_internal.h"
 #include "descq_debug.h"
 
 
 struct __attribute__((aligned(DESCQ_ALIGNMENT))) desc {
-    regionid_t rid; // 4
-    bufferid_t bid; // 8
-    lpaddr_t addr; // 16
-    size_t len; // 24
-    uint64_t flags; // 32
-    uint64_t seq; // 40
-    uint8_t pad[24];
+    genoffset_t offset; // 8 
+    genoffset_t length; // 16 
+    genoffset_t valid_data; // 24
+    genoffset_t valid_length; // 32
+    uint64_t flags; // 40
+    uint64_t seq; // 48
+    regionid_t rid; // 52
+    uint8_t pad[12];
 };
 
 union __attribute__((aligned(DESCQ_ALIGNMENT))) pointer {
@@ -56,7 +56,6 @@ struct descq {
     // Flounder
     struct descq_data_binding* data;
     struct descq_ctrl_binding* ctrl;
-    struct descq_ctrl_binding* rpc;
 
     // linked list
     struct descq* next;
@@ -79,18 +78,21 @@ struct descq_endpoint_state {
  *
  * @param q                     The descriptor queue
  * @param region_id             Region id of the enqueued buffer
- * @param buffer_id             Buffer id of the buffer
- * @param base                  Physical address of hte buffer
- * @param len                   Lenght of the buffer
+ * @param offset                Offset into the region where the buffer resides
+ * @param length                Length of the buffer
+ * @param valid_data            Offset into the region where the valid data
+ *                              of the buffer resides
+ * @param valid_length          Length of the valid data of the buffer
  * @param misc_flags            Miscellaneous flags
  *
  * @returns error if queue is full or SYS_ERR_OK on success
  */
 static errval_t descq_enqueue(struct devq* queue,
                               regionid_t region_id,
-                              bufferid_t buffer_id,
-                              lpaddr_t base,
-                              size_t len,
+                              genoffset_t offset,
+                              genoffset_t length,
+                              genoffset_t valid_data,
+                              genoffset_t valid_length,
                               uint64_t misc_flags)
 {
     struct descq* q = (struct descq*) queue;
@@ -100,19 +102,21 @@ static errval_t descq_enqueue(struct devq* queue,
     }
     
     q->tx_descs[head].rid = region_id;
-    q->tx_descs[head].bid = buffer_id;
-    q->tx_descs[head].addr = base;
-    q->tx_descs[head].len = len;
+    q->tx_descs[head].offset = offset;
+    q->tx_descs[head].length = length;
+    q->tx_descs[head].valid_data = valid_data;
+    q->tx_descs[head].valid_length = valid_length;
     q->tx_descs[head].flags = misc_flags;
     q->tx_descs[head].seq = q->tx_seq;    
 
     // only write local head
     q->tx_seq++;
 
-    DESCQ_DEBUG("tx_seq=%lu tx_seq_ack=%lu bid=%d\n", 
-                    q->tx_seq, q->tx_seq_ack->value, buffer_id);
+    DESCQ_DEBUG("tx_seq=%lu tx_seq_ack=%lu \n", 
+                    q->tx_seq, q->tx_seq_ack->value);
     return SYS_ERR_OK;
 }
+
 /**
  * @brief Dequeue a descriptor (as seperate fields) 
  *        from the descriptor queue
@@ -120,19 +124,23 @@ static errval_t descq_enqueue(struct devq* queue,
  * @param q                     The descriptor queue
  * @param region_id             Return pointer to the region id of 
  *                              the denqueued buffer
- * @param buffer_id             Return pointer to the buffer id of the buffer
- * @param base                  Return pointer to the physical address 
- *                              of the buffer
- * @param len                   Return pointer to the lenght of the buffer
+ * @param offset                Return pointer to the offset into the region
+ *                              where the buffer resides
+ * @param length                Return pointer to the length of the buffer
+ * @param valid_data            Return pointer to the offset into the region
+ *                              where the valid data of the buffer resides
+ * @param valid_lenght          Return pointer to the length of the valid
+ *                              data of the buffer
  * @param misc_flags            Return pointer to miscellaneous flags
  *
  * @returns error if queue is empty or SYS_ERR_OK on success
  */
 static errval_t descq_dequeue(struct devq* queue,
                               regionid_t* region_id,
-                              bufferid_t* buffer_id,
-                              lpaddr_t* base,
-                              size_t* len,
+                              genoffset_t* offset,
+                              genoffset_t* length,
+                              genoffset_t* valid_data,
+                              genoffset_t* valid_length,
                               uint64_t* misc_flags)
 {
     struct descq* q = (struct descq*) queue;
@@ -144,16 +152,17 @@ static errval_t descq_dequeue(struct devq* queue,
 
     size_t tail = q->rx_seq % q->slots;
     *region_id = q->rx_descs[tail].rid;
-    *buffer_id = q->rx_descs[tail].bid;
-    *base = q->rx_descs[tail].addr;
-    *len = q->rx_descs[tail].len;
+    *offset = q->rx_descs[tail].offset;
+    *length = q->rx_descs[tail].length;
+    *valid_data = q->rx_descs[tail].valid_data;
+    *valid_length = q->rx_descs[tail].valid_length;
     *misc_flags = q->rx_descs[tail].flags;
  
        
     q->rx_seq++;
     q->rx_seq_ack->value = q->rx_seq;
 
-    DESCQ_DEBUG("rx_seq_ack=%lu bid=%d \n", q->rx_seq_ack->value, *buffer_id);
+    DESCQ_DEBUG("rx_seq_ack=%lu\n", q->rx_seq_ack->value);
     return SYS_ERR_OK;
 }
 
@@ -171,7 +180,7 @@ static errval_t descq_notify(struct devq* q)
     struct descq* queue = (struct descq*) q;
     /*
     DESCQ_DEBUG("start \n");
-    err = queue->rpc->rpc_tx_vtbl.notify(queue->rpc, &err2);
+    err = queue->ctrl->rpc_tx_vtbl.notify(queue->rpc, &err2);
     err = err_is_fail(err) ? err : err2;
     DESCQ_DEBUG("end\n");
     */
@@ -195,7 +204,7 @@ static errval_t descq_control(struct devq* q, uint64_t cmd,
     struct descq* queue = (struct descq*) q;
 
     DESCQ_DEBUG("start \n");
-    err = queue->rpc->rpc_tx_vtbl.control(queue->rpc, cmd, value, &err2);
+    err = queue->ctrl->rpc_tx_vtbl.control(queue->ctrl, cmd, value, &err2);
     err = err_is_fail(err) ? err : err2;
     DESCQ_DEBUG("end\n");
     return err;
@@ -208,7 +217,7 @@ static errval_t descq_register(struct devq* q, struct capref cap,
     struct descq* queue = (struct descq*) q;
 
     DESCQ_DEBUG("start %p\n", queue);
-    err = queue->rpc->rpc_tx_vtbl.register_region(queue->rpc, cap, rid, &err2);
+    err = queue->ctrl->rpc_tx_vtbl.register_region(queue->ctrl, cap, rid, &err2);
     err = err_is_fail(err) ? err : err2;
     DESCQ_DEBUG("end\n");
     return err;
@@ -219,7 +228,7 @@ static errval_t descq_deregister(struct devq* q, regionid_t rid)
     errval_t err, err2;
     struct descq* queue = (struct descq*) q;
 
-    err = queue->rpc->rpc_tx_vtbl.deregister_region(queue->rpc, rid, &err2);
+    err = queue->ctrl->rpc_tx_vtbl.deregister_region(queue->ctrl, rid, &err2);
     err = err_is_fail(err) ? err : err2;
     return err;
 }
@@ -451,11 +460,7 @@ static void ctrl_bind_cb(void *st, errval_t err, struct descq_ctrl_binding* b)
     struct descq* q = (struct descq*) st;
     DESCQ_DEBUG("Control interface bound \n");
     q->ctrl = b;
-    q->rpc = malloc(sizeof(struct descq_ctrl_binding));
-    assert(q->rpc != NULL); 
-
-    err = descq_ctrl_binding_init(q->rpc, b);
-    assert(err_is_ok(err));
+    descq_ctrl_rpc_client_init(q->ctrl);
 
     b->rx_vtbl = ctrl_rx_vtbl;
     b->st = q;
@@ -603,7 +608,7 @@ errval_t descq_create(struct descq** q,
         }
 
         errval_t err2;
-        err = tmp->rpc->rpc_tx_vtbl.create_queue(tmp->rpc, slots, rx, tx, &err2);
+        err = tmp->ctrl->rpc_tx_vtbl.create_queue(tmp->ctrl, slots, rx, tx, &err2);
         if (err_is_fail(err) || err_is_fail(err2)) {
             err = err_is_fail(err) ? err: err2;
             goto cleanup5;
index 5376449..22732b5 100644 (file)
@@ -97,7 +97,10 @@ static struct region_entry* get_region(struct e10k_queue* q, regionid_t rid)
 
 
 static errval_t enqueue_tx_buf(struct e10k_queue* q, regionid_t rid,
-                               bufferid_t bid, lpaddr_t base, size_t len, 
+                               genoffset_t offset,
+                               genoffset_t length,
+                               genoffset_t valid_data,
+                               genoffset_t valid_length,
                                uint64_t flags)
 {
     DEBUG_QUEUE("Enqueueing TX buf \n");
@@ -131,13 +134,21 @@ static errval_t enqueue_tx_buf(struct e10k_queue* q, regionid_t rid,
             assert(entry != NULL);
 
             lpaddr_t addr = 0;
-            addr = (lpaddr_t) entry->virt + (base-entry->phys);
-            e10k_queue_add_txbuf_ctx(q, rid, bid, addr, len, flags, 
-                                     first, last, len, 0, true, l4len !=0);
+            addr = (lpaddr_t) entry->virt + offset;
+            e10k_queue_add_txbuf_ctx(q, addr, rid, offset, length,
+                                     valid_data, valid_length, flags, 
+                                     first, last, length, 0, true, l4len !=0);
            } else {
 
-            e10k_queue_add_txbuf_ctx(q, rid, bid, base, len, flags, 
-                                     first, last, len, 0, true, l4len != 0);
+            // get virtual address of buffer
+            struct region_entry* entry = get_region(q, rid);
+            assert(entry != NULL);
+
+            lpaddr_t addr = 0;
+            addr = (lpaddr_t) entry->phys + offset;
+            e10k_queue_add_txbuf_ctx(q, addr, rid, offset, length,
+                                     valid_data, valid_length, flags, 
+                                     first, last, length, 0, true, l4len != 0);
         }
     } else {
         if (q->use_vtd) {
@@ -146,11 +157,18 @@ static errval_t enqueue_tx_buf(struct e10k_queue* q, regionid_t rid,
             assert(entry != NULL);
 
             lpaddr_t addr = 0;
-            addr = (lpaddr_t) entry->virt + (base-entry->phys);
-            e10k_queue_add_txbuf(q, rid, bid, addr, len, flags, 
-                                 first, last, len);
+            addr = (lpaddr_t) entry->virt + offset;
+            e10k_queue_add_txbuf(q, addr, rid, offset, length, valid_data,
+                                 valid_length, flags, 
+                                 first, last, length);
         } else {
-            e10k_queue_add_txbuf(q, rid, bid, base, len, flags, first, last, len);
+            struct region_entry* entry = get_region(q, rid);
+            assert(entry != NULL);
+
+            lpaddr_t addr = 0;
+            addr = (lpaddr_t) entry->phys + offset;
+            e10k_queue_add_txbuf(q, addr, rid, offset, length, valid_data,
+                                 valid_length, flags, first, last, length);
         }
     }
     e10k_queue_bump_txtail(q);
@@ -159,7 +177,10 @@ static errval_t enqueue_tx_buf(struct e10k_queue* q, regionid_t rid,
 
 
 static errval_t enqueue_rx_buf(struct e10k_queue* q, regionid_t rid,
-                               bufferid_t bid, lpaddr_t base, size_t len, 
+                               genoffset_t offset,
+                               genoffset_t length,
+                               genoffset_t valid_data,
+                               genoffset_t valid_length,
                                uint64_t flags)
 {
     DEBUG_QUEUE("Enqueueing RX buf \n");
@@ -177,10 +198,18 @@ static errval_t enqueue_rx_buf(struct e10k_queue* q, regionid_t rid,
         assert(entry != NULL);
 
         lpaddr_t addr = 0;
-        addr = (lpaddr_t) entry->virt + (base-entry->phys);
-        e10k_queue_add_rxbuf(q, rid, bid, addr, len, flags);
+        addr = (lpaddr_t) entry->virt + offset;
+        e10k_queue_add_rxbuf(q, addr, rid, offset, length, valid_data,
+                             valid_length, flags);
     } else {
-        e10k_queue_add_rxbuf(q, rid, bid, base, len, flags);
+        // get virtual address of buffer
+        struct region_entry* entry = get_region(q, rid);
+        assert(entry != NULL);
+
+        lpaddr_t addr = 0;
+        addr = (lpaddr_t) entry->phys + offset;
+        e10k_queue_add_rxbuf(q, addr, rid, offset, length, valid_data,
+                             valid_length, flags);
     }
 
     DEBUG_QUEUE("before bump tail\n");
@@ -192,8 +221,9 @@ static errval_t enqueue_rx_buf(struct e10k_queue* q, regionid_t rid,
 /******************************************************************************/
 /* Queue functions */
 
-static errval_t e10k_enqueue(struct devq* q, regionid_t rid, bufferid_t bid, 
-                             lpaddr_t base, size_t len, uint64_t flags)
+static errval_t e10k_enqueue(struct devq* q, regionid_t rid, genoffset_t offset,
+                             genoffset_t length, genoffset_t valid_data,
+                             genoffset_t valid_length, uint64_t flags)
 {
     errval_t err;
 
@@ -201,17 +231,19 @@ static errval_t e10k_enqueue(struct devq* q, regionid_t rid, bufferid_t bid,
     struct e10k_queue* queue = (struct e10k_queue*) q;
     if (flags & NETIF_RXFLAG) {
         /* can not enqueue receive buffer larger than 2048 bytes */
-        assert(len <= 2048);
+        assert(length <= 2048);
 
-        err = enqueue_rx_buf(queue, rid, bid, base, len, flags);
+        err = enqueue_rx_buf(queue, rid, offset, length, valid_data,
+                             valid_length, flags);
         if (err_is_fail(err)) {
             return err;
         }      
     } else if (flags & NETIF_TXFLAG) {
 
-        assert(len <= 2048);
+        assert(length <= 2048);
         
-        err = enqueue_tx_buf(queue, rid, bid, base, len, flags);
+        err = enqueue_tx_buf(queue, rid, offset, length, valid_data,
+                             valid_length, flags);
         if (err_is_fail(err)) {
             return err;
         } 
@@ -221,20 +253,24 @@ static errval_t e10k_enqueue(struct devq* q, regionid_t rid, bufferid_t bid,
 }
 
 
-static errval_t e10k_dequeue(struct devq* q, regionid_t* rid, bufferid_t* bid, 
-                             lpaddr_t* base, size_t* len, uint64_t* flags)
+static errval_t e10k_dequeue(struct devq* q, regionid_t* rid,
+                             genoffset_t* offset, genoffset_t* length,
+                             genoffset_t* valid_data,
+                             genoffset_t* valid_length, uint64_t* flags)
 {
     struct e10k_queue* que = (struct e10k_queue*) q;
     int last;
     errval_t err = SYS_ERR_OK;
 
-    if (!e10k_queue_get_rxbuf(que, rid, bid, base, len, flags, &last)) {
+    if (!e10k_queue_get_rxbuf(que, rid, offset, length, valid_data, 
+                             valid_length, flags, &last)) {
         err = DEVQ_ERR_RX_EMPTY;
     } else {
         return SYS_ERR_OK;
     }
      
-    if (!e10k_queue_get_txbuf(que, rid, bid, base, len, flags)) {
+    if (!e10k_queue_get_txbuf(que, rid, offset, length, valid_data,
+                              valid_length, flags)) {
         err = DEVQ_ERR_RX_EMPTY;
     }  else {
         return SYS_ERR_OK;
@@ -326,14 +362,10 @@ static void bind_cb(void *st, errval_t err, struct e10k_vf_binding *b)
 
     DEBUG_QUEUE("Sucessfully connected to management interface\n");
 
-    struct e10k_vf_rpc_client *r = malloc(sizeof(*r));
-    assert(r != NULL);
-    err = e10k_vf_rpc_client_init(r, b);
-    assert(err_is_ok(err));
     b->st = q;
-    q->binding = r;
+    q->binding = b;
+    e10k_vf_rpc_client_init(q->binding);
     q->bound = true;
-
 }
 
 /** Connect to the management interface */
@@ -521,7 +553,7 @@ errval_t e10k_queue_create(struct e10k_queue** queue, e10k_event_cb_t cb,
         }
 
         int q_id;
-        err = q->binding->vtbl.create_queue(q->binding, tx_frame, txhwb_frame, 
+        err = q->binding->rpc_tx_vtbl.create_queue(q->binding, tx_frame, txhwb_frame, 
                                             rx_frame, 2048, q->msix_intvec, 
                                             q->msix_intdest, false, false, &q_id,
                                             &regs);   
index b28b5c6..fa08b10 100644 (file)
@@ -68,7 +68,7 @@ struct vf_state {
     bool use_interrupts;
 
     //
-    struct e10k_vf_rpc_client *binding;
+    struct e10k_vf_binding *binding;
     bool bound;
 };
 
@@ -468,7 +468,7 @@ static void pci_init_card(struct device_mem* bar_info, int bar_count)
     assert(vf->initialized);
 
     // Tell PF driver
-    err = vf->binding->vtbl.init_done(vf->binding, vf->vf_num);
+    err = vf->binding->rpc_tx_vtbl.init_done(vf->binding, vf->vf_num);
     assert(err_is_ok(err));
 
 }
@@ -510,14 +510,7 @@ static void vf_bind_cont(void *st, errval_t err, struct e10k_vf_binding *b)
 {
     assert(err_is_ok(err));
 
-    struct e10k_vf_rpc_client *r = malloc(sizeof(*r));
-    assert(r != NULL);
-    err = e10k_vf_rpc_client_init(r, b);
-    if (err_is_ok(err)) {
-        vf->binding = r;
-    } else {
-        free(r);
-    }
+    vf->binding = b;
 }
 
 static errval_t e10k_vf_client_connect(int pci_function)
@@ -601,14 +594,16 @@ errval_t e10k_init_vf_driver(uint8_t pci_function,
     }  
 
     DEBUG_VF("Requesting VF number from PF...\n");
-    err = vf->binding->vtbl.request_vf_number(vf->binding, (uint8_t*) &vf->vf_num, 
-                                              &err2); 
+    err = vf->binding->rpc_tx_vtbl.request_vf_number(vf->binding, 
+                                                     (uint8_t*) &vf->vf_num, 
+                                                     &err2); 
     if (err_is_fail(err) || err_is_fail(err2)) {
         return err_is_fail(err) ? err: err2;
     }
  
     DEBUG_VF("Requesting MAC from PF...\n");
-    err = vf->binding->vtbl.get_mac_address(vf->binding, vf->vf_num, &vf->d_mac);
+    err = vf->binding->rpc_tx_vtbl.get_mac_address(vf->binding, vf->vf_num, 
+                                                   &vf->d_mac);
     assert(err_is_ok(err));
 
     DEBUG_VF("VF num %d initalize...\n", vf->vf_num);
index 760cac1..d92d520 100644 (file)
@@ -81,7 +81,7 @@ struct e10k_queue {
     struct vf_state* vf;
 
     // Communicatio to PF
-    struct e10k_vf_rpc_client *binding;
+    struct e10k_vf_binding *binding;
     bool bound;
 
     // FIXME: Look for appropriate type for the _head/tail/size fields
@@ -161,10 +161,14 @@ static inline int e10k_queue_add_txcontext(e10k_queue_t* q, uint8_t idx,
     return 0;
 }
 
-
-static inline int e10k_queue_add_txbuf_ctx(e10k_queue_t* q, regionid_t rid,
-                                           bufferid_t bid, lpaddr_t base,
-                                           size_t totallen, uint64_t flags,
+// len is only length of this descriptor where length is the total length
+static inline int e10k_queue_add_txbuf_ctx(e10k_queue_t* q, lpaddr_t phys,
+                                           regionid_t rid,
+                                           genoffset_t offset,
+                                           genoffset_t length,
+                                           genoffset_t valid_data, 
+                                           genoffset_t valid_length,
+                                           uint64_t flags,
                                            bool first, bool last,
                                            size_t len, uint8_t ctx,
                                            bool ixsm, bool txsm)
@@ -177,17 +181,18 @@ static inline int e10k_queue_add_txbuf_ctx(e10k_queue_t* q, regionid_t rid,
     // TODO: Check if there is room in the queue
     q->tx_isctx[tail] = false;
     struct devq_buf* buf = &q->tx_bufs[tail];
-    buf->addr = base;
-    buf->bid = bid;
     buf->rid = rid;
+    buf->offset = offset;
+    buf->length = length;
+    buf->valid_data = valid_data;
+    buf->valid_length = valid_length;
     buf->flags = flags;  
-    buf->len = totallen;
     d = q->tx_ring[tail];
 
-    e10k_q_tdesc_adv_rd_buffer_insert(d, base);
+    e10k_q_tdesc_adv_rd_buffer_insert(d, phys);
     e10k_q_tdesc_adv_rd_dtalen_insert(d, len);
     if (first) {
-        e10k_q_tdesc_adv_rd_paylen_insert(d, totallen);
+        e10k_q_tdesc_adv_rd_paylen_insert(d, length);
     }
     e10k_q_tdesc_adv_rd_dtyp_insert(d, e10k_q_adv_data);
     e10k_q_tdesc_adv_rd_dext_insert(d, 1);
@@ -208,13 +213,18 @@ static inline int e10k_queue_add_txbuf_ctx(e10k_queue_t* q, regionid_t rid,
 
 }
 
-static inline int e10k_queue_add_txbuf(e10k_queue_t* q, regionid_t rid,
-                                       bufferid_t bid, lpaddr_t base,
-                                       size_t totallen, uint64_t flags,
+static inline int e10k_queue_add_txbuf(e10k_queue_t* q, lpaddr_t phys,
+                                       regionid_t rid,
+                                       genoffset_t offset,
+                                       genoffset_t length,      
+                                       genoffset_t valid_data,
+                                       genoffset_t valid_length,
+                                       uint64_t flags,
                                        bool first, bool last,
                                        size_t len)
 {
-    return e10k_queue_add_txbuf_ctx(q, rid, bid, base, totallen, 
+    return e10k_queue_add_txbuf_ctx(q, phys, rid, offset, length,
+                                    valid_data, valid_length, 
                                     flags, first, last, 
                                     len, -1, false, false);
 }
@@ -228,9 +238,12 @@ static inline int e10k_queue_add_txbuf(e10k_queue_t* q, regionid_t rid,
  *
  * \return true if packet can be reclaimed otherwise false
  */
-static inline bool e10k_queue_get_txbuf(e10k_queue_t* q, regionid_t* rid,
-                                       bufferid_t* bid, lpaddr_t* base, 
-                                       size_t* len, uint64_t* flags)
+static inline bool e10k_queue_get_txbuf(e10k_queue_t* q, regionid_t* rid,   
+                                        genoffset_t* offset,
+                                        genoffset_t* length,
+                                        genoffset_t* valid_data,
+                                        genoffset_t* valid_length,
+                                        uint64_t* flags)
 {
     /* e10k_q_tdesc_adv_wb_t d; */
     size_t head = q->tx_head;
@@ -259,9 +272,10 @@ static inline bool e10k_queue_get_txbuf(e10k_queue_t* q, regionid_t* rid,
     if (!q->tx_isctx[head]) {
         //*opaque = q->tx_opaque[head];
         *rid = q->tx_bufs[head].rid;
-        *bid = q->tx_bufs[head].bid;
-        *base = q->tx_bufs[head].addr;
-        *len = q->tx_bufs[head].len;
+        *offset = q->tx_bufs[head].offset;
+        *length = q->tx_bufs[head].length;
+        *valid_data = q->tx_bufs[head].valid_data;
+        *valid_length = q->tx_bufs[head].valid_length;
         *flags = q->tx_bufs[head].flags;
 
         result = true;
@@ -292,10 +306,12 @@ static inline size_t e10k_queue_free_txslots(e10k_queue_t* q)
 }
 
 static inline int e10k_queue_add_rxbuf(e10k_queue_t* q,
+                                       lpaddr_t phys,
                                        regionid_t rid,
-                                       bufferid_t bid,
-                                       lpaddr_t base,
-                                       size_t len,
+                                       genoffset_t offset,
+                                       genoffset_t length,
+                                       genoffset_t valid_data,
+                                       genoffset_t valid_length,
                                        uint64_t flags)
 {
     e10k_q_rdesc_adv_rd_t d;
@@ -310,14 +326,15 @@ static inline int e10k_queue_add_rxbuf(e10k_queue_t* q,
 
     // TODO: Check if there is room in the queue
     ctx->buf.rid = rid;
-    ctx->buf.bid = bid;
-    ctx->buf.len = len;
-    ctx->buf.addr = base;
+    ctx->buf.offset = offset;
+    ctx->buf.length = length;
+    ctx->buf.valid_data = valid_data;
+    ctx->buf.valid_length = valid_length;
     ctx->buf.flags = flags;
     ctx->used = true;
     d = (e10k_q_rdesc_adv_rd_t) q->rx_ring[tail];
 
-    e10k_q_rdesc_adv_rd_buffer_insert(d, base);
+    e10k_q_rdesc_adv_rd_buffer_insert(d, phys);
     // TODO: Does this make sense for RSC?
     e10k_q_rdesc_adv_rd_hdr_buffer_insert(d, 0);
 
@@ -361,8 +378,12 @@ static inline uint64_t e10k_queue_convert_rxflags(e10k_q_rdesc_adv_wb_t d)
 }
 
 static inline bool e10k_queue_get_rxbuf(e10k_queue_t* q, regionid_t* rid,
-                                        bufferid_t* bid, lpaddr_t* base,
-                                        size_t* len, uint64_t* flags, int* last)
+                                        genoffset_t* offset,
+                                        genoffset_t* length,
+                                        genoffset_t* valid_data,
+                                        genoffset_t* valid_length,
+                                        uint64_t* flags,
+                                        int* last)
 {
     e10k_q_rdesc_adv_wb_t d;
     size_t head = q->rx_head;
@@ -390,10 +411,11 @@ static inline bool e10k_queue_get_rxbuf(e10k_queue_t* q, regionid_t* rid,
 
     // TODO: Extract status (okay/error)
     *last = e10k_q_rdesc_adv_wb_eop_extract(d);
-    *len = e10k_q_rdesc_adv_wb_pkt_len_extract(d);
+    *valid_length = e10k_q_rdesc_adv_wb_pkt_len_extract(d);
     *rid = ctx->buf.rid;
-    *bid = ctx->buf.bid;
-    *base = ctx->buf.addr;
+    *offset = ctx->buf.offset;
+    *length = ctx->buf.length;
+    *valid_data = ctx->buf.valid_data;
 
     ctx->used = false;
     memset(d, 0, e10k_q_rdesc_adv_wb_size);
index fbd5718..6266c6f 100644 (file)
@@ -90,8 +90,7 @@ static void bind_cb(void *st, errval_t err, struct sfn5122f_devif_binding *b)
     // Initi RPC client
     
     queue->b = b;
-
-    sfn5122f_devif_binding_init(queue->b);
+    sfn5122f_devif_rpc_client_init(queue->b);
     queue->bound = true;
 }
 
@@ -106,8 +105,8 @@ static errval_t sfn5122f_register(struct devq* q, struct capref cap,
     struct sfn5122f_queue* queue = (struct sfn5122f_queue*) q;
 
     if (queue->userspace) {
-        err = queue->b->b_tx_vtbl.register_region(queue->b, queue->id, cap,
-                                               &buftbl_idx, &err2);
+        err = queue->b->rpc_tx_vtbl.register_region(queue->b, queue->id, cap,
+                                                    &buftbl_idx, &err2);
         if (err_is_fail(err) || err_is_fail(err2)) {
             err = err_is_fail(err) ? err: err2;
             return err;
@@ -164,8 +163,8 @@ static errval_t sfn5122f_deregister(struct devq* q, regionid_t rid)
    
     // do rpc do inform carddriver to remove buftbl entries
     if (queue->userspace) {
-        err = queue->b->b_tx_vtbl.deregister_region(queue->b, cur->buftbl_idx, cur->size,
-                                                 &err2);
+        err = queue->b->rpc_tx_vtbl.deregister_region(queue->b, cur->buftbl_idx, 
+                                                      cur->size, &err2);
         if (err_is_fail(err) || err_is_fail(err2)) {
             err = err_is_fail(err) ? err: err2;
             return err;
@@ -191,7 +190,8 @@ static errval_t sfn5122f_notify(struct devq* q)
 }
 
 static errval_t enqueue_rx_buf(struct sfn5122f_queue* q, regionid_t rid,
-                               bufferid_t bid, lpaddr_t base, size_t len,
+                               genoffset_t offset, genoffset_t length,
+                               genoffset_t valid_data, genoffset_t valid_length,
                                uint64_t flags)
 {
 
@@ -215,21 +215,22 @@ static errval_t enqueue_rx_buf(struct sfn5122f_queue* q, regionid_t rid,
     }
     
     // compute buffer table entry of the rx buffer and the within it offset
-    uint64_t buftbl_idx = entry->buftbl_idx + (bid/BUF_SIZE);
-    uint16_t offset = bid & 0x00000FFF;
+    uint64_t buftbl_idx = entry->buftbl_idx + (offset/BUF_SIZE);
+    uint16_t b_off = offset & 0x00000FFF;
 
     // still in the same buffer table entry
-    assert(buftbl_idx == (entry->buftbl_idx + ((bid+len-1)/BUF_SIZE)));
+    assert(buftbl_idx == (entry->buftbl_idx + ((offset+length-1)/BUF_SIZE)));
 
    
     DEBUG_QUEUE("RX_BUF tbl_idx=%lu offset=%d flags=%lu \n",
-                buftbl_idx, offset, flags);
+                buftbl_idx, b_off, flags);
     if (q->userspace) {
-        sfn5122f_queue_add_user_rxbuf_devif(q, buftbl_idx, offset,
-                                            rid, bid, base, len, flags);
+        sfn5122f_queue_add_user_rxbuf_devif(q, buftbl_idx, b_off,
+                                            rid, offset, length, valid_data,
+                                            valid_length, flags);
     } else {
-        sfn5122f_queue_add_rxbuf_devif(q, rid, bid, base,
-                                       len, flags);
+        sfn5122f_queue_add_rxbuf_devif(q, entry->phys + offset, rid, offset, length,
+                                       valid_data, valid_length, flags);
     }
     sfn5122f_queue_bump_rxtail(q);
     return SYS_ERR_OK;
@@ -237,7 +238,8 @@ static errval_t enqueue_rx_buf(struct sfn5122f_queue* q, regionid_t rid,
 
 
 static errval_t enqueue_tx_buf(struct sfn5122f_queue* q, regionid_t rid,
-                               bufferid_t bid, lpaddr_t base, size_t len,
+                               genoffset_t offset, genoffset_t length,
+                               genoffset_t valid_data, genoffset_t valid_length,
                                uint64_t flags)
 {
     DEBUG_QUEUE("Enqueueing TX buf \n");
@@ -260,33 +262,37 @@ static errval_t enqueue_tx_buf(struct sfn5122f_queue* q, regionid_t rid,
     }
     
     // compute buffer table entry of the rx buffer and the within it offset
-    uint64_t buftbl_idx = entry->buftbl_idx + (bid/BUF_SIZE);
-    uint16_t offset = bid & 0x00000FFF;
+    uint64_t buftbl_idx = entry->buftbl_idx + (offset/BUF_SIZE);
+    uint16_t b_off = offset & 0x00000FFF;
 
 
     // still in the same buffer table entry
-    assert(buftbl_idx == (entry->buftbl_idx + ((bid+len-1)/BUF_SIZE)));
+    assert(buftbl_idx == (entry->buftbl_idx + ((offset+length-1)/BUF_SIZE)));
 
-    DEBUG_QUEUE("TX_BUF tbl_idx=%lu offset=%d flags=%lu \n", buftbl_idx, offset,
+    DEBUG_QUEUE("TX_BUF tbl_idx=%lu offset=%d flags=%lu \n", buftbl_idx, b_off,
                 flags);
     if (q->userspace) {
 
-        DEBUG_QUEUE("TX_BUF tbl_idx=%lu offset=%d flags=%lu \n", buftbl_idx, offset,
+        DEBUG_QUEUE("TX_BUF tbl_idx=%lu offset=%d flags=%lu \n", buftbl_idx, b_off,
                     flags);
-        sfn5122f_queue_add_user_txbuf_devif(q, buftbl_idx, offset,
-                                            rid, bid, base, len, flags);
+        sfn5122f_queue_add_user_txbuf_devif(q, buftbl_idx, b_off,
+                                            rid, offset, length, valid_data,
+                                            valid_length, flags);
     } else {
 
         DEBUG_QUEUE("TX_BUF flags=%lu \n", flags);
-        sfn5122f_queue_add_txbuf_devif(q, rid, bid, base,
-                                       len, flags);
+        sfn5122f_queue_add_txbuf_devif(q, entry->phys + offset, rid, offset, 
+                                       length, valid_data, valid_length,
+                                       flags);
     }
     sfn5122f_queue_bump_txtail(q);
     return SYS_ERR_OK;
 }
 
-static errval_t sfn5122f_enqueue(struct devq* q, regionid_t rid, bufferid_t bid,
-                                 lpaddr_t base, size_t len, uint64_t flags)
+static errval_t sfn5122f_enqueue(struct devq* q, regionid_t rid, 
+                                 genoffset_t offset, genoffset_t length,
+                                 genoffset_t valid_data, genoffset_t valid_length,
+                                 uint64_t flags)
 {
     errval_t err;
 
@@ -294,16 +300,18 @@ static errval_t sfn5122f_enqueue(struct devq* q, regionid_t rid, bufferid_t bid,
     struct sfn5122f_queue* queue = (struct sfn5122f_queue*) q;
     if (flags & NETIF_RXFLAG) {
         /* can not enqueue receive buffer larger than 2048 bytes */
-        assert(len <= 2048);
+        assert(length <= 2048);
 
-        err = enqueue_rx_buf(queue, rid, bid, base, len, flags);
+        err = enqueue_rx_buf(queue, rid, offset, length, valid_data, valid_length,
+                             flags);
         if (err_is_fail(err)) {
             return err;
         }
     } else if (flags & NETIF_TXFLAG) {
-        assert(len <= BASE_PAGE_SIZE);
+        assert(length <= BASE_PAGE_SIZE);
 
-        err = enqueue_tx_buf(queue, rid, bid, base, len, flags);
+        err = enqueue_tx_buf(queue, rid, offset, length, valid_data, valid_length, 
+                             flags);
         if (err_is_fail(err)) {
             return err;
         }
@@ -312,8 +320,9 @@ static errval_t sfn5122f_enqueue(struct devq* q, regionid_t rid, bufferid_t bid,
     return SYS_ERR_OK;
 }
 
-static errval_t sfn5122f_dequeue(struct devq* q, regionid_t* rid, bufferid_t* bid,
-                                 lpaddr_t* base, size_t* len, uint64_t* flags)
+static errval_t sfn5122f_dequeue(struct devq* q, regionid_t* rid, genoffset_t* offset,
+                                 genoffset_t* length, genoffset_t* valid_data,
+                                 genoffset_t* valid_length, uint64_t* flags)
 {
     uint8_t ev_code;
     errval_t err = DEVQ_ERR_RX_EMPTY;
@@ -325,10 +334,11 @@ static errval_t sfn5122f_dequeue(struct devq* q, regionid_t* rid, bufferid_t* bi
 
     if (queue->num_left > 0) {
         *rid = queue->bufs[queue->last_deq].rid;
-        *bid = queue->bufs[queue->last_deq].bid;
+        *offset = queue->bufs[queue->last_deq].offset;
         *flags = queue->bufs[queue->last_deq].flags;
-        *base = queue->bufs[queue->last_deq].addr;
-        *len = queue->bufs[queue->last_deq].len;
+        *valid_length = queue->bufs[queue->last_deq].valid_length;
+        *valid_data = queue->bufs[queue->last_deq].valid_data;
+        *length = queue->bufs[queue->last_deq].length;
         queue->num_left--;
         queue->last_deq++;
         return SYS_ERR_OK;
@@ -339,16 +349,18 @@ static errval_t sfn5122f_dequeue(struct devq* q, regionid_t* rid, bufferid_t* bi
         switch(ev_code){
         case EV_CODE_RX:
             // TODO multiple packets
-            err = sfn5122f_queue_handle_rx_ev_devif(queue, rid, bid, base,
-                                                    len, flags);
+            err = sfn5122f_queue_handle_rx_ev_devif(queue, rid, offset, length,
+                                                    valid_data, valid_length, 
+                                                    flags);
             if (err_is_ok(err)) {
-                DEBUG_QUEUE(" RX_EV Q_ID: %d len %ld \n", queue->id, *len);
+                DEBUG_QUEUE(" RX_EV Q_ID: %d len %ld \n", queue->id, *length);
             }
             sfn5122f_queue_bump_evhead(queue);
             return SYS_ERR_OK;
         case EV_CODE_TX:
-            err = sfn5122f_queue_handle_tx_ev_devif(queue, rid, bid, base,
-                                                    len, flags);
+            err = sfn5122f_queue_handle_tx_ev_devif(queue, rid, offset, length,
+                                                    valid_data, valid_length,
+                                                    flags);
             if (err_is_ok(err)) {
                 DEBUG_QUEUE("TX EVENT OK %d \n", queue->id);
             } else {
@@ -478,8 +490,9 @@ errval_t sfn5122f_queue_create(struct sfn5122f_queue** q, sfn5122f_event_cb_t cb
 
     if (!interrupts) {
         printf("Solarflare queue used in polling mode \n");
-        err = queue->b->b_tx_vtbl.create_queue(queue->b, frame, userlevel, interrupts, 
-                                            0, 0, &queue->id, &regs, &err2);
+        err = queue->b->rpc_tx_vtbl.create_queue(queue->b, frame, userlevel, 
+                                                 interrupts, 
+                                                 0, 0, &queue->id, &regs, &err2);
         if (err_is_fail(err) || err_is_fail(err2)) {
             err = err_is_fail(err) ? err: err2;
             return err;
@@ -491,10 +504,10 @@ errval_t sfn5122f_queue_create(struct sfn5122f_queue** q, sfn5122f_event_cb_t cb
 
         queue->core = disp_get_core_id();
         
-        err = queue->b->b_tx_vtbl.create_queue(queue->b, frame, userlevel,
-                                            interrupts, queue->core,
-                                            queue->vector, &queue->id,
-                                            &regs, &err2);
+        err = queue->b->rpc_tx_vtbl.create_queue(queue->b, frame, userlevel,
+                                                 interrupts, queue->core,
+                                                 queue->vector, &queue->id,
+                                                 &regs, &err2);
         if (err_is_fail(err) || err_is_fail(err2)) {
             err = err_is_fail(err) ? err: err2;
             printf("Registering interrupt failed, continueing in polling mode \n");
@@ -539,7 +552,7 @@ errval_t sfn5122f_queue_create(struct sfn5122f_queue** q, sfn5122f_event_cb_t cb
 errval_t sfn5122f_queue_destroy(struct sfn5122f_queue* q)
 {
     errval_t err, err2;
-    err = q->b->b_tx_vtbl.destroy_queue(q->b, q->id, &err2);
+    err = q->b->rpc_tx_vtbl.destroy_queue(q->b, q->id, &err2);
     if (err_is_fail(err) || err_is_fail(err2)) {
         err = err_is_fail(err) ? err: err2;
         return err;
index 803d1d6..adf4de8 100644 (file)
@@ -247,11 +247,12 @@ static inline errval_t sfn5122f_queue_handle_mcdi_event(sfn5122f_queue_t* q)
 /*    RX      */
 static inline int sfn5122f_queue_add_user_rxbuf_devif(sfn5122f_queue_t* q, 
                                                       uint32_t buf_id,
-                                                      uint16_t offset,
+                                                      uint16_t b_off,
                                                       regionid_t rid,
-                                                      bufferid_t devq_bid,
-                                                      lpaddr_t base,
-                                                      size_t len,
+                                                      genoffset_t offset,
+                                                      genoffset_t length,
+                                                      genoffset_t valid_data,
+                                                      genoffset_t valid_length,
                                                       uint64_t flags)
 {
     struct devq_buf* buf;
@@ -262,21 +263,24 @@ static inline int sfn5122f_queue_add_user_rxbuf_devif(sfn5122f_queue_t* q,
     buf = &q->rx_bufs[tail];
 
     buf->rid = rid;
-    buf->bid = devq_bid;
-    buf->addr = base;
-    buf->len = len;
+    buf->offset = offset;
+    buf->length = length;
+    buf->valid_data = valid_data;
+    buf->valid_length = valid_length;
     buf->flags = flags;
     sfn5122f_q_rx_user_desc_rx_user_buf_id_insert(d, buf_id);
-    sfn5122f_q_rx_user_desc_rx_user_2byte_offset_insert(d, offset >> 1);
+    sfn5122f_q_rx_user_desc_rx_user_2byte_offset_insert(d, b_off >> 1);
     q->rx_tail = (tail + 1) % q->rx_size;
     return 0;
 }
 
 static inline int sfn5122f_queue_add_rxbuf_devif(sfn5122f_queue_t* q, 
-                                                 regionid_t rid,
-                                                 bufferid_t bid,
                                                  lpaddr_t addr,
-                                                 size_t len,
+                                                 regionid_t rid,
+                                                 genoffset_t offset,
+                                                 genoffset_t length,
+                                                 genoffset_t valid_data,
+                                                 genoffset_t valid_length,
                                                  uint64_t flags)
 {
     struct devq_buf* buf;
@@ -288,24 +292,26 @@ static inline int sfn5122f_queue_add_rxbuf_devif(sfn5122f_queue_t* q,
     buf = &q->rx_bufs[tail];
 
     buf->rid = rid;
-    buf->bid = bid;
-    buf->addr = addr;
-    buf->len = len;
+    buf->offset = offset;
+    buf->length = length;
+    buf->valid_data = valid_data;
+    buf->valid_length = valid_length;
     buf->flags = flags;
 
     sfn5122f_q_rx_ker_desc_rx_ker_buf_addr_insert(d, addr);
     sfn5122f_q_rx_ker_desc_rx_ker_buf_region_insert(d, 0);
     // TODO: Check size
-    sfn5122f_q_rx_ker_desc_rx_ker_buf_size_insert(d, len);
+    sfn5122f_q_rx_ker_desc_rx_ker_buf_size_insert(d, length);
     q->rx_tail = (tail + 1) % q->rx_size;
     return 0;
 }
 
 static inline errval_t sfn5122f_queue_handle_rx_ev_devif(sfn5122f_queue_t* q, 
                                                          regionid_t* rid,
-                                                         bufferid_t* bid,
-                                                         lpaddr_t* base,
-                                                         size_t* len,
+                                                         genoffset_t* offset,
+                                                         genoffset_t* length,
+                                                         genoffset_t* valid_data,
+                                                         genoffset_t* valid_length,
                                                          uint64_t* flags)
 {   
     /*  Only one event is generated even if there is more than one
@@ -322,8 +328,9 @@ static inline errval_t sfn5122f_queue_handle_rx_ev_devif(sfn5122f_queue_t* q,
     buf = &q->rx_bufs[rx_head];
 
     *rid = buf->rid;
-    *bid = buf->bid;
-    *base = buf->addr;
+    *offset = buf->offset;
+    *length = buf->length;
+    *valid_data = buf->valid_data;
     *flags = buf->flags;
 
     if(!sfn5122f_q_rx_ev_rx_ev_pkt_ok_extract(ev)) {   
@@ -341,10 +348,10 @@ static inline errval_t sfn5122f_queue_handle_rx_ev_devif(sfn5122f_queue_t* q,
          return SFN_ERR_RX_PKT;
     }
 
-    *len = sfn5122f_q_rx_ev_rx_ev_byte_ctn_extract(ev);
+    *valid_length = sfn5122f_q_rx_ev_rx_ev_byte_ctn_extract(ev);
     /* Length of 0 is treated as 16384 bytes */
-    if (*len == 0) {
-        *len = 16384;
+    if (*valid_length == 0) {
+        *valid_length = 16384;
     }
 
     rx_head = sfn5122f_q_rx_ev_rx_ev_desc_ptr_extract(ev);
@@ -353,8 +360,9 @@ static inline errval_t sfn5122f_queue_handle_rx_ev_devif(sfn5122f_queue_t* q,
     buf = &q->rx_bufs[rx_head];
 
     *rid = buf->rid;
-    *bid = buf->bid;
-    *base = buf->addr;
+    *offset = buf->offset;
+    *length = buf->length;
+    *valid_data = buf->valid_data;
     *flags = buf->flags;
 
     memset(ev, 0xff, sfn5122f_q_event_entry_size);
@@ -409,9 +417,10 @@ static inline bool is_batched(size_t size, uint16_t tx_head, uint16_t q_tx_head)
 
 static inline errval_t sfn5122f_queue_handle_tx_ev_devif(sfn5122f_queue_t* q, 
                                                          regionid_t* rid,
-                                                         bufferid_t* bid,
-                                                         lpaddr_t* base,
-                                                         size_t* len,
+                                                         genoffset_t* offset,
+                                                         genoffset_t* length,
+                                                         genoffset_t* valid_data,
+                                                         genoffset_t* valid_length,
                                                          uint64_t* flags)
 {
     /*  Only one event is generated even if there is more than one
@@ -432,10 +441,10 @@ static inline errval_t sfn5122f_queue_handle_tx_ev_devif(sfn5122f_queue_t* q,
     //        q->tx_size);
 
     *rid = buf->rid;
-    *bid = buf->bid;
-    *base = buf->addr;
+    *offset = buf->offset;
+    *length = buf->length;
+    *valid_data = buf->valid_data;
     *flags = buf->flags;
-    *len = buf->len;
 
     if (sfn5122f_q_tx_ev_tx_ev_pkt_err_extract(ev)){     
         q->tx_head = (tx_head +1) % q->tx_size;
@@ -451,10 +460,11 @@ static inline errval_t sfn5122f_queue_handle_tx_ev_devif(sfn5122f_queue_t* q,
             while (q->tx_head != (tx_head + 1) % q->tx_size ) {
                 buf = &q->tx_bufs[q->tx_head];
                 q->bufs[index].rid = buf->rid;
-                q->bufs[index].bid = buf->bid;
-                q->bufs[index].addr = buf->addr;
+                q->bufs[index].offset = buf->offset;
+                q->bufs[index].valid_data = buf->valid_data;
+                q->bufs[index].valid_length = buf->valid_length;
                 q->bufs[index].flags = buf->flags;
-                q->bufs[index].len = buf->len;
+                q->bufs[index].length = buf->length;
                 d_user = q->tx_ring.user[tx_head];  
                 index++;
                 q->tx_head = (q->tx_head + 1) % q->tx_size;
@@ -476,10 +486,12 @@ static inline errval_t sfn5122f_queue_handle_tx_ev_devif(sfn5122f_queue_t* q,
 }
 
 static inline int sfn5122f_queue_add_txbuf_devif(sfn5122f_queue_t* q, 
+                                                 lpaddr_t addr,
                                                  regionid_t rid,
-                                                 bufferid_t bid,
-                                                 lpaddr_t base,
-                                                 size_t len,
+                                                 genoffset_t offset,
+                                                 genoffset_t length,
+                                                 genoffset_t valid_data,
+                                                 genoffset_t valid_length,
                                                  uint64_t flags)
 {
     struct devq_buf* buf;
@@ -492,13 +504,14 @@ static inline int sfn5122f_queue_add_txbuf_devif(sfn5122f_queue_t* q,
    
     bool last = flags & NETIF_TXFLAG_LAST;    
     buf->rid = rid;
-    buf->bid = bid;
-    buf->addr = base;
-    buf->len = len;
+    buf->offset = offset;
+    buf->length = length;
+    buf->valid_data = valid_data;
+    buf->valid_length = valid_length;
     buf->flags = flags;
 
-    sfn5122f_q_tx_ker_desc_tx_ker_buf_addr_insert(d, base);
-    sfn5122f_q_tx_ker_desc_tx_ker_byte_count_insert(d, len);
+    sfn5122f_q_tx_ker_desc_tx_ker_buf_addr_insert(d, addr);
+    sfn5122f_q_tx_ker_desc_tx_ker_byte_count_insert(d, valid_length);
     sfn5122f_q_tx_ker_desc_tx_ker_cont_insert(d, !last);
     sfn5122f_q_tx_ker_desc_tx_ker_buf_region_insert(d, 0);
 
@@ -511,11 +524,12 @@ static inline int sfn5122f_queue_add_txbuf_devif(sfn5122f_queue_t* q,
 
 static inline int sfn5122f_queue_add_user_txbuf_devif(sfn5122f_queue_t* q, 
                                                       uint64_t buftbl_idx, 
-                                                      uint64_t offset,
+                                                      uint64_t b_off,
                                                       regionid_t rid,
-                                                      bufferid_t devq_bid,
-                                                      lpaddr_t base,
-                                                      size_t len,
+                                                      genoffset_t offset,
+                                                      genoffset_t length,
+                                                      genoffset_t valid_data,
+                                                      genoffset_t valid_length,
                                                       uint64_t flags)
 {
     
@@ -529,16 +543,17 @@ static inline int sfn5122f_queue_add_user_txbuf_devif(sfn5122f_queue_t* q,
    
     bool last = flags & NETIF_TXFLAG_LAST;    
     buf->rid = rid;
-    buf->bid = devq_bid;
-    buf->addr = base;
-    buf->len = len;
+    buf->offset = offset;
+    buf->length = length;
+    buf->valid_data = valid_data;
+    buf->valid_length = valid_length;
     buf->flags = flags;
 
     sfn5122f_q_tx_user_desc_tx_user_sw_ev_en_insert(d, 0);
     sfn5122f_q_tx_user_desc_tx_user_cont_insert(d, !last);
-    sfn5122f_q_tx_user_desc_tx_user_byte_cnt_insert(d, len);
+    sfn5122f_q_tx_user_desc_tx_user_byte_cnt_insert(d, valid_length);
     sfn5122f_q_tx_user_desc_tx_user_buf_id_insert(d, buftbl_idx);
-    sfn5122f_q_tx_user_desc_tx_user_byte_ofs_insert(d, offset);
+    sfn5122f_q_tx_user_desc_tx_user_byte_ofs_insert(d, b_off);
 
     __sync_synchronize();
  
index 4d8997b..77b36e4 100644 (file)
  *
  * @param q             The device queue to call the operation on
  * @param region_id     Id of the memory region the buffer belongs to
- * @param base          Physical address of the start of the enqueued buffer
+ * @param offset        Offset into the region i.e. where the buffer starts
+ *                      that is enqueued
  * @param lenght        Lenght of the enqueued buffer
+ * @param valid_data    Offset into the region where the valid data of this buffer
+ *                      starts
+ * @param valid_length  Length of the valid data of this buffer
  * @param misc_flags    Any other argument that makes sense to the device queue
- * @param buffer_id     Return pointer to buffer id of the enqueued buffer 
- *                      buffer_id is assigned by the interface
  *
  * @returns error on failure or SYS_ERR_OK on success
  *
  */
-
 errval_t devq_enqueue(struct devq *q,
                       regionid_t region_id,
-                      lpaddr_t base,
-                      size_t length,
-                      uint64_t misc_flags,
-                      bufferid_t* buffer_id)
+                      genoffset_t offset,
+                      genoffset_t length,
+                      genoffset_t valid_data,
+                      genoffset_t valid_length,
+                      uint64_t misc_flags)
 {
     errval_t err;
 
@@ -51,20 +53,21 @@ errval_t devq_enqueue(struct devq *q,
        access. In the device case, we keep track of the buffers the device
        actually has access to.
     */
+    /* TODO do bounds checks
     if (q->exp) {
         err = region_pool_return_buffer_to_region(q->pool, region_id, base);
     } else {
         err = region_pool_get_buffer_id_from_region(q->pool, region_id, base,
                                                     buffer_id);
     }
-
     if (err_is_fail(err)) {
         return err;
     }
+    */
+    err = q->f.enq(q, region_id, offset, length, valid_data,
+                   valid_length, misc_flags);
 
-    err = q->f.enq(q, region_id, *buffer_id, base, length, 
-                   misc_flags);
-
+    /*
     if (err_is_fail(err)){
         if (q->exp) {
             region_pool_get_buffer_id_from_region(q->pool, region_id, base,
@@ -73,7 +76,7 @@ errval_t devq_enqueue(struct devq *q,
             region_pool_return_buffer_to_region(q->pool, region_id, base);
         }
     }
-
+    */
     DQI_DEBUG("Enqueue q=%p rid=%d, bid=%d, err=%s \n", q, region_id, 
               *buffer_id, err_getstring(err));
 
@@ -86,27 +89,30 @@ errval_t devq_enqueue(struct devq *q,
  * @param q             The device queue to call the operation on
  * @param region_id     Return pointer to the id of the memory 
  *                      region the buffer belongs to
- * @param base          Return pointer to the physical address of 
- *                      the of the buffer
+ * @param region_offset Return pointer to the offset into the region where
+ *                      this buffer starts.
  * @param lenght        Return pointer to the lenght of the dequeue buffer
- * @param buffer_id     Return pointer to the buffer id of the dequeued buffer 
+ * @param valid_data    Return pointer to an offset into the region where the
+ *                      valid data of this buffer starts
+ * @param valid_length  Return pointer to the length of the valid data of 
+ *                      this buffer
  * @param misc_flags    Return value from other endpoint
  *
  * @returns error on failure or SYS_ERR_OK on success
  *
  */
-
 errval_t devq_dequeue(struct devq *q,
                       regionid_t* region_id,
-                      lpaddr_t* base,
-                      size_t* length,
-                      bufferid_t* buffer_id,
+                      genoffset_t* offset,
+                      genoffset_t* length,
+                      genoffset_t* valid_data,
+                      genoffset_t* valid_length,
                       uint64_t* misc_flags)
 {
     errval_t err;
 
-    err = q->f.deq(q, region_id, buffer_id, base, length, 
-                   misc_flags);
+    err = q->f.deq(q, region_id, offset, length, valid_data,
+                   valid_length, misc_flags);
     if (err_is_fail(err)) {
         return err;
     }
@@ -116,6 +122,7 @@ errval_t devq_dequeue(struct devq *q,
        actually has access to.
     */
     // Add buffer to free ones
+    /*
     if (q->exp) {
         err = region_pool_set_buffer_id_from_region(q->pool, *region_id,
                                                     *base, *buffer_id);
@@ -127,7 +134,7 @@ errval_t devq_dequeue(struct devq *q,
     if (err_is_fail(err)) {
         return err;
     }
-
+    */
     DQI_DEBUG("Dequeue q=%p rid=%d, bid=%d \n", q, *region_id, *buffer_id);
 
     return SYS_ERR_OK;
index 45178f8..edec46c 100644 (file)
@@ -79,15 +79,19 @@ typedef errval_t (*devq_control_t)(struct devq *q,
   *
   * @param q            The device queue handle
   * @param region_id    The region id of the buffer
-  * @param buffer_id    The buffer id of the buffer
-  * @param base         The base address of the buffer
-  * @param length       The length of the buffer
+  * @param offset       Offset into the region where the buffer starts
+  * @param length       Length of the buffer
+  * @param valid_data   Offset into the region where the valid data of the
+  *                     buffer starts
+  * @param valid_length Length of the valid data in this buffer   
   * @param misc_flags   Misc flags
   *
   * @returns error on failure or SYS_ERR_OK on success
   */
 typedef errval_t (*devq_enqueue_t)(struct devq *q, regionid_t region_id,
-                                   bufferid_t buffer_id, lpaddr_t base, size_t length,
+                                   genoffset_t offset, genoffset_t length, 
+                                   genoffset_t valid_offset,
+                                   genoffset_t valid_length,
                                    uint64_t misc_flags);
 
  /**
@@ -96,15 +100,21 @@ typedef errval_t (*devq_enqueue_t)(struct devq *q, regionid_t region_id,
   *
   * @param q            The device queue handle
   * @param region_id    The region id of the buffer
-  * @param buffer_id    The buffer id of the buffer
-  * @param base         The base address of the buffer
-  * @param length       The length of the buffer
+  * @param offset       Return pointer to the offset into the region
+  *                     where the buffer starts
+  * @param length       Return pointer to the length of the buffer
+  * @param valid_offset Return pointer to the offset into the region
+  *                     where the valid data of the buffer starts
+  * @param valid_length Return pointer to the length of the valid data of
+  *                     this buffer
   * @param misc_flags   Misc flags
   *
   * @returns error on failure if the queue is empty or SYS_ERR_OK on success
   */
 typedef errval_t (*devq_dequeue_t)(struct devq *q, regionid_t* region_id,
-                                   bufferid_t* buffer_id, lpaddr_t* base, size_t* length,
+                                   genoffset_t* offset, genoffset_t* length, 
+                                   genoffset_t* valid_offset,
+                                   genoffset_t* valid_length,
                                    uint64_t* misc_flags);
 
 
index e7b4ed8..1c0ac52 100644 (file)
@@ -121,9 +121,10 @@ void ahci_simple_test(void)
 {
     errval_t err;
     regionid_t region_id = 0;
-    lpaddr_t base = 0;
-    size_t length = 0;
-    bufferid_t buffer_id = 0;
+    genoffset_t offset = 0;
+    genoffset_t length = 0;
+    genoffset_t valid_data = 0;
+    genoffset_t valid_length = 0;
 
     // Allocate a buffer:
     struct dma_mem mem;
@@ -156,14 +157,14 @@ void ahci_simple_test(void)
     }
 
     uint64_t flags = 0x0;
-    bufferid_t bid;
-    devq_enqueue(dq, region_id, id.base, 512, flags, &bid);
+    devq_enqueue(dq, region_id, 0, 512, 0, 512, flags);
     if (err_is_fail(err)) {
         USER_PANIC_ERR(err, "devq enqueue");
     }
 
     do {
-        err = devq_dequeue(dq, &region_id, &base, &length, &buffer_id, &flags);
+        err = devq_dequeue(dq, &region_id, &offset, &length, &valid_data, 
+                           &valid_length, &flags);
         if (err_is_ok(err)) {
             break;
         }
@@ -173,7 +174,7 @@ void ahci_simple_test(void)
         wait_for_interrupt();
     } while (err_no(err) == DEV_ERR_QUEUE_EMPTY);
 
-    assert (base == id.base);
+    assert (offset == 0);
     assert (length == 512);
 
     err = devq_deregister(dq, region_id, &mem.frame);
@@ -184,13 +185,15 @@ void ahci_simple_test(void)
     printf("[%s]: DONE\n", __FUNCTION__);
 }
 
-static void blocking_dequeue(void* q, regionid_t* region_id, lpaddr_t* base, 
-                             size_t* length, bufferid_t* buffer_id)
+static void blocking_dequeue(void* q, regionid_t* region_id, 
+                             genoffset_t* offset, genoffset_t* length,
+                             genoffset_t* valid_data, genoffset_t* valid_length)
 {
     uint64_t flags;
     errval_t err;
     do {
-        err = devq_dequeue(q, region_id, base, length, buffer_id, &flags);
+        err = devq_dequeue(q, region_id, offset, length, valid_data,
+                           valid_length, &flags);
         if (err_is_ok(err)) {
             break;
         }
@@ -206,10 +209,12 @@ static void blocking_dequeue(void* q, regionid_t* region_id, lpaddr_t* base,
 static void receive_block(void)
 {
     regionid_t rid = 0;
-    lpaddr_t base = 0;
-    size_t len = 0;
-    bufferid_t bid = 0;
-    blocking_dequeue(dq, &rid, &base, &len, &bid);
+    genoffset_t offset = 0;
+    genoffset_t length = 0;
+    genoffset_t valid_data = 0;
+    genoffset_t valid_length = 0;
+    blocking_dequeue(dq, &rid, &offset, &length, &valid_data,
+                     &valid_length);
     finish_counter++;
 }
 
@@ -239,8 +244,9 @@ void ahci_perf_sequential(size_t buffer_size, size_t block_size, bool write)
     for (size_t i=0; i < read_requests; i++) {
         uint64_t disk_block = write_flag | i;
         do {
-            err = devq_enqueue(dq, region_id, id.base + (i*block_size), 
-                               block_size, disk_block, &received[i]);
+            err = devq_enqueue(dq, region_id, (i*block_size), 
+                               block_size, (i*block_size),
+                               block_size, disk_block);
             if (err_is_ok(err)) {
                 break;
             }
@@ -315,8 +321,8 @@ void ahci_verify_sequential(size_t buffer_size, size_t block_size)
     for (size_t i=0; i < requests; i++) {
         uint64_t disk_block = write_flag | i;
         do {
-            err = devq_enqueue(dq, region_id, id.base + (i*block_size), block_size, 
-                               disk_block, &received[i]);
+            err = devq_enqueue(dq, region_id, (i*block_size), block_size, 
+                               (i*block_size), block_size, disk_block);
             if (err_is_ok(err)) {
                 break;
             }
@@ -341,8 +347,9 @@ void ahci_verify_sequential(size_t buffer_size, size_t block_size)
         //printf("%s:%s:%d: i: %zu requests: %zu\n", __FILE__, __FUNCTION__, __LINE__, i, requests);
         uint64_t disk_block = i;
         do {
-            err = devq_enqueue(dq, region_id, id.base + (i*block_size), 
-                               block_size, disk_block, &received[i]);
+            err = devq_enqueue(dq, region_id, (i*block_size), 
+                               block_size, (i*block_size), block_size,
+                               disk_block);
             if (err_is_ok(err)) {
                 break;
             }
index d05c7ea..48f5f91 100644 (file)
@@ -1606,8 +1606,7 @@ static void a_bind_cb(void *st, errval_t err, struct net_ARP_binding *b)
 {
     assert(err_is_ok(err));
     arp_binding = b;
-    err = net_ARP_rpc_client_init(arp_binding);
-    assert(err_is_ok(err));
+    net_ARP_rpc_client_init(arp_binding);
     net_arp_connected = true;
 }
 
index 3365d30..2aa0e3d 100644 (file)
@@ -65,20 +65,23 @@ static errval_t notify(struct descq* q)
     errval_t err = SYS_ERR_OK;
     //errval_t err2 = SYS_ERR_OK;
     regionid_t rid;
-    lpaddr_t base;
-    size_t len;
-    bufferid_t bid;
+    genoffset_t offset;
+    genoffset_t length;
+    genoffset_t valid_data;
+    genoffset_t valid_length;
     uint64_t flags;
     bool exit = false;
     uint16_t num_enq = 0;
     while(!exit) {
-        err = devq_dequeue(queue, &rid, &base, &len, &bid, &flags);
+        err = devq_dequeue(queue, &rid, &offset, &length, 
+                           &valid_data, &valid_length, &flags);
         if (err_is_fail(err)) {
             exit = true;
         } else {
            bool exit2 = false;
             while(!exit2) {
-                err = devq_enqueue(queue, rid, base, len, flags, &bid);
+                err = devq_enqueue(queue, rid, offset, length, valid_data,
+                                   valid_length, flags);
                 if (err_is_ok(err)) {
                     exit2 = true;
                     num_enq++;
index 724a440..9af1af5 100644 (file)
@@ -25,7 +25,8 @@
 //#define DEBUG(x...) printf("devif_test: " x)
 #define DEBUG(x...) do {} while (0)
 
-#define BUF_SIZE 2048
+#define TX_BUF_SIZE 2048
+#define RX_BUF_SIZE 2048
 #define NUM_ENQ 512
 #define NUM_RX_BUF 1024
 #define NUM_ROUNDS_TX 16384
@@ -75,10 +76,10 @@ static uint8_t udp_header[8] = {
 
 static void print_buffer(size_t len, bufferid_t bid)
 {
-    /*
+   /*
     uint8_t* buf = (uint8_t*) va_rx+bid;
-    DEBUG("Packet in region %p at address %p len %zu \n", 
-            va_rx, buf, len);
+    printf("Packet in region %p at address %p len %zu \n", 
+           va_rx, buf, len);
     for (int i = 0; i < len; i++) {
         if (((i % 10) == 0) && i > 0) {
             printf("\n");
@@ -104,15 +105,17 @@ static void event_cb(void* queue)
     errval_t err;
 
     regionid_t rid;
-    bufferid_t bid;
-    lpaddr_t addr;
-    size_t len;
+    genoffset_t offset;
+    genoffset_t length;
+    genoffset_t valid_data;
+    genoffset_t valid_length;
     uint64_t flags;
 
     err = SYS_ERR_OK;
 
     while (err == SYS_ERR_OK) {    
-        err = devq_dequeue(q, &rid, &addr, &len, &bid, &flags);
+        err = devq_dequeue(q, &rid, &offset, &length, &valid_data,  
+                           &valid_length, &flags);
         if (err_is_fail(err)) {
             break;
         }
@@ -123,7 +126,7 @@ static void event_cb(void* queue)
         } else if (flags & NETIF_RXFLAG) {
             num_rx++;
             DEBUG("Received RX buffer \n");
-            print_buffer(len, bid);
+            print_buffer(valid_length, offset);
         } else {
             printf("Unknown flags %lx \n", flags);
         }
@@ -231,18 +234,16 @@ static void test_net_tx(void)
         USER_PANIC("Registering memory to devq failed \n");
     }
     
-    lpaddr_t addr;  
-    bufferid_t bid;
 
     // write something into the buffers
     char* write = NULL;
 
     for (int i = 0; i < NUM_ENQ; i++) {
-        write = va_tx + i*(BUF_SIZE);
+        write = va_tx + i*(TX_BUF_SIZE);
         for (int j = 0; j < 8; j++) {
             write[j] = udp_header[j];
         }
-        for (int j = 8; j < BUF_SIZE; j++) {
+        for (int j = 8; j < TX_BUF_SIZE; j++) {
             write[j] = 'a';
         }
     }
@@ -252,10 +253,9 @@ static void test_net_tx(void)
 
     for (int z = 0; z < NUM_ROUNDS_TX; z++) {
         for (int i = 0; i < NUM_ENQ; i++) {
-            addr = phys_tx+(i*(BUF_SIZE));
-
-            err = devq_enqueue(q, regid_tx, addr, BUF_SIZE, 
-                               NETIF_TXFLAG | NETIF_TXFLAG_LAST, &bid);
+            err = devq_enqueue(q, regid_tx, i*(TX_BUF_SIZE), TX_BUF_SIZE, 
+                               i*(TX_BUF_SIZE), TX_BUF_SIZE,
+                               NETIF_TXFLAG | NETIF_TXFLAG_LAST);
             if (err_is_fail(err)){
                 USER_PANIC("Devq enqueue failed \n");
             }    
@@ -274,7 +274,7 @@ static void test_net_tx(void)
     cycles_t t2 = bench_tsc();
     cycles_t result = (t2 -t1 - bench_tscoverhead());
  
-    uint64_t sent_bytes = (uint64_t) BUF_SIZE*NUM_ENQ*NUM_ROUNDS_TX;
+    uint64_t sent_bytes = (uint64_t) TX_BUF_SIZE*NUM_ENQ*NUM_ROUNDS_TX;
     double result_ms = (double) bench_tsc_to_ms(result);
     double bw = sent_bytes / result_ms / 1000;
     
@@ -335,14 +335,11 @@ static void test_net_rx(void)
         USER_PANIC("Registering memory to devq failed \n");
     }
     
-    lpaddr_t addr;  
-    bufferid_t bid;
-
     // Enqueue RX buffers to receive into
     for (int i = 0; i < NUM_ROUNDS_RX; i++){
-        addr = phys_rx+(i*2048);
-        err = devq_enqueue(q, regid_rx, addr, 2048, 
-                           NETIF_RXFLAG, &bid);
+        err = devq_enqueue(q, regid_rx, i*RX_BUF_SIZE, RX_BUF_SIZE, 
+                           i*RX_BUF_SIZE, RX_BUF_SIZE,
+                           NETIF_RXFLAG);
         if (err_is_fail(err)){
             USER_PANIC("Devq enqueue failed: %s\n", err_getstring(err));
         }    
@@ -386,13 +383,15 @@ static errval_t descq_notify(struct descq* q)
     struct devq* queue = (struct devq*) q;
     
     regionid_t rid;
-    bufferid_t bid;
-    lpaddr_t addr;
+    genoffset_t offset;
+    genoffset_t length;
+    genoffset_t valid_data;
+    genoffset_t valid_length;
     uint64_t flags;
-    size_t len;
 
     while(err_is_ok(err)) {
-        err = devq_dequeue(queue, &rid, &addr, &len, &bid, &flags);
+        err = devq_dequeue(queue, &rid, &offset, &length, &valid_data, 
+                           &valid_length, &flags);
         if (err_is_ok(err)){
             num_rx++;
         }
@@ -431,14 +430,11 @@ static void test_idc_queue(void)
         USER_PANIC("Registering memory to devq failed \n");
     }
  
-    lpaddr_t addr;
-    bufferid_t bid;
     // Enqueue RX buffers to receive into
     for (int j = 0; j < 1000000; j++){
         for (int i = 0; i < 32; i++){
-            addr = phys_rx+(i*2048);
-            err = devq_enqueue(q, regid_rx, addr, 2048, 
-                               0, &bid);
+            err = devq_enqueue(q, regid_rx, i*2048, 2048, 
+                               i*2048, 2048, 0);
             if (err_is_fail(err)){
                 // retry
                 i--;