Whamcloud - gitweb
- typo fixed
[fs/lustre-release.git] / lustre / portals / include / portals / lib-nal.h
1 #ifndef _LIB_NAL_H_
2 #define _LIB_NAL_H_
3
4 #include "build_check.h"
5 /*
6  * nal.h
7  *
8  * Library side headers that define the abstraction layer's
9  * responsibilities and interfaces
10  */
11
12 #include <portals/lib-types.h>
13
14 struct nal_cb_t {
15         /*
16          * Per interface portal table, access control table
17          * and NAL private data field;
18          */
19         lib_ni_t ni;
20         void *nal_data;
21         /*
22          * send: Sends a preformatted header and payload data to a
23          * specified remote process. The payload is scattered over 'niov'
24          * fragments described by iov, starting at 'offset' for 'mlen'
25          * bytes.  
26          * NB the NAL may NOT overwrite iov.  
27          * PTL_OK on success => NAL has committed to send and will call
28          * lib_finalize on completion
29          */
30         ptl_err_t (*cb_send) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
31                               ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
32                               unsigned int niov, struct iovec *iov, 
33                               size_t offset, size_t mlen);
34
35         /* as send, but with a set of page fragments (NULL if not supported) */
36         ptl_err_t (*cb_send_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
37                                     ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
38                                     unsigned int niov, ptl_kiov_t *iov, 
39                                     size_t offset, size_t mlen);
40         /*
41          * recv: Receives an incoming message from a remote process.  The
42          * payload is to be received into the scattered buffer of 'niov'
43          * fragments described by iov, starting at 'offset' for 'mlen'
44          * bytes.  Payload bytes after 'mlen' up to 'rlen' are to be
45          * discarded.  
46          * NB the NAL may NOT overwrite iov.
47          * PTL_OK on success => NAL has committed to receive and will call
48          * lib_finalize on completion
49          */
50         ptl_err_t (*cb_recv) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
51                               unsigned int niov, struct iovec *iov, 
52                               size_t offset, size_t mlen, size_t rlen);
53
54         /* as recv, but with a set of page fragments (NULL if not supported) */
55         ptl_err_t (*cb_recv_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
56                                     unsigned int niov, ptl_kiov_t *iov, 
57                                     size_t offset, size_t mlen, size_t rlen);
58         /*
59          * read: Reads a block of data from a specified user address
60          */
61         ptl_err_t (*cb_read) (nal_cb_t * nal, void *private, void *dst_addr,
62                               user_ptr src_addr, size_t len);
63
64         /*
65          * write: Writes a block of data into a specified user address
66          */
67         ptl_err_t (*cb_write) (nal_cb_t * nal, void *private, user_ptr dsr_addr,
68                                void *src_addr, size_t len);
69
70         /*
71          * callback: Calls an event callback
72          * NULL => lib calls eq's callback (if any) directly.
73          */
74         void (*cb_callback) (nal_cb_t * nal, void *private, lib_eq_t *eq,
75                              ptl_event_t *ev);
76
77         /*
78          *  malloc: Acquire a block of memory in a system independent
79          * fashion.
80          */
81         void *(*cb_malloc) (nal_cb_t * nal, size_t len);
82
83         void (*cb_free) (nal_cb_t * nal, void *buf, size_t len);
84
85         /*
86          * (un)map: Tell the NAL about some memory it will access.
87          * *addrkey passed to cb_unmap() is what cb_map() set it to.
88          * type of *iov depends on options.
89          * Set to NULL if not required.
90          */
91         ptl_err_t (*cb_map) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
92                              void **addrkey);
93         void (*cb_unmap) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
94                           void **addrkey);
95
96         /* as (un)map, but with a set of page fragments */
97         ptl_err_t (*cb_map_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
98                                    void **addrkey);
99         void (*cb_unmap_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
100                           void **addrkey);
101
102         void (*cb_printf) (nal_cb_t * nal, const char *fmt, ...);
103
104         /* Turn interrupts off (begin of protected area) */
105         void (*cb_cli) (nal_cb_t * nal, unsigned long *flags);
106
107         /* Turn interrupts on (end of protected area) */
108         void (*cb_sti) (nal_cb_t * nal, unsigned long *flags);
109
110         /*
111          * Calculate a network "distance" to given node
112          */
113         int (*cb_dist) (nal_cb_t * nal, ptl_nid_t nid, unsigned long *dist);
114 };
115
116 #endif