Index: trunk/kernel/libk/remote_fifo.h
===================================================================
--- trunk/kernel/libk/remote_fifo.h	(revision 690)
+++ trunk/kernel/libk/remote_fifo.h	(revision 1)
@@ -1,7 +1,6 @@
 /*
- * remote_fifo.h - Lock-less Single-Reader Multiple-Writers FIFO
+ * remote_fifo.h - kernel generic SRMW FIFO
  *
- * Authors : Mohamed Lamine Karaoui (2015)
- *           Alain Greiner (2016,2017)
+ * Authors : Mohamed Lamine Karaoui / Alain Greiner (2016)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -26,33 +25,29 @@
 #define _REMOTE_FIFO_H_
 
-#include <kernel_config.h>
-#include <hal_kernel_types.h>
-#include <printk.h>
+#include <almos_config.h>
+#include <hal_types.h>
 #include <errno.h>
 #include <hal_remote.h>
 
 /************************************************************************************
- * This structure defines a generic, single reader, multiple writers FIFO,
- * that is used for - RPC based - inter cluster communications.
- * Each FIF0 slot can contain one 64 bits integer (or one extended pointer).
- * The number of slots is defined by the CONFIG_RPC_FIFO_SLOTS parameter.
- * - The write accesses are implemented using a lock-free algorithm, as it uses
- *   a ticket based mechanism to handle concurrent access between multiple writers.
- *   In case of FIFO full, the writer deschedule without blocking, to retry later.
- * - The reader must take the try_lock implemented by the "owner" field, using
- *   an atomic_add(). The TRDID is a good owner identifier, because all
- *   RPC threads in a given cluster belong to the same kernel process,
- *   and RPC threads cannot have local index LTID = 0.
-*
- * WARNING : Each FIFO requires 12 + (12 * CONFIG_RPC_FIFO_SLOTS) bytes.
+ * This structure defines a generic, single reader, multiple writers
+ * remote FIFO, that is used by the RPCs for inter cluster communications.
+ * The accesses are implemented using a lock-free algorithm, as it
+ * uses a ticket based mechanism to handle concurrent access between
+ * the multiple writers.
+ * Each FIF0 slot can contain one full cache line, even if RPCs store only
+ * an extended pointer on the RPC descriptor in each slot.
+ * In case of FIFO full, the writer deschedule without blocking, to retry later.
+ *
+ * WARNING : the number of slots is statically defined by the global 
+ * configuration parameter CONFIG_REMOTE_FIFO_SLOTS for all fifos, requiring
+ * CACHE_LINE_SIZE * CONFIG_REMOTE_FIFO_SLOTS bytes for each FIFO...
  ***********************************************************************************/
-
 typedef struct remote_fifo_s
 {
-    uint32_t           owner;                            /*! owner thread trdid    */
 	volatile uint32_t  wr_id;                            /*! write slot index      */
 	volatile uint32_t  rd_id;                            /*! read  slot index      */
-    volatile uint32_t  valid[CONFIG_RPC_FIFO_SLOTS];  /*! empty slot if 0       */
-	uint64_t           data[CONFIG_RPC_FIFO_SLOTS];   /*! fifo slot content     */
+    volatile bool_t    valid[CONFIG_REMOTE_FIFO_SLOTS];  /*! empty slot if false   */
+	cacheline_t        data[CONFIG_REMOTE_FIFO_SLOTS];   /*! fifo slot content     */
 }
 remote_fifo_t;
@@ -62,47 +57,53 @@
  * It can only initialise a local FIFO.
  ************************************************************************************
- * @ fifo    : local pointer to the local fifo.
+ * @ fifo    : pointer to the local fifo.
  ***********************************************************************************/
-void remote_fifo_init( remote_fifo_t * fifo );
+void local_fifo_init( remote_fifo_t * fifo );
 
 /************************************************************************************
  * This non blocking function tries to get one item from the local fifo.
- * The reader must get exclusive access for read before calling this function.  
+ * The reader must get exclusive access before calling this function.  
  * The read slot index is incremented.
  ************************************************************************************
- * @ fifo    : local pointer to the local fifo.
- * @ item    : [out] pointer on buffer for extracted item.
+ * @ fifo    : pointer to the local fifo.
+ * @ item    : pointer on destination buffer for extracted item.
+ * @ size    : actual number of bytes in one item.
  * @ return  0 on success, EAGAIN if the buffer is empty.
  ***********************************************************************************/
-error_t remote_fifo_get_item( remote_fifo_t * fifo, 
-                              uint64_t      * item );
+error_t local_fifo_get_item( remote_fifo_t * fifo, 
+                             void          * item,
+                             uint32_t        size );
 
 /************************************************************************************
  * This blocking function puts one item to a remote fifo identified
- * by an extended pointer. It gets a write ticket on the slot to be written,
- * using a remote_atomic_add() on the write slot index. Then, it waits until
- * the slot is empty, using a descheduling policy without blocking if required. 
- * It implements a watchdog, returning when the item has been successfully
- * registered, or after CONFIG_RPC_FIFO_MAX_ITERATIONS failures.   
+ * by an extended pointer.
+ * This function gets a write ticket using a remote_atomic_increment on the
+ * write slot index and waits until the slot is empty, using a descheduling
+ * policy (without blocking).
  ************************************************************************************
- * @ fifo    : extended pointer to the remote fifo.
- * @ item    : item to be stored.
+ * @ fifo    : extended pointer to the fifo in remote cluster.
+ * @ item    : pointer on a local buffer containing the item to be stored.
+ * @ size    : actual number of bytes in one item.
+ * @ first   : return value (true if first item registered in remote fifo)
  * @ return  0 on success / EBUSY if a contention has been detected.
  ***********************************************************************************/
 error_t remote_fifo_put_item( xptr_t     fifo,
-                              uint64_t   item );
+                              void     * item,
+                              uint32_t   size,
+                              bool_t   * first );
 
 /************************************************************************************
  * Query if local fifo is empty
  ************************************************************************************
- * @ fifo    : local pointer to the local fifo.
+ * @ fifo    : pointer to the fifo.
  * @ return true if the fifo is empty, false otherwise.
  ***********************************************************************************/
-bool_t remote_fifo_is_empty( remote_fifo_t * fifo );
+bool_t local_fifo_is_empty( remote_fifo_t * fifo );
 
 /************************************************************************************
  * Query if remote fifo is full
  ************************************************************************************
- * @ fifo    : extended pointer to the remote fifo.
+ * @ fifo    : pointer to the fifo in remote cluster.
+ * @ cxy	 : remote cluster index.
  * @ return true if the fifo is full, false otherwise.
  ***********************************************************************************/
@@ -112,5 +113,6 @@
  * Query number ot items in remote fifo.
  ************************************************************************************
- * @ fifo     : extended pointer to the remote fifo.
+ * @ fifo     : pointer to the fifo in remote cluster.
+ * @ cxy	  : remote cluster index.
  * @ return  number of items.
  ***********************************************************************************/
