xref: /freebsd/sys/dev/iscsi/icl_conn_if.m (revision da5137ab)
1#-
2# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3#
4# Copyright (c) 2014 The FreeBSD Foundation
5#
6# This software was developed by Edward Tomasz Napierala under sponsorship
7# from the FreeBSD Foundation.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28# SUCH DAMAGE.
29#
30# $FreeBSD$
31#
32
33#include <sys/bio.h>
34#include <sys/socket.h>
35#include <dev/iscsi/icl.h>
36
37INTERFACE icl_conn;
38
39CODE {
40	static void null_pdu_queue_cb(struct icl_conn *ic,
41	    struct icl_pdu *ip, icl_pdu_cb cb)
42	{
43		ICL_CONN_PDU_QUEUE(ic, ip);
44		if (cb)
45			cb(ip, 0);
46	}
47};
48
49METHOD size_t pdu_data_segment_length {
50	struct icl_conn *_ic;
51	const struct icl_pdu *_ip;
52};
53
54METHOD int pdu_append_bio {
55	struct icl_conn *_ic;
56	struct icl_pdu *_ip;
57	struct bio *_bp;
58	size_t _offset;
59	size_t _len;
60	int _flags;
61};
62
63METHOD int pdu_append_data {
64	struct icl_conn *_ic;
65	struct icl_pdu *_ip;
66	const void *_addr;
67	size_t _len;
68	int _flags;
69};
70
71METHOD void pdu_get_bio {
72	struct icl_conn *_ic;
73	struct icl_pdu *_ip;
74	size_t _pdu_off;
75	struct bio *_bp;
76	size_t _bio_off;
77	size_t _len;
78};
79
80METHOD void pdu_get_data {
81	struct icl_conn *_ic;
82	struct icl_pdu *_ip;
83	size_t _off;
84	void *_addr;
85	size_t _len;
86};
87
88METHOD void pdu_queue {
89	struct icl_conn *_ic;
90	struct icl_pdu *_ip;
91};
92
93METHOD void pdu_queue_cb {
94	struct icl_conn *_ic;
95	struct icl_pdu *_ip;
96	icl_pdu_cb cb;
97} DEFAULT null_pdu_queue_cb;
98
99METHOD void pdu_free {
100	struct icl_conn *_ic;
101	struct icl_pdu *_ip;
102};
103
104METHOD struct icl_pdu * new_pdu {
105	struct icl_conn *_ic;
106	int _flags;
107};
108
109METHOD void free {
110	struct icl_conn *_ic;
111};
112
113METHOD int handoff {
114	struct icl_conn *_ic;
115	int _fd;
116};
117
118METHOD void close {
119	struct icl_conn *_ic;
120};
121
122METHOD int task_setup {
123	struct icl_conn *_ic;
124	struct icl_pdu *_ip;
125	struct ccb_scsiio *_csio;
126	uint32_t *_task_tag;
127	void **_prvp;
128};
129
130METHOD void task_done {
131	struct icl_conn *_ic;
132	void *_prv;
133};
134
135METHOD int transfer_setup {
136	struct icl_conn *_ic;
137	struct icl_pdu *_ip;
138	union ctl_io *_io;
139	uint32_t *_transfer_tag;
140	void **_prvp;
141};
142
143METHOD void transfer_done {
144	struct icl_conn *_ic;
145	void *_prv;
146};
147
148#
149# The function below is only used with ICL_KERNEL_PROXY.
150#
151METHOD int connect {
152	struct icl_conn *_ic;
153	int _domain;
154	int _socktype;
155	int _protocol;
156	struct sockaddr *_from_sa;
157	struct sockaddr *_to_sa;
158};
159