summaryrefslogtreecommitdiff
path: root/usr/iscsi_ipc.h
blob: fc67c4a93ac5b834d863c2340aab9340e968b0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * User/Kernel Transport IPC API Ioctl/NETLINK/etc
 *
 * Copyright (C) 2005 Dmitry Yusupov, Alex Aizman
 * maintained by open-iscsi@googlegroups.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * See the file COPYING included with this distribution for more details.
 *
 * NOTE: OSes must implement this API in terms of user's control-plane re-use.
 */

#ifndef ISCSI_IPC_H
#define ISCSI_IPC_H

#if defined(FreeBSD)
#include <sys/_iovec.h>
#endif

#include "iscsi_if.h"

enum {
	ISCSI_INT,
	ISCSI_STRING,
};

struct iscsi_conn;
struct iscsi_ev_context;

/*
 * When handling async events, the initiator may not be able to
 * handle the event in the same context, so this allows the interface
 * code to call into the initiator to shedule handling.
 */
struct iscsi_ipc_ev_clbk {
	void (*create_session) (uint32_t host_no, uint32_t sid);
	void (*destroy_session) (uint32_t host_no, uint32_t sid);

	struct iscsi_ev_context *(*get_ev_context) (struct iscsi_conn *conn,
						    int ev_size);
	void (*put_ev_context) (struct iscsi_ev_context *ev_context);
	int (*sched_ev_context) (struct iscsi_ev_context *ev_context,
				 struct iscsi_conn *conn,
				 unsigned long tmo, int event);
};

extern void ipc_register_ev_callback(struct iscsi_ipc_ev_clbk *ipc_ev_clbk);

/**
 * struct iscsi_ipc - Open-iSCSI Interface for Kernel IPC
 *
 * All functions allowed to return POSIX kind of error. i.e. 0 - OK, non-zero
 * means IPC error and errno set.
 */
struct iscsi_ipc {
	char *name;

	int ctldev_bufmax;

	int (*ctldev_open) (void);

	void (*ctldev_close) (void);

	int (*ctldev_handle) (void);

	int (*sendtargets) (uint64_t transport_handle, uint32_t host_no,
			    struct sockaddr *addr);

	int (*create_session) (uint64_t transport_handle, uint64_t ep_handle,
			       uint32_t initial_cmdsn, uint16_t cmds_max,
			       uint16_t qdepth, uint32_t *out_sid,
			       uint32_t *hostno);

	int (*destroy_session) (uint64_t transport_handle, uint32_t sid);

	int (*unbind_session) (uint64_t transport_handle, uint32_t sid);

	int (*create_conn) (uint64_t transport_handle,
			    uint32_t sid, uint32_t cid, uint32_t *out_cid);

	int (*destroy_conn) (uint64_t transport_handle, uint32_t sid,
			     uint32_t cid);

	int (*bind_conn) (uint64_t transport_handle, uint32_t sid,
			  uint32_t cid, uint64_t transport_eph,
			  int is_leading, int *retcode);

	int (*set_param) (uint64_t transport_handle, uint32_t sid,
			  uint32_t cid, enum iscsi_param param,
			  void *value, int type);

	int (*set_host_param) (uint64_t transport_handle, uint32_t host_no,
			       enum iscsi_host_param param,
			       void *value, int type);

	/* not implemented yet */
	int (*get_param) (uint64_t transport_handle, uint32_t sid,
			  uint32_t cid, enum iscsi_param param,
			  uint32_t *value, int *retcode);

	int (*get_stats) (uint64_t transport_handle, uint32_t sid,
			  uint32_t cid, char *statsbuf, int statsbuf_max);

	int (*start_conn) (uint64_t transport_handle, uint32_t sid,
			   uint32_t cid, int *retcode);

	int (*stop_conn) (uint64_t transport_handle, uint32_t sid,
			  uint32_t cid, int flag);

	int (*read) (char *data, int count);

	void (*send_pdu_begin) (uint64_t transport_handle, uint32_t sid,
				uint32_t cid, int hdr_size, int data_size);

	int (*send_pdu_end) (uint64_t transport_handle, uint32_t sid,
			     uint32_t cid, int *retcode);

	int (*writev) (enum iscsi_uevent_e type, struct iovec *iovp, int count);

	int (*recv_pdu_begin) (struct iscsi_conn *conn);

	int (*recv_pdu_end) (struct iscsi_conn *conn);

	int (*set_net_config) (uint64_t transport_handle, uint32_t host_no,
			       struct iovec *iovs, uint32_t param_count);

	int (*recv_conn_state) (struct iscsi_conn *conn, uint32_t *state);
};

#endif /* ISCSI_IPC_H */