Deleted Added
sdiff udiff text old ( 277963 ) new ( 278037 )
full compact
1/*-
2 * Copyright (c) 2012 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

--- 12 unchanged lines hidden (view full) ---

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: head/sys/cam/ctl/ctl_frontend_iscsi.c 278037 2015-02-01 21:50:28Z mav $
30 */
31
32/*
33 * CTL frontend for the iSCSI protocol.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_iscsi.c 278037 2015-02-01 21:50:28Z mav $");
38
39#include <sys/param.h>
40#include <sys/capsicum.h>
41#include <sys/condvar.h>
42#include <sys/file.h>
43#include <sys/kernel.h>
44#include <sys/kthread.h>
45#include <sys/lock.h>

--- 100 unchanged lines hidden (view full) ---

146int cfiscsi_init(void);
147static void cfiscsi_online(void *arg);
148static void cfiscsi_offline(void *arg);
149static int cfiscsi_info(void *arg, struct sbuf *sb);
150static int cfiscsi_lun_enable(void *arg,
151 struct ctl_id target_id, int lun_id);
152static int cfiscsi_lun_disable(void *arg,
153 struct ctl_id target_id, int lun_id);
154static int cfiscsi_ioctl(struct cdev *dev,
155 u_long cmd, caddr_t addr, int flag, struct thread *td);
156static void cfiscsi_datamove(union ctl_io *io);
157static void cfiscsi_datamove_in(union ctl_io *io);
158static void cfiscsi_datamove_out(union ctl_io *io);
159static void cfiscsi_done(union ctl_io *io);
160static bool cfiscsi_pdu_update_cmdsn(const struct icl_pdu *request);
161static void cfiscsi_pdu_handle_nop_out(struct icl_pdu *request);

--- 1863 unchanged lines hidden (view full) ---

2025 port->physical_port = strtoul(tag, NULL, 0);
2026 port->virtual_port = ct->ct_target_id;
2027 port->port_online = cfiscsi_online;
2028 port->port_offline = cfiscsi_offline;
2029 port->port_info = cfiscsi_info;
2030 port->onoff_arg = ct;
2031 port->lun_enable = cfiscsi_lun_enable;
2032 port->lun_disable = cfiscsi_lun_disable;
2033 port->targ_lun_arg = ct;
2034 port->fe_datamove = cfiscsi_datamove;
2035 port->fe_done = cfiscsi_done;
2036
2037 /* XXX KDM what should we report here? */
2038 /* XXX These should probably be fetched from CTL. */
2039 port->max_targets = 1;
2040 port->max_target_id = 15;

--- 33 unchanged lines hidden (view full) ---

2074 retval = ctl_port_register(port);
2075 if (retval != 0) {
2076 ctl_free_opts(&port->options);
2077 cfiscsi_target_release(ct);
2078 free(port->port_devid, M_CFISCSI);
2079 free(port->target_devid, M_CFISCSI);
2080 req->status = CTL_LUN_ERROR;
2081 snprintf(req->error_str, sizeof(req->error_str),
2082 "ctl_port_register() failed with error %d", retval);
2083 return;
2084 }
2085done:
2086 ct->ct_state = CFISCSI_TARGET_STATE_ACTIVE;
2087 req->status = CTL_LUN_OK;
2088 memcpy(req->kern_args[0].kvalue, &port->targ_port,
2089 sizeof(port->targ_port)); //XXX
2090}

--- 161 unchanged lines hidden (view full) ---

2252 return (NULL);
2253}
2254
2255static struct cfiscsi_target *
2256cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name,
2257 const char *alias)
2258{
2259 struct cfiscsi_target *ct, *newct;
2260
2261 if (name[0] == '\0' || strlen(name) >= CTL_ISCSI_NAME_LEN)
2262 return (NULL);
2263
2264 newct = malloc(sizeof(*newct), M_CFISCSI, M_WAITOK | M_ZERO);
2265
2266 mtx_lock(&softc->lock);
2267 TAILQ_FOREACH(ct, &softc->targets, ct_next) {
2268 if (strcmp(name, ct->ct_name) != 0 ||
2269 ct->ct_state == CFISCSI_TARGET_STATE_INVALID)
2270 continue;
2271 cfiscsi_target_hold(ct);
2272 mtx_unlock(&softc->lock);
2273 free(newct, M_CFISCSI);
2274 return (ct);
2275 }
2276
2277 strlcpy(newct->ct_name, name, sizeof(newct->ct_name));
2278 if (alias != NULL)
2279 strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias));
2280 refcount_init(&newct->ct_refcount, 1);
2281 newct->ct_softc = softc;
2282 if (TAILQ_EMPTY(&softc->targets))
2283 softc->last_target_id = 0;
2284 newct->ct_target_id = ++softc->last_target_id;
2285 TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next);
2286 mtx_unlock(&softc->lock);
2287
2288 return (newct);
2289}
2290
2291static int
2292cfiscsi_lun_enable(void *arg, struct ctl_id target_id, int lun_id)
2293{
2294
2295 return (0);
2296}
2297
2298static int
2299cfiscsi_lun_disable(void *arg, struct ctl_id target_id, int lun_id)
2300{
2301
2302 return (0);
2303}
2304
2305static void
2306cfiscsi_datamove_in(union ctl_io *io)
2307{
2308 struct cfiscsi_session *cs;
2309 struct icl_pdu *request, *response;

--- 575 unchanged lines hidden ---