Deleted Added
full compact
ctl_frontend_iscsi.c (273313) ctl_frontend_iscsi.c (273319)
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 *
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: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 273313 2014-10-20 07:35:46Z mav $
29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 273319 2014-10-20 07:59:29Z mav $
30 */
31
32/*
33 * CTL frontend for the iSCSI protocol.
34 */
35
36#include <sys/cdefs.h>
30 */
31
32/*
33 * CTL frontend for the iSCSI protocol.
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 273313 2014-10-20 07:35:46Z mav $");
37__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.c 273319 2014-10-20 07:59:29Z mav $");
38
39#include <sys/param.h>
40#include <sys/capability.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>

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

1995 if (ct->ct_state == CFISCSI_TARGET_STATE_DYING)
1996 goto done;
1997
1998 port->frontend = &cfiscsi_frontend;
1999 port->port_type = CTL_PORT_ISCSI;
2000 /* XXX KDM what should the real number be here? */
2001 port->num_requested_ctl_io = 4096;
2002 port->port_name = "iscsi";
38
39#include <sys/param.h>
40#include <sys/capability.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>

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

1995 if (ct->ct_state == CFISCSI_TARGET_STATE_DYING)
1996 goto done;
1997
1998 port->frontend = &cfiscsi_frontend;
1999 port->port_type = CTL_PORT_ISCSI;
2000 /* XXX KDM what should the real number be here? */
2001 port->num_requested_ctl_io = 4096;
2002 port->port_name = "iscsi";
2003 port->virtual_port = strtoul(tag, NULL, 0);
2003 port->physical_port = strtoul(tag, NULL, 0);
2004 port->virtual_port = ct->ct_target_id;
2004 port->port_online = cfiscsi_online;
2005 port->port_offline = cfiscsi_offline;
2006 port->port_info = cfiscsi_info;
2007 port->onoff_arg = ct;
2008 port->lun_enable = cfiscsi_lun_enable;
2009 port->lun_disable = cfiscsi_lun_disable;
2010 port->lun_map = cfiscsi_lun_map;
2011 port->targ_lun_arg = ct;

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

2028 M_CTL, M_WAITOK | M_ZERO);
2029 port->port_devid->len = len;
2030 desc = (struct scsi_vpd_id_descriptor *)port->port_devid->data;
2031 desc->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_UTF8;
2032 desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
2033 SVPD_ID_TYPE_SCSI_NAME;
2034 desc->length = idlen;
2035 snprintf(desc->identifier, idlen, "%s,t,0x%4.4x",
2005 port->port_online = cfiscsi_online;
2006 port->port_offline = cfiscsi_offline;
2007 port->port_info = cfiscsi_info;
2008 port->onoff_arg = ct;
2009 port->lun_enable = cfiscsi_lun_enable;
2010 port->lun_disable = cfiscsi_lun_disable;
2011 port->lun_map = cfiscsi_lun_map;
2012 port->targ_lun_arg = ct;

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

2029 M_CTL, M_WAITOK | M_ZERO);
2030 port->port_devid->len = len;
2031 desc = (struct scsi_vpd_id_descriptor *)port->port_devid->data;
2032 desc->proto_codeset = (SCSI_PROTO_ISCSI << 4) | SVPD_ID_CODESET_UTF8;
2033 desc->id_type = SVPD_ID_PIV | SVPD_ID_ASSOC_PORT |
2034 SVPD_ID_TYPE_SCSI_NAME;
2035 desc->length = idlen;
2036 snprintf(desc->identifier, idlen, "%s,t,0x%4.4x",
2036 target, port->virtual_port);
2037 target, port->physical_port);
2037
2038 /* Generate Target ID. */
2039 idlen = strlen(target) + 1;
2040 idlen = roundup2(idlen, 4);
2041 len = sizeof(struct scsi_vpd_device_id) + idlen;
2042 port->target_devid = malloc(sizeof(struct ctl_devid) + len,
2043 M_CTL, M_WAITOK | M_ZERO);
2044 port->target_devid->len = len;

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

2256 for (i = 0; i < CTL_MAX_LUNS; i++)
2257 newct->ct_luns[i] = UINT32_MAX;
2258
2259 strlcpy(newct->ct_name, name, sizeof(newct->ct_name));
2260 if (alias != NULL)
2261 strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias));
2262 refcount_init(&newct->ct_refcount, 1);
2263 newct->ct_softc = softc;
2038
2039 /* Generate Target ID. */
2040 idlen = strlen(target) + 1;
2041 idlen = roundup2(idlen, 4);
2042 len = sizeof(struct scsi_vpd_device_id) + idlen;
2043 port->target_devid = malloc(sizeof(struct ctl_devid) + len,
2044 M_CTL, M_WAITOK | M_ZERO);
2045 port->target_devid->len = len;

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

2257 for (i = 0; i < CTL_MAX_LUNS; i++)
2258 newct->ct_luns[i] = UINT32_MAX;
2259
2260 strlcpy(newct->ct_name, name, sizeof(newct->ct_name));
2261 if (alias != NULL)
2262 strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias));
2263 refcount_init(&newct->ct_refcount, 1);
2264 newct->ct_softc = softc;
2265 if (TAILQ_EMPTY(&softc->targets))
2266 softc->last_target_id = 0;
2267 newct->ct_target_id = ++softc->last_target_id;
2264 TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next);
2265 mtx_unlock(&softc->lock);
2266
2267 return (newct);
2268}
2269
2270/*
2271 * Takes LUN from the target space and returns LUN from the CTL space.

--- 660 unchanged lines hidden ---
2268 TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next);
2269 mtx_unlock(&softc->lock);
2270
2271 return (newct);
2272}
2273
2274/*
2275 * Takes LUN from the target space and returns LUN from the CTL space.

--- 660 unchanged lines hidden ---