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