1 /*- 2 * Copyright (c) 2014 The FreeBSD Foundation 3 * All rights reserved. 4 * 5 * This software was developed by Edward Tomasz Napierala under sponsorship 6 * from the FreeBSD Foundation. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 32 /* 33 * This file is used to provide the initiator and target with a prettier 34 * interface. It must not be included by ICL modules, such as icl_soft.c. 35 */ 36 37 #ifndef ICL_WRAPPERS_H 38 #define ICL_WRAPPERS_H 39 40 #include <sys/kobj.h> 41 42 #include <dev/iscsi/icl.h> 43 #include <icl_conn_if.h> 44 45 static inline struct icl_pdu * 46 icl_pdu_new(struct icl_conn *ic, int flags) 47 { 48 49 return (ICL_CONN_NEW_PDU(ic, flags)); 50 } 51 52 static inline size_t 53 icl_pdu_data_segment_length(const struct icl_pdu *ip) 54 { 55 56 return (ICL_CONN_PDU_DATA_SEGMENT_LENGTH(ip->ip_conn, ip)); 57 } 58 59 static inline int 60 icl_pdu_append_data(struct icl_pdu *ip, const void *addr, size_t len, int flags) 61 { 62 63 return (ICL_CONN_PDU_APPEND_DATA(ip->ip_conn, ip, addr, len, flags)); 64 } 65 66 static inline void 67 icl_pdu_get_data(struct icl_pdu *ip, size_t off, void *addr, size_t len) 68 { 69 70 ICL_CONN_PDU_GET_DATA(ip->ip_conn, ip, off, addr, len); 71 } 72 73 static inline void 74 icl_pdu_queue(struct icl_pdu *ip) 75 { 76 77 ICL_CONN_PDU_QUEUE(ip->ip_conn, ip); 78 } 79 80 static inline void 81 icl_pdu_free(struct icl_pdu *ip) 82 { 83 84 ICL_CONN_PDU_FREE(ip->ip_conn, ip); 85 } 86 87 static inline void 88 icl_conn_free(struct icl_conn *ic) 89 { 90 91 ICL_CONN_FREE(ic); 92 } 93 94 static inline int 95 icl_conn_handoff(struct icl_conn *ic, int fd) 96 { 97 98 return (ICL_CONN_HANDOFF(ic, fd)); 99 } 100 101 static inline void 102 icl_conn_close(struct icl_conn *ic) 103 { 104 105 ICL_CONN_CLOSE(ic); 106 } 107 108 static inline int 109 icl_conn_task_setup(struct icl_conn *ic, struct icl_pdu *ip, 110 struct ccb_scsiio *csio, uint32_t *task_tagp, void **prvp) 111 { 112 113 return (ICL_CONN_TASK_SETUP(ic, ip, csio, task_tagp, prvp)); 114 } 115 116 static inline void 117 icl_conn_task_done(struct icl_conn *ic, void *prv) 118 { 119 120 ICL_CONN_TASK_DONE(ic, prv); 121 } 122 123 static inline int 124 icl_conn_transfer_setup(struct icl_conn *ic, union ctl_io *io, 125 uint32_t *transfer_tagp, void **prvp) 126 { 127 128 return (ICL_CONN_TRANSFER_SETUP(ic, io, transfer_tagp, prvp)); 129 } 130 131 static inline void 132 icl_conn_transfer_done(struct icl_conn *ic, void *prv) 133 { 134 135 ICL_CONN_TRANSFER_DONE(ic, prv); 136 } 137 138 /* 139 * The function below is only used with ICL_KERNEL_PROXY. 140 */ 141 static inline int 142 icl_conn_connect(struct icl_conn *ic, int domain, int socktype, 143 int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa) 144 { 145 146 return (ICL_CONN_CONNECT(ic, domain, socktype, protocol, 147 from_sa, to_sa)); 148 } 149 150 #endif /* !ICL_WRAPPERS_H */ 151