Whamcloud - gitweb
b=2776
[fs/lustre-release.git] / lustre / portals / include / portals / lib-nal.h
index 4052c0c..d1d0495 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _LIB_NAL_H_
 #define _LIB_NAL_H_
 
+#include "build_check.h"
 /*
  * nal.h
  *
@@ -18,47 +19,60 @@ struct nal_cb_t {
        lib_ni_t ni;
        void *nal_data;
        /*
-        * send:  Sends a preformatted header and user data to a
-        * specified remote process.
-        * Can overwrite iov.
+        * send: Sends a preformatted header and payload data to a
+        * specified remote process. The payload is scattered over 'niov'
+        * fragments described by iov, starting at 'offset' for 'mlen'
+        * bytes.  
+        * NB the NAL may NOT overwrite iov.  
+        * PTL_OK on success => NAL has committed to send and will call
+        * lib_finalize on completion
         */
-       int (*cb_send) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
-                       ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
-                       unsigned int niov, struct iovec *iov, size_t mlen);
+       ptl_err_t (*cb_send) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
+                             ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
+                             unsigned int niov, struct iovec *iov, 
+                             size_t offset, size_t mlen);
 
        /* as send, but with a set of page fragments (NULL if not supported) */
-       int (*cb_send_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
-                             ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
-                             unsigned int niov, ptl_kiov_t *iov, size_t mlen);
+       ptl_err_t (*cb_send_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
+                                   ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
+                                   unsigned int niov, ptl_kiov_t *iov, 
+                                   size_t offset, size_t mlen);
        /*
-        * recv: Receives an incoming message from a remote process
-        * Type of iov depends on options.  Can overwrite iov.
+        * recv: Receives an incoming message from a remote process.  The
+        * payload is to be received into the scattered buffer of 'niov'
+        * fragments described by iov, starting at 'offset' for 'mlen'
+        * bytes.  Payload bytes after 'mlen' up to 'rlen' are to be
+        * discarded.  
+        * NB the NAL may NOT overwrite iov.
+        * PTL_OK on success => NAL has committed to receive and will call
+        * lib_finalize on completion
         */
-       int (*cb_recv) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
-                       unsigned int niov, struct iovec *iov, size_t mlen
-                       size_t rlen);
+       ptl_err_t (*cb_recv) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
+                             unsigned int niov, struct iovec *iov
+                             size_t offset, size_t mlen, size_t rlen);
 
        /* as recv, but with a set of page fragments (NULL if not supported) */
-       int (*cb_recv_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
-                             unsigned int niov, ptl_kiov_t *iov, size_t mlen
-                             size_t rlen);
+       ptl_err_t (*cb_recv_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
+                                   unsigned int niov, ptl_kiov_t *iov
+                                   size_t offset, size_t mlen, size_t rlen);
        /*
         * read: Reads a block of data from a specified user address
         */
-       int (*cb_read) (nal_cb_t * nal, void *private, void *dst_addr,
-                       user_ptr src_addr, size_t len);
+       ptl_err_t (*cb_read) (nal_cb_t * nal, void *private, void *dst_addr,
+                             user_ptr src_addr, size_t len);
 
        /*
         * write: Writes a block of data into a specified user address
         */
-       int (*cb_write) (nal_cb_t * nal, void *private, user_ptr dsr_addr,
-                        void *src_addr, size_t len);
+       ptl_err_t (*cb_write) (nal_cb_t * nal, void *private, user_ptr dsr_addr,
+                              void *src_addr, size_t len);
 
        /*
         * callback: Calls an event callback
+        * NULL => lib calls eq's callback (if any) directly.
         */
-       int (*cb_callback) (nal_cb_t * nal, void *private, lib_eq_t *eq,
-                        ptl_event_t *ev);
+       void (*cb_callback) (nal_cb_t * nal, void *private, lib_eq_t *eq,
+                            ptl_event_t *ev);
 
        /*
         *  malloc: Acquire a block of memory in a system independent
@@ -74,14 +88,14 @@ struct nal_cb_t {
         * type of *iov depends on options.
         * Set to NULL if not required.
         */
-       int (*cb_map) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
-                      void **addrkey);
+       ptl_err_t (*cb_map) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
+                            void **addrkey);
        void (*cb_unmap) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
                          void **addrkey);
 
        /* as (un)map, but with a set of page fragments */
-       int (*cb_map_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
-                            void **addrkey);
+       ptl_err_t (*cb_map_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
+                                  void **addrkey);
        void (*cb_unmap_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
                          void **addrkey);