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 /* 34 * This file is used to provide the initiator and target with a prettier 35 * interface. It must not be included by ICL modules, such as icl_soft.c. 36 */ 37 38 #ifndef ICL_WRAPPERS_H 39 #define ICL_WRAPPERS_H 40 41 #include <sys/kobj.h> 42 43 #include <dev/iscsi/icl.h> 44 #include <icl_conn_if.h> 45 46 static inline struct icl_pdu * 47 icl_pdu_new(struct icl_conn *ic, int flags) 48 { 49 50 return (ICL_CONN_NEW_PDU(ic, flags)); 51 } 52 53 static inline size_t 54 icl_pdu_data_segment_length(const struct icl_pdu *ip) 55 { 56 57 return (ICL_CONN_PDU_DATA_SEGMENT_LENGTH(ip->ip_conn, ip)); 58 } 59 60 static inline int 61 icl_pdu_append_data(struct icl_pdu *ip, const void *addr, size_t len, int flags) 62 { 63 64 return (ICL_CONN_PDU_APPEND_DATA(ip->ip_conn, ip, addr, len, flags)); 65 } 66 67 static inline void 68 icl_pdu_get_data(struct icl_pdu *ip, size_t off, void *addr, size_t len) 69 { 70 71 ICL_CONN_PDU_GET_DATA(ip->ip_conn, ip, off, addr, len); 72 } 73 74 static inline void 75 icl_pdu_queue(struct icl_pdu *ip) 76 { 77 78 ICL_CONN_PDU_QUEUE(ip->ip_conn, ip); 79 } 80 81 static inline void 82 icl_pdu_queue_cb(struct icl_pdu *ip, icl_pdu_cb cb) 83 { 84 85 ICL_CONN_PDU_QUEUE_CB(ip->ip_conn, ip, cb); 86 } 87 88 static inline void 89 icl_pdu_free(struct icl_pdu *ip) 90 { 91 92 ICL_CONN_PDU_FREE(ip->ip_conn, ip); 93 } 94 95 static inline void 96 icl_conn_free(struct icl_conn *ic) 97 { 98 99 ICL_CONN_FREE(ic); 100 } 101 102 static inline int 103 icl_conn_handoff(struct icl_conn *ic, int fd) 104 { 105 106 return (ICL_CONN_HANDOFF(ic, fd)); 107 } 108 109 static inline void 110 icl_conn_close(struct icl_conn *ic) 111 { 112 113 ICL_CONN_CLOSE(ic); 114 } 115 116 static inline int 117 icl_conn_task_setup(struct icl_conn *ic, struct icl_pdu *ip, 118 struct ccb_scsiio *csio, uint32_t *task_tagp, void **prvp) 119 { 120 121 return (ICL_CONN_TASK_SETUP(ic, ip, csio, task_tagp, prvp)); 122 } 123 124 static inline void 125 icl_conn_task_done(struct icl_conn *ic, void *prv) 126 { 127 128 ICL_CONN_TASK_DONE(ic, prv); 129 } 130 131 static inline int 132 icl_conn_transfer_setup(struct icl_conn *ic, union ctl_io *io, 133 uint32_t *transfer_tagp, void **prvp) 134 { 135 136 return (ICL_CONN_TRANSFER_SETUP(ic, io, transfer_tagp, prvp)); 137 } 138 139 static inline void 140 icl_conn_transfer_done(struct icl_conn *ic, void *prv) 141 { 142 143 ICL_CONN_TRANSFER_DONE(ic, prv); 144 } 145 146 /* 147 * The function below is only used with ICL_KERNEL_PROXY. 148 */ 149 static inline int 150 icl_conn_connect(struct icl_conn *ic, int domain, int socktype, 151 int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa) 152 { 153 154 return (ICL_CONN_CONNECT(ic, domain, socktype, protocol, 155 from_sa, to_sa)); 156 } 157 158 #endif /* !ICL_WRAPPERS_H */ 159