Whamcloud - gitweb
- merge 0.7rc1 from b_devel to HEAD (20030612 merge point)
[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 user data to a
22          * specified remote process.
23          * Can overwrite iov.
24          */
25         int (*cb_send) (nal_cb_t * nal, void *private, lib_msg_t * cookie, 
26                         ptl_hdr_t * hdr, int type, ptl_nid_t nid, ptl_pid_t pid, 
27                         unsigned int niov, struct iovec *iov, size_t mlen);
28
29         /* as send, but with a set of page fragments (NULL if not supported) */
30         int (*cb_send_pages) (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, ptl_kiov_t *iov, size_t mlen);
33         /*
34          * recv: Receives an incoming message from a remote process
35          * Type of iov depends on options.  Can overwrite iov.
36          */
37         int (*cb_recv) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
38                         unsigned int niov, struct iovec *iov, size_t mlen, 
39                         size_t rlen);
40
41         /* as recv, but with a set of page fragments (NULL if not supported) */
42         int (*cb_recv_pages) (nal_cb_t * nal, void *private, lib_msg_t * cookie,
43                               unsigned int niov, ptl_kiov_t *iov, size_t mlen, 
44                               size_t rlen);
45         /*
46          * read: Reads a block of data from a specified user address
47          */
48         int (*cb_read) (nal_cb_t * nal, void *private, void *dst_addr,
49                         user_ptr src_addr, size_t len);
50
51         /*
52          * write: Writes a block of data into a specified user address
53          */
54         int (*cb_write) (nal_cb_t * nal, void *private, user_ptr dsr_addr,
55                          void *src_addr, size_t len);
56
57         /*
58          * callback: Calls an event callback
59          */
60         int (*cb_callback) (nal_cb_t * nal, void *private, lib_eq_t *eq,
61                          ptl_event_t *ev);
62
63         /*
64          *  malloc: Acquire a block of memory in a system independent
65          * fashion.
66          */
67         void *(*cb_malloc) (nal_cb_t * nal, size_t len);
68
69         void (*cb_free) (nal_cb_t * nal, void *buf, size_t len);
70
71         /*
72          * (un)map: Tell the NAL about some memory it will access.
73          * *addrkey passed to cb_unmap() is what cb_map() set it to.
74          * type of *iov depends on options.
75          * Set to NULL if not required.
76          */
77         int (*cb_map) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
78                        void **addrkey);
79         void (*cb_unmap) (nal_cb_t * nal, unsigned int niov, struct iovec *iov, 
80                           void **addrkey);
81
82         /* as (un)map, but with a set of page fragments */
83         int (*cb_map_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
84                              void **addrkey);
85         void (*cb_unmap_pages) (nal_cb_t * nal, unsigned int niov, ptl_kiov_t *iov, 
86                           void **addrkey);
87
88         void (*cb_printf) (nal_cb_t * nal, const char *fmt, ...);
89
90         /* Turn interrupts off (begin of protected area) */
91         void (*cb_cli) (nal_cb_t * nal, unsigned long *flags);
92
93         /* Turn interrupts on (end of protected area) */
94         void (*cb_sti) (nal_cb_t * nal, unsigned long *flags);
95
96         /*
97          * Calculate a network "distance" to given node
98          */
99         int (*cb_dist) (nal_cb_t * nal, ptl_nid_t nid, unsigned long *dist);
100 };
101
102 #endif