libmemif: unmask head/tail pointers fix, additional ring info in memif_queue_details_t
[vpp.git] / extras / libmemif / src / libmemif.h
index a2d1a5e..796d121 100644 (file)
@@ -72,6 +72,8 @@ typedef enum
   MEMIF_ERR_DISCONNECT,                /*!< disconenct received */
   MEMIF_ERR_DISCONNECTED,      /*!< peer interface disconnected */
   MEMIF_ERR_UNKNOWN_MSG,       /*!< unknown message type */
+  MEMIF_ERR_POLL_CANCEL,       /*!< memif_poll_event() was cancelled */
+  MEMIF_ERR_MAX_RING,          /*!< too large ring size */
 } memif_err_t;
 
 /**
@@ -198,14 +200,21 @@ typedef struct
 /** \brief Memif queue details
     @param qid - queue id
     @param ring_size - size of ring buffer in sharem memory
+    @param flags - ring flags
+    @param head - ring head pointer
+    @param tail - ring tail pointer
     @param buffer_size - buffer size on sharem memory
 */
 typedef struct
 {
   uint8_t qid;
   uint32_t ring_size;
+/** if set queue is in polling mode, else in interrupt mode */
+#define MEMIF_QUEUE_FLAG_POLLING 1
+  uint16_t flags;
+  uint16_t head;
+  uint16_t tail;
   uint16_t buffer_size;
-  /* add ring information */
 } memif_queue_details_t;
 
 /** \brief Memif details
@@ -438,6 +447,21 @@ int memif_rx_burst (memif_conn_handle_t conn, uint16_t qid,
     \return memif_err_t
 */
 int memif_poll_event (int timeout);
+
+/** \brief Send signal to stop concurrently running memif_poll_event().
+
+    The function, however, does not wait for memif_poll_event() to stop.
+    memif_poll_event() may still return simply because an event has occured
+    or the timeout has elapsed, but if called repeatedly in an infinite loop,
+    a canceled memif_poll_event() is guaranted to return MEMIF_ERR_POLL_CANCEL
+    in the shortest possible time.
+    This feature was not available in the first release.
+    Use macro MEMIF_HAVE_CANCEL_POLL_EVENT to check if the feature is present.
+
+    \return memif_err_t
+*/
+#define MEMIF_HAVE_CANCEL_POLL_EVENT 1
+int memif_cancel_poll_event ();
 /** @} */
 
 #endif /* _LIBMEMIF_H_ */