diff options
Diffstat (limited to 'drivers/scsi')
84 files changed, 10628 insertions, 989 deletions
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 8b7983aba8f7..36c21b19e5d7 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -1978,7 +1978,8 @@ static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id) | |||
1978 | { | 1978 | { |
1979 | struct scsi_cmnd *cmd = tw_dev->srb[request_id]; | 1979 | struct scsi_cmnd *cmd = tw_dev->srb[request_id]; |
1980 | 1980 | ||
1981 | scsi_dma_unmap(cmd); | 1981 | if (cmd->SCp.phase == TW_PHASE_SGLIST) |
1982 | scsi_dma_unmap(cmd); | ||
1982 | } /* End twa_unmap_scsi_data() */ | 1983 | } /* End twa_unmap_scsi_data() */ |
1983 | 1984 | ||
1984 | /* scsi_host_template initializer */ | 1985 | /* scsi_host_template initializer */ |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index c03f1d2c9e2e..faa0fcfed71e 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -6,7 +6,7 @@ | |||
6 | Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 6 | Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
7 | Brad Strand <linux@3ware.com> | 7 | Brad Strand <linux@3ware.com> |
8 | 8 | ||
9 | Copyright (C) 1999-2007 3ware Inc. | 9 | Copyright (C) 1999-2009 3ware Inc. |
10 | 10 | ||
11 | Kernel compatiblity By: Andre Hedrick <andre@suse.com> | 11 | Kernel compatiblity By: Andre Hedrick <andre@suse.com> |
12 | Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com> | 12 | Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com> |
@@ -1294,7 +1294,8 @@ static void tw_unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd) | |||
1294 | { | 1294 | { |
1295 | dprintk(KERN_WARNING "3w-xxxx: tw_unmap_scsi_data()\n"); | 1295 | dprintk(KERN_WARNING "3w-xxxx: tw_unmap_scsi_data()\n"); |
1296 | 1296 | ||
1297 | scsi_dma_unmap(cmd); | 1297 | if (cmd->SCp.phase == TW_PHASE_SGLIST) |
1298 | scsi_dma_unmap(cmd); | ||
1298 | } /* End tw_unmap_scsi_data() */ | 1299 | } /* End tw_unmap_scsi_data() */ |
1299 | 1300 | ||
1300 | /* This function will reset a device extension */ | 1301 | /* This function will reset a device extension */ |
diff --git a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h index 8e71e5e122b3..a5a2ba2561d9 100644 --- a/drivers/scsi/3w-xxxx.h +++ b/drivers/scsi/3w-xxxx.h | |||
@@ -6,7 +6,7 @@ | |||
6 | Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 6 | Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
7 | Brad Strand <linux@3ware.com> | 7 | Brad Strand <linux@3ware.com> |
8 | 8 | ||
9 | Copyright (C) 1999-2007 3ware Inc. | 9 | Copyright (C) 1999-2009 3ware Inc. |
10 | 10 | ||
11 | Kernel compatiblity By: Andre Hedrick <andre@suse.com> | 11 | Kernel compatiblity By: Andre Hedrick <andre@suse.com> |
12 | Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com> | 12 | Non-Copyright (C) 2000 Andre Hedrick <andre@suse.com> |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 8ed2990c826e..fb2740789b68 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -628,6 +628,17 @@ config FCOE | |||
628 | ---help--- | 628 | ---help--- |
629 | Fibre Channel over Ethernet module | 629 | Fibre Channel over Ethernet module |
630 | 630 | ||
631 | config FCOE_FNIC | ||
632 | tristate "Cisco FNIC Driver" | ||
633 | depends on PCI && X86 | ||
634 | select LIBFC | ||
635 | help | ||
636 | This is support for the Cisco PCI-Express FCoE HBA. | ||
637 | |||
638 | To compile this driver as a module, choose M here and read | ||
639 | <file:Documentation/scsi/scsi.txt>. | ||
640 | The module will be called fnic. | ||
641 | |||
631 | config SCSI_DMX3191D | 642 | config SCSI_DMX3191D |
632 | tristate "DMX3191D SCSI support" | 643 | tristate "DMX3191D SCSI support" |
633 | depends on PCI && SCSI | 644 | depends on PCI && SCSI |
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index e7c861ac417d..a5049cfb40ed 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -39,6 +39,7 @@ obj-$(CONFIG_SCSI_DH) += device_handler/ | |||
39 | obj-$(CONFIG_LIBFC) += libfc/ | 39 | obj-$(CONFIG_LIBFC) += libfc/ |
40 | obj-$(CONFIG_LIBFCOE) += fcoe/ | 40 | obj-$(CONFIG_LIBFCOE) += fcoe/ |
41 | obj-$(CONFIG_FCOE) += fcoe/ | 41 | obj-$(CONFIG_FCOE) += fcoe/ |
42 | obj-$(CONFIG_FCOE_FNIC) += fnic/ | ||
42 | obj-$(CONFIG_ISCSI_TCP) += libiscsi.o libiscsi_tcp.o iscsi_tcp.o | 43 | obj-$(CONFIG_ISCSI_TCP) += libiscsi.o libiscsi_tcp.o iscsi_tcp.o |
43 | obj-$(CONFIG_INFINIBAND_ISER) += libiscsi.o | 44 | obj-$(CONFIG_INFINIBAND_ISER) += libiscsi.o |
44 | obj-$(CONFIG_SCSI_A4000T) += 53c700.o a4000t.o | 45 | obj-$(CONFIG_SCSI_A4000T) += 53c700.o a4000t.o |
diff --git a/drivers/scsi/cxgb3i/cxgb3i.h b/drivers/scsi/cxgb3i/cxgb3i.h index d362860e7504..59b0958d2d11 100644 --- a/drivers/scsi/cxgb3i/cxgb3i.h +++ b/drivers/scsi/cxgb3i/cxgb3i.h | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "cxgb3i_offload.h" | 34 | #include "cxgb3i_offload.h" |
35 | #include "cxgb3i_ddp.h" | 35 | #include "cxgb3i_ddp.h" |
36 | 36 | ||
37 | #define CXGB3I_SCSI_QDEPTH_DFLT 128 | 37 | #define CXGB3I_SCSI_HOST_QDEPTH 1024 |
38 | #define CXGB3I_MAX_TARGET CXGB3I_MAX_CONN | 38 | #define CXGB3I_MAX_TARGET CXGB3I_MAX_CONN |
39 | #define CXGB3I_MAX_LUN 512 | 39 | #define CXGB3I_MAX_LUN 512 |
40 | #define ISCSI_PDU_NONPAYLOAD_MAX \ | 40 | #define ISCSI_PDU_NONPAYLOAD_MAX \ |
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.c b/drivers/scsi/cxgb3i/cxgb3i_ddp.c index d06a661c209f..99c912547902 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_ddp.c +++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.c | |||
@@ -120,20 +120,26 @@ static void clear_ddp_map(struct cxgb3i_ddp_info *ddp, unsigned int tag, | |||
120 | } | 120 | } |
121 | 121 | ||
122 | static inline int ddp_find_unused_entries(struct cxgb3i_ddp_info *ddp, | 122 | static inline int ddp_find_unused_entries(struct cxgb3i_ddp_info *ddp, |
123 | int start, int max, int count, | 123 | unsigned int start, unsigned int max, |
124 | unsigned int count, | ||
124 | struct cxgb3i_gather_list *gl) | 125 | struct cxgb3i_gather_list *gl) |
125 | { | 126 | { |
126 | unsigned int i, j; | 127 | unsigned int i, j, k; |
127 | 128 | ||
129 | /* not enough entries */ | ||
130 | if ((max - start) < count) | ||
131 | return -EBUSY; | ||
132 | |||
133 | max -= count; | ||
128 | spin_lock(&ddp->map_lock); | 134 | spin_lock(&ddp->map_lock); |
129 | for (i = start; i <= max;) { | 135 | for (i = start; i < max;) { |
130 | for (j = 0; j < count; j++) { | 136 | for (j = 0, k = i; j < count; j++, k++) { |
131 | if (ddp->gl_map[i + j]) | 137 | if (ddp->gl_map[k]) |
132 | break; | 138 | break; |
133 | } | 139 | } |
134 | if (j == count) { | 140 | if (j == count) { |
135 | for (j = 0; j < count; j++) | 141 | for (j = 0, k = i; j < count; j++, k++) |
136 | ddp->gl_map[i + j] = gl; | 142 | ddp->gl_map[k] = gl; |
137 | spin_unlock(&ddp->map_lock); | 143 | spin_unlock(&ddp->map_lock); |
138 | return i; | 144 | return i; |
139 | } | 145 | } |
@@ -354,7 +360,7 @@ int cxgb3i_ddp_tag_reserve(struct t3cdev *tdev, unsigned int tid, | |||
354 | struct cxgb3i_ddp_info *ddp = tdev->ulp_iscsi; | 360 | struct cxgb3i_ddp_info *ddp = tdev->ulp_iscsi; |
355 | struct pagepod_hdr hdr; | 361 | struct pagepod_hdr hdr; |
356 | unsigned int npods; | 362 | unsigned int npods; |
357 | int idx = -1, idx_max; | 363 | int idx = -1; |
358 | int err = -ENOMEM; | 364 | int err = -ENOMEM; |
359 | u32 sw_tag = *tagp; | 365 | u32 sw_tag = *tagp; |
360 | u32 tag; | 366 | u32 tag; |
@@ -367,17 +373,17 @@ int cxgb3i_ddp_tag_reserve(struct t3cdev *tdev, unsigned int tid, | |||
367 | } | 373 | } |
368 | 374 | ||
369 | npods = (gl->nelem + PPOD_PAGES_MAX - 1) >> PPOD_PAGES_SHIFT; | 375 | npods = (gl->nelem + PPOD_PAGES_MAX - 1) >> PPOD_PAGES_SHIFT; |
370 | idx_max = ddp->nppods - npods + 1; | ||
371 | 376 | ||
372 | if (ddp->idx_last == ddp->nppods) | 377 | if (ddp->idx_last == ddp->nppods) |
373 | idx = ddp_find_unused_entries(ddp, 0, idx_max, npods, gl); | 378 | idx = ddp_find_unused_entries(ddp, 0, ddp->nppods, npods, gl); |
374 | else { | 379 | else { |
375 | idx = ddp_find_unused_entries(ddp, ddp->idx_last + 1, | 380 | idx = ddp_find_unused_entries(ddp, ddp->idx_last + 1, |
376 | idx_max, npods, gl); | 381 | ddp->nppods, npods, gl); |
377 | if (idx < 0 && ddp->idx_last >= npods) | 382 | if (idx < 0 && ddp->idx_last >= npods) { |
378 | idx = ddp_find_unused_entries(ddp, 0, | 383 | idx = ddp_find_unused_entries(ddp, 0, |
379 | ddp->idx_last - npods + 1, | 384 | min(ddp->idx_last + npods, ddp->nppods), |
380 | npods, gl); | 385 | npods, gl); |
386 | } | ||
381 | } | 387 | } |
382 | if (idx < 0) { | 388 | if (idx < 0) { |
383 | ddp_log_debug("xferlen %u, gl %u, npods %u NO DDP.\n", | 389 | ddp_log_debug("xferlen %u, gl %u, npods %u NO DDP.\n", |
diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c index fff8e4327644..9212400b9b13 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c +++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c | |||
@@ -876,13 +876,14 @@ static struct scsi_host_template cxgb3i_host_template = { | |||
876 | .proc_name = "cxgb3i", | 876 | .proc_name = "cxgb3i", |
877 | .queuecommand = iscsi_queuecommand, | 877 | .queuecommand = iscsi_queuecommand, |
878 | .change_queue_depth = iscsi_change_queue_depth, | 878 | .change_queue_depth = iscsi_change_queue_depth, |
879 | .can_queue = CXGB3I_SCSI_QDEPTH_DFLT - 1, | 879 | .can_queue = CXGB3I_SCSI_HOST_QDEPTH, |
880 | .sg_tablesize = SG_ALL, | 880 | .sg_tablesize = SG_ALL, |
881 | .max_sectors = 0xFFFF, | 881 | .max_sectors = 0xFFFF, |
882 | .cmd_per_lun = CXGB3I_SCSI_QDEPTH_DFLT, | 882 | .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, |
883 | .eh_abort_handler = iscsi_eh_abort, | 883 | .eh_abort_handler = iscsi_eh_abort, |
884 | .eh_device_reset_handler = iscsi_eh_device_reset, | 884 | .eh_device_reset_handler = iscsi_eh_device_reset, |
885 | .eh_target_reset_handler = iscsi_eh_target_reset, | 885 | .eh_target_reset_handler = iscsi_eh_target_reset, |
886 | .target_alloc = iscsi_target_alloc, | ||
886 | .use_clustering = DISABLE_CLUSTERING, | 887 | .use_clustering = DISABLE_CLUSTERING, |
887 | .this_id = -1, | 888 | .this_id = -1, |
888 | }; | 889 | }; |
diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c b/drivers/scsi/cxgb3i/cxgb3i_offload.c index 4d8654cdbdae..e11c9c180f39 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_offload.c +++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c | |||
@@ -1737,7 +1737,7 @@ int cxgb3i_c3cn_send_pdus(struct s3_conn *c3cn, struct sk_buff *skb) | |||
1737 | c3cn_tx_debug("c3cn 0x%p, snd %u - %u > %u.\n", | 1737 | c3cn_tx_debug("c3cn 0x%p, snd %u - %u > %u.\n", |
1738 | c3cn, c3cn->write_seq, c3cn->snd_una, | 1738 | c3cn, c3cn->write_seq, c3cn->snd_una, |
1739 | cxgb3_snd_win); | 1739 | cxgb3_snd_win); |
1740 | err = -EAGAIN; | 1740 | err = -ENOBUFS; |
1741 | goto out_err; | 1741 | goto out_err; |
1742 | } | 1742 | } |
1743 | 1743 | ||
@@ -1775,6 +1775,8 @@ done: | |||
1775 | out_err: | 1775 | out_err: |
1776 | if (copied == 0 && err == -EPIPE) | 1776 | if (copied == 0 && err == -EPIPE) |
1777 | copied = c3cn->err ? c3cn->err : -EPIPE; | 1777 | copied = c3cn->err ? c3cn->err : -EPIPE; |
1778 | else | ||
1779 | copied = err; | ||
1778 | goto done; | 1780 | goto done; |
1779 | } | 1781 | } |
1780 | 1782 | ||
diff --git a/drivers/scsi/cxgb3i/cxgb3i_pdu.c b/drivers/scsi/cxgb3i/cxgb3i_pdu.c index 7eebc9a7cb35..709105071177 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_pdu.c +++ b/drivers/scsi/cxgb3i/cxgb3i_pdu.c | |||
@@ -400,17 +400,18 @@ int cxgb3i_conn_xmit_pdu(struct iscsi_task *task) | |||
400 | return 0; | 400 | return 0; |
401 | } | 401 | } |
402 | 402 | ||
403 | if (err < 0 && err != -EAGAIN) { | 403 | if (err == -EAGAIN || err == -ENOBUFS) { |
404 | kfree_skb(skb); | 404 | /* reset skb to send when we are called again */ |
405 | cxgb3i_tx_debug("itt 0x%x, skb 0x%p, len %u/%u, xmit err %d.\n", | 405 | tdata->skb = skb; |
406 | task->itt, skb, skb->len, skb->data_len, err); | ||
407 | iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err); | ||
408 | iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED); | ||
409 | return err; | 406 | return err; |
410 | } | 407 | } |
411 | /* reset skb to send when we are called again */ | 408 | |
412 | tdata->skb = skb; | 409 | kfree_skb(skb); |
413 | return -EAGAIN; | 410 | cxgb3i_tx_debug("itt 0x%x, skb 0x%p, len %u/%u, xmit err %d.\n", |
411 | task->itt, skb, skb->len, skb->data_len, err); | ||
412 | iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err); | ||
413 | iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED); | ||
414 | return err; | ||
414 | } | 415 | } |
415 | 416 | ||
416 | int cxgb3i_pdu_init(void) | 417 | int cxgb3i_pdu_init(void) |
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 94e1e3189773..03e1926f40b5 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
@@ -57,7 +57,7 @@ DEFINE_RWLOCK(fcoe_hostlist_lock); | |||
57 | DEFINE_TIMER(fcoe_timer, NULL, 0, 0); | 57 | DEFINE_TIMER(fcoe_timer, NULL, 0, 0); |
58 | DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); | 58 | DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); |
59 | 59 | ||
60 | /* Function Prototyes */ | 60 | /* Function Prototypes */ |
61 | static int fcoe_reset(struct Scsi_Host *shost); | 61 | static int fcoe_reset(struct Scsi_Host *shost); |
62 | static int fcoe_xmit(struct fc_lport *, struct fc_frame *); | 62 | static int fcoe_xmit(struct fc_lport *, struct fc_frame *); |
63 | static int fcoe_rcv(struct sk_buff *, struct net_device *, | 63 | static int fcoe_rcv(struct sk_buff *, struct net_device *, |
@@ -138,7 +138,6 @@ static struct scsi_host_template fcoe_shost_template = { | |||
138 | /** | 138 | /** |
139 | * fcoe_lport_config() - sets up the fc_lport | 139 | * fcoe_lport_config() - sets up the fc_lport |
140 | * @lp: ptr to the fc_lport | 140 | * @lp: ptr to the fc_lport |
141 | * @shost: ptr to the parent scsi host | ||
142 | * | 141 | * |
143 | * Returns: 0 for success | 142 | * Returns: 0 for success |
144 | */ | 143 | */ |
@@ -256,6 +255,7 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) | |||
256 | rtnl_lock(); | 255 | rtnl_lock(); |
257 | memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); | 256 | memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); |
258 | dev_unicast_add(fc->real_dev, flogi_maddr, ETH_ALEN); | 257 | dev_unicast_add(fc->real_dev, flogi_maddr, ETH_ALEN); |
258 | dev_mc_add(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); | ||
259 | rtnl_unlock(); | 259 | rtnl_unlock(); |
260 | 260 | ||
261 | /* | 261 | /* |
@@ -380,7 +380,7 @@ static int fcoe_if_destroy(struct net_device *netdev) | |||
380 | dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); | 380 | dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); |
381 | rtnl_unlock(); | 381 | rtnl_unlock(); |
382 | 382 | ||
383 | /* Free the per-CPU revieve threads */ | 383 | /* Free the per-CPU receive threads */ |
384 | fcoe_percpu_clean(lp); | 384 | fcoe_percpu_clean(lp); |
385 | 385 | ||
386 | /* Free existing skbs */ | 386 | /* Free existing skbs */ |
@@ -720,7 +720,7 @@ static void fcoe_percpu_thread_destroy(unsigned int cpu) | |||
720 | } | 720 | } |
721 | #else | 721 | #else |
722 | /* | 722 | /* |
723 | * This a non-SMP scenario where the singluar Rx thread is | 723 | * This a non-SMP scenario where the singular Rx thread is |
724 | * being removed. Free all skbs and stop the thread. | 724 | * being removed. Free all skbs and stop the thread. |
725 | */ | 725 | */ |
726 | spin_lock_bh(&p->fcoe_rx_list.lock); | 726 | spin_lock_bh(&p->fcoe_rx_list.lock); |
@@ -777,7 +777,7 @@ static struct notifier_block fcoe_cpu_notifier = { | |||
777 | * @skb: the receive skb | 777 | * @skb: the receive skb |
778 | * @dev: associated net device | 778 | * @dev: associated net device |
779 | * @ptype: context | 779 | * @ptype: context |
780 | * @odldev: last device | 780 | * @olddev: last device |
781 | * | 781 | * |
782 | * this function will receive the packet and build fc frame and pass it up | 782 | * this function will receive the packet and build fc frame and pass it up |
783 | * | 783 | * |
@@ -884,7 +884,6 @@ err2: | |||
884 | kfree_skb(skb); | 884 | kfree_skb(skb); |
885 | return -1; | 885 | return -1; |
886 | } | 886 | } |
887 | EXPORT_SYMBOL_GPL(fcoe_rcv); | ||
888 | 887 | ||
889 | /** | 888 | /** |
890 | * fcoe_start_io() - pass to netdev to start xmit for fcoe | 889 | * fcoe_start_io() - pass to netdev to start xmit for fcoe |
@@ -905,7 +904,7 @@ static inline int fcoe_start_io(struct sk_buff *skb) | |||
905 | } | 904 | } |
906 | 905 | ||
907 | /** | 906 | /** |
908 | * fcoe_get_paged_crc_eof() - in case we need alloc a page for crc_eof | 907 | * fcoe_get_paged_crc_eof() - in case we need to alloc a page for crc_eof |
909 | * @skb: the skb to be xmitted | 908 | * @skb: the skb to be xmitted |
910 | * @tlen: total len | 909 | * @tlen: total len |
911 | * | 910 | * |
@@ -947,7 +946,7 @@ static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen) | |||
947 | 946 | ||
948 | /** | 947 | /** |
949 | * fcoe_fc_crc() - calculates FC CRC in this fcoe skb | 948 | * fcoe_fc_crc() - calculates FC CRC in this fcoe skb |
950 | * @fp: the fc_frame containg data to be checksummed | 949 | * @fp: the fc_frame containing data to be checksummed |
951 | * | 950 | * |
952 | * This uses crc32() to calculate the crc for fc frame | 951 | * This uses crc32() to calculate the crc for fc frame |
953 | * Return : 32 bit crc | 952 | * Return : 32 bit crc |
@@ -1011,7 +1010,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1011 | wlen = skb->len / FCOE_WORD_TO_BYTE; | 1010 | wlen = skb->len / FCOE_WORD_TO_BYTE; |
1012 | 1011 | ||
1013 | if (!lp->link_up) { | 1012 | if (!lp->link_up) { |
1014 | kfree(skb); | 1013 | kfree_skb(skb); |
1015 | return 0; | 1014 | return 0; |
1016 | } | 1015 | } |
1017 | 1016 | ||
@@ -1062,7 +1061,7 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1062 | cp = NULL; | 1061 | cp = NULL; |
1063 | } | 1062 | } |
1064 | 1063 | ||
1065 | /* adjust skb netowrk/transport offsets to match mac/fcoe/fc */ | 1064 | /* adjust skb network/transport offsets to match mac/fcoe/fc */ |
1066 | skb_push(skb, elen + hlen); | 1065 | skb_push(skb, elen + hlen); |
1067 | skb_reset_mac_header(skb); | 1066 | skb_reset_mac_header(skb); |
1068 | skb_reset_network_header(skb); | 1067 | skb_reset_network_header(skb); |
@@ -1123,7 +1122,6 @@ int fcoe_xmit(struct fc_lport *lp, struct fc_frame *fp) | |||
1123 | 1122 | ||
1124 | return 0; | 1123 | return 0; |
1125 | } | 1124 | } |
1126 | EXPORT_SYMBOL_GPL(fcoe_xmit); | ||
1127 | 1125 | ||
1128 | /** | 1126 | /** |
1129 | * fcoe_percpu_receive_thread() - recv thread per cpu | 1127 | * fcoe_percpu_receive_thread() - recv thread per cpu |
@@ -1296,17 +1294,16 @@ void fcoe_watchdog(ulong vp) | |||
1296 | 1294 | ||
1297 | 1295 | ||
1298 | /** | 1296 | /** |
1299 | * fcoe_check_wait_queue() - put the skb into fcoe pending xmit queue | 1297 | * fcoe_check_wait_queue() - attempt to clear the transmit backlog |
1300 | * @lp: the fc_port for this skb | 1298 | * @lp: the fc_lport |
1301 | * @skb: the associated skb to be xmitted | ||
1302 | * | 1299 | * |
1303 | * This empties the wait_queue, dequeue the head of the wait_queue queue | 1300 | * This empties the wait_queue, dequeue the head of the wait_queue queue |
1304 | * and calls fcoe_start_io() for each packet, if all skb have been | 1301 | * and calls fcoe_start_io() for each packet, if all skb have been |
1305 | * transmitted, return qlen or -1 if a error occurs, then restore | 1302 | * transmitted, return qlen or -1 if a error occurs, then restore |
1306 | * wait_queue and try again later. | 1303 | * wait_queue and try again later. |
1307 | * | 1304 | * |
1308 | * The wait_queue is used when the skb transmit fails. skb will go | 1305 | * The wait_queue is used when the skb transmit fails. skb will go |
1309 | * in the wait_queue which will be emptied by the time function OR | 1306 | * in the wait_queue which will be emptied by the timer function or |
1310 | * by the next skb transmit. | 1307 | * by the next skb transmit. |
1311 | * | 1308 | * |
1312 | * Returns: 0 for success | 1309 | * Returns: 0 for success |
@@ -1355,10 +1352,6 @@ out: | |||
1355 | */ | 1352 | */ |
1356 | static void fcoe_dev_setup() | 1353 | static void fcoe_dev_setup() |
1357 | { | 1354 | { |
1358 | /* | ||
1359 | * here setup a interface specific wd time to | ||
1360 | * monitor the link state | ||
1361 | */ | ||
1362 | register_netdevice_notifier(&fcoe_notifier); | 1355 | register_netdevice_notifier(&fcoe_notifier); |
1363 | } | 1356 | } |
1364 | 1357 | ||
@@ -1437,10 +1430,9 @@ out: | |||
1437 | 1430 | ||
1438 | /** | 1431 | /** |
1439 | * fcoe_if_to_netdev() - parse a name buffer to get netdev | 1432 | * fcoe_if_to_netdev() - parse a name buffer to get netdev |
1440 | * @ifname: fixed array for output parsed ifname | ||
1441 | * @buffer: incoming buffer to be copied | 1433 | * @buffer: incoming buffer to be copied |
1442 | * | 1434 | * |
1443 | * Returns: NULL or ptr to netdeive | 1435 | * Returns: NULL or ptr to net_device |
1444 | */ | 1436 | */ |
1445 | static struct net_device *fcoe_if_to_netdev(const char *buffer) | 1437 | static struct net_device *fcoe_if_to_netdev(const char *buffer) |
1446 | { | 1438 | { |
@@ -1458,7 +1450,7 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer) | |||
1458 | } | 1450 | } |
1459 | 1451 | ||
1460 | /** | 1452 | /** |
1461 | * fcoe_netdev_to_module_owner() - finds out the nic drive moddule of the netdev | 1453 | * fcoe_netdev_to_module_owner() - finds out the driver module of the netdev |
1462 | * @netdev: the target netdev | 1454 | * @netdev: the target netdev |
1463 | * | 1455 | * |
1464 | * Returns: ptr to the struct module, NULL for failure | 1456 | * Returns: ptr to the struct module, NULL for failure |
@@ -1488,7 +1480,7 @@ fcoe_netdev_to_module_owner(const struct net_device *netdev) | |||
1488 | * Holds the Ethernet driver module by try_module_get() for | 1480 | * Holds the Ethernet driver module by try_module_get() for |
1489 | * the corresponding netdev. | 1481 | * the corresponding netdev. |
1490 | * | 1482 | * |
1491 | * Returns: 0 for succsss | 1483 | * Returns: 0 for success |
1492 | */ | 1484 | */ |
1493 | static int fcoe_ethdrv_get(const struct net_device *netdev) | 1485 | static int fcoe_ethdrv_get(const struct net_device *netdev) |
1494 | { | 1486 | { |
@@ -1510,7 +1502,7 @@ static int fcoe_ethdrv_get(const struct net_device *netdev) | |||
1510 | * Releases the Ethernet driver module by module_put for | 1502 | * Releases the Ethernet driver module by module_put for |
1511 | * the corresponding netdev. | 1503 | * the corresponding netdev. |
1512 | * | 1504 | * |
1513 | * Returns: 0 for succsss | 1505 | * Returns: 0 for success |
1514 | */ | 1506 | */ |
1515 | static int fcoe_ethdrv_put(const struct net_device *netdev) | 1507 | static int fcoe_ethdrv_put(const struct net_device *netdev) |
1516 | { | 1508 | { |
@@ -1528,7 +1520,7 @@ static int fcoe_ethdrv_put(const struct net_device *netdev) | |||
1528 | 1520 | ||
1529 | /** | 1521 | /** |
1530 | * fcoe_destroy() - handles the destroy from sysfs | 1522 | * fcoe_destroy() - handles the destroy from sysfs |
1531 | * @buffer: expcted to be a eth if name | 1523 | * @buffer: expected to be an eth if name |
1532 | * @kp: associated kernel param | 1524 | * @kp: associated kernel param |
1533 | * | 1525 | * |
1534 | * Returns: 0 for success | 1526 | * Returns: 0 for success |
@@ -1565,7 +1557,7 @@ out_nodev: | |||
1565 | 1557 | ||
1566 | /** | 1558 | /** |
1567 | * fcoe_create() - Handles the create call from sysfs | 1559 | * fcoe_create() - Handles the create call from sysfs |
1568 | * @buffer: expcted to be a eth if name | 1560 | * @buffer: expected to be an eth if name |
1569 | * @kp: associated kernel param | 1561 | * @kp: associated kernel param |
1570 | * | 1562 | * |
1571 | * Returns: 0 for success | 1563 | * Returns: 0 for success |
@@ -1652,7 +1644,6 @@ int fcoe_link_ok(struct fc_lport *lp) | |||
1652 | 1644 | ||
1653 | return rc; | 1645 | return rc; |
1654 | } | 1646 | } |
1655 | EXPORT_SYMBOL_GPL(fcoe_link_ok); | ||
1656 | 1647 | ||
1657 | /** | 1648 | /** |
1658 | * fcoe_percpu_clean() - Clear the pending skbs for an lport | 1649 | * fcoe_percpu_clean() - Clear the pending skbs for an lport |
@@ -1684,7 +1675,6 @@ void fcoe_percpu_clean(struct fc_lport *lp) | |||
1684 | spin_unlock_bh(&pp->fcoe_rx_list.lock); | 1675 | spin_unlock_bh(&pp->fcoe_rx_list.lock); |
1685 | } | 1676 | } |
1686 | } | 1677 | } |
1687 | EXPORT_SYMBOL_GPL(fcoe_percpu_clean); | ||
1688 | 1678 | ||
1689 | /** | 1679 | /** |
1690 | * fcoe_clean_pending_queue() - Dequeue a skb and free it | 1680 | * fcoe_clean_pending_queue() - Dequeue a skb and free it |
@@ -1705,7 +1695,6 @@ void fcoe_clean_pending_queue(struct fc_lport *lp) | |||
1705 | } | 1695 | } |
1706 | spin_unlock_bh(&fc->fcoe_pending_queue.lock); | 1696 | spin_unlock_bh(&fc->fcoe_pending_queue.lock); |
1707 | } | 1697 | } |
1708 | EXPORT_SYMBOL_GPL(fcoe_clean_pending_queue); | ||
1709 | 1698 | ||
1710 | /** | 1699 | /** |
1711 | * fcoe_reset() - Resets the fcoe | 1700 | * fcoe_reset() - Resets the fcoe |
@@ -1719,11 +1708,10 @@ int fcoe_reset(struct Scsi_Host *shost) | |||
1719 | fc_lport_reset(lport); | 1708 | fc_lport_reset(lport); |
1720 | return 0; | 1709 | return 0; |
1721 | } | 1710 | } |
1722 | EXPORT_SYMBOL_GPL(fcoe_reset); | ||
1723 | 1711 | ||
1724 | /** | 1712 | /** |
1725 | * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device | 1713 | * fcoe_hostlist_lookup_softc() - find the corresponding lport by a given device |
1726 | * @device: this is currently ptr to net_device | 1714 | * @dev: this is currently ptr to net_device |
1727 | * | 1715 | * |
1728 | * Returns: NULL or the located fcoe_softc | 1716 | * Returns: NULL or the located fcoe_softc |
1729 | */ | 1717 | */ |
@@ -1757,11 +1745,10 @@ struct fc_lport *fcoe_hostlist_lookup(const struct net_device *netdev) | |||
1757 | 1745 | ||
1758 | return (fc) ? fc->ctlr.lp : NULL; | 1746 | return (fc) ? fc->ctlr.lp : NULL; |
1759 | } | 1747 | } |
1760 | EXPORT_SYMBOL_GPL(fcoe_hostlist_lookup); | ||
1761 | 1748 | ||
1762 | /** | 1749 | /** |
1763 | * fcoe_hostlist_add() - Add a lport to lports list | 1750 | * fcoe_hostlist_add() - Add a lport to lports list |
1764 | * @lp: ptr to the fc_lport to badded | 1751 | * @lp: ptr to the fc_lport to be added |
1765 | * | 1752 | * |
1766 | * Returns: 0 for success | 1753 | * Returns: 0 for success |
1767 | */ | 1754 | */ |
@@ -1778,11 +1765,10 @@ int fcoe_hostlist_add(const struct fc_lport *lp) | |||
1778 | } | 1765 | } |
1779 | return 0; | 1766 | return 0; |
1780 | } | 1767 | } |
1781 | EXPORT_SYMBOL_GPL(fcoe_hostlist_add); | ||
1782 | 1768 | ||
1783 | /** | 1769 | /** |
1784 | * fcoe_hostlist_remove() - remove a lport from lports list | 1770 | * fcoe_hostlist_remove() - remove a lport from lports list |
1785 | * @lp: ptr to the fc_lport to badded | 1771 | * @lp: ptr to the fc_lport to be removed |
1786 | * | 1772 | * |
1787 | * Returns: 0 for success | 1773 | * Returns: 0 for success |
1788 | */ | 1774 | */ |
@@ -1798,7 +1784,6 @@ int fcoe_hostlist_remove(const struct fc_lport *lp) | |||
1798 | 1784 | ||
1799 | return 0; | 1785 | return 0; |
1800 | } | 1786 | } |
1801 | EXPORT_SYMBOL_GPL(fcoe_hostlist_remove); | ||
1802 | 1787 | ||
1803 | /** | 1788 | /** |
1804 | * fcoe_init() - fcoe module loading initialization | 1789 | * fcoe_init() - fcoe module loading initialization |
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c index f410f4abb548..62ba0f39c6bd 100644 --- a/drivers/scsi/fcoe/libfcoe.c +++ b/drivers/scsi/fcoe/libfcoe.c | |||
@@ -122,7 +122,7 @@ static void fcoe_ctlr_reset_fcfs(struct fcoe_ctlr *fip) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * fcoe_ctrl_destroy() - Disable and tear-down the FCoE controller. | 125 | * fcoe_ctlr_destroy() - Disable and tear-down the FCoE controller. |
126 | * @fip: FCoE controller. | 126 | * @fip: FCoE controller. |
127 | * | 127 | * |
128 | * This is called by FCoE drivers before freeing the &fcoe_ctlr. | 128 | * This is called by FCoE drivers before freeing the &fcoe_ctlr. |
diff --git a/drivers/scsi/fnic/Makefile b/drivers/scsi/fnic/Makefile new file mode 100644 index 000000000000..37c3440bc17c --- /dev/null +++ b/drivers/scsi/fnic/Makefile | |||
@@ -0,0 +1,15 @@ | |||
1 | obj-$(CONFIG_FCOE_FNIC) += fnic.o | ||
2 | |||
3 | fnic-y := \ | ||
4 | fnic_attrs.o \ | ||
5 | fnic_isr.o \ | ||
6 | fnic_main.o \ | ||
7 | fnic_res.o \ | ||
8 | fnic_fcs.o \ | ||
9 | fnic_scsi.o \ | ||
10 | vnic_cq.o \ | ||
11 | vnic_dev.o \ | ||
12 | vnic_intr.o \ | ||
13 | vnic_rq.o \ | ||
14 | vnic_wq_copy.o \ | ||
15 | vnic_wq.o | ||
diff --git a/drivers/scsi/fnic/cq_desc.h b/drivers/scsi/fnic/cq_desc.h new file mode 100644 index 000000000000..d1225cf6320e --- /dev/null +++ b/drivers/scsi/fnic/cq_desc.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _CQ_DESC_H_ | ||
19 | #define _CQ_DESC_H_ | ||
20 | |||
21 | /* | ||
22 | * Completion queue descriptor types | ||
23 | */ | ||
24 | enum cq_desc_types { | ||
25 | CQ_DESC_TYPE_WQ_ENET = 0, | ||
26 | CQ_DESC_TYPE_DESC_COPY = 1, | ||
27 | CQ_DESC_TYPE_WQ_EXCH = 2, | ||
28 | CQ_DESC_TYPE_RQ_ENET = 3, | ||
29 | CQ_DESC_TYPE_RQ_FCP = 4, | ||
30 | }; | ||
31 | |||
32 | /* Completion queue descriptor: 16B | ||
33 | * | ||
34 | * All completion queues have this basic layout. The | ||
35 | * type_specfic area is unique for each completion | ||
36 | * queue type. | ||
37 | */ | ||
38 | struct cq_desc { | ||
39 | __le16 completed_index; | ||
40 | __le16 q_number; | ||
41 | u8 type_specfic[11]; | ||
42 | u8 type_color; | ||
43 | }; | ||
44 | |||
45 | #define CQ_DESC_TYPE_BITS 4 | ||
46 | #define CQ_DESC_TYPE_MASK ((1 << CQ_DESC_TYPE_BITS) - 1) | ||
47 | #define CQ_DESC_COLOR_MASK 1 | ||
48 | #define CQ_DESC_COLOR_SHIFT 7 | ||
49 | #define CQ_DESC_Q_NUM_BITS 10 | ||
50 | #define CQ_DESC_Q_NUM_MASK ((1 << CQ_DESC_Q_NUM_BITS) - 1) | ||
51 | #define CQ_DESC_COMP_NDX_BITS 12 | ||
52 | #define CQ_DESC_COMP_NDX_MASK ((1 << CQ_DESC_COMP_NDX_BITS) - 1) | ||
53 | |||
54 | static inline void cq_desc_dec(const struct cq_desc *desc_arg, | ||
55 | u8 *type, u8 *color, u16 *q_number, u16 *completed_index) | ||
56 | { | ||
57 | const struct cq_desc *desc = desc_arg; | ||
58 | const u8 type_color = desc->type_color; | ||
59 | |||
60 | *color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK; | ||
61 | |||
62 | /* | ||
63 | * Make sure color bit is read from desc *before* other fields | ||
64 | * are read from desc. Hardware guarantees color bit is last | ||
65 | * bit (byte) written. Adding the rmb() prevents the compiler | ||
66 | * and/or CPU from reordering the reads which would potentially | ||
67 | * result in reading stale values. | ||
68 | */ | ||
69 | |||
70 | rmb(); | ||
71 | |||
72 | *type = type_color & CQ_DESC_TYPE_MASK; | ||
73 | *q_number = le16_to_cpu(desc->q_number) & CQ_DESC_Q_NUM_MASK; | ||
74 | *completed_index = le16_to_cpu(desc->completed_index) & | ||
75 | CQ_DESC_COMP_NDX_MASK; | ||
76 | } | ||
77 | |||
78 | #endif /* _CQ_DESC_H_ */ | ||
diff --git a/drivers/scsi/fnic/cq_enet_desc.h b/drivers/scsi/fnic/cq_enet_desc.h new file mode 100644 index 000000000000..a9fa26f82ddd --- /dev/null +++ b/drivers/scsi/fnic/cq_enet_desc.h | |||
@@ -0,0 +1,167 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _CQ_ENET_DESC_H_ | ||
19 | #define _CQ_ENET_DESC_H_ | ||
20 | |||
21 | #include "cq_desc.h" | ||
22 | |||
23 | /* Ethernet completion queue descriptor: 16B */ | ||
24 | struct cq_enet_wq_desc { | ||
25 | __le16 completed_index; | ||
26 | __le16 q_number; | ||
27 | u8 reserved[11]; | ||
28 | u8 type_color; | ||
29 | }; | ||
30 | |||
31 | static inline void cq_enet_wq_desc_dec(struct cq_enet_wq_desc *desc, | ||
32 | u8 *type, u8 *color, u16 *q_number, u16 *completed_index) | ||
33 | { | ||
34 | cq_desc_dec((struct cq_desc *)desc, type, | ||
35 | color, q_number, completed_index); | ||
36 | } | ||
37 | |||
38 | /* Completion queue descriptor: Ethernet receive queue, 16B */ | ||
39 | struct cq_enet_rq_desc { | ||
40 | __le16 completed_index_flags; | ||
41 | __le16 q_number_rss_type_flags; | ||
42 | __le32 rss_hash; | ||
43 | __le16 bytes_written_flags; | ||
44 | __le16 vlan; | ||
45 | __le16 checksum_fcoe; | ||
46 | u8 flags; | ||
47 | u8 type_color; | ||
48 | }; | ||
49 | |||
50 | #define CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT (0x1 << 12) | ||
51 | #define CQ_ENET_RQ_DESC_FLAGS_FCOE (0x1 << 13) | ||
52 | #define CQ_ENET_RQ_DESC_FLAGS_EOP (0x1 << 14) | ||
53 | #define CQ_ENET_RQ_DESC_FLAGS_SOP (0x1 << 15) | ||
54 | |||
55 | #define CQ_ENET_RQ_DESC_RSS_TYPE_BITS 4 | ||
56 | #define CQ_ENET_RQ_DESC_RSS_TYPE_MASK \ | ||
57 | ((1 << CQ_ENET_RQ_DESC_RSS_TYPE_BITS) - 1) | ||
58 | #define CQ_ENET_RQ_DESC_RSS_TYPE_NONE 0 | ||
59 | #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv4 1 | ||
60 | #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv4 2 | ||
61 | #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6 3 | ||
62 | #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6 4 | ||
63 | #define CQ_ENET_RQ_DESC_RSS_TYPE_IPv6_EX 5 | ||
64 | #define CQ_ENET_RQ_DESC_RSS_TYPE_TCP_IPv6_EX 6 | ||
65 | |||
66 | #define CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC (0x1 << 14) | ||
67 | |||
68 | #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS 14 | ||
69 | #define CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK \ | ||
70 | ((1 << CQ_ENET_RQ_DESC_BYTES_WRITTEN_BITS) - 1) | ||
71 | #define CQ_ENET_RQ_DESC_FLAGS_TRUNCATED (0x1 << 14) | ||
72 | #define CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED (0x1 << 15) | ||
73 | |||
74 | #define CQ_ENET_RQ_DESC_FCOE_SOF_BITS 4 | ||
75 | #define CQ_ENET_RQ_DESC_FCOE_SOF_MASK \ | ||
76 | ((1 << CQ_ENET_RQ_DESC_FCOE_SOF_BITS) - 1) | ||
77 | #define CQ_ENET_RQ_DESC_FCOE_EOF_BITS 8 | ||
78 | #define CQ_ENET_RQ_DESC_FCOE_EOF_MASK \ | ||
79 | ((1 << CQ_ENET_RQ_DESC_FCOE_EOF_BITS) - 1) | ||
80 | #define CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT 8 | ||
81 | |||
82 | #define CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK (0x1 << 0) | ||
83 | #define CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK (0x1 << 0) | ||
84 | #define CQ_ENET_RQ_DESC_FLAGS_UDP (0x1 << 1) | ||
85 | #define CQ_ENET_RQ_DESC_FCOE_ENC_ERROR (0x1 << 1) | ||
86 | #define CQ_ENET_RQ_DESC_FLAGS_TCP (0x1 << 2) | ||
87 | #define CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK (0x1 << 3) | ||
88 | #define CQ_ENET_RQ_DESC_FLAGS_IPV6 (0x1 << 4) | ||
89 | #define CQ_ENET_RQ_DESC_FLAGS_IPV4 (0x1 << 5) | ||
90 | #define CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT (0x1 << 6) | ||
91 | #define CQ_ENET_RQ_DESC_FLAGS_FCS_OK (0x1 << 7) | ||
92 | |||
93 | static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc, | ||
94 | u8 *type, u8 *color, u16 *q_number, u16 *completed_index, | ||
95 | u8 *ingress_port, u8 *fcoe, u8 *eop, u8 *sop, u8 *rss_type, | ||
96 | u8 *csum_not_calc, u32 *rss_hash, u16 *bytes_written, u8 *packet_error, | ||
97 | u8 *vlan_stripped, u16 *vlan, u16 *checksum, u8 *fcoe_sof, | ||
98 | u8 *fcoe_fc_crc_ok, u8 *fcoe_enc_error, u8 *fcoe_eof, | ||
99 | u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok, | ||
100 | u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok) | ||
101 | { | ||
102 | u16 completed_index_flags = le16_to_cpu(desc->completed_index_flags); | ||
103 | u16 q_number_rss_type_flags = | ||
104 | le16_to_cpu(desc->q_number_rss_type_flags); | ||
105 | u16 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags); | ||
106 | |||
107 | cq_desc_dec((struct cq_desc *)desc, type, | ||
108 | color, q_number, completed_index); | ||
109 | |||
110 | *ingress_port = (completed_index_flags & | ||
111 | CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0; | ||
112 | *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ? | ||
113 | 1 : 0; | ||
114 | *eop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_EOP) ? | ||
115 | 1 : 0; | ||
116 | *sop = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_SOP) ? | ||
117 | 1 : 0; | ||
118 | |||
119 | *rss_type = (u8)((q_number_rss_type_flags >> CQ_DESC_Q_NUM_BITS) & | ||
120 | CQ_ENET_RQ_DESC_RSS_TYPE_MASK); | ||
121 | *csum_not_calc = (q_number_rss_type_flags & | ||
122 | CQ_ENET_RQ_DESC_FLAGS_CSUM_NOT_CALC) ? 1 : 0; | ||
123 | |||
124 | *rss_hash = le32_to_cpu(desc->rss_hash); | ||
125 | |||
126 | *bytes_written = bytes_written_flags & | ||
127 | CQ_ENET_RQ_DESC_BYTES_WRITTEN_MASK; | ||
128 | *packet_error = (bytes_written_flags & | ||
129 | CQ_ENET_RQ_DESC_FLAGS_TRUNCATED) ? 1 : 0; | ||
130 | *vlan_stripped = (bytes_written_flags & | ||
131 | CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) ? 1 : 0; | ||
132 | |||
133 | *vlan = le16_to_cpu(desc->vlan); | ||
134 | |||
135 | if (*fcoe) { | ||
136 | *fcoe_sof = (u8)(le16_to_cpu(desc->checksum_fcoe) & | ||
137 | CQ_ENET_RQ_DESC_FCOE_SOF_MASK); | ||
138 | *fcoe_fc_crc_ok = (desc->flags & | ||
139 | CQ_ENET_RQ_DESC_FCOE_FC_CRC_OK) ? 1 : 0; | ||
140 | *fcoe_enc_error = (desc->flags & | ||
141 | CQ_ENET_RQ_DESC_FCOE_ENC_ERROR) ? 1 : 0; | ||
142 | *fcoe_eof = (u8)((desc->checksum_fcoe >> | ||
143 | CQ_ENET_RQ_DESC_FCOE_EOF_SHIFT) & | ||
144 | CQ_ENET_RQ_DESC_FCOE_EOF_MASK); | ||
145 | *checksum = 0; | ||
146 | } else { | ||
147 | *fcoe_sof = 0; | ||
148 | *fcoe_fc_crc_ok = 0; | ||
149 | *fcoe_enc_error = 0; | ||
150 | *fcoe_eof = 0; | ||
151 | *checksum = le16_to_cpu(desc->checksum_fcoe); | ||
152 | } | ||
153 | |||
154 | *tcp_udp_csum_ok = | ||
155 | (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP_UDP_CSUM_OK) ? 1 : 0; | ||
156 | *udp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_UDP) ? 1 : 0; | ||
157 | *tcp = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_TCP) ? 1 : 0; | ||
158 | *ipv4_csum_ok = | ||
159 | (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_CSUM_OK) ? 1 : 0; | ||
160 | *ipv6 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV6) ? 1 : 0; | ||
161 | *ipv4 = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4) ? 1 : 0; | ||
162 | *ipv4_fragment = | ||
163 | (desc->flags & CQ_ENET_RQ_DESC_FLAGS_IPV4_FRAGMENT) ? 1 : 0; | ||
164 | *fcs_ok = (desc->flags & CQ_ENET_RQ_DESC_FLAGS_FCS_OK) ? 1 : 0; | ||
165 | } | ||
166 | |||
167 | #endif /* _CQ_ENET_DESC_H_ */ | ||
diff --git a/drivers/scsi/fnic/cq_exch_desc.h b/drivers/scsi/fnic/cq_exch_desc.h new file mode 100644 index 000000000000..501660cfe228 --- /dev/null +++ b/drivers/scsi/fnic/cq_exch_desc.h | |||
@@ -0,0 +1,182 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _CQ_EXCH_DESC_H_ | ||
19 | #define _CQ_EXCH_DESC_H_ | ||
20 | |||
21 | #include "cq_desc.h" | ||
22 | |||
23 | /* Exchange completion queue descriptor: 16B */ | ||
24 | struct cq_exch_wq_desc { | ||
25 | u16 completed_index; | ||
26 | u16 q_number; | ||
27 | u16 exchange_id; | ||
28 | u8 tmpl; | ||
29 | u8 reserved0; | ||
30 | u32 reserved1; | ||
31 | u8 exch_status; | ||
32 | u8 reserved2[2]; | ||
33 | u8 type_color; | ||
34 | }; | ||
35 | |||
36 | #define CQ_EXCH_WQ_STATUS_BITS 2 | ||
37 | #define CQ_EXCH_WQ_STATUS_MASK ((1 << CQ_EXCH_WQ_STATUS_BITS) - 1) | ||
38 | |||
39 | enum cq_exch_status_types { | ||
40 | CQ_EXCH_WQ_STATUS_TYPE_COMPLETE = 0, | ||
41 | CQ_EXCH_WQ_STATUS_TYPE_ABORT = 1, | ||
42 | CQ_EXCH_WQ_STATUS_TYPE_SGL_EOF = 2, | ||
43 | CQ_EXCH_WQ_STATUS_TYPE_TMPL_ERR = 3, | ||
44 | }; | ||
45 | |||
46 | static inline void cq_exch_wq_desc_dec(struct cq_exch_wq_desc *desc_ptr, | ||
47 | u8 *type, | ||
48 | u8 *color, | ||
49 | u16 *q_number, | ||
50 | u16 *completed_index, | ||
51 | u8 *exch_status) | ||
52 | { | ||
53 | cq_desc_dec((struct cq_desc *)desc_ptr, type, | ||
54 | color, q_number, completed_index); | ||
55 | *exch_status = desc_ptr->exch_status & CQ_EXCH_WQ_STATUS_MASK; | ||
56 | } | ||
57 | |||
58 | struct cq_fcp_rq_desc { | ||
59 | u16 completed_index_eop_sop_prt; | ||
60 | u16 q_number; | ||
61 | u16 exchange_id; | ||
62 | u16 tmpl; | ||
63 | u16 bytes_written; | ||
64 | u16 vlan; | ||
65 | u8 sof; | ||
66 | u8 eof; | ||
67 | u8 fcs_fer_fck; | ||
68 | u8 type_color; | ||
69 | }; | ||
70 | |||
71 | #define CQ_FCP_RQ_DESC_FLAGS_SOP (1 << 15) | ||
72 | #define CQ_FCP_RQ_DESC_FLAGS_EOP (1 << 14) | ||
73 | #define CQ_FCP_RQ_DESC_FLAGS_PRT (1 << 12) | ||
74 | #define CQ_FCP_RQ_DESC_TMPL_MASK 0x1f | ||
75 | #define CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK 0x3fff | ||
76 | #define CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT 14 | ||
77 | #define CQ_FCP_RQ_DESC_PACKET_ERR_MASK (1 << CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT) | ||
78 | #define CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT 15 | ||
79 | #define CQ_FCP_RQ_DESC_VS_STRIPPED_MASK (1 << CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT) | ||
80 | #define CQ_FCP_RQ_DESC_FC_CRC_OK_MASK 0x1 | ||
81 | #define CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT 1 | ||
82 | #define CQ_FCP_RQ_DESC_FCOE_ERR_MASK (1 << CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT) | ||
83 | #define CQ_FCP_RQ_DESC_FCS_OK_SHIFT 7 | ||
84 | #define CQ_FCP_RQ_DESC_FCS_OK_MASK (1 << CQ_FCP_RQ_DESC_FCS_OK_SHIFT) | ||
85 | |||
86 | static inline void cq_fcp_rq_desc_dec(struct cq_fcp_rq_desc *desc_ptr, | ||
87 | u8 *type, | ||
88 | u8 *color, | ||
89 | u16 *q_number, | ||
90 | u16 *completed_index, | ||
91 | u8 *eop, | ||
92 | u8 *sop, | ||
93 | u8 *fck, | ||
94 | u16 *exchange_id, | ||
95 | u16 *tmpl, | ||
96 | u32 *bytes_written, | ||
97 | u8 *sof, | ||
98 | u8 *eof, | ||
99 | u8 *ingress_port, | ||
100 | u8 *packet_err, | ||
101 | u8 *fcoe_err, | ||
102 | u8 *fcs_ok, | ||
103 | u8 *vlan_stripped, | ||
104 | u16 *vlan) | ||
105 | { | ||
106 | cq_desc_dec((struct cq_desc *)desc_ptr, type, | ||
107 | color, q_number, completed_index); | ||
108 | *eop = (desc_ptr->completed_index_eop_sop_prt & | ||
109 | CQ_FCP_RQ_DESC_FLAGS_EOP) ? 1 : 0; | ||
110 | *sop = (desc_ptr->completed_index_eop_sop_prt & | ||
111 | CQ_FCP_RQ_DESC_FLAGS_SOP) ? 1 : 0; | ||
112 | *ingress_port = | ||
113 | (desc_ptr->completed_index_eop_sop_prt & | ||
114 | CQ_FCP_RQ_DESC_FLAGS_PRT) ? 1 : 0; | ||
115 | *exchange_id = desc_ptr->exchange_id; | ||
116 | *tmpl = desc_ptr->tmpl & CQ_FCP_RQ_DESC_TMPL_MASK; | ||
117 | *bytes_written = | ||
118 | desc_ptr->bytes_written & CQ_FCP_RQ_DESC_BYTES_WRITTEN_MASK; | ||
119 | *packet_err = | ||
120 | (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_PACKET_ERR_MASK) >> | ||
121 | CQ_FCP_RQ_DESC_PACKET_ERR_SHIFT; | ||
122 | *vlan_stripped = | ||
123 | (desc_ptr->bytes_written & CQ_FCP_RQ_DESC_VS_STRIPPED_MASK) >> | ||
124 | CQ_FCP_RQ_DESC_VS_STRIPPED_SHIFT; | ||
125 | *vlan = desc_ptr->vlan; | ||
126 | *sof = desc_ptr->sof; | ||
127 | *fck = desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FC_CRC_OK_MASK; | ||
128 | *fcoe_err = (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCOE_ERR_MASK) >> | ||
129 | CQ_FCP_RQ_DESC_FCOE_ERR_SHIFT; | ||
130 | *eof = desc_ptr->eof; | ||
131 | *fcs_ok = | ||
132 | (desc_ptr->fcs_fer_fck & CQ_FCP_RQ_DESC_FCS_OK_MASK) >> | ||
133 | CQ_FCP_RQ_DESC_FCS_OK_SHIFT; | ||
134 | } | ||
135 | |||
136 | struct cq_sgl_desc { | ||
137 | u16 exchange_id; | ||
138 | u16 q_number; | ||
139 | u32 active_burst_offset; | ||
140 | u32 tot_data_bytes; | ||
141 | u16 tmpl; | ||
142 | u8 sgl_err; | ||
143 | u8 type_color; | ||
144 | }; | ||
145 | |||
146 | enum cq_sgl_err_types { | ||
147 | CQ_SGL_ERR_NO_ERROR = 0, | ||
148 | CQ_SGL_ERR_OVERFLOW, /* data ran beyond end of SGL */ | ||
149 | CQ_SGL_ERR_SGL_LCL_ADDR_ERR, /* sgl access to local vnic addr illegal*/ | ||
150 | CQ_SGL_ERR_ADDR_RSP_ERR, /* sgl address error */ | ||
151 | CQ_SGL_ERR_DATA_RSP_ERR, /* sgl data rsp error */ | ||
152 | CQ_SGL_ERR_CNT_ZERO_ERR, /* SGL count is 0 */ | ||
153 | CQ_SGL_ERR_CNT_MAX_ERR, /* SGL count is larger than supported */ | ||
154 | CQ_SGL_ERR_ORDER_ERR, /* frames recv on both ports, order err */ | ||
155 | CQ_SGL_ERR_DATA_LCL_ADDR_ERR,/* sgl data buf to local vnic addr ill */ | ||
156 | CQ_SGL_ERR_HOST_CQ_ERR, /* host cq entry to local vnic addr ill */ | ||
157 | }; | ||
158 | |||
159 | #define CQ_SGL_SGL_ERR_MASK 0x1f | ||
160 | #define CQ_SGL_TMPL_MASK 0x1f | ||
161 | |||
162 | static inline void cq_sgl_desc_dec(struct cq_sgl_desc *desc_ptr, | ||
163 | u8 *type, | ||
164 | u8 *color, | ||
165 | u16 *q_number, | ||
166 | u16 *exchange_id, | ||
167 | u32 *active_burst_offset, | ||
168 | u32 *tot_data_bytes, | ||
169 | u16 *tmpl, | ||
170 | u8 *sgl_err) | ||
171 | { | ||
172 | /* Cheat a little by assuming exchange_id is the same as completed | ||
173 | index */ | ||
174 | cq_desc_dec((struct cq_desc *)desc_ptr, type, color, q_number, | ||
175 | exchange_id); | ||
176 | *active_burst_offset = desc_ptr->active_burst_offset; | ||
177 | *tot_data_bytes = desc_ptr->tot_data_bytes; | ||
178 | *tmpl = desc_ptr->tmpl & CQ_SGL_TMPL_MASK; | ||
179 | *sgl_err = desc_ptr->sgl_err & CQ_SGL_SGL_ERR_MASK; | ||
180 | } | ||
181 | |||
182 | #endif /* _CQ_EXCH_DESC_H_ */ | ||
diff --git a/drivers/scsi/fnic/fcpio.h b/drivers/scsi/fnic/fcpio.h new file mode 100644 index 000000000000..12d770d885c5 --- /dev/null +++ b/drivers/scsi/fnic/fcpio.h | |||
@@ -0,0 +1,780 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _FCPIO_H_ | ||
19 | #define _FCPIO_H_ | ||
20 | |||
21 | #include <linux/if_ether.h> | ||
22 | |||
23 | /* | ||
24 | * This header file includes all of the data structures used for | ||
25 | * communication by the host driver to the fcp firmware. | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | * Exchange and sequence id space allocated to the host driver | ||
30 | */ | ||
31 | #define FCPIO_HOST_EXCH_RANGE_START 0x1000 | ||
32 | #define FCPIO_HOST_EXCH_RANGE_END 0x1fff | ||
33 | #define FCPIO_HOST_SEQ_ID_RANGE_START 0x80 | ||
34 | #define FCPIO_HOST_SEQ_ID_RANGE_END 0xff | ||
35 | |||
36 | /* | ||
37 | * Command entry type | ||
38 | */ | ||
39 | enum fcpio_type { | ||
40 | /* | ||
41 | * Initiator request types | ||
42 | */ | ||
43 | FCPIO_ICMND_16 = 0x1, | ||
44 | FCPIO_ICMND_32, | ||
45 | FCPIO_ICMND_CMPL, | ||
46 | FCPIO_ITMF, | ||
47 | FCPIO_ITMF_CMPL, | ||
48 | |||
49 | /* | ||
50 | * Target request types | ||
51 | */ | ||
52 | FCPIO_TCMND_16 = 0x11, | ||
53 | FCPIO_TCMND_32, | ||
54 | FCPIO_TDATA, | ||
55 | FCPIO_TXRDY, | ||
56 | FCPIO_TRSP, | ||
57 | FCPIO_TDRSP_CMPL, | ||
58 | FCPIO_TTMF, | ||
59 | FCPIO_TTMF_ACK, | ||
60 | FCPIO_TABORT, | ||
61 | FCPIO_TABORT_CMPL, | ||
62 | |||
63 | /* | ||
64 | * Misc request types | ||
65 | */ | ||
66 | FCPIO_ACK = 0x20, | ||
67 | FCPIO_RESET, | ||
68 | FCPIO_RESET_CMPL, | ||
69 | FCPIO_FLOGI_REG, | ||
70 | FCPIO_FLOGI_REG_CMPL, | ||
71 | FCPIO_ECHO, | ||
72 | FCPIO_ECHO_CMPL, | ||
73 | FCPIO_LUNMAP_CHNG, | ||
74 | FCPIO_LUNMAP_REQ, | ||
75 | FCPIO_LUNMAP_REQ_CMPL, | ||
76 | FCPIO_FLOGI_FIP_REG, | ||
77 | FCPIO_FLOGI_FIP_REG_CMPL, | ||
78 | }; | ||
79 | |||
80 | /* | ||
81 | * Header status codes from the firmware | ||
82 | */ | ||
83 | enum fcpio_status { | ||
84 | FCPIO_SUCCESS = 0, /* request was successful */ | ||
85 | |||
86 | /* | ||
87 | * If a request to the firmware is rejected, the original request | ||
88 | * header will be returned with the status set to one of the following: | ||
89 | */ | ||
90 | FCPIO_INVALID_HEADER, /* header contains invalid data */ | ||
91 | FCPIO_OUT_OF_RESOURCE, /* out of resources to complete request */ | ||
92 | FCPIO_INVALID_PARAM, /* some parameter in request is invalid */ | ||
93 | FCPIO_REQ_NOT_SUPPORTED, /* request type is not supported */ | ||
94 | FCPIO_IO_NOT_FOUND, /* requested I/O was not found */ | ||
95 | |||
96 | /* | ||
97 | * Once a request is processed, the firmware will usually return | ||
98 | * a cmpl message type. In cases where errors occurred, | ||
99 | * the header status field would be filled in with one of the following: | ||
100 | */ | ||
101 | FCPIO_ABORTED = 0x41, /* request was aborted */ | ||
102 | FCPIO_TIMEOUT, /* request was timed out */ | ||
103 | FCPIO_SGL_INVALID, /* request was aborted due to sgl error */ | ||
104 | FCPIO_MSS_INVALID, /* request was aborted due to mss error */ | ||
105 | FCPIO_DATA_CNT_MISMATCH, /* recv/sent more/less data than exp. */ | ||
106 | FCPIO_FW_ERR, /* request was terminated due to fw error */ | ||
107 | FCPIO_ITMF_REJECTED, /* itmf req was rejected by remote node */ | ||
108 | FCPIO_ITMF_FAILED, /* itmf req was failed by remote node */ | ||
109 | FCPIO_ITMF_INCORRECT_LUN, /* itmf req targeted incorrect LUN */ | ||
110 | FCPIO_CMND_REJECTED, /* request was invalid and rejected */ | ||
111 | FCPIO_NO_PATH_AVAIL, /* no paths to the lun was available */ | ||
112 | FCPIO_PATH_FAILED, /* i/o sent to current path failed */ | ||
113 | FCPIO_LUNMAP_CHNG_PEND, /* i/o rejected due to lunmap change */ | ||
114 | }; | ||
115 | |||
116 | /* | ||
117 | * The header command tag. All host requests will use the "tag" field | ||
118 | * to mark commands with a unique tag. When the firmware responds to | ||
119 | * a host request, it will copy the tag field into the response. | ||
120 | * | ||
121 | * The only firmware requests that will use the rx_id/ox_id fields instead | ||
122 | * of the tag field will be the target command and target task management | ||
123 | * requests. These two requests do not have corresponding host requests | ||
124 | * since they come directly from the FC initiator on the network. | ||
125 | */ | ||
126 | struct fcpio_tag { | ||
127 | union { | ||
128 | u32 req_id; | ||
129 | struct { | ||
130 | u16 rx_id; | ||
131 | u16 ox_id; | ||
132 | } ex_id; | ||
133 | } u; | ||
134 | }; | ||
135 | |||
136 | static inline void | ||
137 | fcpio_tag_id_enc(struct fcpio_tag *tag, u32 id) | ||
138 | { | ||
139 | tag->u.req_id = id; | ||
140 | } | ||
141 | |||
142 | static inline void | ||
143 | fcpio_tag_id_dec(struct fcpio_tag *tag, u32 *id) | ||
144 | { | ||
145 | *id = tag->u.req_id; | ||
146 | } | ||
147 | |||
148 | static inline void | ||
149 | fcpio_tag_exid_enc(struct fcpio_tag *tag, u16 ox_id, u16 rx_id) | ||
150 | { | ||
151 | tag->u.ex_id.rx_id = rx_id; | ||
152 | tag->u.ex_id.ox_id = ox_id; | ||
153 | } | ||
154 | |||
155 | static inline void | ||
156 | fcpio_tag_exid_dec(struct fcpio_tag *tag, u16 *ox_id, u16 *rx_id) | ||
157 | { | ||
158 | *rx_id = tag->u.ex_id.rx_id; | ||
159 | *ox_id = tag->u.ex_id.ox_id; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * The header for an fcpio request, whether from the firmware or from the | ||
164 | * host driver | ||
165 | */ | ||
166 | struct fcpio_header { | ||
167 | u8 type; /* enum fcpio_type */ | ||
168 | u8 status; /* header status entry */ | ||
169 | u16 _resvd; /* reserved */ | ||
170 | struct fcpio_tag tag; /* header tag */ | ||
171 | }; | ||
172 | |||
173 | static inline void | ||
174 | fcpio_header_enc(struct fcpio_header *hdr, | ||
175 | u8 type, u8 status, | ||
176 | struct fcpio_tag tag) | ||
177 | { | ||
178 | hdr->type = type; | ||
179 | hdr->status = status; | ||
180 | hdr->_resvd = 0; | ||
181 | hdr->tag = tag; | ||
182 | } | ||
183 | |||
184 | static inline void | ||
185 | fcpio_header_dec(struct fcpio_header *hdr, | ||
186 | u8 *type, u8 *status, | ||
187 | struct fcpio_tag *tag) | ||
188 | { | ||
189 | *type = hdr->type; | ||
190 | *status = hdr->status; | ||
191 | *tag = hdr->tag; | ||
192 | } | ||
193 | |||
194 | #define CDB_16 16 | ||
195 | #define CDB_32 32 | ||
196 | #define LUN_ADDRESS 8 | ||
197 | |||
198 | /* | ||
199 | * fcpio_icmnd_16: host -> firmware request | ||
200 | * | ||
201 | * used for sending out an initiator SCSI 16-byte command | ||
202 | */ | ||
203 | struct fcpio_icmnd_16 { | ||
204 | u32 lunmap_id; /* index into lunmap table */ | ||
205 | u8 special_req_flags; /* special exchange request flags */ | ||
206 | u8 _resvd0[3]; /* reserved */ | ||
207 | u32 sgl_cnt; /* scatter-gather list count */ | ||
208 | u32 sense_len; /* sense buffer length */ | ||
209 | u64 sgl_addr; /* scatter-gather list addr */ | ||
210 | u64 sense_addr; /* sense buffer address */ | ||
211 | u8 crn; /* SCSI Command Reference No. */ | ||
212 | u8 pri_ta; /* SCSI Priority and Task attribute */ | ||
213 | u8 _resvd1; /* reserved: should be 0 */ | ||
214 | u8 flags; /* command flags */ | ||
215 | u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */ | ||
216 | u32 data_len; /* length of data expected */ | ||
217 | u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ | ||
218 | u8 _resvd2; /* reserved */ | ||
219 | u8 d_id[3]; /* FC vNIC only: Target D_ID */ | ||
220 | u16 mss; /* FC vNIC only: max burst */ | ||
221 | u16 _resvd3; /* reserved */ | ||
222 | u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */ | ||
223 | u32 e_d_tov; /* FC vNIC only: Err Detect Timeout */ | ||
224 | }; | ||
225 | |||
226 | /* | ||
227 | * Special request flags | ||
228 | */ | ||
229 | #define FCPIO_ICMND_SRFLAG_RETRY 0x01 /* Enable Retry handling on exchange */ | ||
230 | |||
231 | /* | ||
232 | * Priority/Task Attribute settings | ||
233 | */ | ||
234 | #define FCPIO_ICMND_PTA_SIMPLE 0 /* simple task attribute */ | ||
235 | #define FCPIO_ICMND_PTA_HEADQ 1 /* head of queue task attribute */ | ||
236 | #define FCPIO_ICMND_PTA_ORDERED 2 /* ordered task attribute */ | ||
237 | #define FCPIO_ICMND_PTA_ACA 4 /* auto contingent allegiance */ | ||
238 | #define FCPIO_ICMND_PRI_SHIFT 3 /* priority field starts in bit 3 */ | ||
239 | |||
240 | /* | ||
241 | * Command flags | ||
242 | */ | ||
243 | #define FCPIO_ICMND_RDDATA 0x02 /* read data */ | ||
244 | #define FCPIO_ICMND_WRDATA 0x01 /* write data */ | ||
245 | |||
246 | /* | ||
247 | * fcpio_icmnd_32: host -> firmware request | ||
248 | * | ||
249 | * used for sending out an initiator SCSI 32-byte command | ||
250 | */ | ||
251 | struct fcpio_icmnd_32 { | ||
252 | u32 lunmap_id; /* index into lunmap table */ | ||
253 | u8 special_req_flags; /* special exchange request flags */ | ||
254 | u8 _resvd0[3]; /* reserved */ | ||
255 | u32 sgl_cnt; /* scatter-gather list count */ | ||
256 | u32 sense_len; /* sense buffer length */ | ||
257 | u64 sgl_addr; /* scatter-gather list addr */ | ||
258 | u64 sense_addr; /* sense buffer address */ | ||
259 | u8 crn; /* SCSI Command Reference No. */ | ||
260 | u8 pri_ta; /* SCSI Priority and Task attribute */ | ||
261 | u8 _resvd1; /* reserved: should be 0 */ | ||
262 | u8 flags; /* command flags */ | ||
263 | u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */ | ||
264 | u32 data_len; /* length of data expected */ | ||
265 | u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ | ||
266 | u8 _resvd2; /* reserved */ | ||
267 | u8 d_id[3]; /* FC vNIC only: Target D_ID */ | ||
268 | u16 mss; /* FC vNIC only: max burst */ | ||
269 | u16 _resvd3; /* reserved */ | ||
270 | u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */ | ||
271 | u32 e_d_tov; /* FC vNIC only: Error Detect Timeout */ | ||
272 | }; | ||
273 | |||
274 | /* | ||
275 | * fcpio_itmf: host -> firmware request | ||
276 | * | ||
277 | * used for requesting the firmware to abort a request and/or send out | ||
278 | * a task management function | ||
279 | * | ||
280 | * The t_tag field is only needed when the request type is ABT_TASK. | ||
281 | */ | ||
282 | struct fcpio_itmf { | ||
283 | u32 lunmap_id; /* index into lunmap table */ | ||
284 | u32 tm_req; /* SCSI Task Management request */ | ||
285 | u32 t_tag; /* header tag of fcpio to be aborted */ | ||
286 | u32 _resvd; /* _reserved */ | ||
287 | u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ | ||
288 | u8 _resvd1; /* reserved */ | ||
289 | u8 d_id[3]; /* FC vNIC only: Target D_ID */ | ||
290 | u32 r_a_tov; /* FC vNIC only: R_A_TOV in msec */ | ||
291 | u32 e_d_tov; /* FC vNIC only: E_D_TOV in msec */ | ||
292 | }; | ||
293 | |||
294 | /* | ||
295 | * Task Management request | ||
296 | */ | ||
297 | enum fcpio_itmf_tm_req_type { | ||
298 | FCPIO_ITMF_ABT_TASK_TERM = 0x01, /* abort task and terminate */ | ||
299 | FCPIO_ITMF_ABT_TASK, /* abort task and issue abts */ | ||
300 | FCPIO_ITMF_ABT_TASK_SET, /* abort task set */ | ||
301 | FCPIO_ITMF_CLR_TASK_SET, /* clear task set */ | ||
302 | FCPIO_ITMF_LUN_RESET, /* logical unit reset task mgmt */ | ||
303 | FCPIO_ITMF_CLR_ACA, /* Clear ACA condition */ | ||
304 | }; | ||
305 | |||
306 | /* | ||
307 | * fcpio_tdata: host -> firmware request | ||
308 | * | ||
309 | * used for requesting the firmware to send out a read data transfer for a | ||
310 | * target command | ||
311 | */ | ||
312 | struct fcpio_tdata { | ||
313 | u16 rx_id; /* FC rx_id of target command */ | ||
314 | u16 flags; /* command flags */ | ||
315 | u32 rel_offset; /* data sequence relative offset */ | ||
316 | u32 sgl_cnt; /* scatter-gather list count */ | ||
317 | u32 data_len; /* length of data expected to send */ | ||
318 | u64 sgl_addr; /* scatter-gather list address */ | ||
319 | }; | ||
320 | |||
321 | /* | ||
322 | * Command flags | ||
323 | */ | ||
324 | #define FCPIO_TDATA_SCSI_RSP 0x01 /* send a scsi resp. after last frame */ | ||
325 | |||
326 | /* | ||
327 | * fcpio_txrdy: host -> firmware request | ||
328 | * | ||
329 | * used for requesting the firmware to send out a write data transfer for a | ||
330 | * target command | ||
331 | */ | ||
332 | struct fcpio_txrdy { | ||
333 | u16 rx_id; /* FC rx_id of target command */ | ||
334 | u16 _resvd0; /* reserved */ | ||
335 | u32 rel_offset; /* data sequence relative offset */ | ||
336 | u32 sgl_cnt; /* scatter-gather list count */ | ||
337 | u32 data_len; /* length of data expected to send */ | ||
338 | u64 sgl_addr; /* scatter-gather list address */ | ||
339 | }; | ||
340 | |||
341 | /* | ||
342 | * fcpio_trsp: host -> firmware request | ||
343 | * | ||
344 | * used for requesting the firmware to send out a response for a target | ||
345 | * command | ||
346 | */ | ||
347 | struct fcpio_trsp { | ||
348 | u16 rx_id; /* FC rx_id of target command */ | ||
349 | u16 _resvd0; /* reserved */ | ||
350 | u32 sense_len; /* sense data buffer length */ | ||
351 | u64 sense_addr; /* sense data buffer address */ | ||
352 | u16 _resvd1; /* reserved */ | ||
353 | u8 flags; /* response request flags */ | ||
354 | u8 scsi_status; /* SCSI status */ | ||
355 | u32 residual; /* SCSI data residual value of I/O */ | ||
356 | }; | ||
357 | |||
358 | /* | ||
359 | * resposnse request flags | ||
360 | */ | ||
361 | #define FCPIO_TRSP_RESID_UNDER 0x08 /* residual is valid and is underflow */ | ||
362 | #define FCPIO_TRSP_RESID_OVER 0x04 /* residual is valid and is overflow */ | ||
363 | |||
364 | /* | ||
365 | * fcpio_ttmf_ack: host -> firmware response | ||
366 | * | ||
367 | * used by the host to indicate to the firmware it has received and processed | ||
368 | * the target tmf request | ||
369 | */ | ||
370 | struct fcpio_ttmf_ack { | ||
371 | u16 rx_id; /* FC rx_id of target command */ | ||
372 | u16 _resvd0; /* reserved */ | ||
373 | u32 tmf_status; /* SCSI task management status */ | ||
374 | }; | ||
375 | |||
376 | /* | ||
377 | * fcpio_tabort: host -> firmware request | ||
378 | * | ||
379 | * used by the host to request the firmware to abort a target request that was | ||
380 | * received by the firmware | ||
381 | */ | ||
382 | struct fcpio_tabort { | ||
383 | u16 rx_id; /* rx_id of the target request */ | ||
384 | }; | ||
385 | |||
386 | /* | ||
387 | * fcpio_reset: host -> firmware request | ||
388 | * | ||
389 | * used by the host to signal a reset of the driver to the firmware | ||
390 | * and to request firmware to clean up all outstanding I/O | ||
391 | */ | ||
392 | struct fcpio_reset { | ||
393 | u32 _resvd; | ||
394 | }; | ||
395 | |||
396 | enum fcpio_flogi_reg_format_type { | ||
397 | FCPIO_FLOGI_REG_DEF_DEST = 0, /* Use the oui | s_id mac format */ | ||
398 | FCPIO_FLOGI_REG_GW_DEST, /* Use the fixed gateway mac */ | ||
399 | }; | ||
400 | |||
401 | /* | ||
402 | * fcpio_flogi_reg: host -> firmware request | ||
403 | * | ||
404 | * fc vnic only | ||
405 | * used by the host to notify the firmware of the lif's s_id | ||
406 | * and destination mac address format | ||
407 | */ | ||
408 | struct fcpio_flogi_reg { | ||
409 | u8 format; | ||
410 | u8 s_id[3]; /* FC vNIC only: Source S_ID */ | ||
411 | u8 gateway_mac[ETH_ALEN]; /* Destination gateway mac */ | ||
412 | u16 _resvd; | ||
413 | u32 r_a_tov; /* R_A_TOV in msec */ | ||
414 | u32 e_d_tov; /* E_D_TOV in msec */ | ||
415 | }; | ||
416 | |||
417 | /* | ||
418 | * fcpio_echo: host -> firmware request | ||
419 | * | ||
420 | * sends a heartbeat echo request to the firmware | ||
421 | */ | ||
422 | struct fcpio_echo { | ||
423 | u32 _resvd; | ||
424 | }; | ||
425 | |||
426 | /* | ||
427 | * fcpio_lunmap_req: host -> firmware request | ||
428 | * | ||
429 | * scsi vnic only | ||
430 | * sends a request to retrieve the lunmap table for scsi vnics | ||
431 | */ | ||
432 | struct fcpio_lunmap_req { | ||
433 | u64 addr; /* address of the buffer */ | ||
434 | u32 len; /* len of the buffer */ | ||
435 | }; | ||
436 | |||
437 | /* | ||
438 | * fcpio_flogi_fip_reg: host -> firmware request | ||
439 | * | ||
440 | * fc vnic only | ||
441 | * used by the host to notify the firmware of the lif's s_id | ||
442 | * and destination mac address format | ||
443 | */ | ||
444 | struct fcpio_flogi_fip_reg { | ||
445 | u8 _resvd0; | ||
446 | u8 s_id[3]; /* FC vNIC only: Source S_ID */ | ||
447 | u8 fcf_mac[ETH_ALEN]; /* FCF Target destination mac */ | ||
448 | u16 _resvd1; | ||
449 | u32 r_a_tov; /* R_A_TOV in msec */ | ||
450 | u32 e_d_tov; /* E_D_TOV in msec */ | ||
451 | u8 ha_mac[ETH_ALEN]; /* Host adapter source mac */ | ||
452 | u16 _resvd2; | ||
453 | }; | ||
454 | |||
455 | /* | ||
456 | * Basic structure for all fcpio structures that are sent from the host to the | ||
457 | * firmware. They are 128 bytes per structure. | ||
458 | */ | ||
459 | #define FCPIO_HOST_REQ_LEN 128 /* expected length of host requests */ | ||
460 | |||
461 | struct fcpio_host_req { | ||
462 | struct fcpio_header hdr; | ||
463 | |||
464 | union { | ||
465 | /* | ||
466 | * Defines space needed for request | ||
467 | */ | ||
468 | u8 buf[FCPIO_HOST_REQ_LEN - sizeof(struct fcpio_header)]; | ||
469 | |||
470 | /* | ||
471 | * Initiator host requests | ||
472 | */ | ||
473 | struct fcpio_icmnd_16 icmnd_16; | ||
474 | struct fcpio_icmnd_32 icmnd_32; | ||
475 | struct fcpio_itmf itmf; | ||
476 | |||
477 | /* | ||
478 | * Target host requests | ||
479 | */ | ||
480 | struct fcpio_tdata tdata; | ||
481 | struct fcpio_txrdy txrdy; | ||
482 | struct fcpio_trsp trsp; | ||
483 | struct fcpio_ttmf_ack ttmf_ack; | ||
484 | struct fcpio_tabort tabort; | ||
485 | |||
486 | /* | ||
487 | * Misc requests | ||
488 | */ | ||
489 | struct fcpio_reset reset; | ||
490 | struct fcpio_flogi_reg flogi_reg; | ||
491 | struct fcpio_echo echo; | ||
492 | struct fcpio_lunmap_req lunmap_req; | ||
493 | struct fcpio_flogi_fip_reg flogi_fip_reg; | ||
494 | } u; | ||
495 | }; | ||
496 | |||
497 | /* | ||
498 | * fcpio_icmnd_cmpl: firmware -> host response | ||
499 | * | ||
500 | * used for sending the host a response to an initiator command | ||
501 | */ | ||
502 | struct fcpio_icmnd_cmpl { | ||
503 | u8 _resvd0[6]; /* reserved */ | ||
504 | u8 flags; /* response flags */ | ||
505 | u8 scsi_status; /* SCSI status */ | ||
506 | u32 residual; /* SCSI data residual length */ | ||
507 | u32 sense_len; /* SCSI sense length */ | ||
508 | }; | ||
509 | |||
510 | /* | ||
511 | * response flags | ||
512 | */ | ||
513 | #define FCPIO_ICMND_CMPL_RESID_UNDER 0x08 /* resid under and valid */ | ||
514 | #define FCPIO_ICMND_CMPL_RESID_OVER 0x04 /* resid over and valid */ | ||
515 | |||
516 | /* | ||
517 | * fcpio_itmf_cmpl: firmware -> host response | ||
518 | * | ||
519 | * used for sending the host a response for a itmf request | ||
520 | */ | ||
521 | struct fcpio_itmf_cmpl { | ||
522 | u32 _resvd; /* reserved */ | ||
523 | }; | ||
524 | |||
525 | /* | ||
526 | * fcpio_tcmnd_16: firmware -> host request | ||
527 | * | ||
528 | * used by the firmware to notify the host of an incoming target SCSI 16-Byte | ||
529 | * request | ||
530 | */ | ||
531 | struct fcpio_tcmnd_16 { | ||
532 | u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ | ||
533 | u8 crn; /* SCSI Command Reference No. */ | ||
534 | u8 pri_ta; /* SCSI Priority and Task attribute */ | ||
535 | u8 _resvd2; /* reserved: should be 0 */ | ||
536 | u8 flags; /* command flags */ | ||
537 | u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */ | ||
538 | u32 data_len; /* length of data expected */ | ||
539 | u8 _resvd1; /* reserved */ | ||
540 | u8 s_id[3]; /* FC vNIC only: Source S_ID */ | ||
541 | }; | ||
542 | |||
543 | /* | ||
544 | * Priority/Task Attribute settings | ||
545 | */ | ||
546 | #define FCPIO_TCMND_PTA_SIMPLE 0 /* simple task attribute */ | ||
547 | #define FCPIO_TCMND_PTA_HEADQ 1 /* head of queue task attribute */ | ||
548 | #define FCPIO_TCMND_PTA_ORDERED 2 /* ordered task attribute */ | ||
549 | #define FCPIO_TCMND_PTA_ACA 4 /* auto contingent allegiance */ | ||
550 | #define FCPIO_TCMND_PRI_SHIFT 3 /* priority field starts in bit 3 */ | ||
551 | |||
552 | /* | ||
553 | * Command flags | ||
554 | */ | ||
555 | #define FCPIO_TCMND_RDDATA 0x02 /* read data */ | ||
556 | #define FCPIO_TCMND_WRDATA 0x01 /* write data */ | ||
557 | |||
558 | /* | ||
559 | * fcpio_tcmnd_32: firmware -> host request | ||
560 | * | ||
561 | * used by the firmware to notify the host of an incoming target SCSI 32-Byte | ||
562 | * request | ||
563 | */ | ||
564 | struct fcpio_tcmnd_32 { | ||
565 | u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ | ||
566 | u8 crn; /* SCSI Command Reference No. */ | ||
567 | u8 pri_ta; /* SCSI Priority and Task attribute */ | ||
568 | u8 _resvd2; /* reserved: should be 0 */ | ||
569 | u8 flags; /* command flags */ | ||
570 | u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */ | ||
571 | u32 data_len; /* length of data expected */ | ||
572 | u8 _resvd0; /* reserved */ | ||
573 | u8 s_id[3]; /* FC vNIC only: Source S_ID */ | ||
574 | }; | ||
575 | |||
576 | /* | ||
577 | * fcpio_tdrsp_cmpl: firmware -> host response | ||
578 | * | ||
579 | * used by the firmware to notify the host of a response to a host target | ||
580 | * command | ||
581 | */ | ||
582 | struct fcpio_tdrsp_cmpl { | ||
583 | u16 rx_id; /* rx_id of the target request */ | ||
584 | u16 _resvd0; /* reserved */ | ||
585 | }; | ||
586 | |||
587 | /* | ||
588 | * fcpio_ttmf: firmware -> host request | ||
589 | * | ||
590 | * used by the firmware to notify the host of an incoming task management | ||
591 | * function request | ||
592 | */ | ||
593 | struct fcpio_ttmf { | ||
594 | u8 _resvd0; /* reserved */ | ||
595 | u8 s_id[3]; /* FC vNIC only: Source S_ID */ | ||
596 | u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */ | ||
597 | u8 crn; /* SCSI Command Reference No. */ | ||
598 | u8 _resvd2[3]; /* reserved */ | ||
599 | u32 tmf_type; /* task management request type */ | ||
600 | }; | ||
601 | |||
602 | /* | ||
603 | * Task Management request | ||
604 | */ | ||
605 | #define FCPIO_TTMF_CLR_ACA 0x40 /* Clear ACA condition */ | ||
606 | #define FCPIO_TTMF_LUN_RESET 0x10 /* logical unit reset task mgmt */ | ||
607 | #define FCPIO_TTMF_CLR_TASK_SET 0x04 /* clear task set */ | ||
608 | #define FCPIO_TTMF_ABT_TASK_SET 0x02 /* abort task set */ | ||
609 | #define FCPIO_TTMF_ABT_TASK 0x01 /* abort task */ | ||
610 | |||
611 | /* | ||
612 | * fcpio_tabort_cmpl: firmware -> host response | ||
613 | * | ||
614 | * used by the firmware to respond to a host's tabort request | ||
615 | */ | ||
616 | struct fcpio_tabort_cmpl { | ||
617 | u16 rx_id; /* rx_id of the target request */ | ||
618 | u16 _resvd0; /* reserved */ | ||
619 | }; | ||
620 | |||
621 | /* | ||
622 | * fcpio_ack: firmware -> host response | ||
623 | * | ||
624 | * used by firmware to notify the host of the last work request received | ||
625 | */ | ||
626 | struct fcpio_ack { | ||
627 | u16 request_out; /* last host entry received */ | ||
628 | u16 _resvd; | ||
629 | }; | ||
630 | |||
631 | /* | ||
632 | * fcpio_reset_cmpl: firmware -> host response | ||
633 | * | ||
634 | * use by firmware to respond to the host's reset request | ||
635 | */ | ||
636 | struct fcpio_reset_cmpl { | ||
637 | u16 vnic_id; | ||
638 | }; | ||
639 | |||
640 | /* | ||
641 | * fcpio_flogi_reg_cmpl: firmware -> host response | ||
642 | * | ||
643 | * fc vnic only | ||
644 | * response to the fcpio_flogi_reg request | ||
645 | */ | ||
646 | struct fcpio_flogi_reg_cmpl { | ||
647 | u32 _resvd; | ||
648 | }; | ||
649 | |||
650 | /* | ||
651 | * fcpio_echo_cmpl: firmware -> host response | ||
652 | * | ||
653 | * response to the fcpio_echo request | ||
654 | */ | ||
655 | struct fcpio_echo_cmpl { | ||
656 | u32 _resvd; | ||
657 | }; | ||
658 | |||
659 | /* | ||
660 | * fcpio_lunmap_chng: firmware -> host notification | ||
661 | * | ||
662 | * scsi vnic only | ||
663 | * notifies the host that the lunmap tables have changed | ||
664 | */ | ||
665 | struct fcpio_lunmap_chng { | ||
666 | u32 _resvd; | ||
667 | }; | ||
668 | |||
669 | /* | ||
670 | * fcpio_lunmap_req_cmpl: firmware -> host response | ||
671 | * | ||
672 | * scsi vnic only | ||
673 | * response for lunmap table request from the host | ||
674 | */ | ||
675 | struct fcpio_lunmap_req_cmpl { | ||
676 | u32 _resvd; | ||
677 | }; | ||
678 | |||
679 | /* | ||
680 | * Basic structure for all fcpio structures that are sent from the firmware to | ||
681 | * the host. They are 64 bytes per structure. | ||
682 | */ | ||
683 | #define FCPIO_FW_REQ_LEN 64 /* expected length of fw requests */ | ||
684 | struct fcpio_fw_req { | ||
685 | struct fcpio_header hdr; | ||
686 | |||
687 | union { | ||
688 | /* | ||
689 | * Defines space needed for request | ||
690 | */ | ||
691 | u8 buf[FCPIO_FW_REQ_LEN - sizeof(struct fcpio_header)]; | ||
692 | |||
693 | /* | ||
694 | * Initiator firmware responses | ||
695 | */ | ||
696 | struct fcpio_icmnd_cmpl icmnd_cmpl; | ||
697 | struct fcpio_itmf_cmpl itmf_cmpl; | ||
698 | |||
699 | /* | ||
700 | * Target firmware new requests | ||
701 | */ | ||
702 | struct fcpio_tcmnd_16 tcmnd_16; | ||
703 | struct fcpio_tcmnd_32 tcmnd_32; | ||
704 | |||
705 | /* | ||
706 | * Target firmware responses | ||
707 | */ | ||
708 | struct fcpio_tdrsp_cmpl tdrsp_cmpl; | ||
709 | struct fcpio_ttmf ttmf; | ||
710 | struct fcpio_tabort_cmpl tabort_cmpl; | ||
711 | |||
712 | /* | ||
713 | * Firmware response to work received | ||
714 | */ | ||
715 | struct fcpio_ack ack; | ||
716 | |||
717 | /* | ||
718 | * Misc requests | ||
719 | */ | ||
720 | struct fcpio_reset_cmpl reset_cmpl; | ||
721 | struct fcpio_flogi_reg_cmpl flogi_reg_cmpl; | ||
722 | struct fcpio_echo_cmpl echo_cmpl; | ||
723 | struct fcpio_lunmap_chng lunmap_chng; | ||
724 | struct fcpio_lunmap_req_cmpl lunmap_req_cmpl; | ||
725 | } u; | ||
726 | }; | ||
727 | |||
728 | /* | ||
729 | * Access routines to encode and decode the color bit, which is the most | ||
730 | * significant bit of the MSB of the structure | ||
731 | */ | ||
732 | static inline void fcpio_color_enc(struct fcpio_fw_req *fw_req, u8 color) | ||
733 | { | ||
734 | u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1; | ||
735 | |||
736 | if (color) | ||
737 | *c |= 0x80; | ||
738 | else | ||
739 | *c &= ~0x80; | ||
740 | } | ||
741 | |||
742 | static inline void fcpio_color_dec(struct fcpio_fw_req *fw_req, u8 *color) | ||
743 | { | ||
744 | u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1; | ||
745 | |||
746 | *color = *c >> 7; | ||
747 | |||
748 | /* | ||
749 | * Make sure color bit is read from desc *before* other fields | ||
750 | * are read from desc. Hardware guarantees color bit is last | ||
751 | * bit (byte) written. Adding the rmb() prevents the compiler | ||
752 | * and/or CPU from reordering the reads which would potentially | ||
753 | * result in reading stale values. | ||
754 | */ | ||
755 | |||
756 | rmb(); | ||
757 | |||
758 | } | ||
759 | |||
760 | /* | ||
761 | * Lunmap table entry for scsi vnics | ||
762 | */ | ||
763 | #define FCPIO_LUNMAP_TABLE_SIZE 256 | ||
764 | #define FCPIO_FLAGS_LUNMAP_VALID 0x80 | ||
765 | #define FCPIO_FLAGS_BOOT 0x01 | ||
766 | struct fcpio_lunmap_entry { | ||
767 | u8 bus; | ||
768 | u8 target; | ||
769 | u8 lun; | ||
770 | u8 path_cnt; | ||
771 | u16 flags; | ||
772 | u16 update_cnt; | ||
773 | }; | ||
774 | |||
775 | struct fcpio_lunmap_tbl { | ||
776 | u32 update_cnt; | ||
777 | struct fcpio_lunmap_entry lunmaps[FCPIO_LUNMAP_TABLE_SIZE]; | ||
778 | }; | ||
779 | |||
780 | #endif /* _FCPIO_H_ */ | ||
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h new file mode 100644 index 000000000000..e4c0a3d7d87b --- /dev/null +++ b/drivers/scsi/fnic/fnic.h | |||
@@ -0,0 +1,265 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _FNIC_H_ | ||
19 | #define _FNIC_H_ | ||
20 | |||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/netdevice.h> | ||
23 | #include <linux/workqueue.h> | ||
24 | #include <scsi/libfc.h> | ||
25 | #include "fnic_io.h" | ||
26 | #include "fnic_res.h" | ||
27 | #include "vnic_dev.h" | ||
28 | #include "vnic_wq.h" | ||
29 | #include "vnic_rq.h" | ||
30 | #include "vnic_cq.h" | ||
31 | #include "vnic_wq_copy.h" | ||
32 | #include "vnic_intr.h" | ||
33 | #include "vnic_stats.h" | ||
34 | #include "vnic_scsi.h" | ||
35 | |||
36 | #define DRV_NAME "fnic" | ||
37 | #define DRV_DESCRIPTION "Cisco FCoE HBA Driver" | ||
38 | #define DRV_VERSION "1.0.0.1121" | ||
39 | #define PFX DRV_NAME ": " | ||
40 | #define DFX DRV_NAME "%d: " | ||
41 | |||
42 | #define DESC_CLEAN_LOW_WATERMARK 8 | ||
43 | #define FNIC_MAX_IO_REQ 2048 /* scsi_cmnd tag map entries */ | ||
44 | #define FNIC_IO_LOCKS 64 /* IO locks: power of 2 */ | ||
45 | #define FNIC_DFLT_QUEUE_DEPTH 32 | ||
46 | #define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */ | ||
47 | |||
48 | /* | ||
49 | * Tag bits used for special requests. | ||
50 | */ | ||
51 | #define BIT(nr) (1UL << (nr)) | ||
52 | #define FNIC_TAG_ABORT BIT(30) /* tag bit indicating abort */ | ||
53 | #define FNIC_TAG_DEV_RST BIT(29) /* indicates device reset */ | ||
54 | #define FNIC_TAG_MASK (BIT(24) - 1) /* mask for lookup */ | ||
55 | #define FNIC_NO_TAG -1 | ||
56 | |||
57 | /* | ||
58 | * Usage of the scsi_cmnd scratchpad. | ||
59 | * These fields are locked by the hashed io_req_lock. | ||
60 | */ | ||
61 | #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) | ||
62 | #define CMD_STATE(Cmnd) ((Cmnd)->SCp.phase) | ||
63 | #define CMD_ABTS_STATUS(Cmnd) ((Cmnd)->SCp.Message) | ||
64 | #define CMD_LR_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in) | ||
65 | #define CMD_TAG(Cmnd) ((Cmnd)->SCp.sent_command) | ||
66 | |||
67 | #define FCPIO_INVALID_CODE 0x100 /* hdr_status value unused by firmware */ | ||
68 | |||
69 | #define FNIC_LUN_RESET_TIMEOUT 10000 /* mSec */ | ||
70 | #define FNIC_HOST_RESET_TIMEOUT 10000 /* mSec */ | ||
71 | #define FNIC_RMDEVICE_TIMEOUT 1000 /* mSec */ | ||
72 | #define FNIC_HOST_RESET_SETTLE_TIME 30 /* Sec */ | ||
73 | |||
74 | #define FNIC_MAX_FCP_TARGET 256 | ||
75 | |||
76 | extern unsigned int fnic_log_level; | ||
77 | |||
78 | #define FNIC_MAIN_LOGGING 0x01 | ||
79 | #define FNIC_FCS_LOGGING 0x02 | ||
80 | #define FNIC_SCSI_LOGGING 0x04 | ||
81 | #define FNIC_ISR_LOGGING 0x08 | ||
82 | |||
83 | #define FNIC_CHECK_LOGGING(LEVEL, CMD) \ | ||
84 | do { \ | ||
85 | if (unlikely(fnic_log_level & LEVEL)) \ | ||
86 | do { \ | ||
87 | CMD; \ | ||
88 | } while (0); \ | ||
89 | } while (0) | ||
90 | |||
91 | #define FNIC_MAIN_DBG(kern_level, host, fmt, args...) \ | ||
92 | FNIC_CHECK_LOGGING(FNIC_MAIN_LOGGING, \ | ||
93 | shost_printk(kern_level, host, fmt, ##args);) | ||
94 | |||
95 | #define FNIC_FCS_DBG(kern_level, host, fmt, args...) \ | ||
96 | FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \ | ||
97 | shost_printk(kern_level, host, fmt, ##args);) | ||
98 | |||
99 | #define FNIC_SCSI_DBG(kern_level, host, fmt, args...) \ | ||
100 | FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \ | ||
101 | shost_printk(kern_level, host, fmt, ##args);) | ||
102 | |||
103 | #define FNIC_ISR_DBG(kern_level, host, fmt, args...) \ | ||
104 | FNIC_CHECK_LOGGING(FNIC_ISR_LOGGING, \ | ||
105 | shost_printk(kern_level, host, fmt, ##args);) | ||
106 | |||
107 | extern const char *fnic_state_str[]; | ||
108 | |||
109 | enum fnic_intx_intr_index { | ||
110 | FNIC_INTX_WQ_RQ_COPYWQ, | ||
111 | FNIC_INTX_ERR, | ||
112 | FNIC_INTX_NOTIFY, | ||
113 | FNIC_INTX_INTR_MAX, | ||
114 | }; | ||
115 | |||
116 | enum fnic_msix_intr_index { | ||
117 | FNIC_MSIX_RQ, | ||
118 | FNIC_MSIX_WQ, | ||
119 | FNIC_MSIX_WQ_COPY, | ||
120 | FNIC_MSIX_ERR_NOTIFY, | ||
121 | FNIC_MSIX_INTR_MAX, | ||
122 | }; | ||
123 | |||
124 | struct fnic_msix_entry { | ||
125 | int requested; | ||
126 | char devname[IFNAMSIZ]; | ||
127 | irqreturn_t (*isr)(int, void *); | ||
128 | void *devid; | ||
129 | }; | ||
130 | |||
131 | enum fnic_state { | ||
132 | FNIC_IN_FC_MODE = 0, | ||
133 | FNIC_IN_FC_TRANS_ETH_MODE, | ||
134 | FNIC_IN_ETH_MODE, | ||
135 | FNIC_IN_ETH_TRANS_FC_MODE, | ||
136 | }; | ||
137 | |||
138 | #define FNIC_WQ_COPY_MAX 1 | ||
139 | #define FNIC_WQ_MAX 1 | ||
140 | #define FNIC_RQ_MAX 1 | ||
141 | #define FNIC_CQ_MAX (FNIC_WQ_COPY_MAX + FNIC_WQ_MAX + FNIC_RQ_MAX) | ||
142 | |||
143 | struct mempool; | ||
144 | |||
145 | /* Per-instance private data structure */ | ||
146 | struct fnic { | ||
147 | struct fc_lport *lport; | ||
148 | struct vnic_dev_bar bar0; | ||
149 | |||
150 | struct msix_entry msix_entry[FNIC_MSIX_INTR_MAX]; | ||
151 | struct fnic_msix_entry msix[FNIC_MSIX_INTR_MAX]; | ||
152 | |||
153 | struct vnic_stats *stats; | ||
154 | unsigned long stats_time; /* time of stats update */ | ||
155 | struct vnic_nic_cfg *nic_cfg; | ||
156 | char name[IFNAMSIZ]; | ||
157 | struct timer_list notify_timer; /* used for MSI interrupts */ | ||
158 | |||
159 | unsigned int err_intr_offset; | ||
160 | unsigned int link_intr_offset; | ||
161 | |||
162 | unsigned int wq_count; | ||
163 | unsigned int cq_count; | ||
164 | |||
165 | u32 fcoui_mode:1; /* use fcoui address*/ | ||
166 | u32 vlan_hw_insert:1; /* let hw insert the tag */ | ||
167 | u32 in_remove:1; /* fnic device in removal */ | ||
168 | u32 stop_rx_link_events:1; /* stop proc. rx frames, link events */ | ||
169 | |||
170 | struct completion *remove_wait; /* device remove thread blocks */ | ||
171 | |||
172 | struct fc_frame *flogi; | ||
173 | struct fc_frame *flogi_resp; | ||
174 | u16 flogi_oxid; | ||
175 | unsigned long s_id; | ||
176 | enum fnic_state state; | ||
177 | spinlock_t fnic_lock; | ||
178 | |||
179 | u16 vlan_id; /* VLAN tag including priority */ | ||
180 | u8 mac_addr[ETH_ALEN]; | ||
181 | u8 dest_addr[ETH_ALEN]; | ||
182 | u8 data_src_addr[ETH_ALEN]; | ||
183 | u64 fcp_input_bytes; /* internal statistic */ | ||
184 | u64 fcp_output_bytes; /* internal statistic */ | ||
185 | u32 link_down_cnt; | ||
186 | int link_status; | ||
187 | |||
188 | struct list_head list; | ||
189 | struct pci_dev *pdev; | ||
190 | struct vnic_fc_config config; | ||
191 | struct vnic_dev *vdev; | ||
192 | unsigned int raw_wq_count; | ||
193 | unsigned int wq_copy_count; | ||
194 | unsigned int rq_count; | ||
195 | int fw_ack_index[FNIC_WQ_COPY_MAX]; | ||
196 | unsigned short fw_ack_recd[FNIC_WQ_COPY_MAX]; | ||
197 | unsigned short wq_copy_desc_low[FNIC_WQ_COPY_MAX]; | ||
198 | unsigned int intr_count; | ||
199 | u32 __iomem *legacy_pba; | ||
200 | struct fnic_host_tag *tags; | ||
201 | mempool_t *io_req_pool; | ||
202 | mempool_t *io_sgl_pool[FNIC_SGL_NUM_CACHES]; | ||
203 | spinlock_t io_req_lock[FNIC_IO_LOCKS]; /* locks for scsi cmnds */ | ||
204 | |||
205 | struct work_struct link_work; | ||
206 | struct work_struct frame_work; | ||
207 | struct sk_buff_head frame_queue; | ||
208 | |||
209 | /* copy work queue cache line section */ | ||
210 | ____cacheline_aligned struct vnic_wq_copy wq_copy[FNIC_WQ_COPY_MAX]; | ||
211 | /* completion queue cache line section */ | ||
212 | ____cacheline_aligned struct vnic_cq cq[FNIC_CQ_MAX]; | ||
213 | |||
214 | spinlock_t wq_copy_lock[FNIC_WQ_COPY_MAX]; | ||
215 | |||
216 | /* work queue cache line section */ | ||
217 | ____cacheline_aligned struct vnic_wq wq[FNIC_WQ_MAX]; | ||
218 | spinlock_t wq_lock[FNIC_WQ_MAX]; | ||
219 | |||
220 | /* receive queue cache line section */ | ||
221 | ____cacheline_aligned struct vnic_rq rq[FNIC_RQ_MAX]; | ||
222 | |||
223 | /* interrupt resource cache line section */ | ||
224 | ____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX]; | ||
225 | }; | ||
226 | |||
227 | extern struct workqueue_struct *fnic_event_queue; | ||
228 | extern struct device_attribute *fnic_attrs[]; | ||
229 | |||
230 | void fnic_clear_intr_mode(struct fnic *fnic); | ||
231 | int fnic_set_intr_mode(struct fnic *fnic); | ||
232 | void fnic_free_intr(struct fnic *fnic); | ||
233 | int fnic_request_intr(struct fnic *fnic); | ||
234 | |||
235 | int fnic_send(struct fc_lport *, struct fc_frame *); | ||
236 | void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf); | ||
237 | void fnic_handle_frame(struct work_struct *work); | ||
238 | void fnic_handle_link(struct work_struct *work); | ||
239 | int fnic_rq_cmpl_handler(struct fnic *fnic, int); | ||
240 | int fnic_alloc_rq_frame(struct vnic_rq *rq); | ||
241 | void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf); | ||
242 | int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp); | ||
243 | |||
244 | int fnic_queuecommand(struct scsi_cmnd *, void (*done)(struct scsi_cmnd *)); | ||
245 | int fnic_abort_cmd(struct scsi_cmnd *); | ||
246 | int fnic_device_reset(struct scsi_cmnd *); | ||
247 | int fnic_host_reset(struct scsi_cmnd *); | ||
248 | int fnic_reset(struct Scsi_Host *); | ||
249 | void fnic_scsi_cleanup(struct fc_lport *); | ||
250 | void fnic_scsi_abort_io(struct fc_lport *); | ||
251 | void fnic_empty_scsi_cleanup(struct fc_lport *); | ||
252 | void fnic_exch_mgr_reset(struct fc_lport *, u32, u32); | ||
253 | int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int); | ||
254 | int fnic_wq_cmpl_handler(struct fnic *fnic, int); | ||
255 | int fnic_flogi_reg_handler(struct fnic *fnic); | ||
256 | void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, | ||
257 | struct fcpio_host_req *desc); | ||
258 | int fnic_fw_reset_handler(struct fnic *fnic); | ||
259 | void fnic_terminate_rport_io(struct fc_rport *); | ||
260 | const char *fnic_state_to_str(unsigned int state); | ||
261 | |||
262 | void fnic_log_q_error(struct fnic *fnic); | ||
263 | void fnic_handle_link_event(struct fnic *fnic); | ||
264 | |||
265 | #endif /* _FNIC_H_ */ | ||
diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c new file mode 100644 index 000000000000..aea0c3becfd4 --- /dev/null +++ b/drivers/scsi/fnic/fnic_attrs.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/device.h> | ||
20 | #include <scsi/scsi_host.h> | ||
21 | #include "fnic.h" | ||
22 | |||
23 | static ssize_t fnic_show_state(struct device *dev, | ||
24 | struct device_attribute *attr, char *buf) | ||
25 | { | ||
26 | struct fc_lport *lp = shost_priv(class_to_shost(dev)); | ||
27 | struct fnic *fnic = lport_priv(lp); | ||
28 | |||
29 | return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]); | ||
30 | } | ||
31 | |||
32 | static ssize_t fnic_show_drv_version(struct device *dev, | ||
33 | struct device_attribute *attr, char *buf) | ||
34 | { | ||
35 | return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); | ||
36 | } | ||
37 | |||
38 | static ssize_t fnic_show_link_state(struct device *dev, | ||
39 | struct device_attribute *attr, char *buf) | ||
40 | { | ||
41 | struct fc_lport *lp = shost_priv(class_to_shost(dev)); | ||
42 | |||
43 | return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up) | ||
44 | ? "Link Up" : "Link Down"); | ||
45 | } | ||
46 | |||
47 | static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); | ||
48 | static DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL); | ||
49 | static DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL); | ||
50 | |||
51 | struct device_attribute *fnic_attrs[] = { | ||
52 | &dev_attr_fnic_state, | ||
53 | &dev_attr_drv_version, | ||
54 | &dev_attr_link_state, | ||
55 | NULL, | ||
56 | }; | ||
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c new file mode 100644 index 000000000000..07e6eedb83ce --- /dev/null +++ b/drivers/scsi/fnic/fnic_fcs.c | |||
@@ -0,0 +1,742 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/pci.h> | ||
20 | #include <linux/skbuff.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/spinlock.h> | ||
23 | #include <linux/if_ether.h> | ||
24 | #include <linux/if_vlan.h> | ||
25 | #include <linux/workqueue.h> | ||
26 | #include <scsi/fc/fc_els.h> | ||
27 | #include <scsi/fc/fc_fcoe.h> | ||
28 | #include <scsi/fc_frame.h> | ||
29 | #include <scsi/libfc.h> | ||
30 | #include "fnic_io.h" | ||
31 | #include "fnic.h" | ||
32 | #include "cq_enet_desc.h" | ||
33 | #include "cq_exch_desc.h" | ||
34 | |||
35 | struct workqueue_struct *fnic_event_queue; | ||
36 | |||
37 | void fnic_handle_link(struct work_struct *work) | ||
38 | { | ||
39 | struct fnic *fnic = container_of(work, struct fnic, link_work); | ||
40 | unsigned long flags; | ||
41 | int old_link_status; | ||
42 | u32 old_link_down_cnt; | ||
43 | |||
44 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
45 | |||
46 | if (fnic->stop_rx_link_events) { | ||
47 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
48 | return; | ||
49 | } | ||
50 | |||
51 | old_link_down_cnt = fnic->link_down_cnt; | ||
52 | old_link_status = fnic->link_status; | ||
53 | fnic->link_status = vnic_dev_link_status(fnic->vdev); | ||
54 | fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev); | ||
55 | |||
56 | if (old_link_status == fnic->link_status) { | ||
57 | if (!fnic->link_status) | ||
58 | /* DOWN -> DOWN */ | ||
59 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
60 | else { | ||
61 | if (old_link_down_cnt != fnic->link_down_cnt) { | ||
62 | /* UP -> DOWN -> UP */ | ||
63 | fnic->lport->host_stats.link_failure_count++; | ||
64 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
65 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, | ||
66 | "link down\n"); | ||
67 | fc_linkdown(fnic->lport); | ||
68 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, | ||
69 | "link up\n"); | ||
70 | fc_linkup(fnic->lport); | ||
71 | } else | ||
72 | /* UP -> UP */ | ||
73 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
74 | } | ||
75 | } else if (fnic->link_status) { | ||
76 | /* DOWN -> UP */ | ||
77 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
78 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n"); | ||
79 | fc_linkup(fnic->lport); | ||
80 | } else { | ||
81 | /* UP -> DOWN */ | ||
82 | fnic->lport->host_stats.link_failure_count++; | ||
83 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
84 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link down\n"); | ||
85 | fc_linkdown(fnic->lport); | ||
86 | } | ||
87 | |||
88 | } | ||
89 | |||
90 | /* | ||
91 | * This function passes incoming fabric frames to libFC | ||
92 | */ | ||
93 | void fnic_handle_frame(struct work_struct *work) | ||
94 | { | ||
95 | struct fnic *fnic = container_of(work, struct fnic, frame_work); | ||
96 | struct fc_lport *lp = fnic->lport; | ||
97 | unsigned long flags; | ||
98 | struct sk_buff *skb; | ||
99 | struct fc_frame *fp; | ||
100 | |||
101 | while ((skb = skb_dequeue(&fnic->frame_queue))) { | ||
102 | |||
103 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
104 | if (fnic->stop_rx_link_events) { | ||
105 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
106 | dev_kfree_skb(skb); | ||
107 | return; | ||
108 | } | ||
109 | fp = (struct fc_frame *)skb; | ||
110 | /* if Flogi resp frame, register the address */ | ||
111 | if (fr_flags(fp)) { | ||
112 | vnic_dev_add_addr(fnic->vdev, | ||
113 | fnic->data_src_addr); | ||
114 | fr_flags(fp) = 0; | ||
115 | } | ||
116 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
117 | |||
118 | fc_exch_recv(lp, lp->emp, fp); | ||
119 | } | ||
120 | |||
121 | } | ||
122 | |||
123 | static inline void fnic_import_rq_fc_frame(struct sk_buff *skb, | ||
124 | u32 len, u8 sof, u8 eof) | ||
125 | { | ||
126 | struct fc_frame *fp = (struct fc_frame *)skb; | ||
127 | |||
128 | skb_trim(skb, len); | ||
129 | fr_eof(fp) = eof; | ||
130 | fr_sof(fp) = sof; | ||
131 | } | ||
132 | |||
133 | |||
134 | static inline int fnic_import_rq_eth_pkt(struct sk_buff *skb, u32 len) | ||
135 | { | ||
136 | struct fc_frame *fp; | ||
137 | struct ethhdr *eh; | ||
138 | struct vlan_ethhdr *vh; | ||
139 | struct fcoe_hdr *fcoe_hdr; | ||
140 | struct fcoe_crc_eof *ft; | ||
141 | u32 transport_len = 0; | ||
142 | |||
143 | eh = (struct ethhdr *)skb->data; | ||
144 | vh = (struct vlan_ethhdr *)skb->data; | ||
145 | if (vh->h_vlan_proto == htons(ETH_P_8021Q) && | ||
146 | vh->h_vlan_encapsulated_proto == htons(ETH_P_FCOE)) { | ||
147 | skb_pull(skb, sizeof(struct vlan_ethhdr)); | ||
148 | transport_len += sizeof(struct vlan_ethhdr); | ||
149 | } else if (eh->h_proto == htons(ETH_P_FCOE)) { | ||
150 | transport_len += sizeof(struct ethhdr); | ||
151 | skb_pull(skb, sizeof(struct ethhdr)); | ||
152 | } else | ||
153 | return -1; | ||
154 | |||
155 | fcoe_hdr = (struct fcoe_hdr *)skb->data; | ||
156 | if (FC_FCOE_DECAPS_VER(fcoe_hdr) != FC_FCOE_VER) | ||
157 | return -1; | ||
158 | |||
159 | fp = (struct fc_frame *)skb; | ||
160 | fc_frame_init(fp); | ||
161 | fr_sof(fp) = fcoe_hdr->fcoe_sof; | ||
162 | skb_pull(skb, sizeof(struct fcoe_hdr)); | ||
163 | transport_len += sizeof(struct fcoe_hdr); | ||
164 | |||
165 | ft = (struct fcoe_crc_eof *)(skb->data + len - | ||
166 | transport_len - sizeof(*ft)); | ||
167 | fr_eof(fp) = ft->fcoe_eof; | ||
168 | skb_trim(skb, len - transport_len - sizeof(*ft)); | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | static inline int fnic_handle_flogi_resp(struct fnic *fnic, | ||
173 | struct fc_frame *fp) | ||
174 | { | ||
175 | u8 mac[ETH_ALEN] = FC_FCOE_FLOGI_MAC; | ||
176 | struct ethhdr *eth_hdr; | ||
177 | struct fc_frame_header *fh; | ||
178 | int ret = 0; | ||
179 | unsigned long flags; | ||
180 | struct fc_frame *old_flogi_resp = NULL; | ||
181 | |||
182 | fh = (struct fc_frame_header *)fr_hdr(fp); | ||
183 | |||
184 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
185 | |||
186 | if (fnic->state == FNIC_IN_ETH_MODE) { | ||
187 | |||
188 | /* | ||
189 | * Check if oxid matches on taking the lock. A new Flogi | ||
190 | * issued by libFC might have changed the fnic cached oxid | ||
191 | */ | ||
192 | if (fnic->flogi_oxid != ntohs(fh->fh_ox_id)) { | ||
193 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, | ||
194 | "Flogi response oxid not" | ||
195 | " matching cached oxid, dropping frame" | ||
196 | "\n"); | ||
197 | ret = -1; | ||
198 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
199 | dev_kfree_skb_irq(fp_skb(fp)); | ||
200 | goto handle_flogi_resp_end; | ||
201 | } | ||
202 | |||
203 | /* Drop older cached flogi response frame, cache this frame */ | ||
204 | old_flogi_resp = fnic->flogi_resp; | ||
205 | fnic->flogi_resp = fp; | ||
206 | fnic->flogi_oxid = FC_XID_UNKNOWN; | ||
207 | |||
208 | /* | ||
209 | * this frame is part of flogi get the src mac addr from this | ||
210 | * frame if the src mac is fcoui based then we mark the | ||
211 | * address mode flag to use fcoui base for dst mac addr | ||
212 | * otherwise we have to store the fcoe gateway addr | ||
213 | */ | ||
214 | eth_hdr = (struct ethhdr *)skb_mac_header(fp_skb(fp)); | ||
215 | memcpy(mac, eth_hdr->h_source, ETH_ALEN); | ||
216 | |||
217 | if (ntoh24(mac) == FC_FCOE_OUI) | ||
218 | fnic->fcoui_mode = 1; | ||
219 | else { | ||
220 | fnic->fcoui_mode = 0; | ||
221 | memcpy(fnic->dest_addr, mac, ETH_ALEN); | ||
222 | } | ||
223 | |||
224 | /* | ||
225 | * Except for Flogi frame, all outbound frames from us have the | ||
226 | * Eth Src address as FC_FCOE_OUI"our_sid". Flogi frame uses | ||
227 | * the vnic MAC address as the Eth Src address | ||
228 | */ | ||
229 | fc_fcoe_set_mac(fnic->data_src_addr, fh->fh_d_id); | ||
230 | |||
231 | /* We get our s_id from the d_id of the flogi resp frame */ | ||
232 | fnic->s_id = ntoh24(fh->fh_d_id); | ||
233 | |||
234 | /* Change state to reflect transition from Eth to FC mode */ | ||
235 | fnic->state = FNIC_IN_ETH_TRANS_FC_MODE; | ||
236 | |||
237 | } else { | ||
238 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, | ||
239 | "Unexpected fnic state %s while" | ||
240 | " processing flogi resp\n", | ||
241 | fnic_state_to_str(fnic->state)); | ||
242 | ret = -1; | ||
243 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
244 | dev_kfree_skb_irq(fp_skb(fp)); | ||
245 | goto handle_flogi_resp_end; | ||
246 | } | ||
247 | |||
248 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
249 | |||
250 | /* Drop older cached frame */ | ||
251 | if (old_flogi_resp) | ||
252 | dev_kfree_skb_irq(fp_skb(old_flogi_resp)); | ||
253 | |||
254 | /* | ||
255 | * send flogi reg request to firmware, this will put the fnic in | ||
256 | * in FC mode | ||
257 | */ | ||
258 | ret = fnic_flogi_reg_handler(fnic); | ||
259 | |||
260 | if (ret < 0) { | ||
261 | int free_fp = 1; | ||
262 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
263 | /* | ||
264 | * free the frame is some other thread is not | ||
265 | * pointing to it | ||
266 | */ | ||
267 | if (fnic->flogi_resp != fp) | ||
268 | free_fp = 0; | ||
269 | else | ||
270 | fnic->flogi_resp = NULL; | ||
271 | |||
272 | if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE) | ||
273 | fnic->state = FNIC_IN_ETH_MODE; | ||
274 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
275 | if (free_fp) | ||
276 | dev_kfree_skb_irq(fp_skb(fp)); | ||
277 | } | ||
278 | |||
279 | handle_flogi_resp_end: | ||
280 | return ret; | ||
281 | } | ||
282 | |||
283 | /* Returns 1 for a response that matches cached flogi oxid */ | ||
284 | static inline int is_matching_flogi_resp_frame(struct fnic *fnic, | ||
285 | struct fc_frame *fp) | ||
286 | { | ||
287 | struct fc_frame_header *fh; | ||
288 | int ret = 0; | ||
289 | u32 f_ctl; | ||
290 | |||
291 | fh = fc_frame_header_get(fp); | ||
292 | f_ctl = ntoh24(fh->fh_f_ctl); | ||
293 | |||
294 | if (fnic->flogi_oxid == ntohs(fh->fh_ox_id) && | ||
295 | fh->fh_r_ctl == FC_RCTL_ELS_REP && | ||
296 | (f_ctl & (FC_FC_EX_CTX | FC_FC_SEQ_CTX)) == FC_FC_EX_CTX && | ||
297 | fh->fh_type == FC_TYPE_ELS) | ||
298 | ret = 1; | ||
299 | |||
300 | return ret; | ||
301 | } | ||
302 | |||
303 | static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc | ||
304 | *cq_desc, struct vnic_rq_buf *buf, | ||
305 | int skipped __attribute__((unused)), | ||
306 | void *opaque) | ||
307 | { | ||
308 | struct fnic *fnic = vnic_dev_priv(rq->vdev); | ||
309 | struct sk_buff *skb; | ||
310 | struct fc_frame *fp; | ||
311 | unsigned int eth_hdrs_stripped; | ||
312 | u8 type, color, eop, sop, ingress_port, vlan_stripped; | ||
313 | u8 fcoe = 0, fcoe_sof, fcoe_eof; | ||
314 | u8 fcoe_fc_crc_ok = 1, fcoe_enc_error = 0; | ||
315 | u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok; | ||
316 | u8 ipv6, ipv4, ipv4_fragment, rss_type, csum_not_calc; | ||
317 | u8 fcs_ok = 1, packet_error = 0; | ||
318 | u16 q_number, completed_index, bytes_written = 0, vlan, checksum; | ||
319 | u32 rss_hash; | ||
320 | u16 exchange_id, tmpl; | ||
321 | u8 sof = 0; | ||
322 | u8 eof = 0; | ||
323 | u32 fcp_bytes_written = 0; | ||
324 | unsigned long flags; | ||
325 | |||
326 | pci_unmap_single(fnic->pdev, buf->dma_addr, buf->len, | ||
327 | PCI_DMA_FROMDEVICE); | ||
328 | skb = buf->os_buf; | ||
329 | buf->os_buf = NULL; | ||
330 | |||
331 | cq_desc_dec(cq_desc, &type, &color, &q_number, &completed_index); | ||
332 | if (type == CQ_DESC_TYPE_RQ_FCP) { | ||
333 | cq_fcp_rq_desc_dec((struct cq_fcp_rq_desc *)cq_desc, | ||
334 | &type, &color, &q_number, &completed_index, | ||
335 | &eop, &sop, &fcoe_fc_crc_ok, &exchange_id, | ||
336 | &tmpl, &fcp_bytes_written, &sof, &eof, | ||
337 | &ingress_port, &packet_error, | ||
338 | &fcoe_enc_error, &fcs_ok, &vlan_stripped, | ||
339 | &vlan); | ||
340 | eth_hdrs_stripped = 1; | ||
341 | |||
342 | } else if (type == CQ_DESC_TYPE_RQ_ENET) { | ||
343 | cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc, | ||
344 | &type, &color, &q_number, &completed_index, | ||
345 | &ingress_port, &fcoe, &eop, &sop, | ||
346 | &rss_type, &csum_not_calc, &rss_hash, | ||
347 | &bytes_written, &packet_error, | ||
348 | &vlan_stripped, &vlan, &checksum, | ||
349 | &fcoe_sof, &fcoe_fc_crc_ok, | ||
350 | &fcoe_enc_error, &fcoe_eof, | ||
351 | &tcp_udp_csum_ok, &udp, &tcp, | ||
352 | &ipv4_csum_ok, &ipv6, &ipv4, | ||
353 | &ipv4_fragment, &fcs_ok); | ||
354 | eth_hdrs_stripped = 0; | ||
355 | |||
356 | } else { | ||
357 | /* wrong CQ type*/ | ||
358 | shost_printk(KERN_ERR, fnic->lport->host, | ||
359 | "fnic rq_cmpl wrong cq type x%x\n", type); | ||
360 | goto drop; | ||
361 | } | ||
362 | |||
363 | if (!fcs_ok || packet_error || !fcoe_fc_crc_ok || fcoe_enc_error) { | ||
364 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, | ||
365 | "fnic rq_cmpl fcoe x%x fcsok x%x" | ||
366 | " pkterr x%x fcoe_fc_crc_ok x%x, fcoe_enc_err" | ||
367 | " x%x\n", | ||
368 | fcoe, fcs_ok, packet_error, | ||
369 | fcoe_fc_crc_ok, fcoe_enc_error); | ||
370 | goto drop; | ||
371 | } | ||
372 | |||
373 | if (eth_hdrs_stripped) | ||
374 | fnic_import_rq_fc_frame(skb, fcp_bytes_written, sof, eof); | ||
375 | else if (fnic_import_rq_eth_pkt(skb, bytes_written)) | ||
376 | goto drop; | ||
377 | |||
378 | fp = (struct fc_frame *)skb; | ||
379 | |||
380 | /* | ||
381 | * If frame is an ELS response that matches the cached FLOGI OX_ID, | ||
382 | * and is accept, issue flogi_reg_request copy wq request to firmware | ||
383 | * to register the S_ID and determine whether FC_OUI mode or GW mode. | ||
384 | */ | ||
385 | if (is_matching_flogi_resp_frame(fnic, fp)) { | ||
386 | if (!eth_hdrs_stripped) { | ||
387 | if (fc_frame_payload_op(fp) == ELS_LS_ACC) { | ||
388 | fnic_handle_flogi_resp(fnic, fp); | ||
389 | return; | ||
390 | } | ||
391 | /* | ||
392 | * Recd. Flogi reject. No point registering | ||
393 | * with fw, but forward to libFC | ||
394 | */ | ||
395 | goto forward; | ||
396 | } | ||
397 | goto drop; | ||
398 | } | ||
399 | if (!eth_hdrs_stripped) | ||
400 | goto drop; | ||
401 | |||
402 | forward: | ||
403 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
404 | if (fnic->stop_rx_link_events) { | ||
405 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
406 | goto drop; | ||
407 | } | ||
408 | /* Use fr_flags to indicate whether succ. flogi resp or not */ | ||
409 | fr_flags(fp) = 0; | ||
410 | fr_dev(fp) = fnic->lport; | ||
411 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
412 | |||
413 | skb_queue_tail(&fnic->frame_queue, skb); | ||
414 | queue_work(fnic_event_queue, &fnic->frame_work); | ||
415 | |||
416 | return; | ||
417 | drop: | ||
418 | dev_kfree_skb_irq(skb); | ||
419 | } | ||
420 | |||
421 | static int fnic_rq_cmpl_handler_cont(struct vnic_dev *vdev, | ||
422 | struct cq_desc *cq_desc, u8 type, | ||
423 | u16 q_number, u16 completed_index, | ||
424 | void *opaque) | ||
425 | { | ||
426 | struct fnic *fnic = vnic_dev_priv(vdev); | ||
427 | |||
428 | vnic_rq_service(&fnic->rq[q_number], cq_desc, completed_index, | ||
429 | VNIC_RQ_RETURN_DESC, fnic_rq_cmpl_frame_recv, | ||
430 | NULL); | ||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | int fnic_rq_cmpl_handler(struct fnic *fnic, int rq_work_to_do) | ||
435 | { | ||
436 | unsigned int tot_rq_work_done = 0, cur_work_done; | ||
437 | unsigned int i; | ||
438 | int err; | ||
439 | |||
440 | for (i = 0; i < fnic->rq_count; i++) { | ||
441 | cur_work_done = vnic_cq_service(&fnic->cq[i], rq_work_to_do, | ||
442 | fnic_rq_cmpl_handler_cont, | ||
443 | NULL); | ||
444 | if (cur_work_done) { | ||
445 | err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); | ||
446 | if (err) | ||
447 | shost_printk(KERN_ERR, fnic->lport->host, | ||
448 | "fnic_alloc_rq_frame cant alloc" | ||
449 | " frame\n"); | ||
450 | } | ||
451 | tot_rq_work_done += cur_work_done; | ||
452 | } | ||
453 | |||
454 | return tot_rq_work_done; | ||
455 | } | ||
456 | |||
457 | /* | ||
458 | * This function is called once at init time to allocate and fill RQ | ||
459 | * buffers. Subsequently, it is called in the interrupt context after RQ | ||
460 | * buffer processing to replenish the buffers in the RQ | ||
461 | */ | ||
462 | int fnic_alloc_rq_frame(struct vnic_rq *rq) | ||
463 | { | ||
464 | struct fnic *fnic = vnic_dev_priv(rq->vdev); | ||
465 | struct sk_buff *skb; | ||
466 | u16 len; | ||
467 | dma_addr_t pa; | ||
468 | |||
469 | len = FC_FRAME_HEADROOM + FC_MAX_FRAME + FC_FRAME_TAILROOM; | ||
470 | skb = dev_alloc_skb(len); | ||
471 | if (!skb) { | ||
472 | FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, | ||
473 | "Unable to allocate RQ sk_buff\n"); | ||
474 | return -ENOMEM; | ||
475 | } | ||
476 | skb_reset_mac_header(skb); | ||
477 | skb_reset_transport_header(skb); | ||
478 | skb_reset_network_header(skb); | ||
479 | skb_put(skb, len); | ||
480 | pa = pci_map_single(fnic->pdev, skb->data, len, PCI_DMA_FROMDEVICE); | ||
481 | fnic_queue_rq_desc(rq, skb, pa, len); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf) | ||
486 | { | ||
487 | struct fc_frame *fp = buf->os_buf; | ||
488 | struct fnic *fnic = vnic_dev_priv(rq->vdev); | ||
489 | |||
490 | pci_unmap_single(fnic->pdev, buf->dma_addr, buf->len, | ||
491 | PCI_DMA_FROMDEVICE); | ||
492 | |||
493 | dev_kfree_skb(fp_skb(fp)); | ||
494 | buf->os_buf = NULL; | ||
495 | } | ||
496 | |||
497 | static inline int is_flogi_frame(struct fc_frame_header *fh) | ||
498 | { | ||
499 | return fh->fh_r_ctl == FC_RCTL_ELS_REQ && *(u8 *)(fh + 1) == ELS_FLOGI; | ||
500 | } | ||
501 | |||
502 | int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp) | ||
503 | { | ||
504 | struct vnic_wq *wq = &fnic->wq[0]; | ||
505 | struct sk_buff *skb; | ||
506 | dma_addr_t pa; | ||
507 | struct ethhdr *eth_hdr; | ||
508 | struct vlan_ethhdr *vlan_hdr; | ||
509 | struct fcoe_hdr *fcoe_hdr; | ||
510 | struct fc_frame_header *fh; | ||
511 | u32 tot_len, eth_hdr_len; | ||
512 | int ret = 0; | ||
513 | unsigned long flags; | ||
514 | |||
515 | fh = fc_frame_header_get(fp); | ||
516 | skb = fp_skb(fp); | ||
517 | |||
518 | if (!fnic->vlan_hw_insert) { | ||
519 | eth_hdr_len = sizeof(*vlan_hdr) + sizeof(*fcoe_hdr); | ||
520 | vlan_hdr = (struct vlan_ethhdr *)skb_push(skb, eth_hdr_len); | ||
521 | eth_hdr = (struct ethhdr *)vlan_hdr; | ||
522 | vlan_hdr->h_vlan_proto = htons(ETH_P_8021Q); | ||
523 | vlan_hdr->h_vlan_encapsulated_proto = htons(ETH_P_FCOE); | ||
524 | vlan_hdr->h_vlan_TCI = htons(fnic->vlan_id); | ||
525 | fcoe_hdr = (struct fcoe_hdr *)(vlan_hdr + 1); | ||
526 | } else { | ||
527 | eth_hdr_len = sizeof(*eth_hdr) + sizeof(*fcoe_hdr); | ||
528 | eth_hdr = (struct ethhdr *)skb_push(skb, eth_hdr_len); | ||
529 | eth_hdr->h_proto = htons(ETH_P_FCOE); | ||
530 | fcoe_hdr = (struct fcoe_hdr *)(eth_hdr + 1); | ||
531 | } | ||
532 | |||
533 | if (is_flogi_frame(fh)) { | ||
534 | fc_fcoe_set_mac(eth_hdr->h_dest, fh->fh_d_id); | ||
535 | memcpy(eth_hdr->h_source, fnic->mac_addr, ETH_ALEN); | ||
536 | } else { | ||
537 | if (fnic->fcoui_mode) | ||
538 | fc_fcoe_set_mac(eth_hdr->h_dest, fh->fh_d_id); | ||
539 | else | ||
540 | memcpy(eth_hdr->h_dest, fnic->dest_addr, ETH_ALEN); | ||
541 | memcpy(eth_hdr->h_source, fnic->data_src_addr, ETH_ALEN); | ||
542 | } | ||
543 | |||
544 | tot_len = skb->len; | ||
545 | BUG_ON(tot_len % 4); | ||
546 | |||
547 | memset(fcoe_hdr, 0, sizeof(*fcoe_hdr)); | ||
548 | fcoe_hdr->fcoe_sof = fr_sof(fp); | ||
549 | if (FC_FCOE_VER) | ||
550 | FC_FCOE_ENCAPS_VER(fcoe_hdr, FC_FCOE_VER); | ||
551 | |||
552 | pa = pci_map_single(fnic->pdev, eth_hdr, tot_len, PCI_DMA_TODEVICE); | ||
553 | |||
554 | spin_lock_irqsave(&fnic->wq_lock[0], flags); | ||
555 | |||
556 | if (!vnic_wq_desc_avail(wq)) { | ||
557 | pci_unmap_single(fnic->pdev, pa, | ||
558 | tot_len, PCI_DMA_TODEVICE); | ||
559 | ret = -1; | ||
560 | goto fnic_send_frame_end; | ||
561 | } | ||
562 | |||
563 | fnic_queue_wq_desc(wq, skb, pa, tot_len, fr_eof(fp), | ||
564 | fnic->vlan_hw_insert, fnic->vlan_id, 1, 1, 1); | ||
565 | fnic_send_frame_end: | ||
566 | spin_unlock_irqrestore(&fnic->wq_lock[0], flags); | ||
567 | |||
568 | if (ret) | ||
569 | dev_kfree_skb_any(fp_skb(fp)); | ||
570 | |||
571 | return ret; | ||
572 | } | ||
573 | |||
574 | /* | ||
575 | * fnic_send | ||
576 | * Routine to send a raw frame | ||
577 | */ | ||
578 | int fnic_send(struct fc_lport *lp, struct fc_frame *fp) | ||
579 | { | ||
580 | struct fnic *fnic = lport_priv(lp); | ||
581 | struct fc_frame_header *fh; | ||
582 | int ret = 0; | ||
583 | enum fnic_state old_state; | ||
584 | unsigned long flags; | ||
585 | struct fc_frame *old_flogi = NULL; | ||
586 | struct fc_frame *old_flogi_resp = NULL; | ||
587 | |||
588 | if (fnic->in_remove) { | ||
589 | dev_kfree_skb(fp_skb(fp)); | ||
590 | ret = -1; | ||
591 | goto fnic_send_end; | ||
592 | } | ||
593 | |||
594 | fh = fc_frame_header_get(fp); | ||
595 | /* if not an Flogi frame, send it out, this is the common case */ | ||
596 | if (!is_flogi_frame(fh)) | ||
597 | return fnic_send_frame(fnic, fp); | ||
598 | |||
599 | /* Flogi frame, now enter the state machine */ | ||
600 | |||
601 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
602 | again: | ||
603 | /* Get any old cached frames, free them after dropping lock */ | ||
604 | old_flogi = fnic->flogi; | ||
605 | fnic->flogi = NULL; | ||
606 | old_flogi_resp = fnic->flogi_resp; | ||
607 | fnic->flogi_resp = NULL; | ||
608 | |||
609 | fnic->flogi_oxid = FC_XID_UNKNOWN; | ||
610 | |||
611 | old_state = fnic->state; | ||
612 | switch (old_state) { | ||
613 | case FNIC_IN_FC_MODE: | ||
614 | case FNIC_IN_ETH_TRANS_FC_MODE: | ||
615 | default: | ||
616 | fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; | ||
617 | vnic_dev_del_addr(fnic->vdev, fnic->data_src_addr); | ||
618 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
619 | |||
620 | if (old_flogi) { | ||
621 | dev_kfree_skb(fp_skb(old_flogi)); | ||
622 | old_flogi = NULL; | ||
623 | } | ||
624 | if (old_flogi_resp) { | ||
625 | dev_kfree_skb(fp_skb(old_flogi_resp)); | ||
626 | old_flogi_resp = NULL; | ||
627 | } | ||
628 | |||
629 | ret = fnic_fw_reset_handler(fnic); | ||
630 | |||
631 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
632 | if (fnic->state != FNIC_IN_FC_TRANS_ETH_MODE) | ||
633 | goto again; | ||
634 | if (ret) { | ||
635 | fnic->state = old_state; | ||
636 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
637 | dev_kfree_skb(fp_skb(fp)); | ||
638 | goto fnic_send_end; | ||
639 | } | ||
640 | old_flogi = fnic->flogi; | ||
641 | fnic->flogi = fp; | ||
642 | fnic->flogi_oxid = ntohs(fh->fh_ox_id); | ||
643 | old_flogi_resp = fnic->flogi_resp; | ||
644 | fnic->flogi_resp = NULL; | ||
645 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
646 | break; | ||
647 | |||
648 | case FNIC_IN_FC_TRANS_ETH_MODE: | ||
649 | /* | ||
650 | * A reset is pending with the firmware. Store the flogi | ||
651 | * and its oxid. The transition out of this state happens | ||
652 | * only when Firmware completes the reset, either with | ||
653 | * success or failed. If success, transition to | ||
654 | * FNIC_IN_ETH_MODE, if fail, then transition to | ||
655 | * FNIC_IN_FC_MODE | ||
656 | */ | ||
657 | fnic->flogi = fp; | ||
658 | fnic->flogi_oxid = ntohs(fh->fh_ox_id); | ||
659 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
660 | break; | ||
661 | |||
662 | case FNIC_IN_ETH_MODE: | ||
663 | /* | ||
664 | * The fw/hw is already in eth mode. Store the oxid, | ||
665 | * and send the flogi frame out. The transition out of this | ||
666 | * state happens only we receive flogi response from the | ||
667 | * network, and the oxid matches the cached oxid when the | ||
668 | * flogi frame was sent out. If they match, then we issue | ||
669 | * a flogi_reg request and transition to state | ||
670 | * FNIC_IN_ETH_TRANS_FC_MODE | ||
671 | */ | ||
672 | fnic->flogi_oxid = ntohs(fh->fh_ox_id); | ||
673 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
674 | ret = fnic_send_frame(fnic, fp); | ||
675 | break; | ||
676 | } | ||
677 | |||
678 | fnic_send_end: | ||
679 | if (old_flogi) | ||
680 | dev_kfree_skb(fp_skb(old_flogi)); | ||
681 | if (old_flogi_resp) | ||
682 | dev_kfree_skb(fp_skb(old_flogi_resp)); | ||
683 | return ret; | ||
684 | } | ||
685 | |||
686 | static void fnic_wq_complete_frame_send(struct vnic_wq *wq, | ||
687 | struct cq_desc *cq_desc, | ||
688 | struct vnic_wq_buf *buf, void *opaque) | ||
689 | { | ||
690 | struct sk_buff *skb = buf->os_buf; | ||
691 | struct fc_frame *fp = (struct fc_frame *)skb; | ||
692 | struct fnic *fnic = vnic_dev_priv(wq->vdev); | ||
693 | |||
694 | pci_unmap_single(fnic->pdev, buf->dma_addr, | ||
695 | buf->len, PCI_DMA_TODEVICE); | ||
696 | dev_kfree_skb_irq(fp_skb(fp)); | ||
697 | buf->os_buf = NULL; | ||
698 | } | ||
699 | |||
700 | static int fnic_wq_cmpl_handler_cont(struct vnic_dev *vdev, | ||
701 | struct cq_desc *cq_desc, u8 type, | ||
702 | u16 q_number, u16 completed_index, | ||
703 | void *opaque) | ||
704 | { | ||
705 | struct fnic *fnic = vnic_dev_priv(vdev); | ||
706 | unsigned long flags; | ||
707 | |||
708 | spin_lock_irqsave(&fnic->wq_lock[q_number], flags); | ||
709 | vnic_wq_service(&fnic->wq[q_number], cq_desc, completed_index, | ||
710 | fnic_wq_complete_frame_send, NULL); | ||
711 | spin_unlock_irqrestore(&fnic->wq_lock[q_number], flags); | ||
712 | |||
713 | return 0; | ||
714 | } | ||
715 | |||
716 | int fnic_wq_cmpl_handler(struct fnic *fnic, int work_to_do) | ||
717 | { | ||
718 | unsigned int wq_work_done = 0; | ||
719 | unsigned int i; | ||
720 | |||
721 | for (i = 0; i < fnic->raw_wq_count; i++) { | ||
722 | wq_work_done += vnic_cq_service(&fnic->cq[fnic->rq_count+i], | ||
723 | work_to_do, | ||
724 | fnic_wq_cmpl_handler_cont, | ||
725 | NULL); | ||
726 | } | ||
727 | |||
728 | return wq_work_done; | ||
729 | } | ||
730 | |||
731 | |||
732 | void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf) | ||
733 | { | ||
734 | struct fc_frame *fp = buf->os_buf; | ||
735 | struct fnic *fnic = vnic_dev_priv(wq->vdev); | ||
736 | |||
737 | pci_unmap_single(fnic->pdev, buf->dma_addr, | ||
738 | buf->len, PCI_DMA_TODEVICE); | ||
739 | |||
740 | dev_kfree_skb(fp_skb(fp)); | ||
741 | buf->os_buf = NULL; | ||
742 | } | ||
diff --git a/drivers/scsi/fnic/fnic_io.h b/drivers/scsi/fnic/fnic_io.h new file mode 100644 index 000000000000..f0b896988cd5 --- /dev/null +++ b/drivers/scsi/fnic/fnic_io.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _FNIC_IO_H_ | ||
19 | #define _FNIC_IO_H_ | ||
20 | |||
21 | #include <scsi/fc/fc_fcp.h> | ||
22 | |||
23 | #define FNIC_DFLT_SG_DESC_CNT 32 | ||
24 | #define FNIC_MAX_SG_DESC_CNT 1024 /* Maximum descriptors per sgl */ | ||
25 | #define FNIC_SG_DESC_ALIGN 16 /* Descriptor address alignment */ | ||
26 | |||
27 | struct host_sg_desc { | ||
28 | __le64 addr; | ||
29 | __le32 len; | ||
30 | u32 _resvd; | ||
31 | }; | ||
32 | |||
33 | struct fnic_dflt_sgl_list { | ||
34 | struct host_sg_desc sg_desc[FNIC_DFLT_SG_DESC_CNT]; | ||
35 | }; | ||
36 | |||
37 | struct fnic_sgl_list { | ||
38 | struct host_sg_desc sg_desc[FNIC_MAX_SG_DESC_CNT]; | ||
39 | }; | ||
40 | |||
41 | enum fnic_sgl_list_type { | ||
42 | FNIC_SGL_CACHE_DFLT = 0, /* cache with default size sgl */ | ||
43 | FNIC_SGL_CACHE_MAX, /* cache with max size sgl */ | ||
44 | FNIC_SGL_NUM_CACHES /* number of sgl caches */ | ||
45 | }; | ||
46 | |||
47 | enum fnic_ioreq_state { | ||
48 | FNIC_IOREQ_CMD_PENDING = 0, | ||
49 | FNIC_IOREQ_ABTS_PENDING, | ||
50 | FNIC_IOREQ_ABTS_COMPLETE, | ||
51 | FNIC_IOREQ_CMD_COMPLETE, | ||
52 | }; | ||
53 | |||
54 | struct fnic_io_req { | ||
55 | struct host_sg_desc *sgl_list; /* sgl list */ | ||
56 | void *sgl_list_alloc; /* sgl list address used for free */ | ||
57 | dma_addr_t sense_buf_pa; /* dma address for sense buffer*/ | ||
58 | dma_addr_t sgl_list_pa; /* dma address for sgl list */ | ||
59 | u16 sgl_cnt; | ||
60 | u8 sgl_type; /* device DMA descriptor list type */ | ||
61 | u8 io_completed:1; /* set to 1 when fw completes IO */ | ||
62 | u32 port_id; /* remote port DID */ | ||
63 | struct completion *abts_done; /* completion for abts */ | ||
64 | struct completion *dr_done; /* completion for device reset */ | ||
65 | }; | ||
66 | |||
67 | #endif /* _FNIC_IO_H_ */ | ||
diff --git a/drivers/scsi/fnic/fnic_isr.c b/drivers/scsi/fnic/fnic_isr.c new file mode 100644 index 000000000000..2b3064828aea --- /dev/null +++ b/drivers/scsi/fnic/fnic_isr.c | |||
@@ -0,0 +1,332 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <scsi/libfc.h> | ||
23 | #include <scsi/fc_frame.h> | ||
24 | #include "vnic_dev.h" | ||
25 | #include "vnic_intr.h" | ||
26 | #include "vnic_stats.h" | ||
27 | #include "fnic_io.h" | ||
28 | #include "fnic.h" | ||
29 | |||
30 | static irqreturn_t fnic_isr_legacy(int irq, void *data) | ||
31 | { | ||
32 | struct fnic *fnic = data; | ||
33 | u32 pba; | ||
34 | unsigned long work_done = 0; | ||
35 | |||
36 | pba = vnic_intr_legacy_pba(fnic->legacy_pba); | ||
37 | if (!pba) | ||
38 | return IRQ_NONE; | ||
39 | |||
40 | if (pba & (1 << FNIC_INTX_NOTIFY)) { | ||
41 | vnic_intr_return_all_credits(&fnic->intr[FNIC_INTX_NOTIFY]); | ||
42 | fnic_handle_link_event(fnic); | ||
43 | } | ||
44 | |||
45 | if (pba & (1 << FNIC_INTX_ERR)) { | ||
46 | vnic_intr_return_all_credits(&fnic->intr[FNIC_INTX_ERR]); | ||
47 | fnic_log_q_error(fnic); | ||
48 | } | ||
49 | |||
50 | if (pba & (1 << FNIC_INTX_WQ_RQ_COPYWQ)) { | ||
51 | work_done += fnic_wq_copy_cmpl_handler(fnic, 8); | ||
52 | work_done += fnic_wq_cmpl_handler(fnic, 4); | ||
53 | work_done += fnic_rq_cmpl_handler(fnic, 4); | ||
54 | |||
55 | vnic_intr_return_credits(&fnic->intr[FNIC_INTX_WQ_RQ_COPYWQ], | ||
56 | work_done, | ||
57 | 1 /* unmask intr */, | ||
58 | 1 /* reset intr timer */); | ||
59 | } | ||
60 | |||
61 | return IRQ_HANDLED; | ||
62 | } | ||
63 | |||
64 | static irqreturn_t fnic_isr_msi(int irq, void *data) | ||
65 | { | ||
66 | struct fnic *fnic = data; | ||
67 | unsigned long work_done = 0; | ||
68 | |||
69 | work_done += fnic_wq_copy_cmpl_handler(fnic, 8); | ||
70 | work_done += fnic_wq_cmpl_handler(fnic, 4); | ||
71 | work_done += fnic_rq_cmpl_handler(fnic, 4); | ||
72 | |||
73 | vnic_intr_return_credits(&fnic->intr[0], | ||
74 | work_done, | ||
75 | 1 /* unmask intr */, | ||
76 | 1 /* reset intr timer */); | ||
77 | |||
78 | return IRQ_HANDLED; | ||
79 | } | ||
80 | |||
81 | static irqreturn_t fnic_isr_msix_rq(int irq, void *data) | ||
82 | { | ||
83 | struct fnic *fnic = data; | ||
84 | unsigned long rq_work_done = 0; | ||
85 | |||
86 | rq_work_done = fnic_rq_cmpl_handler(fnic, 4); | ||
87 | vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_RQ], | ||
88 | rq_work_done, | ||
89 | 1 /* unmask intr */, | ||
90 | 1 /* reset intr timer */); | ||
91 | |||
92 | return IRQ_HANDLED; | ||
93 | } | ||
94 | |||
95 | static irqreturn_t fnic_isr_msix_wq(int irq, void *data) | ||
96 | { | ||
97 | struct fnic *fnic = data; | ||
98 | unsigned long wq_work_done = 0; | ||
99 | |||
100 | wq_work_done = fnic_wq_cmpl_handler(fnic, 4); | ||
101 | vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_WQ], | ||
102 | wq_work_done, | ||
103 | 1 /* unmask intr */, | ||
104 | 1 /* reset intr timer */); | ||
105 | return IRQ_HANDLED; | ||
106 | } | ||
107 | |||
108 | static irqreturn_t fnic_isr_msix_wq_copy(int irq, void *data) | ||
109 | { | ||
110 | struct fnic *fnic = data; | ||
111 | unsigned long wq_copy_work_done = 0; | ||
112 | |||
113 | wq_copy_work_done = fnic_wq_copy_cmpl_handler(fnic, 8); | ||
114 | vnic_intr_return_credits(&fnic->intr[FNIC_MSIX_WQ_COPY], | ||
115 | wq_copy_work_done, | ||
116 | 1 /* unmask intr */, | ||
117 | 1 /* reset intr timer */); | ||
118 | return IRQ_HANDLED; | ||
119 | } | ||
120 | |||
121 | static irqreturn_t fnic_isr_msix_err_notify(int irq, void *data) | ||
122 | { | ||
123 | struct fnic *fnic = data; | ||
124 | |||
125 | vnic_intr_return_all_credits(&fnic->intr[FNIC_MSIX_ERR_NOTIFY]); | ||
126 | fnic_log_q_error(fnic); | ||
127 | fnic_handle_link_event(fnic); | ||
128 | |||
129 | return IRQ_HANDLED; | ||
130 | } | ||
131 | |||
132 | void fnic_free_intr(struct fnic *fnic) | ||
133 | { | ||
134 | int i; | ||
135 | |||
136 | switch (vnic_dev_get_intr_mode(fnic->vdev)) { | ||
137 | case VNIC_DEV_INTR_MODE_INTX: | ||
138 | case VNIC_DEV_INTR_MODE_MSI: | ||
139 | free_irq(fnic->pdev->irq, fnic); | ||
140 | break; | ||
141 | |||
142 | case VNIC_DEV_INTR_MODE_MSIX: | ||
143 | for (i = 0; i < ARRAY_SIZE(fnic->msix); i++) | ||
144 | if (fnic->msix[i].requested) | ||
145 | free_irq(fnic->msix_entry[i].vector, | ||
146 | fnic->msix[i].devid); | ||
147 | break; | ||
148 | |||
149 | default: | ||
150 | break; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | int fnic_request_intr(struct fnic *fnic) | ||
155 | { | ||
156 | int err = 0; | ||
157 | int i; | ||
158 | |||
159 | switch (vnic_dev_get_intr_mode(fnic->vdev)) { | ||
160 | |||
161 | case VNIC_DEV_INTR_MODE_INTX: | ||
162 | err = request_irq(fnic->pdev->irq, &fnic_isr_legacy, | ||
163 | IRQF_SHARED, DRV_NAME, fnic); | ||
164 | break; | ||
165 | |||
166 | case VNIC_DEV_INTR_MODE_MSI: | ||
167 | err = request_irq(fnic->pdev->irq, &fnic_isr_msi, | ||
168 | 0, fnic->name, fnic); | ||
169 | break; | ||
170 | |||
171 | case VNIC_DEV_INTR_MODE_MSIX: | ||
172 | |||
173 | sprintf(fnic->msix[FNIC_MSIX_RQ].devname, | ||
174 | "%.11s-fcs-rq", fnic->name); | ||
175 | fnic->msix[FNIC_MSIX_RQ].isr = fnic_isr_msix_rq; | ||
176 | fnic->msix[FNIC_MSIX_RQ].devid = fnic; | ||
177 | |||
178 | sprintf(fnic->msix[FNIC_MSIX_WQ].devname, | ||
179 | "%.11s-fcs-wq", fnic->name); | ||
180 | fnic->msix[FNIC_MSIX_WQ].isr = fnic_isr_msix_wq; | ||
181 | fnic->msix[FNIC_MSIX_WQ].devid = fnic; | ||
182 | |||
183 | sprintf(fnic->msix[FNIC_MSIX_WQ_COPY].devname, | ||
184 | "%.11s-scsi-wq", fnic->name); | ||
185 | fnic->msix[FNIC_MSIX_WQ_COPY].isr = fnic_isr_msix_wq_copy; | ||
186 | fnic->msix[FNIC_MSIX_WQ_COPY].devid = fnic; | ||
187 | |||
188 | sprintf(fnic->msix[FNIC_MSIX_ERR_NOTIFY].devname, | ||
189 | "%.11s-err-notify", fnic->name); | ||
190 | fnic->msix[FNIC_MSIX_ERR_NOTIFY].isr = | ||
191 | fnic_isr_msix_err_notify; | ||
192 | fnic->msix[FNIC_MSIX_ERR_NOTIFY].devid = fnic; | ||
193 | |||
194 | for (i = 0; i < ARRAY_SIZE(fnic->msix); i++) { | ||
195 | err = request_irq(fnic->msix_entry[i].vector, | ||
196 | fnic->msix[i].isr, 0, | ||
197 | fnic->msix[i].devname, | ||
198 | fnic->msix[i].devid); | ||
199 | if (err) { | ||
200 | shost_printk(KERN_ERR, fnic->lport->host, | ||
201 | "MSIX: request_irq" | ||
202 | " failed %d\n", err); | ||
203 | fnic_free_intr(fnic); | ||
204 | break; | ||
205 | } | ||
206 | fnic->msix[i].requested = 1; | ||
207 | } | ||
208 | break; | ||
209 | |||
210 | default: | ||
211 | break; | ||
212 | } | ||
213 | |||
214 | return err; | ||
215 | } | ||
216 | |||
217 | int fnic_set_intr_mode(struct fnic *fnic) | ||
218 | { | ||
219 | unsigned int n = ARRAY_SIZE(fnic->rq); | ||
220 | unsigned int m = ARRAY_SIZE(fnic->wq); | ||
221 | unsigned int o = ARRAY_SIZE(fnic->wq_copy); | ||
222 | unsigned int i; | ||
223 | |||
224 | /* | ||
225 | * Set interrupt mode (INTx, MSI, MSI-X) depending | ||
226 | * system capabilities. | ||
227 | * | ||
228 | * Try MSI-X first | ||
229 | * | ||
230 | * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs | ||
231 | * (last INTR is used for WQ/RQ errors and notification area) | ||
232 | */ | ||
233 | |||
234 | BUG_ON(ARRAY_SIZE(fnic->msix_entry) < n + m + o + 1); | ||
235 | for (i = 0; i < n + m + o + 1; i++) | ||
236 | fnic->msix_entry[i].entry = i; | ||
237 | |||
238 | if (fnic->rq_count >= n && | ||
239 | fnic->raw_wq_count >= m && | ||
240 | fnic->wq_copy_count >= o && | ||
241 | fnic->cq_count >= n + m + o) { | ||
242 | if (!pci_enable_msix(fnic->pdev, fnic->msix_entry, | ||
243 | n + m + o + 1)) { | ||
244 | fnic->rq_count = n; | ||
245 | fnic->raw_wq_count = m; | ||
246 | fnic->wq_copy_count = o; | ||
247 | fnic->wq_count = m + o; | ||
248 | fnic->cq_count = n + m + o; | ||
249 | fnic->intr_count = n + m + o + 1; | ||
250 | fnic->err_intr_offset = FNIC_MSIX_ERR_NOTIFY; | ||
251 | |||
252 | FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, | ||
253 | "Using MSI-X Interrupts\n"); | ||
254 | vnic_dev_set_intr_mode(fnic->vdev, | ||
255 | VNIC_DEV_INTR_MODE_MSIX); | ||
256 | return 0; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | /* | ||
261 | * Next try MSI | ||
262 | * We need 1 RQ, 1 WQ, 1 WQ_COPY, 3 CQs, and 1 INTR | ||
263 | */ | ||
264 | if (fnic->rq_count >= 1 && | ||
265 | fnic->raw_wq_count >= 1 && | ||
266 | fnic->wq_copy_count >= 1 && | ||
267 | fnic->cq_count >= 3 && | ||
268 | fnic->intr_count >= 1 && | ||
269 | !pci_enable_msi(fnic->pdev)) { | ||
270 | |||
271 | fnic->rq_count = 1; | ||
272 | fnic->raw_wq_count = 1; | ||
273 | fnic->wq_copy_count = 1; | ||
274 | fnic->wq_count = 2; | ||
275 | fnic->cq_count = 3; | ||
276 | fnic->intr_count = 1; | ||
277 | fnic->err_intr_offset = 0; | ||
278 | |||
279 | FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, | ||
280 | "Using MSI Interrupts\n"); | ||
281 | vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSI); | ||
282 | |||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | /* | ||
287 | * Next try INTx | ||
288 | * We need 1 RQ, 1 WQ, 1 WQ_COPY, 3 CQs, and 3 INTRs | ||
289 | * 1 INTR is used for all 3 queues, 1 INTR for queue errors | ||
290 | * 1 INTR for notification area | ||
291 | */ | ||
292 | |||
293 | if (fnic->rq_count >= 1 && | ||
294 | fnic->raw_wq_count >= 1 && | ||
295 | fnic->wq_copy_count >= 1 && | ||
296 | fnic->cq_count >= 3 && | ||
297 | fnic->intr_count >= 3) { | ||
298 | |||
299 | fnic->rq_count = 1; | ||
300 | fnic->raw_wq_count = 1; | ||
301 | fnic->wq_copy_count = 1; | ||
302 | fnic->cq_count = 3; | ||
303 | fnic->intr_count = 3; | ||
304 | |||
305 | FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, | ||
306 | "Using Legacy Interrupts\n"); | ||
307 | vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN); | ||
313 | |||
314 | return -EINVAL; | ||
315 | } | ||
316 | |||
317 | void fnic_clear_intr_mode(struct fnic *fnic) | ||
318 | { | ||
319 | switch (vnic_dev_get_intr_mode(fnic->vdev)) { | ||
320 | case VNIC_DEV_INTR_MODE_MSIX: | ||
321 | pci_disable_msix(fnic->pdev); | ||
322 | break; | ||
323 | case VNIC_DEV_INTR_MODE_MSI: | ||
324 | pci_disable_msi(fnic->pdev); | ||
325 | break; | ||
326 | default: | ||
327 | break; | ||
328 | } | ||
329 | |||
330 | vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX); | ||
331 | } | ||
332 | |||
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c new file mode 100644 index 000000000000..32ef6b87d895 --- /dev/null +++ b/drivers/scsi/fnic/fnic_main.c | |||
@@ -0,0 +1,942 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/mempool.h> | ||
20 | #include <linux/string.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/pci.h> | ||
24 | #include <linux/skbuff.h> | ||
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <linux/workqueue.h> | ||
28 | #include <scsi/scsi_host.h> | ||
29 | #include <scsi/scsi_transport.h> | ||
30 | #include <scsi/scsi_transport_fc.h> | ||
31 | #include <scsi/scsi_tcq.h> | ||
32 | #include <scsi/libfc.h> | ||
33 | #include <scsi/fc_frame.h> | ||
34 | |||
35 | #include "vnic_dev.h" | ||
36 | #include "vnic_intr.h" | ||
37 | #include "vnic_stats.h" | ||
38 | #include "fnic_io.h" | ||
39 | #include "fnic.h" | ||
40 | |||
41 | #define PCI_DEVICE_ID_CISCO_FNIC 0x0045 | ||
42 | |||
43 | /* Timer to poll notification area for events. Used for MSI interrupts */ | ||
44 | #define FNIC_NOTIFY_TIMER_PERIOD (2 * HZ) | ||
45 | |||
46 | static struct kmem_cache *fnic_sgl_cache[FNIC_SGL_NUM_CACHES]; | ||
47 | static struct kmem_cache *fnic_io_req_cache; | ||
48 | LIST_HEAD(fnic_list); | ||
49 | DEFINE_SPINLOCK(fnic_list_lock); | ||
50 | |||
51 | /* Supported devices by fnic module */ | ||
52 | static struct pci_device_id fnic_id_table[] = { | ||
53 | { PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_FNIC) }, | ||
54 | { 0, } | ||
55 | }; | ||
56 | |||
57 | MODULE_DESCRIPTION(DRV_DESCRIPTION); | ||
58 | MODULE_AUTHOR("Abhijeet Joglekar <abjoglek@cisco.com>, " | ||
59 | "Joseph R. Eykholt <jeykholt@cisco.com>"); | ||
60 | MODULE_LICENSE("GPL v2"); | ||
61 | MODULE_VERSION(DRV_VERSION); | ||
62 | MODULE_DEVICE_TABLE(pci, fnic_id_table); | ||
63 | |||
64 | unsigned int fnic_log_level; | ||
65 | module_param(fnic_log_level, int, S_IRUGO|S_IWUSR); | ||
66 | MODULE_PARM_DESC(fnic_log_level, "bit mask of fnic logging levels"); | ||
67 | |||
68 | |||
69 | static struct libfc_function_template fnic_transport_template = { | ||
70 | .frame_send = fnic_send, | ||
71 | .fcp_abort_io = fnic_empty_scsi_cleanup, | ||
72 | .fcp_cleanup = fnic_empty_scsi_cleanup, | ||
73 | .exch_mgr_reset = fnic_exch_mgr_reset | ||
74 | }; | ||
75 | |||
76 | static int fnic_slave_alloc(struct scsi_device *sdev) | ||
77 | { | ||
78 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); | ||
79 | struct fc_lport *lp = shost_priv(sdev->host); | ||
80 | struct fnic *fnic = lport_priv(lp); | ||
81 | |||
82 | sdev->tagged_supported = 1; | ||
83 | |||
84 | if (!rport || fc_remote_port_chkready(rport)) | ||
85 | return -ENXIO; | ||
86 | |||
87 | scsi_activate_tcq(sdev, FNIC_DFLT_QUEUE_DEPTH); | ||
88 | rport->dev_loss_tmo = fnic->config.port_down_timeout / 1000; | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static struct scsi_host_template fnic_host_template = { | ||
94 | .module = THIS_MODULE, | ||
95 | .name = DRV_NAME, | ||
96 | .queuecommand = fnic_queuecommand, | ||
97 | .eh_abort_handler = fnic_abort_cmd, | ||
98 | .eh_device_reset_handler = fnic_device_reset, | ||
99 | .eh_host_reset_handler = fnic_host_reset, | ||
100 | .slave_alloc = fnic_slave_alloc, | ||
101 | .change_queue_depth = fc_change_queue_depth, | ||
102 | .change_queue_type = fc_change_queue_type, | ||
103 | .this_id = -1, | ||
104 | .cmd_per_lun = 3, | ||
105 | .can_queue = FNIC_MAX_IO_REQ, | ||
106 | .use_clustering = ENABLE_CLUSTERING, | ||
107 | .sg_tablesize = FNIC_MAX_SG_DESC_CNT, | ||
108 | .max_sectors = 0xffff, | ||
109 | .shost_attrs = fnic_attrs, | ||
110 | }; | ||
111 | |||
112 | static void fnic_get_host_speed(struct Scsi_Host *shost); | ||
113 | static struct scsi_transport_template *fnic_fc_transport; | ||
114 | static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *); | ||
115 | |||
116 | static struct fc_function_template fnic_fc_functions = { | ||
117 | |||
118 | .show_host_node_name = 1, | ||
119 | .show_host_port_name = 1, | ||
120 | .show_host_supported_classes = 1, | ||
121 | .show_host_supported_fc4s = 1, | ||
122 | .show_host_active_fc4s = 1, | ||
123 | .show_host_maxframe_size = 1, | ||
124 | .show_host_port_id = 1, | ||
125 | .show_host_supported_speeds = 1, | ||
126 | .get_host_speed = fnic_get_host_speed, | ||
127 | .show_host_speed = 1, | ||
128 | .show_host_port_type = 1, | ||
129 | .get_host_port_state = fc_get_host_port_state, | ||
130 | .show_host_port_state = 1, | ||
131 | .show_host_symbolic_name = 1, | ||
132 | .show_rport_maxframe_size = 1, | ||
133 | .show_rport_supported_classes = 1, | ||
134 | .show_host_fabric_name = 1, | ||
135 | .show_starget_node_name = 1, | ||
136 | .show_starget_port_name = 1, | ||
137 | .show_starget_port_id = 1, | ||
138 | .show_rport_dev_loss_tmo = 1, | ||
139 | .issue_fc_host_lip = fnic_reset, | ||
140 | .get_fc_host_stats = fnic_get_stats, | ||
141 | .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv), | ||
142 | .terminate_rport_io = fnic_terminate_rport_io, | ||
143 | }; | ||
144 | |||
145 | static void fnic_get_host_speed(struct Scsi_Host *shost) | ||
146 | { | ||
147 | struct fc_lport *lp = shost_priv(shost); | ||
148 | struct fnic *fnic = lport_priv(lp); | ||
149 | u32 port_speed = vnic_dev_port_speed(fnic->vdev); | ||
150 | |||
151 | /* Add in other values as they get defined in fw */ | ||
152 | switch (port_speed) { | ||
153 | case 10000: | ||
154 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; | ||
155 | break; | ||
156 | default: | ||
157 | fc_host_speed(shost) = FC_PORTSPEED_10GBIT; | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host) | ||
163 | { | ||
164 | int ret; | ||
165 | struct fc_lport *lp = shost_priv(host); | ||
166 | struct fnic *fnic = lport_priv(lp); | ||
167 | struct fc_host_statistics *stats = &lp->host_stats; | ||
168 | struct vnic_stats *vs; | ||
169 | unsigned long flags; | ||
170 | |||
171 | if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT)) | ||
172 | return stats; | ||
173 | fnic->stats_time = jiffies; | ||
174 | |||
175 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
176 | ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); | ||
177 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
178 | |||
179 | if (ret) { | ||
180 | FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, | ||
181 | "fnic: Get vnic stats failed" | ||
182 | " 0x%x", ret); | ||
183 | return stats; | ||
184 | } | ||
185 | vs = fnic->stats; | ||
186 | stats->tx_frames = vs->tx.tx_unicast_frames_ok; | ||
187 | stats->tx_words = vs->tx.tx_unicast_bytes_ok / 4; | ||
188 | stats->rx_frames = vs->rx.rx_unicast_frames_ok; | ||
189 | stats->rx_words = vs->rx.rx_unicast_bytes_ok / 4; | ||
190 | stats->error_frames = vs->tx.tx_errors + vs->rx.rx_errors; | ||
191 | stats->dumped_frames = vs->tx.tx_drops + vs->rx.rx_drop; | ||
192 | stats->invalid_crc_count = vs->rx.rx_crc_errors; | ||
193 | stats->seconds_since_last_reset = (jiffies - lp->boot_time) / HZ; | ||
194 | stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000); | ||
195 | stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000); | ||
196 | |||
197 | return stats; | ||
198 | } | ||
199 | |||
200 | void fnic_log_q_error(struct fnic *fnic) | ||
201 | { | ||
202 | unsigned int i; | ||
203 | u32 error_status; | ||
204 | |||
205 | for (i = 0; i < fnic->raw_wq_count; i++) { | ||
206 | error_status = ioread32(&fnic->wq[i].ctrl->error_status); | ||
207 | if (error_status) | ||
208 | shost_printk(KERN_ERR, fnic->lport->host, | ||
209 | "WQ[%d] error_status" | ||
210 | " %d\n", i, error_status); | ||
211 | } | ||
212 | |||
213 | for (i = 0; i < fnic->rq_count; i++) { | ||
214 | error_status = ioread32(&fnic->rq[i].ctrl->error_status); | ||
215 | if (error_status) | ||
216 | shost_printk(KERN_ERR, fnic->lport->host, | ||
217 | "RQ[%d] error_status" | ||
218 | " %d\n", i, error_status); | ||
219 | } | ||
220 | |||
221 | for (i = 0; i < fnic->wq_copy_count; i++) { | ||
222 | error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status); | ||
223 | if (error_status) | ||
224 | shost_printk(KERN_ERR, fnic->lport->host, | ||
225 | "CWQ[%d] error_status" | ||
226 | " %d\n", i, error_status); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | void fnic_handle_link_event(struct fnic *fnic) | ||
231 | { | ||
232 | unsigned long flags; | ||
233 | |||
234 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
235 | if (fnic->stop_rx_link_events) { | ||
236 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
237 | return; | ||
238 | } | ||
239 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
240 | |||
241 | queue_work(fnic_event_queue, &fnic->link_work); | ||
242 | |||
243 | } | ||
244 | |||
245 | static int fnic_notify_set(struct fnic *fnic) | ||
246 | { | ||
247 | int err; | ||
248 | |||
249 | switch (vnic_dev_get_intr_mode(fnic->vdev)) { | ||
250 | case VNIC_DEV_INTR_MODE_INTX: | ||
251 | err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY); | ||
252 | break; | ||
253 | case VNIC_DEV_INTR_MODE_MSI: | ||
254 | err = vnic_dev_notify_set(fnic->vdev, -1); | ||
255 | break; | ||
256 | case VNIC_DEV_INTR_MODE_MSIX: | ||
257 | err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY); | ||
258 | break; | ||
259 | default: | ||
260 | shost_printk(KERN_ERR, fnic->lport->host, | ||
261 | "Interrupt mode should be set up" | ||
262 | " before devcmd notify set %d\n", | ||
263 | vnic_dev_get_intr_mode(fnic->vdev)); | ||
264 | err = -1; | ||
265 | break; | ||
266 | } | ||
267 | |||
268 | return err; | ||
269 | } | ||
270 | |||
271 | static void fnic_notify_timer(unsigned long data) | ||
272 | { | ||
273 | struct fnic *fnic = (struct fnic *)data; | ||
274 | |||
275 | fnic_handle_link_event(fnic); | ||
276 | mod_timer(&fnic->notify_timer, | ||
277 | round_jiffies(jiffies + FNIC_NOTIFY_TIMER_PERIOD)); | ||
278 | } | ||
279 | |||
280 | static void fnic_notify_timer_start(struct fnic *fnic) | ||
281 | { | ||
282 | switch (vnic_dev_get_intr_mode(fnic->vdev)) { | ||
283 | case VNIC_DEV_INTR_MODE_MSI: | ||
284 | /* | ||
285 | * Schedule first timeout immediately. The driver is | ||
286 | * initiatialized and ready to look for link up notification | ||
287 | */ | ||
288 | mod_timer(&fnic->notify_timer, jiffies); | ||
289 | break; | ||
290 | default: | ||
291 | /* Using intr for notification for INTx/MSI-X */ | ||
292 | break; | ||
293 | }; | ||
294 | } | ||
295 | |||
296 | static int fnic_dev_wait(struct vnic_dev *vdev, | ||
297 | int (*start)(struct vnic_dev *, int), | ||
298 | int (*finished)(struct vnic_dev *, int *), | ||
299 | int arg) | ||
300 | { | ||
301 | unsigned long time; | ||
302 | int done; | ||
303 | int err; | ||
304 | |||
305 | err = start(vdev, arg); | ||
306 | if (err) | ||
307 | return err; | ||
308 | |||
309 | /* Wait for func to complete...2 seconds max */ | ||
310 | time = jiffies + (HZ * 2); | ||
311 | do { | ||
312 | err = finished(vdev, &done); | ||
313 | if (err) | ||
314 | return err; | ||
315 | if (done) | ||
316 | return 0; | ||
317 | schedule_timeout_uninterruptible(HZ / 10); | ||
318 | } while (time_after(time, jiffies)); | ||
319 | |||
320 | return -ETIMEDOUT; | ||
321 | } | ||
322 | |||
323 | static int fnic_cleanup(struct fnic *fnic) | ||
324 | { | ||
325 | unsigned int i; | ||
326 | int err; | ||
327 | unsigned long flags; | ||
328 | struct fc_frame *flogi = NULL; | ||
329 | struct fc_frame *flogi_resp = NULL; | ||
330 | |||
331 | vnic_dev_disable(fnic->vdev); | ||
332 | for (i = 0; i < fnic->intr_count; i++) | ||
333 | vnic_intr_mask(&fnic->intr[i]); | ||
334 | |||
335 | for (i = 0; i < fnic->rq_count; i++) { | ||
336 | err = vnic_rq_disable(&fnic->rq[i]); | ||
337 | if (err) | ||
338 | return err; | ||
339 | } | ||
340 | for (i = 0; i < fnic->raw_wq_count; i++) { | ||
341 | err = vnic_wq_disable(&fnic->wq[i]); | ||
342 | if (err) | ||
343 | return err; | ||
344 | } | ||
345 | for (i = 0; i < fnic->wq_copy_count; i++) { | ||
346 | err = vnic_wq_copy_disable(&fnic->wq_copy[i]); | ||
347 | if (err) | ||
348 | return err; | ||
349 | } | ||
350 | |||
351 | /* Clean up completed IOs and FCS frames */ | ||
352 | fnic_wq_copy_cmpl_handler(fnic, -1); | ||
353 | fnic_wq_cmpl_handler(fnic, -1); | ||
354 | fnic_rq_cmpl_handler(fnic, -1); | ||
355 | |||
356 | /* Clean up the IOs and FCS frames that have not completed */ | ||
357 | for (i = 0; i < fnic->raw_wq_count; i++) | ||
358 | vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf); | ||
359 | for (i = 0; i < fnic->rq_count; i++) | ||
360 | vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); | ||
361 | for (i = 0; i < fnic->wq_copy_count; i++) | ||
362 | vnic_wq_copy_clean(&fnic->wq_copy[i], | ||
363 | fnic_wq_copy_cleanup_handler); | ||
364 | |||
365 | for (i = 0; i < fnic->cq_count; i++) | ||
366 | vnic_cq_clean(&fnic->cq[i]); | ||
367 | for (i = 0; i < fnic->intr_count; i++) | ||
368 | vnic_intr_clean(&fnic->intr[i]); | ||
369 | |||
370 | /* | ||
371 | * Remove cached flogi and flogi resp frames if any | ||
372 | * These frames are not in any queue, and therefore queue | ||
373 | * cleanup does not clean them. So clean them explicitly | ||
374 | */ | ||
375 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
376 | flogi = fnic->flogi; | ||
377 | fnic->flogi = NULL; | ||
378 | flogi_resp = fnic->flogi_resp; | ||
379 | fnic->flogi_resp = NULL; | ||
380 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
381 | |||
382 | if (flogi) | ||
383 | dev_kfree_skb(fp_skb(flogi)); | ||
384 | |||
385 | if (flogi_resp) | ||
386 | dev_kfree_skb(fp_skb(flogi_resp)); | ||
387 | |||
388 | mempool_destroy(fnic->io_req_pool); | ||
389 | for (i = 0; i < FNIC_SGL_NUM_CACHES; i++) | ||
390 | mempool_destroy(fnic->io_sgl_pool[i]); | ||
391 | |||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | static void fnic_iounmap(struct fnic *fnic) | ||
396 | { | ||
397 | if (fnic->bar0.vaddr) | ||
398 | iounmap(fnic->bar0.vaddr); | ||
399 | } | ||
400 | |||
401 | /* | ||
402 | * Allocate element for mempools requiring GFP_DMA flag. | ||
403 | * Otherwise, checks in kmem_flagcheck() hit BUG_ON(). | ||
404 | */ | ||
405 | static void *fnic_alloc_slab_dma(gfp_t gfp_mask, void *pool_data) | ||
406 | { | ||
407 | struct kmem_cache *mem = pool_data; | ||
408 | |||
409 | return kmem_cache_alloc(mem, gfp_mask | GFP_ATOMIC | GFP_DMA); | ||
410 | } | ||
411 | |||
412 | static int __devinit fnic_probe(struct pci_dev *pdev, | ||
413 | const struct pci_device_id *ent) | ||
414 | { | ||
415 | struct Scsi_Host *host; | ||
416 | struct fc_lport *lp; | ||
417 | struct fnic *fnic; | ||
418 | mempool_t *pool; | ||
419 | int err; | ||
420 | int i; | ||
421 | unsigned long flags; | ||
422 | |||
423 | /* | ||
424 | * Allocate SCSI Host and set up association between host, | ||
425 | * local port, and fnic | ||
426 | */ | ||
427 | host = scsi_host_alloc(&fnic_host_template, | ||
428 | sizeof(struct fc_lport) + sizeof(struct fnic)); | ||
429 | if (!host) { | ||
430 | printk(KERN_ERR PFX "Unable to alloc SCSI host\n"); | ||
431 | err = -ENOMEM; | ||
432 | goto err_out; | ||
433 | } | ||
434 | lp = shost_priv(host); | ||
435 | lp->host = host; | ||
436 | fnic = lport_priv(lp); | ||
437 | fnic->lport = lp; | ||
438 | |||
439 | snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, | ||
440 | host->host_no); | ||
441 | |||
442 | host->transportt = fnic_fc_transport; | ||
443 | |||
444 | err = scsi_init_shared_tag_map(host, FNIC_MAX_IO_REQ); | ||
445 | if (err) { | ||
446 | shost_printk(KERN_ERR, fnic->lport->host, | ||
447 | "Unable to alloc shared tag map\n"); | ||
448 | goto err_out_free_hba; | ||
449 | } | ||
450 | |||
451 | /* Setup PCI resources */ | ||
452 | pci_set_drvdata(pdev, fnic); | ||
453 | |||
454 | fnic->pdev = pdev; | ||
455 | |||
456 | err = pci_enable_device(pdev); | ||
457 | if (err) { | ||
458 | shost_printk(KERN_ERR, fnic->lport->host, | ||
459 | "Cannot enable PCI device, aborting.\n"); | ||
460 | goto err_out_free_hba; | ||
461 | } | ||
462 | |||
463 | err = pci_request_regions(pdev, DRV_NAME); | ||
464 | if (err) { | ||
465 | shost_printk(KERN_ERR, fnic->lport->host, | ||
466 | "Cannot enable PCI resources, aborting\n"); | ||
467 | goto err_out_disable_device; | ||
468 | } | ||
469 | |||
470 | pci_set_master(pdev); | ||
471 | |||
472 | /* Query PCI controller on system for DMA addressing | ||
473 | * limitation for the device. Try 40-bit first, and | ||
474 | * fail to 32-bit. | ||
475 | */ | ||
476 | err = pci_set_dma_mask(pdev, DMA_40BIT_MASK); | ||
477 | if (err) { | ||
478 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | ||
479 | if (err) { | ||
480 | shost_printk(KERN_ERR, fnic->lport->host, | ||
481 | "No usable DMA configuration " | ||
482 | "aborting\n"); | ||
483 | goto err_out_release_regions; | ||
484 | } | ||
485 | err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
486 | if (err) { | ||
487 | shost_printk(KERN_ERR, fnic->lport->host, | ||
488 | "Unable to obtain 32-bit DMA " | ||
489 | "for consistent allocations, aborting.\n"); | ||
490 | goto err_out_release_regions; | ||
491 | } | ||
492 | } else { | ||
493 | err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK); | ||
494 | if (err) { | ||
495 | shost_printk(KERN_ERR, fnic->lport->host, | ||
496 | "Unable to obtain 40-bit DMA " | ||
497 | "for consistent allocations, aborting.\n"); | ||
498 | goto err_out_release_regions; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | /* Map vNIC resources from BAR0 */ | ||
503 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { | ||
504 | shost_printk(KERN_ERR, fnic->lport->host, | ||
505 | "BAR0 not memory-map'able, aborting.\n"); | ||
506 | err = -ENODEV; | ||
507 | goto err_out_release_regions; | ||
508 | } | ||
509 | |||
510 | fnic->bar0.vaddr = pci_iomap(pdev, 0, 0); | ||
511 | fnic->bar0.bus_addr = pci_resource_start(pdev, 0); | ||
512 | fnic->bar0.len = pci_resource_len(pdev, 0); | ||
513 | |||
514 | if (!fnic->bar0.vaddr) { | ||
515 | shost_printk(KERN_ERR, fnic->lport->host, | ||
516 | "Cannot memory-map BAR0 res hdr, " | ||
517 | "aborting.\n"); | ||
518 | err = -ENODEV; | ||
519 | goto err_out_release_regions; | ||
520 | } | ||
521 | |||
522 | fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0); | ||
523 | if (!fnic->vdev) { | ||
524 | shost_printk(KERN_ERR, fnic->lport->host, | ||
525 | "vNIC registration failed, " | ||
526 | "aborting.\n"); | ||
527 | err = -ENODEV; | ||
528 | goto err_out_iounmap; | ||
529 | } | ||
530 | |||
531 | err = fnic_dev_wait(fnic->vdev, vnic_dev_open, | ||
532 | vnic_dev_open_done, 0); | ||
533 | if (err) { | ||
534 | shost_printk(KERN_ERR, fnic->lport->host, | ||
535 | "vNIC dev open failed, aborting.\n"); | ||
536 | goto err_out_vnic_unregister; | ||
537 | } | ||
538 | |||
539 | err = vnic_dev_init(fnic->vdev, 0); | ||
540 | if (err) { | ||
541 | shost_printk(KERN_ERR, fnic->lport->host, | ||
542 | "vNIC dev init failed, aborting.\n"); | ||
543 | goto err_out_dev_close; | ||
544 | } | ||
545 | |||
546 | err = vnic_dev_mac_addr(fnic->vdev, fnic->mac_addr); | ||
547 | if (err) { | ||
548 | shost_printk(KERN_ERR, fnic->lport->host, | ||
549 | "vNIC get MAC addr failed \n"); | ||
550 | goto err_out_dev_close; | ||
551 | } | ||
552 | |||
553 | /* Get vNIC configuration */ | ||
554 | err = fnic_get_vnic_config(fnic); | ||
555 | if (err) { | ||
556 | shost_printk(KERN_ERR, fnic->lport->host, | ||
557 | "Get vNIC configuration failed, " | ||
558 | "aborting.\n"); | ||
559 | goto err_out_dev_close; | ||
560 | } | ||
561 | host->max_lun = fnic->config.luns_per_tgt; | ||
562 | host->max_id = FNIC_MAX_FCP_TARGET; | ||
563 | |||
564 | fnic_get_res_counts(fnic); | ||
565 | |||
566 | err = fnic_set_intr_mode(fnic); | ||
567 | if (err) { | ||
568 | shost_printk(KERN_ERR, fnic->lport->host, | ||
569 | "Failed to set intr mode, " | ||
570 | "aborting.\n"); | ||
571 | goto err_out_dev_close; | ||
572 | } | ||
573 | |||
574 | err = fnic_request_intr(fnic); | ||
575 | if (err) { | ||
576 | shost_printk(KERN_ERR, fnic->lport->host, | ||
577 | "Unable to request irq.\n"); | ||
578 | goto err_out_clear_intr; | ||
579 | } | ||
580 | |||
581 | err = fnic_alloc_vnic_resources(fnic); | ||
582 | if (err) { | ||
583 | shost_printk(KERN_ERR, fnic->lport->host, | ||
584 | "Failed to alloc vNIC resources, " | ||
585 | "aborting.\n"); | ||
586 | goto err_out_free_intr; | ||
587 | } | ||
588 | |||
589 | |||
590 | /* initialize all fnic locks */ | ||
591 | spin_lock_init(&fnic->fnic_lock); | ||
592 | |||
593 | for (i = 0; i < FNIC_WQ_MAX; i++) | ||
594 | spin_lock_init(&fnic->wq_lock[i]); | ||
595 | |||
596 | for (i = 0; i < FNIC_WQ_COPY_MAX; i++) { | ||
597 | spin_lock_init(&fnic->wq_copy_lock[i]); | ||
598 | fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK; | ||
599 | fnic->fw_ack_recd[i] = 0; | ||
600 | fnic->fw_ack_index[i] = -1; | ||
601 | } | ||
602 | |||
603 | for (i = 0; i < FNIC_IO_LOCKS; i++) | ||
604 | spin_lock_init(&fnic->io_req_lock[i]); | ||
605 | |||
606 | fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); | ||
607 | if (!fnic->io_req_pool) | ||
608 | goto err_out_free_resources; | ||
609 | |||
610 | pool = mempool_create(2, fnic_alloc_slab_dma, mempool_free_slab, | ||
611 | fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]); | ||
612 | if (!pool) | ||
613 | goto err_out_free_ioreq_pool; | ||
614 | fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool; | ||
615 | |||
616 | pool = mempool_create(2, fnic_alloc_slab_dma, mempool_free_slab, | ||
617 | fnic_sgl_cache[FNIC_SGL_CACHE_MAX]); | ||
618 | if (!pool) | ||
619 | goto err_out_free_dflt_pool; | ||
620 | fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool; | ||
621 | |||
622 | /* setup vlan config, hw inserts vlan header */ | ||
623 | fnic->vlan_hw_insert = 1; | ||
624 | fnic->vlan_id = 0; | ||
625 | |||
626 | fnic->flogi_oxid = FC_XID_UNKNOWN; | ||
627 | fnic->flogi = NULL; | ||
628 | fnic->flogi_resp = NULL; | ||
629 | fnic->state = FNIC_IN_FC_MODE; | ||
630 | |||
631 | /* Enable hardware stripping of vlan header on ingress */ | ||
632 | fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1); | ||
633 | |||
634 | /* Setup notification buffer area */ | ||
635 | err = fnic_notify_set(fnic); | ||
636 | if (err) { | ||
637 | shost_printk(KERN_ERR, fnic->lport->host, | ||
638 | "Failed to alloc notify buffer, aborting.\n"); | ||
639 | goto err_out_free_max_pool; | ||
640 | } | ||
641 | |||
642 | /* Setup notify timer when using MSI interrupts */ | ||
643 | if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) | ||
644 | setup_timer(&fnic->notify_timer, | ||
645 | fnic_notify_timer, (unsigned long)fnic); | ||
646 | |||
647 | /* allocate RQ buffers and post them to RQ*/ | ||
648 | for (i = 0; i < fnic->rq_count; i++) { | ||
649 | err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); | ||
650 | if (err) { | ||
651 | shost_printk(KERN_ERR, fnic->lport->host, | ||
652 | "fnic_alloc_rq_frame can't alloc " | ||
653 | "frame\n"); | ||
654 | goto err_out_free_rq_buf; | ||
655 | } | ||
656 | } | ||
657 | |||
658 | /* | ||
659 | * Initialization done with PCI system, hardware, firmware. | ||
660 | * Add host to SCSI | ||
661 | */ | ||
662 | err = scsi_add_host(lp->host, &pdev->dev); | ||
663 | if (err) { | ||
664 | shost_printk(KERN_ERR, fnic->lport->host, | ||
665 | "fnic: scsi_add_host failed...exiting\n"); | ||
666 | goto err_out_free_rq_buf; | ||
667 | } | ||
668 | |||
669 | /* Start local port initiatialization */ | ||
670 | |||
671 | lp->link_up = 0; | ||
672 | lp->tt = fnic_transport_template; | ||
673 | |||
674 | lp->emp = fc_exch_mgr_alloc(lp, FC_CLASS_3, | ||
675 | FCPIO_HOST_EXCH_RANGE_START, | ||
676 | FCPIO_HOST_EXCH_RANGE_END); | ||
677 | if (!lp->emp) { | ||
678 | err = -ENOMEM; | ||
679 | goto err_out_remove_scsi_host; | ||
680 | } | ||
681 | |||
682 | lp->max_retry_count = fnic->config.flogi_retries; | ||
683 | lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS | | ||
684 | FCP_SPPF_CONF_COMPL); | ||
685 | if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) | ||
686 | lp->service_params |= FCP_SPPF_RETRY; | ||
687 | |||
688 | lp->boot_time = jiffies; | ||
689 | lp->e_d_tov = fnic->config.ed_tov; | ||
690 | lp->r_a_tov = fnic->config.ra_tov; | ||
691 | lp->link_supported_speeds = FC_PORTSPEED_10GBIT; | ||
692 | fc_set_wwnn(lp, fnic->config.node_wwn); | ||
693 | fc_set_wwpn(lp, fnic->config.port_wwn); | ||
694 | |||
695 | fc_exch_init(lp); | ||
696 | fc_lport_init(lp); | ||
697 | fc_elsct_init(lp); | ||
698 | fc_rport_init(lp); | ||
699 | fc_disc_init(lp); | ||
700 | |||
701 | fc_lport_config(lp); | ||
702 | |||
703 | if (fc_set_mfs(lp, fnic->config.maxdatafieldsize + | ||
704 | sizeof(struct fc_frame_header))) { | ||
705 | err = -EINVAL; | ||
706 | goto err_out_free_exch_mgr; | ||
707 | } | ||
708 | fc_host_maxframe_size(lp->host) = lp->mfs; | ||
709 | |||
710 | sprintf(fc_host_symbolic_name(lp->host), | ||
711 | DRV_NAME " v" DRV_VERSION " over %s", fnic->name); | ||
712 | |||
713 | spin_lock_irqsave(&fnic_list_lock, flags); | ||
714 | list_add_tail(&fnic->list, &fnic_list); | ||
715 | spin_unlock_irqrestore(&fnic_list_lock, flags); | ||
716 | |||
717 | INIT_WORK(&fnic->link_work, fnic_handle_link); | ||
718 | INIT_WORK(&fnic->frame_work, fnic_handle_frame); | ||
719 | skb_queue_head_init(&fnic->frame_queue); | ||
720 | |||
721 | /* Enable all queues */ | ||
722 | for (i = 0; i < fnic->raw_wq_count; i++) | ||
723 | vnic_wq_enable(&fnic->wq[i]); | ||
724 | for (i = 0; i < fnic->rq_count; i++) | ||
725 | vnic_rq_enable(&fnic->rq[i]); | ||
726 | for (i = 0; i < fnic->wq_copy_count; i++) | ||
727 | vnic_wq_copy_enable(&fnic->wq_copy[i]); | ||
728 | |||
729 | fc_fabric_login(lp); | ||
730 | |||
731 | vnic_dev_enable(fnic->vdev); | ||
732 | for (i = 0; i < fnic->intr_count; i++) | ||
733 | vnic_intr_unmask(&fnic->intr[i]); | ||
734 | |||
735 | fnic_notify_timer_start(fnic); | ||
736 | |||
737 | return 0; | ||
738 | |||
739 | err_out_free_exch_mgr: | ||
740 | fc_exch_mgr_free(lp->emp); | ||
741 | err_out_remove_scsi_host: | ||
742 | fc_remove_host(fnic->lport->host); | ||
743 | scsi_remove_host(fnic->lport->host); | ||
744 | err_out_free_rq_buf: | ||
745 | for (i = 0; i < fnic->rq_count; i++) | ||
746 | vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); | ||
747 | vnic_dev_notify_unset(fnic->vdev); | ||
748 | err_out_free_max_pool: | ||
749 | mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]); | ||
750 | err_out_free_dflt_pool: | ||
751 | mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]); | ||
752 | err_out_free_ioreq_pool: | ||
753 | mempool_destroy(fnic->io_req_pool); | ||
754 | err_out_free_resources: | ||
755 | fnic_free_vnic_resources(fnic); | ||
756 | err_out_free_intr: | ||
757 | fnic_free_intr(fnic); | ||
758 | err_out_clear_intr: | ||
759 | fnic_clear_intr_mode(fnic); | ||
760 | err_out_dev_close: | ||
761 | vnic_dev_close(fnic->vdev); | ||
762 | err_out_vnic_unregister: | ||
763 | vnic_dev_unregister(fnic->vdev); | ||
764 | err_out_iounmap: | ||
765 | fnic_iounmap(fnic); | ||
766 | err_out_release_regions: | ||
767 | pci_release_regions(pdev); | ||
768 | err_out_disable_device: | ||
769 | pci_disable_device(pdev); | ||
770 | err_out_free_hba: | ||
771 | scsi_host_put(lp->host); | ||
772 | err_out: | ||
773 | return err; | ||
774 | } | ||
775 | |||
776 | static void __devexit fnic_remove(struct pci_dev *pdev) | ||
777 | { | ||
778 | struct fnic *fnic = pci_get_drvdata(pdev); | ||
779 | unsigned long flags; | ||
780 | |||
781 | /* | ||
782 | * Mark state so that the workqueue thread stops forwarding | ||
783 | * received frames and link events to the local port. ISR and | ||
784 | * other threads that can queue work items will also stop | ||
785 | * creating work items on the fnic workqueue | ||
786 | */ | ||
787 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
788 | fnic->stop_rx_link_events = 1; | ||
789 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
790 | |||
791 | if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) | ||
792 | del_timer_sync(&fnic->notify_timer); | ||
793 | |||
794 | /* | ||
795 | * Flush the fnic event queue. After this call, there should | ||
796 | * be no event queued for this fnic device in the workqueue | ||
797 | */ | ||
798 | flush_workqueue(fnic_event_queue); | ||
799 | skb_queue_purge(&fnic->frame_queue); | ||
800 | |||
801 | /* | ||
802 | * Log off the fabric. This stops all remote ports, dns port, | ||
803 | * logs off the fabric. This flushes all rport, disc, lport work | ||
804 | * before returning | ||
805 | */ | ||
806 | fc_fabric_logoff(fnic->lport); | ||
807 | |||
808 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
809 | fnic->in_remove = 1; | ||
810 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
811 | |||
812 | fc_lport_destroy(fnic->lport); | ||
813 | |||
814 | /* | ||
815 | * This stops the fnic device, masks all interrupts. Completed | ||
816 | * CQ entries are drained. Posted WQ/RQ/Copy-WQ entries are | ||
817 | * cleaned up | ||
818 | */ | ||
819 | fnic_cleanup(fnic); | ||
820 | |||
821 | BUG_ON(!skb_queue_empty(&fnic->frame_queue)); | ||
822 | |||
823 | spin_lock_irqsave(&fnic_list_lock, flags); | ||
824 | list_del(&fnic->list); | ||
825 | spin_unlock_irqrestore(&fnic_list_lock, flags); | ||
826 | |||
827 | fc_remove_host(fnic->lport->host); | ||
828 | scsi_remove_host(fnic->lport->host); | ||
829 | fc_exch_mgr_free(fnic->lport->emp); | ||
830 | vnic_dev_notify_unset(fnic->vdev); | ||
831 | fnic_free_vnic_resources(fnic); | ||
832 | fnic_free_intr(fnic); | ||
833 | fnic_clear_intr_mode(fnic); | ||
834 | vnic_dev_close(fnic->vdev); | ||
835 | vnic_dev_unregister(fnic->vdev); | ||
836 | fnic_iounmap(fnic); | ||
837 | pci_release_regions(pdev); | ||
838 | pci_disable_device(pdev); | ||
839 | pci_set_drvdata(pdev, NULL); | ||
840 | scsi_host_put(fnic->lport->host); | ||
841 | } | ||
842 | |||
843 | static struct pci_driver fnic_driver = { | ||
844 | .name = DRV_NAME, | ||
845 | .id_table = fnic_id_table, | ||
846 | .probe = fnic_probe, | ||
847 | .remove = __devexit_p(fnic_remove), | ||
848 | }; | ||
849 | |||
850 | static int __init fnic_init_module(void) | ||
851 | { | ||
852 | size_t len; | ||
853 | int err = 0; | ||
854 | |||
855 | printk(KERN_INFO PFX "%s, ver %s\n", DRV_DESCRIPTION, DRV_VERSION); | ||
856 | |||
857 | /* Create a cache for allocation of default size sgls */ | ||
858 | len = sizeof(struct fnic_dflt_sgl_list); | ||
859 | fnic_sgl_cache[FNIC_SGL_CACHE_DFLT] = kmem_cache_create | ||
860 | ("fnic_sgl_dflt", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN, | ||
861 | SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA, | ||
862 | NULL); | ||
863 | if (!fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]) { | ||
864 | printk(KERN_ERR PFX "failed to create fnic dflt sgl slab\n"); | ||
865 | err = -ENOMEM; | ||
866 | goto err_create_fnic_sgl_slab_dflt; | ||
867 | } | ||
868 | |||
869 | /* Create a cache for allocation of max size sgls*/ | ||
870 | len = sizeof(struct fnic_sgl_list); | ||
871 | fnic_sgl_cache[FNIC_SGL_CACHE_MAX] = kmem_cache_create | ||
872 | ("fnic_sgl_max", len + FNIC_SG_DESC_ALIGN, FNIC_SG_DESC_ALIGN, | ||
873 | SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA, | ||
874 | NULL); | ||
875 | if (!fnic_sgl_cache[FNIC_SGL_CACHE_MAX]) { | ||
876 | printk(KERN_ERR PFX "failed to create fnic max sgl slab\n"); | ||
877 | err = -ENOMEM; | ||
878 | goto err_create_fnic_sgl_slab_max; | ||
879 | } | ||
880 | |||
881 | /* Create a cache of io_req structs for use via mempool */ | ||
882 | fnic_io_req_cache = kmem_cache_create("fnic_io_req", | ||
883 | sizeof(struct fnic_io_req), | ||
884 | 0, SLAB_HWCACHE_ALIGN, NULL); | ||
885 | if (!fnic_io_req_cache) { | ||
886 | printk(KERN_ERR PFX "failed to create fnic io_req slab\n"); | ||
887 | err = -ENOMEM; | ||
888 | goto err_create_fnic_ioreq_slab; | ||
889 | } | ||
890 | |||
891 | fnic_event_queue = create_singlethread_workqueue("fnic_event_wq"); | ||
892 | if (!fnic_event_queue) { | ||
893 | printk(KERN_ERR PFX "fnic work queue create failed\n"); | ||
894 | err = -ENOMEM; | ||
895 | goto err_create_fnic_workq; | ||
896 | } | ||
897 | |||
898 | spin_lock_init(&fnic_list_lock); | ||
899 | INIT_LIST_HEAD(&fnic_list); | ||
900 | |||
901 | fnic_fc_transport = fc_attach_transport(&fnic_fc_functions); | ||
902 | if (!fnic_fc_transport) { | ||
903 | printk(KERN_ERR PFX "fc_attach_transport error\n"); | ||
904 | err = -ENOMEM; | ||
905 | goto err_fc_transport; | ||
906 | } | ||
907 | |||
908 | /* register the driver with PCI system */ | ||
909 | err = pci_register_driver(&fnic_driver); | ||
910 | if (err < 0) { | ||
911 | printk(KERN_ERR PFX "pci register error\n"); | ||
912 | goto err_pci_register; | ||
913 | } | ||
914 | return err; | ||
915 | |||
916 | err_pci_register: | ||
917 | fc_release_transport(fnic_fc_transport); | ||
918 | err_fc_transport: | ||
919 | destroy_workqueue(fnic_event_queue); | ||
920 | err_create_fnic_workq: | ||
921 | kmem_cache_destroy(fnic_io_req_cache); | ||
922 | err_create_fnic_ioreq_slab: | ||
923 | kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]); | ||
924 | err_create_fnic_sgl_slab_max: | ||
925 | kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]); | ||
926 | err_create_fnic_sgl_slab_dflt: | ||
927 | return err; | ||
928 | } | ||
929 | |||
930 | static void __exit fnic_cleanup_module(void) | ||
931 | { | ||
932 | pci_unregister_driver(&fnic_driver); | ||
933 | destroy_workqueue(fnic_event_queue); | ||
934 | kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]); | ||
935 | kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]); | ||
936 | kmem_cache_destroy(fnic_io_req_cache); | ||
937 | fc_release_transport(fnic_fc_transport); | ||
938 | } | ||
939 | |||
940 | module_init(fnic_init_module); | ||
941 | module_exit(fnic_cleanup_module); | ||
942 | |||
diff --git a/drivers/scsi/fnic/fnic_res.c b/drivers/scsi/fnic/fnic_res.c new file mode 100644 index 000000000000..7ba61ec715d2 --- /dev/null +++ b/drivers/scsi/fnic/fnic_res.c | |||
@@ -0,0 +1,444 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/types.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include "wq_enet_desc.h" | ||
22 | #include "rq_enet_desc.h" | ||
23 | #include "cq_enet_desc.h" | ||
24 | #include "vnic_resource.h" | ||
25 | #include "vnic_dev.h" | ||
26 | #include "vnic_wq.h" | ||
27 | #include "vnic_rq.h" | ||
28 | #include "vnic_cq.h" | ||
29 | #include "vnic_intr.h" | ||
30 | #include "vnic_stats.h" | ||
31 | #include "vnic_nic.h" | ||
32 | #include "fnic.h" | ||
33 | |||
34 | int fnic_get_vnic_config(struct fnic *fnic) | ||
35 | { | ||
36 | struct vnic_fc_config *c = &fnic->config; | ||
37 | int err; | ||
38 | |||
39 | #define GET_CONFIG(m) \ | ||
40 | do { \ | ||
41 | err = vnic_dev_spec(fnic->vdev, \ | ||
42 | offsetof(struct vnic_fc_config, m), \ | ||
43 | sizeof(c->m), &c->m); \ | ||
44 | if (err) { \ | ||
45 | shost_printk(KERN_ERR, fnic->lport->host, \ | ||
46 | "Error getting %s, %d\n", #m, \ | ||
47 | err); \ | ||
48 | return err; \ | ||
49 | } \ | ||
50 | } while (0); | ||
51 | |||
52 | GET_CONFIG(node_wwn); | ||
53 | GET_CONFIG(port_wwn); | ||
54 | GET_CONFIG(wq_enet_desc_count); | ||
55 | GET_CONFIG(wq_copy_desc_count); | ||
56 | GET_CONFIG(rq_desc_count); | ||
57 | GET_CONFIG(maxdatafieldsize); | ||
58 | GET_CONFIG(ed_tov); | ||
59 | GET_CONFIG(ra_tov); | ||
60 | GET_CONFIG(intr_timer); | ||
61 | GET_CONFIG(intr_timer_type); | ||
62 | GET_CONFIG(flags); | ||
63 | GET_CONFIG(flogi_retries); | ||
64 | GET_CONFIG(flogi_timeout); | ||
65 | GET_CONFIG(plogi_retries); | ||
66 | GET_CONFIG(plogi_timeout); | ||
67 | GET_CONFIG(io_throttle_count); | ||
68 | GET_CONFIG(link_down_timeout); | ||
69 | GET_CONFIG(port_down_timeout); | ||
70 | GET_CONFIG(port_down_io_retries); | ||
71 | GET_CONFIG(luns_per_tgt); | ||
72 | |||
73 | c->wq_enet_desc_count = | ||
74 | min_t(u32, VNIC_FNIC_WQ_DESCS_MAX, | ||
75 | max_t(u32, VNIC_FNIC_WQ_DESCS_MIN, | ||
76 | c->wq_enet_desc_count)); | ||
77 | c->wq_enet_desc_count = ALIGN(c->wq_enet_desc_count, 16); | ||
78 | |||
79 | c->wq_copy_desc_count = | ||
80 | min_t(u32, VNIC_FNIC_WQ_COPY_DESCS_MAX, | ||
81 | max_t(u32, VNIC_FNIC_WQ_COPY_DESCS_MIN, | ||
82 | c->wq_copy_desc_count)); | ||
83 | c->wq_copy_desc_count = ALIGN(c->wq_copy_desc_count, 16); | ||
84 | |||
85 | c->rq_desc_count = | ||
86 | min_t(u32, VNIC_FNIC_RQ_DESCS_MAX, | ||
87 | max_t(u32, VNIC_FNIC_RQ_DESCS_MIN, | ||
88 | c->rq_desc_count)); | ||
89 | c->rq_desc_count = ALIGN(c->rq_desc_count, 16); | ||
90 | |||
91 | c->maxdatafieldsize = | ||
92 | min_t(u16, VNIC_FNIC_MAXDATAFIELDSIZE_MAX, | ||
93 | max_t(u16, VNIC_FNIC_MAXDATAFIELDSIZE_MIN, | ||
94 | c->maxdatafieldsize)); | ||
95 | c->ed_tov = | ||
96 | min_t(u32, VNIC_FNIC_EDTOV_MAX, | ||
97 | max_t(u32, VNIC_FNIC_EDTOV_MIN, | ||
98 | c->ed_tov)); | ||
99 | |||
100 | c->ra_tov = | ||
101 | min_t(u32, VNIC_FNIC_RATOV_MAX, | ||
102 | max_t(u32, VNIC_FNIC_RATOV_MIN, | ||
103 | c->ra_tov)); | ||
104 | |||
105 | c->flogi_retries = | ||
106 | min_t(u32, VNIC_FNIC_FLOGI_RETRIES_MAX, c->flogi_retries); | ||
107 | |||
108 | c->flogi_timeout = | ||
109 | min_t(u32, VNIC_FNIC_FLOGI_TIMEOUT_MAX, | ||
110 | max_t(u32, VNIC_FNIC_FLOGI_TIMEOUT_MIN, | ||
111 | c->flogi_timeout)); | ||
112 | |||
113 | c->plogi_retries = | ||
114 | min_t(u32, VNIC_FNIC_PLOGI_RETRIES_MAX, c->plogi_retries); | ||
115 | |||
116 | c->plogi_timeout = | ||
117 | min_t(u32, VNIC_FNIC_PLOGI_TIMEOUT_MAX, | ||
118 | max_t(u32, VNIC_FNIC_PLOGI_TIMEOUT_MIN, | ||
119 | c->plogi_timeout)); | ||
120 | |||
121 | c->io_throttle_count = | ||
122 | min_t(u32, VNIC_FNIC_IO_THROTTLE_COUNT_MAX, | ||
123 | max_t(u32, VNIC_FNIC_IO_THROTTLE_COUNT_MIN, | ||
124 | c->io_throttle_count)); | ||
125 | |||
126 | c->link_down_timeout = | ||
127 | min_t(u32, VNIC_FNIC_LINK_DOWN_TIMEOUT_MAX, | ||
128 | c->link_down_timeout); | ||
129 | |||
130 | c->port_down_timeout = | ||
131 | min_t(u32, VNIC_FNIC_PORT_DOWN_TIMEOUT_MAX, | ||
132 | c->port_down_timeout); | ||
133 | |||
134 | c->port_down_io_retries = | ||
135 | min_t(u32, VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX, | ||
136 | c->port_down_io_retries); | ||
137 | |||
138 | c->luns_per_tgt = | ||
139 | min_t(u32, VNIC_FNIC_LUNS_PER_TARGET_MAX, | ||
140 | max_t(u32, VNIC_FNIC_LUNS_PER_TARGET_MIN, | ||
141 | c->luns_per_tgt)); | ||
142 | |||
143 | c->intr_timer = min_t(u16, VNIC_INTR_TIMER_MAX, c->intr_timer); | ||
144 | c->intr_timer_type = c->intr_timer_type; | ||
145 | |||
146 | shost_printk(KERN_INFO, fnic->lport->host, | ||
147 | "vNIC MAC addr %02x:%02x:%02x:%02x:%02x:%02x " | ||
148 | "wq/wq_copy/rq %d/%d/%d\n", | ||
149 | fnic->mac_addr[0], fnic->mac_addr[1], fnic->mac_addr[2], | ||
150 | fnic->mac_addr[3], fnic->mac_addr[4], fnic->mac_addr[5], | ||
151 | c->wq_enet_desc_count, c->wq_copy_desc_count, | ||
152 | c->rq_desc_count); | ||
153 | shost_printk(KERN_INFO, fnic->lport->host, | ||
154 | "vNIC node wwn %llx port wwn %llx\n", | ||
155 | c->node_wwn, c->port_wwn); | ||
156 | shost_printk(KERN_INFO, fnic->lport->host, | ||
157 | "vNIC ed_tov %d ra_tov %d\n", | ||
158 | c->ed_tov, c->ra_tov); | ||
159 | shost_printk(KERN_INFO, fnic->lport->host, | ||
160 | "vNIC mtu %d intr timer %d\n", | ||
161 | c->maxdatafieldsize, c->intr_timer); | ||
162 | shost_printk(KERN_INFO, fnic->lport->host, | ||
163 | "vNIC flags 0x%x luns per tgt %d\n", | ||
164 | c->flags, c->luns_per_tgt); | ||
165 | shost_printk(KERN_INFO, fnic->lport->host, | ||
166 | "vNIC flogi_retries %d flogi timeout %d\n", | ||
167 | c->flogi_retries, c->flogi_timeout); | ||
168 | shost_printk(KERN_INFO, fnic->lport->host, | ||
169 | "vNIC plogi retries %d plogi timeout %d\n", | ||
170 | c->plogi_retries, c->plogi_timeout); | ||
171 | shost_printk(KERN_INFO, fnic->lport->host, | ||
172 | "vNIC io throttle count %d link dn timeout %d\n", | ||
173 | c->io_throttle_count, c->link_down_timeout); | ||
174 | shost_printk(KERN_INFO, fnic->lport->host, | ||
175 | "vNIC port dn io retries %d port dn timeout %d\n", | ||
176 | c->port_down_io_retries, c->port_down_timeout); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | int fnic_set_nic_config(struct fnic *fnic, u8 rss_default_cpu, | ||
182 | u8 rss_hash_type, | ||
183 | u8 rss_hash_bits, u8 rss_base_cpu, u8 rss_enable, | ||
184 | u8 tso_ipid_split_en, u8 ig_vlan_strip_en) | ||
185 | { | ||
186 | u64 a0, a1; | ||
187 | u32 nic_cfg; | ||
188 | int wait = 1000; | ||
189 | |||
190 | vnic_set_nic_cfg(&nic_cfg, rss_default_cpu, | ||
191 | rss_hash_type, rss_hash_bits, rss_base_cpu, | ||
192 | rss_enable, tso_ipid_split_en, ig_vlan_strip_en); | ||
193 | |||
194 | a0 = nic_cfg; | ||
195 | a1 = 0; | ||
196 | |||
197 | return vnic_dev_cmd(fnic->vdev, CMD_NIC_CFG, &a0, &a1, wait); | ||
198 | } | ||
199 | |||
200 | void fnic_get_res_counts(struct fnic *fnic) | ||
201 | { | ||
202 | fnic->wq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_WQ); | ||
203 | fnic->raw_wq_count = fnic->wq_count - 1; | ||
204 | fnic->wq_copy_count = fnic->wq_count - fnic->raw_wq_count; | ||
205 | fnic->rq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_RQ); | ||
206 | fnic->cq_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_CQ); | ||
207 | fnic->intr_count = vnic_dev_get_res_count(fnic->vdev, | ||
208 | RES_TYPE_INTR_CTRL); | ||
209 | } | ||
210 | |||
211 | void fnic_free_vnic_resources(struct fnic *fnic) | ||
212 | { | ||
213 | unsigned int i; | ||
214 | |||
215 | for (i = 0; i < fnic->raw_wq_count; i++) | ||
216 | vnic_wq_free(&fnic->wq[i]); | ||
217 | |||
218 | for (i = 0; i < fnic->wq_copy_count; i++) | ||
219 | vnic_wq_copy_free(&fnic->wq_copy[i]); | ||
220 | |||
221 | for (i = 0; i < fnic->rq_count; i++) | ||
222 | vnic_rq_free(&fnic->rq[i]); | ||
223 | |||
224 | for (i = 0; i < fnic->cq_count; i++) | ||
225 | vnic_cq_free(&fnic->cq[i]); | ||
226 | |||
227 | for (i = 0; i < fnic->intr_count; i++) | ||
228 | vnic_intr_free(&fnic->intr[i]); | ||
229 | } | ||
230 | |||
231 | int fnic_alloc_vnic_resources(struct fnic *fnic) | ||
232 | { | ||
233 | enum vnic_dev_intr_mode intr_mode; | ||
234 | unsigned int mask_on_assertion; | ||
235 | unsigned int interrupt_offset; | ||
236 | unsigned int error_interrupt_enable; | ||
237 | unsigned int error_interrupt_offset; | ||
238 | unsigned int i, cq_index; | ||
239 | unsigned int wq_copy_cq_desc_count; | ||
240 | int err; | ||
241 | |||
242 | intr_mode = vnic_dev_get_intr_mode(fnic->vdev); | ||
243 | |||
244 | shost_printk(KERN_INFO, fnic->lport->host, "vNIC interrupt mode: %s\n", | ||
245 | intr_mode == VNIC_DEV_INTR_MODE_INTX ? "legacy PCI INTx" : | ||
246 | intr_mode == VNIC_DEV_INTR_MODE_MSI ? "MSI" : | ||
247 | intr_mode == VNIC_DEV_INTR_MODE_MSIX ? | ||
248 | "MSI-X" : "unknown"); | ||
249 | |||
250 | shost_printk(KERN_INFO, fnic->lport->host, "vNIC resources avail: " | ||
251 | "wq %d cp_wq %d raw_wq %d rq %d cq %d intr %d\n", | ||
252 | fnic->wq_count, fnic->wq_copy_count, fnic->raw_wq_count, | ||
253 | fnic->rq_count, fnic->cq_count, fnic->intr_count); | ||
254 | |||
255 | /* Allocate Raw WQ used for FCS frames */ | ||
256 | for (i = 0; i < fnic->raw_wq_count; i++) { | ||
257 | err = vnic_wq_alloc(fnic->vdev, &fnic->wq[i], i, | ||
258 | fnic->config.wq_enet_desc_count, | ||
259 | sizeof(struct wq_enet_desc)); | ||
260 | if (err) | ||
261 | goto err_out_cleanup; | ||
262 | } | ||
263 | |||
264 | /* Allocate Copy WQs used for SCSI IOs */ | ||
265 | for (i = 0; i < fnic->wq_copy_count; i++) { | ||
266 | err = vnic_wq_copy_alloc(fnic->vdev, &fnic->wq_copy[i], | ||
267 | (fnic->raw_wq_count + i), | ||
268 | fnic->config.wq_copy_desc_count, | ||
269 | sizeof(struct fcpio_host_req)); | ||
270 | if (err) | ||
271 | goto err_out_cleanup; | ||
272 | } | ||
273 | |||
274 | /* RQ for receiving FCS frames */ | ||
275 | for (i = 0; i < fnic->rq_count; i++) { | ||
276 | err = vnic_rq_alloc(fnic->vdev, &fnic->rq[i], i, | ||
277 | fnic->config.rq_desc_count, | ||
278 | sizeof(struct rq_enet_desc)); | ||
279 | if (err) | ||
280 | goto err_out_cleanup; | ||
281 | } | ||
282 | |||
283 | /* CQ for each RQ */ | ||
284 | for (i = 0; i < fnic->rq_count; i++) { | ||
285 | cq_index = i; | ||
286 | err = vnic_cq_alloc(fnic->vdev, | ||
287 | &fnic->cq[cq_index], cq_index, | ||
288 | fnic->config.rq_desc_count, | ||
289 | sizeof(struct cq_enet_rq_desc)); | ||
290 | if (err) | ||
291 | goto err_out_cleanup; | ||
292 | } | ||
293 | |||
294 | /* CQ for each WQ */ | ||
295 | for (i = 0; i < fnic->raw_wq_count; i++) { | ||
296 | cq_index = fnic->rq_count + i; | ||
297 | err = vnic_cq_alloc(fnic->vdev, &fnic->cq[cq_index], cq_index, | ||
298 | fnic->config.wq_enet_desc_count, | ||
299 | sizeof(struct cq_enet_wq_desc)); | ||
300 | if (err) | ||
301 | goto err_out_cleanup; | ||
302 | } | ||
303 | |||
304 | /* CQ for each COPY WQ */ | ||
305 | wq_copy_cq_desc_count = (fnic->config.wq_copy_desc_count * 3); | ||
306 | for (i = 0; i < fnic->wq_copy_count; i++) { | ||
307 | cq_index = fnic->raw_wq_count + fnic->rq_count + i; | ||
308 | err = vnic_cq_alloc(fnic->vdev, &fnic->cq[cq_index], | ||
309 | cq_index, | ||
310 | wq_copy_cq_desc_count, | ||
311 | sizeof(struct fcpio_fw_req)); | ||
312 | if (err) | ||
313 | goto err_out_cleanup; | ||
314 | } | ||
315 | |||
316 | for (i = 0; i < fnic->intr_count; i++) { | ||
317 | err = vnic_intr_alloc(fnic->vdev, &fnic->intr[i], i); | ||
318 | if (err) | ||
319 | goto err_out_cleanup; | ||
320 | } | ||
321 | |||
322 | fnic->legacy_pba = vnic_dev_get_res(fnic->vdev, | ||
323 | RES_TYPE_INTR_PBA_LEGACY, 0); | ||
324 | |||
325 | if (!fnic->legacy_pba && intr_mode == VNIC_DEV_INTR_MODE_INTX) { | ||
326 | shost_printk(KERN_ERR, fnic->lport->host, | ||
327 | "Failed to hook legacy pba resource\n"); | ||
328 | err = -ENODEV; | ||
329 | goto err_out_cleanup; | ||
330 | } | ||
331 | |||
332 | /* | ||
333 | * Init RQ/WQ resources. | ||
334 | * | ||
335 | * RQ[0 to n-1] point to CQ[0 to n-1] | ||
336 | * WQ[0 to m-1] point to CQ[n to n+m-1] | ||
337 | * WQ_COPY[0 to k-1] points to CQ[n+m to n+m+k-1] | ||
338 | * | ||
339 | * Note for copy wq we always initialize with cq_index = 0 | ||
340 | * | ||
341 | * Error interrupt is not enabled for MSI. | ||
342 | */ | ||
343 | |||
344 | switch (intr_mode) { | ||
345 | case VNIC_DEV_INTR_MODE_INTX: | ||
346 | case VNIC_DEV_INTR_MODE_MSIX: | ||
347 | error_interrupt_enable = 1; | ||
348 | error_interrupt_offset = fnic->err_intr_offset; | ||
349 | break; | ||
350 | default: | ||
351 | error_interrupt_enable = 0; | ||
352 | error_interrupt_offset = 0; | ||
353 | break; | ||
354 | } | ||
355 | |||
356 | for (i = 0; i < fnic->rq_count; i++) { | ||
357 | cq_index = i; | ||
358 | vnic_rq_init(&fnic->rq[i], | ||
359 | cq_index, | ||
360 | error_interrupt_enable, | ||
361 | error_interrupt_offset); | ||
362 | } | ||
363 | |||
364 | for (i = 0; i < fnic->raw_wq_count; i++) { | ||
365 | cq_index = i + fnic->rq_count; | ||
366 | vnic_wq_init(&fnic->wq[i], | ||
367 | cq_index, | ||
368 | error_interrupt_enable, | ||
369 | error_interrupt_offset); | ||
370 | } | ||
371 | |||
372 | for (i = 0; i < fnic->wq_copy_count; i++) { | ||
373 | vnic_wq_copy_init(&fnic->wq_copy[i], | ||
374 | 0 /* cq_index 0 - always */, | ||
375 | error_interrupt_enable, | ||
376 | error_interrupt_offset); | ||
377 | } | ||
378 | |||
379 | for (i = 0; i < fnic->cq_count; i++) { | ||
380 | |||
381 | switch (intr_mode) { | ||
382 | case VNIC_DEV_INTR_MODE_MSIX: | ||
383 | interrupt_offset = i; | ||
384 | break; | ||
385 | default: | ||
386 | interrupt_offset = 0; | ||
387 | break; | ||
388 | } | ||
389 | |||
390 | vnic_cq_init(&fnic->cq[i], | ||
391 | 0 /* flow_control_enable */, | ||
392 | 1 /* color_enable */, | ||
393 | 0 /* cq_head */, | ||
394 | 0 /* cq_tail */, | ||
395 | 1 /* cq_tail_color */, | ||
396 | 1 /* interrupt_enable */, | ||
397 | 1 /* cq_entry_enable */, | ||
398 | 0 /* cq_message_enable */, | ||
399 | interrupt_offset, | ||
400 | 0 /* cq_message_addr */); | ||
401 | } | ||
402 | |||
403 | /* | ||
404 | * Init INTR resources | ||
405 | * | ||
406 | * mask_on_assertion is not used for INTx due to the level- | ||
407 | * triggered nature of INTx | ||
408 | */ | ||
409 | |||
410 | switch (intr_mode) { | ||
411 | case VNIC_DEV_INTR_MODE_MSI: | ||
412 | case VNIC_DEV_INTR_MODE_MSIX: | ||
413 | mask_on_assertion = 1; | ||
414 | break; | ||
415 | default: | ||
416 | mask_on_assertion = 0; | ||
417 | break; | ||
418 | } | ||
419 | |||
420 | for (i = 0; i < fnic->intr_count; i++) { | ||
421 | vnic_intr_init(&fnic->intr[i], | ||
422 | fnic->config.intr_timer, | ||
423 | fnic->config.intr_timer_type, | ||
424 | mask_on_assertion); | ||
425 | } | ||
426 | |||
427 | /* init the stats memory by making the first call here */ | ||
428 | err = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); | ||
429 | if (err) { | ||
430 | shost_printk(KERN_ERR, fnic->lport->host, | ||
431 | "vnic_dev_stats_dump failed - x%x\n", err); | ||
432 | goto err_out_cleanup; | ||
433 | } | ||
434 | |||
435 | /* Clear LIF stats */ | ||
436 | vnic_dev_stats_clear(fnic->vdev); | ||
437 | |||
438 | return 0; | ||
439 | |||
440 | err_out_cleanup: | ||
441 | fnic_free_vnic_resources(fnic); | ||
442 | |||
443 | return err; | ||
444 | } | ||
diff --git a/drivers/scsi/fnic/fnic_res.h b/drivers/scsi/fnic/fnic_res.h new file mode 100644 index 000000000000..b6f310262534 --- /dev/null +++ b/drivers/scsi/fnic/fnic_res.h | |||
@@ -0,0 +1,197 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _FNIC_RES_H_ | ||
19 | #define _FNIC_RES_H_ | ||
20 | |||
21 | #include "wq_enet_desc.h" | ||
22 | #include "rq_enet_desc.h" | ||
23 | #include "vnic_wq.h" | ||
24 | #include "vnic_rq.h" | ||
25 | #include "fnic_io.h" | ||
26 | #include "fcpio.h" | ||
27 | #include "vnic_wq_copy.h" | ||
28 | #include "vnic_cq_copy.h" | ||
29 | |||
30 | static inline void fnic_queue_wq_desc(struct vnic_wq *wq, | ||
31 | void *os_buf, dma_addr_t dma_addr, | ||
32 | unsigned int len, unsigned int fc_eof, | ||
33 | int vlan_tag_insert, | ||
34 | unsigned int vlan_tag, | ||
35 | int cq_entry, int sop, int eop) | ||
36 | { | ||
37 | struct wq_enet_desc *desc = vnic_wq_next_desc(wq); | ||
38 | |||
39 | wq_enet_desc_enc(desc, | ||
40 | (u64)dma_addr | VNIC_PADDR_TARGET, | ||
41 | (u16)len, | ||
42 | 0, /* mss_or_csum_offset */ | ||
43 | (u16)fc_eof, | ||
44 | 0, /* offload_mode */ | ||
45 | (u8)eop, (u8)cq_entry, | ||
46 | 1, /* fcoe_encap */ | ||
47 | (u8)vlan_tag_insert, | ||
48 | (u16)vlan_tag, | ||
49 | 0 /* loopback */); | ||
50 | |||
51 | vnic_wq_post(wq, os_buf, dma_addr, len, sop, eop); | ||
52 | } | ||
53 | |||
54 | static inline void fnic_queue_wq_copy_desc_icmnd_16(struct vnic_wq_copy *wq, | ||
55 | u32 req_id, | ||
56 | u32 lunmap_id, u8 spl_flags, | ||
57 | u32 sgl_cnt, u32 sense_len, | ||
58 | u64 sgl_addr, u64 sns_addr, | ||
59 | u8 crn, u8 pri_ta, | ||
60 | u8 flags, u8 *scsi_cdb, | ||
61 | u32 data_len, u8 *lun, | ||
62 | u32 d_id, u16 mss, | ||
63 | u32 ratov, u32 edtov) | ||
64 | { | ||
65 | struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq); | ||
66 | |||
67 | desc->hdr.type = FCPIO_ICMND_16; /* enum fcpio_type */ | ||
68 | desc->hdr.status = 0; /* header status entry */ | ||
69 | desc->hdr._resvd = 0; /* reserved */ | ||
70 | desc->hdr.tag.u.req_id = req_id; /* id for this request */ | ||
71 | |||
72 | desc->u.icmnd_16.lunmap_id = lunmap_id; /* index into lunmap table */ | ||
73 | desc->u.icmnd_16.special_req_flags = spl_flags; /* exch req flags */ | ||
74 | desc->u.icmnd_16._resvd0[0] = 0; /* reserved */ | ||
75 | desc->u.icmnd_16._resvd0[1] = 0; /* reserved */ | ||
76 | desc->u.icmnd_16._resvd0[2] = 0; /* reserved */ | ||
77 | desc->u.icmnd_16.sgl_cnt = sgl_cnt; /* scatter-gather list count */ | ||
78 | desc->u.icmnd_16.sense_len = sense_len; /* sense buffer length */ | ||
79 | desc->u.icmnd_16.sgl_addr = sgl_addr; /* scatter-gather list addr */ | ||
80 | desc->u.icmnd_16.sense_addr = sns_addr; /* sense buffer address */ | ||
81 | desc->u.icmnd_16.crn = crn; /* SCSI Command Reference No.*/ | ||
82 | desc->u.icmnd_16.pri_ta = pri_ta; /* SCSI Pri & Task attribute */ | ||
83 | desc->u.icmnd_16._resvd1 = 0; /* reserved: should be 0 */ | ||
84 | desc->u.icmnd_16.flags = flags; /* command flags */ | ||
85 | memcpy(desc->u.icmnd_16.scsi_cdb, scsi_cdb, CDB_16); /* SCSI CDB */ | ||
86 | desc->u.icmnd_16.data_len = data_len; /* length of data expected */ | ||
87 | memcpy(desc->u.icmnd_16.lun, lun, LUN_ADDRESS); /* LUN address */ | ||
88 | desc->u.icmnd_16._resvd2 = 0; /* reserved */ | ||
89 | hton24(desc->u.icmnd_16.d_id, d_id); /* FC vNIC only: Target D_ID */ | ||
90 | desc->u.icmnd_16.mss = mss; /* FC vNIC only: max burst */ | ||
91 | desc->u.icmnd_16.r_a_tov = ratov; /*FC vNIC only: Res. Alloc Timeout */ | ||
92 | desc->u.icmnd_16.e_d_tov = edtov; /*FC vNIC only: Err Detect Timeout */ | ||
93 | |||
94 | vnic_wq_copy_post(wq); | ||
95 | } | ||
96 | |||
97 | static inline void fnic_queue_wq_copy_desc_itmf(struct vnic_wq_copy *wq, | ||
98 | u32 req_id, u32 lunmap_id, | ||
99 | u32 tm_req, u32 tm_id, u8 *lun, | ||
100 | u32 d_id, u32 r_a_tov, | ||
101 | u32 e_d_tov) | ||
102 | { | ||
103 | struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq); | ||
104 | |||
105 | desc->hdr.type = FCPIO_ITMF; /* enum fcpio_type */ | ||
106 | desc->hdr.status = 0; /* header status entry */ | ||
107 | desc->hdr._resvd = 0; /* reserved */ | ||
108 | desc->hdr.tag.u.req_id = req_id; /* id for this request */ | ||
109 | |||
110 | desc->u.itmf.lunmap_id = lunmap_id; /* index into lunmap table */ | ||
111 | desc->u.itmf.tm_req = tm_req; /* SCSI Task Management request */ | ||
112 | desc->u.itmf.t_tag = tm_id; /* tag of fcpio to be aborted */ | ||
113 | desc->u.itmf._resvd = 0; | ||
114 | memcpy(desc->u.itmf.lun, lun, LUN_ADDRESS); /* LUN address */ | ||
115 | desc->u.itmf._resvd1 = 0; | ||
116 | hton24(desc->u.itmf.d_id, d_id); /* FC vNIC only: Target D_ID */ | ||
117 | desc->u.itmf.r_a_tov = r_a_tov; /* FC vNIC only: R_A_TOV in msec */ | ||
118 | desc->u.itmf.e_d_tov = e_d_tov; /* FC vNIC only: E_D_TOV in msec */ | ||
119 | |||
120 | vnic_wq_copy_post(wq); | ||
121 | } | ||
122 | |||
123 | static inline void fnic_queue_wq_copy_desc_flogi_reg(struct vnic_wq_copy *wq, | ||
124 | u32 req_id, u8 format, | ||
125 | u32 s_id, u8 *gw_mac) | ||
126 | { | ||
127 | struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq); | ||
128 | |||
129 | desc->hdr.type = FCPIO_FLOGI_REG; /* enum fcpio_type */ | ||
130 | desc->hdr.status = 0; /* header status entry */ | ||
131 | desc->hdr._resvd = 0; /* reserved */ | ||
132 | desc->hdr.tag.u.req_id = req_id; /* id for this request */ | ||
133 | |||
134 | desc->u.flogi_reg.format = format; | ||
135 | hton24(desc->u.flogi_reg.s_id, s_id); | ||
136 | memcpy(desc->u.flogi_reg.gateway_mac, gw_mac, ETH_ALEN); | ||
137 | |||
138 | vnic_wq_copy_post(wq); | ||
139 | } | ||
140 | |||
141 | static inline void fnic_queue_wq_copy_desc_fw_reset(struct vnic_wq_copy *wq, | ||
142 | u32 req_id) | ||
143 | { | ||
144 | struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq); | ||
145 | |||
146 | desc->hdr.type = FCPIO_RESET; /* enum fcpio_type */ | ||
147 | desc->hdr.status = 0; /* header status entry */ | ||
148 | desc->hdr._resvd = 0; /* reserved */ | ||
149 | desc->hdr.tag.u.req_id = req_id; /* id for this request */ | ||
150 | |||
151 | vnic_wq_copy_post(wq); | ||
152 | } | ||
153 | |||
154 | static inline void fnic_queue_wq_copy_desc_lunmap(struct vnic_wq_copy *wq, | ||
155 | u32 req_id, u64 lunmap_addr, | ||
156 | u32 lunmap_len) | ||
157 | { | ||
158 | struct fcpio_host_req *desc = vnic_wq_copy_next_desc(wq); | ||
159 | |||
160 | desc->hdr.type = FCPIO_LUNMAP_REQ; /* enum fcpio_type */ | ||
161 | desc->hdr.status = 0; /* header status entry */ | ||
162 | desc->hdr._resvd = 0; /* reserved */ | ||
163 | desc->hdr.tag.u.req_id = req_id; /* id for this request */ | ||
164 | |||
165 | desc->u.lunmap_req.addr = lunmap_addr; /* address of the buffer */ | ||
166 | desc->u.lunmap_req.len = lunmap_len; /* len of the buffer */ | ||
167 | |||
168 | vnic_wq_copy_post(wq); | ||
169 | } | ||
170 | |||
171 | static inline void fnic_queue_rq_desc(struct vnic_rq *rq, | ||
172 | void *os_buf, dma_addr_t dma_addr, | ||
173 | u16 len) | ||
174 | { | ||
175 | struct rq_enet_desc *desc = vnic_rq_next_desc(rq); | ||
176 | |||
177 | rq_enet_desc_enc(desc, | ||
178 | (u64)dma_addr | VNIC_PADDR_TARGET, | ||
179 | RQ_ENET_TYPE_ONLY_SOP, | ||
180 | (u16)len); | ||
181 | |||
182 | vnic_rq_post(rq, os_buf, 0, dma_addr, len); | ||
183 | } | ||
184 | |||
185 | |||
186 | struct fnic; | ||
187 | |||
188 | int fnic_get_vnic_config(struct fnic *); | ||
189 | int fnic_alloc_vnic_resources(struct fnic *); | ||
190 | void fnic_free_vnic_resources(struct fnic *); | ||
191 | void fnic_get_res_counts(struct fnic *); | ||
192 | int fnic_set_nic_config(struct fnic *fnic, u8 rss_default_cpu, | ||
193 | u8 rss_hash_type, u8 rss_hash_bits, u8 rss_base_cpu, | ||
194 | u8 rss_enable, u8 tso_ipid_split_en, | ||
195 | u8 ig_vlan_strip_en); | ||
196 | |||
197 | #endif /* _FNIC_RES_H_ */ | ||
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c new file mode 100644 index 000000000000..eabf36502856 --- /dev/null +++ b/drivers/scsi/fnic/fnic_scsi.c | |||
@@ -0,0 +1,1850 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/mempool.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/workqueue.h> | ||
22 | #include <linux/pci.h> | ||
23 | #include <linux/scatterlist.h> | ||
24 | #include <linux/skbuff.h> | ||
25 | #include <linux/spinlock.h> | ||
26 | #include <linux/if_ether.h> | ||
27 | #include <linux/if_vlan.h> | ||
28 | #include <linux/delay.h> | ||
29 | #include <scsi/scsi.h> | ||
30 | #include <scsi/scsi_host.h> | ||
31 | #include <scsi/scsi_device.h> | ||
32 | #include <scsi/scsi_cmnd.h> | ||
33 | #include <scsi/scsi_tcq.h> | ||
34 | #include <scsi/fc/fc_els.h> | ||
35 | #include <scsi/fc/fc_fcoe.h> | ||
36 | #include <scsi/libfc.h> | ||
37 | #include <scsi/fc_frame.h> | ||
38 | #include "fnic_io.h" | ||
39 | #include "fnic.h" | ||
40 | |||
41 | const char *fnic_state_str[] = { | ||
42 | [FNIC_IN_FC_MODE] = "FNIC_IN_FC_MODE", | ||
43 | [FNIC_IN_FC_TRANS_ETH_MODE] = "FNIC_IN_FC_TRANS_ETH_MODE", | ||
44 | [FNIC_IN_ETH_MODE] = "FNIC_IN_ETH_MODE", | ||
45 | [FNIC_IN_ETH_TRANS_FC_MODE] = "FNIC_IN_ETH_TRANS_FC_MODE", | ||
46 | }; | ||
47 | |||
48 | static const char *fnic_ioreq_state_str[] = { | ||
49 | [FNIC_IOREQ_CMD_PENDING] = "FNIC_IOREQ_CMD_PENDING", | ||
50 | [FNIC_IOREQ_ABTS_PENDING] = "FNIC_IOREQ_ABTS_PENDING", | ||
51 | [FNIC_IOREQ_ABTS_COMPLETE] = "FNIC_IOREQ_ABTS_COMPLETE", | ||
52 | [FNIC_IOREQ_CMD_COMPLETE] = "FNIC_IOREQ_CMD_COMPLETE", | ||
53 | }; | ||
54 | |||
55 | static const char *fcpio_status_str[] = { | ||
56 | [FCPIO_SUCCESS] = "FCPIO_SUCCESS", /*0x0*/ | ||
57 | [FCPIO_INVALID_HEADER] = "FCPIO_INVALID_HEADER", | ||
58 | [FCPIO_OUT_OF_RESOURCE] = "FCPIO_OUT_OF_RESOURCE", | ||
59 | [FCPIO_INVALID_PARAM] = "FCPIO_INVALID_PARAM]", | ||
60 | [FCPIO_REQ_NOT_SUPPORTED] = "FCPIO_REQ_NOT_SUPPORTED", | ||
61 | [FCPIO_IO_NOT_FOUND] = "FCPIO_IO_NOT_FOUND", | ||
62 | [FCPIO_ABORTED] = "FCPIO_ABORTED", /*0x41*/ | ||
63 | [FCPIO_TIMEOUT] = "FCPIO_TIMEOUT", | ||
64 | [FCPIO_SGL_INVALID] = "FCPIO_SGL_INVALID", | ||
65 | [FCPIO_MSS_INVALID] = "FCPIO_MSS_INVALID", | ||
66 | [FCPIO_DATA_CNT_MISMATCH] = "FCPIO_DATA_CNT_MISMATCH", | ||
67 | [FCPIO_FW_ERR] = "FCPIO_FW_ERR", | ||
68 | [FCPIO_ITMF_REJECTED] = "FCPIO_ITMF_REJECTED", | ||
69 | [FCPIO_ITMF_FAILED] = "FCPIO_ITMF_FAILED", | ||
70 | [FCPIO_ITMF_INCORRECT_LUN] = "FCPIO_ITMF_INCORRECT_LUN", | ||
71 | [FCPIO_CMND_REJECTED] = "FCPIO_CMND_REJECTED", | ||
72 | [FCPIO_NO_PATH_AVAIL] = "FCPIO_NO_PATH_AVAIL", | ||
73 | [FCPIO_PATH_FAILED] = "FCPIO_PATH_FAILED", | ||
74 | [FCPIO_LUNMAP_CHNG_PEND] = "FCPIO_LUNHMAP_CHNG_PEND", | ||
75 | }; | ||
76 | |||
77 | const char *fnic_state_to_str(unsigned int state) | ||
78 | { | ||
79 | if (state >= ARRAY_SIZE(fnic_state_str) || !fnic_state_str[state]) | ||
80 | return "unknown"; | ||
81 | |||
82 | return fnic_state_str[state]; | ||
83 | } | ||
84 | |||
85 | static const char *fnic_ioreq_state_to_str(unsigned int state) | ||
86 | { | ||
87 | if (state >= ARRAY_SIZE(fnic_ioreq_state_str) || | ||
88 | !fnic_ioreq_state_str[state]) | ||
89 | return "unknown"; | ||
90 | |||
91 | return fnic_ioreq_state_str[state]; | ||
92 | } | ||
93 | |||
94 | static const char *fnic_fcpio_status_to_str(unsigned int status) | ||
95 | { | ||
96 | if (status >= ARRAY_SIZE(fcpio_status_str) || !fcpio_status_str[status]) | ||
97 | return "unknown"; | ||
98 | |||
99 | return fcpio_status_str[status]; | ||
100 | } | ||
101 | |||
102 | static void fnic_cleanup_io(struct fnic *fnic, int exclude_id); | ||
103 | |||
104 | static inline spinlock_t *fnic_io_lock_hash(struct fnic *fnic, | ||
105 | struct scsi_cmnd *sc) | ||
106 | { | ||
107 | u32 hash = sc->request->tag & (FNIC_IO_LOCKS - 1); | ||
108 | |||
109 | return &fnic->io_req_lock[hash]; | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * Unmap the data buffer and sense buffer for an io_req, | ||
114 | * also unmap and free the device-private scatter/gather list. | ||
115 | */ | ||
116 | static void fnic_release_ioreq_buf(struct fnic *fnic, | ||
117 | struct fnic_io_req *io_req, | ||
118 | struct scsi_cmnd *sc) | ||
119 | { | ||
120 | if (io_req->sgl_list_pa) | ||
121 | pci_unmap_single(fnic->pdev, io_req->sgl_list_pa, | ||
122 | sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt, | ||
123 | PCI_DMA_TODEVICE); | ||
124 | scsi_dma_unmap(sc); | ||
125 | |||
126 | if (io_req->sgl_cnt) | ||
127 | mempool_free(io_req->sgl_list_alloc, | ||
128 | fnic->io_sgl_pool[io_req->sgl_type]); | ||
129 | if (io_req->sense_buf_pa) | ||
130 | pci_unmap_single(fnic->pdev, io_req->sense_buf_pa, | ||
131 | SCSI_SENSE_BUFFERSIZE, PCI_DMA_FROMDEVICE); | ||
132 | } | ||
133 | |||
134 | /* Free up Copy Wq descriptors. Called with copy_wq lock held */ | ||
135 | static int free_wq_copy_descs(struct fnic *fnic, struct vnic_wq_copy *wq) | ||
136 | { | ||
137 | /* if no Ack received from firmware, then nothing to clean */ | ||
138 | if (!fnic->fw_ack_recd[0]) | ||
139 | return 1; | ||
140 | |||
141 | /* | ||
142 | * Update desc_available count based on number of freed descriptors | ||
143 | * Account for wraparound | ||
144 | */ | ||
145 | if (wq->to_clean_index <= fnic->fw_ack_index[0]) | ||
146 | wq->ring.desc_avail += (fnic->fw_ack_index[0] | ||
147 | - wq->to_clean_index + 1); | ||
148 | else | ||
149 | wq->ring.desc_avail += (wq->ring.desc_count | ||
150 | - wq->to_clean_index | ||
151 | + fnic->fw_ack_index[0] + 1); | ||
152 | |||
153 | /* | ||
154 | * just bump clean index to ack_index+1 accounting for wraparound | ||
155 | * this will essentially free up all descriptors between | ||
156 | * to_clean_index and fw_ack_index, both inclusive | ||
157 | */ | ||
158 | wq->to_clean_index = | ||
159 | (fnic->fw_ack_index[0] + 1) % wq->ring.desc_count; | ||
160 | |||
161 | /* we have processed the acks received so far */ | ||
162 | fnic->fw_ack_recd[0] = 0; | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | |||
167 | /* | ||
168 | * fnic_fw_reset_handler | ||
169 | * Routine to send reset msg to fw | ||
170 | */ | ||
171 | int fnic_fw_reset_handler(struct fnic *fnic) | ||
172 | { | ||
173 | struct vnic_wq_copy *wq = &fnic->wq_copy[0]; | ||
174 | int ret = 0; | ||
175 | unsigned long flags; | ||
176 | |||
177 | spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); | ||
178 | |||
179 | if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) | ||
180 | free_wq_copy_descs(fnic, wq); | ||
181 | |||
182 | if (!vnic_wq_copy_desc_avail(wq)) | ||
183 | ret = -EAGAIN; | ||
184 | else | ||
185 | fnic_queue_wq_copy_desc_fw_reset(wq, SCSI_NO_TAG); | ||
186 | |||
187 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); | ||
188 | |||
189 | if (!ret) | ||
190 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
191 | "Issued fw reset\n"); | ||
192 | else | ||
193 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
194 | "Failed to issue fw reset\n"); | ||
195 | return ret; | ||
196 | } | ||
197 | |||
198 | |||
199 | /* | ||
200 | * fnic_flogi_reg_handler | ||
201 | * Routine to send flogi register msg to fw | ||
202 | */ | ||
203 | int fnic_flogi_reg_handler(struct fnic *fnic) | ||
204 | { | ||
205 | struct vnic_wq_copy *wq = &fnic->wq_copy[0]; | ||
206 | u8 gw_mac[ETH_ALEN]; | ||
207 | int ret = 0; | ||
208 | unsigned long flags; | ||
209 | |||
210 | spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); | ||
211 | |||
212 | if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) | ||
213 | free_wq_copy_descs(fnic, wq); | ||
214 | |||
215 | if (!vnic_wq_copy_desc_avail(wq)) { | ||
216 | ret = -EAGAIN; | ||
217 | goto flogi_reg_ioreq_end; | ||
218 | } | ||
219 | |||
220 | if (fnic->fcoui_mode) | ||
221 | memset(gw_mac, 0xff, ETH_ALEN); | ||
222 | else | ||
223 | memcpy(gw_mac, fnic->dest_addr, ETH_ALEN); | ||
224 | |||
225 | fnic_queue_wq_copy_desc_flogi_reg(wq, SCSI_NO_TAG, | ||
226 | FCPIO_FLOGI_REG_GW_DEST, | ||
227 | fnic->s_id, | ||
228 | gw_mac); | ||
229 | |||
230 | flogi_reg_ioreq_end: | ||
231 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); | ||
232 | |||
233 | if (!ret) | ||
234 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
235 | "flog reg issued\n"); | ||
236 | |||
237 | return ret; | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * fnic_queue_wq_copy_desc | ||
242 | * Routine to enqueue a wq copy desc | ||
243 | */ | ||
244 | static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, | ||
245 | struct vnic_wq_copy *wq, | ||
246 | struct fnic_io_req *io_req, | ||
247 | struct scsi_cmnd *sc, | ||
248 | u32 sg_count) | ||
249 | { | ||
250 | struct scatterlist *sg; | ||
251 | struct fc_rport *rport = starget_to_rport(scsi_target(sc->device)); | ||
252 | struct fc_rport_libfc_priv *rp = rport->dd_data; | ||
253 | struct host_sg_desc *desc; | ||
254 | u8 pri_tag = 0; | ||
255 | unsigned int i; | ||
256 | unsigned long intr_flags; | ||
257 | int flags; | ||
258 | u8 exch_flags; | ||
259 | struct scsi_lun fc_lun; | ||
260 | char msg[2]; | ||
261 | |||
262 | if (sg_count) { | ||
263 | BUG_ON(sg_count < 0); | ||
264 | BUG_ON(sg_count > FNIC_MAX_SG_DESC_CNT); | ||
265 | |||
266 | /* For each SGE, create a device desc entry */ | ||
267 | desc = io_req->sgl_list; | ||
268 | for_each_sg(scsi_sglist(sc), sg, sg_count, i) { | ||
269 | desc->addr = cpu_to_le64(sg_dma_address(sg)); | ||
270 | desc->len = cpu_to_le32(sg_dma_len(sg)); | ||
271 | desc->_resvd = 0; | ||
272 | desc++; | ||
273 | } | ||
274 | |||
275 | io_req->sgl_list_pa = pci_map_single | ||
276 | (fnic->pdev, | ||
277 | io_req->sgl_list, | ||
278 | sizeof(io_req->sgl_list[0]) * sg_count, | ||
279 | PCI_DMA_TODEVICE); | ||
280 | } | ||
281 | |||
282 | io_req->sense_buf_pa = pci_map_single(fnic->pdev, | ||
283 | sc->sense_buffer, | ||
284 | SCSI_SENSE_BUFFERSIZE, | ||
285 | PCI_DMA_FROMDEVICE); | ||
286 | |||
287 | int_to_scsilun(sc->device->lun, &fc_lun); | ||
288 | |||
289 | pri_tag = FCPIO_ICMND_PTA_SIMPLE; | ||
290 | msg[0] = MSG_SIMPLE_TAG; | ||
291 | scsi_populate_tag_msg(sc, msg); | ||
292 | if (msg[0] == MSG_ORDERED_TAG) | ||
293 | pri_tag = FCPIO_ICMND_PTA_ORDERED; | ||
294 | |||
295 | /* Enqueue the descriptor in the Copy WQ */ | ||
296 | spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); | ||
297 | |||
298 | if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) | ||
299 | free_wq_copy_descs(fnic, wq); | ||
300 | |||
301 | if (unlikely(!vnic_wq_copy_desc_avail(wq))) { | ||
302 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); | ||
303 | return SCSI_MLQUEUE_HOST_BUSY; | ||
304 | } | ||
305 | |||
306 | flags = 0; | ||
307 | if (sc->sc_data_direction == DMA_FROM_DEVICE) | ||
308 | flags = FCPIO_ICMND_RDDATA; | ||
309 | else if (sc->sc_data_direction == DMA_TO_DEVICE) | ||
310 | flags = FCPIO_ICMND_WRDATA; | ||
311 | |||
312 | exch_flags = 0; | ||
313 | if ((fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) && | ||
314 | (rp->flags & FC_RP_FLAGS_RETRY)) | ||
315 | exch_flags |= FCPIO_ICMND_SRFLAG_RETRY; | ||
316 | |||
317 | fnic_queue_wq_copy_desc_icmnd_16(wq, sc->request->tag, | ||
318 | 0, exch_flags, io_req->sgl_cnt, | ||
319 | SCSI_SENSE_BUFFERSIZE, | ||
320 | io_req->sgl_list_pa, | ||
321 | io_req->sense_buf_pa, | ||
322 | 0, /* scsi cmd ref, always 0 */ | ||
323 | pri_tag, /* scsi pri and tag */ | ||
324 | flags, /* command flags */ | ||
325 | sc->cmnd, scsi_bufflen(sc), | ||
326 | fc_lun.scsi_lun, io_req->port_id, | ||
327 | rport->maxframe_size, rp->r_a_tov, | ||
328 | rp->e_d_tov); | ||
329 | |||
330 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * fnic_queuecommand | ||
336 | * Routine to send a scsi cdb | ||
337 | * Called with host_lock held and interrupts disabled. | ||
338 | */ | ||
339 | int fnic_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | ||
340 | { | ||
341 | struct fc_lport *lp; | ||
342 | struct fc_rport *rport; | ||
343 | struct fnic_io_req *io_req; | ||
344 | struct fnic *fnic; | ||
345 | struct vnic_wq_copy *wq; | ||
346 | int ret; | ||
347 | u32 sg_count; | ||
348 | unsigned long flags; | ||
349 | unsigned long ptr; | ||
350 | |||
351 | rport = starget_to_rport(scsi_target(sc->device)); | ||
352 | ret = fc_remote_port_chkready(rport); | ||
353 | if (ret) { | ||
354 | sc->result = ret; | ||
355 | done(sc); | ||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | lp = shost_priv(sc->device->host); | ||
360 | if (lp->state != LPORT_ST_READY || !(lp->link_up)) | ||
361 | return SCSI_MLQUEUE_HOST_BUSY; | ||
362 | |||
363 | /* | ||
364 | * Release host lock, use driver resource specific locks from here. | ||
365 | * Don't re-enable interrupts in case they were disabled prior to the | ||
366 | * caller disabling them. | ||
367 | */ | ||
368 | spin_unlock(lp->host->host_lock); | ||
369 | |||
370 | /* Get a new io_req for this SCSI IO */ | ||
371 | fnic = lport_priv(lp); | ||
372 | |||
373 | io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); | ||
374 | if (!io_req) { | ||
375 | ret = SCSI_MLQUEUE_HOST_BUSY; | ||
376 | goto out; | ||
377 | } | ||
378 | memset(io_req, 0, sizeof(*io_req)); | ||
379 | |||
380 | /* Map the data buffer */ | ||
381 | sg_count = scsi_dma_map(sc); | ||
382 | if (sg_count < 0) { | ||
383 | mempool_free(io_req, fnic->io_req_pool); | ||
384 | goto out; | ||
385 | } | ||
386 | |||
387 | /* Determine the type of scatter/gather list we need */ | ||
388 | io_req->sgl_cnt = sg_count; | ||
389 | io_req->sgl_type = FNIC_SGL_CACHE_DFLT; | ||
390 | if (sg_count > FNIC_DFLT_SG_DESC_CNT) | ||
391 | io_req->sgl_type = FNIC_SGL_CACHE_MAX; | ||
392 | |||
393 | if (sg_count) { | ||
394 | io_req->sgl_list = | ||
395 | mempool_alloc(fnic->io_sgl_pool[io_req->sgl_type], | ||
396 | GFP_ATOMIC | GFP_DMA); | ||
397 | if (!io_req->sgl_list) { | ||
398 | ret = SCSI_MLQUEUE_HOST_BUSY; | ||
399 | scsi_dma_unmap(sc); | ||
400 | mempool_free(io_req, fnic->io_req_pool); | ||
401 | goto out; | ||
402 | } | ||
403 | |||
404 | /* Cache sgl list allocated address before alignment */ | ||
405 | io_req->sgl_list_alloc = io_req->sgl_list; | ||
406 | ptr = (unsigned long) io_req->sgl_list; | ||
407 | if (ptr % FNIC_SG_DESC_ALIGN) { | ||
408 | io_req->sgl_list = (struct host_sg_desc *) | ||
409 | (((unsigned long) ptr | ||
410 | + FNIC_SG_DESC_ALIGN - 1) | ||
411 | & ~(FNIC_SG_DESC_ALIGN - 1)); | ||
412 | } | ||
413 | } | ||
414 | |||
415 | /* initialize rest of io_req */ | ||
416 | io_req->port_id = rport->port_id; | ||
417 | CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; | ||
418 | CMD_SP(sc) = (char *)io_req; | ||
419 | sc->scsi_done = done; | ||
420 | |||
421 | /* create copy wq desc and enqueue it */ | ||
422 | wq = &fnic->wq_copy[0]; | ||
423 | ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count); | ||
424 | if (ret) { | ||
425 | /* | ||
426 | * In case another thread cancelled the request, | ||
427 | * refetch the pointer under the lock. | ||
428 | */ | ||
429 | spinlock_t *io_lock = fnic_io_lock_hash(fnic, sc); | ||
430 | |||
431 | spin_lock_irqsave(io_lock, flags); | ||
432 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
433 | CMD_SP(sc) = NULL; | ||
434 | CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; | ||
435 | spin_unlock_irqrestore(io_lock, flags); | ||
436 | if (io_req) { | ||
437 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
438 | mempool_free(io_req, fnic->io_req_pool); | ||
439 | } | ||
440 | } | ||
441 | out: | ||
442 | /* acquire host lock before returning to SCSI */ | ||
443 | spin_lock(lp->host->host_lock); | ||
444 | return ret; | ||
445 | } | ||
446 | |||
447 | /* | ||
448 | * fnic_fcpio_fw_reset_cmpl_handler | ||
449 | * Routine to handle fw reset completion | ||
450 | */ | ||
451 | static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, | ||
452 | struct fcpio_fw_req *desc) | ||
453 | { | ||
454 | u8 type; | ||
455 | u8 hdr_status; | ||
456 | struct fcpio_tag tag; | ||
457 | int ret = 0; | ||
458 | struct fc_frame *flogi; | ||
459 | unsigned long flags; | ||
460 | |||
461 | fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); | ||
462 | |||
463 | /* Clean up all outstanding io requests */ | ||
464 | fnic_cleanup_io(fnic, SCSI_NO_TAG); | ||
465 | |||
466 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
467 | |||
468 | flogi = fnic->flogi; | ||
469 | fnic->flogi = NULL; | ||
470 | |||
471 | /* fnic should be in FC_TRANS_ETH_MODE */ | ||
472 | if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) { | ||
473 | /* Check status of reset completion */ | ||
474 | if (!hdr_status) { | ||
475 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
476 | "reset cmpl success\n"); | ||
477 | /* Ready to send flogi out */ | ||
478 | fnic->state = FNIC_IN_ETH_MODE; | ||
479 | } else { | ||
480 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
481 | fnic->lport->host, | ||
482 | "fnic fw_reset : failed %s\n", | ||
483 | fnic_fcpio_status_to_str(hdr_status)); | ||
484 | |||
485 | /* | ||
486 | * Unable to change to eth mode, cannot send out flogi | ||
487 | * Change state to fc mode, so that subsequent Flogi | ||
488 | * requests from libFC will cause more attempts to | ||
489 | * reset the firmware. Free the cached flogi | ||
490 | */ | ||
491 | fnic->state = FNIC_IN_FC_MODE; | ||
492 | ret = -1; | ||
493 | } | ||
494 | } else { | ||
495 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
496 | fnic->lport->host, | ||
497 | "Unexpected state %s while processing" | ||
498 | " reset cmpl\n", fnic_state_to_str(fnic->state)); | ||
499 | ret = -1; | ||
500 | } | ||
501 | |||
502 | /* Thread removing device blocks till firmware reset is complete */ | ||
503 | if (fnic->remove_wait) | ||
504 | complete(fnic->remove_wait); | ||
505 | |||
506 | /* | ||
507 | * If fnic is being removed, or fw reset failed | ||
508 | * free the flogi frame. Else, send it out | ||
509 | */ | ||
510 | if (fnic->remove_wait || ret) { | ||
511 | fnic->flogi_oxid = FC_XID_UNKNOWN; | ||
512 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
513 | if (flogi) | ||
514 | dev_kfree_skb_irq(fp_skb(flogi)); | ||
515 | goto reset_cmpl_handler_end; | ||
516 | } | ||
517 | |||
518 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
519 | |||
520 | if (flogi) | ||
521 | ret = fnic_send_frame(fnic, flogi); | ||
522 | |||
523 | reset_cmpl_handler_end: | ||
524 | return ret; | ||
525 | } | ||
526 | |||
527 | /* | ||
528 | * fnic_fcpio_flogi_reg_cmpl_handler | ||
529 | * Routine to handle flogi register completion | ||
530 | */ | ||
531 | static int fnic_fcpio_flogi_reg_cmpl_handler(struct fnic *fnic, | ||
532 | struct fcpio_fw_req *desc) | ||
533 | { | ||
534 | u8 type; | ||
535 | u8 hdr_status; | ||
536 | struct fcpio_tag tag; | ||
537 | int ret = 0; | ||
538 | struct fc_frame *flogi_resp = NULL; | ||
539 | unsigned long flags; | ||
540 | struct sk_buff *skb; | ||
541 | |||
542 | fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); | ||
543 | |||
544 | /* Update fnic state based on status of flogi reg completion */ | ||
545 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
546 | |||
547 | flogi_resp = fnic->flogi_resp; | ||
548 | fnic->flogi_resp = NULL; | ||
549 | |||
550 | if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE) { | ||
551 | |||
552 | /* Check flogi registration completion status */ | ||
553 | if (!hdr_status) { | ||
554 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
555 | "flog reg succeeded\n"); | ||
556 | fnic->state = FNIC_IN_FC_MODE; | ||
557 | } else { | ||
558 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
559 | fnic->lport->host, | ||
560 | "fnic flogi reg :failed %s\n", | ||
561 | fnic_fcpio_status_to_str(hdr_status)); | ||
562 | fnic->state = FNIC_IN_ETH_MODE; | ||
563 | ret = -1; | ||
564 | } | ||
565 | } else { | ||
566 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
567 | "Unexpected fnic state %s while" | ||
568 | " processing flogi reg completion\n", | ||
569 | fnic_state_to_str(fnic->state)); | ||
570 | ret = -1; | ||
571 | } | ||
572 | |||
573 | /* Successful flogi reg cmpl, pass frame to LibFC */ | ||
574 | if (!ret && flogi_resp) { | ||
575 | if (fnic->stop_rx_link_events) { | ||
576 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
577 | goto reg_cmpl_handler_end; | ||
578 | } | ||
579 | skb = (struct sk_buff *)flogi_resp; | ||
580 | /* Use fr_flags to indicate whether flogi resp or not */ | ||
581 | fr_flags(flogi_resp) = 1; | ||
582 | fr_dev(flogi_resp) = fnic->lport; | ||
583 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
584 | |||
585 | skb_queue_tail(&fnic->frame_queue, skb); | ||
586 | queue_work(fnic_event_queue, &fnic->frame_work); | ||
587 | |||
588 | } else { | ||
589 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
590 | if (flogi_resp) | ||
591 | dev_kfree_skb_irq(fp_skb(flogi_resp)); | ||
592 | } | ||
593 | |||
594 | reg_cmpl_handler_end: | ||
595 | return ret; | ||
596 | } | ||
597 | |||
598 | static inline int is_ack_index_in_range(struct vnic_wq_copy *wq, | ||
599 | u16 request_out) | ||
600 | { | ||
601 | if (wq->to_clean_index <= wq->to_use_index) { | ||
602 | /* out of range, stale request_out index */ | ||
603 | if (request_out < wq->to_clean_index || | ||
604 | request_out >= wq->to_use_index) | ||
605 | return 0; | ||
606 | } else { | ||
607 | /* out of range, stale request_out index */ | ||
608 | if (request_out < wq->to_clean_index && | ||
609 | request_out >= wq->to_use_index) | ||
610 | return 0; | ||
611 | } | ||
612 | /* request_out index is in range */ | ||
613 | return 1; | ||
614 | } | ||
615 | |||
616 | |||
617 | /* | ||
618 | * Mark that ack received and store the Ack index. If there are multiple | ||
619 | * acks received before Tx thread cleans it up, the latest value will be | ||
620 | * used which is correct behavior. This state should be in the copy Wq | ||
621 | * instead of in the fnic | ||
622 | */ | ||
623 | static inline void fnic_fcpio_ack_handler(struct fnic *fnic, | ||
624 | unsigned int cq_index, | ||
625 | struct fcpio_fw_req *desc) | ||
626 | { | ||
627 | struct vnic_wq_copy *wq; | ||
628 | u16 request_out = desc->u.ack.request_out; | ||
629 | unsigned long flags; | ||
630 | |||
631 | /* mark the ack state */ | ||
632 | wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count]; | ||
633 | spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); | ||
634 | |||
635 | if (is_ack_index_in_range(wq, request_out)) { | ||
636 | fnic->fw_ack_index[0] = request_out; | ||
637 | fnic->fw_ack_recd[0] = 1; | ||
638 | } | ||
639 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); | ||
640 | } | ||
641 | |||
642 | /* | ||
643 | * fnic_fcpio_icmnd_cmpl_handler | ||
644 | * Routine to handle icmnd completions | ||
645 | */ | ||
646 | static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, | ||
647 | struct fcpio_fw_req *desc) | ||
648 | { | ||
649 | u8 type; | ||
650 | u8 hdr_status; | ||
651 | struct fcpio_tag tag; | ||
652 | u32 id; | ||
653 | u64 xfer_len = 0; | ||
654 | struct fcpio_icmnd_cmpl *icmnd_cmpl; | ||
655 | struct fnic_io_req *io_req; | ||
656 | struct scsi_cmnd *sc; | ||
657 | unsigned long flags; | ||
658 | spinlock_t *io_lock; | ||
659 | |||
660 | /* Decode the cmpl description to get the io_req id */ | ||
661 | fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); | ||
662 | fcpio_tag_id_dec(&tag, &id); | ||
663 | |||
664 | if (id >= FNIC_MAX_IO_REQ) | ||
665 | return; | ||
666 | |||
667 | sc = scsi_host_find_tag(fnic->lport->host, id); | ||
668 | WARN_ON_ONCE(!sc); | ||
669 | if (!sc) | ||
670 | return; | ||
671 | |||
672 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
673 | spin_lock_irqsave(io_lock, flags); | ||
674 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
675 | WARN_ON_ONCE(!io_req); | ||
676 | if (!io_req) { | ||
677 | spin_unlock_irqrestore(io_lock, flags); | ||
678 | return; | ||
679 | } | ||
680 | |||
681 | /* firmware completed the io */ | ||
682 | io_req->io_completed = 1; | ||
683 | |||
684 | /* | ||
685 | * if SCSI-ML has already issued abort on this command, | ||
686 | * ignore completion of the IO. The abts path will clean it up | ||
687 | */ | ||
688 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { | ||
689 | spin_unlock_irqrestore(io_lock, flags); | ||
690 | return; | ||
691 | } | ||
692 | |||
693 | /* Mark the IO as complete */ | ||
694 | CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; | ||
695 | |||
696 | icmnd_cmpl = &desc->u.icmnd_cmpl; | ||
697 | |||
698 | switch (hdr_status) { | ||
699 | case FCPIO_SUCCESS: | ||
700 | sc->result = (DID_OK << 16) | icmnd_cmpl->scsi_status; | ||
701 | xfer_len = scsi_bufflen(sc); | ||
702 | scsi_set_resid(sc, icmnd_cmpl->residual); | ||
703 | |||
704 | if (icmnd_cmpl->flags & FCPIO_ICMND_CMPL_RESID_UNDER) | ||
705 | xfer_len -= icmnd_cmpl->residual; | ||
706 | |||
707 | /* | ||
708 | * If queue_full, then try to reduce queue depth for all | ||
709 | * LUNS on the target. Todo: this should be accompanied | ||
710 | * by a periodic queue_depth rampup based on successful | ||
711 | * IO completion. | ||
712 | */ | ||
713 | if (icmnd_cmpl->scsi_status == QUEUE_FULL) { | ||
714 | struct scsi_device *t_sdev; | ||
715 | int qd = 0; | ||
716 | |||
717 | shost_for_each_device(t_sdev, sc->device->host) { | ||
718 | if (t_sdev->id != sc->device->id) | ||
719 | continue; | ||
720 | |||
721 | if (t_sdev->queue_depth > 1) { | ||
722 | qd = scsi_track_queue_full | ||
723 | (t_sdev, | ||
724 | t_sdev->queue_depth - 1); | ||
725 | if (qd == -1) | ||
726 | qd = t_sdev->host->cmd_per_lun; | ||
727 | shost_printk(KERN_INFO, | ||
728 | fnic->lport->host, | ||
729 | "scsi[%d:%d:%d:%d" | ||
730 | "] queue full detected," | ||
731 | "new depth = %d\n", | ||
732 | t_sdev->host->host_no, | ||
733 | t_sdev->channel, | ||
734 | t_sdev->id, t_sdev->lun, | ||
735 | t_sdev->queue_depth); | ||
736 | } | ||
737 | } | ||
738 | } | ||
739 | break; | ||
740 | |||
741 | case FCPIO_TIMEOUT: /* request was timed out */ | ||
742 | sc->result = (DID_TIME_OUT << 16) | icmnd_cmpl->scsi_status; | ||
743 | break; | ||
744 | |||
745 | case FCPIO_ABORTED: /* request was aborted */ | ||
746 | sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; | ||
747 | break; | ||
748 | |||
749 | case FCPIO_DATA_CNT_MISMATCH: /* recv/sent more/less data than exp. */ | ||
750 | scsi_set_resid(sc, icmnd_cmpl->residual); | ||
751 | sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; | ||
752 | break; | ||
753 | |||
754 | case FCPIO_OUT_OF_RESOURCE: /* out of resources to complete request */ | ||
755 | sc->result = (DID_REQUEUE << 16) | icmnd_cmpl->scsi_status; | ||
756 | break; | ||
757 | case FCPIO_INVALID_HEADER: /* header contains invalid data */ | ||
758 | case FCPIO_INVALID_PARAM: /* some parameter in request invalid */ | ||
759 | case FCPIO_REQ_NOT_SUPPORTED:/* request type is not supported */ | ||
760 | case FCPIO_IO_NOT_FOUND: /* requested I/O was not found */ | ||
761 | case FCPIO_SGL_INVALID: /* request was aborted due to sgl error */ | ||
762 | case FCPIO_MSS_INVALID: /* request was aborted due to mss error */ | ||
763 | case FCPIO_FW_ERR: /* request was terminated due fw error */ | ||
764 | default: | ||
765 | shost_printk(KERN_ERR, fnic->lport->host, "hdr status = %s\n", | ||
766 | fnic_fcpio_status_to_str(hdr_status)); | ||
767 | sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; | ||
768 | break; | ||
769 | } | ||
770 | |||
771 | /* Break link with the SCSI command */ | ||
772 | CMD_SP(sc) = NULL; | ||
773 | |||
774 | spin_unlock_irqrestore(io_lock, flags); | ||
775 | |||
776 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
777 | |||
778 | mempool_free(io_req, fnic->io_req_pool); | ||
779 | |||
780 | if (sc->sc_data_direction == DMA_FROM_DEVICE) { | ||
781 | fnic->lport->host_stats.fcp_input_requests++; | ||
782 | fnic->fcp_input_bytes += xfer_len; | ||
783 | } else if (sc->sc_data_direction == DMA_TO_DEVICE) { | ||
784 | fnic->lport->host_stats.fcp_output_requests++; | ||
785 | fnic->fcp_output_bytes += xfer_len; | ||
786 | } else | ||
787 | fnic->lport->host_stats.fcp_control_requests++; | ||
788 | |||
789 | /* Call SCSI completion function to complete the IO */ | ||
790 | if (sc->scsi_done) | ||
791 | sc->scsi_done(sc); | ||
792 | |||
793 | } | ||
794 | |||
795 | /* fnic_fcpio_itmf_cmpl_handler | ||
796 | * Routine to handle itmf completions | ||
797 | */ | ||
798 | static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, | ||
799 | struct fcpio_fw_req *desc) | ||
800 | { | ||
801 | u8 type; | ||
802 | u8 hdr_status; | ||
803 | struct fcpio_tag tag; | ||
804 | u32 id; | ||
805 | struct scsi_cmnd *sc; | ||
806 | struct fnic_io_req *io_req; | ||
807 | unsigned long flags; | ||
808 | spinlock_t *io_lock; | ||
809 | |||
810 | fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); | ||
811 | fcpio_tag_id_dec(&tag, &id); | ||
812 | |||
813 | if ((id & FNIC_TAG_MASK) >= FNIC_MAX_IO_REQ) | ||
814 | return; | ||
815 | |||
816 | sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK); | ||
817 | WARN_ON_ONCE(!sc); | ||
818 | if (!sc) | ||
819 | return; | ||
820 | |||
821 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
822 | spin_lock_irqsave(io_lock, flags); | ||
823 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
824 | WARN_ON_ONCE(!io_req); | ||
825 | if (!io_req) { | ||
826 | spin_unlock_irqrestore(io_lock, flags); | ||
827 | return; | ||
828 | } | ||
829 | |||
830 | if (id & FNIC_TAG_ABORT) { | ||
831 | /* Completion of abort cmd */ | ||
832 | if (CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING) { | ||
833 | /* This is a late completion. Ignore it */ | ||
834 | spin_unlock_irqrestore(io_lock, flags); | ||
835 | return; | ||
836 | } | ||
837 | CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; | ||
838 | CMD_ABTS_STATUS(sc) = hdr_status; | ||
839 | |||
840 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
841 | "abts cmpl recd. id %d status %s\n", | ||
842 | (int)(id & FNIC_TAG_MASK), | ||
843 | fnic_fcpio_status_to_str(hdr_status)); | ||
844 | |||
845 | /* | ||
846 | * If scsi_eh thread is blocked waiting for abts to complete, | ||
847 | * signal completion to it. IO will be cleaned in the thread | ||
848 | * else clean it in this context | ||
849 | */ | ||
850 | if (io_req->abts_done) { | ||
851 | complete(io_req->abts_done); | ||
852 | spin_unlock_irqrestore(io_lock, flags); | ||
853 | } else { | ||
854 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
855 | "abts cmpl, completing IO\n"); | ||
856 | CMD_SP(sc) = NULL; | ||
857 | sc->result = (DID_ERROR << 16); | ||
858 | |||
859 | spin_unlock_irqrestore(io_lock, flags); | ||
860 | |||
861 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
862 | mempool_free(io_req, fnic->io_req_pool); | ||
863 | if (sc->scsi_done) | ||
864 | sc->scsi_done(sc); | ||
865 | } | ||
866 | |||
867 | } else if (id & FNIC_TAG_DEV_RST) { | ||
868 | /* Completion of device reset */ | ||
869 | CMD_LR_STATUS(sc) = hdr_status; | ||
870 | CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; | ||
871 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
872 | "dev reset cmpl recd. id %d status %s\n", | ||
873 | (int)(id & FNIC_TAG_MASK), | ||
874 | fnic_fcpio_status_to_str(hdr_status)); | ||
875 | if (io_req->dr_done) | ||
876 | complete(io_req->dr_done); | ||
877 | spin_unlock_irqrestore(io_lock, flags); | ||
878 | |||
879 | } else { | ||
880 | shost_printk(KERN_ERR, fnic->lport->host, | ||
881 | "Unexpected itmf io state %s tag %x\n", | ||
882 | fnic_ioreq_state_to_str(CMD_STATE(sc)), id); | ||
883 | spin_unlock_irqrestore(io_lock, flags); | ||
884 | } | ||
885 | |||
886 | } | ||
887 | |||
888 | /* | ||
889 | * fnic_fcpio_cmpl_handler | ||
890 | * Routine to service the cq for wq_copy | ||
891 | */ | ||
892 | static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev, | ||
893 | unsigned int cq_index, | ||
894 | struct fcpio_fw_req *desc) | ||
895 | { | ||
896 | struct fnic *fnic = vnic_dev_priv(vdev); | ||
897 | int ret = 0; | ||
898 | |||
899 | switch (desc->hdr.type) { | ||
900 | case FCPIO_ACK: /* fw copied copy wq desc to its queue */ | ||
901 | fnic_fcpio_ack_handler(fnic, cq_index, desc); | ||
902 | break; | ||
903 | |||
904 | case FCPIO_ICMND_CMPL: /* fw completed a command */ | ||
905 | fnic_fcpio_icmnd_cmpl_handler(fnic, desc); | ||
906 | break; | ||
907 | |||
908 | case FCPIO_ITMF_CMPL: /* fw completed itmf (abort cmd, lun reset)*/ | ||
909 | fnic_fcpio_itmf_cmpl_handler(fnic, desc); | ||
910 | break; | ||
911 | |||
912 | case FCPIO_FLOGI_REG_CMPL: /* fw completed flogi_reg */ | ||
913 | ret = fnic_fcpio_flogi_reg_cmpl_handler(fnic, desc); | ||
914 | break; | ||
915 | |||
916 | case FCPIO_RESET_CMPL: /* fw completed reset */ | ||
917 | ret = fnic_fcpio_fw_reset_cmpl_handler(fnic, desc); | ||
918 | break; | ||
919 | |||
920 | default: | ||
921 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
922 | "firmware completion type %d\n", | ||
923 | desc->hdr.type); | ||
924 | break; | ||
925 | } | ||
926 | |||
927 | return ret; | ||
928 | } | ||
929 | |||
930 | /* | ||
931 | * fnic_wq_copy_cmpl_handler | ||
932 | * Routine to process wq copy | ||
933 | */ | ||
934 | int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do) | ||
935 | { | ||
936 | unsigned int wq_work_done = 0; | ||
937 | unsigned int i, cq_index; | ||
938 | unsigned int cur_work_done; | ||
939 | |||
940 | for (i = 0; i < fnic->wq_copy_count; i++) { | ||
941 | cq_index = i + fnic->raw_wq_count + fnic->rq_count; | ||
942 | cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index], | ||
943 | fnic_fcpio_cmpl_handler, | ||
944 | copy_work_to_do); | ||
945 | wq_work_done += cur_work_done; | ||
946 | } | ||
947 | return wq_work_done; | ||
948 | } | ||
949 | |||
950 | static void fnic_cleanup_io(struct fnic *fnic, int exclude_id) | ||
951 | { | ||
952 | unsigned int i; | ||
953 | struct fnic_io_req *io_req; | ||
954 | unsigned long flags = 0; | ||
955 | struct scsi_cmnd *sc; | ||
956 | spinlock_t *io_lock; | ||
957 | |||
958 | for (i = 0; i < FNIC_MAX_IO_REQ; i++) { | ||
959 | if (i == exclude_id) | ||
960 | continue; | ||
961 | |||
962 | sc = scsi_host_find_tag(fnic->lport->host, i); | ||
963 | if (!sc) | ||
964 | continue; | ||
965 | |||
966 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
967 | spin_lock_irqsave(io_lock, flags); | ||
968 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
969 | if (!io_req) { | ||
970 | spin_unlock_irqrestore(io_lock, flags); | ||
971 | goto cleanup_scsi_cmd; | ||
972 | } | ||
973 | |||
974 | CMD_SP(sc) = NULL; | ||
975 | |||
976 | spin_unlock_irqrestore(io_lock, flags); | ||
977 | |||
978 | /* | ||
979 | * If there is a scsi_cmnd associated with this io_req, then | ||
980 | * free the corresponding state | ||
981 | */ | ||
982 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
983 | mempool_free(io_req, fnic->io_req_pool); | ||
984 | |||
985 | cleanup_scsi_cmd: | ||
986 | sc->result = DID_TRANSPORT_DISRUPTED << 16; | ||
987 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "fnic_cleanup_io:" | ||
988 | " DID_TRANSPORT_DISRUPTED\n"); | ||
989 | |||
990 | /* Complete the command to SCSI */ | ||
991 | if (sc->scsi_done) | ||
992 | sc->scsi_done(sc); | ||
993 | } | ||
994 | } | ||
995 | |||
996 | void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, | ||
997 | struct fcpio_host_req *desc) | ||
998 | { | ||
999 | u32 id; | ||
1000 | struct fnic *fnic = vnic_dev_priv(wq->vdev); | ||
1001 | struct fnic_io_req *io_req; | ||
1002 | struct scsi_cmnd *sc; | ||
1003 | unsigned long flags; | ||
1004 | spinlock_t *io_lock; | ||
1005 | |||
1006 | /* get the tag reference */ | ||
1007 | fcpio_tag_id_dec(&desc->hdr.tag, &id); | ||
1008 | id &= FNIC_TAG_MASK; | ||
1009 | |||
1010 | if (id >= FNIC_MAX_IO_REQ) | ||
1011 | return; | ||
1012 | |||
1013 | sc = scsi_host_find_tag(fnic->lport->host, id); | ||
1014 | if (!sc) | ||
1015 | return; | ||
1016 | |||
1017 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1018 | spin_lock_irqsave(io_lock, flags); | ||
1019 | |||
1020 | /* Get the IO context which this desc refers to */ | ||
1021 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1022 | |||
1023 | /* fnic interrupts are turned off by now */ | ||
1024 | |||
1025 | if (!io_req) { | ||
1026 | spin_unlock_irqrestore(io_lock, flags); | ||
1027 | goto wq_copy_cleanup_scsi_cmd; | ||
1028 | } | ||
1029 | |||
1030 | CMD_SP(sc) = NULL; | ||
1031 | |||
1032 | spin_unlock_irqrestore(io_lock, flags); | ||
1033 | |||
1034 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
1035 | mempool_free(io_req, fnic->io_req_pool); | ||
1036 | |||
1037 | wq_copy_cleanup_scsi_cmd: | ||
1038 | sc->result = DID_NO_CONNECT << 16; | ||
1039 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" | ||
1040 | " DID_NO_CONNECT\n"); | ||
1041 | |||
1042 | if (sc->scsi_done) | ||
1043 | sc->scsi_done(sc); | ||
1044 | } | ||
1045 | |||
1046 | static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, | ||
1047 | u32 task_req, u8 *fc_lun, | ||
1048 | struct fnic_io_req *io_req) | ||
1049 | { | ||
1050 | struct vnic_wq_copy *wq = &fnic->wq_copy[0]; | ||
1051 | unsigned long flags; | ||
1052 | |||
1053 | spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); | ||
1054 | |||
1055 | if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) | ||
1056 | free_wq_copy_descs(fnic, wq); | ||
1057 | |||
1058 | if (!vnic_wq_copy_desc_avail(wq)) { | ||
1059 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); | ||
1060 | return 1; | ||
1061 | } | ||
1062 | fnic_queue_wq_copy_desc_itmf(wq, tag | FNIC_TAG_ABORT, | ||
1063 | 0, task_req, tag, fc_lun, io_req->port_id, | ||
1064 | fnic->config.ra_tov, fnic->config.ed_tov); | ||
1065 | |||
1066 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); | ||
1067 | return 0; | ||
1068 | } | ||
1069 | |||
1070 | void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) | ||
1071 | { | ||
1072 | int tag; | ||
1073 | struct fnic_io_req *io_req; | ||
1074 | spinlock_t *io_lock; | ||
1075 | unsigned long flags; | ||
1076 | struct scsi_cmnd *sc; | ||
1077 | struct scsi_lun fc_lun; | ||
1078 | enum fnic_ioreq_state old_ioreq_state; | ||
1079 | |||
1080 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
1081 | fnic->lport->host, | ||
1082 | "fnic_rport_reset_exch called portid 0x%06x\n", | ||
1083 | port_id); | ||
1084 | |||
1085 | if (fnic->in_remove) | ||
1086 | return; | ||
1087 | |||
1088 | for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) { | ||
1089 | sc = scsi_host_find_tag(fnic->lport->host, tag); | ||
1090 | if (!sc) | ||
1091 | continue; | ||
1092 | |||
1093 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1094 | spin_lock_irqsave(io_lock, flags); | ||
1095 | |||
1096 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1097 | |||
1098 | if (!io_req || io_req->port_id != port_id) { | ||
1099 | spin_unlock_irqrestore(io_lock, flags); | ||
1100 | continue; | ||
1101 | } | ||
1102 | |||
1103 | /* | ||
1104 | * Found IO that is still pending with firmware and | ||
1105 | * belongs to rport that went away | ||
1106 | */ | ||
1107 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { | ||
1108 | spin_unlock_irqrestore(io_lock, flags); | ||
1109 | continue; | ||
1110 | } | ||
1111 | old_ioreq_state = CMD_STATE(sc); | ||
1112 | CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; | ||
1113 | CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; | ||
1114 | |||
1115 | BUG_ON(io_req->abts_done); | ||
1116 | |||
1117 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1118 | "fnic_rport_reset_exch: Issuing abts\n"); | ||
1119 | |||
1120 | spin_unlock_irqrestore(io_lock, flags); | ||
1121 | |||
1122 | /* Now queue the abort command to firmware */ | ||
1123 | int_to_scsilun(sc->device->lun, &fc_lun); | ||
1124 | |||
1125 | if (fnic_queue_abort_io_req(fnic, tag, | ||
1126 | FCPIO_ITMF_ABT_TASK_TERM, | ||
1127 | fc_lun.scsi_lun, io_req)) { | ||
1128 | /* | ||
1129 | * Revert the cmd state back to old state, if | ||
1130 | * it hasnt changed in between. This cmd will get | ||
1131 | * aborted later by scsi_eh, or cleaned up during | ||
1132 | * lun reset | ||
1133 | */ | ||
1134 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1135 | |||
1136 | spin_lock_irqsave(io_lock, flags); | ||
1137 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) | ||
1138 | CMD_STATE(sc) = old_ioreq_state; | ||
1139 | spin_unlock_irqrestore(io_lock, flags); | ||
1140 | } | ||
1141 | } | ||
1142 | |||
1143 | } | ||
1144 | |||
1145 | void fnic_terminate_rport_io(struct fc_rport *rport) | ||
1146 | { | ||
1147 | int tag; | ||
1148 | struct fnic_io_req *io_req; | ||
1149 | spinlock_t *io_lock; | ||
1150 | unsigned long flags; | ||
1151 | struct scsi_cmnd *sc; | ||
1152 | struct scsi_lun fc_lun; | ||
1153 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | ||
1154 | struct fc_lport *lport = rdata->local_port; | ||
1155 | struct fnic *fnic = lport_priv(lport); | ||
1156 | struct fc_rport *cmd_rport; | ||
1157 | enum fnic_ioreq_state old_ioreq_state; | ||
1158 | |||
1159 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
1160 | fnic->lport->host, "fnic_terminate_rport_io called" | ||
1161 | " wwpn 0x%llx, wwnn0x%llx, portid 0x%06x\n", | ||
1162 | rport->port_name, rport->node_name, | ||
1163 | rport->port_id); | ||
1164 | |||
1165 | if (fnic->in_remove) | ||
1166 | return; | ||
1167 | |||
1168 | for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) { | ||
1169 | sc = scsi_host_find_tag(fnic->lport->host, tag); | ||
1170 | if (!sc) | ||
1171 | continue; | ||
1172 | |||
1173 | cmd_rport = starget_to_rport(scsi_target(sc->device)); | ||
1174 | if (rport != cmd_rport) | ||
1175 | continue; | ||
1176 | |||
1177 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1178 | spin_lock_irqsave(io_lock, flags); | ||
1179 | |||
1180 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1181 | |||
1182 | if (!io_req || rport != cmd_rport) { | ||
1183 | spin_unlock_irqrestore(io_lock, flags); | ||
1184 | continue; | ||
1185 | } | ||
1186 | |||
1187 | /* | ||
1188 | * Found IO that is still pending with firmware and | ||
1189 | * belongs to rport that went away | ||
1190 | */ | ||
1191 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { | ||
1192 | spin_unlock_irqrestore(io_lock, flags); | ||
1193 | continue; | ||
1194 | } | ||
1195 | old_ioreq_state = CMD_STATE(sc); | ||
1196 | CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; | ||
1197 | CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; | ||
1198 | |||
1199 | BUG_ON(io_req->abts_done); | ||
1200 | |||
1201 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
1202 | fnic->lport->host, | ||
1203 | "fnic_terminate_rport_io: Issuing abts\n"); | ||
1204 | |||
1205 | spin_unlock_irqrestore(io_lock, flags); | ||
1206 | |||
1207 | /* Now queue the abort command to firmware */ | ||
1208 | int_to_scsilun(sc->device->lun, &fc_lun); | ||
1209 | |||
1210 | if (fnic_queue_abort_io_req(fnic, tag, | ||
1211 | FCPIO_ITMF_ABT_TASK_TERM, | ||
1212 | fc_lun.scsi_lun, io_req)) { | ||
1213 | /* | ||
1214 | * Revert the cmd state back to old state, if | ||
1215 | * it hasnt changed in between. This cmd will get | ||
1216 | * aborted later by scsi_eh, or cleaned up during | ||
1217 | * lun reset | ||
1218 | */ | ||
1219 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1220 | |||
1221 | spin_lock_irqsave(io_lock, flags); | ||
1222 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) | ||
1223 | CMD_STATE(sc) = old_ioreq_state; | ||
1224 | spin_unlock_irqrestore(io_lock, flags); | ||
1225 | } | ||
1226 | } | ||
1227 | |||
1228 | } | ||
1229 | |||
1230 | static void fnic_block_error_handler(struct scsi_cmnd *sc) | ||
1231 | { | ||
1232 | struct Scsi_Host *shost = sc->device->host; | ||
1233 | struct fc_rport *rport = starget_to_rport(scsi_target(sc->device)); | ||
1234 | unsigned long flags; | ||
1235 | |||
1236 | spin_lock_irqsave(shost->host_lock, flags); | ||
1237 | while (rport->port_state == FC_PORTSTATE_BLOCKED) { | ||
1238 | spin_unlock_irqrestore(shost->host_lock, flags); | ||
1239 | msleep(1000); | ||
1240 | spin_lock_irqsave(shost->host_lock, flags); | ||
1241 | } | ||
1242 | spin_unlock_irqrestore(shost->host_lock, flags); | ||
1243 | |||
1244 | } | ||
1245 | |||
1246 | /* | ||
1247 | * This function is exported to SCSI for sending abort cmnds. | ||
1248 | * A SCSI IO is represented by a io_req in the driver. | ||
1249 | * The ioreq is linked to the SCSI Cmd, thus a link with the ULP's IO. | ||
1250 | */ | ||
1251 | int fnic_abort_cmd(struct scsi_cmnd *sc) | ||
1252 | { | ||
1253 | struct fc_lport *lp; | ||
1254 | struct fnic *fnic; | ||
1255 | struct fnic_io_req *io_req; | ||
1256 | struct fc_rport *rport; | ||
1257 | spinlock_t *io_lock; | ||
1258 | unsigned long flags; | ||
1259 | int ret = SUCCESS; | ||
1260 | u32 task_req; | ||
1261 | struct scsi_lun fc_lun; | ||
1262 | DECLARE_COMPLETION_ONSTACK(tm_done); | ||
1263 | |||
1264 | /* Wait for rport to unblock */ | ||
1265 | fnic_block_error_handler(sc); | ||
1266 | |||
1267 | /* Get local-port, check ready and link up */ | ||
1268 | lp = shost_priv(sc->device->host); | ||
1269 | |||
1270 | fnic = lport_priv(lp); | ||
1271 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
1272 | fnic->lport->host, | ||
1273 | "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %d\n", | ||
1274 | (starget_to_rport(scsi_target(sc->device)))->port_id, | ||
1275 | sc->device->lun, sc->request->tag); | ||
1276 | |||
1277 | if (lp->state != LPORT_ST_READY || !(lp->link_up)) { | ||
1278 | ret = FAILED; | ||
1279 | goto fnic_abort_cmd_end; | ||
1280 | } | ||
1281 | |||
1282 | /* | ||
1283 | * Avoid a race between SCSI issuing the abort and the device | ||
1284 | * completing the command. | ||
1285 | * | ||
1286 | * If the command is already completed by the fw cmpl code, | ||
1287 | * we just return SUCCESS from here. This means that the abort | ||
1288 | * succeeded. In the SCSI ML, since the timeout for command has | ||
1289 | * happened, the completion wont actually complete the command | ||
1290 | * and it will be considered as an aborted command | ||
1291 | * | ||
1292 | * The CMD_SP will not be cleared except while holding io_req_lock. | ||
1293 | */ | ||
1294 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1295 | spin_lock_irqsave(io_lock, flags); | ||
1296 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1297 | if (!io_req) { | ||
1298 | spin_unlock_irqrestore(io_lock, flags); | ||
1299 | goto fnic_abort_cmd_end; | ||
1300 | } | ||
1301 | |||
1302 | io_req->abts_done = &tm_done; | ||
1303 | |||
1304 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { | ||
1305 | spin_unlock_irqrestore(io_lock, flags); | ||
1306 | goto wait_pending; | ||
1307 | } | ||
1308 | /* | ||
1309 | * Command is still pending, need to abort it | ||
1310 | * If the firmware completes the command after this point, | ||
1311 | * the completion wont be done till mid-layer, since abort | ||
1312 | * has already started. | ||
1313 | */ | ||
1314 | CMD_STATE(sc) = FNIC_IOREQ_ABTS_PENDING; | ||
1315 | CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; | ||
1316 | |||
1317 | spin_unlock_irqrestore(io_lock, flags); | ||
1318 | |||
1319 | /* | ||
1320 | * Check readiness of the remote port. If the path to remote | ||
1321 | * port is up, then send abts to the remote port to terminate | ||
1322 | * the IO. Else, just locally terminate the IO in the firmware | ||
1323 | */ | ||
1324 | rport = starget_to_rport(scsi_target(sc->device)); | ||
1325 | if (fc_remote_port_chkready(rport) == 0) | ||
1326 | task_req = FCPIO_ITMF_ABT_TASK; | ||
1327 | else | ||
1328 | task_req = FCPIO_ITMF_ABT_TASK_TERM; | ||
1329 | |||
1330 | /* Now queue the abort command to firmware */ | ||
1331 | int_to_scsilun(sc->device->lun, &fc_lun); | ||
1332 | |||
1333 | if (fnic_queue_abort_io_req(fnic, sc->request->tag, task_req, | ||
1334 | fc_lun.scsi_lun, io_req)) { | ||
1335 | spin_lock_irqsave(io_lock, flags); | ||
1336 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1337 | if (io_req) | ||
1338 | io_req->abts_done = NULL; | ||
1339 | spin_unlock_irqrestore(io_lock, flags); | ||
1340 | ret = FAILED; | ||
1341 | goto fnic_abort_cmd_end; | ||
1342 | } | ||
1343 | |||
1344 | /* | ||
1345 | * We queued an abort IO, wait for its completion. | ||
1346 | * Once the firmware completes the abort command, it will | ||
1347 | * wake up this thread. | ||
1348 | */ | ||
1349 | wait_pending: | ||
1350 | wait_for_completion_timeout(&tm_done, | ||
1351 | msecs_to_jiffies | ||
1352 | (2 * fnic->config.ra_tov + | ||
1353 | fnic->config.ed_tov)); | ||
1354 | |||
1355 | /* Check the abort status */ | ||
1356 | spin_lock_irqsave(io_lock, flags); | ||
1357 | |||
1358 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1359 | if (!io_req) { | ||
1360 | spin_unlock_irqrestore(io_lock, flags); | ||
1361 | ret = FAILED; | ||
1362 | goto fnic_abort_cmd_end; | ||
1363 | } | ||
1364 | io_req->abts_done = NULL; | ||
1365 | |||
1366 | /* fw did not complete abort, timed out */ | ||
1367 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { | ||
1368 | spin_unlock_irqrestore(io_lock, flags); | ||
1369 | ret = FAILED; | ||
1370 | goto fnic_abort_cmd_end; | ||
1371 | } | ||
1372 | |||
1373 | /* | ||
1374 | * firmware completed the abort, check the status, | ||
1375 | * free the io_req irrespective of failure or success | ||
1376 | */ | ||
1377 | if (CMD_ABTS_STATUS(sc) != FCPIO_SUCCESS) | ||
1378 | ret = FAILED; | ||
1379 | |||
1380 | CMD_SP(sc) = NULL; | ||
1381 | |||
1382 | spin_unlock_irqrestore(io_lock, flags); | ||
1383 | |||
1384 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
1385 | mempool_free(io_req, fnic->io_req_pool); | ||
1386 | |||
1387 | fnic_abort_cmd_end: | ||
1388 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1389 | "Returning from abort cmd %s\n", | ||
1390 | (ret == SUCCESS) ? | ||
1391 | "SUCCESS" : "FAILED"); | ||
1392 | return ret; | ||
1393 | } | ||
1394 | |||
1395 | static inline int fnic_queue_dr_io_req(struct fnic *fnic, | ||
1396 | struct scsi_cmnd *sc, | ||
1397 | struct fnic_io_req *io_req) | ||
1398 | { | ||
1399 | struct vnic_wq_copy *wq = &fnic->wq_copy[0]; | ||
1400 | struct scsi_lun fc_lun; | ||
1401 | int ret = 0; | ||
1402 | unsigned long intr_flags; | ||
1403 | |||
1404 | spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); | ||
1405 | |||
1406 | if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) | ||
1407 | free_wq_copy_descs(fnic, wq); | ||
1408 | |||
1409 | if (!vnic_wq_copy_desc_avail(wq)) { | ||
1410 | ret = -EAGAIN; | ||
1411 | goto lr_io_req_end; | ||
1412 | } | ||
1413 | |||
1414 | /* fill in the lun info */ | ||
1415 | int_to_scsilun(sc->device->lun, &fc_lun); | ||
1416 | |||
1417 | fnic_queue_wq_copy_desc_itmf(wq, sc->request->tag | FNIC_TAG_DEV_RST, | ||
1418 | 0, FCPIO_ITMF_LUN_RESET, SCSI_NO_TAG, | ||
1419 | fc_lun.scsi_lun, io_req->port_id, | ||
1420 | fnic->config.ra_tov, fnic->config.ed_tov); | ||
1421 | |||
1422 | lr_io_req_end: | ||
1423 | spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); | ||
1424 | |||
1425 | return ret; | ||
1426 | } | ||
1427 | |||
1428 | /* | ||
1429 | * Clean up any pending aborts on the lun | ||
1430 | * For each outstanding IO on this lun, whose abort is not completed by fw, | ||
1431 | * issue a local abort. Wait for abort to complete. Return 0 if all commands | ||
1432 | * successfully aborted, 1 otherwise | ||
1433 | */ | ||
1434 | static int fnic_clean_pending_aborts(struct fnic *fnic, | ||
1435 | struct scsi_cmnd *lr_sc) | ||
1436 | { | ||
1437 | int tag; | ||
1438 | struct fnic_io_req *io_req; | ||
1439 | spinlock_t *io_lock; | ||
1440 | unsigned long flags; | ||
1441 | int ret = 0; | ||
1442 | struct scsi_cmnd *sc; | ||
1443 | struct fc_rport *rport; | ||
1444 | struct scsi_lun fc_lun; | ||
1445 | struct scsi_device *lun_dev = lr_sc->device; | ||
1446 | DECLARE_COMPLETION_ONSTACK(tm_done); | ||
1447 | |||
1448 | for (tag = 0; tag < FNIC_MAX_IO_REQ; tag++) { | ||
1449 | sc = scsi_host_find_tag(fnic->lport->host, tag); | ||
1450 | /* | ||
1451 | * ignore this lun reset cmd or cmds that do not belong to | ||
1452 | * this lun | ||
1453 | */ | ||
1454 | if (!sc || sc == lr_sc || sc->device != lun_dev) | ||
1455 | continue; | ||
1456 | |||
1457 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1458 | spin_lock_irqsave(io_lock, flags); | ||
1459 | |||
1460 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1461 | |||
1462 | if (!io_req || sc->device != lun_dev) { | ||
1463 | spin_unlock_irqrestore(io_lock, flags); | ||
1464 | continue; | ||
1465 | } | ||
1466 | |||
1467 | /* | ||
1468 | * Found IO that is still pending with firmware and | ||
1469 | * belongs to the LUN that we are resetting | ||
1470 | */ | ||
1471 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1472 | "Found IO in %s on lun\n", | ||
1473 | fnic_ioreq_state_to_str(CMD_STATE(sc))); | ||
1474 | |||
1475 | BUG_ON(CMD_STATE(sc) != FNIC_IOREQ_ABTS_PENDING); | ||
1476 | |||
1477 | CMD_ABTS_STATUS(sc) = FCPIO_INVALID_CODE; | ||
1478 | io_req->abts_done = &tm_done; | ||
1479 | spin_unlock_irqrestore(io_lock, flags); | ||
1480 | |||
1481 | /* Now queue the abort command to firmware */ | ||
1482 | int_to_scsilun(sc->device->lun, &fc_lun); | ||
1483 | rport = starget_to_rport(scsi_target(sc->device)); | ||
1484 | |||
1485 | if (fnic_queue_abort_io_req(fnic, tag, | ||
1486 | FCPIO_ITMF_ABT_TASK_TERM, | ||
1487 | fc_lun.scsi_lun, io_req)) { | ||
1488 | spin_lock_irqsave(io_lock, flags); | ||
1489 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1490 | if (io_req) | ||
1491 | io_req->abts_done = NULL; | ||
1492 | spin_unlock_irqrestore(io_lock, flags); | ||
1493 | ret = 1; | ||
1494 | goto clean_pending_aborts_end; | ||
1495 | } | ||
1496 | |||
1497 | wait_for_completion_timeout(&tm_done, | ||
1498 | msecs_to_jiffies | ||
1499 | (fnic->config.ed_tov)); | ||
1500 | |||
1501 | /* Recheck cmd state to check if it is now aborted */ | ||
1502 | spin_lock_irqsave(io_lock, flags); | ||
1503 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1504 | if (!io_req) { | ||
1505 | spin_unlock_irqrestore(io_lock, flags); | ||
1506 | ret = 1; | ||
1507 | goto clean_pending_aborts_end; | ||
1508 | } | ||
1509 | |||
1510 | io_req->abts_done = NULL; | ||
1511 | |||
1512 | /* if abort is still pending with fw, fail */ | ||
1513 | if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { | ||
1514 | spin_unlock_irqrestore(io_lock, flags); | ||
1515 | ret = 1; | ||
1516 | goto clean_pending_aborts_end; | ||
1517 | } | ||
1518 | CMD_SP(sc) = NULL; | ||
1519 | spin_unlock_irqrestore(io_lock, flags); | ||
1520 | |||
1521 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
1522 | mempool_free(io_req, fnic->io_req_pool); | ||
1523 | } | ||
1524 | |||
1525 | clean_pending_aborts_end: | ||
1526 | return ret; | ||
1527 | } | ||
1528 | |||
1529 | /* | ||
1530 | * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN | ||
1531 | * fail to get aborted. It calls driver's eh_device_reset with a SCSI command | ||
1532 | * on the LUN. | ||
1533 | */ | ||
1534 | int fnic_device_reset(struct scsi_cmnd *sc) | ||
1535 | { | ||
1536 | struct fc_lport *lp; | ||
1537 | struct fnic *fnic; | ||
1538 | struct fnic_io_req *io_req; | ||
1539 | struct fc_rport *rport; | ||
1540 | int status; | ||
1541 | int ret = FAILED; | ||
1542 | spinlock_t *io_lock; | ||
1543 | unsigned long flags; | ||
1544 | DECLARE_COMPLETION_ONSTACK(tm_done); | ||
1545 | |||
1546 | /* Wait for rport to unblock */ | ||
1547 | fnic_block_error_handler(sc); | ||
1548 | |||
1549 | /* Get local-port, check ready and link up */ | ||
1550 | lp = shost_priv(sc->device->host); | ||
1551 | |||
1552 | fnic = lport_priv(lp); | ||
1553 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
1554 | fnic->lport->host, | ||
1555 | "Device reset called FCID 0x%x, LUN 0x%x\n", | ||
1556 | (starget_to_rport(scsi_target(sc->device)))->port_id, | ||
1557 | sc->device->lun); | ||
1558 | |||
1559 | |||
1560 | if (lp->state != LPORT_ST_READY || !(lp->link_up)) | ||
1561 | goto fnic_device_reset_end; | ||
1562 | |||
1563 | /* Check if remote port up */ | ||
1564 | rport = starget_to_rport(scsi_target(sc->device)); | ||
1565 | if (fc_remote_port_chkready(rport)) | ||
1566 | goto fnic_device_reset_end; | ||
1567 | |||
1568 | io_lock = fnic_io_lock_hash(fnic, sc); | ||
1569 | spin_lock_irqsave(io_lock, flags); | ||
1570 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1571 | |||
1572 | /* | ||
1573 | * If there is a io_req attached to this command, then use it, | ||
1574 | * else allocate a new one. | ||
1575 | */ | ||
1576 | if (!io_req) { | ||
1577 | io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); | ||
1578 | if (!io_req) { | ||
1579 | spin_unlock_irqrestore(io_lock, flags); | ||
1580 | goto fnic_device_reset_end; | ||
1581 | } | ||
1582 | memset(io_req, 0, sizeof(*io_req)); | ||
1583 | io_req->port_id = rport->port_id; | ||
1584 | CMD_SP(sc) = (char *)io_req; | ||
1585 | } | ||
1586 | io_req->dr_done = &tm_done; | ||
1587 | CMD_STATE(sc) = FNIC_IOREQ_CMD_PENDING; | ||
1588 | CMD_LR_STATUS(sc) = FCPIO_INVALID_CODE; | ||
1589 | spin_unlock_irqrestore(io_lock, flags); | ||
1590 | |||
1591 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %d\n", | ||
1592 | sc->request->tag); | ||
1593 | |||
1594 | /* | ||
1595 | * issue the device reset, if enqueue failed, clean up the ioreq | ||
1596 | * and break assoc with scsi cmd | ||
1597 | */ | ||
1598 | if (fnic_queue_dr_io_req(fnic, sc, io_req)) { | ||
1599 | spin_lock_irqsave(io_lock, flags); | ||
1600 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1601 | if (io_req) | ||
1602 | io_req->dr_done = NULL; | ||
1603 | goto fnic_device_reset_clean; | ||
1604 | } | ||
1605 | |||
1606 | /* | ||
1607 | * Wait on the local completion for LUN reset. The io_req may be | ||
1608 | * freed while we wait since we hold no lock. | ||
1609 | */ | ||
1610 | wait_for_completion_timeout(&tm_done, | ||
1611 | msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); | ||
1612 | |||
1613 | spin_lock_irqsave(io_lock, flags); | ||
1614 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1615 | if (!io_req) { | ||
1616 | spin_unlock_irqrestore(io_lock, flags); | ||
1617 | goto fnic_device_reset_end; | ||
1618 | } | ||
1619 | io_req->dr_done = NULL; | ||
1620 | |||
1621 | status = CMD_LR_STATUS(sc); | ||
1622 | spin_unlock_irqrestore(io_lock, flags); | ||
1623 | |||
1624 | /* | ||
1625 | * If lun reset not completed, bail out with failed. io_req | ||
1626 | * gets cleaned up during higher levels of EH | ||
1627 | */ | ||
1628 | if (status == FCPIO_INVALID_CODE) { | ||
1629 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1630 | "Device reset timed out\n"); | ||
1631 | goto fnic_device_reset_end; | ||
1632 | } | ||
1633 | |||
1634 | /* Completed, but not successful, clean up the io_req, return fail */ | ||
1635 | if (status != FCPIO_SUCCESS) { | ||
1636 | spin_lock_irqsave(io_lock, flags); | ||
1637 | FNIC_SCSI_DBG(KERN_DEBUG, | ||
1638 | fnic->lport->host, | ||
1639 | "Device reset completed - failed\n"); | ||
1640 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1641 | goto fnic_device_reset_clean; | ||
1642 | } | ||
1643 | |||
1644 | /* | ||
1645 | * Clean up any aborts on this lun that have still not | ||
1646 | * completed. If any of these fail, then LUN reset fails. | ||
1647 | * clean_pending_aborts cleans all cmds on this lun except | ||
1648 | * the lun reset cmd. If all cmds get cleaned, the lun reset | ||
1649 | * succeeds | ||
1650 | */ | ||
1651 | if (fnic_clean_pending_aborts(fnic, sc)) { | ||
1652 | spin_lock_irqsave(io_lock, flags); | ||
1653 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1654 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1655 | "Device reset failed" | ||
1656 | " since could not abort all IOs\n"); | ||
1657 | goto fnic_device_reset_clean; | ||
1658 | } | ||
1659 | |||
1660 | /* Clean lun reset command */ | ||
1661 | spin_lock_irqsave(io_lock, flags); | ||
1662 | io_req = (struct fnic_io_req *)CMD_SP(sc); | ||
1663 | if (io_req) | ||
1664 | /* Completed, and successful */ | ||
1665 | ret = SUCCESS; | ||
1666 | |||
1667 | fnic_device_reset_clean: | ||
1668 | if (io_req) | ||
1669 | CMD_SP(sc) = NULL; | ||
1670 | |||
1671 | spin_unlock_irqrestore(io_lock, flags); | ||
1672 | |||
1673 | if (io_req) { | ||
1674 | fnic_release_ioreq_buf(fnic, io_req, sc); | ||
1675 | mempool_free(io_req, fnic->io_req_pool); | ||
1676 | } | ||
1677 | |||
1678 | fnic_device_reset_end: | ||
1679 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1680 | "Returning from device reset %s\n", | ||
1681 | (ret == SUCCESS) ? | ||
1682 | "SUCCESS" : "FAILED"); | ||
1683 | return ret; | ||
1684 | } | ||
1685 | |||
1686 | /* Clean up all IOs, clean up libFC local port */ | ||
1687 | int fnic_reset(struct Scsi_Host *shost) | ||
1688 | { | ||
1689 | struct fc_lport *lp; | ||
1690 | struct fnic *fnic; | ||
1691 | int ret = SUCCESS; | ||
1692 | |||
1693 | lp = shost_priv(shost); | ||
1694 | fnic = lport_priv(lp); | ||
1695 | |||
1696 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1697 | "fnic_reset called\n"); | ||
1698 | |||
1699 | /* | ||
1700 | * Reset local port, this will clean up libFC exchanges, | ||
1701 | * reset remote port sessions, and if link is up, begin flogi | ||
1702 | */ | ||
1703 | if (lp->tt.lport_reset(lp)) | ||
1704 | ret = FAILED; | ||
1705 | |||
1706 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1707 | "Returning from fnic reset %s\n", | ||
1708 | (ret == SUCCESS) ? | ||
1709 | "SUCCESS" : "FAILED"); | ||
1710 | |||
1711 | return ret; | ||
1712 | } | ||
1713 | |||
1714 | /* | ||
1715 | * SCSI Error handling calls driver's eh_host_reset if all prior | ||
1716 | * error handling levels return FAILED. If host reset completes | ||
1717 | * successfully, and if link is up, then Fabric login begins. | ||
1718 | * | ||
1719 | * Host Reset is the highest level of error recovery. If this fails, then | ||
1720 | * host is offlined by SCSI. | ||
1721 | * | ||
1722 | */ | ||
1723 | int fnic_host_reset(struct scsi_cmnd *sc) | ||
1724 | { | ||
1725 | int ret; | ||
1726 | unsigned long wait_host_tmo; | ||
1727 | struct Scsi_Host *shost = sc->device->host; | ||
1728 | struct fc_lport *lp = shost_priv(shost); | ||
1729 | |||
1730 | /* | ||
1731 | * If fnic_reset is successful, wait for fabric login to complete | ||
1732 | * scsi-ml tries to send a TUR to every device if host reset is | ||
1733 | * successful, so before returning to scsi, fabric should be up | ||
1734 | */ | ||
1735 | ret = fnic_reset(shost); | ||
1736 | if (ret == SUCCESS) { | ||
1737 | wait_host_tmo = jiffies + FNIC_HOST_RESET_SETTLE_TIME * HZ; | ||
1738 | ret = FAILED; | ||
1739 | while (time_before(jiffies, wait_host_tmo)) { | ||
1740 | if ((lp->state == LPORT_ST_READY) && | ||
1741 | (lp->link_up)) { | ||
1742 | ret = SUCCESS; | ||
1743 | break; | ||
1744 | } | ||
1745 | ssleep(1); | ||
1746 | } | ||
1747 | } | ||
1748 | |||
1749 | return ret; | ||
1750 | } | ||
1751 | |||
1752 | /* | ||
1753 | * This fxn is called from libFC when host is removed | ||
1754 | */ | ||
1755 | void fnic_scsi_abort_io(struct fc_lport *lp) | ||
1756 | { | ||
1757 | int err = 0; | ||
1758 | unsigned long flags; | ||
1759 | enum fnic_state old_state; | ||
1760 | struct fnic *fnic = lport_priv(lp); | ||
1761 | DECLARE_COMPLETION_ONSTACK(remove_wait); | ||
1762 | |||
1763 | /* Issue firmware reset for fnic, wait for reset to complete */ | ||
1764 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
1765 | fnic->remove_wait = &remove_wait; | ||
1766 | old_state = fnic->state; | ||
1767 | fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; | ||
1768 | vnic_dev_del_addr(fnic->vdev, fnic->data_src_addr); | ||
1769 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
1770 | |||
1771 | err = fnic_fw_reset_handler(fnic); | ||
1772 | if (err) { | ||
1773 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
1774 | if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) | ||
1775 | fnic->state = old_state; | ||
1776 | fnic->remove_wait = NULL; | ||
1777 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
1778 | return; | ||
1779 | } | ||
1780 | |||
1781 | /* Wait for firmware reset to complete */ | ||
1782 | wait_for_completion_timeout(&remove_wait, | ||
1783 | msecs_to_jiffies(FNIC_RMDEVICE_TIMEOUT)); | ||
1784 | |||
1785 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
1786 | fnic->remove_wait = NULL; | ||
1787 | FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, | ||
1788 | "fnic_scsi_abort_io %s\n", | ||
1789 | (fnic->state == FNIC_IN_ETH_MODE) ? | ||
1790 | "SUCCESS" : "FAILED"); | ||
1791 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
1792 | |||
1793 | } | ||
1794 | |||
1795 | /* | ||
1796 | * This fxn called from libFC to clean up driver IO state on link down | ||
1797 | */ | ||
1798 | void fnic_scsi_cleanup(struct fc_lport *lp) | ||
1799 | { | ||
1800 | unsigned long flags; | ||
1801 | enum fnic_state old_state; | ||
1802 | struct fnic *fnic = lport_priv(lp); | ||
1803 | |||
1804 | /* issue fw reset */ | ||
1805 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
1806 | old_state = fnic->state; | ||
1807 | fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; | ||
1808 | vnic_dev_del_addr(fnic->vdev, fnic->data_src_addr); | ||
1809 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
1810 | |||
1811 | if (fnic_fw_reset_handler(fnic)) { | ||
1812 | spin_lock_irqsave(&fnic->fnic_lock, flags); | ||
1813 | if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) | ||
1814 | fnic->state = old_state; | ||
1815 | spin_unlock_irqrestore(&fnic->fnic_lock, flags); | ||
1816 | } | ||
1817 | |||
1818 | } | ||
1819 | |||
1820 | void fnic_empty_scsi_cleanup(struct fc_lport *lp) | ||
1821 | { | ||
1822 | } | ||
1823 | |||
1824 | void fnic_exch_mgr_reset(struct fc_lport *lp, u32 sid, u32 did) | ||
1825 | { | ||
1826 | struct fnic *fnic = lport_priv(lp); | ||
1827 | |||
1828 | /* Non-zero sid, nothing to do */ | ||
1829 | if (sid) | ||
1830 | goto call_fc_exch_mgr_reset; | ||
1831 | |||
1832 | if (did) { | ||
1833 | fnic_rport_exch_reset(fnic, did); | ||
1834 | goto call_fc_exch_mgr_reset; | ||
1835 | } | ||
1836 | |||
1837 | /* | ||
1838 | * sid = 0, did = 0 | ||
1839 | * link down or device being removed | ||
1840 | */ | ||
1841 | if (!fnic->in_remove) | ||
1842 | fnic_scsi_cleanup(lp); | ||
1843 | else | ||
1844 | fnic_scsi_abort_io(lp); | ||
1845 | |||
1846 | /* call libFC exch mgr reset to reset its exchanges */ | ||
1847 | call_fc_exch_mgr_reset: | ||
1848 | fc_exch_mgr_reset(lp, sid, did); | ||
1849 | |||
1850 | } | ||
diff --git a/drivers/scsi/fnic/rq_enet_desc.h b/drivers/scsi/fnic/rq_enet_desc.h new file mode 100644 index 000000000000..92e80ae6b725 --- /dev/null +++ b/drivers/scsi/fnic/rq_enet_desc.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _RQ_ENET_DESC_H_ | ||
19 | #define _RQ_ENET_DESC_H_ | ||
20 | |||
21 | /* Ethernet receive queue descriptor: 16B */ | ||
22 | struct rq_enet_desc { | ||
23 | __le64 address; | ||
24 | __le16 length_type; | ||
25 | u8 reserved[6]; | ||
26 | }; | ||
27 | |||
28 | enum rq_enet_type_types { | ||
29 | RQ_ENET_TYPE_ONLY_SOP = 0, | ||
30 | RQ_ENET_TYPE_NOT_SOP = 1, | ||
31 | RQ_ENET_TYPE_RESV2 = 2, | ||
32 | RQ_ENET_TYPE_RESV3 = 3, | ||
33 | }; | ||
34 | |||
35 | #define RQ_ENET_ADDR_BITS 64 | ||
36 | #define RQ_ENET_LEN_BITS 14 | ||
37 | #define RQ_ENET_LEN_MASK ((1 << RQ_ENET_LEN_BITS) - 1) | ||
38 | #define RQ_ENET_TYPE_BITS 2 | ||
39 | #define RQ_ENET_TYPE_MASK ((1 << RQ_ENET_TYPE_BITS) - 1) | ||
40 | |||
41 | static inline void rq_enet_desc_enc(struct rq_enet_desc *desc, | ||
42 | u64 address, u8 type, u16 length) | ||
43 | { | ||
44 | desc->address = cpu_to_le64(address); | ||
45 | desc->length_type = cpu_to_le16((length & RQ_ENET_LEN_MASK) | | ||
46 | ((type & RQ_ENET_TYPE_MASK) << RQ_ENET_LEN_BITS)); | ||
47 | } | ||
48 | |||
49 | static inline void rq_enet_desc_dec(struct rq_enet_desc *desc, | ||
50 | u64 *address, u8 *type, u16 *length) | ||
51 | { | ||
52 | *address = le64_to_cpu(desc->address); | ||
53 | *length = le16_to_cpu(desc->length_type) & RQ_ENET_LEN_MASK; | ||
54 | *type = (u8)((le16_to_cpu(desc->length_type) >> RQ_ENET_LEN_BITS) & | ||
55 | RQ_ENET_TYPE_MASK); | ||
56 | } | ||
57 | |||
58 | #endif /* _RQ_ENET_DESC_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_cq.c b/drivers/scsi/fnic/vnic_cq.c new file mode 100644 index 000000000000..c5db32eda5ef --- /dev/null +++ b/drivers/scsi/fnic/vnic_cq.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/types.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include "vnic_dev.h" | ||
22 | #include "vnic_cq.h" | ||
23 | |||
24 | void vnic_cq_free(struct vnic_cq *cq) | ||
25 | { | ||
26 | vnic_dev_free_desc_ring(cq->vdev, &cq->ring); | ||
27 | |||
28 | cq->ctrl = NULL; | ||
29 | } | ||
30 | |||
31 | int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index, | ||
32 | unsigned int desc_count, unsigned int desc_size) | ||
33 | { | ||
34 | int err; | ||
35 | |||
36 | cq->index = index; | ||
37 | cq->vdev = vdev; | ||
38 | |||
39 | cq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_CQ, index); | ||
40 | if (!cq->ctrl) { | ||
41 | printk(KERN_ERR "Failed to hook CQ[%d] resource\n", index); | ||
42 | return -EINVAL; | ||
43 | } | ||
44 | |||
45 | err = vnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, desc_size); | ||
46 | if (err) | ||
47 | return err; | ||
48 | |||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable, | ||
53 | unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail, | ||
54 | unsigned int cq_tail_color, unsigned int interrupt_enable, | ||
55 | unsigned int cq_entry_enable, unsigned int cq_message_enable, | ||
56 | unsigned int interrupt_offset, u64 cq_message_addr) | ||
57 | { | ||
58 | u64 paddr; | ||
59 | |||
60 | paddr = (u64)cq->ring.base_addr | VNIC_PADDR_TARGET; | ||
61 | writeq(paddr, &cq->ctrl->ring_base); | ||
62 | iowrite32(cq->ring.desc_count, &cq->ctrl->ring_size); | ||
63 | iowrite32(flow_control_enable, &cq->ctrl->flow_control_enable); | ||
64 | iowrite32(color_enable, &cq->ctrl->color_enable); | ||
65 | iowrite32(cq_head, &cq->ctrl->cq_head); | ||
66 | iowrite32(cq_tail, &cq->ctrl->cq_tail); | ||
67 | iowrite32(cq_tail_color, &cq->ctrl->cq_tail_color); | ||
68 | iowrite32(interrupt_enable, &cq->ctrl->interrupt_enable); | ||
69 | iowrite32(cq_entry_enable, &cq->ctrl->cq_entry_enable); | ||
70 | iowrite32(cq_message_enable, &cq->ctrl->cq_message_enable); | ||
71 | iowrite32(interrupt_offset, &cq->ctrl->interrupt_offset); | ||
72 | writeq(cq_message_addr, &cq->ctrl->cq_message_addr); | ||
73 | } | ||
74 | |||
75 | void vnic_cq_clean(struct vnic_cq *cq) | ||
76 | { | ||
77 | cq->to_clean = 0; | ||
78 | cq->last_color = 0; | ||
79 | |||
80 | iowrite32(0, &cq->ctrl->cq_head); | ||
81 | iowrite32(0, &cq->ctrl->cq_tail); | ||
82 | iowrite32(1, &cq->ctrl->cq_tail_color); | ||
83 | |||
84 | vnic_dev_clear_desc_ring(&cq->ring); | ||
85 | } | ||
diff --git a/drivers/scsi/fnic/vnic_cq.h b/drivers/scsi/fnic/vnic_cq.h new file mode 100644 index 000000000000..4ede6809fb1e --- /dev/null +++ b/drivers/scsi/fnic/vnic_cq.h | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_CQ_H_ | ||
19 | #define _VNIC_CQ_H_ | ||
20 | |||
21 | #include "cq_desc.h" | ||
22 | #include "vnic_dev.h" | ||
23 | |||
24 | /* | ||
25 | * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth | ||
26 | * Driver) when both are built with CONFIG options =y | ||
27 | */ | ||
28 | #define vnic_cq_service fnic_cq_service | ||
29 | #define vnic_cq_free fnic_cq_free | ||
30 | #define vnic_cq_alloc fnic_cq_alloc | ||
31 | #define vnic_cq_init fnic_cq_init | ||
32 | #define vnic_cq_clean fnic_cq_clean | ||
33 | |||
34 | /* Completion queue control */ | ||
35 | struct vnic_cq_ctrl { | ||
36 | u64 ring_base; /* 0x00 */ | ||
37 | u32 ring_size; /* 0x08 */ | ||
38 | u32 pad0; | ||
39 | u32 flow_control_enable; /* 0x10 */ | ||
40 | u32 pad1; | ||
41 | u32 color_enable; /* 0x18 */ | ||
42 | u32 pad2; | ||
43 | u32 cq_head; /* 0x20 */ | ||
44 | u32 pad3; | ||
45 | u32 cq_tail; /* 0x28 */ | ||
46 | u32 pad4; | ||
47 | u32 cq_tail_color; /* 0x30 */ | ||
48 | u32 pad5; | ||
49 | u32 interrupt_enable; /* 0x38 */ | ||
50 | u32 pad6; | ||
51 | u32 cq_entry_enable; /* 0x40 */ | ||
52 | u32 pad7; | ||
53 | u32 cq_message_enable; /* 0x48 */ | ||
54 | u32 pad8; | ||
55 | u32 interrupt_offset; /* 0x50 */ | ||
56 | u32 pad9; | ||
57 | u64 cq_message_addr; /* 0x58 */ | ||
58 | u32 pad10; | ||
59 | }; | ||
60 | |||
61 | struct vnic_cq { | ||
62 | unsigned int index; | ||
63 | struct vnic_dev *vdev; | ||
64 | struct vnic_cq_ctrl __iomem *ctrl; /* memory-mapped */ | ||
65 | struct vnic_dev_ring ring; | ||
66 | unsigned int to_clean; | ||
67 | unsigned int last_color; | ||
68 | }; | ||
69 | |||
70 | static inline unsigned int vnic_cq_service(struct vnic_cq *cq, | ||
71 | unsigned int work_to_do, | ||
72 | int (*q_service)(struct vnic_dev *vdev, struct cq_desc *cq_desc, | ||
73 | u8 type, u16 q_number, u16 completed_index, void *opaque), | ||
74 | void *opaque) | ||
75 | { | ||
76 | struct cq_desc *cq_desc; | ||
77 | unsigned int work_done = 0; | ||
78 | u16 q_number, completed_index; | ||
79 | u8 type, color; | ||
80 | |||
81 | cq_desc = (struct cq_desc *)((u8 *)cq->ring.descs + | ||
82 | cq->ring.desc_size * cq->to_clean); | ||
83 | cq_desc_dec(cq_desc, &type, &color, | ||
84 | &q_number, &completed_index); | ||
85 | |||
86 | while (color != cq->last_color) { | ||
87 | |||
88 | if ((*q_service)(cq->vdev, cq_desc, type, | ||
89 | q_number, completed_index, opaque)) | ||
90 | break; | ||
91 | |||
92 | cq->to_clean++; | ||
93 | if (cq->to_clean == cq->ring.desc_count) { | ||
94 | cq->to_clean = 0; | ||
95 | cq->last_color = cq->last_color ? 0 : 1; | ||
96 | } | ||
97 | |||
98 | cq_desc = (struct cq_desc *)((u8 *)cq->ring.descs + | ||
99 | cq->ring.desc_size * cq->to_clean); | ||
100 | cq_desc_dec(cq_desc, &type, &color, | ||
101 | &q_number, &completed_index); | ||
102 | |||
103 | work_done++; | ||
104 | if (work_done >= work_to_do) | ||
105 | break; | ||
106 | } | ||
107 | |||
108 | return work_done; | ||
109 | } | ||
110 | |||
111 | void vnic_cq_free(struct vnic_cq *cq); | ||
112 | int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index, | ||
113 | unsigned int desc_count, unsigned int desc_size); | ||
114 | void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable, | ||
115 | unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail, | ||
116 | unsigned int cq_tail_color, unsigned int interrupt_enable, | ||
117 | unsigned int cq_entry_enable, unsigned int message_enable, | ||
118 | unsigned int interrupt_offset, u64 message_addr); | ||
119 | void vnic_cq_clean(struct vnic_cq *cq); | ||
120 | |||
121 | #endif /* _VNIC_CQ_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_cq_copy.h b/drivers/scsi/fnic/vnic_cq_copy.h new file mode 100644 index 000000000000..7901ce255a81 --- /dev/null +++ b/drivers/scsi/fnic/vnic_cq_copy.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_CQ_COPY_H_ | ||
19 | #define _VNIC_CQ_COPY_H_ | ||
20 | |||
21 | #include "fcpio.h" | ||
22 | |||
23 | static inline unsigned int vnic_cq_copy_service( | ||
24 | struct vnic_cq *cq, | ||
25 | int (*q_service)(struct vnic_dev *vdev, | ||
26 | unsigned int index, | ||
27 | struct fcpio_fw_req *desc), | ||
28 | unsigned int work_to_do) | ||
29 | |||
30 | { | ||
31 | struct fcpio_fw_req *desc; | ||
32 | unsigned int work_done = 0; | ||
33 | u8 color; | ||
34 | |||
35 | desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs + | ||
36 | cq->ring.desc_size * cq->to_clean); | ||
37 | fcpio_color_dec(desc, &color); | ||
38 | |||
39 | while (color != cq->last_color) { | ||
40 | |||
41 | if ((*q_service)(cq->vdev, cq->index, desc)) | ||
42 | break; | ||
43 | |||
44 | cq->to_clean++; | ||
45 | if (cq->to_clean == cq->ring.desc_count) { | ||
46 | cq->to_clean = 0; | ||
47 | cq->last_color = cq->last_color ? 0 : 1; | ||
48 | } | ||
49 | |||
50 | desc = (struct fcpio_fw_req *)((u8 *)cq->ring.descs + | ||
51 | cq->ring.desc_size * cq->to_clean); | ||
52 | fcpio_color_dec(desc, &color); | ||
53 | |||
54 | work_done++; | ||
55 | if (work_done >= work_to_do) | ||
56 | break; | ||
57 | } | ||
58 | |||
59 | return work_done; | ||
60 | } | ||
61 | |||
62 | #endif /* _VNIC_CQ_COPY_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c new file mode 100644 index 000000000000..566770645086 --- /dev/null +++ b/drivers/scsi/fnic/vnic_dev.c | |||
@@ -0,0 +1,690 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/types.h> | ||
22 | #include <linux/pci.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/if_ether.h> | ||
25 | #include "vnic_resource.h" | ||
26 | #include "vnic_devcmd.h" | ||
27 | #include "vnic_dev.h" | ||
28 | #include "vnic_stats.h" | ||
29 | |||
30 | struct vnic_res { | ||
31 | void __iomem *vaddr; | ||
32 | unsigned int count; | ||
33 | }; | ||
34 | |||
35 | struct vnic_dev { | ||
36 | void *priv; | ||
37 | struct pci_dev *pdev; | ||
38 | struct vnic_res res[RES_TYPE_MAX]; | ||
39 | enum vnic_dev_intr_mode intr_mode; | ||
40 | struct vnic_devcmd __iomem *devcmd; | ||
41 | struct vnic_devcmd_notify *notify; | ||
42 | struct vnic_devcmd_notify notify_copy; | ||
43 | dma_addr_t notify_pa; | ||
44 | u32 *linkstatus; | ||
45 | dma_addr_t linkstatus_pa; | ||
46 | struct vnic_stats *stats; | ||
47 | dma_addr_t stats_pa; | ||
48 | struct vnic_devcmd_fw_info *fw_info; | ||
49 | dma_addr_t fw_info_pa; | ||
50 | }; | ||
51 | |||
52 | #define VNIC_MAX_RES_HDR_SIZE \ | ||
53 | (sizeof(struct vnic_resource_header) + \ | ||
54 | sizeof(struct vnic_resource) * RES_TYPE_MAX) | ||
55 | #define VNIC_RES_STRIDE 128 | ||
56 | |||
57 | void *vnic_dev_priv(struct vnic_dev *vdev) | ||
58 | { | ||
59 | return vdev->priv; | ||
60 | } | ||
61 | |||
62 | static int vnic_dev_discover_res(struct vnic_dev *vdev, | ||
63 | struct vnic_dev_bar *bar) | ||
64 | { | ||
65 | struct vnic_resource_header __iomem *rh; | ||
66 | struct vnic_resource __iomem *r; | ||
67 | u8 type; | ||
68 | |||
69 | if (bar->len < VNIC_MAX_RES_HDR_SIZE) { | ||
70 | printk(KERN_ERR "vNIC BAR0 res hdr length error\n"); | ||
71 | return -EINVAL; | ||
72 | } | ||
73 | |||
74 | rh = bar->vaddr; | ||
75 | if (!rh) { | ||
76 | printk(KERN_ERR "vNIC BAR0 res hdr not mem-mapped\n"); | ||
77 | return -EINVAL; | ||
78 | } | ||
79 | |||
80 | if (ioread32(&rh->magic) != VNIC_RES_MAGIC || | ||
81 | ioread32(&rh->version) != VNIC_RES_VERSION) { | ||
82 | printk(KERN_ERR "vNIC BAR0 res magic/version error " | ||
83 | "exp (%lx/%lx) curr (%x/%x)\n", | ||
84 | VNIC_RES_MAGIC, VNIC_RES_VERSION, | ||
85 | ioread32(&rh->magic), ioread32(&rh->version)); | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | |||
89 | r = (struct vnic_resource __iomem *)(rh + 1); | ||
90 | |||
91 | while ((type = ioread8(&r->type)) != RES_TYPE_EOL) { | ||
92 | |||
93 | u8 bar_num = ioread8(&r->bar); | ||
94 | u32 bar_offset = ioread32(&r->bar_offset); | ||
95 | u32 count = ioread32(&r->count); | ||
96 | u32 len; | ||
97 | |||
98 | r++; | ||
99 | |||
100 | if (bar_num != 0) /* only mapping in BAR0 resources */ | ||
101 | continue; | ||
102 | |||
103 | switch (type) { | ||
104 | case RES_TYPE_WQ: | ||
105 | case RES_TYPE_RQ: | ||
106 | case RES_TYPE_CQ: | ||
107 | case RES_TYPE_INTR_CTRL: | ||
108 | /* each count is stride bytes long */ | ||
109 | len = count * VNIC_RES_STRIDE; | ||
110 | if (len + bar_offset > bar->len) { | ||
111 | printk(KERN_ERR "vNIC BAR0 resource %d " | ||
112 | "out-of-bounds, offset 0x%x + " | ||
113 | "size 0x%x > bar len 0x%lx\n", | ||
114 | type, bar_offset, | ||
115 | len, | ||
116 | bar->len); | ||
117 | return -EINVAL; | ||
118 | } | ||
119 | break; | ||
120 | case RES_TYPE_INTR_PBA_LEGACY: | ||
121 | case RES_TYPE_DEVCMD: | ||
122 | len = count; | ||
123 | break; | ||
124 | default: | ||
125 | continue; | ||
126 | } | ||
127 | |||
128 | vdev->res[type].count = count; | ||
129 | vdev->res[type].vaddr = (char __iomem *)bar->vaddr + bar_offset; | ||
130 | } | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev, | ||
136 | enum vnic_res_type type) | ||
137 | { | ||
138 | return vdev->res[type].count; | ||
139 | } | ||
140 | |||
141 | void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, | ||
142 | unsigned int index) | ||
143 | { | ||
144 | if (!vdev->res[type].vaddr) | ||
145 | return NULL; | ||
146 | |||
147 | switch (type) { | ||
148 | case RES_TYPE_WQ: | ||
149 | case RES_TYPE_RQ: | ||
150 | case RES_TYPE_CQ: | ||
151 | case RES_TYPE_INTR_CTRL: | ||
152 | return (char __iomem *)vdev->res[type].vaddr + | ||
153 | index * VNIC_RES_STRIDE; | ||
154 | default: | ||
155 | return (char __iomem *)vdev->res[type].vaddr; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring, | ||
160 | unsigned int desc_count, | ||
161 | unsigned int desc_size) | ||
162 | { | ||
163 | /* The base address of the desc rings must be 512 byte aligned. | ||
164 | * Descriptor count is aligned to groups of 32 descriptors. A | ||
165 | * count of 0 means the maximum 4096 descriptors. Descriptor | ||
166 | * size is aligned to 16 bytes. | ||
167 | */ | ||
168 | |||
169 | unsigned int count_align = 32; | ||
170 | unsigned int desc_align = 16; | ||
171 | |||
172 | ring->base_align = 512; | ||
173 | |||
174 | if (desc_count == 0) | ||
175 | desc_count = 4096; | ||
176 | |||
177 | ring->desc_count = ALIGN(desc_count, count_align); | ||
178 | |||
179 | ring->desc_size = ALIGN(desc_size, desc_align); | ||
180 | |||
181 | ring->size = ring->desc_count * ring->desc_size; | ||
182 | ring->size_unaligned = ring->size + ring->base_align; | ||
183 | |||
184 | return ring->size_unaligned; | ||
185 | } | ||
186 | |||
187 | void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring) | ||
188 | { | ||
189 | memset(ring->descs, 0, ring->size); | ||
190 | } | ||
191 | |||
192 | int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, | ||
193 | unsigned int desc_count, unsigned int desc_size) | ||
194 | { | ||
195 | vnic_dev_desc_ring_size(ring, desc_count, desc_size); | ||
196 | |||
197 | ring->descs_unaligned = pci_alloc_consistent(vdev->pdev, | ||
198 | ring->size_unaligned, | ||
199 | &ring->base_addr_unaligned); | ||
200 | |||
201 | if (!ring->descs_unaligned) { | ||
202 | printk(KERN_ERR | ||
203 | "Failed to allocate ring (size=%d), aborting\n", | ||
204 | (int)ring->size); | ||
205 | return -ENOMEM; | ||
206 | } | ||
207 | |||
208 | ring->base_addr = ALIGN(ring->base_addr_unaligned, | ||
209 | ring->base_align); | ||
210 | ring->descs = (u8 *)ring->descs_unaligned + | ||
211 | (ring->base_addr - ring->base_addr_unaligned); | ||
212 | |||
213 | vnic_dev_clear_desc_ring(ring); | ||
214 | |||
215 | ring->desc_avail = ring->desc_count - 1; | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | void vnic_dev_free_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring) | ||
221 | { | ||
222 | if (ring->descs) { | ||
223 | pci_free_consistent(vdev->pdev, | ||
224 | ring->size_unaligned, | ||
225 | ring->descs_unaligned, | ||
226 | ring->base_addr_unaligned); | ||
227 | ring->descs = NULL; | ||
228 | } | ||
229 | } | ||
230 | |||
231 | int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, | ||
232 | u64 *a0, u64 *a1, int wait) | ||
233 | { | ||
234 | struct vnic_devcmd __iomem *devcmd = vdev->devcmd; | ||
235 | int delay; | ||
236 | u32 status; | ||
237 | int dev_cmd_err[] = { | ||
238 | /* convert from fw's version of error.h to host's version */ | ||
239 | 0, /* ERR_SUCCESS */ | ||
240 | EINVAL, /* ERR_EINVAL */ | ||
241 | EFAULT, /* ERR_EFAULT */ | ||
242 | EPERM, /* ERR_EPERM */ | ||
243 | EBUSY, /* ERR_EBUSY */ | ||
244 | }; | ||
245 | int err; | ||
246 | |||
247 | status = ioread32(&devcmd->status); | ||
248 | if (status & STAT_BUSY) { | ||
249 | printk(KERN_ERR "Busy devcmd %d\n", _CMD_N(cmd)); | ||
250 | return -EBUSY; | ||
251 | } | ||
252 | |||
253 | if (_CMD_DIR(cmd) & _CMD_DIR_WRITE) { | ||
254 | writeq(*a0, &devcmd->args[0]); | ||
255 | writeq(*a1, &devcmd->args[1]); | ||
256 | wmb(); | ||
257 | } | ||
258 | |||
259 | iowrite32(cmd, &devcmd->cmd); | ||
260 | |||
261 | if ((_CMD_FLAGS(cmd) & _CMD_FLAGS_NOWAIT)) | ||
262 | return 0; | ||
263 | |||
264 | for (delay = 0; delay < wait; delay++) { | ||
265 | |||
266 | udelay(100); | ||
267 | |||
268 | status = ioread32(&devcmd->status); | ||
269 | if (!(status & STAT_BUSY)) { | ||
270 | |||
271 | if (status & STAT_ERROR) { | ||
272 | err = dev_cmd_err[(int)readq(&devcmd->args[0])]; | ||
273 | printk(KERN_ERR "Error %d devcmd %d\n", | ||
274 | err, _CMD_N(cmd)); | ||
275 | return -err; | ||
276 | } | ||
277 | |||
278 | if (_CMD_DIR(cmd) & _CMD_DIR_READ) { | ||
279 | rmb(); | ||
280 | *a0 = readq(&devcmd->args[0]); | ||
281 | *a1 = readq(&devcmd->args[1]); | ||
282 | } | ||
283 | |||
284 | return 0; | ||
285 | } | ||
286 | } | ||
287 | |||
288 | printk(KERN_ERR "Timedout devcmd %d\n", _CMD_N(cmd)); | ||
289 | return -ETIMEDOUT; | ||
290 | } | ||
291 | |||
292 | int vnic_dev_fw_info(struct vnic_dev *vdev, | ||
293 | struct vnic_devcmd_fw_info **fw_info) | ||
294 | { | ||
295 | u64 a0, a1 = 0; | ||
296 | int wait = 1000; | ||
297 | int err = 0; | ||
298 | |||
299 | if (!vdev->fw_info) { | ||
300 | vdev->fw_info = pci_alloc_consistent(vdev->pdev, | ||
301 | sizeof(struct vnic_devcmd_fw_info), | ||
302 | &vdev->fw_info_pa); | ||
303 | if (!vdev->fw_info) | ||
304 | return -ENOMEM; | ||
305 | |||
306 | a0 = vdev->fw_info_pa; | ||
307 | |||
308 | /* only get fw_info once and cache it */ | ||
309 | err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait); | ||
310 | } | ||
311 | |||
312 | *fw_info = vdev->fw_info; | ||
313 | |||
314 | return err; | ||
315 | } | ||
316 | |||
317 | int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size, | ||
318 | void *value) | ||
319 | { | ||
320 | u64 a0, a1; | ||
321 | int wait = 1000; | ||
322 | int err; | ||
323 | |||
324 | a0 = offset; | ||
325 | a1 = size; | ||
326 | |||
327 | err = vnic_dev_cmd(vdev, CMD_DEV_SPEC, &a0, &a1, wait); | ||
328 | |||
329 | switch (size) { | ||
330 | case 1: | ||
331 | *(u8 *)value = (u8)a0; | ||
332 | break; | ||
333 | case 2: | ||
334 | *(u16 *)value = (u16)a0; | ||
335 | break; | ||
336 | case 4: | ||
337 | *(u32 *)value = (u32)a0; | ||
338 | break; | ||
339 | case 8: | ||
340 | *(u64 *)value = a0; | ||
341 | break; | ||
342 | default: | ||
343 | BUG(); | ||
344 | break; | ||
345 | } | ||
346 | |||
347 | return err; | ||
348 | } | ||
349 | |||
350 | int vnic_dev_stats_clear(struct vnic_dev *vdev) | ||
351 | { | ||
352 | u64 a0 = 0, a1 = 0; | ||
353 | int wait = 1000; | ||
354 | return vnic_dev_cmd(vdev, CMD_STATS_CLEAR, &a0, &a1, wait); | ||
355 | } | ||
356 | |||
357 | int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats) | ||
358 | { | ||
359 | u64 a0, a1; | ||
360 | int wait = 1000; | ||
361 | |||
362 | if (!vdev->stats) { | ||
363 | vdev->stats = pci_alloc_consistent(vdev->pdev, | ||
364 | sizeof(struct vnic_stats), &vdev->stats_pa); | ||
365 | if (!vdev->stats) | ||
366 | return -ENOMEM; | ||
367 | } | ||
368 | |||
369 | *stats = vdev->stats; | ||
370 | a0 = vdev->stats_pa; | ||
371 | a1 = sizeof(struct vnic_stats); | ||
372 | |||
373 | return vnic_dev_cmd(vdev, CMD_STATS_DUMP, &a0, &a1, wait); | ||
374 | } | ||
375 | |||
376 | int vnic_dev_close(struct vnic_dev *vdev) | ||
377 | { | ||
378 | u64 a0 = 0, a1 = 0; | ||
379 | int wait = 1000; | ||
380 | return vnic_dev_cmd(vdev, CMD_CLOSE, &a0, &a1, wait); | ||
381 | } | ||
382 | |||
383 | int vnic_dev_enable(struct vnic_dev *vdev) | ||
384 | { | ||
385 | u64 a0 = 0, a1 = 0; | ||
386 | int wait = 1000; | ||
387 | return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait); | ||
388 | } | ||
389 | |||
390 | int vnic_dev_disable(struct vnic_dev *vdev) | ||
391 | { | ||
392 | u64 a0 = 0, a1 = 0; | ||
393 | int wait = 1000; | ||
394 | return vnic_dev_cmd(vdev, CMD_DISABLE, &a0, &a1, wait); | ||
395 | } | ||
396 | |||
397 | int vnic_dev_open(struct vnic_dev *vdev, int arg) | ||
398 | { | ||
399 | u64 a0 = (u32)arg, a1 = 0; | ||
400 | int wait = 1000; | ||
401 | return vnic_dev_cmd(vdev, CMD_OPEN, &a0, &a1, wait); | ||
402 | } | ||
403 | |||
404 | int vnic_dev_open_done(struct vnic_dev *vdev, int *done) | ||
405 | { | ||
406 | u64 a0 = 0, a1 = 0; | ||
407 | int wait = 1000; | ||
408 | int err; | ||
409 | |||
410 | *done = 0; | ||
411 | |||
412 | err = vnic_dev_cmd(vdev, CMD_OPEN_STATUS, &a0, &a1, wait); | ||
413 | if (err) | ||
414 | return err; | ||
415 | |||
416 | *done = (a0 == 0); | ||
417 | |||
418 | return 0; | ||
419 | } | ||
420 | |||
421 | int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg) | ||
422 | { | ||
423 | u64 a0 = (u32)arg, a1 = 0; | ||
424 | int wait = 1000; | ||
425 | return vnic_dev_cmd(vdev, CMD_SOFT_RESET, &a0, &a1, wait); | ||
426 | } | ||
427 | |||
428 | int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done) | ||
429 | { | ||
430 | u64 a0 = 0, a1 = 0; | ||
431 | int wait = 1000; | ||
432 | int err; | ||
433 | |||
434 | *done = 0; | ||
435 | |||
436 | err = vnic_dev_cmd(vdev, CMD_SOFT_RESET_STATUS, &a0, &a1, wait); | ||
437 | if (err) | ||
438 | return err; | ||
439 | |||
440 | *done = (a0 == 0); | ||
441 | |||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | int vnic_dev_hang_notify(struct vnic_dev *vdev) | ||
446 | { | ||
447 | u64 a0, a1; | ||
448 | int wait = 1000; | ||
449 | return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait); | ||
450 | } | ||
451 | |||
452 | int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr) | ||
453 | { | ||
454 | u64 a0, a1; | ||
455 | int wait = 1000; | ||
456 | int err, i; | ||
457 | |||
458 | for (i = 0; i < ETH_ALEN; i++) | ||
459 | mac_addr[i] = 0; | ||
460 | |||
461 | err = vnic_dev_cmd(vdev, CMD_MAC_ADDR, &a0, &a1, wait); | ||
462 | if (err) | ||
463 | return err; | ||
464 | |||
465 | for (i = 0; i < ETH_ALEN; i++) | ||
466 | mac_addr[i] = ((u8 *)&a0)[i]; | ||
467 | |||
468 | return 0; | ||
469 | } | ||
470 | |||
471 | void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, | ||
472 | int broadcast, int promisc, int allmulti) | ||
473 | { | ||
474 | u64 a0, a1 = 0; | ||
475 | int wait = 1000; | ||
476 | int err; | ||
477 | |||
478 | a0 = (directed ? CMD_PFILTER_DIRECTED : 0) | | ||
479 | (multicast ? CMD_PFILTER_MULTICAST : 0) | | ||
480 | (broadcast ? CMD_PFILTER_BROADCAST : 0) | | ||
481 | (promisc ? CMD_PFILTER_PROMISCUOUS : 0) | | ||
482 | (allmulti ? CMD_PFILTER_ALL_MULTICAST : 0); | ||
483 | |||
484 | err = vnic_dev_cmd(vdev, CMD_PACKET_FILTER, &a0, &a1, wait); | ||
485 | if (err) | ||
486 | printk(KERN_ERR "Can't set packet filter\n"); | ||
487 | } | ||
488 | |||
489 | void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr) | ||
490 | { | ||
491 | u64 a0 = 0, a1 = 0; | ||
492 | int wait = 1000; | ||
493 | int err; | ||
494 | int i; | ||
495 | |||
496 | for (i = 0; i < ETH_ALEN; i++) | ||
497 | ((u8 *)&a0)[i] = addr[i]; | ||
498 | |||
499 | err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, &a0, &a1, wait); | ||
500 | if (err) | ||
501 | printk(KERN_ERR | ||
502 | "Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n", | ||
503 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], | ||
504 | err); | ||
505 | } | ||
506 | |||
507 | void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr) | ||
508 | { | ||
509 | u64 a0 = 0, a1 = 0; | ||
510 | int wait = 1000; | ||
511 | int err; | ||
512 | int i; | ||
513 | |||
514 | for (i = 0; i < ETH_ALEN; i++) | ||
515 | ((u8 *)&a0)[i] = addr[i]; | ||
516 | |||
517 | err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, &a0, &a1, wait); | ||
518 | if (err) | ||
519 | printk(KERN_ERR | ||
520 | "Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n", | ||
521 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], | ||
522 | err); | ||
523 | } | ||
524 | |||
525 | int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) | ||
526 | { | ||
527 | u64 a0, a1; | ||
528 | int wait = 1000; | ||
529 | |||
530 | if (!vdev->notify) { | ||
531 | vdev->notify = pci_alloc_consistent(vdev->pdev, | ||
532 | sizeof(struct vnic_devcmd_notify), | ||
533 | &vdev->notify_pa); | ||
534 | if (!vdev->notify) | ||
535 | return -ENOMEM; | ||
536 | } | ||
537 | |||
538 | a0 = vdev->notify_pa; | ||
539 | a1 = ((u64)intr << 32) & 0x0000ffff00000000ULL; | ||
540 | a1 += sizeof(struct vnic_devcmd_notify); | ||
541 | |||
542 | return vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); | ||
543 | } | ||
544 | |||
545 | void vnic_dev_notify_unset(struct vnic_dev *vdev) | ||
546 | { | ||
547 | u64 a0, a1; | ||
548 | int wait = 1000; | ||
549 | |||
550 | a0 = 0; /* paddr = 0 to unset notify buffer */ | ||
551 | a1 = 0x0000ffff00000000ULL; /* intr num = -1 to unreg for intr */ | ||
552 | a1 += sizeof(struct vnic_devcmd_notify); | ||
553 | |||
554 | vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); | ||
555 | } | ||
556 | |||
557 | static int vnic_dev_notify_ready(struct vnic_dev *vdev) | ||
558 | { | ||
559 | u32 *words; | ||
560 | unsigned int nwords = sizeof(struct vnic_devcmd_notify) / 4; | ||
561 | unsigned int i; | ||
562 | u32 csum; | ||
563 | |||
564 | if (!vdev->notify) | ||
565 | return 0; | ||
566 | |||
567 | do { | ||
568 | csum = 0; | ||
569 | memcpy(&vdev->notify_copy, vdev->notify, | ||
570 | sizeof(struct vnic_devcmd_notify)); | ||
571 | words = (u32 *)&vdev->notify_copy; | ||
572 | for (i = 1; i < nwords; i++) | ||
573 | csum += words[i]; | ||
574 | } while (csum != words[0]); | ||
575 | |||
576 | return 1; | ||
577 | } | ||
578 | |||
579 | int vnic_dev_init(struct vnic_dev *vdev, int arg) | ||
580 | { | ||
581 | u64 a0 = (u32)arg, a1 = 0; | ||
582 | int wait = 1000; | ||
583 | return vnic_dev_cmd(vdev, CMD_INIT, &a0, &a1, wait); | ||
584 | } | ||
585 | |||
586 | int vnic_dev_link_status(struct vnic_dev *vdev) | ||
587 | { | ||
588 | if (vdev->linkstatus) | ||
589 | return *vdev->linkstatus; | ||
590 | |||
591 | if (!vnic_dev_notify_ready(vdev)) | ||
592 | return 0; | ||
593 | |||
594 | return vdev->notify_copy.link_state; | ||
595 | } | ||
596 | |||
597 | u32 vnic_dev_port_speed(struct vnic_dev *vdev) | ||
598 | { | ||
599 | if (!vnic_dev_notify_ready(vdev)) | ||
600 | return 0; | ||
601 | |||
602 | return vdev->notify_copy.port_speed; | ||
603 | } | ||
604 | |||
605 | u32 vnic_dev_msg_lvl(struct vnic_dev *vdev) | ||
606 | { | ||
607 | if (!vnic_dev_notify_ready(vdev)) | ||
608 | return 0; | ||
609 | |||
610 | return vdev->notify_copy.msglvl; | ||
611 | } | ||
612 | |||
613 | u32 vnic_dev_mtu(struct vnic_dev *vdev) | ||
614 | { | ||
615 | if (!vnic_dev_notify_ready(vdev)) | ||
616 | return 0; | ||
617 | |||
618 | return vdev->notify_copy.mtu; | ||
619 | } | ||
620 | |||
621 | u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev) | ||
622 | { | ||
623 | if (!vnic_dev_notify_ready(vdev)) | ||
624 | return 0; | ||
625 | |||
626 | return vdev->notify_copy.link_down_cnt; | ||
627 | } | ||
628 | |||
629 | void vnic_dev_set_intr_mode(struct vnic_dev *vdev, | ||
630 | enum vnic_dev_intr_mode intr_mode) | ||
631 | { | ||
632 | vdev->intr_mode = intr_mode; | ||
633 | } | ||
634 | |||
635 | enum vnic_dev_intr_mode vnic_dev_get_intr_mode( | ||
636 | struct vnic_dev *vdev) | ||
637 | { | ||
638 | return vdev->intr_mode; | ||
639 | } | ||
640 | |||
641 | void vnic_dev_unregister(struct vnic_dev *vdev) | ||
642 | { | ||
643 | if (vdev) { | ||
644 | if (vdev->notify) | ||
645 | pci_free_consistent(vdev->pdev, | ||
646 | sizeof(struct vnic_devcmd_notify), | ||
647 | vdev->notify, | ||
648 | vdev->notify_pa); | ||
649 | if (vdev->linkstatus) | ||
650 | pci_free_consistent(vdev->pdev, | ||
651 | sizeof(u32), | ||
652 | vdev->linkstatus, | ||
653 | vdev->linkstatus_pa); | ||
654 | if (vdev->stats) | ||
655 | pci_free_consistent(vdev->pdev, | ||
656 | sizeof(struct vnic_dev), | ||
657 | vdev->stats, vdev->stats_pa); | ||
658 | if (vdev->fw_info) | ||
659 | pci_free_consistent(vdev->pdev, | ||
660 | sizeof(struct vnic_devcmd_fw_info), | ||
661 | vdev->fw_info, vdev->fw_info_pa); | ||
662 | kfree(vdev); | ||
663 | } | ||
664 | } | ||
665 | |||
666 | struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, | ||
667 | void *priv, struct pci_dev *pdev, struct vnic_dev_bar *bar) | ||
668 | { | ||
669 | if (!vdev) { | ||
670 | vdev = kzalloc(sizeof(struct vnic_dev), GFP_KERNEL); | ||
671 | if (!vdev) | ||
672 | return NULL; | ||
673 | } | ||
674 | |||
675 | vdev->priv = priv; | ||
676 | vdev->pdev = pdev; | ||
677 | |||
678 | if (vnic_dev_discover_res(vdev, bar)) | ||
679 | goto err_out; | ||
680 | |||
681 | vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0); | ||
682 | if (!vdev->devcmd) | ||
683 | goto err_out; | ||
684 | |||
685 | return vdev; | ||
686 | |||
687 | err_out: | ||
688 | vnic_dev_unregister(vdev); | ||
689 | return NULL; | ||
690 | } | ||
diff --git a/drivers/scsi/fnic/vnic_dev.h b/drivers/scsi/fnic/vnic_dev.h new file mode 100644 index 000000000000..f9935a8a5a09 --- /dev/null +++ b/drivers/scsi/fnic/vnic_dev.h | |||
@@ -0,0 +1,161 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_DEV_H_ | ||
19 | #define _VNIC_DEV_H_ | ||
20 | |||
21 | #include "vnic_resource.h" | ||
22 | #include "vnic_devcmd.h" | ||
23 | |||
24 | /* | ||
25 | * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth | ||
26 | * Driver) when both are built with CONFIG options =y | ||
27 | */ | ||
28 | #define vnic_dev_priv fnic_dev_priv | ||
29 | #define vnic_dev_get_res_count fnic_dev_get_res_count | ||
30 | #define vnic_dev_get_res fnic_dev_get_res | ||
31 | #define vnic_dev_desc_ring_size fnic_dev_desc_ring_siz | ||
32 | #define vnic_dev_clear_desc_ring fnic_dev_clear_desc_ring | ||
33 | #define vnic_dev_alloc_desc_ring fnic_dev_alloc_desc_ring | ||
34 | #define vnic_dev_free_desc_ring fnic_dev_free_desc_ring | ||
35 | #define vnic_dev_cmd fnic_dev_cmd | ||
36 | #define vnic_dev_fw_info fnic_dev_fw_info | ||
37 | #define vnic_dev_spec fnic_dev_spec | ||
38 | #define vnic_dev_stats_clear fnic_dev_stats_clear | ||
39 | #define vnic_dev_stats_dump fnic_dev_stats_dump | ||
40 | #define vnic_dev_hang_notify fnic_dev_hang_notify | ||
41 | #define vnic_dev_packet_filter fnic_dev_packet_filter | ||
42 | #define vnic_dev_add_addr fnic_dev_add_addr | ||
43 | #define vnic_dev_del_addr fnic_dev_del_addr | ||
44 | #define vnic_dev_mac_addr fnic_dev_mac_addr | ||
45 | #define vnic_dev_notify_set fnic_dev_notify_set | ||
46 | #define vnic_dev_notify_unset fnic_dev_notify_unset | ||
47 | #define vnic_dev_link_status fnic_dev_link_status | ||
48 | #define vnic_dev_port_speed fnic_dev_port_speed | ||
49 | #define vnic_dev_msg_lvl fnic_dev_msg_lvl | ||
50 | #define vnic_dev_mtu fnic_dev_mtu | ||
51 | #define vnic_dev_link_down_cnt fnic_dev_link_down_cnt | ||
52 | #define vnic_dev_close fnic_dev_close | ||
53 | #define vnic_dev_enable fnic_dev_enable | ||
54 | #define vnic_dev_disable fnic_dev_disable | ||
55 | #define vnic_dev_open fnic_dev_open | ||
56 | #define vnic_dev_open_done fnic_dev_open_done | ||
57 | #define vnic_dev_init fnic_dev_init | ||
58 | #define vnic_dev_soft_reset fnic_dev_soft_reset | ||
59 | #define vnic_dev_soft_reset_done fnic_dev_soft_reset_done | ||
60 | #define vnic_dev_set_intr_mode fnic_dev_set_intr_mode | ||
61 | #define vnic_dev_get_intr_mode fnic_dev_get_intr_mode | ||
62 | #define vnic_dev_unregister fnic_dev_unregister | ||
63 | #define vnic_dev_register fnic_dev_register | ||
64 | |||
65 | #ifndef VNIC_PADDR_TARGET | ||
66 | #define VNIC_PADDR_TARGET 0x0000000000000000ULL | ||
67 | #endif | ||
68 | |||
69 | #ifndef readq | ||
70 | static inline u64 readq(void __iomem *reg) | ||
71 | { | ||
72 | return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg); | ||
73 | } | ||
74 | |||
75 | static inline void writeq(u64 val, void __iomem *reg) | ||
76 | { | ||
77 | writel(val & 0xffffffff, reg); | ||
78 | writel(val >> 32, reg + 0x4UL); | ||
79 | } | ||
80 | #endif | ||
81 | |||
82 | enum vnic_dev_intr_mode { | ||
83 | VNIC_DEV_INTR_MODE_UNKNOWN, | ||
84 | VNIC_DEV_INTR_MODE_INTX, | ||
85 | VNIC_DEV_INTR_MODE_MSI, | ||
86 | VNIC_DEV_INTR_MODE_MSIX, | ||
87 | }; | ||
88 | |||
89 | struct vnic_dev_bar { | ||
90 | void __iomem *vaddr; | ||
91 | dma_addr_t bus_addr; | ||
92 | unsigned long len; | ||
93 | }; | ||
94 | |||
95 | struct vnic_dev_ring { | ||
96 | void *descs; | ||
97 | size_t size; | ||
98 | dma_addr_t base_addr; | ||
99 | size_t base_align; | ||
100 | void *descs_unaligned; | ||
101 | size_t size_unaligned; | ||
102 | dma_addr_t base_addr_unaligned; | ||
103 | unsigned int desc_size; | ||
104 | unsigned int desc_count; | ||
105 | unsigned int desc_avail; | ||
106 | }; | ||
107 | |||
108 | struct vnic_dev; | ||
109 | struct vnic_stats; | ||
110 | |||
111 | void *vnic_dev_priv(struct vnic_dev *vdev); | ||
112 | unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev, | ||
113 | enum vnic_res_type type); | ||
114 | void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type, | ||
115 | unsigned int index); | ||
116 | unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring, | ||
117 | unsigned int desc_count, | ||
118 | unsigned int desc_size); | ||
119 | void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring); | ||
120 | int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring, | ||
121 | unsigned int desc_count, unsigned int desc_size); | ||
122 | void vnic_dev_free_desc_ring(struct vnic_dev *vdev, | ||
123 | struct vnic_dev_ring *ring); | ||
124 | int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd, | ||
125 | u64 *a0, u64 *a1, int wait); | ||
126 | int vnic_dev_fw_info(struct vnic_dev *vdev, | ||
127 | struct vnic_devcmd_fw_info **fw_info); | ||
128 | int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, | ||
129 | unsigned int size, void *value); | ||
130 | int vnic_dev_stats_clear(struct vnic_dev *vdev); | ||
131 | int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats); | ||
132 | int vnic_dev_hang_notify(struct vnic_dev *vdev); | ||
133 | void vnic_dev_packet_filter(struct vnic_dev *vdev, int directed, int multicast, | ||
134 | int broadcast, int promisc, int allmulti); | ||
135 | void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr); | ||
136 | void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr); | ||
137 | int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); | ||
138 | int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr); | ||
139 | void vnic_dev_notify_unset(struct vnic_dev *vdev); | ||
140 | int vnic_dev_link_status(struct vnic_dev *vdev); | ||
141 | u32 vnic_dev_port_speed(struct vnic_dev *vdev); | ||
142 | u32 vnic_dev_msg_lvl(struct vnic_dev *vdev); | ||
143 | u32 vnic_dev_mtu(struct vnic_dev *vdev); | ||
144 | u32 vnic_dev_link_down_cnt(struct vnic_dev *vdev); | ||
145 | int vnic_dev_close(struct vnic_dev *vdev); | ||
146 | int vnic_dev_enable(struct vnic_dev *vdev); | ||
147 | int vnic_dev_disable(struct vnic_dev *vdev); | ||
148 | int vnic_dev_open(struct vnic_dev *vdev, int arg); | ||
149 | int vnic_dev_open_done(struct vnic_dev *vdev, int *done); | ||
150 | int vnic_dev_init(struct vnic_dev *vdev, int arg); | ||
151 | int vnic_dev_soft_reset(struct vnic_dev *vdev, int arg); | ||
152 | int vnic_dev_soft_reset_done(struct vnic_dev *vdev, int *done); | ||
153 | void vnic_dev_set_intr_mode(struct vnic_dev *vdev, | ||
154 | enum vnic_dev_intr_mode intr_mode); | ||
155 | enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev); | ||
156 | void vnic_dev_unregister(struct vnic_dev *vdev); | ||
157 | struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, | ||
158 | void *priv, struct pci_dev *pdev, | ||
159 | struct vnic_dev_bar *bar); | ||
160 | |||
161 | #endif /* _VNIC_DEV_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_devcmd.h b/drivers/scsi/fnic/vnic_devcmd.h new file mode 100644 index 000000000000..d62b9061bf12 --- /dev/null +++ b/drivers/scsi/fnic/vnic_devcmd.h | |||
@@ -0,0 +1,281 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_DEVCMD_H_ | ||
19 | #define _VNIC_DEVCMD_H_ | ||
20 | |||
21 | #define _CMD_NBITS 14 | ||
22 | #define _CMD_VTYPEBITS 10 | ||
23 | #define _CMD_FLAGSBITS 6 | ||
24 | #define _CMD_DIRBITS 2 | ||
25 | |||
26 | #define _CMD_NMASK ((1 << _CMD_NBITS)-1) | ||
27 | #define _CMD_VTYPEMASK ((1 << _CMD_VTYPEBITS)-1) | ||
28 | #define _CMD_FLAGSMASK ((1 << _CMD_FLAGSBITS)-1) | ||
29 | #define _CMD_DIRMASK ((1 << _CMD_DIRBITS)-1) | ||
30 | |||
31 | #define _CMD_NSHIFT 0 | ||
32 | #define _CMD_VTYPESHIFT (_CMD_NSHIFT+_CMD_NBITS) | ||
33 | #define _CMD_FLAGSSHIFT (_CMD_VTYPESHIFT+_CMD_VTYPEBITS) | ||
34 | #define _CMD_DIRSHIFT (_CMD_FLAGSSHIFT+_CMD_FLAGSBITS) | ||
35 | |||
36 | /* | ||
37 | * Direction bits (from host perspective). | ||
38 | */ | ||
39 | #define _CMD_DIR_NONE 0U | ||
40 | #define _CMD_DIR_WRITE 1U | ||
41 | #define _CMD_DIR_READ 2U | ||
42 | #define _CMD_DIR_RW (_CMD_DIR_WRITE | _CMD_DIR_READ) | ||
43 | |||
44 | /* | ||
45 | * Flag bits. | ||
46 | */ | ||
47 | #define _CMD_FLAGS_NONE 0U | ||
48 | #define _CMD_FLAGS_NOWAIT 1U | ||
49 | |||
50 | /* | ||
51 | * vNIC type bits. | ||
52 | */ | ||
53 | #define _CMD_VTYPE_NONE 0U | ||
54 | #define _CMD_VTYPE_ENET 1U | ||
55 | #define _CMD_VTYPE_FC 2U | ||
56 | #define _CMD_VTYPE_SCSI 4U | ||
57 | #define _CMD_VTYPE_ALL (_CMD_VTYPE_ENET | _CMD_VTYPE_FC | _CMD_VTYPE_SCSI) | ||
58 | |||
59 | /* | ||
60 | * Used to create cmds.. | ||
61 | */ | ||
62 | #define _CMDCF(dir, flags, vtype, nr) \ | ||
63 | (((dir) << _CMD_DIRSHIFT) | \ | ||
64 | ((flags) << _CMD_FLAGSSHIFT) | \ | ||
65 | ((vtype) << _CMD_VTYPESHIFT) | \ | ||
66 | ((nr) << _CMD_NSHIFT)) | ||
67 | #define _CMDC(dir, vtype, nr) _CMDCF(dir, 0, vtype, nr) | ||
68 | #define _CMDCNW(dir, vtype, nr) _CMDCF(dir, _CMD_FLAGS_NOWAIT, vtype, nr) | ||
69 | |||
70 | /* | ||
71 | * Used to decode cmds.. | ||
72 | */ | ||
73 | #define _CMD_DIR(cmd) (((cmd) >> _CMD_DIRSHIFT) & _CMD_DIRMASK) | ||
74 | #define _CMD_FLAGS(cmd) (((cmd) >> _CMD_FLAGSSHIFT) & _CMD_FLAGSMASK) | ||
75 | #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK) | ||
76 | #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK) | ||
77 | |||
78 | enum vnic_devcmd_cmd { | ||
79 | CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0), | ||
80 | |||
81 | /* mcpu fw info in mem: (u64)a0=paddr to struct vnic_devcmd_fw_info */ | ||
82 | CMD_MCPU_FW_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 1), | ||
83 | |||
84 | /* dev-specific block member: | ||
85 | * in: (u16)a0=offset,(u8)a1=size | ||
86 | * out: a0=value */ | ||
87 | CMD_DEV_SPEC = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 2), | ||
88 | |||
89 | /* stats clear */ | ||
90 | CMD_STATS_CLEAR = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 3), | ||
91 | |||
92 | /* stats dump in mem: (u64)a0=paddr to stats area, | ||
93 | * (u16)a1=sizeof stats area */ | ||
94 | CMD_STATS_DUMP = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 4), | ||
95 | |||
96 | /* set Rx packet filter: (u32)a0=filters (see CMD_PFILTER_*) */ | ||
97 | CMD_PACKET_FILTER = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 7), | ||
98 | |||
99 | /* hang detection notification */ | ||
100 | CMD_HANG_NOTIFY = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 8), | ||
101 | |||
102 | /* MAC address in (u48)a0 */ | ||
103 | CMD_MAC_ADDR = _CMDC(_CMD_DIR_READ, | ||
104 | _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 9), | ||
105 | |||
106 | /* disable/enable promisc mode: (u8)a0=0/1 */ | ||
107 | /***** XXX DEPRECATED *****/ | ||
108 | CMD_PROMISC_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 10), | ||
109 | |||
110 | /* disable/enable all-multi mode: (u8)a0=0/1 */ | ||
111 | /***** XXX DEPRECATED *****/ | ||
112 | CMD_ALLMULTI_MODE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 11), | ||
113 | |||
114 | /* add addr from (u48)a0 */ | ||
115 | CMD_ADDR_ADD = _CMDCNW(_CMD_DIR_WRITE, | ||
116 | _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 12), | ||
117 | |||
118 | /* del addr from (u48)a0 */ | ||
119 | CMD_ADDR_DEL = _CMDCNW(_CMD_DIR_WRITE, | ||
120 | _CMD_VTYPE_ENET | _CMD_VTYPE_FC, 13), | ||
121 | |||
122 | /* add VLAN id in (u16)a0 */ | ||
123 | CMD_VLAN_ADD = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 14), | ||
124 | |||
125 | /* del VLAN id in (u16)a0 */ | ||
126 | CMD_VLAN_DEL = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 15), | ||
127 | |||
128 | /* nic_cfg in (u32)a0 */ | ||
129 | CMD_NIC_CFG = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 16), | ||
130 | |||
131 | /* union vnic_rss_key in mem: (u64)a0=paddr, (u16)a1=len */ | ||
132 | CMD_RSS_KEY = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 17), | ||
133 | |||
134 | /* union vnic_rss_cpu in mem: (u64)a0=paddr, (u16)a1=len */ | ||
135 | CMD_RSS_CPU = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 18), | ||
136 | |||
137 | /* initiate softreset */ | ||
138 | CMD_SOFT_RESET = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 19), | ||
139 | |||
140 | /* softreset status: | ||
141 | * out: a0=0 reset complete, a0=1 reset in progress */ | ||
142 | CMD_SOFT_RESET_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 20), | ||
143 | |||
144 | /* set struct vnic_devcmd_notify buffer in mem: | ||
145 | * in: | ||
146 | * (u64)a0=paddr to notify (set paddr=0 to unset) | ||
147 | * (u32)a1 & 0x00000000ffffffff=sizeof(struct vnic_devcmd_notify) | ||
148 | * (u16)a1 & 0x0000ffff00000000=intr num (-1 for no intr) | ||
149 | * out: | ||
150 | * (u32)a1 = effective size | ||
151 | */ | ||
152 | CMD_NOTIFY = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 21), | ||
153 | |||
154 | /* UNDI API: (u64)a0=paddr to s_PXENV_UNDI_ struct, | ||
155 | * (u8)a1=PXENV_UNDI_xxx */ | ||
156 | CMD_UNDI = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 22), | ||
157 | |||
158 | /* initiate open sequence (u32)a0=flags (see CMD_OPENF_*) */ | ||
159 | CMD_OPEN = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 23), | ||
160 | |||
161 | /* open status: | ||
162 | * out: a0=0 open complete, a0=1 open in progress */ | ||
163 | CMD_OPEN_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 24), | ||
164 | |||
165 | /* close vnic */ | ||
166 | CMD_CLOSE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 25), | ||
167 | |||
168 | /* initialize virtual link: (u32)a0=flags (see CMD_INITF_*) */ | ||
169 | CMD_INIT = _CMDCNW(_CMD_DIR_READ, _CMD_VTYPE_ALL, 26), | ||
170 | |||
171 | /* variant of CMD_INIT, with provisioning info | ||
172 | * (u64)a0=paddr of vnic_devcmd_provinfo | ||
173 | * (u32)a1=sizeof provision info */ | ||
174 | CMD_INIT_PROV_INFO = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 27), | ||
175 | |||
176 | /* enable virtual link */ | ||
177 | CMD_ENABLE = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 28), | ||
178 | |||
179 | /* disable virtual link */ | ||
180 | CMD_DISABLE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 29), | ||
181 | |||
182 | /* stats dump all vnics on uplink in mem: (u64)a0=paddr (u32)a1=uif */ | ||
183 | CMD_STATS_DUMP_ALL = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_ALL, 30), | ||
184 | |||
185 | /* init status: | ||
186 | * out: a0=0 init complete, a0=1 init in progress | ||
187 | * if a0=0, a1=errno */ | ||
188 | CMD_INIT_STATUS = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 31), | ||
189 | |||
190 | /* INT13 API: (u64)a0=paddr to vnic_int13_params struct | ||
191 | * (u8)a1=INT13_CMD_xxx */ | ||
192 | CMD_INT13 = _CMDC(_CMD_DIR_WRITE, _CMD_VTYPE_FC, 32), | ||
193 | |||
194 | /* logical uplink enable/disable: (u64)a0: 0/1=disable/enable */ | ||
195 | CMD_LOGICAL_UPLINK = _CMDCNW(_CMD_DIR_WRITE, _CMD_VTYPE_ENET, 33), | ||
196 | |||
197 | /* undo initialize of virtual link */ | ||
198 | CMD_DEINIT = _CMDCNW(_CMD_DIR_NONE, _CMD_VTYPE_ALL, 34), | ||
199 | }; | ||
200 | |||
201 | /* flags for CMD_OPEN */ | ||
202 | #define CMD_OPENF_OPROM 0x1 /* open coming from option rom */ | ||
203 | |||
204 | /* flags for CMD_INIT */ | ||
205 | #define CMD_INITF_DEFAULT_MAC 0x1 /* init with default mac addr */ | ||
206 | |||
207 | /* flags for CMD_PACKET_FILTER */ | ||
208 | #define CMD_PFILTER_DIRECTED 0x01 | ||
209 | #define CMD_PFILTER_MULTICAST 0x02 | ||
210 | #define CMD_PFILTER_BROADCAST 0x04 | ||
211 | #define CMD_PFILTER_PROMISCUOUS 0x08 | ||
212 | #define CMD_PFILTER_ALL_MULTICAST 0x10 | ||
213 | |||
214 | enum vnic_devcmd_status { | ||
215 | STAT_NONE = 0, | ||
216 | STAT_BUSY = 1 << 0, /* cmd in progress */ | ||
217 | STAT_ERROR = 1 << 1, /* last cmd caused error (code in a0) */ | ||
218 | }; | ||
219 | |||
220 | enum vnic_devcmd_error { | ||
221 | ERR_SUCCESS = 0, | ||
222 | ERR_EINVAL = 1, | ||
223 | ERR_EFAULT = 2, | ||
224 | ERR_EPERM = 3, | ||
225 | ERR_EBUSY = 4, | ||
226 | ERR_ECMDUNKNOWN = 5, | ||
227 | ERR_EBADSTATE = 6, | ||
228 | ERR_ENOMEM = 7, | ||
229 | ERR_ETIMEDOUT = 8, | ||
230 | ERR_ELINKDOWN = 9, | ||
231 | }; | ||
232 | |||
233 | struct vnic_devcmd_fw_info { | ||
234 | char fw_version[32]; | ||
235 | char fw_build[32]; | ||
236 | char hw_version[32]; | ||
237 | char hw_serial_number[32]; | ||
238 | }; | ||
239 | |||
240 | struct vnic_devcmd_notify { | ||
241 | u32 csum; /* checksum over following words */ | ||
242 | |||
243 | u32 link_state; /* link up == 1 */ | ||
244 | u32 port_speed; /* effective port speed (rate limit) */ | ||
245 | u32 mtu; /* MTU */ | ||
246 | u32 msglvl; /* requested driver msg lvl */ | ||
247 | u32 uif; /* uplink interface */ | ||
248 | u32 status; /* status bits (see VNIC_STF_*) */ | ||
249 | u32 error; /* error code (see ERR_*) for first ERR */ | ||
250 | u32 link_down_cnt; /* running count of link down transitions */ | ||
251 | }; | ||
252 | #define VNIC_STF_FATAL_ERR 0x0001 /* fatal fw error */ | ||
253 | |||
254 | struct vnic_devcmd_provinfo { | ||
255 | u8 oui[3]; | ||
256 | u8 type; | ||
257 | u8 data[0]; | ||
258 | }; | ||
259 | |||
260 | /* | ||
261 | * Writing cmd register causes STAT_BUSY to get set in status register. | ||
262 | * When cmd completes, STAT_BUSY will be cleared. | ||
263 | * | ||
264 | * If cmd completed successfully STAT_ERROR will be clear | ||
265 | * and args registers contain cmd-specific results. | ||
266 | * | ||
267 | * If cmd error, STAT_ERROR will be set and args[0] contains error code. | ||
268 | * | ||
269 | * status register is read-only. While STAT_BUSY is set, | ||
270 | * all other register contents are read-only. | ||
271 | */ | ||
272 | |||
273 | /* Make sizeof(vnic_devcmd) a power-of-2 for I/O BAR. */ | ||
274 | #define VNIC_DEVCMD_NARGS 15 | ||
275 | struct vnic_devcmd { | ||
276 | u32 status; /* RO */ | ||
277 | u32 cmd; /* RW */ | ||
278 | u64 args[VNIC_DEVCMD_NARGS]; /* RW cmd args (little-endian) */ | ||
279 | }; | ||
280 | |||
281 | #endif /* _VNIC_DEVCMD_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_intr.c b/drivers/scsi/fnic/vnic_intr.c new file mode 100644 index 000000000000..4f4dc8793d23 --- /dev/null +++ b/drivers/scsi/fnic/vnic_intr.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/types.h> | ||
22 | #include <linux/pci.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include "vnic_dev.h" | ||
25 | #include "vnic_intr.h" | ||
26 | |||
27 | void vnic_intr_free(struct vnic_intr *intr) | ||
28 | { | ||
29 | intr->ctrl = NULL; | ||
30 | } | ||
31 | |||
32 | int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, | ||
33 | unsigned int index) | ||
34 | { | ||
35 | intr->index = index; | ||
36 | intr->vdev = vdev; | ||
37 | |||
38 | intr->ctrl = vnic_dev_get_res(vdev, RES_TYPE_INTR_CTRL, index); | ||
39 | if (!intr->ctrl) { | ||
40 | printk(KERN_ERR "Failed to hook INTR[%d].ctrl resource\n", | ||
41 | index); | ||
42 | return -EINVAL; | ||
43 | } | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer, | ||
49 | unsigned int coalescing_type, unsigned int mask_on_assertion) | ||
50 | { | ||
51 | iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer); | ||
52 | iowrite32(coalescing_type, &intr->ctrl->coalescing_type); | ||
53 | iowrite32(mask_on_assertion, &intr->ctrl->mask_on_assertion); | ||
54 | iowrite32(0, &intr->ctrl->int_credits); | ||
55 | } | ||
56 | |||
57 | void vnic_intr_clean(struct vnic_intr *intr) | ||
58 | { | ||
59 | iowrite32(0, &intr->ctrl->int_credits); | ||
60 | } | ||
diff --git a/drivers/scsi/fnic/vnic_intr.h b/drivers/scsi/fnic/vnic_intr.h new file mode 100644 index 000000000000..d5fb40e7c98e --- /dev/null +++ b/drivers/scsi/fnic/vnic_intr.h | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_INTR_H_ | ||
19 | #define _VNIC_INTR_H_ | ||
20 | |||
21 | #include <linux/pci.h> | ||
22 | #include "vnic_dev.h" | ||
23 | |||
24 | /* | ||
25 | * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth | ||
26 | * Driver) when both are built with CONFIG options =y | ||
27 | */ | ||
28 | #define vnic_intr_unmask fnic_intr_unmask | ||
29 | #define vnic_intr_mask fnic_intr_mask | ||
30 | #define vnic_intr_return_credits fnic_intr_return_credits | ||
31 | #define vnic_intr_credits fnic_intr_credits | ||
32 | #define vnic_intr_return_all_credits fnic_intr_return_all_credits | ||
33 | #define vnic_intr_legacy_pba fnic_intr_legacy_pba | ||
34 | #define vnic_intr_free fnic_intr_free | ||
35 | #define vnic_intr_alloc fnic_intr_alloc | ||
36 | #define vnic_intr_init fnic_intr_init | ||
37 | #define vnic_intr_clean fnic_intr_clean | ||
38 | |||
39 | #define VNIC_INTR_TIMER_MAX 0xffff | ||
40 | |||
41 | #define VNIC_INTR_TIMER_TYPE_ABS 0 | ||
42 | #define VNIC_INTR_TIMER_TYPE_QUIET 1 | ||
43 | |||
44 | /* Interrupt control */ | ||
45 | struct vnic_intr_ctrl { | ||
46 | u32 coalescing_timer; /* 0x00 */ | ||
47 | u32 pad0; | ||
48 | u32 coalescing_value; /* 0x08 */ | ||
49 | u32 pad1; | ||
50 | u32 coalescing_type; /* 0x10 */ | ||
51 | u32 pad2; | ||
52 | u32 mask_on_assertion; /* 0x18 */ | ||
53 | u32 pad3; | ||
54 | u32 mask; /* 0x20 */ | ||
55 | u32 pad4; | ||
56 | u32 int_credits; /* 0x28 */ | ||
57 | u32 pad5; | ||
58 | u32 int_credit_return; /* 0x30 */ | ||
59 | u32 pad6; | ||
60 | }; | ||
61 | |||
62 | struct vnic_intr { | ||
63 | unsigned int index; | ||
64 | struct vnic_dev *vdev; | ||
65 | struct vnic_intr_ctrl __iomem *ctrl; /* memory-mapped */ | ||
66 | }; | ||
67 | |||
68 | static inline void vnic_intr_unmask(struct vnic_intr *intr) | ||
69 | { | ||
70 | iowrite32(0, &intr->ctrl->mask); | ||
71 | } | ||
72 | |||
73 | static inline void vnic_intr_mask(struct vnic_intr *intr) | ||
74 | { | ||
75 | iowrite32(1, &intr->ctrl->mask); | ||
76 | } | ||
77 | |||
78 | static inline void vnic_intr_return_credits(struct vnic_intr *intr, | ||
79 | unsigned int credits, int unmask, int reset_timer) | ||
80 | { | ||
81 | #define VNIC_INTR_UNMASK_SHIFT 16 | ||
82 | #define VNIC_INTR_RESET_TIMER_SHIFT 17 | ||
83 | |||
84 | u32 int_credit_return = (credits & 0xffff) | | ||
85 | (unmask ? (1 << VNIC_INTR_UNMASK_SHIFT) : 0) | | ||
86 | (reset_timer ? (1 << VNIC_INTR_RESET_TIMER_SHIFT) : 0); | ||
87 | |||
88 | iowrite32(int_credit_return, &intr->ctrl->int_credit_return); | ||
89 | } | ||
90 | |||
91 | static inline unsigned int vnic_intr_credits(struct vnic_intr *intr) | ||
92 | { | ||
93 | return ioread32(&intr->ctrl->int_credits); | ||
94 | } | ||
95 | |||
96 | static inline void vnic_intr_return_all_credits(struct vnic_intr *intr) | ||
97 | { | ||
98 | unsigned int credits = vnic_intr_credits(intr); | ||
99 | int unmask = 1; | ||
100 | int reset_timer = 1; | ||
101 | |||
102 | vnic_intr_return_credits(intr, credits, unmask, reset_timer); | ||
103 | } | ||
104 | |||
105 | static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba) | ||
106 | { | ||
107 | /* read PBA without clearing */ | ||
108 | return ioread32(legacy_pba); | ||
109 | } | ||
110 | |||
111 | void vnic_intr_free(struct vnic_intr *intr); | ||
112 | int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, | ||
113 | unsigned int index); | ||
114 | void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer, | ||
115 | unsigned int coalescing_type, unsigned int mask_on_assertion); | ||
116 | void vnic_intr_clean(struct vnic_intr *intr); | ||
117 | |||
118 | #endif /* _VNIC_INTR_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_nic.h b/drivers/scsi/fnic/vnic_nic.h new file mode 100644 index 000000000000..f15b83eeaced --- /dev/null +++ b/drivers/scsi/fnic/vnic_nic.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_NIC_H_ | ||
19 | #define _VNIC_NIC_H_ | ||
20 | |||
21 | /* | ||
22 | * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth | ||
23 | * Driver) when both are built with CONFIG options =y | ||
24 | */ | ||
25 | #define vnic_set_nic_cfg fnic_set_nic_cfg | ||
26 | |||
27 | #define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD 0xffUL | ||
28 | #define NIC_CFG_RSS_DEFAULT_CPU_SHIFT 0 | ||
29 | #define NIC_CFG_RSS_HASH_TYPE (0xffUL << 8) | ||
30 | #define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD 0xffUL | ||
31 | #define NIC_CFG_RSS_HASH_TYPE_SHIFT 8 | ||
32 | #define NIC_CFG_RSS_HASH_BITS (7UL << 16) | ||
33 | #define NIC_CFG_RSS_HASH_BITS_MASK_FIELD 7UL | ||
34 | #define NIC_CFG_RSS_HASH_BITS_SHIFT 16 | ||
35 | #define NIC_CFG_RSS_BASE_CPU (7UL << 19) | ||
36 | #define NIC_CFG_RSS_BASE_CPU_MASK_FIELD 7UL | ||
37 | #define NIC_CFG_RSS_BASE_CPU_SHIFT 19 | ||
38 | #define NIC_CFG_RSS_ENABLE (1UL << 22) | ||
39 | #define NIC_CFG_RSS_ENABLE_MASK_FIELD 1UL | ||
40 | #define NIC_CFG_RSS_ENABLE_SHIFT 22 | ||
41 | #define NIC_CFG_TSO_IPID_SPLIT_EN (1UL << 23) | ||
42 | #define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD 1UL | ||
43 | #define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT 23 | ||
44 | #define NIC_CFG_IG_VLAN_STRIP_EN (1UL << 24) | ||
45 | #define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD 1UL | ||
46 | #define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT 24 | ||
47 | |||
48 | static inline void vnic_set_nic_cfg(u32 *nic_cfg, | ||
49 | u8 rss_default_cpu, u8 rss_hash_type, | ||
50 | u8 rss_hash_bits, u8 rss_base_cpu, | ||
51 | u8 rss_enable, u8 tso_ipid_split_en, | ||
52 | u8 ig_vlan_strip_en) | ||
53 | { | ||
54 | *nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) | | ||
55 | ((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD) | ||
56 | << NIC_CFG_RSS_HASH_TYPE_SHIFT) | | ||
57 | ((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD) | ||
58 | << NIC_CFG_RSS_HASH_BITS_SHIFT) | | ||
59 | ((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD) | ||
60 | << NIC_CFG_RSS_BASE_CPU_SHIFT) | | ||
61 | ((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD) | ||
62 | << NIC_CFG_RSS_ENABLE_SHIFT) | | ||
63 | ((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD) | ||
64 | << NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) | | ||
65 | ((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD) | ||
66 | << NIC_CFG_IG_VLAN_STRIP_EN_SHIFT); | ||
67 | } | ||
68 | |||
69 | #endif /* _VNIC_NIC_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_resource.h b/drivers/scsi/fnic/vnic_resource.h new file mode 100644 index 000000000000..2d842f79d41a --- /dev/null +++ b/drivers/scsi/fnic/vnic_resource.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_RESOURCE_H_ | ||
19 | #define _VNIC_RESOURCE_H_ | ||
20 | |||
21 | #define VNIC_RES_MAGIC 0x766E6963L /* 'vnic' */ | ||
22 | #define VNIC_RES_VERSION 0x00000000L | ||
23 | |||
24 | /* vNIC resource types */ | ||
25 | enum vnic_res_type { | ||
26 | RES_TYPE_EOL, /* End-of-list */ | ||
27 | RES_TYPE_WQ, /* Work queues */ | ||
28 | RES_TYPE_RQ, /* Receive queues */ | ||
29 | RES_TYPE_CQ, /* Completion queues */ | ||
30 | RES_TYPE_RSVD1, | ||
31 | RES_TYPE_NIC_CFG, /* Enet NIC config registers */ | ||
32 | RES_TYPE_RSVD2, | ||
33 | RES_TYPE_RSVD3, | ||
34 | RES_TYPE_RSVD4, | ||
35 | RES_TYPE_RSVD5, | ||
36 | RES_TYPE_INTR_CTRL, /* Interrupt ctrl table */ | ||
37 | RES_TYPE_INTR_TABLE, /* MSI/MSI-X Interrupt table */ | ||
38 | RES_TYPE_INTR_PBA, /* MSI/MSI-X PBA table */ | ||
39 | RES_TYPE_INTR_PBA_LEGACY, /* Legacy intr status */ | ||
40 | RES_TYPE_RSVD6, | ||
41 | RES_TYPE_RSVD7, | ||
42 | RES_TYPE_DEVCMD, /* Device command region */ | ||
43 | RES_TYPE_PASS_THRU_PAGE, /* Pass-thru page */ | ||
44 | |||
45 | RES_TYPE_MAX, /* Count of resource types */ | ||
46 | }; | ||
47 | |||
48 | struct vnic_resource_header { | ||
49 | u32 magic; | ||
50 | u32 version; | ||
51 | }; | ||
52 | |||
53 | struct vnic_resource { | ||
54 | u8 type; | ||
55 | u8 bar; | ||
56 | u8 pad[2]; | ||
57 | u32 bar_offset; | ||
58 | u32 count; | ||
59 | }; | ||
60 | |||
61 | #endif /* _VNIC_RESOURCE_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_rq.c b/drivers/scsi/fnic/vnic_rq.c new file mode 100644 index 000000000000..bedd0d285630 --- /dev/null +++ b/drivers/scsi/fnic/vnic_rq.c | |||
@@ -0,0 +1,196 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <linux/errno.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include "vnic_dev.h" | ||
24 | #include "vnic_rq.h" | ||
25 | |||
26 | static int vnic_rq_alloc_bufs(struct vnic_rq *rq) | ||
27 | { | ||
28 | struct vnic_rq_buf *buf; | ||
29 | struct vnic_dev *vdev; | ||
30 | unsigned int i, j, count = rq->ring.desc_count; | ||
31 | unsigned int blks = VNIC_RQ_BUF_BLKS_NEEDED(count); | ||
32 | |||
33 | vdev = rq->vdev; | ||
34 | |||
35 | for (i = 0; i < blks; i++) { | ||
36 | rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ, GFP_ATOMIC); | ||
37 | if (!rq->bufs[i]) { | ||
38 | printk(KERN_ERR "Failed to alloc rq_bufs\n"); | ||
39 | return -ENOMEM; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | for (i = 0; i < blks; i++) { | ||
44 | buf = rq->bufs[i]; | ||
45 | for (j = 0; j < VNIC_RQ_BUF_BLK_ENTRIES; j++) { | ||
46 | buf->index = i * VNIC_RQ_BUF_BLK_ENTRIES + j; | ||
47 | buf->desc = (u8 *)rq->ring.descs + | ||
48 | rq->ring.desc_size * buf->index; | ||
49 | if (buf->index + 1 == count) { | ||
50 | buf->next = rq->bufs[0]; | ||
51 | break; | ||
52 | } else if (j + 1 == VNIC_RQ_BUF_BLK_ENTRIES) { | ||
53 | buf->next = rq->bufs[i + 1]; | ||
54 | } else { | ||
55 | buf->next = buf + 1; | ||
56 | buf++; | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | rq->to_use = rq->to_clean = rq->bufs[0]; | ||
62 | rq->buf_index = 0; | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | void vnic_rq_free(struct vnic_rq *rq) | ||
68 | { | ||
69 | struct vnic_dev *vdev; | ||
70 | unsigned int i; | ||
71 | |||
72 | vdev = rq->vdev; | ||
73 | |||
74 | vnic_dev_free_desc_ring(vdev, &rq->ring); | ||
75 | |||
76 | for (i = 0; i < VNIC_RQ_BUF_BLKS_MAX; i++) { | ||
77 | kfree(rq->bufs[i]); | ||
78 | rq->bufs[i] = NULL; | ||
79 | } | ||
80 | |||
81 | rq->ctrl = NULL; | ||
82 | } | ||
83 | |||
84 | int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index, | ||
85 | unsigned int desc_count, unsigned int desc_size) | ||
86 | { | ||
87 | int err; | ||
88 | |||
89 | rq->index = index; | ||
90 | rq->vdev = vdev; | ||
91 | |||
92 | rq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_RQ, index); | ||
93 | if (!rq->ctrl) { | ||
94 | printk(KERN_ERR "Failed to hook RQ[%d] resource\n", index); | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | |||
98 | vnic_rq_disable(rq); | ||
99 | |||
100 | err = vnic_dev_alloc_desc_ring(vdev, &rq->ring, desc_count, desc_size); | ||
101 | if (err) | ||
102 | return err; | ||
103 | |||
104 | err = vnic_rq_alloc_bufs(rq); | ||
105 | if (err) { | ||
106 | vnic_rq_free(rq); | ||
107 | return err; | ||
108 | } | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index, | ||
114 | unsigned int error_interrupt_enable, | ||
115 | unsigned int error_interrupt_offset) | ||
116 | { | ||
117 | u64 paddr; | ||
118 | u32 fetch_index; | ||
119 | |||
120 | paddr = (u64)rq->ring.base_addr | VNIC_PADDR_TARGET; | ||
121 | writeq(paddr, &rq->ctrl->ring_base); | ||
122 | iowrite32(rq->ring.desc_count, &rq->ctrl->ring_size); | ||
123 | iowrite32(cq_index, &rq->ctrl->cq_index); | ||
124 | iowrite32(error_interrupt_enable, &rq->ctrl->error_interrupt_enable); | ||
125 | iowrite32(error_interrupt_offset, &rq->ctrl->error_interrupt_offset); | ||
126 | iowrite32(0, &rq->ctrl->dropped_packet_count); | ||
127 | iowrite32(0, &rq->ctrl->error_status); | ||
128 | |||
129 | /* Use current fetch_index as the ring starting point */ | ||
130 | fetch_index = ioread32(&rq->ctrl->fetch_index); | ||
131 | rq->to_use = rq->to_clean = | ||
132 | &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES] | ||
133 | [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES]; | ||
134 | iowrite32(fetch_index, &rq->ctrl->posted_index); | ||
135 | |||
136 | rq->buf_index = 0; | ||
137 | } | ||
138 | |||
139 | unsigned int vnic_rq_error_status(struct vnic_rq *rq) | ||
140 | { | ||
141 | return ioread32(&rq->ctrl->error_status); | ||
142 | } | ||
143 | |||
144 | void vnic_rq_enable(struct vnic_rq *rq) | ||
145 | { | ||
146 | iowrite32(1, &rq->ctrl->enable); | ||
147 | } | ||
148 | |||
149 | int vnic_rq_disable(struct vnic_rq *rq) | ||
150 | { | ||
151 | unsigned int wait; | ||
152 | |||
153 | iowrite32(0, &rq->ctrl->enable); | ||
154 | |||
155 | /* Wait for HW to ACK disable request */ | ||
156 | for (wait = 0; wait < 100; wait++) { | ||
157 | if (!(ioread32(&rq->ctrl->running))) | ||
158 | return 0; | ||
159 | udelay(1); | ||
160 | } | ||
161 | |||
162 | printk(KERN_ERR "Failed to disable RQ[%d]\n", rq->index); | ||
163 | |||
164 | return -ETIMEDOUT; | ||
165 | } | ||
166 | |||
167 | void vnic_rq_clean(struct vnic_rq *rq, | ||
168 | void (*buf_clean)(struct vnic_rq *rq, struct vnic_rq_buf *buf)) | ||
169 | { | ||
170 | struct vnic_rq_buf *buf; | ||
171 | u32 fetch_index; | ||
172 | |||
173 | BUG_ON(ioread32(&rq->ctrl->enable)); | ||
174 | |||
175 | buf = rq->to_clean; | ||
176 | |||
177 | while (vnic_rq_desc_used(rq) > 0) { | ||
178 | |||
179 | (*buf_clean)(rq, buf); | ||
180 | |||
181 | buf = rq->to_clean = buf->next; | ||
182 | rq->ring.desc_avail++; | ||
183 | } | ||
184 | |||
185 | /* Use current fetch_index as the ring starting point */ | ||
186 | fetch_index = ioread32(&rq->ctrl->fetch_index); | ||
187 | rq->to_use = rq->to_clean = | ||
188 | &rq->bufs[fetch_index / VNIC_RQ_BUF_BLK_ENTRIES] | ||
189 | [fetch_index % VNIC_RQ_BUF_BLK_ENTRIES]; | ||
190 | iowrite32(fetch_index, &rq->ctrl->posted_index); | ||
191 | |||
192 | rq->buf_index = 0; | ||
193 | |||
194 | vnic_dev_clear_desc_ring(&rq->ring); | ||
195 | } | ||
196 | |||
diff --git a/drivers/scsi/fnic/vnic_rq.h b/drivers/scsi/fnic/vnic_rq.h new file mode 100644 index 000000000000..aebdfbd6ad3c --- /dev/null +++ b/drivers/scsi/fnic/vnic_rq.h | |||
@@ -0,0 +1,235 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_RQ_H_ | ||
19 | #define _VNIC_RQ_H_ | ||
20 | |||
21 | #include <linux/pci.h> | ||
22 | #include "vnic_dev.h" | ||
23 | #include "vnic_cq.h" | ||
24 | |||
25 | /* | ||
26 | * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth | ||
27 | * Driver) when both are built with CONFIG options =y | ||
28 | */ | ||
29 | #define vnic_rq_desc_avail fnic_rq_desc_avail | ||
30 | #define vnic_rq_desc_used fnic_rq_desc_used | ||
31 | #define vnic_rq_next_desc fnic_rq_next_desc | ||
32 | #define vnic_rq_next_index fnic_rq_next_index | ||
33 | #define vnic_rq_next_buf_index fnic_rq_next_buf_index | ||
34 | #define vnic_rq_post fnic_rq_post | ||
35 | #define vnic_rq_posting_soon fnic_rq_posting_soon | ||
36 | #define vnic_rq_return_descs fnic_rq_return_descs | ||
37 | #define vnic_rq_service fnic_rq_service | ||
38 | #define vnic_rq_fill fnic_rq_fill | ||
39 | #define vnic_rq_free fnic_rq_free | ||
40 | #define vnic_rq_alloc fnic_rq_alloc | ||
41 | #define vnic_rq_init fnic_rq_init | ||
42 | #define vnic_rq_error_status fnic_rq_error_status | ||
43 | #define vnic_rq_enable fnic_rq_enable | ||
44 | #define vnic_rq_disable fnic_rq_disable | ||
45 | #define vnic_rq_clean fnic_rq_clean | ||
46 | |||
47 | /* Receive queue control */ | ||
48 | struct vnic_rq_ctrl { | ||
49 | u64 ring_base; /* 0x00 */ | ||
50 | u32 ring_size; /* 0x08 */ | ||
51 | u32 pad0; | ||
52 | u32 posted_index; /* 0x10 */ | ||
53 | u32 pad1; | ||
54 | u32 cq_index; /* 0x18 */ | ||
55 | u32 pad2; | ||
56 | u32 enable; /* 0x20 */ | ||
57 | u32 pad3; | ||
58 | u32 running; /* 0x28 */ | ||
59 | u32 pad4; | ||
60 | u32 fetch_index; /* 0x30 */ | ||
61 | u32 pad5; | ||
62 | u32 error_interrupt_enable; /* 0x38 */ | ||
63 | u32 pad6; | ||
64 | u32 error_interrupt_offset; /* 0x40 */ | ||
65 | u32 pad7; | ||
66 | u32 error_status; /* 0x48 */ | ||
67 | u32 pad8; | ||
68 | u32 dropped_packet_count; /* 0x50 */ | ||
69 | u32 pad9; | ||
70 | u32 dropped_packet_count_rc; /* 0x58 */ | ||
71 | u32 pad10; | ||
72 | }; | ||
73 | |||
74 | /* Break the vnic_rq_buf allocations into blocks of 64 entries */ | ||
75 | #define VNIC_RQ_BUF_BLK_ENTRIES 64 | ||
76 | #define VNIC_RQ_BUF_BLK_SZ \ | ||
77 | (VNIC_RQ_BUF_BLK_ENTRIES * sizeof(struct vnic_rq_buf)) | ||
78 | #define VNIC_RQ_BUF_BLKS_NEEDED(entries) \ | ||
79 | DIV_ROUND_UP(entries, VNIC_RQ_BUF_BLK_ENTRIES) | ||
80 | #define VNIC_RQ_BUF_BLKS_MAX VNIC_RQ_BUF_BLKS_NEEDED(4096) | ||
81 | |||
82 | struct vnic_rq_buf { | ||
83 | struct vnic_rq_buf *next; | ||
84 | dma_addr_t dma_addr; | ||
85 | void *os_buf; | ||
86 | unsigned int os_buf_index; | ||
87 | unsigned int len; | ||
88 | unsigned int index; | ||
89 | void *desc; | ||
90 | }; | ||
91 | |||
92 | struct vnic_rq { | ||
93 | unsigned int index; | ||
94 | struct vnic_dev *vdev; | ||
95 | struct vnic_rq_ctrl __iomem *ctrl; /* memory-mapped */ | ||
96 | struct vnic_dev_ring ring; | ||
97 | struct vnic_rq_buf *bufs[VNIC_RQ_BUF_BLKS_MAX]; | ||
98 | struct vnic_rq_buf *to_use; | ||
99 | struct vnic_rq_buf *to_clean; | ||
100 | void *os_buf_head; | ||
101 | unsigned int buf_index; | ||
102 | unsigned int pkts_outstanding; | ||
103 | }; | ||
104 | |||
105 | static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq) | ||
106 | { | ||
107 | /* how many does SW own? */ | ||
108 | return rq->ring.desc_avail; | ||
109 | } | ||
110 | |||
111 | static inline unsigned int vnic_rq_desc_used(struct vnic_rq *rq) | ||
112 | { | ||
113 | /* how many does HW own? */ | ||
114 | return rq->ring.desc_count - rq->ring.desc_avail - 1; | ||
115 | } | ||
116 | |||
117 | static inline void *vnic_rq_next_desc(struct vnic_rq *rq) | ||
118 | { | ||
119 | return rq->to_use->desc; | ||
120 | } | ||
121 | |||
122 | static inline unsigned int vnic_rq_next_index(struct vnic_rq *rq) | ||
123 | { | ||
124 | return rq->to_use->index; | ||
125 | } | ||
126 | |||
127 | static inline unsigned int vnic_rq_next_buf_index(struct vnic_rq *rq) | ||
128 | { | ||
129 | return rq->buf_index++; | ||
130 | } | ||
131 | |||
132 | static inline void vnic_rq_post(struct vnic_rq *rq, | ||
133 | void *os_buf, unsigned int os_buf_index, | ||
134 | dma_addr_t dma_addr, unsigned int len) | ||
135 | { | ||
136 | struct vnic_rq_buf *buf = rq->to_use; | ||
137 | |||
138 | buf->os_buf = os_buf; | ||
139 | buf->os_buf_index = os_buf_index; | ||
140 | buf->dma_addr = dma_addr; | ||
141 | buf->len = len; | ||
142 | |||
143 | buf = buf->next; | ||
144 | rq->to_use = buf; | ||
145 | rq->ring.desc_avail--; | ||
146 | |||
147 | /* Move the posted_index every nth descriptor | ||
148 | */ | ||
149 | |||
150 | #ifndef VNIC_RQ_RETURN_RATE | ||
151 | #define VNIC_RQ_RETURN_RATE 0xf /* keep 2^n - 1 */ | ||
152 | #endif | ||
153 | |||
154 | if ((buf->index & VNIC_RQ_RETURN_RATE) == 0) { | ||
155 | /* Adding write memory barrier prevents compiler and/or CPU | ||
156 | * reordering, thus avoiding descriptor posting before | ||
157 | * descriptor is initialized. Otherwise, hardware can read | ||
158 | * stale descriptor fields. | ||
159 | */ | ||
160 | wmb(); | ||
161 | iowrite32(buf->index, &rq->ctrl->posted_index); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | static inline int vnic_rq_posting_soon(struct vnic_rq *rq) | ||
166 | { | ||
167 | return (rq->to_use->index & VNIC_RQ_RETURN_RATE) == 0; | ||
168 | } | ||
169 | |||
170 | static inline void vnic_rq_return_descs(struct vnic_rq *rq, unsigned int count) | ||
171 | { | ||
172 | rq->ring.desc_avail += count; | ||
173 | } | ||
174 | |||
175 | enum desc_return_options { | ||
176 | VNIC_RQ_RETURN_DESC, | ||
177 | VNIC_RQ_DEFER_RETURN_DESC, | ||
178 | }; | ||
179 | |||
180 | static inline void vnic_rq_service(struct vnic_rq *rq, | ||
181 | struct cq_desc *cq_desc, u16 completed_index, | ||
182 | int desc_return, void (*buf_service)(struct vnic_rq *rq, | ||
183 | struct cq_desc *cq_desc, struct vnic_rq_buf *buf, | ||
184 | int skipped, void *opaque), void *opaque) | ||
185 | { | ||
186 | struct vnic_rq_buf *buf; | ||
187 | int skipped; | ||
188 | |||
189 | buf = rq->to_clean; | ||
190 | while (1) { | ||
191 | |||
192 | skipped = (buf->index != completed_index); | ||
193 | |||
194 | (*buf_service)(rq, cq_desc, buf, skipped, opaque); | ||
195 | |||
196 | if (desc_return == VNIC_RQ_RETURN_DESC) | ||
197 | rq->ring.desc_avail++; | ||
198 | |||
199 | rq->to_clean = buf->next; | ||
200 | |||
201 | if (!skipped) | ||
202 | break; | ||
203 | |||
204 | buf = rq->to_clean; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | static inline int vnic_rq_fill(struct vnic_rq *rq, | ||
209 | int (*buf_fill)(struct vnic_rq *rq)) | ||
210 | { | ||
211 | int err; | ||
212 | |||
213 | while (vnic_rq_desc_avail(rq) > 1) { | ||
214 | |||
215 | err = (*buf_fill)(rq); | ||
216 | if (err) | ||
217 | return err; | ||
218 | } | ||
219 | |||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | void vnic_rq_free(struct vnic_rq *rq); | ||
224 | int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index, | ||
225 | unsigned int desc_count, unsigned int desc_size); | ||
226 | void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index, | ||
227 | unsigned int error_interrupt_enable, | ||
228 | unsigned int error_interrupt_offset); | ||
229 | unsigned int vnic_rq_error_status(struct vnic_rq *rq); | ||
230 | void vnic_rq_enable(struct vnic_rq *rq); | ||
231 | int vnic_rq_disable(struct vnic_rq *rq); | ||
232 | void vnic_rq_clean(struct vnic_rq *rq, | ||
233 | void (*buf_clean)(struct vnic_rq *rq, struct vnic_rq_buf *buf)); | ||
234 | |||
235 | #endif /* _VNIC_RQ_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_scsi.h b/drivers/scsi/fnic/vnic_scsi.h new file mode 100644 index 000000000000..46baa5254001 --- /dev/null +++ b/drivers/scsi/fnic/vnic_scsi.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_SCSI_H_ | ||
19 | #define _VNIC_SCSI_H_ | ||
20 | |||
21 | #define VNIC_FNIC_WQ_COPY_COUNT_MIN 1 | ||
22 | #define VNIC_FNIC_WQ_COPY_COUNT_MAX 1 | ||
23 | |||
24 | #define VNIC_FNIC_WQ_DESCS_MIN 64 | ||
25 | #define VNIC_FNIC_WQ_DESCS_MAX 128 | ||
26 | |||
27 | #define VNIC_FNIC_WQ_COPY_DESCS_MIN 64 | ||
28 | #define VNIC_FNIC_WQ_COPY_DESCS_MAX 512 | ||
29 | |||
30 | #define VNIC_FNIC_RQ_DESCS_MIN 64 | ||
31 | #define VNIC_FNIC_RQ_DESCS_MAX 128 | ||
32 | |||
33 | #define VNIC_FNIC_EDTOV_MIN 1000 | ||
34 | #define VNIC_FNIC_EDTOV_MAX 255000 | ||
35 | #define VNIC_FNIC_EDTOV_DEF 2000 | ||
36 | |||
37 | #define VNIC_FNIC_RATOV_MIN 1000 | ||
38 | #define VNIC_FNIC_RATOV_MAX 255000 | ||
39 | |||
40 | #define VNIC_FNIC_MAXDATAFIELDSIZE_MIN 256 | ||
41 | #define VNIC_FNIC_MAXDATAFIELDSIZE_MAX 2112 | ||
42 | |||
43 | #define VNIC_FNIC_FLOGI_RETRIES_MIN 0 | ||
44 | #define VNIC_FNIC_FLOGI_RETRIES_MAX 0xffffffff | ||
45 | #define VNIC_FNIC_FLOGI_RETRIES_DEF 0xffffffff | ||
46 | |||
47 | #define VNIC_FNIC_FLOGI_TIMEOUT_MIN 1000 | ||
48 | #define VNIC_FNIC_FLOGI_TIMEOUT_MAX 255000 | ||
49 | |||
50 | #define VNIC_FNIC_PLOGI_RETRIES_MIN 0 | ||
51 | #define VNIC_FNIC_PLOGI_RETRIES_MAX 255 | ||
52 | #define VNIC_FNIC_PLOGI_RETRIES_DEF 8 | ||
53 | |||
54 | #define VNIC_FNIC_PLOGI_TIMEOUT_MIN 1000 | ||
55 | #define VNIC_FNIC_PLOGI_TIMEOUT_MAX 255000 | ||
56 | |||
57 | #define VNIC_FNIC_IO_THROTTLE_COUNT_MIN 256 | ||
58 | #define VNIC_FNIC_IO_THROTTLE_COUNT_MAX 4096 | ||
59 | |||
60 | #define VNIC_FNIC_LINK_DOWN_TIMEOUT_MIN 0 | ||
61 | #define VNIC_FNIC_LINK_DOWN_TIMEOUT_MAX 240000 | ||
62 | |||
63 | #define VNIC_FNIC_PORT_DOWN_TIMEOUT_MIN 0 | ||
64 | #define VNIC_FNIC_PORT_DOWN_TIMEOUT_MAX 240000 | ||
65 | |||
66 | #define VNIC_FNIC_PORT_DOWN_IO_RETRIES_MIN 0 | ||
67 | #define VNIC_FNIC_PORT_DOWN_IO_RETRIES_MAX 255 | ||
68 | |||
69 | #define VNIC_FNIC_LUNS_PER_TARGET_MIN 1 | ||
70 | #define VNIC_FNIC_LUNS_PER_TARGET_MAX 1024 | ||
71 | |||
72 | /* Device-specific region: scsi configuration */ | ||
73 | struct vnic_fc_config { | ||
74 | u64 node_wwn; | ||
75 | u64 port_wwn; | ||
76 | u32 flags; | ||
77 | u32 wq_enet_desc_count; | ||
78 | u32 wq_copy_desc_count; | ||
79 | u32 rq_desc_count; | ||
80 | u32 flogi_retries; | ||
81 | u32 flogi_timeout; | ||
82 | u32 plogi_retries; | ||
83 | u32 plogi_timeout; | ||
84 | u32 io_throttle_count; | ||
85 | u32 link_down_timeout; | ||
86 | u32 port_down_timeout; | ||
87 | u32 port_down_io_retries; | ||
88 | u32 luns_per_tgt; | ||
89 | u16 maxdatafieldsize; | ||
90 | u16 ed_tov; | ||
91 | u16 ra_tov; | ||
92 | u16 intr_timer; | ||
93 | u8 intr_timer_type; | ||
94 | }; | ||
95 | |||
96 | #define VFCF_FCP_SEQ_LVL_ERR 0x1 /* Enable FCP-2 Error Recovery */ | ||
97 | #define VFCF_PERBI 0x2 /* persistent binding info available */ | ||
98 | |||
99 | #endif /* _VNIC_SCSI_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_stats.h b/drivers/scsi/fnic/vnic_stats.h new file mode 100644 index 000000000000..5372e23c1cb3 --- /dev/null +++ b/drivers/scsi/fnic/vnic_stats.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_STATS_H_ | ||
19 | #define _VNIC_STATS_H_ | ||
20 | |||
21 | /* Tx statistics */ | ||
22 | struct vnic_tx_stats { | ||
23 | u64 tx_frames_ok; | ||
24 | u64 tx_unicast_frames_ok; | ||
25 | u64 tx_multicast_frames_ok; | ||
26 | u64 tx_broadcast_frames_ok; | ||
27 | u64 tx_bytes_ok; | ||
28 | u64 tx_unicast_bytes_ok; | ||
29 | u64 tx_multicast_bytes_ok; | ||
30 | u64 tx_broadcast_bytes_ok; | ||
31 | u64 tx_drops; | ||
32 | u64 tx_errors; | ||
33 | u64 tx_tso; | ||
34 | u64 rsvd[16]; | ||
35 | }; | ||
36 | |||
37 | /* Rx statistics */ | ||
38 | struct vnic_rx_stats { | ||
39 | u64 rx_frames_ok; | ||
40 | u64 rx_frames_total; | ||
41 | u64 rx_unicast_frames_ok; | ||
42 | u64 rx_multicast_frames_ok; | ||
43 | u64 rx_broadcast_frames_ok; | ||
44 | u64 rx_bytes_ok; | ||
45 | u64 rx_unicast_bytes_ok; | ||
46 | u64 rx_multicast_bytes_ok; | ||
47 | u64 rx_broadcast_bytes_ok; | ||
48 | u64 rx_drop; | ||
49 | u64 rx_no_bufs; | ||
50 | u64 rx_errors; | ||
51 | u64 rx_rss; | ||
52 | u64 rx_crc_errors; | ||
53 | u64 rx_frames_64; | ||
54 | u64 rx_frames_127; | ||
55 | u64 rx_frames_255; | ||
56 | u64 rx_frames_511; | ||
57 | u64 rx_frames_1023; | ||
58 | u64 rx_frames_1518; | ||
59 | u64 rx_frames_to_max; | ||
60 | u64 rsvd[16]; | ||
61 | }; | ||
62 | |||
63 | struct vnic_stats { | ||
64 | struct vnic_tx_stats tx; | ||
65 | struct vnic_rx_stats rx; | ||
66 | }; | ||
67 | |||
68 | #endif /* _VNIC_STATS_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_wq.c b/drivers/scsi/fnic/vnic_wq.c new file mode 100644 index 000000000000..1f9ea790d130 --- /dev/null +++ b/drivers/scsi/fnic/vnic_wq.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <linux/errno.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include "vnic_dev.h" | ||
24 | #include "vnic_wq.h" | ||
25 | |||
26 | static int vnic_wq_alloc_bufs(struct vnic_wq *wq) | ||
27 | { | ||
28 | struct vnic_wq_buf *buf; | ||
29 | struct vnic_dev *vdev; | ||
30 | unsigned int i, j, count = wq->ring.desc_count; | ||
31 | unsigned int blks = VNIC_WQ_BUF_BLKS_NEEDED(count); | ||
32 | |||
33 | vdev = wq->vdev; | ||
34 | |||
35 | for (i = 0; i < blks; i++) { | ||
36 | wq->bufs[i] = kzalloc(VNIC_WQ_BUF_BLK_SZ, GFP_ATOMIC); | ||
37 | if (!wq->bufs[i]) { | ||
38 | printk(KERN_ERR "Failed to alloc wq_bufs\n"); | ||
39 | return -ENOMEM; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | for (i = 0; i < blks; i++) { | ||
44 | buf = wq->bufs[i]; | ||
45 | for (j = 0; j < VNIC_WQ_BUF_BLK_ENTRIES; j++) { | ||
46 | buf->index = i * VNIC_WQ_BUF_BLK_ENTRIES + j; | ||
47 | buf->desc = (u8 *)wq->ring.descs + | ||
48 | wq->ring.desc_size * buf->index; | ||
49 | if (buf->index + 1 == count) { | ||
50 | buf->next = wq->bufs[0]; | ||
51 | break; | ||
52 | } else if (j + 1 == VNIC_WQ_BUF_BLK_ENTRIES) { | ||
53 | buf->next = wq->bufs[i + 1]; | ||
54 | } else { | ||
55 | buf->next = buf + 1; | ||
56 | buf++; | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | wq->to_use = wq->to_clean = wq->bufs[0]; | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | void vnic_wq_free(struct vnic_wq *wq) | ||
67 | { | ||
68 | struct vnic_dev *vdev; | ||
69 | unsigned int i; | ||
70 | |||
71 | vdev = wq->vdev; | ||
72 | |||
73 | vnic_dev_free_desc_ring(vdev, &wq->ring); | ||
74 | |||
75 | for (i = 0; i < VNIC_WQ_BUF_BLKS_MAX; i++) { | ||
76 | kfree(wq->bufs[i]); | ||
77 | wq->bufs[i] = NULL; | ||
78 | } | ||
79 | |||
80 | wq->ctrl = NULL; | ||
81 | |||
82 | } | ||
83 | |||
84 | int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int index, | ||
85 | unsigned int desc_count, unsigned int desc_size) | ||
86 | { | ||
87 | int err; | ||
88 | |||
89 | wq->index = index; | ||
90 | wq->vdev = vdev; | ||
91 | |||
92 | wq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_WQ, index); | ||
93 | if (!wq->ctrl) { | ||
94 | printk(KERN_ERR "Failed to hook WQ[%d] resource\n", index); | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | |||
98 | vnic_wq_disable(wq); | ||
99 | |||
100 | err = vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size); | ||
101 | if (err) | ||
102 | return err; | ||
103 | |||
104 | err = vnic_wq_alloc_bufs(wq); | ||
105 | if (err) { | ||
106 | vnic_wq_free(wq); | ||
107 | return err; | ||
108 | } | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | void vnic_wq_init(struct vnic_wq *wq, unsigned int cq_index, | ||
114 | unsigned int error_interrupt_enable, | ||
115 | unsigned int error_interrupt_offset) | ||
116 | { | ||
117 | u64 paddr; | ||
118 | |||
119 | paddr = (u64)wq->ring.base_addr | VNIC_PADDR_TARGET; | ||
120 | writeq(paddr, &wq->ctrl->ring_base); | ||
121 | iowrite32(wq->ring.desc_count, &wq->ctrl->ring_size); | ||
122 | iowrite32(0, &wq->ctrl->fetch_index); | ||
123 | iowrite32(0, &wq->ctrl->posted_index); | ||
124 | iowrite32(cq_index, &wq->ctrl->cq_index); | ||
125 | iowrite32(error_interrupt_enable, &wq->ctrl->error_interrupt_enable); | ||
126 | iowrite32(error_interrupt_offset, &wq->ctrl->error_interrupt_offset); | ||
127 | iowrite32(0, &wq->ctrl->error_status); | ||
128 | } | ||
129 | |||
130 | unsigned int vnic_wq_error_status(struct vnic_wq *wq) | ||
131 | { | ||
132 | return ioread32(&wq->ctrl->error_status); | ||
133 | } | ||
134 | |||
135 | void vnic_wq_enable(struct vnic_wq *wq) | ||
136 | { | ||
137 | iowrite32(1, &wq->ctrl->enable); | ||
138 | } | ||
139 | |||
140 | int vnic_wq_disable(struct vnic_wq *wq) | ||
141 | { | ||
142 | unsigned int wait; | ||
143 | |||
144 | iowrite32(0, &wq->ctrl->enable); | ||
145 | |||
146 | /* Wait for HW to ACK disable request */ | ||
147 | for (wait = 0; wait < 100; wait++) { | ||
148 | if (!(ioread32(&wq->ctrl->running))) | ||
149 | return 0; | ||
150 | udelay(1); | ||
151 | } | ||
152 | |||
153 | printk(KERN_ERR "Failed to disable WQ[%d]\n", wq->index); | ||
154 | |||
155 | return -ETIMEDOUT; | ||
156 | } | ||
157 | |||
158 | void vnic_wq_clean(struct vnic_wq *wq, | ||
159 | void (*buf_clean)(struct vnic_wq *wq, struct vnic_wq_buf *buf)) | ||
160 | { | ||
161 | struct vnic_wq_buf *buf; | ||
162 | |||
163 | BUG_ON(ioread32(&wq->ctrl->enable)); | ||
164 | |||
165 | buf = wq->to_clean; | ||
166 | |||
167 | while (vnic_wq_desc_used(wq) > 0) { | ||
168 | |||
169 | (*buf_clean)(wq, buf); | ||
170 | |||
171 | buf = wq->to_clean = buf->next; | ||
172 | wq->ring.desc_avail++; | ||
173 | } | ||
174 | |||
175 | wq->to_use = wq->to_clean = wq->bufs[0]; | ||
176 | |||
177 | iowrite32(0, &wq->ctrl->fetch_index); | ||
178 | iowrite32(0, &wq->ctrl->posted_index); | ||
179 | iowrite32(0, &wq->ctrl->error_status); | ||
180 | |||
181 | vnic_dev_clear_desc_ring(&wq->ring); | ||
182 | } | ||
diff --git a/drivers/scsi/fnic/vnic_wq.h b/drivers/scsi/fnic/vnic_wq.h new file mode 100644 index 000000000000..5cd094f79281 --- /dev/null +++ b/drivers/scsi/fnic/vnic_wq.h | |||
@@ -0,0 +1,175 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_WQ_H_ | ||
19 | #define _VNIC_WQ_H_ | ||
20 | |||
21 | #include <linux/pci.h> | ||
22 | #include "vnic_dev.h" | ||
23 | #include "vnic_cq.h" | ||
24 | |||
25 | /* | ||
26 | * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth | ||
27 | * Driver) when both are built with CONFIG options =y | ||
28 | */ | ||
29 | #define vnic_wq_desc_avail fnic_wq_desc_avail | ||
30 | #define vnic_wq_desc_used fnic_wq_desc_used | ||
31 | #define vnic_wq_next_desc fni_cwq_next_desc | ||
32 | #define vnic_wq_post fnic_wq_post | ||
33 | #define vnic_wq_service fnic_wq_service | ||
34 | #define vnic_wq_free fnic_wq_free | ||
35 | #define vnic_wq_alloc fnic_wq_alloc | ||
36 | #define vnic_wq_init fnic_wq_init | ||
37 | #define vnic_wq_error_status fnic_wq_error_status | ||
38 | #define vnic_wq_enable fnic_wq_enable | ||
39 | #define vnic_wq_disable fnic_wq_disable | ||
40 | #define vnic_wq_clean fnic_wq_clean | ||
41 | |||
42 | /* Work queue control */ | ||
43 | struct vnic_wq_ctrl { | ||
44 | u64 ring_base; /* 0x00 */ | ||
45 | u32 ring_size; /* 0x08 */ | ||
46 | u32 pad0; | ||
47 | u32 posted_index; /* 0x10 */ | ||
48 | u32 pad1; | ||
49 | u32 cq_index; /* 0x18 */ | ||
50 | u32 pad2; | ||
51 | u32 enable; /* 0x20 */ | ||
52 | u32 pad3; | ||
53 | u32 running; /* 0x28 */ | ||
54 | u32 pad4; | ||
55 | u32 fetch_index; /* 0x30 */ | ||
56 | u32 pad5; | ||
57 | u32 dca_value; /* 0x38 */ | ||
58 | u32 pad6; | ||
59 | u32 error_interrupt_enable; /* 0x40 */ | ||
60 | u32 pad7; | ||
61 | u32 error_interrupt_offset; /* 0x48 */ | ||
62 | u32 pad8; | ||
63 | u32 error_status; /* 0x50 */ | ||
64 | u32 pad9; | ||
65 | }; | ||
66 | |||
67 | struct vnic_wq_buf { | ||
68 | struct vnic_wq_buf *next; | ||
69 | dma_addr_t dma_addr; | ||
70 | void *os_buf; | ||
71 | unsigned int len; | ||
72 | unsigned int index; | ||
73 | int sop; | ||
74 | void *desc; | ||
75 | }; | ||
76 | |||
77 | /* Break the vnic_wq_buf allocations into blocks of 64 entries */ | ||
78 | #define VNIC_WQ_BUF_BLK_ENTRIES 64 | ||
79 | #define VNIC_WQ_BUF_BLK_SZ \ | ||
80 | (VNIC_WQ_BUF_BLK_ENTRIES * sizeof(struct vnic_wq_buf)) | ||
81 | #define VNIC_WQ_BUF_BLKS_NEEDED(entries) \ | ||
82 | DIV_ROUND_UP(entries, VNIC_WQ_BUF_BLK_ENTRIES) | ||
83 | #define VNIC_WQ_BUF_BLKS_MAX VNIC_WQ_BUF_BLKS_NEEDED(4096) | ||
84 | |||
85 | struct vnic_wq { | ||
86 | unsigned int index; | ||
87 | struct vnic_dev *vdev; | ||
88 | struct vnic_wq_ctrl __iomem *ctrl; /* memory-mapped */ | ||
89 | struct vnic_dev_ring ring; | ||
90 | struct vnic_wq_buf *bufs[VNIC_WQ_BUF_BLKS_MAX]; | ||
91 | struct vnic_wq_buf *to_use; | ||
92 | struct vnic_wq_buf *to_clean; | ||
93 | unsigned int pkts_outstanding; | ||
94 | }; | ||
95 | |||
96 | static inline unsigned int vnic_wq_desc_avail(struct vnic_wq *wq) | ||
97 | { | ||
98 | /* how many does SW own? */ | ||
99 | return wq->ring.desc_avail; | ||
100 | } | ||
101 | |||
102 | static inline unsigned int vnic_wq_desc_used(struct vnic_wq *wq) | ||
103 | { | ||
104 | /* how many does HW own? */ | ||
105 | return wq->ring.desc_count - wq->ring.desc_avail - 1; | ||
106 | } | ||
107 | |||
108 | static inline void *vnic_wq_next_desc(struct vnic_wq *wq) | ||
109 | { | ||
110 | return wq->to_use->desc; | ||
111 | } | ||
112 | |||
113 | static inline void vnic_wq_post(struct vnic_wq *wq, | ||
114 | void *os_buf, dma_addr_t dma_addr, | ||
115 | unsigned int len, int sop, int eop) | ||
116 | { | ||
117 | struct vnic_wq_buf *buf = wq->to_use; | ||
118 | |||
119 | buf->sop = sop; | ||
120 | buf->os_buf = eop ? os_buf : NULL; | ||
121 | buf->dma_addr = dma_addr; | ||
122 | buf->len = len; | ||
123 | |||
124 | buf = buf->next; | ||
125 | if (eop) { | ||
126 | /* Adding write memory barrier prevents compiler and/or CPU | ||
127 | * reordering, thus avoiding descriptor posting before | ||
128 | * descriptor is initialized. Otherwise, hardware can read | ||
129 | * stale descriptor fields. | ||
130 | */ | ||
131 | wmb(); | ||
132 | iowrite32(buf->index, &wq->ctrl->posted_index); | ||
133 | } | ||
134 | wq->to_use = buf; | ||
135 | |||
136 | wq->ring.desc_avail--; | ||
137 | } | ||
138 | |||
139 | static inline void vnic_wq_service(struct vnic_wq *wq, | ||
140 | struct cq_desc *cq_desc, u16 completed_index, | ||
141 | void (*buf_service)(struct vnic_wq *wq, | ||
142 | struct cq_desc *cq_desc, struct vnic_wq_buf *buf, void *opaque), | ||
143 | void *opaque) | ||
144 | { | ||
145 | struct vnic_wq_buf *buf; | ||
146 | |||
147 | buf = wq->to_clean; | ||
148 | while (1) { | ||
149 | |||
150 | (*buf_service)(wq, cq_desc, buf, opaque); | ||
151 | |||
152 | wq->ring.desc_avail++; | ||
153 | |||
154 | wq->to_clean = buf->next; | ||
155 | |||
156 | if (buf->index == completed_index) | ||
157 | break; | ||
158 | |||
159 | buf = wq->to_clean; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | void vnic_wq_free(struct vnic_wq *wq); | ||
164 | int vnic_wq_alloc(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int index, | ||
165 | unsigned int desc_count, unsigned int desc_size); | ||
166 | void vnic_wq_init(struct vnic_wq *wq, unsigned int cq_index, | ||
167 | unsigned int error_interrupt_enable, | ||
168 | unsigned int error_interrupt_offset); | ||
169 | unsigned int vnic_wq_error_status(struct vnic_wq *wq); | ||
170 | void vnic_wq_enable(struct vnic_wq *wq); | ||
171 | int vnic_wq_disable(struct vnic_wq *wq); | ||
172 | void vnic_wq_clean(struct vnic_wq *wq, | ||
173 | void (*buf_clean)(struct vnic_wq *wq, struct vnic_wq_buf *buf)); | ||
174 | |||
175 | #endif /* _VNIC_WQ_H_ */ | ||
diff --git a/drivers/scsi/fnic/vnic_wq_copy.c b/drivers/scsi/fnic/vnic_wq_copy.c new file mode 100644 index 000000000000..9eab7e7caf38 --- /dev/null +++ b/drivers/scsi/fnic/vnic_wq_copy.c | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <linux/errno.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/pci.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include "vnic_wq_copy.h" | ||
24 | |||
25 | void vnic_wq_copy_enable(struct vnic_wq_copy *wq) | ||
26 | { | ||
27 | iowrite32(1, &wq->ctrl->enable); | ||
28 | } | ||
29 | |||
30 | int vnic_wq_copy_disable(struct vnic_wq_copy *wq) | ||
31 | { | ||
32 | unsigned int wait; | ||
33 | |||
34 | iowrite32(0, &wq->ctrl->enable); | ||
35 | |||
36 | /* Wait for HW to ACK disable request */ | ||
37 | for (wait = 0; wait < 100; wait++) { | ||
38 | if (!(ioread32(&wq->ctrl->running))) | ||
39 | return 0; | ||
40 | udelay(1); | ||
41 | } | ||
42 | |||
43 | printk(KERN_ERR "Failed to disable Copy WQ[%d]," | ||
44 | " fetch index=%d, posted_index=%d\n", | ||
45 | wq->index, ioread32(&wq->ctrl->fetch_index), | ||
46 | ioread32(&wq->ctrl->posted_index)); | ||
47 | |||
48 | return -ENODEV; | ||
49 | } | ||
50 | |||
51 | void vnic_wq_copy_clean(struct vnic_wq_copy *wq, | ||
52 | void (*q_clean)(struct vnic_wq_copy *wq, | ||
53 | struct fcpio_host_req *wq_desc)) | ||
54 | { | ||
55 | BUG_ON(ioread32(&wq->ctrl->enable)); | ||
56 | |||
57 | if (vnic_wq_copy_desc_in_use(wq)) | ||
58 | vnic_wq_copy_service(wq, -1, q_clean); | ||
59 | |||
60 | wq->to_use_index = wq->to_clean_index = 0; | ||
61 | |||
62 | iowrite32(0, &wq->ctrl->fetch_index); | ||
63 | iowrite32(0, &wq->ctrl->posted_index); | ||
64 | iowrite32(0, &wq->ctrl->error_status); | ||
65 | |||
66 | vnic_dev_clear_desc_ring(&wq->ring); | ||
67 | } | ||
68 | |||
69 | void vnic_wq_copy_free(struct vnic_wq_copy *wq) | ||
70 | { | ||
71 | struct vnic_dev *vdev; | ||
72 | |||
73 | vdev = wq->vdev; | ||
74 | vnic_dev_free_desc_ring(vdev, &wq->ring); | ||
75 | wq->ctrl = NULL; | ||
76 | } | ||
77 | |||
78 | int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct vnic_wq_copy *wq, | ||
79 | unsigned int index, unsigned int desc_count, | ||
80 | unsigned int desc_size) | ||
81 | { | ||
82 | int err; | ||
83 | |||
84 | wq->index = index; | ||
85 | wq->vdev = vdev; | ||
86 | wq->to_use_index = wq->to_clean_index = 0; | ||
87 | wq->ctrl = vnic_dev_get_res(vdev, RES_TYPE_WQ, index); | ||
88 | if (!wq->ctrl) { | ||
89 | printk(KERN_ERR "Failed to hook COPY WQ[%d] resource\n", index); | ||
90 | return -EINVAL; | ||
91 | } | ||
92 | |||
93 | vnic_wq_copy_disable(wq); | ||
94 | |||
95 | err = vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size); | ||
96 | if (err) | ||
97 | return err; | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | void vnic_wq_copy_init(struct vnic_wq_copy *wq, unsigned int cq_index, | ||
103 | unsigned int error_interrupt_enable, | ||
104 | unsigned int error_interrupt_offset) | ||
105 | { | ||
106 | u64 paddr; | ||
107 | |||
108 | paddr = (u64)wq->ring.base_addr | VNIC_PADDR_TARGET; | ||
109 | writeq(paddr, &wq->ctrl->ring_base); | ||
110 | iowrite32(wq->ring.desc_count, &wq->ctrl->ring_size); | ||
111 | iowrite32(0, &wq->ctrl->fetch_index); | ||
112 | iowrite32(0, &wq->ctrl->posted_index); | ||
113 | iowrite32(cq_index, &wq->ctrl->cq_index); | ||
114 | iowrite32(error_interrupt_enable, &wq->ctrl->error_interrupt_enable); | ||
115 | iowrite32(error_interrupt_offset, &wq->ctrl->error_interrupt_offset); | ||
116 | } | ||
117 | |||
diff --git a/drivers/scsi/fnic/vnic_wq_copy.h b/drivers/scsi/fnic/vnic_wq_copy.h new file mode 100644 index 000000000000..6aff9740c3df --- /dev/null +++ b/drivers/scsi/fnic/vnic_wq_copy.h | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _VNIC_WQ_COPY_H_ | ||
19 | #define _VNIC_WQ_COPY_H_ | ||
20 | |||
21 | #include <linux/pci.h> | ||
22 | #include "vnic_wq.h" | ||
23 | #include "fcpio.h" | ||
24 | |||
25 | #define VNIC_WQ_COPY_MAX 1 | ||
26 | |||
27 | struct vnic_wq_copy { | ||
28 | unsigned int index; | ||
29 | struct vnic_dev *vdev; | ||
30 | struct vnic_wq_ctrl __iomem *ctrl; /* memory-mapped */ | ||
31 | struct vnic_dev_ring ring; | ||
32 | unsigned to_use_index; | ||
33 | unsigned to_clean_index; | ||
34 | }; | ||
35 | |||
36 | static inline unsigned int vnic_wq_copy_desc_avail(struct vnic_wq_copy *wq) | ||
37 | { | ||
38 | return wq->ring.desc_avail; | ||
39 | } | ||
40 | |||
41 | static inline unsigned int vnic_wq_copy_desc_in_use(struct vnic_wq_copy *wq) | ||
42 | { | ||
43 | return wq->ring.desc_count - 1 - wq->ring.desc_avail; | ||
44 | } | ||
45 | |||
46 | static inline void *vnic_wq_copy_next_desc(struct vnic_wq_copy *wq) | ||
47 | { | ||
48 | struct fcpio_host_req *desc = wq->ring.descs; | ||
49 | return &desc[wq->to_use_index]; | ||
50 | } | ||
51 | |||
52 | static inline void vnic_wq_copy_post(struct vnic_wq_copy *wq) | ||
53 | { | ||
54 | |||
55 | ((wq->to_use_index + 1) == wq->ring.desc_count) ? | ||
56 | (wq->to_use_index = 0) : (wq->to_use_index++); | ||
57 | wq->ring.desc_avail--; | ||
58 | |||
59 | /* Adding write memory barrier prevents compiler and/or CPU | ||
60 | * reordering, thus avoiding descriptor posting before | ||
61 | * descriptor is initialized. Otherwise, hardware can read | ||
62 | * stale descriptor fields. | ||
63 | */ | ||
64 | wmb(); | ||
65 | |||
66 | iowrite32(wq->to_use_index, &wq->ctrl->posted_index); | ||
67 | } | ||
68 | |||
69 | static inline void vnic_wq_copy_desc_process(struct vnic_wq_copy *wq, u16 index) | ||
70 | { | ||
71 | unsigned int cnt; | ||
72 | |||
73 | if (wq->to_clean_index <= index) | ||
74 | cnt = (index - wq->to_clean_index) + 1; | ||
75 | else | ||
76 | cnt = wq->ring.desc_count - wq->to_clean_index + index + 1; | ||
77 | |||
78 | wq->to_clean_index = ((index + 1) % wq->ring.desc_count); | ||
79 | wq->ring.desc_avail += cnt; | ||
80 | |||
81 | } | ||
82 | |||
83 | static inline void vnic_wq_copy_service(struct vnic_wq_copy *wq, | ||
84 | u16 completed_index, | ||
85 | void (*q_service)(struct vnic_wq_copy *wq, | ||
86 | struct fcpio_host_req *wq_desc)) | ||
87 | { | ||
88 | struct fcpio_host_req *wq_desc = wq->ring.descs; | ||
89 | unsigned int curr_index; | ||
90 | |||
91 | while (1) { | ||
92 | |||
93 | if (q_service) | ||
94 | (*q_service)(wq, &wq_desc[wq->to_clean_index]); | ||
95 | |||
96 | wq->ring.desc_avail++; | ||
97 | |||
98 | curr_index = wq->to_clean_index; | ||
99 | |||
100 | /* increment the to-clean index so that we start | ||
101 | * with an unprocessed index next time we enter the loop | ||
102 | */ | ||
103 | ((wq->to_clean_index + 1) == wq->ring.desc_count) ? | ||
104 | (wq->to_clean_index = 0) : (wq->to_clean_index++); | ||
105 | |||
106 | if (curr_index == completed_index) | ||
107 | break; | ||
108 | |||
109 | /* we have cleaned all the entries */ | ||
110 | if ((completed_index == (u16)-1) && | ||
111 | (wq->to_clean_index == wq->to_use_index)) | ||
112 | break; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | void vnic_wq_copy_enable(struct vnic_wq_copy *wq); | ||
117 | int vnic_wq_copy_disable(struct vnic_wq_copy *wq); | ||
118 | void vnic_wq_copy_free(struct vnic_wq_copy *wq); | ||
119 | int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct vnic_wq_copy *wq, | ||
120 | unsigned int index, unsigned int desc_count, unsigned int desc_size); | ||
121 | void vnic_wq_copy_init(struct vnic_wq_copy *wq, unsigned int cq_index, | ||
122 | unsigned int error_interrupt_enable, | ||
123 | unsigned int error_interrupt_offset); | ||
124 | void vnic_wq_copy_clean(struct vnic_wq_copy *wq, | ||
125 | void (*q_clean)(struct vnic_wq_copy *wq, | ||
126 | struct fcpio_host_req *wq_desc)); | ||
127 | |||
128 | #endif /* _VNIC_WQ_COPY_H_ */ | ||
diff --git a/drivers/scsi/fnic/wq_enet_desc.h b/drivers/scsi/fnic/wq_enet_desc.h new file mode 100644 index 000000000000..b121cbad18b8 --- /dev/null +++ b/drivers/scsi/fnic/wq_enet_desc.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cisco Systems, Inc. All rights reserved. | ||
3 | * Copyright 2007 Nuova Systems, Inc. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you may redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; version 2 of the License. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
10 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
11 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
12 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
13 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
15 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
16 | * SOFTWARE. | ||
17 | */ | ||
18 | #ifndef _WQ_ENET_DESC_H_ | ||
19 | #define _WQ_ENET_DESC_H_ | ||
20 | |||
21 | /* Ethernet work queue descriptor: 16B */ | ||
22 | struct wq_enet_desc { | ||
23 | __le64 address; | ||
24 | __le16 length; | ||
25 | __le16 mss_loopback; | ||
26 | __le16 header_length_flags; | ||
27 | __le16 vlan_tag; | ||
28 | }; | ||
29 | |||
30 | #define WQ_ENET_ADDR_BITS 64 | ||
31 | #define WQ_ENET_LEN_BITS 14 | ||
32 | #define WQ_ENET_LEN_MASK ((1 << WQ_ENET_LEN_BITS) - 1) | ||
33 | #define WQ_ENET_MSS_BITS 14 | ||
34 | #define WQ_ENET_MSS_MASK ((1 << WQ_ENET_MSS_BITS) - 1) | ||
35 | #define WQ_ENET_MSS_SHIFT 2 | ||
36 | #define WQ_ENET_LOOPBACK_SHIFT 1 | ||
37 | #define WQ_ENET_HDRLEN_BITS 10 | ||
38 | #define WQ_ENET_HDRLEN_MASK ((1 << WQ_ENET_HDRLEN_BITS) - 1) | ||
39 | #define WQ_ENET_FLAGS_OM_BITS 2 | ||
40 | #define WQ_ENET_FLAGS_OM_MASK ((1 << WQ_ENET_FLAGS_OM_BITS) - 1) | ||
41 | #define WQ_ENET_FLAGS_EOP_SHIFT 12 | ||
42 | #define WQ_ENET_FLAGS_CQ_ENTRY_SHIFT 13 | ||
43 | #define WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT 14 | ||
44 | #define WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT 15 | ||
45 | |||
46 | #define WQ_ENET_OFFLOAD_MODE_CSUM 0 | ||
47 | #define WQ_ENET_OFFLOAD_MODE_RESERVED 1 | ||
48 | #define WQ_ENET_OFFLOAD_MODE_CSUM_L4 2 | ||
49 | #define WQ_ENET_OFFLOAD_MODE_TSO 3 | ||
50 | |||
51 | static inline void wq_enet_desc_enc(struct wq_enet_desc *desc, | ||
52 | u64 address, u16 length, u16 mss, u16 header_length, | ||
53 | u8 offload_mode, u8 eop, u8 cq_entry, u8 fcoe_encap, | ||
54 | u8 vlan_tag_insert, u16 vlan_tag, u8 loopback) | ||
55 | { | ||
56 | desc->address = cpu_to_le64(address); | ||
57 | desc->length = cpu_to_le16(length & WQ_ENET_LEN_MASK); | ||
58 | desc->mss_loopback = cpu_to_le16((mss & WQ_ENET_MSS_MASK) << | ||
59 | WQ_ENET_MSS_SHIFT | (loopback & 1) << WQ_ENET_LOOPBACK_SHIFT); | ||
60 | desc->header_length_flags = cpu_to_le16( | ||
61 | (header_length & WQ_ENET_HDRLEN_MASK) | | ||
62 | (offload_mode & WQ_ENET_FLAGS_OM_MASK) << WQ_ENET_HDRLEN_BITS | | ||
63 | (eop & 1) << WQ_ENET_FLAGS_EOP_SHIFT | | ||
64 | (cq_entry & 1) << WQ_ENET_FLAGS_CQ_ENTRY_SHIFT | | ||
65 | (fcoe_encap & 1) << WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT | | ||
66 | (vlan_tag_insert & 1) << WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT); | ||
67 | desc->vlan_tag = cpu_to_le16(vlan_tag); | ||
68 | } | ||
69 | |||
70 | static inline void wq_enet_desc_dec(struct wq_enet_desc *desc, | ||
71 | u64 *address, u16 *length, u16 *mss, u16 *header_length, | ||
72 | u8 *offload_mode, u8 *eop, u8 *cq_entry, u8 *fcoe_encap, | ||
73 | u8 *vlan_tag_insert, u16 *vlan_tag, u8 *loopback) | ||
74 | { | ||
75 | *address = le64_to_cpu(desc->address); | ||
76 | *length = le16_to_cpu(desc->length) & WQ_ENET_LEN_MASK; | ||
77 | *mss = (le16_to_cpu(desc->mss_loopback) >> WQ_ENET_MSS_SHIFT) & | ||
78 | WQ_ENET_MSS_MASK; | ||
79 | *loopback = (u8)((le16_to_cpu(desc->mss_loopback) >> | ||
80 | WQ_ENET_LOOPBACK_SHIFT) & 1); | ||
81 | *header_length = le16_to_cpu(desc->header_length_flags) & | ||
82 | WQ_ENET_HDRLEN_MASK; | ||
83 | *offload_mode = (u8)((le16_to_cpu(desc->header_length_flags) >> | ||
84 | WQ_ENET_HDRLEN_BITS) & WQ_ENET_FLAGS_OM_MASK); | ||
85 | *eop = (u8)((le16_to_cpu(desc->header_length_flags) >> | ||
86 | WQ_ENET_FLAGS_EOP_SHIFT) & 1); | ||
87 | *cq_entry = (u8)((le16_to_cpu(desc->header_length_flags) >> | ||
88 | WQ_ENET_FLAGS_CQ_ENTRY_SHIFT) & 1); | ||
89 | *fcoe_encap = (u8)((le16_to_cpu(desc->header_length_flags) >> | ||
90 | WQ_ENET_FLAGS_FCOE_ENCAP_SHIFT) & 1); | ||
91 | *vlan_tag_insert = (u8)((le16_to_cpu(desc->header_length_flags) >> | ||
92 | WQ_ENET_FLAGS_VLAN_TAG_INSERT_SHIFT) & 1); | ||
93 | *vlan_tag = le16_to_cpu(desc->vlan_tag); | ||
94 | } | ||
95 | |||
96 | #endif /* _WQ_ENET_DESC_H_ */ | ||
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index c09d77591f92..dd689ded8609 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -3654,6 +3654,7 @@ static int ipr_slave_configure(struct scsi_device *sdev) | |||
3654 | { | 3654 | { |
3655 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata; | 3655 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata; |
3656 | struct ipr_resource_entry *res; | 3656 | struct ipr_resource_entry *res; |
3657 | struct ata_port *ap = NULL; | ||
3657 | unsigned long lock_flags = 0; | 3658 | unsigned long lock_flags = 0; |
3658 | 3659 | ||
3659 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | 3660 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); |
@@ -3672,12 +3673,16 @@ static int ipr_slave_configure(struct scsi_device *sdev) | |||
3672 | } | 3673 | } |
3673 | if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res)) | 3674 | if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res)) |
3674 | sdev->allow_restart = 1; | 3675 | sdev->allow_restart = 1; |
3675 | if (ipr_is_gata(res) && res->sata_port) { | 3676 | if (ipr_is_gata(res) && res->sata_port) |
3677 | ap = res->sata_port->ap; | ||
3678 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
3679 | |||
3680 | if (ap) { | ||
3676 | scsi_adjust_queue_depth(sdev, 0, IPR_MAX_CMD_PER_ATA_LUN); | 3681 | scsi_adjust_queue_depth(sdev, 0, IPR_MAX_CMD_PER_ATA_LUN); |
3677 | ata_sas_slave_configure(sdev, res->sata_port->ap); | 3682 | ata_sas_slave_configure(sdev, ap); |
3678 | } else { | 3683 | } else |
3679 | scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); | 3684 | scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); |
3680 | } | 3685 | return 0; |
3681 | } | 3686 | } |
3682 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | 3687 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); |
3683 | return 0; | 3688 | return 0; |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index b3e5e08e44ab..b7c092d63bbe 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
@@ -463,7 +463,7 @@ static int iscsi_sw_tcp_pdu_init(struct iscsi_task *task, | |||
463 | } | 463 | } |
464 | 464 | ||
465 | if (err) { | 465 | if (err) { |
466 | iscsi_conn_failure(conn, err); | 466 | /* got invalid offset/len */ |
467 | return -EIO; | 467 | return -EIO; |
468 | } | 468 | } |
469 | return 0; | 469 | return 0; |
@@ -851,6 +851,7 @@ static struct scsi_host_template iscsi_sw_tcp_sht = { | |||
851 | .use_clustering = DISABLE_CLUSTERING, | 851 | .use_clustering = DISABLE_CLUSTERING, |
852 | .slave_alloc = iscsi_sw_tcp_slave_alloc, | 852 | .slave_alloc = iscsi_sw_tcp_slave_alloc, |
853 | .slave_configure = iscsi_sw_tcp_slave_configure, | 853 | .slave_configure = iscsi_sw_tcp_slave_configure, |
854 | .target_alloc = iscsi_target_alloc, | ||
854 | .proc_name = "iscsi_tcp", | 855 | .proc_name = "iscsi_tcp", |
855 | .this_id = -1, | 856 | .this_id = -1, |
856 | }; | 857 | }; |
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index e57556ea5b48..4c880656990b 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -113,6 +113,11 @@ void fc_disc_stop_rports(struct fc_disc *disc) | |||
113 | lport->tt.rport_logoff(rport); | 113 | lport->tt.rport_logoff(rport); |
114 | } | 114 | } |
115 | 115 | ||
116 | list_for_each_entry_safe(rdata, next, &disc->rogue_rports, peers) { | ||
117 | rport = PRIV_TO_RPORT(rdata); | ||
118 | lport->tt.rport_logoff(rport); | ||
119 | } | ||
120 | |||
116 | mutex_unlock(&disc->disc_mutex); | 121 | mutex_unlock(&disc->disc_mutex); |
117 | } | 122 | } |
118 | 123 | ||
@@ -131,23 +136,32 @@ static void fc_disc_rport_callback(struct fc_lport *lport, | |||
131 | { | 136 | { |
132 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 137 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
133 | struct fc_disc *disc = &lport->disc; | 138 | struct fc_disc *disc = &lport->disc; |
134 | int found = 0; | ||
135 | 139 | ||
136 | FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event, | 140 | FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event, |
137 | rport->port_id); | 141 | rport->port_id); |
138 | 142 | ||
139 | if (event == RPORT_EV_CREATED) { | 143 | switch (event) { |
144 | case RPORT_EV_CREATED: | ||
140 | if (disc) { | 145 | if (disc) { |
141 | found = 1; | ||
142 | mutex_lock(&disc->disc_mutex); | 146 | mutex_lock(&disc->disc_mutex); |
143 | list_add_tail(&rdata->peers, &disc->rports); | 147 | list_add_tail(&rdata->peers, &disc->rports); |
144 | mutex_unlock(&disc->disc_mutex); | 148 | mutex_unlock(&disc->disc_mutex); |
145 | } | 149 | } |
150 | break; | ||
151 | case RPORT_EV_LOGO: | ||
152 | case RPORT_EV_FAILED: | ||
153 | case RPORT_EV_STOP: | ||
154 | mutex_lock(&disc->disc_mutex); | ||
155 | mutex_lock(&rdata->rp_mutex); | ||
156 | if (rdata->trans_state == FC_PORTSTATE_ROGUE) | ||
157 | list_del(&rdata->peers); | ||
158 | mutex_unlock(&rdata->rp_mutex); | ||
159 | mutex_unlock(&disc->disc_mutex); | ||
160 | break; | ||
161 | default: | ||
162 | break; | ||
146 | } | 163 | } |
147 | 164 | ||
148 | if (!found) | ||
149 | FC_DEBUG_DISC("The rport (%6x) is not maintained " | ||
150 | "by the discovery layer\n", rport->port_id); | ||
151 | } | 165 | } |
152 | 166 | ||
153 | /** | 167 | /** |
@@ -439,6 +453,7 @@ static int fc_disc_new_target(struct fc_disc *disc, | |||
439 | rdata = rport->dd_data; | 453 | rdata = rport->dd_data; |
440 | rdata->ops = &fc_disc_rport_ops; | 454 | rdata->ops = &fc_disc_rport_ops; |
441 | rdata->rp_state = RPORT_ST_INIT; | 455 | rdata->rp_state = RPORT_ST_INIT; |
456 | list_add_tail(&rdata->peers, &disc->rogue_rports); | ||
442 | lport->tt.rport_login(rport); | 457 | lport->tt.rport_login(rport); |
443 | } | 458 | } |
444 | } | 459 | } |
@@ -461,21 +476,29 @@ static void fc_disc_del_target(struct fc_disc *disc, struct fc_rport *rport) | |||
461 | /** | 476 | /** |
462 | * fc_disc_done() - Discovery has been completed | 477 | * fc_disc_done() - Discovery has been completed |
463 | * @disc: FC discovery context | 478 | * @disc: FC discovery context |
479 | * Locking Note: This function expects that the disc mutex is locked before | ||
480 | * it is called. The discovery callback is then made with the lock released, | ||
481 | * and the lock is re-taken before returning from this function | ||
464 | */ | 482 | */ |
465 | static void fc_disc_done(struct fc_disc *disc) | 483 | static void fc_disc_done(struct fc_disc *disc) |
466 | { | 484 | { |
467 | struct fc_lport *lport = disc->lport; | 485 | struct fc_lport *lport = disc->lport; |
486 | enum fc_disc_event event; | ||
468 | 487 | ||
469 | FC_DEBUG_DISC("Discovery complete for port (%6x)\n", | 488 | FC_DEBUG_DISC("Discovery complete for port (%6x)\n", |
470 | fc_host_port_id(lport->host)); | 489 | fc_host_port_id(lport->host)); |
471 | 490 | ||
472 | disc->disc_callback(lport, disc->event); | 491 | event = disc->event; |
473 | disc->event = DISC_EV_NONE; | 492 | disc->event = DISC_EV_NONE; |
474 | 493 | ||
475 | if (disc->requested) | 494 | if (disc->requested) |
476 | fc_disc_gpn_ft_req(disc); | 495 | fc_disc_gpn_ft_req(disc); |
477 | else | 496 | else |
478 | disc->pending = 0; | 497 | disc->pending = 0; |
498 | |||
499 | mutex_unlock(&disc->disc_mutex); | ||
500 | disc->disc_callback(lport, event); | ||
501 | mutex_lock(&disc->disc_mutex); | ||
479 | } | 502 | } |
480 | 503 | ||
481 | /** | 504 | /** |
@@ -622,6 +645,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
622 | rdata = rport->dd_data; | 645 | rdata = rport->dd_data; |
623 | rdata->ops = &fc_disc_rport_ops; | 646 | rdata->ops = &fc_disc_rport_ops; |
624 | rdata->local_port = lport; | 647 | rdata->local_port = lport; |
648 | list_add_tail(&rdata->peers, | ||
649 | &disc->rogue_rports); | ||
625 | lport->tt.rport_login(rport); | 650 | lport->tt.rport_login(rport); |
626 | } else | 651 | } else |
627 | FC_DBG("Failed to allocate memory for " | 652 | FC_DBG("Failed to allocate memory for " |
@@ -681,8 +706,8 @@ static void fc_disc_timeout(struct work_struct *work) | |||
681 | * @fp: response frame | 706 | * @fp: response frame |
682 | * @lp_arg: Fibre Channel host port instance | 707 | * @lp_arg: Fibre Channel host port instance |
683 | * | 708 | * |
684 | * Locking Note: This function expects that the disc_mutex is locked | 709 | * Locking Note: This function is called without disc mutex held, and |
685 | * before it is called. | 710 | * should do all its processing with the mutex held |
686 | */ | 711 | */ |
687 | static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | 712 | static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, |
688 | void *disc_arg) | 713 | void *disc_arg) |
@@ -695,11 +720,13 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
695 | unsigned int len; | 720 | unsigned int len; |
696 | int error; | 721 | int error; |
697 | 722 | ||
723 | mutex_lock(&disc->disc_mutex); | ||
698 | FC_DEBUG_DISC("Received a GPN_FT response on port (%6x)\n", | 724 | FC_DEBUG_DISC("Received a GPN_FT response on port (%6x)\n", |
699 | fc_host_port_id(disc->lport->host)); | 725 | fc_host_port_id(disc->lport->host)); |
700 | 726 | ||
701 | if (IS_ERR(fp)) { | 727 | if (IS_ERR(fp)) { |
702 | fc_disc_error(disc, fp); | 728 | fc_disc_error(disc, fp); |
729 | mutex_unlock(&disc->disc_mutex); | ||
703 | return; | 730 | return; |
704 | } | 731 | } |
705 | 732 | ||
@@ -744,6 +771,8 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
744 | disc->seq_count++; | 771 | disc->seq_count++; |
745 | } | 772 | } |
746 | fc_frame_free(fp); | 773 | fc_frame_free(fp); |
774 | |||
775 | mutex_unlock(&disc->disc_mutex); | ||
747 | } | 776 | } |
748 | 777 | ||
749 | /** | 778 | /** |
@@ -757,7 +786,6 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
757 | static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp) | 786 | static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp) |
758 | { | 787 | { |
759 | struct fc_lport *lport; | 788 | struct fc_lport *lport; |
760 | struct fc_rport *rport; | ||
761 | struct fc_rport *new_rport; | 789 | struct fc_rport *new_rport; |
762 | struct fc_rport_libfc_priv *rdata; | 790 | struct fc_rport_libfc_priv *rdata; |
763 | 791 | ||
@@ -766,15 +794,12 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp) | |||
766 | if (dp->ids.port_id == fc_host_port_id(lport->host)) | 794 | if (dp->ids.port_id == fc_host_port_id(lport->host)) |
767 | goto out; | 795 | goto out; |
768 | 796 | ||
769 | rport = lport->tt.rport_lookup(lport, dp->ids.port_id); | ||
770 | if (rport) | ||
771 | fc_disc_del_target(disc, rport); | ||
772 | |||
773 | new_rport = lport->tt.rport_create(dp); | 797 | new_rport = lport->tt.rport_create(dp); |
774 | if (new_rport) { | 798 | if (new_rport) { |
775 | rdata = new_rport->dd_data; | 799 | rdata = new_rport->dd_data; |
776 | rdata->ops = &fc_disc_rport_ops; | 800 | rdata->ops = &fc_disc_rport_ops; |
777 | kfree(dp); | 801 | kfree(dp); |
802 | list_add_tail(&rdata->peers, &disc->rogue_rports); | ||
778 | lport->tt.rport_login(new_rport); | 803 | lport->tt.rport_login(new_rport); |
779 | } | 804 | } |
780 | return; | 805 | return; |
@@ -836,6 +861,7 @@ int fc_disc_init(struct fc_lport *lport) | |||
836 | INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout); | 861 | INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout); |
837 | mutex_init(&disc->disc_mutex); | 862 | mutex_init(&disc->disc_mutex); |
838 | INIT_LIST_HEAD(&disc->rports); | 863 | INIT_LIST_HEAD(&disc->rports); |
864 | INIT_LIST_HEAD(&disc->rogue_rports); | ||
839 | 865 | ||
840 | disc->lport = lport; | 866 | disc->lport = lport; |
841 | disc->delay = FC_DISC_DELAY; | 867 | disc->delay = FC_DISC_DELAY; |
diff --git a/drivers/scsi/libfc/fc_elsct.c b/drivers/scsi/libfc/fc_elsct.c index dd47fe619d1e..5878b34bff18 100644 --- a/drivers/scsi/libfc/fc_elsct.c +++ b/drivers/scsi/libfc/fc_elsct.c | |||
@@ -41,7 +41,7 @@ static struct fc_seq *fc_elsct_send(struct fc_lport *lport, | |||
41 | void *arg, u32 timer_msec) | 41 | void *arg, u32 timer_msec) |
42 | { | 42 | { |
43 | enum fc_rctl r_ctl; | 43 | enum fc_rctl r_ctl; |
44 | u32 did; | 44 | u32 did = FC_FID_NONE; |
45 | enum fc_fh_type fh_type; | 45 | enum fc_fh_type fh_type; |
46 | int rc; | 46 | int rc; |
47 | 47 | ||
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index f555ae99ad40..521f996f9b13 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c | |||
@@ -713,7 +713,7 @@ done: | |||
713 | static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | 713 | static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
714 | { | 714 | { |
715 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)arg; | 715 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)arg; |
716 | struct fc_lport *lp; | 716 | struct fc_lport *lport = fsp->lp; |
717 | struct fc_frame_header *fh; | 717 | struct fc_frame_header *fh; |
718 | struct fcp_txrdy *dd; | 718 | struct fcp_txrdy *dd; |
719 | u8 r_ctl; | 719 | u8 r_ctl; |
@@ -724,9 +724,8 @@ static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
724 | 724 | ||
725 | fh = fc_frame_header_get(fp); | 725 | fh = fc_frame_header_get(fp); |
726 | r_ctl = fh->fh_r_ctl; | 726 | r_ctl = fh->fh_r_ctl; |
727 | lp = fsp->lp; | ||
728 | 727 | ||
729 | if (!(lp->state & LPORT_ST_READY)) | 728 | if (!(lport->state & LPORT_ST_READY)) |
730 | goto out; | 729 | goto out; |
731 | if (fc_fcp_lock_pkt(fsp)) | 730 | if (fc_fcp_lock_pkt(fsp)) |
732 | goto out; | 731 | goto out; |
@@ -779,7 +778,7 @@ errout: | |||
779 | if (IS_ERR(fp)) | 778 | if (IS_ERR(fp)) |
780 | fc_fcp_error(fsp, fp); | 779 | fc_fcp_error(fsp, fp); |
781 | else if (rc == -ENOMEM) | 780 | else if (rc == -ENOMEM) |
782 | fc_fcp_reduce_can_queue(lp); | 781 | fc_fcp_reduce_can_queue(lport); |
783 | } | 782 | } |
784 | 783 | ||
785 | static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 784 | static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index b8178ef398d7..e0c247724d2b 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
@@ -618,6 +618,11 @@ int fc_fabric_logoff(struct fc_lport *lport) | |||
618 | { | 618 | { |
619 | lport->tt.disc_stop_final(lport); | 619 | lport->tt.disc_stop_final(lport); |
620 | mutex_lock(&lport->lp_mutex); | 620 | mutex_lock(&lport->lp_mutex); |
621 | if (lport->dns_rp) | ||
622 | lport->tt.rport_logoff(lport->dns_rp); | ||
623 | mutex_unlock(&lport->lp_mutex); | ||
624 | lport->tt.rport_flush_queue(); | ||
625 | mutex_lock(&lport->lp_mutex); | ||
621 | fc_lport_enter_logo(lport); | 626 | fc_lport_enter_logo(lport); |
622 | mutex_unlock(&lport->lp_mutex); | 627 | mutex_unlock(&lport->lp_mutex); |
623 | cancel_delayed_work_sync(&lport->retry_work); | 628 | cancel_delayed_work_sync(&lport->retry_work); |
@@ -639,7 +644,12 @@ EXPORT_SYMBOL(fc_fabric_logoff); | |||
639 | */ | 644 | */ |
640 | int fc_lport_destroy(struct fc_lport *lport) | 645 | int fc_lport_destroy(struct fc_lport *lport) |
641 | { | 646 | { |
647 | mutex_lock(&lport->lp_mutex); | ||
648 | lport->state = LPORT_ST_NONE; | ||
649 | lport->link_up = 0; | ||
642 | lport->tt.frame_send = fc_frame_drop; | 650 | lport->tt.frame_send = fc_frame_drop; |
651 | mutex_unlock(&lport->lp_mutex); | ||
652 | |||
643 | lport->tt.fcp_abort_io(lport); | 653 | lport->tt.fcp_abort_io(lport); |
644 | lport->tt.exch_mgr_reset(lport, 0, 0); | 654 | lport->tt.exch_mgr_reset(lport, 0, 0); |
645 | return 0; | 655 | return 0; |
@@ -1032,17 +1042,19 @@ static void fc_lport_rft_id_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1032 | 1042 | ||
1033 | FC_DEBUG_LPORT("Received a RFT_ID response\n"); | 1043 | FC_DEBUG_LPORT("Received a RFT_ID response\n"); |
1034 | 1044 | ||
1035 | if (IS_ERR(fp)) { | ||
1036 | fc_lport_error(lport, fp); | ||
1037 | goto err; | ||
1038 | } | ||
1039 | |||
1040 | if (lport->state != LPORT_ST_RFT_ID) { | 1045 | if (lport->state != LPORT_ST_RFT_ID) { |
1041 | FC_DBG("Received a RFT_ID response, but in state %s\n", | 1046 | FC_DBG("Received a RFT_ID response, but in state %s\n", |
1042 | fc_lport_state(lport)); | 1047 | fc_lport_state(lport)); |
1048 | if (IS_ERR(fp)) | ||
1049 | goto err; | ||
1043 | goto out; | 1050 | goto out; |
1044 | } | 1051 | } |
1045 | 1052 | ||
1053 | if (IS_ERR(fp)) { | ||
1054 | fc_lport_error(lport, fp); | ||
1055 | goto err; | ||
1056 | } | ||
1057 | |||
1046 | fh = fc_frame_header_get(fp); | 1058 | fh = fc_frame_header_get(fp); |
1047 | ct = fc_frame_payload_get(fp, sizeof(*ct)); | 1059 | ct = fc_frame_payload_get(fp, sizeof(*ct)); |
1048 | 1060 | ||
@@ -1084,17 +1096,19 @@ static void fc_lport_rpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1084 | 1096 | ||
1085 | FC_DEBUG_LPORT("Received a RPN_ID response\n"); | 1097 | FC_DEBUG_LPORT("Received a RPN_ID response\n"); |
1086 | 1098 | ||
1087 | if (IS_ERR(fp)) { | ||
1088 | fc_lport_error(lport, fp); | ||
1089 | goto err; | ||
1090 | } | ||
1091 | |||
1092 | if (lport->state != LPORT_ST_RPN_ID) { | 1099 | if (lport->state != LPORT_ST_RPN_ID) { |
1093 | FC_DBG("Received a RPN_ID response, but in state %s\n", | 1100 | FC_DBG("Received a RPN_ID response, but in state %s\n", |
1094 | fc_lport_state(lport)); | 1101 | fc_lport_state(lport)); |
1102 | if (IS_ERR(fp)) | ||
1103 | goto err; | ||
1095 | goto out; | 1104 | goto out; |
1096 | } | 1105 | } |
1097 | 1106 | ||
1107 | if (IS_ERR(fp)) { | ||
1108 | fc_lport_error(lport, fp); | ||
1109 | goto err; | ||
1110 | } | ||
1111 | |||
1098 | fh = fc_frame_header_get(fp); | 1112 | fh = fc_frame_header_get(fp); |
1099 | ct = fc_frame_payload_get(fp, sizeof(*ct)); | 1113 | ct = fc_frame_payload_get(fp, sizeof(*ct)); |
1100 | if (fh && ct && fh->fh_type == FC_TYPE_CT && | 1114 | if (fh && ct && fh->fh_type == FC_TYPE_CT && |
@@ -1134,17 +1148,19 @@ static void fc_lport_scr_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1134 | 1148 | ||
1135 | FC_DEBUG_LPORT("Received a SCR response\n"); | 1149 | FC_DEBUG_LPORT("Received a SCR response\n"); |
1136 | 1150 | ||
1137 | if (IS_ERR(fp)) { | ||
1138 | fc_lport_error(lport, fp); | ||
1139 | goto err; | ||
1140 | } | ||
1141 | |||
1142 | if (lport->state != LPORT_ST_SCR) { | 1151 | if (lport->state != LPORT_ST_SCR) { |
1143 | FC_DBG("Received a SCR response, but in state %s\n", | 1152 | FC_DBG("Received a SCR response, but in state %s\n", |
1144 | fc_lport_state(lport)); | 1153 | fc_lport_state(lport)); |
1154 | if (IS_ERR(fp)) | ||
1155 | goto err; | ||
1145 | goto out; | 1156 | goto out; |
1146 | } | 1157 | } |
1147 | 1158 | ||
1159 | if (IS_ERR(fp)) { | ||
1160 | fc_lport_error(lport, fp); | ||
1161 | goto err; | ||
1162 | } | ||
1163 | |||
1148 | op = fc_frame_payload_op(fp); | 1164 | op = fc_frame_payload_op(fp); |
1149 | if (op == ELS_LS_ACC) | 1165 | if (op == ELS_LS_ACC) |
1150 | fc_lport_enter_ready(lport); | 1166 | fc_lport_enter_ready(lport); |
@@ -1360,17 +1376,19 @@ static void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1360 | 1376 | ||
1361 | FC_DEBUG_LPORT("Received a LOGO response\n"); | 1377 | FC_DEBUG_LPORT("Received a LOGO response\n"); |
1362 | 1378 | ||
1363 | if (IS_ERR(fp)) { | ||
1364 | fc_lport_error(lport, fp); | ||
1365 | goto err; | ||
1366 | } | ||
1367 | |||
1368 | if (lport->state != LPORT_ST_LOGO) { | 1379 | if (lport->state != LPORT_ST_LOGO) { |
1369 | FC_DBG("Received a LOGO response, but in state %s\n", | 1380 | FC_DBG("Received a LOGO response, but in state %s\n", |
1370 | fc_lport_state(lport)); | 1381 | fc_lport_state(lport)); |
1382 | if (IS_ERR(fp)) | ||
1383 | goto err; | ||
1371 | goto out; | 1384 | goto out; |
1372 | } | 1385 | } |
1373 | 1386 | ||
1387 | if (IS_ERR(fp)) { | ||
1388 | fc_lport_error(lport, fp); | ||
1389 | goto err; | ||
1390 | } | ||
1391 | |||
1374 | op = fc_frame_payload_op(fp); | 1392 | op = fc_frame_payload_op(fp); |
1375 | if (op == ELS_LS_ACC) | 1393 | if (op == ELS_LS_ACC) |
1376 | fc_lport_enter_reset(lport); | 1394 | fc_lport_enter_reset(lport); |
@@ -1400,10 +1418,6 @@ static void fc_lport_enter_logo(struct fc_lport *lport) | |||
1400 | 1418 | ||
1401 | fc_lport_state_enter(lport, LPORT_ST_LOGO); | 1419 | fc_lport_state_enter(lport, LPORT_ST_LOGO); |
1402 | 1420 | ||
1403 | /* DNS session should be closed so we can release it here */ | ||
1404 | if (lport->dns_rp) | ||
1405 | lport->tt.rport_logoff(lport->dns_rp); | ||
1406 | |||
1407 | fp = fc_frame_alloc(lport, sizeof(*logo)); | 1421 | fp = fc_frame_alloc(lport, sizeof(*logo)); |
1408 | if (!fp) { | 1422 | if (!fp) { |
1409 | fc_lport_error(lport, fp); | 1423 | fc_lport_error(lport, fp); |
@@ -1444,17 +1458,19 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1444 | 1458 | ||
1445 | FC_DEBUG_LPORT("Received a FLOGI response\n"); | 1459 | FC_DEBUG_LPORT("Received a FLOGI response\n"); |
1446 | 1460 | ||
1447 | if (IS_ERR(fp)) { | ||
1448 | fc_lport_error(lport, fp); | ||
1449 | goto err; | ||
1450 | } | ||
1451 | |||
1452 | if (lport->state != LPORT_ST_FLOGI) { | 1461 | if (lport->state != LPORT_ST_FLOGI) { |
1453 | FC_DBG("Received a FLOGI response, but in state %s\n", | 1462 | FC_DBG("Received a FLOGI response, but in state %s\n", |
1454 | fc_lport_state(lport)); | 1463 | fc_lport_state(lport)); |
1464 | if (IS_ERR(fp)) | ||
1465 | goto err; | ||
1455 | goto out; | 1466 | goto out; |
1456 | } | 1467 | } |
1457 | 1468 | ||
1469 | if (IS_ERR(fp)) { | ||
1470 | fc_lport_error(lport, fp); | ||
1471 | goto err; | ||
1472 | } | ||
1473 | |||
1458 | fh = fc_frame_header_get(fp); | 1474 | fh = fc_frame_header_get(fp); |
1459 | did = ntoh24(fh->fh_d_id); | 1475 | did = ntoh24(fh->fh_d_id); |
1460 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { | 1476 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { |
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 0472bb73221e..747d73c5c8af 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c | |||
@@ -267,6 +267,10 @@ static void fc_rport_work(struct work_struct *work) | |||
267 | "(%6x).\n", ids.port_id); | 267 | "(%6x).\n", ids.port_id); |
268 | event = RPORT_EV_FAILED; | 268 | event = RPORT_EV_FAILED; |
269 | } | 269 | } |
270 | if (rport->port_id != FC_FID_DIR_SERV) | ||
271 | if (rport_ops->event_callback) | ||
272 | rport_ops->event_callback(lport, rport, | ||
273 | RPORT_EV_FAILED); | ||
270 | put_device(&rport->dev); | 274 | put_device(&rport->dev); |
271 | rport = new_rport; | 275 | rport = new_rport; |
272 | rdata = new_rport->dd_data; | 276 | rdata = new_rport->dd_data; |
@@ -325,11 +329,20 @@ int fc_rport_login(struct fc_rport *rport) | |||
325 | int fc_rport_logoff(struct fc_rport *rport) | 329 | int fc_rport_logoff(struct fc_rport *rport) |
326 | { | 330 | { |
327 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 331 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
332 | struct fc_lport *lport = rdata->local_port; | ||
328 | 333 | ||
329 | mutex_lock(&rdata->rp_mutex); | 334 | mutex_lock(&rdata->rp_mutex); |
330 | 335 | ||
331 | FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); | 336 | FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); |
332 | 337 | ||
338 | if (rdata->rp_state == RPORT_ST_NONE) { | ||
339 | FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state," | ||
340 | " not removing", fc_host_port_id(lport->host), | ||
341 | rport->port_id); | ||
342 | mutex_unlock(&rdata->rp_mutex); | ||
343 | goto out; | ||
344 | } | ||
345 | |||
333 | fc_rport_enter_logo(rport); | 346 | fc_rport_enter_logo(rport); |
334 | 347 | ||
335 | /* | 348 | /* |
@@ -349,6 +362,7 @@ int fc_rport_logoff(struct fc_rport *rport) | |||
349 | 362 | ||
350 | mutex_unlock(&rdata->rp_mutex); | 363 | mutex_unlock(&rdata->rp_mutex); |
351 | 364 | ||
365 | out: | ||
352 | return 0; | 366 | return 0; |
353 | } | 367 | } |
354 | 368 | ||
@@ -430,6 +444,7 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp) | |||
430 | case RPORT_ST_PRLI: | 444 | case RPORT_ST_PRLI: |
431 | case RPORT_ST_LOGO: | 445 | case RPORT_ST_LOGO: |
432 | rdata->event = RPORT_EV_FAILED; | 446 | rdata->event = RPORT_EV_FAILED; |
447 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
433 | queue_work(rport_event_queue, | 448 | queue_work(rport_event_queue, |
434 | &rdata->event_work); | 449 | &rdata->event_work); |
435 | break; | 450 | break; |
@@ -494,7 +509,7 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
494 | struct fc_rport *rport = rp_arg; | 509 | struct fc_rport *rport = rp_arg; |
495 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 510 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
496 | struct fc_lport *lport = rdata->local_port; | 511 | struct fc_lport *lport = rdata->local_port; |
497 | struct fc_els_flogi *plp; | 512 | struct fc_els_flogi *plp = NULL; |
498 | unsigned int tov; | 513 | unsigned int tov; |
499 | u16 csp_seq; | 514 | u16 csp_seq; |
500 | u16 cssp_seq; | 515 | u16 cssp_seq; |
@@ -505,17 +520,19 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
505 | FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", | 520 | FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", |
506 | rport->port_id); | 521 | rport->port_id); |
507 | 522 | ||
508 | if (IS_ERR(fp)) { | ||
509 | fc_rport_error_retry(rport, fp); | ||
510 | goto err; | ||
511 | } | ||
512 | |||
513 | if (rdata->rp_state != RPORT_ST_PLOGI) { | 523 | if (rdata->rp_state != RPORT_ST_PLOGI) { |
514 | FC_DBG("Received a PLOGI response, but in state %s\n", | 524 | FC_DBG("Received a PLOGI response, but in state %s\n", |
515 | fc_rport_state(rport)); | 525 | fc_rport_state(rport)); |
526 | if (IS_ERR(fp)) | ||
527 | goto err; | ||
516 | goto out; | 528 | goto out; |
517 | } | 529 | } |
518 | 530 | ||
531 | if (IS_ERR(fp)) { | ||
532 | fc_rport_error_retry(rport, fp); | ||
533 | goto err; | ||
534 | } | ||
535 | |||
519 | op = fc_frame_payload_op(fp); | 536 | op = fc_frame_payload_op(fp); |
520 | if (op == ELS_LS_ACC && | 537 | if (op == ELS_LS_ACC && |
521 | (plp = fc_frame_payload_get(fp, sizeof(*plp))) != NULL) { | 538 | (plp = fc_frame_payload_get(fp, sizeof(*plp))) != NULL) { |
@@ -614,17 +631,19 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
614 | FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", | 631 | FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", |
615 | rport->port_id); | 632 | rport->port_id); |
616 | 633 | ||
617 | if (IS_ERR(fp)) { | ||
618 | fc_rport_error_retry(rport, fp); | ||
619 | goto err; | ||
620 | } | ||
621 | |||
622 | if (rdata->rp_state != RPORT_ST_PRLI) { | 634 | if (rdata->rp_state != RPORT_ST_PRLI) { |
623 | FC_DBG("Received a PRLI response, but in state %s\n", | 635 | FC_DBG("Received a PRLI response, but in state %s\n", |
624 | fc_rport_state(rport)); | 636 | fc_rport_state(rport)); |
637 | if (IS_ERR(fp)) | ||
638 | goto err; | ||
625 | goto out; | 639 | goto out; |
626 | } | 640 | } |
627 | 641 | ||
642 | if (IS_ERR(fp)) { | ||
643 | fc_rport_error_retry(rport, fp); | ||
644 | goto err; | ||
645 | } | ||
646 | |||
628 | op = fc_frame_payload_op(fp); | 647 | op = fc_frame_payload_op(fp); |
629 | if (op == ELS_LS_ACC) { | 648 | if (op == ELS_LS_ACC) { |
630 | pp = fc_frame_payload_get(fp, sizeof(*pp)); | 649 | pp = fc_frame_payload_get(fp, sizeof(*pp)); |
@@ -646,6 +665,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
646 | } else { | 665 | } else { |
647 | FC_DBG("Bad ELS response\n"); | 666 | FC_DBG("Bad ELS response\n"); |
648 | rdata->event = RPORT_EV_FAILED; | 667 | rdata->event = RPORT_EV_FAILED; |
668 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
649 | queue_work(rport_event_queue, &rdata->event_work); | 669 | queue_work(rport_event_queue, &rdata->event_work); |
650 | } | 670 | } |
651 | 671 | ||
@@ -678,23 +698,26 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
678 | FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", | 698 | FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", |
679 | rport->port_id); | 699 | rport->port_id); |
680 | 700 | ||
681 | if (IS_ERR(fp)) { | ||
682 | fc_rport_error_retry(rport, fp); | ||
683 | goto err; | ||
684 | } | ||
685 | |||
686 | if (rdata->rp_state != RPORT_ST_LOGO) { | 701 | if (rdata->rp_state != RPORT_ST_LOGO) { |
687 | FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", | 702 | FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", |
688 | fc_rport_state(rport)); | 703 | fc_rport_state(rport)); |
704 | if (IS_ERR(fp)) | ||
705 | goto err; | ||
689 | goto out; | 706 | goto out; |
690 | } | 707 | } |
691 | 708 | ||
709 | if (IS_ERR(fp)) { | ||
710 | fc_rport_error_retry(rport, fp); | ||
711 | goto err; | ||
712 | } | ||
713 | |||
692 | op = fc_frame_payload_op(fp); | 714 | op = fc_frame_payload_op(fp); |
693 | if (op == ELS_LS_ACC) { | 715 | if (op == ELS_LS_ACC) { |
694 | fc_rport_enter_rtv(rport); | 716 | fc_rport_enter_rtv(rport); |
695 | } else { | 717 | } else { |
696 | FC_DBG("Bad ELS response\n"); | 718 | FC_DBG("Bad ELS response\n"); |
697 | rdata->event = RPORT_EV_LOGO; | 719 | rdata->event = RPORT_EV_LOGO; |
720 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
698 | queue_work(rport_event_queue, &rdata->event_work); | 721 | queue_work(rport_event_queue, &rdata->event_work); |
699 | } | 722 | } |
700 | 723 | ||
@@ -764,17 +787,19 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
764 | FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", | 787 | FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", |
765 | rport->port_id); | 788 | rport->port_id); |
766 | 789 | ||
767 | if (IS_ERR(fp)) { | ||
768 | fc_rport_error(rport, fp); | ||
769 | goto err; | ||
770 | } | ||
771 | |||
772 | if (rdata->rp_state != RPORT_ST_RTV) { | 790 | if (rdata->rp_state != RPORT_ST_RTV) { |
773 | FC_DBG("Received a RTV response, but in state %s\n", | 791 | FC_DBG("Received a RTV response, but in state %s\n", |
774 | fc_rport_state(rport)); | 792 | fc_rport_state(rport)); |
793 | if (IS_ERR(fp)) | ||
794 | goto err; | ||
775 | goto out; | 795 | goto out; |
776 | } | 796 | } |
777 | 797 | ||
798 | if (IS_ERR(fp)) { | ||
799 | fc_rport_error(rport, fp); | ||
800 | goto err; | ||
801 | } | ||
802 | |||
778 | op = fc_frame_payload_op(fp); | 803 | op = fc_frame_payload_op(fp); |
779 | if (op == ELS_LS_ACC) { | 804 | if (op == ELS_LS_ACC) { |
780 | struct fc_els_rtv_acc *rtv; | 805 | struct fc_els_rtv_acc *rtv; |
@@ -1007,6 +1032,8 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport, | |||
1007 | default: | 1032 | default: |
1008 | FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " | 1033 | FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " |
1009 | "state %d\n", sid, rdata->rp_state); | 1034 | "state %d\n", sid, rdata->rp_state); |
1035 | fc_frame_free(fp); | ||
1036 | return; | ||
1010 | break; | 1037 | break; |
1011 | } | 1038 | } |
1012 | 1039 | ||
@@ -1098,6 +1125,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport, | |||
1098 | reason = ELS_RJT_NONE; | 1125 | reason = ELS_RJT_NONE; |
1099 | break; | 1126 | break; |
1100 | default: | 1127 | default: |
1128 | fc_frame_free(rx_fp); | ||
1129 | return; | ||
1101 | break; | 1130 | break; |
1102 | } | 1131 | } |
1103 | len = fr_len(rx_fp) - sizeof(*fh); | 1132 | len = fr_len(rx_fp) - sizeof(*fh); |
@@ -1227,6 +1256,11 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp, | |||
1227 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1256 | "while in state %s\n", ntoh24(fh->fh_s_id), |
1228 | fc_rport_state(rport)); | 1257 | fc_rport_state(rport)); |
1229 | 1258 | ||
1259 | if (rdata->rp_state == RPORT_ST_NONE) { | ||
1260 | fc_frame_free(fp); | ||
1261 | return; | ||
1262 | } | ||
1263 | |||
1230 | rjt_data.fp = NULL; | 1264 | rjt_data.fp = NULL; |
1231 | rjt_data.reason = ELS_RJT_UNAB; | 1265 | rjt_data.reason = ELS_RJT_UNAB; |
1232 | rjt_data.explan = ELS_EXPL_NONE; | 1266 | rjt_data.explan = ELS_EXPL_NONE; |
@@ -1256,7 +1290,13 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp, | |||
1256 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1290 | "while in state %s\n", ntoh24(fh->fh_s_id), |
1257 | fc_rport_state(rport)); | 1291 | fc_rport_state(rport)); |
1258 | 1292 | ||
1293 | if (rdata->rp_state == RPORT_ST_NONE) { | ||
1294 | fc_frame_free(fp); | ||
1295 | return; | ||
1296 | } | ||
1297 | |||
1259 | rdata->event = RPORT_EV_LOGO; | 1298 | rdata->event = RPORT_EV_LOGO; |
1299 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
1260 | queue_work(rport_event_queue, &rdata->event_work); | 1300 | queue_work(rport_event_queue, &rdata->event_work); |
1261 | 1301 | ||
1262 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); | 1302 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 689628359169..e72b4ad47d35 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -1463,6 +1463,16 @@ int iscsi_change_queue_depth(struct scsi_device *sdev, int depth) | |||
1463 | } | 1463 | } |
1464 | EXPORT_SYMBOL_GPL(iscsi_change_queue_depth); | 1464 | EXPORT_SYMBOL_GPL(iscsi_change_queue_depth); |
1465 | 1465 | ||
1466 | int iscsi_target_alloc(struct scsi_target *starget) | ||
1467 | { | ||
1468 | struct iscsi_cls_session *cls_session = starget_to_session(starget); | ||
1469 | struct iscsi_session *session = cls_session->dd_data; | ||
1470 | |||
1471 | starget->can_queue = session->scsi_cmds_max; | ||
1472 | return 0; | ||
1473 | } | ||
1474 | EXPORT_SYMBOL_GPL(iscsi_target_alloc); | ||
1475 | |||
1466 | void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session) | 1476 | void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session) |
1467 | { | 1477 | { |
1468 | struct iscsi_session *session = cls_session->dd_data; | 1478 | struct iscsi_session *session = cls_session->dd_data; |
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 91f8ce4d8d08..b579ca9f4836 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c | |||
@@ -1036,8 +1036,11 @@ flush: | |||
1036 | 1036 | ||
1037 | rc = conn->session->tt->init_pdu(task, r2t->data_offset + r2t->sent, | 1037 | rc = conn->session->tt->init_pdu(task, r2t->data_offset + r2t->sent, |
1038 | r2t->data_count); | 1038 | r2t->data_count); |
1039 | if (rc) | 1039 | if (rc) { |
1040 | iscsi_conn_failure(conn, ISCSI_ERR_XMIT_FAILED); | ||
1040 | return rc; | 1041 | return rc; |
1042 | } | ||
1043 | |||
1041 | r2t->sent += r2t->data_count; | 1044 | r2t->sent += r2t->data_count; |
1042 | goto flush; | 1045 | goto flush; |
1043 | } | 1046 | } |
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index dcba267db711..1105f9a111ba 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h | |||
@@ -443,6 +443,7 @@ struct lpfc_hba { | |||
443 | uint32_t hba_flag; /* hba generic flags */ | 443 | uint32_t hba_flag; /* hba generic flags */ |
444 | #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */ | 444 | #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */ |
445 | 445 | ||
446 | #define DEFER_ERATT 0x4 /* Deferred error attention in progress */ | ||
446 | struct lpfc_dmabuf slim2p; | 447 | struct lpfc_dmabuf slim2p; |
447 | 448 | ||
448 | MAILBOX_t *mbox; | 449 | MAILBOX_t *mbox; |
@@ -723,4 +724,3 @@ lpfc_sli_read_hs(struct lpfc_hba *phba) | |||
723 | 724 | ||
724 | return; | 725 | return; |
725 | } | 726 | } |
726 | |||
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 40cf0f4f327f..c14f0cbdb125 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8" | 51 | #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8" |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * lpfc_jedec_to_ascii: Hex to ascii convertor according to JEDEC rules. | 54 | * lpfc_jedec_to_ascii - Hex to ascii convertor according to JEDEC rules |
55 | * @incr: integer to convert. | 55 | * @incr: integer to convert. |
56 | * @hdw: ascii string holding converted integer plus a string terminator. | 56 | * @hdw: ascii string holding converted integer plus a string terminator. |
57 | * | 57 | * |
@@ -82,7 +82,7 @@ lpfc_jedec_to_ascii(int incr, char hdw[]) | |||
82 | } | 82 | } |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * lpfc_drvr_version_show: Return the Emulex driver string with version number. | 85 | * lpfc_drvr_version_show - Return the Emulex driver string with version number |
86 | * @dev: class unused variable. | 86 | * @dev: class unused variable. |
87 | * @attr: device attribute, not used. | 87 | * @attr: device attribute, not used. |
88 | * @buf: on return contains the module description text. | 88 | * @buf: on return contains the module description text. |
@@ -152,7 +152,7 @@ lpfc_bg_reftag_err_show(struct device *dev, struct device_attribute *attr, | |||
152 | } | 152 | } |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * lpfc_info_show: Return some pci info about the host in ascii. | 155 | * lpfc_info_show - Return some pci info about the host in ascii |
156 | * @dev: class converted to a Scsi_host structure. | 156 | * @dev: class converted to a Scsi_host structure. |
157 | * @attr: device attribute, not used. | 157 | * @attr: device attribute, not used. |
158 | * @buf: on return contains the formatted text from lpfc_info(). | 158 | * @buf: on return contains the formatted text from lpfc_info(). |
@@ -169,7 +169,7 @@ lpfc_info_show(struct device *dev, struct device_attribute *attr, | |||
169 | } | 169 | } |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * lpfc_serialnum_show: Return the hba serial number in ascii. | 172 | * lpfc_serialnum_show - Return the hba serial number in ascii |
173 | * @dev: class converted to a Scsi_host structure. | 173 | * @dev: class converted to a Scsi_host structure. |
174 | * @attr: device attribute, not used. | 174 | * @attr: device attribute, not used. |
175 | * @buf: on return contains the formatted text serial number. | 175 | * @buf: on return contains the formatted text serial number. |
@@ -188,7 +188,7 @@ lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, | |||
188 | } | 188 | } |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * lpfc_temp_sensor_show: Return the temperature sensor level. | 191 | * lpfc_temp_sensor_show - Return the temperature sensor level |
192 | * @dev: class converted to a Scsi_host structure. | 192 | * @dev: class converted to a Scsi_host structure. |
193 | * @attr: device attribute, not used. | 193 | * @attr: device attribute, not used. |
194 | * @buf: on return contains the formatted support level. | 194 | * @buf: on return contains the formatted support level. |
@@ -210,7 +210,7 @@ lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, | |||
210 | } | 210 | } |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * lpfc_modeldesc_show: Return the model description of the hba. | 213 | * lpfc_modeldesc_show - Return the model description of the hba |
214 | * @dev: class converted to a Scsi_host structure. | 214 | * @dev: class converted to a Scsi_host structure. |
215 | * @attr: device attribute, not used. | 215 | * @attr: device attribute, not used. |
216 | * @buf: on return contains the scsi vpd model description. | 216 | * @buf: on return contains the scsi vpd model description. |
@@ -229,7 +229,7 @@ lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, | |||
229 | } | 229 | } |
230 | 230 | ||
231 | /** | 231 | /** |
232 | * lpfc_modelname_show: Return the model name of the hba. | 232 | * lpfc_modelname_show - Return the model name of the hba |
233 | * @dev: class converted to a Scsi_host structure. | 233 | * @dev: class converted to a Scsi_host structure. |
234 | * @attr: device attribute, not used. | 234 | * @attr: device attribute, not used. |
235 | * @buf: on return contains the scsi vpd model name. | 235 | * @buf: on return contains the scsi vpd model name. |
@@ -248,7 +248,7 @@ lpfc_modelname_show(struct device *dev, struct device_attribute *attr, | |||
248 | } | 248 | } |
249 | 249 | ||
250 | /** | 250 | /** |
251 | * lpfc_programtype_show: Return the program type of the hba. | 251 | * lpfc_programtype_show - Return the program type of the hba |
252 | * @dev: class converted to a Scsi_host structure. | 252 | * @dev: class converted to a Scsi_host structure. |
253 | * @attr: device attribute, not used. | 253 | * @attr: device attribute, not used. |
254 | * @buf: on return contains the scsi vpd program type. | 254 | * @buf: on return contains the scsi vpd program type. |
@@ -267,7 +267,7 @@ lpfc_programtype_show(struct device *dev, struct device_attribute *attr, | |||
267 | } | 267 | } |
268 | 268 | ||
269 | /** | 269 | /** |
270 | * lpfc_mlomgmt_show: Return the Menlo Maintenance sli flag. | 270 | * lpfc_mlomgmt_show - Return the Menlo Maintenance sli flag |
271 | * @dev: class converted to a Scsi_host structure. | 271 | * @dev: class converted to a Scsi_host structure. |
272 | * @attr: device attribute, not used. | 272 | * @attr: device attribute, not used. |
273 | * @buf: on return contains the Menlo Maintenance sli flag. | 273 | * @buf: on return contains the Menlo Maintenance sli flag. |
@@ -286,7 +286,7 @@ lpfc_mlomgmt_show(struct device *dev, struct device_attribute *attr, char *buf) | |||
286 | } | 286 | } |
287 | 287 | ||
288 | /** | 288 | /** |
289 | * lpfc_vportnum_show: Return the port number in ascii of the hba. | 289 | * lpfc_vportnum_show - Return the port number in ascii of the hba |
290 | * @dev: class converted to a Scsi_host structure. | 290 | * @dev: class converted to a Scsi_host structure. |
291 | * @attr: device attribute, not used. | 291 | * @attr: device attribute, not used. |
292 | * @buf: on return contains scsi vpd program type. | 292 | * @buf: on return contains scsi vpd program type. |
@@ -305,7 +305,7 @@ lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, | |||
305 | } | 305 | } |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * lpfc_fwrev_show: Return the firmware rev running in the hba. | 308 | * lpfc_fwrev_show - Return the firmware rev running in the hba |
309 | * @dev: class converted to a Scsi_host structure. | 309 | * @dev: class converted to a Scsi_host structure. |
310 | * @attr: device attribute, not used. | 310 | * @attr: device attribute, not used. |
311 | * @buf: on return contains the scsi vpd program type. | 311 | * @buf: on return contains the scsi vpd program type. |
@@ -326,7 +326,7 @@ lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, | |||
326 | } | 326 | } |
327 | 327 | ||
328 | /** | 328 | /** |
329 | * lpfc_hdw_show: Return the jedec information about the hba. | 329 | * lpfc_hdw_show - Return the jedec information about the hba |
330 | * @dev: class converted to a Scsi_host structure. | 330 | * @dev: class converted to a Scsi_host structure. |
331 | * @attr: device attribute, not used. | 331 | * @attr: device attribute, not used. |
332 | * @buf: on return contains the scsi vpd program type. | 332 | * @buf: on return contains the scsi vpd program type. |
@@ -347,7 +347,7 @@ lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) | |||
347 | } | 347 | } |
348 | 348 | ||
349 | /** | 349 | /** |
350 | * lpfc_option_rom_version_show: Return the adapter ROM FCode version. | 350 | * lpfc_option_rom_version_show - Return the adapter ROM FCode version |
351 | * @dev: class converted to a Scsi_host structure. | 351 | * @dev: class converted to a Scsi_host structure. |
352 | * @attr: device attribute, not used. | 352 | * @attr: device attribute, not used. |
353 | * @buf: on return contains the ROM and FCode ascii strings. | 353 | * @buf: on return contains the ROM and FCode ascii strings. |
@@ -366,7 +366,7 @@ lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, | |||
366 | } | 366 | } |
367 | 367 | ||
368 | /** | 368 | /** |
369 | * lpfc_state_show: Return the link state of the port. | 369 | * lpfc_state_show - Return the link state of the port |
370 | * @dev: class converted to a Scsi_host structure. | 370 | * @dev: class converted to a Scsi_host structure. |
371 | * @attr: device attribute, not used. | 371 | * @attr: device attribute, not used. |
372 | * @buf: on return contains text describing the state of the link. | 372 | * @buf: on return contains text describing the state of the link. |
@@ -451,7 +451,7 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr, | |||
451 | } | 451 | } |
452 | 452 | ||
453 | /** | 453 | /** |
454 | * lpfc_num_discovered_ports_show: Return sum of mapped and unmapped vports. | 454 | * lpfc_num_discovered_ports_show - Return sum of mapped and unmapped vports |
455 | * @dev: class device that is converted into a Scsi_host. | 455 | * @dev: class device that is converted into a Scsi_host. |
456 | * @attr: device attribute, not used. | 456 | * @attr: device attribute, not used. |
457 | * @buf: on return contains the sum of fc mapped and unmapped. | 457 | * @buf: on return contains the sum of fc mapped and unmapped. |
@@ -474,7 +474,7 @@ lpfc_num_discovered_ports_show(struct device *dev, | |||
474 | } | 474 | } |
475 | 475 | ||
476 | /** | 476 | /** |
477 | * lpfc_issue_lip: Misnomer, name carried over from long ago. | 477 | * lpfc_issue_lip - Misnomer, name carried over from long ago |
478 | * @shost: Scsi_Host pointer. | 478 | * @shost: Scsi_Host pointer. |
479 | * | 479 | * |
480 | * Description: | 480 | * Description: |
@@ -529,7 +529,7 @@ lpfc_issue_lip(struct Scsi_Host *shost) | |||
529 | } | 529 | } |
530 | 530 | ||
531 | /** | 531 | /** |
532 | * lpfc_do_offline: Issues a mailbox command to bring the link down. | 532 | * lpfc_do_offline - Issues a mailbox command to bring the link down |
533 | * @phba: lpfc_hba pointer. | 533 | * @phba: lpfc_hba pointer. |
534 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. | 534 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. |
535 | * | 535 | * |
@@ -537,7 +537,7 @@ lpfc_issue_lip(struct Scsi_Host *shost) | |||
537 | * Assumes any error from lpfc_do_offline() will be negative. | 537 | * Assumes any error from lpfc_do_offline() will be negative. |
538 | * Can wait up to 5 seconds for the port ring buffers count | 538 | * Can wait up to 5 seconds for the port ring buffers count |
539 | * to reach zero, prints a warning if it is not zero and continues. | 539 | * to reach zero, prints a warning if it is not zero and continues. |
540 | * lpfc_workq_post_event() returns a non-zero return coce if call fails. | 540 | * lpfc_workq_post_event() returns a non-zero return code if call fails. |
541 | * | 541 | * |
542 | * Returns: | 542 | * Returns: |
543 | * -EIO error posting the event | 543 | * -EIO error posting the event |
@@ -591,7 +591,7 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) | |||
591 | } | 591 | } |
592 | 592 | ||
593 | /** | 593 | /** |
594 | * lpfc_selective_reset: Offline then onlines the port. | 594 | * lpfc_selective_reset - Offline then onlines the port |
595 | * @phba: lpfc_hba pointer. | 595 | * @phba: lpfc_hba pointer. |
596 | * | 596 | * |
597 | * Description: | 597 | * Description: |
@@ -632,7 +632,7 @@ lpfc_selective_reset(struct lpfc_hba *phba) | |||
632 | } | 632 | } |
633 | 633 | ||
634 | /** | 634 | /** |
635 | * lpfc_issue_reset: Selectively resets an adapter. | 635 | * lpfc_issue_reset - Selectively resets an adapter |
636 | * @dev: class device that is converted into a Scsi_host. | 636 | * @dev: class device that is converted into a Scsi_host. |
637 | * @attr: device attribute, not used. | 637 | * @attr: device attribute, not used. |
638 | * @buf: containing the string "selective". | 638 | * @buf: containing the string "selective". |
@@ -672,7 +672,7 @@ lpfc_issue_reset(struct device *dev, struct device_attribute *attr, | |||
672 | } | 672 | } |
673 | 673 | ||
674 | /** | 674 | /** |
675 | * lpfc_nport_evt_cnt_show: Return the number of nport events. | 675 | * lpfc_nport_evt_cnt_show - Return the number of nport events |
676 | * @dev: class device that is converted into a Scsi_host. | 676 | * @dev: class device that is converted into a Scsi_host. |
677 | * @attr: device attribute, not used. | 677 | * @attr: device attribute, not used. |
678 | * @buf: on return contains the ascii number of nport events. | 678 | * @buf: on return contains the ascii number of nport events. |
@@ -691,7 +691,7 @@ lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, | |||
691 | } | 691 | } |
692 | 692 | ||
693 | /** | 693 | /** |
694 | * lpfc_board_mode_show: Return the state of the board. | 694 | * lpfc_board_mode_show - Return the state of the board |
695 | * @dev: class device that is converted into a Scsi_host. | 695 | * @dev: class device that is converted into a Scsi_host. |
696 | * @attr: device attribute, not used. | 696 | * @attr: device attribute, not used. |
697 | * @buf: on return contains the state of the adapter. | 697 | * @buf: on return contains the state of the adapter. |
@@ -720,7 +720,7 @@ lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, | |||
720 | } | 720 | } |
721 | 721 | ||
722 | /** | 722 | /** |
723 | * lpfc_board_mode_store: Puts the hba in online, offline, warm or error state. | 723 | * lpfc_board_mode_store - Puts the hba in online, offline, warm or error state |
724 | * @dev: class device that is converted into a Scsi_host. | 724 | * @dev: class device that is converted into a Scsi_host. |
725 | * @attr: device attribute, not used. | 725 | * @attr: device attribute, not used. |
726 | * @buf: containing one of the strings "online", "offline", "warm" or "error". | 726 | * @buf: containing one of the strings "online", "offline", "warm" or "error". |
@@ -766,14 +766,14 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, | |||
766 | } | 766 | } |
767 | 767 | ||
768 | /** | 768 | /** |
769 | * lpfc_get_hba_info: Return various bits of informaton about the adapter. | 769 | * lpfc_get_hba_info - Return various bits of informaton about the adapter |
770 | * @phba: pointer to the adapter structure. | 770 | * @phba: pointer to the adapter structure. |
771 | * @mxri max xri count. | 771 | * @mxri: max xri count. |
772 | * @axri available xri count. | 772 | * @axri: available xri count. |
773 | * @mrpi max rpi count. | 773 | * @mrpi: max rpi count. |
774 | * @arpi available rpi count. | 774 | * @arpi: available rpi count. |
775 | * @mvpi max vpi count. | 775 | * @mvpi: max vpi count. |
776 | * @avpi available vpi count. | 776 | * @avpi: available vpi count. |
777 | * | 777 | * |
778 | * Description: | 778 | * Description: |
779 | * If an integer pointer for an count is not null then the value for the | 779 | * If an integer pointer for an count is not null then the value for the |
@@ -846,7 +846,7 @@ lpfc_get_hba_info(struct lpfc_hba *phba, | |||
846 | } | 846 | } |
847 | 847 | ||
848 | /** | 848 | /** |
849 | * lpfc_max_rpi_show: Return maximum rpi. | 849 | * lpfc_max_rpi_show - Return maximum rpi |
850 | * @dev: class device that is converted into a Scsi_host. | 850 | * @dev: class device that is converted into a Scsi_host. |
851 | * @attr: device attribute, not used. | 851 | * @attr: device attribute, not used. |
852 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". | 852 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". |
@@ -874,7 +874,7 @@ lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, | |||
874 | } | 874 | } |
875 | 875 | ||
876 | /** | 876 | /** |
877 | * lpfc_used_rpi_show: Return maximum rpi minus available rpi. | 877 | * lpfc_used_rpi_show - Return maximum rpi minus available rpi |
878 | * @dev: class device that is converted into a Scsi_host. | 878 | * @dev: class device that is converted into a Scsi_host. |
879 | * @attr: device attribute, not used. | 879 | * @attr: device attribute, not used. |
880 | * @buf: containing the used rpi count in decimal or "Unknown". | 880 | * @buf: containing the used rpi count in decimal or "Unknown". |
@@ -902,7 +902,7 @@ lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, | |||
902 | } | 902 | } |
903 | 903 | ||
904 | /** | 904 | /** |
905 | * lpfc_max_xri_show: Return maximum xri. | 905 | * lpfc_max_xri_show - Return maximum xri |
906 | * @dev: class device that is converted into a Scsi_host. | 906 | * @dev: class device that is converted into a Scsi_host. |
907 | * @attr: device attribute, not used. | 907 | * @attr: device attribute, not used. |
908 | * @buf: on return contains the maximum xri count in decimal or "Unknown". | 908 | * @buf: on return contains the maximum xri count in decimal or "Unknown". |
@@ -930,7 +930,7 @@ lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, | |||
930 | } | 930 | } |
931 | 931 | ||
932 | /** | 932 | /** |
933 | * lpfc_used_xri_show: Return maximum xpi minus the available xpi. | 933 | * lpfc_used_xri_show - Return maximum xpi minus the available xpi |
934 | * @dev: class device that is converted into a Scsi_host. | 934 | * @dev: class device that is converted into a Scsi_host. |
935 | * @attr: device attribute, not used. | 935 | * @attr: device attribute, not used. |
936 | * @buf: on return contains the used xri count in decimal or "Unknown". | 936 | * @buf: on return contains the used xri count in decimal or "Unknown". |
@@ -958,7 +958,7 @@ lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, | |||
958 | } | 958 | } |
959 | 959 | ||
960 | /** | 960 | /** |
961 | * lpfc_max_vpi_show: Return maximum vpi. | 961 | * lpfc_max_vpi_show - Return maximum vpi |
962 | * @dev: class device that is converted into a Scsi_host. | 962 | * @dev: class device that is converted into a Scsi_host. |
963 | * @attr: device attribute, not used. | 963 | * @attr: device attribute, not used. |
964 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". | 964 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". |
@@ -986,7 +986,7 @@ lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, | |||
986 | } | 986 | } |
987 | 987 | ||
988 | /** | 988 | /** |
989 | * lpfc_used_vpi_show: Return maximum vpi minus the available vpi. | 989 | * lpfc_used_vpi_show - Return maximum vpi minus the available vpi |
990 | * @dev: class device that is converted into a Scsi_host. | 990 | * @dev: class device that is converted into a Scsi_host. |
991 | * @attr: device attribute, not used. | 991 | * @attr: device attribute, not used. |
992 | * @buf: on return contains the used vpi count in decimal or "Unknown". | 992 | * @buf: on return contains the used vpi count in decimal or "Unknown". |
@@ -1014,7 +1014,7 @@ lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, | |||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | /** | 1016 | /** |
1017 | * lpfc_npiv_info_show: Return text about NPIV support for the adapter. | 1017 | * lpfc_npiv_info_show - Return text about NPIV support for the adapter |
1018 | * @dev: class device that is converted into a Scsi_host. | 1018 | * @dev: class device that is converted into a Scsi_host. |
1019 | * @attr: device attribute, not used. | 1019 | * @attr: device attribute, not used. |
1020 | * @buf: text that must be interpreted to determine if npiv is supported. | 1020 | * @buf: text that must be interpreted to determine if npiv is supported. |
@@ -1042,7 +1042,7 @@ lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, | |||
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | /** | 1044 | /** |
1045 | * lpfc_poll_show: Return text about poll support for the adapter. | 1045 | * lpfc_poll_show - Return text about poll support for the adapter |
1046 | * @dev: class device that is converted into a Scsi_host. | 1046 | * @dev: class device that is converted into a Scsi_host. |
1047 | * @attr: device attribute, not used. | 1047 | * @attr: device attribute, not used. |
1048 | * @buf: on return contains the cfg_poll in hex. | 1048 | * @buf: on return contains the cfg_poll in hex. |
@@ -1064,7 +1064,7 @@ lpfc_poll_show(struct device *dev, struct device_attribute *attr, | |||
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | /** | 1066 | /** |
1067 | * lpfc_poll_store: Set the value of cfg_poll for the adapter. | 1067 | * lpfc_poll_store - Set the value of cfg_poll for the adapter |
1068 | * @dev: class device that is converted into a Scsi_host. | 1068 | * @dev: class device that is converted into a Scsi_host. |
1069 | * @attr: device attribute, not used. | 1069 | * @attr: device attribute, not used. |
1070 | * @buf: one or more lpfc_polling_flags values. | 1070 | * @buf: one or more lpfc_polling_flags values. |
@@ -1136,7 +1136,7 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr, | |||
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | /** | 1138 | /** |
1139 | * lpfc_param_show: Return a cfg attribute value in decimal. | 1139 | * lpfc_param_show - Return a cfg attribute value in decimal |
1140 | * | 1140 | * |
1141 | * Description: | 1141 | * Description: |
1142 | * Macro that given an attr e.g. hba_queue_depth expands | 1142 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1164,7 +1164,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | /** | 1166 | /** |
1167 | * lpfc_param_hex_show: Return a cfg attribute value in hex. | 1167 | * lpfc_param_hex_show - Return a cfg attribute value in hex |
1168 | * | 1168 | * |
1169 | * Description: | 1169 | * Description: |
1170 | * Macro that given an attr e.g. hba_queue_depth expands | 1170 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1173,7 +1173,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
1173 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. | 1173 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. |
1174 | * @dev: class device that is converted into a Scsi_host. | 1174 | * @dev: class device that is converted into a Scsi_host. |
1175 | * @attr: device attribute, not used. | 1175 | * @attr: device attribute, not used. |
1176 | * @buf: on return contains the attribute value in hexidecimal. | 1176 | * @buf: on return contains the attribute value in hexadecimal. |
1177 | * | 1177 | * |
1178 | * Returns: size of formatted string. | 1178 | * Returns: size of formatted string. |
1179 | **/ | 1179 | **/ |
@@ -1192,7 +1192,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | /** | 1194 | /** |
1195 | * lpfc_param_init: Intializes a cfg attribute. | 1195 | * lpfc_param_init - Intializes a cfg attribute |
1196 | * | 1196 | * |
1197 | * Description: | 1197 | * Description: |
1198 | * Macro that given an attr e.g. hba_queue_depth expands | 1198 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1226,7 +1226,7 @@ lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ | |||
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | /** | 1228 | /** |
1229 | * lpfc_param_set: Set a cfg attribute value. | 1229 | * lpfc_param_set - Set a cfg attribute value |
1230 | * | 1230 | * |
1231 | * Description: | 1231 | * Description: |
1232 | * Macro that given an attr e.g. hba_queue_depth expands | 1232 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1260,7 +1260,7 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ | |||
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | /** | 1262 | /** |
1263 | * lpfc_param_store: Set a vport attribute value. | 1263 | * lpfc_param_store - Set a vport attribute value |
1264 | * | 1264 | * |
1265 | * Description: | 1265 | * Description: |
1266 | * Macro that given an attr e.g. hba_queue_depth expands | 1266 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1300,7 +1300,7 @@ lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ | |||
1300 | } | 1300 | } |
1301 | 1301 | ||
1302 | /** | 1302 | /** |
1303 | * lpfc_vport_param_show: Return decimal formatted cfg attribute value. | 1303 | * lpfc_vport_param_show - Return decimal formatted cfg attribute value |
1304 | * | 1304 | * |
1305 | * Description: | 1305 | * Description: |
1306 | * Macro that given an attr e.g. hba_queue_depth expands | 1306 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1326,17 +1326,17 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | /** | 1328 | /** |
1329 | * lpfc_vport_param_hex_show: Return hex formatted attribute value. | 1329 | * lpfc_vport_param_hex_show - Return hex formatted attribute value |
1330 | * | 1330 | * |
1331 | * Description: | 1331 | * Description: |
1332 | * Macro that given an attr e.g. | 1332 | * Macro that given an attr e.g. |
1333 | * hba_queue_depth expands into a function with the name | 1333 | * hba_queue_depth expands into a function with the name |
1334 | * lpfc_hba_queue_depth_show | 1334 | * lpfc_hba_queue_depth_show |
1335 | * | 1335 | * |
1336 | * lpfc_##attr##_show: prints the attribute value in hexidecimal. | 1336 | * lpfc_##attr##_show: prints the attribute value in hexadecimal. |
1337 | * @dev: class device that is converted into a Scsi_host. | 1337 | * @dev: class device that is converted into a Scsi_host. |
1338 | * @attr: device attribute, not used. | 1338 | * @attr: device attribute, not used. |
1339 | * @buf: on return contains the attribute value in hexidecimal. | 1339 | * @buf: on return contains the attribute value in hexadecimal. |
1340 | * | 1340 | * |
1341 | * Returns: length of formatted string. | 1341 | * Returns: length of formatted string. |
1342 | **/ | 1342 | **/ |
@@ -1353,7 +1353,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | /** | 1355 | /** |
1356 | * lpfc_vport_param_init: Initialize a vport cfg attribute. | 1356 | * lpfc_vport_param_init - Initialize a vport cfg attribute |
1357 | * | 1357 | * |
1358 | * Description: | 1358 | * Description: |
1359 | * Macro that given an attr e.g. hba_queue_depth expands | 1359 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1386,7 +1386,7 @@ lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ | |||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | /** | 1388 | /** |
1389 | * lpfc_vport_param_set: Set a vport cfg attribute. | 1389 | * lpfc_vport_param_set - Set a vport cfg attribute |
1390 | * | 1390 | * |
1391 | * Description: | 1391 | * Description: |
1392 | * Macro that given an attr e.g. hba_queue_depth expands | 1392 | * Macro that given an attr e.g. hba_queue_depth expands |
@@ -1417,7 +1417,7 @@ lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ | |||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | /** | 1419 | /** |
1420 | * lpfc_vport_param_store: Set a vport attribute. | 1420 | * lpfc_vport_param_store - Set a vport attribute |
1421 | * | 1421 | * |
1422 | * Description: | 1422 | * Description: |
1423 | * Macro that given an attr e.g. hba_queue_depth | 1423 | * Macro that given an attr e.g. hba_queue_depth |
@@ -1576,7 +1576,7 @@ static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); | |||
1576 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; | 1576 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
1577 | 1577 | ||
1578 | /** | 1578 | /** |
1579 | * lpfc_soft_wwn_enable_store: Allows setting of the wwn if the key is valid. | 1579 | * lpfc_soft_wwn_enable_store - Allows setting of the wwn if the key is valid |
1580 | * @dev: class device that is converted into a Scsi_host. | 1580 | * @dev: class device that is converted into a Scsi_host. |
1581 | * @attr: device attribute, not used. | 1581 | * @attr: device attribute, not used. |
1582 | * @buf: containing the string lpfc_soft_wwn_key. | 1582 | * @buf: containing the string lpfc_soft_wwn_key. |
@@ -1623,10 +1623,10 @@ static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, | |||
1623 | lpfc_soft_wwn_enable_store); | 1623 | lpfc_soft_wwn_enable_store); |
1624 | 1624 | ||
1625 | /** | 1625 | /** |
1626 | * lpfc_soft_wwpn_show: Return the cfg soft ww port name of the adapter. | 1626 | * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter |
1627 | * @dev: class device that is converted into a Scsi_host. | 1627 | * @dev: class device that is converted into a Scsi_host. |
1628 | * @attr: device attribute, not used. | 1628 | * @attr: device attribute, not used. |
1629 | * @buf: on return contains the wwpn in hexidecimal. | 1629 | * @buf: on return contains the wwpn in hexadecimal. |
1630 | * | 1630 | * |
1631 | * Returns: size of formatted string. | 1631 | * Returns: size of formatted string. |
1632 | **/ | 1632 | **/ |
@@ -1643,10 +1643,10 @@ lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, | |||
1643 | } | 1643 | } |
1644 | 1644 | ||
1645 | /** | 1645 | /** |
1646 | * lpfc_soft_wwpn_store: Set the ww port name of the adapter. | 1646 | * lpfc_soft_wwpn_store - Set the ww port name of the adapter |
1647 | * @dev class device that is converted into a Scsi_host. | 1647 | * @dev class device that is converted into a Scsi_host. |
1648 | * @attr: device attribute, not used. | 1648 | * @attr: device attribute, not used. |
1649 | * @buf: contains the wwpn in hexidecimal. | 1649 | * @buf: contains the wwpn in hexadecimal. |
1650 | * @count: number of wwpn bytes in buf | 1650 | * @count: number of wwpn bytes in buf |
1651 | * | 1651 | * |
1652 | * Returns: | 1652 | * Returns: |
@@ -1729,10 +1729,10 @@ static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ | |||
1729 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); | 1729 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
1730 | 1730 | ||
1731 | /** | 1731 | /** |
1732 | * lpfc_soft_wwnn_show: Return the cfg soft ww node name for the adapter. | 1732 | * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter |
1733 | * @dev: class device that is converted into a Scsi_host. | 1733 | * @dev: class device that is converted into a Scsi_host. |
1734 | * @attr: device attribute, not used. | 1734 | * @attr: device attribute, not used. |
1735 | * @buf: on return contains the wwnn in hexidecimal. | 1735 | * @buf: on return contains the wwnn in hexadecimal. |
1736 | * | 1736 | * |
1737 | * Returns: size of formatted string. | 1737 | * Returns: size of formatted string. |
1738 | **/ | 1738 | **/ |
@@ -1747,9 +1747,9 @@ lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, | |||
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | /** | 1749 | /** |
1750 | * lpfc_soft_wwnn_store: sets the ww node name of the adapter. | 1750 | * lpfc_soft_wwnn_store - sets the ww node name of the adapter |
1751 | * @cdev: class device that is converted into a Scsi_host. | 1751 | * @cdev: class device that is converted into a Scsi_host. |
1752 | * @buf: contains the ww node name in hexidecimal. | 1752 | * @buf: contains the ww node name in hexadecimal. |
1753 | * @count: number of wwnn bytes in buf. | 1753 | * @count: number of wwnn bytes in buf. |
1754 | * | 1754 | * |
1755 | * Returns: | 1755 | * Returns: |
@@ -1845,7 +1845,7 @@ MODULE_PARM_DESC(lpfc_nodev_tmo, | |||
1845 | "for a device to come back"); | 1845 | "for a device to come back"); |
1846 | 1846 | ||
1847 | /** | 1847 | /** |
1848 | * lpfc_nodev_tmo_show: Return the hba dev loss timeout value. | 1848 | * lpfc_nodev_tmo_show - Return the hba dev loss timeout value |
1849 | * @dev: class converted to a Scsi_host structure. | 1849 | * @dev: class converted to a Scsi_host structure. |
1850 | * @attr: device attribute, not used. | 1850 | * @attr: device attribute, not used. |
1851 | * @buf: on return contains the dev loss timeout in decimal. | 1851 | * @buf: on return contains the dev loss timeout in decimal. |
@@ -1864,7 +1864,7 @@ lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, | |||
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | /** | 1866 | /** |
1867 | * lpfc_nodev_tmo_init: Set the hba nodev timeout value. | 1867 | * lpfc_nodev_tmo_init - Set the hba nodev timeout value |
1868 | * @vport: lpfc vport structure pointer. | 1868 | * @vport: lpfc vport structure pointer. |
1869 | * @val: contains the nodev timeout value. | 1869 | * @val: contains the nodev timeout value. |
1870 | * | 1870 | * |
@@ -1905,7 +1905,7 @@ lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) | |||
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | /** | 1907 | /** |
1908 | * lpfc_update_rport_devloss_tmo: Update dev loss tmo value. | 1908 | * lpfc_update_rport_devloss_tmo - Update dev loss tmo value |
1909 | * @vport: lpfc vport structure pointer. | 1909 | * @vport: lpfc vport structure pointer. |
1910 | * | 1910 | * |
1911 | * Description: | 1911 | * Description: |
@@ -1926,7 +1926,7 @@ lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) | |||
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | /** | 1928 | /** |
1929 | * lpfc_nodev_tmo_set: Set the vport nodev tmo and devloss tmo values. | 1929 | * lpfc_nodev_tmo_set - Set the vport nodev tmo and devloss tmo values |
1930 | * @vport: lpfc vport structure pointer. | 1930 | * @vport: lpfc vport structure pointer. |
1931 | * @val: contains the tmo value. | 1931 | * @val: contains the tmo value. |
1932 | * | 1932 | * |
@@ -1982,7 +1982,7 @@ lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, | |||
1982 | lpfc_vport_param_show(devloss_tmo) | 1982 | lpfc_vport_param_show(devloss_tmo) |
1983 | 1983 | ||
1984 | /** | 1984 | /** |
1985 | * lpfc_devloss_tmo_set: Sets vport nodev tmo, devloss tmo values, changed bit. | 1985 | * lpfc_devloss_tmo_set - Sets vport nodev tmo, devloss tmo values, changed bit |
1986 | * @vport: lpfc vport structure pointer. | 1986 | * @vport: lpfc vport structure pointer. |
1987 | * @val: contains the tmo value. | 1987 | * @val: contains the tmo value. |
1988 | * | 1988 | * |
@@ -2094,7 +2094,7 @@ MODULE_PARM_DESC(lpfc_restrict_login, | |||
2094 | lpfc_vport_param_show(restrict_login); | 2094 | lpfc_vport_param_show(restrict_login); |
2095 | 2095 | ||
2096 | /** | 2096 | /** |
2097 | * lpfc_restrict_login_init: Set the vport restrict login flag. | 2097 | * lpfc_restrict_login_init - Set the vport restrict login flag |
2098 | * @vport: lpfc vport structure pointer. | 2098 | * @vport: lpfc vport structure pointer. |
2099 | * @val: contains the restrict login value. | 2099 | * @val: contains the restrict login value. |
2100 | * | 2100 | * |
@@ -2128,7 +2128,7 @@ lpfc_restrict_login_init(struct lpfc_vport *vport, int val) | |||
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | /** | 2130 | /** |
2131 | * lpfc_restrict_login_set: Set the vport restrict login flag. | 2131 | * lpfc_restrict_login_set - Set the vport restrict login flag |
2132 | * @vport: lpfc vport structure pointer. | 2132 | * @vport: lpfc vport structure pointer. |
2133 | * @val: contains the restrict login value. | 2133 | * @val: contains the restrict login value. |
2134 | * | 2134 | * |
@@ -2201,7 +2201,7 @@ LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, | |||
2201 | */ | 2201 | */ |
2202 | 2202 | ||
2203 | /** | 2203 | /** |
2204 | * lpfc_topology_set: Set the adapters topology field. | 2204 | * lpfc_topology_set - Set the adapters topology field |
2205 | * @phba: lpfc_hba pointer. | 2205 | * @phba: lpfc_hba pointer. |
2206 | * @val: topology value. | 2206 | * @val: topology value. |
2207 | * | 2207 | * |
@@ -2216,18 +2216,41 @@ LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, | |||
2216 | * non-zero return value from lpfc_issue_lip() | 2216 | * non-zero return value from lpfc_issue_lip() |
2217 | * -EINVAL val out of range | 2217 | * -EINVAL val out of range |
2218 | **/ | 2218 | **/ |
2219 | static int | 2219 | static ssize_t |
2220 | lpfc_topology_set(struct lpfc_hba *phba, int val) | 2220 | lpfc_topology_store(struct device *dev, struct device_attribute *attr, |
2221 | const char *buf, size_t count) | ||
2221 | { | 2222 | { |
2223 | struct Scsi_Host *shost = class_to_shost(dev); | ||
2224 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | ||
2225 | struct lpfc_hba *phba = vport->phba; | ||
2226 | int val = 0; | ||
2227 | int nolip = 0; | ||
2228 | const char *val_buf = buf; | ||
2222 | int err; | 2229 | int err; |
2223 | uint32_t prev_val; | 2230 | uint32_t prev_val; |
2231 | |||
2232 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { | ||
2233 | nolip = 1; | ||
2234 | val_buf = &buf[strlen("nolip ")]; | ||
2235 | } | ||
2236 | |||
2237 | if (!isdigit(val_buf[0])) | ||
2238 | return -EINVAL; | ||
2239 | if (sscanf(val_buf, "%i", &val) != 1) | ||
2240 | return -EINVAL; | ||
2241 | |||
2224 | if (val >= 0 && val <= 6) { | 2242 | if (val >= 0 && val <= 6) { |
2225 | prev_val = phba->cfg_topology; | 2243 | prev_val = phba->cfg_topology; |
2226 | phba->cfg_topology = val; | 2244 | phba->cfg_topology = val; |
2245 | if (nolip) | ||
2246 | return strlen(buf); | ||
2247 | |||
2227 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); | 2248 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
2228 | if (err) | 2249 | if (err) { |
2229 | phba->cfg_topology = prev_val; | 2250 | phba->cfg_topology = prev_val; |
2230 | return err; | 2251 | return -EINVAL; |
2252 | } else | ||
2253 | return strlen(buf); | ||
2231 | } | 2254 | } |
2232 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 2255 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
2233 | "%d:0467 lpfc_topology attribute cannot be set to %d, " | 2256 | "%d:0467 lpfc_topology attribute cannot be set to %d, " |
@@ -2240,14 +2263,12 @@ module_param(lpfc_topology, int, 0); | |||
2240 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); | 2263 | MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology"); |
2241 | lpfc_param_show(topology) | 2264 | lpfc_param_show(topology) |
2242 | lpfc_param_init(topology, 0, 0, 6) | 2265 | lpfc_param_init(topology, 0, 0, 6) |
2243 | lpfc_param_store(topology) | ||
2244 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, | 2266 | static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, |
2245 | lpfc_topology_show, lpfc_topology_store); | 2267 | lpfc_topology_show, lpfc_topology_store); |
2246 | 2268 | ||
2247 | 2269 | ||
2248 | /** | 2270 | /** |
2249 | * lpfc_stat_data_ctrl_store: write call back for lpfc_stat_data_ctrl | 2271 | * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file |
2250 | * sysfs file. | ||
2251 | * @dev: Pointer to class device. | 2272 | * @dev: Pointer to class device. |
2252 | * @buf: Data buffer. | 2273 | * @buf: Data buffer. |
2253 | * @count: Size of the data buffer. | 2274 | * @count: Size of the data buffer. |
@@ -2282,7 +2303,7 @@ lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, | |||
2282 | unsigned long base, step, bucket_type; | 2303 | unsigned long base, step, bucket_type; |
2283 | 2304 | ||
2284 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { | 2305 | if (!strncmp(buf, "setbucket", strlen("setbucket"))) { |
2285 | if (strlen(buf) > LPFC_MAX_DATA_CTRL_LEN) | 2306 | if (strlen(buf) > (LPFC_MAX_DATA_CTRL_LEN - 1)) |
2286 | return -EINVAL; | 2307 | return -EINVAL; |
2287 | 2308 | ||
2288 | strcpy(bucket_data, buf); | 2309 | strcpy(bucket_data, buf); |
@@ -2411,8 +2432,7 @@ lpfc_stat_data_ctrl_store(struct device *dev, struct device_attribute *attr, | |||
2411 | 2432 | ||
2412 | 2433 | ||
2413 | /** | 2434 | /** |
2414 | * lpfc_stat_data_ctrl_show: Read callback function for | 2435 | * lpfc_stat_data_ctrl_show - Read function for lpfc_stat_data_ctrl sysfs file |
2415 | * lpfc_stat_data_ctrl sysfs file. | ||
2416 | * @dev: Pointer to class device object. | 2436 | * @dev: Pointer to class device object. |
2417 | * @buf: Data buffer. | 2437 | * @buf: Data buffer. |
2418 | * | 2438 | * |
@@ -2489,8 +2509,7 @@ static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, | |||
2489 | 2509 | ||
2490 | 2510 | ||
2491 | /** | 2511 | /** |
2492 | * sysfs_drvr_stat_data_read: Read callback function for lpfc_drvr_stat_data | 2512 | * sysfs_drvr_stat_data_read - Read function for lpfc_drvr_stat_data attribute |
2493 | * sysfs attribute. | ||
2494 | * @kobj: Pointer to the kernel object | 2513 | * @kobj: Pointer to the kernel object |
2495 | * @bin_attr: Attribute object | 2514 | * @bin_attr: Attribute object |
2496 | * @buff: Buffer pointer | 2515 | * @buff: Buffer pointer |
@@ -2585,7 +2604,7 @@ static struct bin_attribute sysfs_drvr_stat_data_attr = { | |||
2585 | */ | 2604 | */ |
2586 | 2605 | ||
2587 | /** | 2606 | /** |
2588 | * lpfc_link_speed_set: Set the adapters link speed. | 2607 | * lpfc_link_speed_set - Set the adapters link speed |
2589 | * @phba: lpfc_hba pointer. | 2608 | * @phba: lpfc_hba pointer. |
2590 | * @val: link speed value. | 2609 | * @val: link speed value. |
2591 | * | 2610 | * |
@@ -2601,12 +2620,29 @@ static struct bin_attribute sysfs_drvr_stat_data_attr = { | |||
2601 | * non-zero return value from lpfc_issue_lip() | 2620 | * non-zero return value from lpfc_issue_lip() |
2602 | * -EINVAL val out of range | 2621 | * -EINVAL val out of range |
2603 | **/ | 2622 | **/ |
2604 | static int | 2623 | static ssize_t |
2605 | lpfc_link_speed_set(struct lpfc_hba *phba, int val) | 2624 | lpfc_link_speed_store(struct device *dev, struct device_attribute *attr, |
2625 | const char *buf, size_t count) | ||
2606 | { | 2626 | { |
2627 | struct Scsi_Host *shost = class_to_shost(dev); | ||
2628 | struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; | ||
2629 | struct lpfc_hba *phba = vport->phba; | ||
2630 | int val = 0; | ||
2631 | int nolip = 0; | ||
2632 | const char *val_buf = buf; | ||
2607 | int err; | 2633 | int err; |
2608 | uint32_t prev_val; | 2634 | uint32_t prev_val; |
2609 | 2635 | ||
2636 | if (!strncmp(buf, "nolip ", strlen("nolip "))) { | ||
2637 | nolip = 1; | ||
2638 | val_buf = &buf[strlen("nolip ")]; | ||
2639 | } | ||
2640 | |||
2641 | if (!isdigit(val_buf[0])) | ||
2642 | return -EINVAL; | ||
2643 | if (sscanf(val_buf, "%i", &val) != 1) | ||
2644 | return -EINVAL; | ||
2645 | |||
2610 | if (((val == LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || | 2646 | if (((val == LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) || |
2611 | ((val == LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || | 2647 | ((val == LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) || |
2612 | ((val == LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || | 2648 | ((val == LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) || |
@@ -2614,14 +2650,19 @@ lpfc_link_speed_set(struct lpfc_hba *phba, int val) | |||
2614 | ((val == LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb))) | 2650 | ((val == LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb))) |
2615 | return -EINVAL; | 2651 | return -EINVAL; |
2616 | 2652 | ||
2617 | if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED) | 2653 | if ((val >= 0 && val <= 8) |
2618 | && (LPFC_LINK_SPEED_BITMAP & (1 << val))) { | 2654 | && (LPFC_LINK_SPEED_BITMAP & (1 << val))) { |
2619 | prev_val = phba->cfg_link_speed; | 2655 | prev_val = phba->cfg_link_speed; |
2620 | phba->cfg_link_speed = val; | 2656 | phba->cfg_link_speed = val; |
2657 | if (nolip) | ||
2658 | return strlen(buf); | ||
2659 | |||
2621 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); | 2660 | err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport)); |
2622 | if (err) | 2661 | if (err) { |
2623 | phba->cfg_link_speed = prev_val; | 2662 | phba->cfg_link_speed = prev_val; |
2624 | return err; | 2663 | return -EINVAL; |
2664 | } else | ||
2665 | return strlen(buf); | ||
2625 | } | 2666 | } |
2626 | 2667 | ||
2627 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 2668 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
@@ -2637,7 +2678,7 @@ MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); | |||
2637 | lpfc_param_show(link_speed) | 2678 | lpfc_param_show(link_speed) |
2638 | 2679 | ||
2639 | /** | 2680 | /** |
2640 | * lpfc_link_speed_init: Set the adapters link speed. | 2681 | * lpfc_link_speed_init - Set the adapters link speed |
2641 | * @phba: lpfc_hba pointer. | 2682 | * @phba: lpfc_hba pointer. |
2642 | * @val: link speed value. | 2683 | * @val: link speed value. |
2643 | * | 2684 | * |
@@ -2668,7 +2709,6 @@ lpfc_link_speed_init(struct lpfc_hba *phba, int val) | |||
2668 | return -EINVAL; | 2709 | return -EINVAL; |
2669 | } | 2710 | } |
2670 | 2711 | ||
2671 | lpfc_param_store(link_speed) | ||
2672 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, | 2712 | static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, |
2673 | lpfc_link_speed_show, lpfc_link_speed_store); | 2713 | lpfc_link_speed_show, lpfc_link_speed_store); |
2674 | 2714 | ||
@@ -2865,7 +2905,7 @@ MODULE_PARM_DESC(lpfc_prot_guard, "host protection guard type"); | |||
2865 | 2905 | ||
2866 | 2906 | ||
2867 | /* | 2907 | /* |
2868 | * lpfc_sg_seg_cnt: Initial Maximum DMA Segment Count | 2908 | * lpfc_sg_seg_cnt - Initial Maximum DMA Segment Count |
2869 | * This value can be set to values between 64 and 256. The default value is | 2909 | * This value can be set to values between 64 and 256. The default value is |
2870 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer | 2910 | * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer |
2871 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). | 2911 | * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE). |
@@ -2967,7 +3007,7 @@ struct device_attribute *lpfc_vport_attrs[] = { | |||
2967 | }; | 3007 | }; |
2968 | 3008 | ||
2969 | /** | 3009 | /** |
2970 | * sysfs_ctlreg_write: Write method for writing to ctlreg. | 3010 | * sysfs_ctlreg_write - Write method for writing to ctlreg |
2971 | * @kobj: kernel kobject that contains the kernel class device. | 3011 | * @kobj: kernel kobject that contains the kernel class device. |
2972 | * @bin_attr: kernel attributes passed to us. | 3012 | * @bin_attr: kernel attributes passed to us. |
2973 | * @buf: contains the data to be written to the adapter IOREG space. | 3013 | * @buf: contains the data to be written to the adapter IOREG space. |
@@ -3017,7 +3057,7 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
3017 | } | 3057 | } |
3018 | 3058 | ||
3019 | /** | 3059 | /** |
3020 | * sysfs_ctlreg_read: Read method for reading from ctlreg. | 3060 | * sysfs_ctlreg_read - Read method for reading from ctlreg |
3021 | * @kobj: kernel kobject that contains the kernel class device. | 3061 | * @kobj: kernel kobject that contains the kernel class device. |
3022 | * @bin_attr: kernel attributes passed to us. | 3062 | * @bin_attr: kernel attributes passed to us. |
3023 | * @buf: if succesful contains the data from the adapter IOREG space. | 3063 | * @buf: if succesful contains the data from the adapter IOREG space. |
@@ -3078,7 +3118,7 @@ static struct bin_attribute sysfs_ctlreg_attr = { | |||
3078 | }; | 3118 | }; |
3079 | 3119 | ||
3080 | /** | 3120 | /** |
3081 | * sysfs_mbox_idle: frees the sysfs mailbox. | 3121 | * sysfs_mbox_idle - frees the sysfs mailbox |
3082 | * @phba: lpfc_hba pointer | 3122 | * @phba: lpfc_hba pointer |
3083 | **/ | 3123 | **/ |
3084 | static void | 3124 | static void |
@@ -3095,7 +3135,7 @@ sysfs_mbox_idle(struct lpfc_hba *phba) | |||
3095 | } | 3135 | } |
3096 | 3136 | ||
3097 | /** | 3137 | /** |
3098 | * sysfs_mbox_write: Write method for writing information via mbox. | 3138 | * sysfs_mbox_write - Write method for writing information via mbox |
3099 | * @kobj: kernel kobject that contains the kernel class device. | 3139 | * @kobj: kernel kobject that contains the kernel class device. |
3100 | * @bin_attr: kernel attributes passed to us. | 3140 | * @bin_attr: kernel attributes passed to us. |
3101 | * @buf: contains the data to be written to sysfs mbox. | 3141 | * @buf: contains the data to be written to sysfs mbox. |
@@ -3170,7 +3210,7 @@ sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
3170 | } | 3210 | } |
3171 | 3211 | ||
3172 | /** | 3212 | /** |
3173 | * sysfs_mbox_read: Read method for reading information via mbox. | 3213 | * sysfs_mbox_read - Read method for reading information via mbox |
3174 | * @kobj: kernel kobject that contains the kernel class device. | 3214 | * @kobj: kernel kobject that contains the kernel class device. |
3175 | * @bin_attr: kernel attributes passed to us. | 3215 | * @bin_attr: kernel attributes passed to us. |
3176 | * @buf: contains the data to be read from sysfs mbox. | 3216 | * @buf: contains the data to be read from sysfs mbox. |
@@ -3374,7 +3414,7 @@ static struct bin_attribute sysfs_mbox_attr = { | |||
3374 | }; | 3414 | }; |
3375 | 3415 | ||
3376 | /** | 3416 | /** |
3377 | * lpfc_alloc_sysfs_attr: Creates the ctlreg and mbox entries. | 3417 | * lpfc_alloc_sysfs_attr - Creates the ctlreg and mbox entries |
3378 | * @vport: address of lpfc vport structure. | 3418 | * @vport: address of lpfc vport structure. |
3379 | * | 3419 | * |
3380 | * Return codes: | 3420 | * Return codes: |
@@ -3415,7 +3455,7 @@ out: | |||
3415 | } | 3455 | } |
3416 | 3456 | ||
3417 | /** | 3457 | /** |
3418 | * lpfc_free_sysfs_attr: Removes the ctlreg and mbox entries. | 3458 | * lpfc_free_sysfs_attr - Removes the ctlreg and mbox entries |
3419 | * @vport: address of lpfc vport structure. | 3459 | * @vport: address of lpfc vport structure. |
3420 | **/ | 3460 | **/ |
3421 | void | 3461 | void |
@@ -3437,7 +3477,7 @@ lpfc_free_sysfs_attr(struct lpfc_vport *vport) | |||
3437 | */ | 3477 | */ |
3438 | 3478 | ||
3439 | /** | 3479 | /** |
3440 | * lpfc_get_host_port_id: Copy the vport DID into the scsi host port id. | 3480 | * lpfc_get_host_port_id - Copy the vport DID into the scsi host port id |
3441 | * @shost: kernel scsi host pointer. | 3481 | * @shost: kernel scsi host pointer. |
3442 | **/ | 3482 | **/ |
3443 | static void | 3483 | static void |
@@ -3450,7 +3490,7 @@ lpfc_get_host_port_id(struct Scsi_Host *shost) | |||
3450 | } | 3490 | } |
3451 | 3491 | ||
3452 | /** | 3492 | /** |
3453 | * lpfc_get_host_port_type: Set the value of the scsi host port type. | 3493 | * lpfc_get_host_port_type - Set the value of the scsi host port type |
3454 | * @shost: kernel scsi host pointer. | 3494 | * @shost: kernel scsi host pointer. |
3455 | **/ | 3495 | **/ |
3456 | static void | 3496 | static void |
@@ -3482,7 +3522,7 @@ lpfc_get_host_port_type(struct Scsi_Host *shost) | |||
3482 | } | 3522 | } |
3483 | 3523 | ||
3484 | /** | 3524 | /** |
3485 | * lpfc_get_host_port_state: Set the value of the scsi host port state. | 3525 | * lpfc_get_host_port_state - Set the value of the scsi host port state |
3486 | * @shost: kernel scsi host pointer. | 3526 | * @shost: kernel scsi host pointer. |
3487 | **/ | 3527 | **/ |
3488 | static void | 3528 | static void |
@@ -3520,7 +3560,7 @@ lpfc_get_host_port_state(struct Scsi_Host *shost) | |||
3520 | } | 3560 | } |
3521 | 3561 | ||
3522 | /** | 3562 | /** |
3523 | * lpfc_get_host_speed: Set the value of the scsi host speed. | 3563 | * lpfc_get_host_speed - Set the value of the scsi host speed |
3524 | * @shost: kernel scsi host pointer. | 3564 | * @shost: kernel scsi host pointer. |
3525 | **/ | 3565 | **/ |
3526 | static void | 3566 | static void |
@@ -3556,7 +3596,7 @@ lpfc_get_host_speed(struct Scsi_Host *shost) | |||
3556 | } | 3596 | } |
3557 | 3597 | ||
3558 | /** | 3598 | /** |
3559 | * lpfc_get_host_fabric_name: Set the value of the scsi host fabric name. | 3599 | * lpfc_get_host_fabric_name - Set the value of the scsi host fabric name |
3560 | * @shost: kernel scsi host pointer. | 3600 | * @shost: kernel scsi host pointer. |
3561 | **/ | 3601 | **/ |
3562 | static void | 3602 | static void |
@@ -3582,7 +3622,7 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost) | |||
3582 | } | 3622 | } |
3583 | 3623 | ||
3584 | /** | 3624 | /** |
3585 | * lpfc_get_stats: Return statistical information about the adapter. | 3625 | * lpfc_get_stats - Return statistical information about the adapter |
3586 | * @shost: kernel scsi host pointer. | 3626 | * @shost: kernel scsi host pointer. |
3587 | * | 3627 | * |
3588 | * Notes: | 3628 | * Notes: |
@@ -3707,7 +3747,7 @@ lpfc_get_stats(struct Scsi_Host *shost) | |||
3707 | } | 3747 | } |
3708 | 3748 | ||
3709 | /** | 3749 | /** |
3710 | * lpfc_reset_stats: Copy the adapter link stats information. | 3750 | * lpfc_reset_stats - Copy the adapter link stats information |
3711 | * @shost: kernel scsi host pointer. | 3751 | * @shost: kernel scsi host pointer. |
3712 | **/ | 3752 | **/ |
3713 | static void | 3753 | static void |
@@ -3788,7 +3828,7 @@ lpfc_reset_stats(struct Scsi_Host *shost) | |||
3788 | */ | 3828 | */ |
3789 | 3829 | ||
3790 | /** | 3830 | /** |
3791 | * lpfc_get_node_by_target: Return the nodelist for a target. | 3831 | * lpfc_get_node_by_target - Return the nodelist for a target |
3792 | * @starget: kernel scsi target pointer. | 3832 | * @starget: kernel scsi target pointer. |
3793 | * | 3833 | * |
3794 | * Returns: | 3834 | * Returns: |
@@ -3817,7 +3857,7 @@ lpfc_get_node_by_target(struct scsi_target *starget) | |||
3817 | } | 3857 | } |
3818 | 3858 | ||
3819 | /** | 3859 | /** |
3820 | * lpfc_get_starget_port_id: Set the target port id to the ndlp DID or -1. | 3860 | * lpfc_get_starget_port_id - Set the target port id to the ndlp DID or -1 |
3821 | * @starget: kernel scsi target pointer. | 3861 | * @starget: kernel scsi target pointer. |
3822 | **/ | 3862 | **/ |
3823 | static void | 3863 | static void |
@@ -3829,7 +3869,7 @@ lpfc_get_starget_port_id(struct scsi_target *starget) | |||
3829 | } | 3869 | } |
3830 | 3870 | ||
3831 | /** | 3871 | /** |
3832 | * lpfc_get_starget_node_name: Set the target node name. | 3872 | * lpfc_get_starget_node_name - Set the target node name |
3833 | * @starget: kernel scsi target pointer. | 3873 | * @starget: kernel scsi target pointer. |
3834 | * | 3874 | * |
3835 | * Description: Set the target node name to the ndlp node name wwn or zero. | 3875 | * Description: Set the target node name to the ndlp node name wwn or zero. |
@@ -3844,7 +3884,7 @@ lpfc_get_starget_node_name(struct scsi_target *starget) | |||
3844 | } | 3884 | } |
3845 | 3885 | ||
3846 | /** | 3886 | /** |
3847 | * lpfc_get_starget_port_name: Set the target port name. | 3887 | * lpfc_get_starget_port_name - Set the target port name |
3848 | * @starget: kernel scsi target pointer. | 3888 | * @starget: kernel scsi target pointer. |
3849 | * | 3889 | * |
3850 | * Description: set the target port name to the ndlp port name wwn or zero. | 3890 | * Description: set the target port name to the ndlp port name wwn or zero. |
@@ -3859,7 +3899,7 @@ lpfc_get_starget_port_name(struct scsi_target *starget) | |||
3859 | } | 3899 | } |
3860 | 3900 | ||
3861 | /** | 3901 | /** |
3862 | * lpfc_set_rport_loss_tmo: Set the rport dev loss tmo. | 3902 | * lpfc_set_rport_loss_tmo - Set the rport dev loss tmo |
3863 | * @rport: fc rport address. | 3903 | * @rport: fc rport address. |
3864 | * @timeout: new value for dev loss tmo. | 3904 | * @timeout: new value for dev loss tmo. |
3865 | * | 3905 | * |
@@ -3877,7 +3917,7 @@ lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | |||
3877 | } | 3917 | } |
3878 | 3918 | ||
3879 | /** | 3919 | /** |
3880 | * lpfc_rport_show_function: Return rport target information. | 3920 | * lpfc_rport_show_function - Return rport target information |
3881 | * | 3921 | * |
3882 | * Description: | 3922 | * Description: |
3883 | * Macro that uses field to generate a function with the name lpfc_show_rport_ | 3923 | * Macro that uses field to generate a function with the name lpfc_show_rport_ |
@@ -3905,7 +3945,7 @@ lpfc_show_rport_##field (struct device *dev, \ | |||
3905 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) | 3945 | static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL) |
3906 | 3946 | ||
3907 | /** | 3947 | /** |
3908 | * lpfc_set_vport_symbolic_name: Set the vport's symbolic name. | 3948 | * lpfc_set_vport_symbolic_name - Set the vport's symbolic name |
3909 | * @fc_vport: The fc_vport who's symbolic name has been changed. | 3949 | * @fc_vport: The fc_vport who's symbolic name has been changed. |
3910 | * | 3950 | * |
3911 | * Description: | 3951 | * Description: |
@@ -4048,7 +4088,7 @@ struct fc_function_template lpfc_vport_transport_functions = { | |||
4048 | }; | 4088 | }; |
4049 | 4089 | ||
4050 | /** | 4090 | /** |
4051 | * lpfc_get_cfgparam: Used during probe_one to init the adapter structure. | 4091 | * lpfc_get_cfgparam - Used during probe_one to init the adapter structure |
4052 | * @phba: lpfc_hba pointer. | 4092 | * @phba: lpfc_hba pointer. |
4053 | **/ | 4093 | **/ |
4054 | void | 4094 | void |
@@ -4097,7 +4137,7 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) | |||
4097 | } | 4137 | } |
4098 | 4138 | ||
4099 | /** | 4139 | /** |
4100 | * lpfc_get_vport_cfgparam: Used during port create, init the vport structure. | 4140 | * lpfc_get_vport_cfgparam - Used during port create, init the vport structure |
4101 | * @vport: lpfc_vport pointer. | 4141 | * @vport: lpfc_vport pointer. |
4102 | **/ | 4142 | **/ |
4103 | void | 4143 | void |
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 07f4976319a5..f88ce3f26190 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h | |||
@@ -184,6 +184,8 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *); | |||
184 | struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *); | 184 | struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *); |
185 | void lpfc_sli_release_iocbq(struct lpfc_hba *, struct lpfc_iocbq *); | 185 | void lpfc_sli_release_iocbq(struct lpfc_hba *, struct lpfc_iocbq *); |
186 | uint16_t lpfc_sli_next_iotag(struct lpfc_hba *, struct lpfc_iocbq *); | 186 | uint16_t lpfc_sli_next_iotag(struct lpfc_hba *, struct lpfc_iocbq *); |
187 | void lpfc_sli_cancel_iocbs(struct lpfc_hba *, struct list_head *, uint32_t, | ||
188 | uint32_t); | ||
187 | 189 | ||
188 | void lpfc_reset_barrier(struct lpfc_hba * phba); | 190 | void lpfc_reset_barrier(struct lpfc_hba * phba); |
189 | int lpfc_sli_brdready(struct lpfc_hba *, uint32_t); | 191 | int lpfc_sli_brdready(struct lpfc_hba *, uint32_t); |
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index 81cdcf46c471..52be5644e07a 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include "lpfc_debugfs.h" | 47 | #include "lpfc_debugfs.h" |
48 | 48 | ||
49 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 49 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
50 | /** | 50 | /* |
51 | * debugfs interface | 51 | * debugfs interface |
52 | * | 52 | * |
53 | * To access this interface the user should: | 53 | * To access this interface the user should: |
@@ -95,7 +95,7 @@ module_param(lpfc_debugfs_max_slow_ring_trc, int, 0); | |||
95 | MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, | 95 | MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc, |
96 | "Set debugfs slow ring trace depth"); | 96 | "Set debugfs slow ring trace depth"); |
97 | 97 | ||
98 | int lpfc_debugfs_mask_disc_trc; | 98 | static int lpfc_debugfs_mask_disc_trc; |
99 | module_param(lpfc_debugfs_mask_disc_trc, int, 0); | 99 | module_param(lpfc_debugfs_mask_disc_trc, int, 0); |
100 | MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, | 100 | MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, |
101 | "Set debugfs discovery trace mask"); | 101 | "Set debugfs discovery trace mask"); |
@@ -127,7 +127,7 @@ static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0); | |||
127 | static unsigned long lpfc_debugfs_start_time = 0L; | 127 | static unsigned long lpfc_debugfs_start_time = 0L; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer. | 130 | * lpfc_debugfs_disc_trc_data - Dump discovery logging to a buffer |
131 | * @vport: The vport to gather the log info from. | 131 | * @vport: The vport to gather the log info from. |
132 | * @buf: The buffer to dump log into. | 132 | * @buf: The buffer to dump log into. |
133 | * @size: The maximum amount of data to process. | 133 | * @size: The maximum amount of data to process. |
@@ -187,7 +187,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) | |||
187 | } | 187 | } |
188 | 188 | ||
189 | /** | 189 | /** |
190 | * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer. | 190 | * lpfc_debugfs_slow_ring_trc_data - Dump slow ring logging to a buffer |
191 | * @phba: The HBA to gather the log info from. | 191 | * @phba: The HBA to gather the log info from. |
192 | * @buf: The buffer to dump log into. | 192 | * @buf: The buffer to dump log into. |
193 | * @size: The maximum amount of data to process. | 193 | * @size: The maximum amount of data to process. |
@@ -250,7 +250,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size) | |||
250 | static int lpfc_debugfs_last_hbq = -1; | 250 | static int lpfc_debugfs_last_hbq = -1; |
251 | 251 | ||
252 | /** | 252 | /** |
253 | * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer. | 253 | * lpfc_debugfs_hbqinfo_data - Dump host buffer queue info to a buffer |
254 | * @phba: The HBA to gather host buffer info from. | 254 | * @phba: The HBA to gather host buffer info from. |
255 | * @buf: The buffer to dump log into. | 255 | * @buf: The buffer to dump log into. |
256 | * @size: The maximum amount of data to process. | 256 | * @size: The maximum amount of data to process. |
@@ -369,7 +369,7 @@ skipit: | |||
369 | static int lpfc_debugfs_last_hba_slim_off; | 369 | static int lpfc_debugfs_last_hba_slim_off; |
370 | 370 | ||
371 | /** | 371 | /** |
372 | * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer. | 372 | * lpfc_debugfs_dumpHBASlim_data - Dump HBA SLIM info to a buffer |
373 | * @phba: The HBA to gather SLIM info from. | 373 | * @phba: The HBA to gather SLIM info from. |
374 | * @buf: The buffer to dump log into. | 374 | * @buf: The buffer to dump log into. |
375 | * @size: The maximum amount of data to process. | 375 | * @size: The maximum amount of data to process. |
@@ -399,8 +399,7 @@ lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size) | |||
399 | 399 | ||
400 | len += snprintf(buf+len, size-len, "HBA SLIM\n"); | 400 | len += snprintf(buf+len, size-len, "HBA SLIM\n"); |
401 | lpfc_memcpy_from_slim(buffer, | 401 | lpfc_memcpy_from_slim(buffer, |
402 | ((uint8_t *)phba->MBslimaddr) + lpfc_debugfs_last_hba_slim_off, | 402 | phba->MBslimaddr + lpfc_debugfs_last_hba_slim_off, 1024); |
403 | 1024); | ||
404 | 403 | ||
405 | ptr = (uint32_t *)&buffer[0]; | 404 | ptr = (uint32_t *)&buffer[0]; |
406 | off = lpfc_debugfs_last_hba_slim_off; | 405 | off = lpfc_debugfs_last_hba_slim_off; |
@@ -426,7 +425,7 @@ lpfc_debugfs_dumpHBASlim_data(struct lpfc_hba *phba, char *buf, int size) | |||
426 | } | 425 | } |
427 | 426 | ||
428 | /** | 427 | /** |
429 | * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer. | 428 | * lpfc_debugfs_dumpHostSlim_data - Dump host SLIM info to a buffer |
430 | * @phba: The HBA to gather Host SLIM info from. | 429 | * @phba: The HBA to gather Host SLIM info from. |
431 | * @buf: The buffer to dump log into. | 430 | * @buf: The buffer to dump log into. |
432 | * @size: The maximum amount of data to process. | 431 | * @size: The maximum amount of data to process. |
@@ -501,7 +500,7 @@ lpfc_debugfs_dumpHostSlim_data(struct lpfc_hba *phba, char *buf, int size) | |||
501 | } | 500 | } |
502 | 501 | ||
503 | /** | 502 | /** |
504 | * lpfc_debugfs_nodelist_data - Dump target node list to a buffer. | 503 | * lpfc_debugfs_nodelist_data - Dump target node list to a buffer |
505 | * @vport: The vport to gather target node info from. | 504 | * @vport: The vport to gather target node info from. |
506 | * @buf: The buffer to dump log into. | 505 | * @buf: The buffer to dump log into. |
507 | * @size: The maximum amount of data to process. | 506 | * @size: The maximum amount of data to process. |
@@ -599,7 +598,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) | |||
599 | #endif | 598 | #endif |
600 | 599 | ||
601 | /** | 600 | /** |
602 | * lpfc_debugfs_disc_trc - Store discovery trace log. | 601 | * lpfc_debugfs_disc_trc - Store discovery trace log |
603 | * @vport: The vport to associate this trace string with for retrieval. | 602 | * @vport: The vport to associate this trace string with for retrieval. |
604 | * @mask: Log entry classification. | 603 | * @mask: Log entry classification. |
605 | * @fmt: Format string to be displayed when dumping the log. | 604 | * @fmt: Format string to be displayed when dumping the log. |
@@ -643,7 +642,7 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt, | |||
643 | } | 642 | } |
644 | 643 | ||
645 | /** | 644 | /** |
646 | * lpfc_debugfs_slow_ring_trc - Store slow ring trace log. | 645 | * lpfc_debugfs_slow_ring_trc - Store slow ring trace log |
647 | * @phba: The phba to associate this trace string with for retrieval. | 646 | * @phba: The phba to associate this trace string with for retrieval. |
648 | * @fmt: Format string to be displayed when dumping the log. | 647 | * @fmt: Format string to be displayed when dumping the log. |
649 | * @data1: 1st data parameter to be applied to @fmt. | 648 | * @data1: 1st data parameter to be applied to @fmt. |
@@ -682,7 +681,7 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt, | |||
682 | 681 | ||
683 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 682 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
684 | /** | 683 | /** |
685 | * lpfc_debugfs_disc_trc_open - Open the discovery trace log. | 684 | * lpfc_debugfs_disc_trc_open - Open the discovery trace log |
686 | * @inode: The inode pointer that contains a vport pointer. | 685 | * @inode: The inode pointer that contains a vport pointer. |
687 | * @file: The file pointer to attach the log output. | 686 | * @file: The file pointer to attach the log output. |
688 | * | 687 | * |
@@ -732,7 +731,7 @@ out: | |||
732 | } | 731 | } |
733 | 732 | ||
734 | /** | 733 | /** |
735 | * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log. | 734 | * lpfc_debugfs_slow_ring_trc_open - Open the Slow Ring trace log |
736 | * @inode: The inode pointer that contains a vport pointer. | 735 | * @inode: The inode pointer that contains a vport pointer. |
737 | * @file: The file pointer to attach the log output. | 736 | * @file: The file pointer to attach the log output. |
738 | * | 737 | * |
@@ -782,7 +781,7 @@ out: | |||
782 | } | 781 | } |
783 | 782 | ||
784 | /** | 783 | /** |
785 | * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer. | 784 | * lpfc_debugfs_hbqinfo_open - Open the hbqinfo debugfs buffer |
786 | * @inode: The inode pointer that contains a vport pointer. | 785 | * @inode: The inode pointer that contains a vport pointer. |
787 | * @file: The file pointer to attach the log output. | 786 | * @file: The file pointer to attach the log output. |
788 | * | 787 | * |
@@ -824,7 +823,7 @@ out: | |||
824 | } | 823 | } |
825 | 824 | ||
826 | /** | 825 | /** |
827 | * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer. | 826 | * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer |
828 | * @inode: The inode pointer that contains a vport pointer. | 827 | * @inode: The inode pointer that contains a vport pointer. |
829 | * @file: The file pointer to attach the log output. | 828 | * @file: The file pointer to attach the log output. |
830 | * | 829 | * |
@@ -866,7 +865,7 @@ out: | |||
866 | } | 865 | } |
867 | 866 | ||
868 | /** | 867 | /** |
869 | * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer. | 868 | * lpfc_debugfs_dumpHostSlim_open - Open the Dump Host SLIM debugfs buffer |
870 | * @inode: The inode pointer that contains a vport pointer. | 869 | * @inode: The inode pointer that contains a vport pointer. |
871 | * @file: The file pointer to attach the log output. | 870 | * @file: The file pointer to attach the log output. |
872 | * | 871 | * |
@@ -993,7 +992,7 @@ lpfc_debugfs_dumpDataDif_write(struct file *file, const char __user *buf, | |||
993 | 992 | ||
994 | 993 | ||
995 | /** | 994 | /** |
996 | * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file. | 995 | * lpfc_debugfs_nodelist_open - Open the nodelist debugfs file |
997 | * @inode: The inode pointer that contains a vport pointer. | 996 | * @inode: The inode pointer that contains a vport pointer. |
998 | * @file: The file pointer to attach the log output. | 997 | * @file: The file pointer to attach the log output. |
999 | * | 998 | * |
@@ -1035,7 +1034,7 @@ out: | |||
1035 | } | 1034 | } |
1036 | 1035 | ||
1037 | /** | 1036 | /** |
1038 | * lpfc_debugfs_lseek - Seek through a debugfs file. | 1037 | * lpfc_debugfs_lseek - Seek through a debugfs file |
1039 | * @file: The file pointer to seek through. | 1038 | * @file: The file pointer to seek through. |
1040 | * @off: The offset to seek to or the amount to seek by. | 1039 | * @off: The offset to seek to or the amount to seek by. |
1041 | * @whence: Indicates how to seek. | 1040 | * @whence: Indicates how to seek. |
@@ -1073,7 +1072,7 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence) | |||
1073 | } | 1072 | } |
1074 | 1073 | ||
1075 | /** | 1074 | /** |
1076 | * lpfc_debugfs_read - Read a debugfs file. | 1075 | * lpfc_debugfs_read - Read a debugfs file |
1077 | * @file: The file pointer to read from. | 1076 | * @file: The file pointer to read from. |
1078 | * @buf: The buffer to copy the data to. | 1077 | * @buf: The buffer to copy the data to. |
1079 | * @nbytes: The number of bytes to read. | 1078 | * @nbytes: The number of bytes to read. |
@@ -1098,7 +1097,7 @@ lpfc_debugfs_read(struct file *file, char __user *buf, | |||
1098 | } | 1097 | } |
1099 | 1098 | ||
1100 | /** | 1099 | /** |
1101 | * lpfc_debugfs_release - Release the buffer used to store debugfs file data. | 1100 | * lpfc_debugfs_release - Release the buffer used to store debugfs file data |
1102 | * @inode: The inode pointer that contains a vport pointer. (unused) | 1101 | * @inode: The inode pointer that contains a vport pointer. (unused) |
1103 | * @file: The file pointer that contains the buffer to release. | 1102 | * @file: The file pointer that contains the buffer to release. |
1104 | * | 1103 | * |
@@ -1210,7 +1209,7 @@ static atomic_t lpfc_debugfs_hba_count; | |||
1210 | #endif | 1209 | #endif |
1211 | 1210 | ||
1212 | /** | 1211 | /** |
1213 | * lpfc_debugfs_initialize - Initialize debugfs for a vport. | 1212 | * lpfc_debugfs_initialize - Initialize debugfs for a vport |
1214 | * @vport: The vport pointer to initialize. | 1213 | * @vport: The vport pointer to initialize. |
1215 | * | 1214 | * |
1216 | * Description: | 1215 | * Description: |
@@ -1434,7 +1433,7 @@ debug_failed: | |||
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | /** | 1435 | /** |
1437 | * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport. | 1436 | * lpfc_debugfs_terminate - Tear down debugfs infrastructure for this vport |
1438 | * @vport: The vport pointer to remove from debugfs. | 1437 | * @vport: The vport pointer to remove from debugfs. |
1439 | * | 1438 | * |
1440 | * Description: | 1439 | * Description: |
diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index f29e548a90d1..ffd108972072 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h | |||
@@ -99,6 +99,7 @@ struct lpfc_nodelist { | |||
99 | #define NLP_USG_FREE_ACK_BIT 0x8 /* Indicate ndlp memory free invoked */ | 99 | #define NLP_USG_FREE_ACK_BIT 0x8 /* Indicate ndlp memory free invoked */ |
100 | 100 | ||
101 | struct timer_list nlp_delayfunc; /* Used for delayed ELS cmds */ | 101 | struct timer_list nlp_delayfunc; /* Used for delayed ELS cmds */ |
102 | struct lpfc_hba *phba; | ||
102 | struct fc_rport *rport; /* Corresponding FC transport | 103 | struct fc_rport *rport; /* Corresponding FC transport |
103 | port structure */ | 104 | port structure */ |
104 | struct lpfc_vport *vport; | 105 | struct lpfc_vport *vport; |
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index a7302480bc4a..b8b34cf5c3d2 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c | |||
@@ -55,7 +55,7 @@ static void lpfc_register_new_vport(struct lpfc_hba *phba, | |||
55 | static int lpfc_max_els_tries = 3; | 55 | static int lpfc_max_els_tries = 3; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * lpfc_els_chk_latt: Check host link attention event for a vport. | 58 | * lpfc_els_chk_latt - Check host link attention event for a vport |
59 | * @vport: pointer to a host virtual N_Port data structure. | 59 | * @vport: pointer to a host virtual N_Port data structure. |
60 | * | 60 | * |
61 | * This routine checks whether there is an outstanding host link | 61 | * This routine checks whether there is an outstanding host link |
@@ -116,7 +116,7 @@ lpfc_els_chk_latt(struct lpfc_vport *vport) | |||
116 | } | 116 | } |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * lpfc_prep_els_iocb: Allocate and prepare a lpfc iocb data structure. | 119 | * lpfc_prep_els_iocb - Allocate and prepare a lpfc iocb data structure |
120 | * @vport: pointer to a host virtual N_Port data structure. | 120 | * @vport: pointer to a host virtual N_Port data structure. |
121 | * @expectRsp: flag indicating whether response is expected. | 121 | * @expectRsp: flag indicating whether response is expected. |
122 | * @cmdSize: size of the ELS command. | 122 | * @cmdSize: size of the ELS command. |
@@ -290,7 +290,7 @@ els_iocb_free_pcmb_exit: | |||
290 | } | 290 | } |
291 | 291 | ||
292 | /** | 292 | /** |
293 | * lpfc_issue_fabric_reglogin: Issue fabric registration login for a vport. | 293 | * lpfc_issue_fabric_reglogin - Issue fabric registration login for a vport |
294 | * @vport: pointer to a host virtual N_Port data structure. | 294 | * @vport: pointer to a host virtual N_Port data structure. |
295 | * | 295 | * |
296 | * This routine issues a fabric registration login for a @vport. An | 296 | * This routine issues a fabric registration login for a @vport. An |
@@ -386,7 +386,7 @@ fail: | |||
386 | } | 386 | } |
387 | 387 | ||
388 | /** | 388 | /** |
389 | * lpfc_cmpl_els_flogi_fabric: Completion function for flogi to a fabric port. | 389 | * lpfc_cmpl_els_flogi_fabric - Completion function for flogi to a fabric port |
390 | * @vport: pointer to a host virtual N_Port data structure. | 390 | * @vport: pointer to a host virtual N_Port data structure. |
391 | * @ndlp: pointer to a node-list data structure. | 391 | * @ndlp: pointer to a node-list data structure. |
392 | * @sp: pointer to service parameter data structure. | 392 | * @sp: pointer to service parameter data structure. |
@@ -509,7 +509,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
509 | } | 509 | } |
510 | 510 | ||
511 | /** | 511 | /** |
512 | * lpfc_cmpl_els_flogi_nport: Completion function for flogi to an N_Port. | 512 | * lpfc_cmpl_els_flogi_nport - Completion function for flogi to an N_Port |
513 | * @vport: pointer to a host virtual N_Port data structure. | 513 | * @vport: pointer to a host virtual N_Port data structure. |
514 | * @ndlp: pointer to a node-list data structure. | 514 | * @ndlp: pointer to a node-list data structure. |
515 | * @sp: pointer to service parameter data structure. | 515 | * @sp: pointer to service parameter data structure. |
@@ -626,7 +626,7 @@ fail: | |||
626 | } | 626 | } |
627 | 627 | ||
628 | /** | 628 | /** |
629 | * lpfc_cmpl_els_flogi: Completion callback function for flogi. | 629 | * lpfc_cmpl_els_flogi - Completion callback function for flogi |
630 | * @phba: pointer to lpfc hba data structure. | 630 | * @phba: pointer to lpfc hba data structure. |
631 | * @cmdiocb: pointer to lpfc command iocb data structure. | 631 | * @cmdiocb: pointer to lpfc command iocb data structure. |
632 | * @rspiocb: pointer to lpfc response iocb data structure. | 632 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -751,7 +751,7 @@ out: | |||
751 | } | 751 | } |
752 | 752 | ||
753 | /** | 753 | /** |
754 | * lpfc_issue_els_flogi: Issue an flogi iocb command for a vport. | 754 | * lpfc_issue_els_flogi - Issue an flogi iocb command for a vport |
755 | * @vport: pointer to a host virtual N_Port data structure. | 755 | * @vport: pointer to a host virtual N_Port data structure. |
756 | * @ndlp: pointer to a node-list data structure. | 756 | * @ndlp: pointer to a node-list data structure. |
757 | * @retry: number of retries to the command IOCB. | 757 | * @retry: number of retries to the command IOCB. |
@@ -849,7 +849,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
849 | } | 849 | } |
850 | 850 | ||
851 | /** | 851 | /** |
852 | * lpfc_els_abort_flogi: Abort all outstanding flogi iocbs. | 852 | * lpfc_els_abort_flogi - Abort all outstanding flogi iocbs |
853 | * @phba: pointer to lpfc hba data structure. | 853 | * @phba: pointer to lpfc hba data structure. |
854 | * | 854 | * |
855 | * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs | 855 | * This routine aborts all the outstanding Fabric Login (FLOGI) IOCBs |
@@ -898,7 +898,7 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba) | |||
898 | } | 898 | } |
899 | 899 | ||
900 | /** | 900 | /** |
901 | * lpfc_initial_flogi: Issue an initial fabric login for a vport. | 901 | * lpfc_initial_flogi - Issue an initial fabric login for a vport |
902 | * @vport: pointer to a host virtual N_Port data structure. | 902 | * @vport: pointer to a host virtual N_Port data structure. |
903 | * | 903 | * |
904 | * This routine issues an initial Fabric Login (FLOGI) for the @vport | 904 | * This routine issues an initial Fabric Login (FLOGI) for the @vport |
@@ -949,7 +949,7 @@ lpfc_initial_flogi(struct lpfc_vport *vport) | |||
949 | } | 949 | } |
950 | 950 | ||
951 | /** | 951 | /** |
952 | * lpfc_initial_fdisc: Issue an initial fabric discovery for a vport. | 952 | * lpfc_initial_fdisc - Issue an initial fabric discovery for a vport |
953 | * @vport: pointer to a host virtual N_Port data structure. | 953 | * @vport: pointer to a host virtual N_Port data structure. |
954 | * | 954 | * |
955 | * This routine issues an initial Fabric Discover (FDISC) for the @vport | 955 | * This routine issues an initial Fabric Discover (FDISC) for the @vport |
@@ -998,7 +998,7 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) | |||
998 | } | 998 | } |
999 | 999 | ||
1000 | /** | 1000 | /** |
1001 | * lpfc_more_plogi: Check and issue remaining plogis for a vport. | 1001 | * lpfc_more_plogi - Check and issue remaining plogis for a vport |
1002 | * @vport: pointer to a host virtual N_Port data structure. | 1002 | * @vport: pointer to a host virtual N_Port data structure. |
1003 | * | 1003 | * |
1004 | * This routine checks whether there are more remaining Port Logins | 1004 | * This routine checks whether there are more remaining Port Logins |
@@ -1031,7 +1031,7 @@ lpfc_more_plogi(struct lpfc_vport *vport) | |||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | /** | 1033 | /** |
1034 | * lpfc_plogi_confirm_nport: Confirm pologi wwpn matches stored ndlp. | 1034 | * lpfc_plogi_confirm_nport - Confirm pologi wwpn matches stored ndlp |
1035 | * @phba: pointer to lpfc hba data structure. | 1035 | * @phba: pointer to lpfc hba data structure. |
1036 | * @prsp: pointer to response IOCB payload. | 1036 | * @prsp: pointer to response IOCB payload. |
1037 | * @ndlp: pointer to a node-list data structure. | 1037 | * @ndlp: pointer to a node-list data structure. |
@@ -1165,7 +1165,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, | |||
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | /** | 1167 | /** |
1168 | * lpfc_end_rscn: Check and handle more rscn for a vport. | 1168 | * lpfc_end_rscn - Check and handle more rscn for a vport |
1169 | * @vport: pointer to a host virtual N_Port data structure. | 1169 | * @vport: pointer to a host virtual N_Port data structure. |
1170 | * | 1170 | * |
1171 | * This routine checks whether more Registration State Change | 1171 | * This routine checks whether more Registration State Change |
@@ -1197,7 +1197,7 @@ lpfc_end_rscn(struct lpfc_vport *vport) | |||
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | /** | 1199 | /** |
1200 | * lpfc_cmpl_els_plogi: Completion callback function for plogi. | 1200 | * lpfc_cmpl_els_plogi - Completion callback function for plogi |
1201 | * @phba: pointer to lpfc hba data structure. | 1201 | * @phba: pointer to lpfc hba data structure. |
1202 | * @cmdiocb: pointer to lpfc command iocb data structure. | 1202 | * @cmdiocb: pointer to lpfc command iocb data structure. |
1203 | * @rspiocb: pointer to lpfc response iocb data structure. | 1203 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -1322,7 +1322,7 @@ out: | |||
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | /** | 1324 | /** |
1325 | * lpfc_issue_els_plogi: Issue an plogi iocb command for a vport. | 1325 | * lpfc_issue_els_plogi - Issue an plogi iocb command for a vport |
1326 | * @vport: pointer to a host virtual N_Port data structure. | 1326 | * @vport: pointer to a host virtual N_Port data structure. |
1327 | * @did: destination port identifier. | 1327 | * @did: destination port identifier. |
1328 | * @retry: number of retries to the command IOCB. | 1328 | * @retry: number of retries to the command IOCB. |
@@ -1401,7 +1401,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) | |||
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | /** | 1403 | /** |
1404 | * lpfc_cmpl_els_prli: Completion callback function for prli. | 1404 | * lpfc_cmpl_els_prli - Completion callback function for prli |
1405 | * @phba: pointer to lpfc hba data structure. | 1405 | * @phba: pointer to lpfc hba data structure. |
1406 | * @cmdiocb: pointer to lpfc command iocb data structure. | 1406 | * @cmdiocb: pointer to lpfc command iocb data structure. |
1407 | * @rspiocb: pointer to lpfc response iocb data structure. | 1407 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -1472,7 +1472,7 @@ out: | |||
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | /** | 1474 | /** |
1475 | * lpfc_issue_els_prli: Issue a prli iocb command for a vport. | 1475 | * lpfc_issue_els_prli - Issue a prli iocb command for a vport |
1476 | * @vport: pointer to a host virtual N_Port data structure. | 1476 | * @vport: pointer to a host virtual N_Port data structure. |
1477 | * @ndlp: pointer to a node-list data structure. | 1477 | * @ndlp: pointer to a node-list data structure. |
1478 | * @retry: number of retries to the command IOCB. | 1478 | * @retry: number of retries to the command IOCB. |
@@ -1562,7 +1562,7 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | /** | 1564 | /** |
1565 | * lpfc_rscn_disc: Perform rscn discovery for a vport. | 1565 | * lpfc_rscn_disc - Perform rscn discovery for a vport |
1566 | * @vport: pointer to a host virtual N_Port data structure. | 1566 | * @vport: pointer to a host virtual N_Port data structure. |
1567 | * | 1567 | * |
1568 | * This routine performs Registration State Change Notification (RSCN) | 1568 | * This routine performs Registration State Change Notification (RSCN) |
@@ -1588,7 +1588,7 @@ lpfc_rscn_disc(struct lpfc_vport *vport) | |||
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | /** | 1590 | /** |
1591 | * lpfc_adisc_done: Complete the adisc phase of discovery. | 1591 | * lpfc_adisc_done - Complete the adisc phase of discovery |
1592 | * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. | 1592 | * @vport: pointer to lpfc_vport hba data structure that finished all ADISCs. |
1593 | * | 1593 | * |
1594 | * This function is called when the final ADISC is completed during discovery. | 1594 | * This function is called when the final ADISC is completed during discovery. |
@@ -1639,7 +1639,7 @@ lpfc_adisc_done(struct lpfc_vport *vport) | |||
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | /** | 1641 | /** |
1642 | * lpfc_more_adisc: Issue more adisc as needed. | 1642 | * lpfc_more_adisc - Issue more adisc as needed |
1643 | * @vport: pointer to a host virtual N_Port data structure. | 1643 | * @vport: pointer to a host virtual N_Port data structure. |
1644 | * | 1644 | * |
1645 | * This routine determines whether there are more ndlps on a @vport | 1645 | * This routine determines whether there are more ndlps on a @vport |
@@ -1672,7 +1672,7 @@ lpfc_more_adisc(struct lpfc_vport *vport) | |||
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | /** | 1674 | /** |
1675 | * lpfc_cmpl_els_adisc: Completion callback function for adisc. | 1675 | * lpfc_cmpl_els_adisc - Completion callback function for adisc |
1676 | * @phba: pointer to lpfc hba data structure. | 1676 | * @phba: pointer to lpfc hba data structure. |
1677 | * @cmdiocb: pointer to lpfc command iocb data structure. | 1677 | * @cmdiocb: pointer to lpfc command iocb data structure. |
1678 | * @rspiocb: pointer to lpfc response iocb data structure. | 1678 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -1760,7 +1760,7 @@ out: | |||
1760 | } | 1760 | } |
1761 | 1761 | ||
1762 | /** | 1762 | /** |
1763 | * lpfc_issue_els_adisc: Issue an address discover iocb to an node on a vport. | 1763 | * lpfc_issue_els_adisc - Issue an address discover iocb to an node on a vport |
1764 | * @vport: pointer to a virtual N_Port data structure. | 1764 | * @vport: pointer to a virtual N_Port data structure. |
1765 | * @ndlp: pointer to a node-list data structure. | 1765 | * @ndlp: pointer to a node-list data structure. |
1766 | * @retry: number of retries to the command IOCB. | 1766 | * @retry: number of retries to the command IOCB. |
@@ -1833,7 +1833,7 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | /** | 1835 | /** |
1836 | * lpfc_cmpl_els_logo: Completion callback function for logo. | 1836 | * lpfc_cmpl_els_logo - Completion callback function for logo |
1837 | * @phba: pointer to lpfc hba data structure. | 1837 | * @phba: pointer to lpfc hba data structure. |
1838 | * @cmdiocb: pointer to lpfc command iocb data structure. | 1838 | * @cmdiocb: pointer to lpfc command iocb data structure. |
1839 | * @rspiocb: pointer to lpfc response iocb data structure. | 1839 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -1910,7 +1910,7 @@ out: | |||
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | /** | 1912 | /** |
1913 | * lpfc_issue_els_logo: Issue a logo to an node on a vport. | 1913 | * lpfc_issue_els_logo - Issue a logo to an node on a vport |
1914 | * @vport: pointer to a virtual N_Port data structure. | 1914 | * @vport: pointer to a virtual N_Port data structure. |
1915 | * @ndlp: pointer to a node-list data structure. | 1915 | * @ndlp: pointer to a node-list data structure. |
1916 | * @retry: number of retries to the command IOCB. | 1916 | * @retry: number of retries to the command IOCB. |
@@ -1991,7 +1991,7 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
1991 | } | 1991 | } |
1992 | 1992 | ||
1993 | /** | 1993 | /** |
1994 | * lpfc_cmpl_els_cmd: Completion callback function for generic els command. | 1994 | * lpfc_cmpl_els_cmd - Completion callback function for generic els command |
1995 | * @phba: pointer to lpfc hba data structure. | 1995 | * @phba: pointer to lpfc hba data structure. |
1996 | * @cmdiocb: pointer to lpfc command iocb data structure. | 1996 | * @cmdiocb: pointer to lpfc command iocb data structure. |
1997 | * @rspiocb: pointer to lpfc response iocb data structure. | 1997 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -2031,7 +2031,7 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | /** | 2033 | /** |
2034 | * lpfc_issue_els_scr: Issue a scr to an node on a vport. | 2034 | * lpfc_issue_els_scr - Issue a scr to an node on a vport |
2035 | * @vport: pointer to a host virtual N_Port data structure. | 2035 | * @vport: pointer to a host virtual N_Port data structure. |
2036 | * @nportid: N_Port identifier to the remote node. | 2036 | * @nportid: N_Port identifier to the remote node. |
2037 | * @retry: number of retries to the command IOCB. | 2037 | * @retry: number of retries to the command IOCB. |
@@ -2125,7 +2125,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |||
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | /** | 2127 | /** |
2128 | * lpfc_issue_els_farpr: Issue a farp to an node on a vport. | 2128 | * lpfc_issue_els_farpr - Issue a farp to an node on a vport |
2129 | * @vport: pointer to a host virtual N_Port data structure. | 2129 | * @vport: pointer to a host virtual N_Port data structure. |
2130 | * @nportid: N_Port identifier to the remote node. | 2130 | * @nportid: N_Port identifier to the remote node. |
2131 | * @retry: number of retries to the command IOCB. | 2131 | * @retry: number of retries to the command IOCB. |
@@ -2236,7 +2236,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) | |||
2236 | } | 2236 | } |
2237 | 2237 | ||
2238 | /** | 2238 | /** |
2239 | * lpfc_cancel_retry_delay_tmo: Cancel the timer with delayed iocb-cmd retry. | 2239 | * lpfc_cancel_retry_delay_tmo - Cancel the timer with delayed iocb-cmd retry |
2240 | * @vport: pointer to a host virtual N_Port data structure. | 2240 | * @vport: pointer to a host virtual N_Port data structure. |
2241 | * @nlp: pointer to a node-list data structure. | 2241 | * @nlp: pointer to a node-list data structure. |
2242 | * | 2242 | * |
@@ -2291,7 +2291,7 @@ lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp) | |||
2291 | } | 2291 | } |
2292 | 2292 | ||
2293 | /** | 2293 | /** |
2294 | * lpfc_els_retry_delay: Timer function with a ndlp delayed function timer. | 2294 | * lpfc_els_retry_delay - Timer function with a ndlp delayed function timer |
2295 | * @ptr: holder for the pointer to the timer function associated data (ndlp). | 2295 | * @ptr: holder for the pointer to the timer function associated data (ndlp). |
2296 | * | 2296 | * |
2297 | * This routine is invoked by the ndlp delayed-function timer to check | 2297 | * This routine is invoked by the ndlp delayed-function timer to check |
@@ -2333,7 +2333,7 @@ lpfc_els_retry_delay(unsigned long ptr) | |||
2333 | } | 2333 | } |
2334 | 2334 | ||
2335 | /** | 2335 | /** |
2336 | * lpfc_els_retry_delay_handler: Work thread handler for ndlp delayed function. | 2336 | * lpfc_els_retry_delay_handler - Work thread handler for ndlp delayed function |
2337 | * @ndlp: pointer to a node-list data structure. | 2337 | * @ndlp: pointer to a node-list data structure. |
2338 | * | 2338 | * |
2339 | * This routine is the worker-thread handler for processing the @ndlp delayed | 2339 | * This routine is the worker-thread handler for processing the @ndlp delayed |
@@ -2404,7 +2404,7 @@ lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp) | |||
2404 | } | 2404 | } |
2405 | 2405 | ||
2406 | /** | 2406 | /** |
2407 | * lpfc_els_retry: Make retry decision on an els command iocb. | 2407 | * lpfc_els_retry - Make retry decision on an els command iocb |
2408 | * @phba: pointer to lpfc hba data structure. | 2408 | * @phba: pointer to lpfc hba data structure. |
2409 | * @cmdiocb: pointer to lpfc command iocb data structure. | 2409 | * @cmdiocb: pointer to lpfc command iocb data structure. |
2410 | * @rspiocb: pointer to lpfc response iocb data structure. | 2410 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -2732,7 +2732,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
2732 | } | 2732 | } |
2733 | 2733 | ||
2734 | /** | 2734 | /** |
2735 | * lpfc_els_free_data: Free lpfc dma buffer and data structure with an iocb. | 2735 | * lpfc_els_free_data - Free lpfc dma buffer and data structure with an iocb |
2736 | * @phba: pointer to lpfc hba data structure. | 2736 | * @phba: pointer to lpfc hba data structure. |
2737 | * @buf_ptr1: pointer to the lpfc DMA buffer data structure. | 2737 | * @buf_ptr1: pointer to the lpfc DMA buffer data structure. |
2738 | * | 2738 | * |
@@ -2764,7 +2764,7 @@ lpfc_els_free_data(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr1) | |||
2764 | } | 2764 | } |
2765 | 2765 | ||
2766 | /** | 2766 | /** |
2767 | * lpfc_els_free_bpl: Free lpfc dma buffer and data structure with bpl. | 2767 | * lpfc_els_free_bpl - Free lpfc dma buffer and data structure with bpl |
2768 | * @phba: pointer to lpfc hba data structure. | 2768 | * @phba: pointer to lpfc hba data structure. |
2769 | * @buf_ptr: pointer to the lpfc dma buffer data structure. | 2769 | * @buf_ptr: pointer to the lpfc dma buffer data structure. |
2770 | * | 2770 | * |
@@ -2784,7 +2784,7 @@ lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) | |||
2784 | } | 2784 | } |
2785 | 2785 | ||
2786 | /** | 2786 | /** |
2787 | * lpfc_els_free_iocb: Free a command iocb and its associated resources. | 2787 | * lpfc_els_free_iocb - Free a command iocb and its associated resources |
2788 | * @phba: pointer to lpfc hba data structure. | 2788 | * @phba: pointer to lpfc hba data structure. |
2789 | * @elsiocb: pointer to lpfc els command iocb data structure. | 2789 | * @elsiocb: pointer to lpfc els command iocb data structure. |
2790 | * | 2790 | * |
@@ -2877,7 +2877,7 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) | |||
2877 | } | 2877 | } |
2878 | 2878 | ||
2879 | /** | 2879 | /** |
2880 | * lpfc_cmpl_els_logo_acc: Completion callback function to logo acc response. | 2880 | * lpfc_cmpl_els_logo_acc - Completion callback function to logo acc response |
2881 | * @phba: pointer to lpfc hba data structure. | 2881 | * @phba: pointer to lpfc hba data structure. |
2882 | * @cmdiocb: pointer to lpfc command iocb data structure. | 2882 | * @cmdiocb: pointer to lpfc command iocb data structure. |
2883 | * @rspiocb: pointer to lpfc response iocb data structure. | 2883 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -2931,7 +2931,7 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
2931 | } | 2931 | } |
2932 | 2932 | ||
2933 | /** | 2933 | /** |
2934 | * lpfc_mbx_cmpl_dflt_rpi: Completion callbk func for unreg dflt rpi mbox cmd. | 2934 | * lpfc_mbx_cmpl_dflt_rpi - Completion callbk func for unreg dflt rpi mbox cmd |
2935 | * @phba: pointer to lpfc hba data structure. | 2935 | * @phba: pointer to lpfc hba data structure. |
2936 | * @pmb: pointer to the driver internal queue element for mailbox command. | 2936 | * @pmb: pointer to the driver internal queue element for mailbox command. |
2937 | * | 2937 | * |
@@ -2965,7 +2965,7 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2965 | } | 2965 | } |
2966 | 2966 | ||
2967 | /** | 2967 | /** |
2968 | * lpfc_cmpl_els_rsp: Completion callback function for els response iocb cmd. | 2968 | * lpfc_cmpl_els_rsp - Completion callback function for els response iocb cmd |
2969 | * @phba: pointer to lpfc hba data structure. | 2969 | * @phba: pointer to lpfc hba data structure. |
2970 | * @cmdiocb: pointer to lpfc command iocb data structure. | 2970 | * @cmdiocb: pointer to lpfc command iocb data structure. |
2971 | * @rspiocb: pointer to lpfc response iocb data structure. | 2971 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -3136,7 +3136,7 @@ out: | |||
3136 | } | 3136 | } |
3137 | 3137 | ||
3138 | /** | 3138 | /** |
3139 | * lpfc_els_rsp_acc: Prepare and issue an acc response iocb command. | 3139 | * lpfc_els_rsp_acc - Prepare and issue an acc response iocb command |
3140 | * @vport: pointer to a host virtual N_Port data structure. | 3140 | * @vport: pointer to a host virtual N_Port data structure. |
3141 | * @flag: the els command code to be accepted. | 3141 | * @flag: the els command code to be accepted. |
3142 | * @oldiocb: pointer to the original lpfc command iocb data structure. | 3142 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
@@ -3275,7 +3275,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, | |||
3275 | } | 3275 | } |
3276 | 3276 | ||
3277 | /** | 3277 | /** |
3278 | * lpfc_els_rsp_reject: Propare and issue a rjt response iocb command. | 3278 | * lpfc_els_rsp_reject - Propare and issue a rjt response iocb command |
3279 | * @vport: pointer to a virtual N_Port data structure. | 3279 | * @vport: pointer to a virtual N_Port data structure. |
3280 | * @rejectError: | 3280 | * @rejectError: |
3281 | * @oldiocb: pointer to the original lpfc command iocb data structure. | 3281 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
@@ -3356,7 +3356,7 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, | |||
3356 | } | 3356 | } |
3357 | 3357 | ||
3358 | /** | 3358 | /** |
3359 | * lpfc_els_rsp_adisc_acc: Prepare and issue acc response to adisc iocb cmd. | 3359 | * lpfc_els_rsp_adisc_acc - Prepare and issue acc response to adisc iocb cmd |
3360 | * @vport: pointer to a virtual N_Port data structure. | 3360 | * @vport: pointer to a virtual N_Port data structure. |
3361 | * @oldiocb: pointer to the original lpfc command iocb data structure. | 3361 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
3362 | * @ndlp: pointer to a node-list data structure. | 3362 | * @ndlp: pointer to a node-list data structure. |
@@ -3431,7 +3431,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, | |||
3431 | } | 3431 | } |
3432 | 3432 | ||
3433 | /** | 3433 | /** |
3434 | * lpfc_els_rsp_prli_acc: Prepare and issue acc response to prli iocb cmd. | 3434 | * lpfc_els_rsp_prli_acc - Prepare and issue acc response to prli iocb cmd |
3435 | * @vport: pointer to a virtual N_Port data structure. | 3435 | * @vport: pointer to a virtual N_Port data structure. |
3436 | * @oldiocb: pointer to the original lpfc command iocb data structure. | 3436 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
3437 | * @ndlp: pointer to a node-list data structure. | 3437 | * @ndlp: pointer to a node-list data structure. |
@@ -3529,7 +3529,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, | |||
3529 | } | 3529 | } |
3530 | 3530 | ||
3531 | /** | 3531 | /** |
3532 | * lpfc_els_rsp_rnid_acc: Issue rnid acc response iocb command. | 3532 | * lpfc_els_rsp_rnid_acc - Issue rnid acc response iocb command |
3533 | * @vport: pointer to a virtual N_Port data structure. | 3533 | * @vport: pointer to a virtual N_Port data structure. |
3534 | * @format: rnid command format. | 3534 | * @format: rnid command format. |
3535 | * @oldiocb: pointer to the original lpfc command iocb data structure. | 3535 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
@@ -3635,7 +3635,7 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, | |||
3635 | } | 3635 | } |
3636 | 3636 | ||
3637 | /** | 3637 | /** |
3638 | * lpfc_els_disc_adisc: Issue remaining adisc iocbs to npr nodes of a vport. | 3638 | * lpfc_els_disc_adisc - Issue remaining adisc iocbs to npr nodes of a vport |
3639 | * @vport: pointer to a host virtual N_Port data structure. | 3639 | * @vport: pointer to a host virtual N_Port data structure. |
3640 | * | 3640 | * |
3641 | * This routine issues Address Discover (ADISC) ELS commands to those | 3641 | * This routine issues Address Discover (ADISC) ELS commands to those |
@@ -3693,7 +3693,7 @@ lpfc_els_disc_adisc(struct lpfc_vport *vport) | |||
3693 | } | 3693 | } |
3694 | 3694 | ||
3695 | /** | 3695 | /** |
3696 | * lpfc_els_disc_plogi: Issue plogi for all npr nodes of a vport before adisc. | 3696 | * lpfc_els_disc_plogi - Issue plogi for all npr nodes of a vport before adisc |
3697 | * @vport: pointer to a host virtual N_Port data structure. | 3697 | * @vport: pointer to a host virtual N_Port data structure. |
3698 | * | 3698 | * |
3699 | * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports | 3699 | * This routine issues Port Login (PLOGI) ELS commands to all the N_Ports |
@@ -3752,7 +3752,7 @@ lpfc_els_disc_plogi(struct lpfc_vport *vport) | |||
3752 | } | 3752 | } |
3753 | 3753 | ||
3754 | /** | 3754 | /** |
3755 | * lpfc_els_flush_rscn: Clean up any rscn activities with a vport. | 3755 | * lpfc_els_flush_rscn - Clean up any rscn activities with a vport |
3756 | * @vport: pointer to a host virtual N_Port data structure. | 3756 | * @vport: pointer to a host virtual N_Port data structure. |
3757 | * | 3757 | * |
3758 | * This routine cleans up any Registration State Change Notification | 3758 | * This routine cleans up any Registration State Change Notification |
@@ -3791,7 +3791,7 @@ lpfc_els_flush_rscn(struct lpfc_vport *vport) | |||
3791 | } | 3791 | } |
3792 | 3792 | ||
3793 | /** | 3793 | /** |
3794 | * lpfc_rscn_payload_check: Check whether there is a pending rscn to a did. | 3794 | * lpfc_rscn_payload_check - Check whether there is a pending rscn to a did |
3795 | * @vport: pointer to a host virtual N_Port data structure. | 3795 | * @vport: pointer to a host virtual N_Port data structure. |
3796 | * @did: remote destination port identifier. | 3796 | * @did: remote destination port identifier. |
3797 | * | 3797 | * |
@@ -3866,7 +3866,7 @@ return_did_out: | |||
3866 | } | 3866 | } |
3867 | 3867 | ||
3868 | /** | 3868 | /** |
3869 | * lpfc_rscn_recovery_check: Send recovery event to vport nodes matching rscn | 3869 | * lpfc_rscn_recovery_check - Send recovery event to vport nodes matching rscn |
3870 | * @vport: pointer to a host virtual N_Port data structure. | 3870 | * @vport: pointer to a host virtual N_Port data structure. |
3871 | * | 3871 | * |
3872 | * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the | 3872 | * This routine sends recovery (NLP_EVT_DEVICE_RECOVERY) event to the |
@@ -3895,7 +3895,7 @@ lpfc_rscn_recovery_check(struct lpfc_vport *vport) | |||
3895 | } | 3895 | } |
3896 | 3896 | ||
3897 | /** | 3897 | /** |
3898 | * lpfc_send_rscn_event: Send an RSCN event to management application. | 3898 | * lpfc_send_rscn_event - Send an RSCN event to management application |
3899 | * @vport: pointer to a host virtual N_Port data structure. | 3899 | * @vport: pointer to a host virtual N_Port data structure. |
3900 | * @cmdiocb: pointer to lpfc command iocb data structure. | 3900 | * @cmdiocb: pointer to lpfc command iocb data structure. |
3901 | * | 3901 | * |
@@ -3938,7 +3938,7 @@ lpfc_send_rscn_event(struct lpfc_vport *vport, | |||
3938 | } | 3938 | } |
3939 | 3939 | ||
3940 | /** | 3940 | /** |
3941 | * lpfc_els_rcv_rscn: Process an unsolicited rscn iocb. | 3941 | * lpfc_els_rcv_rscn - Process an unsolicited rscn iocb |
3942 | * @vport: pointer to a host virtual N_Port data structure. | 3942 | * @vport: pointer to a host virtual N_Port data structure. |
3943 | * @cmdiocb: pointer to lpfc command iocb data structure. | 3943 | * @cmdiocb: pointer to lpfc command iocb data structure. |
3944 | * @ndlp: pointer to a node-list data structure. | 3944 | * @ndlp: pointer to a node-list data structure. |
@@ -4134,7 +4134,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4134 | } | 4134 | } |
4135 | 4135 | ||
4136 | /** | 4136 | /** |
4137 | * lpfc_els_handle_rscn: Handle rscn for a vport. | 4137 | * lpfc_els_handle_rscn - Handle rscn for a vport |
4138 | * @vport: pointer to a host virtual N_Port data structure. | 4138 | * @vport: pointer to a host virtual N_Port data structure. |
4139 | * | 4139 | * |
4140 | * This routine handles the Registration State Configuration Notification | 4140 | * This routine handles the Registration State Configuration Notification |
@@ -4222,7 +4222,7 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport) | |||
4222 | } | 4222 | } |
4223 | 4223 | ||
4224 | /** | 4224 | /** |
4225 | * lpfc_els_rcv_flogi: Process an unsolicited flogi iocb. | 4225 | * lpfc_els_rcv_flogi - Process an unsolicited flogi iocb |
4226 | * @vport: pointer to a host virtual N_Port data structure. | 4226 | * @vport: pointer to a host virtual N_Port data structure. |
4227 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4227 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4228 | * @ndlp: pointer to a node-list data structure. | 4228 | * @ndlp: pointer to a node-list data structure. |
@@ -4336,7 +4336,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4336 | } | 4336 | } |
4337 | 4337 | ||
4338 | /** | 4338 | /** |
4339 | * lpfc_els_rcv_rnid: Process an unsolicited rnid iocb. | 4339 | * lpfc_els_rcv_rnid - Process an unsolicited rnid iocb |
4340 | * @vport: pointer to a host virtual N_Port data structure. | 4340 | * @vport: pointer to a host virtual N_Port data structure. |
4341 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4341 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4342 | * @ndlp: pointer to a node-list data structure. | 4342 | * @ndlp: pointer to a node-list data structure. |
@@ -4391,7 +4391,7 @@ lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4391 | } | 4391 | } |
4392 | 4392 | ||
4393 | /** | 4393 | /** |
4394 | * lpfc_els_rcv_lirr: Process an unsolicited lirr iocb. | 4394 | * lpfc_els_rcv_lirr - Process an unsolicited lirr iocb |
4395 | * @vport: pointer to a host virtual N_Port data structure. | 4395 | * @vport: pointer to a host virtual N_Port data structure. |
4396 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4396 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4397 | * @ndlp: pointer to a node-list data structure. | 4397 | * @ndlp: pointer to a node-list data structure. |
@@ -4419,7 +4419,7 @@ lpfc_els_rcv_lirr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4419 | } | 4419 | } |
4420 | 4420 | ||
4421 | /** | 4421 | /** |
4422 | * lpfc_els_rsp_rps_acc: Completion callbk func for MBX_READ_LNK_STAT mbox cmd. | 4422 | * lpfc_els_rsp_rps_acc - Completion callbk func for MBX_READ_LNK_STAT mbox cmd |
4423 | * @phba: pointer to lpfc hba data structure. | 4423 | * @phba: pointer to lpfc hba data structure. |
4424 | * @pmb: pointer to the driver internal queue element for mailbox command. | 4424 | * @pmb: pointer to the driver internal queue element for mailbox command. |
4425 | * | 4425 | * |
@@ -4513,7 +4513,7 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
4513 | } | 4513 | } |
4514 | 4514 | ||
4515 | /** | 4515 | /** |
4516 | * lpfc_els_rcv_rps: Process an unsolicited rps iocb. | 4516 | * lpfc_els_rcv_rps - Process an unsolicited rps iocb |
4517 | * @vport: pointer to a host virtual N_Port data structure. | 4517 | * @vport: pointer to a host virtual N_Port data structure. |
4518 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4518 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4519 | * @ndlp: pointer to a node-list data structure. | 4519 | * @ndlp: pointer to a node-list data structure. |
@@ -4590,7 +4590,7 @@ reject_out: | |||
4590 | } | 4590 | } |
4591 | 4591 | ||
4592 | /** | 4592 | /** |
4593 | * lpfc_els_rsp_rpl_acc: Issue an accept rpl els command. | 4593 | * lpfc_els_rsp_rpl_acc - Issue an accept rpl els command |
4594 | * @vport: pointer to a host virtual N_Port data structure. | 4594 | * @vport: pointer to a host virtual N_Port data structure. |
4595 | * @cmdsize: size of the ELS command. | 4595 | * @cmdsize: size of the ELS command. |
4596 | * @oldiocb: pointer to the original lpfc command iocb data structure. | 4596 | * @oldiocb: pointer to the original lpfc command iocb data structure. |
@@ -4662,7 +4662,7 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, | |||
4662 | } | 4662 | } |
4663 | 4663 | ||
4664 | /** | 4664 | /** |
4665 | * lpfc_els_rcv_rpl: Process an unsolicited rpl iocb. | 4665 | * lpfc_els_rcv_rpl - Process an unsolicited rpl iocb |
4666 | * @vport: pointer to a host virtual N_Port data structure. | 4666 | * @vport: pointer to a host virtual N_Port data structure. |
4667 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4667 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4668 | * @ndlp: pointer to a node-list data structure. | 4668 | * @ndlp: pointer to a node-list data structure. |
@@ -4721,7 +4721,7 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4721 | } | 4721 | } |
4722 | 4722 | ||
4723 | /** | 4723 | /** |
4724 | * lpfc_els_rcv_farp: Process an unsolicited farp request els command. | 4724 | * lpfc_els_rcv_farp - Process an unsolicited farp request els command |
4725 | * @vport: pointer to a virtual N_Port data structure. | 4725 | * @vport: pointer to a virtual N_Port data structure. |
4726 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4726 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4727 | * @ndlp: pointer to a node-list data structure. | 4727 | * @ndlp: pointer to a node-list data structure. |
@@ -4804,7 +4804,7 @@ lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4804 | } | 4804 | } |
4805 | 4805 | ||
4806 | /** | 4806 | /** |
4807 | * lpfc_els_rcv_farpr: Process an unsolicited farp response iocb. | 4807 | * lpfc_els_rcv_farpr - Process an unsolicited farp response iocb |
4808 | * @vport: pointer to a host virtual N_Port data structure. | 4808 | * @vport: pointer to a host virtual N_Port data structure. |
4809 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4809 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4810 | * @ndlp: pointer to a node-list data structure. | 4810 | * @ndlp: pointer to a node-list data structure. |
@@ -4842,7 +4842,7 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4842 | } | 4842 | } |
4843 | 4843 | ||
4844 | /** | 4844 | /** |
4845 | * lpfc_els_rcv_fan: Process an unsolicited fan iocb command. | 4845 | * lpfc_els_rcv_fan - Process an unsolicited fan iocb command |
4846 | * @vport: pointer to a host virtual N_Port data structure. | 4846 | * @vport: pointer to a host virtual N_Port data structure. |
4847 | * @cmdiocb: pointer to lpfc command iocb data structure. | 4847 | * @cmdiocb: pointer to lpfc command iocb data structure. |
4848 | * @fan_ndlp: pointer to a node-list data structure. | 4848 | * @fan_ndlp: pointer to a node-list data structure. |
@@ -4890,7 +4890,7 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, | |||
4890 | } | 4890 | } |
4891 | 4891 | ||
4892 | /** | 4892 | /** |
4893 | * lpfc_els_timeout: Handler funciton to the els timer. | 4893 | * lpfc_els_timeout - Handler funciton to the els timer |
4894 | * @ptr: holder for the timer function associated data. | 4894 | * @ptr: holder for the timer function associated data. |
4895 | * | 4895 | * |
4896 | * This routine is invoked by the ELS timer after timeout. It posts the ELS | 4896 | * This routine is invoked by the ELS timer after timeout. It posts the ELS |
@@ -4919,7 +4919,7 @@ lpfc_els_timeout(unsigned long ptr) | |||
4919 | } | 4919 | } |
4920 | 4920 | ||
4921 | /** | 4921 | /** |
4922 | * lpfc_els_timeout_handler: Process an els timeout event. | 4922 | * lpfc_els_timeout_handler - Process an els timeout event |
4923 | * @vport: pointer to a virtual N_Port data structure. | 4923 | * @vport: pointer to a virtual N_Port data structure. |
4924 | * | 4924 | * |
4925 | * This routine is the actual handler function that processes an ELS timeout | 4925 | * This routine is the actual handler function that processes an ELS timeout |
@@ -4994,7 +4994,7 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport) | |||
4994 | } | 4994 | } |
4995 | 4995 | ||
4996 | /** | 4996 | /** |
4997 | * lpfc_els_flush_cmd: Clean up the outstanding els commands to a vport. | 4997 | * lpfc_els_flush_cmd - Clean up the outstanding els commands to a vport |
4998 | * @vport: pointer to a host virtual N_Port data structure. | 4998 | * @vport: pointer to a host virtual N_Port data structure. |
4999 | * | 4999 | * |
5000 | * This routine is used to clean up all the outstanding ELS commands on a | 5000 | * This routine is used to clean up all the outstanding ELS commands on a |
@@ -5058,25 +5058,15 @@ lpfc_els_flush_cmd(struct lpfc_vport *vport) | |||
5058 | } | 5058 | } |
5059 | spin_unlock_irq(&phba->hbalock); | 5059 | spin_unlock_irq(&phba->hbalock); |
5060 | 5060 | ||
5061 | while (!list_empty(&completions)) { | 5061 | /* Cancell all the IOCBs from the completions list */ |
5062 | piocb = list_get_first(&completions, struct lpfc_iocbq, list); | 5062 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
5063 | cmd = &piocb->iocb; | 5063 | IOERR_SLI_ABORTED); |
5064 | list_del_init(&piocb->list); | ||
5065 | |||
5066 | if (!piocb->iocb_cmpl) | ||
5067 | lpfc_sli_release_iocbq(phba, piocb); | ||
5068 | else { | ||
5069 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
5070 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
5071 | (piocb->iocb_cmpl) (phba, piocb, piocb); | ||
5072 | } | ||
5073 | } | ||
5074 | 5064 | ||
5075 | return; | 5065 | return; |
5076 | } | 5066 | } |
5077 | 5067 | ||
5078 | /** | 5068 | /** |
5079 | * lpfc_els_flush_all_cmd: Clean up all the outstanding els commands to a HBA. | 5069 | * lpfc_els_flush_all_cmd - Clean up all the outstanding els commands to a HBA |
5080 | * @phba: pointer to lpfc hba data structure. | 5070 | * @phba: pointer to lpfc hba data structure. |
5081 | * | 5071 | * |
5082 | * This routine is used to clean up all the outstanding ELS commands on a | 5072 | * This routine is used to clean up all the outstanding ELS commands on a |
@@ -5121,23 +5111,16 @@ lpfc_els_flush_all_cmd(struct lpfc_hba *phba) | |||
5121 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); | 5111 | lpfc_sli_issue_abort_iotag(phba, pring, piocb); |
5122 | } | 5112 | } |
5123 | spin_unlock_irq(&phba->hbalock); | 5113 | spin_unlock_irq(&phba->hbalock); |
5124 | while (!list_empty(&completions)) { | 5114 | |
5125 | piocb = list_get_first(&completions, struct lpfc_iocbq, list); | 5115 | /* Cancel all the IOCBs from the completions list */ |
5126 | cmd = &piocb->iocb; | 5116 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
5127 | list_del_init(&piocb->list); | 5117 | IOERR_SLI_ABORTED); |
5128 | if (!piocb->iocb_cmpl) | 5118 | |
5129 | lpfc_sli_release_iocbq(phba, piocb); | ||
5130 | else { | ||
5131 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
5132 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
5133 | (piocb->iocb_cmpl) (phba, piocb, piocb); | ||
5134 | } | ||
5135 | } | ||
5136 | return; | 5119 | return; |
5137 | } | 5120 | } |
5138 | 5121 | ||
5139 | /** | 5122 | /** |
5140 | * lpfc_send_els_failure_event: Posts an ELS command failure event. | 5123 | * lpfc_send_els_failure_event - Posts an ELS command failure event |
5141 | * @phba: Pointer to hba context object. | 5124 | * @phba: Pointer to hba context object. |
5142 | * @cmdiocbp: Pointer to command iocb which reported error. | 5125 | * @cmdiocbp: Pointer to command iocb which reported error. |
5143 | * @rspiocbp: Pointer to response iocb which reported error. | 5126 | * @rspiocbp: Pointer to response iocb which reported error. |
@@ -5204,7 +5187,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, | |||
5204 | } | 5187 | } |
5205 | 5188 | ||
5206 | /** | 5189 | /** |
5207 | * lpfc_send_els_event: Posts unsolicited els event. | 5190 | * lpfc_send_els_event - Posts unsolicited els event |
5208 | * @vport: Pointer to vport object. | 5191 | * @vport: Pointer to vport object. |
5209 | * @ndlp: Pointer FC node object. | 5192 | * @ndlp: Pointer FC node object. |
5210 | * @cmd: ELS command code. | 5193 | * @cmd: ELS command code. |
@@ -5284,7 +5267,7 @@ lpfc_send_els_event(struct lpfc_vport *vport, | |||
5284 | 5267 | ||
5285 | 5268 | ||
5286 | /** | 5269 | /** |
5287 | * lpfc_els_unsol_buffer: Process an unsolicited event data buffer. | 5270 | * lpfc_els_unsol_buffer - Process an unsolicited event data buffer |
5288 | * @phba: pointer to lpfc hba data structure. | 5271 | * @phba: pointer to lpfc hba data structure. |
5289 | * @pring: pointer to a SLI ring. | 5272 | * @pring: pointer to a SLI ring. |
5290 | * @vport: pointer to a host virtual N_Port data structure. | 5273 | * @vport: pointer to a host virtual N_Port data structure. |
@@ -5592,7 +5575,7 @@ dropit: | |||
5592 | } | 5575 | } |
5593 | 5576 | ||
5594 | /** | 5577 | /** |
5595 | * lpfc_find_vport_by_vpid: Find a vport on a HBA through vport identifier. | 5578 | * lpfc_find_vport_by_vpid - Find a vport on a HBA through vport identifier |
5596 | * @phba: pointer to lpfc hba data structure. | 5579 | * @phba: pointer to lpfc hba data structure. |
5597 | * @vpi: host virtual N_Port identifier. | 5580 | * @vpi: host virtual N_Port identifier. |
5598 | * | 5581 | * |
@@ -5622,7 +5605,7 @@ lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi) | |||
5622 | } | 5605 | } |
5623 | 5606 | ||
5624 | /** | 5607 | /** |
5625 | * lpfc_els_unsol_event: Process an unsolicited event from an els sli ring. | 5608 | * lpfc_els_unsol_event - Process an unsolicited event from an els sli ring |
5626 | * @phba: pointer to lpfc hba data structure. | 5609 | * @phba: pointer to lpfc hba data structure. |
5627 | * @pring: pointer to a SLI ring. | 5610 | * @pring: pointer to a SLI ring. |
5628 | * @elsiocb: pointer to lpfc els iocb data structure. | 5611 | * @elsiocb: pointer to lpfc els iocb data structure. |
@@ -5710,7 +5693,7 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
5710 | } | 5693 | } |
5711 | 5694 | ||
5712 | /** | 5695 | /** |
5713 | * lpfc_do_scr_ns_plogi: Issue a plogi to the name server for scr. | 5696 | * lpfc_do_scr_ns_plogi - Issue a plogi to the name server for scr |
5714 | * @phba: pointer to lpfc hba data structure. | 5697 | * @phba: pointer to lpfc hba data structure. |
5715 | * @vport: pointer to a virtual N_Port data structure. | 5698 | * @vport: pointer to a virtual N_Port data structure. |
5716 | * | 5699 | * |
@@ -5781,7 +5764,7 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport) | |||
5781 | } | 5764 | } |
5782 | 5765 | ||
5783 | /** | 5766 | /** |
5784 | * lpfc_cmpl_reg_new_vport: Completion callback function to register new vport. | 5767 | * lpfc_cmpl_reg_new_vport - Completion callback function to register new vport |
5785 | * @phba: pointer to lpfc hba data structure. | 5768 | * @phba: pointer to lpfc hba data structure. |
5786 | * @pmb: pointer to the driver internal queue element for mailbox command. | 5769 | * @pmb: pointer to the driver internal queue element for mailbox command. |
5787 | * | 5770 | * |
@@ -5850,7 +5833,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
5850 | } | 5833 | } |
5851 | 5834 | ||
5852 | /** | 5835 | /** |
5853 | * lpfc_register_new_vport: Register a new vport with a HBA. | 5836 | * lpfc_register_new_vport - Register a new vport with a HBA |
5854 | * @phba: pointer to lpfc hba data structure. | 5837 | * @phba: pointer to lpfc hba data structure. |
5855 | * @vport: pointer to a host virtual N_Port data structure. | 5838 | * @vport: pointer to a host virtual N_Port data structure. |
5856 | * @ndlp: pointer to a node-list data structure. | 5839 | * @ndlp: pointer to a node-list data structure. |
@@ -5899,7 +5882,7 @@ mbox_err_exit: | |||
5899 | } | 5882 | } |
5900 | 5883 | ||
5901 | /** | 5884 | /** |
5902 | * lpfc_cmpl_els_fdisc: Completion function for fdisc iocb command. | 5885 | * lpfc_cmpl_els_fdisc - Completion function for fdisc iocb command |
5903 | * @phba: pointer to lpfc hba data structure. | 5886 | * @phba: pointer to lpfc hba data structure. |
5904 | * @cmdiocb: pointer to lpfc command iocb data structure. | 5887 | * @cmdiocb: pointer to lpfc command iocb data structure. |
5905 | * @rspiocb: pointer to lpfc response iocb data structure. | 5888 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -6007,7 +5990,7 @@ out: | |||
6007 | } | 5990 | } |
6008 | 5991 | ||
6009 | /** | 5992 | /** |
6010 | * lpfc_issue_els_fdisc: Issue a fdisc iocb command. | 5993 | * lpfc_issue_els_fdisc - Issue a fdisc iocb command |
6011 | * @vport: pointer to a virtual N_Port data structure. | 5994 | * @vport: pointer to a virtual N_Port data structure. |
6012 | * @ndlp: pointer to a node-list data structure. | 5995 | * @ndlp: pointer to a node-list data structure. |
6013 | * @retry: number of retries to the command IOCB. | 5996 | * @retry: number of retries to the command IOCB. |
@@ -6101,7 +6084,7 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
6101 | } | 6084 | } |
6102 | 6085 | ||
6103 | /** | 6086 | /** |
6104 | * lpfc_cmpl_els_npiv_logo: Completion function with vport logo. | 6087 | * lpfc_cmpl_els_npiv_logo - Completion function with vport logo |
6105 | * @phba: pointer to lpfc hba data structure. | 6088 | * @phba: pointer to lpfc hba data structure. |
6106 | * @cmdiocb: pointer to lpfc command iocb data structure. | 6089 | * @cmdiocb: pointer to lpfc command iocb data structure. |
6107 | * @rspiocb: pointer to lpfc response iocb data structure. | 6090 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -6136,7 +6119,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
6136 | } | 6119 | } |
6137 | 6120 | ||
6138 | /** | 6121 | /** |
6139 | * lpfc_issue_els_npiv_logo: Issue a logo off a vport. | 6122 | * lpfc_issue_els_npiv_logo - Issue a logo off a vport |
6140 | * @vport: pointer to a virtual N_Port data structure. | 6123 | * @vport: pointer to a virtual N_Port data structure. |
6141 | * @ndlp: pointer to a node-list data structure. | 6124 | * @ndlp: pointer to a node-list data structure. |
6142 | * | 6125 | * |
@@ -6197,7 +6180,7 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
6197 | } | 6180 | } |
6198 | 6181 | ||
6199 | /** | 6182 | /** |
6200 | * lpfc_fabric_block_timeout: Handler function to the fabric block timer. | 6183 | * lpfc_fabric_block_timeout - Handler function to the fabric block timer |
6201 | * @ptr: holder for the timer function associated data. | 6184 | * @ptr: holder for the timer function associated data. |
6202 | * | 6185 | * |
6203 | * This routine is invoked by the fabric iocb block timer after | 6186 | * This routine is invoked by the fabric iocb block timer after |
@@ -6226,7 +6209,7 @@ lpfc_fabric_block_timeout(unsigned long ptr) | |||
6226 | } | 6209 | } |
6227 | 6210 | ||
6228 | /** | 6211 | /** |
6229 | * lpfc_resume_fabric_iocbs: Issue a fabric iocb from driver internal list. | 6212 | * lpfc_resume_fabric_iocbs - Issue a fabric iocb from driver internal list |
6230 | * @phba: pointer to lpfc hba data structure. | 6213 | * @phba: pointer to lpfc hba data structure. |
6231 | * | 6214 | * |
6232 | * This routine issues one fabric iocb from the driver internal list to | 6215 | * This routine issues one fabric iocb from the driver internal list to |
@@ -6285,7 +6268,7 @@ repeat: | |||
6285 | } | 6268 | } |
6286 | 6269 | ||
6287 | /** | 6270 | /** |
6288 | * lpfc_unblock_fabric_iocbs: Unblock issuing fabric iocb command. | 6271 | * lpfc_unblock_fabric_iocbs - Unblock issuing fabric iocb command |
6289 | * @phba: pointer to lpfc hba data structure. | 6272 | * @phba: pointer to lpfc hba data structure. |
6290 | * | 6273 | * |
6291 | * This routine unblocks the issuing fabric iocb command. The function | 6274 | * This routine unblocks the issuing fabric iocb command. The function |
@@ -6303,7 +6286,7 @@ lpfc_unblock_fabric_iocbs(struct lpfc_hba *phba) | |||
6303 | } | 6286 | } |
6304 | 6287 | ||
6305 | /** | 6288 | /** |
6306 | * lpfc_block_fabric_iocbs: Block issuing fabric iocb command. | 6289 | * lpfc_block_fabric_iocbs - Block issuing fabric iocb command |
6307 | * @phba: pointer to lpfc hba data structure. | 6290 | * @phba: pointer to lpfc hba data structure. |
6308 | * | 6291 | * |
6309 | * This routine blocks the issuing fabric iocb for a specified amount of | 6292 | * This routine blocks the issuing fabric iocb for a specified amount of |
@@ -6325,7 +6308,7 @@ lpfc_block_fabric_iocbs(struct lpfc_hba *phba) | |||
6325 | } | 6308 | } |
6326 | 6309 | ||
6327 | /** | 6310 | /** |
6328 | * lpfc_cmpl_fabric_iocb: Completion callback function for fabric iocb. | 6311 | * lpfc_cmpl_fabric_iocb - Completion callback function for fabric iocb |
6329 | * @phba: pointer to lpfc hba data structure. | 6312 | * @phba: pointer to lpfc hba data structure. |
6330 | * @cmdiocb: pointer to lpfc command iocb data structure. | 6313 | * @cmdiocb: pointer to lpfc command iocb data structure. |
6331 | * @rspiocb: pointer to lpfc response iocb data structure. | 6314 | * @rspiocb: pointer to lpfc response iocb data structure. |
@@ -6384,7 +6367,7 @@ lpfc_cmpl_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
6384 | } | 6367 | } |
6385 | 6368 | ||
6386 | /** | 6369 | /** |
6387 | * lpfc_issue_fabric_iocb: Issue a fabric iocb command. | 6370 | * lpfc_issue_fabric_iocb - Issue a fabric iocb command |
6388 | * @phba: pointer to lpfc hba data structure. | 6371 | * @phba: pointer to lpfc hba data structure. |
6389 | * @iocb: pointer to lpfc command iocb data structure. | 6372 | * @iocb: pointer to lpfc command iocb data structure. |
6390 | * | 6373 | * |
@@ -6453,7 +6436,7 @@ lpfc_issue_fabric_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *iocb) | |||
6453 | } | 6436 | } |
6454 | 6437 | ||
6455 | /** | 6438 | /** |
6456 | * lpfc_fabric_abort_vport: Abort a vport's iocbs from driver fabric iocb list. | 6439 | * lpfc_fabric_abort_vport - Abort a vport's iocbs from driver fabric iocb list |
6457 | * @vport: pointer to a virtual N_Port data structure. | 6440 | * @vport: pointer to a virtual N_Port data structure. |
6458 | * | 6441 | * |
6459 | * This routine aborts all the IOCBs associated with a @vport from the | 6442 | * This routine aborts all the IOCBs associated with a @vport from the |
@@ -6468,7 +6451,6 @@ static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) | |||
6468 | LIST_HEAD(completions); | 6451 | LIST_HEAD(completions); |
6469 | struct lpfc_hba *phba = vport->phba; | 6452 | struct lpfc_hba *phba = vport->phba; |
6470 | struct lpfc_iocbq *tmp_iocb, *piocb; | 6453 | struct lpfc_iocbq *tmp_iocb, *piocb; |
6471 | IOCB_t *cmd; | ||
6472 | 6454 | ||
6473 | spin_lock_irq(&phba->hbalock); | 6455 | spin_lock_irq(&phba->hbalock); |
6474 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, | 6456 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
@@ -6481,19 +6463,13 @@ static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) | |||
6481 | } | 6463 | } |
6482 | spin_unlock_irq(&phba->hbalock); | 6464 | spin_unlock_irq(&phba->hbalock); |
6483 | 6465 | ||
6484 | while (!list_empty(&completions)) { | 6466 | /* Cancel all the IOCBs from the completions list */ |
6485 | piocb = list_get_first(&completions, struct lpfc_iocbq, list); | 6467 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
6486 | list_del_init(&piocb->list); | 6468 | IOERR_SLI_ABORTED); |
6487 | |||
6488 | cmd = &piocb->iocb; | ||
6489 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
6490 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
6491 | (piocb->iocb_cmpl) (phba, piocb, piocb); | ||
6492 | } | ||
6493 | } | 6469 | } |
6494 | 6470 | ||
6495 | /** | 6471 | /** |
6496 | * lpfc_fabric_abort_nport: Abort a ndlp's iocbs from driver fabric iocb list. | 6472 | * lpfc_fabric_abort_nport - Abort a ndlp's iocbs from driver fabric iocb list |
6497 | * @ndlp: pointer to a node-list data structure. | 6473 | * @ndlp: pointer to a node-list data structure. |
6498 | * | 6474 | * |
6499 | * This routine aborts all the IOCBs associated with an @ndlp from the | 6475 | * This routine aborts all the IOCBs associated with an @ndlp from the |
@@ -6506,10 +6482,9 @@ static void lpfc_fabric_abort_vport(struct lpfc_vport *vport) | |||
6506 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) | 6482 | void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) |
6507 | { | 6483 | { |
6508 | LIST_HEAD(completions); | 6484 | LIST_HEAD(completions); |
6509 | struct lpfc_hba *phba = ndlp->vport->phba; | 6485 | struct lpfc_hba *phba = ndlp->phba; |
6510 | struct lpfc_iocbq *tmp_iocb, *piocb; | 6486 | struct lpfc_iocbq *tmp_iocb, *piocb; |
6511 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; | 6487 | struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; |
6512 | IOCB_t *cmd; | ||
6513 | 6488 | ||
6514 | spin_lock_irq(&phba->hbalock); | 6489 | spin_lock_irq(&phba->hbalock); |
6515 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, | 6490 | list_for_each_entry_safe(piocb, tmp_iocb, &phba->fabric_iocb_list, |
@@ -6521,19 +6496,13 @@ void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) | |||
6521 | } | 6496 | } |
6522 | spin_unlock_irq(&phba->hbalock); | 6497 | spin_unlock_irq(&phba->hbalock); |
6523 | 6498 | ||
6524 | while (!list_empty(&completions)) { | 6499 | /* Cancel all the IOCBs from the completions list */ |
6525 | piocb = list_get_first(&completions, struct lpfc_iocbq, list); | 6500 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
6526 | list_del_init(&piocb->list); | 6501 | IOERR_SLI_ABORTED); |
6527 | |||
6528 | cmd = &piocb->iocb; | ||
6529 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
6530 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
6531 | (piocb->iocb_cmpl) (phba, piocb, piocb); | ||
6532 | } | ||
6533 | } | 6502 | } |
6534 | 6503 | ||
6535 | /** | 6504 | /** |
6536 | * lpfc_fabric_abort_hba: Abort all iocbs on driver fabric iocb list. | 6505 | * lpfc_fabric_abort_hba - Abort all iocbs on driver fabric iocb list |
6537 | * @phba: pointer to lpfc hba data structure. | 6506 | * @phba: pointer to lpfc hba data structure. |
6538 | * | 6507 | * |
6539 | * This routine aborts all the IOCBs currently on the driver internal | 6508 | * This routine aborts all the IOCBs currently on the driver internal |
@@ -6546,20 +6515,12 @@ void lpfc_fabric_abort_nport(struct lpfc_nodelist *ndlp) | |||
6546 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) | 6515 | void lpfc_fabric_abort_hba(struct lpfc_hba *phba) |
6547 | { | 6516 | { |
6548 | LIST_HEAD(completions); | 6517 | LIST_HEAD(completions); |
6549 | struct lpfc_iocbq *piocb; | ||
6550 | IOCB_t *cmd; | ||
6551 | 6518 | ||
6552 | spin_lock_irq(&phba->hbalock); | 6519 | spin_lock_irq(&phba->hbalock); |
6553 | list_splice_init(&phba->fabric_iocb_list, &completions); | 6520 | list_splice_init(&phba->fabric_iocb_list, &completions); |
6554 | spin_unlock_irq(&phba->hbalock); | 6521 | spin_unlock_irq(&phba->hbalock); |
6555 | 6522 | ||
6556 | while (!list_empty(&completions)) { | 6523 | /* Cancel all the IOCBs from the completions list */ |
6557 | piocb = list_get_first(&completions, struct lpfc_iocbq, list); | 6524 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
6558 | list_del_init(&piocb->list); | 6525 | IOERR_SLI_ABORTED); |
6559 | |||
6560 | cmd = &piocb->iocb; | ||
6561 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
6562 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
6563 | (piocb->iocb_cmpl) (phba, piocb, piocb); | ||
6564 | } | ||
6565 | } | 6526 | } |
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 311ed6dea726..e764ce0bf704 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -78,7 +78,7 @@ lpfc_terminate_rport_io(struct fc_rport *rport) | |||
78 | return; | 78 | return; |
79 | } | 79 | } |
80 | 80 | ||
81 | phba = ndlp->vport->phba; | 81 | phba = ndlp->phba; |
82 | 82 | ||
83 | lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_RPORT, | 83 | lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_RPORT, |
84 | "rport terminate: sid:x%x did:x%x flg:x%x", | 84 | "rport terminate: sid:x%x did:x%x flg:x%x", |
@@ -276,7 +276,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) | |||
276 | } | 276 | } |
277 | 277 | ||
278 | /** | 278 | /** |
279 | * lpfc_alloc_fast_evt: Allocates data structure for posting event. | 279 | * lpfc_alloc_fast_evt - Allocates data structure for posting event |
280 | * @phba: Pointer to hba context object. | 280 | * @phba: Pointer to hba context object. |
281 | * | 281 | * |
282 | * This function is called from the functions which need to post | 282 | * This function is called from the functions which need to post |
@@ -303,7 +303,7 @@ lpfc_alloc_fast_evt(struct lpfc_hba *phba) { | |||
303 | } | 303 | } |
304 | 304 | ||
305 | /** | 305 | /** |
306 | * lpfc_free_fast_evt: Frees event data structure. | 306 | * lpfc_free_fast_evt - Frees event data structure |
307 | * @phba: Pointer to hba context object. | 307 | * @phba: Pointer to hba context object. |
308 | * @evt: Event object which need to be freed. | 308 | * @evt: Event object which need to be freed. |
309 | * | 309 | * |
@@ -319,7 +319,7 @@ lpfc_free_fast_evt(struct lpfc_hba *phba, | |||
319 | } | 319 | } |
320 | 320 | ||
321 | /** | 321 | /** |
322 | * lpfc_send_fastpath_evt: Posts events generated from fast path. | 322 | * lpfc_send_fastpath_evt - Posts events generated from fast path |
323 | * @phba: Pointer to hba context object. | 323 | * @phba: Pointer to hba context object. |
324 | * @evtp: Event data structure. | 324 | * @evtp: Event data structure. |
325 | * | 325 | * |
@@ -1858,13 +1858,18 @@ lpfc_disable_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) | |||
1858 | NLP_STE_UNUSED_NODE); | 1858 | NLP_STE_UNUSED_NODE); |
1859 | } | 1859 | } |
1860 | /** | 1860 | /** |
1861 | * lpfc_initialize_node: Initialize all fields of node object. | 1861 | * lpfc_initialize_node - Initialize all fields of node object |
1862 | * @vport: Pointer to Virtual Port object. | 1862 | * @vport: Pointer to Virtual Port object. |
1863 | * @ndlp: Pointer to FC node object. | 1863 | * @ndlp: Pointer to FC node object. |
1864 | * @did: FC_ID of the node. | 1864 | * @did: FC_ID of the node. |
1865 | * This function is always called when node object need to | 1865 | * |
1866 | * be initialized. It initializes all the fields of the node | 1866 | * This function is always called when node object need to be initialized. |
1867 | * object. | 1867 | * It initializes all the fields of the node object. Although the reference |
1868 | * to phba from @ndlp can be obtained indirectly through it's reference to | ||
1869 | * @vport, a direct reference to phba is taken here by @ndlp. This is due | ||
1870 | * to the life-span of the @ndlp might go beyond the existence of @vport as | ||
1871 | * the final release of ndlp is determined by its reference count. And, the | ||
1872 | * operation on @ndlp needs the reference to phba. | ||
1868 | **/ | 1873 | **/ |
1869 | static inline void | 1874 | static inline void |
1870 | lpfc_initialize_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | 1875 | lpfc_initialize_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, |
@@ -1877,6 +1882,7 @@ lpfc_initialize_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, | |||
1877 | ndlp->nlp_delayfunc.data = (unsigned long)ndlp; | 1882 | ndlp->nlp_delayfunc.data = (unsigned long)ndlp; |
1878 | ndlp->nlp_DID = did; | 1883 | ndlp->nlp_DID = did; |
1879 | ndlp->vport = vport; | 1884 | ndlp->vport = vport; |
1885 | ndlp->phba = vport->phba; | ||
1880 | ndlp->nlp_sid = NLP_NO_SID; | 1886 | ndlp->nlp_sid = NLP_NO_SID; |
1881 | kref_init(&ndlp->kref); | 1887 | kref_init(&ndlp->kref); |
1882 | NLP_INT_NODE_ACT(ndlp); | 1888 | NLP_INT_NODE_ACT(ndlp); |
@@ -2086,7 +2092,6 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
2086 | struct lpfc_sli *psli; | 2092 | struct lpfc_sli *psli; |
2087 | struct lpfc_sli_ring *pring; | 2093 | struct lpfc_sli_ring *pring; |
2088 | struct lpfc_iocbq *iocb, *next_iocb; | 2094 | struct lpfc_iocbq *iocb, *next_iocb; |
2089 | IOCB_t *icmd; | ||
2090 | uint32_t rpi, i; | 2095 | uint32_t rpi, i; |
2091 | 2096 | ||
2092 | lpfc_fabric_abort_nport(ndlp); | 2097 | lpfc_fabric_abort_nport(ndlp); |
@@ -2122,19 +2127,9 @@ lpfc_no_rpi(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
2122 | } | 2127 | } |
2123 | } | 2128 | } |
2124 | 2129 | ||
2125 | while (!list_empty(&completions)) { | 2130 | /* Cancel all the IOCBs from the completions list */ |
2126 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); | 2131 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
2127 | list_del_init(&iocb->list); | 2132 | IOERR_SLI_ABORTED); |
2128 | |||
2129 | if (!iocb->iocb_cmpl) | ||
2130 | lpfc_sli_release_iocbq(phba, iocb); | ||
2131 | else { | ||
2132 | icmd = &iocb->iocb; | ||
2133 | icmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
2134 | icmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
2135 | (iocb->iocb_cmpl)(phba, iocb, iocb); | ||
2136 | } | ||
2137 | } | ||
2138 | 2133 | ||
2139 | return 0; | 2134 | return 0; |
2140 | } | 2135 | } |
@@ -2186,9 +2181,13 @@ lpfc_unreg_all_rpis(struct lpfc_vport *vport) | |||
2186 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 2181 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
2187 | mbox->context1 = NULL; | 2182 | mbox->context1 = NULL; |
2188 | rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO); | 2183 | rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO); |
2189 | if (rc == MBX_NOT_FINISHED) { | 2184 | if (rc != MBX_TIMEOUT) |
2190 | mempool_free(mbox, phba->mbox_mem_pool); | 2185 | mempool_free(mbox, phba->mbox_mem_pool); |
2191 | } | 2186 | |
2187 | if ((rc == MBX_TIMEOUT) || (rc == MBX_NOT_FINISHED)) | ||
2188 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT, | ||
2189 | "1836 Could not issue " | ||
2190 | "unreg_login(all_rpis) status %d\n", rc); | ||
2192 | } | 2191 | } |
2193 | } | 2192 | } |
2194 | 2193 | ||
@@ -2206,12 +2205,14 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport) | |||
2206 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 2205 | mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
2207 | mbox->context1 = NULL; | 2206 | mbox->context1 = NULL; |
2208 | rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO); | 2207 | rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_TMO); |
2209 | if (rc == MBX_NOT_FINISHED) { | 2208 | if (rc != MBX_TIMEOUT) |
2209 | mempool_free(mbox, phba->mbox_mem_pool); | ||
2210 | |||
2211 | if ((rc == MBX_TIMEOUT) || (rc == MBX_NOT_FINISHED)) | ||
2210 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT, | 2212 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT, |
2211 | "1815 Could not issue " | 2213 | "1815 Could not issue " |
2212 | "unreg_did (default rpis)\n"); | 2214 | "unreg_did (default rpis) status %d\n", |
2213 | mempool_free(mbox, phba->mbox_mem_pool); | 2215 | rc); |
2214 | } | ||
2215 | } | 2216 | } |
2216 | } | 2217 | } |
2217 | 2218 | ||
@@ -2470,14 +2471,13 @@ lpfc_setup_disc_node(struct lpfc_vport *vport, uint32_t did) | |||
2470 | if (ndlp->nlp_flag & NLP_RCV_PLOGI) | 2471 | if (ndlp->nlp_flag & NLP_RCV_PLOGI) |
2471 | return NULL; | 2472 | return NULL; |
2472 | 2473 | ||
2473 | spin_lock_irq(shost->host_lock); | ||
2474 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | ||
2475 | spin_unlock_irq(shost->host_lock); | ||
2476 | |||
2477 | /* Since this node is marked for discovery, | 2474 | /* Since this node is marked for discovery, |
2478 | * delay timeout is not needed. | 2475 | * delay timeout is not needed. |
2479 | */ | 2476 | */ |
2480 | lpfc_cancel_retry_delay_tmo(vport, ndlp); | 2477 | lpfc_cancel_retry_delay_tmo(vport, ndlp); |
2478 | spin_lock_irq(shost->host_lock); | ||
2479 | ndlp->nlp_flag |= NLP_NPR_2B_DISC; | ||
2480 | spin_unlock_irq(shost->host_lock); | ||
2481 | } else | 2481 | } else |
2482 | ndlp = NULL; | 2482 | ndlp = NULL; |
2483 | } else { | 2483 | } else { |
@@ -2740,19 +2740,9 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
2740 | } | 2740 | } |
2741 | spin_unlock_irq(&phba->hbalock); | 2741 | spin_unlock_irq(&phba->hbalock); |
2742 | 2742 | ||
2743 | while (!list_empty(&completions)) { | 2743 | /* Cancel all the IOCBs from the completions list */ |
2744 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); | 2744 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
2745 | list_del_init(&iocb->list); | 2745 | IOERR_SLI_ABORTED); |
2746 | |||
2747 | if (!iocb->iocb_cmpl) | ||
2748 | lpfc_sli_release_iocbq(phba, iocb); | ||
2749 | else { | ||
2750 | icmd = &iocb->iocb; | ||
2751 | icmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
2752 | icmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
2753 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
2754 | } | ||
2755 | } | ||
2756 | } | 2746 | } |
2757 | 2747 | ||
2758 | static void | 2748 | static void |
@@ -3173,7 +3163,7 @@ lpfc_nlp_release(struct kref *kref) | |||
3173 | lpfc_nlp_remove(ndlp->vport, ndlp); | 3163 | lpfc_nlp_remove(ndlp->vport, ndlp); |
3174 | 3164 | ||
3175 | /* clear the ndlp active flag for all release cases */ | 3165 | /* clear the ndlp active flag for all release cases */ |
3176 | phba = ndlp->vport->phba; | 3166 | phba = ndlp->phba; |
3177 | spin_lock_irqsave(&phba->ndlp_lock, flags); | 3167 | spin_lock_irqsave(&phba->ndlp_lock, flags); |
3178 | NLP_CLR_NODE_ACT(ndlp); | 3168 | NLP_CLR_NODE_ACT(ndlp); |
3179 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | 3169 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); |
@@ -3181,7 +3171,7 @@ lpfc_nlp_release(struct kref *kref) | |||
3181 | /* free ndlp memory for final ndlp release */ | 3171 | /* free ndlp memory for final ndlp release */ |
3182 | if (NLP_CHK_FREE_REQ(ndlp)) { | 3172 | if (NLP_CHK_FREE_REQ(ndlp)) { |
3183 | kfree(ndlp->lat_data); | 3173 | kfree(ndlp->lat_data); |
3184 | mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool); | 3174 | mempool_free(ndlp, ndlp->phba->nlp_mem_pool); |
3185 | } | 3175 | } |
3186 | } | 3176 | } |
3187 | 3177 | ||
@@ -3204,7 +3194,7 @@ lpfc_nlp_get(struct lpfc_nodelist *ndlp) | |||
3204 | * ndlp reference count that is in the process of being | 3194 | * ndlp reference count that is in the process of being |
3205 | * released. | 3195 | * released. |
3206 | */ | 3196 | */ |
3207 | phba = ndlp->vport->phba; | 3197 | phba = ndlp->phba; |
3208 | spin_lock_irqsave(&phba->ndlp_lock, flags); | 3198 | spin_lock_irqsave(&phba->ndlp_lock, flags); |
3209 | if (!NLP_CHK_NODE_ACT(ndlp) || NLP_CHK_FREE_ACK(ndlp)) { | 3199 | if (!NLP_CHK_NODE_ACT(ndlp) || NLP_CHK_FREE_ACK(ndlp)) { |
3210 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); | 3200 | spin_unlock_irqrestore(&phba->ndlp_lock, flags); |
@@ -3240,7 +3230,7 @@ lpfc_nlp_put(struct lpfc_nodelist *ndlp) | |||
3240 | "node put: did:x%x flg:x%x refcnt:x%x", | 3230 | "node put: did:x%x flg:x%x refcnt:x%x", |
3241 | ndlp->nlp_DID, ndlp->nlp_flag, | 3231 | ndlp->nlp_DID, ndlp->nlp_flag, |
3242 | atomic_read(&ndlp->kref.refcount)); | 3232 | atomic_read(&ndlp->kref.refcount)); |
3243 | phba = ndlp->vport->phba; | 3233 | phba = ndlp->phba; |
3244 | spin_lock_irqsave(&phba->ndlp_lock, flags); | 3234 | spin_lock_irqsave(&phba->ndlp_lock, flags); |
3245 | /* Check the ndlp memory free acknowledge flag to avoid the | 3235 | /* Check the ndlp memory free acknowledge flag to avoid the |
3246 | * possible race condition that kref_put got invoked again | 3236 | * possible race condition that kref_put got invoked again |
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 06874e6009ea..86d1bdcbf2d8 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -60,7 +60,7 @@ static struct scsi_transport_template *lpfc_vport_transport_template = NULL; | |||
60 | static DEFINE_IDR(lpfc_hba_index); | 60 | static DEFINE_IDR(lpfc_hba_index); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * lpfc_config_port_prep: Perform lpfc initialization prior to config port. | 63 | * lpfc_config_port_prep - Perform lpfc initialization prior to config port |
64 | * @phba: pointer to lpfc hba data structure. | 64 | * @phba: pointer to lpfc hba data structure. |
65 | * | 65 | * |
66 | * This routine will do LPFC initialization prior to issuing the CONFIG_PORT | 66 | * This routine will do LPFC initialization prior to issuing the CONFIG_PORT |
@@ -221,7 +221,7 @@ out_free_mbox: | |||
221 | } | 221 | } |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * lpfc_config_async_cmpl: Completion handler for config async event mbox cmd. | 224 | * lpfc_config_async_cmpl - Completion handler for config async event mbox cmd |
225 | * @phba: pointer to lpfc hba data structure. | 225 | * @phba: pointer to lpfc hba data structure. |
226 | * @pmboxq: pointer to the driver internal queue element for mailbox command. | 226 | * @pmboxq: pointer to the driver internal queue element for mailbox command. |
227 | * | 227 | * |
@@ -242,8 +242,7 @@ lpfc_config_async_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) | |||
242 | } | 242 | } |
243 | 243 | ||
244 | /** | 244 | /** |
245 | * lpfc_dump_wakeup_param_cmpl: Completion handler for dump memory mailbox | 245 | * lpfc_dump_wakeup_param_cmpl - dump memory mailbox command completion handler |
246 | * command used for getting wake up parameters. | ||
247 | * @phba: pointer to lpfc hba data structure. | 246 | * @phba: pointer to lpfc hba data structure. |
248 | * @pmboxq: pointer to the driver internal queue element for mailbox command. | 247 | * @pmboxq: pointer to the driver internal queue element for mailbox command. |
249 | * | 248 | * |
@@ -287,7 +286,7 @@ lpfc_dump_wakeup_param_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) | |||
287 | } | 286 | } |
288 | 287 | ||
289 | /** | 288 | /** |
290 | * lpfc_config_port_post: Perform lpfc initialization after config port. | 289 | * lpfc_config_port_post - Perform lpfc initialization after config port |
291 | * @phba: pointer to lpfc hba data structure. | 290 | * @phba: pointer to lpfc hba data structure. |
292 | * | 291 | * |
293 | * This routine will do LPFC initialization after the CONFIG_PORT mailbox | 292 | * This routine will do LPFC initialization after the CONFIG_PORT mailbox |
@@ -303,6 +302,7 @@ int | |||
303 | lpfc_config_port_post(struct lpfc_hba *phba) | 302 | lpfc_config_port_post(struct lpfc_hba *phba) |
304 | { | 303 | { |
305 | struct lpfc_vport *vport = phba->pport; | 304 | struct lpfc_vport *vport = phba->pport; |
305 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
306 | LPFC_MBOXQ_t *pmb; | 306 | LPFC_MBOXQ_t *pmb; |
307 | MAILBOX_t *mb; | 307 | MAILBOX_t *mb; |
308 | struct lpfc_dmabuf *mp; | 308 | struct lpfc_dmabuf *mp; |
@@ -360,6 +360,11 @@ lpfc_config_port_post(struct lpfc_hba *phba) | |||
360 | sizeof (struct lpfc_name)); | 360 | sizeof (struct lpfc_name)); |
361 | memcpy(&vport->fc_portname, &vport->fc_sparam.portName, | 361 | memcpy(&vport->fc_portname, &vport->fc_sparam.portName, |
362 | sizeof (struct lpfc_name)); | 362 | sizeof (struct lpfc_name)); |
363 | |||
364 | /* Update the fc_host data structures with new wwn. */ | ||
365 | fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); | ||
366 | fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); | ||
367 | |||
363 | /* If no serial number in VPD data, use low 6 bytes of WWNN */ | 368 | /* If no serial number in VPD data, use low 6 bytes of WWNN */ |
364 | /* This should be consolidated into parse_vpd ? - mr */ | 369 | /* This should be consolidated into parse_vpd ? - mr */ |
365 | if (phba->SerialNumber[0] == 0) { | 370 | if (phba->SerialNumber[0] == 0) { |
@@ -551,7 +556,7 @@ lpfc_config_port_post(struct lpfc_hba *phba) | |||
551 | } | 556 | } |
552 | 557 | ||
553 | /** | 558 | /** |
554 | * lpfc_hba_down_prep: Perform lpfc uninitialization prior to HBA reset. | 559 | * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset |
555 | * @phba: pointer to lpfc HBA data structure. | 560 | * @phba: pointer to lpfc HBA data structure. |
556 | * | 561 | * |
557 | * This routine will do LPFC uninitialization before the HBA is reset when | 562 | * This routine will do LPFC uninitialization before the HBA is reset when |
@@ -583,7 +588,7 @@ lpfc_hba_down_prep(struct lpfc_hba *phba) | |||
583 | } | 588 | } |
584 | 589 | ||
585 | /** | 590 | /** |
586 | * lpfc_hba_down_post: Perform lpfc uninitialization after HBA reset. | 591 | * lpfc_hba_down_post - Perform lpfc uninitialization after HBA reset |
587 | * @phba: pointer to lpfc HBA data structure. | 592 | * @phba: pointer to lpfc HBA data structure. |
588 | * | 593 | * |
589 | * This routine will do uninitialization after the HBA is reset when bring | 594 | * This routine will do uninitialization after the HBA is reset when bring |
@@ -599,8 +604,6 @@ lpfc_hba_down_post(struct lpfc_hba *phba) | |||
599 | struct lpfc_sli *psli = &phba->sli; | 604 | struct lpfc_sli *psli = &phba->sli; |
600 | struct lpfc_sli_ring *pring; | 605 | struct lpfc_sli_ring *pring; |
601 | struct lpfc_dmabuf *mp, *next_mp; | 606 | struct lpfc_dmabuf *mp, *next_mp; |
602 | struct lpfc_iocbq *iocb; | ||
603 | IOCB_t *cmd = NULL; | ||
604 | LIST_HEAD(completions); | 607 | LIST_HEAD(completions); |
605 | int i; | 608 | int i; |
606 | 609 | ||
@@ -628,20 +631,9 @@ lpfc_hba_down_post(struct lpfc_hba *phba) | |||
628 | pring->txcmplq_cnt = 0; | 631 | pring->txcmplq_cnt = 0; |
629 | spin_unlock_irq(&phba->hbalock); | 632 | spin_unlock_irq(&phba->hbalock); |
630 | 633 | ||
631 | while (!list_empty(&completions)) { | 634 | /* Cancel all the IOCBs from the completions list */ |
632 | iocb = list_get_first(&completions, struct lpfc_iocbq, | 635 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
633 | list); | 636 | IOERR_SLI_ABORTED); |
634 | cmd = &iocb->iocb; | ||
635 | list_del_init(&iocb->list); | ||
636 | |||
637 | if (!iocb->iocb_cmpl) | ||
638 | lpfc_sli_release_iocbq(phba, iocb); | ||
639 | else { | ||
640 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
641 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
642 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
643 | } | ||
644 | } | ||
645 | 637 | ||
646 | lpfc_sli_abort_iocb_ring(phba, pring); | 638 | lpfc_sli_abort_iocb_ring(phba, pring); |
647 | spin_lock_irq(&phba->hbalock); | 639 | spin_lock_irq(&phba->hbalock); |
@@ -652,7 +644,7 @@ lpfc_hba_down_post(struct lpfc_hba *phba) | |||
652 | } | 644 | } |
653 | 645 | ||
654 | /** | 646 | /** |
655 | * lpfc_hb_timeout: The HBA-timer timeout handler. | 647 | * lpfc_hb_timeout - The HBA-timer timeout handler |
656 | * @ptr: unsigned long holds the pointer to lpfc hba data structure. | 648 | * @ptr: unsigned long holds the pointer to lpfc hba data structure. |
657 | * | 649 | * |
658 | * This is the HBA-timer timeout handler registered to the lpfc driver. When | 650 | * This is the HBA-timer timeout handler registered to the lpfc driver. When |
@@ -686,7 +678,7 @@ lpfc_hb_timeout(unsigned long ptr) | |||
686 | } | 678 | } |
687 | 679 | ||
688 | /** | 680 | /** |
689 | * lpfc_hb_mbox_cmpl: The lpfc heart-beat mailbox command callback function. | 681 | * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function |
690 | * @phba: pointer to lpfc hba data structure. | 682 | * @phba: pointer to lpfc hba data structure. |
691 | * @pmboxq: pointer to the driver internal queue element for mailbox command. | 683 | * @pmboxq: pointer to the driver internal queue element for mailbox command. |
692 | * | 684 | * |
@@ -721,7 +713,7 @@ lpfc_hb_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) | |||
721 | } | 713 | } |
722 | 714 | ||
723 | /** | 715 | /** |
724 | * lpfc_hb_timeout_handler: The HBA-timer timeout handler. | 716 | * lpfc_hb_timeout_handler - The HBA-timer timeout handler |
725 | * @phba: pointer to lpfc hba data structure. | 717 | * @phba: pointer to lpfc hba data structure. |
726 | * | 718 | * |
727 | * This is the actual HBA-timer timeout handler to be invoked by the worker | 719 | * This is the actual HBA-timer timeout handler to be invoked by the worker |
@@ -830,7 +822,7 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba) | |||
830 | } | 822 | } |
831 | 823 | ||
832 | /** | 824 | /** |
833 | * lpfc_offline_eratt: Bring lpfc offline on hardware error attention. | 825 | * lpfc_offline_eratt - Bring lpfc offline on hardware error attention |
834 | * @phba: pointer to lpfc hba data structure. | 826 | * @phba: pointer to lpfc hba data structure. |
835 | * | 827 | * |
836 | * This routine is called to bring the HBA offline when HBA hardware error | 828 | * This routine is called to bring the HBA offline when HBA hardware error |
@@ -857,7 +849,73 @@ lpfc_offline_eratt(struct lpfc_hba *phba) | |||
857 | } | 849 | } |
858 | 850 | ||
859 | /** | 851 | /** |
860 | * lpfc_handle_eratt: The HBA hardware error handler. | 852 | * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler |
853 | * @phba: pointer to lpfc hba data structure. | ||
854 | * | ||
855 | * This routine is invoked to handle the deferred HBA hardware error | ||
856 | * conditions. This type of error is indicated by HBA by setting ER1 | ||
857 | * and another ER bit in the host status register. The driver will | ||
858 | * wait until the ER1 bit clears before handling the error condition. | ||
859 | **/ | ||
860 | static void | ||
861 | lpfc_handle_deferred_eratt(struct lpfc_hba *phba) | ||
862 | { | ||
863 | uint32_t old_host_status = phba->work_hs; | ||
864 | struct lpfc_sli_ring *pring; | ||
865 | struct lpfc_sli *psli = &phba->sli; | ||
866 | |||
867 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | ||
868 | "0479 Deferred Adapter Hardware Error " | ||
869 | "Data: x%x x%x x%x\n", | ||
870 | phba->work_hs, | ||
871 | phba->work_status[0], phba->work_status[1]); | ||
872 | |||
873 | spin_lock_irq(&phba->hbalock); | ||
874 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | ||
875 | spin_unlock_irq(&phba->hbalock); | ||
876 | |||
877 | |||
878 | /* | ||
879 | * Firmware stops when it triggred erratt. That could cause the I/Os | ||
880 | * dropped by the firmware. Error iocb (I/O) on txcmplq and let the | ||
881 | * SCSI layer retry it after re-establishing link. | ||
882 | */ | ||
883 | pring = &psli->ring[psli->fcp_ring]; | ||
884 | lpfc_sli_abort_iocb_ring(phba, pring); | ||
885 | |||
886 | /* | ||
887 | * There was a firmware error. Take the hba offline and then | ||
888 | * attempt to restart it. | ||
889 | */ | ||
890 | lpfc_offline_prep(phba); | ||
891 | lpfc_offline(phba); | ||
892 | |||
893 | /* Wait for the ER1 bit to clear.*/ | ||
894 | while (phba->work_hs & HS_FFER1) { | ||
895 | msleep(100); | ||
896 | phba->work_hs = readl(phba->HSregaddr); | ||
897 | /* If driver is unloading let the worker thread continue */ | ||
898 | if (phba->pport->load_flag & FC_UNLOADING) { | ||
899 | phba->work_hs = 0; | ||
900 | break; | ||
901 | } | ||
902 | } | ||
903 | |||
904 | /* | ||
905 | * This is to ptrotect against a race condition in which | ||
906 | * first write to the host attention register clear the | ||
907 | * host status register. | ||
908 | */ | ||
909 | if ((!phba->work_hs) && (!(phba->pport->load_flag & FC_UNLOADING))) | ||
910 | phba->work_hs = old_host_status & ~HS_FFER1; | ||
911 | |||
912 | phba->hba_flag &= ~DEFER_ERATT; | ||
913 | phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); | ||
914 | phba->work_status[1] = readl(phba->MBslimaddr + 0xac); | ||
915 | } | ||
916 | |||
917 | /** | ||
918 | * lpfc_handle_eratt - The HBA hardware error handler | ||
861 | * @phba: pointer to lpfc hba data structure. | 919 | * @phba: pointer to lpfc hba data structure. |
862 | * | 920 | * |
863 | * This routine is invoked to handle the following HBA hardware error | 921 | * This routine is invoked to handle the following HBA hardware error |
@@ -895,6 +953,9 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |||
895 | (char *) &board_event, | 953 | (char *) &board_event, |
896 | LPFC_NL_VENDOR_ID); | 954 | LPFC_NL_VENDOR_ID); |
897 | 955 | ||
956 | if (phba->hba_flag & DEFER_ERATT) | ||
957 | lpfc_handle_deferred_eratt(phba); | ||
958 | |||
898 | if (phba->work_hs & HS_FFER6) { | 959 | if (phba->work_hs & HS_FFER6) { |
899 | /* Re-establishing Link */ | 960 | /* Re-establishing Link */ |
900 | lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, | 961 | lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, |
@@ -976,7 +1037,7 @@ lpfc_handle_eratt(struct lpfc_hba *phba) | |||
976 | } | 1037 | } |
977 | 1038 | ||
978 | /** | 1039 | /** |
979 | * lpfc_handle_latt: The HBA link event handler. | 1040 | * lpfc_handle_latt - The HBA link event handler |
980 | * @phba: pointer to lpfc hba data structure. | 1041 | * @phba: pointer to lpfc hba data structure. |
981 | * | 1042 | * |
982 | * This routine is invoked from the worker thread to handle a HBA host | 1043 | * This routine is invoked from the worker thread to handle a HBA host |
@@ -1063,7 +1124,7 @@ lpfc_handle_latt_err_exit: | |||
1063 | } | 1124 | } |
1064 | 1125 | ||
1065 | /** | 1126 | /** |
1066 | * lpfc_parse_vpd: Parse VPD (Vital Product Data). | 1127 | * lpfc_parse_vpd - Parse VPD (Vital Product Data) |
1067 | * @phba: pointer to lpfc hba data structure. | 1128 | * @phba: pointer to lpfc hba data structure. |
1068 | * @vpd: pointer to the vital product data. | 1129 | * @vpd: pointer to the vital product data. |
1069 | * @len: length of the vital product data in bytes. | 1130 | * @len: length of the vital product data in bytes. |
@@ -1213,7 +1274,7 @@ lpfc_parse_vpd(struct lpfc_hba *phba, uint8_t *vpd, int len) | |||
1213 | } | 1274 | } |
1214 | 1275 | ||
1215 | /** | 1276 | /** |
1216 | * lpfc_get_hba_model_desc: Retrieve HBA device model name and description. | 1277 | * lpfc_get_hba_model_desc - Retrieve HBA device model name and description |
1217 | * @phba: pointer to lpfc hba data structure. | 1278 | * @phba: pointer to lpfc hba data structure. |
1218 | * @mdp: pointer to the data structure to hold the derived model name. | 1279 | * @mdp: pointer to the data structure to hold the derived model name. |
1219 | * @descp: pointer to the data structure to hold the derived description. | 1280 | * @descp: pointer to the data structure to hold the derived description. |
@@ -1322,7 +1383,8 @@ lpfc_get_hba_model_desc(struct lpfc_hba *phba, uint8_t *mdp, uint8_t *descp) | |||
1322 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; | 1383 | m = (typeof(m)){"LPe11000", max_speed, "PCIe"}; |
1323 | break; | 1384 | break; |
1324 | case PCI_DEVICE_ID_ZEPHYR_DCSP: | 1385 | case PCI_DEVICE_ID_ZEPHYR_DCSP: |
1325 | m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"}; | 1386 | m = (typeof(m)){"LP2105", max_speed, "PCIe"}; |
1387 | GE = 1; | ||
1326 | break; | 1388 | break; |
1327 | case PCI_DEVICE_ID_ZMID: | 1389 | case PCI_DEVICE_ID_ZMID: |
1328 | m = (typeof(m)){"LPe1150", max_speed, "PCIe"}; | 1390 | m = (typeof(m)){"LPe1150", max_speed, "PCIe"}; |
@@ -1392,7 +1454,7 @@ lpfc_get_hba_model_desc(struct lpfc_hba *phba, uint8_t *mdp, uint8_t *descp) | |||
1392 | } | 1454 | } |
1393 | 1455 | ||
1394 | /** | 1456 | /** |
1395 | * lpfc_post_buffer: Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring. | 1457 | * lpfc_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring |
1396 | * @phba: pointer to lpfc hba data structure. | 1458 | * @phba: pointer to lpfc hba data structure. |
1397 | * @pring: pointer to a IOCB ring. | 1459 | * @pring: pointer to a IOCB ring. |
1398 | * @cnt: the number of IOCBs to be posted to the IOCB ring. | 1460 | * @cnt: the number of IOCBs to be posted to the IOCB ring. |
@@ -1493,7 +1555,7 @@ lpfc_post_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, int cnt) | |||
1493 | } | 1555 | } |
1494 | 1556 | ||
1495 | /** | 1557 | /** |
1496 | * lpfc_post_rcv_buf: Post the initial receive IOCB buffers to ELS ring. | 1558 | * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring |
1497 | * @phba: pointer to lpfc hba data structure. | 1559 | * @phba: pointer to lpfc hba data structure. |
1498 | * | 1560 | * |
1499 | * This routine posts initial receive IOCB buffers to the ELS ring. The | 1561 | * This routine posts initial receive IOCB buffers to the ELS ring. The |
@@ -1518,7 +1580,7 @@ lpfc_post_rcv_buf(struct lpfc_hba *phba) | |||
1518 | #define S(N,V) (((V)<<(N))|((V)>>(32-(N)))) | 1580 | #define S(N,V) (((V)<<(N))|((V)>>(32-(N)))) |
1519 | 1581 | ||
1520 | /** | 1582 | /** |
1521 | * lpfc_sha_init: Set up initial array of hash table entries. | 1583 | * lpfc_sha_init - Set up initial array of hash table entries |
1522 | * @HashResultPointer: pointer to an array as hash table. | 1584 | * @HashResultPointer: pointer to an array as hash table. |
1523 | * | 1585 | * |
1524 | * This routine sets up the initial values to the array of hash table entries | 1586 | * This routine sets up the initial values to the array of hash table entries |
@@ -1535,7 +1597,7 @@ lpfc_sha_init(uint32_t * HashResultPointer) | |||
1535 | } | 1597 | } |
1536 | 1598 | ||
1537 | /** | 1599 | /** |
1538 | * lpfc_sha_iterate: Iterate initial hash table with the working hash table. | 1600 | * lpfc_sha_iterate - Iterate initial hash table with the working hash table |
1539 | * @HashResultPointer: pointer to an initial/result hash table. | 1601 | * @HashResultPointer: pointer to an initial/result hash table. |
1540 | * @HashWorkingPointer: pointer to an working hash table. | 1602 | * @HashWorkingPointer: pointer to an working hash table. |
1541 | * | 1603 | * |
@@ -1592,7 +1654,7 @@ lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer) | |||
1592 | } | 1654 | } |
1593 | 1655 | ||
1594 | /** | 1656 | /** |
1595 | * lpfc_challenge_key: Create challenge key based on WWPN of the HBA. | 1657 | * lpfc_challenge_key - Create challenge key based on WWPN of the HBA |
1596 | * @RandomChallenge: pointer to the entry of host challenge random number array. | 1658 | * @RandomChallenge: pointer to the entry of host challenge random number array. |
1597 | * @HashWorking: pointer to the entry of the working hash array. | 1659 | * @HashWorking: pointer to the entry of the working hash array. |
1598 | * | 1660 | * |
@@ -1608,7 +1670,7 @@ lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking) | |||
1608 | } | 1670 | } |
1609 | 1671 | ||
1610 | /** | 1672 | /** |
1611 | * lpfc_hba_init: Perform special handling for LC HBA initialization. | 1673 | * lpfc_hba_init - Perform special handling for LC HBA initialization |
1612 | * @phba: pointer to lpfc hba data structure. | 1674 | * @phba: pointer to lpfc hba data structure. |
1613 | * @hbainit: pointer to an array of unsigned 32-bit integers. | 1675 | * @hbainit: pointer to an array of unsigned 32-bit integers. |
1614 | * | 1676 | * |
@@ -1637,7 +1699,7 @@ lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit) | |||
1637 | } | 1699 | } |
1638 | 1700 | ||
1639 | /** | 1701 | /** |
1640 | * lpfc_cleanup: Performs vport cleanups before deleting a vport. | 1702 | * lpfc_cleanup - Performs vport cleanups before deleting a vport |
1641 | * @vport: pointer to a virtual N_Port data structure. | 1703 | * @vport: pointer to a virtual N_Port data structure. |
1642 | * | 1704 | * |
1643 | * This routine performs the necessary cleanups before deleting the @vport. | 1705 | * This routine performs the necessary cleanups before deleting the @vport. |
@@ -1724,7 +1786,7 @@ lpfc_cleanup(struct lpfc_vport *vport) | |||
1724 | } | 1786 | } |
1725 | 1787 | ||
1726 | /** | 1788 | /** |
1727 | * lpfc_stop_vport_timers: Stop all the timers associated with a vport. | 1789 | * lpfc_stop_vport_timers - Stop all the timers associated with a vport |
1728 | * @vport: pointer to a virtual N_Port data structure. | 1790 | * @vport: pointer to a virtual N_Port data structure. |
1729 | * | 1791 | * |
1730 | * This routine stops all the timers associated with a @vport. This function | 1792 | * This routine stops all the timers associated with a @vport. This function |
@@ -1741,7 +1803,7 @@ lpfc_stop_vport_timers(struct lpfc_vport *vport) | |||
1741 | } | 1803 | } |
1742 | 1804 | ||
1743 | /** | 1805 | /** |
1744 | * lpfc_stop_phba_timers: Stop all the timers associated with an HBA. | 1806 | * lpfc_stop_phba_timers - Stop all the timers associated with an HBA |
1745 | * @phba: pointer to lpfc hba data structure. | 1807 | * @phba: pointer to lpfc hba data structure. |
1746 | * | 1808 | * |
1747 | * This routine stops all the timers associated with a HBA. This function is | 1809 | * This routine stops all the timers associated with a HBA. This function is |
@@ -1761,7 +1823,7 @@ lpfc_stop_phba_timers(struct lpfc_hba *phba) | |||
1761 | } | 1823 | } |
1762 | 1824 | ||
1763 | /** | 1825 | /** |
1764 | * lpfc_block_mgmt_io: Mark a HBA's management interface as blocked. | 1826 | * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked |
1765 | * @phba: pointer to lpfc hba data structure. | 1827 | * @phba: pointer to lpfc hba data structure. |
1766 | * | 1828 | * |
1767 | * This routine marks a HBA's management interface as blocked. Once the HBA's | 1829 | * This routine marks a HBA's management interface as blocked. Once the HBA's |
@@ -1781,7 +1843,7 @@ lpfc_block_mgmt_io(struct lpfc_hba * phba) | |||
1781 | } | 1843 | } |
1782 | 1844 | ||
1783 | /** | 1845 | /** |
1784 | * lpfc_online: Initialize and bring a HBA online. | 1846 | * lpfc_online - Initialize and bring a HBA online |
1785 | * @phba: pointer to lpfc hba data structure. | 1847 | * @phba: pointer to lpfc hba data structure. |
1786 | * | 1848 | * |
1787 | * This routine initializes the HBA and brings a HBA online. During this | 1849 | * This routine initializes the HBA and brings a HBA online. During this |
@@ -1839,7 +1901,7 @@ lpfc_online(struct lpfc_hba *phba) | |||
1839 | } | 1901 | } |
1840 | 1902 | ||
1841 | /** | 1903 | /** |
1842 | * lpfc_unblock_mgmt_io: Mark a HBA's management interface to be not blocked. | 1904 | * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked |
1843 | * @phba: pointer to lpfc hba data structure. | 1905 | * @phba: pointer to lpfc hba data structure. |
1844 | * | 1906 | * |
1845 | * This routine marks a HBA's management interface as not blocked. Once the | 1907 | * This routine marks a HBA's management interface as not blocked. Once the |
@@ -1860,7 +1922,7 @@ lpfc_unblock_mgmt_io(struct lpfc_hba * phba) | |||
1860 | } | 1922 | } |
1861 | 1923 | ||
1862 | /** | 1924 | /** |
1863 | * lpfc_offline_prep: Prepare a HBA to be brought offline. | 1925 | * lpfc_offline_prep - Prepare a HBA to be brought offline |
1864 | * @phba: pointer to lpfc hba data structure. | 1926 | * @phba: pointer to lpfc hba data structure. |
1865 | * | 1927 | * |
1866 | * This routine is invoked to prepare a HBA to be brought offline. It performs | 1928 | * This routine is invoked to prepare a HBA to be brought offline. It performs |
@@ -1917,7 +1979,7 @@ lpfc_offline_prep(struct lpfc_hba * phba) | |||
1917 | } | 1979 | } |
1918 | 1980 | ||
1919 | /** | 1981 | /** |
1920 | * lpfc_offline: Bring a HBA offline. | 1982 | * lpfc_offline - Bring a HBA offline |
1921 | * @phba: pointer to lpfc hba data structure. | 1983 | * @phba: pointer to lpfc hba data structure. |
1922 | * | 1984 | * |
1923 | * This routine actually brings a HBA offline. It stops all the timers | 1985 | * This routine actually brings a HBA offline. It stops all the timers |
@@ -1962,7 +2024,7 @@ lpfc_offline(struct lpfc_hba *phba) | |||
1962 | } | 2024 | } |
1963 | 2025 | ||
1964 | /** | 2026 | /** |
1965 | * lpfc_scsi_free: Free all the SCSI buffers and IOCBs from driver lists. | 2027 | * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists |
1966 | * @phba: pointer to lpfc hba data structure. | 2028 | * @phba: pointer to lpfc hba data structure. |
1967 | * | 2029 | * |
1968 | * This routine is to free all the SCSI buffers and IOCBs from the driver | 2030 | * This routine is to free all the SCSI buffers and IOCBs from the driver |
@@ -2001,7 +2063,7 @@ lpfc_scsi_free(struct lpfc_hba *phba) | |||
2001 | } | 2063 | } |
2002 | 2064 | ||
2003 | /** | 2065 | /** |
2004 | * lpfc_create_port: Create an FC port. | 2066 | * lpfc_create_port - Create an FC port |
2005 | * @phba: pointer to lpfc hba data structure. | 2067 | * @phba: pointer to lpfc hba data structure. |
2006 | * @instance: a unique integer ID to this FC port. | 2068 | * @instance: a unique integer ID to this FC port. |
2007 | * @dev: pointer to the device data structure. | 2069 | * @dev: pointer to the device data structure. |
@@ -2091,7 +2153,7 @@ out: | |||
2091 | } | 2153 | } |
2092 | 2154 | ||
2093 | /** | 2155 | /** |
2094 | * destroy_port: Destroy an FC port. | 2156 | * destroy_port - destroy an FC port |
2095 | * @vport: pointer to an lpfc virtual N_Port data structure. | 2157 | * @vport: pointer to an lpfc virtual N_Port data structure. |
2096 | * | 2158 | * |
2097 | * This routine destroys a FC port from the upper layer protocol. All the | 2159 | * This routine destroys a FC port from the upper layer protocol. All the |
@@ -2116,7 +2178,7 @@ destroy_port(struct lpfc_vport *vport) | |||
2116 | } | 2178 | } |
2117 | 2179 | ||
2118 | /** | 2180 | /** |
2119 | * lpfc_get_instance: Get a unique integer ID. | 2181 | * lpfc_get_instance - Get a unique integer ID |
2120 | * | 2182 | * |
2121 | * This routine allocates a unique integer ID from lpfc_hba_index pool. It | 2183 | * This routine allocates a unique integer ID from lpfc_hba_index pool. It |
2122 | * uses the kernel idr facility to perform the task. | 2184 | * uses the kernel idr facility to perform the task. |
@@ -2139,7 +2201,7 @@ lpfc_get_instance(void) | |||
2139 | } | 2201 | } |
2140 | 2202 | ||
2141 | /** | 2203 | /** |
2142 | * lpfc_scan_finished: method for SCSI layer to detect whether scan is done. | 2204 | * lpfc_scan_finished - method for SCSI layer to detect whether scan is done |
2143 | * @shost: pointer to SCSI host data structure. | 2205 | * @shost: pointer to SCSI host data structure. |
2144 | * @time: elapsed time of the scan in jiffies. | 2206 | * @time: elapsed time of the scan in jiffies. |
2145 | * | 2207 | * |
@@ -2197,7 +2259,7 @@ finished: | |||
2197 | } | 2259 | } |
2198 | 2260 | ||
2199 | /** | 2261 | /** |
2200 | * lpfc_host_attrib_init: Initialize SCSI host attributes on a FC port. | 2262 | * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port |
2201 | * @shost: pointer to SCSI host data structure. | 2263 | * @shost: pointer to SCSI host data structure. |
2202 | * | 2264 | * |
2203 | * This routine initializes a given SCSI host attributes on a FC port. The | 2265 | * This routine initializes a given SCSI host attributes on a FC port. The |
@@ -2252,7 +2314,7 @@ void lpfc_host_attrib_init(struct Scsi_Host *shost) | |||
2252 | } | 2314 | } |
2253 | 2315 | ||
2254 | /** | 2316 | /** |
2255 | * lpfc_enable_msix: Enable MSI-X interrupt mode. | 2317 | * lpfc_enable_msix - Enable MSI-X interrupt mode |
2256 | * @phba: pointer to lpfc hba data structure. | 2318 | * @phba: pointer to lpfc hba data structure. |
2257 | * | 2319 | * |
2258 | * This routine is invoked to enable the MSI-X interrupt vectors. The kernel | 2320 | * This routine is invoked to enable the MSI-X interrupt vectors. The kernel |
@@ -2366,7 +2428,7 @@ msi_fail_out: | |||
2366 | } | 2428 | } |
2367 | 2429 | ||
2368 | /** | 2430 | /** |
2369 | * lpfc_disable_msix: Disable MSI-X interrupt mode. | 2431 | * lpfc_disable_msix - Disable MSI-X interrupt mode |
2370 | * @phba: pointer to lpfc hba data structure. | 2432 | * @phba: pointer to lpfc hba data structure. |
2371 | * | 2433 | * |
2372 | * This routine is invoked to release the MSI-X vectors and then disable the | 2434 | * This routine is invoked to release the MSI-X vectors and then disable the |
@@ -2385,7 +2447,7 @@ lpfc_disable_msix(struct lpfc_hba *phba) | |||
2385 | } | 2447 | } |
2386 | 2448 | ||
2387 | /** | 2449 | /** |
2388 | * lpfc_enable_msi: Enable MSI interrupt mode. | 2450 | * lpfc_enable_msi - Enable MSI interrupt mode |
2389 | * @phba: pointer to lpfc hba data structure. | 2451 | * @phba: pointer to lpfc hba data structure. |
2390 | * | 2452 | * |
2391 | * This routine is invoked to enable the MSI interrupt mode. The kernel | 2453 | * This routine is invoked to enable the MSI interrupt mode. The kernel |
@@ -2423,7 +2485,7 @@ lpfc_enable_msi(struct lpfc_hba *phba) | |||
2423 | } | 2485 | } |
2424 | 2486 | ||
2425 | /** | 2487 | /** |
2426 | * lpfc_disable_msi: Disable MSI interrupt mode. | 2488 | * lpfc_disable_msi - Disable MSI interrupt mode |
2427 | * @phba: pointer to lpfc hba data structure. | 2489 | * @phba: pointer to lpfc hba data structure. |
2428 | * | 2490 | * |
2429 | * This routine is invoked to disable the MSI interrupt mode. The driver | 2491 | * This routine is invoked to disable the MSI interrupt mode. The driver |
@@ -2441,7 +2503,7 @@ lpfc_disable_msi(struct lpfc_hba *phba) | |||
2441 | } | 2503 | } |
2442 | 2504 | ||
2443 | /** | 2505 | /** |
2444 | * lpfc_log_intr_mode: Log the active interrupt mode | 2506 | * lpfc_log_intr_mode - Log the active interrupt mode |
2445 | * @phba: pointer to lpfc hba data structure. | 2507 | * @phba: pointer to lpfc hba data structure. |
2446 | * @intr_mode: active interrupt mode adopted. | 2508 | * @intr_mode: active interrupt mode adopted. |
2447 | * | 2509 | * |
@@ -2490,7 +2552,7 @@ lpfc_stop_port(struct lpfc_hba *phba) | |||
2490 | } | 2552 | } |
2491 | 2553 | ||
2492 | /** | 2554 | /** |
2493 | * lpfc_enable_intr: Enable device interrupt. | 2555 | * lpfc_enable_intr - Enable device interrupt |
2494 | * @phba: pointer to lpfc hba data structure. | 2556 | * @phba: pointer to lpfc hba data structure. |
2495 | * | 2557 | * |
2496 | * This routine is invoked to enable device interrupt and associate driver's | 2558 | * This routine is invoked to enable device interrupt and associate driver's |
@@ -2547,7 +2609,7 @@ lpfc_enable_intr(struct lpfc_hba *phba, uint32_t cfg_mode) | |||
2547 | } | 2609 | } |
2548 | 2610 | ||
2549 | /** | 2611 | /** |
2550 | * lpfc_disable_intr: Disable device interrupt. | 2612 | * lpfc_disable_intr - Disable device interrupt |
2551 | * @phba: pointer to lpfc hba data structure. | 2613 | * @phba: pointer to lpfc hba data structure. |
2552 | * | 2614 | * |
2553 | * This routine is invoked to disable device interrupt and disassociate the | 2615 | * This routine is invoked to disable device interrupt and disassociate the |
@@ -2574,7 +2636,7 @@ lpfc_disable_intr(struct lpfc_hba *phba) | |||
2574 | } | 2636 | } |
2575 | 2637 | ||
2576 | /** | 2638 | /** |
2577 | * lpfc_pci_probe_one: lpfc PCI probe func to register device to PCI subsystem. | 2639 | * lpfc_pci_probe_one - lpfc PCI probe func to register device to PCI subsystem |
2578 | * @pdev: pointer to PCI device | 2640 | * @pdev: pointer to PCI device |
2579 | * @pid: pointer to PCI device identifier | 2641 | * @pid: pointer to PCI device identifier |
2580 | * | 2642 | * |
@@ -3010,7 +3072,7 @@ out: | |||
3010 | } | 3072 | } |
3011 | 3073 | ||
3012 | /** | 3074 | /** |
3013 | * lpfc_pci_remove_one: lpfc PCI func to unregister device from PCI subsystem. | 3075 | * lpfc_pci_remove_one - lpfc PCI func to unregister device from PCI subsystem |
3014 | * @pdev: pointer to PCI device | 3076 | * @pdev: pointer to PCI device |
3015 | * | 3077 | * |
3016 | * This routine is to be registered to the kernel's PCI subsystem. When an | 3078 | * This routine is to be registered to the kernel's PCI subsystem. When an |
@@ -3033,8 +3095,6 @@ lpfc_pci_remove_one(struct pci_dev *pdev) | |||
3033 | 3095 | ||
3034 | lpfc_free_sysfs_attr(vport); | 3096 | lpfc_free_sysfs_attr(vport); |
3035 | 3097 | ||
3036 | kthread_stop(phba->worker_thread); | ||
3037 | |||
3038 | /* Release all the vports against this physical port */ | 3098 | /* Release all the vports against this physical port */ |
3039 | vports = lpfc_create_vport_work_array(phba); | 3099 | vports = lpfc_create_vport_work_array(phba); |
3040 | if (vports != NULL) | 3100 | if (vports != NULL) |
@@ -3052,7 +3112,12 @@ lpfc_pci_remove_one(struct pci_dev *pdev) | |||
3052 | * clears the rings, discards all mailbox commands, and resets | 3112 | * clears the rings, discards all mailbox commands, and resets |
3053 | * the HBA. | 3113 | * the HBA. |
3054 | */ | 3114 | */ |
3115 | |||
3116 | /* HBA interrupt will be diabled after this call */ | ||
3055 | lpfc_sli_hba_down(phba); | 3117 | lpfc_sli_hba_down(phba); |
3118 | /* Stop kthread signal shall trigger work_done one more time */ | ||
3119 | kthread_stop(phba->worker_thread); | ||
3120 | /* Final cleanup of txcmplq and reset the HBA */ | ||
3056 | lpfc_sli_brdrestart(phba); | 3121 | lpfc_sli_brdrestart(phba); |
3057 | 3122 | ||
3058 | lpfc_stop_phba_timers(phba); | 3123 | lpfc_stop_phba_timers(phba); |
@@ -3095,7 +3160,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev) | |||
3095 | } | 3160 | } |
3096 | 3161 | ||
3097 | /** | 3162 | /** |
3098 | * lpfc_pci_suspend_one: lpfc PCI func to suspend device for power management. | 3163 | * lpfc_pci_suspend_one - lpfc PCI func to suspend device for power management |
3099 | * @pdev: pointer to PCI device | 3164 | * @pdev: pointer to PCI device |
3100 | * @msg: power management message | 3165 | * @msg: power management message |
3101 | * | 3166 | * |
@@ -3139,7 +3204,7 @@ lpfc_pci_suspend_one(struct pci_dev *pdev, pm_message_t msg) | |||
3139 | } | 3204 | } |
3140 | 3205 | ||
3141 | /** | 3206 | /** |
3142 | * lpfc_pci_resume_one: lpfc PCI func to resume device for power management. | 3207 | * lpfc_pci_resume_one - lpfc PCI func to resume device for power management |
3143 | * @pdev: pointer to PCI device | 3208 | * @pdev: pointer to PCI device |
3144 | * | 3209 | * |
3145 | * This routine is to be registered to the kernel's PCI subsystem to support | 3210 | * This routine is to be registered to the kernel's PCI subsystem to support |
@@ -3204,7 +3269,7 @@ lpfc_pci_resume_one(struct pci_dev *pdev) | |||
3204 | } | 3269 | } |
3205 | 3270 | ||
3206 | /** | 3271 | /** |
3207 | * lpfc_io_error_detected: Driver method for handling PCI I/O error detected. | 3272 | * lpfc_io_error_detected - Driver method for handling PCI I/O error detected |
3208 | * @pdev: pointer to PCI device. | 3273 | * @pdev: pointer to PCI device. |
3209 | * @state: the current PCI connection state. | 3274 | * @state: the current PCI connection state. |
3210 | * | 3275 | * |
@@ -3254,7 +3319,7 @@ static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev, | |||
3254 | } | 3319 | } |
3255 | 3320 | ||
3256 | /** | 3321 | /** |
3257 | * lpfc_io_slot_reset: Restart a PCI device from scratch. | 3322 | * lpfc_io_slot_reset - Restart a PCI device from scratch |
3258 | * @pdev: pointer to PCI device. | 3323 | * @pdev: pointer to PCI device. |
3259 | * | 3324 | * |
3260 | * This routine is registered to the PCI subsystem for error handling. This is | 3325 | * This routine is registered to the PCI subsystem for error handling. This is |
@@ -3313,7 +3378,7 @@ static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev) | |||
3313 | } | 3378 | } |
3314 | 3379 | ||
3315 | /** | 3380 | /** |
3316 | * lpfc_io_resume: Resume PCI I/O operation. | 3381 | * lpfc_io_resume - Resume PCI I/O operation |
3317 | * @pdev: pointer to PCI device | 3382 | * @pdev: pointer to PCI device |
3318 | * | 3383 | * |
3319 | * This routine is registered to the PCI subsystem for error handling. It is | 3384 | * This routine is registered to the PCI subsystem for error handling. It is |
@@ -3426,7 +3491,7 @@ static struct pci_driver lpfc_driver = { | |||
3426 | }; | 3491 | }; |
3427 | 3492 | ||
3428 | /** | 3493 | /** |
3429 | * lpfc_init: lpfc module initialization routine. | 3494 | * lpfc_init - lpfc module initialization routine |
3430 | * | 3495 | * |
3431 | * This routine is to be invoked when the lpfc module is loaded into the | 3496 | * This routine is to be invoked when the lpfc module is loaded into the |
3432 | * kernel. The special kernel macro module_init() is used to indicate the | 3497 | * kernel. The special kernel macro module_init() is used to indicate the |
@@ -3472,7 +3537,7 @@ lpfc_init(void) | |||
3472 | } | 3537 | } |
3473 | 3538 | ||
3474 | /** | 3539 | /** |
3475 | * lpfc_exit: lpfc module removal routine. | 3540 | * lpfc_exit - lpfc module removal routine |
3476 | * | 3541 | * |
3477 | * This routine is invoked when the lpfc module is removed from the kernel. | 3542 | * This routine is invoked when the lpfc module is removed from the kernel. |
3478 | * The special kernel macro module_exit() is used to indicate the role of | 3543 | * The special kernel macro module_exit() is used to indicate the role of |
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h index a85b7c196bbc..1aa85709b012 100644 --- a/drivers/scsi/lpfc/lpfc_logmsg.h +++ b/drivers/scsi/lpfc/lpfc_logmsg.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #define LOG_FCP 0x40 /* FCP traffic history */ | 27 | #define LOG_FCP 0x40 /* FCP traffic history */ |
28 | #define LOG_NODE 0x80 /* Node table events */ | 28 | #define LOG_NODE 0x80 /* Node table events */ |
29 | #define LOG_TEMP 0x100 /* Temperature sensor events */ | 29 | #define LOG_TEMP 0x100 /* Temperature sensor events */ |
30 | #define LOG_BG 0x200 /* BlockBuard events */ | 30 | #define LOG_BG 0x200 /* BlockGuard events */ |
31 | #define LOG_MISC 0x400 /* Miscellaneous events */ | 31 | #define LOG_MISC 0x400 /* Miscellaneous events */ |
32 | #define LOG_SLI 0x800 /* SLI events */ | 32 | #define LOG_SLI 0x800 /* SLI events */ |
33 | #define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */ | 33 | #define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */ |
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 34eeb086a667..134fc7fc2127 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "lpfc_compat.h" | 39 | #include "lpfc_compat.h" |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * lpfc_dump_mem: Prepare a mailbox command for retrieving HBA's VPD memory. | 42 | * lpfc_dump_mem - Prepare a mailbox command for retrieving HBA's VPD memory |
43 | * @phba: pointer to lpfc hba data structure. | 43 | * @phba: pointer to lpfc hba data structure. |
44 | * @pmb: pointer to the driver internal queue element for mailbox command. | 44 | * @pmb: pointer to the driver internal queue element for mailbox command. |
45 | * @offset: offset for dumping VPD memory mailbox command. | 45 | * @offset: offset for dumping VPD memory mailbox command. |
@@ -77,9 +77,10 @@ lpfc_dump_mem(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint16_t offset) | |||
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * lpfc_dump_mem: Prepare a mailbox command for retrieving wakeup params. | 80 | * lpfc_dump_wakeup_param - Prepare mailbox command for retrieving wakeup params |
81 | * @phba: pointer to lpfc hba data structure. | 81 | * @phba: pointer to lpfc hba data structure. |
82 | * @pmb: pointer to the driver internal queue element for mailbox command. | 82 | * @pmb: pointer to the driver internal queue element for mailbox command. |
83 | * | ||
83 | * This function create a dump memory mailbox command to dump wake up | 84 | * This function create a dump memory mailbox command to dump wake up |
84 | * parameters. | 85 | * parameters. |
85 | */ | 86 | */ |
@@ -109,7 +110,7 @@ lpfc_dump_wakeup_param(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
109 | } | 110 | } |
110 | 111 | ||
111 | /** | 112 | /** |
112 | * lpfc_read_nv: Prepare a mailbox command for reading HBA's NVRAM param. | 113 | * lpfc_read_nv - Prepare a mailbox command for reading HBA's NVRAM param |
113 | * @phba: pointer to lpfc hba data structure. | 114 | * @phba: pointer to lpfc hba data structure. |
114 | * @pmb: pointer to the driver internal queue element for mailbox command. | 115 | * @pmb: pointer to the driver internal queue element for mailbox command. |
115 | * | 116 | * |
@@ -132,7 +133,7 @@ lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
132 | } | 133 | } |
133 | 134 | ||
134 | /** | 135 | /** |
135 | * lpfc_config_async: Prepare a mailbox command for enabling HBA async event. | 136 | * lpfc_config_async - Prepare a mailbox command for enabling HBA async event |
136 | * @phba: pointer to lpfc hba data structure. | 137 | * @phba: pointer to lpfc hba data structure. |
137 | * @pmb: pointer to the driver internal queue element for mailbox command. | 138 | * @pmb: pointer to the driver internal queue element for mailbox command. |
138 | * @ring: ring number for the asynchronous event to be configured. | 139 | * @ring: ring number for the asynchronous event to be configured. |
@@ -159,7 +160,7 @@ lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, | |||
159 | } | 160 | } |
160 | 161 | ||
161 | /** | 162 | /** |
162 | * lpfc_heart_beat: Prepare a mailbox command for heart beat. | 163 | * lpfc_heart_beat - Prepare a mailbox command for heart beat |
163 | * @phba: pointer to lpfc hba data structure. | 164 | * @phba: pointer to lpfc hba data structure. |
164 | * @pmb: pointer to the driver internal queue element for mailbox command. | 165 | * @pmb: pointer to the driver internal queue element for mailbox command. |
165 | * | 166 | * |
@@ -184,7 +185,7 @@ lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
184 | } | 185 | } |
185 | 186 | ||
186 | /** | 187 | /** |
187 | * lpfc_read_la: Prepare a mailbox command for reading HBA link attention. | 188 | * lpfc_read_la - Prepare a mailbox command for reading HBA link attention |
188 | * @phba: pointer to lpfc hba data structure. | 189 | * @phba: pointer to lpfc hba data structure. |
189 | * @pmb: pointer to the driver internal queue element for mailbox command. | 190 | * @pmb: pointer to the driver internal queue element for mailbox command. |
190 | * @mp: DMA buffer memory for reading the link attention information into. | 191 | * @mp: DMA buffer memory for reading the link attention information into. |
@@ -228,7 +229,7 @@ lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp) | |||
228 | } | 229 | } |
229 | 230 | ||
230 | /** | 231 | /** |
231 | * lpfc_clear_la: Prepare a mailbox command for clearing HBA link attention. | 232 | * lpfc_clear_la - Prepare a mailbox command for clearing HBA link attention |
232 | * @phba: pointer to lpfc hba data structure. | 233 | * @phba: pointer to lpfc hba data structure. |
233 | * @pmb: pointer to the driver internal queue element for mailbox command. | 234 | * @pmb: pointer to the driver internal queue element for mailbox command. |
234 | * | 235 | * |
@@ -257,7 +258,7 @@ lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
257 | } | 258 | } |
258 | 259 | ||
259 | /** | 260 | /** |
260 | * lpfc_config_link: Prepare a mailbox command for configuring link on a HBA. | 261 | * lpfc_config_link - Prepare a mailbox command for configuring link on a HBA |
261 | * @phba: pointer to lpfc hba data structure. | 262 | * @phba: pointer to lpfc hba data structure. |
262 | * @pmb: pointer to the driver internal queue element for mailbox command. | 263 | * @pmb: pointer to the driver internal queue element for mailbox command. |
263 | * | 264 | * |
@@ -305,7 +306,7 @@ lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
305 | } | 306 | } |
306 | 307 | ||
307 | /** | 308 | /** |
308 | * lpfc_config_msi: Prepare a mailbox command for configuring msi-x. | 309 | * lpfc_config_msi - Prepare a mailbox command for configuring msi-x |
309 | * @phba: pointer to lpfc hba data structure. | 310 | * @phba: pointer to lpfc hba data structure. |
310 | * @pmb: pointer to the driver internal queue element for mailbox command. | 311 | * @pmb: pointer to the driver internal queue element for mailbox command. |
311 | * | 312 | * |
@@ -383,7 +384,7 @@ lpfc_config_msi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
383 | } | 384 | } |
384 | 385 | ||
385 | /** | 386 | /** |
386 | * lpfc_init_link: Prepare a mailbox command for initialize link on a HBA. | 387 | * lpfc_init_link - Prepare a mailbox command for initialize link on a HBA |
387 | * @phba: pointer to lpfc hba data structure. | 388 | * @phba: pointer to lpfc hba data structure. |
388 | * @pmb: pointer to the driver internal queue element for mailbox command. | 389 | * @pmb: pointer to the driver internal queue element for mailbox command. |
389 | * @topology: the link topology for the link to be initialized to. | 390 | * @topology: the link topology for the link to be initialized to. |
@@ -463,7 +464,7 @@ lpfc_init_link(struct lpfc_hba * phba, | |||
463 | } | 464 | } |
464 | 465 | ||
465 | /** | 466 | /** |
466 | * lpfc_read_sparam: Prepare a mailbox command for reading HBA parameters. | 467 | * lpfc_read_sparam - Prepare a mailbox command for reading HBA parameters |
467 | * @phba: pointer to lpfc hba data structure. | 468 | * @phba: pointer to lpfc hba data structure. |
468 | * @pmb: pointer to the driver internal queue element for mailbox command. | 469 | * @pmb: pointer to the driver internal queue element for mailbox command. |
469 | * @vpi: virtual N_Port identifier. | 470 | * @vpi: virtual N_Port identifier. |
@@ -523,7 +524,7 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) | |||
523 | } | 524 | } |
524 | 525 | ||
525 | /** | 526 | /** |
526 | * lpfc_unreg_did: Prepare a mailbox command for unregistering DID. | 527 | * lpfc_unreg_did - Prepare a mailbox command for unregistering DID |
527 | * @phba: pointer to lpfc hba data structure. | 528 | * @phba: pointer to lpfc hba data structure. |
528 | * @vpi: virtual N_Port identifier. | 529 | * @vpi: virtual N_Port identifier. |
529 | * @did: remote port identifier. | 530 | * @did: remote port identifier. |
@@ -555,7 +556,7 @@ lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did, | |||
555 | } | 556 | } |
556 | 557 | ||
557 | /** | 558 | /** |
558 | * lpfc_read_config: Prepare a mailbox command for reading HBA configuration. | 559 | * lpfc_read_config - Prepare a mailbox command for reading HBA configuration |
559 | * @phba: pointer to lpfc hba data structure. | 560 | * @phba: pointer to lpfc hba data structure. |
560 | * @pmb: pointer to the driver internal queue element for mailbox command. | 561 | * @pmb: pointer to the driver internal queue element for mailbox command. |
561 | * | 562 | * |
@@ -581,7 +582,7 @@ lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
581 | } | 582 | } |
582 | 583 | ||
583 | /** | 584 | /** |
584 | * lpfc_read_lnk_stat: Prepare a mailbox command for reading HBA link stats. | 585 | * lpfc_read_lnk_stat - Prepare a mailbox command for reading HBA link stats |
585 | * @phba: pointer to lpfc hba data structure. | 586 | * @phba: pointer to lpfc hba data structure. |
586 | * @pmb: pointer to the driver internal queue element for mailbox command. | 587 | * @pmb: pointer to the driver internal queue element for mailbox command. |
587 | * | 588 | * |
@@ -606,7 +607,7 @@ lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
606 | } | 607 | } |
607 | 608 | ||
608 | /** | 609 | /** |
609 | * lpfc_reg_login: Prepare a mailbox command for registering remote login. | 610 | * lpfc_reg_login - Prepare a mailbox command for registering remote login |
610 | * @phba: pointer to lpfc hba data structure. | 611 | * @phba: pointer to lpfc hba data structure. |
611 | * @vpi: virtual N_Port identifier. | 612 | * @vpi: virtual N_Port identifier. |
612 | * @did: remote port identifier. | 613 | * @did: remote port identifier. |
@@ -677,7 +678,7 @@ lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, | |||
677 | } | 678 | } |
678 | 679 | ||
679 | /** | 680 | /** |
680 | * lpfc_unreg_login: Prepare a mailbox command for unregistering remote login. | 681 | * lpfc_unreg_login - Prepare a mailbox command for unregistering remote login |
681 | * @phba: pointer to lpfc hba data structure. | 682 | * @phba: pointer to lpfc hba data structure. |
682 | * @vpi: virtual N_Port identifier. | 683 | * @vpi: virtual N_Port identifier. |
683 | * @rpi: remote port identifier | 684 | * @rpi: remote port identifier |
@@ -709,7 +710,7 @@ lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi, | |||
709 | } | 710 | } |
710 | 711 | ||
711 | /** | 712 | /** |
712 | * lpfc_reg_vpi: Prepare a mailbox command for registering vport identifier. | 713 | * lpfc_reg_vpi - Prepare a mailbox command for registering vport identifier |
713 | * @phba: pointer to lpfc hba data structure. | 714 | * @phba: pointer to lpfc hba data structure. |
714 | * @vpi: virtual N_Port identifier. | 715 | * @vpi: virtual N_Port identifier. |
715 | * @sid: Fibre Channel S_ID (N_Port_ID assigned to a virtual N_Port). | 716 | * @sid: Fibre Channel S_ID (N_Port_ID assigned to a virtual N_Port). |
@@ -741,7 +742,7 @@ lpfc_reg_vpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t sid, | |||
741 | } | 742 | } |
742 | 743 | ||
743 | /** | 744 | /** |
744 | * lpfc_unreg_vpi: Prepare a mailbox command for unregistering vport id. | 745 | * lpfc_unreg_vpi - Prepare a mailbox command for unregistering vport id |
745 | * @phba: pointer to lpfc hba data structure. | 746 | * @phba: pointer to lpfc hba data structure. |
746 | * @vpi: virtual N_Port identifier. | 747 | * @vpi: virtual N_Port identifier. |
747 | * @pmb: pointer to the driver internal queue element for mailbox command. | 748 | * @pmb: pointer to the driver internal queue element for mailbox command. |
@@ -771,7 +772,7 @@ lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb) | |||
771 | } | 772 | } |
772 | 773 | ||
773 | /** | 774 | /** |
774 | * lpfc_config_pcb_setup: Set up IOCB rings in the Port Control Block (PCB) | 775 | * lpfc_config_pcb_setup - Set up IOCB rings in the Port Control Block (PCB) |
775 | * @phba: pointer to lpfc hba data structure. | 776 | * @phba: pointer to lpfc hba data structure. |
776 | * | 777 | * |
777 | * This routine sets up and initializes the IOCB rings in the Port Control | 778 | * This routine sets up and initializes the IOCB rings in the Port Control |
@@ -835,7 +836,7 @@ lpfc_config_pcb_setup(struct lpfc_hba * phba) | |||
835 | } | 836 | } |
836 | 837 | ||
837 | /** | 838 | /** |
838 | * lpfc_read_rev: Prepare a mailbox command for reading HBA revision. | 839 | * lpfc_read_rev - Prepare a mailbox command for reading HBA revision |
839 | * @phba: pointer to lpfc hba data structure. | 840 | * @phba: pointer to lpfc hba data structure. |
840 | * @pmb: pointer to the driver internal queue element for mailbox command. | 841 | * @pmb: pointer to the driver internal queue element for mailbox command. |
841 | * | 842 | * |
@@ -861,7 +862,7 @@ lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
861 | } | 862 | } |
862 | 863 | ||
863 | /** | 864 | /** |
864 | * lpfc_build_hbq_profile2: Set up the HBQ Selection Profile 2. | 865 | * lpfc_build_hbq_profile2 - Set up the HBQ Selection Profile 2 |
865 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | 866 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. |
866 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | 867 | * @hbq_desc: pointer to the HBQ selection profile descriptor. |
867 | * | 868 | * |
@@ -880,7 +881,7 @@ lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb, | |||
880 | } | 881 | } |
881 | 882 | ||
882 | /** | 883 | /** |
883 | * lpfc_build_hbq_profile3: Set up the HBQ Selection Profile 3. | 884 | * lpfc_build_hbq_profile3 - Set up the HBQ Selection Profile 3 |
884 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | 885 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. |
885 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | 886 | * @hbq_desc: pointer to the HBQ selection profile descriptor. |
886 | * | 887 | * |
@@ -902,7 +903,7 @@ lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb, | |||
902 | } | 903 | } |
903 | 904 | ||
904 | /** | 905 | /** |
905 | * lpfc_build_hbq_profile5: Set up the HBQ Selection Profile 5. | 906 | * lpfc_build_hbq_profile5 - Set up the HBQ Selection Profile 5 |
906 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. | 907 | * @hbqmb: pointer to the HBQ configuration data structure in mailbox command. |
907 | * @hbq_desc: pointer to the HBQ selection profile descriptor. | 908 | * @hbq_desc: pointer to the HBQ selection profile descriptor. |
908 | * | 909 | * |
@@ -925,7 +926,7 @@ lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb, | |||
925 | } | 926 | } |
926 | 927 | ||
927 | /** | 928 | /** |
928 | * lpfc_config_hbq: Prepare a mailbox command for configuring an HBQ. | 929 | * lpfc_config_hbq - Prepare a mailbox command for configuring an HBQ |
929 | * @phba: pointer to lpfc hba data structure. | 930 | * @phba: pointer to lpfc hba data structure. |
930 | * @id: HBQ identifier. | 931 | * @id: HBQ identifier. |
931 | * @hbq_desc: pointer to the HBA descriptor data structure. | 932 | * @hbq_desc: pointer to the HBA descriptor data structure. |
@@ -999,7 +1000,7 @@ lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id, | |||
999 | } | 1000 | } |
1000 | 1001 | ||
1001 | /** | 1002 | /** |
1002 | * lpfc_config_ring: Prepare a mailbox command for configuring an IOCB ring. | 1003 | * lpfc_config_ring - Prepare a mailbox command for configuring an IOCB ring |
1003 | * @phba: pointer to lpfc hba data structure. | 1004 | * @phba: pointer to lpfc hba data structure. |
1004 | * @ring: | 1005 | * @ring: |
1005 | * @pmb: pointer to the driver internal queue element for mailbox command. | 1006 | * @pmb: pointer to the driver internal queue element for mailbox command. |
@@ -1057,7 +1058,7 @@ lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb) | |||
1057 | } | 1058 | } |
1058 | 1059 | ||
1059 | /** | 1060 | /** |
1060 | * lpfc_config_port: Prepare a mailbox command for configuring port. | 1061 | * lpfc_config_port - Prepare a mailbox command for configuring port |
1061 | * @phba: pointer to lpfc hba data structure. | 1062 | * @phba: pointer to lpfc hba data structure. |
1062 | * @pmb: pointer to the driver internal queue element for mailbox command. | 1063 | * @pmb: pointer to the driver internal queue element for mailbox command. |
1063 | * | 1064 | * |
@@ -1227,7 +1228,7 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1227 | } | 1228 | } |
1228 | 1229 | ||
1229 | /** | 1230 | /** |
1230 | * lpfc_kill_board: Prepare a mailbox command for killing board. | 1231 | * lpfc_kill_board - Prepare a mailbox command for killing board |
1231 | * @phba: pointer to lpfc hba data structure. | 1232 | * @phba: pointer to lpfc hba data structure. |
1232 | * @pmb: pointer to the driver internal queue element for mailbox command. | 1233 | * @pmb: pointer to the driver internal queue element for mailbox command. |
1233 | * | 1234 | * |
@@ -1253,7 +1254,7 @@ lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) | |||
1253 | } | 1254 | } |
1254 | 1255 | ||
1255 | /** | 1256 | /** |
1256 | * lpfc_mbox_put: Put a mailbox cmd into the tail of driver's mailbox queue. | 1257 | * lpfc_mbox_put - Put a mailbox cmd into the tail of driver's mailbox queue |
1257 | * @phba: pointer to lpfc hba data structure. | 1258 | * @phba: pointer to lpfc hba data structure. |
1258 | * @mbq: pointer to the driver internal queue element for mailbox command. | 1259 | * @mbq: pointer to the driver internal queue element for mailbox command. |
1259 | * | 1260 | * |
@@ -1277,7 +1278,7 @@ lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |||
1277 | } | 1278 | } |
1278 | 1279 | ||
1279 | /** | 1280 | /** |
1280 | * lpfc_mbox_get: Remove a mailbox cmd from the head of driver's mailbox queue. | 1281 | * lpfc_mbox_get - Remove a mailbox cmd from the head of driver's mailbox queue |
1281 | * @phba: pointer to lpfc hba data structure. | 1282 | * @phba: pointer to lpfc hba data structure. |
1282 | * | 1283 | * |
1283 | * Driver maintains a internal mailbox command queue implemented as a linked | 1284 | * Driver maintains a internal mailbox command queue implemented as a linked |
@@ -1304,7 +1305,7 @@ lpfc_mbox_get(struct lpfc_hba * phba) | |||
1304 | } | 1305 | } |
1305 | 1306 | ||
1306 | /** | 1307 | /** |
1307 | * lpfc_mbox_cmpl_put: Put mailbox command into mailbox command complete list. | 1308 | * lpfc_mbox_cmpl_put - Put mailbox command into mailbox command complete list |
1308 | * @phba: pointer to lpfc hba data structure. | 1309 | * @phba: pointer to lpfc hba data structure. |
1309 | * @mbq: pointer to the driver internal queue element for mailbox command. | 1310 | * @mbq: pointer to the driver internal queue element for mailbox command. |
1310 | * | 1311 | * |
@@ -1327,7 +1328,7 @@ lpfc_mbox_cmpl_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq) | |||
1327 | } | 1328 | } |
1328 | 1329 | ||
1329 | /** | 1330 | /** |
1330 | * lpfc_mbox_tmo_val: Retrieve mailbox command timeout value. | 1331 | * lpfc_mbox_tmo_val - Retrieve mailbox command timeout value |
1331 | * @phba: pointer to lpfc hba data structure. | 1332 | * @phba: pointer to lpfc hba data structure. |
1332 | * @cmd: mailbox command code. | 1333 | * @cmd: mailbox command code. |
1333 | * | 1334 | * |
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c index a4bba2069248..35a976733398 100644 --- a/drivers/scsi/lpfc/lpfc_mem.c +++ b/drivers/scsi/lpfc/lpfc_mem.c | |||
@@ -41,7 +41,7 @@ | |||
41 | 41 | ||
42 | 42 | ||
43 | /** | 43 | /** |
44 | * lpfc_mem_alloc: create and allocate all PCI and memory pools | 44 | * lpfc_mem_alloc - create and allocate all PCI and memory pools |
45 | * @phba: HBA to allocate pools for | 45 | * @phba: HBA to allocate pools for |
46 | * | 46 | * |
47 | * Description: Creates and allocates PCI pools lpfc_scsi_dma_buf_pool, | 47 | * Description: Creates and allocates PCI pools lpfc_scsi_dma_buf_pool, |
@@ -136,12 +136,12 @@ lpfc_mem_alloc(struct lpfc_hba * phba) | |||
136 | } | 136 | } |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * lpfc_mem_free: Frees all PCI and memory allocated by lpfc_mem_alloc | 139 | * lpfc_mem_free - Frees all PCI and memory allocated by lpfc_mem_alloc |
140 | * @phba: HBA to free memory for | 140 | * @phba: HBA to free memory for |
141 | * | 141 | * |
142 | * Description: Frees PCI pools lpfc_scsi_dma_buf_pool, lpfc_mbuf_pool, | 142 | * Description: Frees PCI pools lpfc_scsi_dma_buf_pool, lpfc_mbuf_pool, |
143 | * lpfc_hbq_pool. Frees kmalloc-backed mempools for LPFC_MBOXQ_t and | 143 | * lpfc_hbq_pool. Frees kmalloc-backed mempools for LPFC_MBOXQ_t and |
144 | * lpfc_nodelist. Also frees the VPI bitmask. | 144 | * lpfc_nodelist. Also frees the VPI bitmask |
145 | * | 145 | * |
146 | * Returns: None | 146 | * Returns: None |
147 | **/ | 147 | **/ |
@@ -212,7 +212,7 @@ lpfc_mem_free(struct lpfc_hba * phba) | |||
212 | } | 212 | } |
213 | 213 | ||
214 | /** | 214 | /** |
215 | * lpfc_mbuf_alloc: Allocate an mbuf from the lpfc_mbuf_pool PCI pool | 215 | * lpfc_mbuf_alloc - Allocate an mbuf from the lpfc_mbuf_pool PCI pool |
216 | * @phba: HBA which owns the pool to allocate from | 216 | * @phba: HBA which owns the pool to allocate from |
217 | * @mem_flags: indicates if this is a priority (MEM_PRI) allocation | 217 | * @mem_flags: indicates if this is a priority (MEM_PRI) allocation |
218 | * @handle: used to return the DMA-mapped address of the mbuf | 218 | * @handle: used to return the DMA-mapped address of the mbuf |
@@ -249,7 +249,7 @@ lpfc_mbuf_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle) | |||
249 | } | 249 | } |
250 | 250 | ||
251 | /** | 251 | /** |
252 | * __lpfc_mem_free: Free an mbuf from the lpfc_mbuf_pool PCI pool (locked) | 252 | * __lpfc_mbuf_free - Free an mbuf from the lpfc_mbuf_pool PCI pool (locked) |
253 | * @phba: HBA which owns the pool to return to | 253 | * @phba: HBA which owns the pool to return to |
254 | * @virt: mbuf to free | 254 | * @virt: mbuf to free |
255 | * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed | 255 | * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed |
@@ -278,7 +278,7 @@ __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |||
278 | } | 278 | } |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * lpfc_mem_free: Free an mbuf from the lpfc_mbuf_pool PCI pool (unlocked) | 281 | * lpfc_mbuf_free - Free an mbuf from the lpfc_mbuf_pool PCI pool (unlocked) |
282 | * @phba: HBA which owns the pool to return to | 282 | * @phba: HBA which owns the pool to return to |
283 | * @virt: mbuf to free | 283 | * @virt: mbuf to free |
284 | * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed | 284 | * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed |
@@ -291,7 +291,6 @@ __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |||
291 | * Returns: None | 291 | * Returns: None |
292 | **/ | 292 | **/ |
293 | void | 293 | void |
294 | |||
295 | lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | 294 | lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) |
296 | { | 295 | { |
297 | unsigned long iflags; | 296 | unsigned long iflags; |
@@ -303,7 +302,7 @@ lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |||
303 | } | 302 | } |
304 | 303 | ||
305 | /** | 304 | /** |
306 | * lpfc_els_hbq_alloc: Allocate an HBQ buffer | 305 | * lpfc_els_hbq_alloc - Allocate an HBQ buffer |
307 | * @phba: HBA to allocate HBQ buffer for | 306 | * @phba: HBA to allocate HBQ buffer for |
308 | * | 307 | * |
309 | * Description: Allocates a DMA-mapped HBQ buffer from the lpfc_hbq_pool PCI | 308 | * Description: Allocates a DMA-mapped HBQ buffer from the lpfc_hbq_pool PCI |
@@ -335,7 +334,7 @@ lpfc_els_hbq_alloc(struct lpfc_hba *phba) | |||
335 | } | 334 | } |
336 | 335 | ||
337 | /** | 336 | /** |
338 | * lpfc_mem_hbq_free: Frees an HBQ buffer allocated with lpfc_els_hbq_alloc | 337 | * lpfc_mem_hbq_free - Frees an HBQ buffer allocated with lpfc_els_hbq_alloc |
339 | * @phba: HBA buffer was allocated for | 338 | * @phba: HBA buffer was allocated for |
340 | * @hbqbp: HBQ container returned by lpfc_els_hbq_alloc | 339 | * @hbqbp: HBQ container returned by lpfc_els_hbq_alloc |
341 | * | 340 | * |
@@ -355,7 +354,7 @@ lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp) | |||
355 | } | 354 | } |
356 | 355 | ||
357 | /** | 356 | /** |
358 | * lpfc_in_buf_free: Free a DMA buffer | 357 | * lpfc_in_buf_free - Free a DMA buffer |
359 | * @phba: HBA buffer is associated with | 358 | * @phba: HBA buffer is associated with |
360 | * @mp: Buffer to free | 359 | * @mp: Buffer to free |
361 | * | 360 | * |
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 8f548adae9cc..08cdc77af41c 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c | |||
@@ -192,7 +192,6 @@ lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
192 | struct lpfc_sli *psli = &phba->sli; | 192 | struct lpfc_sli *psli = &phba->sli; |
193 | struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING]; | 193 | struct lpfc_sli_ring *pring = &psli->ring[LPFC_ELS_RING]; |
194 | struct lpfc_iocbq *iocb, *next_iocb; | 194 | struct lpfc_iocbq *iocb, *next_iocb; |
195 | IOCB_t *cmd; | ||
196 | 195 | ||
197 | /* Abort outstanding I/O on NPort <nlp_DID> */ | 196 | /* Abort outstanding I/O on NPort <nlp_DID> */ |
198 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY, | 197 | lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY, |
@@ -223,19 +222,10 @@ lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) | |||
223 | } | 222 | } |
224 | spin_unlock_irq(&phba->hbalock); | 223 | spin_unlock_irq(&phba->hbalock); |
225 | 224 | ||
226 | while (!list_empty(&completions)) { | 225 | /* Cancel all the IOCBs from the completions list */ |
227 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); | 226 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
228 | cmd = &iocb->iocb; | 227 | IOERR_SLI_ABORTED); |
229 | list_del_init(&iocb->list); | 228 | |
230 | |||
231 | if (!iocb->iocb_cmpl) | ||
232 | lpfc_sli_release_iocbq(phba, iocb); | ||
233 | else { | ||
234 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
235 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
236 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
237 | } | ||
238 | } | ||
239 | lpfc_cancel_retry_delay_tmo(phba->pport, ndlp); | 229 | lpfc_cancel_retry_delay_tmo(phba->pport, ndlp); |
240 | return 0; | 230 | return 0; |
241 | } | 231 | } |
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 36fd2e75da1c..167b66dd34c7 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -112,7 +112,7 @@ lpfc_debug_save_dif(struct scsi_cmnd *cmnd) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * lpfc_update_stats: Update statistical data for the command completion. | 115 | * lpfc_update_stats - Update statistical data for the command completion |
116 | * @phba: Pointer to HBA object. | 116 | * @phba: Pointer to HBA object. |
117 | * @lpfc_cmd: lpfc scsi command object pointer. | 117 | * @lpfc_cmd: lpfc scsi command object pointer. |
118 | * | 118 | * |
@@ -165,8 +165,7 @@ lpfc_update_stats(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
165 | } | 165 | } |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * lpfc_send_sdev_queuedepth_change_event: Posts a queuedepth change | 168 | * lpfc_send_sdev_queuedepth_change_event - Posts a queuedepth change event |
169 | * event. | ||
170 | * @phba: Pointer to HBA context object. | 169 | * @phba: Pointer to HBA context object. |
171 | * @vport: Pointer to vport object. | 170 | * @vport: Pointer to vport object. |
172 | * @ndlp: Pointer to FC node associated with the target. | 171 | * @ndlp: Pointer to FC node associated with the target. |
@@ -220,7 +219,7 @@ lpfc_send_sdev_queuedepth_change_event(struct lpfc_hba *phba, | |||
220 | } | 219 | } |
221 | 220 | ||
222 | /** | 221 | /** |
223 | * lpfc_rampdown_queue_depth: Post RAMP_DOWN_QUEUE event to worker thread. | 222 | * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread |
224 | * @phba: The Hba for which this call is being executed. | 223 | * @phba: The Hba for which this call is being executed. |
225 | * | 224 | * |
226 | * This routine is called when there is resource error in driver or firmware. | 225 | * This routine is called when there is resource error in driver or firmware. |
@@ -261,7 +260,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba) | |||
261 | } | 260 | } |
262 | 261 | ||
263 | /** | 262 | /** |
264 | * lpfc_rampup_queue_depth: Post RAMP_UP_QUEUE event for worker thread. | 263 | * lpfc_rampup_queue_depth - Post RAMP_UP_QUEUE event for worker thread |
265 | * @phba: The Hba for which this call is being executed. | 264 | * @phba: The Hba for which this call is being executed. |
266 | * | 265 | * |
267 | * This routine post WORKER_RAMP_UP_QUEUE event for @phba vport. This routine | 266 | * This routine post WORKER_RAMP_UP_QUEUE event for @phba vport. This routine |
@@ -273,14 +272,14 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba) | |||
273 | **/ | 272 | **/ |
274 | static inline void | 273 | static inline void |
275 | lpfc_rampup_queue_depth(struct lpfc_vport *vport, | 274 | lpfc_rampup_queue_depth(struct lpfc_vport *vport, |
276 | struct scsi_device *sdev) | 275 | uint32_t queue_depth) |
277 | { | 276 | { |
278 | unsigned long flags; | 277 | unsigned long flags; |
279 | struct lpfc_hba *phba = vport->phba; | 278 | struct lpfc_hba *phba = vport->phba; |
280 | uint32_t evt_posted; | 279 | uint32_t evt_posted; |
281 | atomic_inc(&phba->num_cmd_success); | 280 | atomic_inc(&phba->num_cmd_success); |
282 | 281 | ||
283 | if (vport->cfg_lun_queue_depth <= sdev->queue_depth) | 282 | if (vport->cfg_lun_queue_depth <= queue_depth) |
284 | return; | 283 | return; |
285 | spin_lock_irqsave(&phba->hbalock, flags); | 284 | spin_lock_irqsave(&phba->hbalock, flags); |
286 | if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || | 285 | if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || |
@@ -303,7 +302,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport, | |||
303 | } | 302 | } |
304 | 303 | ||
305 | /** | 304 | /** |
306 | * lpfc_ramp_down_queue_handler: WORKER_RAMP_DOWN_QUEUE event handler. | 305 | * lpfc_ramp_down_queue_handler - WORKER_RAMP_DOWN_QUEUE event handler |
307 | * @phba: The Hba for which this call is being executed. | 306 | * @phba: The Hba for which this call is being executed. |
308 | * | 307 | * |
309 | * This routine is called to process WORKER_RAMP_DOWN_QUEUE event for worker | 308 | * This routine is called to process WORKER_RAMP_DOWN_QUEUE event for worker |
@@ -361,7 +360,7 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) | |||
361 | } | 360 | } |
362 | 361 | ||
363 | /** | 362 | /** |
364 | * lpfc_ramp_up_queue_handler: WORKER_RAMP_UP_QUEUE event handler. | 363 | * lpfc_ramp_up_queue_handler - WORKER_RAMP_UP_QUEUE event handler |
365 | * @phba: The Hba for which this call is being executed. | 364 | * @phba: The Hba for which this call is being executed. |
366 | * | 365 | * |
367 | * This routine is called to process WORKER_RAMP_UP_QUEUE event for worker | 366 | * This routine is called to process WORKER_RAMP_UP_QUEUE event for worker |
@@ -410,7 +409,7 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) | |||
410 | } | 409 | } |
411 | 410 | ||
412 | /** | 411 | /** |
413 | * lpfc_scsi_dev_block: set all scsi hosts to block state. | 412 | * lpfc_scsi_dev_block - set all scsi hosts to block state |
414 | * @phba: Pointer to HBA context object. | 413 | * @phba: Pointer to HBA context object. |
415 | * | 414 | * |
416 | * This function walks vport list and set each SCSI host to block state | 415 | * This function walks vport list and set each SCSI host to block state |
@@ -439,7 +438,7 @@ lpfc_scsi_dev_block(struct lpfc_hba *phba) | |||
439 | } | 438 | } |
440 | 439 | ||
441 | /** | 440 | /** |
442 | * lpfc_new_scsi_buf: Scsi buffer allocator. | 441 | * lpfc_new_scsi_buf - Scsi buffer allocator |
443 | * @vport: The virtual port for which this call being executed. | 442 | * @vport: The virtual port for which this call being executed. |
444 | * | 443 | * |
445 | * This routine allocates a scsi buffer, which contains all the necessary | 444 | * This routine allocates a scsi buffer, which contains all the necessary |
@@ -563,7 +562,7 @@ lpfc_new_scsi_buf(struct lpfc_vport *vport) | |||
563 | } | 562 | } |
564 | 563 | ||
565 | /** | 564 | /** |
566 | * lpfc_get_scsi_buf: Get a scsi buffer from lpfc_scsi_buf_list list of Hba. | 565 | * lpfc_get_scsi_buf - Get a scsi buffer from lpfc_scsi_buf_list list of Hba |
567 | * @phba: The Hba for which this call is being executed. | 566 | * @phba: The Hba for which this call is being executed. |
568 | * | 567 | * |
569 | * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list | 568 | * This routine removes a scsi buffer from head of @phba lpfc_scsi_buf_list list |
@@ -592,7 +591,7 @@ lpfc_get_scsi_buf(struct lpfc_hba * phba) | |||
592 | } | 591 | } |
593 | 592 | ||
594 | /** | 593 | /** |
595 | * lpfc_release_scsi_buf: Return a scsi buffer back to hba lpfc_scsi_buf_list list. | 594 | * lpfc_release_scsi_buf - Return a scsi buffer back to hba's lpfc_scsi_buf_list |
596 | * @phba: The Hba for which this call is being executed. | 595 | * @phba: The Hba for which this call is being executed. |
597 | * @psb: The scsi buffer which is being released. | 596 | * @psb: The scsi buffer which is being released. |
598 | * | 597 | * |
@@ -611,7 +610,7 @@ lpfc_release_scsi_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb) | |||
611 | } | 610 | } |
612 | 611 | ||
613 | /** | 612 | /** |
614 | * lpfc_scsi_prep_dma_buf: Routine to do DMA mapping for scsi buffer. | 613 | * lpfc_scsi_prep_dma_buf - Routine to do DMA mapping for scsi buffer |
615 | * @phba: The Hba for which this call is being executed. | 614 | * @phba: The Hba for which this call is being executed. |
616 | * @lpfc_cmd: The scsi buffer which is going to be mapped. | 615 | * @lpfc_cmd: The scsi buffer which is going to be mapped. |
617 | * | 616 | * |
@@ -738,7 +737,7 @@ lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) | |||
738 | * Due to difference in data length between DIF/non-DIF paths, | 737 | * Due to difference in data length between DIF/non-DIF paths, |
739 | * we need to set word 4 of IOCB here | 738 | * we need to set word 4 of IOCB here |
740 | */ | 739 | */ |
741 | iocb_cmd->un.fcpi.fcpi_parm = le32_to_cpu(scsi_bufflen(scsi_cmnd)); | 740 | iocb_cmd->un.fcpi.fcpi_parm = scsi_bufflen(scsi_cmnd); |
742 | return 0; | 741 | return 0; |
743 | } | 742 | } |
744 | 743 | ||
@@ -823,9 +822,9 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc) | |||
823 | /** | 822 | /** |
824 | * lpfc_get_cmd_dif_parms - Extract DIF parameters from SCSI command | 823 | * lpfc_get_cmd_dif_parms - Extract DIF parameters from SCSI command |
825 | * @sc: in: SCSI command | 824 | * @sc: in: SCSI command |
826 | * @apptagmask out: app tag mask | 825 | * @apptagmask: out: app tag mask |
827 | * @apptagval out: app tag value | 826 | * @apptagval: out: app tag value |
828 | * @reftag out: ref tag (reference tag) | 827 | * @reftag: out: ref tag (reference tag) |
829 | * | 828 | * |
830 | * Description: | 829 | * Description: |
831 | * Extract DIF paramters from the command if possible. Otherwise, | 830 | * Extract DIF paramters from the command if possible. Otherwise, |
@@ -1413,7 +1412,7 @@ out: | |||
1413 | } | 1412 | } |
1414 | 1413 | ||
1415 | /** | 1414 | /** |
1416 | * lpfc_send_scsi_error_event: Posts an event when there is SCSI error. | 1415 | * lpfc_send_scsi_error_event - Posts an event when there is SCSI error |
1417 | * @phba: Pointer to hba context object. | 1416 | * @phba: Pointer to hba context object. |
1418 | * @vport: Pointer to vport object. | 1417 | * @vport: Pointer to vport object. |
1419 | * @lpfc_cmd: Pointer to lpfc scsi command which reported the error. | 1418 | * @lpfc_cmd: Pointer to lpfc scsi command which reported the error. |
@@ -1505,7 +1504,7 @@ lpfc_send_scsi_error_event(struct lpfc_hba *phba, struct lpfc_vport *vport, | |||
1505 | } | 1504 | } |
1506 | 1505 | ||
1507 | /** | 1506 | /** |
1508 | * lpfc_scsi_unprep_dma_buf: Routine to un-map DMA mapping of scatter gather. | 1507 | * lpfc_scsi_unprep_dma_buf - Routine to un-map DMA mapping of scatter gather |
1509 | * @phba: The Hba for which this call is being executed. | 1508 | * @phba: The Hba for which this call is being executed. |
1510 | * @psb: The scsi buffer which is going to be un-mapped. | 1509 | * @psb: The scsi buffer which is going to be un-mapped. |
1511 | * | 1510 | * |
@@ -1530,7 +1529,7 @@ lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) | |||
1530 | } | 1529 | } |
1531 | 1530 | ||
1532 | /** | 1531 | /** |
1533 | * lpfc_handler_fcp_err: FCP response handler. | 1532 | * lpfc_handler_fcp_err - FCP response handler |
1534 | * @vport: The virtual port for which this call is being executed. | 1533 | * @vport: The virtual port for which this call is being executed. |
1535 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. | 1534 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
1536 | * @rsp_iocb: The response IOCB which contains FCP error. | 1535 | * @rsp_iocb: The response IOCB which contains FCP error. |
@@ -1674,7 +1673,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |||
1674 | } | 1673 | } |
1675 | 1674 | ||
1676 | /** | 1675 | /** |
1677 | * lpfc_scsi_cmd_iocb_cmpl: Scsi cmnd IOCB completion routine. | 1676 | * lpfc_scsi_cmd_iocb_cmpl - Scsi cmnd IOCB completion routine |
1678 | * @phba: The Hba for which this call is being executed. | 1677 | * @phba: The Hba for which this call is being executed. |
1679 | * @pIocbIn: The command IOCBQ for the scsi cmnd. | 1678 | * @pIocbIn: The command IOCBQ for the scsi cmnd. |
1680 | * @pIocbOut: The response IOCBQ for the scsi cmnd . | 1679 | * @pIocbOut: The response IOCBQ for the scsi cmnd . |
@@ -1694,10 +1693,12 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1694 | struct lpfc_nodelist *pnode = rdata->pnode; | 1693 | struct lpfc_nodelist *pnode = rdata->pnode; |
1695 | struct scsi_cmnd *cmd = lpfc_cmd->pCmd; | 1694 | struct scsi_cmnd *cmd = lpfc_cmd->pCmd; |
1696 | int result; | 1695 | int result; |
1697 | struct scsi_device *sdev, *tmp_sdev; | 1696 | struct scsi_device *tmp_sdev; |
1698 | int depth = 0; | 1697 | int depth = 0; |
1699 | unsigned long flags; | 1698 | unsigned long flags; |
1700 | struct lpfc_fast_path_event *fast_path_evt; | 1699 | struct lpfc_fast_path_event *fast_path_evt; |
1700 | struct Scsi_Host *shost = cmd->device->host; | ||
1701 | uint32_t queue_depth, scsi_id; | ||
1701 | 1702 | ||
1702 | lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; | 1703 | lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; |
1703 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; | 1704 | lpfc_cmd->status = pIocbOut->iocb.ulpStatus; |
@@ -1808,11 +1809,10 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1808 | 1809 | ||
1809 | lpfc_update_stats(phba, lpfc_cmd); | 1810 | lpfc_update_stats(phba, lpfc_cmd); |
1810 | result = cmd->result; | 1811 | result = cmd->result; |
1811 | sdev = cmd->device; | ||
1812 | if (vport->cfg_max_scsicmpl_time && | 1812 | if (vport->cfg_max_scsicmpl_time && |
1813 | time_after(jiffies, lpfc_cmd->start_time + | 1813 | time_after(jiffies, lpfc_cmd->start_time + |
1814 | msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) { | 1814 | msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) { |
1815 | spin_lock_irqsave(sdev->host->host_lock, flags); | 1815 | spin_lock_irqsave(shost->host_lock, flags); |
1816 | if (pnode && NLP_CHK_NODE_ACT(pnode)) { | 1816 | if (pnode && NLP_CHK_NODE_ACT(pnode)) { |
1817 | if (pnode->cmd_qdepth > | 1817 | if (pnode->cmd_qdepth > |
1818 | atomic_read(&pnode->cmd_pending) && | 1818 | atomic_read(&pnode->cmd_pending) && |
@@ -1825,22 +1825,26 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1825 | 1825 | ||
1826 | pnode->last_change_time = jiffies; | 1826 | pnode->last_change_time = jiffies; |
1827 | } | 1827 | } |
1828 | spin_unlock_irqrestore(sdev->host->host_lock, flags); | 1828 | spin_unlock_irqrestore(shost->host_lock, flags); |
1829 | } else if (pnode && NLP_CHK_NODE_ACT(pnode)) { | 1829 | } else if (pnode && NLP_CHK_NODE_ACT(pnode)) { |
1830 | if ((pnode->cmd_qdepth < LPFC_MAX_TGT_QDEPTH) && | 1830 | if ((pnode->cmd_qdepth < LPFC_MAX_TGT_QDEPTH) && |
1831 | time_after(jiffies, pnode->last_change_time + | 1831 | time_after(jiffies, pnode->last_change_time + |
1832 | msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) { | 1832 | msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) { |
1833 | spin_lock_irqsave(sdev->host->host_lock, flags); | 1833 | spin_lock_irqsave(shost->host_lock, flags); |
1834 | pnode->cmd_qdepth += pnode->cmd_qdepth * | 1834 | pnode->cmd_qdepth += pnode->cmd_qdepth * |
1835 | LPFC_TGTQ_RAMPUP_PCENT / 100; | 1835 | LPFC_TGTQ_RAMPUP_PCENT / 100; |
1836 | if (pnode->cmd_qdepth > LPFC_MAX_TGT_QDEPTH) | 1836 | if (pnode->cmd_qdepth > LPFC_MAX_TGT_QDEPTH) |
1837 | pnode->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; | 1837 | pnode->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; |
1838 | pnode->last_change_time = jiffies; | 1838 | pnode->last_change_time = jiffies; |
1839 | spin_unlock_irqrestore(sdev->host->host_lock, flags); | 1839 | spin_unlock_irqrestore(shost->host_lock, flags); |
1840 | } | 1840 | } |
1841 | } | 1841 | } |
1842 | 1842 | ||
1843 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); | 1843 | lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); |
1844 | |||
1845 | /* The sdev is not guaranteed to be valid post scsi_done upcall. */ | ||
1846 | queue_depth = cmd->device->queue_depth; | ||
1847 | scsi_id = cmd->device->id; | ||
1844 | cmd->scsi_done(cmd); | 1848 | cmd->scsi_done(cmd); |
1845 | 1849 | ||
1846 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { | 1850 | if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { |
@@ -1848,28 +1852,28 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1848 | * If there is a thread waiting for command completion | 1852 | * If there is a thread waiting for command completion |
1849 | * wake up the thread. | 1853 | * wake up the thread. |
1850 | */ | 1854 | */ |
1851 | spin_lock_irqsave(sdev->host->host_lock, flags); | 1855 | spin_lock_irqsave(shost->host_lock, flags); |
1852 | lpfc_cmd->pCmd = NULL; | 1856 | lpfc_cmd->pCmd = NULL; |
1853 | if (lpfc_cmd->waitq) | 1857 | if (lpfc_cmd->waitq) |
1854 | wake_up(lpfc_cmd->waitq); | 1858 | wake_up(lpfc_cmd->waitq); |
1855 | spin_unlock_irqrestore(sdev->host->host_lock, flags); | 1859 | spin_unlock_irqrestore(shost->host_lock, flags); |
1856 | lpfc_release_scsi_buf(phba, lpfc_cmd); | 1860 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
1857 | return; | 1861 | return; |
1858 | } | 1862 | } |
1859 | 1863 | ||
1860 | 1864 | ||
1861 | if (!result) | 1865 | if (!result) |
1862 | lpfc_rampup_queue_depth(vport, sdev); | 1866 | lpfc_rampup_queue_depth(vport, queue_depth); |
1863 | 1867 | ||
1864 | if (!result && pnode && NLP_CHK_NODE_ACT(pnode) && | 1868 | if (!result && pnode && NLP_CHK_NODE_ACT(pnode) && |
1865 | ((jiffies - pnode->last_ramp_up_time) > | 1869 | ((jiffies - pnode->last_ramp_up_time) > |
1866 | LPFC_Q_RAMP_UP_INTERVAL * HZ) && | 1870 | LPFC_Q_RAMP_UP_INTERVAL * HZ) && |
1867 | ((jiffies - pnode->last_q_full_time) > | 1871 | ((jiffies - pnode->last_q_full_time) > |
1868 | LPFC_Q_RAMP_UP_INTERVAL * HZ) && | 1872 | LPFC_Q_RAMP_UP_INTERVAL * HZ) && |
1869 | (vport->cfg_lun_queue_depth > sdev->queue_depth)) { | 1873 | (vport->cfg_lun_queue_depth > queue_depth)) { |
1870 | shost_for_each_device(tmp_sdev, sdev->host) { | 1874 | shost_for_each_device(tmp_sdev, shost) { |
1871 | if (vport->cfg_lun_queue_depth > tmp_sdev->queue_depth){ | 1875 | if (vport->cfg_lun_queue_depth > tmp_sdev->queue_depth){ |
1872 | if (tmp_sdev->id != sdev->id) | 1876 | if (tmp_sdev->id != scsi_id) |
1873 | continue; | 1877 | continue; |
1874 | if (tmp_sdev->ordered_tags) | 1878 | if (tmp_sdev->ordered_tags) |
1875 | scsi_adjust_queue_depth(tmp_sdev, | 1879 | scsi_adjust_queue_depth(tmp_sdev, |
@@ -1885,7 +1889,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1885 | } | 1889 | } |
1886 | lpfc_send_sdev_queuedepth_change_event(phba, vport, pnode, | 1890 | lpfc_send_sdev_queuedepth_change_event(phba, vport, pnode, |
1887 | 0xFFFFFFFF, | 1891 | 0xFFFFFFFF, |
1888 | sdev->queue_depth - 1, sdev->queue_depth); | 1892 | queue_depth , queue_depth + 1); |
1889 | } | 1893 | } |
1890 | 1894 | ||
1891 | /* | 1895 | /* |
@@ -1896,8 +1900,8 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1896 | NLP_CHK_NODE_ACT(pnode)) { | 1900 | NLP_CHK_NODE_ACT(pnode)) { |
1897 | pnode->last_q_full_time = jiffies; | 1901 | pnode->last_q_full_time = jiffies; |
1898 | 1902 | ||
1899 | shost_for_each_device(tmp_sdev, sdev->host) { | 1903 | shost_for_each_device(tmp_sdev, shost) { |
1900 | if (tmp_sdev->id != sdev->id) | 1904 | if (tmp_sdev->id != scsi_id) |
1901 | continue; | 1905 | continue; |
1902 | depth = scsi_track_queue_full(tmp_sdev, | 1906 | depth = scsi_track_queue_full(tmp_sdev, |
1903 | tmp_sdev->queue_depth - 1); | 1907 | tmp_sdev->queue_depth - 1); |
@@ -1909,7 +1913,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1909 | * scsi_track_queue_full. | 1913 | * scsi_track_queue_full. |
1910 | */ | 1914 | */ |
1911 | if (depth == -1) | 1915 | if (depth == -1) |
1912 | depth = sdev->host->cmd_per_lun; | 1916 | depth = shost->cmd_per_lun; |
1913 | 1917 | ||
1914 | if (depth) { | 1918 | if (depth) { |
1915 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, | 1919 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, |
@@ -1925,17 +1929,17 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
1925 | * If there is a thread waiting for command completion | 1929 | * If there is a thread waiting for command completion |
1926 | * wake up the thread. | 1930 | * wake up the thread. |
1927 | */ | 1931 | */ |
1928 | spin_lock_irqsave(sdev->host->host_lock, flags); | 1932 | spin_lock_irqsave(shost->host_lock, flags); |
1929 | lpfc_cmd->pCmd = NULL; | 1933 | lpfc_cmd->pCmd = NULL; |
1930 | if (lpfc_cmd->waitq) | 1934 | if (lpfc_cmd->waitq) |
1931 | wake_up(lpfc_cmd->waitq); | 1935 | wake_up(lpfc_cmd->waitq); |
1932 | spin_unlock_irqrestore(sdev->host->host_lock, flags); | 1936 | spin_unlock_irqrestore(shost->host_lock, flags); |
1933 | 1937 | ||
1934 | lpfc_release_scsi_buf(phba, lpfc_cmd); | 1938 | lpfc_release_scsi_buf(phba, lpfc_cmd); |
1935 | } | 1939 | } |
1936 | 1940 | ||
1937 | /** | 1941 | /** |
1938 | * lpfc_fcpcmd_to_iocb - copy the fcp_cmd data into the IOCB. | 1942 | * lpfc_fcpcmd_to_iocb - copy the fcp_cmd data into the IOCB |
1939 | * @data: A pointer to the immediate command data portion of the IOCB. | 1943 | * @data: A pointer to the immediate command data portion of the IOCB. |
1940 | * @fcp_cmnd: The FCP Command that is provided by the SCSI layer. | 1944 | * @fcp_cmnd: The FCP Command that is provided by the SCSI layer. |
1941 | * | 1945 | * |
@@ -1953,7 +1957,7 @@ lpfc_fcpcmd_to_iocb(uint8_t *data, struct fcp_cmnd *fcp_cmnd) | |||
1953 | } | 1957 | } |
1954 | 1958 | ||
1955 | /** | 1959 | /** |
1956 | * lpfc_scsi_prep_cmnd: Routine to convert scsi cmnd to FCP information unit. | 1960 | * lpfc_scsi_prep_cmnd - Routine to convert scsi cmnd to FCP information unit |
1957 | * @vport: The virtual port for which this call is being executed. | 1961 | * @vport: The virtual port for which this call is being executed. |
1958 | * @lpfc_cmd: The scsi command which needs to send. | 1962 | * @lpfc_cmd: The scsi command which needs to send. |
1959 | * @pnode: Pointer to lpfc_nodelist. | 1963 | * @pnode: Pointer to lpfc_nodelist. |
@@ -2047,7 +2051,7 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd, | |||
2047 | } | 2051 | } |
2048 | 2052 | ||
2049 | /** | 2053 | /** |
2050 | * lpfc_scsi_prep_task_mgmt_cmnd: Convert scsi TM cmnd to FCP information unit. | 2054 | * lpfc_scsi_prep_task_mgmt_cmnd - Convert scsi TM cmnd to FCP information unit |
2051 | * @vport: The virtual port for which this call is being executed. | 2055 | * @vport: The virtual port for which this call is being executed. |
2052 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. | 2056 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure. |
2053 | * @lun: Logical unit number. | 2057 | * @lun: Logical unit number. |
@@ -2110,7 +2114,7 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport, | |||
2110 | } | 2114 | } |
2111 | 2115 | ||
2112 | /** | 2116 | /** |
2113 | * lpc_taskmgmt_def_cmpl: IOCB completion routine for task management command. | 2117 | * lpfc_taskmgmt_def_cmpl - IOCB completion routine for task management command |
2114 | * @phba: The Hba for which this call is being executed. | 2118 | * @phba: The Hba for which this call is being executed. |
2115 | * @cmdiocbq: Pointer to lpfc_iocbq data structure. | 2119 | * @cmdiocbq: Pointer to lpfc_iocbq data structure. |
2116 | * @rspiocbq: Pointer to lpfc_iocbq data structure. | 2120 | * @rspiocbq: Pointer to lpfc_iocbq data structure. |
@@ -2131,7 +2135,7 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, | |||
2131 | } | 2135 | } |
2132 | 2136 | ||
2133 | /** | 2137 | /** |
2134 | * lpfc_scsi_tgt_reset: Target reset handler. | 2138 | * lpfc_scsi_tgt_reset - Target reset handler |
2135 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure | 2139 | * @lpfc_cmd: Pointer to lpfc_scsi_buf data structure |
2136 | * @vport: The virtual port for which this call is being executed. | 2140 | * @vport: The virtual port for which this call is being executed. |
2137 | * @tgt_id: Target ID. | 2141 | * @tgt_id: Target ID. |
@@ -2198,7 +2202,7 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport, | |||
2198 | } | 2202 | } |
2199 | 2203 | ||
2200 | /** | 2204 | /** |
2201 | * lpfc_info: Info entry point of scsi_host_template data structure. | 2205 | * lpfc_info - Info entry point of scsi_host_template data structure |
2202 | * @host: The scsi host for which this call is being executed. | 2206 | * @host: The scsi host for which this call is being executed. |
2203 | * | 2207 | * |
2204 | * This routine provides module information about hba. | 2208 | * This routine provides module information about hba. |
@@ -2236,7 +2240,7 @@ lpfc_info(struct Scsi_Host *host) | |||
2236 | } | 2240 | } |
2237 | 2241 | ||
2238 | /** | 2242 | /** |
2239 | * lpfc_poll_rearm_time: Routine to modify fcp_poll timer of hba. | 2243 | * lpfc_poll_rearm_time - Routine to modify fcp_poll timer of hba |
2240 | * @phba: The Hba for which this call is being executed. | 2244 | * @phba: The Hba for which this call is being executed. |
2241 | * | 2245 | * |
2242 | * This routine modifies fcp_poll_timer field of @phba by cfg_poll_tmo. | 2246 | * This routine modifies fcp_poll_timer field of @phba by cfg_poll_tmo. |
@@ -2253,7 +2257,7 @@ static __inline__ void lpfc_poll_rearm_timer(struct lpfc_hba * phba) | |||
2253 | } | 2257 | } |
2254 | 2258 | ||
2255 | /** | 2259 | /** |
2256 | * lpfc_poll_start_timer: Routine to start fcp_poll_timer of HBA. | 2260 | * lpfc_poll_start_timer - Routine to start fcp_poll_timer of HBA |
2257 | * @phba: The Hba for which this call is being executed. | 2261 | * @phba: The Hba for which this call is being executed. |
2258 | * | 2262 | * |
2259 | * This routine starts the fcp_poll_timer of @phba. | 2263 | * This routine starts the fcp_poll_timer of @phba. |
@@ -2264,7 +2268,7 @@ void lpfc_poll_start_timer(struct lpfc_hba * phba) | |||
2264 | } | 2268 | } |
2265 | 2269 | ||
2266 | /** | 2270 | /** |
2267 | * lpfc_poll_timeout: Restart polling timer. | 2271 | * lpfc_poll_timeout - Restart polling timer |
2268 | * @ptr: Map to lpfc_hba data structure pointer. | 2272 | * @ptr: Map to lpfc_hba data structure pointer. |
2269 | * | 2273 | * |
2270 | * This routine restarts fcp_poll timer, when FCP ring polling is enable | 2274 | * This routine restarts fcp_poll timer, when FCP ring polling is enable |
@@ -2283,8 +2287,7 @@ void lpfc_poll_timeout(unsigned long ptr) | |||
2283 | } | 2287 | } |
2284 | 2288 | ||
2285 | /** | 2289 | /** |
2286 | * lpfc_queuecommand: Queuecommand entry point of Scsi Host Templater data | 2290 | * lpfc_queuecommand - scsi_host_template queuecommand entry point |
2287 | * structure. | ||
2288 | * @cmnd: Pointer to scsi_cmnd data structure. | 2291 | * @cmnd: Pointer to scsi_cmnd data structure. |
2289 | * @done: Pointer to done routine. | 2292 | * @done: Pointer to done routine. |
2290 | * | 2293 | * |
@@ -2450,7 +2453,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |||
2450 | } | 2453 | } |
2451 | 2454 | ||
2452 | /** | 2455 | /** |
2453 | * lpfc_block_error_handler: Routine to block error handler. | 2456 | * lpfc_block_error_handler - Routine to block error handler |
2454 | * @cmnd: Pointer to scsi_cmnd data structure. | 2457 | * @cmnd: Pointer to scsi_cmnd data structure. |
2455 | * | 2458 | * |
2456 | * This routine blocks execution till fc_rport state is not FC_PORSTAT_BLCOEKD. | 2459 | * This routine blocks execution till fc_rport state is not FC_PORSTAT_BLCOEKD. |
@@ -2472,8 +2475,7 @@ lpfc_block_error_handler(struct scsi_cmnd *cmnd) | |||
2472 | } | 2475 | } |
2473 | 2476 | ||
2474 | /** | 2477 | /** |
2475 | * lpfc_abort_handler: Eh_abort_handler entry point of Scsi Host Template data | 2478 | * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point |
2476 | *structure. | ||
2477 | * @cmnd: Pointer to scsi_cmnd data structure. | 2479 | * @cmnd: Pointer to scsi_cmnd data structure. |
2478 | * | 2480 | * |
2479 | * This routine aborts @cmnd pending in base driver. | 2481 | * This routine aborts @cmnd pending in base driver. |
@@ -2578,8 +2580,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) | |||
2578 | } | 2580 | } |
2579 | 2581 | ||
2580 | /** | 2582 | /** |
2581 | * lpfc_device_reset_handler: eh_device_reset entry point of Scsi Host Template | 2583 | * lpfc_device_reset_handler - scsi_host_template eh_device_reset entry point |
2582 | *data structure. | ||
2583 | * @cmnd: Pointer to scsi_cmnd data structure. | 2584 | * @cmnd: Pointer to scsi_cmnd data structure. |
2584 | * | 2585 | * |
2585 | * This routine does a device reset by sending a TARGET_RESET task management | 2586 | * This routine does a device reset by sending a TARGET_RESET task management |
@@ -2587,7 +2588,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) | |||
2587 | * | 2588 | * |
2588 | * Return code : | 2589 | * Return code : |
2589 | * 0x2003 - Error | 2590 | * 0x2003 - Error |
2590 | * 0ex2002 - Success | 2591 | * 0x2002 - Success |
2591 | **/ | 2592 | **/ |
2592 | static int | 2593 | static int |
2593 | lpfc_device_reset_handler(struct scsi_cmnd *cmnd) | 2594 | lpfc_device_reset_handler(struct scsi_cmnd *cmnd) |
@@ -2707,8 +2708,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) | |||
2707 | } | 2708 | } |
2708 | 2709 | ||
2709 | /** | 2710 | /** |
2710 | * lpfc_bus_reset_handler: eh_bus_reset_handler entry point of Scsi Host | 2711 | * lpfc_bus_reset_handler - scsi_host_template eh_bus_reset_handler entry point |
2711 | * Template data structure. | ||
2712 | * @cmnd: Pointer to scsi_cmnd data structure. | 2712 | * @cmnd: Pointer to scsi_cmnd data structure. |
2713 | * | 2713 | * |
2714 | * This routine does target reset to all target on @cmnd->device->host. | 2714 | * This routine does target reset to all target on @cmnd->device->host. |
@@ -2808,8 +2808,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) | |||
2808 | } | 2808 | } |
2809 | 2809 | ||
2810 | /** | 2810 | /** |
2811 | * lpfc_slave_alloc: slave_alloc entry point of Scsi Host Template data | 2811 | * lpfc_slave_alloc - scsi_host_template slave_alloc entry point |
2812 | * structure. | ||
2813 | * @sdev: Pointer to scsi_device. | 2812 | * @sdev: Pointer to scsi_device. |
2814 | * | 2813 | * |
2815 | * This routine populates the cmds_per_lun count + 2 scsi_bufs into this host's | 2814 | * This routine populates the cmds_per_lun count + 2 scsi_bufs into this host's |
@@ -2883,8 +2882,7 @@ lpfc_slave_alloc(struct scsi_device *sdev) | |||
2883 | } | 2882 | } |
2884 | 2883 | ||
2885 | /** | 2884 | /** |
2886 | * lpfc_slave_configure: slave_configure entry point of Scsi Host Templater data | 2885 | * lpfc_slave_configure - scsi_host_template slave_configure entry point |
2887 | * structure. | ||
2888 | * @sdev: Pointer to scsi_device. | 2886 | * @sdev: Pointer to scsi_device. |
2889 | * | 2887 | * |
2890 | * This routine configures following items | 2888 | * This routine configures following items |
@@ -2925,7 +2923,7 @@ lpfc_slave_configure(struct scsi_device *sdev) | |||
2925 | } | 2923 | } |
2926 | 2924 | ||
2927 | /** | 2925 | /** |
2928 | * lpfc_slave_destroy: slave_destroy entry point of SHT data structure. | 2926 | * lpfc_slave_destroy - slave_destroy entry point of SHT data structure |
2929 | * @sdev: Pointer to scsi_device. | 2927 | * @sdev: Pointer to scsi_device. |
2930 | * | 2928 | * |
2931 | * This routine sets @sdev hostatdata filed to null. | 2929 | * This routine sets @sdev hostatdata filed to null. |
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index a36a120561e2..eb5c75c45ba4 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -68,7 +68,7 @@ typedef enum _lpfc_iocb_type { | |||
68 | } lpfc_iocb_type; | 68 | } lpfc_iocb_type; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * lpfc_cmd_iocb: Get next command iocb entry in the ring. | 71 | * lpfc_cmd_iocb - Get next command iocb entry in the ring |
72 | * @phba: Pointer to HBA context object. | 72 | * @phba: Pointer to HBA context object. |
73 | * @pring: Pointer to driver SLI ring object. | 73 | * @pring: Pointer to driver SLI ring object. |
74 | * | 74 | * |
@@ -85,7 +85,7 @@ lpfc_cmd_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * lpfc_resp_iocb: Get next response iocb entry in the ring. | 88 | * lpfc_resp_iocb - Get next response iocb entry in the ring |
89 | * @phba: Pointer to HBA context object. | 89 | * @phba: Pointer to HBA context object. |
90 | * @pring: Pointer to driver SLI ring object. | 90 | * @pring: Pointer to driver SLI ring object. |
91 | * | 91 | * |
@@ -102,7 +102,7 @@ lpfc_resp_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
102 | } | 102 | } |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * __lpfc_sli_get_iocbq: Allocates an iocb object from iocb pool. | 105 | * __lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool |
106 | * @phba: Pointer to HBA context object. | 106 | * @phba: Pointer to HBA context object. |
107 | * | 107 | * |
108 | * This function is called with hbalock held. This function | 108 | * This function is called with hbalock held. This function |
@@ -121,7 +121,7 @@ __lpfc_sli_get_iocbq(struct lpfc_hba *phba) | |||
121 | } | 121 | } |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * lpfc_sli_get_iocbq: Allocates an iocb object from iocb pool. | 124 | * lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool |
125 | * @phba: Pointer to HBA context object. | 125 | * @phba: Pointer to HBA context object. |
126 | * | 126 | * |
127 | * This function is called with no lock held. This function | 127 | * This function is called with no lock held. This function |
@@ -142,7 +142,7 @@ lpfc_sli_get_iocbq(struct lpfc_hba *phba) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * __lpfc_sli_release_iocbq: Release iocb to the iocb pool. | 145 | * __lpfc_sli_release_iocbq - Release iocb to the iocb pool |
146 | * @phba: Pointer to HBA context object. | 146 | * @phba: Pointer to HBA context object. |
147 | * @iocbq: Pointer to driver iocb object. | 147 | * @iocbq: Pointer to driver iocb object. |
148 | * | 148 | * |
@@ -164,7 +164,7 @@ __lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | /** | 166 | /** |
167 | * lpfc_sli_release_iocbq: Release iocb to the iocb pool. | 167 | * lpfc_sli_release_iocbq - Release iocb to the iocb pool |
168 | * @phba: Pointer to HBA context object. | 168 | * @phba: Pointer to HBA context object. |
169 | * @iocbq: Pointer to driver iocb object. | 169 | * @iocbq: Pointer to driver iocb object. |
170 | * | 170 | * |
@@ -185,8 +185,40 @@ lpfc_sli_release_iocbq(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | /** | 187 | /** |
188 | * lpfc_sli_iocb_cmd_type: Get the iocb type. | 188 | * lpfc_sli_cancel_iocbs - Cancel all iocbs from a list. |
189 | * @iocb_cmnd : iocb command code. | 189 | * @phba: Pointer to HBA context object. |
190 | * @iocblist: List of IOCBs. | ||
191 | * @ulpstatus: ULP status in IOCB command field. | ||
192 | * @ulpWord4: ULP word-4 in IOCB command field. | ||
193 | * | ||
194 | * This function is called with a list of IOCBs to cancel. It cancels the IOCB | ||
195 | * on the list by invoking the complete callback function associated with the | ||
196 | * IOCB with the provided @ulpstatus and @ulpword4 set to the IOCB commond | ||
197 | * fields. | ||
198 | **/ | ||
199 | void | ||
200 | lpfc_sli_cancel_iocbs(struct lpfc_hba *phba, struct list_head *iocblist, | ||
201 | uint32_t ulpstatus, uint32_t ulpWord4) | ||
202 | { | ||
203 | struct lpfc_iocbq *piocb; | ||
204 | |||
205 | while (!list_empty(iocblist)) { | ||
206 | list_remove_head(iocblist, piocb, struct lpfc_iocbq, list); | ||
207 | |||
208 | if (!piocb->iocb_cmpl) | ||
209 | lpfc_sli_release_iocbq(phba, piocb); | ||
210 | else { | ||
211 | piocb->iocb.ulpStatus = ulpstatus; | ||
212 | piocb->iocb.un.ulpWord[4] = ulpWord4; | ||
213 | (piocb->iocb_cmpl) (phba, piocb, piocb); | ||
214 | } | ||
215 | } | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * lpfc_sli_iocb_cmd_type - Get the iocb type | ||
221 | * @iocb_cmnd: iocb command code. | ||
190 | * | 222 | * |
191 | * This function is called by ring event handler function to get the iocb type. | 223 | * This function is called by ring event handler function to get the iocb type. |
192 | * This function translates the iocb command to an iocb command type used to | 224 | * This function translates the iocb command to an iocb command type used to |
@@ -295,7 +327,7 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd) | |||
295 | } | 327 | } |
296 | 328 | ||
297 | /** | 329 | /** |
298 | * lpfc_sli_ring_map: Issue config_ring mbox for all rings. | 330 | * lpfc_sli_ring_map - Issue config_ring mbox for all rings |
299 | * @phba: Pointer to HBA context object. | 331 | * @phba: Pointer to HBA context object. |
300 | * | 332 | * |
301 | * This function is called from SLI initialization code | 333 | * This function is called from SLI initialization code |
@@ -338,7 +370,7 @@ lpfc_sli_ring_map(struct lpfc_hba *phba) | |||
338 | } | 370 | } |
339 | 371 | ||
340 | /** | 372 | /** |
341 | * lpfc_sli_ringtxcmpl_put: Adds new iocb to the txcmplq. | 373 | * lpfc_sli_ringtxcmpl_put - Adds new iocb to the txcmplq |
342 | * @phba: Pointer to HBA context object. | 374 | * @phba: Pointer to HBA context object. |
343 | * @pring: Pointer to driver SLI ring object. | 375 | * @pring: Pointer to driver SLI ring object. |
344 | * @piocb: Pointer to the driver iocb object. | 376 | * @piocb: Pointer to the driver iocb object. |
@@ -370,7 +402,7 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
370 | } | 402 | } |
371 | 403 | ||
372 | /** | 404 | /** |
373 | * lpfc_sli_ringtx_get: Get first element of the txq. | 405 | * lpfc_sli_ringtx_get - Get first element of the txq |
374 | * @phba: Pointer to HBA context object. | 406 | * @phba: Pointer to HBA context object. |
375 | * @pring: Pointer to driver SLI ring object. | 407 | * @pring: Pointer to driver SLI ring object. |
376 | * | 408 | * |
@@ -391,7 +423,7 @@ lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
391 | } | 423 | } |
392 | 424 | ||
393 | /** | 425 | /** |
394 | * lpfc_sli_next_iocb_slot: Get next iocb slot in the ring. | 426 | * lpfc_sli_next_iocb_slot - Get next iocb slot in the ring |
395 | * @phba: Pointer to HBA context object. | 427 | * @phba: Pointer to HBA context object. |
396 | * @pring: Pointer to driver SLI ring object. | 428 | * @pring: Pointer to driver SLI ring object. |
397 | * | 429 | * |
@@ -445,7 +477,7 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
445 | } | 477 | } |
446 | 478 | ||
447 | /** | 479 | /** |
448 | * lpfc_sli_next_iotag: Get an iotag for the iocb. | 480 | * lpfc_sli_next_iotag - Get an iotag for the iocb |
449 | * @phba: Pointer to HBA context object. | 481 | * @phba: Pointer to HBA context object. |
450 | * @iocbq: Pointer to driver iocb object. | 482 | * @iocbq: Pointer to driver iocb object. |
451 | * | 483 | * |
@@ -520,7 +552,7 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
520 | } | 552 | } |
521 | 553 | ||
522 | /** | 554 | /** |
523 | * lpfc_sli_submit_iocb: Submit an iocb to the firmware. | 555 | * lpfc_sli_submit_iocb - Submit an iocb to the firmware |
524 | * @phba: Pointer to HBA context object. | 556 | * @phba: Pointer to HBA context object. |
525 | * @pring: Pointer to driver SLI ring object. | 557 | * @pring: Pointer to driver SLI ring object. |
526 | * @iocb: Pointer to iocb slot in the ring. | 558 | * @iocb: Pointer to iocb slot in the ring. |
@@ -577,7 +609,7 @@ lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
577 | } | 609 | } |
578 | 610 | ||
579 | /** | 611 | /** |
580 | * lpfc_sli_update_full_ring: Update the chip attention register. | 612 | * lpfc_sli_update_full_ring - Update the chip attention register |
581 | * @phba: Pointer to HBA context object. | 613 | * @phba: Pointer to HBA context object. |
582 | * @pring: Pointer to driver SLI ring object. | 614 | * @pring: Pointer to driver SLI ring object. |
583 | * | 615 | * |
@@ -608,7 +640,7 @@ lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
608 | } | 640 | } |
609 | 641 | ||
610 | /** | 642 | /** |
611 | * lpfc_sli_update_ring: Update chip attention register. | 643 | * lpfc_sli_update_ring - Update chip attention register |
612 | * @phba: Pointer to HBA context object. | 644 | * @phba: Pointer to HBA context object. |
613 | * @pring: Pointer to driver SLI ring object. | 645 | * @pring: Pointer to driver SLI ring object. |
614 | * | 646 | * |
@@ -632,7 +664,7 @@ lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
632 | } | 664 | } |
633 | 665 | ||
634 | /** | 666 | /** |
635 | * lpfc_sli_resume_iocb: Process iocbs in the txq. | 667 | * lpfc_sli_resume_iocb - Process iocbs in the txq |
636 | * @phba: Pointer to HBA context object. | 668 | * @phba: Pointer to HBA context object. |
637 | * @pring: Pointer to driver SLI ring object. | 669 | * @pring: Pointer to driver SLI ring object. |
638 | * | 670 | * |
@@ -672,7 +704,7 @@ lpfc_sli_resume_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
672 | } | 704 | } |
673 | 705 | ||
674 | /** | 706 | /** |
675 | * lpfc_sli_next_hbq_slot: Get next hbq entry for the HBQ. | 707 | * lpfc_sli_next_hbq_slot - Get next hbq entry for the HBQ |
676 | * @phba: Pointer to HBA context object. | 708 | * @phba: Pointer to HBA context object. |
677 | * @hbqno: HBQ number. | 709 | * @hbqno: HBQ number. |
678 | * | 710 | * |
@@ -717,7 +749,7 @@ lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno) | |||
717 | } | 749 | } |
718 | 750 | ||
719 | /** | 751 | /** |
720 | * lpfc_sli_hbqbuf_free_all: Free all the hbq buffers. | 752 | * lpfc_sli_hbqbuf_free_all - Free all the hbq buffers |
721 | * @phba: Pointer to HBA context object. | 753 | * @phba: Pointer to HBA context object. |
722 | * | 754 | * |
723 | * This function is called with no lock held to free all the | 755 | * This function is called with no lock held to free all the |
@@ -771,7 +803,7 @@ lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba) | |||
771 | } | 803 | } |
772 | 804 | ||
773 | /** | 805 | /** |
774 | * lpfc_sli_hbq_to_firmware: Post the hbq buffer to firmware. | 806 | * lpfc_sli_hbq_to_firmware - Post the hbq buffer to firmware |
775 | * @phba: Pointer to HBA context object. | 807 | * @phba: Pointer to HBA context object. |
776 | * @hbqno: HBQ number. | 808 | * @hbqno: HBQ number. |
777 | * @hbq_buf: Pointer to HBQ buffer. | 809 | * @hbq_buf: Pointer to HBQ buffer. |
@@ -818,8 +850,8 @@ static struct lpfc_hbq_init lpfc_els_hbq = { | |||
818 | .profile = 0, | 850 | .profile = 0, |
819 | .ring_mask = (1 << LPFC_ELS_RING), | 851 | .ring_mask = (1 << LPFC_ELS_RING), |
820 | .buffer_count = 0, | 852 | .buffer_count = 0, |
821 | .init_count = 20, | 853 | .init_count = 40, |
822 | .add_count = 5, | 854 | .add_count = 40, |
823 | }; | 855 | }; |
824 | 856 | ||
825 | /* HBQ for the extra ring if needed */ | 857 | /* HBQ for the extra ring if needed */ |
@@ -841,7 +873,7 @@ struct lpfc_hbq_init *lpfc_hbq_defs[] = { | |||
841 | }; | 873 | }; |
842 | 874 | ||
843 | /** | 875 | /** |
844 | * lpfc_sli_hbqbuf_fill_hbqs: Post more hbq buffers to HBQ. | 876 | * lpfc_sli_hbqbuf_fill_hbqs - Post more hbq buffers to HBQ |
845 | * @phba: Pointer to HBA context object. | 877 | * @phba: Pointer to HBA context object. |
846 | * @hbqno: HBQ number. | 878 | * @hbqno: HBQ number. |
847 | * @count: Number of HBQ buffers to be posted. | 879 | * @count: Number of HBQ buffers to be posted. |
@@ -901,7 +933,7 @@ err: | |||
901 | } | 933 | } |
902 | 934 | ||
903 | /** | 935 | /** |
904 | * lpfc_sli_hbqbuf_add_hbqs: Post more HBQ buffers to firmware. | 936 | * lpfc_sli_hbqbuf_add_hbqs - Post more HBQ buffers to firmware |
905 | * @phba: Pointer to HBA context object. | 937 | * @phba: Pointer to HBA context object. |
906 | * @qno: HBQ number. | 938 | * @qno: HBQ number. |
907 | * | 939 | * |
@@ -917,7 +949,7 @@ lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *phba, uint32_t qno) | |||
917 | } | 949 | } |
918 | 950 | ||
919 | /** | 951 | /** |
920 | * lpfc_sli_hbqbuf_init_hbqs: Post initial buffers to the HBQ. | 952 | * lpfc_sli_hbqbuf_init_hbqs - Post initial buffers to the HBQ |
921 | * @phba: Pointer to HBA context object. | 953 | * @phba: Pointer to HBA context object. |
922 | * @qno: HBQ queue number. | 954 | * @qno: HBQ queue number. |
923 | * | 955 | * |
@@ -933,7 +965,7 @@ lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *phba, uint32_t qno) | |||
933 | } | 965 | } |
934 | 966 | ||
935 | /** | 967 | /** |
936 | * lpfc_sli_hbqbuf_find: Find the hbq buffer associated with a tag. | 968 | * lpfc_sli_hbqbuf_find - Find the hbq buffer associated with a tag |
937 | * @phba: Pointer to HBA context object. | 969 | * @phba: Pointer to HBA context object. |
938 | * @tag: Tag of the hbq buffer. | 970 | * @tag: Tag of the hbq buffer. |
939 | * | 971 | * |
@@ -966,7 +998,7 @@ lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag) | |||
966 | } | 998 | } |
967 | 999 | ||
968 | /** | 1000 | /** |
969 | * lpfc_sli_free_hbq: Give back the hbq buffer to firmware. | 1001 | * lpfc_sli_free_hbq - Give back the hbq buffer to firmware |
970 | * @phba: Pointer to HBA context object. | 1002 | * @phba: Pointer to HBA context object. |
971 | * @hbq_buffer: Pointer to HBQ buffer. | 1003 | * @hbq_buffer: Pointer to HBQ buffer. |
972 | * | 1004 | * |
@@ -988,7 +1020,7 @@ lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *hbq_buffer) | |||
988 | } | 1020 | } |
989 | 1021 | ||
990 | /** | 1022 | /** |
991 | * lpfc_sli_chk_mbx_command: Check if the mailbox is a legitimate mailbox. | 1023 | * lpfc_sli_chk_mbx_command - Check if the mailbox is a legitimate mailbox |
992 | * @mbxCommand: mailbox command code. | 1024 | * @mbxCommand: mailbox command code. |
993 | * | 1025 | * |
994 | * This function is called by the mailbox event handler function to verify | 1026 | * This function is called by the mailbox event handler function to verify |
@@ -1064,8 +1096,7 @@ lpfc_sli_chk_mbx_command(uint8_t mbxCommand) | |||
1064 | } | 1096 | } |
1065 | 1097 | ||
1066 | /** | 1098 | /** |
1067 | * lpfc_sli_wake_mbox_wait: Completion handler for mbox issued from | 1099 | * lpfc_sli_wake_mbox_wait - lpfc_sli_issue_mbox_wait mbox completion handler |
1068 | * lpfc_sli_issue_mbox_wait. | ||
1069 | * @phba: Pointer to HBA context object. | 1100 | * @phba: Pointer to HBA context object. |
1070 | * @pmboxq: Pointer to mailbox command. | 1101 | * @pmboxq: Pointer to mailbox command. |
1071 | * | 1102 | * |
@@ -1096,7 +1127,7 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) | |||
1096 | 1127 | ||
1097 | 1128 | ||
1098 | /** | 1129 | /** |
1099 | * lpfc_sli_def_mbox_cmpl: Default mailbox completion handler. | 1130 | * lpfc_sli_def_mbox_cmpl - Default mailbox completion handler |
1100 | * @phba: Pointer to HBA context object. | 1131 | * @phba: Pointer to HBA context object. |
1101 | * @pmb: Pointer to mailbox object. | 1132 | * @pmb: Pointer to mailbox object. |
1102 | * | 1133 | * |
@@ -1140,7 +1171,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
1140 | } | 1171 | } |
1141 | 1172 | ||
1142 | /** | 1173 | /** |
1143 | * lpfc_sli_handle_mb_event: Handle mailbox completions from firmware. | 1174 | * lpfc_sli_handle_mb_event - Handle mailbox completions from firmware |
1144 | * @phba: Pointer to HBA context object. | 1175 | * @phba: Pointer to HBA context object. |
1145 | * | 1176 | * |
1146 | * This function is called with no lock held. This function processes all | 1177 | * This function is called with no lock held. This function processes all |
@@ -1260,7 +1291,7 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba) | |||
1260 | } | 1291 | } |
1261 | 1292 | ||
1262 | /** | 1293 | /** |
1263 | * lpfc_sli_get_buff: Get the buffer associated with the buffer tag. | 1294 | * lpfc_sli_get_buff - Get the buffer associated with the buffer tag |
1264 | * @phba: Pointer to HBA context object. | 1295 | * @phba: Pointer to HBA context object. |
1265 | * @pring: Pointer to driver SLI ring object. | 1296 | * @pring: Pointer to driver SLI ring object. |
1266 | * @tag: buffer tag. | 1297 | * @tag: buffer tag. |
@@ -1288,7 +1319,7 @@ lpfc_sli_get_buff(struct lpfc_hba *phba, | |||
1288 | 1319 | ||
1289 | 1320 | ||
1290 | /** | 1321 | /** |
1291 | * lpfc_sli_process_unsol_iocb: Unsolicited iocb handler. | 1322 | * lpfc_sli_process_unsol_iocb - Unsolicited iocb handler |
1292 | * @phba: Pointer to HBA context object. | 1323 | * @phba: Pointer to HBA context object. |
1293 | * @pring: Pointer to driver SLI ring object. | 1324 | * @pring: Pointer to driver SLI ring object. |
1294 | * @saveq: Pointer to the unsolicited iocb. | 1325 | * @saveq: Pointer to the unsolicited iocb. |
@@ -1484,7 +1515,7 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
1484 | } | 1515 | } |
1485 | 1516 | ||
1486 | /** | 1517 | /** |
1487 | * lpfc_sli_iocbq_lookup: Find command iocb for the given response iocb. | 1518 | * lpfc_sli_iocbq_lookup - Find command iocb for the given response iocb |
1488 | * @phba: Pointer to HBA context object. | 1519 | * @phba: Pointer to HBA context object. |
1489 | * @pring: Pointer to driver SLI ring object. | 1520 | * @pring: Pointer to driver SLI ring object. |
1490 | * @prspiocb: Pointer to response iocb object. | 1521 | * @prspiocb: Pointer to response iocb object. |
@@ -1521,7 +1552,7 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *phba, | |||
1521 | } | 1552 | } |
1522 | 1553 | ||
1523 | /** | 1554 | /** |
1524 | * lpfc_sli_process_sol_iocb: process solicited iocb completion. | 1555 | * lpfc_sli_process_sol_iocb - process solicited iocb completion |
1525 | * @phba: Pointer to HBA context object. | 1556 | * @phba: Pointer to HBA context object. |
1526 | * @pring: Pointer to driver SLI ring object. | 1557 | * @pring: Pointer to driver SLI ring object. |
1527 | * @saveq: Pointer to the response iocb to be processed. | 1558 | * @saveq: Pointer to the response iocb to be processed. |
@@ -1597,7 +1628,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
1597 | * Ring <ringno> handler: unexpected completion IoTag | 1628 | * Ring <ringno> handler: unexpected completion IoTag |
1598 | * <IoTag> | 1629 | * <IoTag> |
1599 | */ | 1630 | */ |
1600 | lpfc_printf_vlog(cmdiocbp->vport, KERN_WARNING, LOG_SLI, | 1631 | lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, |
1601 | "0322 Ring %d handler: " | 1632 | "0322 Ring %d handler: " |
1602 | "unexpected completion IoTag x%x " | 1633 | "unexpected completion IoTag x%x " |
1603 | "Data: x%x x%x x%x x%x\n", | 1634 | "Data: x%x x%x x%x x%x\n", |
@@ -1614,7 +1645,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
1614 | } | 1645 | } |
1615 | 1646 | ||
1616 | /** | 1647 | /** |
1617 | * lpfc_sli_rsp_pointers_error: Response ring pointer error handler. | 1648 | * lpfc_sli_rsp_pointers_error - Response ring pointer error handler |
1618 | * @phba: Pointer to HBA context object. | 1649 | * @phba: Pointer to HBA context object. |
1619 | * @pring: Pointer to driver SLI ring object. | 1650 | * @pring: Pointer to driver SLI ring object. |
1620 | * | 1651 | * |
@@ -1652,7 +1683,7 @@ lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
1652 | } | 1683 | } |
1653 | 1684 | ||
1654 | /** | 1685 | /** |
1655 | * lpfc_poll_eratt: Error attention polling timer timeout handler. | 1686 | * lpfc_poll_eratt - Error attention polling timer timeout handler |
1656 | * @ptr: Pointer to address of HBA context object. | 1687 | * @ptr: Pointer to address of HBA context object. |
1657 | * | 1688 | * |
1658 | * This function is invoked by the Error Attention polling timer when the | 1689 | * This function is invoked by the Error Attention polling timer when the |
@@ -1682,7 +1713,7 @@ void lpfc_poll_eratt(unsigned long ptr) | |||
1682 | } | 1713 | } |
1683 | 1714 | ||
1684 | /** | 1715 | /** |
1685 | * lpfc_sli_poll_fcp_ring: Handle FCP ring completion in polling mode. | 1716 | * lpfc_sli_poll_fcp_ring - Handle FCP ring completion in polling mode |
1686 | * @phba: Pointer to HBA context object. | 1717 | * @phba: Pointer to HBA context object. |
1687 | * | 1718 | * |
1688 | * This function is called from lpfc_queuecommand, lpfc_poll_timeout, | 1719 | * This function is called from lpfc_queuecommand, lpfc_poll_timeout, |
@@ -1845,7 +1876,7 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba) | |||
1845 | } | 1876 | } |
1846 | 1877 | ||
1847 | /** | 1878 | /** |
1848 | * lpfc_sli_handle_fast_ring_event: Handle ring events on FCP ring. | 1879 | * lpfc_sli_handle_fast_ring_event - Handle ring events on FCP ring |
1849 | * @phba: Pointer to HBA context object. | 1880 | * @phba: Pointer to HBA context object. |
1850 | * @pring: Pointer to driver SLI ring object. | 1881 | * @pring: Pointer to driver SLI ring object. |
1851 | * @mask: Host attention register mask for this ring. | 1882 | * @mask: Host attention register mask for this ring. |
@@ -2037,7 +2068,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, | |||
2037 | } | 2068 | } |
2038 | 2069 | ||
2039 | /** | 2070 | /** |
2040 | * lpfc_sli_handle_slow_ring_event: Handle ring events for non-FCP rings. | 2071 | * lpfc_sli_handle_slow_ring_event - Handle ring events for non-FCP rings |
2041 | * @phba: Pointer to HBA context object. | 2072 | * @phba: Pointer to HBA context object. |
2042 | * @pring: Pointer to driver SLI ring object. | 2073 | * @pring: Pointer to driver SLI ring object. |
2043 | * @mask: Host attention register mask for this ring. | 2074 | * @mask: Host attention register mask for this ring. |
@@ -2311,7 +2342,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, | |||
2311 | } | 2342 | } |
2312 | 2343 | ||
2313 | /** | 2344 | /** |
2314 | * lpfc_sli_abort_iocb_ring: Abort all iocbs in the ring. | 2345 | * lpfc_sli_abort_iocb_ring - Abort all iocbs in the ring |
2315 | * @phba: Pointer to HBA context object. | 2346 | * @phba: Pointer to HBA context object. |
2316 | * @pring: Pointer to driver SLI ring object. | 2347 | * @pring: Pointer to driver SLI ring object. |
2317 | * | 2348 | * |
@@ -2325,7 +2356,6 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
2325 | { | 2356 | { |
2326 | LIST_HEAD(completions); | 2357 | LIST_HEAD(completions); |
2327 | struct lpfc_iocbq *iocb, *next_iocb; | 2358 | struct lpfc_iocbq *iocb, *next_iocb; |
2328 | IOCB_t *cmd = NULL; | ||
2329 | 2359 | ||
2330 | if (pring->ringno == LPFC_ELS_RING) { | 2360 | if (pring->ringno == LPFC_ELS_RING) { |
2331 | lpfc_fabric_abort_hba(phba); | 2361 | lpfc_fabric_abort_hba(phba); |
@@ -2344,23 +2374,13 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) | |||
2344 | 2374 | ||
2345 | spin_unlock_irq(&phba->hbalock); | 2375 | spin_unlock_irq(&phba->hbalock); |
2346 | 2376 | ||
2347 | while (!list_empty(&completions)) { | 2377 | /* Cancel all the IOCBs from the completions list */ |
2348 | iocb = list_get_first(&completions, struct lpfc_iocbq, list); | 2378 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
2349 | cmd = &iocb->iocb; | 2379 | IOERR_SLI_ABORTED); |
2350 | list_del_init(&iocb->list); | ||
2351 | |||
2352 | if (!iocb->iocb_cmpl) | ||
2353 | lpfc_sli_release_iocbq(phba, iocb); | ||
2354 | else { | ||
2355 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
2356 | cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; | ||
2357 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
2358 | } | ||
2359 | } | ||
2360 | } | 2380 | } |
2361 | 2381 | ||
2362 | /** | 2382 | /** |
2363 | * lpfc_sli_flush_fcp_rings: flush all iocbs in the fcp ring. | 2383 | * lpfc_sli_flush_fcp_rings - flush all iocbs in the fcp ring |
2364 | * @phba: Pointer to HBA context object. | 2384 | * @phba: Pointer to HBA context object. |
2365 | * | 2385 | * |
2366 | * This function flushes all iocbs in the fcp ring and frees all the iocb | 2386 | * This function flushes all iocbs in the fcp ring and frees all the iocb |
@@ -2374,8 +2394,6 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) | |||
2374 | { | 2394 | { |
2375 | LIST_HEAD(txq); | 2395 | LIST_HEAD(txq); |
2376 | LIST_HEAD(txcmplq); | 2396 | LIST_HEAD(txcmplq); |
2377 | struct lpfc_iocbq *iocb; | ||
2378 | IOCB_t *cmd = NULL; | ||
2379 | struct lpfc_sli *psli = &phba->sli; | 2397 | struct lpfc_sli *psli = &phba->sli; |
2380 | struct lpfc_sli_ring *pring; | 2398 | struct lpfc_sli_ring *pring; |
2381 | 2399 | ||
@@ -2393,38 +2411,16 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba) | |||
2393 | spin_unlock_irq(&phba->hbalock); | 2411 | spin_unlock_irq(&phba->hbalock); |
2394 | 2412 | ||
2395 | /* Flush the txq */ | 2413 | /* Flush the txq */ |
2396 | while (!list_empty(&txq)) { | 2414 | lpfc_sli_cancel_iocbs(phba, &txq, IOSTAT_LOCAL_REJECT, |
2397 | iocb = list_get_first(&txq, struct lpfc_iocbq, list); | 2415 | IOERR_SLI_DOWN); |
2398 | cmd = &iocb->iocb; | ||
2399 | list_del_init(&iocb->list); | ||
2400 | |||
2401 | if (!iocb->iocb_cmpl) | ||
2402 | lpfc_sli_release_iocbq(phba, iocb); | ||
2403 | else { | ||
2404 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
2405 | cmd->un.ulpWord[4] = IOERR_SLI_DOWN; | ||
2406 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
2407 | } | ||
2408 | } | ||
2409 | 2416 | ||
2410 | /* Flush the txcmpq */ | 2417 | /* Flush the txcmpq */ |
2411 | while (!list_empty(&txcmplq)) { | 2418 | lpfc_sli_cancel_iocbs(phba, &txcmplq, IOSTAT_LOCAL_REJECT, |
2412 | iocb = list_get_first(&txcmplq, struct lpfc_iocbq, list); | 2419 | IOERR_SLI_DOWN); |
2413 | cmd = &iocb->iocb; | ||
2414 | list_del_init(&iocb->list); | ||
2415 | |||
2416 | if (!iocb->iocb_cmpl) | ||
2417 | lpfc_sli_release_iocbq(phba, iocb); | ||
2418 | else { | ||
2419 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
2420 | cmd->un.ulpWord[4] = IOERR_SLI_DOWN; | ||
2421 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
2422 | } | ||
2423 | } | ||
2424 | } | 2420 | } |
2425 | 2421 | ||
2426 | /** | 2422 | /** |
2427 | * lpfc_sli_brdready: Check for host status bits. | 2423 | * lpfc_sli_brdready - Check for host status bits |
2428 | * @phba: Pointer to HBA context object. | 2424 | * @phba: Pointer to HBA context object. |
2429 | * @mask: Bit mask to be checked. | 2425 | * @mask: Bit mask to be checked. |
2430 | * | 2426 | * |
@@ -2484,7 +2480,7 @@ lpfc_sli_brdready(struct lpfc_hba *phba, uint32_t mask) | |||
2484 | #define BARRIER_TEST_PATTERN (0xdeadbeef) | 2480 | #define BARRIER_TEST_PATTERN (0xdeadbeef) |
2485 | 2481 | ||
2486 | /** | 2482 | /** |
2487 | * lpfc_reset_barrier: Make HBA ready for HBA reset. | 2483 | * lpfc_reset_barrier - Make HBA ready for HBA reset |
2488 | * @phba: Pointer to HBA context object. | 2484 | * @phba: Pointer to HBA context object. |
2489 | * | 2485 | * |
2490 | * This function is called before resetting an HBA. This | 2486 | * This function is called before resetting an HBA. This |
@@ -2564,7 +2560,7 @@ restore_hc: | |||
2564 | } | 2560 | } |
2565 | 2561 | ||
2566 | /** | 2562 | /** |
2567 | * lpfc_sli_brdkill: Issue a kill_board mailbox command. | 2563 | * lpfc_sli_brdkill - Issue a kill_board mailbox command |
2568 | * @phba: Pointer to HBA context object. | 2564 | * @phba: Pointer to HBA context object. |
2569 | * | 2565 | * |
2570 | * This function issues a kill_board mailbox command and waits for | 2566 | * This function issues a kill_board mailbox command and waits for |
@@ -2651,7 +2647,7 @@ lpfc_sli_brdkill(struct lpfc_hba *phba) | |||
2651 | } | 2647 | } |
2652 | 2648 | ||
2653 | /** | 2649 | /** |
2654 | * lpfc_sli_brdreset: Reset the HBA. | 2650 | * lpfc_sli_brdreset - Reset the HBA |
2655 | * @phba: Pointer to HBA context object. | 2651 | * @phba: Pointer to HBA context object. |
2656 | * | 2652 | * |
2657 | * This function resets the HBA by writing HC_INITFF to the control | 2653 | * This function resets the HBA by writing HC_INITFF to the control |
@@ -2714,7 +2710,7 @@ lpfc_sli_brdreset(struct lpfc_hba *phba) | |||
2714 | } | 2710 | } |
2715 | 2711 | ||
2716 | /** | 2712 | /** |
2717 | * lpfc_sli_brdrestart: Restart the HBA. | 2713 | * lpfc_sli_brdrestart - Restart the HBA |
2718 | * @phba: Pointer to HBA context object. | 2714 | * @phba: Pointer to HBA context object. |
2719 | * | 2715 | * |
2720 | * This function is called in the SLI initialization code path to | 2716 | * This function is called in the SLI initialization code path to |
@@ -2781,7 +2777,7 @@ lpfc_sli_brdrestart(struct lpfc_hba *phba) | |||
2781 | } | 2777 | } |
2782 | 2778 | ||
2783 | /** | 2779 | /** |
2784 | * lpfc_sli_chipset_init: Wait for the restart of the HBA after a restart. | 2780 | * lpfc_sli_chipset_init - Wait for the restart of the HBA after a restart |
2785 | * @phba: Pointer to HBA context object. | 2781 | * @phba: Pointer to HBA context object. |
2786 | * | 2782 | * |
2787 | * This function is called after a HBA restart to wait for successful | 2783 | * This function is called after a HBA restart to wait for successful |
@@ -2876,7 +2872,7 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba) | |||
2876 | } | 2872 | } |
2877 | 2873 | ||
2878 | /** | 2874 | /** |
2879 | * lpfc_sli_hbq_count: Get the number of HBQs to be configured. | 2875 | * lpfc_sli_hbq_count - Get the number of HBQs to be configured |
2880 | * | 2876 | * |
2881 | * This function calculates and returns the number of HBQs required to be | 2877 | * This function calculates and returns the number of HBQs required to be |
2882 | * configured. | 2878 | * configured. |
@@ -2888,7 +2884,7 @@ lpfc_sli_hbq_count(void) | |||
2888 | } | 2884 | } |
2889 | 2885 | ||
2890 | /** | 2886 | /** |
2891 | * lpfc_sli_hbq_entry_count: Calculate total number of hbq entries. | 2887 | * lpfc_sli_hbq_entry_count - Calculate total number of hbq entries |
2892 | * | 2888 | * |
2893 | * This function adds the number of hbq entries in every HBQ to get | 2889 | * This function adds the number of hbq entries in every HBQ to get |
2894 | * the total number of hbq entries required for the HBA and returns | 2890 | * the total number of hbq entries required for the HBA and returns |
@@ -2907,7 +2903,7 @@ lpfc_sli_hbq_entry_count(void) | |||
2907 | } | 2903 | } |
2908 | 2904 | ||
2909 | /** | 2905 | /** |
2910 | * lpfc_sli_hbq_size: Calculate memory required for all hbq entries. | 2906 | * lpfc_sli_hbq_size - Calculate memory required for all hbq entries |
2911 | * | 2907 | * |
2912 | * This function calculates amount of memory required for all hbq entries | 2908 | * This function calculates amount of memory required for all hbq entries |
2913 | * to be configured and returns the total memory required. | 2909 | * to be configured and returns the total memory required. |
@@ -2919,7 +2915,7 @@ lpfc_sli_hbq_size(void) | |||
2919 | } | 2915 | } |
2920 | 2916 | ||
2921 | /** | 2917 | /** |
2922 | * lpfc_sli_hbq_setup: configure and initialize HBQs. | 2918 | * lpfc_sli_hbq_setup - configure and initialize HBQs |
2923 | * @phba: Pointer to HBA context object. | 2919 | * @phba: Pointer to HBA context object. |
2924 | * | 2920 | * |
2925 | * This function is called during the SLI initialization to configure | 2921 | * This function is called during the SLI initialization to configure |
@@ -2988,7 +2984,7 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba) | |||
2988 | } | 2984 | } |
2989 | 2985 | ||
2990 | /** | 2986 | /** |
2991 | * lpfc_sli_config_port: Issue config port mailbox command. | 2987 | * lpfc_sli_config_port - Issue config port mailbox command |
2992 | * @phba: Pointer to HBA context object. | 2988 | * @phba: Pointer to HBA context object. |
2993 | * @sli_mode: sli mode - 2/3 | 2989 | * @sli_mode: sli mode - 2/3 |
2994 | * | 2990 | * |
@@ -3114,7 +3110,7 @@ do_prep_failed: | |||
3114 | 3110 | ||
3115 | 3111 | ||
3116 | /** | 3112 | /** |
3117 | * lpfc_sli_hba_setup: SLI intialization function. | 3113 | * lpfc_sli_hba_setup - SLI intialization function |
3118 | * @phba: Pointer to HBA context object. | 3114 | * @phba: Pointer to HBA context object. |
3119 | * | 3115 | * |
3120 | * This function is the main SLI intialization function. This function | 3116 | * This function is the main SLI intialization function. This function |
@@ -3206,7 +3202,7 @@ lpfc_sli_hba_setup_error: | |||
3206 | 3202 | ||
3207 | 3203 | ||
3208 | /** | 3204 | /** |
3209 | * lpfc_mbox_timeout: Timeout call back function for mbox timer. | 3205 | * lpfc_mbox_timeout - Timeout call back function for mbox timer |
3210 | * @ptr: context object - pointer to hba structure. | 3206 | * @ptr: context object - pointer to hba structure. |
3211 | * | 3207 | * |
3212 | * This is the callback function for mailbox timer. The mailbox | 3208 | * This is the callback function for mailbox timer. The mailbox |
@@ -3237,7 +3233,7 @@ lpfc_mbox_timeout(unsigned long ptr) | |||
3237 | 3233 | ||
3238 | 3234 | ||
3239 | /** | 3235 | /** |
3240 | * lpfc_mbox_timeout_handler: Worker thread function to handle mailbox timeout. | 3236 | * lpfc_mbox_timeout_handler - Worker thread function to handle mailbox timeout |
3241 | * @phba: Pointer to HBA context object. | 3237 | * @phba: Pointer to HBA context object. |
3242 | * | 3238 | * |
3243 | * This function is called from worker thread when a mailbox command times out. | 3239 | * This function is called from worker thread when a mailbox command times out. |
@@ -3252,6 +3248,21 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | |||
3252 | struct lpfc_sli *psli = &phba->sli; | 3248 | struct lpfc_sli *psli = &phba->sli; |
3253 | struct lpfc_sli_ring *pring; | 3249 | struct lpfc_sli_ring *pring; |
3254 | 3250 | ||
3251 | /* Check the pmbox pointer first. There is a race condition | ||
3252 | * between the mbox timeout handler getting executed in the | ||
3253 | * worklist and the mailbox actually completing. When this | ||
3254 | * race condition occurs, the mbox_active will be NULL. | ||
3255 | */ | ||
3256 | spin_lock_irq(&phba->hbalock); | ||
3257 | if (pmbox == NULL) { | ||
3258 | lpfc_printf_log(phba, KERN_WARNING, | ||
3259 | LOG_MBOX | LOG_SLI, | ||
3260 | "0353 Active Mailbox cleared - mailbox timeout " | ||
3261 | "exiting\n"); | ||
3262 | spin_unlock_irq(&phba->hbalock); | ||
3263 | return; | ||
3264 | } | ||
3265 | |||
3255 | /* Mbox cmd <mbxCommand> timeout */ | 3266 | /* Mbox cmd <mbxCommand> timeout */ |
3256 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, | 3267 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, |
3257 | "0310 Mailbox command x%x timeout Data: x%x x%x x%p\n", | 3268 | "0310 Mailbox command x%x timeout Data: x%x x%x x%p\n", |
@@ -3259,6 +3270,7 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | |||
3259 | phba->pport->port_state, | 3270 | phba->pport->port_state, |
3260 | phba->sli.sli_flag, | 3271 | phba->sli.sli_flag, |
3261 | phba->sli.mbox_active); | 3272 | phba->sli.mbox_active); |
3273 | spin_unlock_irq(&phba->hbalock); | ||
3262 | 3274 | ||
3263 | /* Setting state unknown so lpfc_sli_abort_iocb_ring | 3275 | /* Setting state unknown so lpfc_sli_abort_iocb_ring |
3264 | * would get IOCB_ERROR from lpfc_sli_issue_iocb, allowing | 3276 | * would get IOCB_ERROR from lpfc_sli_issue_iocb, allowing |
@@ -3295,7 +3307,7 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba) | |||
3295 | } | 3307 | } |
3296 | 3308 | ||
3297 | /** | 3309 | /** |
3298 | * lpfc_sli_issue_mbox: Issue a mailbox command to firmware. | 3310 | * lpfc_sli_issue_mbox - Issue a mailbox command to firmware |
3299 | * @phba: Pointer to HBA context object. | 3311 | * @phba: Pointer to HBA context object. |
3300 | * @pmbox: Pointer to mailbox object. | 3312 | * @pmbox: Pointer to mailbox object. |
3301 | * @flag: Flag indicating how the mailbox need to be processed. | 3313 | * @flag: Flag indicating how the mailbox need to be processed. |
@@ -3365,6 +3377,12 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag) | |||
3365 | goto out_not_finished; | 3377 | goto out_not_finished; |
3366 | } | 3378 | } |
3367 | 3379 | ||
3380 | /* If HBA has a deferred error attention, fail the iocb. */ | ||
3381 | if (unlikely(phba->hba_flag & DEFER_ERATT)) { | ||
3382 | spin_unlock_irqrestore(&phba->hbalock, drvr_flag); | ||
3383 | goto out_not_finished; | ||
3384 | } | ||
3385 | |||
3368 | psli = &phba->sli; | 3386 | psli = &phba->sli; |
3369 | 3387 | ||
3370 | mb = &pmbox->mb; | 3388 | mb = &pmbox->mb; |
@@ -3632,7 +3650,7 @@ out_not_finished: | |||
3632 | } | 3650 | } |
3633 | 3651 | ||
3634 | /** | 3652 | /** |
3635 | * __lpfc_sli_ringtx_put: Add an iocb to the txq. | 3653 | * __lpfc_sli_ringtx_put - Add an iocb to the txq |
3636 | * @phba: Pointer to HBA context object. | 3654 | * @phba: Pointer to HBA context object. |
3637 | * @pring: Pointer to driver SLI ring object. | 3655 | * @pring: Pointer to driver SLI ring object. |
3638 | * @piocb: Pointer to address of newly added command iocb. | 3656 | * @piocb: Pointer to address of newly added command iocb. |
@@ -3651,7 +3669,7 @@ __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3651 | } | 3669 | } |
3652 | 3670 | ||
3653 | /** | 3671 | /** |
3654 | * lpfc_sli_next_iocb: Get the next iocb in the txq. | 3672 | * lpfc_sli_next_iocb - Get the next iocb in the txq |
3655 | * @phba: Pointer to HBA context object. | 3673 | * @phba: Pointer to HBA context object. |
3656 | * @pring: Pointer to driver SLI ring object. | 3674 | * @pring: Pointer to driver SLI ring object. |
3657 | * @piocb: Pointer to address of newly added command iocb. | 3675 | * @piocb: Pointer to address of newly added command iocb. |
@@ -3683,7 +3701,7 @@ lpfc_sli_next_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3683 | } | 3701 | } |
3684 | 3702 | ||
3685 | /** | 3703 | /** |
3686 | * __lpfc_sli_issue_iocb: Lockless version of lpfc_sli_issue_iocb. | 3704 | * __lpfc_sli_issue_iocb - Lockless version of lpfc_sli_issue_iocb |
3687 | * @phba: Pointer to HBA context object. | 3705 | * @phba: Pointer to HBA context object. |
3688 | * @pring: Pointer to driver SLI ring object. | 3706 | * @pring: Pointer to driver SLI ring object. |
3689 | * @piocb: Pointer to command iocb. | 3707 | * @piocb: Pointer to command iocb. |
@@ -3729,6 +3747,10 @@ __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3729 | if (unlikely(pci_channel_offline(phba->pcidev))) | 3747 | if (unlikely(pci_channel_offline(phba->pcidev))) |
3730 | return IOCB_ERROR; | 3748 | return IOCB_ERROR; |
3731 | 3749 | ||
3750 | /* If HBA has a deferred error attention, fail the iocb. */ | ||
3751 | if (unlikely(phba->hba_flag & DEFER_ERATT)) | ||
3752 | return IOCB_ERROR; | ||
3753 | |||
3732 | /* | 3754 | /* |
3733 | * We should never get an IOCB if we are in a < LINK_DOWN state | 3755 | * We should never get an IOCB if we are in a < LINK_DOWN state |
3734 | */ | 3756 | */ |
@@ -3813,7 +3835,7 @@ __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3813 | 3835 | ||
3814 | 3836 | ||
3815 | /** | 3837 | /** |
3816 | * lpfc_sli_issue_iocb: Wrapper function for __lpfc_sli_issue_iocb. | 3838 | * lpfc_sli_issue_iocb - Wrapper function for __lpfc_sli_issue_iocb |
3817 | * @phba: Pointer to HBA context object. | 3839 | * @phba: Pointer to HBA context object. |
3818 | * @pring: Pointer to driver SLI ring object. | 3840 | * @pring: Pointer to driver SLI ring object. |
3819 | * @piocb: Pointer to command iocb. | 3841 | * @piocb: Pointer to command iocb. |
@@ -3840,7 +3862,7 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
3840 | } | 3862 | } |
3841 | 3863 | ||
3842 | /** | 3864 | /** |
3843 | * lpfc_extra_ring_setup: Extra ring setup function. | 3865 | * lpfc_extra_ring_setup - Extra ring setup function |
3844 | * @phba: Pointer to HBA context object. | 3866 | * @phba: Pointer to HBA context object. |
3845 | * | 3867 | * |
3846 | * This function is called while driver attaches with the | 3868 | * This function is called while driver attaches with the |
@@ -3886,7 +3908,7 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba) | |||
3886 | } | 3908 | } |
3887 | 3909 | ||
3888 | /** | 3910 | /** |
3889 | * lpfc_sli_async_event_handler: ASYNC iocb handler function. | 3911 | * lpfc_sli_async_event_handler - ASYNC iocb handler function |
3890 | * @phba: Pointer to HBA context object. | 3912 | * @phba: Pointer to HBA context object. |
3891 | * @pring: Pointer to driver SLI ring object. | 3913 | * @pring: Pointer to driver SLI ring object. |
3892 | * @iocbq: Pointer to iocb object. | 3914 | * @iocbq: Pointer to iocb object. |
@@ -3907,6 +3929,7 @@ lpfc_sli_async_event_handler(struct lpfc_hba * phba, | |||
3907 | uint16_t temp; | 3929 | uint16_t temp; |
3908 | struct temp_event temp_event_data; | 3930 | struct temp_event temp_event_data; |
3909 | struct Scsi_Host *shost; | 3931 | struct Scsi_Host *shost; |
3932 | uint32_t *iocb_w; | ||
3910 | 3933 | ||
3911 | icmd = &iocbq->iocb; | 3934 | icmd = &iocbq->iocb; |
3912 | evt_code = icmd->un.asyncstat.evt_code; | 3935 | evt_code = icmd->un.asyncstat.evt_code; |
@@ -3914,13 +3937,23 @@ lpfc_sli_async_event_handler(struct lpfc_hba * phba, | |||
3914 | 3937 | ||
3915 | if ((evt_code != ASYNC_TEMP_WARN) && | 3938 | if ((evt_code != ASYNC_TEMP_WARN) && |
3916 | (evt_code != ASYNC_TEMP_SAFE)) { | 3939 | (evt_code != ASYNC_TEMP_SAFE)) { |
3940 | iocb_w = (uint32_t *) icmd; | ||
3917 | lpfc_printf_log(phba, | 3941 | lpfc_printf_log(phba, |
3918 | KERN_ERR, | 3942 | KERN_ERR, |
3919 | LOG_SLI, | 3943 | LOG_SLI, |
3920 | "0346 Ring %d handler: unexpected ASYNC_STATUS" | 3944 | "0346 Ring %d handler: unexpected ASYNC_STATUS" |
3921 | " evt_code 0x%x\n", | 3945 | " evt_code 0x%x \n" |
3946 | "W0 0x%08x W1 0x%08x W2 0x%08x W3 0x%08x\n" | ||
3947 | "W4 0x%08x W5 0x%08x W6 0x%08x W7 0x%08x\n" | ||
3948 | "W8 0x%08x W9 0x%08x W10 0x%08x W11 0x%08x\n" | ||
3949 | "W12 0x%08x W13 0x%08x W14 0x%08x W15 0x%08x\n", | ||
3922 | pring->ringno, | 3950 | pring->ringno, |
3923 | icmd->un.asyncstat.evt_code); | 3951 | icmd->un.asyncstat.evt_code, |
3952 | iocb_w[0], iocb_w[1], iocb_w[2], iocb_w[3], | ||
3953 | iocb_w[4], iocb_w[5], iocb_w[6], iocb_w[7], | ||
3954 | iocb_w[8], iocb_w[9], iocb_w[10], iocb_w[11], | ||
3955 | iocb_w[12], iocb_w[13], iocb_w[14], iocb_w[15]); | ||
3956 | |||
3924 | return; | 3957 | return; |
3925 | } | 3958 | } |
3926 | temp_event_data.data = (uint32_t)temp; | 3959 | temp_event_data.data = (uint32_t)temp; |
@@ -3954,7 +3987,7 @@ lpfc_sli_async_event_handler(struct lpfc_hba * phba, | |||
3954 | 3987 | ||
3955 | 3988 | ||
3956 | /** | 3989 | /** |
3957 | * lpfc_sli_setup: SLI ring setup function. | 3990 | * lpfc_sli_setup - SLI ring setup function |
3958 | * @phba: Pointer to HBA context object. | 3991 | * @phba: Pointer to HBA context object. |
3959 | * | 3992 | * |
3960 | * lpfc_sli_setup sets up rings of the SLI interface with | 3993 | * lpfc_sli_setup sets up rings of the SLI interface with |
@@ -4076,7 +4109,7 @@ lpfc_sli_setup(struct lpfc_hba *phba) | |||
4076 | } | 4109 | } |
4077 | 4110 | ||
4078 | /** | 4111 | /** |
4079 | * lpfc_sli_queue_setup: Queue initialization function. | 4112 | * lpfc_sli_queue_setup - Queue initialization function |
4080 | * @phba: Pointer to HBA context object. | 4113 | * @phba: Pointer to HBA context object. |
4081 | * | 4114 | * |
4082 | * lpfc_sli_queue_setup sets up mailbox queues and iocb queues for each | 4115 | * lpfc_sli_queue_setup sets up mailbox queues and iocb queues for each |
@@ -4115,7 +4148,7 @@ lpfc_sli_queue_setup(struct lpfc_hba *phba) | |||
4115 | } | 4148 | } |
4116 | 4149 | ||
4117 | /** | 4150 | /** |
4118 | * lpfc_sli_host_down: Vport cleanup function. | 4151 | * lpfc_sli_host_down - Vport cleanup function |
4119 | * @vport: Pointer to virtual port object. | 4152 | * @vport: Pointer to virtual port object. |
4120 | * | 4153 | * |
4121 | * lpfc_sli_host_down is called to clean up the resources | 4154 | * lpfc_sli_host_down is called to clean up the resources |
@@ -4179,22 +4212,14 @@ lpfc_sli_host_down(struct lpfc_vport *vport) | |||
4179 | 4212 | ||
4180 | spin_unlock_irqrestore(&phba->hbalock, flags); | 4213 | spin_unlock_irqrestore(&phba->hbalock, flags); |
4181 | 4214 | ||
4182 | while (!list_empty(&completions)) { | 4215 | /* Cancel all the IOCBs from the completions list */ |
4183 | list_remove_head(&completions, iocb, struct lpfc_iocbq, list); | 4216 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
4184 | 4217 | IOERR_SLI_DOWN); | |
4185 | if (!iocb->iocb_cmpl) | ||
4186 | lpfc_sli_release_iocbq(phba, iocb); | ||
4187 | else { | ||
4188 | iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; | ||
4189 | iocb->iocb.un.ulpWord[4] = IOERR_SLI_DOWN; | ||
4190 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
4191 | } | ||
4192 | } | ||
4193 | return 1; | 4218 | return 1; |
4194 | } | 4219 | } |
4195 | 4220 | ||
4196 | /** | 4221 | /** |
4197 | * lpfc_sli_hba_down: Resource cleanup function for the HBA. | 4222 | * lpfc_sli_hba_down - Resource cleanup function for the HBA |
4198 | * @phba: Pointer to HBA context object. | 4223 | * @phba: Pointer to HBA context object. |
4199 | * | 4224 | * |
4200 | * This function cleans up all iocb, buffers, mailbox commands | 4225 | * This function cleans up all iocb, buffers, mailbox commands |
@@ -4216,8 +4241,6 @@ lpfc_sli_hba_down(struct lpfc_hba *phba) | |||
4216 | struct lpfc_sli_ring *pring; | 4241 | struct lpfc_sli_ring *pring; |
4217 | struct lpfc_dmabuf *buf_ptr; | 4242 | struct lpfc_dmabuf *buf_ptr; |
4218 | LPFC_MBOXQ_t *pmb; | 4243 | LPFC_MBOXQ_t *pmb; |
4219 | struct lpfc_iocbq *iocb; | ||
4220 | IOCB_t *cmd = NULL; | ||
4221 | int i; | 4244 | int i; |
4222 | unsigned long flags = 0; | 4245 | unsigned long flags = 0; |
4223 | 4246 | ||
@@ -4245,18 +4268,9 @@ lpfc_sli_hba_down(struct lpfc_hba *phba) | |||
4245 | } | 4268 | } |
4246 | spin_unlock_irqrestore(&phba->hbalock, flags); | 4269 | spin_unlock_irqrestore(&phba->hbalock, flags); |
4247 | 4270 | ||
4248 | while (!list_empty(&completions)) { | 4271 | /* Cancel all the IOCBs from the completions list */ |
4249 | list_remove_head(&completions, iocb, struct lpfc_iocbq, list); | 4272 | lpfc_sli_cancel_iocbs(phba, &completions, IOSTAT_LOCAL_REJECT, |
4250 | cmd = &iocb->iocb; | 4273 | IOERR_SLI_DOWN); |
4251 | |||
4252 | if (!iocb->iocb_cmpl) | ||
4253 | lpfc_sli_release_iocbq(phba, iocb); | ||
4254 | else { | ||
4255 | cmd->ulpStatus = IOSTAT_LOCAL_REJECT; | ||
4256 | cmd->un.ulpWord[4] = IOERR_SLI_DOWN; | ||
4257 | (iocb->iocb_cmpl) (phba, iocb, iocb); | ||
4258 | } | ||
4259 | } | ||
4260 | 4274 | ||
4261 | spin_lock_irqsave(&phba->hbalock, flags); | 4275 | spin_lock_irqsave(&phba->hbalock, flags); |
4262 | list_splice_init(&phba->elsbuf, &completions); | 4276 | list_splice_init(&phba->elsbuf, &completions); |
@@ -4299,7 +4313,7 @@ lpfc_sli_hba_down(struct lpfc_hba *phba) | |||
4299 | } | 4313 | } |
4300 | 4314 | ||
4301 | /** | 4315 | /** |
4302 | * lpfc_sli_pcimem_bcopy: SLI memory copy function. | 4316 | * lpfc_sli_pcimem_bcopy - SLI memory copy function |
4303 | * @srcp: Source memory pointer. | 4317 | * @srcp: Source memory pointer. |
4304 | * @destp: Destination memory pointer. | 4318 | * @destp: Destination memory pointer. |
4305 | * @cnt: Number of words required to be copied. | 4319 | * @cnt: Number of words required to be copied. |
@@ -4329,7 +4343,7 @@ lpfc_sli_pcimem_bcopy(void *srcp, void *destp, uint32_t cnt) | |||
4329 | 4343 | ||
4330 | 4344 | ||
4331 | /** | 4345 | /** |
4332 | * lpfc_sli_ringpostbuf_put: Function to add a buffer to postbufq. | 4346 | * lpfc_sli_ringpostbuf_put - Function to add a buffer to postbufq |
4333 | * @phba: Pointer to HBA context object. | 4347 | * @phba: Pointer to HBA context object. |
4334 | * @pring: Pointer to driver SLI ring object. | 4348 | * @pring: Pointer to driver SLI ring object. |
4335 | * @mp: Pointer to driver buffer object. | 4349 | * @mp: Pointer to driver buffer object. |
@@ -4352,8 +4366,7 @@ lpfc_sli_ringpostbuf_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4352 | } | 4366 | } |
4353 | 4367 | ||
4354 | /** | 4368 | /** |
4355 | * lpfc_sli_get_buffer_tag: Tag allocation function for a buffer posted | 4369 | * lpfc_sli_get_buffer_tag - allocates a tag for a CMD_QUE_XRI64_CX buffer |
4356 | * using CMD_QUE_XRI64_CX iocb. | ||
4357 | * @phba: Pointer to HBA context object. | 4370 | * @phba: Pointer to HBA context object. |
4358 | * | 4371 | * |
4359 | * When HBQ is enabled, buffers are searched based on tags. This function | 4372 | * When HBQ is enabled, buffers are searched based on tags. This function |
@@ -4378,8 +4391,7 @@ lpfc_sli_get_buffer_tag(struct lpfc_hba *phba) | |||
4378 | } | 4391 | } |
4379 | 4392 | ||
4380 | /** | 4393 | /** |
4381 | * lpfc_sli_ring_taggedbuf_get: Search HBQ buffer associated with | 4394 | * lpfc_sli_ring_taggedbuf_get - find HBQ buffer associated with given tag |
4382 | * posted using CMD_QUE_XRI64_CX iocb. | ||
4383 | * @phba: Pointer to HBA context object. | 4395 | * @phba: Pointer to HBA context object. |
4384 | * @pring: Pointer to driver SLI ring object. | 4396 | * @pring: Pointer to driver SLI ring object. |
4385 | * @tag: Buffer tag. | 4397 | * @tag: Buffer tag. |
@@ -4422,8 +4434,7 @@ lpfc_sli_ring_taggedbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4422 | } | 4434 | } |
4423 | 4435 | ||
4424 | /** | 4436 | /** |
4425 | * lpfc_sli_ringpostbuf_get: SLI2 buffer search function for | 4437 | * lpfc_sli_ringpostbuf_get - search buffers for unsolicited CT and ELS events |
4426 | * unsolicited ct and els events. | ||
4427 | * @phba: Pointer to HBA context object. | 4438 | * @phba: Pointer to HBA context object. |
4428 | * @pring: Pointer to driver SLI ring object. | 4439 | * @pring: Pointer to driver SLI ring object. |
4429 | * @phys: DMA address of the buffer. | 4440 | * @phys: DMA address of the buffer. |
@@ -4466,7 +4477,7 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
4466 | } | 4477 | } |
4467 | 4478 | ||
4468 | /** | 4479 | /** |
4469 | * lpfc_sli_abort_els_cmpl: Completion handler for the els abort iocbs. | 4480 | * lpfc_sli_abort_els_cmpl - Completion handler for the els abort iocbs |
4470 | * @phba: Pointer to HBA context object. | 4481 | * @phba: Pointer to HBA context object. |
4471 | * @cmdiocb: Pointer to driver command iocb object. | 4482 | * @cmdiocb: Pointer to driver command iocb object. |
4472 | * @rspiocb: Pointer to driver response iocb object. | 4483 | * @rspiocb: Pointer to driver response iocb object. |
@@ -4542,7 +4553,7 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4542 | } | 4553 | } |
4543 | 4554 | ||
4544 | /** | 4555 | /** |
4545 | * lpfc_ignore_els_cmpl: Completion handler for aborted ELS command. | 4556 | * lpfc_ignore_els_cmpl - Completion handler for aborted ELS command |
4546 | * @phba: Pointer to HBA context object. | 4557 | * @phba: Pointer to HBA context object. |
4547 | * @cmdiocb: Pointer to driver command iocb object. | 4558 | * @cmdiocb: Pointer to driver command iocb object. |
4548 | * @rspiocb: Pointer to driver response iocb object. | 4559 | * @rspiocb: Pointer to driver response iocb object. |
@@ -4572,7 +4583,7 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4572 | } | 4583 | } |
4573 | 4584 | ||
4574 | /** | 4585 | /** |
4575 | * lpfc_sli_issue_abort_iotag: Abort function for a command iocb. | 4586 | * lpfc_sli_issue_abort_iotag - Abort function for a command iocb |
4576 | * @phba: Pointer to HBA context object. | 4587 | * @phba: Pointer to HBA context object. |
4577 | * @pring: Pointer to driver SLI ring object. | 4588 | * @pring: Pointer to driver SLI ring object. |
4578 | * @cmdiocb: Pointer to driver command iocb object. | 4589 | * @cmdiocb: Pointer to driver command iocb object. |
@@ -4658,15 +4669,14 @@ abort_iotag_exit: | |||
4658 | } | 4669 | } |
4659 | 4670 | ||
4660 | /** | 4671 | /** |
4661 | * lpfc_sli_validate_fcp_iocb: Filtering function, used to find commands | 4672 | * lpfc_sli_validate_fcp_iocb - find commands associated with a vport or LUN |
4662 | * associated with a vport/SCSI target/lun. | ||
4663 | * @iocbq: Pointer to driver iocb object. | 4673 | * @iocbq: Pointer to driver iocb object. |
4664 | * @vport: Pointer to driver virtual port object. | 4674 | * @vport: Pointer to driver virtual port object. |
4665 | * @tgt_id: SCSI ID of the target. | 4675 | * @tgt_id: SCSI ID of the target. |
4666 | * @lun_id: LUN ID of the scsi device. | 4676 | * @lun_id: LUN ID of the scsi device. |
4667 | * @ctx_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST | 4677 | * @ctx_cmd: LPFC_CTX_LUN/LPFC_CTX_TGT/LPFC_CTX_HOST |
4668 | * | 4678 | * |
4669 | * This function acts as iocb filter for functions which abort or count | 4679 | * This function acts as an iocb filter for functions which abort or count |
4670 | * all FCP iocbs pending on a lun/SCSI target/SCSI host. It will return | 4680 | * all FCP iocbs pending on a lun/SCSI target/SCSI host. It will return |
4671 | * 0 if the filtering criteria is met for the given iocb and will return | 4681 | * 0 if the filtering criteria is met for the given iocb and will return |
4672 | * 1 if the filtering criteria is not met. | 4682 | * 1 if the filtering criteria is not met. |
@@ -4724,7 +4734,7 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport, | |||
4724 | } | 4734 | } |
4725 | 4735 | ||
4726 | /** | 4736 | /** |
4727 | * lpfc_sli_sum_iocb: Function to count the number of FCP iocbs pending. | 4737 | * lpfc_sli_sum_iocb - Function to count the number of FCP iocbs pending |
4728 | * @vport: Pointer to virtual port. | 4738 | * @vport: Pointer to virtual port. |
4729 | * @tgt_id: SCSI ID of the target. | 4739 | * @tgt_id: SCSI ID of the target. |
4730 | * @lun_id: LUN ID of the scsi device. | 4740 | * @lun_id: LUN ID of the scsi device. |
@@ -4762,8 +4772,7 @@ lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id, | |||
4762 | } | 4772 | } |
4763 | 4773 | ||
4764 | /** | 4774 | /** |
4765 | * lpfc_sli_abort_fcp_cmpl: Completion handler function for an aborted | 4775 | * lpfc_sli_abort_fcp_cmpl - Completion handler function for aborted FCP IOCBs |
4766 | * FCP iocb. | ||
4767 | * @phba: Pointer to HBA context object | 4776 | * @phba: Pointer to HBA context object |
4768 | * @cmdiocb: Pointer to command iocb object. | 4777 | * @cmdiocb: Pointer to command iocb object. |
4769 | * @rspiocb: Pointer to response iocb object. | 4778 | * @rspiocb: Pointer to response iocb object. |
@@ -4781,8 +4790,7 @@ lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
4781 | } | 4790 | } |
4782 | 4791 | ||
4783 | /** | 4792 | /** |
4784 | * lpfc_sli_abort_iocb: This function issue abort for all SCSI commands | 4793 | * lpfc_sli_abort_iocb - issue abort for all commands on a host/target/LUN |
4785 | * pending on a SCSI host(vport)/target/lun. | ||
4786 | * @vport: Pointer to virtual port. | 4794 | * @vport: Pointer to virtual port. |
4787 | * @pring: Pointer to driver SLI ring object. | 4795 | * @pring: Pointer to driver SLI ring object. |
4788 | * @tgt_id: SCSI ID of the target. | 4796 | * @tgt_id: SCSI ID of the target. |
@@ -4854,8 +4862,7 @@ lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, | |||
4854 | } | 4862 | } |
4855 | 4863 | ||
4856 | /** | 4864 | /** |
4857 | * lpfc_sli_wake_iocb_wait: iocb completion handler for iocb issued using | 4865 | * lpfc_sli_wake_iocb_wait - lpfc_sli_issue_iocb_wait's completion handler |
4858 | * lpfc_sli_issue_iocb_wait. | ||
4859 | * @phba: Pointer to HBA context object. | 4866 | * @phba: Pointer to HBA context object. |
4860 | * @cmdiocbq: Pointer to command iocb. | 4867 | * @cmdiocbq: Pointer to command iocb. |
4861 | * @rspiocbq: Pointer to response iocb. | 4868 | * @rspiocbq: Pointer to response iocb. |
@@ -4893,7 +4900,7 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, | |||
4893 | } | 4900 | } |
4894 | 4901 | ||
4895 | /** | 4902 | /** |
4896 | * lpfc_sli_issue_iocb_wait: Synchronous function to issue iocb commands. | 4903 | * lpfc_sli_issue_iocb_wait - Synchronous function to issue iocb commands |
4897 | * @phba: Pointer to HBA context object.. | 4904 | * @phba: Pointer to HBA context object.. |
4898 | * @pring: Pointer to sli ring. | 4905 | * @pring: Pointer to sli ring. |
4899 | * @piocb: Pointer to command iocb. | 4906 | * @piocb: Pointer to command iocb. |
@@ -5000,7 +5007,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, | |||
5000 | } | 5007 | } |
5001 | 5008 | ||
5002 | /** | 5009 | /** |
5003 | * lpfc_sli_issue_mbox_wait: Synchronous function to issue mailbox. | 5010 | * lpfc_sli_issue_mbox_wait - Synchronous function to issue mailbox |
5004 | * @phba: Pointer to HBA context object. | 5011 | * @phba: Pointer to HBA context object. |
5005 | * @pmboxq: Pointer to driver mailbox object. | 5012 | * @pmboxq: Pointer to driver mailbox object. |
5006 | * @timeout: Timeout in number of seconds. | 5013 | * @timeout: Timeout in number of seconds. |
@@ -5070,7 +5077,7 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq, | |||
5070 | } | 5077 | } |
5071 | 5078 | ||
5072 | /** | 5079 | /** |
5073 | * lpfc_sli_flush_mbox_queue: mailbox queue cleanup function. | 5080 | * lpfc_sli_flush_mbox_queue - mailbox queue cleanup function |
5074 | * @phba: Pointer to HBA context. | 5081 | * @phba: Pointer to HBA context. |
5075 | * | 5082 | * |
5076 | * This function is called to cleanup any pending mailbox | 5083 | * This function is called to cleanup any pending mailbox |
@@ -5113,7 +5120,7 @@ lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba) | |||
5113 | } | 5120 | } |
5114 | 5121 | ||
5115 | /** | 5122 | /** |
5116 | * lpfc_sli_check_eratt: check error attention events | 5123 | * lpfc_sli_check_eratt - check error attention events |
5117 | * @phba: Pointer to HBA context. | 5124 | * @phba: Pointer to HBA context. |
5118 | * | 5125 | * |
5119 | * This function is called form timer soft interrupt context to check HBA's | 5126 | * This function is called form timer soft interrupt context to check HBA's |
@@ -5145,11 +5152,31 @@ lpfc_sli_check_eratt(struct lpfc_hba *phba) | |||
5145 | return 0; | 5152 | return 0; |
5146 | } | 5153 | } |
5147 | 5154 | ||
5155 | /* | ||
5156 | * If there is deferred error attention, do not check for error | ||
5157 | * attention | ||
5158 | */ | ||
5159 | if (unlikely(phba->hba_flag & DEFER_ERATT)) { | ||
5160 | spin_unlock_irq(&phba->hbalock); | ||
5161 | return 0; | ||
5162 | } | ||
5163 | |||
5148 | /* Read chip Host Attention (HA) register */ | 5164 | /* Read chip Host Attention (HA) register */ |
5149 | ha_copy = readl(phba->HAregaddr); | 5165 | ha_copy = readl(phba->HAregaddr); |
5150 | if (ha_copy & HA_ERATT) { | 5166 | if (ha_copy & HA_ERATT) { |
5151 | /* Read host status register to retrieve error event */ | 5167 | /* Read host status register to retrieve error event */ |
5152 | lpfc_sli_read_hs(phba); | 5168 | lpfc_sli_read_hs(phba); |
5169 | |||
5170 | /* Check if there is a deferred error condition is active */ | ||
5171 | if ((HS_FFER1 & phba->work_hs) && | ||
5172 | ((HS_FFER2 | HS_FFER3 | HS_FFER4 | HS_FFER5 | | ||
5173 | HS_FFER6 | HS_FFER7) & phba->work_hs)) { | ||
5174 | phba->hba_flag |= DEFER_ERATT; | ||
5175 | /* Clear all interrupt enable conditions */ | ||
5176 | writel(0, phba->HCregaddr); | ||
5177 | readl(phba->HCregaddr); | ||
5178 | } | ||
5179 | |||
5153 | /* Set the driver HA work bitmap */ | 5180 | /* Set the driver HA work bitmap */ |
5154 | phba->work_ha |= HA_ERATT; | 5181 | phba->work_ha |= HA_ERATT; |
5155 | /* Indicate polling handles this ERATT */ | 5182 | /* Indicate polling handles this ERATT */ |
@@ -5162,7 +5189,7 @@ lpfc_sli_check_eratt(struct lpfc_hba *phba) | |||
5162 | } | 5189 | } |
5163 | 5190 | ||
5164 | /** | 5191 | /** |
5165 | * lpfc_sp_intr_handler: The slow-path interrupt handler of lpfc driver. | 5192 | * lpfc_sp_intr_handler - The slow-path interrupt handler of lpfc driver |
5166 | * @irq: Interrupt number. | 5193 | * @irq: Interrupt number. |
5167 | * @dev_id: The device context pointer. | 5194 | * @dev_id: The device context pointer. |
5168 | * | 5195 | * |
@@ -5238,6 +5265,16 @@ lpfc_sp_intr_handler(int irq, void *dev_id) | |||
5238 | /* Indicate interrupt handler handles ERATT */ | 5265 | /* Indicate interrupt handler handles ERATT */ |
5239 | phba->hba_flag |= HBA_ERATT_HANDLED; | 5266 | phba->hba_flag |= HBA_ERATT_HANDLED; |
5240 | } | 5267 | } |
5268 | |||
5269 | /* | ||
5270 | * If there is deferred error attention, do not check for any | ||
5271 | * interrupt. | ||
5272 | */ | ||
5273 | if (unlikely(phba->hba_flag & DEFER_ERATT)) { | ||
5274 | spin_unlock_irq(&phba->hbalock); | ||
5275 | return IRQ_NONE; | ||
5276 | } | ||
5277 | |||
5241 | /* Clear up only attention source related to slow-path */ | 5278 | /* Clear up only attention source related to slow-path */ |
5242 | writel((ha_copy & (HA_MBATT | HA_R2_CLR_MSK)), | 5279 | writel((ha_copy & (HA_MBATT | HA_R2_CLR_MSK)), |
5243 | phba->HAregaddr); | 5280 | phba->HAregaddr); |
@@ -5309,8 +5346,22 @@ lpfc_sp_intr_handler(int irq, void *dev_id) | |||
5309 | } | 5346 | } |
5310 | } | 5347 | } |
5311 | spin_lock_irqsave(&phba->hbalock, iflag); | 5348 | spin_lock_irqsave(&phba->hbalock, iflag); |
5312 | if (work_ha_copy & HA_ERATT) | 5349 | if (work_ha_copy & HA_ERATT) { |
5313 | lpfc_sli_read_hs(phba); | 5350 | lpfc_sli_read_hs(phba); |
5351 | /* | ||
5352 | * Check if there is a deferred error condition | ||
5353 | * is active | ||
5354 | */ | ||
5355 | if ((HS_FFER1 & phba->work_hs) && | ||
5356 | ((HS_FFER2 | HS_FFER3 | HS_FFER4 | HS_FFER5 | | ||
5357 | HS_FFER6 | HS_FFER7) & phba->work_hs)) { | ||
5358 | phba->hba_flag |= DEFER_ERATT; | ||
5359 | /* Clear all interrupt enable conditions */ | ||
5360 | writel(0, phba->HCregaddr); | ||
5361 | readl(phba->HCregaddr); | ||
5362 | } | ||
5363 | } | ||
5364 | |||
5314 | if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { | 5365 | if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { |
5315 | pmb = phba->sli.mbox_active; | 5366 | pmb = phba->sli.mbox_active; |
5316 | pmbox = &pmb->mb; | 5367 | pmbox = &pmb->mb; |
@@ -5423,7 +5474,7 @@ send_current_mbox: | |||
5423 | } /* lpfc_sp_intr_handler */ | 5474 | } /* lpfc_sp_intr_handler */ |
5424 | 5475 | ||
5425 | /** | 5476 | /** |
5426 | * lpfc_fp_intr_handler: The fast-path interrupt handler of lpfc driver. | 5477 | * lpfc_fp_intr_handler - The fast-path interrupt handler of lpfc driver |
5427 | * @irq: Interrupt number. | 5478 | * @irq: Interrupt number. |
5428 | * @dev_id: The device context pointer. | 5479 | * @dev_id: The device context pointer. |
5429 | * | 5480 | * |
@@ -5474,6 +5525,14 @@ lpfc_fp_intr_handler(int irq, void *dev_id) | |||
5474 | ha_copy = readl(phba->HAregaddr); | 5525 | ha_copy = readl(phba->HAregaddr); |
5475 | /* Clear up only attention source related to fast-path */ | 5526 | /* Clear up only attention source related to fast-path */ |
5476 | spin_lock_irqsave(&phba->hbalock, iflag); | 5527 | spin_lock_irqsave(&phba->hbalock, iflag); |
5528 | /* | ||
5529 | * If there is deferred error attention, do not check for | ||
5530 | * any interrupt. | ||
5531 | */ | ||
5532 | if (unlikely(phba->hba_flag & DEFER_ERATT)) { | ||
5533 | spin_unlock_irq(&phba->hbalock); | ||
5534 | return IRQ_NONE; | ||
5535 | } | ||
5477 | writel((ha_copy & (HA_R0_CLR_MSK | HA_R1_CLR_MSK)), | 5536 | writel((ha_copy & (HA_R0_CLR_MSK | HA_R1_CLR_MSK)), |
5478 | phba->HAregaddr); | 5537 | phba->HAregaddr); |
5479 | readl(phba->HAregaddr); /* flush */ | 5538 | readl(phba->HAregaddr); /* flush */ |
@@ -5510,7 +5569,7 @@ lpfc_fp_intr_handler(int irq, void *dev_id) | |||
5510 | } /* lpfc_fp_intr_handler */ | 5569 | } /* lpfc_fp_intr_handler */ |
5511 | 5570 | ||
5512 | /** | 5571 | /** |
5513 | * lpfc_intr_handler: The device-level interrupt handler of lpfc driver. | 5572 | * lpfc_intr_handler - The device-level interrupt handler of lpfc driver |
5514 | * @irq: Interrupt number. | 5573 | * @irq: Interrupt number. |
5515 | * @dev_id: The device context pointer. | 5574 | * @dev_id: The device context pointer. |
5516 | * | 5575 | * |
@@ -5566,6 +5625,14 @@ lpfc_intr_handler(int irq, void *dev_id) | |||
5566 | phba->hba_flag |= HBA_ERATT_HANDLED; | 5625 | phba->hba_flag |= HBA_ERATT_HANDLED; |
5567 | } | 5626 | } |
5568 | 5627 | ||
5628 | /* | ||
5629 | * If there is deferred error attention, do not check for any interrupt. | ||
5630 | */ | ||
5631 | if (unlikely(phba->hba_flag & DEFER_ERATT)) { | ||
5632 | spin_unlock_irq(&phba->hbalock); | ||
5633 | return IRQ_NONE; | ||
5634 | } | ||
5635 | |||
5569 | /* Clear attention sources except link and error attentions */ | 5636 | /* Clear attention sources except link and error attentions */ |
5570 | writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); | 5637 | writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); |
5571 | readl(phba->HAregaddr); /* flush */ | 5638 | readl(phba->HAregaddr); /* flush */ |
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 7e32e95c5392..e599519e3078 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2009 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * * | 7 | * * |
@@ -18,7 +18,7 @@ | |||
18 | * included with this package. * | 18 | * included with this package. * |
19 | *******************************************************************/ | 19 | *******************************************************************/ |
20 | 20 | ||
21 | #define LPFC_DRIVER_VERSION "8.3.0" | 21 | #define LPFC_DRIVER_VERSION "8.3.1" |
22 | 22 | ||
23 | #define LPFC_DRIVER_NAME "lpfc" | 23 | #define LPFC_DRIVER_NAME "lpfc" |
24 | #define LPFC_SP_DRIVER_HANDLER_NAME "lpfc:sp" | 24 | #define LPFC_SP_DRIVER_HANDLER_NAME "lpfc:sp" |
@@ -26,4 +26,4 @@ | |||
26 | 26 | ||
27 | #define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \ | 27 | #define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \ |
28 | LPFC_DRIVER_VERSION | 28 | LPFC_DRIVER_VERSION |
29 | #define LPFC_COPYRIGHT "Copyright(c) 2004-2008 Emulex. All rights reserved." | 29 | #define LPFC_COPYRIGHT "Copyright(c) 2004-2009 Emulex. All rights reserved." |
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c index 63b54c66756c..917ad56b0aff 100644 --- a/drivers/scsi/lpfc/lpfc_vport.c +++ b/drivers/scsi/lpfc/lpfc_vport.c | |||
@@ -206,7 +206,7 @@ lpfc_unique_wwpn(struct lpfc_hba *phba, struct lpfc_vport *new_vport) | |||
206 | } | 206 | } |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * lpfc_discovery_wait: Wait for driver discovery to quiesce. | 209 | * lpfc_discovery_wait - Wait for driver discovery to quiesce |
210 | * @vport: The virtual port for which this call is being executed. | 210 | * @vport: The virtual port for which this call is being executed. |
211 | * | 211 | * |
212 | * This driver calls this routine specifically from lpfc_vport_delete | 212 | * This driver calls this routine specifically from lpfc_vport_delete |
@@ -741,7 +741,7 @@ lpfc_destroy_vport_work_array(struct lpfc_hba *phba, struct lpfc_vport **vports) | |||
741 | 741 | ||
742 | 742 | ||
743 | /** | 743 | /** |
744 | * lpfc_vport_reset_stat_data: Reset the statistical data for the vport. | 744 | * lpfc_vport_reset_stat_data - Reset the statistical data for the vport |
745 | * @vport: Pointer to vport object. | 745 | * @vport: Pointer to vport object. |
746 | * | 746 | * |
747 | * This function resets the statistical data for the vport. This function | 747 | * This function resets the statistical data for the vport. This function |
@@ -763,8 +763,7 @@ lpfc_vport_reset_stat_data(struct lpfc_vport *vport) | |||
763 | 763 | ||
764 | 764 | ||
765 | /** | 765 | /** |
766 | * lpfc_alloc_bucket: Allocate data buffer required for collecting | 766 | * lpfc_alloc_bucket - Allocate data buffer required for statistical data |
767 | * statistical data. | ||
768 | * @vport: Pointer to vport object. | 767 | * @vport: Pointer to vport object. |
769 | * | 768 | * |
770 | * This function allocates data buffer required for all the FC | 769 | * This function allocates data buffer required for all the FC |
@@ -797,8 +796,7 @@ lpfc_alloc_bucket(struct lpfc_vport *vport) | |||
797 | } | 796 | } |
798 | 797 | ||
799 | /** | 798 | /** |
800 | * lpfc_free_bucket: Free data buffer required for collecting | 799 | * lpfc_free_bucket - Free data buffer required for statistical data |
801 | * statistical data. | ||
802 | * @vport: Pointer to vport object. | 800 | * @vport: Pointer to vport object. |
803 | * | 801 | * |
804 | * Th function frees statistical data buffer of all the FC | 802 | * Th function frees statistical data buffer of all the FC |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index a91f5143ceac..f3da592f7bcc 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -636,6 +636,14 @@ _base_unmask_interrupts(struct MPT2SAS_ADAPTER *ioc) | |||
636 | static irqreturn_t | 636 | static irqreturn_t |
637 | _base_interrupt(int irq, void *bus_id) | 637 | _base_interrupt(int irq, void *bus_id) |
638 | { | 638 | { |
639 | union reply_descriptor { | ||
640 | u64 word; | ||
641 | struct { | ||
642 | u32 low; | ||
643 | u32 high; | ||
644 | } u; | ||
645 | }; | ||
646 | union reply_descriptor rd; | ||
639 | u32 post_index, post_index_next, completed_cmds; | 647 | u32 post_index, post_index_next, completed_cmds; |
640 | u8 request_desript_type; | 648 | u8 request_desript_type; |
641 | u16 smid; | 649 | u16 smid; |
@@ -656,7 +664,8 @@ _base_interrupt(int irq, void *bus_id) | |||
656 | 664 | ||
657 | completed_cmds = 0; | 665 | completed_cmds = 0; |
658 | do { | 666 | do { |
659 | if (ioc->reply_post_free[post_index].Words == ~0ULL) | 667 | rd.word = ioc->reply_post_free[post_index].Words; |
668 | if (rd.u.low == UINT_MAX || rd.u.high == UINT_MAX) | ||
660 | goto out; | 669 | goto out; |
661 | reply = 0; | 670 | reply = 0; |
662 | cb_idx = 0xFF; | 671 | cb_idx = 0xFF; |
@@ -721,7 +730,7 @@ _base_interrupt(int irq, void *bus_id) | |||
721 | for (i = 0 ; i < completed_cmds; i++) { | 730 | for (i = 0 ; i < completed_cmds; i++) { |
722 | post_index = post_index_next; | 731 | post_index = post_index_next; |
723 | /* poison the reply post descriptor */ | 732 | /* poison the reply post descriptor */ |
724 | ioc->reply_post_free[post_index_next].Words = ~0ULL; | 733 | ioc->reply_post_free[post_index_next].Words = ULLONG_MAX; |
725 | post_index_next = (post_index == | 734 | post_index_next = (post_index == |
726 | (ioc->reply_post_queue_depth - 1)) | 735 | (ioc->reply_post_queue_depth - 1)) |
727 | ? 0 : post_index + 1; | 736 | ? 0 : post_index + 1; |
@@ -1387,6 +1396,64 @@ mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid, | |||
1387 | } | 1396 | } |
1388 | 1397 | ||
1389 | /** | 1398 | /** |
1399 | * _base_display_dell_branding - Disply branding string | ||
1400 | * @ioc: per adapter object | ||
1401 | * | ||
1402 | * Return nothing. | ||
1403 | */ | ||
1404 | static void | ||
1405 | _base_display_dell_branding(struct MPT2SAS_ADAPTER *ioc) | ||
1406 | { | ||
1407 | char dell_branding[MPT2SAS_DELL_BRANDING_SIZE]; | ||
1408 | |||
1409 | if (ioc->pdev->subsystem_vendor != PCI_VENDOR_ID_DELL) | ||
1410 | return; | ||
1411 | |||
1412 | memset(dell_branding, 0, MPT2SAS_DELL_BRANDING_SIZE); | ||
1413 | switch (ioc->pdev->subsystem_device) { | ||
1414 | case MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID: | ||
1415 | strncpy(dell_branding, MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING, | ||
1416 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1417 | break; | ||
1418 | case MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID: | ||
1419 | strncpy(dell_branding, MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING, | ||
1420 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1421 | break; | ||
1422 | case MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID: | ||
1423 | strncpy(dell_branding, | ||
1424 | MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING, | ||
1425 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1426 | break; | ||
1427 | case MPT2SAS_DELL_PERC_H200_MODULAR_SSDID: | ||
1428 | strncpy(dell_branding, | ||
1429 | MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING, | ||
1430 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1431 | break; | ||
1432 | case MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID: | ||
1433 | strncpy(dell_branding, | ||
1434 | MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING, | ||
1435 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1436 | break; | ||
1437 | case MPT2SAS_DELL_PERC_H200_SSDID: | ||
1438 | strncpy(dell_branding, MPT2SAS_DELL_PERC_H200_BRANDING, | ||
1439 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1440 | break; | ||
1441 | case MPT2SAS_DELL_6GBPS_SAS_SSDID: | ||
1442 | strncpy(dell_branding, MPT2SAS_DELL_6GBPS_SAS_BRANDING, | ||
1443 | MPT2SAS_DELL_BRANDING_SIZE - 1); | ||
1444 | break; | ||
1445 | default: | ||
1446 | sprintf(dell_branding, "0x%4X", ioc->pdev->subsystem_device); | ||
1447 | break; | ||
1448 | } | ||
1449 | |||
1450 | printk(MPT2SAS_INFO_FMT "%s: Vendor(0x%04X), Device(0x%04X)," | ||
1451 | " SSVID(0x%04X), SSDID(0x%04X)\n", ioc->name, dell_branding, | ||
1452 | ioc->pdev->vendor, ioc->pdev->device, ioc->pdev->subsystem_vendor, | ||
1453 | ioc->pdev->subsystem_device); | ||
1454 | } | ||
1455 | |||
1456 | /** | ||
1390 | * _base_display_ioc_capabilities - Disply IOC's capabilities. | 1457 | * _base_display_ioc_capabilities - Disply IOC's capabilities. |
1391 | * @ioc: per adapter object | 1458 | * @ioc: per adapter object |
1392 | * | 1459 | * |
@@ -1427,6 +1494,8 @@ _base_display_ioc_capabilities(struct MPT2SAS_ADAPTER *ioc) | |||
1427 | i++; | 1494 | i++; |
1428 | } | 1495 | } |
1429 | 1496 | ||
1497 | _base_display_dell_branding(ioc); | ||
1498 | |||
1430 | i = 0; | 1499 | i = 0; |
1431 | printk("), "); | 1500 | printk("), "); |
1432 | printk("Capabilities=("); | 1501 | printk("Capabilities=("); |
@@ -3068,7 +3137,7 @@ _base_make_ioc_operational(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, | |||
3068 | 3137 | ||
3069 | /* initialize Reply Post Free Queue */ | 3138 | /* initialize Reply Post Free Queue */ |
3070 | for (i = 0; i < ioc->reply_post_queue_depth; i++) | 3139 | for (i = 0; i < ioc->reply_post_queue_depth; i++) |
3071 | ioc->reply_post_free[i].Words = ~0ULL; | 3140 | ioc->reply_post_free[i].Words = ULLONG_MAX; |
3072 | 3141 | ||
3073 | r = _base_send_ioc_init(ioc, VF_ID, sleep_flag); | 3142 | r = _base_send_ioc_init(ioc, VF_ID, sleep_flag); |
3074 | if (r) | 3143 | if (r) |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index 6945ff4d382e..36b1d1052ba1 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h | |||
@@ -68,11 +68,11 @@ | |||
68 | #define MPT2SAS_DRIVER_NAME "mpt2sas" | 68 | #define MPT2SAS_DRIVER_NAME "mpt2sas" |
69 | #define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>" | 69 | #define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>" |
70 | #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver" | 70 | #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver" |
71 | #define MPT2SAS_DRIVER_VERSION "00.100.11.16" | 71 | #define MPT2SAS_DRIVER_VERSION "01.100.02.00" |
72 | #define MPT2SAS_MAJOR_VERSION 00 | 72 | #define MPT2SAS_MAJOR_VERSION 01 |
73 | #define MPT2SAS_MINOR_VERSION 100 | 73 | #define MPT2SAS_MINOR_VERSION 100 |
74 | #define MPT2SAS_BUILD_VERSION 11 | 74 | #define MPT2SAS_BUILD_VERSION 02 |
75 | #define MPT2SAS_RELEASE_VERSION 16 | 75 | #define MPT2SAS_RELEASE_VERSION 00 |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * Set MPT2SAS_SG_DEPTH value based on user input. | 78 | * Set MPT2SAS_SG_DEPTH value based on user input. |
@@ -130,6 +130,30 @@ | |||
130 | #define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT | 130 | #define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT |
131 | 131 | ||
132 | /* | 132 | /* |
133 | * Dell HBA branding | ||
134 | */ | ||
135 | #define MPT2SAS_DELL_BRANDING_SIZE 32 | ||
136 | |||
137 | #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA" | ||
138 | #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter" | ||
139 | #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated" | ||
140 | #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular" | ||
141 | #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded" | ||
142 | #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200" | ||
143 | #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS" | ||
144 | |||
145 | /* | ||
146 | * Dell HBA SSDIDs | ||
147 | */ | ||
148 | #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C | ||
149 | #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D | ||
150 | #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E | ||
151 | #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F | ||
152 | #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20 | ||
153 | #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21 | ||
154 | #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22 | ||
155 | |||
156 | /* | ||
133 | * per target private data | 157 | * per target private data |
134 | */ | 158 | */ |
135 | #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01 | 159 | #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01 |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index 2d4f85c9d7a1..ba6ab170bdf0 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c | |||
@@ -64,6 +64,9 @@ | |||
64 | static struct fasync_struct *async_queue; | 64 | static struct fasync_struct *async_queue; |
65 | static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); | 65 | static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); |
66 | 66 | ||
67 | static int _ctl_send_release(struct MPT2SAS_ADAPTER *ioc, u8 buffer_type, | ||
68 | u8 *issue_reset); | ||
69 | |||
67 | /** | 70 | /** |
68 | * enum block_state - blocking state | 71 | * enum block_state - blocking state |
69 | * @NON_BLOCKING: non blocking | 72 | * @NON_BLOCKING: non blocking |
@@ -378,10 +381,22 @@ _ctl_verify_adapter(int ioc_number, struct MPT2SAS_ADAPTER **iocpp) | |||
378 | void | 381 | void |
379 | mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) | 382 | mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) |
380 | { | 383 | { |
384 | int i; | ||
385 | u8 issue_reset; | ||
386 | |||
381 | switch (reset_phase) { | 387 | switch (reset_phase) { |
382 | case MPT2_IOC_PRE_RESET: | 388 | case MPT2_IOC_PRE_RESET: |
383 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " | 389 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " |
384 | "MPT2_IOC_PRE_RESET\n", ioc->name, __func__)); | 390 | "MPT2_IOC_PRE_RESET\n", ioc->name, __func__)); |
391 | for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { | ||
392 | if (!(ioc->diag_buffer_status[i] & | ||
393 | MPT2_DIAG_BUFFER_IS_REGISTERED)) | ||
394 | continue; | ||
395 | if ((ioc->diag_buffer_status[i] & | ||
396 | MPT2_DIAG_BUFFER_IS_RELEASED)) | ||
397 | continue; | ||
398 | _ctl_send_release(ioc, i, &issue_reset); | ||
399 | } | ||
385 | break; | 400 | break; |
386 | case MPT2_IOC_AFTER_RESET: | 401 | case MPT2_IOC_AFTER_RESET: |
387 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " | 402 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " |
@@ -395,6 +410,17 @@ mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase) | |||
395 | case MPT2_IOC_DONE_RESET: | 410 | case MPT2_IOC_DONE_RESET: |
396 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " | 411 | dtmprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " |
397 | "MPT2_IOC_DONE_RESET\n", ioc->name, __func__)); | 412 | "MPT2_IOC_DONE_RESET\n", ioc->name, __func__)); |
413 | |||
414 | for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { | ||
415 | if (!(ioc->diag_buffer_status[i] & | ||
416 | MPT2_DIAG_BUFFER_IS_REGISTERED)) | ||
417 | continue; | ||
418 | if ((ioc->diag_buffer_status[i] & | ||
419 | MPT2_DIAG_BUFFER_IS_RELEASED)) | ||
420 | continue; | ||
421 | ioc->diag_buffer_status[i] |= | ||
422 | MPT2_DIAG_BUFFER_IS_DIAG_RESET; | ||
423 | } | ||
398 | break; | 424 | break; |
399 | } | 425 | } |
400 | } | 426 | } |
@@ -714,8 +740,10 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc, | |||
714 | 740 | ||
715 | if (tm_request->TaskType == | 741 | if (tm_request->TaskType == |
716 | MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { | 742 | MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { |
717 | if (_ctl_do_task_abort(ioc, &karg, tm_request)) | 743 | if (_ctl_do_task_abort(ioc, &karg, tm_request)) { |
744 | mpt2sas_base_free_smid(ioc, smid); | ||
718 | goto out; | 745 | goto out; |
746 | } | ||
719 | } | 747 | } |
720 | 748 | ||
721 | mutex_lock(&ioc->tm_cmds.mutex); | 749 | mutex_lock(&ioc->tm_cmds.mutex); |
@@ -915,9 +943,9 @@ _ctl_getiocinfo(void __user *arg) | |||
915 | karg.pci_information.u.bits.function = PCI_FUNC(ioc->pdev->devfn); | 943 | karg.pci_information.u.bits.function = PCI_FUNC(ioc->pdev->devfn); |
916 | karg.pci_information.segment_id = pci_domain_nr(ioc->pdev->bus); | 944 | karg.pci_information.segment_id = pci_domain_nr(ioc->pdev->bus); |
917 | karg.firmware_version = ioc->facts.FWVersion.Word; | 945 | karg.firmware_version = ioc->facts.FWVersion.Word; |
918 | strncpy(karg.driver_version, MPT2SAS_DRIVER_VERSION, | 946 | strcpy(karg.driver_version, MPT2SAS_DRIVER_NAME); |
919 | MPT2_IOCTL_VERSION_LENGTH); | 947 | strcat(karg.driver_version, "-"); |
920 | karg.driver_version[MPT2_IOCTL_VERSION_LENGTH - 1] = '\0'; | 948 | strcat(karg.driver_version, MPT2SAS_DRIVER_VERSION); |
921 | karg.bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion); | 949 | karg.bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion); |
922 | 950 | ||
923 | if (copy_to_user(arg, &karg, sizeof(karg))) { | 951 | if (copy_to_user(arg, &karg, sizeof(karg))) { |
@@ -1551,81 +1579,38 @@ _ctl_diag_query(void __user *arg) | |||
1551 | } | 1579 | } |
1552 | 1580 | ||
1553 | /** | 1581 | /** |
1554 | * _ctl_diag_release - request to send Diag Release Message to firmware | 1582 | * _ctl_send_release - Diag Release Message |
1555 | * @arg - user space buffer containing ioctl content | 1583 | * @ioc: per adapter object |
1556 | * @state - NON_BLOCKING or BLOCKING | 1584 | * @buffer_type - specifies either TRACE or SNAPSHOT |
1585 | * @issue_reset - specifies whether host reset is required. | ||
1557 | * | 1586 | * |
1558 | * This allows ownership of the specified buffer to returned to the driver, | ||
1559 | * allowing an application to read the buffer without fear that firmware is | ||
1560 | * overwritting information in the buffer. | ||
1561 | */ | 1587 | */ |
1562 | static long | 1588 | static int |
1563 | _ctl_diag_release(void __user *arg, enum block_state state) | 1589 | _ctl_send_release(struct MPT2SAS_ADAPTER *ioc, u8 buffer_type, u8 *issue_reset) |
1564 | { | 1590 | { |
1565 | struct mpt2_diag_release karg; | ||
1566 | struct MPT2SAS_ADAPTER *ioc; | ||
1567 | void *request_data; | ||
1568 | int rc; | ||
1569 | Mpi2DiagReleaseRequest_t *mpi_request; | 1591 | Mpi2DiagReleaseRequest_t *mpi_request; |
1570 | Mpi2DiagReleaseReply_t *mpi_reply; | 1592 | Mpi2DiagReleaseReply_t *mpi_reply; |
1571 | u8 buffer_type; | ||
1572 | unsigned long timeleft; | ||
1573 | u16 smid; | 1593 | u16 smid; |
1574 | u16 ioc_status; | 1594 | u16 ioc_status; |
1575 | u8 issue_reset = 0; | 1595 | u32 ioc_state; |
1576 | 1596 | int rc; | |
1577 | if (copy_from_user(&karg, arg, sizeof(karg))) { | 1597 | unsigned long timeleft; |
1578 | printk(KERN_ERR "failure at %s:%d/%s()!\n", | ||
1579 | __FILE__, __LINE__, __func__); | ||
1580 | return -EFAULT; | ||
1581 | } | ||
1582 | if (_ctl_verify_adapter(karg.hdr.ioc_number, &ioc) == -1 || !ioc) | ||
1583 | return -ENODEV; | ||
1584 | 1598 | ||
1585 | dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, | 1599 | dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, |
1586 | __func__)); | 1600 | __func__)); |
1587 | 1601 | ||
1588 | buffer_type = karg.unique_id & 0x000000ff; | 1602 | rc = 0; |
1589 | if (!_ctl_diag_capability(ioc, buffer_type)) { | 1603 | *issue_reset = 0; |
1590 | printk(MPT2SAS_ERR_FMT "%s: doesn't have capability for " | ||
1591 | "buffer_type(0x%02x)\n", ioc->name, __func__, buffer_type); | ||
1592 | return -EPERM; | ||
1593 | } | ||
1594 | |||
1595 | if ((ioc->diag_buffer_status[buffer_type] & | ||
1596 | MPT2_DIAG_BUFFER_IS_REGISTERED) == 0) { | ||
1597 | printk(MPT2SAS_ERR_FMT "%s: buffer_type(0x%02x) is not " | ||
1598 | "registered\n", ioc->name, __func__, buffer_type); | ||
1599 | return -EINVAL; | ||
1600 | } | ||
1601 | |||
1602 | if (karg.unique_id != ioc->unique_id[buffer_type]) { | ||
1603 | printk(MPT2SAS_ERR_FMT "%s: unique_id(0x%08x) is not " | ||
1604 | "registered\n", ioc->name, __func__, karg.unique_id); | ||
1605 | return -EINVAL; | ||
1606 | } | ||
1607 | |||
1608 | if (ioc->diag_buffer_status[buffer_type] & | ||
1609 | MPT2_DIAG_BUFFER_IS_RELEASED) { | ||
1610 | printk(MPT2SAS_ERR_FMT "%s: buffer_type(0x%02x) " | ||
1611 | "is already released\n", ioc->name, __func__, | ||
1612 | buffer_type); | ||
1613 | return 0; | ||
1614 | } | ||
1615 | |||
1616 | request_data = ioc->diag_buffer[buffer_type]; | ||
1617 | 1604 | ||
1618 | if (!request_data) { | 1605 | ioc_state = mpt2sas_base_get_iocstate(ioc, 1); |
1619 | printk(MPT2SAS_ERR_FMT "%s: doesn't have memory allocated for " | 1606 | if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
1620 | "buffer_type(0x%02x)\n", ioc->name, __func__, buffer_type); | 1607 | dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s: " |
1621 | return -ENOMEM; | 1608 | "skipping due to FAULT state\n", ioc->name, |
1609 | __func__)); | ||
1610 | rc = -EAGAIN; | ||
1611 | goto out; | ||
1622 | } | 1612 | } |
1623 | 1613 | ||
1624 | if (state == NON_BLOCKING && !mutex_trylock(&ioc->ctl_cmds.mutex)) | ||
1625 | return -EAGAIN; | ||
1626 | else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex)) | ||
1627 | return -ERESTARTSYS; | ||
1628 | |||
1629 | if (ioc->ctl_cmds.status != MPT2_CMD_NOT_USED) { | 1614 | if (ioc->ctl_cmds.status != MPT2_CMD_NOT_USED) { |
1630 | printk(MPT2SAS_ERR_FMT "%s: ctl_cmd in use\n", | 1615 | printk(MPT2SAS_ERR_FMT "%s: ctl_cmd in use\n", |
1631 | ioc->name, __func__); | 1616 | ioc->name, __func__); |
@@ -1641,7 +1626,6 @@ _ctl_diag_release(void __user *arg, enum block_state state) | |||
1641 | goto out; | 1626 | goto out; |
1642 | } | 1627 | } |
1643 | 1628 | ||
1644 | rc = 0; | ||
1645 | ioc->ctl_cmds.status = MPT2_CMD_PENDING; | 1629 | ioc->ctl_cmds.status = MPT2_CMD_PENDING; |
1646 | memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz); | 1630 | memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz); |
1647 | mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); | 1631 | mpi_request = mpt2sas_base_get_msg_frame(ioc, smid); |
@@ -1660,8 +1644,9 @@ _ctl_diag_release(void __user *arg, enum block_state state) | |||
1660 | _debug_dump_mf(mpi_request, | 1644 | _debug_dump_mf(mpi_request, |
1661 | sizeof(Mpi2DiagReleaseRequest_t)/4); | 1645 | sizeof(Mpi2DiagReleaseRequest_t)/4); |
1662 | if (!(ioc->ctl_cmds.status & MPT2_CMD_RESET)) | 1646 | if (!(ioc->ctl_cmds.status & MPT2_CMD_RESET)) |
1663 | issue_reset = 1; | 1647 | *issue_reset = 1; |
1664 | goto issue_host_reset; | 1648 | rc = -EFAULT; |
1649 | goto out; | ||
1665 | } | 1650 | } |
1666 | 1651 | ||
1667 | /* process the completed Reply Message Frame */ | 1652 | /* process the completed Reply Message Frame */ |
@@ -1687,14 +1672,101 @@ _ctl_diag_release(void __user *arg, enum block_state state) | |||
1687 | rc = -EFAULT; | 1672 | rc = -EFAULT; |
1688 | } | 1673 | } |
1689 | 1674 | ||
1690 | issue_host_reset: | 1675 | out: |
1676 | ioc->ctl_cmds.status = MPT2_CMD_NOT_USED; | ||
1677 | return rc; | ||
1678 | } | ||
1679 | |||
1680 | /** | ||
1681 | * _ctl_diag_release - request to send Diag Release Message to firmware | ||
1682 | * @arg - user space buffer containing ioctl content | ||
1683 | * @state - NON_BLOCKING or BLOCKING | ||
1684 | * | ||
1685 | * This allows ownership of the specified buffer to returned to the driver, | ||
1686 | * allowing an application to read the buffer without fear that firmware is | ||
1687 | * overwritting information in the buffer. | ||
1688 | */ | ||
1689 | static long | ||
1690 | _ctl_diag_release(void __user *arg, enum block_state state) | ||
1691 | { | ||
1692 | struct mpt2_diag_release karg; | ||
1693 | struct MPT2SAS_ADAPTER *ioc; | ||
1694 | void *request_data; | ||
1695 | int rc; | ||
1696 | u8 buffer_type; | ||
1697 | u8 issue_reset = 0; | ||
1698 | |||
1699 | if (copy_from_user(&karg, arg, sizeof(karg))) { | ||
1700 | printk(KERN_ERR "failure at %s:%d/%s()!\n", | ||
1701 | __FILE__, __LINE__, __func__); | ||
1702 | return -EFAULT; | ||
1703 | } | ||
1704 | if (_ctl_verify_adapter(karg.hdr.ioc_number, &ioc) == -1 || !ioc) | ||
1705 | return -ENODEV; | ||
1706 | |||
1707 | dctlprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, | ||
1708 | __func__)); | ||
1709 | |||
1710 | buffer_type = karg.unique_id & 0x000000ff; | ||
1711 | if (!_ctl_diag_capability(ioc, buffer_type)) { | ||
1712 | printk(MPT2SAS_ERR_FMT "%s: doesn't have capability for " | ||
1713 | "buffer_type(0x%02x)\n", ioc->name, __func__, buffer_type); | ||
1714 | return -EPERM; | ||
1715 | } | ||
1716 | |||
1717 | if ((ioc->diag_buffer_status[buffer_type] & | ||
1718 | MPT2_DIAG_BUFFER_IS_REGISTERED) == 0) { | ||
1719 | printk(MPT2SAS_ERR_FMT "%s: buffer_type(0x%02x) is not " | ||
1720 | "registered\n", ioc->name, __func__, buffer_type); | ||
1721 | return -EINVAL; | ||
1722 | } | ||
1723 | |||
1724 | if (karg.unique_id != ioc->unique_id[buffer_type]) { | ||
1725 | printk(MPT2SAS_ERR_FMT "%s: unique_id(0x%08x) is not " | ||
1726 | "registered\n", ioc->name, __func__, karg.unique_id); | ||
1727 | return -EINVAL; | ||
1728 | } | ||
1729 | |||
1730 | if (ioc->diag_buffer_status[buffer_type] & | ||
1731 | MPT2_DIAG_BUFFER_IS_RELEASED) { | ||
1732 | printk(MPT2SAS_ERR_FMT "%s: buffer_type(0x%02x) " | ||
1733 | "is already released\n", ioc->name, __func__, | ||
1734 | buffer_type); | ||
1735 | return 0; | ||
1736 | } | ||
1737 | |||
1738 | request_data = ioc->diag_buffer[buffer_type]; | ||
1739 | |||
1740 | if (!request_data) { | ||
1741 | printk(MPT2SAS_ERR_FMT "%s: doesn't have memory allocated for " | ||
1742 | "buffer_type(0x%02x)\n", ioc->name, __func__, buffer_type); | ||
1743 | return -ENOMEM; | ||
1744 | } | ||
1745 | |||
1746 | /* buffers were released by due to host reset */ | ||
1747 | if ((ioc->diag_buffer_status[buffer_type] & | ||
1748 | MPT2_DIAG_BUFFER_IS_DIAG_RESET)) { | ||
1749 | ioc->diag_buffer_status[buffer_type] |= | ||
1750 | MPT2_DIAG_BUFFER_IS_RELEASED; | ||
1751 | ioc->diag_buffer_status[buffer_type] &= | ||
1752 | ~MPT2_DIAG_BUFFER_IS_DIAG_RESET; | ||
1753 | printk(MPT2SAS_ERR_FMT "%s: buffer_type(0x%02x) " | ||
1754 | "was released due to host reset\n", ioc->name, __func__, | ||
1755 | buffer_type); | ||
1756 | return 0; | ||
1757 | } | ||
1758 | |||
1759 | if (state == NON_BLOCKING && !mutex_trylock(&ioc->ctl_cmds.mutex)) | ||
1760 | return -EAGAIN; | ||
1761 | else if (mutex_lock_interruptible(&ioc->ctl_cmds.mutex)) | ||
1762 | return -ERESTARTSYS; | ||
1763 | |||
1764 | rc = _ctl_send_release(ioc, buffer_type, &issue_reset); | ||
1765 | |||
1691 | if (issue_reset) | 1766 | if (issue_reset) |
1692 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, | 1767 | mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, |
1693 | FORCE_BIG_HAMMER); | 1768 | FORCE_BIG_HAMMER); |
1694 | 1769 | ||
1695 | out: | ||
1696 | |||
1697 | ioc->ctl_cmds.status = MPT2_CMD_NOT_USED; | ||
1698 | mutex_unlock(&ioc->ctl_cmds.mutex); | 1770 | mutex_unlock(&ioc->ctl_cmds.mutex); |
1699 | return rc; | 1771 | return rc; |
1700 | } | 1772 | } |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.h b/drivers/scsi/mpt2sas/mpt2sas_ctl.h index dbb6c0cf8889..4da11435533f 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.h +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.h | |||
@@ -50,7 +50,7 @@ | |||
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #define MPT2SAS_DEV_NAME "mpt2ctl" | 52 | #define MPT2SAS_DEV_NAME "mpt2ctl" |
53 | #define MPT2_MAGIC_NUMBER 'm' | 53 | #define MPT2_MAGIC_NUMBER 'L' |
54 | #define MPT2_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */ | 54 | #define MPT2_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */ |
55 | 55 | ||
56 | /** | 56 | /** |
@@ -295,8 +295,9 @@ struct mpt2_ioctl_btdh_mapping { | |||
295 | 295 | ||
296 | 296 | ||
297 | /* status bits for ioc->diag_buffer_status */ | 297 | /* status bits for ioc->diag_buffer_status */ |
298 | #define MPT2_DIAG_BUFFER_IS_REGISTERED (0x01) | 298 | #define MPT2_DIAG_BUFFER_IS_REGISTERED (0x01) |
299 | #define MPT2_DIAG_BUFFER_IS_RELEASED (0x02) | 299 | #define MPT2_DIAG_BUFFER_IS_RELEASED (0x02) |
300 | #define MPT2_DIAG_BUFFER_IS_DIAG_RESET (0x04) | ||
300 | 301 | ||
301 | /* application flags for mpt2_diag_register, mpt2_diag_query */ | 302 | /* application flags for mpt2_diag_register, mpt2_diag_query */ |
302 | #define MPT2_APP_FLAGS_APP_OWNED (0x0001) | 303 | #define MPT2_APP_FLAGS_APP_OWNED (0x0001) |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 0c463c483c02..e3a7967259e7 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c | |||
@@ -119,7 +119,7 @@ struct sense_info { | |||
119 | */ | 119 | */ |
120 | struct fw_event_work { | 120 | struct fw_event_work { |
121 | struct list_head list; | 121 | struct list_head list; |
122 | struct delayed_work work; | 122 | struct work_struct work; |
123 | struct MPT2SAS_ADAPTER *ioc; | 123 | struct MPT2SAS_ADAPTER *ioc; |
124 | u8 VF_ID; | 124 | u8 VF_ID; |
125 | u8 host_reset_handling; | 125 | u8 host_reset_handling; |
@@ -516,12 +516,8 @@ _scsih_sas_device_add(struct MPT2SAS_ADAPTER *ioc, | |||
516 | handle = sas_device->handle; | 516 | handle = sas_device->handle; |
517 | parent_handle = sas_device->parent_handle; | 517 | parent_handle = sas_device->parent_handle; |
518 | sas_address = sas_device->sas_address; | 518 | sas_address = sas_device->sas_address; |
519 | if (!mpt2sas_transport_port_add(ioc, handle, parent_handle)) { | 519 | if (!mpt2sas_transport_port_add(ioc, handle, parent_handle)) |
520 | _scsih_sas_device_remove(ioc, sas_device); | 520 | _scsih_sas_device_remove(ioc, sas_device); |
521 | } else if (!sas_device->starget) { | ||
522 | mpt2sas_transport_port_remove(ioc, sas_address, parent_handle); | ||
523 | _scsih_sas_device_remove(ioc, sas_device); | ||
524 | } | ||
525 | } | 521 | } |
526 | 522 | ||
527 | /** | 523 | /** |
@@ -1203,7 +1199,9 @@ scsih_target_destroy(struct scsi_target *starget) | |||
1203 | rphy = dev_to_rphy(starget->dev.parent); | 1199 | rphy = dev_to_rphy(starget->dev.parent); |
1204 | sas_device = mpt2sas_scsih_sas_device_find_by_sas_address(ioc, | 1200 | sas_device = mpt2sas_scsih_sas_device_find_by_sas_address(ioc, |
1205 | rphy->identify.sas_address); | 1201 | rphy->identify.sas_address); |
1206 | if (sas_device) | 1202 | if (sas_device && (sas_device->starget == starget) && |
1203 | (sas_device->id == starget->id) && | ||
1204 | (sas_device->channel == starget->channel)) | ||
1207 | sas_device->starget = NULL; | 1205 | sas_device->starget = NULL; |
1208 | 1206 | ||
1209 | spin_unlock_irqrestore(&ioc->sas_device_lock, flags); | 1207 | spin_unlock_irqrestore(&ioc->sas_device_lock, flags); |
@@ -2009,8 +2007,8 @@ _scsih_fw_event_add(struct MPT2SAS_ADAPTER *ioc, struct fw_event_work *fw_event) | |||
2009 | 2007 | ||
2010 | spin_lock_irqsave(&ioc->fw_event_lock, flags); | 2008 | spin_lock_irqsave(&ioc->fw_event_lock, flags); |
2011 | list_add_tail(&fw_event->list, &ioc->fw_event_list); | 2009 | list_add_tail(&fw_event->list, &ioc->fw_event_list); |
2012 | INIT_DELAYED_WORK(&fw_event->work, _firmware_event_work); | 2010 | INIT_WORK(&fw_event->work, _firmware_event_work); |
2013 | queue_delayed_work(ioc->firmware_event_thread, &fw_event->work, 1); | 2011 | queue_work(ioc->firmware_event_thread, &fw_event->work); |
2014 | spin_unlock_irqrestore(&ioc->fw_event_lock, flags); | 2012 | spin_unlock_irqrestore(&ioc->fw_event_lock, flags); |
2015 | } | 2013 | } |
2016 | 2014 | ||
@@ -2054,7 +2052,7 @@ _scsih_fw_event_requeue(struct MPT2SAS_ADAPTER *ioc, struct fw_event_work | |||
2054 | return; | 2052 | return; |
2055 | 2053 | ||
2056 | spin_lock_irqsave(&ioc->fw_event_lock, flags); | 2054 | spin_lock_irqsave(&ioc->fw_event_lock, flags); |
2057 | queue_delayed_work(ioc->firmware_event_thread, &fw_event->work, delay); | 2055 | queue_work(ioc->firmware_event_thread, &fw_event->work); |
2058 | spin_unlock_irqrestore(&ioc->fw_event_lock, flags); | 2056 | spin_unlock_irqrestore(&ioc->fw_event_lock, flags); |
2059 | } | 2057 | } |
2060 | 2058 | ||
@@ -2863,8 +2861,9 @@ scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) | |||
2863 | struct sense_info data; | 2861 | struct sense_info data; |
2864 | const void *sense_data = mpt2sas_base_get_sense_buffer(ioc, | 2862 | const void *sense_data = mpt2sas_base_get_sense_buffer(ioc, |
2865 | smid); | 2863 | smid); |
2866 | memcpy(scmd->sense_buffer, sense_data, | 2864 | u32 sz = min_t(u32, SCSI_SENSE_BUFFERSIZE, |
2867 | le32_to_cpu(mpi_reply->SenseCount)); | 2865 | le32_to_cpu(mpi_reply->SenseCount)); |
2866 | memcpy(scmd->sense_buffer, sense_data, sz); | ||
2868 | _scsih_normalize_sense(scmd->sense_buffer, &data); | 2867 | _scsih_normalize_sense(scmd->sense_buffer, &data); |
2869 | /* failure prediction threshold exceeded */ | 2868 | /* failure prediction threshold exceeded */ |
2870 | if (data.asc == 0x5D) | 2869 | if (data.asc == 0x5D) |
@@ -3923,7 +3922,7 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, | |||
3923 | 3922 | ||
3924 | mpt2sas_scsih_issue_tm(ioc, handle, lun, | 3923 | mpt2sas_scsih_issue_tm(ioc, handle, lun, |
3925 | MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, smid, 30); | 3924 | MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK, smid, 30); |
3926 | termination_count += le32_to_cpu(mpi_reply->TerminationCount); | 3925 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; |
3927 | 3926 | ||
3928 | if ((mpi_reply->IOCStatus == MPI2_IOCSTATUS_SUCCESS) && | 3927 | if ((mpi_reply->IOCStatus == MPI2_IOCSTATUS_SUCCESS) && |
3929 | (mpi_reply->ResponseCode == | 3928 | (mpi_reply->ResponseCode == |
@@ -3933,10 +3932,10 @@ _scsih_sas_broadcast_primative_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, | |||
3933 | continue; | 3932 | continue; |
3934 | 3933 | ||
3935 | mpt2sas_scsih_issue_tm(ioc, handle, lun, | 3934 | mpt2sas_scsih_issue_tm(ioc, handle, lun, |
3936 | MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, smid, 30); | 3935 | MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET, 0, 30); |
3936 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; | ||
3937 | termination_count += le32_to_cpu(mpi_reply->TerminationCount); | 3937 | termination_count += le32_to_cpu(mpi_reply->TerminationCount); |
3938 | } | 3938 | } |
3939 | ioc->tm_cmds.status = MPT2_CMD_NOT_USED; | ||
3940 | ioc->broadcast_aen_busy = 0; | 3939 | ioc->broadcast_aen_busy = 0; |
3941 | mutex_unlock(&ioc->tm_cmds.mutex); | 3940 | mutex_unlock(&ioc->tm_cmds.mutex); |
3942 | 3941 | ||
@@ -4962,7 +4961,7 @@ static void | |||
4962 | _firmware_event_work(struct work_struct *work) | 4961 | _firmware_event_work(struct work_struct *work) |
4963 | { | 4962 | { |
4964 | struct fw_event_work *fw_event = container_of(work, | 4963 | struct fw_event_work *fw_event = container_of(work, |
4965 | struct fw_event_work, work.work); | 4964 | struct fw_event_work, work); |
4966 | unsigned long flags; | 4965 | unsigned long flags; |
4967 | struct MPT2SAS_ADAPTER *ioc = fw_event->ioc; | 4966 | struct MPT2SAS_ADAPTER *ioc = fw_event->ioc; |
4968 | 4967 | ||
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index 2a5f0777148d..1ce6b24abab2 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c | |||
@@ -205,6 +205,74 @@ static unsigned _osd_req_alist_elem_size(struct osd_request *or, unsigned len) | |||
205 | osdv2_attr_list_elem_size(len); | 205 | osdv2_attr_list_elem_size(len); |
206 | } | 206 | } |
207 | 207 | ||
208 | static void _osd_req_alist_elem_encode(struct osd_request *or, | ||
209 | void *attr_last, const struct osd_attr *oa) | ||
210 | { | ||
211 | if (osd_req_is_ver1(or)) { | ||
212 | struct osdv1_attributes_list_element *attr = attr_last; | ||
213 | |||
214 | attr->attr_page = cpu_to_be32(oa->attr_page); | ||
215 | attr->attr_id = cpu_to_be32(oa->attr_id); | ||
216 | attr->attr_bytes = cpu_to_be16(oa->len); | ||
217 | memcpy(attr->attr_val, oa->val_ptr, oa->len); | ||
218 | } else { | ||
219 | struct osdv2_attributes_list_element *attr = attr_last; | ||
220 | |||
221 | attr->attr_page = cpu_to_be32(oa->attr_page); | ||
222 | attr->attr_id = cpu_to_be32(oa->attr_id); | ||
223 | attr->attr_bytes = cpu_to_be16(oa->len); | ||
224 | memcpy(attr->attr_val, oa->val_ptr, oa->len); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | static int _osd_req_alist_elem_decode(struct osd_request *or, | ||
229 | void *cur_p, struct osd_attr *oa, unsigned max_bytes) | ||
230 | { | ||
231 | unsigned inc; | ||
232 | if (osd_req_is_ver1(or)) { | ||
233 | struct osdv1_attributes_list_element *attr = cur_p; | ||
234 | |||
235 | if (max_bytes < sizeof(*attr)) | ||
236 | return -1; | ||
237 | |||
238 | oa->len = be16_to_cpu(attr->attr_bytes); | ||
239 | inc = _osd_req_alist_elem_size(or, oa->len); | ||
240 | if (inc > max_bytes) | ||
241 | return -1; | ||
242 | |||
243 | oa->attr_page = be32_to_cpu(attr->attr_page); | ||
244 | oa->attr_id = be32_to_cpu(attr->attr_id); | ||
245 | |||
246 | /* OSD1: On empty attributes we return a pointer to 2 bytes | ||
247 | * of zeros. This keeps similar behaviour with OSD2. | ||
248 | * (See below) | ||
249 | */ | ||
250 | oa->val_ptr = likely(oa->len) ? attr->attr_val : | ||
251 | (u8 *)&attr->attr_bytes; | ||
252 | } else { | ||
253 | struct osdv2_attributes_list_element *attr = cur_p; | ||
254 | |||
255 | if (max_bytes < sizeof(*attr)) | ||
256 | return -1; | ||
257 | |||
258 | oa->len = be16_to_cpu(attr->attr_bytes); | ||
259 | inc = _osd_req_alist_elem_size(or, oa->len); | ||
260 | if (inc > max_bytes) | ||
261 | return -1; | ||
262 | |||
263 | oa->attr_page = be32_to_cpu(attr->attr_page); | ||
264 | oa->attr_id = be32_to_cpu(attr->attr_id); | ||
265 | |||
266 | /* OSD2: For convenience, on empty attributes, we return 8 bytes | ||
267 | * of zeros here. This keeps the same behaviour with OSD2r04, | ||
268 | * and is nice with null terminating ASCII fields. | ||
269 | * oa->val_ptr == NULL marks the end-of-list, or error. | ||
270 | */ | ||
271 | oa->val_ptr = likely(oa->len) ? attr->attr_val : attr->reserved; | ||
272 | } | ||
273 | return inc; | ||
274 | } | ||
275 | |||
208 | static unsigned _osd_req_alist_size(struct osd_request *or, void *list_head) | 276 | static unsigned _osd_req_alist_size(struct osd_request *or, void *list_head) |
209 | { | 277 | { |
210 | return osd_req_is_ver1(or) ? | 278 | return osd_req_is_ver1(or) ? |
@@ -282,9 +350,9 @@ _osd_req_sec_params(struct osd_request *or) | |||
282 | struct osd_cdb *ocdb = &or->cdb; | 350 | struct osd_cdb *ocdb = &or->cdb; |
283 | 351 | ||
284 | if (osd_req_is_ver1(or)) | 352 | if (osd_req_is_ver1(or)) |
285 | return &ocdb->v1.sec_params; | 353 | return (struct osd_security_parameters *)&ocdb->v1.sec_params; |
286 | else | 354 | else |
287 | return &ocdb->v2.sec_params; | 355 | return (struct osd_security_parameters *)&ocdb->v2.sec_params; |
288 | } | 356 | } |
289 | 357 | ||
290 | void osd_dev_init(struct osd_dev *osdd, struct scsi_device *scsi_device) | 358 | void osd_dev_init(struct osd_dev *osdd, struct scsi_device *scsi_device) |
@@ -612,9 +680,9 @@ static int _osd_req_list_objects(struct osd_request *or, | |||
612 | 680 | ||
613 | WARN_ON(or->in.bio); | 681 | WARN_ON(or->in.bio); |
614 | bio = bio_map_kern(q, list, len, or->alloc_flags); | 682 | bio = bio_map_kern(q, list, len, or->alloc_flags); |
615 | if (!bio) { | 683 | if (IS_ERR(bio)) { |
616 | OSD_ERR("!!! Failed to allocate list_objects BIO\n"); | 684 | OSD_ERR("!!! Failed to allocate list_objects BIO\n"); |
617 | return -ENOMEM; | 685 | return PTR_ERR(bio); |
618 | } | 686 | } |
619 | 687 | ||
620 | bio->bi_rw &= ~(1 << BIO_RW); | 688 | bio->bi_rw &= ~(1 << BIO_RW); |
@@ -798,7 +866,6 @@ int osd_req_add_set_attr_list(struct osd_request *or, | |||
798 | attr_last = or->set_attr.buff + total_bytes; | 866 | attr_last = or->set_attr.buff + total_bytes; |
799 | 867 | ||
800 | for (; nelem; --nelem) { | 868 | for (; nelem; --nelem) { |
801 | struct osd_attributes_list_element *attr; | ||
802 | unsigned elem_size = _osd_req_alist_elem_size(or, oa->len); | 869 | unsigned elem_size = _osd_req_alist_elem_size(or, oa->len); |
803 | 870 | ||
804 | total_bytes += elem_size; | 871 | total_bytes += elem_size; |
@@ -811,11 +878,7 @@ int osd_req_add_set_attr_list(struct osd_request *or, | |||
811 | or->set_attr.buff + or->set_attr.total_bytes; | 878 | or->set_attr.buff + or->set_attr.total_bytes; |
812 | } | 879 | } |
813 | 880 | ||
814 | attr = attr_last; | 881 | _osd_req_alist_elem_encode(or, attr_last, oa); |
815 | attr->attr_page = cpu_to_be32(oa->attr_page); | ||
816 | attr->attr_id = cpu_to_be32(oa->attr_id); | ||
817 | attr->attr_bytes = cpu_to_be16(oa->len); | ||
818 | memcpy(attr->attr_val, oa->val_ptr, oa->len); | ||
819 | 882 | ||
820 | attr_last += elem_size; | 883 | attr_last += elem_size; |
821 | ++oa; | 884 | ++oa; |
@@ -1070,15 +1133,10 @@ int osd_req_decode_get_attr_list(struct osd_request *or, | |||
1070 | } | 1133 | } |
1071 | 1134 | ||
1072 | for (n = 0; (n < *nelem) && (cur_bytes < returned_bytes); ++n) { | 1135 | for (n = 0; (n < *nelem) && (cur_bytes < returned_bytes); ++n) { |
1073 | struct osd_attributes_list_element *attr = cur_p; | 1136 | int inc = _osd_req_alist_elem_decode(or, cur_p, oa, |
1074 | unsigned inc; | 1137 | returned_bytes - cur_bytes); |
1075 | 1138 | ||
1076 | oa->len = be16_to_cpu(attr->attr_bytes); | 1139 | if (inc < 0) { |
1077 | inc = _osd_req_alist_elem_size(or, oa->len); | ||
1078 | OSD_DEBUG("oa->len=%d inc=%d cur_bytes=%d\n", | ||
1079 | oa->len, inc, cur_bytes); | ||
1080 | cur_bytes += inc; | ||
1081 | if (cur_bytes > returned_bytes) { | ||
1082 | OSD_ERR("BAD FOOD from target. list not valid!" | 1140 | OSD_ERR("BAD FOOD from target. list not valid!" |
1083 | "c=%d r=%d n=%d\n", | 1141 | "c=%d r=%d n=%d\n", |
1084 | cur_bytes, returned_bytes, n); | 1142 | cur_bytes, returned_bytes, n); |
@@ -1086,10 +1144,7 @@ int osd_req_decode_get_attr_list(struct osd_request *or, | |||
1086 | break; | 1144 | break; |
1087 | } | 1145 | } |
1088 | 1146 | ||
1089 | oa->attr_page = be32_to_cpu(attr->attr_page); | 1147 | cur_bytes += inc; |
1090 | oa->attr_id = be32_to_cpu(attr->attr_id); | ||
1091 | oa->val_ptr = attr->attr_val; | ||
1092 | |||
1093 | cur_p += inc; | 1148 | cur_p += inc; |
1094 | ++oa; | 1149 | ++oa; |
1095 | } | 1150 | } |
@@ -1159,6 +1214,24 @@ static int _osd_req_finalize_attr_page(struct osd_request *or) | |||
1159 | return ret; | 1214 | return ret; |
1160 | } | 1215 | } |
1161 | 1216 | ||
1217 | static inline void osd_sec_parms_set_out_offset(bool is_v1, | ||
1218 | struct osd_security_parameters *sec_parms, osd_cdb_offset offset) | ||
1219 | { | ||
1220 | if (is_v1) | ||
1221 | sec_parms->v1.data_out_integrity_check_offset = offset; | ||
1222 | else | ||
1223 | sec_parms->v2.data_out_integrity_check_offset = offset; | ||
1224 | } | ||
1225 | |||
1226 | static inline void osd_sec_parms_set_in_offset(bool is_v1, | ||
1227 | struct osd_security_parameters *sec_parms, osd_cdb_offset offset) | ||
1228 | { | ||
1229 | if (is_v1) | ||
1230 | sec_parms->v1.data_in_integrity_check_offset = offset; | ||
1231 | else | ||
1232 | sec_parms->v2.data_in_integrity_check_offset = offset; | ||
1233 | } | ||
1234 | |||
1162 | static int _osd_req_finalize_data_integrity(struct osd_request *or, | 1235 | static int _osd_req_finalize_data_integrity(struct osd_request *or, |
1163 | bool has_in, bool has_out, const u8 *cap_key) | 1236 | bool has_in, bool has_out, const u8 *cap_key) |
1164 | { | 1237 | { |
@@ -1182,8 +1255,8 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or, | |||
1182 | or->out_data_integ.get_attributes_bytes = cpu_to_be64( | 1255 | or->out_data_integ.get_attributes_bytes = cpu_to_be64( |
1183 | or->enc_get_attr.total_bytes); | 1256 | or->enc_get_attr.total_bytes); |
1184 | 1257 | ||
1185 | sec_parms->data_out_integrity_check_offset = | 1258 | osd_sec_parms_set_out_offset(osd_req_is_ver1(or), sec_parms, |
1186 | osd_req_encode_offset(or, or->out.total_bytes, &pad); | 1259 | osd_req_encode_offset(or, or->out.total_bytes, &pad)); |
1187 | 1260 | ||
1188 | ret = _req_append_segment(or, pad, &seg, or->out.last_seg, | 1261 | ret = _req_append_segment(or, pad, &seg, or->out.last_seg, |
1189 | &or->out); | 1262 | &or->out); |
@@ -1203,8 +1276,8 @@ static int _osd_req_finalize_data_integrity(struct osd_request *or, | |||
1203 | }; | 1276 | }; |
1204 | unsigned pad; | 1277 | unsigned pad; |
1205 | 1278 | ||
1206 | sec_parms->data_in_integrity_check_offset = | 1279 | osd_sec_parms_set_in_offset(osd_req_is_ver1(or), sec_parms, |
1207 | osd_req_encode_offset(or, or->in.total_bytes, &pad); | 1280 | osd_req_encode_offset(or, or->in.total_bytes, &pad)); |
1208 | 1281 | ||
1209 | ret = _req_append_segment(or, pad, &seg, or->in.last_seg, | 1282 | ret = _req_append_segment(or, pad, &seg, or->in.last_seg, |
1210 | &or->in); | 1283 | &or->in); |
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index f644c9571eab..22b59e13ba83 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c | |||
@@ -173,26 +173,26 @@ static const struct file_operations osd_fops = { | |||
173 | .unlocked_ioctl = osd_uld_ioctl, | 173 | .unlocked_ioctl = osd_uld_ioctl, |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct osd_dev *osduld_path_lookup(const char *path) | 176 | struct osd_dev *osduld_path_lookup(const char *name) |
177 | { | 177 | { |
178 | struct nameidata nd; | 178 | struct path path; |
179 | struct inode *inode; | 179 | struct inode *inode; |
180 | struct cdev *cdev; | 180 | struct cdev *cdev; |
181 | struct osd_uld_device *uninitialized_var(oud); | 181 | struct osd_uld_device *uninitialized_var(oud); |
182 | int error; | 182 | int error; |
183 | 183 | ||
184 | if (!path || !*path) { | 184 | if (!name || !*name) { |
185 | OSD_ERR("Mount with !path || !*path\n"); | 185 | OSD_ERR("Mount with !path || !*path\n"); |
186 | return ERR_PTR(-EINVAL); | 186 | return ERR_PTR(-EINVAL); |
187 | } | 187 | } |
188 | 188 | ||
189 | error = path_lookup(path, LOOKUP_FOLLOW, &nd); | 189 | error = kern_path(name, LOOKUP_FOLLOW, &path); |
190 | if (error) { | 190 | if (error) { |
191 | OSD_ERR("path_lookup of %s faild=>%d\n", path, error); | 191 | OSD_ERR("path_lookup of %s failed=>%d\n", name, error); |
192 | return ERR_PTR(error); | 192 | return ERR_PTR(error); |
193 | } | 193 | } |
194 | 194 | ||
195 | inode = nd.path.dentry->d_inode; | 195 | inode = path.dentry->d_inode; |
196 | error = -EINVAL; /* Not the right device e.g osd_uld_device */ | 196 | error = -EINVAL; /* Not the right device e.g osd_uld_device */ |
197 | if (!S_ISCHR(inode->i_mode)) { | 197 | if (!S_ISCHR(inode->i_mode)) { |
198 | OSD_DEBUG("!S_ISCHR()\n"); | 198 | OSD_DEBUG("!S_ISCHR()\n"); |
@@ -202,15 +202,15 @@ struct osd_dev *osduld_path_lookup(const char *path) | |||
202 | cdev = inode->i_cdev; | 202 | cdev = inode->i_cdev; |
203 | if (!cdev) { | 203 | if (!cdev) { |
204 | OSD_ERR("Before mounting an OSD Based filesystem\n"); | 204 | OSD_ERR("Before mounting an OSD Based filesystem\n"); |
205 | OSD_ERR(" user-mode must open+close the %s device\n", path); | 205 | OSD_ERR(" user-mode must open+close the %s device\n", name); |
206 | OSD_ERR(" Example: bash: echo < %s\n", path); | 206 | OSD_ERR(" Example: bash: echo < %s\n", name); |
207 | goto out; | 207 | goto out; |
208 | } | 208 | } |
209 | 209 | ||
210 | /* The Magic wand. Is it our char-dev */ | 210 | /* The Magic wand. Is it our char-dev */ |
211 | /* TODO: Support sg devices */ | 211 | /* TODO: Support sg devices */ |
212 | if (cdev->owner != THIS_MODULE) { | 212 | if (cdev->owner != THIS_MODULE) { |
213 | OSD_ERR("Error mounting %s - is not an OSD device\n", path); | 213 | OSD_ERR("Error mounting %s - is not an OSD device\n", name); |
214 | goto out; | 214 | goto out; |
215 | } | 215 | } |
216 | 216 | ||
@@ -220,7 +220,7 @@ struct osd_dev *osduld_path_lookup(const char *path) | |||
220 | error = 0; | 220 | error = 0; |
221 | 221 | ||
222 | out: | 222 | out: |
223 | path_put(&nd.path); | 223 | path_put(&path); |
224 | return error ? ERR_PTR(error) : &oud->od; | 224 | return error ? ERR_PTR(error) : &oud->od; |
225 | } | 225 | } |
226 | EXPORT_SYMBOL(osduld_path_lookup); | 226 | EXPORT_SYMBOL(osduld_path_lookup); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d1cb64ad1a3f..bb218c8b6e98 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1291,10 +1291,8 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost, | |||
1291 | if (--starget->target_blocked == 0) { | 1291 | if (--starget->target_blocked == 0) { |
1292 | SCSI_LOG_MLQUEUE(3, starget_printk(KERN_INFO, starget, | 1292 | SCSI_LOG_MLQUEUE(3, starget_printk(KERN_INFO, starget, |
1293 | "unblocking target at zero depth\n")); | 1293 | "unblocking target at zero depth\n")); |
1294 | } else { | 1294 | } else |
1295 | blk_plug_device(sdev->request_queue); | ||
1296 | return 0; | 1295 | return 0; |
1297 | } | ||
1298 | } | 1296 | } |
1299 | 1297 | ||
1300 | if (scsi_target_is_busy(starget)) { | 1298 | if (scsi_target_is_busy(starget)) { |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 6f51ca485f35..e2b50d8f57a8 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -425,6 +425,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, | |||
425 | INIT_LIST_HEAD(&starget->devices); | 425 | INIT_LIST_HEAD(&starget->devices); |
426 | starget->state = STARGET_CREATED; | 426 | starget->state = STARGET_CREATED; |
427 | starget->scsi_level = SCSI_2; | 427 | starget->scsi_level = SCSI_2; |
428 | starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; | ||
428 | retry: | 429 | retry: |
429 | spin_lock_irqsave(shost->host_lock, flags); | 430 | spin_lock_irqsave(shost->host_lock, flags); |
430 | 431 | ||
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 094795455293..0a2ce7b6325c 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
@@ -357,7 +357,7 @@ int iscsi_session_chkready(struct iscsi_cls_session *session) | |||
357 | err = 0; | 357 | err = 0; |
358 | break; | 358 | break; |
359 | case ISCSI_SESSION_FAILED: | 359 | case ISCSI_SESSION_FAILED: |
360 | err = DID_TRANSPORT_DISRUPTED << 16; | 360 | err = DID_IMM_RETRY << 16; |
361 | break; | 361 | break; |
362 | case ISCSI_SESSION_FREE: | 362 | case ISCSI_SESSION_FREE: |
363 | err = DID_TRANSPORT_FAILFAST << 16; | 363 | err = DID_TRANSPORT_FAILFAST << 16; |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3fcb64b91c43..84044233b637 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include <linux/string_helpers.h> | 50 | #include <linux/string_helpers.h> |
51 | #include <linux/async.h> | 51 | #include <linux/async.h> |
52 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
53 | #include <asm/unaligned.h> | ||
53 | 54 | ||
54 | #include <scsi/scsi.h> | 55 | #include <scsi/scsi.h> |
55 | #include <scsi/scsi_cmnd.h> | 56 | #include <scsi/scsi_cmnd.h> |
@@ -1344,12 +1345,8 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
1344 | return -EINVAL; | 1345 | return -EINVAL; |
1345 | } | 1346 | } |
1346 | 1347 | ||
1347 | sector_size = (buffer[8] << 24) | (buffer[9] << 16) | | 1348 | sector_size = get_unaligned_be32(&buffer[8]); |
1348 | (buffer[10] << 8) | buffer[11]; | 1349 | lba = get_unaligned_be64(&buffer[0]); |
1349 | lba = (((u64)buffer[0] << 56) | ((u64)buffer[1] << 48) | | ||
1350 | ((u64)buffer[2] << 40) | ((u64)buffer[3] << 32) | | ||
1351 | ((u64)buffer[4] << 24) | ((u64)buffer[5] << 16) | | ||
1352 | ((u64)buffer[6] << 8) | (u64)buffer[7]); | ||
1353 | 1350 | ||
1354 | sd_read_protection_type(sdkp, buffer); | 1351 | sd_read_protection_type(sdkp, buffer); |
1355 | 1352 | ||
@@ -1400,10 +1397,8 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
1400 | return -EINVAL; | 1397 | return -EINVAL; |
1401 | } | 1398 | } |
1402 | 1399 | ||
1403 | sector_size = (buffer[4] << 24) | (buffer[5] << 16) | | 1400 | sector_size = get_unaligned_be32(&buffer[4]); |
1404 | (buffer[6] << 8) | buffer[7]; | 1401 | lba = get_unaligned_be32(&buffer[0]); |
1405 | lba = (buffer[0] << 24) | (buffer[1] << 16) | | ||
1406 | (buffer[2] << 8) | buffer[3]; | ||
1407 | 1402 | ||
1408 | if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) { | 1403 | if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) { |
1409 | sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " | 1404 | sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 82312df9b0bf..e1716f14cd47 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -179,7 +179,7 @@ typedef struct sg_device { /* holds the state of each scsi generic device */ | |||
179 | /* tasklet or soft irq callback */ | 179 | /* tasklet or soft irq callback */ |
180 | static void sg_rq_end_io(struct request *rq, int uptodate); | 180 | static void sg_rq_end_io(struct request *rq, int uptodate); |
181 | static int sg_start_req(Sg_request *srp, unsigned char *cmd); | 181 | static int sg_start_req(Sg_request *srp, unsigned char *cmd); |
182 | static void sg_finish_rem_req(Sg_request * srp); | 182 | static int sg_finish_rem_req(Sg_request * srp); |
183 | static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); | 183 | static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); |
184 | static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, | 184 | static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, |
185 | Sg_request * srp); | 185 | Sg_request * srp); |
@@ -518,7 +518,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) | |||
518 | goto err_out; | 518 | goto err_out; |
519 | } | 519 | } |
520 | err_out: | 520 | err_out: |
521 | sg_finish_rem_req(srp); | 521 | err = sg_finish_rem_req(srp); |
522 | return (0 == err) ? count : err; | 522 | return (0 == err) ? count : err; |
523 | } | 523 | } |
524 | 524 | ||
@@ -1696,9 +1696,10 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd) | |||
1696 | return res; | 1696 | return res; |
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | static void | 1699 | static int sg_finish_rem_req(Sg_request * srp) |
1700 | sg_finish_rem_req(Sg_request * srp) | ||
1701 | { | 1700 | { |
1701 | int ret = 0; | ||
1702 | |||
1702 | Sg_fd *sfp = srp->parentfp; | 1703 | Sg_fd *sfp = srp->parentfp; |
1703 | Sg_scatter_hold *req_schp = &srp->data; | 1704 | Sg_scatter_hold *req_schp = &srp->data; |
1704 | 1705 | ||
@@ -1710,12 +1711,14 @@ sg_finish_rem_req(Sg_request * srp) | |||
1710 | 1711 | ||
1711 | if (srp->rq) { | 1712 | if (srp->rq) { |
1712 | if (srp->bio) | 1713 | if (srp->bio) |
1713 | blk_rq_unmap_user(srp->bio); | 1714 | ret = blk_rq_unmap_user(srp->bio); |
1714 | 1715 | ||
1715 | blk_put_request(srp->rq); | 1716 | blk_put_request(srp->rq); |
1716 | } | 1717 | } |
1717 | 1718 | ||
1718 | sg_remove_request(sfp, srp); | 1719 | sg_remove_request(sfp, srp); |
1720 | |||
1721 | return ret; | ||
1719 | } | 1722 | } |
1720 | 1723 | ||
1721 | static int | 1724 | static int |
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index d92ff512d213..291236e6e435 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c | |||
@@ -309,6 +309,11 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot) | |||
309 | if (0 == sr_test_unit_ready(cd->device, &sshdr)) | 309 | if (0 == sr_test_unit_ready(cd->device, &sshdr)) |
310 | return CDS_DISC_OK; | 310 | return CDS_DISC_OK; |
311 | 311 | ||
312 | /* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */ | ||
313 | if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY | ||
314 | && sshdr.asc == 0x04 && sshdr.ascq == 0x01) | ||
315 | return CDS_DRIVE_NOT_READY; | ||
316 | |||
312 | if (!cdrom_get_media_event(cdi, &med)) { | 317 | if (!cdrom_get_media_event(cdi, &med)) { |
313 | if (med.media_present) | 318 | if (med.media_present) |
314 | return CDS_DISC_OK; | 319 | return CDS_DISC_OK; |