[ANNOUNCE 1b/6] Linux-iSCSI High-Performance Initiator
For the start of this thread please refer to: http://marc.theaimsgroup.com/?l=linux-kernel=111327337005048=2 and http://marc.theaimsgroup.com/?l=linux-kernel=111328256211837=2 Regards, The combined open-iscsi and linux-iscsi teams SCSI LLDD, the 2nd part: - iscsi_if.c (iSCSI open interface over netlink, iSCSI generic transport module). Signed-off-by: Alex Aizman <[EMAIL PROTECTED]> Signed-off-by: Dmitry Yusupov <[EMAIL PROTECTED]> diff -Nru --exclude Kconfig --exclude Makefile linux-2.6.12-rc2.orig/drivers/scsi/iscsi_if.c linux-2.6.12-rc2.dima/drivers/scsi/iscsi_if.c --- linux-2.6.12-rc2.orig/drivers/scsi/iscsi_if.c 1969-12-31 16:00:00.0 -0800 +++ linux-2.6.12-rc2.dima/drivers/scsi/iscsi_if.c 2005-04-11 18:13:12.0 -0700 @@ -0,0 +1,818 @@ +/* + * iSCSI Initiator Kernel/User Interface + * + * Copyright (C) 2004 Dmitry Yusupov, Alex Aizman + * maintained by [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * See the file COPYING included with this distribution for more details. + */ + +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_SCSI_ISCSI_ATTRS +#include +#endif +#include +#include + +MODULE_AUTHOR("Dmitry Yusupov <[EMAIL PROTECTED]>, " + "Alex Aizman <[EMAIL PROTECTED]>"); +MODULE_DESCRIPTION("Open-iSCSI Interface"); +MODULE_LICENSE("GPL"); + +static struct iscsi_transport *transport_table[ISCSI_TRANSPORT_MAX]; +static struct sock *nls; +static int daemon_pid; +DECLARE_MUTEX(callsema); + +struct mempool_zone { + mempool_t *pool; + volatile int allocated; + int size; + int max; + int hiwat; + struct list_head freequeue; + spinlock_t freelock; +}; + +static struct mempool_zone z_reply; + +#define Z_REPLY0 +#define Z_SIZE_REPLY NLMSG_SPACE(sizeof(struct iscsi_uevent)) +#define Z_MAX_REPLY8 +#define Z_HIWAT_REPLY 6 + +#define Z_PDU 1 +#define Z_SIZE_PDU NLMSG_SPACE(sizeof(struct iscsi_uevent) + \ + sizeof(struct iscsi_hdr) + \ + DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH) +#define Z_MAX_PDU 8 +#define Z_HIWAT_PDU6 + +#define Z_ERROR2 +#define Z_SIZE_ERROR NLMSG_SPACE(sizeof(struct iscsi_uevent)) +#define Z_MAX_ERROR16 +#define Z_HIWAT_ERROR 12 + +#define zone_init(_zp, _zone) ({ \ + (_zp)->pool = mempool_create(Z_MAX_##_zone, \ + mempool_zone_alloc_skb, mempool_zone_free_skb, \ + (void*)(_zp)); \ + if ((_zp)->pool) { \ + (_zp)->max = Z_MAX_##_zone; \ + (_zp)->size = Z_SIZE_##_zone; \ + (_zp)->hiwat = Z_HIWAT_##_zone; \ + INIT_LIST_HEAD(&(_zp)->freequeue); \ + spin_lock_init(&(_zp)->freelock); \ + (_zp)->allocated = 0; \ + } \ + (_zp)->pool; \ +}) + +struct iscsi_if_cnx { + struct list_head item; /* item in cnxlist */ + struct list_head snxitem; /* item in snx->connections */ + iscsi_cnx_t cp_cnx; + iscsi_cnx_t dp_cnx; + volatile int active; + struct Scsi_Host *host; /* originated shost */ + struct iscsi_transport *transport; + struct mempool_zone z_error; + struct mempool_zone z_pdu; + struct list_head freequeue; +}; +LIST_HEAD(cnxlist); +spinlock_t cnxlock; + +struct iscsi_if_snx { + struct list_head item; /* item in snxlist */ + struct list_head connections; + iscsi_snx_t cp_snx; + iscsi_snx_t dp_snx; + struct iscsi_transport *transport; +}; +LIST_HEAD(snxlist); +spinlock_t snxlock; + +#define H_TYPE_CP 0 +#define H_TYPE_DP 1 +#define H_TYPE_HOST2 +static struct iscsi_if_cnx* +iscsi_if_find_cnx(uint64_t key, int type) +{ + unsigned long flags; + struct iscsi_if_cnx *cnx; + + spin_lock_irqsave(, flags); + list_for_each_entry(cnx, , item) { + if ((type == H_TYPE_DP && cnx->dp_cnx == key) || + (type == H_TYPE_CP && cnx->cp_cnx == key) || + (type == H_TYPE_HOST && cnx->host == iscsi_ptr(key))) { + spin_unlock_irqrestore(, flags); + return cnx; + } + } + spin_unlock_irqrestore(, flags); + return NULL; +} + +static struct iscsi_if_snx* +iscsi_if_find_snx(struct iscsi_transport *t) +{ + unsigned long
[ANNOUNCE 1b/6] Linux-iSCSI High-Performance Initiator
For the start of this thread please refer to: http://marc.theaimsgroup.com/?l=linux-kernelm=111327337005048w=2 and http://marc.theaimsgroup.com/?l=linux-kernelm=111328256211837w=2 Regards, The combined open-iscsi and linux-iscsi teams SCSI LLDD, the 2nd part: - iscsi_if.c (iSCSI open interface over netlink, iSCSI generic transport module). Signed-off-by: Alex Aizman [EMAIL PROTECTED] Signed-off-by: Dmitry Yusupov [EMAIL PROTECTED] diff -Nru --exclude Kconfig --exclude Makefile linux-2.6.12-rc2.orig/drivers/scsi/iscsi_if.c linux-2.6.12-rc2.dima/drivers/scsi/iscsi_if.c --- linux-2.6.12-rc2.orig/drivers/scsi/iscsi_if.c 1969-12-31 16:00:00.0 -0800 +++ linux-2.6.12-rc2.dima/drivers/scsi/iscsi_if.c 2005-04-11 18:13:12.0 -0700 @@ -0,0 +1,818 @@ +/* + * iSCSI Initiator Kernel/User Interface + * + * Copyright (C) 2004 Dmitry Yusupov, Alex Aizman + * maintained by [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * See the file COPYING included with this distribution for more details. + */ + +#include linux/module.h +#include linux/mempool.h +#include net/tcp.h +#include scsi/scsi_host.h +#include scsi/scsi_device.h +#include scsi/scsi_transport.h +#ifdef CONFIG_SCSI_ISCSI_ATTRS +#include scsi/scsi_transport_iscsi.h +#endif +#include scsi/iscsi_iftrans.h +#include scsi/iscsi_ifev.h + +MODULE_AUTHOR(Dmitry Yusupov [EMAIL PROTECTED], + Alex Aizman [EMAIL PROTECTED]); +MODULE_DESCRIPTION(Open-iSCSI Interface); +MODULE_LICENSE(GPL); + +static struct iscsi_transport *transport_table[ISCSI_TRANSPORT_MAX]; +static struct sock *nls; +static int daemon_pid; +DECLARE_MUTEX(callsema); + +struct mempool_zone { + mempool_t *pool; + volatile int allocated; + int size; + int max; + int hiwat; + struct list_head freequeue; + spinlock_t freelock; +}; + +static struct mempool_zone z_reply; + +#define Z_REPLY0 +#define Z_SIZE_REPLY NLMSG_SPACE(sizeof(struct iscsi_uevent)) +#define Z_MAX_REPLY8 +#define Z_HIWAT_REPLY 6 + +#define Z_PDU 1 +#define Z_SIZE_PDU NLMSG_SPACE(sizeof(struct iscsi_uevent) + \ + sizeof(struct iscsi_hdr) + \ + DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH) +#define Z_MAX_PDU 8 +#define Z_HIWAT_PDU6 + +#define Z_ERROR2 +#define Z_SIZE_ERROR NLMSG_SPACE(sizeof(struct iscsi_uevent)) +#define Z_MAX_ERROR16 +#define Z_HIWAT_ERROR 12 + +#define zone_init(_zp, _zone) ({ \ + (_zp)-pool = mempool_create(Z_MAX_##_zone, \ + mempool_zone_alloc_skb, mempool_zone_free_skb, \ + (void*)(_zp)); \ + if ((_zp)-pool) { \ + (_zp)-max = Z_MAX_##_zone; \ + (_zp)-size = Z_SIZE_##_zone; \ + (_zp)-hiwat = Z_HIWAT_##_zone; \ + INIT_LIST_HEAD((_zp)-freequeue); \ + spin_lock_init((_zp)-freelock); \ + (_zp)-allocated = 0; \ + } \ + (_zp)-pool; \ +}) + +struct iscsi_if_cnx { + struct list_head item; /* item in cnxlist */ + struct list_head snxitem; /* item in snx-connections */ + iscsi_cnx_t cp_cnx; + iscsi_cnx_t dp_cnx; + volatile int active; + struct Scsi_Host *host; /* originated shost */ + struct iscsi_transport *transport; + struct mempool_zone z_error; + struct mempool_zone z_pdu; + struct list_head freequeue; +}; +LIST_HEAD(cnxlist); +spinlock_t cnxlock; + +struct iscsi_if_snx { + struct list_head item; /* item in snxlist */ + struct list_head connections; + iscsi_snx_t cp_snx; + iscsi_snx_t dp_snx; + struct iscsi_transport *transport; +}; +LIST_HEAD(snxlist); +spinlock_t snxlock; + +#define H_TYPE_CP 0 +#define H_TYPE_DP 1 +#define H_TYPE_HOST2 +static struct iscsi_if_cnx* +iscsi_if_find_cnx(uint64_t key, int type) +{ + unsigned long flags; + struct iscsi_if_cnx *cnx; + + spin_lock_irqsave(cnxlock, flags); + list_for_each_entry(cnx, cnxlist, item) { + if ((type == H_TYPE_DP cnx-dp_cnx == key) || + (type == H_TYPE_CP cnx-cp_cnx == key) || + (type == H_TYPE_HOST cnx-host == iscsi_ptr(key))) { + spin_unlock_irqrestore(cnxlock, flags); + return cnx; + } + } +