2 * Core I2O structure managment
4 * (C) Copyright 1999 Red Hat Software
6 * Written by Alan Cox, Building Number Three Ltd
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
13 * A lot of the I2O message side code from this is taken from the
14 * Red Creek RCPCI45 adapter driver by Red Creek Communications
16 * Fixes by Philipp Rumpf
17 * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
18 * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
19 * Deepak Saxena <deepak@plexity.net>
22 #include <linux/config.h>
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/pci.h>
27 #if defined(CONFIG_I2O_PCI) || defined (CONFIG_I2O_PCI_MODULE)
28 #include <linux/i2o.h>
31 #include <linux/errno.h>
32 #include <linux/init.h>
33 #include <linux/malloc.h>
34 #include <linux/spinlock.h>
43 * Size of the I2O module table
46 static struct i2o_handler
*i2o_handlers
[MAX_I2O_MODULES
];
47 static struct i2o_controller
*i2o_controllers
[MAX_I2O_CONTROLLERS
];
48 int i2o_num_controllers
= 0;
49 static int core_context
= 0;
50 static int reply_flag
= 0;
52 extern int i2o_online_controller(struct i2o_controller
*c
);
53 static void i2o_core_reply(struct i2o_handler
*, struct i2o_controller
*,
54 struct i2o_message
*);
55 static int i2o_add_management_user(struct i2o_device
*, struct i2o_handler
*);
56 static int i2o_remove_management_user(struct i2o_device
*, struct i2o_handler
*);
57 static void i2o_dump_message(u32
*);
61 * Function table to send to bus specific layers
62 * See <include/linux/i2o.h> for explanation of this
64 static struct i2o_core_func_table i2o_core_functions
=
66 i2o_install_controller
,
67 i2o_activate_controller
,
69 i2o_unlock_controller
,
74 #ifdef CONFIG_I2O_PCI_MODULE
75 extern int i2o_pci_core_attach(struct i2o_core_func_table
*);
76 extern void i2o_pci_core_detach(void);
77 #endif /* CONFIG_I2O_PCI_MODULE */
83 static struct i2o_handler i2o_core_handler
=
85 (void *)i2o_core_reply
,
91 * I2O configuration spinlock. This isnt a big deal for contention
95 static spinlock_t i2o_configuration_lock
= SPIN_LOCK_UNLOCKED
;
97 void i2o_core_reply(struct i2o_handler
*h
, struct i2o_controller
*c
,
98 struct i2o_message
*m
)
101 u32
*flag
= (u32
*)msg
[3];
104 i2o_report_status(KERN_INFO
, "i2o_core", msg
);
107 if (msg
[0] & (1<<13)) // Fail bit is set
109 printk(KERN_ERR
"IOP failed to process the msg:\n");
110 printk(KERN_ERR
" Cmd = 0x%02X, InitiatorTid = %d, TargetTid =%d\n",
111 (msg
[1] >> 24) & 0xFF, (msg
[1] >> 12) & 0xFFF, msg
[1] &
113 printk(KERN_ERR
" FailureCode = 0x%02X\n Severity = 0x%02X\n"
114 "LowestVersion = 0x%02X\n HighestVersion = 0x%02X\n",
115 msg
[4] >> 24, (msg
[4] >> 16) & 0xFF,
116 (msg
[4] >> 8) & 0xFF, msg
[4] & 0xFF);
117 printk(KERN_ERR
" FailingHostUnit = 0x%04X\n FailingIOP = 0x%03X\n",
118 msg
[5] >> 16, msg
[5] & 0xFFF);
124 i2o_report_status(KERN_WARNING
, "i2o_core", msg
);
125 *flag
= -(msg
[4] & 0xFFFF);
128 *flag
= I2O_POST_WAIT_OK
;
132 * Install an I2O handler - these handle the asynchronous messaging
133 * from the card once it has initialised.
136 int i2o_install_handler(struct i2o_handler
*h
)
139 spin_lock(&i2o_configuration_lock
);
140 for(i
=0;i
<MAX_I2O_MODULES
;i
++)
142 if(i2o_handlers
[i
]==NULL
)
146 spin_unlock(&i2o_configuration_lock
);
150 spin_unlock(&i2o_configuration_lock
);
154 int i2o_remove_handler(struct i2o_handler
*h
)
156 i2o_handlers
[h
->context
]=NULL
;
162 * Each I2O controller has a chain of devices on it - these match
163 * the useful parts of the LCT of the board.
166 int i2o_install_device(struct i2o_controller
*c
, struct i2o_device
*d
)
170 spin_lock(&i2o_configuration_lock
);
178 for(i
= 0; i
< I2O_MAX_MANAGERS
; i
++)
179 d
->managers
[i
] = NULL
;
181 spin_unlock(&i2o_configuration_lock
);
185 /* we need this version to call out of i2o_delete_controller */
187 int __i2o_delete_device(struct i2o_device
*d
)
189 struct i2o_device
**p
;
191 p
=&(d
->controller
->devices
);
194 * Hey we have a driver!
217 printk(KERN_ERR
"i2o_delete_device: passed invalid device.\n");
221 int i2o_delete_device(struct i2o_device
*d
)
225 spin_lock(&i2o_configuration_lock
);
227 ret
= __i2o_delete_device(d
);
229 spin_unlock(&i2o_configuration_lock
);
235 * Add and remove controllers from the I2O controller list
238 int i2o_install_controller(struct i2o_controller
*c
)
241 spin_lock(&i2o_configuration_lock
);
242 for(i
=0;i
<MAX_I2O_CONTROLLERS
;i
++)
244 if(i2o_controllers
[i
]==NULL
)
246 i2o_controllers
[i
]=c
;
247 c
->next
=i2o_controller_chain
;
248 i2o_controller_chain
=c
;
250 sprintf(c
->name
, "i2o/iop%d", i
);
251 i2o_num_controllers
++;
252 spin_unlock(&i2o_configuration_lock
);
256 printk(KERN_ERR
"No free i2o controller slots.\n");
257 spin_unlock(&i2o_configuration_lock
);
261 int i2o_delete_controller(struct i2o_controller
*c
)
263 struct i2o_controller
**p
;
265 spin_lock(&i2o_configuration_lock
);
266 if(atomic_read(&c
->users
))
268 printk("Someone is using controller iop%d\n", c
->unit
);
269 spin_unlock(&i2o_configuration_lock
);
274 if(__i2o_delete_device(c
->devices
)<0)
276 /* Shouldnt happen */
277 spin_unlock(&i2o_configuration_lock
);
281 // c->destructor(c); /* We dont want to free the IRQ yet */
283 p
=&i2o_controller_chain
;
285 /* Send first SysQuiesce to other IOPs */
290 printk("Quiescing controller %p != %p\n", c
, *p
);
291 if(i2o_quiesce_controller(*p
)<0)
292 printk(KERN_INFO
"Unable to quiesce iop%d\n",
298 p
=&i2o_controller_chain
;
304 /* Ask the IOP to switch to HOLD state */
305 if (i2o_clear_controller(c
) < 0)
306 printk("Unable to clear iop%d\n", c
->unit
);
312 spin_unlock(&i2o_configuration_lock
);
314 kfree(c
->page_frame
);
319 i2o_controllers
[c
->unit
]=NULL
;
321 i2o_num_controllers
--;
326 spin_unlock(&i2o_configuration_lock
);
327 printk(KERN_ERR
"i2o_delete_controller: bad pointer!\n");
331 void i2o_unlock_controller(struct i2o_controller
*c
)
333 atomic_dec(&c
->users
);
336 struct i2o_controller
*i2o_find_controller(int n
)
338 struct i2o_controller
*c
;
340 if(n
<0 || n
>=MAX_I2O_CONTROLLERS
)
343 spin_lock(&i2o_configuration_lock
);
344 c
=i2o_controllers
[n
];
346 atomic_inc(&c
->users
);
347 spin_unlock(&i2o_configuration_lock
);
353 * Claim a device for use as either the primary user or just
354 * as a management/secondary user
356 int i2o_claim_device(struct i2o_device
*d
, struct i2o_handler
*h
, u32 type
)
358 /* Device already has a primary user or too many managers */
359 if((type
== I2O_CLAIM_PRIMARY
&& d
->owner
) ||
360 (d
->num_managers
== I2O_MAX_MANAGERS
))
365 if(i2o_issue_claim(d
->controller
,d
->id
, h
->context
, 1, &reply_flag
, type
) < 0)
370 spin_lock(&i2o_configuration_lock
);
373 spin_unlock(&i2o_configuration_lock
);
376 atomic_inc(&d
->controller
->users
);
378 if(type
== I2O_CLAIM_PRIMARY
)
381 i2o_add_management_user(d
, h
);
383 spin_unlock(&i2o_configuration_lock
);
387 int i2o_release_device(struct i2o_device
*d
, struct i2o_handler
*h
, u32 type
)
391 spin_lock(&i2o_configuration_lock
);
394 if(type
== I2O_CLAIM_PRIMARY
)
400 if(i2o_issue_claim(d
->controller
,d
->id
, h
->context
, 0, &reply_flag
, type
) < 0)
407 atomic_dec(&d
->controller
->users
);
411 spin_unlock(&i2o_configuration_lock
);
415 /* Management or other user */
416 if(i2o_remove_management_user(d
, h
))
420 atomic_dec(&d
->controller
->users
);
422 if(i2o_issue_claim(d
->controller
,d
->id
, h
->context
, 0,
423 &reply_flag
, type
) < 0)
427 spin_unlock(&i2o_configuration_lock
);
431 int i2o_add_management_user(struct i2o_device
*d
, struct i2o_handler
*h
)
435 if(d
->num_managers
== I2O_MAX_MANAGERS
)
438 for(i
= 0; i
< I2O_MAX_MANAGERS
; i
++)
447 int i2o_remove_management_user(struct i2o_device
*d
, struct i2o_handler
*h
)
451 for(i
=0; i
< I2O_MAX_MANAGERS
; i
++)
453 if(d
->managers
[i
] == h
)
455 d
->managers
[i
] = NULL
;
464 * This is called by the bus specific driver layer when an interrupt
465 * or poll of this card interface is desired.
468 void i2o_run_queue(struct i2o_controller
*c
)
470 struct i2o_message
*m
;
473 while((mv
=I2O_REPLY_READ32(c
))!=0xFFFFFFFF)
475 struct i2o_handler
*i
;
476 m
=(struct i2o_message
*)bus_to_virt(mv
);
478 * Temporary Debugging
480 if(((m
->function_addr
>>24)&0xFF)==0x15)
482 // printk("dispatching.\n");
483 i
=i2o_handlers
[m
->initiator_context
&(MAX_I2O_MODULES
-1)];
488 printk("Spurious reply to handler %d\n",
489 m
->initiator_context
&(MAX_I2O_MODULES
-1));
490 i2o_dump_message((u32
*)m
);
492 i2o_flush_reply(c
,mv
);
499 * Do i2o class name lookup
501 const char *i2o_get_class_name(int class)
504 static char *i2o_class_name
[] = {
506 "Device Driver Module",
511 "Fibre Channel Port",
512 "Fibre Channel Device",
518 "Secondary Bus Port",
519 "Peer Transport Agent",
526 case I2O_CLASS_EXECUTIVE
:
530 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
532 case I2O_CLASS_SEQUENTIAL_STORAGE
:
538 case I2O_CLASS_FIBRE_CHANNEL_PORT
:
540 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL
:
542 case I2O_CLASS_SCSI_PERIPHERAL
:
544 case I2O_CLASS_ATE_PORT
:
546 case I2O_CLASS_ATE_PERIPHERAL
:
548 case I2O_CLASS_FLOPPY_CONTROLLER
:
550 case I2O_CLASS_FLOPPY_DEVICE
:
552 case I2O_CLASS_BUS_ADAPTER_PORT
:
554 case I2O_CLASS_PEER_TRANSPORT_AGENT
:
556 case I2O_CLASS_PEER_TRANSPORT
:
560 return i2o_class_name
[idx
];
565 * Wait up to 5 seconds for a message slot to be available.
568 u32
i2o_wait_message(struct i2o_controller
*c
, char *why
)
572 while((m
=I2O_POST_READ32(c
))==0xFFFFFFFF)
574 if((jiffies
-time
)>=5*HZ
)
576 printk(KERN_ERR
"%s: Timeout waiting for message frame to send %s.\n",
588 * Wait up to timeout seconds for a reply to be available.
591 u32
i2o_wait_reply(struct i2o_controller
*c
, char *why
, int timeout
)
596 while((m
=I2O_REPLY_READ32(c
))==0xFFFFFFFF)
598 if(jiffies
-time
>= timeout
*HZ
)
600 printk(KERN_ERR
"%s: timeout waiting for %s reply.\n",
610 static int i2o_query_scalar_polled(struct i2o_controller
*c
, int tid
, void *buf
, int buflen
,
611 int group
, int field
)
620 op
[0]=1; /* One Operation */
622 op
[2]=1; /* FIELD_GET */
623 op
[3]=group
; /* group number */
624 op
[4]=1; /* 1 field */
625 op
[5]=field
; /* Field number */
627 m
=i2o_wait_message(c
, "ParamsGet");
633 msg
=(u32
*)(c
->mem_offset
+m
);
635 rbuf
=kmalloc(buflen
+32, GFP_KERNEL
);
638 printk(KERN_ERR
"No free memory for scalar read.\n");
642 msg
[0]=NINE_WORD_MSG_SIZE
|SGL_OFFSET_5
;
643 msg
[1]=I2O_CMD_UTIL_PARAMS_GET
<<24|HOST_TID
<<12|tid
;
644 msg
[2]=0; /* Context */
647 msg
[5]=0x54000000|12;
648 msg
[6]=virt_to_bus(op
);
649 msg
[7]=0xD0000000|(32+buflen
);
650 msg
[8]=virt_to_bus(rbuf
);
652 i2o_post_message(c
,m
);
656 * Now wait for a reply
659 m
=i2o_wait_reply(c
, "ParamsGet", 5);
667 msg
= (u32
*)bus_to_virt(m
);
670 i2o_report_status(KERN_WARNING
, "i2o_core", msg
);
675 /* Ok 'p' is the reply block - lets see what happened */
676 /* p0->p2 are the header */
678 /* FIXME: endians - turn p3 to little endian */
681 printk(KERN_WARNING
"Suspicious field read return 0x%08X\n", p
[0]);
683 i
=(p
[1]&0xFFFF)<<2; /* Message size */
687 /* Do we have an error block ? */
690 printk(KERN_ERR
"%s: error in field read.\n",
696 /* p[1] holds the more flag and row count - we dont care */
698 /* Ok it worked p[2]-> hold the data */
699 memcpy(buf
, p
+2, buflen
);
703 /* Finally return the message */
704 I2O_REPLY_WRITE32(c
,m
);
709 * Dump the information block associated with a given unit (TID)
712 void i2o_report_controller_unit(struct i2o_controller
*c
, int unit
)
716 if(i2o_query_scalar_polled(c
, unit
, buf
, 16, 0xF100, 3)>=0)
719 printk(KERN_INFO
" Vendor: %s\n", buf
);
721 if(i2o_query_scalar_polled(c
, unit
, buf
, 16, 0xF100, 4)>=0)
724 printk(KERN_INFO
" Device: %s\n", buf
);
727 if(i2o_query_scalar_polled(c
, unit
, buf
, 16, 0xF100, 5)>=0)
730 printk(KERN_INFO
"Description: %s\n", buf
);
733 if(i2o_query_scalar_polled(c
, unit
, buf
, 8, 0xF100, 6)>=0)
736 printk(KERN_INFO
" Rev: %s\n", buf
);
742 * Parse the hardware resource table. Right now we print it out
743 * and don't do a lot with it. We should collate these and then
744 * interact with the Linux resource allocation block.
746 * Lets prove we can read it first eh ?
748 * This is full of endianisms!
751 static int i2o_parse_hrt(struct i2o_controller
*c
)
763 printk(KERN_ERR
"i2o: HRT table for controller is too new a version.\n");
767 count
=p
[0]|(p
[1]<<8);
770 printk(KERN_INFO
"HRT has %d entries of %d bytes each.\n",
777 printk(KERN_INFO
"Adapter %08X: ", rows
[0]);
782 printk("TID %04X:[", state
&0xFFF);
785 printk("H"); /* Hidden */
788 printk("P"); /* Present */
790 printk("C"); /* Controlled */
793 printk("*"); /* Hard */
800 /* Adapter private bus - easy */
801 printk("Local bus %d: I/O at 0x%04X Mem 0x%08X",
802 p
[2], d
[1]<<8|d
[0], *(u32
*)(d
+4));
806 printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X",
807 p
[2], d
[2], d
[1]<<8|d
[0], *(u32
*)(d
+4));
810 case 2: /* EISA bus */
811 printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
812 p
[2], d
[3], d
[1]<<8|d
[0], *(u32
*)(d
+4));
815 case 3: /* MCA bus */
816 printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
817 p
[2], d
[3], d
[1]<<8|d
[0], *(u32
*)(d
+4));
820 case 4: /* PCI bus */
821 printk("PCI %d: Bus %d Device %d Function %d",
822 p
[2], d
[2], d
[1], d
[0]);
825 case 0x80: /* Other */
827 printk("Unsupported bus type.");
837 * The logical configuration table tells us what we can talk to
838 * on the board. Most of the stuff isn't interesting to us.
841 static int i2o_parse_lct(struct i2o_controller
*c
)
847 struct i2o_device
*d
;
849 u32
*lct
=(u32
*)c
->lct
;
858 printk(KERN_ERR
"LCT is empty????\n");
862 printk(KERN_INFO
"LCT has %d entries.\n", max
);
866 printk(KERN_INFO
"LCT was truncated.\n");
871 printk(KERN_WARNING
"Configuration dialog desired.\n");
877 d
= (struct i2o_device
*)kmalloc(sizeof(struct i2o_device
), GFP_KERNEL
);
880 printk("i2o_core: Out of memory for LCT data.\n");
887 d
->id
= tid
= (p
[0]>>16)&0xFFF;
888 d
->class = p
[3]&0xFFF;
889 d
->subclass
= p
[4]&0xFFF;
890 d
->parent
= (p
[5]>>12)&0xFFF;
893 printk(KERN_INFO
"TID %d.\n", tid
);
895 i2o_report_controller_unit(c
, tid
);
897 i2o_install_device(c
, d
);
899 printk(KERN_INFO
" Class: ");
901 sprintf(str
, "%-21s", i2o_get_class_name(d
->class));
904 printk(" Subclass: 0x%03X Flags: ",
908 printk("C"); // ConfigDialog requested
910 printk("M"); // Multi-user capable
912 printk("P"); // Peer service enabled!
914 printk("m"); // Mgmt service enabled!
922 int i2o_quiesce_controller(struct i2o_controller
*c
)
926 msg
[0]=FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
927 msg
[1]=I2O_CMD_SYS_QUIESCE
<<24|HOST_TID
<<12|ADAPTER_TID
;
929 msg
[3]=(u32
)&reply_flag
;
931 /* Long timeout needed for quiesce if lots of devices */
932 return i2o_post_wait(c
, ADAPTER_TID
, msg
, sizeof(msg
), &reply_flag
, 120);
936 int i2o_clear_controller(struct i2o_controller
*c
)
940 /* First stop external operations for this IOP */
941 if(i2o_quiesce_controller(c
)<0)
942 printk(KERN_INFO
"Unable to quiesce iop%d\n", c
->unit
);
944 printk(KERN_INFO
"Iop%d quiesced\n", c
->unit
);
946 /* Then clear the IOP */
947 msg
[0]=FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
948 msg
[1]=I2O_CMD_ADAPTER_CLEAR
<<24|HOST_TID
<<12|ADAPTER_TID
;
950 msg
[3]=(u32
)&reply_flag
;
952 return i2o_post_wait(c
, ADAPTER_TID
, msg
, sizeof(msg
), &reply_flag
, 10);
956 /* Reset the IOP to sane state */
957 static int i2o_reset_controller(struct i2o_controller
*c
)
963 struct i2o_controller
*iop
;
965 /* First stop external operations */
966 for(iop
=i2o_controller_chain
; iop
!= NULL
; iop
=iop
->next
)
968 /* Quiesce is rejected on hold state */
969 if(iop
->status
!= ADAPTER_STATE_HOLD
)
971 if(i2o_quiesce_controller(iop
)<0)
972 printk(KERN_INFO
"Unable to quiesce iop%d\n",
975 printk(KERN_DEBUG
"%s quiesced\n", iop
->name
);
979 /* Then reset the IOP */
980 m
=i2o_wait_message(c
, "AdapterReset");
984 msg
=(u32
*)(c
->mem_offset
+m
);
986 work8
=(void *)kmalloc(4, GFP_KERNEL
);
988 printk(KERN_ERR
"IOP reset failed - no free memory.\n");
994 msg
[0]=EIGHT_WORD_MSG_SIZE
|SGL_OFFSET_0
;
995 msg
[1]=I2O_CMD_ADAPTER_RESET
<<24|HOST_TID
<<12|ADAPTER_TID
;
997 msg
[3]=(u32
)&reply_flag
;
1000 msg
[6]=virt_to_phys(work8
);
1001 msg
[7]=0; /* 64bit host FIXME */
1003 i2o_post_message(c
,m
);
1005 /* Wait for a reply */
1008 while(work8
[0]==0x01)
1010 if((jiffies
-time
)>=5*HZ
)
1012 printk(KERN_ERR
"IOP reset timeout.\n");
1021 printk(KERN_WARNING
"IOP Reset rejected\n");
1027 int i2o_status_get(struct i2o_controller
*c
)
1034 status_block
=(void *)kmalloc(88, GFP_KERNEL
);
1035 if(status_block
==NULL
)
1037 printk(KERN_ERR
"StatusGet failed - no free memory.\n");
1041 m
=i2o_wait_message(c
, "StatusGet");
1045 msg
=(u32
*)(c
->mem_offset
+m
);
1047 msg
[0]=NINE_WORD_MSG_SIZE
|SGL_OFFSET_0
;
1048 msg
[1]=I2O_CMD_STATUS_GET
<<24|HOST_TID
<<12|ADAPTER_TID
;
1049 msg
[2]=core_context
;
1053 msg
[6]=virt_to_phys(status_block
);
1054 msg
[7]=0; /* 64bit host FIXME */
1057 i2o_post_message(c
,m
);
1059 /* Wait for a reply */
1062 while(status_block
[87]!=0xFF)
1064 if((jiffies
-time
)>=5*HZ
)
1066 printk(KERN_ERR
"IOP get status timeout.\n");
1073 /* Ok the reply has arrived. Fill in the important stuff */
1074 c
->status
= status_block
[10];
1075 c
->i2oversion
= (status_block
[9]>>4)&0xFF;
1076 c
->inbound_size
= (status_block
[12]|(status_block
[13]<<8))*4;
1082 int i2o_hrt_get(struct i2o_controller
*c
)
1087 c
->hrt
=kmalloc(2048, GFP_KERNEL
);
1090 printk(KERN_ERR
"IOP init failed; no memory.\n");
1094 m
=i2o_wait_message(c
, "HRTGet");
1098 msg
=(u32
*)(c
->mem_offset
+m
);
1100 msg
[0]= SIX_WORD_MSG_SIZE
| SGL_OFFSET_4
;
1101 msg
[1]= I2O_CMD_HRT_GET
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1102 msg
[2]= core_context
;
1103 msg
[3]= 0x0; /* Transaction context */
1104 msg
[4]= (0xD0000000 | 2048); /* Simple transaction , 2K */
1105 msg
[5]= virt_to_phys(c
->hrt
); /* Dump it here */
1107 i2o_post_message(c
,m
);
1111 /* Now wait for a reply */
1112 m
=i2o_wait_reply(c
, "HRTGet", 5);
1117 msg
=(u32
*)bus_to_virt(m
);
1120 i2o_report_status(KERN_WARNING
, "i2o_core", msg
);
1122 I2O_REPLY_WRITE32(c
,m
);
1129 * Bring an I2O controller into HOLD state. See the 1.5
1130 * spec. Basically we go
1132 * Wait for the message queue to initialise.
1133 * If it didnt -> controller is dead
1135 * Send a get status using the message queue
1136 * Poll for a reply block 88 bytes long
1138 * Send an initialise outbound queue
1141 * Post our blank messages to the queue FIFO
1143 * Send GetHRT, Parse it
1146 int i2o_activate_controller(struct i2o_controller
*c
)
1155 printk(KERN_INFO
"Configuring I2O controller at 0x%08X.\n",
1158 if((ret
=i2o_status_get(c
)))
1161 if(c
->status
== ADAPTER_STATE_FAULTED
) /* not likely to be seen */
1163 printk(KERN_CRIT
"i2o: iop%d has hardware fault\n",
1169 * If the board is running, reset it - we have no idea
1170 * what kind of a mess the previous owner left it in.
1172 if(c
->status
== ADAPTER_STATE_HOLD
||
1173 c
->status
== ADAPTER_STATE_READY
||
1174 c
->status
== ADAPTER_STATE_OPERATIONAL
||
1175 c
->status
== ADAPTER_STATE_FAILED
)
1177 if((ret
=i2o_reset_controller(c
)))
1180 if((ret
=i2o_status_get(c
)))
1184 workspace
= (void *)kmalloc(88, GFP_KERNEL
);
1187 printk(KERN_ERR
"IOP initialisation failed - no free memory.\n");
1191 memset(workspace
, 0, 88);
1193 m
=i2o_wait_message(c
, "OutboundInit");
1200 msg
=(u32
*)(c
->mem_offset
+m
);
1202 msg
[0]= EIGHT_WORD_MSG_SIZE
| TRL_OFFSET_6
;
1203 msg
[1]= I2O_CMD_OUTBOUND_INIT
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1204 msg
[2]= core_context
;
1205 msg
[3]= 0x0106; /* Transaction context */
1206 msg
[4]= 4096; /* Host page frame size */
1207 msg
[5]= MSG_FRAME_SIZE
<<16|0x80; /* Outbound msg frame size and Initcode */
1208 msg
[6]= 0xD0000004; /* Simple SG LE, EOB */
1209 msg
[7]= virt_to_phys(workspace
);
1210 *((u32
*)workspace
)=0;
1216 i2o_post_message(c
,m
);
1222 while(workspace
[0]!=I2O_CMD_OUTBOUND_INIT_COMPLETE
)
1224 if((jiffies
-time
)>=5*HZ
)
1226 printk(KERN_ERR
"IOP outbound initialise failed.\n");
1236 /* TODO: v2.0: Set Executive class group 000Bh - OS Operating Info */
1238 c
->page_frame
= kmalloc(MSG_POOL_SIZE
, GFP_KERNEL
);
1239 if(c
->page_frame
==NULL
)
1241 printk(KERN_ERR
"IOP init failed: no memory for message page.\n");
1245 m
=virt_to_phys(c
->page_frame
);
1247 for(i
=0; i
< NMBR_MSG_FRAMES
; i
++)
1249 I2O_REPLY_WRITE32(c
,m
);
1255 * The outbound queue is initialised and loaded,
1257 * Now we need the Hardware Resource Table. We must ask for
1258 * this next we can't issue random messages yet.
1264 ret
=i2o_parse_hrt(c
);
1268 return i2o_online_controller(c
);
1269 // i2o_report_controller_unit(c, ADAPTER_TID);
1273 int i2o_lct_get(struct i2o_controller
*c
)
1278 m
=i2o_wait_message(c
, "LCTNotify");
1283 msg
=(u32
*)(c
->mem_offset
+m
);
1285 c
->lct
= kmalloc(8192, GFP_KERNEL
);
1288 msg
[0]=FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
1289 msg
[1]= HOST_TID
<<12|ADAPTER_TID
; /* NOP */
1290 i2o_post_message(c
,m
);
1291 printk(KERN_ERR
"No free memory for i2o controller buffer.\n");
1295 memset(c
->lct
, 0, 8192);
1297 msg
[0] = EIGHT_WORD_MSG_SIZE
|SGL_OFFSET_6
;
1298 msg
[1] = I2O_CMD_LCT_NOTIFY
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1299 msg
[2] = 0; /* Context not needed */
1301 msg
[4] = 0xFFFFFFFF; /* All devices */
1302 msg
[5] = 0x00000000; /* Report now */
1303 msg
[6] = 0xD0000000|8192;
1304 msg
[7] = virt_to_bus(c
->lct
);
1306 i2o_post_message(c
,m
);
1310 /* Now wait for a reply */
1311 m
=i2o_wait_reply(c
, "LCTNotify", 5);
1316 msg
=(u32
*)bus_to_virt(m
);
1318 /* TODO: Check TableSize for big LCTs and send new ExecLctNotify
1319 * with bigger workspace */
1322 i2o_report_status(KERN_ERR
, "i2o_core", msg
);
1329 * Bring a controller online. Needs completing for multiple controllers
1332 int i2o_online_controller(struct i2o_controller
*c
)
1345 systab
[4]=0; /* Organisation ID */
1346 systab
[5]=2; /* Ident 2 for now */
1347 systab
[6]=0<<24|0<<16|I2OVERSION
<<12|1; /* Memory mapped, IOPState, v1.5, segment 1 */
1348 systab
[7]=MSG_FRAME_SIZE
>>2; /* Message size */
1349 systab
[8]=0; /* LastChanged */
1350 systab
[9]=0; /* Should be IOP capabilities */
1351 systab
[10]=virt_to_phys(c
->post_port
);
1354 privmem
[0]=c
->priv_mem
; /* Private memory space base address */
1355 privmem
[1]=c
->priv_mem_size
;
1356 privio
[0]=c
->priv_io
; /* Private I/O address */
1357 privio
[1]=c
->priv_io_size
;
1359 m
=i2o_wait_message(c
, "SysTabSet");
1363 /* Now we build the systab */
1364 msg
=(u32
*)(c
->mem_offset
+m
);
1366 msg
[0] = NINE_WORD_MSG_SIZE
|SGL_OFFSET_6
;
1367 msg
[1] = I2O_CMD_SYS_TAB_SET
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1368 msg
[2] = 0; /* Context not needed */
1370 msg
[4] = (1<<16)|(2<<12); /* Host 1 I2O 2 */
1371 msg
[5] = 1; /* Segment 1 */
1374 * Scatter Gather List
1377 msg
[6] = 0x54000000|48; /* One table for now */
1378 msg
[7] = virt_to_phys(systab
);
1379 msg
[8] = 0xD4000000|48; /* One table for now */
1380 msg
[9] = virt_to_phys(privmem
);
1381 /* msg[10] = virt_to_phys(privio); */
1383 i2o_post_message(c
,m
);
1388 * Now wait for a reply
1392 m
=i2o_wait_reply(c
, "SysTabSet", 5);
1397 msg
=(u32
*)bus_to_virt(m
);
1401 i2o_report_status(KERN_ERR
, "i2o_core", msg
);
1403 I2O_REPLY_WRITE32(c
,m
);
1406 * Finally we go online
1409 m
=i2o_wait_message(c
, "SysEnable");
1414 msg
=(u32
*)(c
->mem_offset
+m
);
1416 msg
[0] = FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
1417 msg
[1] = I2O_CMD_SYS_ENABLE
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1418 msg
[2] = 0; /* Context not needed */
1421 i2o_post_message(c
,m
);
1426 * Now wait for a reply
1430 m
=i2o_wait_reply(c
, "SysEnable", 240);
1435 msg
=(u32
*)bus_to_virt(m
);
1439 i2o_report_status(KERN_ERR
, "i2o_core", msg
);
1441 I2O_REPLY_WRITE32(c
,m
);
1444 * Grab the LCT, see what is attached
1450 /* Maybe we should do also sthg else */
1454 ret
=i2o_parse_lct(c
);
1458 I2O_REPLY_WRITE32(c
,m
);
1464 * Run time support routines
1468 * Generic "post and forget" helpers. This is less efficient - we do
1469 * a memcpy for example that isnt strictly needed, but for most uses
1470 * this is simply not worth optimising
1473 int i2o_post_this(struct i2o_controller
*c
, int tid
, u32
*data
, int len
)
1477 unsigned long t
=jiffies
;
1482 m
= I2O_POST_READ32(c
);
1484 while(m
==0xFFFFFFFF && (jiffies
-t
)<HZ
);
1489 printk(KERN_ERR
"i2o: controller not responding.\n");
1492 msg
= bus_to_virt(c
->mem_offset
+ m
);
1493 memcpy(msg
, data
, len
);
1494 i2o_post_message(c
,m
);
1499 * Post a message and wait for a response flag to be set. This API will
1500 * change to use wait_queue's one day
1503 int i2o_post_wait(struct i2o_controller
*c
, int tid
, u32
*data
, int len
, int *flag
, int timeout
)
1505 unsigned long t
=jiffies
;
1509 if(i2o_post_this(c
, tid
, data
, len
))
1510 return I2O_POST_WAIT_TIMEOUT
;
1512 while(!*flag
&& (jiffies
-t
)<timeout
*HZ
)
1519 return *flag
; /* DetailedStatus */
1522 return I2O_POST_WAIT_TIMEOUT
;
1524 return I2O_POST_WAIT_OK
;
1528 * Issue UTIL_CLAIM messages
1531 int i2o_issue_claim(struct i2o_controller
*c
, int tid
, int context
, int onoff
, int *flag
, u32 type
)
1535 msg
[0] = FIVE_WORD_MSG_SIZE
| SGL_OFFSET_0
;
1537 msg
[1] = I2O_CMD_UTIL_CLAIM
<< 24 | HOST_TID
<<12 | tid
;
1539 msg
[1] = I2O_CMD_UTIL_RELEASE
<< 24 | HOST_TID
<< 12 | tid
;
1541 /* The 0x80000000 convention for flagging is assumed by this helper */
1543 msg
[2] = 0x80000000|context
;
1547 return i2o_post_wait(c
, tid
, msg
, 20, flag
,2);
1550 /* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET
1552 * This function can be used for all UtilParamsGet/Set operations.
1553 * The OperationBlock is given in opblk-buffer,
1554 * and results are returned in resblk-buffer.
1555 * Note that the minimum sized resblk is 8 bytes and contains
1556 * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
1558 int i2o_issue_params(int cmd
,
1559 struct i2o_controller
*iop
, int tid
, int context
,
1560 void *opblk
, int oplen
, void *resblk
, int reslen
,
1564 u8
*res
= (u8
*)resblk
;
1570 msg
[0] = NINE_WORD_MSG_SIZE
| SGL_OFFSET_5
;
1571 msg
[1] = cmd
<< 24 | HOST_TID
<< 12 | tid
;
1572 msg
[2] = context
| 0x80000000;
1575 msg
[5] = 0x54000000 | oplen
; /* OperationBlock */
1576 msg
[6] = virt_to_bus(opblk
);
1577 msg
[7] = 0xD0000000 | reslen
; /* ResultBlock */
1578 msg
[8] = virt_to_bus(resblk
);
1580 wait_status
= i2o_post_wait(iop
, tid
, msg
, sizeof(msg
), flag
, 10);
1581 if (wait_status
< 0)
1582 return wait_status
; /* -DetailedStatus */
1584 if (res
[1]&0x00FF0000) /* BlockStatus != SUCCESS */
1586 printk(KERN_WARNING
"%s - Error:\n ErrorInfoSize = 0x%02x, "
1587 "BlockStatus = 0x%02x, BlockSize = 0x%04x\n",
1588 (cmd
== I2O_CMD_UTIL_PARAMS_SET
) ? "PARAMS_SET"
1590 res
[1]>>24, (res
[1]>>16)&0xFF, res
[1]&0xFFFF);
1591 return -((res
[1] >> 16) & 0xFF); /* -BlockStatus */
1594 res_count
= res
[0] & 0xFFFF; /* # of resultblocks */
1599 blk_size
= (res
[0] & 0xFFFF) << 2;
1604 return bytes
; /* total sizeof Result List in bytes */
1608 * Query one scalar group value or a whole scalar group.
1610 int i2o_query_scalar(struct i2o_controller
*iop
, int tid
, int context
,
1611 int group
, int field
, void *buf
, int buflen
, int *flag
)
1613 u16 opblk
[] = { 1, 0, I2O_PARAMS_FIELD_GET
, group
, 1, field
};
1614 u8 resblk
[8+buflen
]; /* 8 bytes for header */
1617 if (field
== -1) /* whole group */
1620 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET
, iop
, tid
, context
,
1621 opblk
, sizeof(opblk
), resblk
, sizeof(resblk
), flag
);
1626 memcpy(buf
, resblk
+8, buflen
); /* cut off header */
1631 * Set a scalar group value or a whole group.
1633 int i2o_set_scalar(struct i2o_controller
*iop
, int tid
, int context
,
1634 int group
, int field
, void *buf
, int buflen
, int *flag
)
1637 u8 resblk
[8+buflen
]; /* 8 bytes for header */
1640 opblk
= kmalloc(buflen
+64, GFP_KERNEL
);
1643 printk(KERN_ERR
"i2o: no memory for operation buffer.\n");
1647 opblk
[0] = 1; /* operation count */
1648 opblk
[1] = 0; /* pad */
1649 opblk
[2] = I2O_PARAMS_FIELD_SET
;
1652 if(field
== -1) { /* whole group */
1654 memcpy(opblk
+5, buf
, buflen
);
1656 else /* single field */
1660 memcpy(opblk
+6, buf
, buflen
);
1663 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1664 opblk
, 12+buflen
, resblk
, sizeof(resblk
), flag
);
1671 * if oper == I2O_PARAMS_TABLE_GET:
1672 * Get all table group fields from all rows or
1673 * get specific table group fields from all rows.
1675 * if fieldcount == -1 we query all fields from all rows
1676 * ibuf is NULL and ibuflen is 0
1677 * else we query specific fields from all rows
1678 * ibuf contains fieldindexes
1680 * if oper == I2O_PARAMS_LIST_GET:
1681 * Get all table group fields from specified rows or
1682 * get specific table group fields from specified rows.
1684 * if fieldcount == -1 we query all fields from specified rows
1685 * ibuf contains rowcount, keyvalues
1686 * else we query specific fields from specified rows
1687 * ibuf contains fieldindexes, rowcount, keyvalues
1689 * You could also use directly function i2o_issue_params().
1691 int i2o_query_table(int oper
,
1692 struct i2o_controller
*iop
, int tid
, int context
, int group
,
1693 int fieldcount
, void *ibuf
, int ibuflen
,
1694 void *resblk
, int reslen
, int *flag
)
1699 opblk
= kmalloc(10 + ibuflen
, GFP_KERNEL
);
1702 printk(KERN_ERR
"i2o: no memory for query buffer.\n");
1706 opblk
[0] = 1; /* operation count */
1707 opblk
[1] = 0; /* pad */
1710 opblk
[4] = fieldcount
;
1711 memcpy(opblk
+5, ibuf
, ibuflen
); /* other params */
1713 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET
,iop
, tid
, context
,
1714 opblk
, 10+ibuflen
, resblk
, reslen
, flag
);
1721 * Clear table group, i.e. delete all rows.
1724 int i2o_clear_table(struct i2o_controller
*iop
, int tid
, int context
,
1725 int group
, int *flag
)
1727 u16 opblk
[] = { 1, 0, I2O_PARAMS_TABLE_CLEAR
, group
};
1728 u8 resblk
[32]; /* min 8 bytes for result header */
1730 return i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1731 opblk
, sizeof(opblk
), resblk
, sizeof(resblk
), flag
);
1735 * Add a new row into a table group.
1737 * if fieldcount==-1 then we add whole rows
1738 * buf contains rowcount, keyvalues
1739 * else just specific fields are given, rest use defaults
1740 * buf contains fieldindexes, rowcount, keyvalues
1743 int i2o_row_add_table(struct i2o_controller
*iop
, int tid
, int context
,
1744 int group
, int fieldcount
, void *buf
, int buflen
,
1748 u8 resblk
[32]; /* min 8 bytes for header */
1751 opblk
= kmalloc(buflen
+64, GFP_KERNEL
);
1754 printk(KERN_ERR
"i2o: no memory for operation buffer.\n");
1758 opblk
[0] = 1; /* operation count */
1759 opblk
[1] = 0; /* pad */
1760 opblk
[2] = I2O_PARAMS_ROW_ADD
;
1762 opblk
[4] = fieldcount
;
1763 memcpy(opblk
+5, buf
, buflen
);
1765 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1766 opblk
, 10+buflen
, resblk
, sizeof(resblk
), flag
);
1773 * Delete rows from a table group.
1776 int i2o_row_delete_table(struct i2o_controller
*iop
, int tid
, int context
,
1777 int group
, int keycount
, void *keys
, int keyslen
,
1781 u8 resblk
[32]; /* min 8 bytes for header */
1784 opblk
= kmalloc(keyslen
+64, GFP_KERNEL
);
1787 printk(KERN_ERR
"i2o: no memory for operation buffer.\n");
1791 opblk
[0] = 1; /* operation count */
1792 opblk
[1] = 0; /* pad */
1793 opblk
[2] = I2O_PARAMS_ROW_DELETE
;
1795 opblk
[4] = keycount
;
1796 memcpy(opblk
+5, keys
, keyslen
);
1798 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1799 opblk
, 10+keyslen
, resblk
, sizeof(resblk
), flag
);
1805 void i2o_report_common_status(u8 req_status
)
1807 /* the following reply status strings are common to all classes */
1809 static char *REPLY_STATUS
[] = {
1812 "ABORT_NO_DATA_TRANSFER",
1813 "ABORT_PARTIAL_TRANSFER",
1815 "ERROR_NO_DATA_TRANSFER",
1816 "ERROR_PARTIAL_TRANSFER",
1817 "PROCESS_ABORT_DIRTY",
1818 "PROCESS_ABORT_NO_DATA_TRANSFER",
1819 "PROCESS_ABORT_PARTIAL_TRANSFER",
1820 "TRANSACTION_ERROR",
1824 if (req_status
> I2O_REPLY_STATUS_PROGRESS_REPORT
)
1825 printk("%0#4x / ", req_status
);
1827 printk("%s / ", REPLY_STATUS
[req_status
]);
1832 static void i2o_report_common_dsc(u16 detailed_status
)
1834 /* The following detailed statuscodes are valid
1835 - for executive class, utility class, DDM class and
1836 - for transaction error replies
1839 static char *COMMON_DSC
[] = {
1844 "REPLY_BUFFER_FULL",
1846 "INSUFFICIENT_RESOURCE_SOFT",
1847 "INSUFFICIENT_RESOURCE_HARD",
1849 "CHAIN_BUFFER_TOO_LARGE",
1850 "UNSUPPORTED_FUNCTION",
1853 "INAPPROPRIATE_FUNCTION",
1854 "INVALID_INITIATOR_ADDRESS",
1855 "INVALID_MESSAGE_FLAGS",
1857 "INVALID_PARAMETER",
1859 "INVALID_TARGET_ADDRESS",
1860 "MESSAGE_TOO_LARGE",
1861 "MESSAGE_TOO_SMALL",
1862 "MISSING_PARAMETER",
1866 "UNSUPPORTED_VERSION",
1868 "DEVICE_NOT_AVAILABLE"
1871 if (detailed_status
> I2O_DSC_DEVICE_NOT_AVAILABLE
)
1872 printk("%0#4x.\n", detailed_status
);
1874 printk("%s.\n", COMMON_DSC
[detailed_status
]);
1879 static void i2o_report_lan_dsc(u16 detailed_status
)
1881 static char *LAN_DSC
[] = { // Lan detailed status code strings
1884 "DESTINATION_NOT_FOUND",
1890 "BAD_PACKET_DETECTED",
1893 "IOP_INTERNAL_ERROR",
1895 "INVALID_TRANSACTION_CONTEXT",
1896 "DEST_ADDRESS_DETECTED",
1897 "DEST_ADDRESS_OMITTED",
1898 "PARTIAL_PACKET_RETURNED",
1899 "TEMP_SUSPENDED_STATE", // last Lan detailed status code
1900 "INVALID_REQUEST" // general detailed status code
1903 if (detailed_status
> I2O_DSC_INVALID_REQUEST
)
1904 printk("%0#4x.\n", detailed_status
);
1906 printk("%s.\n", LAN_DSC
[detailed_status
]);
1911 static void i2o_report_util_cmd(u8 cmd
)
1914 case I2O_CMD_UTIL_NOP
:
1915 printk("UTIL_NOP, ");
1917 case I2O_CMD_UTIL_ABORT
:
1918 printk("UTIL_ABORT, ");
1920 case I2O_CMD_UTIL_CLAIM
:
1921 printk("UTIL_CLAIM, ");
1923 case I2O_CMD_UTIL_RELEASE
:
1924 printk("UTIL_CLAIM_RELEASE, ");
1926 case I2O_CMD_UTIL_CONFIG_DIALOG
:
1927 printk("UTIL_CONFIG_DIALOG, ");
1929 case I2O_CMD_UTIL_DEVICE_RESERVE
:
1930 printk("UTIL_DEVICE_RESERVE, ");
1932 case I2O_CMD_UTIL_DEVICE_RELEASE
:
1933 printk("UTIL_DEVICE_RELEASE, ");
1935 case I2O_CMD_UTIL_ACK
:
1936 printk("UTIL_EVENT_ACKNOWLEDGE, ");
1938 case I2O_CMD_UTIL_EVT_REGISTER
:
1939 printk("UTIL_EVENT_REGISTER, ");
1941 case I2O_CMD_UTIL_LOCK
:
1942 printk("UTIL_LOCK, ");
1944 case I2O_CMD_UTIL_LOCK_RELEASE
:
1945 printk("UTIL_LOCK_RELEASE, ");
1947 case I2O_CMD_UTIL_PARAMS_GET
:
1948 printk("UTIL_PARAMS_GET, ");
1950 case I2O_CMD_UTIL_PARAMS_SET
:
1951 printk("UTIL_PARAMS_SET, ");
1953 case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY
:
1954 printk("UTIL_REPLY_FAULT_NOTIFY, ");
1957 printk("%0#2x, ",cmd
);
1964 static void i2o_report_exec_cmd(u8 cmd
)
1967 case I2O_CMD_ADAPTER_ASSIGN
:
1968 printk("EXEC_ADAPTER_ASSIGN, ");
1970 case I2O_CMD_ADAPTER_READ
:
1971 printk("EXEC_ADAPTER_READ, ");
1973 case I2O_CMD_ADAPTER_RELEASE
:
1974 printk("EXEC_ADAPTER_RELEASE, ");
1976 case I2O_CMD_BIOS_INFO_SET
:
1977 printk("EXEC_BIOS_INFO_SET, ");
1979 case I2O_CMD_BOOT_DEVICE_SET
:
1980 printk("EXEC_BOOT_DEVICE_SET, ");
1982 case I2O_CMD_CONFIG_VALIDATE
:
1983 printk("EXEC_CONFIG_VALIDATE, ");
1985 case I2O_CMD_CONN_SETUP
:
1986 printk("EXEC_CONN_SETUP, ");
1988 case I2O_CMD_DDM_DESTROY
:
1989 printk("EXEC_DDM_DESTROY, ");
1991 case I2O_CMD_DDM_ENABLE
:
1992 printk("EXEC_DDM_ENABLE, ");
1994 case I2O_CMD_DDM_QUIESCE
:
1995 printk("EXEC_DDM_QUIESCE, ");
1997 case I2O_CMD_DDM_RESET
:
1998 printk("EXEC_DDM_RESET, ");
2000 case I2O_CMD_DDM_SUSPEND
:
2001 printk("EXEC_DDM_SUSPEND, ");
2003 case I2O_CMD_DEVICE_ASSIGN
:
2004 printk("EXEC_DEVICE_ASSIGN, ");
2006 case I2O_CMD_DEVICE_RELEASE
:
2007 printk("EXEC_DEVICE_RELEASE, ");
2009 case I2O_CMD_HRT_GET
:
2010 printk("EXEC_HRT_GET, ");
2012 case I2O_CMD_ADAPTER_CLEAR
:
2013 printk("EXEC_IOP_CLEAR, ");
2015 case I2O_CMD_ADAPTER_CONNECT
:
2016 printk("EXEC_IOP_CONNECT, ");
2018 case I2O_CMD_ADAPTER_RESET
:
2019 printk("EXEC_IOP_RESET, ");
2021 case I2O_CMD_LCT_NOTIFY
:
2022 printk("EXEC_LCT_NOTIFY, ");
2024 case I2O_CMD_OUTBOUND_INIT
:
2025 printk("EXEC_OUTBOUND_INIT, ");
2027 case I2O_CMD_PATH_ENABLE
:
2028 printk("EXEC_PATH_ENABLE, ");
2030 case I2O_CMD_PATH_QUIESCE
:
2031 printk("EXEC_PATH_QUIESCE, ");
2033 case I2O_CMD_PATH_RESET
:
2034 printk("EXEC_PATH_RESET, ");
2036 case I2O_CMD_STATIC_MF_CREATE
:
2037 printk("EXEC_STATIC_MF_CREATE, ");
2039 case I2O_CMD_STATIC_MF_RELEASE
:
2040 printk("EXEC_STATIC_MF_RELEASE, ");
2042 case I2O_CMD_STATUS_GET
:
2043 printk("EXEC_STATUS_GET, ");
2045 case I2O_CMD_SW_DOWNLOAD
:
2046 printk("EXEC_SW_DOWNLOAD, ");
2048 case I2O_CMD_SW_UPLOAD
:
2049 printk("EXEC_SW_UPLOAD, ");
2051 case I2O_CMD_SW_REMOVE
:
2052 printk("EXEC_SW_REMOVE, ");
2054 case I2O_CMD_SYS_ENABLE
:
2055 printk("EXEC_SYS_ENABLE, ");
2057 case I2O_CMD_SYS_MODIFY
:
2058 printk("EXEC_SYS_MODIFY, ");
2060 case I2O_CMD_SYS_QUIESCE
:
2061 printk("EXEC_SYS_QUIESCE, ");
2063 case I2O_CMD_SYS_TAB_SET
:
2064 printk("EXEC_SYS_TAB_SET, ");
2067 printk("%02x, ",cmd
);
2073 static void i2o_report_lan_cmd(u8 cmd
)
2076 case LAN_PACKET_SEND
:
2077 printk("LAN_PACKET_SEND, ");
2080 printk("LAN_SDU_SEND, ");
2082 case LAN_RECEIVE_POST
:
2083 printk("LAN_RECEIVE_POST, ");
2086 printk("LAN_RESET, ");
2089 printk("LAN_SUSPEND, ");
2092 printk("%02x, ",cmd
);
2098 /* TODO: Add support for other classes */
2099 void i2o_report_status(const char *severity
, const char *module
, u32
*msg
)
2101 u8 cmd
= (msg
[1]>>24)&0xFF;
2102 u8 req_status
= (msg
[4]>>24)&0xFF;
2103 u16 detailed_status
= msg
[4]&0xFFFF;
2105 printk("%s%s: ", severity
, module
);
2107 if (cmd
< 0x1F) { // Utility Class
2108 i2o_report_util_cmd(cmd
);
2109 i2o_report_common_status(req_status
);
2110 i2o_report_common_dsc(detailed_status
);
2114 if (cmd
>= 0x30 && cmd
<= 0x3F) { // LAN class
2115 i2o_report_lan_cmd(cmd
);
2116 i2o_report_common_status(req_status
);
2117 i2o_report_lan_dsc(detailed_status
);
2121 if (cmd
>= 0xA0 && cmd
<= 0xEF) { // Executive class
2122 i2o_report_exec_cmd(cmd
);
2123 i2o_report_common_status(req_status
);
2124 i2o_report_common_dsc(detailed_status
);
2128 printk("%02x, %02x / %04x.\n", cmd
, req_status
, detailed_status
);
2132 /* Used to dump a message to syslog during debugging */
2133 static void i2o_dump_message(u32
*msg
)
2138 printk(KERN_INFO
"Dumping I2O message @ %p\n", msg
);
2139 for(i
= 0; i
< ((msg
[0]>>16)&0xffff); i
++)
2140 printk(KERN_INFO
"\tmsg[%d] = %#10x\n", i
, msg
[i
]);
2146 EXPORT_SYMBOL(i2o_install_handler
);
2147 EXPORT_SYMBOL(i2o_remove_handler
);
2148 EXPORT_SYMBOL(i2o_install_device
);
2149 EXPORT_SYMBOL(i2o_delete_device
);
2150 EXPORT_SYMBOL(i2o_quiesce_controller
);
2151 EXPORT_SYMBOL(i2o_clear_controller
);
2152 EXPORT_SYMBOL(i2o_install_controller
);
2153 EXPORT_SYMBOL(i2o_delete_controller
);
2154 EXPORT_SYMBOL(i2o_unlock_controller
);
2155 EXPORT_SYMBOL(i2o_find_controller
);
2156 EXPORT_SYMBOL(i2o_num_controllers
);
2157 EXPORT_SYMBOL(i2o_claim_device
);
2158 EXPORT_SYMBOL(i2o_release_device
);
2159 EXPORT_SYMBOL(i2o_run_queue
);
2160 EXPORT_SYMBOL(i2o_report_controller_unit
);
2161 EXPORT_SYMBOL(i2o_activate_controller
);
2162 EXPORT_SYMBOL(i2o_online_controller
);
2163 EXPORT_SYMBOL(i2o_get_class_name
);
2165 EXPORT_SYMBOL(i2o_query_scalar
);
2166 EXPORT_SYMBOL(i2o_set_scalar
);
2167 EXPORT_SYMBOL(i2o_query_table
);
2168 EXPORT_SYMBOL(i2o_clear_table
);
2169 EXPORT_SYMBOL(i2o_row_add_table
);
2170 EXPORT_SYMBOL(i2o_row_delete_table
);
2172 EXPORT_SYMBOL(i2o_post_this
);
2173 EXPORT_SYMBOL(i2o_post_wait
);
2174 EXPORT_SYMBOL(i2o_issue_claim
);
2176 EXPORT_SYMBOL(i2o_report_status
);
2178 MODULE_AUTHOR("Red Hat Software");
2179 MODULE_DESCRIPTION("I2O Core");
2182 int init_module(void)
2184 if (i2o_install_handler(&i2o_core_handler
) < 0)
2186 printk(KERN_ERR
"i2o_core: Unable to install core handler.\n");
2190 core_context
= i2o_core_handler
.context
;
2193 * Attach core to I2O PCI subsystem
2195 #ifdef CONFIG_I2O_PCI_MODULE
2196 if(i2o_pci_core_attach(&i2o_core_functions
) < 0)
2197 printk(KERN_INFO
"No PCI I2O controllers found\n");
2203 void cleanup_module(void)
2205 #ifdef CONFIG_I2O_PCI_MODULE
2206 i2o_pci_core_detach();
2209 i2o_remove_handler(&i2o_core_handler
);
2214 extern int i2o_block_init(void);
2215 extern int i2o_config_init(void);
2216 extern int i2o_lan_init(void);
2217 extern int i2o_pci_init(void);
2218 extern int i2o_proc_init(void);
2219 extern int i2o_scsi_init(void);
2221 __init
int i2o_init(void)
2223 if (i2o_install_handler(&i2o_core_handler
) < 0)
2225 printk(KERN_ERR
"i2o_core: Unable to install core handler.\n");
2229 core_context
= i2o_core_handler
.context
;
2230 #ifdef CONFIG_I2O_PCI
2234 #ifdef CONFIG_I2O_BLOCK
2237 #ifdef CONFIG_I2O_SCSI
2240 #ifdef CONFIG_I2O_LAN
2243 #ifdef CONFIG_I2O_PROC