Whamcloud - gitweb
LU-4423 lnet: don't use iovec instead of kvec
[fs/lustre-release.git] / lnet / include / lnet / lib-lnet.h
index 3daa92c..d23e4b1 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #ifndef __LNET_LIB_LNET_H__
 #define __LNET_LIB_LNET_H__
 
+#ifndef __KERNEL__
+# error This include is only for kernel use.
+#endif
+
 #include <libcfs/libcfs.h>
-#include <lnet/types.h>
+#include <lnet/api.h>
 #include <lnet/lnet.h>
 #include <lnet/lib-types.h>
-#include <lnet/lib-dlc.h>
 
 extern lnet_t  the_lnet;                        /* THE network */
 
@@ -454,14 +457,14 @@ extern lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
 extern lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt);
 extern lnet_ni_t *lnet_net2ni(__u32 net);
 
-int lnet_init(void);
-void lnet_fini(void);
+int lnet_lib_init(void);
+void lnet_lib_exit(void);
 
 extern int portal_rotor;
 
 int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, cfs_time_t when);
 void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when);
-int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid,
+int lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway_nid,
                   unsigned int priority);
 int lnet_check_routes(void);
 int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
@@ -478,6 +481,22 @@ int lnet_get_net_config(int idx,
                        struct lnet_ioctl_net_config *net_config);
 int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg);
 
+struct libcfs_ioctl_handler {
+       struct list_head item;
+       int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
+};
+
+#define DECLARE_IOCTL_HANDLER(ident, func)                      \
+       static struct libcfs_ioctl_handler ident = {            \
+               /* .item = */ LIST_HEAD_INIT(ident.item),       \
+               /* .handle_ioctl = */ func                      \
+       }
+
+extern int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
+extern int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
+extern int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+                               struct libcfs_ioctl_hdr __user *uparam);
+
 void lnet_proc_init(void);
 void lnet_proc_fini(void);
 int  lnet_rtrpools_alloc(int im_a_router);
@@ -491,6 +510,7 @@ int lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets,
                    __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr,
                    __s32 credits);
 int lnet_dyn_del_ni(__u32 net);
+int lnet_clear_lazy_portal(struct lnet_ni *ni, int portal, char *reason);
 
 int lnet_islocalnid(lnet_nid_t nid);
 int lnet_islocalnet(__u32 net);
@@ -616,39 +636,39 @@ bool lnet_delay_rule_match_locked(lnet_hdr_t *hdr, struct lnet_msg *msg);
 void lnet_counters_get(lnet_counters_t *counters);
 void lnet_counters_reset(void);
 
-unsigned int lnet_iov_nob (unsigned int niov, struct iovec *iov);
-int lnet_extract_iov (int dst_niov, struct iovec *dst,
-                      int src_niov, struct iovec *src,
+unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
+int lnet_extract_iov(int dst_niov, struct kvec *dst,
+                     int src_niov, struct kvec *src,
                       unsigned int offset, unsigned int len);
 
 unsigned int lnet_kiov_nob (unsigned int niov, lnet_kiov_t *iov);
-int lnet_extract_kiov (int dst_niov, lnet_kiov_t *dst,
-                      int src_niov, lnet_kiov_t *src,
-                      unsigned int offset, unsigned int len);
-
-void lnet_copy_iov2iov (unsigned int ndiov, struct iovec *diov,
-                        unsigned int doffset,
-                        unsigned int nsiov, struct iovec *siov,
-                        unsigned int soffset, unsigned int nob);
-void lnet_copy_kiov2iov (unsigned int niov, struct iovec *iov,
-                         unsigned int iovoffset,
-                         unsigned int nkiov, lnet_kiov_t *kiov,
-                         unsigned int kiovoffset, unsigned int nob);
-void lnet_copy_iov2kiov (unsigned int nkiov, lnet_kiov_t *kiov,
-                         unsigned int kiovoffset,
-                         unsigned int niov, struct iovec *iov,
-                         unsigned int iovoffset, unsigned int nob);
-void lnet_copy_kiov2kiov (unsigned int ndkiov, lnet_kiov_t *dkiov,
-                          unsigned int doffset,
-                          unsigned int nskiov, lnet_kiov_t *skiov,
-                          unsigned int soffset, unsigned int nob);
+int lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
+                    int src_niov, lnet_kiov_t *src,
+                    unsigned int offset, unsigned int len);
+
+void lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov,
+                      unsigned int doffset,
+                      unsigned int nsiov, struct kvec *siov,
+                      unsigned int soffset, unsigned int nob);
+void lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov,
+                       unsigned int iovoffset,
+                       unsigned int nkiov, lnet_kiov_t *kiov,
+                       unsigned int kiovoffset, unsigned int nob);
+void lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov,
+                       unsigned int kiovoffset,
+                       unsigned int niov, struct kvec *iov,
+                       unsigned int iovoffset, unsigned int nob);
+void lnet_copy_kiov2kiov(unsigned int ndkiov, lnet_kiov_t *dkiov,
+                        unsigned int doffset,
+                        unsigned int nskiov, lnet_kiov_t *skiov,
+                        unsigned int soffset, unsigned int nob);
 
 static inline void
 lnet_copy_iov2flat(int dlen, __user void *dest, unsigned int doffset,
-                   unsigned int nsiov, struct iovec *siov, unsigned int soffset,
+                  unsigned int nsiov, struct kvec *siov, unsigned int soffset,
                    unsigned int nob)
 {
-        struct iovec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
+       struct kvec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
 
         lnet_copy_iov2iov(1, &diov, doffset,
                           nsiov, siov, soffset, nob);
@@ -659,18 +679,18 @@ lnet_copy_kiov2flat(int dlen, void __user *dest, unsigned int doffset,
                    unsigned int nsiov, lnet_kiov_t *skiov,
                    unsigned int soffset, unsigned int nob)
 {
-        struct iovec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
+       struct kvec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
 
         lnet_copy_kiov2iov(1, &diov, doffset,
                            nsiov, skiov, soffset, nob);
 }
 
 static inline void
-lnet_copy_flat2iov(unsigned int ndiov, struct iovec *diov, unsigned int doffset,
+lnet_copy_flat2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
                   int slen, void __user *src, unsigned int soffset,
                   unsigned int nob)
 {
-        struct iovec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
+       struct kvec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
         lnet_copy_iov2iov(ndiov, diov, doffset,
                           1, &siov, soffset, nob);
 }
@@ -680,7 +700,7 @@ lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov,
                    unsigned int doffset, int slen, void __user *src,
                    unsigned int soffset, unsigned int nob)
 {
-        struct iovec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
+       struct kvec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
         lnet_copy_iov2kiov(ndiov, dkiov, doffset,
                            1, &siov, soffset, nob);
 }
@@ -693,7 +713,7 @@ void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd);
 void lnet_register_lnd(lnd_t *lnd);
 void lnet_unregister_lnd(lnd_t *lnd);
 
-int lnet_connect(cfs_socket_t **sockp, lnet_nid_t peer_nid,
+int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
                  __u32 local_ip, __u32 peer_ip, int peer_port);
 void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
                                 __u32 peer_ip, int port);
@@ -703,6 +723,21 @@ int lnet_acceptor_port(void);
 int lnet_acceptor_start(void);
 void lnet_acceptor_stop(void);
 
+int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
+int lnet_ipif_enumerate(char ***names);
+void lnet_ipif_free_enumeration(char **names, int n);
+int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
+int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
+int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
+int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
+int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
+
+int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
+int lnet_sock_accept(struct socket **newsockp, struct socket *sock);
+int lnet_sock_connect(struct socket **sockp, int *fatal,
+                       __u32 local_ip, int local_port,
+                       __u32 peer_ip, int peer_port);
+
 int lnet_peers_start_down(void);
 int lnet_peer_buffer_credits(lnet_ni_t *ni);