aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/be2iscsi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/be2iscsi')
-rw-r--r--drivers/scsi/be2iscsi/Kconfig2
-rw-r--r--drivers/scsi/be2iscsi/be.h6
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.c116
-rw-r--r--drivers/scsi/be2iscsi/be_cmds.h27
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c199
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.h2
-rw-r--r--drivers/scsi/be2iscsi/be_main.c333
-rw-r--r--drivers/scsi/be2iscsi/be_main.h29
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c64
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.h19
10 files changed, 512 insertions, 285 deletions
diff --git a/drivers/scsi/be2iscsi/Kconfig b/drivers/scsi/be2iscsi/Kconfig
index 2952fcd008ea..84c275fb9f6b 100644
--- a/drivers/scsi/be2iscsi/Kconfig
+++ b/drivers/scsi/be2iscsi/Kconfig
@@ -1,6 +1,6 @@
1config BE2ISCSI 1config BE2ISCSI
2 tristate "ServerEngines' 10Gbps iSCSI - BladeEngine 2" 2 tristate "ServerEngines' 10Gbps iSCSI - BladeEngine 2"
3 depends on PCI && SCSI 3 depends on PCI && SCSI && NET
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 5
6 help 6 help
diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h
index 136b49cea791..1cb8a5e85c7f 100644
--- a/drivers/scsi/be2iscsi/be.h
+++ b/drivers/scsi/be2iscsi/be.h
@@ -128,8 +128,8 @@ struct be_ctrl_info {
128#define mcc_timeout 120000 /* 5s timeout */ 128#define mcc_timeout 120000 /* 5s timeout */
129 129
130/* Returns number of pages spanned by the data starting at the given addr */ 130/* Returns number of pages spanned by the data starting at the given addr */
131#define PAGES_4K_SPANNED(_address, size) \ 131#define PAGES_4K_SPANNED(_address, size) \
132 ((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) + \ 132 ((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) + \
133 (size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K)) 133 (size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K))
134 134
135/* Byte offset into the page corresponding to given address */ 135/* Byte offset into the page corresponding to given address */
@@ -137,7 +137,7 @@ struct be_ctrl_info {
137 ((size_t)(addr) & (PAGE_SIZE_4K-1)) 137 ((size_t)(addr) & (PAGE_SIZE_4K-1))
138 138
139/* Returns bit offset within a DWORD of a bitfield */ 139/* Returns bit offset within a DWORD of a bitfield */
140#define AMAP_BIT_OFFSET(_struct, field) \ 140#define AMAP_BIT_OFFSET(_struct, field) \
141 (((size_t)&(((_struct *)0)->field))%32) 141 (((size_t)&(((_struct *)0)->field))%32)
142 142
143/* Returns the bit mask of the field that is NOT shifted into location. */ 143/* Returns the bit mask of the field that is NOT shifted into location. */
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index cda6642c7368..7c7537335c88 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -19,6 +19,86 @@
19#include "be_mgmt.h" 19#include "be_mgmt.h"
20#include "be_main.h" 20#include "be_main.h"
21 21
22int beiscsi_pci_soft_reset(struct beiscsi_hba *phba)
23{
24 u32 sreset;
25 u8 *pci_reset_offset = 0;
26 u8 *pci_online0_offset = 0;
27 u8 *pci_online1_offset = 0;
28 u32 pconline0 = 0;
29 u32 pconline1 = 0;
30 u32 i;
31
32 pci_reset_offset = (u8 *)phba->pci_va + BE2_SOFT_RESET;
33 pci_online0_offset = (u8 *)phba->pci_va + BE2_PCI_ONLINE0;
34 pci_online1_offset = (u8 *)phba->pci_va + BE2_PCI_ONLINE1;
35 sreset = readl((void *)pci_reset_offset);
36 sreset |= BE2_SET_RESET;
37 writel(sreset, (void *)pci_reset_offset);
38
39 i = 0;
40 while (sreset & BE2_SET_RESET) {
41 if (i > 64)
42 break;
43 msleep(100);
44 sreset = readl((void *)pci_reset_offset);
45 i++;
46 }
47
48 if (sreset & BE2_SET_RESET) {
49 printk(KERN_ERR "Soft Reset did not deassert\n");
50 return -EIO;
51 }
52 pconline1 = BE2_MPU_IRAM_ONLINE;
53 writel(pconline0, (void *)pci_online0_offset);
54 writel(pconline1, (void *)pci_online1_offset);
55
56 sreset = BE2_SET_RESET;
57 writel(sreset, (void *)pci_reset_offset);
58
59 i = 0;
60 while (sreset & BE2_SET_RESET) {
61 if (i > 64)
62 break;
63 msleep(1);
64 sreset = readl((void *)pci_reset_offset);
65 i++;
66 }
67 if (sreset & BE2_SET_RESET) {
68 printk(KERN_ERR "MPU Online Soft Reset did not deassert\n");
69 return -EIO;
70 }
71 return 0;
72}
73
74int be_chk_reset_complete(struct beiscsi_hba *phba)
75{
76 unsigned int num_loop;
77 u8 *mpu_sem = 0;
78 u32 status;
79
80 num_loop = 1000;
81 mpu_sem = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE;
82 msleep(5000);
83
84 while (num_loop) {
85 status = readl((void *)mpu_sem);
86
87 if ((status & 0x80000000) || (status & 0x0000FFFF) == 0xC000)
88 break;
89 msleep(60);
90 num_loop--;
91 }
92
93 if ((status & 0x80000000) || (!num_loop)) {
94 printk(KERN_ERR "Failed in be_chk_reset_complete"
95 "status = 0x%x\n", status);
96 return -EIO;
97 }
98
99 return 0;
100}
101
22void be_mcc_notify(struct beiscsi_hba *phba) 102void be_mcc_notify(struct beiscsi_hba *phba)
23{ 103{
24 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; 104 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
@@ -98,7 +178,7 @@ static int be_mcc_compl_process(struct be_ctrl_info *ctrl,
98 dev_err(&ctrl->pdev->dev, 178 dev_err(&ctrl->pdev->dev,
99 "error in cmd completion: status(compl/extd)=%d/%d\n", 179 "error in cmd completion: status(compl/extd)=%d/%d\n",
100 compl_status, extd_status); 180 compl_status, extd_status);
101 return -1; 181 return -EBUSY;
102 } 182 }
103 return 0; 183 return 0;
104} 184}
@@ -151,20 +231,20 @@ void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
151{ 231{
152 switch (evt->port_link_status) { 232 switch (evt->port_link_status) {
153 case ASYNC_EVENT_LINK_DOWN: 233 case ASYNC_EVENT_LINK_DOWN:
154 SE_DEBUG(DBG_LVL_1, "Link Down on Physical Port %d \n", 234 SE_DEBUG(DBG_LVL_1, "Link Down on Physical Port %d\n",
155 evt->physical_port); 235 evt->physical_port);
156 phba->state |= BE_ADAPTER_LINK_DOWN; 236 phba->state |= BE_ADAPTER_LINK_DOWN;
157 iscsi_host_for_each_session(phba->shost, 237 iscsi_host_for_each_session(phba->shost,
158 be2iscsi_fail_session); 238 be2iscsi_fail_session);
159 break; 239 break;
160 case ASYNC_EVENT_LINK_UP: 240 case ASYNC_EVENT_LINK_UP:
161 phba->state = BE_ADAPTER_UP; 241 phba->state = BE_ADAPTER_UP;
162 SE_DEBUG(DBG_LVL_1, "Link UP on Physical Port %d \n", 242 SE_DEBUG(DBG_LVL_1, "Link UP on Physical Port %d\n",
163 evt->physical_port); 243 evt->physical_port);
164 break; 244 break;
165 default: 245 default:
166 SE_DEBUG(DBG_LVL_1, "Unexpected Async Notification %d on" 246 SE_DEBUG(DBG_LVL_1, "Unexpected Async Notification %d on"
167 "Physical Port %d \n", 247 "Physical Port %d\n",
168 evt->port_link_status, 248 evt->port_link_status,
169 evt->physical_port); 249 evt->physical_port);
170 } 250 }
@@ -199,7 +279,7 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba)
199 else 279 else
200 SE_DEBUG(DBG_LVL_1, 280 SE_DEBUG(DBG_LVL_1,
201 " Unsupported Async Event, flags" 281 " Unsupported Async Event, flags"
202 " = 0x%08x \n", compl->flags); 282 " = 0x%08x\n", compl->flags);
203 283
204 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { 284 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) {
205 status = be_mcc_compl_process(ctrl, compl); 285 status = be_mcc_compl_process(ctrl, compl);
@@ -231,7 +311,7 @@ static int be_mcc_wait_compl(struct beiscsi_hba *phba)
231 } 311 }
232 if (i == mcc_timeout) { 312 if (i == mcc_timeout) {
233 dev_err(&phba->pcidev->dev, "mccq poll timed out\n"); 313 dev_err(&phba->pcidev->dev, "mccq poll timed out\n");
234 return -1; 314 return -EBUSY;
235 } 315 }
236 return 0; 316 return 0;
237} 317}
@@ -257,7 +337,7 @@ static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl)
257 337
258 if (cnt > 6000000) { 338 if (cnt > 6000000) {
259 dev_err(&ctrl->pdev->dev, "mbox_db poll timed out\n"); 339 dev_err(&ctrl->pdev->dev, "mbox_db poll timed out\n");
260 return -1; 340 return -EBUSY;
261 } 341 }
262 342
263 if (cnt > 50) { 343 if (cnt > 50) {
@@ -286,7 +366,7 @@ int be_mbox_notify(struct be_ctrl_info *ctrl)
286 366
287 status = be_mbox_db_ready_wait(ctrl); 367 status = be_mbox_db_ready_wait(ctrl);
288 if (status != 0) { 368 if (status != 0) {
289 SE_DEBUG(DBG_LVL_1, " be_mbox_db_ready_wait failed 1\n"); 369 SE_DEBUG(DBG_LVL_1, " be_mbox_db_ready_wait failed\n");
290 return status; 370 return status;
291 } 371 }
292 val = 0; 372 val = 0;
@@ -297,19 +377,19 @@ int be_mbox_notify(struct be_ctrl_info *ctrl)
297 377
298 status = be_mbox_db_ready_wait(ctrl); 378 status = be_mbox_db_ready_wait(ctrl);
299 if (status != 0) { 379 if (status != 0) {
300 SE_DEBUG(DBG_LVL_1, " be_mbox_db_ready_wait failed 2\n"); 380 SE_DEBUG(DBG_LVL_1, " be_mbox_db_ready_wait failed\n");
301 return status; 381 return status;
302 } 382 }
303 if (be_mcc_compl_is_new(compl)) { 383 if (be_mcc_compl_is_new(compl)) {
304 status = be_mcc_compl_process(ctrl, &mbox->compl); 384 status = be_mcc_compl_process(ctrl, &mbox->compl);
305 be_mcc_compl_use(compl); 385 be_mcc_compl_use(compl);
306 if (status) { 386 if (status) {
307 SE_DEBUG(DBG_LVL_1, "After be_mcc_compl_process \n"); 387 SE_DEBUG(DBG_LVL_1, "After be_mcc_compl_process\n");
308 return status; 388 return status;
309 } 389 }
310 } else { 390 } else {
311 dev_err(&ctrl->pdev->dev, "invalid mailbox completion\n"); 391 dev_err(&ctrl->pdev->dev, "invalid mailbox completion\n");
312 return -1; 392 return -EBUSY;
313 } 393 }
314 return 0; 394 return 0;
315} 395}
@@ -355,7 +435,7 @@ static int be_mbox_notify_wait(struct beiscsi_hba *phba)
355 return status; 435 return status;
356 } else { 436 } else {
357 dev_err(&phba->pcidev->dev, "invalid mailbox completion\n"); 437 dev_err(&phba->pcidev->dev, "invalid mailbox completion\n");
358 return -1; 438 return -EBUSY;
359 } 439 }
360 return 0; 440 return 0;
361} 441}
@@ -500,7 +580,7 @@ int be_cmd_fw_initialize(struct be_ctrl_info *ctrl)
500 580
501 status = be_mbox_notify(ctrl); 581 status = be_mbox_notify(ctrl);
502 if (status) 582 if (status)
503 SE_DEBUG(DBG_LVL_1, "be_cmd_fw_initialize Failed \n"); 583 SE_DEBUG(DBG_LVL_1, "be_cmd_fw_initialize Failed\n");
504 584
505 spin_unlock(&ctrl->mbox_lock); 585 spin_unlock(&ctrl->mbox_lock);
506 return status; 586 return status;
@@ -517,7 +597,7 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
517 void *ctxt = &req->context; 597 void *ctxt = &req->context;
518 int status; 598 int status;
519 599
520 SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_cq_create \n"); 600 SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_cq_create\n");
521 spin_lock(&ctrl->mbox_lock); 601 spin_lock(&ctrl->mbox_lock);
522 memset(wrb, 0, sizeof(*wrb)); 602 memset(wrb, 0, sizeof(*wrb));
523 603
@@ -550,7 +630,7 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
550 cq->id = le16_to_cpu(resp->cq_id); 630 cq->id = le16_to_cpu(resp->cq_id);
551 cq->created = true; 631 cq->created = true;
552 } else 632 } else
553 SE_DEBUG(DBG_LVL_1, "In be_cmd_cq_create, status=ox%08x \n", 633 SE_DEBUG(DBG_LVL_1, "In be_cmd_cq_create, status=ox%08x\n",
554 status); 634 status);
555 spin_unlock(&ctrl->mbox_lock); 635 spin_unlock(&ctrl->mbox_lock);
556 636
@@ -619,7 +699,7 @@ int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
619 u8 subsys = 0, opcode = 0; 699 u8 subsys = 0, opcode = 0;
620 int status; 700 int status;
621 701
622 SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_q_destroy \n"); 702 SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_q_destroy\n");
623 spin_lock(&ctrl->mbox_lock); 703 spin_lock(&ctrl->mbox_lock);
624 memset(wrb, 0, sizeof(*wrb)); 704 memset(wrb, 0, sizeof(*wrb));
625 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 705 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
@@ -652,7 +732,7 @@ int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
652 default: 732 default:
653 spin_unlock(&ctrl->mbox_lock); 733 spin_unlock(&ctrl->mbox_lock);
654 BUG(); 734 BUG();
655 return -1; 735 return -ENXIO;
656 } 736 }
657 be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); 737 be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req));
658 if (queue_type != QTYPE_SGL) 738 if (queue_type != QTYPE_SGL)
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h
index 49fcc787ee8b..40641d0845f4 100644
--- a/drivers/scsi/be2iscsi/be_cmds.h
+++ b/drivers/scsi/be2iscsi/be_cmds.h
@@ -47,8 +47,8 @@ struct be_mcc_wrb {
47 47
48#define CQE_FLAGS_VALID_MASK (1 << 31) 48#define CQE_FLAGS_VALID_MASK (1 << 31)
49#define CQE_FLAGS_ASYNC_MASK (1 << 30) 49#define CQE_FLAGS_ASYNC_MASK (1 << 30)
50#define CQE_FLAGS_COMPLETED_MASK (1 << 28) 50#define CQE_FLAGS_COMPLETED_MASK (1 << 28)
51#define CQE_FLAGS_CONSUMED_MASK (1 << 27) 51#define CQE_FLAGS_CONSUMED_MASK (1 << 27)
52 52
53/* Completion Status */ 53/* Completion Status */
54#define MCC_STATUS_SUCCESS 0x0 54#define MCC_STATUS_SUCCESS 0x0
@@ -56,7 +56,7 @@ struct be_mcc_wrb {
56#define CQE_STATUS_COMPL_MASK 0xFFFF 56#define CQE_STATUS_COMPL_MASK 0xFFFF
57#define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */ 57#define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
58#define CQE_STATUS_EXTD_MASK 0xFFFF 58#define CQE_STATUS_EXTD_MASK 0xFFFF
59#define CQE_STATUS_EXTD_SHIFT 0 /* bits 0 - 15 */ 59#define CQE_STATUS_EXTD_SHIFT 16 /* bits 0 - 15 */
60 60
61struct be_mcc_compl { 61struct be_mcc_compl {
62 u32 status; /* dword 0 */ 62 u32 status; /* dword 0 */
@@ -143,14 +143,14 @@ struct be_mcc_mailbox {
143 */ 143 */
144#define OPCODE_COMMON_CQ_CREATE 12 144#define OPCODE_COMMON_CQ_CREATE 12
145#define OPCODE_COMMON_EQ_CREATE 13 145#define OPCODE_COMMON_EQ_CREATE 13
146#define OPCODE_COMMON_MCC_CREATE 21 146#define OPCODE_COMMON_MCC_CREATE 21
147#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32 147#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
148#define OPCODE_COMMON_GET_FW_VERSION 35 148#define OPCODE_COMMON_GET_FW_VERSION 35
149#define OPCODE_COMMON_MODIFY_EQ_DELAY 41 149#define OPCODE_COMMON_MODIFY_EQ_DELAY 41
150#define OPCODE_COMMON_FIRMWARE_CONFIG 42 150#define OPCODE_COMMON_FIRMWARE_CONFIG 42
151#define OPCODE_COMMON_MCC_DESTROY 53 151#define OPCODE_COMMON_MCC_DESTROY 53
152#define OPCODE_COMMON_CQ_DESTROY 54 152#define OPCODE_COMMON_CQ_DESTROY 54
153#define OPCODE_COMMON_EQ_DESTROY 55 153#define OPCODE_COMMON_EQ_DESTROY 55
154#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58 154#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
155#define OPCODE_COMMON_FUNCTION_RESET 61 155#define OPCODE_COMMON_FUNCTION_RESET 61
156 156
@@ -164,9 +164,9 @@ struct be_mcc_mailbox {
164#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7 164#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
165#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61 165#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
166#define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64 166#define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
167#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65 167#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
168#define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66 168#define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
169#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67 169#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
170 170
171struct be_cmd_req_hdr { 171struct be_cmd_req_hdr {
172 u8 opcode; /* dword 0 */ 172 u8 opcode; /* dword 0 */
@@ -423,7 +423,7 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
423 struct be_queue_info *cq); 423 struct be_queue_info *cq);
424 424
425int be_poll_mcc(struct be_ctrl_info *ctrl); 425int be_poll_mcc(struct be_ctrl_info *ctrl);
426unsigned char mgmt_check_supported_fw(struct be_ctrl_info *ctrl, 426int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
427 struct beiscsi_hba *phba); 427 struct beiscsi_hba *phba);
428unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba); 428unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba);
429void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); 429void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
@@ -875,7 +875,7 @@ struct be_fw_cfg {
875 */ 875 */
876#define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/ 876#define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
877#define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/ 877#define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
878#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest 878#define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
879 * error notify. 879 * error notify.
880 */ 880 */
881#define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based 881#define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
@@ -901,6 +901,9 @@ struct be_fw_cfg {
901 * the cxn 901 * the cxn
902 */ 902 */
903 903
904int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
905int be_chk_reset_complete(struct beiscsi_hba *phba);
906
904void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len, 907void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
905 bool embedded, u8 sge_cnt); 908 bool embedded, u8 sge_cnt);
906 909
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index c3928cb8b042..6d63e7b312cf 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -52,7 +52,7 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep,
52 SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n"); 52 SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n");
53 53
54 if (!ep) { 54 if (!ep) {
55 SE_DEBUG(DBG_LVL_1, "beiscsi_session_create: invalid ep \n"); 55 SE_DEBUG(DBG_LVL_1, "beiscsi_session_create: invalid ep\n");
56 return NULL; 56 return NULL;
57 } 57 }
58 beiscsi_ep = ep->dd_data; 58 beiscsi_ep = ep->dd_data;
@@ -157,7 +157,7 @@ static int beiscsi_bindconn_cid(struct beiscsi_hba *phba,
157 "Connection table already occupied. Detected clash\n"); 157 "Connection table already occupied. Detected clash\n");
158 return -EINVAL; 158 return -EINVAL;
159 } else { 159 } else {
160 SE_DEBUG(DBG_LVL_8, "phba->conn_table[%d]=%p(beiscsi_conn) \n", 160 SE_DEBUG(DBG_LVL_8, "phba->conn_table[%d]=%p(beiscsi_conn)\n",
161 cid, beiscsi_conn); 161 cid, beiscsi_conn);
162 phba->conn_table[cid] = beiscsi_conn; 162 phba->conn_table[cid] = beiscsi_conn;
163 } 163 }
@@ -196,7 +196,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
196 196
197 if (beiscsi_ep->phba != phba) { 197 if (beiscsi_ep->phba != phba) {
198 SE_DEBUG(DBG_LVL_8, 198 SE_DEBUG(DBG_LVL_8,
199 "beiscsi_ep->hba=%p not equal to phba=%p \n", 199 "beiscsi_ep->hba=%p not equal to phba=%p\n",
200 beiscsi_ep->phba, phba); 200 beiscsi_ep->phba, phba);
201 return -EEXIST; 201 return -EEXIST;
202 } 202 }
@@ -204,7 +204,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session,
204 beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; 204 beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid;
205 beiscsi_conn->ep = beiscsi_ep; 205 beiscsi_conn->ep = beiscsi_ep;
206 beiscsi_ep->conn = beiscsi_conn; 206 beiscsi_ep->conn = beiscsi_conn;
207 SE_DEBUG(DBG_LVL_8, "beiscsi_conn=%p conn=%p ep_cid=%d \n", 207 SE_DEBUG(DBG_LVL_8, "beiscsi_conn=%p conn=%p ep_cid=%d\n",
208 beiscsi_conn, conn, beiscsi_ep->ep_cid); 208 beiscsi_conn, conn, beiscsi_ep->ep_cid);
209 return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid); 209 return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid);
210} 210}
@@ -230,7 +230,7 @@ int beiscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
230 if (!beiscsi_ep) { 230 if (!beiscsi_ep) {
231 SE_DEBUG(DBG_LVL_1, 231 SE_DEBUG(DBG_LVL_1,
232 "In beiscsi_conn_get_param , no beiscsi_ep\n"); 232 "In beiscsi_conn_get_param , no beiscsi_ep\n");
233 return -1; 233 return -ENODEV;
234 } 234 }
235 235
236 switch (param) { 236 switch (param) {
@@ -277,6 +277,10 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
277 if (session->max_burst > 262144) 277 if (session->max_burst > 262144)
278 session->max_burst = 262144; 278 session->max_burst = 262144;
279 break; 279 break;
280 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
281 if ((conn->max_xmit_dlength > 65536) ||
282 (conn->max_xmit_dlength == 0))
283 conn->max_xmit_dlength = 65536;
280 default: 284 default:
281 return 0; 285 return 0;
282 } 286 }
@@ -308,8 +312,8 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
308 case ISCSI_HOST_PARAM_HWADDRESS: 312 case ISCSI_HOST_PARAM_HWADDRESS:
309 tag = be_cmd_get_mac_addr(phba); 313 tag = be_cmd_get_mac_addr(phba);
310 if (!tag) { 314 if (!tag) {
311 SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed \n"); 315 SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n");
312 return -1; 316 return -EAGAIN;
313 } else 317 } else
314 wait_event_interruptible(phba->ctrl.mcc_wait[tag], 318 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
315 phba->ctrl.mcc_numtag[tag]); 319 phba->ctrl.mcc_numtag[tag]);
@@ -319,10 +323,10 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
319 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; 323 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
320 if (status || extd_status) { 324 if (status || extd_status) {
321 SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed" 325 SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed"
322 " status = %d extd_status = %d \n", 326 " status = %d extd_status = %d\n",
323 status, extd_status); 327 status, extd_status);
324 free_mcc_tag(&phba->ctrl, tag); 328 free_mcc_tag(&phba->ctrl, tag);
325 return -1; 329 return -EAGAIN;
326 } else { 330 } else {
327 wrb = queue_get_wrb(mccq, wrb_num); 331 wrb = queue_get_wrb(mccq, wrb_num);
328 free_mcc_tag(&phba->ctrl, tag); 332 free_mcc_tag(&phba->ctrl, tag);
@@ -442,6 +446,31 @@ static int beiscsi_get_cid(struct beiscsi_hba *phba)
442} 446}
443 447
444/** 448/**
449 * beiscsi_put_cid - Free the cid
450 * @phba: The phba for which the cid is being freed
451 * @cid: The cid to free
452 */
453static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid)
454{
455 phba->avlbl_cids++;
456 phba->cid_array[phba->cid_free++] = cid;
457 if (phba->cid_free == phba->params.cxns_per_ctrl)
458 phba->cid_free = 0;
459}
460
461/**
462 * beiscsi_free_ep - free endpoint
463 * @ep: pointer to iscsi endpoint structure
464 */
465static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep)
466{
467 struct beiscsi_hba *phba = beiscsi_ep->phba;
468
469 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
470 beiscsi_ep->phba = NULL;
471}
472
473/**
445 * beiscsi_open_conn - Ask FW to open a TCP connection 474 * beiscsi_open_conn - Ask FW to open a TCP connection
446 * @ep: endpoint to be used 475 * @ep: endpoint to be used
447 * @src_addr: The source IP address 476 * @src_addr: The source IP address
@@ -459,8 +488,9 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
459 struct be_mcc_wrb *wrb; 488 struct be_mcc_wrb *wrb;
460 struct tcp_connect_and_offload_out *ptcpcnct_out; 489 struct tcp_connect_and_offload_out *ptcpcnct_out;
461 unsigned short status, extd_status; 490 unsigned short status, extd_status;
491 struct be_dma_mem nonemb_cmd;
462 unsigned int tag, wrb_num; 492 unsigned int tag, wrb_num;
463 int ret = -1; 493 int ret = -ENOMEM;
464 494
465 SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn\n"); 495 SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn\n");
466 beiscsi_ep->ep_cid = beiscsi_get_cid(phba); 496 beiscsi_ep->ep_cid = beiscsi_get_cid(phba);
@@ -468,22 +498,39 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
468 SE_DEBUG(DBG_LVL_1, "No free cid available\n"); 498 SE_DEBUG(DBG_LVL_1, "No free cid available\n");
469 return ret; 499 return ret;
470 } 500 }
471 SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn, ep_cid=%d ", 501 SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn, ep_cid=%d\n",
472 beiscsi_ep->ep_cid); 502 beiscsi_ep->ep_cid);
473 phba->ep_array[beiscsi_ep->ep_cid - 503 phba->ep_array[beiscsi_ep->ep_cid -
474 phba->fw_config.iscsi_cid_start] = ep; 504 phba->fw_config.iscsi_cid_start] = ep;
475 if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start + 505 if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start +
476 phba->params.cxns_per_ctrl * 2)) { 506 phba->params.cxns_per_ctrl * 2)) {
477 SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n"); 507 SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n");
478 return ret; 508 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
509 goto free_ep;
479 } 510 }
480 511
481 beiscsi_ep->cid_vld = 0; 512 beiscsi_ep->cid_vld = 0;
482 tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep); 513 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
514 sizeof(struct tcp_connect_and_offload_in),
515 &nonemb_cmd.dma);
516 if (nonemb_cmd.va == NULL) {
517 SE_DEBUG(DBG_LVL_1,
518 "Failed to allocate memory for mgmt_open_connection"
519 "\n");
520 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
521 return -ENOMEM;
522 }
523 nonemb_cmd.size = sizeof(struct tcp_connect_and_offload_in);
524 memset(nonemb_cmd.va, 0, nonemb_cmd.size);
525 tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd);
483 if (!tag) { 526 if (!tag) {
484 SE_DEBUG(DBG_LVL_1, 527 SE_DEBUG(DBG_LVL_1,
485 "mgmt_open_connection Failed for cid=%d \n", 528 "mgmt_open_connection Failed for cid=%d\n",
486 beiscsi_ep->ep_cid); 529 beiscsi_ep->ep_cid);
530 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
531 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
532 nonemb_cmd.va, nonemb_cmd.dma);
533 return -EAGAIN;
487 } else { 534 } else {
488 wait_event_interruptible(phba->ctrl.mcc_wait[tag], 535 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
489 phba->ctrl.mcc_numtag[tag]); 536 phba->ctrl.mcc_numtag[tag]);
@@ -493,46 +540,31 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
493 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; 540 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
494 if (status || extd_status) { 541 if (status || extd_status) {
495 SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed" 542 SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed"
496 " status = %d extd_status = %d \n", 543 " status = %d extd_status = %d\n",
497 status, extd_status); 544 status, extd_status);
545 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
498 free_mcc_tag(&phba->ctrl, tag); 546 free_mcc_tag(&phba->ctrl, tag);
499 return -1; 547 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
548 nonemb_cmd.va, nonemb_cmd.dma);
549 goto free_ep;
500 } else { 550 } else {
501 wrb = queue_get_wrb(mccq, wrb_num); 551 wrb = queue_get_wrb(mccq, wrb_num);
502 free_mcc_tag(&phba->ctrl, tag); 552 free_mcc_tag(&phba->ctrl, tag);
503 553
504 ptcpcnct_out = embedded_payload(wrb); 554 ptcpcnct_out = embedded_payload(wrb);
505 beiscsi_ep = ep->dd_data; 555 beiscsi_ep = ep->dd_data;
506 beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; 556 beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle;
507 beiscsi_ep->cid_vld = 1; 557 beiscsi_ep->cid_vld = 1;
508 SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n"); 558 SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n");
509 } 559 }
560 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
561 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
562 nonemb_cmd.va, nonemb_cmd.dma);
510 return 0; 563 return 0;
511}
512
513/**
514 * beiscsi_put_cid - Free the cid
515 * @phba: The phba for which the cid is being freed
516 * @cid: The cid to free
517 */
518static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid)
519{
520 phba->avlbl_cids++;
521 phba->cid_array[phba->cid_free++] = cid;
522 if (phba->cid_free == phba->params.cxns_per_ctrl)
523 phba->cid_free = 0;
524}
525
526/**
527 * beiscsi_free_ep - free endpoint
528 * @ep: pointer to iscsi endpoint structure
529 */
530static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep)
531{
532 struct beiscsi_hba *phba = beiscsi_ep->phba;
533 564
534 beiscsi_put_cid(phba, beiscsi_ep->ep_cid); 565free_ep:
535 beiscsi_ep->phba = NULL; 566 beiscsi_free_ep(beiscsi_ep);
567 return -EBUSY;
536} 568}
537 569
538/** 570/**
@@ -552,18 +584,18 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
552 struct iscsi_endpoint *ep; 584 struct iscsi_endpoint *ep;
553 int ret; 585 int ret;
554 586
555 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_connect \n"); 587 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_connect\n");
556 if (shost) 588 if (shost)
557 phba = iscsi_host_priv(shost); 589 phba = iscsi_host_priv(shost);
558 else { 590 else {
559 ret = -ENXIO; 591 ret = -ENXIO;
560 SE_DEBUG(DBG_LVL_1, "shost is NULL \n"); 592 SE_DEBUG(DBG_LVL_1, "shost is NULL\n");
561 return ERR_PTR(ret); 593 return ERR_PTR(ret);
562 } 594 }
563 595
564 if (phba->state != BE_ADAPTER_UP) { 596 if (phba->state != BE_ADAPTER_UP) {
565 ret = -EBUSY; 597 ret = -EBUSY;
566 SE_DEBUG(DBG_LVL_1, "The Adapter state is Not UP \n"); 598 SE_DEBUG(DBG_LVL_1, "The Adapter state is Not UP\n");
567 return ERR_PTR(ret); 599 return ERR_PTR(ret);
568 } 600 }
569 601
@@ -576,16 +608,16 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
576 beiscsi_ep = ep->dd_data; 608 beiscsi_ep = ep->dd_data;
577 beiscsi_ep->phba = phba; 609 beiscsi_ep->phba = phba;
578 beiscsi_ep->openiscsi_ep = ep; 610 beiscsi_ep->openiscsi_ep = ep;
579 if (beiscsi_open_conn(ep, NULL, dst_addr, non_blocking)) { 611 ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking);
580 SE_DEBUG(DBG_LVL_1, "Failed in beiscsi_open_conn \n"); 612 if (ret) {
581 ret = -ENOMEM; 613 SE_DEBUG(DBG_LVL_1, "Failed in beiscsi_open_conn\n");
582 goto free_ep; 614 goto free_ep;
583 } 615 }
584 616
585 return ep; 617 return ep;
586 618
587free_ep: 619free_ep:
588 beiscsi_free_ep(beiscsi_ep); 620 iscsi_destroy_endpoint(ep);
589 return ERR_PTR(ret); 621 return ERR_PTR(ret);
590} 622}
591 623
@@ -620,9 +652,9 @@ static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag)
620 652
621 tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag); 653 tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag);
622 if (!tag) { 654 if (!tag) {
623 SE_DEBUG(DBG_LVL_8, "upload failed for cid 0x%x", 655 SE_DEBUG(DBG_LVL_8, "upload failed for cid 0x%x\n",
624 beiscsi_ep->ep_cid); 656 beiscsi_ep->ep_cid);
625 ret = -1; 657 ret = -EAGAIN;
626 } else { 658 } else {
627 wait_event_interruptible(phba->ctrl.mcc_wait[tag], 659 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
628 phba->ctrl.mcc_numtag[tag]); 660 phba->ctrl.mcc_numtag[tag]);
@@ -632,30 +664,6 @@ static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag)
632} 664}
633 665
634/** 666/**
635 * beiscsi_ep_disconnect - Tears down the TCP connection
636 * @ep: endpoint to be used
637 *
638 * Tears down the TCP connection
639 */
640void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
641{
642 struct beiscsi_conn *beiscsi_conn;
643 struct beiscsi_endpoint *beiscsi_ep;
644 struct beiscsi_hba *phba;
645
646 beiscsi_ep = ep->dd_data;
647 phba = beiscsi_ep->phba;
648 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect for ep_cid = %d\n",
649 beiscsi_ep->ep_cid);
650
651 if (beiscsi_ep->conn) {
652 beiscsi_conn = beiscsi_ep->conn;
653 iscsi_suspend_queue(beiscsi_conn->conn);
654 }
655
656}
657
658/**
659 * beiscsi_unbind_conn_to_cid - Unbind the beiscsi_conn from phba conn table 667 * beiscsi_unbind_conn_to_cid - Unbind the beiscsi_conn from phba conn table
660 * @phba: The phba instance 668 * @phba: The phba instance
661 * @cid: The cid to free 669 * @cid: The cid to free
@@ -666,50 +674,57 @@ static int beiscsi_unbind_conn_to_cid(struct beiscsi_hba *phba,
666 if (phba->conn_table[cid]) 674 if (phba->conn_table[cid])
667 phba->conn_table[cid] = NULL; 675 phba->conn_table[cid] = NULL;
668 else { 676 else {
669 SE_DEBUG(DBG_LVL_8, "Connection table Not occupied. \n"); 677 SE_DEBUG(DBG_LVL_8, "Connection table Not occupied.\n");
670 return -EINVAL; 678 return -EINVAL;
671 } 679 }
672 return 0; 680 return 0;
673} 681}
674 682
675/** 683/**
676 * beiscsi_conn_stop - Invalidate and stop the connection 684 * beiscsi_ep_disconnect - Tears down the TCP connection
677 * @cls_conn: pointer to get iscsi_conn 685 * @ep: endpoint to be used
678 * @flag: The type of connection closure 686 *
687 * Tears down the TCP connection
679 */ 688 */
680void beiscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) 689void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
681{ 690{
682 struct iscsi_conn *conn = cls_conn->dd_data; 691 struct beiscsi_conn *beiscsi_conn;
683 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
684 struct beiscsi_endpoint *beiscsi_ep; 692 struct beiscsi_endpoint *beiscsi_ep;
685 struct iscsi_session *session = conn->session; 693 struct beiscsi_hba *phba;
686 struct Scsi_Host *shost = iscsi_session_to_shost(session->cls_session);
687 struct beiscsi_hba *phba = iscsi_host_priv(shost);
688 unsigned int tag; 694 unsigned int tag;
689 unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; 695 unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH;
690 696
691 beiscsi_ep = beiscsi_conn->ep; 697 beiscsi_ep = ep->dd_data;
692 if (!beiscsi_ep) { 698 phba = beiscsi_ep->phba;
693 SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_stop , no beiscsi_ep\n"); 699 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect for ep_cid = %d\n",
700 beiscsi_ep->ep_cid);
701
702 if (!beiscsi_ep->conn) {
703 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect, no "
704 "beiscsi_ep\n");
694 return; 705 return;
695 } 706 }
696 SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_stop ep_cid = %d\n", 707 beiscsi_conn = beiscsi_ep->conn;
697 beiscsi_ep->ep_cid); 708 iscsi_suspend_queue(beiscsi_conn->conn);
709
710 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect ep_cid = %d\n",
711 beiscsi_ep->ep_cid);
712
698 tag = mgmt_invalidate_connection(phba, beiscsi_ep, 713 tag = mgmt_invalidate_connection(phba, beiscsi_ep,
699 beiscsi_ep->ep_cid, 1, 714 beiscsi_ep->ep_cid, 1,
700 savecfg_flag); 715 savecfg_flag);
701 if (!tag) { 716 if (!tag) {
702 SE_DEBUG(DBG_LVL_1, 717 SE_DEBUG(DBG_LVL_1,
703 "mgmt_invalidate_connection Failed for cid=%d \n", 718 "mgmt_invalidate_connection Failed for cid=%d\n",
704 beiscsi_ep->ep_cid); 719 beiscsi_ep->ep_cid);
705 } else { 720 } else {
706 wait_event_interruptible(phba->ctrl.mcc_wait[tag], 721 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
707 phba->ctrl.mcc_numtag[tag]); 722 phba->ctrl.mcc_numtag[tag]);
708 free_mcc_tag(&phba->ctrl, tag); 723 free_mcc_tag(&phba->ctrl, tag);
709 } 724 }
725
710 beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL); 726 beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL);
711 beiscsi_free_ep(beiscsi_ep); 727 beiscsi_free_ep(beiscsi_ep);
712 iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep);
713 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); 728 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid);
714 iscsi_conn_stop(cls_conn, flag); 729 iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep);
715} 730}
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index 1f512c28cbf9..870cdb2a73e4 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -59,8 +59,6 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
59 59
60int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn); 60int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn);
61 61
62void beiscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag);
63
64struct iscsi_endpoint *beiscsi_ep_connect(struct Scsi_Host *shost, 62struct iscsi_endpoint *beiscsi_ep_connect(struct Scsi_Host *shost,
65 struct sockaddr *dst_addr, 63 struct sockaddr *dst_addr,
66 int non_blocking); 64 int non_blocking);
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index dd5b105f8f47..7436c5ad5697 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -41,6 +41,8 @@
41static unsigned int be_iopoll_budget = 10; 41static unsigned int be_iopoll_budget = 10;
42static unsigned int be_max_phys_size = 64; 42static unsigned int be_max_phys_size = 64;
43static unsigned int enable_msix = 1; 43static unsigned int enable_msix = 1;
44static unsigned int gcrashmode = 0;
45static unsigned int num_hba = 0;
44 46
45MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); 47MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table);
46MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR); 48MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR);
@@ -69,6 +71,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
69 struct beiscsi_hba *phba; 71 struct beiscsi_hba *phba;
70 struct iscsi_session *session; 72 struct iscsi_session *session;
71 struct invalidate_command_table *inv_tbl; 73 struct invalidate_command_table *inv_tbl;
74 struct be_dma_mem nonemb_cmd;
72 unsigned int cid, tag, num_invalidate; 75 unsigned int cid, tag, num_invalidate;
73 76
74 cls_session = starget_to_session(scsi_target(sc->device)); 77 cls_session = starget_to_session(scsi_target(sc->device));
@@ -99,18 +102,34 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
99 inv_tbl->cid = cid; 102 inv_tbl->cid = cid;
100 inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index; 103 inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index;
101 num_invalidate = 1; 104 num_invalidate = 1;
102 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, cid); 105 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
106 sizeof(struct invalidate_commands_params_in),
107 &nonemb_cmd.dma);
108 if (nonemb_cmd.va == NULL) {
109 SE_DEBUG(DBG_LVL_1,
110 "Failed to allocate memory for"
111 "mgmt_invalidate_icds\n");
112 return FAILED;
113 }
114 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
115
116 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate,
117 cid, &nonemb_cmd);
103 if (!tag) { 118 if (!tag) {
104 shost_printk(KERN_WARNING, phba->shost, 119 shost_printk(KERN_WARNING, phba->shost,
105 "mgmt_invalidate_icds could not be" 120 "mgmt_invalidate_icds could not be"
106 " submitted\n"); 121 " submitted\n");
122 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
123 nonemb_cmd.va, nonemb_cmd.dma);
124
107 return FAILED; 125 return FAILED;
108 } else { 126 } else {
109 wait_event_interruptible(phba->ctrl.mcc_wait[tag], 127 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
110 phba->ctrl.mcc_numtag[tag]); 128 phba->ctrl.mcc_numtag[tag]);
111 free_mcc_tag(&phba->ctrl, tag); 129 free_mcc_tag(&phba->ctrl, tag);
112 } 130 }
113 131 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
132 nonemb_cmd.va, nonemb_cmd.dma);
114 return iscsi_eh_abort(sc); 133 return iscsi_eh_abort(sc);
115} 134}
116 135
@@ -124,6 +143,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
124 struct iscsi_session *session; 143 struct iscsi_session *session;
125 struct iscsi_cls_session *cls_session; 144 struct iscsi_cls_session *cls_session;
126 struct invalidate_command_table *inv_tbl; 145 struct invalidate_command_table *inv_tbl;
146 struct be_dma_mem nonemb_cmd;
127 unsigned int cid, tag, i, num_invalidate; 147 unsigned int cid, tag, i, num_invalidate;
128 int rc = FAILED; 148 int rc = FAILED;
129 149
@@ -158,18 +178,33 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
158 spin_unlock_bh(&session->lock); 178 spin_unlock_bh(&session->lock);
159 inv_tbl = phba->inv_tbl; 179 inv_tbl = phba->inv_tbl;
160 180
161 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, cid); 181 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
182 sizeof(struct invalidate_commands_params_in),
183 &nonemb_cmd.dma);
184 if (nonemb_cmd.va == NULL) {
185 SE_DEBUG(DBG_LVL_1,
186 "Failed to allocate memory for"
187 "mgmt_invalidate_icds\n");
188 return FAILED;
189 }
190 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
191 memset(nonemb_cmd.va, 0, nonemb_cmd.size);
192 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate,
193 cid, &nonemb_cmd);
162 if (!tag) { 194 if (!tag) {
163 shost_printk(KERN_WARNING, phba->shost, 195 shost_printk(KERN_WARNING, phba->shost,
164 "mgmt_invalidate_icds could not be" 196 "mgmt_invalidate_icds could not be"
165 " submitted\n"); 197 " submitted\n");
198 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
199 nonemb_cmd.va, nonemb_cmd.dma);
166 return FAILED; 200 return FAILED;
167 } else { 201 } else {
168 wait_event_interruptible(phba->ctrl.mcc_wait[tag], 202 wait_event_interruptible(phba->ctrl.mcc_wait[tag],
169 phba->ctrl.mcc_numtag[tag]); 203 phba->ctrl.mcc_numtag[tag]);
170 free_mcc_tag(&phba->ctrl, tag); 204 free_mcc_tag(&phba->ctrl, tag);
171 } 205 }
172 206 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
207 nonemb_cmd.va, nonemb_cmd.dma);
173 return iscsi_eh_device_reset(sc); 208 return iscsi_eh_device_reset(sc);
174unlock: 209unlock:
175 spin_unlock_bh(&session->lock); 210 spin_unlock_bh(&session->lock);
@@ -216,7 +251,7 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev)
216 shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0); 251 shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0);
217 if (!shost) { 252 if (!shost) {
218 dev_err(&pcidev->dev, "beiscsi_hba_alloc -" 253 dev_err(&pcidev->dev, "beiscsi_hba_alloc -"
219 "iscsi_host_alloc failed \n"); 254 "iscsi_host_alloc failed\n");
220 return NULL; 255 return NULL;
221 } 256 }
222 shost->dma_boundary = pcidev->dma_mask; 257 shost->dma_boundary = pcidev->dma_mask;
@@ -371,7 +406,7 @@ static void beiscsi_get_params(struct beiscsi_hba *phba)
371 + BE2_TMFS) / 512) + 1) * 512; 406 + BE2_TMFS) / 512) + 1) * 512;
372 phba->params.num_eq_entries = (phba->params.num_eq_entries < 1024) 407 phba->params.num_eq_entries = (phba->params.num_eq_entries < 1024)
373 ? 1024 : phba->params.num_eq_entries; 408 ? 1024 : phba->params.num_eq_entries;
374 SE_DEBUG(DBG_LVL_8, "phba->params.num_eq_entries=%d \n", 409 SE_DEBUG(DBG_LVL_8, "phba->params.num_eq_entries=%d\n",
375 phba->params.num_eq_entries); 410 phba->params.num_eq_entries);
376 phba->params.num_cq_entries = 411 phba->params.num_cq_entries =
377 (((BE2_CMDS_PER_CXN * 2 + phba->fw_config.iscsi_cid_count * 2 412 (((BE2_CMDS_PER_CXN * 2 + phba->fw_config.iscsi_cid_count * 2
@@ -616,7 +651,7 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
616 struct pci_dev *pcidev = phba->pcidev; 651 struct pci_dev *pcidev = phba->pcidev;
617 struct hwi_controller *phwi_ctrlr; 652 struct hwi_controller *phwi_ctrlr;
618 struct hwi_context_memory *phwi_context; 653 struct hwi_context_memory *phwi_context;
619 int ret, msix_vec, i = 0; 654 int ret, msix_vec, i, j;
620 char desc[32]; 655 char desc[32];
621 656
622 phwi_ctrlr = phba->phwi_ctrlr; 657 phwi_ctrlr = phba->phwi_ctrlr;
@@ -628,10 +663,25 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
628 msix_vec = phba->msix_entries[i].vector; 663 msix_vec = phba->msix_entries[i].vector;
629 ret = request_irq(msix_vec, be_isr_msix, 0, desc, 664 ret = request_irq(msix_vec, be_isr_msix, 0, desc,
630 &phwi_context->be_eq[i]); 665 &phwi_context->be_eq[i]);
666 if (ret) {
667 shost_printk(KERN_ERR, phba->shost,
668 "beiscsi_init_irqs-Failed to"
669 "register msix for i = %d\n", i);
670 if (!i)
671 return ret;
672 goto free_msix_irqs;
673 }
631 } 674 }
632 msix_vec = phba->msix_entries[i].vector; 675 msix_vec = phba->msix_entries[i].vector;
633 ret = request_irq(msix_vec, be_isr_mcc, 0, "beiscsi_msix_mcc", 676 ret = request_irq(msix_vec, be_isr_mcc, 0, "beiscsi_msix_mcc",
634 &phwi_context->be_eq[i]); 677 &phwi_context->be_eq[i]);
678 if (ret) {
679 shost_printk(KERN_ERR, phba->shost, "beiscsi_init_irqs-"
680 "Failed to register beiscsi_msix_mcc\n");
681 i++;
682 goto free_msix_irqs;
683 }
684
635 } else { 685 } else {
636 ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED, 686 ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED,
637 "beiscsi", phba); 687 "beiscsi", phba);
@@ -642,6 +692,10 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
642 } 692 }
643 } 693 }
644 return 0; 694 return 0;
695free_msix_irqs:
696 for (j = i - 1; j == 0; j++)
697 free_irq(msix_vec, &phwi_context->be_eq[j]);
698 return ret;
645} 699}
646 700
647static void hwi_ring_cq_db(struct beiscsi_hba *phba, 701static void hwi_ring_cq_db(struct beiscsi_hba *phba,
@@ -692,7 +746,7 @@ beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn,
692 break; 746 break;
693 default: 747 default:
694 shost_printk(KERN_WARNING, phba->shost, 748 shost_printk(KERN_WARNING, phba->shost,
695 "Unrecognized opcode 0x%x in async msg \n", 749 "Unrecognized opcode 0x%x in async msg\n",
696 (ppdu-> 750 (ppdu->
697 dw[offsetof(struct amap_pdu_base, opcode) / 32] 751 dw[offsetof(struct amap_pdu_base, opcode) / 32]
698 & PDUBASE_OPCODE_MASK)); 752 & PDUBASE_OPCODE_MASK));
@@ -711,7 +765,7 @@ static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
711 765
712 if (phba->io_sgl_hndl_avbl) { 766 if (phba->io_sgl_hndl_avbl) {
713 SE_DEBUG(DBG_LVL_8, 767 SE_DEBUG(DBG_LVL_8,
714 "In alloc_io_sgl_handle,io_sgl_alloc_index=%d \n", 768 "In alloc_io_sgl_handle,io_sgl_alloc_index=%d\n",
715 phba->io_sgl_alloc_index); 769 phba->io_sgl_alloc_index);
716 psgl_handle = phba->io_sgl_hndl_base[phba-> 770 psgl_handle = phba->io_sgl_hndl_base[phba->
717 io_sgl_alloc_index]; 771 io_sgl_alloc_index];
@@ -730,7 +784,7 @@ static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
730static void 784static void
731free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) 785free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
732{ 786{
733 SE_DEBUG(DBG_LVL_8, "In free_,io_sgl_free_index=%d \n", 787 SE_DEBUG(DBG_LVL_8, "In free_,io_sgl_free_index=%d\n",
734 phba->io_sgl_free_index); 788 phba->io_sgl_free_index);
735 if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) { 789 if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) {
736 /* 790 /*
@@ -739,7 +793,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
739 */ 793 */
740 SE_DEBUG(DBG_LVL_8, 794 SE_DEBUG(DBG_LVL_8,
741 "Double Free in IO SGL io_sgl_free_index=%d," 795 "Double Free in IO SGL io_sgl_free_index=%d,"
742 "value there=%p \n", phba->io_sgl_free_index, 796 "value there=%p\n", phba->io_sgl_free_index,
743 phba->io_sgl_hndl_base[phba->io_sgl_free_index]); 797 phba->io_sgl_hndl_base[phba->io_sgl_free_index]);
744 return; 798 return;
745 } 799 }
@@ -804,7 +858,7 @@ free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context,
804 858
805 SE_DEBUG(DBG_LVL_8, 859 SE_DEBUG(DBG_LVL_8,
806 "FREE WRB: pwrb_handle=%p free_index=0x%x" 860 "FREE WRB: pwrb_handle=%p free_index=0x%x"
807 "wrb_handles_available=%d \n", 861 "wrb_handles_available=%d\n",
808 pwrb_handle, pwrb_context->free_index, 862 pwrb_handle, pwrb_context->free_index,
809 pwrb_context->wrb_handles_available); 863 pwrb_context->wrb_handles_available);
810} 864}
@@ -816,7 +870,7 @@ static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba)
816 if (phba->eh_sgl_hndl_avbl) { 870 if (phba->eh_sgl_hndl_avbl) {
817 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; 871 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index];
818 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; 872 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL;
819 SE_DEBUG(DBG_LVL_8, "mgmt_sgl_alloc_index=%d=0x%x \n", 873 SE_DEBUG(DBG_LVL_8, "mgmt_sgl_alloc_index=%d=0x%x\n",
820 phba->eh_sgl_alloc_index, phba->eh_sgl_alloc_index); 874 phba->eh_sgl_alloc_index, phba->eh_sgl_alloc_index);
821 phba->eh_sgl_hndl_avbl--; 875 phba->eh_sgl_hndl_avbl--;
822 if (phba->eh_sgl_alloc_index == 876 if (phba->eh_sgl_alloc_index ==
@@ -834,7 +888,7 @@ void
834free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) 888free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
835{ 889{
836 890
837 SE_DEBUG(DBG_LVL_8, "In free_mgmt_sgl_handle,eh_sgl_free_index=%d \n", 891 SE_DEBUG(DBG_LVL_8, "In free_mgmt_sgl_handle,eh_sgl_free_index=%d\n",
838 phba->eh_sgl_free_index); 892 phba->eh_sgl_free_index);
839 if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) { 893 if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) {
840 /* 894 /*
@@ -842,7 +896,7 @@ free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
842 * failed in xmit_task or alloc_pdu. 896 * failed in xmit_task or alloc_pdu.
843 */ 897 */
844 SE_DEBUG(DBG_LVL_8, 898 SE_DEBUG(DBG_LVL_8,
845 "Double Free in eh SGL ,eh_sgl_free_index=%d \n", 899 "Double Free in eh SGL ,eh_sgl_free_index=%d\n",
846 phba->eh_sgl_free_index); 900 phba->eh_sgl_free_index);
847 return; 901 return;
848 } 902 }
@@ -1081,7 +1135,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
1081 case HWH_TYPE_LOGIN: 1135 case HWH_TYPE_LOGIN:
1082 SE_DEBUG(DBG_LVL_1, 1136 SE_DEBUG(DBG_LVL_1,
1083 "\t\t No HWH_TYPE_LOGIN Expected in hwi_complete_cmd" 1137 "\t\t No HWH_TYPE_LOGIN Expected in hwi_complete_cmd"
1084 "- Solicited path \n"); 1138 "- Solicited path\n");
1085 break; 1139 break;
1086 1140
1087 case HWH_TYPE_NOP: 1141 case HWH_TYPE_NOP:
@@ -1164,7 +1218,7 @@ hwi_get_async_handle(struct beiscsi_hba *phba,
1164 default: 1218 default:
1165 pbusy_list = NULL; 1219 pbusy_list = NULL;
1166 shost_printk(KERN_WARNING, phba->shost, 1220 shost_printk(KERN_WARNING, phba->shost,
1167 "Unexpected code=%d \n", 1221 "Unexpected code=%d\n",
1168 pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, 1222 pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe,
1169 code) / 32] & PDUCQE_CODE_MASK); 1223 code) / 32] & PDUCQE_CODE_MASK);
1170 return NULL; 1224 return NULL;
@@ -1552,7 +1606,7 @@ static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba)
1552 else 1606 else
1553 SE_DEBUG(DBG_LVL_1, 1607 SE_DEBUG(DBG_LVL_1,
1554 " Unsupported Async Event, flags" 1608 " Unsupported Async Event, flags"
1555 " = 0x%08x \n", mcc_compl->flags); 1609 " = 0x%08x\n", mcc_compl->flags);
1556 } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) { 1610 } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) {
1557 be_mcc_compl_process_isr(&phba->ctrl, mcc_compl); 1611 be_mcc_compl_process_isr(&phba->ctrl, mcc_compl);
1558 atomic_dec(&phba->ctrl.mcc_obj.q.used); 1612 atomic_dec(&phba->ctrl.mcc_obj.q.used);
@@ -1611,7 +1665,7 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
1611 hwi_complete_cmd(beiscsi_conn, phba, sol); 1665 hwi_complete_cmd(beiscsi_conn, phba, sol);
1612 break; 1666 break;
1613 case DRIVERMSG_NOTIFY: 1667 case DRIVERMSG_NOTIFY:
1614 SE_DEBUG(DBG_LVL_8, "Received DRIVERMSG_NOTIFY \n"); 1668 SE_DEBUG(DBG_LVL_8, "Received DRIVERMSG_NOTIFY\n");
1615 dmsg = (struct dmsg_cqe *)sol; 1669 dmsg = (struct dmsg_cqe *)sol;
1616 hwi_complete_drvr_msgs(beiscsi_conn, phba, sol); 1670 hwi_complete_drvr_msgs(beiscsi_conn, phba, sol);
1617 break; 1671 break;
@@ -1782,9 +1836,9 @@ hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg,
1782 sg_len = sg_dma_len(sg); 1836 sg_len = sg_dma_len(sg);
1783 addr = (u64) sg_dma_address(sg); 1837 addr = (u64) sg_dma_address(sg);
1784 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb, 1838 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb,
1785 (addr & 0xFFFFFFFF)); 1839 ((u32)(addr & 0xFFFFFFFF)));
1786 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb, 1840 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb,
1787 (addr >> 32)); 1841 ((u32)(addr >> 32)));
1788 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb, 1842 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb,
1789 sg_len); 1843 sg_len);
1790 sge_len = sg_len; 1844 sge_len = sg_len;
@@ -1794,9 +1848,9 @@ hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg,
1794 sg_len = sg_dma_len(sg); 1848 sg_len = sg_dma_len(sg);
1795 addr = (u64) sg_dma_address(sg); 1849 addr = (u64) sg_dma_address(sg);
1796 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_lo, pwrb, 1850 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_lo, pwrb,
1797 (addr & 0xFFFFFFFF)); 1851 ((u32)(addr & 0xFFFFFFFF)));
1798 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_hi, pwrb, 1852 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_hi, pwrb,
1799 (addr >> 32)); 1853 ((u32)(addr >> 32)));
1800 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_len, pwrb, 1854 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_len, pwrb,
1801 sg_len); 1855 sg_len);
1802 } 1856 }
@@ -1872,9 +1926,9 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task)
1872 addr = 0; 1926 addr = 0;
1873 } 1927 }
1874 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb, 1928 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb,
1875 (addr & 0xFFFFFFFF)); 1929 ((u32)(addr & 0xFFFFFFFF)));
1876 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb, 1930 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb,
1877 (addr >> 32)); 1931 ((u32)(addr >> 32)));
1878 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb, 1932 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb,
1879 task->data_count); 1933 task->data_count);
1880 1934
@@ -1904,9 +1958,9 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task)
1904 psgl++; 1958 psgl++;
1905 if (task->data) { 1959 if (task->data) {
1906 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 1960 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
1907 (addr & 0xFFFFFFFF)); 1961 ((u32)(addr & 0xFFFFFFFF)));
1908 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 1962 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
1909 (addr >> 32)); 1963 ((u32)(addr >> 32)));
1910 } 1964 }
1911 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106); 1965 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106);
1912 } 1966 }
@@ -2054,7 +2108,8 @@ free_mem:
2054 mem_descr->mem_array[j - 1].size, 2108 mem_descr->mem_array[j - 1].size,
2055 mem_descr->mem_array[j - 1]. 2109 mem_descr->mem_array[j - 1].
2056 virtual_address, 2110 virtual_address,
2057 mem_descr->mem_array[j - 1]. 2111 (unsigned long)mem_descr->
2112 mem_array[j - 1].
2058 bus_address.u.a64.address); 2113 bus_address.u.a64.address);
2059 } 2114 }
2060 if (i) { 2115 if (i) {
@@ -2223,10 +2278,10 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2223 if (mem_descr->mem_array[0].virtual_address) { 2278 if (mem_descr->mem_array[0].virtual_address) {
2224 SE_DEBUG(DBG_LVL_8, 2279 SE_DEBUG(DBG_LVL_8,
2225 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_BUF" 2280 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_BUF"
2226 "va=%p \n", mem_descr->mem_array[0].virtual_address); 2281 "va=%p\n", mem_descr->mem_array[0].virtual_address);
2227 } else 2282 } else
2228 shost_printk(KERN_WARNING, phba->shost, 2283 shost_printk(KERN_WARNING, phba->shost,
2229 "No Virtual address \n"); 2284 "No Virtual address\n");
2230 2285
2231 pasync_ctx->async_header.va_base = 2286 pasync_ctx->async_header.va_base =
2232 mem_descr->mem_array[0].virtual_address; 2287 mem_descr->mem_array[0].virtual_address;
@@ -2239,10 +2294,10 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2239 if (mem_descr->mem_array[0].virtual_address) { 2294 if (mem_descr->mem_array[0].virtual_address) {
2240 SE_DEBUG(DBG_LVL_8, 2295 SE_DEBUG(DBG_LVL_8,
2241 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_RING" 2296 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_RING"
2242 "va=%p \n", mem_descr->mem_array[0].virtual_address); 2297 "va=%p\n", mem_descr->mem_array[0].virtual_address);
2243 } else 2298 } else
2244 shost_printk(KERN_WARNING, phba->shost, 2299 shost_printk(KERN_WARNING, phba->shost,
2245 "No Virtual address \n"); 2300 "No Virtual address\n");
2246 pasync_ctx->async_header.ring_base = 2301 pasync_ctx->async_header.ring_base =
2247 mem_descr->mem_array[0].virtual_address; 2302 mem_descr->mem_array[0].virtual_address;
2248 2303
@@ -2251,10 +2306,10 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2251 if (mem_descr->mem_array[0].virtual_address) { 2306 if (mem_descr->mem_array[0].virtual_address) {
2252 SE_DEBUG(DBG_LVL_8, 2307 SE_DEBUG(DBG_LVL_8,
2253 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_HANDLE" 2308 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_HANDLE"
2254 "va=%p \n", mem_descr->mem_array[0].virtual_address); 2309 "va=%p\n", mem_descr->mem_array[0].virtual_address);
2255 } else 2310 } else
2256 shost_printk(KERN_WARNING, phba->shost, 2311 shost_printk(KERN_WARNING, phba->shost,
2257 "No Virtual address \n"); 2312 "No Virtual address\n");
2258 2313
2259 pasync_ctx->async_header.handle_base = 2314 pasync_ctx->async_header.handle_base =
2260 mem_descr->mem_array[0].virtual_address; 2315 mem_descr->mem_array[0].virtual_address;
@@ -2266,10 +2321,10 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2266 if (mem_descr->mem_array[0].virtual_address) { 2321 if (mem_descr->mem_array[0].virtual_address) {
2267 SE_DEBUG(DBG_LVL_8, 2322 SE_DEBUG(DBG_LVL_8,
2268 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_DATA_BUF" 2323 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_DATA_BUF"
2269 "va=%p \n", mem_descr->mem_array[0].virtual_address); 2324 "va=%p\n", mem_descr->mem_array[0].virtual_address);
2270 } else 2325 } else
2271 shost_printk(KERN_WARNING, phba->shost, 2326 shost_printk(KERN_WARNING, phba->shost,
2272 "No Virtual address \n"); 2327 "No Virtual address\n");
2273 pasync_ctx->async_data.va_base = 2328 pasync_ctx->async_data.va_base =
2274 mem_descr->mem_array[0].virtual_address; 2329 mem_descr->mem_array[0].virtual_address;
2275 pasync_ctx->async_data.pa_base.u.a64.address = 2330 pasync_ctx->async_data.pa_base.u.a64.address =
@@ -2280,10 +2335,10 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2280 if (mem_descr->mem_array[0].virtual_address) { 2335 if (mem_descr->mem_array[0].virtual_address) {
2281 SE_DEBUG(DBG_LVL_8, 2336 SE_DEBUG(DBG_LVL_8,
2282 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_DATA_RING" 2337 "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_DATA_RING"
2283 "va=%p \n", mem_descr->mem_array[0].virtual_address); 2338 "va=%p\n", mem_descr->mem_array[0].virtual_address);
2284 } else 2339 } else
2285 shost_printk(KERN_WARNING, phba->shost, 2340 shost_printk(KERN_WARNING, phba->shost,
2286 "No Virtual address \n"); 2341 "No Virtual address\n");
2287 2342
2288 pasync_ctx->async_data.ring_base = 2343 pasync_ctx->async_data.ring_base =
2289 mem_descr->mem_array[0].virtual_address; 2344 mem_descr->mem_array[0].virtual_address;
@@ -2292,7 +2347,7 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2292 mem_descr += HWI_MEM_ASYNC_DATA_HANDLE; 2347 mem_descr += HWI_MEM_ASYNC_DATA_HANDLE;
2293 if (!mem_descr->mem_array[0].virtual_address) 2348 if (!mem_descr->mem_array[0].virtual_address)
2294 shost_printk(KERN_WARNING, phba->shost, 2349 shost_printk(KERN_WARNING, phba->shost,
2295 "No Virtual address \n"); 2350 "No Virtual address\n");
2296 2351
2297 pasync_ctx->async_data.handle_base = 2352 pasync_ctx->async_data.handle_base =
2298 mem_descr->mem_array[0].virtual_address; 2353 mem_descr->mem_array[0].virtual_address;
@@ -2364,7 +2419,7 @@ be_sgl_create_contiguous(void *virtual_address,
2364 WARN_ON(!sgl); 2419 WARN_ON(!sgl);
2365 2420
2366 sgl->va = virtual_address; 2421 sgl->va = virtual_address;
2367 sgl->dma = physical_address; 2422 sgl->dma = (unsigned long)physical_address;
2368 sgl->size = length; 2423 sgl->size = length;
2369 2424
2370 return 0; 2425 return 0;
@@ -2447,7 +2502,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
2447 sizeof(struct be_eq_entry), eq_vaddress); 2502 sizeof(struct be_eq_entry), eq_vaddress);
2448 if (ret) { 2503 if (ret) {
2449 shost_printk(KERN_ERR, phba->shost, 2504 shost_printk(KERN_ERR, phba->shost,
2450 "be_fill_queue Failed for EQ \n"); 2505 "be_fill_queue Failed for EQ\n");
2451 goto create_eq_error; 2506 goto create_eq_error;
2452 } 2507 }
2453 2508
@@ -2457,7 +2512,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba,
2457 if (ret) { 2512 if (ret) {
2458 shost_printk(KERN_ERR, phba->shost, 2513 shost_printk(KERN_ERR, phba->shost,
2459 "beiscsi_cmd_eq_create" 2514 "beiscsi_cmd_eq_create"
2460 "Failedfor EQ \n"); 2515 "Failedfor EQ\n");
2461 goto create_eq_error; 2516 goto create_eq_error;
2462 } 2517 }
2463 SE_DEBUG(DBG_LVL_8, "eqid = %d\n", phwi_context->be_eq[i].q.id); 2518 SE_DEBUG(DBG_LVL_8, "eqid = %d\n", phwi_context->be_eq[i].q.id);
@@ -2505,7 +2560,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
2505 sizeof(struct sol_cqe), cq_vaddress); 2560 sizeof(struct sol_cqe), cq_vaddress);
2506 if (ret) { 2561 if (ret) {
2507 shost_printk(KERN_ERR, phba->shost, 2562 shost_printk(KERN_ERR, phba->shost,
2508 "be_fill_queue Failed for ISCSI CQ \n"); 2563 "be_fill_queue Failed for ISCSI CQ\n");
2509 goto create_cq_error; 2564 goto create_cq_error;
2510 } 2565 }
2511 2566
@@ -2515,7 +2570,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba,
2515 if (ret) { 2570 if (ret) {
2516 shost_printk(KERN_ERR, phba->shost, 2571 shost_printk(KERN_ERR, phba->shost,
2517 "beiscsi_cmd_eq_create" 2572 "beiscsi_cmd_eq_create"
2518 "Failed for ISCSI CQ \n"); 2573 "Failed for ISCSI CQ\n");
2519 goto create_cq_error; 2574 goto create_cq_error;
2520 } 2575 }
2521 SE_DEBUG(DBG_LVL_8, "iscsi cq_id is %d for eq_id %d\n", 2576 SE_DEBUG(DBG_LVL_8, "iscsi cq_id is %d for eq_id %d\n",
@@ -2565,7 +2620,8 @@ beiscsi_create_def_hdr(struct beiscsi_hba *phba,
2565 "be_fill_queue Failed for DEF PDU HDR\n"); 2620 "be_fill_queue Failed for DEF PDU HDR\n");
2566 return ret; 2621 return ret;
2567 } 2622 }
2568 mem->dma = mem_descr->mem_array[idx].bus_address.u.a64.address; 2623 mem->dma = (unsigned long)mem_descr->mem_array[idx].
2624 bus_address.u.a64.address;
2569 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq, 2625 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq,
2570 def_pdu_ring_sz, 2626 def_pdu_ring_sz,
2571 phba->params.defpdu_hdr_sz); 2627 phba->params.defpdu_hdr_sz);
@@ -2609,7 +2665,8 @@ beiscsi_create_def_data(struct beiscsi_hba *phba,
2609 "be_fill_queue Failed for DEF PDU DATA\n"); 2665 "be_fill_queue Failed for DEF PDU DATA\n");
2610 return ret; 2666 return ret;
2611 } 2667 }
2612 mem->dma = mem_descr->mem_array[idx].bus_address.u.a64.address; 2668 mem->dma = (unsigned long)mem_descr->mem_array[idx].
2669 bus_address.u.a64.address;
2613 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq, 2670 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq,
2614 def_pdu_ring_sz, 2671 def_pdu_ring_sz,
2615 phba->params.defpdu_data_sz); 2672 phba->params.defpdu_data_sz);
@@ -2623,7 +2680,7 @@ beiscsi_create_def_data(struct beiscsi_hba *phba,
2623 SE_DEBUG(DBG_LVL_8, "iscsi def data id is %d\n", 2680 SE_DEBUG(DBG_LVL_8, "iscsi def data id is %d\n",
2624 phwi_context->be_def_dataq.id); 2681 phwi_context->be_def_dataq.id);
2625 hwi_post_async_buffers(phba, 0); 2682 hwi_post_async_buffers(phba, 0);
2626 SE_DEBUG(DBG_LVL_8, "DEFAULT PDU DATA RING CREATED \n"); 2683 SE_DEBUG(DBG_LVL_8, "DEFAULT PDU DATA RING CREATED\n");
2627 return 0; 2684 return 0;
2628} 2685}
2629 2686
@@ -2655,7 +2712,7 @@ beiscsi_post_pages(struct beiscsi_hba *phba)
2655 } 2712 }
2656 pm_arr++; 2713 pm_arr++;
2657 } 2714 }
2658 SE_DEBUG(DBG_LVL_8, "POSTED PAGES \n"); 2715 SE_DEBUG(DBG_LVL_8, "POSTED PAGES\n");
2659 return 0; 2716 return 0;
2660} 2717}
2661 2718
@@ -2678,7 +2735,7 @@ static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q,
2678 mem->size = len * entry_size; 2735 mem->size = len * entry_size;
2679 mem->va = pci_alloc_consistent(phba->pcidev, mem->size, &mem->dma); 2736 mem->va = pci_alloc_consistent(phba->pcidev, mem->size, &mem->dma);
2680 if (!mem->va) 2737 if (!mem->va)
2681 return -1; 2738 return -ENOMEM;
2682 memset(mem->va, 0, mem->size); 2739 memset(mem->va, 0, mem->size);
2683 return 0; 2740 return 0;
2684} 2741}
@@ -2750,6 +2807,7 @@ beiscsi_create_wrb_rings(struct beiscsi_hba *phba,
2750 if (status != 0) { 2807 if (status != 0) {
2751 shost_printk(KERN_ERR, phba->shost, 2808 shost_printk(KERN_ERR, phba->shost,
2752 "wrbq create failed."); 2809 "wrbq create failed.");
2810 kfree(pwrb_arr);
2753 return status; 2811 return status;
2754 } 2812 }
2755 phwi_ctrlr->wrb_context[i * 2].cid = phwi_context->be_wrbq[i]. 2813 phwi_ctrlr->wrb_context[i * 2].cid = phwi_context->be_wrbq[i].
@@ -2873,7 +2931,7 @@ mcc_cq_destroy:
2873mcc_cq_free: 2931mcc_cq_free:
2874 be_queue_free(phba, cq); 2932 be_queue_free(phba, cq);
2875err: 2933err:
2876 return -1; 2934 return -ENOMEM;
2877} 2935}
2878 2936
2879static int find_num_cpus(void) 2937static int find_num_cpus(void)
@@ -2884,7 +2942,7 @@ static int find_num_cpus(void)
2884 if (num_cpus >= MAX_CPUS) 2942 if (num_cpus >= MAX_CPUS)
2885 num_cpus = MAX_CPUS - 1; 2943 num_cpus = MAX_CPUS - 1;
2886 2944
2887 SE_DEBUG(DBG_LVL_8, "num_cpus = %d \n", num_cpus); 2945 SE_DEBUG(DBG_LVL_8, "num_cpus = %d\n", num_cpus);
2888 return num_cpus; 2946 return num_cpus;
2889} 2947}
2890 2948
@@ -2907,7 +2965,7 @@ static int hwi_init_port(struct beiscsi_hba *phba)
2907 2965
2908 status = beiscsi_create_eqs(phba, phwi_context); 2966 status = beiscsi_create_eqs(phba, phwi_context);
2909 if (status != 0) { 2967 if (status != 0) {
2910 shost_printk(KERN_ERR, phba->shost, "EQ not created \n"); 2968 shost_printk(KERN_ERR, phba->shost, "EQ not created\n");
2911 goto error; 2969 goto error;
2912 } 2970 }
2913 2971
@@ -2918,7 +2976,7 @@ static int hwi_init_port(struct beiscsi_hba *phba)
2918 status = mgmt_check_supported_fw(ctrl, phba); 2976 status = mgmt_check_supported_fw(ctrl, phba);
2919 if (status != 0) { 2977 if (status != 0) {
2920 shost_printk(KERN_ERR, phba->shost, 2978 shost_printk(KERN_ERR, phba->shost,
2921 "Unsupported fw version \n"); 2979 "Unsupported fw version\n");
2922 goto error; 2980 goto error;
2923 } 2981 }
2924 2982
@@ -2974,7 +3032,7 @@ static int hwi_init_controller(struct beiscsi_hba *phba)
2974 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { 3032 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) {
2975 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> 3033 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba->
2976 init_mem[HWI_MEM_ADDN_CONTEXT].mem_array[0].virtual_address; 3034 init_mem[HWI_MEM_ADDN_CONTEXT].mem_array[0].virtual_address;
2977 SE_DEBUG(DBG_LVL_8, " phwi_ctrlr->phwi_ctxt=%p \n", 3035 SE_DEBUG(DBG_LVL_8, " phwi_ctrlr->phwi_ctxt=%p\n",
2978 phwi_ctrlr->phwi_ctxt); 3036 phwi_ctrlr->phwi_ctxt);
2979 } else { 3037 } else {
2980 shost_printk(KERN_ERR, phba->shost, 3038 shost_printk(KERN_ERR, phba->shost,
@@ -3007,8 +3065,8 @@ static void beiscsi_free_mem(struct beiscsi_hba *phba)
3007 pci_free_consistent(phba->pcidev, 3065 pci_free_consistent(phba->pcidev,
3008 mem_descr->mem_array[j - 1].size, 3066 mem_descr->mem_array[j - 1].size,
3009 mem_descr->mem_array[j - 1].virtual_address, 3067 mem_descr->mem_array[j - 1].virtual_address,
3010 mem_descr->mem_array[j - 1].bus_address. 3068 (unsigned long)mem_descr->mem_array[j - 1].
3011 u.a64.address); 3069 bus_address.u.a64.address);
3012 } 3070 }
3013 kfree(mem_descr->mem_array); 3071 kfree(mem_descr->mem_array);
3014 mem_descr++; 3072 mem_descr++;
@@ -3024,7 +3082,7 @@ static int beiscsi_init_controller(struct beiscsi_hba *phba)
3024 ret = beiscsi_get_memory(phba); 3082 ret = beiscsi_get_memory(phba);
3025 if (ret < 0) { 3083 if (ret < 0) {
3026 shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe -" 3084 shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe -"
3027 "Failed in beiscsi_alloc_memory \n"); 3085 "Failed in beiscsi_alloc_memory\n");
3028 return ret; 3086 return ret;
3029 } 3087 }
3030 3088
@@ -3101,12 +3159,12 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba)
3101 } 3159 }
3102 SE_DEBUG(DBG_LVL_8, 3160 SE_DEBUG(DBG_LVL_8,
3103 "phba->io_sgl_hndl_avbl=%d" 3161 "phba->io_sgl_hndl_avbl=%d"
3104 "phba->eh_sgl_hndl_avbl=%d \n", 3162 "phba->eh_sgl_hndl_avbl=%d\n",
3105 phba->io_sgl_hndl_avbl, 3163 phba->io_sgl_hndl_avbl,
3106 phba->eh_sgl_hndl_avbl); 3164 phba->eh_sgl_hndl_avbl);
3107 mem_descr_sg = phba->init_mem; 3165 mem_descr_sg = phba->init_mem;
3108 mem_descr_sg += HWI_MEM_SGE; 3166 mem_descr_sg += HWI_MEM_SGE;
3109 SE_DEBUG(DBG_LVL_8, "\n mem_descr_sg->num_elements=%d \n", 3167 SE_DEBUG(DBG_LVL_8, "\n mem_descr_sg->num_elements=%d\n",
3110 mem_descr_sg->num_elements); 3168 mem_descr_sg->num_elements);
3111 arr_index = 0; 3169 arr_index = 0;
3112 idx = 0; 3170 idx = 0;
@@ -3155,7 +3213,7 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
3155 if (!phba->ep_array) { 3213 if (!phba->ep_array) {
3156 shost_printk(KERN_ERR, phba->shost, 3214 shost_printk(KERN_ERR, phba->shost,
3157 "Failed to allocate memory in " 3215 "Failed to allocate memory in "
3158 "hba_setup_cid_tbls \n"); 3216 "hba_setup_cid_tbls\n");
3159 kfree(phba->cid_array); 3217 kfree(phba->cid_array);
3160 return -ENOMEM; 3218 return -ENOMEM;
3161 } 3219 }
@@ -3168,7 +3226,7 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
3168 return 0; 3226 return 0;
3169} 3227}
3170 3228
3171static unsigned char hwi_enable_intr(struct beiscsi_hba *phba) 3229static void hwi_enable_intr(struct beiscsi_hba *phba)
3172{ 3230{
3173 struct be_ctrl_info *ctrl = &phba->ctrl; 3231 struct be_ctrl_info *ctrl = &phba->ctrl;
3174 struct hwi_controller *phwi_ctrlr; 3232 struct hwi_controller *phwi_ctrlr;
@@ -3184,26 +3242,25 @@ static unsigned char hwi_enable_intr(struct beiscsi_hba *phba)
3184 addr = (u8 __iomem *) ((u8 __iomem *) ctrl->pcicfg + 3242 addr = (u8 __iomem *) ((u8 __iomem *) ctrl->pcicfg +
3185 PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET); 3243 PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET);
3186 reg = ioread32(addr); 3244 reg = ioread32(addr);
3187 SE_DEBUG(DBG_LVL_8, "reg =x%08x \n", reg); 3245 SE_DEBUG(DBG_LVL_8, "reg =x%08x\n", reg);
3188 3246
3189 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 3247 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
3190 if (!enabled) { 3248 if (!enabled) {
3191 reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 3249 reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
3192 SE_DEBUG(DBG_LVL_8, "reg =x%08x addr=%p \n", reg, addr); 3250 SE_DEBUG(DBG_LVL_8, "reg =x%08x addr=%p\n", reg, addr);
3193 iowrite32(reg, addr); 3251 iowrite32(reg, addr);
3194 if (!phba->msix_enabled) { 3252 if (!phba->msix_enabled) {
3195 eq = &phwi_context->be_eq[0].q; 3253 eq = &phwi_context->be_eq[0].q;
3196 SE_DEBUG(DBG_LVL_8, "eq->id=%d \n", eq->id); 3254 SE_DEBUG(DBG_LVL_8, "eq->id=%d\n", eq->id);
3197 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); 3255 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1);
3198 } else { 3256 } else {
3199 for (i = 0; i <= phba->num_cpus; i++) { 3257 for (i = 0; i <= phba->num_cpus; i++) {
3200 eq = &phwi_context->be_eq[i].q; 3258 eq = &phwi_context->be_eq[i].q;
3201 SE_DEBUG(DBG_LVL_8, "eq->id=%d \n", eq->id); 3259 SE_DEBUG(DBG_LVL_8, "eq->id=%d\n", eq->id);
3202 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); 3260 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1);
3203 } 3261 }
3204 } 3262 }
3205 } 3263 }
3206 return true;
3207} 3264}
3208 3265
3209static void hwi_disable_intr(struct beiscsi_hba *phba) 3266static void hwi_disable_intr(struct beiscsi_hba *phba)
@@ -3219,7 +3276,7 @@ static void hwi_disable_intr(struct beiscsi_hba *phba)
3219 iowrite32(reg, addr); 3276 iowrite32(reg, addr);
3220 } else 3277 } else
3221 shost_printk(KERN_WARNING, phba->shost, 3278 shost_printk(KERN_WARNING, phba->shost,
3222 "In hwi_disable_intr, Already Disabled \n"); 3279 "In hwi_disable_intr, Already Disabled\n");
3223} 3280}
3224 3281
3225static int beiscsi_init_port(struct beiscsi_hba *phba) 3282static int beiscsi_init_port(struct beiscsi_hba *phba)
@@ -3230,14 +3287,14 @@ static int beiscsi_init_port(struct beiscsi_hba *phba)
3230 if (ret < 0) { 3287 if (ret < 0) {
3231 shost_printk(KERN_ERR, phba->shost, 3288 shost_printk(KERN_ERR, phba->shost,
3232 "beiscsi_dev_probe - Failed in" 3289 "beiscsi_dev_probe - Failed in"
3233 "beiscsi_init_controller \n"); 3290 "beiscsi_init_controller\n");
3234 return ret; 3291 return ret;
3235 } 3292 }
3236 ret = beiscsi_init_sgl_handle(phba); 3293 ret = beiscsi_init_sgl_handle(phba);
3237 if (ret < 0) { 3294 if (ret < 0) {
3238 shost_printk(KERN_ERR, phba->shost, 3295 shost_printk(KERN_ERR, phba->shost,
3239 "beiscsi_dev_probe - Failed in" 3296 "beiscsi_dev_probe - Failed in"
3240 "beiscsi_init_sgl_handle \n"); 3297 "beiscsi_init_sgl_handle\n");
3241 goto do_cleanup_ctrlr; 3298 goto do_cleanup_ctrlr;
3242 } 3299 }
3243 3300
@@ -3291,12 +3348,12 @@ static void hwi_purge_eq(struct beiscsi_hba *phba)
3291 3348
3292static void beiscsi_clean_port(struct beiscsi_hba *phba) 3349static void beiscsi_clean_port(struct beiscsi_hba *phba)
3293{ 3350{
3294 unsigned char mgmt_status; 3351 int mgmt_status;
3295 3352
3296 mgmt_status = mgmt_epfw_cleanup(phba, CMD_CONNECTION_CHUTE_0); 3353 mgmt_status = mgmt_epfw_cleanup(phba, CMD_CONNECTION_CHUTE_0);
3297 if (mgmt_status) 3354 if (mgmt_status)
3298 shost_printk(KERN_WARNING, phba->shost, 3355 shost_printk(KERN_WARNING, phba->shost,
3299 "mgmt_epfw_cleanup FAILED \n"); 3356 "mgmt_epfw_cleanup FAILED\n");
3300 3357
3301 hwi_purge_eq(phba); 3358 hwi_purge_eq(phba);
3302 hwi_cleanup(phba); 3359 hwi_cleanup(phba);
@@ -3428,14 +3485,12 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
3428 return -ENOMEM; 3485 return -ENOMEM;
3429 io_task->bhs_pa.u.a64.address = paddr; 3486 io_task->bhs_pa.u.a64.address = paddr;
3430 io_task->libiscsi_itt = (itt_t)task->itt; 3487 io_task->libiscsi_itt = (itt_t)task->itt;
3431 io_task->pwrb_handle = alloc_wrb_handle(phba,
3432 beiscsi_conn->beiscsi_conn_cid -
3433 phba->fw_config.iscsi_cid_start
3434 );
3435 io_task->conn = beiscsi_conn; 3488 io_task->conn = beiscsi_conn;
3436 3489
3437 task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr; 3490 task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr;
3438 task->hdr_max = sizeof(struct be_cmd_bhs); 3491 task->hdr_max = sizeof(struct be_cmd_bhs);
3492 io_task->psgl_handle = NULL;
3493 io_task->psgl_handle = NULL;
3439 3494
3440 if (task->sc) { 3495 if (task->sc) {
3441 spin_lock(&phba->io_sgl_lock); 3496 spin_lock(&phba->io_sgl_lock);
@@ -3443,6 +3498,11 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
3443 spin_unlock(&phba->io_sgl_lock); 3498 spin_unlock(&phba->io_sgl_lock);
3444 if (!io_task->psgl_handle) 3499 if (!io_task->psgl_handle)
3445 goto free_hndls; 3500 goto free_hndls;
3501 io_task->pwrb_handle = alloc_wrb_handle(phba,
3502 beiscsi_conn->beiscsi_conn_cid -
3503 phba->fw_config.iscsi_cid_start);
3504 if (!io_task->pwrb_handle)
3505 goto free_io_hndls;
3446 } else { 3506 } else {
3447 io_task->scsi_cmnd = NULL; 3507 io_task->scsi_cmnd = NULL;
3448 if ((opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) { 3508 if ((opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) {
@@ -3457,9 +3517,20 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
3457 beiscsi_conn->login_in_progress = 1; 3517 beiscsi_conn->login_in_progress = 1;
3458 beiscsi_conn->plogin_sgl_handle = 3518 beiscsi_conn->plogin_sgl_handle =
3459 io_task->psgl_handle; 3519 io_task->psgl_handle;
3520 io_task->pwrb_handle =
3521 alloc_wrb_handle(phba,
3522 beiscsi_conn->beiscsi_conn_cid -
3523 phba->fw_config.iscsi_cid_start);
3524 if (!io_task->pwrb_handle)
3525 goto free_io_hndls;
3526 beiscsi_conn->plogin_wrb_handle =
3527 io_task->pwrb_handle;
3528
3460 } else { 3529 } else {
3461 io_task->psgl_handle = 3530 io_task->psgl_handle =
3462 beiscsi_conn->plogin_sgl_handle; 3531 beiscsi_conn->plogin_sgl_handle;
3532 io_task->pwrb_handle =
3533 beiscsi_conn->plogin_wrb_handle;
3463 } 3534 }
3464 } else { 3535 } else {
3465 spin_lock(&phba->mgmt_sgl_lock); 3536 spin_lock(&phba->mgmt_sgl_lock);
@@ -3467,6 +3538,13 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
3467 spin_unlock(&phba->mgmt_sgl_lock); 3538 spin_unlock(&phba->mgmt_sgl_lock);
3468 if (!io_task->psgl_handle) 3539 if (!io_task->psgl_handle)
3469 goto free_hndls; 3540 goto free_hndls;
3541 io_task->pwrb_handle =
3542 alloc_wrb_handle(phba,
3543 beiscsi_conn->beiscsi_conn_cid -
3544 phba->fw_config.iscsi_cid_start);
3545 if (!io_task->pwrb_handle)
3546 goto free_mgmt_hndls;
3547
3470 } 3548 }
3471 } 3549 }
3472 itt = (itt_t) cpu_to_be32(((unsigned int)io_task->pwrb_handle-> 3550 itt = (itt_t) cpu_to_be32(((unsigned int)io_task->pwrb_handle->
@@ -3477,16 +3555,26 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
3477 io_task->cmd_bhs->iscsi_hdr.itt = itt; 3555 io_task->cmd_bhs->iscsi_hdr.itt = itt;
3478 return 0; 3556 return 0;
3479 3557
3558free_io_hndls:
3559 spin_lock(&phba->io_sgl_lock);
3560 free_io_sgl_handle(phba, io_task->psgl_handle);
3561 spin_unlock(&phba->io_sgl_lock);
3562 goto free_hndls;
3563free_mgmt_hndls:
3564 spin_lock(&phba->mgmt_sgl_lock);
3565 free_mgmt_sgl_handle(phba, io_task->psgl_handle);
3566 spin_unlock(&phba->mgmt_sgl_lock);
3480free_hndls: 3567free_hndls:
3481 phwi_ctrlr = phba->phwi_ctrlr; 3568 phwi_ctrlr = phba->phwi_ctrlr;
3482 pwrb_context = &phwi_ctrlr->wrb_context[ 3569 pwrb_context = &phwi_ctrlr->wrb_context[
3483 beiscsi_conn->beiscsi_conn_cid - 3570 beiscsi_conn->beiscsi_conn_cid -
3484 phba->fw_config.iscsi_cid_start]; 3571 phba->fw_config.iscsi_cid_start];
3485 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); 3572 if (io_task->pwrb_handle)
3573 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle);
3486 io_task->pwrb_handle = NULL; 3574 io_task->pwrb_handle = NULL;
3487 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, 3575 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
3488 io_task->bhs_pa.u.a64.address); 3576 io_task->bhs_pa.u.a64.address);
3489 SE_DEBUG(DBG_LVL_1, "Alloc of SGL_ICD Failed \n"); 3577 SE_DEBUG(DBG_LVL_1, "Alloc of SGL_ICD Failed\n");
3490 return -ENOMEM; 3578 return -ENOMEM;
3491} 3579}
3492 3580
@@ -3653,7 +3741,7 @@ static int beiscsi_mtask(struct iscsi_task *task)
3653 break; 3741 break;
3654 3742
3655 default: 3743 default:
3656 SE_DEBUG(DBG_LVL_1, "opcode =%d Not supported \n", 3744 SE_DEBUG(DBG_LVL_1, "opcode =%d Not supported\n",
3657 task->hdr->opcode & ISCSI_OPCODE_MASK); 3745 task->hdr->opcode & ISCSI_OPCODE_MASK);
3658 return -EINVAL; 3746 return -EINVAL;
3659 } 3747 }
@@ -3689,13 +3777,11 @@ static int beiscsi_task_xmit(struct iscsi_task *task)
3689 SE_DEBUG(DBG_LVL_1, " scsi_dma_map Failed\n") 3777 SE_DEBUG(DBG_LVL_1, " scsi_dma_map Failed\n")
3690 return num_sg; 3778 return num_sg;
3691 } 3779 }
3692 SE_DEBUG(DBG_LVL_4, "xferlen=0x%08x scmd=%p num_sg=%d sernum=%lu\n",
3693 (scsi_bufflen(sc)), sc, num_sg, sc->serial_number);
3694 xferlen = scsi_bufflen(sc); 3780 xferlen = scsi_bufflen(sc);
3695 sg = scsi_sglist(sc); 3781 sg = scsi_sglist(sc);
3696 if (sc->sc_data_direction == DMA_TO_DEVICE) { 3782 if (sc->sc_data_direction == DMA_TO_DEVICE) {
3697 writedir = 1; 3783 writedir = 1;
3698 SE_DEBUG(DBG_LVL_4, "task->imm_count=0x%08x \n", 3784 SE_DEBUG(DBG_LVL_4, "task->imm_count=0x%08x\n",
3699 task->imm_count); 3785 task->imm_count);
3700 } else 3786 } else
3701 writedir = 0; 3787 writedir = 0;
@@ -3709,10 +3795,12 @@ static void beiscsi_remove(struct pci_dev *pcidev)
3709 struct hwi_context_memory *phwi_context; 3795 struct hwi_context_memory *phwi_context;
3710 struct be_eq_obj *pbe_eq; 3796 struct be_eq_obj *pbe_eq;
3711 unsigned int i, msix_vec; 3797 unsigned int i, msix_vec;
3798 u8 *real_offset = 0;
3799 u32 value = 0;
3712 3800
3713 phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev); 3801 phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev);
3714 if (!phba) { 3802 if (!phba) {
3715 dev_err(&pcidev->dev, "beiscsi_remove called with no phba \n"); 3803 dev_err(&pcidev->dev, "beiscsi_remove called with no phba\n");
3716 return; 3804 return;
3717 } 3805 }
3718 3806
@@ -3737,6 +3825,14 @@ static void beiscsi_remove(struct pci_dev *pcidev)
3737 3825
3738 beiscsi_clean_port(phba); 3826 beiscsi_clean_port(phba);
3739 beiscsi_free_mem(phba); 3827 beiscsi_free_mem(phba);
3828 real_offset = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE;
3829
3830 value = readl((void *)real_offset);
3831
3832 if (value & 0x00010000) {
3833 value &= 0xfffeffff;
3834 writel(value, (void *)real_offset);
3835 }
3740 beiscsi_unmap_pci_function(phba); 3836 beiscsi_unmap_pci_function(phba);
3741 pci_free_consistent(phba->pcidev, 3837 pci_free_consistent(phba->pcidev,
3742 phba->ctrl.mbox_mem_alloced.size, 3838 phba->ctrl.mbox_mem_alloced.size,
@@ -3769,19 +3865,21 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
3769 struct hwi_controller *phwi_ctrlr; 3865 struct hwi_controller *phwi_ctrlr;
3770 struct hwi_context_memory *phwi_context; 3866 struct hwi_context_memory *phwi_context;
3771 struct be_eq_obj *pbe_eq; 3867 struct be_eq_obj *pbe_eq;
3772 int ret, msix_vec, num_cpus, i; 3868 int ret, num_cpus, i;
3869 u8 *real_offset = 0;
3870 u32 value = 0;
3773 3871
3774 ret = beiscsi_enable_pci(pcidev); 3872 ret = beiscsi_enable_pci(pcidev);
3775 if (ret < 0) { 3873 if (ret < 0) {
3776 shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-" 3874 dev_err(&pcidev->dev, "beiscsi_dev_probe-"
3777 "Failed to enable pci device \n"); 3875 " Failed to enable pci device\n");
3778 return ret; 3876 return ret;
3779 } 3877 }
3780 3878
3781 phba = beiscsi_hba_alloc(pcidev); 3879 phba = beiscsi_hba_alloc(pcidev);
3782 if (!phba) { 3880 if (!phba) {
3783 dev_err(&pcidev->dev, "beiscsi_dev_probe-" 3881 dev_err(&pcidev->dev, "beiscsi_dev_probe-"
3784 " Failed in beiscsi_hba_alloc \n"); 3882 " Failed in beiscsi_hba_alloc\n");
3785 goto disable_pci; 3883 goto disable_pci;
3786 } 3884 }
3787 3885
@@ -3804,7 +3902,7 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
3804 else 3902 else
3805 num_cpus = 1; 3903 num_cpus = 1;
3806 phba->num_cpus = num_cpus; 3904 phba->num_cpus = num_cpus;
3807 SE_DEBUG(DBG_LVL_8, "num_cpus = %d \n", phba->num_cpus); 3905 SE_DEBUG(DBG_LVL_8, "num_cpus = %d\n", phba->num_cpus);
3808 3906
3809 if (enable_msix) 3907 if (enable_msix)
3810 beiscsi_msix_enable(phba); 3908 beiscsi_msix_enable(phba);
@@ -3815,6 +3913,33 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
3815 goto hba_free; 3913 goto hba_free;
3816 } 3914 }
3817 3915
3916 if (!num_hba) {
3917 real_offset = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE;
3918 value = readl((void *)real_offset);
3919 if (value & 0x00010000) {
3920 gcrashmode++;
3921 shost_printk(KERN_ERR, phba->shost,
3922 "Loading Driver in crashdump mode\n");
3923 ret = beiscsi_pci_soft_reset(phba);
3924 if (ret) {
3925 shost_printk(KERN_ERR, phba->shost,
3926 "Reset Failed. Aborting Crashdump\n");
3927 goto hba_free;
3928 }
3929 ret = be_chk_reset_complete(phba);
3930 if (ret) {
3931 shost_printk(KERN_ERR, phba->shost,
3932 "Failed to get out of reset."
3933 "Aborting Crashdump\n");
3934 goto hba_free;
3935 }
3936 } else {
3937 value |= 0x00010000;
3938 writel(value, (void *)real_offset);
3939 num_hba++;
3940 }
3941 }
3942
3818 spin_lock_init(&phba->io_sgl_lock); 3943 spin_lock_init(&phba->io_sgl_lock);
3819 spin_lock_init(&phba->mgmt_sgl_lock); 3944 spin_lock_init(&phba->mgmt_sgl_lock);
3820 spin_lock_init(&phba->isr_lock); 3945 spin_lock_init(&phba->isr_lock);
@@ -3870,25 +3995,10 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
3870 "Failed to beiscsi_init_irqs\n"); 3995 "Failed to beiscsi_init_irqs\n");
3871 goto free_blkenbld; 3996 goto free_blkenbld;
3872 } 3997 }
3873 ret = hwi_enable_intr(phba); 3998 hwi_enable_intr(phba);
3874 if (ret < 0) { 3999 SE_DEBUG(DBG_LVL_8, "\n\n\n SUCCESS - DRIVER LOADED\n\n\n");
3875 shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-"
3876 "Failed to hwi_enable_intr\n");
3877 goto free_ctrlr;
3878 }
3879 SE_DEBUG(DBG_LVL_8, "\n\n\n SUCCESS - DRIVER LOADED \n\n\n");
3880 return 0; 4000 return 0;
3881 4001
3882free_ctrlr:
3883 if (phba->msix_enabled) {
3884 for (i = 0; i <= phba->num_cpus; i++) {
3885 msix_vec = phba->msix_entries[i].vector;
3886 free_irq(msix_vec, &phwi_context->be_eq[i]);
3887 }
3888 } else
3889 if (phba->pcidev->irq)
3890 free_irq(phba->pcidev->irq, phba);
3891 pci_disable_msix(phba->pcidev);
3892free_blkenbld: 4002free_blkenbld:
3893 destroy_workqueue(phba->wq); 4003 destroy_workqueue(phba->wq);
3894 if (blk_iopoll_enabled) 4004 if (blk_iopoll_enabled)
@@ -3900,12 +4010,23 @@ free_twq:
3900 beiscsi_clean_port(phba); 4010 beiscsi_clean_port(phba);
3901 beiscsi_free_mem(phba); 4011 beiscsi_free_mem(phba);
3902free_port: 4012free_port:
4013 real_offset = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE;
4014
4015 value = readl((void *)real_offset);
4016
4017 if (value & 0x00010000) {
4018 value &= 0xfffeffff;
4019 writel(value, (void *)real_offset);
4020 }
4021
3903 pci_free_consistent(phba->pcidev, 4022 pci_free_consistent(phba->pcidev,
3904 phba->ctrl.mbox_mem_alloced.size, 4023 phba->ctrl.mbox_mem_alloced.size,
3905 phba->ctrl.mbox_mem_alloced.va, 4024 phba->ctrl.mbox_mem_alloced.va,
3906 phba->ctrl.mbox_mem_alloced.dma); 4025 phba->ctrl.mbox_mem_alloced.dma);
3907 beiscsi_unmap_pci_function(phba); 4026 beiscsi_unmap_pci_function(phba);
3908hba_free: 4027hba_free:
4028 if (phba->msix_enabled)
4029 pci_disable_msix(phba->pcidev);
3909 iscsi_host_remove(phba->shost); 4030 iscsi_host_remove(phba->shost);
3910 pci_dev_put(phba->pcidev); 4031 pci_dev_put(phba->pcidev);
3911 iscsi_host_free(phba->shost); 4032 iscsi_host_free(phba->shost);
@@ -3955,7 +4076,7 @@ struct iscsi_transport beiscsi_iscsi_transport = {
3955 .get_session_param = iscsi_session_get_param, 4076 .get_session_param = iscsi_session_get_param,
3956 .get_host_param = beiscsi_get_host_param, 4077 .get_host_param = beiscsi_get_host_param,
3957 .start_conn = beiscsi_conn_start, 4078 .start_conn = beiscsi_conn_start,
3958 .stop_conn = beiscsi_conn_stop, 4079 .stop_conn = iscsi_conn_stop,
3959 .send_pdu = iscsi_conn_send_pdu, 4080 .send_pdu = iscsi_conn_send_pdu,
3960 .xmit_task = beiscsi_task_xmit, 4081 .xmit_task = beiscsi_task_xmit,
3961 .cleanup_task = beiscsi_cleanup_task, 4082 .cleanup_task = beiscsi_cleanup_task,
@@ -3988,7 +4109,7 @@ static int __init beiscsi_module_init(void)
3988 "transport.\n"); 4109 "transport.\n");
3989 return -ENOMEM; 4110 return -ENOMEM;
3990 } 4111 }
3991 SE_DEBUG(DBG_LVL_8, "In beiscsi_module_init, tt=%p \n", 4112 SE_DEBUG(DBG_LVL_8, "In beiscsi_module_init, tt=%p\n",
3992 &beiscsi_iscsi_transport); 4113 &beiscsi_iscsi_transport);
3993 4114
3994 ret = pci_register_driver(&beiscsi_pci_driver); 4115 ret = pci_register_driver(&beiscsi_pci_driver);
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 87ec21280a37..c643bb3736fc 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/if_ether.h>
26#include <linux/in.h> 27#include <linux/in.h>
27#include <scsi/scsi.h> 28#include <scsi/scsi.h>
28#include <scsi/scsi_cmnd.h> 29#include <scsi/scsi_cmnd.h>
@@ -39,7 +40,7 @@
39 "Linux iSCSI Driver version" BUILD_STR 40 "Linux iSCSI Driver version" BUILD_STR
40#define DRV_DESC BE_NAME " " "Driver" 41#define DRV_DESC BE_NAME " " "Driver"
41 42
42#define BE_VENDOR_ID 0x19A2 43#define BE_VENDOR_ID 0x19A2
43/* DEVICE ID's for BE2 */ 44/* DEVICE ID's for BE2 */
44#define BE_DEVICE_ID1 0x212 45#define BE_DEVICE_ID1 0x212
45#define OC_DEVICE_ID1 0x702 46#define OC_DEVICE_ID1 0x702
@@ -68,8 +69,15 @@
68#define BEISCSI_NUM_MAX_LUN 256 /* scsi_host->max_lun */ 69#define BEISCSI_NUM_MAX_LUN 256 /* scsi_host->max_lun */
69#define BEISCSI_NUM_DEVICES_SUPPORTED 0x01 70#define BEISCSI_NUM_DEVICES_SUPPORTED 0x01
70#define BEISCSI_MAX_FRAGS_INIT 192 71#define BEISCSI_MAX_FRAGS_INIT 192
71#define BE_NUM_MSIX_ENTRIES 1 72#define BE_NUM_MSIX_ENTRIES 1
72#define MPU_EP_SEMAPHORE 0xac 73
74#define MPU_EP_CONTROL 0
75#define MPU_EP_SEMAPHORE 0xac
76#define BE2_SOFT_RESET 0x5c
77#define BE2_PCI_ONLINE0 0xb0
78#define BE2_PCI_ONLINE1 0xb4
79#define BE2_SET_RESET 0x80
80#define BE2_MPU_IRAM_ONLINE 0x00000080
73 81
74#define BE_SENSE_INFO_SIZE 258 82#define BE_SENSE_INFO_SIZE 258
75#define BE_ISCSI_PDU_HEADER_SIZE 64 83#define BE_ISCSI_PDU_HEADER_SIZE 64
@@ -105,7 +113,7 @@ do { \
105#define HWI_GET_ASYNC_PDU_CTX(phwi) (phwi->phwi_ctxt->pasync_ctx) 113#define HWI_GET_ASYNC_PDU_CTX(phwi) (phwi->phwi_ctxt->pasync_ctx)
106 114
107/********* Memory BAR register ************/ 115/********* Memory BAR register ************/
108#define PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET 0xfc 116#define PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET 0xfc
109/** 117/**
110 * Host Interrupt Enable, if set interrupts are enabled although "PCI Interrupt 118 * Host Interrupt Enable, if set interrupts are enabled although "PCI Interrupt
111 * Disable" may still globally block interrupts in addition to individual 119 * Disable" may still globally block interrupts in addition to individual
@@ -116,7 +124,7 @@ do { \
116#define MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK (1 << 29) /* bit 29 */ 124#define MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK (1 << 29) /* bit 29 */
117 125
118/********* ISR0 Register offset **********/ 126/********* ISR0 Register offset **********/
119#define CEV_ISR0_OFFSET 0xC18 127#define CEV_ISR0_OFFSET 0xC18
120#define CEV_ISR_SIZE 4 128#define CEV_ISR_SIZE 4
121 129
122/** 130/**
@@ -139,12 +147,12 @@ do { \
139#define DB_EQ_REARM_SHIFT (29) /* bit 29 */ 147#define DB_EQ_REARM_SHIFT (29) /* bit 29 */
140 148
141/********* Compl Q door bell *************/ 149/********* Compl Q door bell *************/
142#define DB_CQ_OFFSET 0x120 150#define DB_CQ_OFFSET 0x120
143#define DB_CQ_RING_ID_MASK 0x3FF /* bits 0 - 9 */ 151#define DB_CQ_RING_ID_MASK 0x3FF /* bits 0 - 9 */
144/* Number of event entries processed */ 152/* Number of event entries processed */
145#define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */ 153#define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */
146/* Rearm bit */ 154/* Rearm bit */
147#define DB_CQ_REARM_SHIFT (29) /* bit 29 */ 155#define DB_CQ_REARM_SHIFT (29) /* bit 29 */
148 156
149#define GET_HWI_CONTROLLER_WS(pc) (pc->phwi_ctrlr) 157#define GET_HWI_CONTROLLER_WS(pc) (pc->phwi_ctrlr)
150#define HWI_GET_DEF_BUFQ_ID(pc) (((struct hwi_controller *)\ 158#define HWI_GET_DEF_BUFQ_ID(pc) (((struct hwi_controller *)\
@@ -161,12 +169,12 @@ enum be_mem_enum {
161 HWI_MEM_WRBH, 169 HWI_MEM_WRBH,
162 HWI_MEM_SGLH, 170 HWI_MEM_SGLH,
163 HWI_MEM_SGE, 171 HWI_MEM_SGE,
164 HWI_MEM_ASYNC_HEADER_BUF, /* 5 */ 172 HWI_MEM_ASYNC_HEADER_BUF, /* 5 */
165 HWI_MEM_ASYNC_DATA_BUF, 173 HWI_MEM_ASYNC_DATA_BUF,
166 HWI_MEM_ASYNC_HEADER_RING, 174 HWI_MEM_ASYNC_HEADER_RING,
167 HWI_MEM_ASYNC_DATA_RING, 175 HWI_MEM_ASYNC_DATA_RING,
168 HWI_MEM_ASYNC_HEADER_HANDLE, 176 HWI_MEM_ASYNC_HEADER_HANDLE,
169 HWI_MEM_ASYNC_DATA_HANDLE, /* 10 */ 177 HWI_MEM_ASYNC_DATA_HANDLE, /* 10 */
170 HWI_MEM_ASYNC_PDU_CONTEXT, 178 HWI_MEM_ASYNC_PDU_CONTEXT,
171 ISCSI_MEM_GLOBAL_HEADER, 179 ISCSI_MEM_GLOBAL_HEADER,
172 SE_MEM_MAX 180 SE_MEM_MAX
@@ -352,6 +360,7 @@ struct beiscsi_conn {
352 u32 beiscsi_conn_cid; 360 u32 beiscsi_conn_cid;
353 struct beiscsi_endpoint *ep; 361 struct beiscsi_endpoint *ep;
354 unsigned short login_in_progress; 362 unsigned short login_in_progress;
363 struct wrb_handle *plogin_wrb_handle;
355 struct sgl_handle *plogin_sgl_handle; 364 struct sgl_handle *plogin_sgl_handle;
356 struct beiscsi_session *beiscsi_sess; 365 struct beiscsi_session *beiscsi_sess;
357 struct iscsi_task *task; 366 struct iscsi_task *task;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 350cbeaae160..3f3fab91a7d1 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -21,7 +21,7 @@
21#include "be_mgmt.h" 21#include "be_mgmt.h"
22#include "be_iscsi.h" 22#include "be_iscsi.h"
23 23
24unsigned char mgmt_get_fw_config(struct be_ctrl_info *ctrl, 24int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
25 struct beiscsi_hba *phba) 25 struct beiscsi_hba *phba)
26{ 26{
27 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); 27 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);
@@ -50,7 +50,7 @@ unsigned char mgmt_get_fw_config(struct be_ctrl_info *ctrl,
50 pfw_cfg->ulp[0].sq_count; 50 pfw_cfg->ulp[0].sq_count;
51 if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) { 51 if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) {
52 SE_DEBUG(DBG_LVL_8, 52 SE_DEBUG(DBG_LVL_8,
53 "FW reported MAX CXNS as %d \t" 53 "FW reported MAX CXNS as %d\t"
54 "Max Supported = %d.\n", 54 "Max Supported = %d.\n",
55 phba->fw_config.iscsi_cid_count, 55 phba->fw_config.iscsi_cid_count,
56 BE2_MAX_SESSIONS); 56 BE2_MAX_SESSIONS);
@@ -58,14 +58,14 @@ unsigned char mgmt_get_fw_config(struct be_ctrl_info *ctrl,
58 } 58 }
59 } else { 59 } else {
60 shost_printk(KERN_WARNING, phba->shost, 60 shost_printk(KERN_WARNING, phba->shost,
61 "Failed in mgmt_get_fw_config \n"); 61 "Failed in mgmt_get_fw_config\n");
62 } 62 }
63 63
64 spin_unlock(&ctrl->mbox_lock); 64 spin_unlock(&ctrl->mbox_lock);
65 return status; 65 return status;
66} 66}
67 67
68unsigned char mgmt_check_supported_fw(struct be_ctrl_info *ctrl, 68int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
69 struct beiscsi_hba *phba) 69 struct beiscsi_hba *phba)
70{ 70{
71 struct be_dma_mem nonemb_cmd; 71 struct be_dma_mem nonemb_cmd;
@@ -81,7 +81,7 @@ unsigned char mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
81 SE_DEBUG(DBG_LVL_1, 81 SE_DEBUG(DBG_LVL_1,
82 "Failed to allocate memory for mgmt_check_supported_fw" 82 "Failed to allocate memory for mgmt_check_supported_fw"
83 "\n"); 83 "\n");
84 return -1; 84 return -ENOMEM;
85 } 85 }
86 nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); 86 nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes);
87 req = nonemb_cmd.va; 87 req = nonemb_cmd.va;
@@ -117,8 +117,7 @@ unsigned char mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
117 return status; 117 return status;
118} 118}
119 119
120 120int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute)
121unsigned char mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute)
122{ 121{
123 struct be_ctrl_info *ctrl = &phba->ctrl; 122 struct be_ctrl_info *ctrl = &phba->ctrl;
124 struct be_mcc_wrb *wrb = wrb_from_mccq(phba); 123 struct be_mcc_wrb *wrb = wrb_from_mccq(phba);
@@ -144,11 +143,12 @@ unsigned char mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute)
144 return status; 143 return status;
145} 144}
146 145
147unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, 146unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
148 struct invalidate_command_table *inv_tbl, 147 struct invalidate_command_table *inv_tbl,
149 unsigned int num_invalidate, unsigned int cid) 148 unsigned int num_invalidate, unsigned int cid,
149 struct be_dma_mem *nonemb_cmd)
150
150{ 151{
151 struct be_dma_mem nonemb_cmd;
152 struct be_ctrl_info *ctrl = &phba->ctrl; 152 struct be_ctrl_info *ctrl = &phba->ctrl;
153 struct be_mcc_wrb *wrb; 153 struct be_mcc_wrb *wrb;
154 struct be_sge *sge; 154 struct be_sge *sge;
@@ -162,17 +162,7 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba,
162 return tag; 162 return tag;
163 } 163 }
164 164
165 nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev, 165 req = nonemb_cmd->va;
166 sizeof(struct invalidate_commands_params_in),
167 &nonemb_cmd.dma);
168 if (nonemb_cmd.va == NULL) {
169 SE_DEBUG(DBG_LVL_1,
170 "Failed to allocate memory for mgmt_invalidate_icds\n");
171 spin_unlock(&ctrl->mbox_lock);
172 return 0;
173 }
174 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
175 req = nonemb_cmd.va;
176 memset(req, 0, sizeof(*req)); 166 memset(req, 0, sizeof(*req));
177 wrb = wrb_from_mccq(phba); 167 wrb = wrb_from_mccq(phba);
178 sge = nonembedded_sgl(wrb); 168 sge = nonembedded_sgl(wrb);
@@ -190,19 +180,16 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba,
190 req->icd_count++; 180 req->icd_count++;
191 inv_tbl++; 181 inv_tbl++;
192 } 182 }
193 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma)); 183 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
194 sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); 184 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
195 sge->len = cpu_to_le32(nonemb_cmd.size); 185 sge->len = cpu_to_le32(nonemb_cmd->size);
196 186
197 be_mcc_notify(phba); 187 be_mcc_notify(phba);
198 spin_unlock(&ctrl->mbox_lock); 188 spin_unlock(&ctrl->mbox_lock);
199 if (nonemb_cmd.va)
200 pci_free_consistent(ctrl->pdev, nonemb_cmd.size,
201 nonemb_cmd.va, nonemb_cmd.dma);
202 return tag; 189 return tag;
203} 190}
204 191
205unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba, 192unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
206 struct beiscsi_endpoint *beiscsi_ep, 193 struct beiscsi_endpoint *beiscsi_ep,
207 unsigned short cid, 194 unsigned short cid,
208 unsigned short issue_reset, 195 unsigned short issue_reset,
@@ -239,7 +226,7 @@ unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba,
239 return tag; 226 return tag;
240} 227}
241 228
242unsigned char mgmt_upload_connection(struct beiscsi_hba *phba, 229unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
243 unsigned short cid, unsigned int upload_flag) 230 unsigned short cid, unsigned int upload_flag)
244{ 231{
245 struct be_ctrl_info *ctrl = &phba->ctrl; 232 struct be_ctrl_info *ctrl = &phba->ctrl;
@@ -269,7 +256,9 @@ unsigned char mgmt_upload_connection(struct beiscsi_hba *phba,
269 256
270int mgmt_open_connection(struct beiscsi_hba *phba, 257int mgmt_open_connection(struct beiscsi_hba *phba,
271 struct sockaddr *dst_addr, 258 struct sockaddr *dst_addr,
272 struct beiscsi_endpoint *beiscsi_ep) 259 struct beiscsi_endpoint *beiscsi_ep,
260 struct be_dma_mem *nonemb_cmd)
261
273{ 262{
274 struct hwi_controller *phwi_ctrlr; 263 struct hwi_controller *phwi_ctrlr;
275 struct hwi_context_memory *phwi_context; 264 struct hwi_context_memory *phwi_context;
@@ -285,6 +274,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
285 unsigned int tag = 0; 274 unsigned int tag = 0;
286 unsigned int i; 275 unsigned int i;
287 unsigned short cid = beiscsi_ep->ep_cid; 276 unsigned short cid = beiscsi_ep->ep_cid;
277 struct be_sge *sge;
288 278
289 phwi_ctrlr = phba->phwi_ctrlr; 279 phwi_ctrlr = phba->phwi_ctrlr;
290 phwi_context = phwi_ctrlr->phwi_ctxt; 280 phwi_context = phwi_ctrlr->phwi_ctxt;
@@ -300,10 +290,14 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
300 return tag; 290 return tag;
301 } 291 }
302 wrb = wrb_from_mccq(phba); 292 wrb = wrb_from_mccq(phba);
303 req = embedded_payload(wrb); 293 memset(wrb, 0, sizeof(*wrb));
294 sge = nonembedded_sgl(wrb);
295
296 req = nonemb_cmd->va;
297 memset(req, 0, sizeof(*req));
304 wrb->tag0 |= tag; 298 wrb->tag0 |= tag;
305 299
306 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); 300 be_wrb_hdr_prepare(wrb, sizeof(*req), true, 1);
307 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, 301 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
308 OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD, 302 OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD,
309 sizeof(*req)); 303 sizeof(*req));
@@ -331,6 +325,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
331 shost_printk(KERN_ERR, phba->shost, "unknown addr family %d\n", 325 shost_printk(KERN_ERR, phba->shost, "unknown addr family %d\n",
332 dst_addr->sa_family); 326 dst_addr->sa_family);
333 spin_unlock(&ctrl->mbox_lock); 327 spin_unlock(&ctrl->mbox_lock);
328 free_mcc_tag(&phba->ctrl, tag);
334 return -EINVAL; 329 return -EINVAL;
335 330
336 } 331 }
@@ -339,13 +334,16 @@ int mgmt_open_connection(struct beiscsi_hba *phba,
339 if (phba->nxt_cqid == phba->num_cpus) 334 if (phba->nxt_cqid == phba->num_cpus)
340 phba->nxt_cqid = 0; 335 phba->nxt_cqid = 0;
341 req->cq_id = phwi_context->be_cq[i].id; 336 req->cq_id = phwi_context->be_cq[i].id;
342 SE_DEBUG(DBG_LVL_8, "i=%d cq_id=%d \n", i, req->cq_id); 337 SE_DEBUG(DBG_LVL_8, "i=%d cq_id=%d\n", i, req->cq_id);
343 req->defq_id = def_hdr_id; 338 req->defq_id = def_hdr_id;
344 req->hdr_ring_id = def_hdr_id; 339 req->hdr_ring_id = def_hdr_id;
345 req->data_ring_id = def_data_id; 340 req->data_ring_id = def_data_id;
346 req->do_offload = 1; 341 req->do_offload = 1;
347 req->dataout_template_pa.lo = ptemplate_address->lo; 342 req->dataout_template_pa.lo = ptemplate_address->lo;
348 req->dataout_template_pa.hi = ptemplate_address->hi; 343 req->dataout_template_pa.hi = ptemplate_address->hi;
344 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
345 sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
346 sge->len = cpu_to_le32(nonemb_cmd->size);
349 be_mcc_notify(phba); 347 be_mcc_notify(phba);
350 spin_unlock(&ctrl->mbox_lock); 348 spin_unlock(&ctrl->mbox_lock);
351 return tag; 349 return tag;
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index 3d316b82feb1..b9acedf78653 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -86,16 +86,19 @@ struct mcc_wrb {
86 struct mcc_wrb_payload payload; 86 struct mcc_wrb_payload payload;
87}; 87};
88 88
89unsigned char mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute); 89int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute);
90int mgmt_open_connection(struct beiscsi_hba *phba, struct sockaddr *dst_addr, 90int mgmt_open_connection(struct beiscsi_hba *phba,
91 struct beiscsi_endpoint *beiscsi_ep); 91 struct sockaddr *dst_addr,
92 struct beiscsi_endpoint *beiscsi_ep,
93 struct be_dma_mem *nonemb_cmd);
92 94
93unsigned char mgmt_upload_connection(struct beiscsi_hba *phba, 95unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
94 unsigned short cid, 96 unsigned short cid,
95 unsigned int upload_flag); 97 unsigned int upload_flag);
96unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba, 98unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
97 struct invalidate_command_table *inv_tbl, 99 struct invalidate_command_table *inv_tbl,
98 unsigned int num_invalidate, unsigned int cid); 100 unsigned int num_invalidate, unsigned int cid,
101 struct be_dma_mem *nonemb_cmd);
99 102
100struct iscsi_invalidate_connection_params_in { 103struct iscsi_invalidate_connection_params_in {
101 struct be_cmd_req_hdr hdr; 104 struct be_cmd_req_hdr hdr;
@@ -237,10 +240,10 @@ struct beiscsi_endpoint {
237 u16 cid_vld; 240 u16 cid_vld;
238}; 241};
239 242
240unsigned char mgmt_get_fw_config(struct be_ctrl_info *ctrl, 243int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
241 struct beiscsi_hba *phba); 244 struct beiscsi_hba *phba);
242 245
243unsigned char mgmt_invalidate_connection(struct beiscsi_hba *phba, 246unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
244 struct beiscsi_endpoint *beiscsi_ep, 247 struct beiscsi_endpoint *beiscsi_ep,
245 unsigned short cid, 248 unsigned short cid,
246 unsigned short issue_reset, 249 unsigned short issue_reset,