aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptbase.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptbase.c')
-rw-r--r--drivers/message/fusion/mptbase.c220
1 files changed, 119 insertions, 101 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 7ef86cb3aa55..8cf0f5155e2e 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -102,8 +102,6 @@ static int mfcounter = 0;
102/* 102/*
103 * Public data... 103 * Public data...
104 */ 104 */
105int mpt_lan_index = -1;
106int mpt_stm_index = -1;
107 105
108struct proc_dir_entry *mpt_proc_root_dir; 106struct proc_dir_entry *mpt_proc_root_dir;
109 107
@@ -125,11 +123,14 @@ static MPT_EVHANDLER MptEvHandlers[MPT_MAX_PROTOCOL_DRIVERS];
125static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS]; 123static MPT_RESETHANDLER MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS];
126static struct mpt_pci_driver *MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS]; 124static struct mpt_pci_driver *MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS];
127 125
128static int mpt_base_index = -1;
129static int last_drv_idx = -1;
130
131static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq); 126static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq);
132 127
128/*
129 * Driver Callback Index's
130 */
131static u8 mpt_base_index = MPT_MAX_PROTOCOL_DRIVERS;
132static u8 last_drv_idx;
133
133/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 134/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
134/* 135/*
135 * Forward protos... 136 * Forward protos...
@@ -235,6 +236,23 @@ static int mpt_set_debug_level(const char *val, struct kernel_param *kp)
235 return 0; 236 return 0;
236} 237}
237 238
239/**
240 * mpt_get_cb_idx - obtain cb_idx for registered driver
241 * @dclass: class driver enum
242 *
243 * Returns cb_idx, or zero means it wasn't found
244 **/
245static u8
246mpt_get_cb_idx(MPT_DRIVER_CLASS dclass)
247{
248 u8 cb_idx;
249
250 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--)
251 if (MptDriverClass[cb_idx] == dclass)
252 return cb_idx;
253 return 0;
254}
255
238/* 256/*
239 * Process turbo (context) reply... 257 * Process turbo (context) reply...
240 */ 258 */
@@ -243,8 +261,8 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
243{ 261{
244 MPT_FRAME_HDR *mf = NULL; 262 MPT_FRAME_HDR *mf = NULL;
245 MPT_FRAME_HDR *mr = NULL; 263 MPT_FRAME_HDR *mr = NULL;
246 int req_idx = 0; 264 u16 req_idx = 0;
247 int cb_idx; 265 u8 cb_idx;
248 266
249 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n", 267 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n",
250 ioc->name, pa)); 268 ioc->name, pa));
@@ -256,7 +274,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
256 mf = MPT_INDEX_2_MFPTR(ioc, req_idx); 274 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
257 break; 275 break;
258 case MPI_CONTEXT_REPLY_TYPE_LAN: 276 case MPI_CONTEXT_REPLY_TYPE_LAN:
259 cb_idx = mpt_lan_index; 277 cb_idx = mpt_get_cb_idx(MPTLAN_DRIVER);
260 /* 278 /*
261 * Blind set of mf to NULL here was fatal 279 * Blind set of mf to NULL here was fatal
262 * after lan_reply says "freeme" 280 * after lan_reply says "freeme"
@@ -277,7 +295,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
277 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); 295 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
278 break; 296 break;
279 case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET: 297 case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET:
280 cb_idx = mpt_stm_index; 298 cb_idx = mpt_get_cb_idx(MPTSTM_DRIVER);
281 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa); 299 mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
282 break; 300 break;
283 default: 301 default:
@@ -286,7 +304,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
286 } 304 }
287 305
288 /* Check for (valid) IO callback! */ 306 /* Check for (valid) IO callback! */
289 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 307 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
290 MptCallbacks[cb_idx] == NULL) { 308 MptCallbacks[cb_idx] == NULL) {
291 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", 309 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
292 __FUNCTION__, ioc->name, cb_idx); 310 __FUNCTION__, ioc->name, cb_idx);
@@ -304,8 +322,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
304{ 322{
305 MPT_FRAME_HDR *mf; 323 MPT_FRAME_HDR *mf;
306 MPT_FRAME_HDR *mr; 324 MPT_FRAME_HDR *mr;
307 int req_idx; 325 u16 req_idx;
308 int cb_idx; 326 u8 cb_idx;
309 int freeme; 327 int freeme;
310 328
311 u32 reply_dma_low; 329 u32 reply_dma_low;
@@ -350,7 +368,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
350 mpt_iocstatus_info(ioc, (u32)ioc_stat, mf); 368 mpt_iocstatus_info(ioc, (u32)ioc_stat, mf);
351 369
352 /* Check for (valid) IO callback! */ 370 /* Check for (valid) IO callback! */
353 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 371 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
354 MptCallbacks[cb_idx] == NULL) { 372 MptCallbacks[cb_idx] == NULL) {
355 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n", 373 printk(MYIOC_s_WARN_FMT "%s: Invalid cb_idx (%d)!\n",
356 __FUNCTION__, ioc->name, cb_idx); 374 __FUNCTION__, ioc->name, cb_idx);
@@ -563,28 +581,27 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
563 * in order to register separate callbacks; one for "normal" SCSI IO; 581 * in order to register separate callbacks; one for "normal" SCSI IO;
564 * one for MptScsiTaskMgmt requests; one for Scan/DV requests. 582 * one for MptScsiTaskMgmt requests; one for Scan/DV requests.
565 * 583 *
566 * Returns a positive integer valued "handle" in the 584 * Returns u8 valued "handle" in the range (and S.O.D. order)
567 * range (and S.O.D. order) {N,...,7,6,5,...,1} if successful. 585 * {N,...,7,6,5,...,1} if successful.
568 * Any non-positive return value (including zero!) should be considered 586 * A return value of MPT_MAX_PROTOCOL_DRIVERS (including zero!) should be
569 * an error by the caller. 587 * considered an error by the caller.
570 */ 588 */
571int 589u8
572mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass) 590mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
573{ 591{
574 int i; 592 u8 cb_idx;
575 593 last_drv_idx = MPT_MAX_PROTOCOL_DRIVERS;
576 last_drv_idx = -1;
577 594
578 /* 595 /*
579 * Search for empty callback slot in this order: {N,...,7,6,5,...,1} 596 * Search for empty callback slot in this order: {N,...,7,6,5,...,1}
580 * (slot/handle 0 is reserved!) 597 * (slot/handle 0 is reserved!)
581 */ 598 */
582 for (i = MPT_MAX_PROTOCOL_DRIVERS-1; i; i--) { 599 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
583 if (MptCallbacks[i] == NULL) { 600 if (MptCallbacks[cb_idx] == NULL) {
584 MptCallbacks[i] = cbfunc; 601 MptCallbacks[cb_idx] = cbfunc;
585 MptDriverClass[i] = dclass; 602 MptDriverClass[cb_idx] = dclass;
586 MptEvHandlers[i] = NULL; 603 MptEvHandlers[cb_idx] = NULL;
587 last_drv_idx = i; 604 last_drv_idx = cb_idx;
588 break; 605 break;
589 } 606 }
590 } 607 }
@@ -601,9 +618,9 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
601 * module is unloaded. 618 * module is unloaded.
602 */ 619 */
603void 620void
604mpt_deregister(int cb_idx) 621mpt_deregister(u8 cb_idx)
605{ 622{
606 if ((cb_idx >= 0) && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) { 623 if (cb_idx && (cb_idx < MPT_MAX_PROTOCOL_DRIVERS)) {
607 MptCallbacks[cb_idx] = NULL; 624 MptCallbacks[cb_idx] = NULL;
608 MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER; 625 MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER;
609 MptEvHandlers[cb_idx] = NULL; 626 MptEvHandlers[cb_idx] = NULL;
@@ -625,9 +642,9 @@ mpt_deregister(int cb_idx)
625 * Returns 0 for success. 642 * Returns 0 for success.
626 */ 643 */
627int 644int
628mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc) 645mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc)
629{ 646{
630 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 647 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
631 return -1; 648 return -1;
632 649
633 MptEvHandlers[cb_idx] = ev_cbfunc; 650 MptEvHandlers[cb_idx] = ev_cbfunc;
@@ -645,9 +662,9 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc)
645 * or when its module is unloaded. 662 * or when its module is unloaded.
646 */ 663 */
647void 664void
648mpt_event_deregister(int cb_idx) 665mpt_event_deregister(u8 cb_idx)
649{ 666{
650 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 667 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
651 return; 668 return;
652 669
653 MptEvHandlers[cb_idx] = NULL; 670 MptEvHandlers[cb_idx] = NULL;
@@ -665,9 +682,9 @@ mpt_event_deregister(int cb_idx)
665 * Returns 0 for success. 682 * Returns 0 for success.
666 */ 683 */
667int 684int
668mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func) 685mpt_reset_register(u8 cb_idx, MPT_RESETHANDLER reset_func)
669{ 686{
670 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 687 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
671 return -1; 688 return -1;
672 689
673 MptResetHandlers[cb_idx] = reset_func; 690 MptResetHandlers[cb_idx] = reset_func;
@@ -684,9 +701,9 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func)
684 * or when its module is unloaded. 701 * or when its module is unloaded.
685 */ 702 */
686void 703void
687mpt_reset_deregister(int cb_idx) 704mpt_reset_deregister(u8 cb_idx)
688{ 705{
689 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 706 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
690 return; 707 return;
691 708
692 MptResetHandlers[cb_idx] = NULL; 709 MptResetHandlers[cb_idx] = NULL;
@@ -699,12 +716,12 @@ mpt_reset_deregister(int cb_idx)
699 * @cb_idx: MPT protocol driver index 716 * @cb_idx: MPT protocol driver index
700 */ 717 */
701int 718int
702mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) 719mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx)
703{ 720{
704 MPT_ADAPTER *ioc; 721 MPT_ADAPTER *ioc;
705 const struct pci_device_id *id; 722 const struct pci_device_id *id;
706 723
707 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 724 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
708 return -EINVAL; 725 return -EINVAL;
709 726
710 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc; 727 MptDeviceDriverHandlers[cb_idx] = dd_cbfunc;
@@ -726,12 +743,12 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
726 * @cb_idx: MPT protocol driver index 743 * @cb_idx: MPT protocol driver index
727 */ 744 */
728void 745void
729mpt_device_driver_deregister(int cb_idx) 746mpt_device_driver_deregister(u8 cb_idx)
730{ 747{
731 struct mpt_pci_driver *dd_cbfunc; 748 struct mpt_pci_driver *dd_cbfunc;
732 MPT_ADAPTER *ioc; 749 MPT_ADAPTER *ioc;
733 750
734 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS) 751 if (!cb_idx || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS)
735 return; 752 return;
736 753
737 dd_cbfunc = MptDeviceDriverHandlers[cb_idx]; 754 dd_cbfunc = MptDeviceDriverHandlers[cb_idx];
@@ -749,14 +766,14 @@ mpt_device_driver_deregister(int cb_idx)
749/** 766/**
750 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024) 767 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024)
751 * allocated per MPT adapter. 768 * allocated per MPT adapter.
752 * @handle: Handle of registered MPT protocol driver 769 * @cb_idx: Handle of registered MPT protocol driver
753 * @ioc: Pointer to MPT adapter structure 770 * @ioc: Pointer to MPT adapter structure
754 * 771 *
755 * Returns pointer to a MPT request frame or %NULL if none are available 772 * Returns pointer to a MPT request frame or %NULL if none are available
756 * or IOC is not active. 773 * or IOC is not active.
757 */ 774 */
758MPT_FRAME_HDR* 775MPT_FRAME_HDR*
759mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc) 776mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc)
760{ 777{
761 MPT_FRAME_HDR *mf; 778 MPT_FRAME_HDR *mf;
762 unsigned long flags; 779 unsigned long flags;
@@ -781,7 +798,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
781 u.frame.linkage.list); 798 u.frame.linkage.list);
782 list_del(&mf->u.frame.linkage.list); 799 list_del(&mf->u.frame.linkage.list);
783 mf->u.frame.linkage.arg1 = 0; 800 mf->u.frame.linkage.arg1 = 0;
784 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ 801 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */
785 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; 802 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
786 /* u16! */ 803 /* u16! */
787 req_idx = req_offset / ioc->req_sz; 804 req_idx = req_offset / ioc->req_sz;
@@ -805,7 +822,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
805#endif 822#endif
806 823
807 dmfprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n", 824 dmfprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n",
808 ioc->name, handle, ioc->id, mf)); 825 ioc->name, cb_idx, ioc->id, mf));
809 return mf; 826 return mf;
810} 827}
811 828
@@ -813,7 +830,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
813/** 830/**
814 * mpt_put_msg_frame - Send a protocol specific MPT request frame 831 * mpt_put_msg_frame - Send a protocol specific MPT request frame
815 * to a IOC. 832 * to a IOC.
816 * @handle: Handle of registered MPT protocol driver 833 * @cb_idx: Handle of registered MPT protocol driver
817 * @ioc: Pointer to MPT adapter structure 834 * @ioc: Pointer to MPT adapter structure
818 * @mf: Pointer to MPT request frame 835 * @mf: Pointer to MPT request frame
819 * 836 *
@@ -821,14 +838,14 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
821 * specific MPT adapter. 838 * specific MPT adapter.
822 */ 839 */
823void 840void
824mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) 841mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
825{ 842{
826 u32 mf_dma_addr; 843 u32 mf_dma_addr;
827 int req_offset; 844 int req_offset;
828 u16 req_idx; /* Request index */ 845 u16 req_idx; /* Request index */
829 846
830 /* ensure values are reset properly! */ 847 /* ensure values are reset properly! */
831 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; /* byte */ 848 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx; /* byte */
832 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; 849 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
833 /* u16! */ 850 /* u16! */
834 req_idx = req_offset / ioc->req_sz; 851 req_idx = req_offset / ioc->req_sz;
@@ -845,7 +862,7 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
845/** 862/**
846 * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame 863 * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame
847 * to a IOC using hi priority request queue. 864 * to a IOC using hi priority request queue.
848 * @handle: Handle of registered MPT protocol driver 865 * @cb_idx: Handle of registered MPT protocol driver
849 * @ioc: Pointer to MPT adapter structure 866 * @ioc: Pointer to MPT adapter structure
850 * @mf: Pointer to MPT request frame 867 * @mf: Pointer to MPT request frame
851 * 868 *
@@ -853,14 +870,14 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
853 * specific MPT adapter. 870 * specific MPT adapter.
854 **/ 871 **/
855void 872void
856mpt_put_msg_frame_hi_pri(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf) 873mpt_put_msg_frame_hi_pri(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
857{ 874{
858 u32 mf_dma_addr; 875 u32 mf_dma_addr;
859 int req_offset; 876 int req_offset;
860 u16 req_idx; /* Request index */ 877 u16 req_idx; /* Request index */
861 878
862 /* ensure values are reset properly! */ 879 /* ensure values are reset properly! */
863 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; 880 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx;
864 req_offset = (u8 *)mf - (u8 *)ioc->req_frames; 881 req_offset = (u8 *)mf - (u8 *)ioc->req_frames;
865 req_idx = req_offset / ioc->req_sz; 882 req_idx = req_offset / ioc->req_sz;
866 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); 883 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx);
@@ -931,7 +948,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
931/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 948/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
932/** 949/**
933 * mpt_send_handshake_request - Send MPT request via doorbell handshake method. 950 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
934 * @handle: Handle of registered MPT protocol driver 951 * @cb_idx: Handle of registered MPT protocol driver
935 * @ioc: Pointer to MPT adapter structure 952 * @ioc: Pointer to MPT adapter structure
936 * @reqBytes: Size of the request in bytes 953 * @reqBytes: Size of the request in bytes
937 * @req: Pointer to MPT request frame 954 * @req: Pointer to MPT request frame
@@ -946,7 +963,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
946 * Returns 0 for success, non-zero for failure. 963 * Returns 0 for success, non-zero for failure.
947 */ 964 */
948int 965int
949mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag) 966mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag)
950{ 967{
951 int r = 0; 968 int r = 0;
952 u8 *req_as_bytes; 969 u8 *req_as_bytes;
@@ -966,7 +983,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
966 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) { 983 if (reqBytes >= 12 && ii >= 0 && ii < ioc->req_depth) {
967 MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req; 984 MPT_FRAME_HDR *mf = (MPT_FRAME_HDR*)req;
968 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii); 985 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(ii);
969 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle; 986 mf->u.frame.hwhdr.msgctxu.fld.cb_idx = cb_idx;
970 } 987 }
971 988
972 /* Make sure there are no doorbells */ 989 /* Make sure there are no doorbells */
@@ -1432,6 +1449,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1432 u32 msize; 1449 u32 msize;
1433 u32 psize; 1450 u32 psize;
1434 int ii; 1451 int ii;
1452 u8 cb_idx;
1435 int r = -ENODEV; 1453 int r = -ENODEV;
1436 u8 revision; 1454 u8 revision;
1437 u8 pcixcmd; 1455 u8 pcixcmd;
@@ -1655,10 +1673,10 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1655 } 1673 }
1656 1674
1657 /* call per device driver probe entry point */ 1675 /* call per device driver probe entry point */
1658 for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) { 1676 for(cb_idx=0; cb_idx<MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
1659 if(MptDeviceDriverHandlers[ii] && 1677 if(MptDeviceDriverHandlers[cb_idx] &&
1660 MptDeviceDriverHandlers[ii]->probe) { 1678 MptDeviceDriverHandlers[cb_idx]->probe) {
1661 MptDeviceDriverHandlers[ii]->probe(pdev,id); 1679 MptDeviceDriverHandlers[cb_idx]->probe(pdev,id);
1662 } 1680 }
1663 } 1681 }
1664 1682
@@ -1695,7 +1713,7 @@ mpt_detach(struct pci_dev *pdev)
1695{ 1713{
1696 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1714 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1697 char pname[32]; 1715 char pname[32];
1698 int ii; 1716 u8 cb_idx;
1699 1717
1700 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); 1718 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name);
1701 remove_proc_entry(pname, NULL); 1719 remove_proc_entry(pname, NULL);
@@ -1705,10 +1723,10 @@ mpt_detach(struct pci_dev *pdev)
1705 remove_proc_entry(pname, NULL); 1723 remove_proc_entry(pname, NULL);
1706 1724
1707 /* call per device driver remove entry point */ 1725 /* call per device driver remove entry point */
1708 for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) { 1726 for(cb_idx=0; cb_idx<MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
1709 if(MptDeviceDriverHandlers[ii] && 1727 if(MptDeviceDriverHandlers[cb_idx] &&
1710 MptDeviceDriverHandlers[ii]->remove) { 1728 MptDeviceDriverHandlers[cb_idx]->remove) {
1711 MptDeviceDriverHandlers[ii]->remove(pdev); 1729 MptDeviceDriverHandlers[cb_idx]->remove(pdev);
1712 } 1730 }
1713 } 1731 }
1714 1732
@@ -1820,7 +1838,7 @@ mpt_resume(struct pci_dev *pdev)
1820#endif 1838#endif
1821 1839
1822static int 1840static int
1823mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase) 1841mpt_signal_reset(u8 index, MPT_ADAPTER *ioc, int reset_phase)
1824{ 1842{
1825 if ((MptDriverClass[index] == MPTSPI_DRIVER && 1843 if ((MptDriverClass[index] == MPTSPI_DRIVER &&
1826 ioc->bus_type != SPI) || 1844 ioc->bus_type != SPI) ||
@@ -1862,6 +1880,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1862 int hard; 1880 int hard;
1863 int rc=0; 1881 int rc=0;
1864 int ii; 1882 int ii;
1883 u8 cb_idx;
1865 int handlers; 1884 int handlers;
1866 int ret = 0; 1885 int ret = 0;
1867 int reset_alt_ioc_active = 0; 1886 int reset_alt_ioc_active = 0;
@@ -2146,20 +2165,20 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2146 */ 2165 */
2147 if (hard_reset_done) { 2166 if (hard_reset_done) {
2148 rc = handlers = 0; 2167 rc = handlers = 0;
2149 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 2168 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
2150 if ((ret == 0) && MptResetHandlers[ii]) { 2169 if ((ret == 0) && MptResetHandlers[cb_idx]) {
2151 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2170 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2152 "Calling IOC post_reset handler #%d\n", 2171 "Calling IOC post_reset handler #%d\n",
2153 ioc->name, ii)); 2172 ioc->name, cb_idx));
2154 rc += mpt_signal_reset(ii, ioc, MPT_IOC_POST_RESET); 2173 rc += mpt_signal_reset(cb_idx, ioc, MPT_IOC_POST_RESET);
2155 handlers++; 2174 handlers++;
2156 } 2175 }
2157 2176
2158 if (alt_ioc_ready && MptResetHandlers[ii]) { 2177 if (alt_ioc_ready && MptResetHandlers[cb_idx]) {
2159 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT 2178 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2160 "Calling alt-%s post_reset handler #%d\n", 2179 "Calling alt-%s post_reset handler #%d\n",
2161 ioc->name, ioc->alt_ioc->name, ii)); 2180 ioc->name, ioc->alt_ioc->name, cb_idx));
2162 rc += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_POST_RESET); 2181 rc += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_POST_RESET);
2163 handlers++; 2182 handlers++;
2164 } 2183 }
2165 } 2184 }
@@ -3592,20 +3611,20 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3592 * MptResetHandlers[] registered yet. 3611 * MptResetHandlers[] registered yet.
3593 */ 3612 */
3594 { 3613 {
3595 int ii; 3614 u8 cb_idx;
3596 int r = 0; 3615 int r = 0;
3597 3616
3598 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 3617 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
3599 if (MptResetHandlers[ii]) { 3618 if (MptResetHandlers[cb_idx]) {
3600 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 3619 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3601 "Calling IOC pre_reset handler #%d\n", 3620 "Calling IOC pre_reset handler #%d\n",
3602 ioc->name, ii)); 3621 ioc->name, cb_idx));
3603 r += mpt_signal_reset(ii, ioc, MPT_IOC_PRE_RESET); 3622 r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_PRE_RESET);
3604 if (ioc->alt_ioc) { 3623 if (ioc->alt_ioc) {
3605 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT 3624 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3606 "Calling alt-%s pre_reset handler #%d\n", 3625 "Calling alt-%s pre_reset handler #%d\n",
3607 ioc->name, ioc->alt_ioc->name, ii)); 3626 ioc->name, ioc->alt_ioc->name, cb_idx));
3608 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_PRE_RESET); 3627 r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_PRE_RESET);
3609 } 3628 }
3610 } 3629 }
3611 } 3630 }
@@ -5907,7 +5926,7 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo
5907static int 5926static int
5908procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eof, void *data) 5927procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eof, void *data)
5909{ 5928{
5910 int ii; 5929 u8 cb_idx;
5911 int scsi, fc, sas, lan, ctl, targ, dmp; 5930 int scsi, fc, sas, lan, ctl, targ, dmp;
5912 char *drvname; 5931 char *drvname;
5913 int len; 5932 int len;
@@ -5916,10 +5935,10 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo
5916 len += sprintf(buf+len, " Fusion MPT base driver\n"); 5935 len += sprintf(buf+len, " Fusion MPT base driver\n");
5917 5936
5918 scsi = fc = sas = lan = ctl = targ = dmp = 0; 5937 scsi = fc = sas = lan = ctl = targ = dmp = 0;
5919 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 5938 for (cb_idx=MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
5920 drvname = NULL; 5939 drvname = NULL;
5921 if (MptCallbacks[ii]) { 5940 if (MptCallbacks[cb_idx]) {
5922 switch (MptDriverClass[ii]) { 5941 switch (MptDriverClass[cb_idx]) {
5923 case MPTSPI_DRIVER: 5942 case MPTSPI_DRIVER:
5924 if (!scsi++) drvname = "SPI host"; 5943 if (!scsi++) drvname = "SPI host";
5925 break; 5944 break;
@@ -6163,18 +6182,18 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6163 * For all other protocol drivers, this is a no-op. 6182 * For all other protocol drivers, this is a no-op.
6164 */ 6183 */
6165 { 6184 {
6166 int ii; 6185 u8 cb_idx;
6167 int r = 0; 6186 int r = 0;
6168 6187
6169 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 6188 for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
6170 if (MptResetHandlers[ii]) { 6189 if (MptResetHandlers[cb_idx]) {
6171 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n", 6190 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n",
6172 ioc->name, ii)); 6191 ioc->name, cb_idx));
6173 r += mpt_signal_reset(ii, ioc, MPT_IOC_SETUP_RESET); 6192 r += mpt_signal_reset(cb_idx, ioc, MPT_IOC_SETUP_RESET);
6174 if (ioc->alt_ioc) { 6193 if (ioc->alt_ioc) {
6175 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n", 6194 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n",
6176 ioc->name, ioc->alt_ioc->name, ii)); 6195 ioc->name, ioc->alt_ioc->name, cb_idx));
6177 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_SETUP_RESET); 6196 r += mpt_signal_reset(cb_idx, ioc->alt_ioc, MPT_IOC_SETUP_RESET);
6178 } 6197 }
6179 } 6198 }
6180 } 6199 }
@@ -6579,6 +6598,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6579 u32 evData0 = 0; 6598 u32 evData0 = 0;
6580// u32 evCtx; 6599// u32 evCtx;
6581 int ii; 6600 int ii;
6601 u8 cb_idx;
6582 int r = 0; 6602 int r = 0;
6583 int handlers = 0; 6603 int handlers = 0;
6584 char evStr[EVENT_DESCR_STR_SZ]; 6604 char evStr[EVENT_DESCR_STR_SZ];
@@ -6659,11 +6679,11 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6659 /* 6679 /*
6660 * Call each currently registered protocol event handler. 6680 * Call each currently registered protocol event handler.
6661 */ 6681 */
6662 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 6682 for (cb_idx=MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--) {
6663 if (MptEvHandlers[ii]) { 6683 if (MptEvHandlers[cb_idx]) {
6664 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n", 6684 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n",
6665 ioc->name, ii)); 6685 ioc->name, cb_idx));
6666 r += (*(MptEvHandlers[ii]))(ioc, pEventReply); 6686 r += (*(MptEvHandlers[cb_idx]))(ioc, pEventReply);
6667 handlers++; 6687 handlers++;
6668 } 6688 }
6669 } 6689 }
@@ -7354,8 +7374,6 @@ EXPORT_SYMBOL(mpt_send_handshake_request);
7354EXPORT_SYMBOL(mpt_verify_adapter); 7374EXPORT_SYMBOL(mpt_verify_adapter);
7355EXPORT_SYMBOL(mpt_GetIocState); 7375EXPORT_SYMBOL(mpt_GetIocState);
7356EXPORT_SYMBOL(mpt_print_ioc_summary); 7376EXPORT_SYMBOL(mpt_print_ioc_summary);
7357EXPORT_SYMBOL(mpt_lan_index);
7358EXPORT_SYMBOL(mpt_stm_index);
7359EXPORT_SYMBOL(mpt_HardResetHandler); 7377EXPORT_SYMBOL(mpt_HardResetHandler);
7360EXPORT_SYMBOL(mpt_config); 7378EXPORT_SYMBOL(mpt_config);
7361EXPORT_SYMBOL(mpt_findImVolumes); 7379EXPORT_SYMBOL(mpt_findImVolumes);
@@ -7373,16 +7391,16 @@ EXPORT_SYMBOL(mpt_raid_phys_disk_pg0);
7373static int __init 7391static int __init
7374fusion_init(void) 7392fusion_init(void)
7375{ 7393{
7376 int i; 7394 u8 cb_idx;
7377 7395
7378 show_mptmod_ver(my_NAME, my_VERSION); 7396 show_mptmod_ver(my_NAME, my_VERSION);
7379 printk(KERN_INFO COPYRIGHT "\n"); 7397 printk(KERN_INFO COPYRIGHT "\n");
7380 7398
7381 for (i = 0; i < MPT_MAX_PROTOCOL_DRIVERS; i++) { 7399 for (cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
7382 MptCallbacks[i] = NULL; 7400 MptCallbacks[cb_idx] = NULL;
7383 MptDriverClass[i] = MPTUNKNOWN_DRIVER; 7401 MptDriverClass[cb_idx] = MPTUNKNOWN_DRIVER;
7384 MptEvHandlers[i] = NULL; 7402 MptEvHandlers[cb_idx] = NULL;
7385 MptResetHandlers[i] = NULL; 7403 MptResetHandlers[cb_idx] = NULL;
7386 } 7404 }
7387 7405
7388 /* Register ourselves (mptbase) in order to facilitate 7406 /* Register ourselves (mptbase) in order to facilitate