diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/scsi/be2iscsi | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'drivers/scsi/be2iscsi')
-rw-r--r-- | drivers/scsi/be2iscsi/be.h | 11 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_cmds.c | 390 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_cmds.h | 276 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.c | 866 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.h | 19 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_main.c | 2360 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_main.h | 204 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_mgmt.c | 1085 | ||||
-rw-r--r-- | drivers/scsi/be2iscsi/be_mgmt.h | 84 |
9 files changed, 1197 insertions, 4098 deletions
diff --git a/drivers/scsi/be2iscsi/be.h b/drivers/scsi/be2iscsi/be.h index f1733dfa3ae..1d7b976c850 100644 --- a/drivers/scsi/be2iscsi/be.h +++ b/drivers/scsi/be2iscsi/be.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -28,7 +28,7 @@ | |||
28 | /* BladeEngine Generation numbers */ | 28 | /* BladeEngine Generation numbers */ |
29 | #define BE_GEN2 2 | 29 | #define BE_GEN2 2 |
30 | #define BE_GEN3 3 | 30 | #define BE_GEN3 3 |
31 | #define BE_GEN4 4 | 31 | |
32 | struct be_dma_mem { | 32 | struct be_dma_mem { |
33 | void *va; | 33 | void *va; |
34 | dma_addr_t dma; | 34 | dma_addr_t dma; |
@@ -84,12 +84,9 @@ static inline void queue_tail_inc(struct be_queue_info *q) | |||
84 | /*ISCSI */ | 84 | /*ISCSI */ |
85 | 85 | ||
86 | struct be_eq_obj { | 86 | struct be_eq_obj { |
87 | bool todo_mcc_cq; | ||
88 | bool todo_cq; | ||
89 | struct be_queue_info q; | 87 | struct be_queue_info q; |
90 | struct beiscsi_hba *phba; | 88 | struct beiscsi_hba *phba; |
91 | struct be_queue_info *cq; | 89 | struct be_queue_info *cq; |
92 | struct work_struct work_cqs; /* Work Item */ | ||
93 | struct blk_iopoll iopoll; | 90 | struct blk_iopoll iopoll; |
94 | }; | 91 | }; |
95 | 92 | ||
@@ -135,6 +132,10 @@ struct be_ctrl_info { | |||
135 | ((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) + \ | 132 | ((u32)((((size_t)(_address) & (PAGE_SIZE_4K - 1)) + \ |
136 | (size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K)) | 133 | (size) + (PAGE_SIZE_4K - 1)) >> PAGE_SHIFT_4K)) |
137 | 134 | ||
135 | /* Byte offset into the page corresponding to given address */ | ||
136 | #define OFFSET_IN_PAGE(addr) \ | ||
137 | ((size_t)(addr) & (PAGE_SIZE_4K-1)) | ||
138 | |||
138 | /* Returns bit offset within a DWORD of a bitfield */ | 139 | /* Returns bit offset within a DWORD of a bitfield */ |
139 | #define AMAP_BIT_OFFSET(_struct, field) \ | 140 | #define AMAP_BIT_OFFSET(_struct, field) \ |
140 | (((size_t)&(((_struct *)0)->field))%32) | 141 | (((size_t)&(((_struct *)0)->field))%32) |
diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index 5c87768c109..b8a82f2c62c 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -15,8 +15,6 @@ | |||
15 | * Costa Mesa, CA 92626 | 15 | * Costa Mesa, CA 92626 |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <scsi/iscsi_proto.h> | ||
19 | |||
20 | #include "be.h" | 18 | #include "be.h" |
21 | #include "be_mgmt.h" | 19 | #include "be_mgmt.h" |
22 | #include "be_main.h" | 20 | #include "be_main.h" |
@@ -48,15 +46,14 @@ int beiscsi_pci_soft_reset(struct beiscsi_hba *phba) | |||
48 | } | 46 | } |
49 | 47 | ||
50 | if (sreset & BE2_SET_RESET) { | 48 | if (sreset & BE2_SET_RESET) { |
51 | printk(KERN_ERR DRV_NAME | 49 | printk(KERN_ERR "Soft Reset did not deassert\n"); |
52 | " Soft Reset did not deassert\n"); | ||
53 | return -EIO; | 50 | return -EIO; |
54 | } | 51 | } |
55 | pconline1 = BE2_MPU_IRAM_ONLINE; | 52 | pconline1 = BE2_MPU_IRAM_ONLINE; |
56 | writel(pconline0, (void *)pci_online0_offset); | 53 | writel(pconline0, (void *)pci_online0_offset); |
57 | writel(pconline1, (void *)pci_online1_offset); | 54 | writel(pconline1, (void *)pci_online1_offset); |
58 | 55 | ||
59 | sreset |= BE2_SET_RESET; | 56 | sreset = BE2_SET_RESET; |
60 | writel(sreset, (void *)pci_reset_offset); | 57 | writel(sreset, (void *)pci_reset_offset); |
61 | 58 | ||
62 | i = 0; | 59 | i = 0; |
@@ -68,8 +65,7 @@ int beiscsi_pci_soft_reset(struct beiscsi_hba *phba) | |||
68 | i++; | 65 | i++; |
69 | } | 66 | } |
70 | if (sreset & BE2_SET_RESET) { | 67 | if (sreset & BE2_SET_RESET) { |
71 | printk(KERN_ERR DRV_NAME | 68 | printk(KERN_ERR "MPU Online Soft Reset did not deassert\n"); |
72 | " MPU Online Soft Reset did not deassert\n"); | ||
73 | return -EIO; | 69 | return -EIO; |
74 | } | 70 | } |
75 | return 0; | 71 | return 0; |
@@ -95,9 +91,8 @@ int be_chk_reset_complete(struct beiscsi_hba *phba) | |||
95 | } | 91 | } |
96 | 92 | ||
97 | if ((status & 0x80000000) || (!num_loop)) { | 93 | if ((status & 0x80000000) || (!num_loop)) { |
98 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 94 | printk(KERN_ERR "Failed in be_chk_reset_complete" |
99 | "BC_%d : Failed in be_chk_reset_complete" | 95 | "status = 0x%x\n", status); |
100 | "status = 0x%x\n", status); | ||
101 | return -EIO; | 96 | return -EIO; |
102 | } | 97 | } |
103 | 98 | ||
@@ -133,87 +128,6 @@ unsigned int alloc_mcc_tag(struct beiscsi_hba *phba) | |||
133 | return tag; | 128 | return tag; |
134 | } | 129 | } |
135 | 130 | ||
136 | /* | ||
137 | * beiscsi_mccq_compl()- Wait for completion of MBX | ||
138 | * @phba: Driver private structure | ||
139 | * @tag: Tag for the MBX Command | ||
140 | * @wrb: the WRB used for the MBX Command | ||
141 | * @cmd_hdr: IOCTL Hdr for the MBX Cmd | ||
142 | * | ||
143 | * Waits for MBX completion with the passed TAG. | ||
144 | * | ||
145 | * return | ||
146 | * Success: 0 | ||
147 | * Failure: Non-Zero | ||
148 | **/ | ||
149 | int beiscsi_mccq_compl(struct beiscsi_hba *phba, | ||
150 | uint32_t tag, struct be_mcc_wrb **wrb, | ||
151 | void *cmd_hdr) | ||
152 | { | ||
153 | int rc = 0; | ||
154 | uint32_t mcc_tag_response; | ||
155 | uint16_t status = 0, addl_status = 0, wrb_num = 0; | ||
156 | struct be_mcc_wrb *temp_wrb; | ||
157 | struct be_cmd_req_hdr *ioctl_hdr; | ||
158 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; | ||
159 | |||
160 | if (beiscsi_error(phba)) | ||
161 | return -EIO; | ||
162 | |||
163 | /* wait for the mccq completion */ | ||
164 | rc = wait_event_interruptible_timeout( | ||
165 | phba->ctrl.mcc_wait[tag], | ||
166 | phba->ctrl.mcc_numtag[tag], | ||
167 | msecs_to_jiffies( | ||
168 | BEISCSI_HOST_MBX_TIMEOUT)); | ||
169 | |||
170 | if (rc <= 0) { | ||
171 | beiscsi_log(phba, KERN_ERR, | ||
172 | BEISCSI_LOG_INIT | BEISCSI_LOG_EH | | ||
173 | BEISCSI_LOG_CONFIG, | ||
174 | "BC_%d : MBX Cmd Completion timed out\n"); | ||
175 | rc = -EAGAIN; | ||
176 | goto release_mcc_tag; | ||
177 | } else | ||
178 | rc = 0; | ||
179 | |||
180 | mcc_tag_response = phba->ctrl.mcc_numtag[tag]; | ||
181 | status = (mcc_tag_response & CQE_STATUS_MASK); | ||
182 | addl_status = ((mcc_tag_response & CQE_STATUS_ADDL_MASK) >> | ||
183 | CQE_STATUS_ADDL_SHIFT); | ||
184 | |||
185 | if (cmd_hdr) { | ||
186 | ioctl_hdr = (struct be_cmd_req_hdr *)cmd_hdr; | ||
187 | } else { | ||
188 | wrb_num = (mcc_tag_response & CQE_STATUS_WRB_MASK) >> | ||
189 | CQE_STATUS_WRB_SHIFT; | ||
190 | temp_wrb = (struct be_mcc_wrb *)queue_get_wrb(mccq, wrb_num); | ||
191 | ioctl_hdr = embedded_payload(temp_wrb); | ||
192 | |||
193 | if (wrb) | ||
194 | *wrb = temp_wrb; | ||
195 | } | ||
196 | |||
197 | if (status || addl_status) { | ||
198 | beiscsi_log(phba, KERN_ERR, | ||
199 | BEISCSI_LOG_INIT | BEISCSI_LOG_EH | | ||
200 | BEISCSI_LOG_CONFIG, | ||
201 | "BC_%d : MBX Cmd Failed for " | ||
202 | "Subsys : %d Opcode : %d with " | ||
203 | "Status : %d and Extd_Status : %d\n", | ||
204 | ioctl_hdr->subsystem, | ||
205 | ioctl_hdr->opcode, | ||
206 | status, addl_status); | ||
207 | rc = -EAGAIN; | ||
208 | } | ||
209 | |||
210 | release_mcc_tag: | ||
211 | /* Release the MCC entry */ | ||
212 | free_mcc_tag(&phba->ctrl, tag); | ||
213 | |||
214 | return rc; | ||
215 | } | ||
216 | |||
217 | void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag) | 131 | void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag) |
218 | { | 132 | { |
219 | spin_lock(&ctrl->mbox_lock); | 133 | spin_lock(&ctrl->mbox_lock); |
@@ -249,24 +163,10 @@ static inline void be_mcc_compl_use(struct be_mcc_compl *compl) | |||
249 | compl->flags = 0; | 163 | compl->flags = 0; |
250 | } | 164 | } |
251 | 165 | ||
252 | /* | ||
253 | * be_mcc_compl_process()- Check the MBX comapletion status | ||
254 | * @ctrl: Function specific MBX data structure | ||
255 | * @compl: Completion status of MBX Command | ||
256 | * | ||
257 | * Check for the MBX completion status when BMBX method used | ||
258 | * | ||
259 | * return | ||
260 | * Success: Zero | ||
261 | * Failure: Non-Zero | ||
262 | **/ | ||
263 | static int be_mcc_compl_process(struct be_ctrl_info *ctrl, | 166 | static int be_mcc_compl_process(struct be_ctrl_info *ctrl, |
264 | struct be_mcc_compl *compl) | 167 | struct be_mcc_compl *compl) |
265 | { | 168 | { |
266 | u16 compl_status, extd_status; | 169 | u16 compl_status, extd_status; |
267 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | ||
268 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | ||
269 | struct be_cmd_req_hdr *hdr = embedded_payload(wrb); | ||
270 | 170 | ||
271 | be_dws_le_to_cpu(compl, 4); | 171 | be_dws_le_to_cpu(compl, 4); |
272 | 172 | ||
@@ -275,15 +175,9 @@ static int be_mcc_compl_process(struct be_ctrl_info *ctrl, | |||
275 | if (compl_status != MCC_STATUS_SUCCESS) { | 175 | if (compl_status != MCC_STATUS_SUCCESS) { |
276 | extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & | 176 | extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & |
277 | CQE_STATUS_EXTD_MASK; | 177 | CQE_STATUS_EXTD_MASK; |
278 | 178 | dev_err(&ctrl->pdev->dev, | |
279 | beiscsi_log(phba, KERN_ERR, | 179 | "error in cmd completion: status(compl/extd)=%d/%d\n", |
280 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | 180 | compl_status, extd_status); |
281 | "BC_%d : error in cmd completion: " | ||
282 | "Subsystem : %d Opcode : %d " | ||
283 | "status(compl/extd)=%d/%d\n", | ||
284 | hdr->subsystem, hdr->opcode, | ||
285 | compl_status, extd_status); | ||
286 | |||
287 | return -EBUSY; | 181 | return -EBUSY; |
288 | } | 182 | } |
289 | return 0; | 183 | return 0; |
@@ -337,29 +231,22 @@ void beiscsi_async_link_state_process(struct beiscsi_hba *phba, | |||
337 | { | 231 | { |
338 | switch (evt->port_link_status) { | 232 | switch (evt->port_link_status) { |
339 | case ASYNC_EVENT_LINK_DOWN: | 233 | case ASYNC_EVENT_LINK_DOWN: |
340 | beiscsi_log(phba, KERN_ERR, | 234 | SE_DEBUG(DBG_LVL_1, "Link Down on Physical Port %d\n", |
341 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT, | 235 | evt->physical_port); |
342 | "BC_%d : Link Down on Physical Port %d\n", | ||
343 | evt->physical_port); | ||
344 | |||
345 | phba->state |= BE_ADAPTER_LINK_DOWN; | 236 | phba->state |= BE_ADAPTER_LINK_DOWN; |
346 | iscsi_host_for_each_session(phba->shost, | 237 | iscsi_host_for_each_session(phba->shost, |
347 | be2iscsi_fail_session); | 238 | be2iscsi_fail_session); |
348 | break; | 239 | break; |
349 | case ASYNC_EVENT_LINK_UP: | 240 | case ASYNC_EVENT_LINK_UP: |
350 | phba->state = BE_ADAPTER_UP; | 241 | phba->state = BE_ADAPTER_UP; |
351 | beiscsi_log(phba, KERN_ERR, | 242 | SE_DEBUG(DBG_LVL_1, "Link UP on Physical Port %d\n", |
352 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT, | 243 | evt->physical_port); |
353 | "BC_%d : Link UP on Physical Port %d\n", | ||
354 | evt->physical_port); | ||
355 | break; | 244 | break; |
356 | default: | 245 | default: |
357 | beiscsi_log(phba, KERN_ERR, | 246 | SE_DEBUG(DBG_LVL_1, "Unexpected Async Notification %d on" |
358 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT, | 247 | "Physical Port %d\n", |
359 | "BC_%d : Unexpected Async Notification %d on" | 248 | evt->port_link_status, |
360 | "Physical Port %d\n", | 249 | evt->physical_port); |
361 | evt->port_link_status, | ||
362 | evt->physical_port); | ||
363 | } | 250 | } |
364 | } | 251 | } |
365 | 252 | ||
@@ -390,11 +277,9 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba) | |||
390 | beiscsi_async_link_state_process(phba, | 277 | beiscsi_async_link_state_process(phba, |
391 | (struct be_async_event_link_state *) compl); | 278 | (struct be_async_event_link_state *) compl); |
392 | else | 279 | else |
393 | beiscsi_log(phba, KERN_ERR, | 280 | SE_DEBUG(DBG_LVL_1, |
394 | BEISCSI_LOG_CONFIG | | 281 | " Unsupported Async Event, flags" |
395 | BEISCSI_LOG_MBOX, | 282 | " = 0x%08x\n", compl->flags); |
396 | "BC_%d : Unsupported Async Event, flags" | ||
397 | " = 0x%08x\n", compl->flags); | ||
398 | 283 | ||
399 | } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { | 284 | } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { |
400 | status = be_mcc_compl_process(ctrl, compl); | 285 | status = be_mcc_compl_process(ctrl, compl); |
@@ -411,24 +296,11 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba) | |||
411 | return status; | 296 | return status; |
412 | } | 297 | } |
413 | 298 | ||
414 | /* | 299 | /* Wait till no more pending mcc requests are present */ |
415 | * be_mcc_wait_compl()- Wait for MBX completion | ||
416 | * @phba: driver private structure | ||
417 | * | ||
418 | * Wait till no more pending mcc requests are present | ||
419 | * | ||
420 | * return | ||
421 | * Success: 0 | ||
422 | * Failure: Non-Zero | ||
423 | * | ||
424 | **/ | ||
425 | static int be_mcc_wait_compl(struct beiscsi_hba *phba) | 300 | static int be_mcc_wait_compl(struct beiscsi_hba *phba) |
426 | { | 301 | { |
427 | int i, status; | 302 | int i, status; |
428 | for (i = 0; i < mcc_timeout; i++) { | 303 | for (i = 0; i < mcc_timeout; i++) { |
429 | if (beiscsi_error(phba)) | ||
430 | return -EIO; | ||
431 | |||
432 | status = beiscsi_process_mcc(phba); | 304 | status = beiscsi_process_mcc(phba); |
433 | if (status) | 305 | if (status) |
434 | return status; | 306 | return status; |
@@ -438,85 +310,46 @@ static int be_mcc_wait_compl(struct beiscsi_hba *phba) | |||
438 | udelay(100); | 310 | udelay(100); |
439 | } | 311 | } |
440 | if (i == mcc_timeout) { | 312 | if (i == mcc_timeout) { |
441 | beiscsi_log(phba, KERN_ERR, | 313 | dev_err(&phba->pcidev->dev, "mccq poll timed out\n"); |
442 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
443 | "BC_%d : FW Timed Out\n"); | ||
444 | phba->fw_timeout = true; | ||
445 | beiscsi_ue_detect(phba); | ||
446 | return -EBUSY; | 314 | return -EBUSY; |
447 | } | 315 | } |
448 | return 0; | 316 | return 0; |
449 | } | 317 | } |
450 | 318 | ||
451 | /* | 319 | /* Notify MCC requests and wait for completion */ |
452 | * be_mcc_notify_wait()- Notify and wait for Compl | ||
453 | * @phba: driver private structure | ||
454 | * | ||
455 | * Notify MCC requests and wait for completion | ||
456 | * | ||
457 | * return | ||
458 | * Success: 0 | ||
459 | * Failure: Non-Zero | ||
460 | **/ | ||
461 | int be_mcc_notify_wait(struct beiscsi_hba *phba) | 320 | int be_mcc_notify_wait(struct beiscsi_hba *phba) |
462 | { | 321 | { |
463 | be_mcc_notify(phba); | 322 | be_mcc_notify(phba); |
464 | return be_mcc_wait_compl(phba); | 323 | return be_mcc_wait_compl(phba); |
465 | } | 324 | } |
466 | 325 | ||
467 | /* | ||
468 | * be_mbox_db_ready_wait()- Check ready status | ||
469 | * @ctrl: Function specific MBX data structure | ||
470 | * | ||
471 | * Check for the ready status of FW to send BMBX | ||
472 | * commands to adapter. | ||
473 | * | ||
474 | * return | ||
475 | * Success: 0 | ||
476 | * Failure: Non-Zero | ||
477 | **/ | ||
478 | static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl) | 326 | static int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl) |
479 | { | 327 | { |
328 | #define long_delay 2000 | ||
480 | void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET; | 329 | void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET; |
481 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | 330 | int cnt = 0, wait = 5; /* in usecs */ |
482 | int wait = 0; | ||
483 | u32 ready; | 331 | u32 ready; |
484 | 332 | ||
485 | do { | 333 | do { |
486 | |||
487 | if (beiscsi_error(phba)) | ||
488 | return -EIO; | ||
489 | |||
490 | ready = ioread32(db) & MPU_MAILBOX_DB_RDY_MASK; | 334 | ready = ioread32(db) & MPU_MAILBOX_DB_RDY_MASK; |
491 | if (ready) | 335 | if (ready) |
492 | break; | 336 | break; |
493 | 337 | ||
494 | if (wait > BEISCSI_HOST_MBX_TIMEOUT) { | 338 | if (cnt > 12000000) { |
495 | beiscsi_log(phba, KERN_ERR, | 339 | dev_err(&ctrl->pdev->dev, "mbox_db poll timed out\n"); |
496 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
497 | "BC_%d : FW Timed Out\n"); | ||
498 | phba->fw_timeout = true; | ||
499 | beiscsi_ue_detect(phba); | ||
500 | return -EBUSY; | 340 | return -EBUSY; |
501 | } | 341 | } |
502 | 342 | ||
503 | mdelay(1); | 343 | if (cnt > 50) { |
504 | wait++; | 344 | wait = long_delay; |
345 | mdelay(long_delay / 1000); | ||
346 | } else | ||
347 | udelay(wait); | ||
348 | cnt += wait; | ||
505 | } while (true); | 349 | } while (true); |
506 | return 0; | 350 | return 0; |
507 | } | 351 | } |
508 | 352 | ||
509 | /* | ||
510 | * be_mbox_notify: Notify adapter of new BMBX command | ||
511 | * @ctrl: Function specific MBX data structure | ||
512 | * | ||
513 | * Ring doorbell to inform adapter of a BMBX command | ||
514 | * to process | ||
515 | * | ||
516 | * return | ||
517 | * Success: 0 | ||
518 | * Failure: Non-Zero | ||
519 | **/ | ||
520 | int be_mbox_notify(struct be_ctrl_info *ctrl) | 353 | int be_mbox_notify(struct be_ctrl_info *ctrl) |
521 | { | 354 | { |
522 | int status; | 355 | int status; |
@@ -525,7 +358,6 @@ int be_mbox_notify(struct be_ctrl_info *ctrl) | |||
525 | struct be_dma_mem *mbox_mem = &ctrl->mbox_mem; | 358 | struct be_dma_mem *mbox_mem = &ctrl->mbox_mem; |
526 | struct be_mcc_mailbox *mbox = mbox_mem->va; | 359 | struct be_mcc_mailbox *mbox = mbox_mem->va; |
527 | struct be_mcc_compl *compl = &mbox->compl; | 360 | struct be_mcc_compl *compl = &mbox->compl; |
528 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | ||
529 | 361 | ||
530 | val &= ~MPU_MAILBOX_DB_RDY_MASK; | 362 | val &= ~MPU_MAILBOX_DB_RDY_MASK; |
531 | val |= MPU_MAILBOX_DB_HI_MASK; | 363 | val |= MPU_MAILBOX_DB_HI_MASK; |
@@ -533,9 +365,10 @@ int be_mbox_notify(struct be_ctrl_info *ctrl) | |||
533 | iowrite32(val, db); | 365 | iowrite32(val, db); |
534 | 366 | ||
535 | status = be_mbox_db_ready_wait(ctrl); | 367 | status = be_mbox_db_ready_wait(ctrl); |
536 | if (status) | 368 | if (status != 0) { |
369 | SE_DEBUG(DBG_LVL_1, " be_mbox_db_ready_wait failed\n"); | ||
537 | return status; | 370 | return status; |
538 | 371 | } | |
539 | val = 0; | 372 | val = 0; |
540 | val &= ~MPU_MAILBOX_DB_RDY_MASK; | 373 | val &= ~MPU_MAILBOX_DB_RDY_MASK; |
541 | val &= ~MPU_MAILBOX_DB_HI_MASK; | 374 | val &= ~MPU_MAILBOX_DB_HI_MASK; |
@@ -543,24 +376,19 @@ int be_mbox_notify(struct be_ctrl_info *ctrl) | |||
543 | iowrite32(val, db); | 376 | iowrite32(val, db); |
544 | 377 | ||
545 | status = be_mbox_db_ready_wait(ctrl); | 378 | status = be_mbox_db_ready_wait(ctrl); |
546 | if (status) | 379 | if (status != 0) { |
380 | SE_DEBUG(DBG_LVL_1, " be_mbox_db_ready_wait failed\n"); | ||
547 | return status; | 381 | return status; |
548 | 382 | } | |
549 | if (be_mcc_compl_is_new(compl)) { | 383 | if (be_mcc_compl_is_new(compl)) { |
550 | status = be_mcc_compl_process(ctrl, &mbox->compl); | 384 | status = be_mcc_compl_process(ctrl, &mbox->compl); |
551 | be_mcc_compl_use(compl); | 385 | be_mcc_compl_use(compl); |
552 | if (status) { | 386 | if (status) { |
553 | beiscsi_log(phba, KERN_ERR, | 387 | SE_DEBUG(DBG_LVL_1, "After be_mcc_compl_process\n"); |
554 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
555 | "BC_%d : After be_mcc_compl_process\n"); | ||
556 | |||
557 | return status; | 388 | return status; |
558 | } | 389 | } |
559 | } else { | 390 | } else { |
560 | beiscsi_log(phba, KERN_ERR, | 391 | dev_err(&ctrl->pdev->dev, "invalid mailbox completion\n"); |
561 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
562 | "BC_%d : Invalid Mailbox Completion\n"); | ||
563 | |||
564 | return -EBUSY; | 392 | return -EBUSY; |
565 | } | 393 | } |
566 | return 0; | 394 | return 0; |
@@ -606,10 +434,7 @@ static int be_mbox_notify_wait(struct beiscsi_hba *phba) | |||
606 | if (status) | 434 | if (status) |
607 | return status; | 435 | return status; |
608 | } else { | 436 | } else { |
609 | beiscsi_log(phba, KERN_ERR, | 437 | dev_err(&phba->pcidev->dev, "invalid mailbox completion\n"); |
610 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
611 | "BC_%d : invalid mailbox completion\n"); | ||
612 | |||
613 | return -EBUSY; | 438 | return -EBUSY; |
614 | } | 439 | } |
615 | return 0; | 440 | return 0; |
@@ -633,7 +458,7 @@ void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, | |||
633 | req_hdr->opcode = opcode; | 458 | req_hdr->opcode = opcode; |
634 | req_hdr->subsystem = subsystem; | 459 | req_hdr->subsystem = subsystem; |
635 | req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr)); | 460 | req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr)); |
636 | req_hdr->timeout = BEISCSI_FW_MBX_TIMEOUT; | 461 | req_hdr->timeout = 120; |
637 | } | 462 | } |
638 | 463 | ||
639 | static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages, | 464 | static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages, |
@@ -701,6 +526,7 @@ int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, | |||
701 | struct be_dma_mem *q_mem = &eq->dma_mem; | 526 | struct be_dma_mem *q_mem = &eq->dma_mem; |
702 | int status; | 527 | int status; |
703 | 528 | ||
529 | SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_eq_create\n"); | ||
704 | spin_lock(&ctrl->mbox_lock); | 530 | spin_lock(&ctrl->mbox_lock); |
705 | memset(wrb, 0, sizeof(*wrb)); | 531 | memset(wrb, 0, sizeof(*wrb)); |
706 | 532 | ||
@@ -735,10 +561,10 @@ int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, | |||
735 | int be_cmd_fw_initialize(struct be_ctrl_info *ctrl) | 561 | int be_cmd_fw_initialize(struct be_ctrl_info *ctrl) |
736 | { | 562 | { |
737 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 563 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
738 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | ||
739 | int status; | 564 | int status; |
740 | u8 *endian_check; | 565 | u8 *endian_check; |
741 | 566 | ||
567 | SE_DEBUG(DBG_LVL_8, "In be_cmd_fw_initialize\n"); | ||
742 | spin_lock(&ctrl->mbox_lock); | 568 | spin_lock(&ctrl->mbox_lock); |
743 | memset(wrb, 0, sizeof(*wrb)); | 569 | memset(wrb, 0, sizeof(*wrb)); |
744 | 570 | ||
@@ -755,8 +581,7 @@ int be_cmd_fw_initialize(struct be_ctrl_info *ctrl) | |||
755 | 581 | ||
756 | status = be_mbox_notify(ctrl); | 582 | status = be_mbox_notify(ctrl); |
757 | if (status) | 583 | if (status) |
758 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 584 | SE_DEBUG(DBG_LVL_1, "be_cmd_fw_initialize Failed\n"); |
759 | "BC_%d : be_cmd_fw_initialize Failed\n"); | ||
760 | 585 | ||
761 | spin_unlock(&ctrl->mbox_lock); | 586 | spin_unlock(&ctrl->mbox_lock); |
762 | return status; | 587 | return status; |
@@ -769,11 +594,11 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl, | |||
769 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 594 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
770 | struct be_cmd_req_cq_create *req = embedded_payload(wrb); | 595 | struct be_cmd_req_cq_create *req = embedded_payload(wrb); |
771 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); | 596 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); |
772 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | ||
773 | struct be_dma_mem *q_mem = &cq->dma_mem; | 597 | struct be_dma_mem *q_mem = &cq->dma_mem; |
774 | void *ctxt = &req->context; | 598 | void *ctxt = &req->context; |
775 | int status; | 599 | int status; |
776 | 600 | ||
601 | SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_cq_create\n"); | ||
777 | spin_lock(&ctrl->mbox_lock); | 602 | spin_lock(&ctrl->mbox_lock); |
778 | memset(wrb, 0, sizeof(*wrb)); | 603 | memset(wrb, 0, sizeof(*wrb)); |
779 | 604 | ||
@@ -781,36 +606,22 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl, | |||
781 | 606 | ||
782 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 607 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
783 | OPCODE_COMMON_CQ_CREATE, sizeof(*req)); | 608 | OPCODE_COMMON_CQ_CREATE, sizeof(*req)); |
609 | if (!q_mem->va) | ||
610 | SE_DEBUG(DBG_LVL_1, "uninitialized q_mem->va\n"); | ||
784 | 611 | ||
785 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); | 612 | req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); |
786 | if (chip_skh_r(ctrl->pdev)) { | ||
787 | req->hdr.version = MBX_CMD_VER2; | ||
788 | req->page_size = 1; | ||
789 | AMAP_SET_BITS(struct amap_cq_context_v2, coalescwm, | ||
790 | ctxt, coalesce_wm); | ||
791 | AMAP_SET_BITS(struct amap_cq_context_v2, nodelay, | ||
792 | ctxt, no_delay); | ||
793 | AMAP_SET_BITS(struct amap_cq_context_v2, count, ctxt, | ||
794 | __ilog2_u32(cq->len / 256)); | ||
795 | AMAP_SET_BITS(struct amap_cq_context_v2, valid, ctxt, 1); | ||
796 | AMAP_SET_BITS(struct amap_cq_context_v2, eventable, ctxt, 1); | ||
797 | AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq->id); | ||
798 | AMAP_SET_BITS(struct amap_cq_context_v2, armed, ctxt, 1); | ||
799 | } else { | ||
800 | AMAP_SET_BITS(struct amap_cq_context, coalescwm, | ||
801 | ctxt, coalesce_wm); | ||
802 | AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay); | ||
803 | AMAP_SET_BITS(struct amap_cq_context, count, ctxt, | ||
804 | __ilog2_u32(cq->len / 256)); | ||
805 | AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1); | ||
806 | AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts); | ||
807 | AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1); | ||
808 | AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); | ||
809 | AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); | ||
810 | AMAP_SET_BITS(struct amap_cq_context, func, ctxt, | ||
811 | PCI_FUNC(ctrl->pdev->devfn)); | ||
812 | } | ||
813 | 613 | ||
614 | AMAP_SET_BITS(struct amap_cq_context, coalescwm, ctxt, coalesce_wm); | ||
615 | AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay); | ||
616 | AMAP_SET_BITS(struct amap_cq_context, count, ctxt, | ||
617 | __ilog2_u32(cq->len / 256)); | ||
618 | AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1); | ||
619 | AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts); | ||
620 | AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1); | ||
621 | AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); | ||
622 | AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1); | ||
623 | AMAP_SET_BITS(struct amap_cq_context, func, ctxt, | ||
624 | PCI_FUNC(ctrl->pdev->devfn)); | ||
814 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); | 625 | be_dws_cpu_to_le(ctxt, sizeof(req->context)); |
815 | 626 | ||
816 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 627 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
@@ -820,10 +631,8 @@ int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl, | |||
820 | cq->id = le16_to_cpu(resp->cq_id); | 631 | cq->id = le16_to_cpu(resp->cq_id); |
821 | cq->created = true; | 632 | cq->created = true; |
822 | } else | 633 | } else |
823 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 634 | SE_DEBUG(DBG_LVL_1, "In be_cmd_cq_create, status=ox%08x\n", |
824 | "BC_%d : In be_cmd_cq_create, status=ox%08x\n", | 635 | status); |
825 | status); | ||
826 | |||
827 | spin_unlock(&ctrl->mbox_lock); | 636 | spin_unlock(&ctrl->mbox_lock); |
828 | 637 | ||
829 | return status; | 638 | return status; |
@@ -851,7 +660,6 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba, | |||
851 | spin_lock(&phba->ctrl.mbox_lock); | 660 | spin_lock(&phba->ctrl.mbox_lock); |
852 | ctrl = &phba->ctrl; | 661 | ctrl = &phba->ctrl; |
853 | wrb = wrb_from_mbox(&ctrl->mbox_mem); | 662 | wrb = wrb_from_mbox(&ctrl->mbox_mem); |
854 | memset(wrb, 0, sizeof(*wrb)); | ||
855 | req = embedded_payload(wrb); | 663 | req = embedded_payload(wrb); |
856 | ctxt = &req->context; | 664 | ctxt = &req->context; |
857 | 665 | ||
@@ -889,14 +697,10 @@ int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, | |||
889 | { | 697 | { |
890 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 698 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
891 | struct be_cmd_req_q_destroy *req = embedded_payload(wrb); | 699 | struct be_cmd_req_q_destroy *req = embedded_payload(wrb); |
892 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | ||
893 | u8 subsys = 0, opcode = 0; | 700 | u8 subsys = 0, opcode = 0; |
894 | int status; | 701 | int status; |
895 | 702 | ||
896 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 703 | SE_DEBUG(DBG_LVL_8, "In beiscsi_cmd_q_destroy\n"); |
897 | "BC_%d : In beiscsi_cmd_q_destroy " | ||
898 | "queue_type : %d\n", queue_type); | ||
899 | |||
900 | spin_lock(&ctrl->mbox_lock); | 704 | spin_lock(&ctrl->mbox_lock); |
901 | memset(wrb, 0, sizeof(*wrb)); | 705 | memset(wrb, 0, sizeof(*wrb)); |
902 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 706 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -952,6 +756,7 @@ int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl, | |||
952 | void *ctxt = &req->context; | 756 | void *ctxt = &req->context; |
953 | int status; | 757 | int status; |
954 | 758 | ||
759 | SE_DEBUG(DBG_LVL_8, "In be_cmd_create_default_pdu_queue\n"); | ||
955 | spin_lock(&ctrl->mbox_lock); | 760 | spin_lock(&ctrl->mbox_lock); |
956 | memset(wrb, 0, sizeof(*wrb)); | 761 | memset(wrb, 0, sizeof(*wrb)); |
957 | 762 | ||
@@ -1022,7 +827,6 @@ int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl, | |||
1022 | { | 827 | { |
1023 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | 828 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
1024 | struct be_post_sgl_pages_req *req = embedded_payload(wrb); | 829 | struct be_post_sgl_pages_req *req = embedded_payload(wrb); |
1025 | struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); | ||
1026 | int status; | 830 | int status; |
1027 | unsigned int curr_pages; | 831 | unsigned int curr_pages; |
1028 | u32 internal_page_offset = 0; | 832 | u32 internal_page_offset = 0; |
@@ -1053,9 +857,8 @@ int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl, | |||
1053 | 857 | ||
1054 | status = be_mbox_notify(ctrl); | 858 | status = be_mbox_notify(ctrl); |
1055 | if (status) { | 859 | if (status) { |
1056 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 860 | SE_DEBUG(DBG_LVL_1, |
1057 | "BC_%d : FW CMD to map iscsi frags failed.\n"); | 861 | "FW CMD to map iscsi frags failed.\n"); |
1058 | |||
1059 | goto error; | 862 | goto error; |
1060 | } | 863 | } |
1061 | } while (num_pages > 0); | 864 | } while (num_pages > 0); |
@@ -1065,64 +868,3 @@ error: | |||
1065 | beiscsi_cmd_q_destroy(ctrl, NULL, QTYPE_SGL); | 868 | beiscsi_cmd_q_destroy(ctrl, NULL, QTYPE_SGL); |
1066 | return status; | 869 | return status; |
1067 | } | 870 | } |
1068 | |||
1069 | int beiscsi_cmd_reset_function(struct beiscsi_hba *phba) | ||
1070 | { | ||
1071 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
1072 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | ||
1073 | struct be_post_sgl_pages_req *req = embedded_payload(wrb); | ||
1074 | int status; | ||
1075 | |||
1076 | spin_lock(&ctrl->mbox_lock); | ||
1077 | |||
1078 | req = embedded_payload(wrb); | ||
1079 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | ||
1080 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | ||
1081 | OPCODE_COMMON_FUNCTION_RESET, sizeof(*req)); | ||
1082 | status = be_mbox_notify_wait(phba); | ||
1083 | |||
1084 | spin_unlock(&ctrl->mbox_lock); | ||
1085 | return status; | ||
1086 | } | ||
1087 | |||
1088 | /** | ||
1089 | * be_cmd_set_vlan()- Configure VLAN paramters on the adapter | ||
1090 | * @phba: device priv structure instance | ||
1091 | * @vlan_tag: TAG to be set | ||
1092 | * | ||
1093 | * Set the VLAN_TAG for the adapter or Disable VLAN on adapter | ||
1094 | * | ||
1095 | * returns | ||
1096 | * TAG for the MBX Cmd | ||
1097 | * **/ | ||
1098 | int be_cmd_set_vlan(struct beiscsi_hba *phba, | ||
1099 | uint16_t vlan_tag) | ||
1100 | { | ||
1101 | unsigned int tag = 0; | ||
1102 | struct be_mcc_wrb *wrb; | ||
1103 | struct be_cmd_set_vlan_req *req; | ||
1104 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
1105 | |||
1106 | spin_lock(&ctrl->mbox_lock); | ||
1107 | tag = alloc_mcc_tag(phba); | ||
1108 | if (!tag) { | ||
1109 | spin_unlock(&ctrl->mbox_lock); | ||
1110 | return tag; | ||
1111 | } | ||
1112 | |||
1113 | wrb = wrb_from_mccq(phba); | ||
1114 | req = embedded_payload(wrb); | ||
1115 | wrb->tag0 |= tag; | ||
1116 | be_wrb_hdr_prepare(wrb, sizeof(*wrb), true, 0); | ||
1117 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | ||
1118 | OPCODE_COMMON_ISCSI_NTWK_SET_VLAN, | ||
1119 | sizeof(*req)); | ||
1120 | |||
1121 | req->interface_hndl = phba->interface_handle; | ||
1122 | req->vlan_priority = vlan_tag; | ||
1123 | |||
1124 | be_mcc_notify(phba); | ||
1125 | spin_unlock(&ctrl->mbox_lock); | ||
1126 | |||
1127 | return tag; | ||
1128 | } | ||
diff --git a/drivers/scsi/be2iscsi/be_cmds.h b/drivers/scsi/be2iscsi/be_cmds.h index 23397d51ac5..497eb29e5c9 100644 --- a/drivers/scsi/be2iscsi/be_cmds.h +++ b/drivers/scsi/be2iscsi/be_cmds.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -23,7 +23,7 @@ | |||
23 | * firmware in the BE. These requests are communicated to the processor | 23 | * firmware in the BE. These requests are communicated to the processor |
24 | * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one | 24 | * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one |
25 | * WRB inside a MAILBOX. | 25 | * WRB inside a MAILBOX. |
26 | * The commands are serviced by the ARM processor in the OneConnect's MPU. | 26 | * The commands are serviced by the ARM processor in the BladeEngine's MPU. |
27 | */ | 27 | */ |
28 | struct be_sge { | 28 | struct be_sge { |
29 | u32 pa_lo; | 29 | u32 pa_lo; |
@@ -57,16 +57,6 @@ struct be_mcc_wrb { | |||
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 16 /* bits 0 - 15 */ | 59 | #define CQE_STATUS_EXTD_SHIFT 16 /* bits 0 - 15 */ |
60 | #define CQE_STATUS_ADDL_MASK 0xFF00 | ||
61 | #define CQE_STATUS_MASK 0xFF | ||
62 | #define CQE_STATUS_ADDL_SHIFT 0x08 | ||
63 | #define CQE_STATUS_WRB_MASK 0xFF0000 | ||
64 | #define CQE_STATUS_WRB_SHIFT 16 | ||
65 | #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000) | ||
66 | #define BEISCSI_FW_MBX_TIMEOUT 100 | ||
67 | |||
68 | /* MBOX Command VER */ | ||
69 | #define MBX_CMD_VER2 0x02 | ||
70 | 60 | ||
71 | struct be_mcc_compl { | 61 | struct be_mcc_compl { |
72 | u32 status; /* dword 0 */ | 62 | u32 status; /* dword 0 */ |
@@ -173,8 +163,7 @@ struct be_mcc_mailbox { | |||
173 | #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3 | 163 | #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3 |
174 | #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7 | 164 | #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7 |
175 | #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14 | 165 | #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14 |
176 | #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17 | 166 | #define OPCODE_COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR 17 |
177 | #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18 | ||
178 | #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21 | 167 | #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21 |
179 | #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22 | 168 | #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22 |
180 | #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23 | 169 | #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23 |
@@ -193,8 +182,7 @@ struct be_cmd_req_hdr { | |||
193 | u8 domain; /* dword 0 */ | 182 | u8 domain; /* dword 0 */ |
194 | u32 timeout; /* dword 1 */ | 183 | u32 timeout; /* dword 1 */ |
195 | u32 request_length; /* dword 2 */ | 184 | u32 request_length; /* dword 2 */ |
196 | u8 version; /* dword 3 */ | 185 | u32 rsvd0; /* dword 3 */ |
197 | u8 rsvd0[3]; /* dword 3 */ | ||
198 | }; | 186 | }; |
199 | 187 | ||
200 | struct be_cmd_resp_hdr { | 188 | struct be_cmd_resp_hdr { |
@@ -286,15 +274,15 @@ struct mgmt_conn_login_options { | |||
286 | struct mgmt_auth_method_format auth_data; | 274 | struct mgmt_auth_method_format auth_data; |
287 | } __packed; | 275 | } __packed; |
288 | 276 | ||
289 | struct ip_addr_format { | 277 | struct ip_address_format { |
290 | u16 size_of_structure; | 278 | u16 size_of_structure; |
291 | u8 reserved; | 279 | u8 reserved; |
292 | u8 ip_type; | 280 | u8 ip_type; |
293 | u8 addr[16]; | 281 | u8 ip_address[16]; |
294 | u32 rsvd0; | 282 | u32 rsvd0; |
295 | } __packed; | 283 | } __packed; |
296 | 284 | ||
297 | struct mgmt_conn_info { | 285 | struct mgmt_conn_info { |
298 | u32 connection_handle; | 286 | u32 connection_handle; |
299 | u32 connection_status; | 287 | u32 connection_status; |
300 | u16 src_port; | 288 | u16 src_port; |
@@ -302,9 +290,9 @@ struct mgmt_conn_info { | |||
302 | u16 dest_port_redirected; | 290 | u16 dest_port_redirected; |
303 | u16 cid; | 291 | u16 cid; |
304 | u32 estimated_throughput; | 292 | u32 estimated_throughput; |
305 | struct ip_addr_format src_ipaddr; | 293 | struct ip_address_format src_ipaddr; |
306 | struct ip_addr_format dest_ipaddr; | 294 | struct ip_address_format dest_ipaddr; |
307 | struct ip_addr_format dest_ipaddr_redirected; | 295 | struct ip_address_format dest_ipaddr_redirected; |
308 | struct mgmt_conn_login_options negotiated_login_options; | 296 | struct mgmt_conn_login_options negotiated_login_options; |
309 | } __packed; | 297 | } __packed; |
310 | 298 | ||
@@ -334,138 +322,43 @@ struct mgmt_session_info { | |||
334 | struct mgmt_conn_info conn_list[1]; | 322 | struct mgmt_conn_info conn_list[1]; |
335 | } __packed; | 323 | } __packed; |
336 | 324 | ||
337 | struct be_cmd_get_session_req { | 325 | struct be_cmd_req_get_session { |
338 | struct be_cmd_req_hdr hdr; | 326 | struct be_cmd_req_hdr hdr; |
339 | u32 session_handle; | 327 | u32 session_handle; |
340 | } __packed; | 328 | } __packed; |
341 | 329 | ||
342 | struct be_cmd_get_session_resp { | 330 | struct be_cmd_resp_get_session { |
343 | struct be_cmd_resp_hdr hdr; | 331 | struct be_cmd_resp_hdr hdr; |
344 | struct mgmt_session_info session_info; | 332 | struct mgmt_session_info session_info; |
345 | } __packed; | 333 | } __packed; |
346 | 334 | ||
347 | struct mac_addr { | 335 | struct mac_addr { |
348 | u16 size_of_structure; | 336 | u16 size_of_struct; |
349 | u8 addr[ETH_ALEN]; | 337 | u8 addr[ETH_ALEN]; |
350 | } __packed; | 338 | } __packed; |
351 | 339 | ||
352 | struct be_cmd_get_boot_target_req { | 340 | struct be_cmd_req_get_boot_target { |
353 | struct be_cmd_req_hdr hdr; | 341 | struct be_cmd_req_hdr hdr; |
354 | } __packed; | 342 | } __packed; |
355 | 343 | ||
356 | struct be_cmd_get_boot_target_resp { | 344 | struct be_cmd_resp_get_boot_target { |
357 | struct be_cmd_resp_hdr hdr; | 345 | struct be_cmd_resp_hdr hdr; |
358 | u32 boot_session_count; | 346 | u32 boot_session_count; |
359 | int boot_session_handle; | 347 | int boot_session_handle; |
360 | }; | 348 | }; |
361 | 349 | ||
362 | struct be_cmd_reopen_session_req { | 350 | struct be_cmd_req_mac_query { |
363 | struct be_cmd_req_hdr hdr; | ||
364 | #define BE_REOPEN_ALL_SESSIONS 0x00 | ||
365 | #define BE_REOPEN_BOOT_SESSIONS 0x01 | ||
366 | #define BE_REOPEN_A_SESSION 0x02 | ||
367 | u16 reopen_type; | ||
368 | u16 rsvd; | ||
369 | u32 session_handle; | ||
370 | } __packed; | ||
371 | |||
372 | struct be_cmd_reopen_session_resp { | ||
373 | struct be_cmd_resp_hdr hdr; | ||
374 | u32 rsvd; | ||
375 | u32 session_handle; | ||
376 | } __packed; | ||
377 | |||
378 | |||
379 | struct be_cmd_mac_query_req { | ||
380 | struct be_cmd_req_hdr hdr; | 351 | struct be_cmd_req_hdr hdr; |
381 | u8 type; | 352 | u8 type; |
382 | u8 permanent; | 353 | u8 permanent; |
383 | u16 if_id; | 354 | u16 if_id; |
384 | } __packed; | 355 | } __packed; |
385 | 356 | ||
386 | struct be_cmd_get_mac_resp { | 357 | struct be_cmd_resp_mac_query { |
387 | struct be_cmd_resp_hdr hdr; | 358 | struct be_cmd_resp_hdr hdr; |
388 | struct mac_addr mac; | 359 | struct mac_addr mac; |
389 | }; | 360 | }; |
390 | 361 | ||
391 | struct be_ip_addr_subnet_format { | ||
392 | u16 size_of_structure; | ||
393 | u8 ip_type; | ||
394 | u8 ipv6_prefix_length; | ||
395 | u8 addr[16]; | ||
396 | u8 subnet_mask[16]; | ||
397 | u32 rsvd0; | ||
398 | } __packed; | ||
399 | |||
400 | struct be_cmd_get_if_info_req { | ||
401 | struct be_cmd_req_hdr hdr; | ||
402 | u32 interface_hndl; | ||
403 | u32 ip_type; | ||
404 | } __packed; | ||
405 | |||
406 | struct be_cmd_get_if_info_resp { | ||
407 | struct be_cmd_req_hdr hdr; | ||
408 | u32 interface_hndl; | ||
409 | u32 vlan_priority; | ||
410 | u32 ip_addr_count; | ||
411 | u32 dhcp_state; | ||
412 | struct be_ip_addr_subnet_format ip_addr; | ||
413 | } __packed; | ||
414 | |||
415 | struct be_ip_addr_record { | ||
416 | u32 action; | ||
417 | u32 interface_hndl; | ||
418 | struct be_ip_addr_subnet_format ip_addr; | ||
419 | u32 status; | ||
420 | } __packed; | ||
421 | |||
422 | struct be_ip_addr_record_params { | ||
423 | u32 record_entry_count; | ||
424 | struct be_ip_addr_record ip_record; | ||
425 | } __packed; | ||
426 | |||
427 | struct be_cmd_set_ip_addr_req { | ||
428 | struct be_cmd_req_hdr hdr; | ||
429 | struct be_ip_addr_record_params ip_params; | ||
430 | } __packed; | ||
431 | |||
432 | |||
433 | struct be_cmd_set_dhcp_req { | ||
434 | struct be_cmd_req_hdr hdr; | ||
435 | u32 interface_hndl; | ||
436 | u32 ip_type; | ||
437 | u32 flags; | ||
438 | u32 retry_count; | ||
439 | } __packed; | ||
440 | |||
441 | struct be_cmd_rel_dhcp_req { | ||
442 | struct be_cmd_req_hdr hdr; | ||
443 | u32 interface_hndl; | ||
444 | u32 ip_type; | ||
445 | } __packed; | ||
446 | |||
447 | struct be_cmd_set_def_gateway_req { | ||
448 | struct be_cmd_req_hdr hdr; | ||
449 | u32 action; | ||
450 | struct ip_addr_format ip_addr; | ||
451 | } __packed; | ||
452 | |||
453 | struct be_cmd_get_def_gateway_req { | ||
454 | struct be_cmd_req_hdr hdr; | ||
455 | u32 ip_type; | ||
456 | } __packed; | ||
457 | |||
458 | struct be_cmd_get_def_gateway_resp { | ||
459 | struct be_cmd_req_hdr hdr; | ||
460 | struct ip_addr_format ip_addr; | ||
461 | } __packed; | ||
462 | |||
463 | #define BEISCSI_VLAN_DISABLE 0xFFFF | ||
464 | struct be_cmd_set_vlan_req { | ||
465 | struct be_cmd_req_hdr hdr; | ||
466 | u32 interface_hndl; | ||
467 | u32 vlan_priority; | ||
468 | } __packed; | ||
469 | /******************** Create CQ ***************************/ | 362 | /******************** Create CQ ***************************/ |
470 | /** | 363 | /** |
471 | * Pseudo amap definition in which each bit of the actual structure is defined | 364 | * Pseudo amap definition in which each bit of the actual structure is defined |
@@ -494,28 +387,10 @@ struct amap_cq_context { | |||
494 | u8 rsvd5[32]; /* dword 3 */ | 387 | u8 rsvd5[32]; /* dword 3 */ |
495 | } __packed; | 388 | } __packed; |
496 | 389 | ||
497 | struct amap_cq_context_v2 { | ||
498 | u8 rsvd0[12]; /* dword 0 */ | ||
499 | u8 coalescwm[2]; /* dword 0 */ | ||
500 | u8 nodelay; /* dword 0 */ | ||
501 | u8 rsvd1[12]; /* dword 0 */ | ||
502 | u8 count[2]; /* dword 0 */ | ||
503 | u8 valid; /* dword 0 */ | ||
504 | u8 rsvd2; /* dword 0 */ | ||
505 | u8 eventable; /* dword 0 */ | ||
506 | u8 eqid[16]; /* dword 1 */ | ||
507 | u8 rsvd3[15]; /* dword 1 */ | ||
508 | u8 armed; /* dword 1 */ | ||
509 | u8 cqecount[16];/* dword 2 */ | ||
510 | u8 rsvd4[16]; /* dword 2 */ | ||
511 | u8 rsvd5[32]; /* dword 3 */ | ||
512 | }; | ||
513 | |||
514 | struct be_cmd_req_cq_create { | 390 | struct be_cmd_req_cq_create { |
515 | struct be_cmd_req_hdr hdr; | 391 | struct be_cmd_req_hdr hdr; |
516 | u16 num_pages; | 392 | u16 num_pages; |
517 | u8 page_size; | 393 | u16 rsvd0; |
518 | u8 rsvd0; | ||
519 | u8 context[sizeof(struct amap_cq_context) / 8]; | 394 | u8 context[sizeof(struct amap_cq_context) / 8]; |
520 | struct phys_addr pages[4]; | 395 | struct phys_addr pages[4]; |
521 | } __packed; | 396 | } __packed; |
@@ -614,7 +489,7 @@ struct be_cmd_req_modify_eq_delay { | |||
614 | 489 | ||
615 | #define ETH_ALEN 6 | 490 | #define ETH_ALEN 6 |
616 | 491 | ||
617 | struct be_cmd_get_nic_conf_req { | 492 | struct be_cmd_req_get_mac_addr { |
618 | struct be_cmd_req_hdr hdr; | 493 | struct be_cmd_req_hdr hdr; |
619 | u32 nic_port_count; | 494 | u32 nic_port_count; |
620 | u32 speed; | 495 | u32 speed; |
@@ -626,7 +501,7 @@ struct be_cmd_get_nic_conf_req { | |||
626 | u32 rsvd[23]; | 501 | u32 rsvd[23]; |
627 | }; | 502 | }; |
628 | 503 | ||
629 | struct be_cmd_get_nic_conf_resp { | 504 | struct be_cmd_resp_get_mac_addr { |
630 | struct be_cmd_resp_hdr hdr; | 505 | struct be_cmd_resp_hdr hdr; |
631 | u32 nic_port_count; | 506 | u32 nic_port_count; |
632 | u32 speed; | 507 | u32 speed; |
@@ -638,39 +513,6 @@ struct be_cmd_get_nic_conf_resp { | |||
638 | u32 rsvd[23]; | 513 | u32 rsvd[23]; |
639 | }; | 514 | }; |
640 | 515 | ||
641 | #define BEISCSI_ALIAS_LEN 32 | ||
642 | |||
643 | struct be_cmd_hba_name { | ||
644 | struct be_cmd_req_hdr hdr; | ||
645 | u16 flags; | ||
646 | u16 rsvd0; | ||
647 | u8 initiator_name[ISCSI_NAME_LEN]; | ||
648 | u8 initiator_alias[BEISCSI_ALIAS_LEN]; | ||
649 | } __packed; | ||
650 | |||
651 | struct be_cmd_ntwk_link_status_req { | ||
652 | struct be_cmd_req_hdr hdr; | ||
653 | u32 rsvd0; | ||
654 | } __packed; | ||
655 | |||
656 | /*** Port Speed Values ***/ | ||
657 | #define BE2ISCSI_LINK_SPEED_ZERO 0x00 | ||
658 | #define BE2ISCSI_LINK_SPEED_10MBPS 0x01 | ||
659 | #define BE2ISCSI_LINK_SPEED_100MBPS 0x02 | ||
660 | #define BE2ISCSI_LINK_SPEED_1GBPS 0x03 | ||
661 | #define BE2ISCSI_LINK_SPEED_10GBPS 0x04 | ||
662 | struct be_cmd_ntwk_link_status_resp { | ||
663 | struct be_cmd_resp_hdr hdr; | ||
664 | u8 phys_port; | ||
665 | u8 mac_duplex; | ||
666 | u8 mac_speed; | ||
667 | u8 mac_fault; | ||
668 | u8 mgmt_mac_duplex; | ||
669 | u8 mgmt_mac_speed; | ||
670 | u16 qos_link_speed; | ||
671 | u32 logical_link_speed; | ||
672 | } __packed; | ||
673 | |||
674 | int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, | 516 | int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, |
675 | struct be_queue_info *eq, int eq_delay); | 517 | struct be_queue_info *eq, int eq_delay); |
676 | 518 | ||
@@ -688,13 +530,13 @@ int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba, | |||
688 | int be_poll_mcc(struct be_ctrl_info *ctrl); | 530 | int be_poll_mcc(struct be_ctrl_info *ctrl); |
689 | int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, | 531 | int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, |
690 | struct beiscsi_hba *phba); | 532 | struct beiscsi_hba *phba); |
691 | unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); | 533 | unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba); |
692 | unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba); | 534 | unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba); |
535 | unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba, | ||
536 | u32 boot_session_handle, | ||
537 | struct be_dma_mem *nonemb_cmd); | ||
693 | 538 | ||
694 | void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); | 539 | void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); |
695 | |||
696 | int beiscsi_mccq_compl(struct beiscsi_hba *phba, | ||
697 | uint32_t tag, struct be_mcc_wrb **wrb, void *cmd_va); | ||
698 | /*ISCSI Functuions */ | 540 | /*ISCSI Functuions */ |
699 | int be_cmd_fw_initialize(struct be_ctrl_info *ctrl); | 541 | int be_cmd_fw_initialize(struct be_ctrl_info *ctrl); |
700 | 542 | ||
@@ -719,16 +561,11 @@ int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl, | |||
719 | struct be_dma_mem *q_mem, u32 page_offset, | 561 | struct be_dma_mem *q_mem, u32 page_offset, |
720 | u32 num_pages); | 562 | u32 num_pages); |
721 | 563 | ||
722 | int beiscsi_cmd_reset_function(struct beiscsi_hba *phba); | ||
723 | |||
724 | int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem, | 564 | int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem, |
725 | struct be_queue_info *wrbq); | 565 | struct be_queue_info *wrbq); |
726 | 566 | ||
727 | bool is_link_state_evt(u32 trailer); | 567 | bool is_link_state_evt(u32 trailer); |
728 | 568 | ||
729 | /* Configuration Functions */ | ||
730 | int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); | ||
731 | |||
732 | struct be_default_pdu_context { | 569 | struct be_default_pdu_context { |
733 | u32 dw[4]; | 570 | u32 dw[4]; |
734 | } __packed; | 571 | } __packed; |
@@ -836,59 +673,6 @@ struct amap_sol_cqe_ring { | |||
836 | u8 valid; /* dword 3 */ | 673 | u8 valid; /* dword 3 */ |
837 | } __packed; | 674 | } __packed; |
838 | 675 | ||
839 | struct amap_sol_cqe_v2 { | ||
840 | u8 hw_sts[8]; /* dword 0 */ | ||
841 | u8 i_sts[8]; /* dword 0 */ | ||
842 | u8 wrb_index[16]; /* dword 0 */ | ||
843 | u8 i_exp_cmd_sn[32]; /* dword 1 */ | ||
844 | u8 code[6]; /* dword 2 */ | ||
845 | u8 cmd_cmpl; /* dword 2 */ | ||
846 | u8 rsvd0; /* dword 2 */ | ||
847 | u8 i_cmd_wnd[8]; /* dword 2 */ | ||
848 | u8 cid[13]; /* dword 2 */ | ||
849 | u8 u; /* dword 2 */ | ||
850 | u8 o; /* dword 2 */ | ||
851 | u8 s; /* dword 2 */ | ||
852 | u8 i_res_cnt[31]; /* dword 3 */ | ||
853 | u8 valid; /* dword 3 */ | ||
854 | } __packed; | ||
855 | |||
856 | struct common_sol_cqe { | ||
857 | u32 exp_cmdsn; | ||
858 | u32 res_cnt; | ||
859 | u16 wrb_index; | ||
860 | u16 cid; | ||
861 | u8 hw_sts; | ||
862 | u8 cmd_wnd; | ||
863 | u8 res_flag; /* the s feild of structure */ | ||
864 | u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */ | ||
865 | u8 i_flags; /* for skh or the u and o feilds */ | ||
866 | u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */ | ||
867 | }; | ||
868 | |||
869 | /*** iSCSI ack/driver message completions ***/ | ||
870 | struct amap_it_dmsg_cqe { | ||
871 | u8 ack_num[32]; /* DWORD 0 */ | ||
872 | u8 pdu_bytes_rcvd[32]; /* DWORD 1 */ | ||
873 | u8 code[6]; /* DWORD 2 */ | ||
874 | u8 cid[10]; /* DWORD 2 */ | ||
875 | u8 wrb_idx[8]; /* DWORD 2 */ | ||
876 | u8 rsvd0[8]; /* DWORD 2*/ | ||
877 | u8 rsvd1[31]; /* DWORD 3*/ | ||
878 | u8 valid; /* DWORD 3 */ | ||
879 | } __packed; | ||
880 | |||
881 | struct amap_it_dmsg_cqe_v2 { | ||
882 | u8 ack_num[32]; /* DWORD 0 */ | ||
883 | u8 pdu_bytes_rcvd[32]; /* DWORD 1 */ | ||
884 | u8 code[6]; /* DWORD 2 */ | ||
885 | u8 rsvd0[10]; /* DWORD 2 */ | ||
886 | u8 wrb_idx[16]; /* DWORD 2 */ | ||
887 | u8 rsvd1[16]; /* DWORD 3 */ | ||
888 | u8 cid[13]; /* DWORD 3 */ | ||
889 | u8 rsvd2[2]; /* DWORD 3 */ | ||
890 | u8 valid; /* DWORD 3 */ | ||
891 | } __packed; | ||
892 | 676 | ||
893 | 677 | ||
894 | /** | 678 | /** |
@@ -929,7 +713,7 @@ struct be_eq_delay_params_in { | |||
929 | 713 | ||
930 | struct tcp_connect_and_offload_in { | 714 | struct tcp_connect_and_offload_in { |
931 | struct be_cmd_req_hdr hdr; | 715 | struct be_cmd_req_hdr hdr; |
932 | struct ip_addr_format ip_address; | 716 | struct ip_address_format ip_address; |
933 | u16 tcp_port; | 717 | u16 tcp_port; |
934 | u16 cid; | 718 | u16 cid; |
935 | u16 cq_id; | 719 | u16 cq_id; |
@@ -1006,14 +790,13 @@ struct be_fw_cfg { | |||
1006 | u32 function_caps; | 790 | u32 function_caps; |
1007 | } __packed; | 791 | } __packed; |
1008 | 792 | ||
1009 | struct be_cmd_get_all_if_id_req { | 793 | struct be_all_if_id { |
1010 | struct be_cmd_req_hdr hdr; | 794 | struct be_cmd_req_hdr hdr; |
1011 | u32 if_count; | 795 | u32 if_count; |
1012 | u32 if_hndl_list[1]; | 796 | u32 if_hndl_list[1]; |
1013 | } __packed; | 797 | } __packed; |
1014 | 798 | ||
1015 | #define ISCSI_OPCODE_SCSI_DATA_OUT 5 | 799 | #define ISCSI_OPCODE_SCSI_DATA_OUT 5 |
1016 | #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5 | ||
1017 | #define OPCODE_COMMON_MODIFY_EQ_DELAY 41 | 800 | #define OPCODE_COMMON_MODIFY_EQ_DELAY 41 |
1018 | #define OPCODE_COMMON_ISCSI_CLEANUP 59 | 801 | #define OPCODE_COMMON_ISCSI_CLEANUP 59 |
1019 | #define OPCODE_COMMON_TCP_UPLOAD 56 | 802 | #define OPCODE_COMMON_TCP_UPLOAD 56 |
@@ -1022,12 +805,9 @@ struct be_cmd_get_all_if_id_req { | |||
1022 | #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6 | 805 | #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6 |
1023 | #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7 | 806 | #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7 |
1024 | #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14 | 807 | #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14 |
1025 | #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36 | ||
1026 | #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41 | 808 | #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41 |
1027 | #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42 | 809 | #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42 |
1028 | #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52 | 810 | #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52 |
1029 | #define OPCODE_COMMON_WRITE_FLASH 96 | ||
1030 | #define OPCODE_COMMON_READ_FLASH 97 | ||
1031 | 811 | ||
1032 | /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */ | 812 | /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */ |
1033 | #define CMD_ISCSI_COMMAND_INVALIDATE 1 | 813 | #define CMD_ISCSI_COMMAND_INVALIDATE 1 |
@@ -1077,6 +857,8 @@ struct be_cmd_get_all_if_id_req { | |||
1077 | #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset, | 857 | #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset, |
1078 | * sequence number by driver */ | 858 | * sequence number by driver */ |
1079 | 859 | ||
860 | /* Returns byte size of given field with a structure. */ | ||
861 | |||
1080 | /* Returns the number of items in the field array. */ | 862 | /* Returns the number of items in the field array. */ |
1081 | #define BE_NUMBER_OF_FIELD(_type_, _field_) \ | 863 | #define BE_NUMBER_OF_FIELD(_type_, _field_) \ |
1082 | (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\ | 864 | (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\ |
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 214d691adb5..3cad1060502 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -23,8 +23,6 @@ | |||
23 | #include <scsi/scsi_cmnd.h> | 23 | #include <scsi/scsi_cmnd.h> |
24 | #include <scsi/scsi_device.h> | 24 | #include <scsi/scsi_device.h> |
25 | #include <scsi/scsi_host.h> | 25 | #include <scsi/scsi_host.h> |
26 | #include <scsi/scsi_netlink.h> | ||
27 | #include <net/netlink.h> | ||
28 | #include <scsi/scsi.h> | 26 | #include <scsi/scsi.h> |
29 | 27 | ||
30 | #include "be_iscsi.h" | 28 | #include "be_iscsi.h" |
@@ -50,27 +48,21 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, | |||
50 | struct beiscsi_session *beiscsi_sess; | 48 | struct beiscsi_session *beiscsi_sess; |
51 | struct beiscsi_io_task *io_task; | 49 | struct beiscsi_io_task *io_task; |
52 | 50 | ||
51 | SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n"); | ||
53 | 52 | ||
54 | if (!ep) { | 53 | if (!ep) { |
55 | printk(KERN_ERR | 54 | SE_DEBUG(DBG_LVL_1, "beiscsi_session_create: invalid ep\n"); |
56 | "beiscsi_session_create: invalid ep\n"); | ||
57 | return NULL; | 55 | return NULL; |
58 | } | 56 | } |
59 | beiscsi_ep = ep->dd_data; | 57 | beiscsi_ep = ep->dd_data; |
60 | phba = beiscsi_ep->phba; | 58 | phba = beiscsi_ep->phba; |
61 | shost = phba->shost; | 59 | shost = phba->shost; |
62 | |||
63 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | ||
64 | "BS_%d : In beiscsi_session_create\n"); | ||
65 | |||
66 | if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { | 60 | if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { |
67 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 61 | shost_printk(KERN_ERR, shost, "Cannot handle %d cmds." |
68 | "BS_%d : Cannot handle %d cmds." | 62 | "Max cmds per session supported is %d. Using %d. " |
69 | "Max cmds per session supported is %d. Using %d." | 63 | "\n", cmds_max, |
70 | "\n", cmds_max, | 64 | beiscsi_ep->phba->params.wrbs_per_cxn, |
71 | beiscsi_ep->phba->params.wrbs_per_cxn, | 65 | beiscsi_ep->phba->params.wrbs_per_cxn); |
72 | beiscsi_ep->phba->params.wrbs_per_cxn); | ||
73 | |||
74 | cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; | 66 | cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; |
75 | } | 67 | } |
76 | 68 | ||
@@ -108,7 +100,7 @@ void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) | |||
108 | struct iscsi_session *sess = cls_session->dd_data; | 100 | struct iscsi_session *sess = cls_session->dd_data; |
109 | struct beiscsi_session *beiscsi_sess = sess->dd_data; | 101 | struct beiscsi_session *beiscsi_sess = sess->dd_data; |
110 | 102 | ||
111 | printk(KERN_INFO "In beiscsi_session_destroy\n"); | 103 | SE_DEBUG(DBG_LVL_8, "In beiscsi_session_destroy\n"); |
112 | pci_pool_destroy(beiscsi_sess->bhs_pool); | 104 | pci_pool_destroy(beiscsi_sess->bhs_pool); |
113 | iscsi_session_teardown(cls_session); | 105 | iscsi_session_teardown(cls_session); |
114 | } | 106 | } |
@@ -129,13 +121,11 @@ beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) | |||
129 | struct iscsi_session *sess; | 121 | struct iscsi_session *sess; |
130 | struct beiscsi_session *beiscsi_sess; | 122 | struct beiscsi_session *beiscsi_sess; |
131 | 123 | ||
124 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_create ,cid" | ||
125 | "from iscsi layer=%d\n", cid); | ||
132 | shost = iscsi_session_to_shost(cls_session); | 126 | shost = iscsi_session_to_shost(cls_session); |
133 | phba = iscsi_host_priv(shost); | 127 | phba = iscsi_host_priv(shost); |
134 | 128 | ||
135 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | ||
136 | "BS_%d : In beiscsi_conn_create ,cid" | ||
137 | "from iscsi layer=%d\n", cid); | ||
138 | |||
139 | cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid); | 129 | cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid); |
140 | if (!cls_conn) | 130 | if (!cls_conn) |
141 | return NULL; | 131 | return NULL; |
@@ -162,15 +152,12 @@ static int beiscsi_bindconn_cid(struct beiscsi_hba *phba, | |||
162 | unsigned int cid) | 152 | unsigned int cid) |
163 | { | 153 | { |
164 | if (phba->conn_table[cid]) { | 154 | if (phba->conn_table[cid]) { |
165 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 155 | SE_DEBUG(DBG_LVL_1, |
166 | "BS_%d : Connection table already occupied. Detected clash\n"); | 156 | "Connection table already occupied. Detected clash\n"); |
167 | |||
168 | return -EINVAL; | 157 | return -EINVAL; |
169 | } else { | 158 | } else { |
170 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 159 | SE_DEBUG(DBG_LVL_8, "phba->conn_table[%d]=%p(beiscsi_conn)\n", |
171 | "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n", | 160 | cid, beiscsi_conn); |
172 | cid, beiscsi_conn); | ||
173 | |||
174 | phba->conn_table[cid] = beiscsi_conn; | 161 | phba->conn_table[cid] = beiscsi_conn; |
175 | } | 162 | } |
176 | return 0; | 163 | return 0; |
@@ -190,11 +177,13 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, | |||
190 | { | 177 | { |
191 | struct iscsi_conn *conn = cls_conn->dd_data; | 178 | struct iscsi_conn *conn = cls_conn->dd_data; |
192 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; | 179 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
193 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | 180 | struct Scsi_Host *shost = |
194 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | 181 | (struct Scsi_Host *)iscsi_session_to_shost(cls_session); |
182 | struct beiscsi_hba *phba = (struct beiscsi_hba *)iscsi_host_priv(shost); | ||
195 | struct beiscsi_endpoint *beiscsi_ep; | 183 | struct beiscsi_endpoint *beiscsi_ep; |
196 | struct iscsi_endpoint *ep; | 184 | struct iscsi_endpoint *ep; |
197 | 185 | ||
186 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_bind\n"); | ||
198 | ep = iscsi_lookup_endpoint(transport_fd); | 187 | ep = iscsi_lookup_endpoint(transport_fd); |
199 | if (!ep) | 188 | if (!ep) |
200 | return -EINVAL; | 189 | return -EINVAL; |
@@ -205,402 +194,20 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, | |||
205 | return -EINVAL; | 194 | return -EINVAL; |
206 | 195 | ||
207 | if (beiscsi_ep->phba != phba) { | 196 | if (beiscsi_ep->phba != phba) { |
208 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 197 | SE_DEBUG(DBG_LVL_8, |
209 | "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n", | 198 | "beiscsi_ep->hba=%p not equal to phba=%p\n", |
210 | beiscsi_ep->phba, phba); | 199 | beiscsi_ep->phba, phba); |
211 | |||
212 | return -EEXIST; | 200 | return -EEXIST; |
213 | } | 201 | } |
214 | 202 | ||
215 | beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; | 203 | beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; |
216 | beiscsi_conn->ep = beiscsi_ep; | 204 | beiscsi_conn->ep = beiscsi_ep; |
217 | beiscsi_ep->conn = beiscsi_conn; | 205 | beiscsi_ep->conn = beiscsi_conn; |
218 | 206 | SE_DEBUG(DBG_LVL_8, "beiscsi_conn=%p conn=%p ep_cid=%d\n", | |
219 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 207 | beiscsi_conn, conn, beiscsi_ep->ep_cid); |
220 | "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n", | ||
221 | beiscsi_conn, conn, beiscsi_ep->ep_cid); | ||
222 | |||
223 | return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid); | 208 | return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid); |
224 | } | 209 | } |
225 | 210 | ||
226 | static int beiscsi_create_ipv4_iface(struct beiscsi_hba *phba) | ||
227 | { | ||
228 | if (phba->ipv4_iface) | ||
229 | return 0; | ||
230 | |||
231 | phba->ipv4_iface = iscsi_create_iface(phba->shost, | ||
232 | &beiscsi_iscsi_transport, | ||
233 | ISCSI_IFACE_TYPE_IPV4, | ||
234 | 0, 0); | ||
235 | if (!phba->ipv4_iface) { | ||
236 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
237 | "BS_%d : Could not " | ||
238 | "create default IPv4 address.\n"); | ||
239 | return -ENODEV; | ||
240 | } | ||
241 | |||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | static int beiscsi_create_ipv6_iface(struct beiscsi_hba *phba) | ||
246 | { | ||
247 | if (phba->ipv6_iface) | ||
248 | return 0; | ||
249 | |||
250 | phba->ipv6_iface = iscsi_create_iface(phba->shost, | ||
251 | &beiscsi_iscsi_transport, | ||
252 | ISCSI_IFACE_TYPE_IPV6, | ||
253 | 0, 0); | ||
254 | if (!phba->ipv6_iface) { | ||
255 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
256 | "BS_%d : Could not " | ||
257 | "create default IPv6 address.\n"); | ||
258 | return -ENODEV; | ||
259 | } | ||
260 | |||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | void beiscsi_create_def_ifaces(struct beiscsi_hba *phba) | ||
265 | { | ||
266 | struct be_cmd_get_if_info_resp if_info; | ||
267 | |||
268 | if (!mgmt_get_if_info(phba, BE2_IPV4, &if_info)) | ||
269 | beiscsi_create_ipv4_iface(phba); | ||
270 | |||
271 | if (!mgmt_get_if_info(phba, BE2_IPV6, &if_info)) | ||
272 | beiscsi_create_ipv6_iface(phba); | ||
273 | } | ||
274 | |||
275 | void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba) | ||
276 | { | ||
277 | if (phba->ipv6_iface) | ||
278 | iscsi_destroy_iface(phba->ipv6_iface); | ||
279 | if (phba->ipv4_iface) | ||
280 | iscsi_destroy_iface(phba->ipv4_iface); | ||
281 | } | ||
282 | |||
283 | static int | ||
284 | beiscsi_set_static_ip(struct Scsi_Host *shost, | ||
285 | struct iscsi_iface_param_info *iface_param, | ||
286 | void *data, uint32_t dt_len) | ||
287 | { | ||
288 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
289 | struct iscsi_iface_param_info *iface_ip = NULL; | ||
290 | struct iscsi_iface_param_info *iface_subnet = NULL; | ||
291 | struct nlattr *nla; | ||
292 | int ret; | ||
293 | |||
294 | |||
295 | switch (iface_param->param) { | ||
296 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: | ||
297 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); | ||
298 | if (nla) | ||
299 | iface_ip = nla_data(nla); | ||
300 | |||
301 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); | ||
302 | if (nla) | ||
303 | iface_subnet = nla_data(nla); | ||
304 | break; | ||
305 | case ISCSI_NET_PARAM_IPV4_ADDR: | ||
306 | iface_ip = iface_param; | ||
307 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); | ||
308 | if (nla) | ||
309 | iface_subnet = nla_data(nla); | ||
310 | break; | ||
311 | case ISCSI_NET_PARAM_IPV4_SUBNET: | ||
312 | iface_subnet = iface_param; | ||
313 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); | ||
314 | if (nla) | ||
315 | iface_ip = nla_data(nla); | ||
316 | break; | ||
317 | default: | ||
318 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
319 | "BS_%d : Unsupported param %d\n", | ||
320 | iface_param->param); | ||
321 | } | ||
322 | |||
323 | if (!iface_ip || !iface_subnet) { | ||
324 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
325 | "BS_%d : IP and Subnet Mask required\n"); | ||
326 | return -EINVAL; | ||
327 | } | ||
328 | |||
329 | ret = mgmt_set_ip(phba, iface_ip, iface_subnet, | ||
330 | ISCSI_BOOTPROTO_STATIC); | ||
331 | |||
332 | return ret; | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * beiscsi_set_vlan_tag()- Set the VLAN TAG | ||
337 | * @shost: Scsi Host for the driver instance | ||
338 | * @iface_param: Interface paramters | ||
339 | * | ||
340 | * Set the VLAN TAG for the adapter or disable | ||
341 | * the VLAN config | ||
342 | * | ||
343 | * returns | ||
344 | * Success: 0 | ||
345 | * Failure: Non-Zero Value | ||
346 | **/ | ||
347 | static int | ||
348 | beiscsi_set_vlan_tag(struct Scsi_Host *shost, | ||
349 | struct iscsi_iface_param_info *iface_param) | ||
350 | { | ||
351 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
352 | int ret = 0; | ||
353 | |||
354 | /* Get the Interface Handle */ | ||
355 | if (mgmt_get_all_if_id(phba)) { | ||
356 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
357 | "BS_%d : Getting Interface Handle Failed\n"); | ||
358 | return -EIO; | ||
359 | } | ||
360 | |||
361 | switch (iface_param->param) { | ||
362 | case ISCSI_NET_PARAM_VLAN_ENABLED: | ||
363 | if (iface_param->value[0] != ISCSI_VLAN_ENABLE) | ||
364 | ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE); | ||
365 | break; | ||
366 | case ISCSI_NET_PARAM_VLAN_TAG: | ||
367 | ret = mgmt_set_vlan(phba, | ||
368 | *((uint16_t *)iface_param->value)); | ||
369 | break; | ||
370 | default: | ||
371 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
372 | "BS_%d : Unkown Param Type : %d\n", | ||
373 | iface_param->param); | ||
374 | return -ENOSYS; | ||
375 | } | ||
376 | return ret; | ||
377 | } | ||
378 | |||
379 | |||
380 | static int | ||
381 | beiscsi_set_ipv4(struct Scsi_Host *shost, | ||
382 | struct iscsi_iface_param_info *iface_param, | ||
383 | void *data, uint32_t dt_len) | ||
384 | { | ||
385 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
386 | int ret = 0; | ||
387 | |||
388 | /* Check the param */ | ||
389 | switch (iface_param->param) { | ||
390 | case ISCSI_NET_PARAM_IPV4_GW: | ||
391 | ret = mgmt_set_gateway(phba, iface_param); | ||
392 | break; | ||
393 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: | ||
394 | if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP) | ||
395 | ret = mgmt_set_ip(phba, iface_param, | ||
396 | NULL, ISCSI_BOOTPROTO_DHCP); | ||
397 | else if (iface_param->value[0] == ISCSI_BOOTPROTO_STATIC) | ||
398 | ret = beiscsi_set_static_ip(shost, iface_param, | ||
399 | data, dt_len); | ||
400 | else | ||
401 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
402 | "BS_%d : Invalid BOOTPROTO: %d\n", | ||
403 | iface_param->value[0]); | ||
404 | break; | ||
405 | case ISCSI_NET_PARAM_IFACE_ENABLE: | ||
406 | if (iface_param->value[0] == ISCSI_IFACE_ENABLE) | ||
407 | ret = beiscsi_create_ipv4_iface(phba); | ||
408 | else | ||
409 | iscsi_destroy_iface(phba->ipv4_iface); | ||
410 | break; | ||
411 | case ISCSI_NET_PARAM_IPV4_SUBNET: | ||
412 | case ISCSI_NET_PARAM_IPV4_ADDR: | ||
413 | ret = beiscsi_set_static_ip(shost, iface_param, | ||
414 | data, dt_len); | ||
415 | break; | ||
416 | case ISCSI_NET_PARAM_VLAN_ENABLED: | ||
417 | case ISCSI_NET_PARAM_VLAN_TAG: | ||
418 | ret = beiscsi_set_vlan_tag(shost, iface_param); | ||
419 | break; | ||
420 | default: | ||
421 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
422 | "BS_%d : Param %d not supported\n", | ||
423 | iface_param->param); | ||
424 | } | ||
425 | |||
426 | return ret; | ||
427 | } | ||
428 | |||
429 | static int | ||
430 | beiscsi_set_ipv6(struct Scsi_Host *shost, | ||
431 | struct iscsi_iface_param_info *iface_param, | ||
432 | void *data, uint32_t dt_len) | ||
433 | { | ||
434 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
435 | int ret = 0; | ||
436 | |||
437 | switch (iface_param->param) { | ||
438 | case ISCSI_NET_PARAM_IFACE_ENABLE: | ||
439 | if (iface_param->value[0] == ISCSI_IFACE_ENABLE) | ||
440 | ret = beiscsi_create_ipv6_iface(phba); | ||
441 | else { | ||
442 | iscsi_destroy_iface(phba->ipv6_iface); | ||
443 | ret = 0; | ||
444 | } | ||
445 | break; | ||
446 | case ISCSI_NET_PARAM_IPV6_ADDR: | ||
447 | ret = mgmt_set_ip(phba, iface_param, NULL, | ||
448 | ISCSI_BOOTPROTO_STATIC); | ||
449 | break; | ||
450 | default: | ||
451 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
452 | "BS_%d : Param %d not supported\n", | ||
453 | iface_param->param); | ||
454 | } | ||
455 | |||
456 | return ret; | ||
457 | } | ||
458 | |||
459 | int be2iscsi_iface_set_param(struct Scsi_Host *shost, | ||
460 | void *data, uint32_t dt_len) | ||
461 | { | ||
462 | struct iscsi_iface_param_info *iface_param = NULL; | ||
463 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
464 | struct nlattr *attrib; | ||
465 | uint32_t rm_len = dt_len; | ||
466 | int ret = 0 ; | ||
467 | |||
468 | nla_for_each_attr(attrib, data, dt_len, rm_len) { | ||
469 | iface_param = nla_data(attrib); | ||
470 | |||
471 | if (iface_param->param_type != ISCSI_NET_PARAM) | ||
472 | continue; | ||
473 | |||
474 | /* | ||
475 | * BE2ISCSI only supports 1 interface | ||
476 | */ | ||
477 | if (iface_param->iface_num) { | ||
478 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
479 | "BS_%d : Invalid iface_num %d." | ||
480 | "Only iface_num 0 is supported.\n", | ||
481 | iface_param->iface_num); | ||
482 | |||
483 | return -EINVAL; | ||
484 | } | ||
485 | |||
486 | switch (iface_param->iface_type) { | ||
487 | case ISCSI_IFACE_TYPE_IPV4: | ||
488 | ret = beiscsi_set_ipv4(shost, iface_param, | ||
489 | data, dt_len); | ||
490 | break; | ||
491 | case ISCSI_IFACE_TYPE_IPV6: | ||
492 | ret = beiscsi_set_ipv6(shost, iface_param, | ||
493 | data, dt_len); | ||
494 | break; | ||
495 | default: | ||
496 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
497 | "BS_%d : Invalid iface type :%d passed\n", | ||
498 | iface_param->iface_type); | ||
499 | break; | ||
500 | } | ||
501 | |||
502 | if (ret) | ||
503 | return ret; | ||
504 | } | ||
505 | |||
506 | return ret; | ||
507 | } | ||
508 | |||
509 | static int be2iscsi_get_if_param(struct beiscsi_hba *phba, | ||
510 | struct iscsi_iface *iface, int param, | ||
511 | char *buf) | ||
512 | { | ||
513 | struct be_cmd_get_if_info_resp if_info; | ||
514 | int len, ip_type = BE2_IPV4; | ||
515 | |||
516 | memset(&if_info, 0, sizeof(if_info)); | ||
517 | |||
518 | if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) | ||
519 | ip_type = BE2_IPV6; | ||
520 | |||
521 | len = mgmt_get_if_info(phba, ip_type, &if_info); | ||
522 | if (len) | ||
523 | return len; | ||
524 | |||
525 | switch (param) { | ||
526 | case ISCSI_NET_PARAM_IPV4_ADDR: | ||
527 | len = sprintf(buf, "%pI4\n", &if_info.ip_addr.addr); | ||
528 | break; | ||
529 | case ISCSI_NET_PARAM_IPV6_ADDR: | ||
530 | len = sprintf(buf, "%pI6\n", &if_info.ip_addr.addr); | ||
531 | break; | ||
532 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: | ||
533 | if (!if_info.dhcp_state) | ||
534 | len = sprintf(buf, "static\n"); | ||
535 | else | ||
536 | len = sprintf(buf, "dhcp\n"); | ||
537 | break; | ||
538 | case ISCSI_NET_PARAM_IPV4_SUBNET: | ||
539 | len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask); | ||
540 | break; | ||
541 | case ISCSI_NET_PARAM_VLAN_ENABLED: | ||
542 | len = sprintf(buf, "%s\n", | ||
543 | (if_info.vlan_priority == BEISCSI_VLAN_DISABLE) | ||
544 | ? "Disabled\n" : "Enabled\n"); | ||
545 | break; | ||
546 | case ISCSI_NET_PARAM_VLAN_ID: | ||
547 | if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE) | ||
548 | return -EINVAL; | ||
549 | else | ||
550 | len = sprintf(buf, "%d\n", | ||
551 | (if_info.vlan_priority & | ||
552 | ISCSI_MAX_VLAN_ID)); | ||
553 | break; | ||
554 | case ISCSI_NET_PARAM_VLAN_PRIORITY: | ||
555 | if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE) | ||
556 | return -EINVAL; | ||
557 | else | ||
558 | len = sprintf(buf, "%d\n", | ||
559 | ((if_info.vlan_priority >> 13) & | ||
560 | ISCSI_MAX_VLAN_PRIORITY)); | ||
561 | break; | ||
562 | default: | ||
563 | WARN_ON(1); | ||
564 | } | ||
565 | |||
566 | return len; | ||
567 | } | ||
568 | |||
569 | int be2iscsi_iface_get_param(struct iscsi_iface *iface, | ||
570 | enum iscsi_param_type param_type, | ||
571 | int param, char *buf) | ||
572 | { | ||
573 | struct Scsi_Host *shost = iscsi_iface_to_shost(iface); | ||
574 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
575 | struct be_cmd_get_def_gateway_resp gateway; | ||
576 | int len = -ENOSYS; | ||
577 | |||
578 | switch (param) { | ||
579 | case ISCSI_NET_PARAM_IPV4_ADDR: | ||
580 | case ISCSI_NET_PARAM_IPV4_SUBNET: | ||
581 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: | ||
582 | case ISCSI_NET_PARAM_IPV6_ADDR: | ||
583 | case ISCSI_NET_PARAM_VLAN_ENABLED: | ||
584 | case ISCSI_NET_PARAM_VLAN_ID: | ||
585 | case ISCSI_NET_PARAM_VLAN_PRIORITY: | ||
586 | len = be2iscsi_get_if_param(phba, iface, param, buf); | ||
587 | break; | ||
588 | case ISCSI_NET_PARAM_IFACE_ENABLE: | ||
589 | len = sprintf(buf, "enabled\n"); | ||
590 | break; | ||
591 | case ISCSI_NET_PARAM_IPV4_GW: | ||
592 | memset(&gateway, 0, sizeof(gateway)); | ||
593 | len = mgmt_get_gateway(phba, BE2_IPV4, &gateway); | ||
594 | if (!len) | ||
595 | len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); | ||
596 | break; | ||
597 | default: | ||
598 | len = -ENOSYS; | ||
599 | } | ||
600 | |||
601 | return len; | ||
602 | } | ||
603 | |||
604 | /** | 211 | /** |
605 | * beiscsi_ep_get_param - get the iscsi parameter | 212 | * beiscsi_ep_get_param - get the iscsi parameter |
606 | * @ep: pointer to iscsi ep | 213 | * @ep: pointer to iscsi ep |
@@ -615,10 +222,7 @@ int beiscsi_ep_get_param(struct iscsi_endpoint *ep, | |||
615 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; | 222 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
616 | int len = 0; | 223 | int len = 0; |
617 | 224 | ||
618 | beiscsi_log(beiscsi_ep->phba, KERN_INFO, | 225 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_get_param, param= %d\n", param); |
619 | BEISCSI_LOG_CONFIG, | ||
620 | "BS_%d : In beiscsi_ep_get_param," | ||
621 | " param= %d\n", param); | ||
622 | 226 | ||
623 | switch (param) { | 227 | switch (param) { |
624 | case ISCSI_PARAM_CONN_PORT: | 228 | case ISCSI_PARAM_CONN_PORT: |
@@ -641,14 +245,9 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, | |||
641 | { | 245 | { |
642 | struct iscsi_conn *conn = cls_conn->dd_data; | 246 | struct iscsi_conn *conn = cls_conn->dd_data; |
643 | struct iscsi_session *session = conn->session; | 247 | struct iscsi_session *session = conn->session; |
644 | struct beiscsi_hba *phba = NULL; | ||
645 | int ret; | 248 | int ret; |
646 | 249 | ||
647 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; | 250 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_set_param, param= %d\n", param); |
648 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | ||
649 | "BS_%d : In beiscsi_conn_set_param," | ||
650 | " param= %d\n", param); | ||
651 | |||
652 | ret = iscsi_set_param(cls_conn, param, buf, buflen); | 251 | ret = iscsi_set_param(cls_conn, param, buf, buflen); |
653 | if (ret) | 252 | if (ret) |
654 | return ret; | 253 | return ret; |
@@ -681,105 +280,6 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, | |||
681 | } | 280 | } |
682 | 281 | ||
683 | /** | 282 | /** |
684 | * beiscsi_get_initname - Read Initiator Name from flash | ||
685 | * @buf: buffer bointer | ||
686 | * @phba: The device priv structure instance | ||
687 | * | ||
688 | * returns number of bytes | ||
689 | */ | ||
690 | static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba) | ||
691 | { | ||
692 | int rc; | ||
693 | unsigned int tag; | ||
694 | struct be_mcc_wrb *wrb; | ||
695 | struct be_cmd_hba_name *resp; | ||
696 | |||
697 | tag = be_cmd_get_initname(phba); | ||
698 | if (!tag) { | ||
699 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
700 | "BS_%d : Getting Initiator Name Failed\n"); | ||
701 | |||
702 | return -EBUSY; | ||
703 | } | ||
704 | |||
705 | rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); | ||
706 | if (rc) { | ||
707 | beiscsi_log(phba, KERN_ERR, | ||
708 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
709 | "BS_%d : Initiator Name MBX Failed\n"); | ||
710 | return rc; | ||
711 | } | ||
712 | |||
713 | resp = embedded_payload(wrb); | ||
714 | rc = sprintf(buf, "%s\n", resp->initiator_name); | ||
715 | return rc; | ||
716 | } | ||
717 | |||
718 | /** | ||
719 | * beiscsi_get_port_state - Get the Port State | ||
720 | * @shost : pointer to scsi_host structure | ||
721 | * | ||
722 | */ | ||
723 | static void beiscsi_get_port_state(struct Scsi_Host *shost) | ||
724 | { | ||
725 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
726 | struct iscsi_cls_host *ihost = shost->shost_data; | ||
727 | |||
728 | ihost->port_state = (phba->state == BE_ADAPTER_UP) ? | ||
729 | ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN; | ||
730 | } | ||
731 | |||
732 | /** | ||
733 | * beiscsi_get_port_speed - Get the Port Speed from Adapter | ||
734 | * @shost : pointer to scsi_host structure | ||
735 | * | ||
736 | * returns Success/Failure | ||
737 | */ | ||
738 | static int beiscsi_get_port_speed(struct Scsi_Host *shost) | ||
739 | { | ||
740 | int rc; | ||
741 | unsigned int tag; | ||
742 | struct be_mcc_wrb *wrb; | ||
743 | struct be_cmd_ntwk_link_status_resp *resp; | ||
744 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
745 | struct iscsi_cls_host *ihost = shost->shost_data; | ||
746 | |||
747 | tag = be_cmd_get_port_speed(phba); | ||
748 | if (!tag) { | ||
749 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
750 | "BS_%d : Getting Port Speed Failed\n"); | ||
751 | |||
752 | return -EBUSY; | ||
753 | } | ||
754 | rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); | ||
755 | if (rc) { | ||
756 | beiscsi_log(phba, KERN_ERR, | ||
757 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
758 | "BS_%d : Port Speed MBX Failed\n"); | ||
759 | return rc; | ||
760 | } | ||
761 | resp = embedded_payload(wrb); | ||
762 | |||
763 | switch (resp->mac_speed) { | ||
764 | case BE2ISCSI_LINK_SPEED_10MBPS: | ||
765 | ihost->port_speed = ISCSI_PORT_SPEED_10MBPS; | ||
766 | break; | ||
767 | case BE2ISCSI_LINK_SPEED_100MBPS: | ||
768 | ihost->port_speed = BE2ISCSI_LINK_SPEED_100MBPS; | ||
769 | break; | ||
770 | case BE2ISCSI_LINK_SPEED_1GBPS: | ||
771 | ihost->port_speed = ISCSI_PORT_SPEED_1GBPS; | ||
772 | break; | ||
773 | case BE2ISCSI_LINK_SPEED_10GBPS: | ||
774 | ihost->port_speed = ISCSI_PORT_SPEED_10GBPS; | ||
775 | break; | ||
776 | default: | ||
777 | ihost->port_speed = ISCSI_PORT_SPEED_UNKNOWN; | ||
778 | } | ||
779 | return 0; | ||
780 | } | ||
781 | |||
782 | /** | ||
783 | * beiscsi_get_host_param - get the iscsi parameter | 283 | * beiscsi_get_host_param - get the iscsi parameter |
784 | * @shost: pointer to scsi_host structure | 284 | * @shost: pointer to scsi_host structure |
785 | * @param: parameter type identifier | 285 | * @param: parameter type identifier |
@@ -790,42 +290,17 @@ static int beiscsi_get_port_speed(struct Scsi_Host *shost) | |||
790 | int beiscsi_get_host_param(struct Scsi_Host *shost, | 290 | int beiscsi_get_host_param(struct Scsi_Host *shost, |
791 | enum iscsi_host_param param, char *buf) | 291 | enum iscsi_host_param param, char *buf) |
792 | { | 292 | { |
793 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | 293 | struct beiscsi_hba *phba = (struct beiscsi_hba *)iscsi_host_priv(shost); |
794 | int status = 0; | 294 | int status = 0; |
795 | 295 | ||
796 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 296 | SE_DEBUG(DBG_LVL_8, "In beiscsi_get_host_param, param= %d\n", param); |
797 | "BS_%d : In beiscsi_get_host_param," | ||
798 | " param= %d\n", param); | ||
799 | |||
800 | switch (param) { | 297 | switch (param) { |
801 | case ISCSI_HOST_PARAM_HWADDRESS: | 298 | case ISCSI_HOST_PARAM_HWADDRESS: |
802 | status = beiscsi_get_macaddr(buf, phba); | 299 | status = beiscsi_get_macaddr(buf, phba); |
803 | if (status < 0) { | 300 | if (status < 0) { |
804 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 301 | SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n"); |
805 | "BS_%d : beiscsi_get_macaddr Failed\n"); | ||
806 | return status; | ||
807 | } | ||
808 | break; | ||
809 | case ISCSI_HOST_PARAM_INITIATOR_NAME: | ||
810 | status = beiscsi_get_initname(buf, phba); | ||
811 | if (status < 0) { | ||
812 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
813 | "BS_%d : Retreiving Initiator Name Failed\n"); | ||
814 | return status; | ||
815 | } | ||
816 | break; | ||
817 | case ISCSI_HOST_PARAM_PORT_STATE: | ||
818 | beiscsi_get_port_state(shost); | ||
819 | status = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost)); | ||
820 | break; | ||
821 | case ISCSI_HOST_PARAM_PORT_SPEED: | ||
822 | status = beiscsi_get_port_speed(shost); | ||
823 | if (status) { | ||
824 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
825 | "BS_%d : Retreiving Port Speed Failed\n"); | ||
826 | return status; | 302 | return status; |
827 | } | 303 | } |
828 | status = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost)); | ||
829 | break; | 304 | break; |
830 | default: | 305 | default: |
831 | return iscsi_host_get_param(shost, param, buf); | 306 | return iscsi_host_get_param(shost, param, buf); |
@@ -835,21 +310,46 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, | |||
835 | 310 | ||
836 | int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) | 311 | int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) |
837 | { | 312 | { |
838 | struct be_cmd_get_nic_conf_resp resp; | 313 | struct be_cmd_resp_get_mac_addr *resp; |
314 | struct be_mcc_wrb *wrb; | ||
315 | unsigned int tag, wrb_num; | ||
316 | unsigned short status, extd_status; | ||
317 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; | ||
839 | int rc; | 318 | int rc; |
840 | 319 | ||
841 | if (strlen(phba->mac_address)) | 320 | if (phba->read_mac_address) |
842 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); | 321 | return sysfs_format_mac(buf, phba->mac_address, |
322 | ETH_ALEN); | ||
843 | 323 | ||
844 | memset(&resp, 0, sizeof(resp)); | 324 | tag = be_cmd_get_mac_addr(phba); |
845 | rc = mgmt_get_nic_conf(phba, &resp); | 325 | if (!tag) { |
846 | if (rc) | 326 | SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n"); |
847 | return rc; | 327 | return -EBUSY; |
848 | 328 | } else | |
849 | memcpy(phba->mac_address, resp.mac_address, ETH_ALEN); | 329 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
850 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); | 330 | phba->ctrl.mcc_numtag[tag]); |
331 | |||
332 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; | ||
333 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; | ||
334 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; | ||
335 | if (status || extd_status) { | ||
336 | SE_DEBUG(DBG_LVL_1, "Failed to get be_cmd_get_mac_addr" | ||
337 | " status = %d extd_status = %d\n", | ||
338 | status, extd_status); | ||
339 | free_mcc_tag(&phba->ctrl, tag); | ||
340 | return -EAGAIN; | ||
341 | } | ||
342 | wrb = queue_get_wrb(mccq, wrb_num); | ||
343 | free_mcc_tag(&phba->ctrl, tag); | ||
344 | resp = embedded_payload(wrb); | ||
345 | memcpy(phba->mac_address, resp->mac_address, ETH_ALEN); | ||
346 | rc = sysfs_format_mac(buf, phba->mac_address, | ||
347 | ETH_ALEN); | ||
348 | phba->read_mac_address = 1; | ||
349 | return rc; | ||
851 | } | 350 | } |
852 | 351 | ||
352 | |||
853 | /** | 353 | /** |
854 | * beiscsi_conn_get_stats - get the iscsi stats | 354 | * beiscsi_conn_get_stats - get the iscsi stats |
855 | * @cls_conn: pointer to iscsi cls conn | 355 | * @cls_conn: pointer to iscsi cls conn |
@@ -861,12 +361,8 @@ void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, | |||
861 | struct iscsi_stats *stats) | 361 | struct iscsi_stats *stats) |
862 | { | 362 | { |
863 | struct iscsi_conn *conn = cls_conn->dd_data; | 363 | struct iscsi_conn *conn = cls_conn->dd_data; |
864 | struct beiscsi_hba *phba = NULL; | ||
865 | |||
866 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; | ||
867 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | ||
868 | "BS_%d : In beiscsi_conn_get_stats\n"); | ||
869 | 364 | ||
365 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_get_stats\n"); | ||
870 | stats->txdata_octets = conn->txdata_octets; | 366 | stats->txdata_octets = conn->txdata_octets; |
871 | stats->rxdata_octets = conn->rxdata_octets; | 367 | stats->rxdata_octets = conn->rxdata_octets; |
872 | stats->dataout_pdus = conn->dataout_pdus_cnt; | 368 | stats->dataout_pdus = conn->dataout_pdus_cnt; |
@@ -911,14 +407,6 @@ static void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn, | |||
911 | session->initial_r2t_en); | 407 | session->initial_r2t_en); |
912 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params, | 408 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params, |
913 | session->imm_data_en); | 409 | session->imm_data_en); |
914 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, | ||
915 | data_seq_inorder, params, | ||
916 | session->dataseq_inorder_en); | ||
917 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, | ||
918 | pdu_seq_inorder, params, | ||
919 | session->pdu_inorder_en); | ||
920 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_r2t, params, | ||
921 | session->max_r2t); | ||
922 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params, | 410 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params, |
923 | (conn->exp_statsn - 1)); | 411 | (conn->exp_statsn - 1)); |
924 | } | 412 | } |
@@ -934,16 +422,11 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) | |||
934 | struct beiscsi_endpoint *beiscsi_ep; | 422 | struct beiscsi_endpoint *beiscsi_ep; |
935 | struct beiscsi_offload_params params; | 423 | struct beiscsi_offload_params params; |
936 | 424 | ||
937 | beiscsi_log(beiscsi_conn->phba, KERN_INFO, | 425 | SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_start\n"); |
938 | BEISCSI_LOG_CONFIG, | ||
939 | "BS_%d : In beiscsi_conn_start\n"); | ||
940 | |||
941 | memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); | 426 | memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); |
942 | beiscsi_ep = beiscsi_conn->ep; | 427 | beiscsi_ep = beiscsi_conn->ep; |
943 | if (!beiscsi_ep) | 428 | if (!beiscsi_ep) |
944 | beiscsi_log(beiscsi_conn->phba, KERN_ERR, | 429 | SE_DEBUG(DBG_LVL_1, "In beiscsi_conn_start , no beiscsi_ep\n"); |
945 | BEISCSI_LOG_CONFIG, | ||
946 | "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n"); | ||
947 | 430 | ||
948 | beiscsi_conn->login_in_progress = 0; | 431 | beiscsi_conn->login_in_progress = 0; |
949 | beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); | 432 | beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); |
@@ -1009,33 +492,27 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
1009 | { | 492 | { |
1010 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; | 493 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
1011 | struct beiscsi_hba *phba = beiscsi_ep->phba; | 494 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
495 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; | ||
1012 | struct be_mcc_wrb *wrb; | 496 | struct be_mcc_wrb *wrb; |
1013 | struct tcp_connect_and_offload_out *ptcpcnct_out; | 497 | struct tcp_connect_and_offload_out *ptcpcnct_out; |
498 | unsigned short status, extd_status; | ||
1014 | struct be_dma_mem nonemb_cmd; | 499 | struct be_dma_mem nonemb_cmd; |
1015 | unsigned int tag; | 500 | unsigned int tag, wrb_num; |
1016 | int ret = -ENOMEM; | 501 | int ret = -ENOMEM; |
1017 | 502 | ||
1018 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 503 | SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn\n"); |
1019 | "BS_%d : In beiscsi_open_conn\n"); | ||
1020 | |||
1021 | beiscsi_ep->ep_cid = beiscsi_get_cid(phba); | 504 | beiscsi_ep->ep_cid = beiscsi_get_cid(phba); |
1022 | if (beiscsi_ep->ep_cid == 0xFFFF) { | 505 | if (beiscsi_ep->ep_cid == 0xFFFF) { |
1023 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 506 | SE_DEBUG(DBG_LVL_1, "No free cid available\n"); |
1024 | "BS_%d : No free cid available\n"); | ||
1025 | return ret; | 507 | return ret; |
1026 | } | 508 | } |
1027 | 509 | SE_DEBUG(DBG_LVL_8, "In beiscsi_open_conn, ep_cid=%d\n", | |
1028 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 510 | beiscsi_ep->ep_cid); |
1029 | "BS_%d : In beiscsi_open_conn, ep_cid=%d\n", | ||
1030 | beiscsi_ep->ep_cid); | ||
1031 | |||
1032 | phba->ep_array[beiscsi_ep->ep_cid - | 511 | phba->ep_array[beiscsi_ep->ep_cid - |
1033 | phba->fw_config.iscsi_cid_start] = ep; | 512 | phba->fw_config.iscsi_cid_start] = ep; |
1034 | if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start + | 513 | if (beiscsi_ep->ep_cid > (phba->fw_config.iscsi_cid_start + |
1035 | phba->params.cxns_per_ctrl * 2)) { | 514 | phba->params.cxns_per_ctrl * 2)) { |
1036 | 515 | SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n"); | |
1037 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
1038 | "BS_%d : Failed in allocate iscsi cid\n"); | ||
1039 | goto free_ep; | 516 | goto free_ep; |
1040 | } | 517 | } |
1041 | 518 | ||
@@ -1044,11 +521,9 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
1044 | sizeof(struct tcp_connect_and_offload_in), | 521 | sizeof(struct tcp_connect_and_offload_in), |
1045 | &nonemb_cmd.dma); | 522 | &nonemb_cmd.dma); |
1046 | if (nonemb_cmd.va == NULL) { | 523 | if (nonemb_cmd.va == NULL) { |
1047 | 524 | SE_DEBUG(DBG_LVL_1, | |
1048 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 525 | "Failed to allocate memory for mgmt_open_connection" |
1049 | "BS_%d : Failed to allocate memory for" | 526 | "\n"); |
1050 | " mgmt_open_connection\n"); | ||
1051 | |||
1052 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | 527 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
1053 | return -ENOMEM; | 528 | return -ENOMEM; |
1054 | } | 529 | } |
@@ -1056,34 +531,38 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep, | |||
1056 | memset(nonemb_cmd.va, 0, nonemb_cmd.size); | 531 | memset(nonemb_cmd.va, 0, nonemb_cmd.size); |
1057 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); | 532 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); |
1058 | if (!tag) { | 533 | if (!tag) { |
1059 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 534 | SE_DEBUG(DBG_LVL_1, |
1060 | "BS_%d : mgmt_open_connection Failed for cid=%d\n", | 535 | "mgmt_open_connection Failed for cid=%d\n", |
1061 | beiscsi_ep->ep_cid); | 536 | beiscsi_ep->ep_cid); |
1062 | |||
1063 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); | 537 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
1064 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 538 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
1065 | nonemb_cmd.va, nonemb_cmd.dma); | 539 | nonemb_cmd.va, nonemb_cmd.dma); |
1066 | return -EAGAIN; | 540 | return -EAGAIN; |
1067 | } | 541 | } else { |
1068 | 542 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | |
1069 | ret = beiscsi_mccq_compl(phba, tag, &wrb, NULL); | 543 | phba->ctrl.mcc_numtag[tag]); |
1070 | if (ret) { | 544 | } |
1071 | beiscsi_log(phba, KERN_ERR, | 545 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; |
1072 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | 546 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; |
1073 | "BS_%d : mgmt_open_connection Failed"); | 547 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; |
1074 | 548 | if (status || extd_status) { | |
549 | SE_DEBUG(DBG_LVL_1, "mgmt_open_connection Failed" | ||
550 | " status = %d extd_status = %d\n", | ||
551 | status, extd_status); | ||
552 | free_mcc_tag(&phba->ctrl, tag); | ||
1075 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 553 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
1076 | nonemb_cmd.va, nonemb_cmd.dma); | 554 | nonemb_cmd.va, nonemb_cmd.dma); |
1077 | goto free_ep; | 555 | goto free_ep; |
1078 | } | 556 | } else { |
1079 | 557 | wrb = queue_get_wrb(mccq, wrb_num); | |
1080 | ptcpcnct_out = embedded_payload(wrb); | 558 | free_mcc_tag(&phba->ctrl, tag); |
1081 | beiscsi_ep = ep->dd_data; | ||
1082 | beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; | ||
1083 | beiscsi_ep->cid_vld = 1; | ||
1084 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | ||
1085 | "BS_%d : mgmt_open_connection Success\n"); | ||
1086 | 559 | ||
560 | ptcpcnct_out = embedded_payload(wrb); | ||
561 | beiscsi_ep = ep->dd_data; | ||
562 | beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; | ||
563 | beiscsi_ep->cid_vld = 1; | ||
564 | SE_DEBUG(DBG_LVL_8, "mgmt_open_connection Success\n"); | ||
565 | } | ||
1087 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 566 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
1088 | nonemb_cmd.va, nonemb_cmd.dma); | 567 | nonemb_cmd.va, nonemb_cmd.dma); |
1089 | return 0; | 568 | return 0; |
@@ -1110,19 +589,18 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, | |||
1110 | struct iscsi_endpoint *ep; | 589 | struct iscsi_endpoint *ep; |
1111 | int ret; | 590 | int ret; |
1112 | 591 | ||
592 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_connect\n"); | ||
1113 | if (shost) | 593 | if (shost) |
1114 | phba = iscsi_host_priv(shost); | 594 | phba = iscsi_host_priv(shost); |
1115 | else { | 595 | else { |
1116 | ret = -ENXIO; | 596 | ret = -ENXIO; |
1117 | printk(KERN_ERR | 597 | SE_DEBUG(DBG_LVL_1, "shost is NULL\n"); |
1118 | "beiscsi_ep_connect shost is NULL\n"); | ||
1119 | return ERR_PTR(ret); | 598 | return ERR_PTR(ret); |
1120 | } | 599 | } |
1121 | 600 | ||
1122 | if (phba->state != BE_ADAPTER_UP) { | 601 | if (phba->state != BE_ADAPTER_UP) { |
1123 | ret = -EBUSY; | 602 | ret = -EBUSY; |
1124 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | 603 | SE_DEBUG(DBG_LVL_1, "The Adapter state is Not UP\n"); |
1125 | "BS_%d : The Adapter Port state is Down!!!\n"); | ||
1126 | return ERR_PTR(ret); | 604 | return ERR_PTR(ret); |
1127 | } | 605 | } |
1128 | 606 | ||
@@ -1137,8 +615,7 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, | |||
1137 | beiscsi_ep->openiscsi_ep = ep; | 615 | beiscsi_ep->openiscsi_ep = ep; |
1138 | ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking); | 616 | ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking); |
1139 | if (ret) { | 617 | if (ret) { |
1140 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 618 | SE_DEBUG(DBG_LVL_1, "Failed in beiscsi_open_conn\n"); |
1141 | "BS_%d : Failed in beiscsi_open_conn\n"); | ||
1142 | goto free_ep; | 619 | goto free_ep; |
1143 | } | 620 | } |
1144 | 621 | ||
@@ -1160,9 +637,7 @@ int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms) | |||
1160 | { | 637 | { |
1161 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; | 638 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
1162 | 639 | ||
1163 | beiscsi_log(beiscsi_ep->phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 640 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_poll\n"); |
1164 | "BS_%d : In beiscsi_ep_poll\n"); | ||
1165 | |||
1166 | if (beiscsi_ep->cid_vld == 1) | 641 | if (beiscsi_ep->cid_vld == 1) |
1167 | return 1; | 642 | return 1; |
1168 | else | 643 | else |
@@ -1182,14 +657,14 @@ static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag) | |||
1182 | 657 | ||
1183 | tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag); | 658 | tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag); |
1184 | if (!tag) { | 659 | if (!tag) { |
1185 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 660 | SE_DEBUG(DBG_LVL_8, "upload failed for cid 0x%x\n", |
1186 | "BS_%d : upload failed for cid 0x%x\n", | 661 | beiscsi_ep->ep_cid); |
1187 | beiscsi_ep->ep_cid); | ||
1188 | |||
1189 | ret = -EAGAIN; | 662 | ret = -EAGAIN; |
663 | } else { | ||
664 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | ||
665 | phba->ctrl.mcc_numtag[tag]); | ||
666 | free_mcc_tag(&phba->ctrl, tag); | ||
1190 | } | 667 | } |
1191 | |||
1192 | ret = beiscsi_mccq_compl(phba, tag, NULL, NULL); | ||
1193 | return ret; | 668 | return ret; |
1194 | } | 669 | } |
1195 | 670 | ||
@@ -1204,8 +679,7 @@ static int beiscsi_unbind_conn_to_cid(struct beiscsi_hba *phba, | |||
1204 | if (phba->conn_table[cid]) | 679 | if (phba->conn_table[cid]) |
1205 | phba->conn_table[cid] = NULL; | 680 | phba->conn_table[cid] = NULL; |
1206 | else { | 681 | else { |
1207 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 682 | SE_DEBUG(DBG_LVL_8, "Connection table Not occupied.\n"); |
1208 | "BS_%d : Connection table Not occupied.\n"); | ||
1209 | return -EINVAL; | 683 | return -EINVAL; |
1210 | } | 684 | } |
1211 | return 0; | 685 | return 0; |
@@ -1223,107 +697,39 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) | |||
1223 | struct beiscsi_endpoint *beiscsi_ep; | 697 | struct beiscsi_endpoint *beiscsi_ep; |
1224 | struct beiscsi_hba *phba; | 698 | struct beiscsi_hba *phba; |
1225 | unsigned int tag; | 699 | unsigned int tag; |
1226 | uint8_t mgmt_invalidate_flag, tcp_upload_flag; | ||
1227 | unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; | 700 | unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; |
1228 | 701 | ||
1229 | beiscsi_ep = ep->dd_data; | 702 | beiscsi_ep = ep->dd_data; |
1230 | phba = beiscsi_ep->phba; | 703 | phba = beiscsi_ep->phba; |
1231 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 704 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect for ep_cid = %d\n", |
1232 | "BS_%d : In beiscsi_ep_disconnect for ep_cid = %d\n", | 705 | beiscsi_ep->ep_cid); |
1233 | beiscsi_ep->ep_cid); | 706 | |
1234 | 707 | if (!beiscsi_ep->conn) { | |
1235 | if (beiscsi_ep->conn) { | 708 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect, no " |
1236 | beiscsi_conn = beiscsi_ep->conn; | 709 | "beiscsi_ep\n"); |
1237 | iscsi_suspend_queue(beiscsi_conn->conn); | 710 | return; |
1238 | mgmt_invalidate_flag = ~BEISCSI_NO_RST_ISSUE; | ||
1239 | tcp_upload_flag = CONNECTION_UPLOAD_GRACEFUL; | ||
1240 | } else { | ||
1241 | mgmt_invalidate_flag = BEISCSI_NO_RST_ISSUE; | ||
1242 | tcp_upload_flag = CONNECTION_UPLOAD_ABORT; | ||
1243 | } | 711 | } |
712 | beiscsi_conn = beiscsi_ep->conn; | ||
713 | iscsi_suspend_queue(beiscsi_conn->conn); | ||
714 | |||
715 | SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect ep_cid = %d\n", | ||
716 | beiscsi_ep->ep_cid); | ||
1244 | 717 | ||
1245 | tag = mgmt_invalidate_connection(phba, beiscsi_ep, | 718 | tag = mgmt_invalidate_connection(phba, beiscsi_ep, |
1246 | beiscsi_ep->ep_cid, | 719 | beiscsi_ep->ep_cid, 1, |
1247 | mgmt_invalidate_flag, | 720 | savecfg_flag); |
1248 | savecfg_flag); | ||
1249 | if (!tag) { | 721 | if (!tag) { |
1250 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 722 | SE_DEBUG(DBG_LVL_1, |
1251 | "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n", | 723 | "mgmt_invalidate_connection Failed for cid=%d\n", |
1252 | beiscsi_ep->ep_cid); | 724 | beiscsi_ep->ep_cid); |
725 | } else { | ||
726 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | ||
727 | phba->ctrl.mcc_numtag[tag]); | ||
728 | free_mcc_tag(&phba->ctrl, tag); | ||
1253 | } | 729 | } |
1254 | 730 | ||
1255 | beiscsi_mccq_compl(phba, tag, NULL, NULL); | 731 | beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL); |
1256 | beiscsi_close_conn(beiscsi_ep, tcp_upload_flag); | ||
1257 | beiscsi_free_ep(beiscsi_ep); | 732 | beiscsi_free_ep(beiscsi_ep); |
1258 | beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); | 733 | beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); |
1259 | iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); | 734 | iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); |
1260 | } | 735 | } |
1261 | |||
1262 | umode_t be2iscsi_attr_is_visible(int param_type, int param) | ||
1263 | { | ||
1264 | switch (param_type) { | ||
1265 | case ISCSI_NET_PARAM: | ||
1266 | switch (param) { | ||
1267 | case ISCSI_NET_PARAM_IFACE_ENABLE: | ||
1268 | case ISCSI_NET_PARAM_IPV4_ADDR: | ||
1269 | case ISCSI_NET_PARAM_IPV4_SUBNET: | ||
1270 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: | ||
1271 | case ISCSI_NET_PARAM_IPV4_GW: | ||
1272 | case ISCSI_NET_PARAM_IPV6_ADDR: | ||
1273 | case ISCSI_NET_PARAM_VLAN_ID: | ||
1274 | case ISCSI_NET_PARAM_VLAN_PRIORITY: | ||
1275 | case ISCSI_NET_PARAM_VLAN_ENABLED: | ||
1276 | return S_IRUGO; | ||
1277 | default: | ||
1278 | return 0; | ||
1279 | } | ||
1280 | case ISCSI_HOST_PARAM: | ||
1281 | switch (param) { | ||
1282 | case ISCSI_HOST_PARAM_HWADDRESS: | ||
1283 | case ISCSI_HOST_PARAM_INITIATOR_NAME: | ||
1284 | case ISCSI_HOST_PARAM_PORT_STATE: | ||
1285 | case ISCSI_HOST_PARAM_PORT_SPEED: | ||
1286 | return S_IRUGO; | ||
1287 | default: | ||
1288 | return 0; | ||
1289 | } | ||
1290 | case ISCSI_PARAM: | ||
1291 | switch (param) { | ||
1292 | case ISCSI_PARAM_MAX_RECV_DLENGTH: | ||
1293 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: | ||
1294 | case ISCSI_PARAM_HDRDGST_EN: | ||
1295 | case ISCSI_PARAM_DATADGST_EN: | ||
1296 | case ISCSI_PARAM_CONN_ADDRESS: | ||
1297 | case ISCSI_PARAM_CONN_PORT: | ||
1298 | case ISCSI_PARAM_EXP_STATSN: | ||
1299 | case ISCSI_PARAM_PERSISTENT_ADDRESS: | ||
1300 | case ISCSI_PARAM_PERSISTENT_PORT: | ||
1301 | case ISCSI_PARAM_PING_TMO: | ||
1302 | case ISCSI_PARAM_RECV_TMO: | ||
1303 | case ISCSI_PARAM_INITIAL_R2T_EN: | ||
1304 | case ISCSI_PARAM_MAX_R2T: | ||
1305 | case ISCSI_PARAM_IMM_DATA_EN: | ||
1306 | case ISCSI_PARAM_FIRST_BURST: | ||
1307 | case ISCSI_PARAM_MAX_BURST: | ||
1308 | case ISCSI_PARAM_PDU_INORDER_EN: | ||
1309 | case ISCSI_PARAM_DATASEQ_INORDER_EN: | ||
1310 | case ISCSI_PARAM_ERL: | ||
1311 | case ISCSI_PARAM_TARGET_NAME: | ||
1312 | case ISCSI_PARAM_TPGT: | ||
1313 | case ISCSI_PARAM_USERNAME: | ||
1314 | case ISCSI_PARAM_PASSWORD: | ||
1315 | case ISCSI_PARAM_USERNAME_IN: | ||
1316 | case ISCSI_PARAM_PASSWORD_IN: | ||
1317 | case ISCSI_PARAM_FAST_ABORT: | ||
1318 | case ISCSI_PARAM_ABORT_TMO: | ||
1319 | case ISCSI_PARAM_LU_RESET_TMO: | ||
1320 | case ISCSI_PARAM_IFACE_NAME: | ||
1321 | case ISCSI_PARAM_INITIATOR_NAME: | ||
1322 | return S_IRUGO; | ||
1323 | default: | ||
1324 | return 0; | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | return 0; | ||
1329 | } | ||
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h index 38eab723215..ff60b7fd92d 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.h +++ b/drivers/scsi/be2iscsi/be_iscsi.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -25,23 +25,6 @@ | |||
25 | 25 | ||
26 | #define BE2_IPV4 0x1 | 26 | #define BE2_IPV4 0x1 |
27 | #define BE2_IPV6 0x10 | 27 | #define BE2_IPV6 0x10 |
28 | #define BE2_DHCP_V4 0x05 | ||
29 | |||
30 | #define NON_BLOCKING 0x0 | ||
31 | #define BLOCKING 0x1 | ||
32 | |||
33 | void beiscsi_create_def_ifaces(struct beiscsi_hba *phba); | ||
34 | |||
35 | void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba); | ||
36 | |||
37 | int be2iscsi_iface_get_param(struct iscsi_iface *iface, | ||
38 | enum iscsi_param_type param_type, | ||
39 | int param, char *buf); | ||
40 | |||
41 | int be2iscsi_iface_set_param(struct Scsi_Host *shost, | ||
42 | void *data, uint32_t count); | ||
43 | |||
44 | umode_t be2iscsi_attr_is_visible(int param_type, int param); | ||
45 | 28 | ||
46 | void beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, | 29 | void beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, |
47 | struct beiscsi_offload_params *params); | 30 | struct beiscsi_offload_params *params); |
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 4e2733d2300..0a9bdfa3d93 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -27,12 +27,8 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/semaphore.h> | 28 | #include <linux/semaphore.h> |
29 | #include <linux/iscsi_boot_sysfs.h> | 29 | #include <linux/iscsi_boot_sysfs.h> |
30 | #include <linux/module.h> | ||
31 | #include <linux/bsg-lib.h> | ||
32 | 30 | ||
33 | #include <scsi/libiscsi.h> | 31 | #include <scsi/libiscsi.h> |
34 | #include <scsi/scsi_bsg_iscsi.h> | ||
35 | #include <scsi/scsi_netlink.h> | ||
36 | #include <scsi/scsi_transport_iscsi.h> | 32 | #include <scsi/scsi_transport_iscsi.h> |
37 | #include <scsi/scsi_transport.h> | 33 | #include <scsi/scsi_transport.h> |
38 | #include <scsi/scsi_cmnd.h> | 34 | #include <scsi/scsi_cmnd.h> |
@@ -42,162 +38,23 @@ | |||
42 | #include "be_main.h" | 38 | #include "be_main.h" |
43 | #include "be_iscsi.h" | 39 | #include "be_iscsi.h" |
44 | #include "be_mgmt.h" | 40 | #include "be_mgmt.h" |
45 | #include "be_cmds.h" | ||
46 | 41 | ||
47 | static unsigned int be_iopoll_budget = 10; | 42 | static unsigned int be_iopoll_budget = 10; |
48 | static unsigned int be_max_phys_size = 64; | 43 | static unsigned int be_max_phys_size = 64; |
49 | static unsigned int enable_msix = 1; | 44 | static unsigned int enable_msix = 1; |
45 | static unsigned int gcrashmode = 0; | ||
46 | static unsigned int num_hba = 0; | ||
50 | 47 | ||
51 | MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); | 48 | MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); |
52 | MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR); | 49 | MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR); |
53 | MODULE_VERSION(BUILD_STR); | 50 | MODULE_AUTHOR("ServerEngines Corporation"); |
54 | MODULE_AUTHOR("Emulex Corporation"); | ||
55 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
56 | module_param(be_iopoll_budget, int, 0); | 52 | module_param(be_iopoll_budget, int, 0); |
57 | module_param(enable_msix, int, 0); | 53 | module_param(enable_msix, int, 0); |
58 | module_param(be_max_phys_size, uint, S_IRUGO); | 54 | module_param(be_max_phys_size, uint, S_IRUGO); |
59 | MODULE_PARM_DESC(be_max_phys_size, | 55 | MODULE_PARM_DESC(be_max_phys_size, "Maximum Size (In Kilobytes) of physically" |
60 | "Maximum Size (In Kilobytes) of physically contiguous " | 56 | "contiguous memory that can be allocated." |
61 | "memory that can be allocated. Range is 16 - 128"); | 57 | "Range is 16 - 128"); |
62 | |||
63 | #define beiscsi_disp_param(_name)\ | ||
64 | ssize_t \ | ||
65 | beiscsi_##_name##_disp(struct device *dev,\ | ||
66 | struct device_attribute *attrib, char *buf) \ | ||
67 | { \ | ||
68 | struct Scsi_Host *shost = class_to_shost(dev);\ | ||
69 | struct beiscsi_hba *phba = iscsi_host_priv(shost); \ | ||
70 | uint32_t param_val = 0; \ | ||
71 | param_val = phba->attr_##_name;\ | ||
72 | return snprintf(buf, PAGE_SIZE, "%d\n",\ | ||
73 | phba->attr_##_name);\ | ||
74 | } | ||
75 | |||
76 | #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ | ||
77 | int \ | ||
78 | beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ | ||
79 | {\ | ||
80 | if (val >= _minval && val <= _maxval) {\ | ||
81 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ | ||
82 | "BA_%d : beiscsi_"#_name" updated "\ | ||
83 | "from 0x%x ==> 0x%x\n",\ | ||
84 | phba->attr_##_name, val); \ | ||
85 | phba->attr_##_name = val;\ | ||
86 | return 0;\ | ||
87 | } \ | ||
88 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ | ||
89 | "BA_%d beiscsi_"#_name" attribute "\ | ||
90 | "cannot be updated to 0x%x, "\ | ||
91 | "range allowed is ["#_minval" - "#_maxval"]\n", val);\ | ||
92 | return -EINVAL;\ | ||
93 | } | ||
94 | |||
95 | #define beiscsi_store_param(_name) \ | ||
96 | ssize_t \ | ||
97 | beiscsi_##_name##_store(struct device *dev,\ | ||
98 | struct device_attribute *attr, const char *buf,\ | ||
99 | size_t count) \ | ||
100 | { \ | ||
101 | struct Scsi_Host *shost = class_to_shost(dev);\ | ||
102 | struct beiscsi_hba *phba = iscsi_host_priv(shost);\ | ||
103 | uint32_t param_val = 0;\ | ||
104 | if (!isdigit(buf[0]))\ | ||
105 | return -EINVAL;\ | ||
106 | if (sscanf(buf, "%i", ¶m_val) != 1)\ | ||
107 | return -EINVAL;\ | ||
108 | if (beiscsi_##_name##_change(phba, param_val) == 0) \ | ||
109 | return strlen(buf);\ | ||
110 | else \ | ||
111 | return -EINVAL;\ | ||
112 | } | ||
113 | |||
114 | #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ | ||
115 | int \ | ||
116 | beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ | ||
117 | { \ | ||
118 | if (val >= _minval && val <= _maxval) {\ | ||
119 | phba->attr_##_name = val;\ | ||
120 | return 0;\ | ||
121 | } \ | ||
122 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ | ||
123 | "BA_%d beiscsi_"#_name" attribute " \ | ||
124 | "cannot be updated to 0x%x, "\ | ||
125 | "range allowed is ["#_minval" - "#_maxval"]\n", val);\ | ||
126 | phba->attr_##_name = _defval;\ | ||
127 | return -EINVAL;\ | ||
128 | } | ||
129 | |||
130 | #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ | ||
131 | static uint beiscsi_##_name = _defval;\ | ||
132 | module_param(beiscsi_##_name, uint, S_IRUGO);\ | ||
133 | MODULE_PARM_DESC(beiscsi_##_name, _descp);\ | ||
134 | beiscsi_disp_param(_name)\ | ||
135 | beiscsi_change_param(_name, _minval, _maxval, _defval)\ | ||
136 | beiscsi_store_param(_name)\ | ||
137 | beiscsi_init_param(_name, _minval, _maxval, _defval)\ | ||
138 | DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ | ||
139 | beiscsi_##_name##_disp, beiscsi_##_name##_store) | ||
140 | |||
141 | /* | ||
142 | * When new log level added update the | ||
143 | * the MAX allowed value for log_enable | ||
144 | */ | ||
145 | BEISCSI_RW_ATTR(log_enable, 0x00, | ||
146 | 0xFF, 0x00, "Enable logging Bit Mask\n" | ||
147 | "\t\t\t\tInitialization Events : 0x01\n" | ||
148 | "\t\t\t\tMailbox Events : 0x02\n" | ||
149 | "\t\t\t\tMiscellaneous Events : 0x04\n" | ||
150 | "\t\t\t\tError Handling : 0x08\n" | ||
151 | "\t\t\t\tIO Path Events : 0x10\n" | ||
152 | "\t\t\t\tConfiguration Path : 0x20\n"); | ||
153 | |||
154 | DEVICE_ATTR(beiscsi_drvr_ver, S_IRUGO, beiscsi_drvr_ver_disp, NULL); | ||
155 | DEVICE_ATTR(beiscsi_adapter_family, S_IRUGO, beiscsi_adap_family_disp, NULL); | ||
156 | struct device_attribute *beiscsi_attrs[] = { | ||
157 | &dev_attr_beiscsi_log_enable, | ||
158 | &dev_attr_beiscsi_drvr_ver, | ||
159 | &dev_attr_beiscsi_adapter_family, | ||
160 | NULL, | ||
161 | }; | ||
162 | |||
163 | static char const *cqe_desc[] = { | ||
164 | "RESERVED_DESC", | ||
165 | "SOL_CMD_COMPLETE", | ||
166 | "SOL_CMD_KILLED_DATA_DIGEST_ERR", | ||
167 | "CXN_KILLED_PDU_SIZE_EXCEEDS_DSL", | ||
168 | "CXN_KILLED_BURST_LEN_MISMATCH", | ||
169 | "CXN_KILLED_AHS_RCVD", | ||
170 | "CXN_KILLED_HDR_DIGEST_ERR", | ||
171 | "CXN_KILLED_UNKNOWN_HDR", | ||
172 | "CXN_KILLED_STALE_ITT_TTT_RCVD", | ||
173 | "CXN_KILLED_INVALID_ITT_TTT_RCVD", | ||
174 | "CXN_KILLED_RST_RCVD", | ||
175 | "CXN_KILLED_TIMED_OUT", | ||
176 | "CXN_KILLED_RST_SENT", | ||
177 | "CXN_KILLED_FIN_RCVD", | ||
178 | "CXN_KILLED_BAD_UNSOL_PDU_RCVD", | ||
179 | "CXN_KILLED_BAD_WRB_INDEX_ERROR", | ||
180 | "CXN_KILLED_OVER_RUN_RESIDUAL", | ||
181 | "CXN_KILLED_UNDER_RUN_RESIDUAL", | ||
182 | "CMD_KILLED_INVALID_STATSN_RCVD", | ||
183 | "CMD_KILLED_INVALID_R2T_RCVD", | ||
184 | "CMD_CXN_KILLED_LUN_INVALID", | ||
185 | "CMD_CXN_KILLED_ICD_INVALID", | ||
186 | "CMD_CXN_KILLED_ITT_INVALID", | ||
187 | "CMD_CXN_KILLED_SEQ_OUTOFORDER", | ||
188 | "CMD_CXN_KILLED_INVALID_DATASN_RCVD", | ||
189 | "CXN_INVALIDATE_NOTIFY", | ||
190 | "CXN_INVALIDATE_INDEX_NOTIFY", | ||
191 | "CMD_INVALIDATED_NOTIFY", | ||
192 | "UNSOL_HDR_NOTIFY", | ||
193 | "UNSOL_DATA_NOTIFY", | ||
194 | "UNSOL_DATA_DIGEST_ERROR_NOTIFY", | ||
195 | "DRIVERMSG_NOTIFY", | ||
196 | "CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN", | ||
197 | "SOL_CMD_KILLED_DIF_ERR", | ||
198 | "CXN_KILLED_SYN_RCVD", | ||
199 | "CXN_KILLED_IMM_DATA_RCVD" | ||
200 | }; | ||
201 | 58 | ||
202 | static int beiscsi_slave_configure(struct scsi_device *sdev) | 59 | static int beiscsi_slave_configure(struct scsi_device *sdev) |
203 | { | 60 | { |
@@ -250,9 +107,9 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) | |||
250 | sizeof(struct invalidate_commands_params_in), | 107 | sizeof(struct invalidate_commands_params_in), |
251 | &nonemb_cmd.dma); | 108 | &nonemb_cmd.dma); |
252 | if (nonemb_cmd.va == NULL) { | 109 | if (nonemb_cmd.va == NULL) { |
253 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, | 110 | SE_DEBUG(DBG_LVL_1, |
254 | "BM_%d : Failed to allocate memory for" | 111 | "Failed to allocate memory for" |
255 | "mgmt_invalidate_icds\n"); | 112 | "mgmt_invalidate_icds\n"); |
256 | return FAILED; | 113 | return FAILED; |
257 | } | 114 | } |
258 | nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); | 115 | nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); |
@@ -260,16 +117,18 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) | |||
260 | tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, | 117 | tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, |
261 | cid, &nonemb_cmd); | 118 | cid, &nonemb_cmd); |
262 | if (!tag) { | 119 | if (!tag) { |
263 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, | 120 | shost_printk(KERN_WARNING, phba->shost, |
264 | "BM_%d : mgmt_invalidate_icds could not be" | 121 | "mgmt_invalidate_icds could not be" |
265 | "submitted\n"); | 122 | " submitted\n"); |
266 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 123 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
267 | nonemb_cmd.va, nonemb_cmd.dma); | 124 | nonemb_cmd.va, nonemb_cmd.dma); |
268 | 125 | ||
269 | return FAILED; | 126 | return FAILED; |
127 | } else { | ||
128 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | ||
129 | phba->ctrl.mcc_numtag[tag]); | ||
130 | free_mcc_tag(&phba->ctrl, tag); | ||
270 | } | 131 | } |
271 | |||
272 | beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); | ||
273 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 132 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
274 | nonemb_cmd.va, nonemb_cmd.dma); | 133 | nonemb_cmd.va, nonemb_cmd.dma); |
275 | return iscsi_eh_abort(sc); | 134 | return iscsi_eh_abort(sc); |
@@ -287,15 +146,15 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
287 | struct invalidate_command_table *inv_tbl; | 146 | struct invalidate_command_table *inv_tbl; |
288 | struct be_dma_mem nonemb_cmd; | 147 | struct be_dma_mem nonemb_cmd; |
289 | unsigned int cid, tag, i, num_invalidate; | 148 | unsigned int cid, tag, i, num_invalidate; |
149 | int rc = FAILED; | ||
290 | 150 | ||
291 | /* invalidate iocbs */ | 151 | /* invalidate iocbs */ |
292 | cls_session = starget_to_session(scsi_target(sc->device)); | 152 | cls_session = starget_to_session(scsi_target(sc->device)); |
293 | session = cls_session->dd_data; | 153 | session = cls_session->dd_data; |
294 | spin_lock_bh(&session->lock); | 154 | spin_lock_bh(&session->lock); |
295 | if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) { | 155 | if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) |
296 | spin_unlock_bh(&session->lock); | 156 | goto unlock; |
297 | return FAILED; | 157 | |
298 | } | ||
299 | conn = session->leadconn; | 158 | conn = session->leadconn; |
300 | beiscsi_conn = conn->dd_data; | 159 | beiscsi_conn = conn->dd_data; |
301 | phba = beiscsi_conn->phba; | 160 | phba = beiscsi_conn->phba; |
@@ -324,9 +183,9 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
324 | sizeof(struct invalidate_commands_params_in), | 183 | sizeof(struct invalidate_commands_params_in), |
325 | &nonemb_cmd.dma); | 184 | &nonemb_cmd.dma); |
326 | if (nonemb_cmd.va == NULL) { | 185 | if (nonemb_cmd.va == NULL) { |
327 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, | 186 | SE_DEBUG(DBG_LVL_1, |
328 | "BM_%d : Failed to allocate memory for" | 187 | "Failed to allocate memory for" |
329 | "mgmt_invalidate_icds\n"); | 188 | "mgmt_invalidate_icds\n"); |
330 | return FAILED; | 189 | return FAILED; |
331 | } | 190 | } |
332 | nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); | 191 | nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); |
@@ -334,18 +193,23 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
334 | tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, | 193 | tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, |
335 | cid, &nonemb_cmd); | 194 | cid, &nonemb_cmd); |
336 | if (!tag) { | 195 | if (!tag) { |
337 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, | 196 | shost_printk(KERN_WARNING, phba->shost, |
338 | "BM_%d : mgmt_invalidate_icds could not be" | 197 | "mgmt_invalidate_icds could not be" |
339 | " submitted\n"); | 198 | " submitted\n"); |
340 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 199 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
341 | nonemb_cmd.va, nonemb_cmd.dma); | 200 | nonemb_cmd.va, nonemb_cmd.dma); |
342 | return FAILED; | 201 | return FAILED; |
202 | } else { | ||
203 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | ||
204 | phba->ctrl.mcc_numtag[tag]); | ||
205 | free_mcc_tag(&phba->ctrl, tag); | ||
343 | } | 206 | } |
344 | |||
345 | beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); | ||
346 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | 207 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
347 | nonemb_cmd.va, nonemb_cmd.dma); | 208 | nonemb_cmd.va, nonemb_cmd.dma); |
348 | return iscsi_eh_device_reset(sc); | 209 | return iscsi_eh_device_reset(sc); |
210 | unlock: | ||
211 | spin_unlock_bh(&session->lock); | ||
212 | return rc; | ||
349 | } | 213 | } |
350 | 214 | ||
351 | static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) | 215 | static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) |
@@ -365,10 +229,10 @@ static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) | |||
365 | case ISCSI_BOOT_TGT_IP_ADDR: | 229 | case ISCSI_BOOT_TGT_IP_ADDR: |
366 | if (boot_conn->dest_ipaddr.ip_type == 0x1) | 230 | if (boot_conn->dest_ipaddr.ip_type == 0x1) |
367 | rc = sprintf(buf, "%pI4\n", | 231 | rc = sprintf(buf, "%pI4\n", |
368 | (char *)&boot_conn->dest_ipaddr.addr); | 232 | (char *)&boot_conn->dest_ipaddr.ip_address); |
369 | else | 233 | else |
370 | rc = sprintf(str, "%pI6\n", | 234 | rc = sprintf(str, "%pI6\n", |
371 | (char *)&boot_conn->dest_ipaddr.addr); | 235 | (char *)&boot_conn->dest_ipaddr.ip_address); |
372 | break; | 236 | break; |
373 | case ISCSI_BOOT_TGT_PORT: | 237 | case ISCSI_BOOT_TGT_PORT: |
374 | rc = sprintf(str, "%d\n", boot_conn->dest_port); | 238 | rc = sprintf(str, "%d\n", boot_conn->dest_port); |
@@ -446,8 +310,12 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf) | |||
446 | rc = sprintf(str, "0\n"); | 310 | rc = sprintf(str, "0\n"); |
447 | break; | 311 | break; |
448 | case ISCSI_BOOT_ETH_MAC: | 312 | case ISCSI_BOOT_ETH_MAC: |
449 | rc = beiscsi_get_macaddr(str, phba); | 313 | rc = beiscsi_get_macaddr(buf, phba); |
450 | break; | 314 | if (rc < 0) { |
315 | SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n"); | ||
316 | return rc; | ||
317 | } | ||
318 | break; | ||
451 | default: | 319 | default: |
452 | rc = -ENOSYS; | 320 | rc = -ENOSYS; |
453 | break; | 321 | break; |
@@ -456,9 +324,9 @@ static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf) | |||
456 | } | 324 | } |
457 | 325 | ||
458 | 326 | ||
459 | static umode_t beiscsi_tgt_get_attr_visibility(void *data, int type) | 327 | static mode_t beiscsi_tgt_get_attr_visibility(void *data, int type) |
460 | { | 328 | { |
461 | umode_t rc; | 329 | int rc; |
462 | 330 | ||
463 | switch (type) { | 331 | switch (type) { |
464 | case ISCSI_BOOT_TGT_NAME: | 332 | case ISCSI_BOOT_TGT_NAME: |
@@ -479,9 +347,9 @@ static umode_t beiscsi_tgt_get_attr_visibility(void *data, int type) | |||
479 | return rc; | 347 | return rc; |
480 | } | 348 | } |
481 | 349 | ||
482 | static umode_t beiscsi_ini_get_attr_visibility(void *data, int type) | 350 | static mode_t beiscsi_ini_get_attr_visibility(void *data, int type) |
483 | { | 351 | { |
484 | umode_t rc; | 352 | int rc; |
485 | 353 | ||
486 | switch (type) { | 354 | switch (type) { |
487 | case ISCSI_BOOT_INI_INITIATOR_NAME: | 355 | case ISCSI_BOOT_INI_INITIATOR_NAME: |
@@ -495,9 +363,9 @@ static umode_t beiscsi_ini_get_attr_visibility(void *data, int type) | |||
495 | } | 363 | } |
496 | 364 | ||
497 | 365 | ||
498 | static umode_t beiscsi_eth_get_attr_visibility(void *data, int type) | 366 | static mode_t beiscsi_eth_get_attr_visibility(void *data, int type) |
499 | { | 367 | { |
500 | umode_t rc; | 368 | int rc; |
501 | 369 | ||
502 | switch (type) { | 370 | switch (type) { |
503 | case ISCSI_BOOT_ETH_FLAGS: | 371 | case ISCSI_BOOT_ETH_FLAGS: |
@@ -519,15 +387,13 @@ static DEFINE_PCI_DEVICE_TABLE(beiscsi_pci_id_table) = { | |||
519 | { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) }, | 387 | { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) }, |
520 | { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) }, | 388 | { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) }, |
521 | { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID3) }, | 389 | { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID3) }, |
522 | { PCI_DEVICE(ELX_VENDOR_ID, OC_SKH_ID1) }, | ||
523 | { 0 } | 390 | { 0 } |
524 | }; | 391 | }; |
525 | MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); | 392 | MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); |
526 | 393 | ||
527 | |||
528 | static struct scsi_host_template beiscsi_sht = { | 394 | static struct scsi_host_template beiscsi_sht = { |
529 | .module = THIS_MODULE, | 395 | .module = THIS_MODULE, |
530 | .name = "Emulex 10Gbe open-iscsi Initiator Driver", | 396 | .name = "ServerEngines 10Gbe open-iscsi Initiator Driver", |
531 | .proc_name = DRV_NAME, | 397 | .proc_name = DRV_NAME, |
532 | .queuecommand = iscsi_queuecommand, | 398 | .queuecommand = iscsi_queuecommand, |
533 | .change_queue_depth = iscsi_change_queue_depth, | 399 | .change_queue_depth = iscsi_change_queue_depth, |
@@ -536,15 +402,12 @@ static struct scsi_host_template beiscsi_sht = { | |||
536 | .eh_abort_handler = beiscsi_eh_abort, | 402 | .eh_abort_handler = beiscsi_eh_abort, |
537 | .eh_device_reset_handler = beiscsi_eh_device_reset, | 403 | .eh_device_reset_handler = beiscsi_eh_device_reset, |
538 | .eh_target_reset_handler = iscsi_eh_session_reset, | 404 | .eh_target_reset_handler = iscsi_eh_session_reset, |
539 | .shost_attrs = beiscsi_attrs, | ||
540 | .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, | 405 | .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, |
541 | .can_queue = BE2_IO_DEPTH, | 406 | .can_queue = BE2_IO_DEPTH, |
542 | .this_id = -1, | 407 | .this_id = -1, |
543 | .max_sectors = BEISCSI_MAX_SECTORS, | 408 | .max_sectors = BEISCSI_MAX_SECTORS, |
544 | .cmd_per_lun = BEISCSI_CMD_PER_LUN, | 409 | .cmd_per_lun = BEISCSI_CMD_PER_LUN, |
545 | .use_clustering = ENABLE_CLUSTERING, | 410 | .use_clustering = ENABLE_CLUSTERING, |
546 | .vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID, | ||
547 | |||
548 | }; | 411 | }; |
549 | 412 | ||
550 | static struct scsi_transport_template *beiscsi_scsi_transport; | 413 | static struct scsi_transport_template *beiscsi_scsi_transport; |
@@ -556,8 +419,8 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) | |||
556 | 419 | ||
557 | shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0); | 420 | shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0); |
558 | if (!shost) { | 421 | if (!shost) { |
559 | dev_err(&pcidev->dev, | 422 | dev_err(&pcidev->dev, "beiscsi_hba_alloc -" |
560 | "beiscsi_hba_alloc - iscsi_host_alloc failed\n"); | 423 | "iscsi_host_alloc failed\n"); |
561 | return NULL; | 424 | return NULL; |
562 | } | 425 | } |
563 | shost->dma_boundary = pcidev->dma_mask; | 426 | shost->dma_boundary = pcidev->dma_mask; |
@@ -571,7 +434,6 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) | |||
571 | phba->shost = shost; | 434 | phba->shost = shost; |
572 | phba->pcidev = pci_dev_get(pcidev); | 435 | phba->pcidev = pci_dev_get(pcidev); |
573 | pci_set_drvdata(pcidev, phba); | 436 | pci_set_drvdata(pcidev, phba); |
574 | phba->interface_handle = 0xFFFFFFFF; | ||
575 | 437 | ||
576 | if (iscsi_host_add(shost, &phba->pcidev->dev)) | 438 | if (iscsi_host_add(shost, &phba->pcidev->dev)) |
577 | goto free_devices; | 439 | goto free_devices; |
@@ -647,8 +509,8 @@ static int beiscsi_enable_pci(struct pci_dev *pcidev) | |||
647 | 509 | ||
648 | ret = pci_enable_device(pcidev); | 510 | ret = pci_enable_device(pcidev); |
649 | if (ret) { | 511 | if (ret) { |
650 | dev_err(&pcidev->dev, | 512 | dev_err(&pcidev->dev, "beiscsi_enable_pci - enable device " |
651 | "beiscsi_enable_pci - enable device failed\n"); | 513 | "failed. Returning -ENODEV\n"); |
652 | return ret; | 514 | return ret; |
653 | } | 515 | } |
654 | 516 | ||
@@ -681,7 +543,8 @@ static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev) | |||
681 | &mbox_mem_alloc->dma); | 543 | &mbox_mem_alloc->dma); |
682 | if (!mbox_mem_alloc->va) { | 544 | if (!mbox_mem_alloc->va) { |
683 | beiscsi_unmap_pci_function(phba); | 545 | beiscsi_unmap_pci_function(phba); |
684 | return -ENOMEM; | 546 | status = -ENOMEM; |
547 | return status; | ||
685 | } | 548 | } |
686 | 549 | ||
687 | mbox_mem_align->size = sizeof(struct be_mcc_mailbox); | 550 | mbox_mem_align->size = sizeof(struct be_mcc_mailbox); |
@@ -713,9 +576,8 @@ static void beiscsi_get_params(struct beiscsi_hba *phba) | |||
713 | + BE2_TMFS) / 512) + 1) * 512; | 576 | + BE2_TMFS) / 512) + 1) * 512; |
714 | phba->params.num_eq_entries = (phba->params.num_eq_entries < 1024) | 577 | phba->params.num_eq_entries = (phba->params.num_eq_entries < 1024) |
715 | ? 1024 : phba->params.num_eq_entries; | 578 | ? 1024 : phba->params.num_eq_entries; |
716 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 579 | SE_DEBUG(DBG_LVL_8, "phba->params.num_eq_entries=%d\n", |
717 | "BM_%d : phba->params.num_eq_entries=%d\n", | 580 | phba->params.num_eq_entries); |
718 | phba->params.num_eq_entries); | ||
719 | phba->params.num_cq_entries = | 581 | phba->params.num_cq_entries = |
720 | (((BE2_CMDS_PER_CXN * 2 + phba->fw_config.iscsi_cid_count * 2 | 582 | (((BE2_CMDS_PER_CXN * 2 + phba->fw_config.iscsi_cid_count * 2 |
721 | + BE2_TMFS) / 512) + 1) * 512; | 583 | + BE2_TMFS) / 512) + 1) * 512; |
@@ -759,6 +621,8 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id) | |||
759 | phba = pbe_eq->phba; | 621 | phba = pbe_eq->phba; |
760 | mcc = &phba->ctrl.mcc_obj.cq; | 622 | mcc = &phba->ctrl.mcc_obj.cq; |
761 | eqe = queue_tail_node(eq); | 623 | eqe = queue_tail_node(eq); |
624 | if (!eqe) | ||
625 | SE_DEBUG(DBG_LVL_1, "eqe is NULL\n"); | ||
762 | 626 | ||
763 | num_eq_processed = 0; | 627 | num_eq_processed = 0; |
764 | 628 | ||
@@ -768,7 +632,7 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id) | |||
768 | resource_id) / 32] & | 632 | resource_id) / 32] & |
769 | EQE_RESID_MASK) >> 16) == mcc->id) { | 633 | EQE_RESID_MASK) >> 16) == mcc->id) { |
770 | spin_lock_irqsave(&phba->isr_lock, flags); | 634 | spin_lock_irqsave(&phba->isr_lock, flags); |
771 | pbe_eq->todo_mcc_cq = true; | 635 | phba->todo_mcc_cq = 1; |
772 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 636 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
773 | } | 637 | } |
774 | AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); | 638 | AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); |
@@ -776,8 +640,8 @@ static irqreturn_t be_isr_mcc(int irq, void *dev_id) | |||
776 | eqe = queue_tail_node(eq); | 640 | eqe = queue_tail_node(eq); |
777 | num_eq_processed++; | 641 | num_eq_processed++; |
778 | } | 642 | } |
779 | if (pbe_eq->todo_mcc_cq) | 643 | if (phba->todo_mcc_cq) |
780 | queue_work(phba->wq, &pbe_eq->work_cqs); | 644 | queue_work(phba->wq, &phba->work_cqs); |
781 | if (num_eq_processed) | 645 | if (num_eq_processed) |
782 | hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 1, 1); | 646 | hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 1, 1); |
783 | 647 | ||
@@ -803,6 +667,8 @@ static irqreturn_t be_isr_msix(int irq, void *dev_id) | |||
803 | eq = &pbe_eq->q; | 667 | eq = &pbe_eq->q; |
804 | cq = pbe_eq->cq; | 668 | cq = pbe_eq->cq; |
805 | eqe = queue_tail_node(eq); | 669 | eqe = queue_tail_node(eq); |
670 | if (!eqe) | ||
671 | SE_DEBUG(DBG_LVL_1, "eqe is NULL\n"); | ||
806 | 672 | ||
807 | phba = pbe_eq->phba; | 673 | phba = pbe_eq->phba; |
808 | num_eq_processed = 0; | 674 | num_eq_processed = 0; |
@@ -817,26 +683,29 @@ static irqreturn_t be_isr_msix(int irq, void *dev_id) | |||
817 | eqe = queue_tail_node(eq); | 683 | eqe = queue_tail_node(eq); |
818 | num_eq_processed++; | 684 | num_eq_processed++; |
819 | } | 685 | } |
686 | if (num_eq_processed) | ||
687 | hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 0, 1); | ||
688 | |||
689 | return IRQ_HANDLED; | ||
820 | } else { | 690 | } else { |
821 | while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] | 691 | while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] |
822 | & EQE_VALID_MASK) { | 692 | & EQE_VALID_MASK) { |
823 | spin_lock_irqsave(&phba->isr_lock, flags); | 693 | spin_lock_irqsave(&phba->isr_lock, flags); |
824 | pbe_eq->todo_cq = true; | 694 | phba->todo_cq = 1; |
825 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 695 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
826 | AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); | 696 | AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); |
827 | queue_tail_inc(eq); | 697 | queue_tail_inc(eq); |
828 | eqe = queue_tail_node(eq); | 698 | eqe = queue_tail_node(eq); |
829 | num_eq_processed++; | 699 | num_eq_processed++; |
830 | } | 700 | } |
701 | if (phba->todo_cq) | ||
702 | queue_work(phba->wq, &phba->work_cqs); | ||
831 | 703 | ||
832 | if (pbe_eq->todo_cq) | 704 | if (num_eq_processed) |
833 | queue_work(phba->wq, &pbe_eq->work_cqs); | 705 | hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 1, 1); |
834 | } | ||
835 | 706 | ||
836 | if (num_eq_processed) | 707 | return IRQ_HANDLED; |
837 | hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 0, 1); | 708 | } |
838 | |||
839 | return IRQ_HANDLED; | ||
840 | } | 709 | } |
841 | 710 | ||
842 | /** | 711 | /** |
@@ -874,6 +743,8 @@ static irqreturn_t be_isr(int irq, void *dev_id) | |||
874 | mcc = &phba->ctrl.mcc_obj.cq; | 743 | mcc = &phba->ctrl.mcc_obj.cq; |
875 | index = 0; | 744 | index = 0; |
876 | eqe = queue_tail_node(eq); | 745 | eqe = queue_tail_node(eq); |
746 | if (!eqe) | ||
747 | SE_DEBUG(DBG_LVL_1, "eqe is NULL\n"); | ||
877 | 748 | ||
878 | num_ioeq_processed = 0; | 749 | num_ioeq_processed = 0; |
879 | num_mcceq_processed = 0; | 750 | num_mcceq_processed = 0; |
@@ -884,7 +755,7 @@ static irqreturn_t be_isr(int irq, void *dev_id) | |||
884 | resource_id) / 32] & | 755 | resource_id) / 32] & |
885 | EQE_RESID_MASK) >> 16) == mcc->id) { | 756 | EQE_RESID_MASK) >> 16) == mcc->id) { |
886 | spin_lock_irqsave(&phba->isr_lock, flags); | 757 | spin_lock_irqsave(&phba->isr_lock, flags); |
887 | pbe_eq->todo_mcc_cq = true; | 758 | phba->todo_mcc_cq = 1; |
888 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 759 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
889 | num_mcceq_processed++; | 760 | num_mcceq_processed++; |
890 | } else { | 761 | } else { |
@@ -897,8 +768,8 @@ static irqreturn_t be_isr(int irq, void *dev_id) | |||
897 | eqe = queue_tail_node(eq); | 768 | eqe = queue_tail_node(eq); |
898 | } | 769 | } |
899 | if (num_ioeq_processed || num_mcceq_processed) { | 770 | if (num_ioeq_processed || num_mcceq_processed) { |
900 | if (pbe_eq->todo_mcc_cq) | 771 | if (phba->todo_mcc_cq) |
901 | queue_work(phba->wq, &pbe_eq->work_cqs); | 772 | queue_work(phba->wq, &phba->work_cqs); |
902 | 773 | ||
903 | if ((num_mcceq_processed) && (!num_ioeq_processed)) | 774 | if ((num_mcceq_processed) && (!num_ioeq_processed)) |
904 | hwi_ring_eq_db(phba, eq->id, 0, | 775 | hwi_ring_eq_db(phba, eq->id, 0, |
@@ -921,11 +792,11 @@ static irqreturn_t be_isr(int irq, void *dev_id) | |||
921 | resource_id) / 32] & | 792 | resource_id) / 32] & |
922 | EQE_RESID_MASK) >> 16) != cq->id) { | 793 | EQE_RESID_MASK) >> 16) != cq->id) { |
923 | spin_lock_irqsave(&phba->isr_lock, flags); | 794 | spin_lock_irqsave(&phba->isr_lock, flags); |
924 | pbe_eq->todo_mcc_cq = true; | 795 | phba->todo_mcc_cq = 1; |
925 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 796 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
926 | } else { | 797 | } else { |
927 | spin_lock_irqsave(&phba->isr_lock, flags); | 798 | spin_lock_irqsave(&phba->isr_lock, flags); |
928 | pbe_eq->todo_cq = true; | 799 | phba->todo_cq = 1; |
929 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 800 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
930 | } | 801 | } |
931 | AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); | 802 | AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); |
@@ -933,8 +804,8 @@ static irqreturn_t be_isr(int irq, void *dev_id) | |||
933 | eqe = queue_tail_node(eq); | 804 | eqe = queue_tail_node(eq); |
934 | num_ioeq_processed++; | 805 | num_ioeq_processed++; |
935 | } | 806 | } |
936 | if (pbe_eq->todo_cq || pbe_eq->todo_mcc_cq) | 807 | if (phba->todo_cq || phba->todo_mcc_cq) |
937 | queue_work(phba->wq, &pbe_eq->work_cqs); | 808 | queue_work(phba->wq, &phba->work_cqs); |
938 | 809 | ||
939 | if (num_ioeq_processed) { | 810 | if (num_ioeq_processed) { |
940 | hwi_ring_eq_db(phba, eq->id, 0, | 811 | hwi_ring_eq_db(phba, eq->id, 0, |
@@ -951,49 +822,33 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba) | |||
951 | struct hwi_controller *phwi_ctrlr; | 822 | struct hwi_controller *phwi_ctrlr; |
952 | struct hwi_context_memory *phwi_context; | 823 | struct hwi_context_memory *phwi_context; |
953 | int ret, msix_vec, i, j; | 824 | int ret, msix_vec, i, j; |
825 | char desc[32]; | ||
954 | 826 | ||
955 | phwi_ctrlr = phba->phwi_ctrlr; | 827 | phwi_ctrlr = phba->phwi_ctrlr; |
956 | phwi_context = phwi_ctrlr->phwi_ctxt; | 828 | phwi_context = phwi_ctrlr->phwi_ctxt; |
957 | 829 | ||
958 | if (phba->msix_enabled) { | 830 | if (phba->msix_enabled) { |
959 | for (i = 0; i < phba->num_cpus; i++) { | 831 | for (i = 0; i < phba->num_cpus; i++) { |
960 | phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, | 832 | sprintf(desc, "beiscsi_msix_%04x", i); |
961 | GFP_KERNEL); | ||
962 | if (!phba->msi_name[i]) { | ||
963 | ret = -ENOMEM; | ||
964 | goto free_msix_irqs; | ||
965 | } | ||
966 | |||
967 | sprintf(phba->msi_name[i], "beiscsi_%02x_%02x", | ||
968 | phba->shost->host_no, i); | ||
969 | msix_vec = phba->msix_entries[i].vector; | 833 | msix_vec = phba->msix_entries[i].vector; |
970 | ret = request_irq(msix_vec, be_isr_msix, 0, | 834 | ret = request_irq(msix_vec, be_isr_msix, 0, desc, |
971 | phba->msi_name[i], | ||
972 | &phwi_context->be_eq[i]); | 835 | &phwi_context->be_eq[i]); |
973 | if (ret) { | 836 | if (ret) { |
974 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 837 | shost_printk(KERN_ERR, phba->shost, |
975 | "BM_%d : beiscsi_init_irqs-Failed to" | 838 | "beiscsi_init_irqs-Failed to" |
976 | "register msix for i = %d\n", | 839 | "register msix for i = %d\n", i); |
977 | i); | 840 | if (!i) |
978 | kfree(phba->msi_name[i]); | 841 | return ret; |
979 | goto free_msix_irqs; | 842 | goto free_msix_irqs; |
980 | } | 843 | } |
981 | } | 844 | } |
982 | phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL); | ||
983 | if (!phba->msi_name[i]) { | ||
984 | ret = -ENOMEM; | ||
985 | goto free_msix_irqs; | ||
986 | } | ||
987 | sprintf(phba->msi_name[i], "beiscsi_mcc_%02x", | ||
988 | phba->shost->host_no); | ||
989 | msix_vec = phba->msix_entries[i].vector; | 845 | msix_vec = phba->msix_entries[i].vector; |
990 | ret = request_irq(msix_vec, be_isr_mcc, 0, phba->msi_name[i], | 846 | ret = request_irq(msix_vec, be_isr_mcc, 0, "beiscsi_msix_mcc", |
991 | &phwi_context->be_eq[i]); | 847 | &phwi_context->be_eq[i]); |
992 | if (ret) { | 848 | if (ret) { |
993 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT , | 849 | shost_printk(KERN_ERR, phba->shost, "beiscsi_init_irqs-" |
994 | "BM_%d : beiscsi_init_irqs-" | 850 | "Failed to register beiscsi_msix_mcc\n"); |
995 | "Failed to register beiscsi_msix_mcc\n"); | 851 | i++; |
996 | kfree(phba->msi_name[i]); | ||
997 | goto free_msix_irqs; | 852 | goto free_msix_irqs; |
998 | } | 853 | } |
999 | 854 | ||
@@ -1001,19 +856,15 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba) | |||
1001 | ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED, | 856 | ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED, |
1002 | "beiscsi", phba); | 857 | "beiscsi", phba); |
1003 | if (ret) { | 858 | if (ret) { |
1004 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 859 | shost_printk(KERN_ERR, phba->shost, "beiscsi_init_irqs-" |
1005 | "BM_%d : beiscsi_init_irqs-" | 860 | "Failed to register irq\\n"); |
1006 | "Failed to register irq\\n"); | ||
1007 | return ret; | 861 | return ret; |
1008 | } | 862 | } |
1009 | } | 863 | } |
1010 | return 0; | 864 | return 0; |
1011 | free_msix_irqs: | 865 | free_msix_irqs: |
1012 | for (j = i - 1; j >= 0; j--) { | 866 | for (j = i - 1; j == 0; j++) |
1013 | kfree(phba->msi_name[j]); | ||
1014 | msix_vec = phba->msix_entries[j].vector; | ||
1015 | free_irq(msix_vec, &phwi_context->be_eq[j]); | 867 | free_irq(msix_vec, &phwi_context->be_eq[j]); |
1016 | } | ||
1017 | return ret; | 868 | return ret; |
1018 | } | 869 | } |
1019 | 870 | ||
@@ -1054,9 +905,7 @@ beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn, | |||
1054 | case ISCSI_OP_REJECT: | 905 | case ISCSI_OP_REJECT: |
1055 | WARN_ON(!pbuffer); | 906 | WARN_ON(!pbuffer); |
1056 | WARN_ON(!(buf_len == 48)); | 907 | WARN_ON(!(buf_len == 48)); |
1057 | beiscsi_log(phba, KERN_ERR, | 908 | SE_DEBUG(DBG_LVL_1, "In ISCSI_OP_REJECT\n"); |
1058 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | ||
1059 | "BM_%d : In ISCSI_OP_REJECT\n"); | ||
1060 | break; | 909 | break; |
1061 | case ISCSI_OP_LOGIN_RSP: | 910 | case ISCSI_OP_LOGIN_RSP: |
1062 | case ISCSI_OP_TEXT_RSP: | 911 | case ISCSI_OP_TEXT_RSP: |
@@ -1066,12 +915,11 @@ beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn, | |||
1066 | login_hdr->itt = io_task->libiscsi_itt; | 915 | login_hdr->itt = io_task->libiscsi_itt; |
1067 | break; | 916 | break; |
1068 | default: | 917 | default: |
1069 | beiscsi_log(phba, KERN_WARNING, | 918 | shost_printk(KERN_WARNING, phba->shost, |
1070 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 919 | "Unrecognized opcode 0x%x in async msg\n", |
1071 | "BM_%d : Unrecognized opcode 0x%x in async msg\n", | 920 | (ppdu-> |
1072 | (ppdu-> | ||
1073 | dw[offsetof(struct amap_pdu_base, opcode) / 32] | 921 | dw[offsetof(struct amap_pdu_base, opcode) / 32] |
1074 | & PDUBASE_OPCODE_MASK)); | 922 | & PDUBASE_OPCODE_MASK)); |
1075 | return 1; | 923 | return 1; |
1076 | } | 924 | } |
1077 | 925 | ||
@@ -1086,11 +934,9 @@ static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba) | |||
1086 | struct sgl_handle *psgl_handle; | 934 | struct sgl_handle *psgl_handle; |
1087 | 935 | ||
1088 | if (phba->io_sgl_hndl_avbl) { | 936 | if (phba->io_sgl_hndl_avbl) { |
1089 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, | 937 | SE_DEBUG(DBG_LVL_8, |
1090 | "BM_%d : In alloc_io_sgl_handle," | 938 | "In alloc_io_sgl_handle,io_sgl_alloc_index=%d\n", |
1091 | " io_sgl_alloc_index=%d\n", | 939 | phba->io_sgl_alloc_index); |
1092 | phba->io_sgl_alloc_index); | ||
1093 | |||
1094 | psgl_handle = phba->io_sgl_hndl_base[phba-> | 940 | psgl_handle = phba->io_sgl_hndl_base[phba-> |
1095 | io_sgl_alloc_index]; | 941 | io_sgl_alloc_index]; |
1096 | phba->io_sgl_hndl_base[phba->io_sgl_alloc_index] = NULL; | 942 | phba->io_sgl_hndl_base[phba->io_sgl_alloc_index] = NULL; |
@@ -1108,20 +954,17 @@ static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba) | |||
1108 | static void | 954 | static void |
1109 | free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) | 955 | free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) |
1110 | { | 956 | { |
1111 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, | 957 | SE_DEBUG(DBG_LVL_8, "In free_,io_sgl_free_index=%d\n", |
1112 | "BM_%d : In free_,io_sgl_free_index=%d\n", | 958 | phba->io_sgl_free_index); |
1113 | phba->io_sgl_free_index); | ||
1114 | |||
1115 | if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) { | 959 | if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) { |
1116 | /* | 960 | /* |
1117 | * this can happen if clean_task is called on a task that | 961 | * this can happen if clean_task is called on a task that |
1118 | * failed in xmit_task or alloc_pdu. | 962 | * failed in xmit_task or alloc_pdu. |
1119 | */ | 963 | */ |
1120 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, | 964 | SE_DEBUG(DBG_LVL_8, |
1121 | "BM_%d : Double Free in IO SGL io_sgl_free_index=%d," | 965 | "Double Free in IO SGL io_sgl_free_index=%d," |
1122 | "value there=%p\n", phba->io_sgl_free_index, | 966 | "value there=%p\n", phba->io_sgl_free_index, |
1123 | phba->io_sgl_hndl_base | 967 | phba->io_sgl_hndl_base[phba->io_sgl_free_index]); |
1124 | [phba->io_sgl_free_index]); | ||
1125 | return; | 968 | return; |
1126 | } | 969 | } |
1127 | phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; | 970 | phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; |
@@ -1183,12 +1026,11 @@ free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context, | |||
1183 | else | 1026 | else |
1184 | pwrb_context->free_index++; | 1027 | pwrb_context->free_index++; |
1185 | 1028 | ||
1186 | beiscsi_log(phba, KERN_INFO, | 1029 | SE_DEBUG(DBG_LVL_8, |
1187 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 1030 | "FREE WRB: pwrb_handle=%p free_index=0x%x" |
1188 | "BM_%d : FREE WRB: pwrb_handle=%p free_index=0x%x" | 1031 | "wrb_handles_available=%d\n", |
1189 | "wrb_handles_available=%d\n", | 1032 | pwrb_handle, pwrb_context->free_index, |
1190 | pwrb_handle, pwrb_context->free_index, | 1033 | pwrb_context->wrb_handles_available); |
1191 | pwrb_context->wrb_handles_available); | ||
1192 | } | 1034 | } |
1193 | 1035 | ||
1194 | static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) | 1036 | static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) |
@@ -1198,11 +1040,8 @@ static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) | |||
1198 | if (phba->eh_sgl_hndl_avbl) { | 1040 | if (phba->eh_sgl_hndl_avbl) { |
1199 | psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; | 1041 | psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; |
1200 | phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; | 1042 | phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; |
1201 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 1043 | SE_DEBUG(DBG_LVL_8, "mgmt_sgl_alloc_index=%d=0x%x\n", |
1202 | "BM_%d : mgmt_sgl_alloc_index=%d=0x%x\n", | 1044 | phba->eh_sgl_alloc_index, phba->eh_sgl_alloc_index); |
1203 | phba->eh_sgl_alloc_index, | ||
1204 | phba->eh_sgl_alloc_index); | ||
1205 | |||
1206 | phba->eh_sgl_hndl_avbl--; | 1045 | phba->eh_sgl_hndl_avbl--; |
1207 | if (phba->eh_sgl_alloc_index == | 1046 | if (phba->eh_sgl_alloc_index == |
1208 | (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - | 1047 | (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - |
@@ -1219,20 +1058,16 @@ void | |||
1219 | free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) | 1058 | free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) |
1220 | { | 1059 | { |
1221 | 1060 | ||
1222 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 1061 | SE_DEBUG(DBG_LVL_8, "In free_mgmt_sgl_handle,eh_sgl_free_index=%d\n", |
1223 | "BM_%d : In free_mgmt_sgl_handle," | 1062 | phba->eh_sgl_free_index); |
1224 | "eh_sgl_free_index=%d\n", | ||
1225 | phba->eh_sgl_free_index); | ||
1226 | |||
1227 | if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) { | 1063 | if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) { |
1228 | /* | 1064 | /* |
1229 | * this can happen if clean_task is called on a task that | 1065 | * this can happen if clean_task is called on a task that |
1230 | * failed in xmit_task or alloc_pdu. | 1066 | * failed in xmit_task or alloc_pdu. |
1231 | */ | 1067 | */ |
1232 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | 1068 | SE_DEBUG(DBG_LVL_8, |
1233 | "BM_%d : Double Free in eh SGL ," | 1069 | "Double Free in eh SGL ,eh_sgl_free_index=%d\n", |
1234 | "eh_sgl_free_index=%d\n", | 1070 | phba->eh_sgl_free_index); |
1235 | phba->eh_sgl_free_index); | ||
1236 | return; | 1071 | return; |
1237 | } | 1072 | } |
1238 | phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle; | 1073 | phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle; |
@@ -1246,31 +1081,32 @@ free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) | |||
1246 | 1081 | ||
1247 | static void | 1082 | static void |
1248 | be_complete_io(struct beiscsi_conn *beiscsi_conn, | 1083 | be_complete_io(struct beiscsi_conn *beiscsi_conn, |
1249 | struct iscsi_task *task, | 1084 | struct iscsi_task *task, struct sol_cqe *psol) |
1250 | struct common_sol_cqe *csol_cqe) | ||
1251 | { | 1085 | { |
1252 | struct beiscsi_io_task *io_task = task->dd_data; | 1086 | struct beiscsi_io_task *io_task = task->dd_data; |
1253 | struct be_status_bhs *sts_bhs = | 1087 | struct be_status_bhs *sts_bhs = |
1254 | (struct be_status_bhs *)io_task->cmd_bhs; | 1088 | (struct be_status_bhs *)io_task->cmd_bhs; |
1255 | struct iscsi_conn *conn = beiscsi_conn->conn; | 1089 | struct iscsi_conn *conn = beiscsi_conn->conn; |
1090 | unsigned int sense_len; | ||
1256 | unsigned char *sense; | 1091 | unsigned char *sense; |
1257 | u32 resid = 0, exp_cmdsn, max_cmdsn; | 1092 | u32 resid = 0, exp_cmdsn, max_cmdsn; |
1258 | u8 rsp, status, flags; | 1093 | u8 rsp, status, flags; |
1259 | 1094 | ||
1260 | exp_cmdsn = csol_cqe->exp_cmdsn; | 1095 | exp_cmdsn = (psol-> |
1261 | max_cmdsn = (csol_cqe->exp_cmdsn + | 1096 | dw[offsetof(struct amap_sol_cqe, i_exp_cmd_sn) / 32] |
1262 | csol_cqe->cmd_wnd - 1); | 1097 | & SOL_EXP_CMD_SN_MASK); |
1263 | rsp = csol_cqe->i_resp; | 1098 | max_cmdsn = ((psol-> |
1264 | status = csol_cqe->i_sts; | 1099 | dw[offsetof(struct amap_sol_cqe, i_exp_cmd_sn) / 32] |
1265 | flags = csol_cqe->i_flags; | 1100 | & SOL_EXP_CMD_SN_MASK) + |
1266 | resid = csol_cqe->res_cnt; | 1101 | ((psol->dw[offsetof(struct amap_sol_cqe, i_cmd_wnd) |
1267 | 1102 | / 32] & SOL_CMD_WND_MASK) >> 24) - 1); | |
1268 | if (!task->sc) { | 1103 | rsp = ((psol->dw[offsetof(struct amap_sol_cqe, i_resp) / 32] |
1269 | if (io_task->scsi_cmnd) | 1104 | & SOL_RESP_MASK) >> 16); |
1270 | scsi_dma_unmap(io_task->scsi_cmnd); | 1105 | status = ((psol->dw[offsetof(struct amap_sol_cqe, i_sts) / 32] |
1106 | & SOL_STS_MASK) >> 8); | ||
1107 | flags = ((psol->dw[offsetof(struct amap_sol_cqe, i_flags) / 32] | ||
1108 | & SOL_FLAGS_MASK) >> 24) | 0x80; | ||
1271 | 1109 | ||
1272 | return; | ||
1273 | } | ||
1274 | task->sc->result = (DID_OK << 16) | status; | 1110 | task->sc->result = (DID_OK << 16) | status; |
1275 | if (rsp != ISCSI_STATUS_CMD_COMPLETED) { | 1111 | if (rsp != ISCSI_STATUS_CMD_COMPLETED) { |
1276 | task->sc->result = DID_ERROR << 16; | 1112 | task->sc->result = DID_ERROR << 16; |
@@ -1279,6 +1115,9 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn, | |||
1279 | 1115 | ||
1280 | /* bidi not initially supported */ | 1116 | /* bidi not initially supported */ |
1281 | if (flags & (ISCSI_FLAG_CMD_UNDERFLOW | ISCSI_FLAG_CMD_OVERFLOW)) { | 1117 | if (flags & (ISCSI_FLAG_CMD_UNDERFLOW | ISCSI_FLAG_CMD_OVERFLOW)) { |
1118 | resid = (psol->dw[offsetof(struct amap_sol_cqe, i_res_cnt) / | ||
1119 | 32] & SOL_RES_CNT_MASK); | ||
1120 | |||
1282 | if (!status && (flags & ISCSI_FLAG_CMD_OVERFLOW)) | 1121 | if (!status && (flags & ISCSI_FLAG_CMD_OVERFLOW)) |
1283 | task->sc->result = DID_ERROR << 16; | 1122 | task->sc->result = DID_ERROR << 16; |
1284 | 1123 | ||
@@ -1291,17 +1130,20 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn, | |||
1291 | } | 1130 | } |
1292 | 1131 | ||
1293 | if (status == SAM_STAT_CHECK_CONDITION) { | 1132 | if (status == SAM_STAT_CHECK_CONDITION) { |
1294 | u16 sense_len; | ||
1295 | unsigned short *slen = (unsigned short *)sts_bhs->sense_info; | 1133 | unsigned short *slen = (unsigned short *)sts_bhs->sense_info; |
1296 | |||
1297 | sense = sts_bhs->sense_info + sizeof(unsigned short); | 1134 | sense = sts_bhs->sense_info + sizeof(unsigned short); |
1298 | sense_len = be16_to_cpu(*slen); | 1135 | sense_len = cpu_to_be16(*slen); |
1299 | memcpy(task->sc->sense_buffer, sense, | 1136 | memcpy(task->sc->sense_buffer, sense, |
1300 | min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE)); | 1137 | min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE)); |
1301 | } | 1138 | } |
1302 | 1139 | ||
1303 | if (io_task->cmd_bhs->iscsi_hdr.flags & ISCSI_FLAG_CMD_READ) | 1140 | if (io_task->cmd_bhs->iscsi_hdr.flags & ISCSI_FLAG_CMD_READ) { |
1304 | conn->rxdata_octets += resid; | 1141 | if (psol->dw[offsetof(struct amap_sol_cqe, i_res_cnt) / 32] |
1142 | & SOL_RES_CNT_MASK) | ||
1143 | conn->rxdata_octets += (psol-> | ||
1144 | dw[offsetof(struct amap_sol_cqe, i_res_cnt) / 32] | ||
1145 | & SOL_RES_CNT_MASK); | ||
1146 | } | ||
1305 | unmap: | 1147 | unmap: |
1306 | scsi_dma_unmap(io_task->scsi_cmnd); | 1148 | scsi_dma_unmap(io_task->scsi_cmnd); |
1307 | iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn); | 1149 | iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn); |
@@ -1309,8 +1151,7 @@ unmap: | |||
1309 | 1151 | ||
1310 | static void | 1152 | static void |
1311 | be_complete_logout(struct beiscsi_conn *beiscsi_conn, | 1153 | be_complete_logout(struct beiscsi_conn *beiscsi_conn, |
1312 | struct iscsi_task *task, | 1154 | struct iscsi_task *task, struct sol_cqe *psol) |
1313 | struct common_sol_cqe *csol_cqe) | ||
1314 | { | 1155 | { |
1315 | struct iscsi_logout_rsp *hdr; | 1156 | struct iscsi_logout_rsp *hdr; |
1316 | struct beiscsi_io_task *io_task = task->dd_data; | 1157 | struct beiscsi_io_task *io_task = task->dd_data; |
@@ -1320,11 +1161,18 @@ be_complete_logout(struct beiscsi_conn *beiscsi_conn, | |||
1320 | hdr->opcode = ISCSI_OP_LOGOUT_RSP; | 1161 | hdr->opcode = ISCSI_OP_LOGOUT_RSP; |
1321 | hdr->t2wait = 5; | 1162 | hdr->t2wait = 5; |
1322 | hdr->t2retain = 0; | 1163 | hdr->t2retain = 0; |
1323 | hdr->flags = csol_cqe->i_flags; | 1164 | hdr->flags = ((psol->dw[offsetof(struct amap_sol_cqe, i_flags) / 32] |
1324 | hdr->response = csol_cqe->i_resp; | 1165 | & SOL_FLAGS_MASK) >> 24) | 0x80; |
1325 | hdr->exp_cmdsn = csol_cqe->exp_cmdsn; | 1166 | hdr->response = (psol->dw[offsetof(struct amap_sol_cqe, i_resp) / |
1326 | hdr->max_cmdsn = (csol_cqe->exp_cmdsn + csol_cqe->cmd_wnd - 1); | 1167 | 32] & SOL_RESP_MASK); |
1327 | 1168 | hdr->exp_cmdsn = cpu_to_be32(psol-> | |
1169 | dw[offsetof(struct amap_sol_cqe, i_exp_cmd_sn) / 32] | ||
1170 | & SOL_EXP_CMD_SN_MASK); | ||
1171 | hdr->max_cmdsn = be32_to_cpu((psol-> | ||
1172 | dw[offsetof(struct amap_sol_cqe, i_exp_cmd_sn) / 32] | ||
1173 | & SOL_EXP_CMD_SN_MASK) + | ||
1174 | ((psol->dw[offsetof(struct amap_sol_cqe, i_cmd_wnd) | ||
1175 | / 32] & SOL_CMD_WND_MASK) >> 24) - 1); | ||
1328 | hdr->dlength[0] = 0; | 1176 | hdr->dlength[0] = 0; |
1329 | hdr->dlength[1] = 0; | 1177 | hdr->dlength[1] = 0; |
1330 | hdr->dlength[2] = 0; | 1178 | hdr->dlength[2] = 0; |
@@ -1335,8 +1183,7 @@ be_complete_logout(struct beiscsi_conn *beiscsi_conn, | |||
1335 | 1183 | ||
1336 | static void | 1184 | static void |
1337 | be_complete_tmf(struct beiscsi_conn *beiscsi_conn, | 1185 | be_complete_tmf(struct beiscsi_conn *beiscsi_conn, |
1338 | struct iscsi_task *task, | 1186 | struct iscsi_task *task, struct sol_cqe *psol) |
1339 | struct common_sol_cqe *csol_cqe) | ||
1340 | { | 1187 | { |
1341 | struct iscsi_tm_rsp *hdr; | 1188 | struct iscsi_tm_rsp *hdr; |
1342 | struct iscsi_conn *conn = beiscsi_conn->conn; | 1189 | struct iscsi_conn *conn = beiscsi_conn->conn; |
@@ -1344,12 +1191,16 @@ be_complete_tmf(struct beiscsi_conn *beiscsi_conn, | |||
1344 | 1191 | ||
1345 | hdr = (struct iscsi_tm_rsp *)task->hdr; | 1192 | hdr = (struct iscsi_tm_rsp *)task->hdr; |
1346 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; | 1193 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; |
1347 | hdr->flags = csol_cqe->i_flags; | 1194 | hdr->flags = ((psol->dw[offsetof(struct amap_sol_cqe, i_flags) / 32] |
1348 | hdr->response = csol_cqe->i_resp; | 1195 | & SOL_FLAGS_MASK) >> 24) | 0x80; |
1349 | hdr->exp_cmdsn = csol_cqe->exp_cmdsn; | 1196 | hdr->response = (psol->dw[offsetof(struct amap_sol_cqe, i_resp) / |
1350 | hdr->max_cmdsn = (csol_cqe->exp_cmdsn + | 1197 | 32] & SOL_RESP_MASK); |
1351 | csol_cqe->cmd_wnd - 1); | 1198 | hdr->exp_cmdsn = cpu_to_be32(psol->dw[offsetof(struct amap_sol_cqe, |
1352 | 1199 | i_exp_cmd_sn) / 32] & SOL_EXP_CMD_SN_MASK); | |
1200 | hdr->max_cmdsn = be32_to_cpu((psol->dw[offsetof(struct amap_sol_cqe, | ||
1201 | i_exp_cmd_sn) / 32] & SOL_EXP_CMD_SN_MASK) + | ||
1202 | ((psol->dw[offsetof(struct amap_sol_cqe, i_cmd_wnd) | ||
1203 | / 32] & SOL_CMD_WND_MASK) >> 24) - 1); | ||
1353 | hdr->itt = io_task->libiscsi_itt; | 1204 | hdr->itt = io_task->libiscsi_itt; |
1354 | __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); | 1205 | __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); |
1355 | } | 1206 | } |
@@ -1365,30 +1216,21 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, | |||
1365 | struct beiscsi_io_task *io_task; | 1216 | struct beiscsi_io_task *io_task; |
1366 | struct iscsi_conn *conn = beiscsi_conn->conn; | 1217 | struct iscsi_conn *conn = beiscsi_conn->conn; |
1367 | struct iscsi_session *session = conn->session; | 1218 | struct iscsi_session *session = conn->session; |
1368 | uint16_t wrb_index, cid; | ||
1369 | 1219 | ||
1370 | phwi_ctrlr = phba->phwi_ctrlr; | 1220 | phwi_ctrlr = phba->phwi_ctrlr; |
1371 | if (chip_skh_r(phba->pcidev)) { | 1221 | pwrb_context = &phwi_ctrlr->wrb_context[((psol-> |
1372 | wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2, | 1222 | dw[offsetof(struct amap_sol_cqe, cid) / 32] & |
1373 | wrb_idx, psol); | 1223 | SOL_CID_MASK) >> 6) - |
1374 | cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2, | 1224 | phba->fw_config.iscsi_cid_start]; |
1375 | cid, psol); | 1225 | pwrb_handle = pwrb_context->pwrb_handle_basestd[((psol-> |
1376 | } else { | 1226 | dw[offsetof(struct amap_sol_cqe, wrb_index) / |
1377 | wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe, | 1227 | 32] & SOL_WRB_INDEX_MASK) >> 16)]; |
1378 | wrb_idx, psol); | ||
1379 | cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe, | ||
1380 | cid, psol); | ||
1381 | } | ||
1382 | |||
1383 | pwrb_context = &phwi_ctrlr->wrb_context[ | ||
1384 | cid - phba->fw_config.iscsi_cid_start]; | ||
1385 | pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index]; | ||
1386 | task = pwrb_handle->pio_handle; | 1228 | task = pwrb_handle->pio_handle; |
1387 | 1229 | ||
1388 | io_task = task->dd_data; | 1230 | io_task = task->dd_data; |
1389 | spin_lock_bh(&phba->mgmt_sgl_lock); | 1231 | spin_lock(&phba->mgmt_sgl_lock); |
1390 | free_mgmt_sgl_handle(phba, io_task->psgl_handle); | 1232 | free_mgmt_sgl_handle(phba, io_task->psgl_handle); |
1391 | spin_unlock_bh(&phba->mgmt_sgl_lock); | 1233 | spin_unlock(&phba->mgmt_sgl_lock); |
1392 | spin_lock_bh(&session->lock); | 1234 | spin_lock_bh(&session->lock); |
1393 | free_wrb_handle(phba, pwrb_context, pwrb_handle); | 1235 | free_wrb_handle(phba, pwrb_context, pwrb_handle); |
1394 | spin_unlock_bh(&session->lock); | 1236 | spin_unlock_bh(&session->lock); |
@@ -1396,78 +1238,26 @@ hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, | |||
1396 | 1238 | ||
1397 | static void | 1239 | static void |
1398 | be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn, | 1240 | be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn, |
1399 | struct iscsi_task *task, | 1241 | struct iscsi_task *task, struct sol_cqe *psol) |
1400 | struct common_sol_cqe *csol_cqe) | ||
1401 | { | 1242 | { |
1402 | struct iscsi_nopin *hdr; | 1243 | struct iscsi_nopin *hdr; |
1403 | struct iscsi_conn *conn = beiscsi_conn->conn; | 1244 | struct iscsi_conn *conn = beiscsi_conn->conn; |
1404 | struct beiscsi_io_task *io_task = task->dd_data; | 1245 | struct beiscsi_io_task *io_task = task->dd_data; |
1405 | 1246 | ||
1406 | hdr = (struct iscsi_nopin *)task->hdr; | 1247 | hdr = (struct iscsi_nopin *)task->hdr; |
1407 | hdr->flags = csol_cqe->i_flags; | 1248 | hdr->flags = ((psol->dw[offsetof(struct amap_sol_cqe, i_flags) / 32] |
1408 | hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn); | 1249 | & SOL_FLAGS_MASK) >> 24) | 0x80; |
1409 | hdr->max_cmdsn = be32_to_cpu(hdr->exp_cmdsn + | 1250 | hdr->exp_cmdsn = cpu_to_be32(psol->dw[offsetof(struct amap_sol_cqe, |
1410 | csol_cqe->cmd_wnd - 1); | 1251 | i_exp_cmd_sn) / 32] & SOL_EXP_CMD_SN_MASK); |
1411 | 1252 | hdr->max_cmdsn = be32_to_cpu((psol->dw[offsetof(struct amap_sol_cqe, | |
1253 | i_exp_cmd_sn) / 32] & SOL_EXP_CMD_SN_MASK) + | ||
1254 | ((psol->dw[offsetof(struct amap_sol_cqe, i_cmd_wnd) | ||
1255 | / 32] & SOL_CMD_WND_MASK) >> 24) - 1); | ||
1412 | hdr->opcode = ISCSI_OP_NOOP_IN; | 1256 | hdr->opcode = ISCSI_OP_NOOP_IN; |
1413 | hdr->itt = io_task->libiscsi_itt; | 1257 | hdr->itt = io_task->libiscsi_itt; |
1414 | __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); | 1258 | __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); |
1415 | } | 1259 | } |
1416 | 1260 | ||
1417 | static void adapter_get_sol_cqe(struct beiscsi_hba *phba, | ||
1418 | struct sol_cqe *psol, | ||
1419 | struct common_sol_cqe *csol_cqe) | ||
1420 | { | ||
1421 | if (chip_skh_r(phba->pcidev)) { | ||
1422 | csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1423 | i_exp_cmd_sn, psol); | ||
1424 | csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1425 | i_res_cnt, psol); | ||
1426 | csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1427 | wrb_index, psol); | ||
1428 | csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1429 | cid, psol); | ||
1430 | csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1431 | hw_sts, psol); | ||
1432 | csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1433 | i_cmd_wnd, psol); | ||
1434 | if (AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1435 | cmd_cmpl, psol)) | ||
1436 | csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1437 | i_sts, psol); | ||
1438 | else | ||
1439 | csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1440 | i_sts, psol); | ||
1441 | if (AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1442 | u, psol)) | ||
1443 | csol_cqe->i_flags = ISCSI_FLAG_CMD_UNDERFLOW; | ||
1444 | |||
1445 | if (AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
1446 | o, psol)) | ||
1447 | csol_cqe->i_flags |= ISCSI_FLAG_CMD_OVERFLOW; | ||
1448 | } else { | ||
1449 | csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1450 | i_exp_cmd_sn, psol); | ||
1451 | csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1452 | i_res_cnt, psol); | ||
1453 | csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1454 | i_cmd_wnd, psol); | ||
1455 | csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1456 | wrb_index, psol); | ||
1457 | csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1458 | cid, psol); | ||
1459 | csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1460 | hw_sts, psol); | ||
1461 | csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1462 | i_resp, psol); | ||
1463 | csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1464 | i_sts, psol); | ||
1465 | csol_cqe->i_flags = AMAP_GET_BITS(struct amap_sol_cqe, | ||
1466 | i_flags, psol); | ||
1467 | } | ||
1468 | } | ||
1469 | |||
1470 | |||
1471 | static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, | 1261 | static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, |
1472 | struct beiscsi_hba *phba, struct sol_cqe *psol) | 1262 | struct beiscsi_hba *phba, struct sol_cqe *psol) |
1473 | { | 1263 | { |
@@ -1479,22 +1269,19 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, | |||
1479 | unsigned int type; | 1269 | unsigned int type; |
1480 | struct iscsi_conn *conn = beiscsi_conn->conn; | 1270 | struct iscsi_conn *conn = beiscsi_conn->conn; |
1481 | struct iscsi_session *session = conn->session; | 1271 | struct iscsi_session *session = conn->session; |
1482 | struct common_sol_cqe csol_cqe = {0}; | ||
1483 | 1272 | ||
1484 | phwi_ctrlr = phba->phwi_ctrlr; | 1273 | phwi_ctrlr = phba->phwi_ctrlr; |
1485 | 1274 | pwrb_context = &phwi_ctrlr->wrb_context[((psol->dw[offsetof | |
1486 | /* Copy the elements to a common structure */ | 1275 | (struct amap_sol_cqe, cid) / 32] |
1487 | adapter_get_sol_cqe(phba, psol, &csol_cqe); | 1276 | & SOL_CID_MASK) >> 6) - |
1488 | 1277 | phba->fw_config.iscsi_cid_start]; | |
1489 | pwrb_context = &phwi_ctrlr->wrb_context[ | 1278 | pwrb_handle = pwrb_context->pwrb_handle_basestd[((psol-> |
1490 | csol_cqe.cid - phba->fw_config.iscsi_cid_start]; | 1279 | dw[offsetof(struct amap_sol_cqe, wrb_index) / |
1491 | 1280 | 32] & SOL_WRB_INDEX_MASK) >> 16)]; | |
1492 | pwrb_handle = pwrb_context->pwrb_handle_basestd[ | ||
1493 | csol_cqe.wrb_index]; | ||
1494 | |||
1495 | task = pwrb_handle->pio_handle; | 1281 | task = pwrb_handle->pio_handle; |
1496 | pwrb = pwrb_handle->pwrb; | 1282 | pwrb = pwrb_handle->pwrb; |
1497 | type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type; | 1283 | type = (pwrb->dw[offsetof(struct amap_iscsi_wrb, type) / 32] & |
1284 | WRB_TYPE_MASK) >> 28; | ||
1498 | 1285 | ||
1499 | spin_lock_bh(&session->lock); | 1286 | spin_lock_bh(&session->lock); |
1500 | switch (type) { | 1287 | switch (type) { |
@@ -1502,36 +1289,37 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, | |||
1502 | case HWH_TYPE_IO_RD: | 1289 | case HWH_TYPE_IO_RD: |
1503 | if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == | 1290 | if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == |
1504 | ISCSI_OP_NOOP_OUT) | 1291 | ISCSI_OP_NOOP_OUT) |
1505 | be_complete_nopin_resp(beiscsi_conn, task, &csol_cqe); | 1292 | be_complete_nopin_resp(beiscsi_conn, task, psol); |
1506 | else | 1293 | else |
1507 | be_complete_io(beiscsi_conn, task, &csol_cqe); | 1294 | be_complete_io(beiscsi_conn, task, psol); |
1508 | break; | 1295 | break; |
1509 | 1296 | ||
1510 | case HWH_TYPE_LOGOUT: | 1297 | case HWH_TYPE_LOGOUT: |
1511 | if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) | 1298 | if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) |
1512 | be_complete_logout(beiscsi_conn, task, &csol_cqe); | 1299 | be_complete_logout(beiscsi_conn, task, psol); |
1513 | else | 1300 | else |
1514 | be_complete_tmf(beiscsi_conn, task, &csol_cqe); | 1301 | be_complete_tmf(beiscsi_conn, task, psol); |
1302 | |||
1515 | break; | 1303 | break; |
1516 | 1304 | ||
1517 | case HWH_TYPE_LOGIN: | 1305 | case HWH_TYPE_LOGIN: |
1518 | beiscsi_log(phba, KERN_ERR, | 1306 | SE_DEBUG(DBG_LVL_1, |
1519 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | 1307 | "\t\t No HWH_TYPE_LOGIN Expected in hwi_complete_cmd" |
1520 | "BM_%d :\t\t No HWH_TYPE_LOGIN Expected in" | 1308 | "- Solicited path\n"); |
1521 | " hwi_complete_cmd- Solicited path\n"); | ||
1522 | break; | 1309 | break; |
1523 | 1310 | ||
1524 | case HWH_TYPE_NOP: | 1311 | case HWH_TYPE_NOP: |
1525 | be_complete_nopin_resp(beiscsi_conn, task, &csol_cqe); | 1312 | be_complete_nopin_resp(beiscsi_conn, task, psol); |
1526 | break; | 1313 | break; |
1527 | 1314 | ||
1528 | default: | 1315 | default: |
1529 | beiscsi_log(phba, KERN_WARNING, | 1316 | shost_printk(KERN_WARNING, phba->shost, |
1530 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | 1317 | "In hwi_complete_cmd, unknown type = %d" |
1531 | "BM_%d : In hwi_complete_cmd, unknown type = %d" | 1318 | "wrb_index 0x%x CID 0x%x\n", type, |
1532 | "wrb_index 0x%x CID 0x%x\n", type, | 1319 | ((psol->dw[offsetof(struct amap_iscsi_wrb, |
1533 | csol_cqe.wrb_index, | 1320 | type) / 32] & SOL_WRB_INDEX_MASK) >> 16), |
1534 | csol_cqe.cid); | 1321 | ((psol->dw[offsetof(struct amap_sol_cqe, |
1322 | cid) / 32] & SOL_CID_MASK) >> 6)); | ||
1535 | break; | 1323 | break; |
1536 | } | 1324 | } |
1537 | 1325 | ||
@@ -1558,27 +1346,16 @@ hwi_get_async_handle(struct beiscsi_hba *phba, | |||
1558 | struct be_bus_address phys_addr; | 1346 | struct be_bus_address phys_addr; |
1559 | struct list_head *pbusy_list; | 1347 | struct list_head *pbusy_list; |
1560 | struct async_pdu_handle *pasync_handle = NULL; | 1348 | struct async_pdu_handle *pasync_handle = NULL; |
1349 | int buffer_len = 0; | ||
1350 | unsigned char buffer_index = -1; | ||
1561 | unsigned char is_header = 0; | 1351 | unsigned char is_header = 0; |
1562 | unsigned int index, dpl; | ||
1563 | |||
1564 | if (chip_skh_r(phba->pcidev)) { | ||
1565 | dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2, | ||
1566 | dpl, pdpdu_cqe); | ||
1567 | index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2, | ||
1568 | index, pdpdu_cqe); | ||
1569 | } else { | ||
1570 | dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe, | ||
1571 | dpl, pdpdu_cqe); | ||
1572 | index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe, | ||
1573 | index, pdpdu_cqe); | ||
1574 | } | ||
1575 | 1352 | ||
1576 | phys_addr.u.a32.address_lo = | 1353 | phys_addr.u.a32.address_lo = |
1577 | (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, | 1354 | pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, db_addr_lo) / 32] - |
1578 | db_addr_lo) / 32] - dpl); | 1355 | ((pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, dpl) / 32] |
1356 | & PDUCQE_DPL_MASK) >> 16); | ||
1579 | phys_addr.u.a32.address_hi = | 1357 | phys_addr.u.a32.address_hi = |
1580 | pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, | 1358 | pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, db_addr_hi) / 32]; |
1581 | db_addr_hi) / 32]; | ||
1582 | 1359 | ||
1583 | phys_addr.u.a64.address = | 1360 | phys_addr.u.a64.address = |
1584 | *((unsigned long long *)(&phys_addr.u.a64.address)); | 1361 | *((unsigned long long *)(&phys_addr.u.a64.address)); |
@@ -1588,26 +1365,40 @@ hwi_get_async_handle(struct beiscsi_hba *phba, | |||
1588 | case UNSOL_HDR_NOTIFY: | 1365 | case UNSOL_HDR_NOTIFY: |
1589 | is_header = 1; | 1366 | is_header = 1; |
1590 | 1367 | ||
1591 | pbusy_list = hwi_get_async_busy_list(pasync_ctx, | 1368 | pbusy_list = hwi_get_async_busy_list(pasync_ctx, 1, |
1592 | is_header, index); | 1369 | (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, |
1370 | index) / 32] & PDUCQE_INDEX_MASK)); | ||
1371 | |||
1372 | buffer_len = (unsigned int)(phys_addr.u.a64.address - | ||
1373 | pasync_ctx->async_header.pa_base.u.a64.address); | ||
1374 | |||
1375 | buffer_index = buffer_len / | ||
1376 | pasync_ctx->async_header.buffer_size; | ||
1377 | |||
1593 | break; | 1378 | break; |
1594 | case UNSOL_DATA_NOTIFY: | 1379 | case UNSOL_DATA_NOTIFY: |
1595 | pbusy_list = hwi_get_async_busy_list(pasync_ctx, | 1380 | pbusy_list = hwi_get_async_busy_list(pasync_ctx, 0, (pdpdu_cqe-> |
1596 | is_header, index); | 1381 | dw[offsetof(struct amap_i_t_dpdu_cqe, |
1382 | index) / 32] & PDUCQE_INDEX_MASK)); | ||
1383 | buffer_len = (unsigned long)(phys_addr.u.a64.address - | ||
1384 | pasync_ctx->async_data.pa_base.u. | ||
1385 | a64.address); | ||
1386 | buffer_index = buffer_len / pasync_ctx->async_data.buffer_size; | ||
1597 | break; | 1387 | break; |
1598 | default: | 1388 | default: |
1599 | pbusy_list = NULL; | 1389 | pbusy_list = NULL; |
1600 | beiscsi_log(phba, KERN_WARNING, | 1390 | shost_printk(KERN_WARNING, phba->shost, |
1601 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 1391 | "Unexpected code=%d\n", |
1602 | "BM_%d : Unexpected code=%d\n", | 1392 | pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, |
1603 | pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, | 1393 | code) / 32] & PDUCQE_CODE_MASK); |
1604 | code) / 32] & PDUCQE_CODE_MASK); | ||
1605 | return NULL; | 1394 | return NULL; |
1606 | } | 1395 | } |
1607 | 1396 | ||
1397 | WARN_ON(!(buffer_index <= pasync_ctx->async_data.num_entries)); | ||
1608 | WARN_ON(list_empty(pbusy_list)); | 1398 | WARN_ON(list_empty(pbusy_list)); |
1609 | list_for_each_entry(pasync_handle, pbusy_list, link) { | 1399 | list_for_each_entry(pasync_handle, pbusy_list, link) { |
1610 | if (pasync_handle->pa.u.a64.address == phys_addr.u.a64.address) | 1400 | WARN_ON(pasync_handle->consumed); |
1401 | if (pasync_handle->index == buffer_index) | ||
1611 | break; | 1402 | break; |
1612 | } | 1403 | } |
1613 | 1404 | ||
@@ -1616,29 +1407,33 @@ hwi_get_async_handle(struct beiscsi_hba *phba, | |||
1616 | pasync_handle->cri = (unsigned short)beiscsi_conn->beiscsi_conn_cid - | 1407 | pasync_handle->cri = (unsigned short)beiscsi_conn->beiscsi_conn_cid - |
1617 | phba->fw_config.iscsi_cid_start; | 1408 | phba->fw_config.iscsi_cid_start; |
1618 | pasync_handle->is_header = is_header; | 1409 | pasync_handle->is_header = is_header; |
1619 | pasync_handle->buffer_len = dpl; | 1410 | pasync_handle->buffer_len = ((pdpdu_cqe-> |
1620 | *pcq_index = index; | 1411 | dw[offsetof(struct amap_i_t_dpdu_cqe, dpl) / 32] |
1412 | & PDUCQE_DPL_MASK) >> 16); | ||
1621 | 1413 | ||
1414 | *pcq_index = (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, | ||
1415 | index) / 32] & PDUCQE_INDEX_MASK); | ||
1622 | return pasync_handle; | 1416 | return pasync_handle; |
1623 | } | 1417 | } |
1624 | 1418 | ||
1625 | static unsigned int | 1419 | static unsigned int |
1626 | hwi_update_async_writables(struct beiscsi_hba *phba, | 1420 | hwi_update_async_writables(struct hwi_async_pdu_context *pasync_ctx, |
1627 | struct hwi_async_pdu_context *pasync_ctx, | 1421 | unsigned int is_header, unsigned int cq_index) |
1628 | unsigned int is_header, unsigned int cq_index) | ||
1629 | { | 1422 | { |
1630 | struct list_head *pbusy_list; | 1423 | struct list_head *pbusy_list; |
1631 | struct async_pdu_handle *pasync_handle; | 1424 | struct async_pdu_handle *pasync_handle; |
1632 | unsigned int num_entries, writables = 0; | 1425 | unsigned int num_entries, writables = 0; |
1633 | unsigned int *pep_read_ptr, *pwritables; | 1426 | unsigned int *pep_read_ptr, *pwritables; |
1634 | 1427 | ||
1635 | num_entries = pasync_ctx->num_entries; | 1428 | |
1636 | if (is_header) { | 1429 | if (is_header) { |
1637 | pep_read_ptr = &pasync_ctx->async_header.ep_read_ptr; | 1430 | pep_read_ptr = &pasync_ctx->async_header.ep_read_ptr; |
1638 | pwritables = &pasync_ctx->async_header.writables; | 1431 | pwritables = &pasync_ctx->async_header.writables; |
1432 | num_entries = pasync_ctx->async_header.num_entries; | ||
1639 | } else { | 1433 | } else { |
1640 | pep_read_ptr = &pasync_ctx->async_data.ep_read_ptr; | 1434 | pep_read_ptr = &pasync_ctx->async_data.ep_read_ptr; |
1641 | pwritables = &pasync_ctx->async_data.writables; | 1435 | pwritables = &pasync_ctx->async_data.writables; |
1436 | num_entries = pasync_ctx->async_data.num_entries; | ||
1642 | } | 1437 | } |
1643 | 1438 | ||
1644 | while ((*pep_read_ptr) != cq_index) { | 1439 | while ((*pep_read_ptr) != cq_index) { |
@@ -1662,10 +1457,9 @@ hwi_update_async_writables(struct beiscsi_hba *phba, | |||
1662 | } | 1457 | } |
1663 | 1458 | ||
1664 | if (!writables) { | 1459 | if (!writables) { |
1665 | beiscsi_log(phba, KERN_ERR, | 1460 | SE_DEBUG(DBG_LVL_1, |
1666 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | 1461 | "Duplicate notification received - index 0x%x!!\n", |
1667 | "BM_%d : Duplicate notification received - index 0x%x!!\n", | 1462 | cq_index); |
1668 | cq_index); | ||
1669 | WARN_ON(1); | 1463 | WARN_ON(1); |
1670 | } | 1464 | } |
1671 | 1465 | ||
@@ -1673,13 +1467,14 @@ hwi_update_async_writables(struct beiscsi_hba *phba, | |||
1673 | return 0; | 1467 | return 0; |
1674 | } | 1468 | } |
1675 | 1469 | ||
1676 | static void hwi_free_async_msg(struct beiscsi_hba *phba, | 1470 | static unsigned int hwi_free_async_msg(struct beiscsi_hba *phba, |
1677 | unsigned int cri) | 1471 | unsigned int cri) |
1678 | { | 1472 | { |
1679 | struct hwi_controller *phwi_ctrlr; | 1473 | struct hwi_controller *phwi_ctrlr; |
1680 | struct hwi_async_pdu_context *pasync_ctx; | 1474 | struct hwi_async_pdu_context *pasync_ctx; |
1681 | struct async_pdu_handle *pasync_handle, *tmp_handle; | 1475 | struct async_pdu_handle *pasync_handle, *tmp_handle; |
1682 | struct list_head *plist; | 1476 | struct list_head *plist; |
1477 | unsigned int i = 0; | ||
1683 | 1478 | ||
1684 | phwi_ctrlr = phba->phwi_ctrlr; | 1479 | phwi_ctrlr = phba->phwi_ctrlr; |
1685 | pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr); | 1480 | pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr); |
@@ -1689,20 +1484,23 @@ static void hwi_free_async_msg(struct beiscsi_hba *phba, | |||
1689 | list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) { | 1484 | list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) { |
1690 | list_del(&pasync_handle->link); | 1485 | list_del(&pasync_handle->link); |
1691 | 1486 | ||
1692 | if (pasync_handle->is_header) { | 1487 | if (i == 0) { |
1693 | list_add_tail(&pasync_handle->link, | 1488 | list_add_tail(&pasync_handle->link, |
1694 | &pasync_ctx->async_header.free_list); | 1489 | &pasync_ctx->async_header.free_list); |
1695 | pasync_ctx->async_header.free_entries++; | 1490 | pasync_ctx->async_header.free_entries++; |
1491 | i++; | ||
1696 | } else { | 1492 | } else { |
1697 | list_add_tail(&pasync_handle->link, | 1493 | list_add_tail(&pasync_handle->link, |
1698 | &pasync_ctx->async_data.free_list); | 1494 | &pasync_ctx->async_data.free_list); |
1699 | pasync_ctx->async_data.free_entries++; | 1495 | pasync_ctx->async_data.free_entries++; |
1496 | i++; | ||
1700 | } | 1497 | } |
1701 | } | 1498 | } |
1702 | 1499 | ||
1703 | INIT_LIST_HEAD(&pasync_ctx->async_entry[cri].wait_queue.list); | 1500 | INIT_LIST_HEAD(&pasync_ctx->async_entry[cri].wait_queue.list); |
1704 | pasync_ctx->async_entry[cri].wait_queue.hdr_received = 0; | 1501 | pasync_ctx->async_entry[cri].wait_queue.hdr_received = 0; |
1705 | pasync_ctx->async_entry[cri].wait_queue.bytes_received = 0; | 1502 | pasync_ctx->async_entry[cri].wait_queue.bytes_received = 0; |
1503 | return 0; | ||
1706 | } | 1504 | } |
1707 | 1505 | ||
1708 | static struct phys_addr * | 1506 | static struct phys_addr * |
@@ -1735,15 +1533,16 @@ static void hwi_post_async_buffers(struct beiscsi_hba *phba, | |||
1735 | 1533 | ||
1736 | phwi_ctrlr = phba->phwi_ctrlr; | 1534 | phwi_ctrlr = phba->phwi_ctrlr; |
1737 | pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr); | 1535 | pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr); |
1738 | num_entries = pasync_ctx->num_entries; | ||
1739 | 1536 | ||
1740 | if (is_header) { | 1537 | if (is_header) { |
1538 | num_entries = pasync_ctx->async_header.num_entries; | ||
1741 | writables = min(pasync_ctx->async_header.writables, | 1539 | writables = min(pasync_ctx->async_header.writables, |
1742 | pasync_ctx->async_header.free_entries); | 1540 | pasync_ctx->async_header.free_entries); |
1743 | pfree_link = pasync_ctx->async_header.free_list.next; | 1541 | pfree_link = pasync_ctx->async_header.free_list.next; |
1744 | host_write_num = pasync_ctx->async_header.host_write_ptr; | 1542 | host_write_num = pasync_ctx->async_header.host_write_ptr; |
1745 | ring_id = phwi_ctrlr->default_pdu_hdr.id; | 1543 | ring_id = phwi_ctrlr->default_pdu_hdr.id; |
1746 | } else { | 1544 | } else { |
1545 | num_entries = pasync_ctx->async_data.num_entries; | ||
1747 | writables = min(pasync_ctx->async_data.writables, | 1546 | writables = min(pasync_ctx->async_data.writables, |
1748 | pasync_ctx->async_data.free_entries); | 1547 | pasync_ctx->async_data.free_entries); |
1749 | pfree_link = pasync_ctx->async_data.free_list.next; | 1548 | pfree_link = pasync_ctx->async_data.free_list.next; |
@@ -1816,8 +1615,8 @@ static void hwi_flush_default_pdu_buffer(struct beiscsi_hba *phba, | |||
1816 | pdpdu_cqe, &cq_index); | 1615 | pdpdu_cqe, &cq_index); |
1817 | BUG_ON(pasync_handle->is_header != 0); | 1616 | BUG_ON(pasync_handle->is_header != 0); |
1818 | if (pasync_handle->consumed == 0) | 1617 | if (pasync_handle->consumed == 0) |
1819 | hwi_update_async_writables(phba, pasync_ctx, | 1618 | hwi_update_async_writables(pasync_ctx, pasync_handle->is_header, |
1820 | pasync_handle->is_header, cq_index); | 1619 | cq_index); |
1821 | 1620 | ||
1822 | hwi_free_async_msg(phba, pasync_handle->cri); | 1621 | hwi_free_async_msg(phba, pasync_handle->cri); |
1823 | hwi_post_async_buffers(phba, pasync_handle->is_header); | 1622 | hwi_post_async_buffers(phba, pasync_handle->is_header); |
@@ -1850,7 +1649,7 @@ hwi_fwd_async_msg(struct beiscsi_conn *beiscsi_conn, | |||
1850 | } | 1649 | } |
1851 | memcpy(pfirst_buffer + offset, | 1650 | memcpy(pfirst_buffer + offset, |
1852 | pasync_handle->pbuffer, buf_len); | 1651 | pasync_handle->pbuffer, buf_len); |
1853 | offset += buf_len; | 1652 | offset = buf_len; |
1854 | } | 1653 | } |
1855 | index++; | 1654 | index++; |
1856 | } | 1655 | } |
@@ -1859,9 +1658,10 @@ hwi_fwd_async_msg(struct beiscsi_conn *beiscsi_conn, | |||
1859 | (beiscsi_conn->beiscsi_conn_cid - | 1658 | (beiscsi_conn->beiscsi_conn_cid - |
1860 | phba->fw_config.iscsi_cid_start), | 1659 | phba->fw_config.iscsi_cid_start), |
1861 | phdr, hdr_len, pfirst_buffer, | 1660 | phdr, hdr_len, pfirst_buffer, |
1862 | offset); | 1661 | buf_len); |
1863 | 1662 | ||
1864 | hwi_free_async_msg(phba, cri); | 1663 | if (status == 0) |
1664 | hwi_free_async_msg(phba, cri); | ||
1865 | return 0; | 1665 | return 0; |
1866 | } | 1666 | } |
1867 | 1667 | ||
@@ -1945,9 +1745,8 @@ static void hwi_process_default_pdu_ring(struct beiscsi_conn *beiscsi_conn, | |||
1945 | pdpdu_cqe, &cq_index); | 1745 | pdpdu_cqe, &cq_index); |
1946 | 1746 | ||
1947 | if (pasync_handle->consumed == 0) | 1747 | if (pasync_handle->consumed == 0) |
1948 | hwi_update_async_writables(phba, pasync_ctx, | 1748 | hwi_update_async_writables(pasync_ctx, pasync_handle->is_header, |
1949 | pasync_handle->is_header, cq_index); | 1749 | cq_index); |
1950 | |||
1951 | hwi_gather_async_pdu(beiscsi_conn, phba, pasync_handle); | 1750 | hwi_gather_async_pdu(beiscsi_conn, phba, pasync_handle); |
1952 | hwi_post_async_buffers(phba, pasync_handle->is_header); | 1751 | hwi_post_async_buffers(phba, pasync_handle->is_header); |
1953 | } | 1752 | } |
@@ -1975,10 +1774,9 @@ static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba) | |||
1975 | beiscsi_async_link_state_process(phba, | 1774 | beiscsi_async_link_state_process(phba, |
1976 | (struct be_async_event_link_state *) mcc_compl); | 1775 | (struct be_async_event_link_state *) mcc_compl); |
1977 | else | 1776 | else |
1978 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_MBOX, | 1777 | SE_DEBUG(DBG_LVL_1, |
1979 | "BM_%d : Unsupported Async Event, flags" | 1778 | " Unsupported Async Event, flags" |
1980 | " = 0x%08x\n", | 1779 | " = 0x%08x\n", mcc_compl->flags); |
1981 | mcc_compl->flags); | ||
1982 | } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) { | 1780 | } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) { |
1983 | be_mcc_compl_process_isr(&phba->ctrl, mcc_compl); | 1781 | be_mcc_compl_process_isr(&phba->ctrl, mcc_compl); |
1984 | atomic_dec(&phba->ctrl.mcc_obj.q.used); | 1782 | atomic_dec(&phba->ctrl.mcc_obj.q.used); |
@@ -1996,13 +1794,6 @@ static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba) | |||
1996 | 1794 | ||
1997 | } | 1795 | } |
1998 | 1796 | ||
1999 | /** | ||
2000 | * beiscsi_process_cq()- Process the Completion Queue | ||
2001 | * @pbe_eq: Event Q on which the Completion has come | ||
2002 | * | ||
2003 | * return | ||
2004 | * Number of Completion Entries processed. | ||
2005 | **/ | ||
2006 | static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) | 1797 | static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) |
2007 | { | 1798 | { |
2008 | struct be_queue_info *cq; | 1799 | struct be_queue_info *cq; |
@@ -2010,7 +1801,6 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) | |||
2010 | struct dmsg_cqe *dmsg; | 1801 | struct dmsg_cqe *dmsg; |
2011 | unsigned int num_processed = 0; | 1802 | unsigned int num_processed = 0; |
2012 | unsigned int tot_nump = 0; | 1803 | unsigned int tot_nump = 0; |
2013 | unsigned short code = 0, cid = 0; | ||
2014 | struct beiscsi_conn *beiscsi_conn; | 1804 | struct beiscsi_conn *beiscsi_conn; |
2015 | struct beiscsi_endpoint *beiscsi_ep; | 1805 | struct beiscsi_endpoint *beiscsi_ep; |
2016 | struct iscsi_endpoint *ep; | 1806 | struct iscsi_endpoint *ep; |
@@ -2024,24 +1814,11 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) | |||
2024 | CQE_VALID_MASK) { | 1814 | CQE_VALID_MASK) { |
2025 | be_dws_le_to_cpu(sol, sizeof(struct sol_cqe)); | 1815 | be_dws_le_to_cpu(sol, sizeof(struct sol_cqe)); |
2026 | 1816 | ||
2027 | code = (sol->dw[offsetof(struct amap_sol_cqe, code) / | 1817 | ep = phba->ep_array[(u32) ((sol-> |
2028 | 32] & CQE_CODE_MASK); | 1818 | dw[offsetof(struct amap_sol_cqe, cid) / 32] & |
2029 | 1819 | SOL_CID_MASK) >> 6) - | |
2030 | /* Get the CID */ | 1820 | phba->fw_config.iscsi_cid_start]; |
2031 | if (chip_skh_r(phba->pcidev)) { | 1821 | |
2032 | if ((code == DRIVERMSG_NOTIFY) || | ||
2033 | (code == UNSOL_HDR_NOTIFY) || | ||
2034 | (code == UNSOL_DATA_NOTIFY)) | ||
2035 | cid = AMAP_GET_BITS( | ||
2036 | struct amap_i_t_dpdu_cqe_v2, | ||
2037 | cid, sol); | ||
2038 | else | ||
2039 | cid = AMAP_GET_BITS(struct amap_sol_cqe_v2, | ||
2040 | cid, sol); | ||
2041 | } else | ||
2042 | cid = AMAP_GET_BITS(struct amap_sol_cqe, cid, sol); | ||
2043 | |||
2044 | ep = phba->ep_array[cid - phba->fw_config.iscsi_cid_start]; | ||
2045 | beiscsi_ep = ep->dd_data; | 1822 | beiscsi_ep = ep->dd_data; |
2046 | beiscsi_conn = beiscsi_ep->conn; | 1823 | beiscsi_conn = beiscsi_ep->conn; |
2047 | 1824 | ||
@@ -2052,44 +1829,32 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) | |||
2052 | num_processed = 0; | 1829 | num_processed = 0; |
2053 | } | 1830 | } |
2054 | 1831 | ||
2055 | switch (code) { | 1832 | switch ((u32) sol->dw[offsetof(struct amap_sol_cqe, code) / |
1833 | 32] & CQE_CODE_MASK) { | ||
2056 | case SOL_CMD_COMPLETE: | 1834 | case SOL_CMD_COMPLETE: |
2057 | hwi_complete_cmd(beiscsi_conn, phba, sol); | 1835 | hwi_complete_cmd(beiscsi_conn, phba, sol); |
2058 | break; | 1836 | break; |
2059 | case DRIVERMSG_NOTIFY: | 1837 | case DRIVERMSG_NOTIFY: |
2060 | beiscsi_log(phba, KERN_INFO, | 1838 | SE_DEBUG(DBG_LVL_8, "Received DRIVERMSG_NOTIFY\n"); |
2061 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | ||
2062 | "BM_%d : Received %s[%d] on CID : %d\n", | ||
2063 | cqe_desc[code], code, cid); | ||
2064 | |||
2065 | dmsg = (struct dmsg_cqe *)sol; | 1839 | dmsg = (struct dmsg_cqe *)sol; |
2066 | hwi_complete_drvr_msgs(beiscsi_conn, phba, sol); | 1840 | hwi_complete_drvr_msgs(beiscsi_conn, phba, sol); |
2067 | break; | 1841 | break; |
2068 | case UNSOL_HDR_NOTIFY: | 1842 | case UNSOL_HDR_NOTIFY: |
2069 | beiscsi_log(phba, KERN_INFO, | 1843 | SE_DEBUG(DBG_LVL_8, "Received UNSOL_HDR_ NOTIFY\n"); |
2070 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | ||
2071 | "BM_%d : Received %s[%d] on CID : %d\n", | ||
2072 | cqe_desc[code], code, cid); | ||
2073 | |||
2074 | hwi_process_default_pdu_ring(beiscsi_conn, phba, | 1844 | hwi_process_default_pdu_ring(beiscsi_conn, phba, |
2075 | (struct i_t_dpdu_cqe *)sol); | 1845 | (struct i_t_dpdu_cqe *)sol); |
2076 | break; | 1846 | break; |
2077 | case UNSOL_DATA_NOTIFY: | 1847 | case UNSOL_DATA_NOTIFY: |
2078 | beiscsi_log(phba, KERN_INFO, | 1848 | SE_DEBUG(DBG_LVL_8, "Received UNSOL_DATA_NOTIFY\n"); |
2079 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | ||
2080 | "BM_%d : Received %s[%d] on CID : %d\n", | ||
2081 | cqe_desc[code], code, cid); | ||
2082 | |||
2083 | hwi_process_default_pdu_ring(beiscsi_conn, phba, | 1849 | hwi_process_default_pdu_ring(beiscsi_conn, phba, |
2084 | (struct i_t_dpdu_cqe *)sol); | 1850 | (struct i_t_dpdu_cqe *)sol); |
2085 | break; | 1851 | break; |
2086 | case CXN_INVALIDATE_INDEX_NOTIFY: | 1852 | case CXN_INVALIDATE_INDEX_NOTIFY: |
2087 | case CMD_INVALIDATED_NOTIFY: | 1853 | case CMD_INVALIDATED_NOTIFY: |
2088 | case CXN_INVALIDATE_NOTIFY: | 1854 | case CXN_INVALIDATE_NOTIFY: |
2089 | beiscsi_log(phba, KERN_ERR, | 1855 | SE_DEBUG(DBG_LVL_1, |
2090 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 1856 | "Ignoring CQ Error notification for cmd/cxn" |
2091 | "BM_%d : Ignoring %s[%d] on CID : %d\n", | 1857 | "invalidate\n"); |
2092 | cqe_desc[code], code, cid); | ||
2093 | break; | 1858 | break; |
2094 | case SOL_CMD_KILLED_DATA_DIGEST_ERR: | 1859 | case SOL_CMD_KILLED_DATA_DIGEST_ERR: |
2095 | case CMD_KILLED_INVALID_STATSN_RCVD: | 1860 | case CMD_KILLED_INVALID_STATSN_RCVD: |
@@ -2099,16 +1864,17 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) | |||
2099 | case CMD_CXN_KILLED_ITT_INVALID: | 1864 | case CMD_CXN_KILLED_ITT_INVALID: |
2100 | case CMD_CXN_KILLED_SEQ_OUTOFORDER: | 1865 | case CMD_CXN_KILLED_SEQ_OUTOFORDER: |
2101 | case CMD_CXN_KILLED_INVALID_DATASN_RCVD: | 1866 | case CMD_CXN_KILLED_INVALID_DATASN_RCVD: |
2102 | beiscsi_log(phba, KERN_ERR, | 1867 | SE_DEBUG(DBG_LVL_1, |
2103 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | 1868 | "CQ Error notification for cmd.. " |
2104 | "BM_%d : Cmd Notification %s[%d] on CID : %d\n", | 1869 | "code %d cid 0x%x\n", |
2105 | cqe_desc[code], code, cid); | 1870 | sol->dw[offsetof(struct amap_sol_cqe, code) / |
1871 | 32] & CQE_CODE_MASK, | ||
1872 | (sol->dw[offsetof(struct amap_sol_cqe, cid) / | ||
1873 | 32] & SOL_CID_MASK)); | ||
2106 | break; | 1874 | break; |
2107 | case UNSOL_DATA_DIGEST_ERROR_NOTIFY: | 1875 | case UNSOL_DATA_DIGEST_ERROR_NOTIFY: |
2108 | beiscsi_log(phba, KERN_ERR, | 1876 | SE_DEBUG(DBG_LVL_1, |
2109 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 1877 | "Digest error on def pdu ring, dropping..\n"); |
2110 | "BM_%d : Dropping %s[%d] on DPDU ring on CID : %d\n", | ||
2111 | cqe_desc[code], code, cid); | ||
2112 | hwi_flush_default_pdu_buffer(phba, beiscsi_conn, | 1878 | hwi_flush_default_pdu_buffer(phba, beiscsi_conn, |
2113 | (struct i_t_dpdu_cqe *) sol); | 1879 | (struct i_t_dpdu_cqe *) sol); |
2114 | break; | 1880 | break; |
@@ -2121,27 +1887,38 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) | |||
2121 | case CXN_KILLED_INVALID_ITT_TTT_RCVD: | 1887 | case CXN_KILLED_INVALID_ITT_TTT_RCVD: |
2122 | case CXN_KILLED_TIMED_OUT: | 1888 | case CXN_KILLED_TIMED_OUT: |
2123 | case CXN_KILLED_FIN_RCVD: | 1889 | case CXN_KILLED_FIN_RCVD: |
2124 | case CXN_KILLED_RST_SENT: | ||
2125 | case CXN_KILLED_RST_RCVD: | ||
2126 | case CXN_KILLED_BAD_UNSOL_PDU_RCVD: | 1890 | case CXN_KILLED_BAD_UNSOL_PDU_RCVD: |
2127 | case CXN_KILLED_BAD_WRB_INDEX_ERROR: | 1891 | case CXN_KILLED_BAD_WRB_INDEX_ERROR: |
2128 | case CXN_KILLED_OVER_RUN_RESIDUAL: | 1892 | case CXN_KILLED_OVER_RUN_RESIDUAL: |
2129 | case CXN_KILLED_UNDER_RUN_RESIDUAL: | 1893 | case CXN_KILLED_UNDER_RUN_RESIDUAL: |
2130 | case CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN: | 1894 | case CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN: |
2131 | beiscsi_log(phba, KERN_ERR, | 1895 | SE_DEBUG(DBG_LVL_1, "CQ Error %d, reset CID " |
2132 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 1896 | "0x%x...\n", |
2133 | "BM_%d : Event %s[%d] received on CID : %d\n", | 1897 | sol->dw[offsetof(struct amap_sol_cqe, code) / |
2134 | cqe_desc[code], code, cid); | 1898 | 32] & CQE_CODE_MASK, |
2135 | if (beiscsi_conn) | 1899 | (sol->dw[offsetof(struct amap_sol_cqe, cid) / |
2136 | iscsi_conn_failure(beiscsi_conn->conn, | 1900 | 32] & CQE_CID_MASK)); |
2137 | ISCSI_ERR_CONN_FAILED); | 1901 | iscsi_conn_failure(beiscsi_conn->conn, |
1902 | ISCSI_ERR_CONN_FAILED); | ||
1903 | break; | ||
1904 | case CXN_KILLED_RST_SENT: | ||
1905 | case CXN_KILLED_RST_RCVD: | ||
1906 | SE_DEBUG(DBG_LVL_1, "CQ Error %d, reset" | ||
1907 | "received/sent on CID 0x%x...\n", | ||
1908 | sol->dw[offsetof(struct amap_sol_cqe, code) / | ||
1909 | 32] & CQE_CODE_MASK, | ||
1910 | (sol->dw[offsetof(struct amap_sol_cqe, cid) / | ||
1911 | 32] & CQE_CID_MASK)); | ||
1912 | iscsi_conn_failure(beiscsi_conn->conn, | ||
1913 | ISCSI_ERR_CONN_FAILED); | ||
2138 | break; | 1914 | break; |
2139 | default: | 1915 | default: |
2140 | beiscsi_log(phba, KERN_ERR, | 1916 | SE_DEBUG(DBG_LVL_1, "CQ Error Invalid code= %d " |
2141 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | 1917 | "received on CID 0x%x...\n", |
2142 | "BM_%d : Invalid CQE Event Received Code : %d" | 1918 | sol->dw[offsetof(struct amap_sol_cqe, code) / |
2143 | "CID 0x%x...\n", | 1919 | 32] & CQE_CODE_MASK, |
2144 | code, cid); | 1920 | (sol->dw[offsetof(struct amap_sol_cqe, cid) / |
1921 | 32] & CQE_CID_MASK)); | ||
2145 | break; | 1922 | break; |
2146 | } | 1923 | } |
2147 | 1924 | ||
@@ -2163,30 +1940,30 @@ void beiscsi_process_all_cqs(struct work_struct *work) | |||
2163 | unsigned long flags; | 1940 | unsigned long flags; |
2164 | struct hwi_controller *phwi_ctrlr; | 1941 | struct hwi_controller *phwi_ctrlr; |
2165 | struct hwi_context_memory *phwi_context; | 1942 | struct hwi_context_memory *phwi_context; |
2166 | struct beiscsi_hba *phba; | 1943 | struct be_eq_obj *pbe_eq; |
2167 | struct be_eq_obj *pbe_eq = | 1944 | struct beiscsi_hba *phba = |
2168 | container_of(work, struct be_eq_obj, work_cqs); | 1945 | container_of(work, struct beiscsi_hba, work_cqs); |
2169 | 1946 | ||
2170 | phba = pbe_eq->phba; | ||
2171 | phwi_ctrlr = phba->phwi_ctrlr; | 1947 | phwi_ctrlr = phba->phwi_ctrlr; |
2172 | phwi_context = phwi_ctrlr->phwi_ctxt; | 1948 | phwi_context = phwi_ctrlr->phwi_ctxt; |
1949 | if (phba->msix_enabled) | ||
1950 | pbe_eq = &phwi_context->be_eq[phba->num_cpus]; | ||
1951 | else | ||
1952 | pbe_eq = &phwi_context->be_eq[0]; | ||
2173 | 1953 | ||
2174 | if (pbe_eq->todo_mcc_cq) { | 1954 | if (phba->todo_mcc_cq) { |
2175 | spin_lock_irqsave(&phba->isr_lock, flags); | 1955 | spin_lock_irqsave(&phba->isr_lock, flags); |
2176 | pbe_eq->todo_mcc_cq = false; | 1956 | phba->todo_mcc_cq = 0; |
2177 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 1957 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
2178 | beiscsi_process_mcc_isr(phba); | 1958 | beiscsi_process_mcc_isr(phba); |
2179 | } | 1959 | } |
2180 | 1960 | ||
2181 | if (pbe_eq->todo_cq) { | 1961 | if (phba->todo_cq) { |
2182 | spin_lock_irqsave(&phba->isr_lock, flags); | 1962 | spin_lock_irqsave(&phba->isr_lock, flags); |
2183 | pbe_eq->todo_cq = false; | 1963 | phba->todo_cq = 0; |
2184 | spin_unlock_irqrestore(&phba->isr_lock, flags); | 1964 | spin_unlock_irqrestore(&phba->isr_lock, flags); |
2185 | beiscsi_process_cq(pbe_eq); | 1965 | beiscsi_process_cq(pbe_eq); |
2186 | } | 1966 | } |
2187 | |||
2188 | /* rearm EQ for further interrupts */ | ||
2189 | hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); | ||
2190 | } | 1967 | } |
2191 | 1968 | ||
2192 | static int be_iopoll(struct blk_iopoll *iop, int budget) | 1969 | static int be_iopoll(struct blk_iopoll *iop, int budget) |
@@ -2200,111 +1977,13 @@ static int be_iopoll(struct blk_iopoll *iop, int budget) | |||
2200 | if (ret < budget) { | 1977 | if (ret < budget) { |
2201 | phba = pbe_eq->phba; | 1978 | phba = pbe_eq->phba; |
2202 | blk_iopoll_complete(iop); | 1979 | blk_iopoll_complete(iop); |
2203 | beiscsi_log(phba, KERN_INFO, | 1980 | SE_DEBUG(DBG_LVL_8, "rearm pbe_eq->q.id =%d\n", pbe_eq->q.id); |
2204 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, | ||
2205 | "BM_%d : rearm pbe_eq->q.id =%d\n", | ||
2206 | pbe_eq->q.id); | ||
2207 | hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); | 1981 | hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); |
2208 | } | 1982 | } |
2209 | return ret; | 1983 | return ret; |
2210 | } | 1984 | } |
2211 | 1985 | ||
2212 | static void | 1986 | static void |
2213 | hwi_write_sgl_v2(struct iscsi_wrb *pwrb, struct scatterlist *sg, | ||
2214 | unsigned int num_sg, struct beiscsi_io_task *io_task) | ||
2215 | { | ||
2216 | struct iscsi_sge *psgl; | ||
2217 | unsigned int sg_len, index; | ||
2218 | unsigned int sge_len = 0; | ||
2219 | unsigned long long addr; | ||
2220 | struct scatterlist *l_sg; | ||
2221 | unsigned int offset; | ||
2222 | |||
2223 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_lo, pwrb, | ||
2224 | io_task->bhs_pa.u.a32.address_lo); | ||
2225 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_hi, pwrb, | ||
2226 | io_task->bhs_pa.u.a32.address_hi); | ||
2227 | |||
2228 | l_sg = sg; | ||
2229 | for (index = 0; (index < num_sg) && (index < 2); index++, | ||
2230 | sg = sg_next(sg)) { | ||
2231 | if (index == 0) { | ||
2232 | sg_len = sg_dma_len(sg); | ||
2233 | addr = (u64) sg_dma_address(sg); | ||
2234 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | ||
2235 | sge0_addr_lo, pwrb, | ||
2236 | lower_32_bits(addr)); | ||
2237 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | ||
2238 | sge0_addr_hi, pwrb, | ||
2239 | upper_32_bits(addr)); | ||
2240 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | ||
2241 | sge0_len, pwrb, | ||
2242 | sg_len); | ||
2243 | sge_len = sg_len; | ||
2244 | } else { | ||
2245 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_r2t_offset, | ||
2246 | pwrb, sge_len); | ||
2247 | sg_len = sg_dma_len(sg); | ||
2248 | addr = (u64) sg_dma_address(sg); | ||
2249 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | ||
2250 | sge1_addr_lo, pwrb, | ||
2251 | lower_32_bits(addr)); | ||
2252 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | ||
2253 | sge1_addr_hi, pwrb, | ||
2254 | upper_32_bits(addr)); | ||
2255 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | ||
2256 | sge1_len, pwrb, | ||
2257 | sg_len); | ||
2258 | } | ||
2259 | } | ||
2260 | psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag; | ||
2261 | memset(psgl, 0, sizeof(*psgl) * BE2_SGE); | ||
2262 | |||
2263 | AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len - 2); | ||
2264 | |||
2265 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, | ||
2266 | io_task->bhs_pa.u.a32.address_hi); | ||
2267 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, | ||
2268 | io_task->bhs_pa.u.a32.address_lo); | ||
2269 | |||
2270 | if (num_sg == 1) { | ||
2271 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb, | ||
2272 | 1); | ||
2273 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb, | ||
2274 | 0); | ||
2275 | } else if (num_sg == 2) { | ||
2276 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb, | ||
2277 | 0); | ||
2278 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb, | ||
2279 | 1); | ||
2280 | } else { | ||
2281 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb, | ||
2282 | 0); | ||
2283 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb, | ||
2284 | 0); | ||
2285 | } | ||
2286 | |||
2287 | sg = l_sg; | ||
2288 | psgl++; | ||
2289 | psgl++; | ||
2290 | offset = 0; | ||
2291 | for (index = 0; index < num_sg; index++, sg = sg_next(sg), psgl++) { | ||
2292 | sg_len = sg_dma_len(sg); | ||
2293 | addr = (u64) sg_dma_address(sg); | ||
2294 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, | ||
2295 | lower_32_bits(addr)); | ||
2296 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, | ||
2297 | upper_32_bits(addr)); | ||
2298 | AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, sg_len); | ||
2299 | AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, offset); | ||
2300 | AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0); | ||
2301 | offset += sg_len; | ||
2302 | } | ||
2303 | psgl--; | ||
2304 | AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1); | ||
2305 | } | ||
2306 | |||
2307 | static void | ||
2308 | hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg, | 1987 | hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg, |
2309 | unsigned int num_sg, struct beiscsi_io_task *io_task) | 1988 | unsigned int num_sg, struct beiscsi_io_task *io_task) |
2310 | { | 1989 | { |
@@ -2392,18 +2071,13 @@ hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg, | |||
2392 | AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1); | 2071 | AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1); |
2393 | } | 2072 | } |
2394 | 2073 | ||
2395 | /** | ||
2396 | * hwi_write_buffer()- Populate the WRB with task info | ||
2397 | * @pwrb: ptr to the WRB entry | ||
2398 | * @task: iscsi task which is to be executed | ||
2399 | **/ | ||
2400 | static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task) | 2074 | static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task) |
2401 | { | 2075 | { |
2402 | struct iscsi_sge *psgl; | 2076 | struct iscsi_sge *psgl; |
2077 | unsigned long long addr; | ||
2403 | struct beiscsi_io_task *io_task = task->dd_data; | 2078 | struct beiscsi_io_task *io_task = task->dd_data; |
2404 | struct beiscsi_conn *beiscsi_conn = io_task->conn; | 2079 | struct beiscsi_conn *beiscsi_conn = io_task->conn; |
2405 | struct beiscsi_hba *phba = beiscsi_conn->phba; | 2080 | struct beiscsi_hba *phba = beiscsi_conn->phba; |
2406 | uint8_t dsp_value = 0; | ||
2407 | 2081 | ||
2408 | io_task->bhs_len = sizeof(struct be_nonio_bhs) - 2; | 2082 | io_task->bhs_len = sizeof(struct be_nonio_bhs) - 2; |
2409 | AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_lo, pwrb, | 2083 | AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_lo, pwrb, |
@@ -2412,38 +2086,26 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task) | |||
2412 | io_task->bhs_pa.u.a32.address_hi); | 2086 | io_task->bhs_pa.u.a32.address_hi); |
2413 | 2087 | ||
2414 | if (task->data) { | 2088 | if (task->data) { |
2415 | 2089 | if (task->data_count) { | |
2416 | /* Check for the data_count */ | 2090 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1); |
2417 | dsp_value = (task->data_count) ? 1 : 0; | 2091 | addr = (u64) pci_map_single(phba->pcidev, |
2418 | 2092 | task->data, | |
2419 | if (chip_skh_r(phba->pcidev)) | 2093 | task->data_count, 1); |
2420 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, | 2094 | } else { |
2421 | pwrb, dsp_value); | 2095 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); |
2422 | else | 2096 | addr = 0; |
2423 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, | 2097 | } |
2424 | pwrb, dsp_value); | ||
2425 | |||
2426 | /* Map addr only if there is data_count */ | ||
2427 | if (dsp_value) { | ||
2428 | io_task->mtask_addr = pci_map_single(phba->pcidev, | ||
2429 | task->data, | ||
2430 | task->data_count, | ||
2431 | PCI_DMA_TODEVICE); | ||
2432 | io_task->mtask_data_count = task->data_count; | ||
2433 | } else | ||
2434 | io_task->mtask_addr = 0; | ||
2435 | |||
2436 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb, | 2098 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb, |
2437 | lower_32_bits(io_task->mtask_addr)); | 2099 | ((u32)(addr & 0xFFFFFFFF))); |
2438 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb, | 2100 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb, |
2439 | upper_32_bits(io_task->mtask_addr)); | 2101 | ((u32)(addr >> 32))); |
2440 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb, | 2102 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb, |
2441 | task->data_count); | 2103 | task->data_count); |
2442 | 2104 | ||
2443 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 1); | 2105 | AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 1); |
2444 | } else { | 2106 | } else { |
2445 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); | 2107 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); |
2446 | io_task->mtask_addr = 0; | 2108 | addr = 0; |
2447 | } | 2109 | } |
2448 | 2110 | ||
2449 | psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag; | 2111 | psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag; |
@@ -2466,9 +2128,9 @@ static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task) | |||
2466 | psgl++; | 2128 | psgl++; |
2467 | if (task->data) { | 2129 | if (task->data) { |
2468 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, | 2130 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, |
2469 | lower_32_bits(io_task->mtask_addr)); | 2131 | ((u32)(addr & 0xFFFFFFFF))); |
2470 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, | 2132 | AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, |
2471 | upper_32_bits(io_task->mtask_addr)); | 2133 | ((u32)(addr >> 32))); |
2472 | } | 2134 | } |
2473 | AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106); | 2135 | AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106); |
2474 | } | 2136 | } |
@@ -2543,7 +2205,7 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) | |||
2543 | struct mem_array *mem_arr, *mem_arr_orig; | 2205 | struct mem_array *mem_arr, *mem_arr_orig; |
2544 | unsigned int i, j, alloc_size, curr_alloc_size; | 2206 | unsigned int i, j, alloc_size, curr_alloc_size; |
2545 | 2207 | ||
2546 | phba->phwi_ctrlr = kzalloc(phba->params.hwi_ws_sz, GFP_KERNEL); | 2208 | phba->phwi_ctrlr = kmalloc(phba->params.hwi_ws_sz, GFP_KERNEL); |
2547 | if (!phba->phwi_ctrlr) | 2209 | if (!phba->phwi_ctrlr) |
2548 | return -ENOMEM; | 2210 | return -ENOMEM; |
2549 | 2211 | ||
@@ -2663,21 +2325,27 @@ static void iscsi_init_global_templates(struct beiscsi_hba *phba) | |||
2663 | AMAP_SET_BITS(struct amap_pdu_nop_out, i_bit, pnop_out, 0); | 2325 | AMAP_SET_BITS(struct amap_pdu_nop_out, i_bit, pnop_out, 0); |
2664 | } | 2326 | } |
2665 | 2327 | ||
2666 | static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) | 2328 | static void beiscsi_init_wrb_handle(struct beiscsi_hba *phba) |
2667 | { | 2329 | { |
2668 | struct be_mem_descriptor *mem_descr_wrbh, *mem_descr_wrb; | 2330 | struct be_mem_descriptor *mem_descr_wrbh, *mem_descr_wrb; |
2669 | struct wrb_handle *pwrb_handle = NULL; | 2331 | struct wrb_handle *pwrb_handle; |
2670 | struct hwi_controller *phwi_ctrlr; | 2332 | struct hwi_controller *phwi_ctrlr; |
2671 | struct hwi_wrb_context *pwrb_context; | 2333 | struct hwi_wrb_context *pwrb_context; |
2672 | struct iscsi_wrb *pwrb = NULL; | 2334 | struct iscsi_wrb *pwrb; |
2673 | unsigned int num_cxn_wrbh = 0; | 2335 | unsigned int num_cxn_wrbh; |
2674 | unsigned int num_cxn_wrb = 0, j, idx = 0, index; | 2336 | unsigned int num_cxn_wrb, j, idx, index; |
2675 | 2337 | ||
2676 | mem_descr_wrbh = phba->init_mem; | 2338 | mem_descr_wrbh = phba->init_mem; |
2677 | mem_descr_wrbh += HWI_MEM_WRBH; | 2339 | mem_descr_wrbh += HWI_MEM_WRBH; |
2678 | 2340 | ||
2679 | mem_descr_wrb = phba->init_mem; | 2341 | mem_descr_wrb = phba->init_mem; |
2680 | mem_descr_wrb += HWI_MEM_WRB; | 2342 | mem_descr_wrb += HWI_MEM_WRB; |
2343 | |||
2344 | idx = 0; | ||
2345 | pwrb_handle = mem_descr_wrbh->mem_array[idx].virtual_address; | ||
2346 | num_cxn_wrbh = ((mem_descr_wrbh->mem_array[idx].size) / | ||
2347 | ((sizeof(struct wrb_handle)) * | ||
2348 | phba->params.wrbs_per_cxn)); | ||
2681 | phwi_ctrlr = phba->phwi_ctrlr; | 2349 | phwi_ctrlr = phba->phwi_ctrlr; |
2682 | 2350 | ||
2683 | for (index = 0; index < phba->params.cxns_per_ctrl * 2; index += 2) { | 2351 | for (index = 0; index < phba->params.cxns_per_ctrl * 2; index += 2) { |
@@ -2685,32 +2353,12 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) | |||
2685 | pwrb_context->pwrb_handle_base = | 2353 | pwrb_context->pwrb_handle_base = |
2686 | kzalloc(sizeof(struct wrb_handle *) * | 2354 | kzalloc(sizeof(struct wrb_handle *) * |
2687 | phba->params.wrbs_per_cxn, GFP_KERNEL); | 2355 | phba->params.wrbs_per_cxn, GFP_KERNEL); |
2688 | if (!pwrb_context->pwrb_handle_base) { | ||
2689 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | ||
2690 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | ||
2691 | goto init_wrb_hndl_failed; | ||
2692 | } | ||
2693 | pwrb_context->pwrb_handle_basestd = | 2356 | pwrb_context->pwrb_handle_basestd = |
2694 | kzalloc(sizeof(struct wrb_handle *) * | 2357 | kzalloc(sizeof(struct wrb_handle *) * |
2695 | phba->params.wrbs_per_cxn, GFP_KERNEL); | 2358 | phba->params.wrbs_per_cxn, GFP_KERNEL); |
2696 | if (!pwrb_context->pwrb_handle_basestd) { | ||
2697 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | ||
2698 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | ||
2699 | goto init_wrb_hndl_failed; | ||
2700 | } | ||
2701 | if (!num_cxn_wrbh) { | ||
2702 | pwrb_handle = | ||
2703 | mem_descr_wrbh->mem_array[idx].virtual_address; | ||
2704 | num_cxn_wrbh = ((mem_descr_wrbh->mem_array[idx].size) / | ||
2705 | ((sizeof(struct wrb_handle)) * | ||
2706 | phba->params.wrbs_per_cxn)); | ||
2707 | idx++; | ||
2708 | } | ||
2709 | pwrb_context->alloc_index = 0; | ||
2710 | pwrb_context->wrb_handles_available = 0; | ||
2711 | pwrb_context->free_index = 0; | ||
2712 | |||
2713 | if (num_cxn_wrbh) { | 2359 | if (num_cxn_wrbh) { |
2360 | pwrb_context->alloc_index = 0; | ||
2361 | pwrb_context->wrb_handles_available = 0; | ||
2714 | for (j = 0; j < phba->params.wrbs_per_cxn; j++) { | 2362 | for (j = 0; j < phba->params.wrbs_per_cxn; j++) { |
2715 | pwrb_context->pwrb_handle_base[j] = pwrb_handle; | 2363 | pwrb_context->pwrb_handle_base[j] = pwrb_handle; |
2716 | pwrb_context->pwrb_handle_basestd[j] = | 2364 | pwrb_context->pwrb_handle_basestd[j] = |
@@ -2719,21 +2367,49 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) | |||
2719 | pwrb_handle->wrb_index = j; | 2367 | pwrb_handle->wrb_index = j; |
2720 | pwrb_handle++; | 2368 | pwrb_handle++; |
2721 | } | 2369 | } |
2370 | pwrb_context->free_index = 0; | ||
2371 | num_cxn_wrbh--; | ||
2372 | } else { | ||
2373 | idx++; | ||
2374 | pwrb_handle = | ||
2375 | mem_descr_wrbh->mem_array[idx].virtual_address; | ||
2376 | num_cxn_wrbh = | ||
2377 | ((mem_descr_wrbh->mem_array[idx].size) / | ||
2378 | ((sizeof(struct wrb_handle)) * | ||
2379 | phba->params.wrbs_per_cxn)); | ||
2380 | pwrb_context->alloc_index = 0; | ||
2381 | for (j = 0; j < phba->params.wrbs_per_cxn; j++) { | ||
2382 | pwrb_context->pwrb_handle_base[j] = pwrb_handle; | ||
2383 | pwrb_context->pwrb_handle_basestd[j] = | ||
2384 | pwrb_handle; | ||
2385 | pwrb_context->wrb_handles_available++; | ||
2386 | pwrb_handle->wrb_index = j; | ||
2387 | pwrb_handle++; | ||
2388 | } | ||
2389 | pwrb_context->free_index = 0; | ||
2722 | num_cxn_wrbh--; | 2390 | num_cxn_wrbh--; |
2723 | } | 2391 | } |
2724 | } | 2392 | } |
2725 | idx = 0; | 2393 | idx = 0; |
2394 | pwrb = mem_descr_wrb->mem_array[idx].virtual_address; | ||
2395 | num_cxn_wrb = (mem_descr_wrb->mem_array[idx].size) / | ||
2396 | ((sizeof(struct iscsi_wrb) * | ||
2397 | phba->params.wrbs_per_cxn)); | ||
2726 | for (index = 0; index < phba->params.cxns_per_ctrl * 2; index += 2) { | 2398 | for (index = 0; index < phba->params.cxns_per_ctrl * 2; index += 2) { |
2727 | pwrb_context = &phwi_ctrlr->wrb_context[index]; | 2399 | pwrb_context = &phwi_ctrlr->wrb_context[index]; |
2728 | if (!num_cxn_wrb) { | 2400 | if (num_cxn_wrb) { |
2401 | for (j = 0; j < phba->params.wrbs_per_cxn; j++) { | ||
2402 | pwrb_handle = pwrb_context->pwrb_handle_base[j]; | ||
2403 | pwrb_handle->pwrb = pwrb; | ||
2404 | pwrb++; | ||
2405 | } | ||
2406 | num_cxn_wrb--; | ||
2407 | } else { | ||
2408 | idx++; | ||
2729 | pwrb = mem_descr_wrb->mem_array[idx].virtual_address; | 2409 | pwrb = mem_descr_wrb->mem_array[idx].virtual_address; |
2730 | num_cxn_wrb = (mem_descr_wrb->mem_array[idx].size) / | 2410 | num_cxn_wrb = (mem_descr_wrb->mem_array[idx].size) / |
2731 | ((sizeof(struct iscsi_wrb) * | 2411 | ((sizeof(struct iscsi_wrb) * |
2732 | phba->params.wrbs_per_cxn)); | 2412 | phba->params.wrbs_per_cxn)); |
2733 | idx++; | ||
2734 | } | ||
2735 | |||
2736 | if (num_cxn_wrb) { | ||
2737 | for (j = 0; j < phba->params.wrbs_per_cxn; j++) { | 2413 | for (j = 0; j < phba->params.wrbs_per_cxn; j++) { |
2738 | pwrb_handle = pwrb_context->pwrb_handle_base[j]; | 2414 | pwrb_handle = pwrb_context->pwrb_handle_base[j]; |
2739 | pwrb_handle->pwrb = pwrb; | 2415 | pwrb_handle->pwrb = pwrb; |
@@ -2742,14 +2418,6 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) | |||
2742 | num_cxn_wrb--; | 2418 | num_cxn_wrb--; |
2743 | } | 2419 | } |
2744 | } | 2420 | } |
2745 | return 0; | ||
2746 | init_wrb_hndl_failed: | ||
2747 | for (j = index; j > 0; j--) { | ||
2748 | pwrb_context = &phwi_ctrlr->wrb_context[j]; | ||
2749 | kfree(pwrb_context->pwrb_handle_base); | ||
2750 | kfree(pwrb_context->pwrb_handle_basestd); | ||
2751 | } | ||
2752 | return -ENOMEM; | ||
2753 | } | 2421 | } |
2754 | 2422 | ||
2755 | static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | 2423 | static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) |
@@ -2758,7 +2426,7 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | |||
2758 | struct hba_parameters *p = &phba->params; | 2426 | struct hba_parameters *p = &phba->params; |
2759 | struct hwi_async_pdu_context *pasync_ctx; | 2427 | struct hwi_async_pdu_context *pasync_ctx; |
2760 | struct async_pdu_handle *pasync_header_h, *pasync_data_h; | 2428 | struct async_pdu_handle *pasync_header_h, *pasync_data_h; |
2761 | unsigned int index, idx, num_per_mem, num_async_data; | 2429 | unsigned int index; |
2762 | struct be_mem_descriptor *mem_descr; | 2430 | struct be_mem_descriptor *mem_descr; |
2763 | 2431 | ||
2764 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | 2432 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; |
@@ -2770,19 +2438,20 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | |||
2770 | pasync_ctx = phwi_ctrlr->phwi_ctxt->pasync_ctx; | 2438 | pasync_ctx = phwi_ctrlr->phwi_ctxt->pasync_ctx; |
2771 | memset(pasync_ctx, 0, sizeof(*pasync_ctx)); | 2439 | memset(pasync_ctx, 0, sizeof(*pasync_ctx)); |
2772 | 2440 | ||
2773 | pasync_ctx->num_entries = p->asyncpdus_per_ctrl; | 2441 | pasync_ctx->async_header.num_entries = p->asyncpdus_per_ctrl; |
2774 | pasync_ctx->buffer_size = p->defpdu_hdr_sz; | 2442 | pasync_ctx->async_header.buffer_size = p->defpdu_hdr_sz; |
2443 | pasync_ctx->async_data.buffer_size = p->defpdu_data_sz; | ||
2444 | pasync_ctx->async_data.num_entries = p->asyncpdus_per_ctrl; | ||
2775 | 2445 | ||
2776 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | 2446 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; |
2777 | mem_descr += HWI_MEM_ASYNC_HEADER_BUF; | 2447 | mem_descr += HWI_MEM_ASYNC_HEADER_BUF; |
2778 | if (mem_descr->mem_array[0].virtual_address) { | 2448 | if (mem_descr->mem_array[0].virtual_address) { |
2779 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2449 | SE_DEBUG(DBG_LVL_8, |
2780 | "BM_%d : hwi_init_async_pdu_ctx" | 2450 | "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_BUF" |
2781 | " HWI_MEM_ASYNC_HEADER_BUF va=%p\n", | 2451 | "va=%p\n", mem_descr->mem_array[0].virtual_address); |
2782 | mem_descr->mem_array[0].virtual_address); | ||
2783 | } else | 2452 | } else |
2784 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 2453 | shost_printk(KERN_WARNING, phba->shost, |
2785 | "BM_%d : No Virtual address\n"); | 2454 | "No Virtual address\n"); |
2786 | 2455 | ||
2787 | pasync_ctx->async_header.va_base = | 2456 | pasync_ctx->async_header.va_base = |
2788 | mem_descr->mem_array[0].virtual_address; | 2457 | mem_descr->mem_array[0].virtual_address; |
@@ -2793,44 +2462,53 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | |||
2793 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | 2462 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; |
2794 | mem_descr += HWI_MEM_ASYNC_HEADER_RING; | 2463 | mem_descr += HWI_MEM_ASYNC_HEADER_RING; |
2795 | if (mem_descr->mem_array[0].virtual_address) { | 2464 | if (mem_descr->mem_array[0].virtual_address) { |
2796 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2465 | SE_DEBUG(DBG_LVL_8, |
2797 | "BM_%d : hwi_init_async_pdu_ctx" | 2466 | "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_RING" |
2798 | " HWI_MEM_ASYNC_HEADER_RING va=%p\n", | 2467 | "va=%p\n", mem_descr->mem_array[0].virtual_address); |
2799 | mem_descr->mem_array[0].virtual_address); | ||
2800 | } else | 2468 | } else |
2801 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 2469 | shost_printk(KERN_WARNING, phba->shost, |
2802 | "BM_%d : No Virtual address\n"); | 2470 | "No Virtual address\n"); |
2803 | |||
2804 | pasync_ctx->async_header.ring_base = | 2471 | pasync_ctx->async_header.ring_base = |
2805 | mem_descr->mem_array[0].virtual_address; | 2472 | mem_descr->mem_array[0].virtual_address; |
2806 | 2473 | ||
2807 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | 2474 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; |
2808 | mem_descr += HWI_MEM_ASYNC_HEADER_HANDLE; | 2475 | mem_descr += HWI_MEM_ASYNC_HEADER_HANDLE; |
2809 | if (mem_descr->mem_array[0].virtual_address) { | 2476 | if (mem_descr->mem_array[0].virtual_address) { |
2810 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2477 | SE_DEBUG(DBG_LVL_8, |
2811 | "BM_%d : hwi_init_async_pdu_ctx" | 2478 | "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_HEADER_HANDLE" |
2812 | " HWI_MEM_ASYNC_HEADER_HANDLE va=%p\n", | 2479 | "va=%p\n", mem_descr->mem_array[0].virtual_address); |
2813 | mem_descr->mem_array[0].virtual_address); | ||
2814 | } else | 2480 | } else |
2815 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 2481 | shost_printk(KERN_WARNING, phba->shost, |
2816 | "BM_%d : No Virtual address\n"); | 2482 | "No Virtual address\n"); |
2817 | 2483 | ||
2818 | pasync_ctx->async_header.handle_base = | 2484 | pasync_ctx->async_header.handle_base = |
2819 | mem_descr->mem_array[0].virtual_address; | 2485 | mem_descr->mem_array[0].virtual_address; |
2820 | pasync_ctx->async_header.writables = 0; | 2486 | pasync_ctx->async_header.writables = 0; |
2821 | INIT_LIST_HEAD(&pasync_ctx->async_header.free_list); | 2487 | INIT_LIST_HEAD(&pasync_ctx->async_header.free_list); |
2822 | 2488 | ||
2489 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | ||
2490 | mem_descr += HWI_MEM_ASYNC_DATA_BUF; | ||
2491 | if (mem_descr->mem_array[0].virtual_address) { | ||
2492 | SE_DEBUG(DBG_LVL_8, | ||
2493 | "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_DATA_BUF" | ||
2494 | "va=%p\n", mem_descr->mem_array[0].virtual_address); | ||
2495 | } else | ||
2496 | shost_printk(KERN_WARNING, phba->shost, | ||
2497 | "No Virtual address\n"); | ||
2498 | pasync_ctx->async_data.va_base = | ||
2499 | mem_descr->mem_array[0].virtual_address; | ||
2500 | pasync_ctx->async_data.pa_base.u.a64.address = | ||
2501 | mem_descr->mem_array[0].bus_address.u.a64.address; | ||
2823 | 2502 | ||
2824 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | 2503 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; |
2825 | mem_descr += HWI_MEM_ASYNC_DATA_RING; | 2504 | mem_descr += HWI_MEM_ASYNC_DATA_RING; |
2826 | if (mem_descr->mem_array[0].virtual_address) { | 2505 | if (mem_descr->mem_array[0].virtual_address) { |
2827 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2506 | SE_DEBUG(DBG_LVL_8, |
2828 | "BM_%d : hwi_init_async_pdu_ctx" | 2507 | "hwi_init_async_pdu_ctx HWI_MEM_ASYNC_DATA_RING" |
2829 | " HWI_MEM_ASYNC_DATA_RING va=%p\n", | 2508 | "va=%p\n", mem_descr->mem_array[0].virtual_address); |
2830 | mem_descr->mem_array[0].virtual_address); | ||
2831 | } else | 2509 | } else |
2832 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 2510 | shost_printk(KERN_WARNING, phba->shost, |
2833 | "BM_%d : No Virtual address\n"); | 2511 | "No Virtual address\n"); |
2834 | 2512 | ||
2835 | pasync_ctx->async_data.ring_base = | 2513 | pasync_ctx->async_data.ring_base = |
2836 | mem_descr->mem_array[0].virtual_address; | 2514 | mem_descr->mem_array[0].virtual_address; |
@@ -2838,8 +2516,8 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | |||
2838 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | 2516 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; |
2839 | mem_descr += HWI_MEM_ASYNC_DATA_HANDLE; | 2517 | mem_descr += HWI_MEM_ASYNC_DATA_HANDLE; |
2840 | if (!mem_descr->mem_array[0].virtual_address) | 2518 | if (!mem_descr->mem_array[0].virtual_address) |
2841 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 2519 | shost_printk(KERN_WARNING, phba->shost, |
2842 | "BM_%d : No Virtual address\n"); | 2520 | "No Virtual address\n"); |
2843 | 2521 | ||
2844 | pasync_ctx->async_data.handle_base = | 2522 | pasync_ctx->async_data.handle_base = |
2845 | mem_descr->mem_array[0].virtual_address; | 2523 | mem_descr->mem_array[0].virtual_address; |
@@ -2851,27 +2529,6 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | |||
2851 | pasync_data_h = | 2529 | pasync_data_h = |
2852 | (struct async_pdu_handle *)pasync_ctx->async_data.handle_base; | 2530 | (struct async_pdu_handle *)pasync_ctx->async_data.handle_base; |
2853 | 2531 | ||
2854 | mem_descr = (struct be_mem_descriptor *)phba->init_mem; | ||
2855 | mem_descr += HWI_MEM_ASYNC_DATA_BUF; | ||
2856 | if (mem_descr->mem_array[0].virtual_address) { | ||
2857 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | ||
2858 | "BM_%d : hwi_init_async_pdu_ctx" | ||
2859 | " HWI_MEM_ASYNC_DATA_BUF va=%p\n", | ||
2860 | mem_descr->mem_array[0].virtual_address); | ||
2861 | } else | ||
2862 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | ||
2863 | "BM_%d : No Virtual address\n"); | ||
2864 | |||
2865 | idx = 0; | ||
2866 | pasync_ctx->async_data.va_base = | ||
2867 | mem_descr->mem_array[idx].virtual_address; | ||
2868 | pasync_ctx->async_data.pa_base.u.a64.address = | ||
2869 | mem_descr->mem_array[idx].bus_address.u.a64.address; | ||
2870 | |||
2871 | num_async_data = ((mem_descr->mem_array[idx].size) / | ||
2872 | phba->params.defpdu_data_sz); | ||
2873 | num_per_mem = 0; | ||
2874 | |||
2875 | for (index = 0; index < p->asyncpdus_per_ctrl; index++) { | 2532 | for (index = 0; index < p->asyncpdus_per_ctrl; index++) { |
2876 | pasync_header_h->cri = -1; | 2533 | pasync_header_h->cri = -1; |
2877 | pasync_header_h->index = (char)index; | 2534 | pasync_header_h->index = (char)index; |
@@ -2897,29 +2554,14 @@ static void hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) | |||
2897 | pasync_data_h->cri = -1; | 2554 | pasync_data_h->cri = -1; |
2898 | pasync_data_h->index = (char)index; | 2555 | pasync_data_h->index = (char)index; |
2899 | INIT_LIST_HEAD(&pasync_data_h->link); | 2556 | INIT_LIST_HEAD(&pasync_data_h->link); |
2900 | |||
2901 | if (!num_async_data) { | ||
2902 | num_per_mem = 0; | ||
2903 | idx++; | ||
2904 | pasync_ctx->async_data.va_base = | ||
2905 | mem_descr->mem_array[idx].virtual_address; | ||
2906 | pasync_ctx->async_data.pa_base.u.a64.address = | ||
2907 | mem_descr->mem_array[idx]. | ||
2908 | bus_address.u.a64.address; | ||
2909 | |||
2910 | num_async_data = ((mem_descr->mem_array[idx].size) / | ||
2911 | phba->params.defpdu_data_sz); | ||
2912 | } | ||
2913 | pasync_data_h->pbuffer = | 2557 | pasync_data_h->pbuffer = |
2914 | (void *)((unsigned long) | 2558 | (void *)((unsigned long) |
2915 | (pasync_ctx->async_data.va_base) + | 2559 | (pasync_ctx->async_data.va_base) + |
2916 | (p->defpdu_data_sz * num_per_mem)); | 2560 | (p->defpdu_data_sz * index)); |
2917 | 2561 | ||
2918 | pasync_data_h->pa.u.a64.address = | 2562 | pasync_data_h->pa.u.a64.address = |
2919 | pasync_ctx->async_data.pa_base.u.a64.address + | 2563 | pasync_ctx->async_data.pa_base.u.a64.address + |
2920 | (p->defpdu_data_sz * num_per_mem); | 2564 | (p->defpdu_data_sz * index); |
2921 | num_per_mem++; | ||
2922 | num_async_data--; | ||
2923 | 2565 | ||
2924 | list_add_tail(&pasync_data_h->link, | 2566 | list_add_tail(&pasync_data_h->link, |
2925 | &pasync_ctx->async_data.free_list); | 2567 | &pasync_ctx->async_data.free_list); |
@@ -3002,7 +2644,7 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba, | |||
3002 | struct hwi_context_memory *phwi_context) | 2644 | struct hwi_context_memory *phwi_context) |
3003 | { | 2645 | { |
3004 | unsigned int i, num_eq_pages; | 2646 | unsigned int i, num_eq_pages; |
3005 | int ret = 0, eq_for_mcc; | 2647 | int ret, eq_for_mcc; |
3006 | struct be_queue_info *eq; | 2648 | struct be_queue_info *eq; |
3007 | struct be_dma_mem *mem; | 2649 | struct be_dma_mem *mem; |
3008 | void *eq_vaddress; | 2650 | void *eq_vaddress; |
@@ -3029,8 +2671,8 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba, | |||
3029 | ret = be_fill_queue(eq, phba->params.num_eq_entries, | 2671 | ret = be_fill_queue(eq, phba->params.num_eq_entries, |
3030 | sizeof(struct be_eq_entry), eq_vaddress); | 2672 | sizeof(struct be_eq_entry), eq_vaddress); |
3031 | if (ret) { | 2673 | if (ret) { |
3032 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2674 | shost_printk(KERN_ERR, phba->shost, |
3033 | "BM_%d : be_fill_queue Failed for EQ\n"); | 2675 | "be_fill_queue Failed for EQ\n"); |
3034 | goto create_eq_error; | 2676 | goto create_eq_error; |
3035 | } | 2677 | } |
3036 | 2678 | ||
@@ -3038,19 +2680,16 @@ static int beiscsi_create_eqs(struct beiscsi_hba *phba, | |||
3038 | ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, | 2680 | ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, |
3039 | phwi_context->cur_eqd); | 2681 | phwi_context->cur_eqd); |
3040 | if (ret) { | 2682 | if (ret) { |
3041 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2683 | shost_printk(KERN_ERR, phba->shost, |
3042 | "BM_%d : beiscsi_cmd_eq_create" | 2684 | "beiscsi_cmd_eq_create" |
3043 | "Failed for EQ\n"); | 2685 | "Failedfor EQ\n"); |
3044 | goto create_eq_error; | 2686 | goto create_eq_error; |
3045 | } | 2687 | } |
3046 | 2688 | SE_DEBUG(DBG_LVL_8, "eqid = %d\n", phwi_context->be_eq[i].q.id); | |
3047 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | ||
3048 | "BM_%d : eqid = %d\n", | ||
3049 | phwi_context->be_eq[i].q.id); | ||
3050 | } | 2689 | } |
3051 | return 0; | 2690 | return 0; |
3052 | create_eq_error: | 2691 | create_eq_error: |
3053 | for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { | 2692 | for (i = 0; i < (phba->num_cpus + 1); i++) { |
3054 | eq = &phwi_context->be_eq[i].q; | 2693 | eq = &phwi_context->be_eq[i].q; |
3055 | mem = &eq->dma_mem; | 2694 | mem = &eq->dma_mem; |
3056 | if (mem->va) | 2695 | if (mem->va) |
@@ -3065,7 +2704,7 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba, | |||
3065 | struct hwi_context_memory *phwi_context) | 2704 | struct hwi_context_memory *phwi_context) |
3066 | { | 2705 | { |
3067 | unsigned int i, num_cq_pages; | 2706 | unsigned int i, num_cq_pages; |
3068 | int ret = 0; | 2707 | int ret; |
3069 | struct be_queue_info *cq, *eq; | 2708 | struct be_queue_info *cq, *eq; |
3070 | struct be_dma_mem *mem; | 2709 | struct be_dma_mem *mem; |
3071 | struct be_eq_obj *pbe_eq; | 2710 | struct be_eq_obj *pbe_eq; |
@@ -3090,9 +2729,8 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba, | |||
3090 | ret = be_fill_queue(cq, phba->params.num_cq_entries, | 2729 | ret = be_fill_queue(cq, phba->params.num_cq_entries, |
3091 | sizeof(struct sol_cqe), cq_vaddress); | 2730 | sizeof(struct sol_cqe), cq_vaddress); |
3092 | if (ret) { | 2731 | if (ret) { |
3093 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2732 | shost_printk(KERN_ERR, phba->shost, |
3094 | "BM_%d : be_fill_queue Failed " | 2733 | "be_fill_queue Failed for ISCSI CQ\n"); |
3095 | "for ISCSI CQ\n"); | ||
3096 | goto create_cq_error; | 2734 | goto create_cq_error; |
3097 | } | 2735 | } |
3098 | 2736 | ||
@@ -3100,14 +2738,14 @@ static int beiscsi_create_cqs(struct beiscsi_hba *phba, | |||
3100 | ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false, | 2738 | ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false, |
3101 | false, 0); | 2739 | false, 0); |
3102 | if (ret) { | 2740 | if (ret) { |
3103 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2741 | shost_printk(KERN_ERR, phba->shost, |
3104 | "BM_%d : beiscsi_cmd_eq_create" | 2742 | "beiscsi_cmd_eq_create" |
3105 | "Failed for ISCSI CQ\n"); | 2743 | "Failed for ISCSI CQ\n"); |
3106 | goto create_cq_error; | 2744 | goto create_cq_error; |
3107 | } | 2745 | } |
3108 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2746 | SE_DEBUG(DBG_LVL_8, "iscsi cq_id is %d for eq_id %d\n", |
3109 | "BM_%d : iscsi cq_id is %d for eq_id %d\n" | 2747 | cq->id, eq->id); |
3110 | "iSCSI CQ CREATED\n", cq->id, eq->id); | 2748 | SE_DEBUG(DBG_LVL_8, "ISCSI CQ CREATED\n"); |
3111 | } | 2749 | } |
3112 | return 0; | 2750 | return 0; |
3113 | 2751 | ||
@@ -3148,8 +2786,8 @@ beiscsi_create_def_hdr(struct beiscsi_hba *phba, | |||
3148 | sizeof(struct phys_addr), | 2786 | sizeof(struct phys_addr), |
3149 | sizeof(struct phys_addr), dq_vaddress); | 2787 | sizeof(struct phys_addr), dq_vaddress); |
3150 | if (ret) { | 2788 | if (ret) { |
3151 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2789 | shost_printk(KERN_ERR, phba->shost, |
3152 | "BM_%d : be_fill_queue Failed for DEF PDU HDR\n"); | 2790 | "be_fill_queue Failed for DEF PDU HDR\n"); |
3153 | return ret; | 2791 | return ret; |
3154 | } | 2792 | } |
3155 | mem->dma = (unsigned long)mem_descr->mem_array[idx]. | 2793 | mem->dma = (unsigned long)mem_descr->mem_array[idx]. |
@@ -3158,15 +2796,13 @@ beiscsi_create_def_hdr(struct beiscsi_hba *phba, | |||
3158 | def_pdu_ring_sz, | 2796 | def_pdu_ring_sz, |
3159 | phba->params.defpdu_hdr_sz); | 2797 | phba->params.defpdu_hdr_sz); |
3160 | if (ret) { | 2798 | if (ret) { |
3161 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2799 | shost_printk(KERN_ERR, phba->shost, |
3162 | "BM_%d : be_cmd_create_default_pdu_queue Failed DEFHDR\n"); | 2800 | "be_cmd_create_default_pdu_queue Failed DEFHDR\n"); |
3163 | return ret; | 2801 | return ret; |
3164 | } | 2802 | } |
3165 | phwi_ctrlr->default_pdu_hdr.id = phwi_context->be_def_hdrq.id; | 2803 | phwi_ctrlr->default_pdu_hdr.id = phwi_context->be_def_hdrq.id; |
3166 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2804 | SE_DEBUG(DBG_LVL_8, "iscsi def pdu id is %d\n", |
3167 | "BM_%d : iscsi def pdu id is %d\n", | 2805 | phwi_context->be_def_hdrq.id); |
3168 | phwi_context->be_def_hdrq.id); | ||
3169 | |||
3170 | hwi_post_async_buffers(phba, 1); | 2806 | hwi_post_async_buffers(phba, 1); |
3171 | return 0; | 2807 | return 0; |
3172 | } | 2808 | } |
@@ -3195,8 +2831,8 @@ beiscsi_create_def_data(struct beiscsi_hba *phba, | |||
3195 | sizeof(struct phys_addr), | 2831 | sizeof(struct phys_addr), |
3196 | sizeof(struct phys_addr), dq_vaddress); | 2832 | sizeof(struct phys_addr), dq_vaddress); |
3197 | if (ret) { | 2833 | if (ret) { |
3198 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2834 | shost_printk(KERN_ERR, phba->shost, |
3199 | "BM_%d : be_fill_queue Failed for DEF PDU DATA\n"); | 2835 | "be_fill_queue Failed for DEF PDU DATA\n"); |
3200 | return ret; | 2836 | return ret; |
3201 | } | 2837 | } |
3202 | mem->dma = (unsigned long)mem_descr->mem_array[idx]. | 2838 | mem->dma = (unsigned long)mem_descr->mem_array[idx]. |
@@ -3205,20 +2841,16 @@ beiscsi_create_def_data(struct beiscsi_hba *phba, | |||
3205 | def_pdu_ring_sz, | 2841 | def_pdu_ring_sz, |
3206 | phba->params.defpdu_data_sz); | 2842 | phba->params.defpdu_data_sz); |
3207 | if (ret) { | 2843 | if (ret) { |
3208 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2844 | shost_printk(KERN_ERR, phba->shost, |
3209 | "BM_%d be_cmd_create_default_pdu_queue" | 2845 | "be_cmd_create_default_pdu_queue Failed" |
3210 | " Failed for DEF PDU DATA\n"); | 2846 | " for DEF PDU DATA\n"); |
3211 | return ret; | 2847 | return ret; |
3212 | } | 2848 | } |
3213 | phwi_ctrlr->default_pdu_data.id = phwi_context->be_def_dataq.id; | 2849 | phwi_ctrlr->default_pdu_data.id = phwi_context->be_def_dataq.id; |
3214 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2850 | SE_DEBUG(DBG_LVL_8, "iscsi def data id is %d\n", |
3215 | "BM_%d : iscsi def data id is %d\n", | 2851 | phwi_context->be_def_dataq.id); |
3216 | phwi_context->be_def_dataq.id); | ||
3217 | |||
3218 | hwi_post_async_buffers(phba, 0); | 2852 | hwi_post_async_buffers(phba, 0); |
3219 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2853 | SE_DEBUG(DBG_LVL_8, "DEFAULT PDU DATA RING CREATED\n"); |
3220 | "BM_%d : DEFAULT PDU DATA RING CREATED\n"); | ||
3221 | |||
3222 | return 0; | 2854 | return 0; |
3223 | } | 2855 | } |
3224 | 2856 | ||
@@ -3244,25 +2876,22 @@ beiscsi_post_pages(struct beiscsi_hba *phba) | |||
3244 | (pm_arr->size / PAGE_SIZE)); | 2876 | (pm_arr->size / PAGE_SIZE)); |
3245 | page_offset += pm_arr->size / PAGE_SIZE; | 2877 | page_offset += pm_arr->size / PAGE_SIZE; |
3246 | if (status != 0) { | 2878 | if (status != 0) { |
3247 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2879 | shost_printk(KERN_ERR, phba->shost, |
3248 | "BM_%d : post sgl failed.\n"); | 2880 | "post sgl failed.\n"); |
3249 | return status; | 2881 | return status; |
3250 | } | 2882 | } |
3251 | pm_arr++; | 2883 | pm_arr++; |
3252 | } | 2884 | } |
3253 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 2885 | SE_DEBUG(DBG_LVL_8, "POSTED PAGES\n"); |
3254 | "BM_%d : POSTED PAGES\n"); | ||
3255 | return 0; | 2886 | return 0; |
3256 | } | 2887 | } |
3257 | 2888 | ||
3258 | static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q) | 2889 | static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q) |
3259 | { | 2890 | { |
3260 | struct be_dma_mem *mem = &q->dma_mem; | 2891 | struct be_dma_mem *mem = &q->dma_mem; |
3261 | if (mem->va) { | 2892 | if (mem->va) |
3262 | pci_free_consistent(phba->pcidev, mem->size, | 2893 | pci_free_consistent(phba->pcidev, mem->size, |
3263 | mem->va, mem->dma); | 2894 | mem->va, mem->dma); |
3264 | mem->va = NULL; | ||
3265 | } | ||
3266 | } | 2895 | } |
3267 | 2896 | ||
3268 | static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, | 2897 | static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, |
@@ -3301,8 +2930,8 @@ beiscsi_create_wrb_rings(struct beiscsi_hba *phba, | |||
3301 | pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl, | 2930 | pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl, |
3302 | GFP_KERNEL); | 2931 | GFP_KERNEL); |
3303 | if (!pwrb_arr) { | 2932 | if (!pwrb_arr) { |
3304 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2933 | shost_printk(KERN_ERR, phba->shost, |
3305 | "BM_%d : Memory alloc failed in create wrb ring.\n"); | 2934 | "Memory alloc failed in create wrb ring.\n"); |
3306 | return -ENOMEM; | 2935 | return -ENOMEM; |
3307 | } | 2936 | } |
3308 | wrb_vaddr = mem_descr->mem_array[idx].virtual_address; | 2937 | wrb_vaddr = mem_descr->mem_array[idx].virtual_address; |
@@ -3346,8 +2975,8 @@ beiscsi_create_wrb_rings(struct beiscsi_hba *phba, | |||
3346 | status = be_cmd_wrbq_create(&phba->ctrl, &sgl, | 2975 | status = be_cmd_wrbq_create(&phba->ctrl, &sgl, |
3347 | &phwi_context->be_wrbq[i]); | 2976 | &phwi_context->be_wrbq[i]); |
3348 | if (status != 0) { | 2977 | if (status != 0) { |
3349 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2978 | shost_printk(KERN_ERR, phba->shost, |
3350 | "BM_%d : wrbq create failed."); | 2979 | "wrbq create failed."); |
3351 | kfree(pwrb_arr); | 2980 | kfree(pwrb_arr); |
3352 | return status; | 2981 | return status; |
3353 | } | 2982 | } |
@@ -3475,31 +3104,16 @@ err: | |||
3475 | return -ENOMEM; | 3104 | return -ENOMEM; |
3476 | } | 3105 | } |
3477 | 3106 | ||
3478 | /** | 3107 | static int find_num_cpus(void) |
3479 | * find_num_cpus()- Get the CPU online count | ||
3480 | * @phba: ptr to priv structure | ||
3481 | * | ||
3482 | * CPU count is used for creating EQ. | ||
3483 | **/ | ||
3484 | static void find_num_cpus(struct beiscsi_hba *phba) | ||
3485 | { | 3108 | { |
3486 | int num_cpus = 0; | 3109 | int num_cpus = 0; |
3487 | 3110 | ||
3488 | num_cpus = num_online_cpus(); | 3111 | num_cpus = num_online_cpus(); |
3112 | if (num_cpus >= MAX_CPUS) | ||
3113 | num_cpus = MAX_CPUS - 1; | ||
3489 | 3114 | ||
3490 | switch (phba->generation) { | 3115 | SE_DEBUG(DBG_LVL_8, "num_cpus = %d\n", num_cpus); |
3491 | case BE_GEN2: | 3116 | return num_cpus; |
3492 | case BE_GEN3: | ||
3493 | phba->num_cpus = (num_cpus > BEISCSI_MAX_NUM_CPUS) ? | ||
3494 | BEISCSI_MAX_NUM_CPUS : num_cpus; | ||
3495 | break; | ||
3496 | case BE_GEN4: | ||
3497 | phba->num_cpus = (num_cpus > OC_SKH_MAX_NUM_CPUS) ? | ||
3498 | OC_SKH_MAX_NUM_CPUS : num_cpus; | ||
3499 | break; | ||
3500 | default: | ||
3501 | phba->num_cpus = 1; | ||
3502 | } | ||
3503 | } | 3117 | } |
3504 | 3118 | ||
3505 | static int hwi_init_port(struct beiscsi_hba *phba) | 3119 | static int hwi_init_port(struct beiscsi_hba *phba) |
@@ -3521,8 +3135,7 @@ static int hwi_init_port(struct beiscsi_hba *phba) | |||
3521 | 3135 | ||
3522 | status = beiscsi_create_eqs(phba, phwi_context); | 3136 | status = beiscsi_create_eqs(phba, phwi_context); |
3523 | if (status != 0) { | 3137 | if (status != 0) { |
3524 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3138 | shost_printk(KERN_ERR, phba->shost, "EQ not created\n"); |
3525 | "BM_%d : EQ not created\n"); | ||
3526 | goto error; | 3139 | goto error; |
3527 | } | 3140 | } |
3528 | 3141 | ||
@@ -3532,57 +3145,53 @@ static int hwi_init_port(struct beiscsi_hba *phba) | |||
3532 | 3145 | ||
3533 | status = mgmt_check_supported_fw(ctrl, phba); | 3146 | status = mgmt_check_supported_fw(ctrl, phba); |
3534 | if (status != 0) { | 3147 | if (status != 0) { |
3535 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3148 | shost_printk(KERN_ERR, phba->shost, |
3536 | "BM_%d : Unsupported fw version\n"); | 3149 | "Unsupported fw version\n"); |
3537 | goto error; | 3150 | goto error; |
3538 | } | 3151 | } |
3539 | 3152 | ||
3540 | status = beiscsi_create_cqs(phba, phwi_context); | 3153 | status = beiscsi_create_cqs(phba, phwi_context); |
3541 | if (status != 0) { | 3154 | if (status != 0) { |
3542 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3155 | shost_printk(KERN_ERR, phba->shost, "CQ not created\n"); |
3543 | "BM_%d : CQ not created\n"); | ||
3544 | goto error; | 3156 | goto error; |
3545 | } | 3157 | } |
3546 | 3158 | ||
3547 | status = beiscsi_create_def_hdr(phba, phwi_context, phwi_ctrlr, | 3159 | status = beiscsi_create_def_hdr(phba, phwi_context, phwi_ctrlr, |
3548 | def_pdu_ring_sz); | 3160 | def_pdu_ring_sz); |
3549 | if (status != 0) { | 3161 | if (status != 0) { |
3550 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3162 | shost_printk(KERN_ERR, phba->shost, |
3551 | "BM_%d : Default Header not created\n"); | 3163 | "Default Header not created\n"); |
3552 | goto error; | 3164 | goto error; |
3553 | } | 3165 | } |
3554 | 3166 | ||
3555 | status = beiscsi_create_def_data(phba, phwi_context, | 3167 | status = beiscsi_create_def_data(phba, phwi_context, |
3556 | phwi_ctrlr, def_pdu_ring_sz); | 3168 | phwi_ctrlr, def_pdu_ring_sz); |
3557 | if (status != 0) { | 3169 | if (status != 0) { |
3558 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3170 | shost_printk(KERN_ERR, phba->shost, |
3559 | "BM_%d : Default Data not created\n"); | 3171 | "Default Data not created\n"); |
3560 | goto error; | 3172 | goto error; |
3561 | } | 3173 | } |
3562 | 3174 | ||
3563 | status = beiscsi_post_pages(phba); | 3175 | status = beiscsi_post_pages(phba); |
3564 | if (status != 0) { | 3176 | if (status != 0) { |
3565 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3177 | shost_printk(KERN_ERR, phba->shost, "Post SGL Pages Failed\n"); |
3566 | "BM_%d : Post SGL Pages Failed\n"); | ||
3567 | goto error; | 3178 | goto error; |
3568 | } | 3179 | } |
3569 | 3180 | ||
3570 | status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr); | 3181 | status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr); |
3571 | if (status != 0) { | 3182 | if (status != 0) { |
3572 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3183 | shost_printk(KERN_ERR, phba->shost, |
3573 | "BM_%d : WRB Rings not created\n"); | 3184 | "WRB Rings not created\n"); |
3574 | goto error; | 3185 | goto error; |
3575 | } | 3186 | } |
3576 | 3187 | ||
3577 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3188 | SE_DEBUG(DBG_LVL_8, "hwi_init_port success\n"); |
3578 | "BM_%d : hwi_init_port success\n"); | ||
3579 | return 0; | 3189 | return 0; |
3580 | 3190 | ||
3581 | error: | 3191 | error: |
3582 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3192 | shost_printk(KERN_ERR, phba->shost, "hwi_init_port failed"); |
3583 | "BM_%d : hwi_init_port failed"); | ||
3584 | hwi_cleanup(phba); | 3193 | hwi_cleanup(phba); |
3585 | return status; | 3194 | return -ENOMEM; |
3586 | } | 3195 | } |
3587 | 3196 | ||
3588 | static int hwi_init_controller(struct beiscsi_hba *phba) | 3197 | static int hwi_init_controller(struct beiscsi_hba *phba) |
@@ -3593,25 +3202,21 @@ static int hwi_init_controller(struct beiscsi_hba *phba) | |||
3593 | if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { | 3202 | if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { |
3594 | phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> | 3203 | phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> |
3595 | init_mem[HWI_MEM_ADDN_CONTEXT].mem_array[0].virtual_address; | 3204 | init_mem[HWI_MEM_ADDN_CONTEXT].mem_array[0].virtual_address; |
3596 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3205 | SE_DEBUG(DBG_LVL_8, " phwi_ctrlr->phwi_ctxt=%p\n", |
3597 | "BM_%d : phwi_ctrlr->phwi_ctxt=%p\n", | 3206 | phwi_ctrlr->phwi_ctxt); |
3598 | phwi_ctrlr->phwi_ctxt); | ||
3599 | } else { | 3207 | } else { |
3600 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3208 | shost_printk(KERN_ERR, phba->shost, |
3601 | "BM_%d : HWI_MEM_ADDN_CONTEXT is more " | 3209 | "HWI_MEM_ADDN_CONTEXT is more than one element." |
3602 | "than one element.Failing to load\n"); | 3210 | "Failing to load\n"); |
3603 | return -ENOMEM; | 3211 | return -ENOMEM; |
3604 | } | 3212 | } |
3605 | 3213 | ||
3606 | iscsi_init_global_templates(phba); | 3214 | iscsi_init_global_templates(phba); |
3607 | if (beiscsi_init_wrb_handle(phba)) | 3215 | beiscsi_init_wrb_handle(phba); |
3608 | return -ENOMEM; | ||
3609 | |||
3610 | hwi_init_async_pdu_ctx(phba); | 3216 | hwi_init_async_pdu_ctx(phba); |
3611 | if (hwi_init_port(phba) != 0) { | 3217 | if (hwi_init_port(phba) != 0) { |
3612 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3218 | shost_printk(KERN_ERR, phba->shost, |
3613 | "BM_%d : hwi_init_controller failed\n"); | 3219 | "hwi_init_controller failed\n"); |
3614 | |||
3615 | return -ENOMEM; | 3220 | return -ENOMEM; |
3616 | } | 3221 | } |
3617 | return 0; | 3222 | return 0; |
@@ -3646,23 +3251,20 @@ static int beiscsi_init_controller(struct beiscsi_hba *phba) | |||
3646 | 3251 | ||
3647 | ret = beiscsi_get_memory(phba); | 3252 | ret = beiscsi_get_memory(phba); |
3648 | if (ret < 0) { | 3253 | if (ret < 0) { |
3649 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3254 | shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe -" |
3650 | "BM_%d : beiscsi_dev_probe -" | 3255 | "Failed in beiscsi_alloc_memory\n"); |
3651 | "Failed in beiscsi_alloc_memory\n"); | ||
3652 | return ret; | 3256 | return ret; |
3653 | } | 3257 | } |
3654 | 3258 | ||
3655 | ret = hwi_init_controller(phba); | 3259 | ret = hwi_init_controller(phba); |
3656 | if (ret) | 3260 | if (ret) |
3657 | goto free_init; | 3261 | goto free_init; |
3658 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3262 | SE_DEBUG(DBG_LVL_8, "Return success from beiscsi_init_controller"); |
3659 | "BM_%d : Return success from beiscsi_init_controller"); | ||
3660 | |||
3661 | return 0; | 3263 | return 0; |
3662 | 3264 | ||
3663 | free_init: | 3265 | free_init: |
3664 | beiscsi_free_mem(phba); | 3266 | beiscsi_free_mem(phba); |
3665 | return ret; | 3267 | return -ENOMEM; |
3666 | } | 3268 | } |
3667 | 3269 | ||
3668 | static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) | 3270 | static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) |
@@ -3682,8 +3284,8 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) | |||
3682 | phba->params.ios_per_ctrl, | 3284 | phba->params.ios_per_ctrl, |
3683 | GFP_KERNEL); | 3285 | GFP_KERNEL); |
3684 | if (!phba->io_sgl_hndl_base) { | 3286 | if (!phba->io_sgl_hndl_base) { |
3685 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3287 | shost_printk(KERN_ERR, phba->shost, |
3686 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | 3288 | "Mem Alloc Failed. Failing to load\n"); |
3687 | return -ENOMEM; | 3289 | return -ENOMEM; |
3688 | } | 3290 | } |
3689 | phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) * | 3291 | phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) * |
@@ -3692,14 +3294,14 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) | |||
3692 | GFP_KERNEL); | 3294 | GFP_KERNEL); |
3693 | if (!phba->eh_sgl_hndl_base) { | 3295 | if (!phba->eh_sgl_hndl_base) { |
3694 | kfree(phba->io_sgl_hndl_base); | 3296 | kfree(phba->io_sgl_hndl_base); |
3695 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3297 | shost_printk(KERN_ERR, phba->shost, |
3696 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | 3298 | "Mem Alloc Failed. Failing to load\n"); |
3697 | return -ENOMEM; | 3299 | return -ENOMEM; |
3698 | } | 3300 | } |
3699 | } else { | 3301 | } else { |
3700 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3302 | shost_printk(KERN_ERR, phba->shost, |
3701 | "BM_%d : HWI_MEM_SGLH is more than one element." | 3303 | "HWI_MEM_SGLH is more than one element." |
3702 | "Failing to load\n"); | 3304 | "Failing to load\n"); |
3703 | return -ENOMEM; | 3305 | return -ENOMEM; |
3704 | } | 3306 | } |
3705 | 3307 | ||
@@ -3725,18 +3327,15 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) | |||
3725 | } | 3327 | } |
3726 | idx++; | 3328 | idx++; |
3727 | } | 3329 | } |
3728 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3330 | SE_DEBUG(DBG_LVL_8, |
3729 | "BM_%d : phba->io_sgl_hndl_avbl=%d" | 3331 | "phba->io_sgl_hndl_avbl=%d" |
3730 | "phba->eh_sgl_hndl_avbl=%d\n", | 3332 | "phba->eh_sgl_hndl_avbl=%d\n", |
3731 | phba->io_sgl_hndl_avbl, | 3333 | phba->io_sgl_hndl_avbl, |
3732 | phba->eh_sgl_hndl_avbl); | 3334 | phba->eh_sgl_hndl_avbl); |
3733 | |||
3734 | mem_descr_sg = phba->init_mem; | 3335 | mem_descr_sg = phba->init_mem; |
3735 | mem_descr_sg += HWI_MEM_SGE; | 3336 | mem_descr_sg += HWI_MEM_SGE; |
3736 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3337 | SE_DEBUG(DBG_LVL_8, "\n mem_descr_sg->num_elements=%d\n", |
3737 | "\n BM_%d : mem_descr_sg->num_elements=%d\n", | 3338 | mem_descr_sg->num_elements); |
3738 | mem_descr_sg->num_elements); | ||
3739 | |||
3740 | arr_index = 0; | 3339 | arr_index = 0; |
3741 | idx = 0; | 3340 | idx = 0; |
3742 | while (idx < mem_descr_sg->num_elements) { | 3341 | while (idx < mem_descr_sg->num_elements) { |
@@ -3774,17 +3373,17 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) | |||
3774 | phba->cid_array = kzalloc(sizeof(void *) * phba->params.cxns_per_ctrl, | 3373 | phba->cid_array = kzalloc(sizeof(void *) * phba->params.cxns_per_ctrl, |
3775 | GFP_KERNEL); | 3374 | GFP_KERNEL); |
3776 | if (!phba->cid_array) { | 3375 | if (!phba->cid_array) { |
3777 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3376 | shost_printk(KERN_ERR, phba->shost, |
3778 | "BM_%d : Failed to allocate memory in " | 3377 | "Failed to allocate memory in " |
3779 | "hba_setup_cid_tbls\n"); | 3378 | "hba_setup_cid_tbls\n"); |
3780 | return -ENOMEM; | 3379 | return -ENOMEM; |
3781 | } | 3380 | } |
3782 | phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) * | 3381 | phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) * |
3783 | phba->params.cxns_per_ctrl * 2, GFP_KERNEL); | 3382 | phba->params.cxns_per_ctrl * 2, GFP_KERNEL); |
3784 | if (!phba->ep_array) { | 3383 | if (!phba->ep_array) { |
3785 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3384 | shost_printk(KERN_ERR, phba->shost, |
3786 | "BM_%d : Failed to allocate memory in " | 3385 | "Failed to allocate memory in " |
3787 | "hba_setup_cid_tbls\n"); | 3386 | "hba_setup_cid_tbls\n"); |
3788 | kfree(phba->cid_array); | 3387 | kfree(phba->cid_array); |
3789 | return -ENOMEM; | 3388 | return -ENOMEM; |
3790 | } | 3389 | } |
@@ -3817,22 +3416,18 @@ static void hwi_enable_intr(struct beiscsi_hba *phba) | |||
3817 | enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; | 3416 | enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; |
3818 | if (!enabled) { | 3417 | if (!enabled) { |
3819 | reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; | 3418 | reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; |
3820 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3419 | SE_DEBUG(DBG_LVL_8, "reg =x%08x addr=%p\n", reg, addr); |
3821 | "BM_%d : reg =x%08x addr=%p\n", reg, addr); | ||
3822 | iowrite32(reg, addr); | 3420 | iowrite32(reg, addr); |
3823 | } | 3421 | } |
3824 | 3422 | ||
3825 | if (!phba->msix_enabled) { | 3423 | if (!phba->msix_enabled) { |
3826 | eq = &phwi_context->be_eq[0].q; | 3424 | eq = &phwi_context->be_eq[0].q; |
3827 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3425 | SE_DEBUG(DBG_LVL_8, "eq->id=%d\n", eq->id); |
3828 | "BM_%d : eq->id=%d\n", eq->id); | ||
3829 | |||
3830 | hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); | 3426 | hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); |
3831 | } else { | 3427 | } else { |
3832 | for (i = 0; i <= phba->num_cpus; i++) { | 3428 | for (i = 0; i <= phba->num_cpus; i++) { |
3833 | eq = &phwi_context->be_eq[i].q; | 3429 | eq = &phwi_context->be_eq[i].q; |
3834 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 3430 | SE_DEBUG(DBG_LVL_8, "eq->id=%d\n", eq->id); |
3835 | "BM_%d : eq->id=%d\n", eq->id); | ||
3836 | hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); | 3431 | hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); |
3837 | } | 3432 | } |
3838 | } | 3433 | } |
@@ -3850,68 +3445,81 @@ static void hwi_disable_intr(struct beiscsi_hba *phba) | |||
3850 | reg &= ~MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; | 3445 | reg &= ~MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; |
3851 | iowrite32(reg, addr); | 3446 | iowrite32(reg, addr); |
3852 | } else | 3447 | } else |
3853 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 3448 | shost_printk(KERN_WARNING, phba->shost, |
3854 | "BM_%d : In hwi_disable_intr, Already Disabled\n"); | 3449 | "In hwi_disable_intr, Already Disabled\n"); |
3855 | } | 3450 | } |
3856 | 3451 | ||
3857 | /** | ||
3858 | * beiscsi_get_boot_info()- Get the boot session info | ||
3859 | * @phba: The device priv structure instance | ||
3860 | * | ||
3861 | * Get the boot target info and store in driver priv structure | ||
3862 | * | ||
3863 | * return values | ||
3864 | * Success: 0 | ||
3865 | * Failure: Non-Zero Value | ||
3866 | **/ | ||
3867 | static int beiscsi_get_boot_info(struct beiscsi_hba *phba) | 3452 | static int beiscsi_get_boot_info(struct beiscsi_hba *phba) |
3868 | { | 3453 | { |
3869 | struct be_cmd_get_session_resp *session_resp; | 3454 | struct be_cmd_resp_get_boot_target *boot_resp; |
3455 | struct be_cmd_resp_get_session *session_resp; | ||
3456 | struct be_mcc_wrb *wrb; | ||
3870 | struct be_dma_mem nonemb_cmd; | 3457 | struct be_dma_mem nonemb_cmd; |
3871 | unsigned int tag; | 3458 | unsigned int tag, wrb_num; |
3872 | unsigned int s_handle; | 3459 | unsigned short status, extd_status; |
3460 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; | ||
3873 | int ret = -ENOMEM; | 3461 | int ret = -ENOMEM; |
3874 | 3462 | ||
3875 | /* Get the session handle of the boot target */ | 3463 | tag = beiscsi_get_boot_target(phba); |
3876 | ret = be_mgmt_get_boot_shandle(phba, &s_handle); | 3464 | if (!tag) { |
3877 | if (ret) { | 3465 | SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n"); |
3878 | beiscsi_log(phba, KERN_ERR, | 3466 | return -EAGAIN; |
3879 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | 3467 | } else |
3880 | "BM_%d : No boot session\n"); | 3468 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], |
3881 | return ret; | 3469 | phba->ctrl.mcc_numtag[tag]); |
3470 | |||
3471 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; | ||
3472 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; | ||
3473 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; | ||
3474 | if (status || extd_status) { | ||
3475 | SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed" | ||
3476 | " status = %d extd_status = %d\n", | ||
3477 | status, extd_status); | ||
3478 | free_mcc_tag(&phba->ctrl, tag); | ||
3479 | return -EBUSY; | ||
3882 | } | 3480 | } |
3481 | wrb = queue_get_wrb(mccq, wrb_num); | ||
3482 | free_mcc_tag(&phba->ctrl, tag); | ||
3483 | boot_resp = embedded_payload(wrb); | ||
3484 | |||
3485 | if (boot_resp->boot_session_handle < 0) { | ||
3486 | shost_printk(KERN_INFO, phba->shost, "No Boot Session.\n"); | ||
3487 | return -ENXIO; | ||
3488 | } | ||
3489 | |||
3883 | nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, | 3490 | nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, |
3884 | sizeof(*session_resp), | 3491 | sizeof(*session_resp), |
3885 | &nonemb_cmd.dma); | 3492 | &nonemb_cmd.dma); |
3886 | if (nonemb_cmd.va == NULL) { | 3493 | if (nonemb_cmd.va == NULL) { |
3887 | beiscsi_log(phba, KERN_ERR, | 3494 | SE_DEBUG(DBG_LVL_1, |
3888 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | 3495 | "Failed to allocate memory for" |
3889 | "BM_%d : Failed to allocate memory for" | 3496 | "beiscsi_get_session_info\n"); |
3890 | "beiscsi_get_session_info\n"); | ||
3891 | |||
3892 | return -ENOMEM; | 3497 | return -ENOMEM; |
3893 | } | 3498 | } |
3894 | 3499 | ||
3895 | memset(nonemb_cmd.va, 0, sizeof(*session_resp)); | 3500 | memset(nonemb_cmd.va, 0, sizeof(*session_resp)); |
3896 | tag = mgmt_get_session_info(phba, s_handle, | 3501 | tag = beiscsi_get_session_info(phba, |
3897 | &nonemb_cmd); | 3502 | boot_resp->boot_session_handle, &nonemb_cmd); |
3898 | if (!tag) { | 3503 | if (!tag) { |
3899 | beiscsi_log(phba, KERN_ERR, | 3504 | SE_DEBUG(DBG_LVL_1, "beiscsi_get_session_info" |
3900 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | 3505 | " Failed\n"); |
3901 | "BM_%d : beiscsi_get_session_info" | ||
3902 | " Failed\n"); | ||
3903 | |||
3904 | goto boot_freemem; | 3506 | goto boot_freemem; |
3905 | } | 3507 | } else |
3906 | 3508 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | |
3907 | ret = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); | 3509 | phba->ctrl.mcc_numtag[tag]); |
3908 | if (ret) { | 3510 | |
3909 | beiscsi_log(phba, KERN_ERR, | 3511 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; |
3910 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | 3512 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; |
3911 | "BM_%d : beiscsi_get_session_info Failed"); | 3513 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; |
3514 | if (status || extd_status) { | ||
3515 | SE_DEBUG(DBG_LVL_1, "beiscsi_get_session_info Failed" | ||
3516 | " status = %d extd_status = %d\n", | ||
3517 | status, extd_status); | ||
3518 | free_mcc_tag(&phba->ctrl, tag); | ||
3912 | goto boot_freemem; | 3519 | goto boot_freemem; |
3913 | } | 3520 | } |
3914 | 3521 | wrb = queue_get_wrb(mccq, wrb_num); | |
3522 | free_mcc_tag(&phba->ctrl, tag); | ||
3915 | session_resp = nonemb_cmd.va ; | 3523 | session_resp = nonemb_cmd.va ; |
3916 | 3524 | ||
3917 | memcpy(&phba->boot_sess, &session_resp->session_info, | 3525 | memcpy(&phba->boot_sess, &session_resp->session_info, |
@@ -3986,22 +3594,22 @@ static int beiscsi_init_port(struct beiscsi_hba *phba) | |||
3986 | 3594 | ||
3987 | ret = beiscsi_init_controller(phba); | 3595 | ret = beiscsi_init_controller(phba); |
3988 | if (ret < 0) { | 3596 | if (ret < 0) { |
3989 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3597 | shost_printk(KERN_ERR, phba->shost, |
3990 | "BM_%d : beiscsi_dev_probe - Failed in" | 3598 | "beiscsi_dev_probe - Failed in" |
3991 | "beiscsi_init_controller\n"); | 3599 | "beiscsi_init_controller\n"); |
3992 | return ret; | 3600 | return ret; |
3993 | } | 3601 | } |
3994 | ret = beiscsi_init_sgl_handle(phba); | 3602 | ret = beiscsi_init_sgl_handle(phba); |
3995 | if (ret < 0) { | 3603 | if (ret < 0) { |
3996 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3604 | shost_printk(KERN_ERR, phba->shost, |
3997 | "BM_%d : beiscsi_dev_probe - Failed in" | 3605 | "beiscsi_dev_probe - Failed in" |
3998 | "beiscsi_init_sgl_handle\n"); | 3606 | "beiscsi_init_sgl_handle\n"); |
3999 | goto do_cleanup_ctrlr; | 3607 | goto do_cleanup_ctrlr; |
4000 | } | 3608 | } |
4001 | 3609 | ||
4002 | if (hba_setup_cid_tbls(phba)) { | 3610 | if (hba_setup_cid_tbls(phba)) { |
4003 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3611 | shost_printk(KERN_ERR, phba->shost, |
4004 | "BM_%d : Failed in hba_setup_cid_tbls\n"); | 3612 | "Failed in hba_setup_cid_tbls\n"); |
4005 | kfree(phba->io_sgl_hndl_base); | 3613 | kfree(phba->io_sgl_hndl_base); |
4006 | kfree(phba->eh_sgl_hndl_base); | 3614 | kfree(phba->eh_sgl_hndl_base); |
4007 | goto do_cleanup_ctrlr; | 3615 | goto do_cleanup_ctrlr; |
@@ -4053,8 +3661,8 @@ static void beiscsi_clean_port(struct beiscsi_hba *phba) | |||
4053 | 3661 | ||
4054 | mgmt_status = mgmt_epfw_cleanup(phba, CMD_CONNECTION_CHUTE_0); | 3662 | mgmt_status = mgmt_epfw_cleanup(phba, CMD_CONNECTION_CHUTE_0); |
4055 | if (mgmt_status) | 3663 | if (mgmt_status) |
4056 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 3664 | shost_printk(KERN_WARNING, phba->shost, |
4057 | "BM_%d : mgmt_epfw_cleanup FAILED\n"); | 3665 | "mgmt_epfw_cleanup FAILED\n"); |
4058 | 3666 | ||
4059 | hwi_purge_eq(phba); | 3667 | hwi_purge_eq(phba); |
4060 | hwi_cleanup(phba); | 3668 | hwi_cleanup(phba); |
@@ -4064,100 +3672,83 @@ static void beiscsi_clean_port(struct beiscsi_hba *phba) | |||
4064 | kfree(phba->ep_array); | 3672 | kfree(phba->ep_array); |
4065 | } | 3673 | } |
4066 | 3674 | ||
4067 | /** | ||
4068 | * beiscsi_cleanup_task()- Free driver resources of the task | ||
4069 | * @task: ptr to the iscsi task | ||
4070 | * | ||
4071 | **/ | ||
4072 | static void beiscsi_cleanup_task(struct iscsi_task *task) | ||
4073 | { | ||
4074 | struct beiscsi_io_task *io_task = task->dd_data; | ||
4075 | struct iscsi_conn *conn = task->conn; | ||
4076 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; | ||
4077 | struct beiscsi_hba *phba = beiscsi_conn->phba; | ||
4078 | struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess; | ||
4079 | struct hwi_wrb_context *pwrb_context; | ||
4080 | struct hwi_controller *phwi_ctrlr; | ||
4081 | |||
4082 | phwi_ctrlr = phba->phwi_ctrlr; | ||
4083 | pwrb_context = &phwi_ctrlr->wrb_context[beiscsi_conn->beiscsi_conn_cid | ||
4084 | - phba->fw_config.iscsi_cid_start]; | ||
4085 | |||
4086 | if (io_task->cmd_bhs) { | ||
4087 | pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, | ||
4088 | io_task->bhs_pa.u.a64.address); | ||
4089 | io_task->cmd_bhs = NULL; | ||
4090 | } | ||
4091 | |||
4092 | if (task->sc) { | ||
4093 | if (io_task->pwrb_handle) { | ||
4094 | free_wrb_handle(phba, pwrb_context, | ||
4095 | io_task->pwrb_handle); | ||
4096 | io_task->pwrb_handle = NULL; | ||
4097 | } | ||
4098 | |||
4099 | if (io_task->psgl_handle) { | ||
4100 | spin_lock(&phba->io_sgl_lock); | ||
4101 | free_io_sgl_handle(phba, io_task->psgl_handle); | ||
4102 | spin_unlock(&phba->io_sgl_lock); | ||
4103 | io_task->psgl_handle = NULL; | ||
4104 | } | ||
4105 | } else { | ||
4106 | if (!beiscsi_conn->login_in_progress) { | ||
4107 | if (io_task->pwrb_handle) { | ||
4108 | free_wrb_handle(phba, pwrb_context, | ||
4109 | io_task->pwrb_handle); | ||
4110 | io_task->pwrb_handle = NULL; | ||
4111 | } | ||
4112 | if (io_task->psgl_handle) { | ||
4113 | spin_lock(&phba->mgmt_sgl_lock); | ||
4114 | free_mgmt_sgl_handle(phba, | ||
4115 | io_task->psgl_handle); | ||
4116 | spin_unlock(&phba->mgmt_sgl_lock); | ||
4117 | io_task->psgl_handle = NULL; | ||
4118 | } | ||
4119 | if (io_task->mtask_addr) { | ||
4120 | pci_unmap_single(phba->pcidev, | ||
4121 | io_task->mtask_addr, | ||
4122 | io_task->mtask_data_count, | ||
4123 | PCI_DMA_TODEVICE); | ||
4124 | io_task->mtask_addr = 0; | ||
4125 | } | ||
4126 | } | ||
4127 | } | ||
4128 | } | ||
4129 | |||
4130 | void | 3675 | void |
4131 | beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, | 3676 | beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, |
4132 | struct beiscsi_offload_params *params) | 3677 | struct beiscsi_offload_params *params) |
4133 | { | 3678 | { |
4134 | struct wrb_handle *pwrb_handle; | 3679 | struct wrb_handle *pwrb_handle; |
3680 | struct iscsi_target_context_update_wrb *pwrb = NULL; | ||
3681 | struct be_mem_descriptor *mem_descr; | ||
4135 | struct beiscsi_hba *phba = beiscsi_conn->phba; | 3682 | struct beiscsi_hba *phba = beiscsi_conn->phba; |
4136 | struct iscsi_task *task = beiscsi_conn->task; | ||
4137 | struct iscsi_session *session = task->conn->session; | ||
4138 | u32 doorbell = 0; | 3683 | u32 doorbell = 0; |
4139 | 3684 | ||
4140 | /* | 3685 | /* |
4141 | * We can always use 0 here because it is reserved by libiscsi for | 3686 | * We can always use 0 here because it is reserved by libiscsi for |
4142 | * login/startup related tasks. | 3687 | * login/startup related tasks. |
4143 | */ | 3688 | */ |
4144 | beiscsi_conn->login_in_progress = 0; | ||
4145 | spin_lock_bh(&session->lock); | ||
4146 | beiscsi_cleanup_task(task); | ||
4147 | spin_unlock_bh(&session->lock); | ||
4148 | |||
4149 | pwrb_handle = alloc_wrb_handle(phba, (beiscsi_conn->beiscsi_conn_cid - | 3689 | pwrb_handle = alloc_wrb_handle(phba, (beiscsi_conn->beiscsi_conn_cid - |
4150 | phba->fw_config.iscsi_cid_start)); | 3690 | phba->fw_config.iscsi_cid_start)); |
3691 | pwrb = (struct iscsi_target_context_update_wrb *)pwrb_handle->pwrb; | ||
3692 | memset(pwrb, 0, sizeof(*pwrb)); | ||
3693 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
3694 | max_burst_length, pwrb, params->dw[offsetof | ||
3695 | (struct amap_beiscsi_offload_params, | ||
3696 | max_burst_length) / 32]); | ||
3697 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
3698 | max_send_data_segment_length, pwrb, | ||
3699 | params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3700 | max_send_data_segment_length) / 32]); | ||
3701 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
3702 | first_burst_length, | ||
3703 | pwrb, | ||
3704 | params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3705 | first_burst_length) / 32]); | ||
3706 | |||
3707 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb, | ||
3708 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3709 | erl) / 32] & OFFLD_PARAMS_ERL)); | ||
3710 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb, | ||
3711 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3712 | dde) / 32] & OFFLD_PARAMS_DDE) >> 2); | ||
3713 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb, | ||
3714 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3715 | hde) / 32] & OFFLD_PARAMS_HDE) >> 3); | ||
3716 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb, | ||
3717 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3718 | ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4); | ||
3719 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb, | ||
3720 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3721 | imd) / 32] & OFFLD_PARAMS_IMD) >> 5); | ||
3722 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn, | ||
3723 | pwrb, | ||
3724 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
3725 | exp_statsn) / 32] + 1)); | ||
3726 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb, | ||
3727 | 0x7); | ||
3728 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx, | ||
3729 | pwrb, pwrb_handle->wrb_index); | ||
3730 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb, | ||
3731 | pwrb, pwrb_handle->nxt_wrb_index); | ||
3732 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
3733 | session_state, pwrb, 0); | ||
3734 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, compltonack, | ||
3735 | pwrb, 1); | ||
3736 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, notpredblq, | ||
3737 | pwrb, 0); | ||
3738 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, mode, pwrb, | ||
3739 | 0); | ||
4151 | 3740 | ||
4152 | /* Check for the adapter family */ | 3741 | mem_descr = phba->init_mem; |
4153 | if (chip_skh_r(phba->pcidev)) | 3742 | mem_descr += ISCSI_MEM_GLOBAL_HEADER; |
4154 | beiscsi_offload_cxn_v2(params, pwrb_handle); | 3743 | |
4155 | else | 3744 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
4156 | beiscsi_offload_cxn_v0(params, pwrb_handle, | 3745 | pad_buffer_addr_hi, pwrb, |
4157 | phba->init_mem); | 3746 | mem_descr->mem_array[0].bus_address.u.a32.address_hi); |
3747 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
3748 | pad_buffer_addr_lo, pwrb, | ||
3749 | mem_descr->mem_array[0].bus_address.u.a32.address_lo); | ||
4158 | 3750 | ||
4159 | be_dws_le_to_cpu(pwrb_handle->pwrb, | 3751 | be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_target_context_update_wrb)); |
4160 | sizeof(struct iscsi_target_context_update_wrb)); | ||
4161 | 3752 | ||
4162 | doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK; | 3753 | doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK; |
4163 | doorbell |= (pwrb_handle->wrb_index & DB_DEF_PDU_WRB_INDEX_MASK) | 3754 | doorbell |= (pwrb_handle->wrb_index & DB_DEF_PDU_WRB_INDEX_MASK) |
@@ -4208,31 +3799,19 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
4208 | task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr; | 3799 | task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr; |
4209 | task->hdr_max = sizeof(struct be_cmd_bhs); | 3800 | task->hdr_max = sizeof(struct be_cmd_bhs); |
4210 | io_task->psgl_handle = NULL; | 3801 | io_task->psgl_handle = NULL; |
4211 | io_task->pwrb_handle = NULL; | 3802 | io_task->psgl_handle = NULL; |
4212 | 3803 | ||
4213 | if (task->sc) { | 3804 | if (task->sc) { |
4214 | spin_lock(&phba->io_sgl_lock); | 3805 | spin_lock(&phba->io_sgl_lock); |
4215 | io_task->psgl_handle = alloc_io_sgl_handle(phba); | 3806 | io_task->psgl_handle = alloc_io_sgl_handle(phba); |
4216 | spin_unlock(&phba->io_sgl_lock); | 3807 | spin_unlock(&phba->io_sgl_lock); |
4217 | if (!io_task->psgl_handle) { | 3808 | if (!io_task->psgl_handle) |
4218 | beiscsi_log(phba, KERN_ERR, | ||
4219 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | ||
4220 | "BM_%d : Alloc of IO_SGL_ICD Failed" | ||
4221 | "for the CID : %d\n", | ||
4222 | beiscsi_conn->beiscsi_conn_cid); | ||
4223 | goto free_hndls; | 3809 | goto free_hndls; |
4224 | } | ||
4225 | io_task->pwrb_handle = alloc_wrb_handle(phba, | 3810 | io_task->pwrb_handle = alloc_wrb_handle(phba, |
4226 | beiscsi_conn->beiscsi_conn_cid - | 3811 | beiscsi_conn->beiscsi_conn_cid - |
4227 | phba->fw_config.iscsi_cid_start); | 3812 | phba->fw_config.iscsi_cid_start); |
4228 | if (!io_task->pwrb_handle) { | 3813 | if (!io_task->pwrb_handle) |
4229 | beiscsi_log(phba, KERN_ERR, | ||
4230 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | ||
4231 | "BM_%d : Alloc of WRB_HANDLE Failed" | ||
4232 | "for the CID : %d\n", | ||
4233 | beiscsi_conn->beiscsi_conn_cid); | ||
4234 | goto free_io_hndls; | 3814 | goto free_io_hndls; |
4235 | } | ||
4236 | } else { | 3815 | } else { |
4237 | io_task->scsi_cmnd = NULL; | 3816 | io_task->scsi_cmnd = NULL; |
4238 | if ((opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) { | 3817 | if ((opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) { |
@@ -4241,16 +3820,8 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
4241 | io_task->psgl_handle = (struct sgl_handle *) | 3820 | io_task->psgl_handle = (struct sgl_handle *) |
4242 | alloc_mgmt_sgl_handle(phba); | 3821 | alloc_mgmt_sgl_handle(phba); |
4243 | spin_unlock(&phba->mgmt_sgl_lock); | 3822 | spin_unlock(&phba->mgmt_sgl_lock); |
4244 | if (!io_task->psgl_handle) { | 3823 | if (!io_task->psgl_handle) |
4245 | beiscsi_log(phba, KERN_ERR, | ||
4246 | BEISCSI_LOG_IO | | ||
4247 | BEISCSI_LOG_CONFIG, | ||
4248 | "BM_%d : Alloc of MGMT_SGL_ICD Failed" | ||
4249 | "for the CID : %d\n", | ||
4250 | beiscsi_conn-> | ||
4251 | beiscsi_conn_cid); | ||
4252 | goto free_hndls; | 3824 | goto free_hndls; |
4253 | } | ||
4254 | 3825 | ||
4255 | beiscsi_conn->login_in_progress = 1; | 3826 | beiscsi_conn->login_in_progress = 1; |
4256 | beiscsi_conn->plogin_sgl_handle = | 3827 | beiscsi_conn->plogin_sgl_handle = |
@@ -4259,16 +3830,8 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
4259 | alloc_wrb_handle(phba, | 3830 | alloc_wrb_handle(phba, |
4260 | beiscsi_conn->beiscsi_conn_cid - | 3831 | beiscsi_conn->beiscsi_conn_cid - |
4261 | phba->fw_config.iscsi_cid_start); | 3832 | phba->fw_config.iscsi_cid_start); |
4262 | if (!io_task->pwrb_handle) { | 3833 | if (!io_task->pwrb_handle) |
4263 | beiscsi_log(phba, KERN_ERR, | 3834 | goto free_io_hndls; |
4264 | BEISCSI_LOG_IO | | ||
4265 | BEISCSI_LOG_CONFIG, | ||
4266 | "BM_%d : Alloc of WRB_HANDLE Failed" | ||
4267 | "for the CID : %d\n", | ||
4268 | beiscsi_conn-> | ||
4269 | beiscsi_conn_cid); | ||
4270 | goto free_mgmt_hndls; | ||
4271 | } | ||
4272 | beiscsi_conn->plogin_wrb_handle = | 3835 | beiscsi_conn->plogin_wrb_handle = |
4273 | io_task->pwrb_handle; | 3836 | io_task->pwrb_handle; |
4274 | 3837 | ||
@@ -4278,33 +3841,18 @@ static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) | |||
4278 | io_task->pwrb_handle = | 3841 | io_task->pwrb_handle = |
4279 | beiscsi_conn->plogin_wrb_handle; | 3842 | beiscsi_conn->plogin_wrb_handle; |
4280 | } | 3843 | } |
4281 | beiscsi_conn->task = task; | ||
4282 | } else { | 3844 | } else { |
4283 | spin_lock(&phba->mgmt_sgl_lock); | 3845 | spin_lock(&phba->mgmt_sgl_lock); |
4284 | io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); | 3846 | io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); |
4285 | spin_unlock(&phba->mgmt_sgl_lock); | 3847 | spin_unlock(&phba->mgmt_sgl_lock); |
4286 | if (!io_task->psgl_handle) { | 3848 | if (!io_task->psgl_handle) |
4287 | beiscsi_log(phba, KERN_ERR, | ||
4288 | BEISCSI_LOG_IO | | ||
4289 | BEISCSI_LOG_CONFIG, | ||
4290 | "BM_%d : Alloc of MGMT_SGL_ICD Failed" | ||
4291 | "for the CID : %d\n", | ||
4292 | beiscsi_conn-> | ||
4293 | beiscsi_conn_cid); | ||
4294 | goto free_hndls; | 3849 | goto free_hndls; |
4295 | } | ||
4296 | io_task->pwrb_handle = | 3850 | io_task->pwrb_handle = |
4297 | alloc_wrb_handle(phba, | 3851 | alloc_wrb_handle(phba, |
4298 | beiscsi_conn->beiscsi_conn_cid - | 3852 | beiscsi_conn->beiscsi_conn_cid - |
4299 | phba->fw_config.iscsi_cid_start); | 3853 | phba->fw_config.iscsi_cid_start); |
4300 | if (!io_task->pwrb_handle) { | 3854 | if (!io_task->pwrb_handle) |
4301 | beiscsi_log(phba, KERN_ERR, | ||
4302 | BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, | ||
4303 | "BM_%d : Alloc of WRB_HANDLE Failed" | ||
4304 | "for the CID : %d\n", | ||
4305 | beiscsi_conn->beiscsi_conn_cid); | ||
4306 | goto free_mgmt_hndls; | 3855 | goto free_mgmt_hndls; |
4307 | } | ||
4308 | 3856 | ||
4309 | } | 3857 | } |
4310 | } | 3858 | } |
@@ -4335,64 +3883,51 @@ free_hndls: | |||
4335 | io_task->pwrb_handle = NULL; | 3883 | io_task->pwrb_handle = NULL; |
4336 | pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, | 3884 | pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, |
4337 | io_task->bhs_pa.u.a64.address); | 3885 | io_task->bhs_pa.u.a64.address); |
4338 | io_task->cmd_bhs = NULL; | 3886 | SE_DEBUG(DBG_LVL_1, "Alloc of SGL_ICD Failed\n"); |
4339 | return -ENOMEM; | 3887 | return -ENOMEM; |
4340 | } | 3888 | } |
4341 | int beiscsi_iotask_v2(struct iscsi_task *task, struct scatterlist *sg, | ||
4342 | unsigned int num_sg, unsigned int xferlen, | ||
4343 | unsigned int writedir) | ||
4344 | { | ||
4345 | 3889 | ||
3890 | static void beiscsi_cleanup_task(struct iscsi_task *task) | ||
3891 | { | ||
4346 | struct beiscsi_io_task *io_task = task->dd_data; | 3892 | struct beiscsi_io_task *io_task = task->dd_data; |
4347 | struct iscsi_conn *conn = task->conn; | 3893 | struct iscsi_conn *conn = task->conn; |
4348 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; | 3894 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
4349 | struct beiscsi_hba *phba = beiscsi_conn->phba; | 3895 | struct beiscsi_hba *phba = beiscsi_conn->phba; |
4350 | struct iscsi_wrb *pwrb = NULL; | 3896 | struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess; |
4351 | unsigned int doorbell = 0; | 3897 | struct hwi_wrb_context *pwrb_context; |
3898 | struct hwi_controller *phwi_ctrlr; | ||
4352 | 3899 | ||
4353 | pwrb = io_task->pwrb_handle->pwrb; | 3900 | phwi_ctrlr = phba->phwi_ctrlr; |
4354 | memset(pwrb, 0, sizeof(*pwrb)); | 3901 | pwrb_context = &phwi_ctrlr->wrb_context[beiscsi_conn->beiscsi_conn_cid |
3902 | - phba->fw_config.iscsi_cid_start]; | ||
3903 | if (io_task->pwrb_handle) { | ||
3904 | free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); | ||
3905 | io_task->pwrb_handle = NULL; | ||
3906 | } | ||
4355 | 3907 | ||
4356 | io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0; | 3908 | if (io_task->cmd_bhs) { |
4357 | io_task->bhs_len = sizeof(struct be_cmd_bhs); | 3909 | pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, |
3910 | io_task->bhs_pa.u.a64.address); | ||
3911 | } | ||
4358 | 3912 | ||
4359 | if (writedir) { | 3913 | if (task->sc) { |
4360 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, type, pwrb, | 3914 | if (io_task->psgl_handle) { |
4361 | INI_WR_CMD); | 3915 | spin_lock(&phba->io_sgl_lock); |
4362 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, pwrb, 1); | 3916 | free_io_sgl_handle(phba, io_task->psgl_handle); |
3917 | spin_unlock(&phba->io_sgl_lock); | ||
3918 | io_task->psgl_handle = NULL; | ||
3919 | } | ||
4363 | } else { | 3920 | } else { |
4364 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, type, pwrb, | 3921 | if (task->hdr && |
4365 | INI_RD_CMD); | 3922 | ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN)) |
4366 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, pwrb, 0); | 3923 | return; |
3924 | if (io_task->psgl_handle) { | ||
3925 | spin_lock(&phba->mgmt_sgl_lock); | ||
3926 | free_mgmt_sgl_handle(phba, io_task->psgl_handle); | ||
3927 | spin_unlock(&phba->mgmt_sgl_lock); | ||
3928 | io_task->psgl_handle = NULL; | ||
3929 | } | ||
4367 | } | 3930 | } |
4368 | |||
4369 | io_task->wrb_type = AMAP_GET_BITS(struct amap_iscsi_wrb_v2, | ||
4370 | type, pwrb); | ||
4371 | |||
4372 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, lun, pwrb, | ||
4373 | cpu_to_be16(*(unsigned short *) | ||
4374 | &io_task->cmd_bhs->iscsi_hdr.lun)); | ||
4375 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb, xferlen); | ||
4376 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb, | ||
4377 | io_task->pwrb_handle->wrb_index); | ||
4378 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb, | ||
4379 | be32_to_cpu(task->cmdsn)); | ||
4380 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb, | ||
4381 | io_task->psgl_handle->sgl_index); | ||
4382 | |||
4383 | hwi_write_sgl_v2(pwrb, sg, num_sg, io_task); | ||
4384 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb, | ||
4385 | io_task->pwrb_handle->nxt_wrb_index); | ||
4386 | |||
4387 | be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_wrb)); | ||
4388 | |||
4389 | doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK; | ||
4390 | doorbell |= (io_task->pwrb_handle->wrb_index & | ||
4391 | DB_DEF_PDU_WRB_INDEX_MASK) << | ||
4392 | DB_DEF_PDU_WRB_INDEX_SHIFT; | ||
4393 | doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT; | ||
4394 | iowrite32(doorbell, phba->db_va + DB_TXULP0_OFFSET); | ||
4395 | return 0; | ||
4396 | } | 3931 | } |
4397 | 3932 | ||
4398 | static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, | 3933 | static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, |
@@ -4412,6 +3947,15 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, | |||
4412 | io_task->bhs_len = sizeof(struct be_cmd_bhs); | 3947 | io_task->bhs_len = sizeof(struct be_cmd_bhs); |
4413 | 3948 | ||
4414 | if (writedir) { | 3949 | if (writedir) { |
3950 | memset(&io_task->cmd_bhs->iscsi_data_pdu, 0, 48); | ||
3951 | AMAP_SET_BITS(struct amap_pdu_data_out, itt, | ||
3952 | &io_task->cmd_bhs->iscsi_data_pdu, | ||
3953 | (unsigned int)io_task->cmd_bhs->iscsi_hdr.itt); | ||
3954 | AMAP_SET_BITS(struct amap_pdu_data_out, opcode, | ||
3955 | &io_task->cmd_bhs->iscsi_data_pdu, | ||
3956 | ISCSI_OPCODE_SCSI_DATA_OUT); | ||
3957 | AMAP_SET_BITS(struct amap_pdu_data_out, final_bit, | ||
3958 | &io_task->cmd_bhs->iscsi_data_pdu, 1); | ||
4415 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, | 3959 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, |
4416 | INI_WR_CMD); | 3960 | INI_WR_CMD); |
4417 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1); | 3961 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1); |
@@ -4420,13 +3964,12 @@ static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, | |||
4420 | INI_RD_CMD); | 3964 | INI_RD_CMD); |
4421 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); | 3965 | AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); |
4422 | } | 3966 | } |
4423 | 3967 | memcpy(&io_task->cmd_bhs->iscsi_data_pdu. | |
4424 | io_task->wrb_type = AMAP_GET_BITS(struct amap_iscsi_wrb, | 3968 | dw[offsetof(struct amap_pdu_data_out, lun) / 32], |
4425 | type, pwrb); | 3969 | &io_task->cmd_bhs->iscsi_hdr.lun, sizeof(struct scsi_lun)); |
4426 | 3970 | ||
4427 | AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb, | 3971 | AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb, |
4428 | cpu_to_be16(*(unsigned short *) | 3972 | cpu_to_be16(*(unsigned short *)&io_task->cmd_bhs->iscsi_hdr.lun)); |
4429 | &io_task->cmd_bhs->iscsi_hdr.lun)); | ||
4430 | AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen); | 3973 | AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen); |
4431 | AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, | 3974 | AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, |
4432 | io_task->pwrb_handle->wrb_index); | 3975 | io_task->pwrb_handle->wrb_index); |
@@ -4459,90 +4002,69 @@ static int beiscsi_mtask(struct iscsi_task *task) | |||
4459 | struct iscsi_wrb *pwrb = NULL; | 4002 | struct iscsi_wrb *pwrb = NULL; |
4460 | unsigned int doorbell = 0; | 4003 | unsigned int doorbell = 0; |
4461 | unsigned int cid; | 4004 | unsigned int cid; |
4462 | unsigned int pwrb_typeoffset = 0; | ||
4463 | 4005 | ||
4464 | cid = beiscsi_conn->beiscsi_conn_cid; | 4006 | cid = beiscsi_conn->beiscsi_conn_cid; |
4465 | pwrb = io_task->pwrb_handle->pwrb; | 4007 | pwrb = io_task->pwrb_handle->pwrb; |
4466 | memset(pwrb, 0, sizeof(*pwrb)); | 4008 | memset(pwrb, 0, sizeof(*pwrb)); |
4467 | 4009 | AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, | |
4468 | if (chip_skh_r(phba->pcidev)) { | 4010 | be32_to_cpu(task->cmdsn)); |
4469 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb, | 4011 | AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, |
4470 | be32_to_cpu(task->cmdsn)); | 4012 | io_task->pwrb_handle->wrb_index); |
4471 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb, | 4013 | AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb, |
4472 | io_task->pwrb_handle->wrb_index); | 4014 | io_task->psgl_handle->sgl_index); |
4473 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb, | ||
4474 | io_task->psgl_handle->sgl_index); | ||
4475 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb, | ||
4476 | task->data_count); | ||
4477 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb, | ||
4478 | io_task->pwrb_handle->nxt_wrb_index); | ||
4479 | pwrb_typeoffset = SKH_WRB_TYPE_OFFSET; | ||
4480 | } else { | ||
4481 | AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, | ||
4482 | be32_to_cpu(task->cmdsn)); | ||
4483 | AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, | ||
4484 | io_task->pwrb_handle->wrb_index); | ||
4485 | AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb, | ||
4486 | io_task->psgl_handle->sgl_index); | ||
4487 | AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, | ||
4488 | task->data_count); | ||
4489 | AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb, | ||
4490 | io_task->pwrb_handle->nxt_wrb_index); | ||
4491 | pwrb_typeoffset = BE_WRB_TYPE_OFFSET; | ||
4492 | } | ||
4493 | |||
4494 | 4015 | ||
4495 | switch (task->hdr->opcode & ISCSI_OPCODE_MASK) { | 4016 | switch (task->hdr->opcode & ISCSI_OPCODE_MASK) { |
4496 | case ISCSI_OP_LOGIN: | 4017 | case ISCSI_OP_LOGIN: |
4018 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, | ||
4019 | TGT_DM_CMD); | ||
4020 | AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); | ||
4497 | AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 1); | 4021 | AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 1); |
4498 | ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); | ||
4499 | hwi_write_buffer(pwrb, task); | 4022 | hwi_write_buffer(pwrb, task); |
4500 | break; | 4023 | break; |
4501 | case ISCSI_OP_NOOP_OUT: | 4024 | case ISCSI_OP_NOOP_OUT: |
4502 | if (task->hdr->ttt != ISCSI_RESERVED_TAG) { | 4025 | if (task->hdr->ttt != ISCSI_RESERVED_TAG) { |
4503 | ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); | 4026 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, |
4504 | if (chip_skh_r(phba->pcidev)) | 4027 | TGT_DM_CMD); |
4505 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | 4028 | AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, |
4506 | dmsg, pwrb, 1); | 4029 | pwrb, 0); |
4507 | else | 4030 | AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); |
4508 | AMAP_SET_BITS(struct amap_iscsi_wrb, | ||
4509 | dmsg, pwrb, 1); | ||
4510 | } else { | 4031 | } else { |
4511 | ADAPTER_SET_WRB_TYPE(pwrb, INI_RD_CMD, pwrb_typeoffset); | 4032 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, |
4512 | if (chip_skh_r(phba->pcidev)) | 4033 | INI_RD_CMD); |
4513 | AMAP_SET_BITS(struct amap_iscsi_wrb_v2, | 4034 | AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 1); |
4514 | dmsg, pwrb, 0); | ||
4515 | else | ||
4516 | AMAP_SET_BITS(struct amap_iscsi_wrb, | ||
4517 | dmsg, pwrb, 0); | ||
4518 | } | 4035 | } |
4519 | hwi_write_buffer(pwrb, task); | 4036 | hwi_write_buffer(pwrb, task); |
4520 | break; | 4037 | break; |
4521 | case ISCSI_OP_TEXT: | 4038 | case ISCSI_OP_TEXT: |
4522 | ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); | 4039 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, |
4040 | TGT_DM_CMD); | ||
4041 | AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); | ||
4523 | hwi_write_buffer(pwrb, task); | 4042 | hwi_write_buffer(pwrb, task); |
4524 | break; | 4043 | break; |
4525 | case ISCSI_OP_SCSI_TMFUNC: | 4044 | case ISCSI_OP_SCSI_TMFUNC: |
4526 | ADAPTER_SET_WRB_TYPE(pwrb, INI_TMF_CMD, pwrb_typeoffset); | 4045 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, |
4046 | INI_TMF_CMD); | ||
4047 | AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); | ||
4527 | hwi_write_buffer(pwrb, task); | 4048 | hwi_write_buffer(pwrb, task); |
4528 | break; | 4049 | break; |
4529 | case ISCSI_OP_LOGOUT: | 4050 | case ISCSI_OP_LOGOUT: |
4530 | ADAPTER_SET_WRB_TYPE(pwrb, HWH_TYPE_LOGOUT, pwrb_typeoffset); | 4051 | AMAP_SET_BITS(struct amap_iscsi_wrb, dmsg, pwrb, 0); |
4052 | AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, | ||
4053 | HWH_TYPE_LOGOUT); | ||
4531 | hwi_write_buffer(pwrb, task); | 4054 | hwi_write_buffer(pwrb, task); |
4532 | break; | 4055 | break; |
4533 | 4056 | ||
4534 | default: | 4057 | default: |
4535 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 4058 | SE_DEBUG(DBG_LVL_1, "opcode =%d Not supported\n", |
4536 | "BM_%d : opcode =%d Not supported\n", | 4059 | task->hdr->opcode & ISCSI_OPCODE_MASK); |
4537 | task->hdr->opcode & ISCSI_OPCODE_MASK); | ||
4538 | |||
4539 | return -EINVAL; | 4060 | return -EINVAL; |
4540 | } | 4061 | } |
4541 | 4062 | ||
4542 | /* Set the task type */ | 4063 | AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, |
4543 | io_task->wrb_type = (chip_skh_r(phba->pcidev)) ? | 4064 | task->data_count); |
4544 | AMAP_GET_BITS(struct amap_iscsi_wrb_v2, type, pwrb) : | 4065 | AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb, |
4545 | AMAP_GET_BITS(struct amap_iscsi_wrb, type, pwrb); | 4066 | io_task->pwrb_handle->nxt_wrb_index); |
4067 | be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_wrb)); | ||
4546 | 4068 | ||
4547 | doorbell |= cid & DB_WRB_POST_CID_MASK; | 4069 | doorbell |= cid & DB_WRB_POST_CID_MASK; |
4548 | doorbell |= (io_task->pwrb_handle->wrb_index & | 4070 | doorbell |= (io_task->pwrb_handle->wrb_index & |
@@ -4556,138 +4078,45 @@ static int beiscsi_task_xmit(struct iscsi_task *task) | |||
4556 | { | 4078 | { |
4557 | struct beiscsi_io_task *io_task = task->dd_data; | 4079 | struct beiscsi_io_task *io_task = task->dd_data; |
4558 | struct scsi_cmnd *sc = task->sc; | 4080 | struct scsi_cmnd *sc = task->sc; |
4559 | struct beiscsi_hba *phba = NULL; | ||
4560 | struct scatterlist *sg; | 4081 | struct scatterlist *sg; |
4561 | int num_sg; | 4082 | int num_sg; |
4562 | unsigned int writedir = 0, xferlen = 0; | 4083 | unsigned int writedir = 0, xferlen = 0; |
4563 | 4084 | ||
4564 | phba = ((struct beiscsi_conn *)task->conn->dd_data)->phba; | ||
4565 | |||
4566 | if (!sc) | 4085 | if (!sc) |
4567 | return beiscsi_mtask(task); | 4086 | return beiscsi_mtask(task); |
4568 | 4087 | ||
4569 | io_task->scsi_cmnd = sc; | 4088 | io_task->scsi_cmnd = sc; |
4570 | num_sg = scsi_dma_map(sc); | 4089 | num_sg = scsi_dma_map(sc); |
4571 | if (num_sg < 0) { | 4090 | if (num_sg < 0) { |
4572 | struct iscsi_conn *conn = task->conn; | 4091 | SE_DEBUG(DBG_LVL_1, " scsi_dma_map Failed\n") |
4573 | struct beiscsi_hba *phba = NULL; | ||
4574 | |||
4575 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; | ||
4576 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_IO, | ||
4577 | "BM_%d : scsi_dma_map Failed\n"); | ||
4578 | |||
4579 | return num_sg; | 4092 | return num_sg; |
4580 | } | 4093 | } |
4581 | xferlen = scsi_bufflen(sc); | 4094 | xferlen = scsi_bufflen(sc); |
4582 | sg = scsi_sglist(sc); | 4095 | sg = scsi_sglist(sc); |
4583 | if (sc->sc_data_direction == DMA_TO_DEVICE) | 4096 | if (sc->sc_data_direction == DMA_TO_DEVICE) { |
4584 | writedir = 1; | 4097 | writedir = 1; |
4585 | else | 4098 | SE_DEBUG(DBG_LVL_4, "task->imm_count=0x%08x\n", |
4099 | task->imm_count); | ||
4100 | } else | ||
4586 | writedir = 0; | 4101 | writedir = 0; |
4587 | 4102 | return beiscsi_iotask(task, sg, num_sg, xferlen, writedir); | |
4588 | return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); | ||
4589 | } | ||
4590 | |||
4591 | /** | ||
4592 | * beiscsi_bsg_request - handle bsg request from ISCSI transport | ||
4593 | * @job: job to handle | ||
4594 | */ | ||
4595 | static int beiscsi_bsg_request(struct bsg_job *job) | ||
4596 | { | ||
4597 | struct Scsi_Host *shost; | ||
4598 | struct beiscsi_hba *phba; | ||
4599 | struct iscsi_bsg_request *bsg_req = job->request; | ||
4600 | int rc = -EINVAL; | ||
4601 | unsigned int tag; | ||
4602 | struct be_dma_mem nonemb_cmd; | ||
4603 | struct be_cmd_resp_hdr *resp; | ||
4604 | struct iscsi_bsg_reply *bsg_reply = job->reply; | ||
4605 | unsigned short status, extd_status; | ||
4606 | |||
4607 | shost = iscsi_job_to_shost(job); | ||
4608 | phba = iscsi_host_priv(shost); | ||
4609 | |||
4610 | switch (bsg_req->msgcode) { | ||
4611 | case ISCSI_BSG_HST_VENDOR: | ||
4612 | nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, | ||
4613 | job->request_payload.payload_len, | ||
4614 | &nonemb_cmd.dma); | ||
4615 | if (nonemb_cmd.va == NULL) { | ||
4616 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
4617 | "BM_%d : Failed to allocate memory for " | ||
4618 | "beiscsi_bsg_request\n"); | ||
4619 | return -ENOMEM; | ||
4620 | } | ||
4621 | tag = mgmt_vendor_specific_fw_cmd(&phba->ctrl, phba, job, | ||
4622 | &nonemb_cmd); | ||
4623 | if (!tag) { | ||
4624 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
4625 | "BM_%d : MBX Tag Allocation Failed\n"); | ||
4626 | |||
4627 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | ||
4628 | nonemb_cmd.va, nonemb_cmd.dma); | ||
4629 | return -EAGAIN; | ||
4630 | } | ||
4631 | |||
4632 | rc = wait_event_interruptible_timeout( | ||
4633 | phba->ctrl.mcc_wait[tag], | ||
4634 | phba->ctrl.mcc_numtag[tag], | ||
4635 | msecs_to_jiffies( | ||
4636 | BEISCSI_HOST_MBX_TIMEOUT)); | ||
4637 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; | ||
4638 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; | ||
4639 | free_mcc_tag(&phba->ctrl, tag); | ||
4640 | resp = (struct be_cmd_resp_hdr *)nonemb_cmd.va; | ||
4641 | sg_copy_from_buffer(job->reply_payload.sg_list, | ||
4642 | job->reply_payload.sg_cnt, | ||
4643 | nonemb_cmd.va, (resp->response_length | ||
4644 | + sizeof(*resp))); | ||
4645 | bsg_reply->reply_payload_rcv_len = resp->response_length; | ||
4646 | bsg_reply->result = status; | ||
4647 | bsg_job_done(job, bsg_reply->result, | ||
4648 | bsg_reply->reply_payload_rcv_len); | ||
4649 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, | ||
4650 | nonemb_cmd.va, nonemb_cmd.dma); | ||
4651 | if (status || extd_status) { | ||
4652 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
4653 | "BM_%d : MBX Cmd Failed" | ||
4654 | " status = %d extd_status = %d\n", | ||
4655 | status, extd_status); | ||
4656 | |||
4657 | return -EIO; | ||
4658 | } else { | ||
4659 | rc = 0; | ||
4660 | } | ||
4661 | break; | ||
4662 | |||
4663 | default: | ||
4664 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
4665 | "BM_%d : Unsupported bsg command: 0x%x\n", | ||
4666 | bsg_req->msgcode); | ||
4667 | break; | ||
4668 | } | ||
4669 | |||
4670 | return rc; | ||
4671 | } | 4103 | } |
4672 | 4104 | ||
4673 | void beiscsi_hba_attrs_init(struct beiscsi_hba *phba) | 4105 | static void beiscsi_remove(struct pci_dev *pcidev) |
4674 | { | ||
4675 | /* Set the logging parameter */ | ||
4676 | beiscsi_log_enable_init(phba, beiscsi_log_enable); | ||
4677 | } | ||
4678 | |||
4679 | /* | ||
4680 | * beiscsi_quiesce()- Cleanup Driver resources | ||
4681 | * @phba: Instance Priv structure | ||
4682 | * | ||
4683 | * Free the OS and HW resources held by the driver | ||
4684 | **/ | ||
4685 | static void beiscsi_quiesce(struct beiscsi_hba *phba) | ||
4686 | { | 4106 | { |
4107 | struct beiscsi_hba *phba = NULL; | ||
4687 | struct hwi_controller *phwi_ctrlr; | 4108 | struct hwi_controller *phwi_ctrlr; |
4688 | struct hwi_context_memory *phwi_context; | 4109 | struct hwi_context_memory *phwi_context; |
4689 | struct be_eq_obj *pbe_eq; | 4110 | struct be_eq_obj *pbe_eq; |
4690 | unsigned int i, msix_vec; | 4111 | unsigned int i, msix_vec; |
4112 | u8 *real_offset = 0; | ||
4113 | u32 value = 0; | ||
4114 | |||
4115 | phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev); | ||
4116 | if (!phba) { | ||
4117 | dev_err(&pcidev->dev, "beiscsi_remove called with no phba\n"); | ||
4118 | return; | ||
4119 | } | ||
4691 | 4120 | ||
4692 | phwi_ctrlr = phba->phwi_ctrlr; | 4121 | phwi_ctrlr = phba->phwi_ctrlr; |
4693 | phwi_context = phwi_ctrlr->phwi_ctxt; | 4122 | phwi_context = phwi_ctrlr->phwi_ctxt; |
@@ -4696,7 +4125,6 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba) | |||
4696 | for (i = 0; i <= phba->num_cpus; i++) { | 4125 | for (i = 0; i <= phba->num_cpus; i++) { |
4697 | msix_vec = phba->msix_entries[i].vector; | 4126 | msix_vec = phba->msix_entries[i].vector; |
4698 | free_irq(msix_vec, &phwi_context->be_eq[i]); | 4127 | free_irq(msix_vec, &phwi_context->be_eq[i]); |
4699 | kfree(phba->msi_name[i]); | ||
4700 | } | 4128 | } |
4701 | } else | 4129 | } else |
4702 | if (phba->pcidev->irq) | 4130 | if (phba->pcidev->irq) |
@@ -4711,49 +4139,23 @@ static void beiscsi_quiesce(struct beiscsi_hba *phba) | |||
4711 | 4139 | ||
4712 | beiscsi_clean_port(phba); | 4140 | beiscsi_clean_port(phba); |
4713 | beiscsi_free_mem(phba); | 4141 | beiscsi_free_mem(phba); |
4142 | real_offset = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE; | ||
4714 | 4143 | ||
4144 | value = readl((void *)real_offset); | ||
4145 | |||
4146 | if (value & 0x00010000) { | ||
4147 | value &= 0xfffeffff; | ||
4148 | writel(value, (void *)real_offset); | ||
4149 | } | ||
4715 | beiscsi_unmap_pci_function(phba); | 4150 | beiscsi_unmap_pci_function(phba); |
4716 | pci_free_consistent(phba->pcidev, | 4151 | pci_free_consistent(phba->pcidev, |
4717 | phba->ctrl.mbox_mem_alloced.size, | 4152 | phba->ctrl.mbox_mem_alloced.size, |
4718 | phba->ctrl.mbox_mem_alloced.va, | 4153 | phba->ctrl.mbox_mem_alloced.va, |
4719 | phba->ctrl.mbox_mem_alloced.dma); | 4154 | phba->ctrl.mbox_mem_alloced.dma); |
4720 | |||
4721 | cancel_delayed_work_sync(&phba->beiscsi_hw_check_task); | ||
4722 | } | ||
4723 | |||
4724 | static void beiscsi_remove(struct pci_dev *pcidev) | ||
4725 | { | ||
4726 | |||
4727 | struct beiscsi_hba *phba = NULL; | ||
4728 | |||
4729 | phba = pci_get_drvdata(pcidev); | ||
4730 | if (!phba) { | ||
4731 | dev_err(&pcidev->dev, "beiscsi_remove called with no phba\n"); | ||
4732 | return; | ||
4733 | } | ||
4734 | |||
4735 | beiscsi_destroy_def_ifaces(phba); | ||
4736 | beiscsi_quiesce(phba); | ||
4737 | iscsi_boot_destroy_kset(phba->boot_kset); | 4155 | iscsi_boot_destroy_kset(phba->boot_kset); |
4738 | iscsi_host_remove(phba->shost); | 4156 | iscsi_host_remove(phba->shost); |
4739 | pci_dev_put(phba->pcidev); | 4157 | pci_dev_put(phba->pcidev); |
4740 | iscsi_host_free(phba->shost); | 4158 | iscsi_host_free(phba->shost); |
4741 | pci_disable_device(pcidev); | ||
4742 | } | ||
4743 | |||
4744 | static void beiscsi_shutdown(struct pci_dev *pcidev) | ||
4745 | { | ||
4746 | |||
4747 | struct beiscsi_hba *phba = NULL; | ||
4748 | |||
4749 | phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev); | ||
4750 | if (!phba) { | ||
4751 | dev_err(&pcidev->dev, "beiscsi_shutdown called with no phba\n"); | ||
4752 | return; | ||
4753 | } | ||
4754 | |||
4755 | beiscsi_quiesce(phba); | ||
4756 | pci_disable_device(pcidev); | ||
4757 | } | 4159 | } |
4758 | 4160 | ||
4759 | static void beiscsi_msix_enable(struct beiscsi_hba *phba) | 4161 | static void beiscsi_msix_enable(struct beiscsi_hba *phba) |
@@ -4771,107 +4173,86 @@ static void beiscsi_msix_enable(struct beiscsi_hba *phba) | |||
4771 | return; | 4173 | return; |
4772 | } | 4174 | } |
4773 | 4175 | ||
4774 | /* | 4176 | static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev, |
4775 | * beiscsi_hw_health_check()- Check adapter health | 4177 | const struct pci_device_id *id) |
4776 | * @work: work item to check HW health | ||
4777 | * | ||
4778 | * Check if adapter in an unrecoverable state or not. | ||
4779 | **/ | ||
4780 | static void | ||
4781 | beiscsi_hw_health_check(struct work_struct *work) | ||
4782 | { | ||
4783 | struct beiscsi_hba *phba = | ||
4784 | container_of(work, struct beiscsi_hba, | ||
4785 | beiscsi_hw_check_task.work); | ||
4786 | |||
4787 | beiscsi_ue_detect(phba); | ||
4788 | |||
4789 | schedule_delayed_work(&phba->beiscsi_hw_check_task, | ||
4790 | msecs_to_jiffies(1000)); | ||
4791 | } | ||
4792 | |||
4793 | static int beiscsi_dev_probe(struct pci_dev *pcidev, | ||
4794 | const struct pci_device_id *id) | ||
4795 | { | 4178 | { |
4796 | struct beiscsi_hba *phba = NULL; | 4179 | struct beiscsi_hba *phba = NULL; |
4797 | struct hwi_controller *phwi_ctrlr; | 4180 | struct hwi_controller *phwi_ctrlr; |
4798 | struct hwi_context_memory *phwi_context; | 4181 | struct hwi_context_memory *phwi_context; |
4799 | struct be_eq_obj *pbe_eq; | 4182 | struct be_eq_obj *pbe_eq; |
4800 | int ret, i; | 4183 | int ret, num_cpus, i; |
4184 | u8 *real_offset = 0; | ||
4185 | u32 value = 0; | ||
4801 | 4186 | ||
4802 | ret = beiscsi_enable_pci(pcidev); | 4187 | ret = beiscsi_enable_pci(pcidev); |
4803 | if (ret < 0) { | 4188 | if (ret < 0) { |
4804 | dev_err(&pcidev->dev, | 4189 | dev_err(&pcidev->dev, "beiscsi_dev_probe-" |
4805 | "beiscsi_dev_probe - Failed to enable pci device\n"); | 4190 | " Failed to enable pci device\n"); |
4806 | return ret; | 4191 | return ret; |
4807 | } | 4192 | } |
4808 | 4193 | ||
4809 | phba = beiscsi_hba_alloc(pcidev); | 4194 | phba = beiscsi_hba_alloc(pcidev); |
4810 | if (!phba) { | 4195 | if (!phba) { |
4811 | dev_err(&pcidev->dev, | 4196 | dev_err(&pcidev->dev, "beiscsi_dev_probe-" |
4812 | "beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n"); | 4197 | " Failed in beiscsi_hba_alloc\n"); |
4813 | goto disable_pci; | 4198 | goto disable_pci; |
4814 | } | 4199 | } |
4815 | 4200 | ||
4816 | /* Initialize Driver configuration Paramters */ | ||
4817 | beiscsi_hba_attrs_init(phba); | ||
4818 | |||
4819 | phba->fw_timeout = false; | ||
4820 | |||
4821 | |||
4822 | switch (pcidev->device) { | 4201 | switch (pcidev->device) { |
4823 | case BE_DEVICE_ID1: | 4202 | case BE_DEVICE_ID1: |
4824 | case OC_DEVICE_ID1: | 4203 | case OC_DEVICE_ID1: |
4825 | case OC_DEVICE_ID2: | 4204 | case OC_DEVICE_ID2: |
4826 | phba->generation = BE_GEN2; | 4205 | phba->generation = BE_GEN2; |
4827 | phba->iotask_fn = beiscsi_iotask; | ||
4828 | break; | 4206 | break; |
4829 | case BE_DEVICE_ID2: | 4207 | case BE_DEVICE_ID2: |
4830 | case OC_DEVICE_ID3: | 4208 | case OC_DEVICE_ID3: |
4831 | phba->generation = BE_GEN3; | 4209 | phba->generation = BE_GEN3; |
4832 | phba->iotask_fn = beiscsi_iotask; | ||
4833 | break; | 4210 | break; |
4834 | case OC_SKH_ID1: | ||
4835 | phba->generation = BE_GEN4; | ||
4836 | phba->iotask_fn = beiscsi_iotask_v2; | ||
4837 | default: | 4211 | default: |
4838 | phba->generation = 0; | 4212 | phba->generation = 0; |
4839 | } | 4213 | } |
4840 | 4214 | ||
4841 | if (enable_msix) | 4215 | if (enable_msix) |
4842 | find_num_cpus(phba); | 4216 | num_cpus = find_num_cpus(); |
4843 | else | 4217 | else |
4844 | phba->num_cpus = 1; | 4218 | num_cpus = 1; |
4845 | 4219 | phba->num_cpus = num_cpus; | |
4846 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 4220 | SE_DEBUG(DBG_LVL_8, "num_cpus = %d\n", phba->num_cpus); |
4847 | "BM_%d : num_cpus = %d\n", | ||
4848 | phba->num_cpus); | ||
4849 | 4221 | ||
4850 | if (enable_msix) { | 4222 | if (enable_msix) |
4851 | beiscsi_msix_enable(phba); | 4223 | beiscsi_msix_enable(phba); |
4852 | if (!phba->msix_enabled) | ||
4853 | phba->num_cpus = 1; | ||
4854 | } | ||
4855 | ret = be_ctrl_init(phba, pcidev); | 4224 | ret = be_ctrl_init(phba, pcidev); |
4856 | if (ret) { | 4225 | if (ret) { |
4857 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4226 | shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-" |
4858 | "BM_%d : beiscsi_dev_probe-" | 4227 | "Failed in be_ctrl_init\n"); |
4859 | "Failed in be_ctrl_init\n"); | ||
4860 | goto hba_free; | 4228 | goto hba_free; |
4861 | } | 4229 | } |
4862 | 4230 | ||
4863 | ret = beiscsi_cmd_reset_function(phba); | 4231 | if (!num_hba) { |
4864 | if (ret) { | 4232 | real_offset = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE; |
4865 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4233 | value = readl((void *)real_offset); |
4866 | "BM_%d : Reset Failed. Aborting Crashdump\n"); | 4234 | if (value & 0x00010000) { |
4867 | goto hba_free; | 4235 | gcrashmode++; |
4868 | } | 4236 | shost_printk(KERN_ERR, phba->shost, |
4869 | ret = be_chk_reset_complete(phba); | 4237 | "Loading Driver in crashdump mode\n"); |
4870 | if (ret) { | 4238 | ret = beiscsi_pci_soft_reset(phba); |
4871 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4239 | if (ret) { |
4872 | "BM_%d : Failed to get out of reset." | 4240 | shost_printk(KERN_ERR, phba->shost, |
4873 | "Aborting Crashdump\n"); | 4241 | "Reset Failed. Aborting Crashdump\n"); |
4874 | goto hba_free; | 4242 | goto hba_free; |
4243 | } | ||
4244 | ret = be_chk_reset_complete(phba); | ||
4245 | if (ret) { | ||
4246 | shost_printk(KERN_ERR, phba->shost, | ||
4247 | "Failed to get out of reset." | ||
4248 | "Aborting Crashdump\n"); | ||
4249 | goto hba_free; | ||
4250 | } | ||
4251 | } else { | ||
4252 | value |= 0x00010000; | ||
4253 | writel(value, (void *)real_offset); | ||
4254 | num_hba++; | ||
4255 | } | ||
4875 | } | 4256 | } |
4876 | 4257 | ||
4877 | spin_lock_init(&phba->io_sgl_lock); | 4258 | spin_lock_init(&phba->io_sgl_lock); |
@@ -4879,8 +4260,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, | |||
4879 | spin_lock_init(&phba->isr_lock); | 4260 | spin_lock_init(&phba->isr_lock); |
4880 | ret = mgmt_get_fw_config(&phba->ctrl, phba); | 4261 | ret = mgmt_get_fw_config(&phba->ctrl, phba); |
4881 | if (ret != 0) { | 4262 | if (ret != 0) { |
4882 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4263 | shost_printk(KERN_ERR, phba->shost, |
4883 | "BM_%d : Error getting fw config\n"); | 4264 | "Error getting fw config\n"); |
4884 | goto free_port; | 4265 | goto free_port; |
4885 | } | 4266 | } |
4886 | phba->shost->max_id = phba->fw_config.iscsi_cid_count; | 4267 | phba->shost->max_id = phba->fw_config.iscsi_cid_count; |
@@ -4888,9 +4269,8 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, | |||
4888 | phba->shost->can_queue = phba->params.ios_per_ctrl; | 4269 | phba->shost->can_queue = phba->params.ios_per_ctrl; |
4889 | ret = beiscsi_init_port(phba); | 4270 | ret = beiscsi_init_port(phba); |
4890 | if (ret < 0) { | 4271 | if (ret < 0) { |
4891 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4272 | shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-" |
4892 | "BM_%d : beiscsi_dev_probe-" | 4273 | "Failed in beiscsi_init_port\n"); |
4893 | "Failed in beiscsi_init_port\n"); | ||
4894 | goto free_port; | 4274 | goto free_port; |
4895 | } | 4275 | } |
4896 | 4276 | ||
@@ -4903,22 +4283,19 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, | |||
4903 | 4283 | ||
4904 | phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0; | 4284 | phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0; |
4905 | 4285 | ||
4906 | snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_%02x_wq", | 4286 | snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_q_irq%u", |
4907 | phba->shost->host_no); | 4287 | phba->shost->host_no); |
4908 | phba->wq = alloc_workqueue(phba->wq_name, WQ_MEM_RECLAIM, 1); | 4288 | phba->wq = alloc_workqueue(phba->wq_name, WQ_MEM_RECLAIM, 1); |
4909 | if (!phba->wq) { | 4289 | if (!phba->wq) { |
4910 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4290 | shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-" |
4911 | "BM_%d : beiscsi_dev_probe-" | 4291 | "Failed to allocate work queue\n"); |
4912 | "Failed to allocate work queue\n"); | ||
4913 | goto free_twq; | 4292 | goto free_twq; |
4914 | } | 4293 | } |
4915 | 4294 | ||
4916 | INIT_DELAYED_WORK(&phba->beiscsi_hw_check_task, | 4295 | INIT_WORK(&phba->work_cqs, beiscsi_process_all_cqs); |
4917 | beiscsi_hw_health_check); | ||
4918 | 4296 | ||
4919 | phwi_ctrlr = phba->phwi_ctrlr; | 4297 | phwi_ctrlr = phba->phwi_ctrlr; |
4920 | phwi_context = phwi_ctrlr->phwi_ctxt; | 4298 | phwi_context = phwi_ctrlr->phwi_ctxt; |
4921 | |||
4922 | if (blk_iopoll_enabled) { | 4299 | if (blk_iopoll_enabled) { |
4923 | for (i = 0; i < phba->num_cpus; i++) { | 4300 | for (i = 0; i < phba->num_cpus; i++) { |
4924 | pbe_eq = &phwi_context->be_eq[i]; | 4301 | pbe_eq = &phwi_context->be_eq[i]; |
@@ -4926,30 +4303,11 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, | |||
4926 | be_iopoll); | 4303 | be_iopoll); |
4927 | blk_iopoll_enable(&pbe_eq->iopoll); | 4304 | blk_iopoll_enable(&pbe_eq->iopoll); |
4928 | } | 4305 | } |
4929 | |||
4930 | i = (phba->msix_enabled) ? i : 0; | ||
4931 | /* Work item for MCC handling */ | ||
4932 | pbe_eq = &phwi_context->be_eq[i]; | ||
4933 | INIT_WORK(&pbe_eq->work_cqs, beiscsi_process_all_cqs); | ||
4934 | } else { | ||
4935 | if (phba->msix_enabled) { | ||
4936 | for (i = 0; i <= phba->num_cpus; i++) { | ||
4937 | pbe_eq = &phwi_context->be_eq[i]; | ||
4938 | INIT_WORK(&pbe_eq->work_cqs, | ||
4939 | beiscsi_process_all_cqs); | ||
4940 | } | ||
4941 | } else { | ||
4942 | pbe_eq = &phwi_context->be_eq[0]; | ||
4943 | INIT_WORK(&pbe_eq->work_cqs, | ||
4944 | beiscsi_process_all_cqs); | ||
4945 | } | ||
4946 | } | 4306 | } |
4947 | |||
4948 | ret = beiscsi_init_irqs(phba); | 4307 | ret = beiscsi_init_irqs(phba); |
4949 | if (ret < 0) { | 4308 | if (ret < 0) { |
4950 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4309 | shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-" |
4951 | "BM_%d : beiscsi_dev_probe-" | 4310 | "Failed to beiscsi_init_irqs\n"); |
4952 | "Failed to beiscsi_init_irqs\n"); | ||
4953 | goto free_blkenbld; | 4311 | goto free_blkenbld; |
4954 | } | 4312 | } |
4955 | hwi_enable_intr(phba); | 4313 | hwi_enable_intr(phba); |
@@ -4959,16 +4317,10 @@ static int beiscsi_dev_probe(struct pci_dev *pcidev, | |||
4959 | * log error but continue, because we may not be using | 4317 | * log error but continue, because we may not be using |
4960 | * iscsi boot. | 4318 | * iscsi boot. |
4961 | */ | 4319 | */ |
4962 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4320 | shost_printk(KERN_ERR, phba->shost, "Could not set up " |
4963 | "BM_%d : Could not set up " | 4321 | "iSCSI boot info."); |
4964 | "iSCSI boot info.\n"); | ||
4965 | |||
4966 | beiscsi_create_def_ifaces(phba); | ||
4967 | schedule_delayed_work(&phba->beiscsi_hw_check_task, | ||
4968 | msecs_to_jiffies(1000)); | ||
4969 | 4322 | ||
4970 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 4323 | SE_DEBUG(DBG_LVL_8, "\n\n\n SUCCESS - DRIVER LOADED\n\n\n"); |
4971 | "\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n"); | ||
4972 | return 0; | 4324 | return 0; |
4973 | 4325 | ||
4974 | free_blkenbld: | 4326 | free_blkenbld: |
@@ -4982,6 +4334,15 @@ free_twq: | |||
4982 | beiscsi_clean_port(phba); | 4334 | beiscsi_clean_port(phba); |
4983 | beiscsi_free_mem(phba); | 4335 | beiscsi_free_mem(phba); |
4984 | free_port: | 4336 | free_port: |
4337 | real_offset = (u8 *)phba->csr_va + MPU_EP_SEMAPHORE; | ||
4338 | |||
4339 | value = readl((void *)real_offset); | ||
4340 | |||
4341 | if (value & 0x00010000) { | ||
4342 | value &= 0xfffeffff; | ||
4343 | writel(value, (void *)real_offset); | ||
4344 | } | ||
4345 | |||
4985 | pci_free_consistent(phba->pcidev, | 4346 | pci_free_consistent(phba->pcidev, |
4986 | phba->ctrl.mbox_mem_alloced.size, | 4347 | phba->ctrl.mbox_mem_alloced.size, |
4987 | phba->ctrl.mbox_mem_alloced.va, | 4348 | phba->ctrl.mbox_mem_alloced.va, |
@@ -5003,14 +4364,37 @@ struct iscsi_transport beiscsi_iscsi_transport = { | |||
5003 | .name = DRV_NAME, | 4364 | .name = DRV_NAME, |
5004 | .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_TEXT_NEGO | | 4365 | .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_TEXT_NEGO | |
5005 | CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD, | 4366 | CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD, |
4367 | .param_mask = ISCSI_MAX_RECV_DLENGTH | | ||
4368 | ISCSI_MAX_XMIT_DLENGTH | | ||
4369 | ISCSI_HDRDGST_EN | | ||
4370 | ISCSI_DATADGST_EN | | ||
4371 | ISCSI_INITIAL_R2T_EN | | ||
4372 | ISCSI_MAX_R2T | | ||
4373 | ISCSI_IMM_DATA_EN | | ||
4374 | ISCSI_FIRST_BURST | | ||
4375 | ISCSI_MAX_BURST | | ||
4376 | ISCSI_PDU_INORDER_EN | | ||
4377 | ISCSI_DATASEQ_INORDER_EN | | ||
4378 | ISCSI_ERL | | ||
4379 | ISCSI_CONN_PORT | | ||
4380 | ISCSI_CONN_ADDRESS | | ||
4381 | ISCSI_EXP_STATSN | | ||
4382 | ISCSI_PERSISTENT_PORT | | ||
4383 | ISCSI_PERSISTENT_ADDRESS | | ||
4384 | ISCSI_TARGET_NAME | ISCSI_TPGT | | ||
4385 | ISCSI_USERNAME | ISCSI_PASSWORD | | ||
4386 | ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN | | ||
4387 | ISCSI_FAST_ABORT | ISCSI_ABORT_TMO | | ||
4388 | ISCSI_LU_RESET_TMO | | ||
4389 | ISCSI_PING_TMO | ISCSI_RECV_TMO | | ||
4390 | ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME, | ||
4391 | .host_param_mask = ISCSI_HOST_HWADDRESS | ISCSI_HOST_IPADDRESS | | ||
4392 | ISCSI_HOST_INITIATOR_NAME, | ||
5006 | .create_session = beiscsi_session_create, | 4393 | .create_session = beiscsi_session_create, |
5007 | .destroy_session = beiscsi_session_destroy, | 4394 | .destroy_session = beiscsi_session_destroy, |
5008 | .create_conn = beiscsi_conn_create, | 4395 | .create_conn = beiscsi_conn_create, |
5009 | .bind_conn = beiscsi_conn_bind, | 4396 | .bind_conn = beiscsi_conn_bind, |
5010 | .destroy_conn = iscsi_conn_teardown, | 4397 | .destroy_conn = iscsi_conn_teardown, |
5011 | .attr_is_visible = be2iscsi_attr_is_visible, | ||
5012 | .set_iface_param = be2iscsi_iface_set_param, | ||
5013 | .get_iface_param = be2iscsi_iface_get_param, | ||
5014 | .set_param = beiscsi_set_param, | 4398 | .set_param = beiscsi_set_param, |
5015 | .get_conn_param = iscsi_conn_get_param, | 4399 | .get_conn_param = iscsi_conn_get_param, |
5016 | .get_session_param = iscsi_session_get_param, | 4400 | .get_session_param = iscsi_session_get_param, |
@@ -5028,14 +4412,12 @@ struct iscsi_transport beiscsi_iscsi_transport = { | |||
5028 | .ep_poll = beiscsi_ep_poll, | 4412 | .ep_poll = beiscsi_ep_poll, |
5029 | .ep_disconnect = beiscsi_ep_disconnect, | 4413 | .ep_disconnect = beiscsi_ep_disconnect, |
5030 | .session_recovery_timedout = iscsi_session_recovery_timedout, | 4414 | .session_recovery_timedout = iscsi_session_recovery_timedout, |
5031 | .bsg_request = beiscsi_bsg_request, | ||
5032 | }; | 4415 | }; |
5033 | 4416 | ||
5034 | static struct pci_driver beiscsi_pci_driver = { | 4417 | static struct pci_driver beiscsi_pci_driver = { |
5035 | .name = DRV_NAME, | 4418 | .name = DRV_NAME, |
5036 | .probe = beiscsi_dev_probe, | 4419 | .probe = beiscsi_dev_probe, |
5037 | .remove = beiscsi_remove, | 4420 | .remove = beiscsi_remove, |
5038 | .shutdown = beiscsi_shutdown, | ||
5039 | .id_table = beiscsi_pci_id_table | 4421 | .id_table = beiscsi_pci_id_table |
5040 | }; | 4422 | }; |
5041 | 4423 | ||
@@ -5047,17 +4429,19 @@ static int __init beiscsi_module_init(void) | |||
5047 | beiscsi_scsi_transport = | 4429 | beiscsi_scsi_transport = |
5048 | iscsi_register_transport(&beiscsi_iscsi_transport); | 4430 | iscsi_register_transport(&beiscsi_iscsi_transport); |
5049 | if (!beiscsi_scsi_transport) { | 4431 | if (!beiscsi_scsi_transport) { |
5050 | printk(KERN_ERR | 4432 | SE_DEBUG(DBG_LVL_1, |
5051 | "beiscsi_module_init - Unable to register beiscsi transport.\n"); | 4433 | "beiscsi_module_init - Unable to register beiscsi" |
4434 | "transport.\n"); | ||
5052 | return -ENOMEM; | 4435 | return -ENOMEM; |
5053 | } | 4436 | } |
5054 | printk(KERN_INFO "In beiscsi_module_init, tt=%p\n", | 4437 | SE_DEBUG(DBG_LVL_8, "In beiscsi_module_init, tt=%p\n", |
5055 | &beiscsi_iscsi_transport); | 4438 | &beiscsi_iscsi_transport); |
5056 | 4439 | ||
5057 | ret = pci_register_driver(&beiscsi_pci_driver); | 4440 | ret = pci_register_driver(&beiscsi_pci_driver); |
5058 | if (ret) { | 4441 | if (ret) { |
5059 | printk(KERN_ERR | 4442 | SE_DEBUG(DBG_LVL_1, |
5060 | "beiscsi_module_init - Unable to register beiscsi pci driver.\n"); | 4443 | "beiscsi_module_init - Unable to register" |
4444 | "beiscsi pci driver.\n"); | ||
5061 | goto unregister_iscsi_transport; | 4445 | goto unregister_iscsi_transport; |
5062 | } | 4446 | } |
5063 | return 0; | 4447 | return 0; |
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h index 5946577d79d..5ce5170254c 100644 --- a/drivers/scsi/be2iscsi/be_main.h +++ b/drivers/scsi/be2iscsi/be_main.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -24,8 +24,6 @@ | |||
24 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
25 | #include <linux/if_ether.h> | 25 | #include <linux/if_ether.h> |
26 | #include <linux/in.h> | 26 | #include <linux/in.h> |
27 | #include <linux/ctype.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <scsi/scsi.h> | 27 | #include <scsi/scsi.h> |
30 | #include <scsi/scsi_cmnd.h> | 28 | #include <scsi/scsi_cmnd.h> |
31 | #include <scsi/scsi_device.h> | 29 | #include <scsi/scsi_device.h> |
@@ -36,13 +34,12 @@ | |||
36 | 34 | ||
37 | #include "be.h" | 35 | #include "be.h" |
38 | #define DRV_NAME "be2iscsi" | 36 | #define DRV_NAME "be2iscsi" |
39 | #define BUILD_STR "10.0.272.0" | 37 | #define BUILD_STR "2.103.298.0" |
40 | #define BE_NAME "Emulex OneConnect" \ | 38 | #define BE_NAME "ServerEngines BladeEngine2" \ |
41 | "Open-iSCSI Driver version" BUILD_STR | 39 | "Linux iSCSI Driver version" BUILD_STR |
42 | #define DRV_DESC BE_NAME " " "Driver" | 40 | #define DRV_DESC BE_NAME " " "Driver" |
43 | 41 | ||
44 | #define BE_VENDOR_ID 0x19A2 | 42 | #define BE_VENDOR_ID 0x19A2 |
45 | #define ELX_VENDOR_ID 0x10DF | ||
46 | /* DEVICE ID's for BE2 */ | 43 | /* DEVICE ID's for BE2 */ |
47 | #define BE_DEVICE_ID1 0x212 | 44 | #define BE_DEVICE_ID1 0x212 |
48 | #define OC_DEVICE_ID1 0x702 | 45 | #define OC_DEVICE_ID1 0x702 |
@@ -52,9 +49,6 @@ | |||
52 | #define BE_DEVICE_ID2 0x222 | 49 | #define BE_DEVICE_ID2 0x222 |
53 | #define OC_DEVICE_ID3 0x712 | 50 | #define OC_DEVICE_ID3 0x712 |
54 | 51 | ||
55 | /* DEVICE ID for SKH */ | ||
56 | #define OC_SKH_ID1 0x722 | ||
57 | |||
58 | #define BE2_IO_DEPTH 1024 | 52 | #define BE2_IO_DEPTH 1024 |
59 | #define BE2_MAX_SESSIONS 256 | 53 | #define BE2_MAX_SESSIONS 256 |
60 | #define BE2_CMDS_PER_CXN 128 | 54 | #define BE2_CMDS_PER_CXN 128 |
@@ -64,11 +58,7 @@ | |||
64 | #define BE2_DEFPDU_HDR_SZ 64 | 58 | #define BE2_DEFPDU_HDR_SZ 64 |
65 | #define BE2_DEFPDU_DATA_SZ 8192 | 59 | #define BE2_DEFPDU_DATA_SZ 8192 |
66 | 60 | ||
67 | #define MAX_CPUS 64 | 61 | #define MAX_CPUS 31 |
68 | #define BEISCSI_MAX_NUM_CPUS 7 | ||
69 | #define OC_SKH_MAX_NUM_CPUS 63 | ||
70 | |||
71 | |||
72 | #define BEISCSI_SGLIST_ELEMENTS 30 | 62 | #define BEISCSI_SGLIST_ELEMENTS 30 |
73 | 63 | ||
74 | #define BEISCSI_CMD_PER_LUN 128 /* scsi_host->cmd_per_lun */ | 64 | #define BEISCSI_CMD_PER_LUN 128 /* scsi_host->cmd_per_lun */ |
@@ -94,7 +84,23 @@ | |||
94 | #define MAX_CMD_SZ 65536 | 84 | #define MAX_CMD_SZ 65536 |
95 | #define IIOC_SCSI_DATA 0x05 /* Write Operation */ | 85 | #define IIOC_SCSI_DATA 0x05 /* Write Operation */ |
96 | 86 | ||
97 | #define INVALID_SESS_HANDLE 0xFFFFFFFF | 87 | #define DBG_LVL 0x00000001 |
88 | #define DBG_LVL_1 0x00000001 | ||
89 | #define DBG_LVL_2 0x00000002 | ||
90 | #define DBG_LVL_3 0x00000004 | ||
91 | #define DBG_LVL_4 0x00000008 | ||
92 | #define DBG_LVL_5 0x00000010 | ||
93 | #define DBG_LVL_6 0x00000020 | ||
94 | #define DBG_LVL_7 0x00000040 | ||
95 | #define DBG_LVL_8 0x00000080 | ||
96 | |||
97 | #define SE_DEBUG(debug_mask, fmt, args...) \ | ||
98 | do { \ | ||
99 | if (debug_mask & DBG_LVL) { \ | ||
100 | printk(KERN_ERR "(%s():%d):", __func__, __LINE__);\ | ||
101 | printk(fmt, ##args); \ | ||
102 | } \ | ||
103 | } while (0); | ||
98 | 104 | ||
99 | #define BE_ADAPTER_UP 0x00000000 | 105 | #define BE_ADAPTER_UP 0x00000000 |
100 | #define BE_ADAPTER_LINK_DOWN 0x00000001 | 106 | #define BE_ADAPTER_LINK_DOWN 0x00000001 |
@@ -156,8 +162,6 @@ | |||
156 | #define PAGES_REQUIRED(x) \ | 162 | #define PAGES_REQUIRED(x) \ |
157 | ((x < PAGE_SIZE) ? 1 : ((x + PAGE_SIZE - 1) / PAGE_SIZE)) | 163 | ((x < PAGE_SIZE) ? 1 : ((x + PAGE_SIZE - 1) / PAGE_SIZE)) |
158 | 164 | ||
159 | #define BEISCSI_MSI_NAME 20 /* size of msi_name string */ | ||
160 | |||
161 | enum be_mem_enum { | 165 | enum be_mem_enum { |
162 | HWI_MEM_ADDN_CONTEXT, | 166 | HWI_MEM_ADDN_CONTEXT, |
163 | HWI_MEM_WRB, | 167 | HWI_MEM_WRB, |
@@ -265,7 +269,6 @@ struct invalidate_command_table { | |||
265 | unsigned short cid; | 269 | unsigned short cid; |
266 | } __packed; | 270 | } __packed; |
267 | 271 | ||
268 | #define chip_skh_r(pdev) (pdev->device == OC_SKH_ID1) | ||
269 | struct beiscsi_hba { | 272 | struct beiscsi_hba { |
270 | struct hba_parameters params; | 273 | struct hba_parameters params; |
271 | struct hwi_controller *phwi_ctrlr; | 274 | struct hwi_controller *phwi_ctrlr; |
@@ -279,11 +282,11 @@ struct beiscsi_hba { | |||
279 | struct be_bus_address pci_pa; /* CSR */ | 282 | struct be_bus_address pci_pa; /* CSR */ |
280 | /* PCI representation of our HBA */ | 283 | /* PCI representation of our HBA */ |
281 | struct pci_dev *pcidev; | 284 | struct pci_dev *pcidev; |
285 | unsigned int state; | ||
282 | unsigned short asic_revision; | 286 | unsigned short asic_revision; |
283 | unsigned int num_cpus; | 287 | unsigned int num_cpus; |
284 | unsigned int nxt_cqid; | 288 | unsigned int nxt_cqid; |
285 | struct msix_entry msix_entries[MAX_CPUS]; | 289 | struct msix_entry msix_entries[MAX_CPUS + 1]; |
286 | char *msi_name[MAX_CPUS]; | ||
287 | bool msix_enabled; | 290 | bool msix_enabled; |
288 | struct be_mem_descriptor *init_mem; | 291 | struct be_mem_descriptor *init_mem; |
289 | 292 | ||
@@ -310,8 +313,6 @@ struct beiscsi_hba { | |||
310 | struct iscsi_endpoint **ep_array; | 313 | struct iscsi_endpoint **ep_array; |
311 | struct iscsi_boot_kset *boot_kset; | 314 | struct iscsi_boot_kset *boot_kset; |
312 | struct Scsi_Host *shost; | 315 | struct Scsi_Host *shost; |
313 | struct iscsi_iface *ipv4_iface; | ||
314 | struct iscsi_iface *ipv6_iface; | ||
315 | struct { | 316 | struct { |
316 | /** | 317 | /** |
317 | * group together since they are used most frequently | 318 | * group together since they are used most frequently |
@@ -333,25 +334,18 @@ struct beiscsi_hba { | |||
333 | spinlock_t cid_lock; | 334 | spinlock_t cid_lock; |
334 | } fw_config; | 335 | } fw_config; |
335 | 336 | ||
336 | unsigned int state; | ||
337 | bool fw_timeout; | ||
338 | bool ue_detected; | ||
339 | struct delayed_work beiscsi_hw_check_task; | ||
340 | |||
341 | u8 mac_address[ETH_ALEN]; | 337 | u8 mac_address[ETH_ALEN]; |
338 | unsigned short todo_cq; | ||
339 | unsigned short todo_mcc_cq; | ||
342 | char wq_name[20]; | 340 | char wq_name[20]; |
343 | struct workqueue_struct *wq; /* The actuak work queue */ | 341 | struct workqueue_struct *wq; /* The actuak work queue */ |
342 | struct work_struct work_cqs; /* The work being queued */ | ||
344 | struct be_ctrl_info ctrl; | 343 | struct be_ctrl_info ctrl; |
345 | unsigned int generation; | 344 | unsigned int generation; |
346 | unsigned int interface_handle; | 345 | unsigned int read_mac_address; |
347 | struct mgmt_session_info boot_sess; | 346 | struct mgmt_session_info boot_sess; |
348 | struct invalidate_command_table inv_tbl[128]; | 347 | struct invalidate_command_table inv_tbl[128]; |
349 | 348 | ||
350 | unsigned int attr_log_enable; | ||
351 | int (*iotask_fn)(struct iscsi_task *, | ||
352 | struct scatterlist *sg, | ||
353 | uint32_t num_sg, uint32_t xferlen, | ||
354 | uint32_t writedir); | ||
355 | }; | 349 | }; |
356 | 350 | ||
357 | struct beiscsi_session { | 351 | struct beiscsi_session { |
@@ -423,9 +417,6 @@ struct beiscsi_io_task { | |||
423 | struct be_cmd_bhs *cmd_bhs; | 417 | struct be_cmd_bhs *cmd_bhs; |
424 | struct be_bus_address bhs_pa; | 418 | struct be_bus_address bhs_pa; |
425 | unsigned short bhs_len; | 419 | unsigned short bhs_len; |
426 | dma_addr_t mtask_addr; | ||
427 | uint32_t mtask_data_count; | ||
428 | uint8_t wrb_type; | ||
429 | }; | 420 | }; |
430 | 421 | ||
431 | struct be_nonio_bhs { | 422 | struct be_nonio_bhs { |
@@ -473,9 +464,6 @@ struct beiscsi_offload_params { | |||
473 | #define OFFLD_PARAMS_HDE 0x00000008 | 464 | #define OFFLD_PARAMS_HDE 0x00000008 |
474 | #define OFFLD_PARAMS_IR2T 0x00000010 | 465 | #define OFFLD_PARAMS_IR2T 0x00000010 |
475 | #define OFFLD_PARAMS_IMD 0x00000020 | 466 | #define OFFLD_PARAMS_IMD 0x00000020 |
476 | #define OFFLD_PARAMS_DATA_SEQ_INORDER 0x00000040 | ||
477 | #define OFFLD_PARAMS_PDU_SEQ_INORDER 0x00000080 | ||
478 | #define OFFLD_PARAMS_MAX_R2T 0x00FFFF00 | ||
479 | 467 | ||
480 | /** | 468 | /** |
481 | * Pseudo amap definition in which each bit of the actual structure is defined | 469 | * Pseudo amap definition in which each bit of the actual structure is defined |
@@ -490,10 +478,7 @@ struct amap_beiscsi_offload_params { | |||
490 | u8 hde[1]; | 478 | u8 hde[1]; |
491 | u8 ir2t[1]; | 479 | u8 ir2t[1]; |
492 | u8 imd[1]; | 480 | u8 imd[1]; |
493 | u8 data_seq_inorder[1]; | 481 | u8 pad[26]; |
494 | u8 pdu_seq_inorder[1]; | ||
495 | u8 max_r2t[16]; | ||
496 | u8 pad[8]; | ||
497 | u8 exp_statsn[32]; | 482 | u8 exp_statsn[32]; |
498 | }; | 483 | }; |
499 | 484 | ||
@@ -537,6 +522,8 @@ struct hwi_async_pdu_context { | |||
537 | 522 | ||
538 | unsigned int free_entries; | 523 | unsigned int free_entries; |
539 | unsigned int busy_entries; | 524 | unsigned int busy_entries; |
525 | unsigned int buffer_size; | ||
526 | unsigned int num_entries; | ||
540 | 527 | ||
541 | struct list_head free_list; | 528 | struct list_head free_list; |
542 | } async_header; | 529 | } async_header; |
@@ -553,12 +540,11 @@ struct hwi_async_pdu_context { | |||
553 | 540 | ||
554 | unsigned int free_entries; | 541 | unsigned int free_entries; |
555 | unsigned int busy_entries; | 542 | unsigned int busy_entries; |
543 | unsigned int buffer_size; | ||
556 | struct list_head free_list; | 544 | struct list_head free_list; |
545 | unsigned int num_entries; | ||
557 | } async_data; | 546 | } async_data; |
558 | 547 | ||
559 | unsigned int buffer_size; | ||
560 | unsigned int num_entries; | ||
561 | |||
562 | /** | 548 | /** |
563 | * This is a varying size list! Do not add anything | 549 | * This is a varying size list! Do not add anything |
564 | * after this entry!! | 550 | * after this entry!! |
@@ -591,20 +577,6 @@ struct amap_i_t_dpdu_cqe { | |||
591 | u8 valid; | 577 | u8 valid; |
592 | } __packed; | 578 | } __packed; |
593 | 579 | ||
594 | struct amap_i_t_dpdu_cqe_v2 { | ||
595 | u8 db_addr_hi[32]; /* DWORD 0 */ | ||
596 | u8 db_addr_lo[32]; /* DWORD 1 */ | ||
597 | u8 code[6]; /* DWORD 2 */ | ||
598 | u8 num_cons; /* DWORD 2*/ | ||
599 | u8 rsvd0[8]; /* DWORD 2 */ | ||
600 | u8 dpl[17]; /* DWORD 2 */ | ||
601 | u8 index[16]; /* DWORD 3 */ | ||
602 | u8 cid[13]; /* DWORD 3 */ | ||
603 | u8 rsvd1; /* DWORD 3 */ | ||
604 | u8 final; /* DWORD 3 */ | ||
605 | u8 valid; /* DWORD 3 */ | ||
606 | } __packed; | ||
607 | |||
608 | #define CQE_VALID_MASK 0x80000000 | 580 | #define CQE_VALID_MASK 0x80000000 |
609 | #define CQE_CODE_MASK 0x0000003F | 581 | #define CQE_CODE_MASK 0x0000003F |
610 | #define CQE_CID_MASK 0x0000FFC0 | 582 | #define CQE_CID_MASK 0x0000FFC0 |
@@ -653,11 +625,6 @@ struct iscsi_wrb { | |||
653 | } __packed; | 625 | } __packed; |
654 | 626 | ||
655 | #define WRB_TYPE_MASK 0xF0000000 | 627 | #define WRB_TYPE_MASK 0xF0000000 |
656 | #define SKH_WRB_TYPE_OFFSET 27 | ||
657 | #define BE_WRB_TYPE_OFFSET 28 | ||
658 | |||
659 | #define ADAPTER_SET_WRB_TYPE(pwrb, wrb_type, type_offset) \ | ||
660 | (pwrb->dw[0] |= (wrb_type << type_offset)) | ||
661 | 628 | ||
662 | /** | 629 | /** |
663 | * Pseudo amap definition in which each bit of the actual structure is defined | 630 | * Pseudo amap definition in which each bit of the actual structure is defined |
@@ -704,57 +671,12 @@ struct amap_iscsi_wrb { | |||
704 | 671 | ||
705 | } __packed; | 672 | } __packed; |
706 | 673 | ||
707 | struct amap_iscsi_wrb_v2 { | ||
708 | u8 r2t_exp_dtl[25]; /* DWORD 0 */ | ||
709 | u8 rsvd0[2]; /* DWORD 0*/ | ||
710 | u8 type[5]; /* DWORD 0 */ | ||
711 | u8 ptr2nextwrb[8]; /* DWORD 1 */ | ||
712 | u8 wrb_idx[8]; /* DWORD 1 */ | ||
713 | u8 lun[16]; /* DWORD 1 */ | ||
714 | u8 sgl_idx[16]; /* DWORD 2 */ | ||
715 | u8 ref_sgl_icd_idx[16]; /* DWORD 2 */ | ||
716 | u8 exp_data_sn[32]; /* DWORD 3 */ | ||
717 | u8 iscsi_bhs_addr_hi[32]; /* DWORD 4 */ | ||
718 | u8 iscsi_bhs_addr_lo[32]; /* DWORD 5 */ | ||
719 | u8 cq_id[16]; /* DWORD 6 */ | ||
720 | u8 rsvd1[16]; /* DWORD 6 */ | ||
721 | u8 cmdsn_itt[32]; /* DWORD 7 */ | ||
722 | u8 sge0_addr_hi[32]; /* DWORD 8 */ | ||
723 | u8 sge0_addr_lo[32]; /* DWORD 9 */ | ||
724 | u8 sge0_offset[24]; /* DWORD 10 */ | ||
725 | u8 rsvd2[7]; /* DWORD 10 */ | ||
726 | u8 sge0_last; /* DWORD 10 */ | ||
727 | u8 sge0_len[17]; /* DWORD 11 */ | ||
728 | u8 rsvd3[7]; /* DWORD 11 */ | ||
729 | u8 diff_enbl; /* DWORD 11 */ | ||
730 | u8 u_run; /* DWORD 11 */ | ||
731 | u8 o_run; /* DWORD 11 */ | ||
732 | u8 invalid; /* DWORD 11 */ | ||
733 | u8 dsp; /* DWORD 11 */ | ||
734 | u8 dmsg; /* DWORD 11 */ | ||
735 | u8 rsvd4; /* DWORD 11 */ | ||
736 | u8 lt; /* DWORD 11 */ | ||
737 | u8 sge1_addr_hi[32]; /* DWORD 12 */ | ||
738 | u8 sge1_addr_lo[32]; /* DWORD 13 */ | ||
739 | u8 sge1_r2t_offset[24]; /* DWORD 14 */ | ||
740 | u8 rsvd5[7]; /* DWORD 14 */ | ||
741 | u8 sge1_last; /* DWORD 14 */ | ||
742 | u8 sge1_len[17]; /* DWORD 15 */ | ||
743 | u8 rsvd6[15]; /* DWORD 15 */ | ||
744 | } __packed; | ||
745 | |||
746 | |||
747 | struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid); | 674 | struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid); |
748 | void | 675 | void |
749 | free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle); | 676 | free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle); |
750 | 677 | ||
751 | void beiscsi_process_all_cqs(struct work_struct *work); | 678 | void beiscsi_process_all_cqs(struct work_struct *work); |
752 | 679 | ||
753 | static inline bool beiscsi_error(struct beiscsi_hba *phba) | ||
754 | { | ||
755 | return phba->ue_detected || phba->fw_timeout; | ||
756 | } | ||
757 | |||
758 | struct pdu_nop_out { | 680 | struct pdu_nop_out { |
759 | u32 dw[12]; | 681 | u32 dw[12]; |
760 | }; | 682 | }; |
@@ -814,7 +736,6 @@ struct iscsi_target_context_update_wrb { | |||
814 | * Pseudo amap definition in which each bit of the actual structure is defined | 736 | * Pseudo amap definition in which each bit of the actual structure is defined |
815 | * as a byte: used to calculate offset/shift/mask of each field | 737 | * as a byte: used to calculate offset/shift/mask of each field |
816 | */ | 738 | */ |
817 | #define BE_TGT_CTX_UPDT_CMD 0x07 | ||
818 | struct amap_iscsi_target_context_update_wrb { | 739 | struct amap_iscsi_target_context_update_wrb { |
819 | u8 lun[14]; /* DWORD 0 */ | 740 | u8 lun[14]; /* DWORD 0 */ |
820 | u8 lt; /* DWORD 0 */ | 741 | u8 lt; /* DWORD 0 */ |
@@ -860,47 +781,6 @@ struct amap_iscsi_target_context_update_wrb { | |||
860 | 781 | ||
861 | } __packed; | 782 | } __packed; |
862 | 783 | ||
863 | #define BEISCSI_MAX_RECV_DATASEG_LEN (64 * 1024) | ||
864 | #define BEISCSI_MAX_CXNS 1 | ||
865 | struct amap_iscsi_target_context_update_wrb_v2 { | ||
866 | u8 max_burst_length[24]; /* DWORD 0 */ | ||
867 | u8 rsvd0[3]; /* DWORD 0 */ | ||
868 | u8 type[5]; /* DWORD 0 */ | ||
869 | u8 ptr2nextwrb[8]; /* DWORD 1 */ | ||
870 | u8 wrb_idx[8]; /* DWORD 1 */ | ||
871 | u8 rsvd1[16]; /* DWORD 1 */ | ||
872 | u8 max_send_data_segment_length[24]; /* DWORD 2 */ | ||
873 | u8 rsvd2[8]; /* DWORD 2 */ | ||
874 | u8 first_burst_length[24]; /* DWORD 3 */ | ||
875 | u8 rsvd3[8]; /* DOWRD 3 */ | ||
876 | u8 max_r2t[16]; /* DWORD 4 */ | ||
877 | u8 rsvd4[10]; /* DWORD 4 */ | ||
878 | u8 hde; /* DWORD 4 */ | ||
879 | u8 dde; /* DWORD 4 */ | ||
880 | u8 erl[2]; /* DWORD 4 */ | ||
881 | u8 imd; /* DWORD 4 */ | ||
882 | u8 ir2t; /* DWORD 4 */ | ||
883 | u8 stat_sn[32]; /* DWORD 5 */ | ||
884 | u8 rsvd5[32]; /* DWORD 6 */ | ||
885 | u8 rsvd6[32]; /* DWORD 7 */ | ||
886 | u8 max_recv_dataseg_len[24]; /* DWORD 8 */ | ||
887 | u8 rsvd7[8]; /* DWORD 8 */ | ||
888 | u8 rsvd8[32]; /* DWORD 9 */ | ||
889 | u8 rsvd9[32]; /* DWORD 10 */ | ||
890 | u8 max_cxns[16]; /* DWORD 11 */ | ||
891 | u8 rsvd10[11]; /* DWORD 11*/ | ||
892 | u8 invld; /* DWORD 11 */ | ||
893 | u8 rsvd11;/* DWORD 11*/ | ||
894 | u8 dmsg; /* DWORD 11 */ | ||
895 | u8 data_seq_inorder; /* DWORD 11 */ | ||
896 | u8 pdu_seq_inorder; /* DWORD 11 */ | ||
897 | u8 rsvd12[32]; /*DWORD 12 */ | ||
898 | u8 rsvd13[32]; /* DWORD 13 */ | ||
899 | u8 rsvd14[32]; /* DWORD 14 */ | ||
900 | u8 rsvd15[32]; /* DWORD 15 */ | ||
901 | } __packed; | ||
902 | |||
903 | |||
904 | struct be_ring { | 784 | struct be_ring { |
905 | u32 pages; /* queue size in pages */ | 785 | u32 pages; /* queue size in pages */ |
906 | u32 id; /* queue id assigned by beklib */ | 786 | u32 id; /* queue id assigned by beklib */ |
@@ -965,7 +845,7 @@ struct hwi_context_memory { | |||
965 | u16 max_eqd; /* in usecs */ | 845 | u16 max_eqd; /* in usecs */ |
966 | u16 cur_eqd; /* in usecs */ | 846 | u16 cur_eqd; /* in usecs */ |
967 | struct be_eq_obj be_eq[MAX_CPUS]; | 847 | struct be_eq_obj be_eq[MAX_CPUS]; |
968 | struct be_queue_info be_cq[MAX_CPUS - 1]; | 848 | struct be_queue_info be_cq[MAX_CPUS]; |
969 | 849 | ||
970 | struct be_queue_info be_def_hdrq; | 850 | struct be_queue_info be_def_hdrq; |
971 | struct be_queue_info be_def_dataq; | 851 | struct be_queue_info be_def_dataq; |
@@ -976,20 +856,4 @@ struct hwi_context_memory { | |||
976 | struct hwi_async_pdu_context *pasync_ctx; | 856 | struct hwi_async_pdu_context *pasync_ctx; |
977 | }; | 857 | }; |
978 | 858 | ||
979 | /* Logging related definitions */ | ||
980 | #define BEISCSI_LOG_INIT 0x0001 /* Initialization events */ | ||
981 | #define BEISCSI_LOG_MBOX 0x0002 /* Mailbox Events */ | ||
982 | #define BEISCSI_LOG_MISC 0x0004 /* Miscllaneous Events */ | ||
983 | #define BEISCSI_LOG_EH 0x0008 /* Error Handler */ | ||
984 | #define BEISCSI_LOG_IO 0x0010 /* IO Code Path */ | ||
985 | #define BEISCSI_LOG_CONFIG 0x0020 /* CONFIG Code Path */ | ||
986 | |||
987 | #define beiscsi_log(phba, level, mask, fmt, arg...) \ | ||
988 | do { \ | ||
989 | uint32_t log_value = phba->attr_log_enable; \ | ||
990 | if (((mask) & log_value) || (level[1] <= '3')) \ | ||
991 | shost_printk(level, phba->shost, \ | ||
992 | fmt, __LINE__, ##arg); \ | ||
993 | } while (0) | ||
994 | |||
995 | #endif | 859 | #endif |
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index a6c2fe4b4d6..44762cfa3e1 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -17,202 +17,18 @@ | |||
17 | * Costa Mesa, CA 92626 | 17 | * Costa Mesa, CA 92626 |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/bsg-lib.h> | ||
21 | #include <scsi/scsi_transport_iscsi.h> | ||
22 | #include <scsi/scsi_bsg_iscsi.h> | ||
23 | #include "be_mgmt.h" | 20 | #include "be_mgmt.h" |
24 | #include "be_iscsi.h" | 21 | #include "be_iscsi.h" |
25 | #include "be_main.h" | 22 | #include <scsi/scsi_transport_iscsi.h> |
26 | |||
27 | /* UE Status Low CSR */ | ||
28 | static const char * const desc_ue_status_low[] = { | ||
29 | "CEV", | ||
30 | "CTX", | ||
31 | "DBUF", | ||
32 | "ERX", | ||
33 | "Host", | ||
34 | "MPU", | ||
35 | "NDMA", | ||
36 | "PTC ", | ||
37 | "RDMA ", | ||
38 | "RXF ", | ||
39 | "RXIPS ", | ||
40 | "RXULP0 ", | ||
41 | "RXULP1 ", | ||
42 | "RXULP2 ", | ||
43 | "TIM ", | ||
44 | "TPOST ", | ||
45 | "TPRE ", | ||
46 | "TXIPS ", | ||
47 | "TXULP0 ", | ||
48 | "TXULP1 ", | ||
49 | "UC ", | ||
50 | "WDMA ", | ||
51 | "TXULP2 ", | ||
52 | "HOST1 ", | ||
53 | "P0_OB_LINK ", | ||
54 | "P1_OB_LINK ", | ||
55 | "HOST_GPIO ", | ||
56 | "MBOX ", | ||
57 | "AXGMAC0", | ||
58 | "AXGMAC1", | ||
59 | "JTAG", | ||
60 | "MPU_INTPEND" | ||
61 | }; | ||
62 | |||
63 | /* UE Status High CSR */ | ||
64 | static const char * const desc_ue_status_hi[] = { | ||
65 | "LPCMEMHOST", | ||
66 | "MGMT_MAC", | ||
67 | "PCS0ONLINE", | ||
68 | "MPU_IRAM", | ||
69 | "PCS1ONLINE", | ||
70 | "PCTL0", | ||
71 | "PCTL1", | ||
72 | "PMEM", | ||
73 | "RR", | ||
74 | "TXPB", | ||
75 | "RXPP", | ||
76 | "XAUI", | ||
77 | "TXP", | ||
78 | "ARM", | ||
79 | "IPC", | ||
80 | "HOST2", | ||
81 | "HOST3", | ||
82 | "HOST4", | ||
83 | "HOST5", | ||
84 | "HOST6", | ||
85 | "HOST7", | ||
86 | "HOST8", | ||
87 | "HOST9", | ||
88 | "NETC", | ||
89 | "Unknown", | ||
90 | "Unknown", | ||
91 | "Unknown", | ||
92 | "Unknown", | ||
93 | "Unknown", | ||
94 | "Unknown", | ||
95 | "Unknown", | ||
96 | "Unknown" | ||
97 | }; | ||
98 | |||
99 | /* | ||
100 | * beiscsi_ue_detec()- Detect Unrecoverable Error on adapter | ||
101 | * @phba: Driver priv structure | ||
102 | * | ||
103 | * Read registers linked to UE and check for the UE status | ||
104 | **/ | ||
105 | void beiscsi_ue_detect(struct beiscsi_hba *phba) | ||
106 | { | ||
107 | uint32_t ue_hi = 0, ue_lo = 0; | ||
108 | uint32_t ue_mask_hi = 0, ue_mask_lo = 0; | ||
109 | uint8_t i = 0; | ||
110 | |||
111 | if (phba->ue_detected) | ||
112 | return; | ||
113 | |||
114 | pci_read_config_dword(phba->pcidev, | ||
115 | PCICFG_UE_STATUS_LOW, &ue_lo); | ||
116 | pci_read_config_dword(phba->pcidev, | ||
117 | PCICFG_UE_STATUS_MASK_LOW, | ||
118 | &ue_mask_lo); | ||
119 | pci_read_config_dword(phba->pcidev, | ||
120 | PCICFG_UE_STATUS_HIGH, | ||
121 | &ue_hi); | ||
122 | pci_read_config_dword(phba->pcidev, | ||
123 | PCICFG_UE_STATUS_MASK_HI, | ||
124 | &ue_mask_hi); | ||
125 | |||
126 | ue_lo = (ue_lo & ~ue_mask_lo); | ||
127 | ue_hi = (ue_hi & ~ue_mask_hi); | ||
128 | |||
129 | |||
130 | if (ue_lo || ue_hi) { | ||
131 | phba->ue_detected = true; | ||
132 | beiscsi_log(phba, KERN_ERR, | ||
133 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
134 | "BG_%d : Error detected on the adapter\n"); | ||
135 | } | ||
136 | |||
137 | if (ue_lo) { | ||
138 | for (i = 0; ue_lo; ue_lo >>= 1, i++) { | ||
139 | if (ue_lo & 1) | ||
140 | beiscsi_log(phba, KERN_ERR, | ||
141 | BEISCSI_LOG_CONFIG, | ||
142 | "BG_%d : UE_LOW %s bit set\n", | ||
143 | desc_ue_status_low[i]); | ||
144 | } | ||
145 | } | ||
146 | |||
147 | if (ue_hi) { | ||
148 | for (i = 0; ue_hi; ue_hi >>= 1, i++) { | ||
149 | if (ue_hi & 1) | ||
150 | beiscsi_log(phba, KERN_ERR, | ||
151 | BEISCSI_LOG_CONFIG, | ||
152 | "BG_%d : UE_HIGH %s bit set\n", | ||
153 | desc_ue_status_hi[i]); | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * mgmt_reopen_session()- Reopen a session based on reopen_type | ||
160 | * @phba: Device priv structure instance | ||
161 | * @reopen_type: Type of reopen_session FW should do. | ||
162 | * @sess_handle: Session Handle of the session to be re-opened | ||
163 | * | ||
164 | * return | ||
165 | * the TAG used for MBOX Command | ||
166 | * | ||
167 | **/ | ||
168 | unsigned int mgmt_reopen_session(struct beiscsi_hba *phba, | ||
169 | unsigned int reopen_type, | ||
170 | unsigned int sess_handle) | ||
171 | { | ||
172 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
173 | struct be_mcc_wrb *wrb; | ||
174 | struct be_cmd_reopen_session_req *req; | ||
175 | unsigned int tag = 0; | ||
176 | |||
177 | beiscsi_log(phba, KERN_INFO, | ||
178 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
179 | "BG_%d : In bescsi_get_boot_target\n"); | ||
180 | |||
181 | spin_lock(&ctrl->mbox_lock); | ||
182 | tag = alloc_mcc_tag(phba); | ||
183 | if (!tag) { | ||
184 | spin_unlock(&ctrl->mbox_lock); | ||
185 | return tag; | ||
186 | } | ||
187 | |||
188 | wrb = wrb_from_mccq(phba); | ||
189 | req = embedded_payload(wrb); | ||
190 | wrb->tag0 |= tag; | ||
191 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | ||
192 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, | ||
193 | OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS, | ||
194 | sizeof(struct be_cmd_reopen_session_resp)); | ||
195 | |||
196 | /* set the reopen_type,sess_handle */ | ||
197 | req->reopen_type = reopen_type; | ||
198 | req->session_handle = sess_handle; | ||
199 | |||
200 | be_mcc_notify(phba); | ||
201 | spin_unlock(&ctrl->mbox_lock); | ||
202 | return tag; | ||
203 | } | ||
204 | 23 | ||
205 | unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba) | 24 | unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba) |
206 | { | 25 | { |
207 | struct be_ctrl_info *ctrl = &phba->ctrl; | 26 | struct be_ctrl_info *ctrl = &phba->ctrl; |
208 | struct be_mcc_wrb *wrb; | 27 | struct be_mcc_wrb *wrb; |
209 | struct be_cmd_get_boot_target_req *req; | 28 | struct be_cmd_req_get_mac_addr *req; |
210 | unsigned int tag = 0; | 29 | unsigned int tag = 0; |
211 | 30 | ||
212 | beiscsi_log(phba, KERN_INFO, | 31 | SE_DEBUG(DBG_LVL_8, "In bescsi_get_boot_target\n"); |
213 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
214 | "BG_%d : In bescsi_get_boot_target\n"); | ||
215 | |||
216 | spin_lock(&ctrl->mbox_lock); | 32 | spin_lock(&ctrl->mbox_lock); |
217 | tag = alloc_mcc_tag(phba); | 33 | tag = alloc_mcc_tag(phba); |
218 | if (!tag) { | 34 | if (!tag) { |
@@ -226,28 +42,25 @@ unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba) | |||
226 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 42 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
227 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, | 43 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
228 | OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET, | 44 | OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET, |
229 | sizeof(struct be_cmd_get_boot_target_resp)); | 45 | sizeof(*req)); |
230 | 46 | ||
231 | be_mcc_notify(phba); | 47 | be_mcc_notify(phba); |
232 | spin_unlock(&ctrl->mbox_lock); | 48 | spin_unlock(&ctrl->mbox_lock); |
233 | return tag; | 49 | return tag; |
234 | } | 50 | } |
235 | 51 | ||
236 | unsigned int mgmt_get_session_info(struct beiscsi_hba *phba, | 52 | unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba, |
237 | u32 boot_session_handle, | 53 | u32 boot_session_handle, |
238 | struct be_dma_mem *nonemb_cmd) | 54 | struct be_dma_mem *nonemb_cmd) |
239 | { | 55 | { |
240 | struct be_ctrl_info *ctrl = &phba->ctrl; | 56 | struct be_ctrl_info *ctrl = &phba->ctrl; |
241 | struct be_mcc_wrb *wrb; | 57 | struct be_mcc_wrb *wrb; |
242 | unsigned int tag = 0; | 58 | unsigned int tag = 0; |
243 | struct be_cmd_get_session_req *req; | 59 | struct be_cmd_req_get_session *req; |
244 | struct be_cmd_get_session_resp *resp; | 60 | struct be_cmd_resp_get_session *resp; |
245 | struct be_sge *sge; | 61 | struct be_sge *sge; |
246 | 62 | ||
247 | beiscsi_log(phba, KERN_INFO, | 63 | SE_DEBUG(DBG_LVL_8, "In beiscsi_get_session_info\n"); |
248 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
249 | "BG_%d : In beiscsi_get_session_info\n"); | ||
250 | |||
251 | spin_lock(&ctrl->mbox_lock); | 64 | spin_lock(&ctrl->mbox_lock); |
252 | tag = alloc_mcc_tag(phba); | 65 | tag = alloc_mcc_tag(phba); |
253 | if (!tag) { | 66 | if (!tag) { |
@@ -306,16 +119,16 @@ int mgmt_get_fw_config(struct be_ctrl_info *ctrl, | |||
306 | phba->fw_config.iscsi_cid_count = | 119 | phba->fw_config.iscsi_cid_count = |
307 | pfw_cfg->ulp[0].sq_count; | 120 | pfw_cfg->ulp[0].sq_count; |
308 | if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) { | 121 | if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) { |
309 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 122 | SE_DEBUG(DBG_LVL_8, |
310 | "BG_%d : FW reported MAX CXNS as %d\t" | 123 | "FW reported MAX CXNS as %d\t" |
311 | "Max Supported = %d.\n", | 124 | "Max Supported = %d.\n", |
312 | phba->fw_config.iscsi_cid_count, | 125 | phba->fw_config.iscsi_cid_count, |
313 | BE2_MAX_SESSIONS); | 126 | BE2_MAX_SESSIONS); |
314 | phba->fw_config.iscsi_cid_count = BE2_MAX_SESSIONS / 2; | 127 | phba->fw_config.iscsi_cid_count = BE2_MAX_SESSIONS / 2; |
315 | } | 128 | } |
316 | } else { | 129 | } else { |
317 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 130 | shost_printk(KERN_WARNING, phba->shost, |
318 | "BG_%d : Failed in mgmt_get_fw_config\n"); | 131 | "Failed in mgmt_get_fw_config\n"); |
319 | } | 132 | } |
320 | 133 | ||
321 | spin_unlock(&ctrl->mbox_lock); | 134 | spin_unlock(&ctrl->mbox_lock); |
@@ -335,9 +148,9 @@ int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, | |||
335 | sizeof(struct be_mgmt_controller_attributes), | 148 | sizeof(struct be_mgmt_controller_attributes), |
336 | &nonemb_cmd.dma); | 149 | &nonemb_cmd.dma); |
337 | if (nonemb_cmd.va == NULL) { | 150 | if (nonemb_cmd.va == NULL) { |
338 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 151 | SE_DEBUG(DBG_LVL_1, |
339 | "BG_%d : Failed to allocate memory for " | 152 | "Failed to allocate memory for mgmt_check_supported_fw" |
340 | "mgmt_check_supported_fw\n"); | 153 | "\n"); |
341 | return -ENOMEM; | 154 | return -ENOMEM; |
342 | } | 155 | } |
343 | nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); | 156 | nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); |
@@ -354,23 +167,18 @@ int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, | |||
354 | status = be_mbox_notify(ctrl); | 167 | status = be_mbox_notify(ctrl); |
355 | if (!status) { | 168 | if (!status) { |
356 | struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va; | 169 | struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va; |
357 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 170 | SE_DEBUG(DBG_LVL_8, "Firmware version of CMD: %s\n", |
358 | "BG_%d : Firmware Version of CMD : %s\n" | 171 | resp->params.hba_attribs.flashrom_version_string); |
359 | "Firmware Version is : %s\n" | 172 | SE_DEBUG(DBG_LVL_8, "Firmware version is : %s\n", |
360 | "Developer Build, not performing version check...\n", | 173 | resp->params.hba_attribs.firmware_version_string); |
361 | resp->params.hba_attribs | 174 | SE_DEBUG(DBG_LVL_8, |
362 | .flashrom_version_string, | 175 | "Developer Build, not performing version check...\n"); |
363 | resp->params.hba_attribs. | ||
364 | firmware_version_string); | ||
365 | |||
366 | phba->fw_config.iscsi_features = | 176 | phba->fw_config.iscsi_features = |
367 | resp->params.hba_attribs.iscsi_features; | 177 | resp->params.hba_attribs.iscsi_features; |
368 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, | 178 | SE_DEBUG(DBG_LVL_8, " phba->fw_config.iscsi_features = %d\n", |
369 | "BM_%d : phba->fw_config.iscsi_features = %d\n", | 179 | phba->fw_config.iscsi_features); |
370 | phba->fw_config.iscsi_features); | ||
371 | } else | 180 | } else |
372 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 181 | SE_DEBUG(DBG_LVL_1, " Failed in mgmt_check_supported_fw\n"); |
373 | "BG_%d : Failed in mgmt_check_supported_fw\n"); | ||
374 | spin_unlock(&ctrl->mbox_lock); | 182 | spin_unlock(&ctrl->mbox_lock); |
375 | if (nonemb_cmd.va) | 183 | if (nonemb_cmd.va) |
376 | pci_free_consistent(ctrl->pdev, nonemb_cmd.size, | 184 | pci_free_consistent(ctrl->pdev, nonemb_cmd.size, |
@@ -379,73 +187,6 @@ int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, | |||
379 | return status; | 187 | return status; |
380 | } | 188 | } |
381 | 189 | ||
382 | unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, | ||
383 | struct beiscsi_hba *phba, | ||
384 | struct bsg_job *job, | ||
385 | struct be_dma_mem *nonemb_cmd) | ||
386 | { | ||
387 | struct be_cmd_resp_hdr *resp; | ||
388 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | ||
389 | struct be_sge *mcc_sge = nonembedded_sgl(wrb); | ||
390 | unsigned int tag = 0; | ||
391 | struct iscsi_bsg_request *bsg_req = job->request; | ||
392 | struct be_bsg_vendor_cmd *req = nonemb_cmd->va; | ||
393 | unsigned short region, sector_size, sector, offset; | ||
394 | |||
395 | nonemb_cmd->size = job->request_payload.payload_len; | ||
396 | memset(nonemb_cmd->va, 0, nonemb_cmd->size); | ||
397 | resp = nonemb_cmd->va; | ||
398 | region = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; | ||
399 | sector_size = bsg_req->rqst_data.h_vendor.vendor_cmd[2]; | ||
400 | sector = bsg_req->rqst_data.h_vendor.vendor_cmd[3]; | ||
401 | offset = bsg_req->rqst_data.h_vendor.vendor_cmd[4]; | ||
402 | req->region = region; | ||
403 | req->sector = sector; | ||
404 | req->offset = offset; | ||
405 | spin_lock(&ctrl->mbox_lock); | ||
406 | memset(wrb, 0, sizeof(*wrb)); | ||
407 | |||
408 | switch (bsg_req->rqst_data.h_vendor.vendor_cmd[0]) { | ||
409 | case BEISCSI_WRITE_FLASH: | ||
410 | offset = sector * sector_size + offset; | ||
411 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | ||
412 | OPCODE_COMMON_WRITE_FLASH, sizeof(*req)); | ||
413 | sg_copy_to_buffer(job->request_payload.sg_list, | ||
414 | job->request_payload.sg_cnt, | ||
415 | nonemb_cmd->va + offset, job->request_len); | ||
416 | break; | ||
417 | case BEISCSI_READ_FLASH: | ||
418 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | ||
419 | OPCODE_COMMON_READ_FLASH, sizeof(*req)); | ||
420 | break; | ||
421 | default: | ||
422 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
423 | "BG_%d : Unsupported cmd = 0x%x\n\n", | ||
424 | bsg_req->rqst_data.h_vendor.vendor_cmd[0]); | ||
425 | |||
426 | spin_unlock(&ctrl->mbox_lock); | ||
427 | return -ENOSYS; | ||
428 | } | ||
429 | |||
430 | tag = alloc_mcc_tag(phba); | ||
431 | if (!tag) { | ||
432 | spin_unlock(&ctrl->mbox_lock); | ||
433 | return tag; | ||
434 | } | ||
435 | |||
436 | be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, | ||
437 | job->request_payload.sg_cnt); | ||
438 | mcc_sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); | ||
439 | mcc_sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); | ||
440 | mcc_sge->len = cpu_to_le32(nonemb_cmd->size); | ||
441 | wrb->tag0 |= tag; | ||
442 | |||
443 | be_mcc_notify(phba); | ||
444 | |||
445 | spin_unlock(&ctrl->mbox_lock); | ||
446 | return tag; | ||
447 | } | ||
448 | |||
449 | int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute) | 190 | int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute) |
450 | { | 191 | { |
451 | struct be_ctrl_info *ctrl = &phba->ctrl; | 192 | struct be_ctrl_info *ctrl = &phba->ctrl; |
@@ -466,8 +207,8 @@ int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute) | |||
466 | 207 | ||
467 | status = be_mcc_notify_wait(phba); | 208 | status = be_mcc_notify_wait(phba); |
468 | if (status) | 209 | if (status) |
469 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, | 210 | shost_printk(KERN_WARNING, phba->shost, |
470 | "BG_%d : mgmt_epfw_cleanup , FAILED\n"); | 211 | " mgmt_epfw_cleanup , FAILED\n"); |
471 | spin_unlock(&ctrl->mbox_lock); | 212 | spin_unlock(&ctrl->mbox_lock); |
472 | return status; | 213 | return status; |
473 | } | 214 | } |
@@ -587,6 +328,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
587 | struct sockaddr *dst_addr, | 328 | struct sockaddr *dst_addr, |
588 | struct beiscsi_endpoint *beiscsi_ep, | 329 | struct beiscsi_endpoint *beiscsi_ep, |
589 | struct be_dma_mem *nonemb_cmd) | 330 | struct be_dma_mem *nonemb_cmd) |
331 | |||
590 | { | 332 | { |
591 | struct hwi_controller *phwi_ctrlr; | 333 | struct hwi_controller *phwi_ctrlr; |
592 | struct hwi_context_memory *phwi_context; | 334 | struct hwi_context_memory *phwi_context; |
@@ -632,17 +374,17 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
632 | if (dst_addr->sa_family == PF_INET) { | 374 | if (dst_addr->sa_family == PF_INET) { |
633 | __be32 s_addr = daddr_in->sin_addr.s_addr; | 375 | __be32 s_addr = daddr_in->sin_addr.s_addr; |
634 | req->ip_address.ip_type = BE2_IPV4; | 376 | req->ip_address.ip_type = BE2_IPV4; |
635 | req->ip_address.addr[0] = s_addr & 0x000000ff; | 377 | req->ip_address.ip_address[0] = s_addr & 0x000000ff; |
636 | req->ip_address.addr[1] = (s_addr & 0x0000ff00) >> 8; | 378 | req->ip_address.ip_address[1] = (s_addr & 0x0000ff00) >> 8; |
637 | req->ip_address.addr[2] = (s_addr & 0x00ff0000) >> 16; | 379 | req->ip_address.ip_address[2] = (s_addr & 0x00ff0000) >> 16; |
638 | req->ip_address.addr[3] = (s_addr & 0xff000000) >> 24; | 380 | req->ip_address.ip_address[3] = (s_addr & 0xff000000) >> 24; |
639 | req->tcp_port = ntohs(daddr_in->sin_port); | 381 | req->tcp_port = ntohs(daddr_in->sin_port); |
640 | beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr; | 382 | beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr; |
641 | beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port); | 383 | beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port); |
642 | beiscsi_ep->ip_type = BE2_IPV4; | 384 | beiscsi_ep->ip_type = BE2_IPV4; |
643 | } else if (dst_addr->sa_family == PF_INET6) { | 385 | } else if (dst_addr->sa_family == PF_INET6) { |
644 | req->ip_address.ip_type = BE2_IPV6; | 386 | req->ip_address.ip_type = BE2_IPV6; |
645 | memcpy(&req->ip_address.addr, | 387 | memcpy(&req->ip_address.ip_address, |
646 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); | 388 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); |
647 | req->tcp_port = ntohs(daddr_in6->sin6_port); | 389 | req->tcp_port = ntohs(daddr_in6->sin6_port); |
648 | beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port); | 390 | beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port); |
@@ -650,9 +392,8 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
650 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); | 392 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); |
651 | beiscsi_ep->ip_type = BE2_IPV6; | 393 | beiscsi_ep->ip_type = BE2_IPV6; |
652 | } else{ | 394 | } else{ |
653 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | 395 | shost_printk(KERN_ERR, phba->shost, "unknown addr family %d\n", |
654 | "BG_%d : unknown addr family %d\n", | 396 | dst_addr->sa_family); |
655 | dst_addr->sa_family); | ||
656 | spin_unlock(&ctrl->mbox_lock); | 397 | spin_unlock(&ctrl->mbox_lock); |
657 | free_mcc_tag(&phba->ctrl, tag); | 398 | free_mcc_tag(&phba->ctrl, tag); |
658 | return -EINVAL; | 399 | return -EINVAL; |
@@ -663,8 +404,7 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
663 | if (phba->nxt_cqid == phba->num_cpus) | 404 | if (phba->nxt_cqid == phba->num_cpus) |
664 | phba->nxt_cqid = 0; | 405 | phba->nxt_cqid = 0; |
665 | req->cq_id = phwi_context->be_cq[i].id; | 406 | req->cq_id = phwi_context->be_cq[i].id; |
666 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, | 407 | SE_DEBUG(DBG_LVL_8, "i=%d cq_id=%d\n", i, req->cq_id); |
667 | "BG_%d : i=%d cq_id=%d\n", i, req->cq_id); | ||
668 | req->defq_id = def_hdr_id; | 408 | req->defq_id = def_hdr_id; |
669 | req->hdr_ring_id = def_hdr_id; | 409 | req->hdr_ring_id = def_hdr_id; |
670 | req->data_ring_id = def_data_id; | 410 | req->data_ring_id = def_data_id; |
@@ -679,430 +419,14 @@ int mgmt_open_connection(struct beiscsi_hba *phba, | |||
679 | return tag; | 419 | return tag; |
680 | } | 420 | } |
681 | 421 | ||
682 | unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba) | 422 | unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba) |
683 | { | ||
684 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
685 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); | ||
686 | struct be_cmd_get_all_if_id_req *req = embedded_payload(wrb); | ||
687 | struct be_cmd_get_all_if_id_req *pbe_allid = req; | ||
688 | int status = 0; | ||
689 | |||
690 | memset(wrb, 0, sizeof(*wrb)); | ||
691 | |||
692 | spin_lock(&ctrl->mbox_lock); | ||
693 | |||
694 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | ||
695 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, | ||
696 | OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID, | ||
697 | sizeof(*req)); | ||
698 | status = be_mbox_notify(ctrl); | ||
699 | if (!status) | ||
700 | phba->interface_handle = pbe_allid->if_hndl_list[0]; | ||
701 | else { | ||
702 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
703 | "BG_%d : Failed in mgmt_get_all_if_id\n"); | ||
704 | } | ||
705 | spin_unlock(&ctrl->mbox_lock); | ||
706 | |||
707 | return status; | ||
708 | } | ||
709 | |||
710 | /* | ||
711 | * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd | ||
712 | * @phba: Driver priv structure | ||
713 | * @nonemb_cmd: Address of the MBX command issued | ||
714 | * @resp_buf: Buffer to copy the MBX cmd response | ||
715 | * @resp_buf_len: respone lenght to be copied | ||
716 | * | ||
717 | **/ | ||
718 | static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba, | ||
719 | struct be_dma_mem *nonemb_cmd, void *resp_buf, | ||
720 | int resp_buf_len) | ||
721 | { | 423 | { |
722 | struct be_ctrl_info *ctrl = &phba->ctrl; | 424 | struct be_ctrl_info *ctrl = &phba->ctrl; |
723 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); | ||
724 | struct be_sge *sge; | ||
725 | unsigned int tag; | ||
726 | int rc = 0; | ||
727 | |||
728 | spin_lock(&ctrl->mbox_lock); | ||
729 | tag = alloc_mcc_tag(phba); | ||
730 | if (!tag) { | ||
731 | spin_unlock(&ctrl->mbox_lock); | ||
732 | rc = -ENOMEM; | ||
733 | goto free_cmd; | ||
734 | } | ||
735 | memset(wrb, 0, sizeof(*wrb)); | ||
736 | wrb->tag0 |= tag; | ||
737 | sge = nonembedded_sgl(wrb); | ||
738 | |||
739 | be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1); | ||
740 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); | ||
741 | sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd->dma)); | ||
742 | sge->len = cpu_to_le32(nonemb_cmd->size); | ||
743 | |||
744 | be_mcc_notify(phba); | ||
745 | spin_unlock(&ctrl->mbox_lock); | ||
746 | |||
747 | rc = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd->va); | ||
748 | if (rc) { | ||
749 | beiscsi_log(phba, KERN_ERR, | ||
750 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, | ||
751 | "BG_%d : mgmt_exec_nonemb_cmd Failed status\n"); | ||
752 | |||
753 | rc = -EIO; | ||
754 | goto free_cmd; | ||
755 | } | ||
756 | |||
757 | if (resp_buf) | ||
758 | memcpy(resp_buf, nonemb_cmd->va, resp_buf_len); | ||
759 | |||
760 | free_cmd: | ||
761 | pci_free_consistent(ctrl->pdev, nonemb_cmd->size, | ||
762 | nonemb_cmd->va, nonemb_cmd->dma); | ||
763 | return rc; | ||
764 | } | ||
765 | |||
766 | static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, | ||
767 | int iscsi_cmd, int size) | ||
768 | { | ||
769 | cmd->va = pci_alloc_consistent(phba->ctrl.pdev, size, &cmd->dma); | ||
770 | if (!cmd->va) { | ||
771 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, | ||
772 | "BG_%d : Failed to allocate memory for if info\n"); | ||
773 | return -ENOMEM; | ||
774 | } | ||
775 | memset(cmd->va, 0, size); | ||
776 | cmd->size = size; | ||
777 | be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size); | ||
778 | return 0; | ||
779 | } | ||
780 | |||
781 | static int | ||
782 | mgmt_static_ip_modify(struct beiscsi_hba *phba, | ||
783 | struct be_cmd_get_if_info_resp *if_info, | ||
784 | struct iscsi_iface_param_info *ip_param, | ||
785 | struct iscsi_iface_param_info *subnet_param, | ||
786 | uint32_t ip_action) | ||
787 | { | ||
788 | struct be_cmd_set_ip_addr_req *req; | ||
789 | struct be_dma_mem nonemb_cmd; | ||
790 | uint32_t ip_type; | ||
791 | int rc; | ||
792 | |||
793 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
794 | OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR, | ||
795 | sizeof(*req)); | ||
796 | if (rc) | ||
797 | return rc; | ||
798 | |||
799 | ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ? | ||
800 | BE2_IPV6 : BE2_IPV4 ; | ||
801 | |||
802 | req = nonemb_cmd.va; | ||
803 | req->ip_params.record_entry_count = 1; | ||
804 | req->ip_params.ip_record.action = ip_action; | ||
805 | req->ip_params.ip_record.interface_hndl = | ||
806 | phba->interface_handle; | ||
807 | req->ip_params.ip_record.ip_addr.size_of_structure = | ||
808 | sizeof(struct be_ip_addr_subnet_format); | ||
809 | req->ip_params.ip_record.ip_addr.ip_type = ip_type; | ||
810 | |||
811 | if (ip_action == IP_ACTION_ADD) { | ||
812 | memcpy(req->ip_params.ip_record.ip_addr.addr, ip_param->value, | ||
813 | ip_param->len); | ||
814 | |||
815 | if (subnet_param) | ||
816 | memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, | ||
817 | subnet_param->value, subnet_param->len); | ||
818 | } else { | ||
819 | memcpy(req->ip_params.ip_record.ip_addr.addr, | ||
820 | if_info->ip_addr.addr, ip_param->len); | ||
821 | |||
822 | memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, | ||
823 | if_info->ip_addr.subnet_mask, ip_param->len); | ||
824 | } | ||
825 | |||
826 | rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); | ||
827 | if (rc < 0) | ||
828 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
829 | "BG_%d : Failed to Modify existing IP Address\n"); | ||
830 | return rc; | ||
831 | } | ||
832 | |||
833 | static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, | ||
834 | uint32_t gtway_action, uint32_t param_len) | ||
835 | { | ||
836 | struct be_cmd_set_def_gateway_req *req; | ||
837 | struct be_dma_mem nonemb_cmd; | ||
838 | int rt_val; | ||
839 | |||
840 | |||
841 | rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
842 | OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY, | ||
843 | sizeof(*req)); | ||
844 | if (rt_val) | ||
845 | return rt_val; | ||
846 | |||
847 | req = nonemb_cmd.va; | ||
848 | req->action = gtway_action; | ||
849 | req->ip_addr.ip_type = BE2_IPV4; | ||
850 | |||
851 | memcpy(req->ip_addr.addr, gt_addr, param_len); | ||
852 | |||
853 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); | ||
854 | } | ||
855 | |||
856 | int mgmt_set_ip(struct beiscsi_hba *phba, | ||
857 | struct iscsi_iface_param_info *ip_param, | ||
858 | struct iscsi_iface_param_info *subnet_param, | ||
859 | uint32_t boot_proto) | ||
860 | { | ||
861 | struct be_cmd_get_def_gateway_resp gtway_addr_set; | ||
862 | struct be_cmd_get_if_info_resp if_info; | ||
863 | struct be_cmd_set_dhcp_req *dhcpreq; | ||
864 | struct be_cmd_rel_dhcp_req *reldhcp; | ||
865 | struct be_dma_mem nonemb_cmd; | ||
866 | uint8_t *gtway_addr; | ||
867 | uint32_t ip_type; | ||
868 | int rc; | ||
869 | |||
870 | if (mgmt_get_all_if_id(phba)) | ||
871 | return -EIO; | ||
872 | |||
873 | memset(&if_info, 0, sizeof(if_info)); | ||
874 | ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ? | ||
875 | BE2_IPV6 : BE2_IPV4 ; | ||
876 | |||
877 | rc = mgmt_get_if_info(phba, ip_type, &if_info); | ||
878 | if (rc) | ||
879 | return rc; | ||
880 | |||
881 | if (boot_proto == ISCSI_BOOTPROTO_DHCP) { | ||
882 | if (if_info.dhcp_state) { | ||
883 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
884 | "BG_%d : DHCP Already Enabled\n"); | ||
885 | return 0; | ||
886 | } | ||
887 | /* The ip_param->len is 1 in DHCP case. Setting | ||
888 | proper IP len as this it is used while | ||
889 | freeing the Static IP. | ||
890 | */ | ||
891 | ip_param->len = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ? | ||
892 | IP_V6_LEN : IP_V4_LEN; | ||
893 | |||
894 | } else { | ||
895 | if (if_info.dhcp_state) { | ||
896 | |||
897 | memset(&if_info, 0, sizeof(if_info)); | ||
898 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
899 | OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR, | ||
900 | sizeof(*reldhcp)); | ||
901 | |||
902 | if (rc) | ||
903 | return rc; | ||
904 | |||
905 | reldhcp = nonemb_cmd.va; | ||
906 | reldhcp->interface_hndl = phba->interface_handle; | ||
907 | reldhcp->ip_type = ip_type; | ||
908 | |||
909 | rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); | ||
910 | if (rc < 0) { | ||
911 | beiscsi_log(phba, KERN_WARNING, | ||
912 | BEISCSI_LOG_CONFIG, | ||
913 | "BG_%d : Failed to Delete existing dhcp\n"); | ||
914 | return rc; | ||
915 | } | ||
916 | } | ||
917 | } | ||
918 | |||
919 | /* Delete the Static IP Set */ | ||
920 | if (if_info.ip_addr.addr[0]) { | ||
921 | rc = mgmt_static_ip_modify(phba, &if_info, ip_param, NULL, | ||
922 | IP_ACTION_DEL); | ||
923 | if (rc) | ||
924 | return rc; | ||
925 | } | ||
926 | |||
927 | /* Delete the Gateway settings if mode change is to DHCP */ | ||
928 | if (boot_proto == ISCSI_BOOTPROTO_DHCP) { | ||
929 | memset(>way_addr_set, 0, sizeof(gtway_addr_set)); | ||
930 | rc = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set); | ||
931 | if (rc) { | ||
932 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
933 | "BG_%d : Failed to Get Gateway Addr\n"); | ||
934 | return rc; | ||
935 | } | ||
936 | |||
937 | if (gtway_addr_set.ip_addr.addr[0]) { | ||
938 | gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr; | ||
939 | rc = mgmt_modify_gateway(phba, gtway_addr, | ||
940 | IP_ACTION_DEL, IP_V4_LEN); | ||
941 | |||
942 | if (rc) { | ||
943 | beiscsi_log(phba, KERN_WARNING, | ||
944 | BEISCSI_LOG_CONFIG, | ||
945 | "BG_%d : Failed to clear Gateway Addr Set\n"); | ||
946 | return rc; | ||
947 | } | ||
948 | } | ||
949 | } | ||
950 | |||
951 | /* Set Adapter to DHCP/Static Mode */ | ||
952 | if (boot_proto == ISCSI_BOOTPROTO_DHCP) { | ||
953 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
954 | OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR, | ||
955 | sizeof(*dhcpreq)); | ||
956 | if (rc) | ||
957 | return rc; | ||
958 | |||
959 | dhcpreq = nonemb_cmd.va; | ||
960 | dhcpreq->flags = BLOCKING; | ||
961 | dhcpreq->retry_count = 1; | ||
962 | dhcpreq->interface_hndl = phba->interface_handle; | ||
963 | dhcpreq->ip_type = BE2_DHCP_V4; | ||
964 | |||
965 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); | ||
966 | } else { | ||
967 | return mgmt_static_ip_modify(phba, &if_info, ip_param, | ||
968 | subnet_param, IP_ACTION_ADD); | ||
969 | } | ||
970 | |||
971 | return rc; | ||
972 | } | ||
973 | |||
974 | int mgmt_set_gateway(struct beiscsi_hba *phba, | ||
975 | struct iscsi_iface_param_info *gateway_param) | ||
976 | { | ||
977 | struct be_cmd_get_def_gateway_resp gtway_addr_set; | ||
978 | uint8_t *gtway_addr; | ||
979 | int rt_val; | ||
980 | |||
981 | memset(>way_addr_set, 0, sizeof(gtway_addr_set)); | ||
982 | rt_val = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set); | ||
983 | if (rt_val) { | ||
984 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
985 | "BG_%d : Failed to Get Gateway Addr\n"); | ||
986 | return rt_val; | ||
987 | } | ||
988 | |||
989 | if (gtway_addr_set.ip_addr.addr[0]) { | ||
990 | gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr; | ||
991 | rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_DEL, | ||
992 | gateway_param->len); | ||
993 | if (rt_val) { | ||
994 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
995 | "BG_%d : Failed to clear Gateway Addr Set\n"); | ||
996 | return rt_val; | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | gtway_addr = (uint8_t *)&gateway_param->value; | ||
1001 | rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_ADD, | ||
1002 | gateway_param->len); | ||
1003 | |||
1004 | if (rt_val) | ||
1005 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, | ||
1006 | "BG_%d : Failed to Set Gateway Addr\n"); | ||
1007 | |||
1008 | return rt_val; | ||
1009 | } | ||
1010 | |||
1011 | int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, | ||
1012 | struct be_cmd_get_def_gateway_resp *gateway) | ||
1013 | { | ||
1014 | struct be_cmd_get_def_gateway_req *req; | ||
1015 | struct be_dma_mem nonemb_cmd; | ||
1016 | int rc; | ||
1017 | |||
1018 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
1019 | OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY, | ||
1020 | sizeof(*gateway)); | ||
1021 | if (rc) | ||
1022 | return rc; | ||
1023 | |||
1024 | req = nonemb_cmd.va; | ||
1025 | req->ip_type = ip_type; | ||
1026 | |||
1027 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, gateway, | ||
1028 | sizeof(*gateway)); | ||
1029 | } | ||
1030 | |||
1031 | int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, | ||
1032 | struct be_cmd_get_if_info_resp *if_info) | ||
1033 | { | ||
1034 | struct be_cmd_get_if_info_req *req; | ||
1035 | struct be_dma_mem nonemb_cmd; | ||
1036 | int rc; | ||
1037 | |||
1038 | if (mgmt_get_all_if_id(phba)) | ||
1039 | return -EIO; | ||
1040 | |||
1041 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
1042 | OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO, | ||
1043 | sizeof(*if_info)); | ||
1044 | if (rc) | ||
1045 | return rc; | ||
1046 | |||
1047 | req = nonemb_cmd.va; | ||
1048 | req->interface_hndl = phba->interface_handle; | ||
1049 | req->ip_type = ip_type; | ||
1050 | |||
1051 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, if_info, | ||
1052 | sizeof(*if_info)); | ||
1053 | } | ||
1054 | |||
1055 | int mgmt_get_nic_conf(struct beiscsi_hba *phba, | ||
1056 | struct be_cmd_get_nic_conf_resp *nic) | ||
1057 | { | ||
1058 | struct be_dma_mem nonemb_cmd; | ||
1059 | int rc; | ||
1060 | |||
1061 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, | ||
1062 | OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, | ||
1063 | sizeof(*nic)); | ||
1064 | if (rc) | ||
1065 | return rc; | ||
1066 | |||
1067 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, nic, sizeof(*nic)); | ||
1068 | } | ||
1069 | |||
1070 | |||
1071 | |||
1072 | unsigned int be_cmd_get_initname(struct beiscsi_hba *phba) | ||
1073 | { | ||
1074 | unsigned int tag = 0; | ||
1075 | struct be_mcc_wrb *wrb; | 425 | struct be_mcc_wrb *wrb; |
1076 | struct be_cmd_hba_name *req; | 426 | struct be_cmd_req_get_mac_addr *req; |
1077 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
1078 | |||
1079 | spin_lock(&ctrl->mbox_lock); | ||
1080 | tag = alloc_mcc_tag(phba); | ||
1081 | if (!tag) { | ||
1082 | spin_unlock(&ctrl->mbox_lock); | ||
1083 | return tag; | ||
1084 | } | ||
1085 | |||
1086 | wrb = wrb_from_mccq(phba); | ||
1087 | req = embedded_payload(wrb); | ||
1088 | wrb->tag0 |= tag; | ||
1089 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | ||
1090 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, | ||
1091 | OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, | ||
1092 | sizeof(*req)); | ||
1093 | |||
1094 | be_mcc_notify(phba); | ||
1095 | spin_unlock(&ctrl->mbox_lock); | ||
1096 | return tag; | ||
1097 | } | ||
1098 | |||
1099 | unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba) | ||
1100 | { | ||
1101 | unsigned int tag = 0; | 427 | unsigned int tag = 0; |
1102 | struct be_mcc_wrb *wrb; | ||
1103 | struct be_cmd_ntwk_link_status_req *req; | ||
1104 | struct be_ctrl_info *ctrl = &phba->ctrl; | ||
1105 | 428 | ||
429 | SE_DEBUG(DBG_LVL_8, "In be_cmd_get_mac_addr\n"); | ||
1106 | spin_lock(&ctrl->mbox_lock); | 430 | spin_lock(&ctrl->mbox_lock); |
1107 | tag = alloc_mcc_tag(phba); | 431 | tag = alloc_mcc_tag(phba); |
1108 | if (!tag) { | 432 | if (!tag) { |
@@ -1114,325 +438,12 @@ unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba) | |||
1114 | req = embedded_payload(wrb); | 438 | req = embedded_payload(wrb); |
1115 | wrb->tag0 |= tag; | 439 | wrb->tag0 |= tag; |
1116 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 440 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
1117 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 441 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
1118 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, | 442 | OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, |
1119 | sizeof(*req)); | 443 | sizeof(*req)); |
1120 | 444 | ||
1121 | be_mcc_notify(phba); | 445 | be_mcc_notify(phba); |
1122 | spin_unlock(&ctrl->mbox_lock); | 446 | spin_unlock(&ctrl->mbox_lock); |
1123 | return tag; | 447 | return tag; |
1124 | } | 448 | } |
1125 | 449 | ||
1126 | /** | ||
1127 | * be_mgmt_get_boot_shandle()- Get the session handle | ||
1128 | * @phba: device priv structure instance | ||
1129 | * @s_handle: session handle returned for boot session. | ||
1130 | * | ||
1131 | * Get the boot target session handle. In case of | ||
1132 | * crashdump mode driver has to issue and MBX Cmd | ||
1133 | * for FW to login to boot target | ||
1134 | * | ||
1135 | * return | ||
1136 | * Success: 0 | ||
1137 | * Failure: Non-Zero value | ||
1138 | * | ||
1139 | **/ | ||
1140 | int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, | ||
1141 | unsigned int *s_handle) | ||
1142 | { | ||
1143 | struct be_cmd_get_boot_target_resp *boot_resp; | ||
1144 | struct be_mcc_wrb *wrb; | ||
1145 | unsigned int tag; | ||
1146 | uint8_t boot_retry = 3; | ||
1147 | int rc; | ||
1148 | |||
1149 | do { | ||
1150 | /* Get the Boot Target Session Handle and Count*/ | ||
1151 | tag = mgmt_get_boot_target(phba); | ||
1152 | if (!tag) { | ||
1153 | beiscsi_log(phba, KERN_ERR, | ||
1154 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT, | ||
1155 | "BG_%d : Getting Boot Target Info Failed\n"); | ||
1156 | return -EAGAIN; | ||
1157 | } | ||
1158 | |||
1159 | rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); | ||
1160 | if (rc) { | ||
1161 | beiscsi_log(phba, KERN_ERR, | ||
1162 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | ||
1163 | "BG_%d : MBX CMD get_boot_target Failed\n"); | ||
1164 | return -EBUSY; | ||
1165 | } | ||
1166 | |||
1167 | boot_resp = embedded_payload(wrb); | ||
1168 | |||
1169 | /* Check if the there are any Boot targets configured */ | ||
1170 | if (!boot_resp->boot_session_count) { | ||
1171 | beiscsi_log(phba, KERN_INFO, | ||
1172 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | ||
1173 | "BG_%d ;No boot targets configured\n"); | ||
1174 | return -ENXIO; | ||
1175 | } | ||
1176 | |||
1177 | /* FW returns the session handle of the boot session */ | ||
1178 | if (boot_resp->boot_session_handle != INVALID_SESS_HANDLE) { | ||
1179 | *s_handle = boot_resp->boot_session_handle; | ||
1180 | return 0; | ||
1181 | } | ||
1182 | |||
1183 | /* Issue MBX Cmd to FW to login to the boot target */ | ||
1184 | tag = mgmt_reopen_session(phba, BE_REOPEN_BOOT_SESSIONS, | ||
1185 | INVALID_SESS_HANDLE); | ||
1186 | if (!tag) { | ||
1187 | beiscsi_log(phba, KERN_ERR, | ||
1188 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | ||
1189 | "BG_%d : mgmt_reopen_session Failed\n"); | ||
1190 | return -EAGAIN; | ||
1191 | } | ||
1192 | |||
1193 | rc = beiscsi_mccq_compl(phba, tag, NULL, NULL); | ||
1194 | if (rc) { | ||
1195 | beiscsi_log(phba, KERN_ERR, | ||
1196 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | ||
1197 | "BG_%d : mgmt_reopen_session Failed"); | ||
1198 | return rc; | ||
1199 | } | ||
1200 | } while (--boot_retry); | ||
1201 | |||
1202 | /* Couldn't log into the boot target */ | ||
1203 | beiscsi_log(phba, KERN_ERR, | ||
1204 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, | ||
1205 | "BG_%d : Login to Boot Target Failed\n"); | ||
1206 | return -ENXIO; | ||
1207 | } | ||
1208 | |||
1209 | /** | ||
1210 | * mgmt_set_vlan()- Issue and wait for CMD completion | ||
1211 | * @phba: device private structure instance | ||
1212 | * @vlan_tag: VLAN tag | ||
1213 | * | ||
1214 | * Issue the MBX Cmd and wait for the completion of the | ||
1215 | * command. | ||
1216 | * | ||
1217 | * returns | ||
1218 | * Success: 0 | ||
1219 | * Failure: Non-Xero Value | ||
1220 | **/ | ||
1221 | int mgmt_set_vlan(struct beiscsi_hba *phba, | ||
1222 | uint16_t vlan_tag) | ||
1223 | { | ||
1224 | int rc; | ||
1225 | unsigned int tag; | ||
1226 | struct be_mcc_wrb *wrb = NULL; | ||
1227 | |||
1228 | tag = be_cmd_set_vlan(phba, vlan_tag); | ||
1229 | if (!tag) { | ||
1230 | beiscsi_log(phba, KERN_ERR, | ||
1231 | (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX), | ||
1232 | "BG_%d : VLAN Setting Failed\n"); | ||
1233 | return -EBUSY; | ||
1234 | } | ||
1235 | |||
1236 | rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); | ||
1237 | if (rc) { | ||
1238 | beiscsi_log(phba, KERN_ERR, | ||
1239 | (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX), | ||
1240 | "BS_%d : VLAN MBX Cmd Failed\n"); | ||
1241 | return rc; | ||
1242 | } | ||
1243 | return rc; | ||
1244 | } | ||
1245 | |||
1246 | /** | ||
1247 | * beiscsi_drvr_ver_disp()- Display the driver Name and Version | ||
1248 | * @dev: ptr to device not used. | ||
1249 | * @attr: device attribute, not used. | ||
1250 | * @buf: contains formatted text driver name and version | ||
1251 | * | ||
1252 | * return | ||
1253 | * size of the formatted string | ||
1254 | **/ | ||
1255 | ssize_t | ||
1256 | beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr, | ||
1257 | char *buf) | ||
1258 | { | ||
1259 | return snprintf(buf, PAGE_SIZE, BE_NAME "\n"); | ||
1260 | } | ||
1261 | |||
1262 | /** | ||
1263 | * beiscsi_adap_family_disp()- Display adapter family. | ||
1264 | * @dev: ptr to device to get priv structure | ||
1265 | * @attr: device attribute, not used. | ||
1266 | * @buf: contains formatted text driver name and version | ||
1267 | * | ||
1268 | * return | ||
1269 | * size of the formatted string | ||
1270 | **/ | ||
1271 | ssize_t | ||
1272 | beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr, | ||
1273 | char *buf) | ||
1274 | { | ||
1275 | uint16_t dev_id = 0; | ||
1276 | struct Scsi_Host *shost = class_to_shost(dev); | ||
1277 | struct beiscsi_hba *phba = iscsi_host_priv(shost); | ||
1278 | |||
1279 | dev_id = phba->pcidev->device; | ||
1280 | switch (dev_id) { | ||
1281 | case BE_DEVICE_ID1: | ||
1282 | case OC_DEVICE_ID1: | ||
1283 | case OC_DEVICE_ID2: | ||
1284 | return snprintf(buf, PAGE_SIZE, "BE2 Adapter Family\n"); | ||
1285 | break; | ||
1286 | case BE_DEVICE_ID2: | ||
1287 | case OC_DEVICE_ID3: | ||
1288 | return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n"); | ||
1289 | break; | ||
1290 | case OC_SKH_ID1: | ||
1291 | return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n"); | ||
1292 | break; | ||
1293 | default: | ||
1294 | return snprintf(buf, PAGE_SIZE, | ||
1295 | "Unkown Adapter Family: 0x%x\n", dev_id); | ||
1296 | break; | ||
1297 | } | ||
1298 | } | ||
1299 | |||
1300 | |||
1301 | void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, | ||
1302 | struct wrb_handle *pwrb_handle, | ||
1303 | struct be_mem_descriptor *mem_descr) | ||
1304 | { | ||
1305 | struct iscsi_wrb *pwrb = pwrb_handle->pwrb; | ||
1306 | |||
1307 | memset(pwrb, 0, sizeof(*pwrb)); | ||
1308 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1309 | max_send_data_segment_length, pwrb, | ||
1310 | params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1311 | max_send_data_segment_length) / 32]); | ||
1312 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb, | ||
1313 | BE_TGT_CTX_UPDT_CMD); | ||
1314 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1315 | first_burst_length, | ||
1316 | pwrb, | ||
1317 | params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1318 | first_burst_length) / 32]); | ||
1319 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb, | ||
1320 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1321 | erl) / 32] & OFFLD_PARAMS_ERL)); | ||
1322 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb, | ||
1323 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1324 | dde) / 32] & OFFLD_PARAMS_DDE) >> 2); | ||
1325 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb, | ||
1326 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1327 | hde) / 32] & OFFLD_PARAMS_HDE) >> 3); | ||
1328 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb, | ||
1329 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1330 | ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4); | ||
1331 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb, | ||
1332 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1333 | imd) / 32] & OFFLD_PARAMS_IMD) >> 5); | ||
1334 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn, | ||
1335 | pwrb, | ||
1336 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1337 | exp_statsn) / 32] + 1)); | ||
1338 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx, | ||
1339 | pwrb, pwrb_handle->wrb_index); | ||
1340 | |||
1341 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1342 | max_burst_length, pwrb, params->dw[offsetof | ||
1343 | (struct amap_beiscsi_offload_params, | ||
1344 | max_burst_length) / 32]); | ||
1345 | |||
1346 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb, | ||
1347 | pwrb, pwrb_handle->nxt_wrb_index); | ||
1348 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1349 | session_state, pwrb, 0); | ||
1350 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, compltonack, | ||
1351 | pwrb, 1); | ||
1352 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, notpredblq, | ||
1353 | pwrb, 0); | ||
1354 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, mode, pwrb, | ||
1355 | 0); | ||
1356 | |||
1357 | mem_descr += ISCSI_MEM_GLOBAL_HEADER; | ||
1358 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1359 | pad_buffer_addr_hi, pwrb, | ||
1360 | mem_descr->mem_array[0].bus_address.u.a32.address_hi); | ||
1361 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1362 | pad_buffer_addr_lo, pwrb, | ||
1363 | mem_descr->mem_array[0].bus_address.u.a32.address_lo); | ||
1364 | } | ||
1365 | |||
1366 | void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, | ||
1367 | struct wrb_handle *pwrb_handle) | ||
1368 | { | ||
1369 | struct iscsi_wrb *pwrb = pwrb_handle->pwrb; | ||
1370 | |||
1371 | memset(pwrb, 0, sizeof(*pwrb)); | ||
1372 | |||
1373 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, | ||
1374 | max_burst_length, pwrb, params->dw[offsetof | ||
1375 | (struct amap_beiscsi_offload_params, | ||
1376 | max_burst_length) / 32]); | ||
1377 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1378 | max_burst_length, pwrb, params->dw[offsetof | ||
1379 | (struct amap_beiscsi_offload_params, | ||
1380 | max_burst_length) / 32]); | ||
1381 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1382 | type, pwrb, | ||
1383 | BE_TGT_CTX_UPDT_CMD); | ||
1384 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1385 | ptr2nextwrb, | ||
1386 | pwrb, pwrb_handle->nxt_wrb_index); | ||
1387 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, wrb_idx, | ||
1388 | pwrb, pwrb_handle->wrb_index); | ||
1389 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1390 | max_send_data_segment_length, pwrb, | ||
1391 | params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1392 | max_send_data_segment_length) / 32]); | ||
1393 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1394 | first_burst_length, pwrb, | ||
1395 | params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1396 | first_burst_length) / 32]); | ||
1397 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1398 | max_recv_dataseg_len, pwrb, BEISCSI_MAX_RECV_DATASEG_LEN); | ||
1399 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1400 | max_cxns, pwrb, BEISCSI_MAX_CXNS); | ||
1401 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, erl, pwrb, | ||
1402 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1403 | erl) / 32] & OFFLD_PARAMS_ERL)); | ||
1404 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, dde, pwrb, | ||
1405 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1406 | dde) / 32] & OFFLD_PARAMS_DDE) >> 2); | ||
1407 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, hde, pwrb, | ||
1408 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1409 | hde) / 32] & OFFLD_PARAMS_HDE) >> 3); | ||
1410 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1411 | ir2t, pwrb, | ||
1412 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1413 | ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4); | ||
1414 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, imd, pwrb, | ||
1415 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1416 | imd) / 32] & OFFLD_PARAMS_IMD) >> 5); | ||
1417 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1418 | data_seq_inorder, | ||
1419 | pwrb, | ||
1420 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1421 | data_seq_inorder) / 32] & | ||
1422 | OFFLD_PARAMS_DATA_SEQ_INORDER) >> 6); | ||
1423 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, | ||
1424 | pdu_seq_inorder, | ||
1425 | pwrb, | ||
1426 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1427 | pdu_seq_inorder) / 32] & | ||
1428 | OFFLD_PARAMS_PDU_SEQ_INORDER) >> 7); | ||
1429 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, max_r2t, | ||
1430 | pwrb, | ||
1431 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1432 | max_r2t) / 32] & | ||
1433 | OFFLD_PARAMS_MAX_R2T) >> 8); | ||
1434 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, stat_sn, | ||
1435 | pwrb, | ||
1436 | (params->dw[offsetof(struct amap_beiscsi_offload_params, | ||
1437 | exp_statsn) / 32] + 1)); | ||
1438 | } | ||
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h index 2e4968add79..08428824ace 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.h +++ b/drivers/scsi/be2iscsi/be_mgmt.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (C) 2005 - 2012 Emulex | 2 | * Copyright (C) 2005 - 2011 Emulex |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
@@ -20,22 +20,11 @@ | |||
20 | #ifndef _BEISCSI_MGMT_ | 20 | #ifndef _BEISCSI_MGMT_ |
21 | #define _BEISCSI_MGMT_ | 21 | #define _BEISCSI_MGMT_ |
22 | 22 | ||
23 | #include <scsi/scsi_bsg_iscsi.h> | 23 | #include <linux/types.h> |
24 | #include <linux/list.h> | ||
24 | #include "be_iscsi.h" | 25 | #include "be_iscsi.h" |
25 | #include "be_main.h" | 26 | #include "be_main.h" |
26 | 27 | ||
27 | #define IP_ACTION_ADD 0x01 | ||
28 | #define IP_ACTION_DEL 0x02 | ||
29 | |||
30 | #define IP_V6_LEN 16 | ||
31 | #define IP_V4_LEN 4 | ||
32 | |||
33 | /* UE Status and Mask register */ | ||
34 | #define PCICFG_UE_STATUS_LOW 0xA0 | ||
35 | #define PCICFG_UE_STATUS_HIGH 0xA4 | ||
36 | #define PCICFG_UE_STATUS_MASK_LOW 0xA8 | ||
37 | #define PCICFG_UE_STATUS_MASK_HI 0xAC | ||
38 | |||
39 | /** | 28 | /** |
40 | * Pseudo amap definition in which each bit of the actual structure is defined | 29 | * Pseudo amap definition in which each bit of the actual structure is defined |
41 | * as a byte: used to calculate offset/shift/mask of each field | 30 | * as a byte: used to calculate offset/shift/mask of each field |
@@ -109,12 +98,7 @@ unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba, | |||
109 | struct invalidate_command_table *inv_tbl, | 98 | struct invalidate_command_table *inv_tbl, |
110 | unsigned int num_invalidate, unsigned int cid, | 99 | unsigned int num_invalidate, unsigned int cid, |
111 | struct be_dma_mem *nonemb_cmd); | 100 | struct be_dma_mem *nonemb_cmd); |
112 | unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, | ||
113 | struct beiscsi_hba *phba, | ||
114 | struct bsg_job *job, | ||
115 | struct be_dma_mem *nonemb_cmd); | ||
116 | 101 | ||
117 | #define BEISCSI_NO_RST_ISSUE 0 | ||
118 | struct iscsi_invalidate_connection_params_in { | 102 | struct iscsi_invalidate_connection_params_in { |
119 | struct be_cmd_req_hdr hdr; | 103 | struct be_cmd_req_hdr hdr; |
120 | unsigned int session_handle; | 104 | unsigned int session_handle; |
@@ -220,13 +204,6 @@ struct be_mgmt_controller_attributes_resp { | |||
220 | struct mgmt_controller_attributes params; | 204 | struct mgmt_controller_attributes params; |
221 | } __packed; | 205 | } __packed; |
222 | 206 | ||
223 | struct be_bsg_vendor_cmd { | ||
224 | struct be_cmd_req_hdr hdr; | ||
225 | unsigned short region; | ||
226 | unsigned short offset; | ||
227 | unsigned short sector; | ||
228 | } __packed; | ||
229 | |||
230 | /* configuration management */ | 207 | /* configuration management */ |
231 | 208 | ||
232 | #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws) | 209 | #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws) |
@@ -242,15 +219,12 @@ struct be_bsg_vendor_cmd { | |||
242 | /* the CMD_RESPONSE_HEADER */ | 219 | /* the CMD_RESPONSE_HEADER */ |
243 | 220 | ||
244 | #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\ | 221 | #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\ |
245 | pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ | 222 | pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ |
246 | bus_address.u.a32.address_lo; \ | 223 | bus_address.u.a32.address_lo; \ |
247 | pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ | 224 | pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ |
248 | bus_address.u.a32.address_hi; \ | 225 | bus_address.u.a32.address_hi; \ |
249 | } | 226 | } |
250 | 227 | ||
251 | #define BEISCSI_WRITE_FLASH 0 | ||
252 | #define BEISCSI_READ_FLASH 1 | ||
253 | |||
254 | struct beiscsi_endpoint { | 228 | struct beiscsi_endpoint { |
255 | struct beiscsi_hba *phba; | 229 | struct beiscsi_hba *phba; |
256 | struct beiscsi_sess *sess; | 230 | struct beiscsi_sess *sess; |
@@ -274,52 +248,4 @@ unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, | |||
274 | unsigned short issue_reset, | 248 | unsigned short issue_reset, |
275 | unsigned short savecfg_flag); | 249 | unsigned short savecfg_flag); |
276 | 250 | ||
277 | int mgmt_set_ip(struct beiscsi_hba *phba, | ||
278 | struct iscsi_iface_param_info *ip_param, | ||
279 | struct iscsi_iface_param_info *subnet_param, | ||
280 | uint32_t boot_proto); | ||
281 | |||
282 | unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba); | ||
283 | |||
284 | unsigned int mgmt_reopen_session(struct beiscsi_hba *phba, | ||
285 | unsigned int reopen_type, | ||
286 | unsigned sess_handle); | ||
287 | |||
288 | unsigned int mgmt_get_session_info(struct beiscsi_hba *phba, | ||
289 | u32 boot_session_handle, | ||
290 | struct be_dma_mem *nonemb_cmd); | ||
291 | |||
292 | int mgmt_get_nic_conf(struct beiscsi_hba *phba, | ||
293 | struct be_cmd_get_nic_conf_resp *mac); | ||
294 | |||
295 | int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, | ||
296 | struct be_cmd_get_if_info_resp *if_info); | ||
297 | |||
298 | int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, | ||
299 | struct be_cmd_get_def_gateway_resp *gateway); | ||
300 | |||
301 | int mgmt_set_gateway(struct beiscsi_hba *phba, | ||
302 | struct iscsi_iface_param_info *gateway_param); | ||
303 | |||
304 | int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, | ||
305 | unsigned int *s_handle); | ||
306 | |||
307 | unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba); | ||
308 | |||
309 | int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); | ||
310 | |||
311 | ssize_t beiscsi_drvr_ver_disp(struct device *dev, | ||
312 | struct device_attribute *attr, char *buf); | ||
313 | |||
314 | ssize_t beiscsi_adap_family_disp(struct device *dev, | ||
315 | struct device_attribute *attr, char *buf); | ||
316 | |||
317 | void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, | ||
318 | struct wrb_handle *pwrb_handle, | ||
319 | struct be_mem_descriptor *mem_descr); | ||
320 | |||
321 | void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, | ||
322 | struct wrb_handle *pwrb_handle); | ||
323 | void beiscsi_ue_detect(struct beiscsi_hba *phba); | ||
324 | |||
325 | #endif | 251 | #endif |