Skip to contentSkip to conversation

Add bnx2 iscsi support.

PATCH In review Michael Chan 8 participants 27 messages May 1, 2009 – Jun 8, 2009 4 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Add bnx2 iscsi support.

Adding linux-scsi and James to CC, please review. David has ACK'ed the networking portion. We have also fixed up some sparse warnings. The iscsi patches require these 2 patches from the iscsi tree:

libiscsi: export iscsi_itt_to_task for bnx2i
iscsi: pass ep connect shost

#1 lore raw

PATCH 1/4 bnx2: Add support for CNIC driver.

Add interface and functions to support a new CNIC driver to drive the hardware for iSCSI offload.

---
 drivers/net/bnx2.c |  193 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 drivers/net/bnx2.h |   18 +++++
 2 files changed, 208 insertions(+), 3 deletions(-)
drivers/net/bnx2.c +190 -3
index d478391..aabc030 100644
@@ -49,6 +49,10 @@
 #include <linux/firmware.h>
 #include <linux/log2.h>
 
+#if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
+#define BCM_CNIC 1
+#include "cnic_if.h"
+#endif
 #include "bnx2.h"
 #include "bnx2_fw.h"
 
@@ -315,6 +319,158 @@ bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
 	spin_unlock_bh(&bp->indirect_lock);
 }
 
+#ifdef BCM_CNIC
+static int
+bnx2_drv_ctl(struct net_device *dev, struct drv_ctl_info *info)
+{
+	struct bnx2 *bp = netdev_priv(dev);
+	struct drv_ctl_io *io = &info->data.io;
+
+	switch (info->cmd) {
+	case DRV_CTL_IO_WR_CMD:
+		bnx2_reg_wr_ind(bp, io->offset, io->data);
+		break;
+	case DRV_CTL_IO_RD_CMD:
+		io->data = bnx2_reg_rd_ind(bp, io->offset);
+		break;
+	case DRV_CTL_CTX_WR_CMD:
+		bnx2_ctx_wr(bp, io->cid_addr, io->offset, io->data);
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static void bnx2_setup_cnic_irq_info(struct bnx2 *bp)
+{
+	struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+	struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
+	int sb_id;
+
+	if (bp->flags & BNX2_FLAG_USING_MSIX) {
+		cp->drv_state |= CNIC_DRV_STATE_USING_MSIX;
+		bnapi->cnic_present = 0;
+		sb_id = bp->irq_nvecs;
+		cp->irq_arr[0].irq_flags |= CNIC_IRQ_FL_MSIX;
+	} else {
+		cp->drv_state &= ~CNIC_DRV_STATE_USING_MSIX;
+		bnapi->cnic_tag = bnapi->last_status_idx;
+		bnapi->cnic_present = 1;
+		sb_id = 0;
+		cp->irq_arr[0].irq_flags &= ~CNIC_IRQ_FL_MSIX;
+	}
+
+	cp->irq_arr[0].vector = bp->irq_tbl[sb_id].vector;
+	cp->irq_arr[0].status_blk = (void *)
+		((unsigned long) bnapi->status_blk.msi +
+		(BNX2_SBLK_MSIX_ALIGN_SIZE * sb_id));
+	cp->irq_arr[0].status_blk_num = sb_id;
+	cp->num_irq = 1;
+}
+
+static int bnx2_register_cnic(struct net_device *dev, struct cnic_ops *ops,
+			      void *data)
+{
+	struct bnx2 *bp = netdev_priv(dev);
+	struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+
+	if (ops == NULL)
+		return -EINVAL;
+
+	if (cp->drv_state & CNIC_DRV_STATE_REGD)
+		return -EBUSY;
+
+	bp->cnic_data = data;
+	rcu_assign_pointer(bp->cnic_ops, ops);
+
+	cp->num_irq = 0;
+	cp->drv_state = CNIC_DRV_STATE_REGD;
+
+	bnx2_setup_cnic_irq_info(bp);
+
+	return 0;
+}
+
+static int bnx2_unregister_cnic(struct net_device *dev)
+{
+	struct bnx2 *bp = netdev_priv(dev);
+	struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
+	struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+
+	cp->drv_state = 0;
+	bnapi->cnic_present = 0;
+	rcu_assign_pointer(bp->cnic_ops, NULL);
+	synchronize_rcu();
+	return 0;
+}
+
+struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev)
+{
+	struct bnx2 *bp = netdev_priv(dev);
+	struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
+
+	cp->drv_owner = THIS_MODULE;
+	cp->chip_id = bp->chip_id;
+	cp->pdev = bp->pdev;
+	cp->io_base = bp->regview;
+	cp->drv_ctl = bnx2_drv_ctl;
+	cp->drv_register_cnic = bnx2_register_cnic;
+	cp->drv_unregister_cnic = bnx2_unregister_cnic;
+
+	return cp;
+}
+EXPORT_SYMBOL(bnx2_cnic_probe);
+
+static void
+bnx2_cnic_stop(struct bnx2 *bp)
+{
+	struct cnic_ops *c_ops;
+	struct cnic_ctl_info info;
+
+	rcu_read_lock();
+	c_ops = rcu_dereference(bp->cnic_ops);
+	if (c_ops) {
+		info.cmd = CNIC_CTL_STOP_CMD;
+		c_ops->cnic_ctl(bp->cnic_data, &info);
+	}
+	rcu_read_unlock();
+}
+
+static void
+bnx2_cnic_start(struct bnx2 *bp)
+{
+	struct cnic_ops *c_ops;
+	struct cnic_ctl_info info;
+
+	rcu_read_lock();
+	c_ops = rcu_dereference(bp->cnic_ops);
+	if (c_ops) {
+		if (!(bp->flags & BNX2_FLAG_USING_MSIX)) {
+			struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
+
+			bnapi->cnic_tag = bnapi->last_status_idx;
+		}
+		info.cmd = CNIC_CTL_START_CMD;
+		c_ops->cnic_ctl(bp->cnic_data, &info);
+	}
+	rcu_read_unlock();
+}
+
+#else
+
+static void
+bnx2_cnic_stop(struct bnx2 *bp)
+{
+}
+
+static void
+bnx2_cnic_start(struct bnx2 *bp)
+{
+}
+
+#endif
+
 static int
 bnx2_read_phy(struct bnx2 *bp, u32 reg, u32 *val)
 {
@@ -488,6 +644,7 @@ bnx2_napi_enable(struct bnx2 *bp)
 static void
 bnx2_netif_stop(struct bnx2 *bp)
 {
+	bnx2_cnic_stop(bp);
 	bnx2_disable_int_sync(bp);
 	if (netif_running(bp->dev)) {
 		bnx2_napi_disable(bp);
@@ -504,6 +661,7 @@ bnx2_netif_start(struct bnx2 *bp)
 			netif_tx_wake_all_queues(bp->dev);
 			bnx2_napi_enable(bp);
 			bnx2_enable_int(bp);
+			bnx2_cnic_start(bp);
 		}
 	}
 }
@@ -3162,6 +3320,11 @@ bnx2_has_work(struct bnx2_napi *bnapi)
 	if (bnx2_has_fast_work(bnapi))
 		return 1;
 
+#ifdef BCM_CNIC
+	if (bnapi->cnic_present && (bnapi->cnic_tag != sblk->status_idx))
+		return 1;
+#endif
+
 	if ((sblk->status_attn_bits & STATUS_ATTN_EVENTS) !=
 	    (sblk->status_attn_bits_ack & STATUS_ATTN_EVENTS))
 		return 1;
@@ -3191,6 +3354,23 @@ bnx2_chk_missed_msi(struct bnx2 *bp)
 	bp->idle_chk_status_idx = bnapi->last_status_idx;
 }
 
+#ifdef BCM_CNIC
+static void bnx2_poll_cnic(struct bnx2 *bp, struct bnx2_napi *bnapi)
+{
+	struct cnic_ops *c_ops;
+
+	if (!bnapi->cnic_present)
+		return;
+
+	rcu_read_lock();
+	c_ops = rcu_dereference(bp->cnic_ops);
+	if (c_ops)
+		bnapi->cnic_tag = c_ops->cnic_handler(bp->cnic_data,
+						      bnapi->status_blk.msi);
+	rcu_read_unlock();
+}
+#endif
+
 static void bnx2_poll_link(struct bnx2 *bp, struct bnx2_napi *bnapi)
 {
 	struct status_block *sblk = bnapi->status_blk.msi;
@@ -3265,6 +3445,10 @@ static int bnx2_poll(struct napi_struct *napi, int budget)
 
 		work_done = bnx2_poll_work(bp, bnapi, work_done, budget);
 
+#ifdef BCM_CNIC
+		bnx2_poll_cnic(bp, bnapi);
+#endif
+
 		/* bnapi->last_status_idx is used below to tell the hw how
 		 * much work has been processed, so we must read it before
 		 * checking for more work.
@@ -4630,8 +4814,11 @@ bnx2_init_chip(struct bnx2 *bp)
 	val = REG_RD(bp, BNX2_MQ_CONFIG);
 	val &= ~BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE;
 	val |= BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256;
-	if (CHIP_ID(bp) == CHIP_ID_5709_A0 || CHIP_ID(bp) == CHIP_ID_5709_A1)
-		val |= BNX2_MQ_CONFIG_HALT_DIS;
+	if (CHIP_NUM(bp) == CHIP_NUM_5709) {
+		val |= BNX2_MQ_CONFIG_BIN_MQ_MODE;
+		if (CHIP_REV(bp) == CHIP_REV_Ax)
+			val |= BNX2_MQ_CONFIG_HALT_DIS;
+	}
 
 	REG_WR(bp, BNX2_MQ_CONFIG, val);
 
@@ -7469,7 +7656,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
 	INIT_WORK(&bp->reset_task, bnx2_reset_task);
 
 	dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
-	mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS);
+	mem_len = MB_GET_CID_ADDR(TX_TSS_CID + TX_MAX_TSS_RINGS + 1);
 	dev->mem_end = dev->mem_start + mem_len;
 	dev->irq = pdev->irq;
 
drivers/net/bnx2.h +18 -0
index 5b570e1..a1ff739 100644
@@ -361,6 +361,9 @@ struct l2_fhdr {
 #define BNX2_L2CTX_CTX_TYPE_CTX_BD_CHN_TYPE_VALUE	 (1<<28)
 
 #define BNX2_L2CTX_HOST_BDIDX				0x00000004
+#define BNX2_L2CTX_STATUSB_NUM_SHIFT			 16
+#define BNX2_L2CTX_STATUSB_NUM(sb_id)			 \
+	(((sb_id) > 0) ? (((sb_id) + 7) << BNX2_L2CTX_STATUSB_NUM_SHIFT) : 0)
 #define BNX2_L2CTX_HOST_BSEQ				0x00000008
 #define BNX2_L2CTX_NX_BSEQ				0x0000000c
 #define BNX2_L2CTX_NX_BDHADDR_HI			0x00000010
@@ -5900,6 +5903,7 @@ struct l2_fhdr {
 #define BNX2_RXP_FTQ_CTL_CUR_DEPTH			 (0x3ffL<<22)
 
 #define BNX2_RXP_SCRATCH				0x000e0000
+#define BNX2_RXP_SCRATCH_RXP_FLOOD			 0x000e0024
 #define BNX2_RXP_SCRATCH_RSS_TBL_SZ			 0x000e0038
 #define BNX2_RXP_SCRATCH_RSS_TBL			 0x000e003c
 #define BNX2_RXP_SCRATCH_RSS_TBL_MAX_ENTRIES		 128
@@ -6678,6 +6682,11 @@ struct bnx2_napi {
 	u32 			last_status_idx;
 	u32			int_num;
 
+#ifdef BCM_CNIC
+	u32			cnic_tag;
+	int			cnic_present;
+#endif
+
 	struct bnx2_rx_ring_info	rx_ring;
 	struct bnx2_tx_ring_info	tx_ring;
 };
@@ -6727,6 +6736,11 @@ struct bnx2 {
 	int		tx_ring_size;
 	u32		tx_wake_thresh;
 
+#ifdef BCM_CNIC
+	struct cnic_ops		*cnic_ops;
+	void			*cnic_data;
+#endif
+
 	/* End of fields used in the performance code paths. */
 
 	unsigned int		current_interval;
@@ -6885,6 +6899,10 @@ struct bnx2 {
 
 	u32			idle_chk_status_idx;
 
+#ifdef BCM_CNIC
+	struct cnic_eth_dev	cnic_eth_dev;
+#endif
+
 	const struct firmware	*mips_firmware;
 	const struct firmware	*rv2p_firmware;
 };
Signature · 1 line
1.5.6.GIT

A message that is not in the archive (sent off-list or not yet received): 1241208039-6813-1-git-send-email-mchan-dY08KVG/lbpWk0Htik3J/[email protected]

#3 lore raw

PATCH 2/4 cnic: Add new CNIC driver.

The CNIC driver controls BNX2 hardware rings and resources used by iSCSI. Most hardware resources for iSCSI are separate from those used for ethernet networking.

iSCSI uses a separate MAC address and IP address. The CNIC driver creates a UIO interface to handle the non-offloaded packets such as ARP, etc in userspace.

---
 drivers/net/Kconfig     |   11 +
 drivers/net/Makefile    |    1 +
 drivers/net/cnic.c      | 2695 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/cnic.h      |  300 ++++++
 drivers/net/cnic_defs.h |  569 ++++++++++
 drivers/net/cnic_if.h   |  317 ++++++
 6 files changed, 3893 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/cnic.c
 create mode 100644 drivers/net/cnic.h
 create mode 100644 drivers/net/cnic_defs.h
 create mode 100644 drivers/net/cnic_if.h
drivers/net/Kconfig +11 -0
index 9e92154..7a7f632 100644
@@ -2264,6 +2264,17 @@ config BNX2
 	  To compile this driver as a module, choose M here: the module
 	  will be called bnx2.  This is recommended.
 
+config CNIC
+	tristate "Broadcom CNIC support"
+	depends on BNX2
+	depends on UIO
+	help
+	  This driver supports offload features of Broadcom NetXtremeII
+	  gigabit Ethernet cards.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called cnic.  This is recommended.
+
 config SPIDER_NET
 	tristate "Spider Gigabit Ethernet driver"
 	depends on PCI && (PPC_IBM_CELL_BLADE || PPC_CELLEB)
drivers/net/Makefile +1 -0
index 1fc4602..e6f1f8c 100644
@@ -73,6 +73,7 @@ obj-$(CONFIG_STNIC) += stnic.o 8390.o
 obj-$(CONFIG_FEALNX) += fealnx.o
 obj-$(CONFIG_TIGON3) += tg3.o
 obj-$(CONFIG_BNX2) += bnx2.o
+obj-$(CONFIG_CNIC) += cnic.o
 obj-$(CONFIG_BNX2X) += bnx2x.o
 bnx2x-objs := bnx2x_main.o bnx2x_link.o
 spidernet-y += spider_net.o spider_net_ethtool.o
drivers/net/cnic.c new file +2695 -0

2,695 lines not on this page · raw message

drivers/net/cnic.h new file +300 -0

281 lines not on this page · raw message

drivers/net/cnic_defs.h new file +569 -0

569 lines not on this page · raw message

drivers/net/cnic_if.h new file +317 -0

317 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.6.GIT

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH 3/4 iscsi class, libiscsi: Add net config.

In reply to Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

---
 drivers/scsi/scsi_transport_iscsi.c |   59 ++++++++++++++++++++++++++++++++++-
 include/scsi/iscsi_if.h             |   14 ++++++++
 include/scsi/scsi_transport_iscsi.h |    6 +++
 3 files changed, 78 insertions(+), 1 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +58 -1
index 0947954..ef3af96 100644
@@ -995,6 +995,37 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+extern int iscsi_vendor_priv_mesg(struct Scsi_Host *shost,
+				  struct iscsi_transport *transport,
+				  uint16_t priv_op,
+				  char *data, uint16_t data_size)
+{
+	struct nlmsghdr	*nlh;
+	struct sk_buff *skb;
+	struct iscsi_uevent *ev;
+	int len = NLMSG_SPACE(sizeof(*ev) + data_size);
+
+	skb = alloc_skb(len, GFP_ATOMIC);
+	if (!skb) {
+		printk(KERN_ERR "can not deliver vendor private message:OOM\n");
+		return -ENOMEM;
+	}
+
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
+	ev = NLMSG_DATA(nlh);
+	memset(ev, 0, sizeof(*ev));
+	ev->type = ISCSI_KEVENT_PRIVATE_MESG;
+	ev->transport_handle = iscsi_handle(transport);
+	ev->r.vendor_priv.host_no = shost->host_no;
+	ev->r.vendor_priv.priv_op = priv_op;
+	ev->r.vendor_priv.mesg_size = data_size;
+
+	memcpy((char*)ev + sizeof(*ev), data, data_size);
+
+	return iscsi_broadcast_skb(skb, GFP_KERNEL);
+}
+EXPORT_SYMBOL_GPL(iscsi_vendor_priv_mesg);
+
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 {
 	struct nlmsghdr	*nlh;
@@ -1365,6 +1396,28 @@ iscsi_set_host_param(struct iscsi_transport *transport,
 }
 
 static int
+iscsi_vendor_priv_msg(struct iscsi_transport *transport,
+		      struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	int err;
+
+	shost = scsi_host_lookup(ev->u.vendor_priv.host_no);
+	if (!shost) {
+		printk(KERN_ERR "target discovery could not find host no %u\n",
+		       ev->u.tgt_dscvr.host_no);
+		return -ENODEV;
+	}
+
+	err = transport->nl_priv_recv(shost, ev->u.vendor_priv.priv_op,
+				      ev->u.vendor_priv.status,
+				      (char *)((char*)ev + sizeof(*ev)),
+				      ev->u.vendor_priv.mesg_size);
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	int err = 0;
@@ -1383,7 +1436,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (!try_module_get(transport->owner))
 		return -EINVAL;
 
-	priv->daemon_pid = NETLINK_CREDS(skb)->pid;
+	if (nlh->nlmsg_type != ISCSI_UEVENT_PRIVATE_MESG)
+		priv->daemon_pid = NETLINK_CREDS(skb)->pid;
 
 	switch (nlh->nlmsg_type) {
 	case ISCSI_UEVENT_CREATE_SESSION:
@@ -1477,6 +1531,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	case ISCSI_UEVENT_SET_HOST_PARAM:
 		err = iscsi_set_host_param(transport, ev);
 		break;
+	case ISCSI_UEVENT_PRIVATE_MESG:
+		err = iscsi_vendor_priv_msg(transport, ev);
+		break;
 	default:
 		err = -ENOSYS;
 		break;
include/scsi/iscsi_if.h +14 -0
index d0ed522..9e67946 100644
@@ -52,6 +52,8 @@ enum iscsi_uevent_e {
 	ISCSI_UEVENT_UNBIND_SESSION	= UEVENT_BASE + 17,
 	ISCSI_UEVENT_CREATE_BOUND_SESSION	= UEVENT_BASE + 18,
 
+	ISCSI_UEVENT_PRIVATE_MESG	= UEVENT_BASE + 20,
+
 	/* up events */
 	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
 	ISCSI_KEVENT_CONN_ERROR		= KEVENT_BASE + 2,
@@ -59,6 +61,7 @@ enum iscsi_uevent_e {
 	ISCSI_KEVENT_DESTROY_SESSION	= KEVENT_BASE + 4,
 	ISCSI_KEVENT_UNBIND_SESSION	= KEVENT_BASE + 5,
 	ISCSI_KEVENT_CREATE_SESSION	= KEVENT_BASE + 6,
+	ISCSI_KEVENT_PRIVATE_MESG	= KEVENT_BASE + 7,
 };
 
 enum iscsi_tgt_dscvr {
@@ -154,6 +157,12 @@ struct iscsi_uevent {
 			uint32_t	param; /* enum iscsi_host_param */
 			uint32_t	len;
 		} set_host_param;
+		struct msg_vendor_priv {
+			uint32_t	host_no;
+			uint16_t	priv_op;
+			uint16_t	mesg_size;
+			uint32_t	status;
+		} vendor_priv;
 	} u;
 	union {
 		/* messages k -> u */
@@ -187,6 +196,11 @@ struct iscsi_uevent {
 		struct msg_transport_connect_ret {
 			uint64_t	handle;
 		} ep_connect_ret;
+		struct msg_vendor_priv_ret {
+			uint32_t	host_no;
+			uint16_t	priv_op;
+			uint16_t	mesg_size;
+		} vendor_priv;
 	} r;
 } __attribute__ ((aligned (sizeof(uint64_t))));
 
include/scsi/scsi_transport_iscsi.h +6 -0
index 457588e..14dab4e 100644
@@ -132,6 +132,8 @@ struct iscsi_transport {
 	void (*ep_disconnect) (struct iscsi_endpoint *ep);
 	int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
 			  uint32_t enable, struct sockaddr *dst_addr);
+	int (*nl_priv_recv) (struct Scsi_Host *shost, uint16_t priv_op,
+			     int status, char *data, int data_size);
 };
 
 /*
@@ -147,6 +149,10 @@ extern void iscsi_conn_error_event(struct iscsi_cls_conn *conn,
 				   enum iscsi_err error);
 extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 			  char *data, uint32_t data_size);
+extern int iscsi_vendor_priv_mesg(struct Scsi_Host *shost,
+				  struct iscsi_transport *transport,
+				  uint16_t priv_op,
+				  char *data, uint16_t data_size);
 
 struct iscsi_cls_conn {
 	struct list_head conn_list;	/* item in connlist */
Signature · 1 line
1.5.6.GIT

A message that is not in the archive (sent off-list or not yet received): 1241208039-6813-4-git-send-email-mchan-dY08KVG/lbpWk0Htik3J/[email protected]

#6 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

Quoted 19 lines · Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

---
 drivers/scsi/scsi_transport_iscsi.c |   59 ++++++++++++++++++++++++++++++++++-
 include/scsi/iscsi_if.h             |   14 ++++++++
 include/scsi/scsi_transport_iscsi.h |    6 +++
 3 files changed, 78 insertions(+), 1 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +0 -0
index 0947954..ef3af96 100644

drivers/scsi/scsi_transport_iscsi.c int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, · line 998

Quoted 4 lines
drivers/scsi/scsi_transport_iscsi.c +1 -0
@@ -995,6 +995,37 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+extern int iscsi_vendor_priv_mesg(struct Scsi_Host *shost,

Just a cut and paste error probably. You have an extern in there.

Quoted 4 lines
drivers/scsi/scsi_transport_iscsi.c +4 -0
+				  struct iscsi_transport *transport,
+				  uint16_t priv_op,
+				  char *data, uint16_t data_size)
+{
#7 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

Quoted 23 lines · Mike Christie
Quoted 22 lines · Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

---
 drivers/scsi/scsi_transport_iscsi.c |   59 ++++++++++++++++++++++++++++++++++-
 include/scsi/iscsi_if.h             |   14 ++++++++
 include/scsi/scsi_transport_iscsi.h |    6 +++
 3 files changed, 78 insertions(+), 1 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +0 -0
index 0947954..ef3af96 100644
@@ -995,6 +995,37 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
Quoted 3 lines

drivers/scsi/scsi_transport_iscsi.c int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, · line 998

Quoted 1 line
drivers/scsi/scsi_transport_iscsi.c +1 -0
+extern int iscsi_vendor_priv_mesg(struct Scsi_Host *shost,

Just a cut and paste error probably. You have an extern in there.

Thanks for noticing. Will fix this up in the next version of the patch.

Quoted 7 lines
Quoted 5 lines
drivers/scsi/scsi_transport_iscsi.c +4 -0
+				  struct iscsi_transport *transport,
+				  uint16_t priv_op,
+				  char *data, uint16_t data_size)
+{
maintainer
#8 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

In reply to Michael Chan
Quoted 8 lines · Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

This patch is rejecting pretty badly against both SCSI and net ... is there an update (I saw you updated the other three patches in this series on the 23rd, but not this one)?

James

---

patching file drivers/scsi/scsi_transport_iscsi.c Hunk #1 succeeded at 1015 with fuzz 2 (offset 20 lines). Hunk #2 FAILED at 1416.
Hunk #3 FAILED at 1456.
Hunk #4 succeeded at 1611 with fuzz 2 (offset 80 lines). 2 out of 4 hunks FAILED -- saving rejects to file drivers/scsi/scsi_transport_iscsi.c.rej patching file include/scsi/iscsi_if.h
Hunk #1 succeeded at 60 with fuzz 2 (offset 8 lines). Hunk #2 FAILED at 69.
Hunk #3 FAILED at 165.
Hunk #4 FAILED at 204.
3 out of 4 hunks FAILED -- saving rejects to file include/scsi/iscsi_if.h.rej
patching file include/scsi/scsi_transport_iscsi.h Hunk #1 FAILED at 132.
Hunk #2 succeeded at 151 with fuzz 2 (offset 2 lines). 1 out of 2 hunks FAILED -- saving rejects to file include/scsi/scsi_transport_iscsi.h.rej

#9 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

Quoted 5 lines · James Bottomley
Quoted 4 lines · Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

Quoted 9 lines
Quoted 4 lines

This patch is rejecting pretty badly against both SCSI and net ... is there an update (I saw you updated the other three patches in this series on the 23rd, but not this one)?

I believe this is an earlier version of the patch. On the 23rd, I sent a completely new version after feedback from Mike and Chelsio to standardize the message format. It was also re-ordered as patch 1/4.

We have some cleanups we want to make on the bnx2i patch (4/4). I can re-spin everything and send out the whole set of patches later today.

Thanks.

Quoted 26 lines

James

---

patching file drivers/scsi/scsi_transport_iscsi.c Hunk #1 succeeded at 1015 with fuzz 2 (offset 20 lines). Hunk #2 FAILED at 1416.
Hunk #3 FAILED at 1456.
Hunk #4 succeeded at 1611 with fuzz 2 (offset 80 lines). 2 out of 4 hunks FAILED -- saving rejects to file drivers/scsi/scsi_transport_iscsi.c.rej patching file include/scsi/iscsi_if.h
Hunk #1 succeeded at 60 with fuzz 2 (offset 8 lines). Hunk #2 FAILED at 69.
Hunk #3 FAILED at 165.
Hunk #4 FAILED at 204.
3 out of 4 hunks FAILED -- saving rejects to file include/scsi/iscsi_if.h.rej
patching file include/scsi/scsi_transport_iscsi.h Hunk #1 FAILED at 132.
Hunk #2 succeeded at 151 with fuzz 2 (offset 2 lines). 1 out of 2 hunks FAILED -- saving rejects to file include/scsi/scsi_transport_iscsi.h.rej

maintainer
#10 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

Quoted 16 lines · Michael Chan
Quoted 5 lines · James Bottomley
Quoted 4 lines · Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

Quoted 9 lines
Quoted 4 lines

This patch is rejecting pretty badly against both SCSI and net ... is there an update (I saw you updated the other three patches in this series on the 23rd, but not this one)?

Quoted 6 lines

I believe this is an earlier version of the patch. On the 23rd, I sent a completely new version after feedback from Mike and Chelsio to standardize the message format. It was also re-ordered as patch 1/4.

We have some cleanups we want to make on the bnx2i patch (4/4). I can re-spin everything and send out the whole set of patches later today.

That's probably the best solution ... I found it ... I'd just got the old patch labelled in my workflow somehow.

Thanks,

James

#11 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

In reply to James Bottomley
Quoted 5 lines · James Bottomley
Quoted 4 lines · Michael Chan

Add ISCSI_NETLINK messages to get/set vendor specific information. This is to support bnx2i that handles net config of private iSCSI IP address in userspace.

Quoted 9 lines
Quoted 4 lines

This patch is rejecting pretty badly against both SCSI and net ... is there an update (I saw you updated the other three patches in this series on the 23rd, but not this one)?

The patch in this mail was dropped in their newest patchset from the 23rd.

Instead of the patch in this mail we now added the patch "[PATCH 1/4] iscsi class: Add new NETLINK_ISCSI messages for cnic/bnx2i driver." (link http://marc.info/?l=linux-scsi&m=124311620603619&w=2) that was posted with the updated bnx2i/cnic patches on the 23rd.

James, one note. I was reviewing the bnx2i patch again and found some bugs in the locking. Are you going to merge the patches that were sent on the 23rd and then do you want us to just send fixes against that? Or do you want a new fixed up patchset?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

<snip>

Sorry for jumping in the middle of a thread, I missed the libiscsi in the subject. Can someone please resent me the libiscsi part of this patchset so that I can review it ?

(I'm the libiscsi author)

Thanks & Regards,

Hans

#14 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

Quoted 8 lines · Hans de Goede

<snip>

Sorry for jumping in the middle of a thread, I missed the libiscsi in the subject. Can someone please resent me the libiscsi part of this patchset so that I can review it ?

(I'm the libiscsi author)

I'll be sending a new patchset later today and I'll CC you. In the final version, we are not modifying libiscsi, only scsi_transport_iscsi.

Thanks.

#15 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

In reply to Hans de Goede
Quoted 8 lines · Hans de Goede

<snip>

Sorry for jumping in the middle of a thread, I missed the libiscsi in the subject. Can someone please resent me the libiscsi part of this patchset so that I can review it ?

(I'm the libiscsi author)

There is actually a kernel module called libiscsi. That is what this patch/thread/mail is for. It is not the userpsace libiscsi lib that you did.

#16 lore raw

Re: [PATCH 3/4] iscsi class, libiscsi: Add net config.

Quoted 7 lines · Mike Christie
Quoted 6 lines · Hans de Goede

<snip>

Sorry for jumping in the middle of a thread, I missed the libiscsi in the subject. Can someone please resent me the libiscsi part of this patchset so that I can review it ?

Quoted 6 lines
Quoted 2 lines

(I'm the libiscsi author)

There is actually a kernel module called libiscsi. That is what this patch/thread/mail is for. It is not the userpsace libiscsi lib that you did.

Ah, my bad.

Regards,

Hans

#17 lore raw

PATCH 4/4 bnx2i: Add bnx2i iSCSI driver.

In reply to Michael Chan

New iSCSI driver for BNX2 devices. The driver interfaces with the CNIC driver to access the hardware.

---
 drivers/scsi/Kconfig                      |    1 +
 drivers/scsi/Makefile                     |    1 +
 drivers/scsi/bnx2i/57xx_iscsi_constants.h |  155 ++
 drivers/scsi/bnx2i/57xx_iscsi_hsi.h       | 1509 ++++++++++++++++++
 drivers/scsi/bnx2i/Kconfig                |    6 +
 drivers/scsi/bnx2i/Makefile               |    3 +
 drivers/scsi/bnx2i/bnx2i.h                |  776 +++++++++
 drivers/scsi/bnx2i/bnx2i_hwi.c            | 2446 +++++++++++++++++++++++++++++
 drivers/scsi/bnx2i/bnx2i_init.c           |  434 +++++
 drivers/scsi/bnx2i/bnx2i_iscsi.c          | 2101 +++++++++++++++++++++++++
 drivers/scsi/bnx2i/bnx2i_sysfs.c          |  142 ++
 11 files changed, 7574 insertions(+), 0 deletions(-)
 create mode 100644 drivers/scsi/bnx2i/57xx_iscsi_constants.h
 create mode 100644 drivers/scsi/bnx2i/57xx_iscsi_hsi.h
 create mode 100644 drivers/scsi/bnx2i/Kconfig
 create mode 100644 drivers/scsi/bnx2i/Makefile
 create mode 100644 drivers/scsi/bnx2i/bnx2i.h
 create mode 100644 drivers/scsi/bnx2i/bnx2i_hwi.c
 create mode 100644 drivers/scsi/bnx2i/bnx2i_init.c
 create mode 100644 drivers/scsi/bnx2i/bnx2i_iscsi.c
 create mode 100644 drivers/scsi/bnx2i/bnx2i_sysfs.c
drivers/scsi/Kconfig +1 -0
index 8ed2990..8427b77 100644
@@ -1374,6 +1374,7 @@ config SCSI_QLOGICPTI
 
 source "drivers/scsi/qla2xxx/Kconfig"
 source "drivers/scsi/qla4xxx/Kconfig"
+source "drivers/scsi/bnx2i/Kconfig"
 
 config SCSI_LPFC
 	tristate "Emulex LightPulse Fibre Channel Support"
drivers/scsi/Makefile +1 -0
index e7c861a..919157d 100644
@@ -84,6 +84,7 @@ obj-$(CONFIG_PCMCIA_QLOGIC)	+= qlogicfas408.o
 obj-$(CONFIG_SCSI_QLOGIC_1280)	+= qla1280.o 
 obj-$(CONFIG_SCSI_QLA_FC)	+= qla2xxx/
 obj-$(CONFIG_SCSI_QLA_ISCSI)	+= qla4xxx/
+obj-$(CONFIG_SCSI_BNX2_ISCSI)	+= libiscsi.o bnx2i/
 obj-$(CONFIG_SCSI_LPFC)		+= lpfc/
 obj-$(CONFIG_SCSI_PAS16)	+= pas16.o
 obj-$(CONFIG_SCSI_T128)		+= t128.o
drivers/scsi/bnx2i/57xx_iscsi_constants.h new file +155 -0

155 lines not on this page · raw message

drivers/scsi/bnx2i/57xx_iscsi_hsi.h new file +1509 -0

1,509 lines not on this page · raw message

drivers/scsi/bnx2i/Kconfig new file +6 -0
new file mode 100644
index 0000000..18a6459
@@ -0,0 +1,6 @@
+config SCSI_BNX2_ISCSI
+	tristate "Broadcom NetXtreme II iSCSI support"
+	select SCSI_ISCSI_ATTRS
+	---help---
+	This driver supports iSCSI offload for the Broadcom NetXtreme II
+	devices.
drivers/scsi/bnx2i/Makefile new file +3 -0
new file mode 100644
index 0000000..b5802bd
@@ -0,0 +1,3 @@
+bnx2i-y := bnx2i_init.o bnx2i_hwi.o bnx2i_iscsi.o bnx2i_sysfs.o
+
+obj-$(CONFIG_SCSI_BNX2_ISCSI) += bnx2i.o
drivers/scsi/bnx2i/bnx2i.h new file +776 -0

776 lines not on this page · raw message

drivers/scsi/bnx2i/bnx2i_hwi.c new file +2446 -0

537 lines not on this page · raw message

drivers/scsi/bnx2i/bnx2i_init.c new file +434 -0

434 lines not on this page · raw message

drivers/scsi/bnx2i/bnx2i_iscsi.c new file +2101 -0

2,101 lines not on this page · raw message

drivers/scsi/bnx2i/bnx2i_sysfs.c new file +142 -0

142 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.6.GIT

Part of the diff is not shown here. View the raw message.

#18 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 13 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +12 -0
+
+/**
+ * bnx2i_nl_mesg_recv -
+ * @buf:	pointer to buffer containing vendor specific message
+ * @buf:	buffer length
+ *
+ */
+static int bnx2i_nl_mesg_recv(struct Scsi_Host *shost, uint16_t priv_op,
+			      int status, char *buf, int buflen)
+{
+	struct bnx2i_hba *hba = iscsi_host_priv(shost);
+

drivers/scsi/bnx2i/bnx2i_iscsi.c line 2025

Quoted 10 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +10 -0
+	switch (priv_op) {
+	case NX2_UIO_UEVENT_NEIGH_LOOKUP:
+	default:
+		/* handle by cnic driver */
+		hba->cnic->nl_priv_msg_recv(hba->cnic, priv_op, buf, buflen);
+		break;
+	}
+
+	return buflen;
+}

I think I was wrong with one of the comments I gave you.

It seems like we have two iscsi net config models.

1. qla4xxx and Server Engines type of setup where the driver just tells the card to use some ip or do dhcp and some other net settings and it does all the net magic. The iscsi driver does not have to worry about anything like the dhcp process or arp. It only passes down the setup values.

2. cxgb3i and bnx2i type of model where kernel or userspace code is needed to execute many net operations.
- Right now, cxgb3i sort of cheated :) and only supports static IPs. It currently uses the iscsi set param interface to do this.

- bnx2i wants to add more complicated features and is going to do them in userspace. It us using the private messages that were added in the previous patch.

I think cxgb3i is one day going to want to support the same features bnx2i does. If that is right, then should we just make the NX2_UIO events common iscsi events, and hook cxb3i in? It would not use the iscsi set param interface at all and would work just like bnx2i. Is that possible? What about future drivers? Are done making iscsi cards and drivers. If so, thank goodness :) If not then maybe we want to consider some future driver using the #2 module and possibly using this.

If cxgb3i is really only going to support static ip setup and we think that bnx2i is going to be unique on how it sets up the network then I NX2_UIO private events are fine. Or is this a case of we are thinking that iscsi hardware people are creating crazy interfaces so there is no why to predict what they are going to do so there is no point in trying to design for them.

#19 lore raw

RE: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mike Christie
Sent: Wednesday, May 06, 2009 9:49 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Karen Xie; Jayamohan Kalickal
Subject: Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

drivers/scsi/bnx2i/bnx2i_iscsi.c

Quoted 8 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +8 -0
+
+/**
+ * bnx2i_nl_mesg_recv -
+ * @buf:	pointer to buffer containing vendor specific message
+ * @buf:	buffer length
+ *
+ */
+static int bnx2i_nl_mesg_recv(struct Scsi_Host *shost, uint16_t

priv_op,

drivers/scsi/bnx2i/bnx2i_iscsi.c

Quoted 9 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +9 -0
+			      int status, char *buf, int buflen)
+{
+	struct bnx2i_hba *hba = iscsi_host_priv(shost);
+
+	switch (priv_op) {
+	case NX2_UIO_UEVENT_NEIGH_LOOKUP:
+	default:
+		/* handle by cnic driver */
+		hba->cnic->nl_priv_msg_recv(hba->cnic, priv_op, buf,

buflen);

drivers/scsi/bnx2i/bnx2i_iscsi.c line 2025

Quoted 5 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +5 -0
+		break;
+	}
+
+	return buflen;
+}

I think I was wrong with one of the comments I gave you.

It seems like we have two iscsi net config models.

1. qla4xxx and Server Engines type of setup where the driver just tells the card to use some ip or do dhcp and some other net settings and it does all the net magic. The iscsi driver does not have to worry about anything like the dhcp process or arp. It only passes down the setup values.

2. cxgb3i and bnx2i type of model where kernel or userspace code is needed to execute many net operations.
- Right now, cxgb3i sort of cheated :) and only supports static IPs. It currently uses the iscsi set param interface to do this.

- bnx2i wants to add more complicated features and is going to do them in userspace. It us using the private messages that were added in the previous patch.

I think cxgb3i is one day going to want to support the same features bnx2i does. If that is right, then should we just make the NX2_UIO events common iscsi events, and hook cxb3i in? It would not use the iscsi set param interface at all and would work just like bnx2i. Is that

possible? What about future drivers? Are done making iscsi cards and drivers. If so, thank goodness :) If not then maybe we want to consider

some future driver using the #2 module and possibly using this.

[Karen] for cxgb3i, we are looking into support dynamic IP, so making the events common to iscsi would be helpful.

If cxgb3i is really only going to support static ip setup and we think that bnx2i is going to be unique on how it sets up the network then I NX2_UIO private events are fine. Or is this a case of we are thinking that iscsi hardware people are creating crazy interfaces so there is no why to predict what they are going to do so there is no point in trying to design for them.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

In reply to Mike Christie
Quoted 50 lines · Mike Christie
Quoted 12 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +12 -0
+
+/**
+ * bnx2i_nl_mesg_recv -
+ * @buf:	pointer to buffer containing vendor specific message
+ * @buf:	buffer length
+ *
+ */
+static int bnx2i_nl_mesg_recv(struct Scsi_Host *shost, uint16_t priv_op,
+			      int status, char *buf, int buflen)
+{
+	struct bnx2i_hba *hba = iscsi_host_priv(shost);
+

drivers/scsi/bnx2i/bnx2i_iscsi.c line 2025

Quoted 10 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +10 -0
+	switch (priv_op) {
+	case NX2_UIO_UEVENT_NEIGH_LOOKUP:
+	default:
+		/* handle by cnic driver */
+		hba->cnic->nl_priv_msg_recv(hba->cnic, priv_op, buf, buflen);
+		break;
+	}
+
+	return buflen;
+}

I think I was wrong with one of the comments I gave you.

It seems like we have two iscsi net config models.

1. qla4xxx and Server Engines type of setup where the driver just tells the card to use some ip or do dhcp and some other net settings and it does all the net magic. The iscsi driver does not have to worry about anything like the dhcp process or arp. It only passes down the setup values.

2. cxgb3i and bnx2i type of model where kernel or userspace code is needed to execute many net operations.
- Right now, cxgb3i sort of cheated :) and only supports static IPs. It currently uses the iscsi set param interface to do this.

- bnx2i wants to add more complicated features and is going to do them in userspace. It us using the private messages that were added in the previous patch.

I think cxgb3i is one day going to want to support the same features bnx2i does. If that is right, then should we just make the NX2_UIO events common iscsi events, and hook cxb3i in? It would not use the iscsi set param interface at all and would work just like bnx2i. Is that possible? What about future drivers? Are done making iscsi cards and drivers. If so, thank goodness :) If not then maybe we want to consider some future driver using the #2 module and possibly using this.

Quoted 6 lines

If cxgb3i is really only going to support static ip setup and we think that bnx2i is going to be unique on how it sets up the network then I NX2_UIO private events are fine. Or is this a case of we are thinking that iscsi hardware people are creating crazy interfaces so there is no why to predict what they are going to do so there is no point in trying to design for them.

If there is any possibility that cxgb3i will use something similar to bnx2i, I think we can change the message to a standard one and make the message structure somewhat more generic. We'll probably still need a private area in the message for hardware or vendor specific information.

#21 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 37 lines · Michael Chan
Quoted 36 lines · Mike Christie
Quoted 12 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +12 -0
+
+/**
+ * bnx2i_nl_mesg_recv -
+ * @buf:	pointer to buffer containing vendor specific message
+ * @buf:	buffer length
+ *
+ */
+static int bnx2i_nl_mesg_recv(struct Scsi_Host *shost, uint16_t priv_op,
+			      int status, char *buf, int buflen)
+{
+	struct bnx2i_hba *hba = iscsi_host_priv(shost);
+

drivers/scsi/bnx2i/bnx2i_iscsi.c line 2025

Quoted 10 lines
drivers/scsi/bnx2i/bnx2i_iscsi.c new file +10 -0
+	switch (priv_op) {
+	case NX2_UIO_UEVENT_NEIGH_LOOKUP:
+	default:
+		/* handle by cnic driver */
+		hba->cnic->nl_priv_msg_recv(hba->cnic, priv_op, buf, buflen);
+		break;
+	}
+
+	return buflen;
+}

I think I was wrong with one of the comments I gave you.

It seems like we have two iscsi net config models.

1. qla4xxx and Server Engines type of setup where the driver just tells the card to use some ip or do dhcp and some other net settings and it does all the net magic. The iscsi driver does not have to worry about anything like the dhcp process or arp. It only passes down the setup values.

2. cxgb3i and bnx2i type of model where kernel or userspace code is needed to execute many net operations.
- Right now, cxgb3i sort of cheated :) and only supports static IPs. It
currently uses the iscsi set param interface to do this.

- bnx2i wants to add more complicated features and is going to do them in userspace. It us using the private messages that were added in the previous patch.

Quoted 9 lines
Quoted 3 lines

I think cxgb3i is one day going to want to support the same features bnx2i does. If that is right, then should we just make the NX2_UIO events common iscsi events, and hook cxb3i in? It would not use the iscsi set param interface at all and would work just like bnx2i. Is that possible? What about future drivers? Are done making iscsi cards and drivers. If so, thank goodness :) If not then maybe we want to consider some future driver using the #2 module and possibly using this.

If cxgb3i is really only going to support static ip setup and we think that bnx2i is going to be unique on how it sets up the network then I NX2_UIO private events are fine. Or is this a case of we are thinking that iscsi hardware people are creating crazy interfaces so there is no why to predict what they are going to do so there is no point in trying to design for them.

If there is any possibility that cxgb3i will use something similar to bnx2i, I think we can change the message to a standard one and make the message structure somewhat more generic. We'll probably still need a private area in the message for hardware or vendor specific information.

Ok sounds good to me.

#22 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 17 lines · Mike Christie
Quoted 16 lines · Michael Chan
Quoted 14 lines · Mike Christie

I think cxgb3i is one day going to want to support the same features bnx2i does. If that is right, then should we just make the NX2_UIO events common iscsi events, and hook cxb3i in? It would not use the iscsi set param interface at all and would work just like bnx2i. Is that possible? What about future drivers? Are done making iscsi cards and drivers. If so, thank goodness :) If not then maybe we want to consider some future driver using the #2 module and possibly using this.

If cxgb3i is really only going to support static ip setup and we think that bnx2i is going to be unique on how it sets up the network then I NX2_UIO private events are fine. Or is this a case of we are thinking that iscsi hardware people are creating crazy interfaces so there is no why to predict what they are going to do so there is no point in trying to design for them.

Quoted 8 lines
Quoted 5 lines

If there is any possibility that cxgb3i will use something similar to bnx2i, I think we can change the message to a standard one and make the message structure somewhat more generic. We'll probably still need a private area in the message for hardware or vendor specific information.

Ok sounds good to me.

Here are the more generic NETLINK_ISCSI messages and the iscsi transport code to support them, please review.

drivers/scsi/scsi_transport_iscsi.c +62 -1
index d69a53a..60cb6cb 100644
@@ -995,6 +995,39 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+int iscsi_offload_mesg(struct Scsi_Host *shost,
+		       struct iscsi_transport *transport, uint32_t type,
+		       char *data, uint16_t data_size)
+{
+	struct nlmsghdr	*nlh;
+	struct sk_buff *skb;
+	struct iscsi_uevent *ev;
+	int len = NLMSG_SPACE(sizeof(*ev) + data_size);
+
+	skb = alloc_skb(len, GFP_ATOMIC);
+	if (!skb) {
+		printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
+		return -ENOMEM;
+	}
+
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
+	ev = NLMSG_DATA(nlh);
+	memset(ev, 0, sizeof(*ev));
+	ev->type = type;
+	ev->transport_handle = iscsi_handle(transport);
+	switch (type) {
+	case ISCSI_KEVENT_PATH_REQ:
+		ev->r.req_path.host_no = shost->host_no;
+	case ISCSI_KEVENT_IF_DOWN:
+		ev->r.notify_if_down.host_no = shost->host_no;
+	}
+
+	memcpy((char*)ev + sizeof(*ev), data, data_size);
+
+	return iscsi_broadcast_skb(skb, GFP_KERNEL);
+}
+EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
+
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 {
 	struct nlmsghdr	*nlh;
@@ -1393,6 +1426,30 @@ iscsi_set_host_param(struct iscsi_transport *transport,
 }
 
 static int
+iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	struct iscsi_path *params;
+	int err;
+
+	if (!transport->set_path)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.set_path.host_no);
+	if (!shost) {
+		printk(KERN_ERR "set path could not find host no %u\n",
+		       ev->u.set_path.host_no);
+		return -ENODEV;
+	}
+
+	params = (struct iscsi_path *)((char*)ev + sizeof(*ev));
+	err = transport->set_path(shost, params);
+				      
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	int err = 0;
@@ -1411,7 +1468,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (!try_module_get(transport->owner))
 		return -EINVAL;
 
-	priv->daemon_pid = NETLINK_CREDS(skb)->pid;
+	if (nlh->nlmsg_type != ISCSI_UEVENT_PATH_UPDATE)
+		priv->daemon_pid = NETLINK_CREDS(skb)->pid;
 
 	switch (nlh->nlmsg_type) {
 	case ISCSI_UEVENT_CREATE_SESSION:
@@ -1506,6 +1564,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	case ISCSI_UEVENT_SET_HOST_PARAM:
 		err = iscsi_set_host_param(transport, ev);
 		break;
+	case ISCSI_UEVENT_PATH_UPDATE:
+		err = iscsi_set_path(transport, ev);
+		break;
 	default:
 		err = -ENOSYS;
 		break;
include/scsi/iscsi_if.h +37 -0
index 2c1a4af..cb33e78 100644
@@ -53,6 +53,8 @@ enum iscsi_uevent_e {
 	ISCSI_UEVENT_CREATE_BOUND_SESSION		= UEVENT_BASE + 18,
 	ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST	= UEVENT_BASE + 19,
 
+	ISCSI_UEVENT_PATH_UPDATE	= UEVENT_BASE + 20,
+
 	/* up events */
 	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
 	ISCSI_KEVENT_CONN_ERROR		= KEVENT_BASE + 2,
@@ -60,6 +62,9 @@ enum iscsi_uevent_e {
 	ISCSI_KEVENT_DESTROY_SESSION	= KEVENT_BASE + 4,
 	ISCSI_KEVENT_UNBIND_SESSION	= KEVENT_BASE + 5,
 	ISCSI_KEVENT_CREATE_SESSION	= KEVENT_BASE + 6,
+
+	ISCSI_KEVENT_PATH_REQ		= KEVENT_BASE + 7,
+	ISCSI_KEVENT_IF_DOWN		= KEVENT_BASE + 8,
 };
 
 enum iscsi_tgt_dscvr {
@@ -159,6 +164,9 @@ struct iscsi_uevent {
 			uint32_t	param; /* enum iscsi_host_param */
 			uint32_t	len;
 		} set_host_param;
+		struct msg_set_path {
+			uint32_t	host_no;
+		} set_path;
 	} u;
 	union {
 		/* messages k -> u */
@@ -192,10 +200,39 @@ struct iscsi_uevent {
 		struct msg_transport_connect_ret {
 			uint64_t	handle;
 		} ep_connect_ret;
+		struct msg_req_path {
+			uint32_t	host_no;
+		} req_path;
+		struct msg_notify_if_down {
+			uint32_t	host_no;
+		} notify_if_down;
 	} r;
 } __attribute__ ((aligned (sizeof(uint64_t))));
 
 /*
+ * To keep the struct iscsi_uevent size the same for userspace code
+ * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
+ * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
+ * struct iscsi_uevent in the NETLINK_ISCSI message.
+ */
+struct iscsi_path {
+	uint64_t	handle;
+	uint8_t		mac_addr[6];
+	uint8_t		mac_addr_old[6];
+	uint32_t	ip_addr_len;	/* 4 or 16 */
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
+	} src;
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
+	} dst;
+	uint16_t	vlan_id;
+	uint16_t	pmtu;
+};
+
+/*
  * Common error codes
  */
 enum iscsi_err {
include/scsi/scsi_transport_iscsi.h +5 -0
index 8cb7a31..349c7f3 100644
@@ -133,6 +133,7 @@ struct iscsi_transport {
 	void (*ep_disconnect) (struct iscsi_endpoint *ep);
 	int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
 			  uint32_t enable, struct sockaddr *dst_addr);
+	int (*set_path) (struct Scsi_Host *shost, struct iscsi_path *params);
 };
 
 /*
@@ -149,6 +150,10 @@ extern void iscsi_conn_error_event(struct iscsi_cls_conn *conn,
 extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 			  char *data, uint32_t data_size);
 
+extern int iscsi_offload_mesg(struct Scsi_Host *shost,
+			      struct iscsi_transport *transport, uint32_t type,
+			      char *data, uint16_t data_size);
+
 struct iscsi_cls_conn {
 	struct list_head conn_list;	/* item in connlist */
 	void *dd_data;			/* LLD private data */
#23 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 45 lines · Michael Chan
Quoted 4 lines · Mike Christie
Quoted 3 lines · Michael Chan
Quoted 2 lines · Mike Christie

I think cxgb3i is one day going to want to support the same features bnx2i does. If that is right, then should we just make the NX2_UIO events common iscsi events, and hook cxb3i in? It would not use the iscsi set param interface at all and would work just like bnx2i. Is that possible? What about future drivers? Are done making iscsi cards and drivers. If so, thank goodness :) If not then maybe we want to consider some future driver using the #2 module and possibly using this.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

If cxgb3i is really only going to support static ip setup and we think that bnx2i is going to be unique on how it sets up the network then I NX2_UIO private events are fine. Or is this a case of we are thinking that iscsi hardware people are creating crazy interfaces so there is no why to predict what they are going to do so there is no point in trying to design for them.

If there is any possibility that cxgb3i will use something similar to bnx2i, I think we can change the message to a standard one and make the message structure somewhat more generic. We'll probably still need a private area in the message for hardware or vendor specific information.

Ok sounds good to me.

Here are the more generic NETLINK_ISCSI messages and the iscsi transport code to support them, please review.

drivers/scsi/scsi_transport_iscsi.c +20 -0
index d69a53a..60cb6cb 100644
@@ -995,6 +995,39 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+int iscsi_offload_mesg(struct Scsi_Host *shost,
+		       struct iscsi_transport *transport, uint32_t type,
+		       char *data, uint16_t data_size)
+{
+	struct nlmsghdr	*nlh;
+	struct sk_buff *skb;
+	struct iscsi_uevent *ev;
+	int len = NLMSG_SPACE(sizeof(*ev) + data_size);
+
+	skb = alloc_skb(len, GFP_ATOMIC);
+	if (!skb) {
+		printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
+		return -ENOMEM;
+	}
+
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
+	ev = NLMSG_DATA(nlh);
+	memset(ev, 0, sizeof(*ev));
+	ev->type = type;
+	ev->transport_handle = iscsi_handle(transport);

drivers/scsi/scsi_transport_iscsi.c int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, · line 1027

Quoted 10 lines
drivers/scsi/scsi_transport_iscsi.c +10 -0
+	switch (type) {
+	case ISCSI_KEVENT_PATH_REQ:
+		ev->r.req_path.host_no = shost->host_no;
+	case ISCSI_KEVENT_IF_DOWN:
+		ev->r.notify_if_down.host_no = shost->host_no;
+	}
+
+	memcpy((char*)ev + sizeof(*ev), data, data_size);
+
+	return iscsi_broadcast_skb(skb, GFP_KERNEL);

You can sync up what the gfp flag used here and for the alloc_skb call above. If you have process context, you probably want to use GFP_NOIO, because this could be called for reconnect for a disk in use.

If you do not have process context then you would need to use GFP_ATOMIC.

Quoted 38 lines
drivers/scsi/scsi_transport_iscsi.c +27 -0
+}
+EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
+
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 {
 	struct nlmsghdr	*nlh;
@@ -1393,6 +1426,30 @@ iscsi_set_host_param(struct iscsi_transport *transport,
 }
 
 static int
+iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	struct iscsi_path *params;
+	int err;
+
+	if (!transport->set_path)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.set_path.host_no);
+	if (!shost) {
+		printk(KERN_ERR "set path could not find host no %u\n",
+		       ev->u.set_path.host_no);
+		return -ENODEV;
+	}
+
+	params = (struct iscsi_path *)((char*)ev + sizeof(*ev));
+	err = transport->set_path(shost, params);
+				      
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	int err = 0;

drivers/scsi/scsi_transport_iscsi.c iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · line 1473

Quoted 7 lines
drivers/scsi/scsi_transport_iscsi.c +2 -1
@@ -1411,7 +1468,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (!try_module_get(transport->owner))
 		return -EINVAL;
 
-	priv->daemon_pid = NETLINK_CREDS(skb)->pid;
+	if (nlh->nlmsg_type != ISCSI_UEVENT_PATH_UPDATE)
+		priv->daemon_pid = NETLINK_CREDS(skb)->pid;
 

Instead of using broadcast above and in some other places and then doing this check, could we just use multicast groups or something else? The events from iscsid could be in one group and then events for uip would be in another?

Or is it more common to do it like this or will it break compat with other tools if we change it?

#24 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 49 lines · Mike Christie
Quoted 32 lines · Michael Chan

Here are the more generic NETLINK_ISCSI messages and the iscsi transport code to support them, please review.

drivers/scsi/scsi_transport_iscsi.c +20 -0
index d69a53a..60cb6cb 100644
@@ -995,6 +995,39 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+int iscsi_offload_mesg(struct Scsi_Host *shost,
+		       struct iscsi_transport *transport, uint32_t type,
+		       char *data, uint16_t data_size)
+{
+	struct nlmsghdr	*nlh;
+	struct sk_buff *skb;
+	struct iscsi_uevent *ev;
+	int len = NLMSG_SPACE(sizeof(*ev) + data_size);
+
+	skb = alloc_skb(len, GFP_ATOMIC);
+	if (!skb) {
+		printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
+		return -ENOMEM;
+	}
+
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
+	ev = NLMSG_DATA(nlh);
+	memset(ev, 0, sizeof(*ev));
+	ev->type = type;
+	ev->transport_handle = iscsi_handle(transport);

drivers/scsi/scsi_transport_iscsi.c int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, · line 1027

Quoted 10 lines
drivers/scsi/scsi_transport_iscsi.c +10 -0
+	switch (type) {
+	case ISCSI_KEVENT_PATH_REQ:
+		ev->r.req_path.host_no = shost->host_no;
+	case ISCSI_KEVENT_IF_DOWN:
+		ev->r.notify_if_down.host_no = shost->host_no;
+	}
+
+	memcpy((char*)ev + sizeof(*ev), data, data_size);
+
+	return iscsi_broadcast_skb(skb, GFP_KERNEL);

You can sync up what the gfp flag used here and for the alloc_skb call above. If you have process context, you probably want to use GFP_NOIO, because this could be called for reconnect for a disk in use.

Quoted 3 lines

If you do not have process context then you would need to use GFP_ATOMIC.

We have process context, but I think we should make it more general for other future drivers and use GFP_ATOMIC.

Quoted 41 lines
Quoted 41 lines
drivers/scsi/scsi_transport_iscsi.c +27 -0
+}
+EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
+
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 {
 	struct nlmsghdr	*nlh;
@@ -1393,6 +1426,30 @@ iscsi_set_host_param(struct iscsi_transport *transport,
 }
 
 static int
+iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	struct iscsi_path *params;
+	int err;
+
+	if (!transport->set_path)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.set_path.host_no);
+	if (!shost) {
+		printk(KERN_ERR "set path could not find host no %u\n",
+		       ev->u.set_path.host_no);
+		return -ENODEV;
+	}
+
+	params = (struct iscsi_path *)((char*)ev + sizeof(*ev));
+	err = transport->set_path(shost, params);
+				      
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	int err = 0;
@@ -1411,7 +1468,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (!try_module_get(transport->owner))
 		return -EINVAL;
 
Quoted 9 lines

drivers/scsi/scsi_transport_iscsi.c iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · line 1473

Quoted 4 lines
drivers/scsi/scsi_transport_iscsi.c +2 -1
-	priv->daemon_pid = NETLINK_CREDS(skb)->pid;
+	if (nlh->nlmsg_type != ISCSI_UEVENT_PATH_UPDATE)
+		priv->daemon_pid = NETLINK_CREDS(skb)->pid;
 

Instead of using broadcast above and in some other places and then doing this check, could we just use multicast groups or something else? The events from iscsid could be in one group and then events for uip would be in another?

We need to do this check because we don't want the daemon_pid to be overwritten with a pid that is not iscsid's. If it was overwritten, unicast NETLINK_ISCSI messages will not reach iscsid.

We can use multicast group 2 for the new messages if you prefer. This way, I think iscsid will not receive the new messages since it is only listening on group 1. The pid check will still be needed though.

Quoted 4 lines

Or is it more common to do it like this or will it break compat with other tools if we change it?

#25 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 47 lines · Michael Chan
Quoted 45 lines · Mike Christie
Quoted 31 lines · Michael Chan

Here are the more generic NETLINK_ISCSI messages and the iscsi transport code to support them, please review.

drivers/scsi/scsi_transport_iscsi.c +20 -0
index d69a53a..60cb6cb 100644
@@ -995,6 +995,39 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+int iscsi_offload_mesg(struct Scsi_Host *shost,
+		       struct iscsi_transport *transport, uint32_t type,
+		       char *data, uint16_t data_size)
+{
+	struct nlmsghdr	*nlh;
+	struct sk_buff *skb;
+	struct iscsi_uevent *ev;
+	int len = NLMSG_SPACE(sizeof(*ev) + data_size);
+
+	skb = alloc_skb(len, GFP_ATOMIC);
+	if (!skb) {
+		printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
+		return -ENOMEM;
+	}
+
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
+	ev = NLMSG_DATA(nlh);
+	memset(ev, 0, sizeof(*ev));
+	ev->type = type;
+	ev->transport_handle = iscsi_handle(transport);

drivers/scsi/scsi_transport_iscsi.c int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, · line 1027

Quoted 10 lines
drivers/scsi/scsi_transport_iscsi.c +10 -0
+	switch (type) {
+	case ISCSI_KEVENT_PATH_REQ:
+		ev->r.req_path.host_no = shost->host_no;
+	case ISCSI_KEVENT_IF_DOWN:
+		ev->r.notify_if_down.host_no = shost->host_no;
+	}
+
+	memcpy((char*)ev + sizeof(*ev), data, data_size);
+
+	return iscsi_broadcast_skb(skb, GFP_KERNEL);

You can sync up what the gfp flag used here and for the alloc_skb call above. If you have process context, you probably want to use GFP_NOIO, because this could be called for reconnect for a disk in use.

Quoted 6 lines
Quoted 3 lines

If you do not have process context then you would need to use GFP_ATOMIC.

We have process context, but I think we should make it more general for other future drivers and use GFP_ATOMIC.

If you have process context just use GFP_NOIO. We can change it later when/if a driver needs it. I think we like to avoid GFP_ATOMIC if we can. Or just add a gfp_t argument to the function so the caller can do what is right for them if you want to make it general.

Quoted 48 lines
Quoted 42 lines
Quoted 42 lines
drivers/scsi/scsi_transport_iscsi.c +27 -0
+}
+EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
+
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 {
 	struct nlmsghdr	*nlh;
@@ -1393,6 +1426,30 @@ iscsi_set_host_param(struct iscsi_transport *transport,
 }
 
 static int
+iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	struct iscsi_path *params;
+	int err;
+
+	if (!transport->set_path)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.set_path.host_no);
+	if (!shost) {
+		printk(KERN_ERR "set path could not find host no %u\n",
+		       ev->u.set_path.host_no);
+		return -ENODEV;
+	}
+
+	params = (struct iscsi_path *)((char*)ev + sizeof(*ev));
+	err = transport->set_path(shost, params);
+				      
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	int err = 0;
@@ -1411,7 +1468,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (!try_module_get(transport->owner))
 		return -EINVAL;
 
Quoted 5 lines

drivers/scsi/scsi_transport_iscsi.c iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · line 1473

Quoted 4 lines
drivers/scsi/scsi_transport_iscsi.c +2 -1
-	priv->daemon_pid = NETLINK_CREDS(skb)->pid;
+	if (nlh->nlmsg_type != ISCSI_UEVENT_PATH_UPDATE)
+		priv->daemon_pid = NETLINK_CREDS(skb)->pid;
 

Instead of using broadcast above and in some other places and then doing this check, could we just use multicast groups or something else? The events from iscsid could be in one group and then events for uip would be in another?

Quoted 8 lines

We need to do this check because we don't want the daemon_pid to be overwritten with a pid that is not iscsid's. If it was overwritten, unicast NETLINK_ISCSI messages will not reach iscsid.

We can use multicast group 2 for the new messages if you prefer. This way, I think iscsid will not receive the new messages since it is only listening on group 1. The pid check will still be needed though.

ok.

#26 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 7 lines · Mike Christie

If you have process context just use GFP_NOIO. We can change it later when/if a driver needs it. I think we like to avoid GFP_ATOMIC if we can. Or just add a gfp_t argument to the function so the caller can do
what is right for them if you want to make it general.

Here's the new patch. The multicast change is from Mike Christie.

drivers/scsi/scsi_transport_iscsi.c +86 -36
index d69a53a..9bd337a 100644
@@ -37,7 +37,6 @@
 #define ISCSI_TRANSPORT_VERSION "2.0-870"
 
 struct iscsi_internal {
-	int daemon_pid;
 	struct scsi_transport_template t;
 	struct iscsi_transport *iscsi_transport;
 	struct list_head list;
@@ -938,23 +937,9 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
 }
 
 static int
-iscsi_broadcast_skb(struct sk_buff *skb, gfp_t gfp)
+iscsi_multicast_skb(struct sk_buff *skb, u32 group, gfp_t gfp)
 {
-	return netlink_broadcast(nls, skb, 0, 1, gfp);
-}
-
-static int
-iscsi_unicast_skb(struct sk_buff *skb, int pid)
-{
-	int rc;
-
-	rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT);
-	if (rc < 0) {
-		printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc);
-		return rc;
-	}
-
-	return 0;
+	return nlmsg_multicast(nls, skb, 0, group, gfp);
 }
 
 int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
@@ -980,7 +965,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 		return -ENOMEM;
 	}
 
-	nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0);
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
 	ev = NLMSG_DATA(nlh);
 	memset(ev, 0, sizeof(*ev));
 	ev->transport_handle = iscsi_handle(conn->transport);
@@ -991,10 +976,45 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 	memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
 	memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
 
-	return iscsi_unicast_skb(skb, priv->daemon_pid);
+	return iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
+int iscsi_offload_mesg(struct Scsi_Host *shost,
+		       struct iscsi_transport *transport, uint32_t type,
+		       char *data, uint16_t data_size)
+{
+	struct nlmsghdr	*nlh;
+	struct sk_buff *skb;
+	struct iscsi_uevent *ev;
+	int len = NLMSG_SPACE(sizeof(*ev) + data_size);
+
+	skb = alloc_skb(len, GFP_NOIO);
+	if (!skb) {
+		printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
+		return -ENOMEM;
+	}
+
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
+	ev = NLMSG_DATA(nlh);
+	memset(ev, 0, sizeof(*ev));
+	ev->type = type;
+	ev->transport_handle = iscsi_handle(transport);
+	switch (type) {
+	case ISCSI_KEVENT_PATH_REQ:
+		ev->r.req_path.host_no = shost->host_no;
+		break;
+	case ISCSI_KEVENT_IF_DOWN:
+		ev->r.notify_if_down.host_no = shost->host_no;
+		break;
+	}
+
+	memcpy((char*)ev + sizeof(*ev), data, data_size);
+
+	return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_NOIO);
+}
+EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
+
 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 {
 	struct nlmsghdr	*nlh;
@@ -1014,7 +1034,7 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 		return;
 	}
 
-	nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0);
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
 	ev = NLMSG_DATA(nlh);
 	ev->transport_handle = iscsi_handle(conn->transport);
 	ev->type = ISCSI_KEVENT_CONN_ERROR;
@@ -1022,7 +1042,7 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 	ev->r.connerror.cid = conn->cid;
 	ev->r.connerror.sid = iscsi_conn_get_sid(conn);
 
-	iscsi_broadcast_skb(skb, GFP_ATOMIC);
+	iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
 
 	iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn error (%d)\n",
 			      error);
@@ -1030,8 +1050,8 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
 EXPORT_SYMBOL_GPL(iscsi_conn_error_event);
 
 static int
-iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
-		      void *payload, int size)
+iscsi_if_send_reply(u32 group, int seq, int type, int done, int multi,
+		    void *payload, int size)
 {
 	struct sk_buff	*skb;
 	struct nlmsghdr	*nlh;
@@ -1045,10 +1065,10 @@ iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
 		return -ENOMEM;
 	}
 
-	nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0);
+	nlh = __nlmsg_put(skb, 0, 0, t, (len - sizeof(*nlh)), 0);
 	nlh->nlmsg_flags = flags;
 	memcpy(NLMSG_DATA(nlh), payload, size);
-	return iscsi_unicast_skb(skb, pid);
+	return iscsi_multicast_skb(skb, group, GFP_ATOMIC);
 }
 
 static int
@@ -1085,7 +1105,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
 			return -ENOMEM;
 		}
 
-		nlhstat = __nlmsg_put(skbstat, priv->daemon_pid, 0, 0,
+		nlhstat = __nlmsg_put(skbstat, 0, 0, 0,
 				      (len - sizeof(*nlhstat)), 0);
 		evstat = NLMSG_DATA(nlhstat);
 		memset(evstat, 0, sizeof(*evstat));
@@ -1109,7 +1129,8 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
 		skb_trim(skbstat, NLMSG_ALIGN(actual_size));
 		nlhstat->nlmsg_len = actual_size;
 
-		err = iscsi_unicast_skb(skbstat, priv->daemon_pid);
+		err = iscsi_multicast_skb(skbstat, ISCSI_NL_GRP_ISCSID,
+					  GFP_ATOMIC);
 	} while (err < 0 && err != -ECONNREFUSED);
 
 	return err;
@@ -1143,7 +1164,7 @@ int iscsi_session_event(struct iscsi_cls_session *session,
 		return -ENOMEM;
 	}
 
-	nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0);
+	nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
 	ev = NLMSG_DATA(nlh);
 	ev->transport_handle = iscsi_handle(session->transport);
 
@@ -1172,7 +1193,7 @@ int iscsi_session_event(struct iscsi_cls_session *session,
 	 * this will occur if the daemon is not up, so we just warn
 	 * the user and when the daemon is restarted it will handle it
 	 */
-	rc = iscsi_broadcast_skb(skb, GFP_KERNEL);
+	rc = iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_KERNEL);
 	if (rc == -ESRCH)
 		iscsi_cls_session_printk(KERN_ERR, session,
 					 "Cannot notify userspace of session "
@@ -1393,7 +1414,31 @@ iscsi_set_host_param(struct iscsi_transport *transport,
 }
 
 static int
-iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
+iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	struct iscsi_path *params;
+	int err;
+
+	if (!transport->set_path)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.set_path.host_no);
+	if (!shost) {
+		printk(KERN_ERR "set path could not find host no %u\n",
+		       ev->u.set_path.host_no);
+		return -ENODEV;
+	}
+
+	params = (struct iscsi_path *)((char*)ev + sizeof(*ev));
+	err = transport->set_path(shost, params);
+				      
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
+iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, u32 *group)
 {
 	int err = 0;
 	struct iscsi_uevent *ev = NLMSG_DATA(nlh);
@@ -1403,6 +1448,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	struct iscsi_cls_conn *conn;
 	struct iscsi_endpoint *ep = NULL;
 
+	if (nlh->nlmsg_type == ISCSI_UEVENT_PATH_UPDATE)
+		*group = ISCSI_NL_GRP_UIP;
+	else
+		*group = ISCSI_NL_GRP_ISCSID;
+
 	priv = iscsi_if_transport_lookup(iscsi_ptr(ev->transport_handle));
 	if (!priv)
 		return -EINVAL;
@@ -1411,8 +1461,6 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	if (!try_module_get(transport->owner))
 		return -EINVAL;
 
-	priv->daemon_pid = NETLINK_CREDS(skb)->pid;
-
 	switch (nlh->nlmsg_type) {
 	case ISCSI_UEVENT_CREATE_SESSION:
 		err = iscsi_if_create_session(priv, ep, ev,
@@ -1506,6 +1554,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	case ISCSI_UEVENT_SET_HOST_PARAM:
 		err = iscsi_set_host_param(transport, ev);
 		break;
+	case ISCSI_UEVENT_PATH_UPDATE:
+		err = iscsi_set_path(transport, ev);
+		break;
 	default:
 		err = -ENOSYS;
 		break;
@@ -1528,6 +1579,7 @@ iscsi_if_rx(struct sk_buff *skb)
 		uint32_t rlen;
 		struct nlmsghdr	*nlh;
 		struct iscsi_uevent *ev;
+		u32 group;
 
 		nlh = nlmsg_hdr(skb);
 		if (nlh->nlmsg_len < sizeof(*nlh) ||
@@ -1540,7 +1592,7 @@ iscsi_if_rx(struct sk_buff *skb)
 		if (rlen > skb->len)
 			rlen = skb->len;
 
-		err = iscsi_if_recv_msg(skb, nlh);
+		err = iscsi_if_recv_msg(skb, nlh, &group);
 		if (err) {
 			ev->type = ISCSI_KEVENT_IF_ERROR;
 			ev->iferror = err;
@@ -1554,8 +1606,7 @@ iscsi_if_rx(struct sk_buff *skb)
 			 */
 			if (ev->type == ISCSI_UEVENT_GET_STATS && !err)
 				break;
-			err = iscsi_if_send_reply(
-				NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq,
+			err = iscsi_if_send_reply(group, nlh->nlmsg_seq,
 				nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
 		} while (err < 0 && err != -ECONNREFUSED);
 		skb_pull(skb, rlen);
@@ -1803,7 +1854,6 @@ iscsi_register_transport(struct iscsi_transport *tt)
 	if (!priv)
 		return NULL;
 	INIT_LIST_HEAD(&priv->list);
-	priv->daemon_pid = -1;
 	priv->iscsi_transport = tt;
 	priv->t.user_scan = iscsi_user_scan;
 	priv->t.create_work_queue = 1;
include/scsi/iscsi_if.h +40 -0
index 2c1a4af..0990dbb 100644
@@ -23,6 +23,9 @@
 
 #include <scsi/iscsi_proto.h>
 
+#define ISCSI_NL_GRP_ISCSID	1
+#define ISCSI_NL_GRP_UIP	2
+
 #define UEVENT_BASE			10
 #define KEVENT_BASE			100
 #define ISCSI_ERR_BASE			1000
@@ -53,6 +56,8 @@ enum iscsi_uevent_e {
 	ISCSI_UEVENT_CREATE_BOUND_SESSION		= UEVENT_BASE + 18,
 	ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST	= UEVENT_BASE + 19,
 
+	ISCSI_UEVENT_PATH_UPDATE	= UEVENT_BASE + 20,
+
 	/* up events */
 	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
 	ISCSI_KEVENT_CONN_ERROR		= KEVENT_BASE + 2,
@@ -60,6 +65,9 @@ enum iscsi_uevent_e {
 	ISCSI_KEVENT_DESTROY_SESSION	= KEVENT_BASE + 4,
 	ISCSI_KEVENT_UNBIND_SESSION	= KEVENT_BASE + 5,
 	ISCSI_KEVENT_CREATE_SESSION	= KEVENT_BASE + 6,
+
+	ISCSI_KEVENT_PATH_REQ		= KEVENT_BASE + 7,
+	ISCSI_KEVENT_IF_DOWN		= KEVENT_BASE + 8,
 };
 
 enum iscsi_tgt_dscvr {
@@ -159,6 +167,9 @@ struct iscsi_uevent {
 			uint32_t	param; /* enum iscsi_host_param */
 			uint32_t	len;
 		} set_host_param;
+		struct msg_set_path {
+			uint32_t	host_no;
+		} set_path;
 	} u;
 	union {
 		/* messages k -> u */
@@ -192,10 +203,39 @@ struct iscsi_uevent {
 		struct msg_transport_connect_ret {
 			uint64_t	handle;
 		} ep_connect_ret;
+		struct msg_req_path {
+			uint32_t	host_no;
+		} req_path;
+		struct msg_notify_if_down {
+			uint32_t	host_no;
+		} notify_if_down;
 	} r;
 } __attribute__ ((aligned (sizeof(uint64_t))));
 
 /*
+ * To keep the struct iscsi_uevent size the same for userspace code
+ * compatibility, the main structure for ISCSI_UEVENT_PATH_UPDATE and
+ * ISCSI_KEVENT_PATH_REQ is defined separately and comes after the
+ * struct iscsi_uevent in the NETLINK_ISCSI message.
+ */
+struct iscsi_path {
+	uint64_t	handle;
+	uint8_t		mac_addr[6];
+	uint8_t		mac_addr_old[6];
+	uint32_t	ip_addr_len;	/* 4 or 16 */
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
+	} src;
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
+	} dst;
+	uint16_t	vlan_id;
+	uint16_t	pmtu;
+};
+
+/*
  * Common error codes
  */
 enum iscsi_err {
include/scsi/scsi_transport_iscsi.h +5 -0
index 8cb7a31..349c7f3 100644
@@ -133,6 +133,7 @@ struct iscsi_transport {
 	void (*ep_disconnect) (struct iscsi_endpoint *ep);
 	int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
 			  uint32_t enable, struct sockaddr *dst_addr);
+	int (*set_path) (struct Scsi_Host *shost, struct iscsi_path *params);
 };
 
 /*
@@ -149,6 +150,10 @@ extern void iscsi_conn_error_event(struct iscsi_cls_conn *conn,
 extern int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
 			  char *data, uint32_t data_size);
 
+extern int iscsi_offload_mesg(struct Scsi_Host *shost,
+			      struct iscsi_transport *transport, uint32_t type,
+			      char *data, uint16_t data_size);
+
 struct iscsi_cls_conn {
 	struct list_head conn_list;	/* item in connlist */
 	void *dd_data;			/* LLD private data */
#27 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 10 lines · Michael Chan
include/scsi/iscsi_if.h +3 -0
index 2c1a4af..0990dbb 100644
@@ -23,6 +23,9 @@
 
 
+ */
+struct iscsi_path {
+	uint64_t	handle;

include/scsi/iscsi_if.h struct iscsi_uevent { · line 232

Quoted 10 lines
include/scsi/iscsi_if.h +10 -0
+	uint8_t		mac_addr[6];
+	uint8_t		mac_addr_old[6];
+	uint32_t	ip_addr_len;	/* 4 or 16 */
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
+	} src;
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;

I think we have to include in6.h and in.h in this file, right? iser would not compile with this patch without it. If that is right and it works for you now, I can just fix it when I merge the patch.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#29 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 17 lines · Mike Christie
Quoted 16 lines · Michael Chan
include/scsi/iscsi_if.h +9 -0
index 2c1a4af..0990dbb 100644
@@ -23,6 +23,9 @@
 
 
+ */
+struct iscsi_path {
+	uint64_t	handle;
+	uint8_t		mac_addr[6];
+	uint8_t		mac_addr_old[6];
+	uint32_t	ip_addr_len;	/* 4 or 16 */
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
Quoted 9 lines

include/scsi/iscsi_if.h struct iscsi_uevent { · line 232

Quoted 4 lines
include/scsi/iscsi_if.h +4 -0
+	} src;
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;

I think we have to include in6.h and in.h in this file, right? iser would not compile with this patch without it. If that is right and it works for you now, I can just fix it when I merge the patch.

Yes, either include these files here in iscsi_if.h or include them in places where iscsi_if.h is included. Which way do you prefer?

#30 lore raw

Re: [PATCH 4/4] bnx2i: Add bnx2i iSCSI driver.

Quoted 25 lines · Michael Chan
Quoted 7 lines · Mike Christie
Quoted 6 lines · Michael Chan
include/scsi/iscsi_if.h +0 -0
index 2c1a4af..0990dbb 100644
@@ -23,6 +23,9 @@
 
Quoted 15 lines

include/scsi/iscsi_if.h struct iscsi_uevent { · line 232

Quoted 13 lines
include/scsi/iscsi_if.h +13 -0
+ */
+struct iscsi_path {
+	uint64_t	handle;
+	uint8_t		mac_addr[6];
+	uint8_t		mac_addr_old[6];
+	uint32_t	ip_addr_len;	/* 4 or 16 */
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;
+	} src;
+	union {
+		struct in_addr	v4_addr;
+		struct in6_addr	v6_addr;

I think we have to include in6.h and in.h in this file, right? iser would not compile with this patch without it. If that is right and it works for you now, I can just fix it when I merge the patch.

Quoted 3 lines

Yes, either include these files here in iscsi_if.h or include them in places where iscsi_if.h is included. Which way do you prefer?

Here is fine.