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 #include <linux/i2o.h>
29 #include <linux/errno.h>
30 #include <linux/init.h>
31 #include <linux/malloc.h>
32 #include <linux/spinlock.h>
41 * Size of the I2O module table
44 static struct i2o_handler
*i2o_handlers
[MAX_I2O_MODULES
];
45 static struct i2o_controller
*i2o_controllers
[MAX_I2O_CONTROLLERS
];
46 int i2o_num_controllers
= 0;
47 static int core_context
= 0;
48 static int reply_flag
= 0;
50 extern int i2o_online_controller(struct i2o_controller
*c
);
51 static void i2o_core_reply(struct i2o_handler
*, struct i2o_controller
*,
52 struct i2o_message
*);
53 static int i2o_add_management_user(struct i2o_device
*, struct i2o_handler
*);
54 static int i2o_remove_management_user(struct i2o_device
*, struct i2o_handler
*);
55 static void i2o_dump_message(u32
*);
59 * Function table to send to bus specific layers
60 * See <include/linux/i2o.h> for explanation of this
62 static struct i2o_core_func_table i2o_core_functions
=
64 i2o_install_controller
,
65 i2o_activate_controller
,
67 i2o_unlock_controller
,
72 #ifdef CONFIG_I2O_PCI_MODULE
73 extern int i2o_pci_core_attach(struct i2o_core_func_table
*);
74 extern void i2o_pci_core_detach(void);
75 #endif /* CONFIG_I2O_PCI_MODULE */
81 static struct i2o_handler i2o_core_handler
=
83 (void *)i2o_core_reply
,
89 * I2O configuration spinlock. This isnt a big deal for contention
93 static spinlock_t i2o_configuration_lock
= SPIN_LOCK_UNLOCKED
;
95 void i2o_core_reply(struct i2o_handler
*h
, struct i2o_controller
*c
,
96 struct i2o_message
*m
)
99 u32
*flag
= (u32
*)msg
[3];
102 i2o_report_status(KERN_INFO
, "i2o_core", msg
);
105 if (msg
[0] & (1<<13)) // Fail bit is set
107 printk(KERN_ERR
"IOP failed to process the msg:\n");
108 printk(KERN_ERR
" Cmd = 0x%02X, InitiatorTid = %d, TargetTid =%d\n",
109 (msg
[1] >> 24) & 0xFF, (msg
[1] >> 12) & 0xFFF, msg
[1] &
111 printk(KERN_ERR
" FailureCode = 0x%02X\n Severity = 0x%02X\n"
112 "LowestVersion = 0x%02X\n HighestVersion = 0x%02X\n",
113 msg
[4] >> 24, (msg
[4] >> 16) & 0xFF,
114 (msg
[4] >> 8) & 0xFF, msg
[4] & 0xFF);
115 printk(KERN_ERR
" FailingHostUnit = 0x%04X\n FailingIOP = 0x%03X\n",
116 msg
[5] >> 16, msg
[5] & 0xFFF);
122 i2o_report_status(KERN_WARNING
, "i2o_core", msg
);
123 *flag
= -(msg
[4] & 0xFFFF);
126 *flag
= I2O_POST_WAIT_OK
;
130 * Install an I2O handler - these handle the asynchronous messaging
131 * from the card once it has initialised.
134 int i2o_install_handler(struct i2o_handler
*h
)
137 spin_lock(&i2o_configuration_lock
);
138 for(i
=0;i
<MAX_I2O_MODULES
;i
++)
140 if(i2o_handlers
[i
]==NULL
)
144 spin_unlock(&i2o_configuration_lock
);
148 spin_unlock(&i2o_configuration_lock
);
152 int i2o_remove_handler(struct i2o_handler
*h
)
154 i2o_handlers
[h
->context
]=NULL
;
160 * Each I2O controller has a chain of devices on it - these match
161 * the useful parts of the LCT of the board.
164 int i2o_install_device(struct i2o_controller
*c
, struct i2o_device
*d
)
168 spin_lock(&i2o_configuration_lock
);
176 for(i
= 0; i
< I2O_MAX_MANAGERS
; i
++)
177 d
->managers
[i
] = NULL
;
179 spin_unlock(&i2o_configuration_lock
);
183 /* we need this version to call out of i2o_delete_controller */
185 int __i2o_delete_device(struct i2o_device
*d
)
187 struct i2o_device
**p
;
189 p
=&(d
->controller
->devices
);
192 * Hey we have a driver!
215 printk(KERN_ERR
"i2o_delete_device: passed invalid device.\n");
219 int i2o_delete_device(struct i2o_device
*d
)
223 spin_lock(&i2o_configuration_lock
);
225 ret
= __i2o_delete_device(d
);
227 spin_unlock(&i2o_configuration_lock
);
233 * Add and remove controllers from the I2O controller list
236 int i2o_install_controller(struct i2o_controller
*c
)
239 spin_lock(&i2o_configuration_lock
);
240 for(i
=0;i
<MAX_I2O_CONTROLLERS
;i
++)
242 if(i2o_controllers
[i
]==NULL
)
244 i2o_controllers
[i
]=c
;
245 c
->next
=i2o_controller_chain
;
246 i2o_controller_chain
=c
;
248 sprintf(c
->name
, "i2o/iop%d", i
);
249 i2o_num_controllers
++;
250 spin_unlock(&i2o_configuration_lock
);
254 printk(KERN_ERR
"No free i2o controller slots.\n");
255 spin_unlock(&i2o_configuration_lock
);
259 int i2o_delete_controller(struct i2o_controller
*c
)
261 struct i2o_controller
**p
;
264 spin_lock(&i2o_configuration_lock
);
265 if((users
=atomic_read(&c
->users
)))
267 printk("I2O: %d users for controller iop%d\n", users
, c
->unit
);
268 spin_unlock(&i2o_configuration_lock
);
273 if(__i2o_delete_device(c
->devices
)<0)
275 /* Shouldnt happen */
276 spin_unlock(&i2o_configuration_lock
);
281 p
=&i2o_controller_chain
;
283 /* Send first SysQuiesce to other IOPs */
288 printk("Quiescing controller %p != %p\n", c
, *p
);
289 if(i2o_quiesce_controller(*p
)<0)
290 printk(KERN_INFO
"Unable to quiesce iop%d\n",
296 p
=&i2o_controller_chain
;
302 /* Ask the IOP to switch to HOLD state */
303 if (i2o_clear_controller(c
) < 0)
304 printk("Unable to clear iop%d\n", c
->unit
);
310 spin_unlock(&i2o_configuration_lock
);
312 kfree(c
->page_frame
);
317 i2o_controllers
[c
->unit
]=NULL
;
319 i2o_num_controllers
--;
324 spin_unlock(&i2o_configuration_lock
);
325 printk(KERN_ERR
"i2o_delete_controller: bad pointer!\n");
329 void i2o_unlock_controller(struct i2o_controller
*c
)
331 atomic_dec(&c
->users
);
334 struct i2o_controller
*i2o_find_controller(int n
)
336 struct i2o_controller
*c
;
338 if(n
<0 || n
>=MAX_I2O_CONTROLLERS
)
341 spin_lock(&i2o_configuration_lock
);
342 c
=i2o_controllers
[n
];
344 atomic_inc(&c
->users
);
345 spin_unlock(&i2o_configuration_lock
);
351 * Claim a device for use as either the primary user or just
352 * as a management/secondary user
354 int i2o_claim_device(struct i2o_device
*d
, struct i2o_handler
*h
, u32 type
)
356 /* Device already has a primary user or too many managers */
357 if((type
== I2O_CLAIM_PRIMARY
&& d
->owner
) ||
358 (d
->num_managers
== I2O_MAX_MANAGERS
))
363 if(i2o_issue_claim(d
->controller
,d
->id
, h
->context
, 1, &reply_flag
, type
) < 0)
368 spin_lock(&i2o_configuration_lock
);
371 spin_unlock(&i2o_configuration_lock
);
374 atomic_inc(&d
->controller
->users
);
376 if(type
== I2O_CLAIM_PRIMARY
)
379 i2o_add_management_user(d
, h
);
381 spin_unlock(&i2o_configuration_lock
);
385 int i2o_release_device(struct i2o_device
*d
, struct i2o_handler
*h
, u32 type
)
389 spin_lock(&i2o_configuration_lock
);
392 if(type
== I2O_CLAIM_PRIMARY
)
398 if(i2o_issue_claim(d
->controller
, d
->id
, h
->context
, 0,
399 &reply_flag
, type
) < 0)
406 atomic_dec(&d
->controller
->users
);
410 spin_unlock(&i2o_configuration_lock
);
414 /* Management or other user */
415 if(i2o_remove_management_user(d
, h
))
419 atomic_dec(&d
->controller
->users
);
421 if(i2o_issue_claim(d
->controller
,d
->id
, h
->context
, 0,
422 &reply_flag
, type
) < 0)
426 spin_unlock(&i2o_configuration_lock
);
430 int i2o_add_management_user(struct i2o_device
*d
, struct i2o_handler
*h
)
434 if(d
->num_managers
== I2O_MAX_MANAGERS
)
437 for(i
= 0; i
< I2O_MAX_MANAGERS
; i
++)
446 int i2o_remove_management_user(struct i2o_device
*d
, struct i2o_handler
*h
)
450 for(i
=0; i
< I2O_MAX_MANAGERS
; i
++)
452 if(d
->managers
[i
] == h
)
454 d
->managers
[i
] = NULL
;
463 * This is called by the bus specific driver layer when an interrupt
464 * or poll of this card interface is desired.
467 void i2o_run_queue(struct i2o_controller
*c
)
469 struct i2o_message
*m
;
472 while((mv
=I2O_REPLY_READ32(c
))!=0xFFFFFFFF)
474 struct i2o_handler
*i
;
475 m
=(struct i2o_message
*)bus_to_virt(mv
);
477 * Temporary Debugging
479 if(((m
->function_addr
>>24)&0xFF)==0x15)
481 // printk("dispatching.\n");
482 i
=i2o_handlers
[m
->initiator_context
&(MAX_I2O_MODULES
-1)];
487 printk("Spurious reply to handler %d\n",
488 m
->initiator_context
&(MAX_I2O_MODULES
-1));
489 i2o_dump_message((u32
*)m
);
491 i2o_flush_reply(c
,mv
);
498 * Do i2o class name lookup
500 const char *i2o_get_class_name(int class)
503 static char *i2o_class_name
[] = {
505 "Device Driver Module",
510 "Fibre Channel Port",
511 "Fibre Channel Device",
517 "Secondary Bus Port",
518 "Peer Transport Agent",
525 case I2O_CLASS_EXECUTIVE
:
529 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
531 case I2O_CLASS_SEQUENTIAL_STORAGE
:
537 case I2O_CLASS_FIBRE_CHANNEL_PORT
:
539 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL
:
541 case I2O_CLASS_SCSI_PERIPHERAL
:
543 case I2O_CLASS_ATE_PORT
:
545 case I2O_CLASS_ATE_PERIPHERAL
:
547 case I2O_CLASS_FLOPPY_CONTROLLER
:
549 case I2O_CLASS_FLOPPY_DEVICE
:
551 case I2O_CLASS_BUS_ADAPTER_PORT
:
553 case I2O_CLASS_PEER_TRANSPORT_AGENT
:
555 case I2O_CLASS_PEER_TRANSPORT
:
559 return i2o_class_name
[idx
];
564 * Wait up to 5 seconds for a message slot to be available.
567 u32
i2o_wait_message(struct i2o_controller
*c
, char *why
)
571 while((m
=I2O_POST_READ32(c
))==0xFFFFFFFF)
573 if((jiffies
-time
)>=5*HZ
)
575 printk(KERN_ERR
"%s: Timeout waiting for message frame to send %s.\n",
587 * Wait up to timeout seconds for a reply to be available.
590 u32
i2o_wait_reply(struct i2o_controller
*c
, char *why
, int timeout
)
595 while((m
=I2O_REPLY_READ32(c
))==0xFFFFFFFF)
597 if(jiffies
-time
>= timeout
*HZ
)
599 printk(KERN_ERR
"%s: timeout waiting for %s reply.\n",
609 static int i2o_query_scalar_polled(struct i2o_controller
*c
, int tid
, void *buf
, int buflen
,
610 int group
, int field
)
619 op
[0]=1; /* One Operation */
621 op
[2]=1; /* FIELD_GET */
622 op
[3]=group
; /* group number */
623 op
[4]=1; /* 1 field */
624 op
[5]=field
; /* Field number */
626 m
=i2o_wait_message(c
, "ParamsGet");
632 msg
=(u32
*)(c
->mem_offset
+m
);
634 rbuf
=kmalloc(buflen
+32, GFP_KERNEL
);
637 printk(KERN_ERR
"No free memory for scalar read.\n");
641 msg
[0]=NINE_WORD_MSG_SIZE
|SGL_OFFSET_5
;
642 msg
[1]=I2O_CMD_UTIL_PARAMS_GET
<<24|HOST_TID
<<12|tid
;
643 msg
[2]=0; /* Context */
646 msg
[5]=0x54000000|12;
647 msg
[6]=virt_to_bus(op
);
648 msg
[7]=0xD0000000|(32+buflen
);
649 msg
[8]=virt_to_bus(rbuf
);
651 i2o_post_message(c
,m
);
655 * Now wait for a reply
658 m
=i2o_wait_reply(c
, "ParamsGet", 5);
666 msg
= (u32
*)bus_to_virt(m
);
669 i2o_report_status(KERN_WARNING
, "i2o_core", msg
);
674 /* Ok 'p' is the reply block - lets see what happened */
675 /* p0->p2 are the header */
677 /* FIXME: endians - turn p3 to little endian */
680 printk(KERN_WARNING
"Suspicious field read return 0x%08X\n", p
[0]);
682 i
=(p
[1]&0xFFFF)<<2; /* Message size */
686 /* Do we have an error block ? */
689 printk(KERN_ERR
"%s: error in field read.\n",
695 /* p[1] holds the more flag and row count - we dont care */
697 /* Ok it worked p[2]-> hold the data */
698 memcpy(buf
, p
+2, buflen
);
702 /* Finally return the message */
703 I2O_REPLY_WRITE32(c
,m
);
708 * Dump the information block associated with a given unit (TID)
711 void i2o_report_controller_unit(struct i2o_controller
*c
, int unit
)
715 if(i2o_query_scalar_polled(c
, unit
, buf
, 16, 0xF100, 3)>=0)
718 printk(KERN_INFO
" Vendor: %s\n", buf
);
720 if(i2o_query_scalar_polled(c
, unit
, buf
, 16, 0xF100, 4)>=0)
723 printk(KERN_INFO
" Device: %s\n", buf
);
726 if(i2o_query_scalar_polled(c
, unit
, buf
, 16, 0xF100, 5)>=0)
729 printk(KERN_INFO
"Description: %s\n", buf
);
732 if(i2o_query_scalar_polled(c
, unit
, buf
, 8, 0xF100, 6)>=0)
735 printk(KERN_INFO
" Rev: %s\n", buf
);
741 * Parse the hardware resource table. Right now we print it out
742 * and don't do a lot with it. We should collate these and then
743 * interact with the Linux resource allocation block.
745 * Lets prove we can read it first eh ?
747 * This is full of endianisms!
750 static int i2o_parse_hrt(struct i2o_controller
*c
)
762 printk(KERN_ERR
"i2o: HRT table for controller is too new a version.\n");
766 count
=p
[0]|(p
[1]<<8);
769 printk(KERN_INFO
"HRT has %d entries of %d bytes each.\n",
776 printk(KERN_INFO
"Adapter %08X: ", rows
[0]);
781 printk("TID %04X:[", state
&0xFFF);
784 printk("H"); /* Hidden */
787 printk("P"); /* Present */
789 printk("C"); /* Controlled */
792 printk("*"); /* Hard */
799 /* Adapter private bus - easy */
800 printk("Local bus %d: I/O at 0x%04X Mem 0x%08X",
801 p
[2], d
[1]<<8|d
[0], *(u32
*)(d
+4));
805 printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X",
806 p
[2], d
[2], d
[1]<<8|d
[0], *(u32
*)(d
+4));
809 case 2: /* EISA bus */
810 printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
811 p
[2], d
[3], d
[1]<<8|d
[0], *(u32
*)(d
+4));
814 case 3: /* MCA bus */
815 printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
816 p
[2], d
[3], d
[1]<<8|d
[0], *(u32
*)(d
+4));
819 case 4: /* PCI bus */
820 printk("PCI %d: Bus %d Device %d Function %d",
821 p
[2], d
[2], d
[1], d
[0]);
824 case 0x80: /* Other */
826 printk("Unsupported bus type.");
836 * The logical configuration table tells us what we can talk to
837 * on the board. Most of the stuff isn't interesting to us.
840 static int i2o_parse_lct(struct i2o_controller
*c
)
846 struct i2o_device
*d
;
848 u32
*lct
=(u32
*)c
->lct
;
857 printk(KERN_ERR
"LCT is empty????\n");
861 printk(KERN_INFO
"LCT has %d entries.\n", max
);
865 printk(KERN_INFO
"LCT was truncated.\n");
870 printk(KERN_WARNING
"Configuration dialog desired.\n");
876 d
= (struct i2o_device
*)kmalloc(sizeof(struct i2o_device
), GFP_KERNEL
);
879 printk("i2o_core: Out of memory for LCT data.\n");
886 d
->id
= tid
= (p
[0]>>16)&0xFFF;
887 d
->class = p
[3]&0xFFF;
888 d
->subclass
= p
[4]&0xFFF;
889 d
->parent
= (p
[5]>>12)&0xFFF;
892 printk(KERN_INFO
"TID %d.\n", tid
);
894 i2o_report_controller_unit(c
, tid
);
896 i2o_install_device(c
, d
);
898 printk(KERN_INFO
" Class: ");
900 sprintf(str
, "%-21s", i2o_get_class_name(d
->class));
903 printk(" Subclass: 0x%03X Flags: ",
907 printk("C"); // ConfigDialog requested
909 printk("M"); // Multi-user capable
911 printk("P"); // Peer service enabled!
913 printk("m"); // Mgmt service enabled!
921 int i2o_quiesce_controller(struct i2o_controller
*c
)
925 msg
[0]=FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
926 msg
[1]=I2O_CMD_SYS_QUIESCE
<<24|HOST_TID
<<12|ADAPTER_TID
;
928 msg
[3]=(u32
)&reply_flag
;
930 /* Long timeout needed for quiesce if lots of devices */
931 return i2o_post_wait(c
, ADAPTER_TID
, msg
, sizeof(msg
), &reply_flag
, 120);
935 int i2o_clear_controller(struct i2o_controller
*c
)
939 /* First stop external operations for this IOP */
940 if(i2o_quiesce_controller(c
)<0)
941 printk(KERN_INFO
"Unable to quiesce iop%d\n", c
->unit
);
943 printk(KERN_INFO
"Iop%d quiesced\n", c
->unit
);
945 /* Then clear the IOP */
946 msg
[0]=FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
947 msg
[1]=I2O_CMD_ADAPTER_CLEAR
<<24|HOST_TID
<<12|ADAPTER_TID
;
949 msg
[3]=(u32
)&reply_flag
;
951 return i2o_post_wait(c
, ADAPTER_TID
, msg
, sizeof(msg
), &reply_flag
, 10);
955 /* Reset the IOP to sane state */
956 static int i2o_reset_controller(struct i2o_controller
*c
)
962 struct i2o_controller
*iop
;
964 /* First stop external operations */
965 for(iop
=i2o_controller_chain
; iop
!= NULL
; iop
=iop
->next
)
967 /* Quiesce is rejected on hold state */
968 if(iop
->status
!= ADAPTER_STATE_HOLD
)
970 if(i2o_quiesce_controller(iop
)<0)
971 printk(KERN_INFO
"Unable to quiesce iop%d\n",
974 printk(KERN_DEBUG
"%s quiesced\n", iop
->name
);
978 /* Then reset the IOP */
979 m
=i2o_wait_message(c
, "AdapterReset");
983 msg
=(u32
*)(c
->mem_offset
+m
);
985 work8
=(void *)kmalloc(4, GFP_KERNEL
);
987 printk(KERN_ERR
"IOP reset failed - no free memory.\n");
993 msg
[0]=EIGHT_WORD_MSG_SIZE
|SGL_OFFSET_0
;
994 msg
[1]=I2O_CMD_ADAPTER_RESET
<<24|HOST_TID
<<12|ADAPTER_TID
;
996 msg
[3]=(u32
)&reply_flag
;
999 msg
[6]=virt_to_phys(work8
);
1000 msg
[7]=0; /* 64bit host FIXME */
1002 i2o_post_message(c
,m
);
1004 /* Wait for a reply */
1007 while(work8
[0]==0x01)
1009 if((jiffies
-time
)>=5*HZ
)
1011 printk(KERN_ERR
"IOP reset timeout.\n");
1020 printk(KERN_WARNING
"IOP Reset rejected\n");
1026 int i2o_status_get(struct i2o_controller
*c
)
1033 status_block
=(void *)kmalloc(88, GFP_KERNEL
);
1034 if(status_block
==NULL
)
1036 printk(KERN_ERR
"StatusGet failed - no free memory.\n");
1040 m
=i2o_wait_message(c
, "StatusGet");
1044 msg
=(u32
*)(c
->mem_offset
+m
);
1046 msg
[0]=NINE_WORD_MSG_SIZE
|SGL_OFFSET_0
;
1047 msg
[1]=I2O_CMD_STATUS_GET
<<24|HOST_TID
<<12|ADAPTER_TID
;
1048 msg
[2]=core_context
;
1052 msg
[6]=virt_to_phys(status_block
);
1053 msg
[7]=0; /* 64bit host FIXME */
1056 i2o_post_message(c
,m
);
1058 /* Wait for a reply */
1061 while(status_block
[87]!=0xFF)
1063 if((jiffies
-time
)>=5*HZ
)
1065 printk(KERN_ERR
"IOP get status timeout.\n");
1072 /* Ok the reply has arrived. Fill in the important stuff */
1073 c
->status
= status_block
[10];
1074 c
->i2oversion
= (status_block
[9]>>4)&0xFF;
1075 c
->inbound_size
= (status_block
[12]|(status_block
[13]<<8))*4;
1081 int i2o_hrt_get(struct i2o_controller
*c
)
1086 c
->hrt
=kmalloc(2048, GFP_KERNEL
);
1089 printk(KERN_ERR
"IOP init failed; no memory.\n");
1093 m
=i2o_wait_message(c
, "HRTGet");
1097 msg
=(u32
*)(c
->mem_offset
+m
);
1099 msg
[0]= SIX_WORD_MSG_SIZE
| SGL_OFFSET_4
;
1100 msg
[1]= I2O_CMD_HRT_GET
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1101 msg
[2]= core_context
;
1102 msg
[3]= 0x0; /* Transaction context */
1103 msg
[4]= (0xD0000000 | 2048); /* Simple transaction , 2K */
1104 msg
[5]= virt_to_phys(c
->hrt
); /* Dump it here */
1106 i2o_post_message(c
,m
);
1110 /* Now wait for a reply */
1111 m
=i2o_wait_reply(c
, "HRTGet", 5);
1116 msg
=(u32
*)bus_to_virt(m
);
1119 i2o_report_status(KERN_WARNING
, "i2o_core", msg
);
1121 I2O_REPLY_WRITE32(c
,m
);
1128 * Bring an I2O controller into HOLD state. See the 1.5
1129 * spec. Basically we go
1131 * Wait for the message queue to initialise.
1132 * If it didnt -> controller is dead
1134 * Send a get status using the message queue
1135 * Poll for a reply block 88 bytes long
1137 * Send an initialise outbound queue
1140 * Post our blank messages to the queue FIFO
1142 * Send GetHRT, Parse it
1145 int i2o_activate_controller(struct i2o_controller
*c
)
1154 printk(KERN_INFO
"Configuring I2O controller at 0x%08X.\n",
1157 if((ret
=i2o_status_get(c
)))
1160 if(c
->status
== ADAPTER_STATE_FAULTED
) /* not likely to be seen */
1162 printk(KERN_CRIT
"i2o: iop%d has hardware fault\n",
1168 * If the board is running, reset it - we have no idea
1169 * what kind of a mess the previous owner left it in.
1171 if(c
->status
== ADAPTER_STATE_HOLD
||
1172 c
->status
== ADAPTER_STATE_READY
||
1173 c
->status
== ADAPTER_STATE_OPERATIONAL
||
1174 c
->status
== ADAPTER_STATE_FAILED
)
1176 if((ret
=i2o_reset_controller(c
)))
1179 if((ret
=i2o_status_get(c
)))
1183 workspace
= (void *)kmalloc(88, GFP_KERNEL
);
1186 printk(KERN_ERR
"IOP initialisation failed - no free memory.\n");
1190 memset(workspace
, 0, 88);
1192 m
=i2o_wait_message(c
, "OutboundInit");
1199 msg
=(u32
*)(c
->mem_offset
+m
);
1201 msg
[0]= EIGHT_WORD_MSG_SIZE
| TRL_OFFSET_6
;
1202 msg
[1]= I2O_CMD_OUTBOUND_INIT
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1203 msg
[2]= core_context
;
1204 msg
[3]= 0x0106; /* Transaction context */
1205 msg
[4]= 4096; /* Host page frame size */
1206 msg
[5]= MSG_FRAME_SIZE
<<16|0x80; /* Outbound msg frame size and Initcode */
1207 msg
[6]= 0xD0000004; /* Simple SG LE, EOB */
1208 msg
[7]= virt_to_phys(workspace
);
1209 *((u32
*)workspace
)=0;
1215 i2o_post_message(c
,m
);
1221 while(workspace
[0]!=I2O_CMD_OUTBOUND_INIT_COMPLETE
)
1223 if((jiffies
-time
)>=5*HZ
)
1225 printk(KERN_ERR
"IOP outbound initialise failed.\n");
1235 /* TODO: v2.0: Set Executive class group 000Bh - OS Operating Info */
1237 c
->page_frame
= kmalloc(MSG_POOL_SIZE
, GFP_KERNEL
);
1238 if(c
->page_frame
==NULL
)
1240 printk(KERN_ERR
"IOP init failed: no memory for message page.\n");
1244 m
=virt_to_phys(c
->page_frame
);
1246 for(i
=0; i
< NMBR_MSG_FRAMES
; i
++)
1248 I2O_REPLY_WRITE32(c
,m
);
1254 * The outbound queue is initialised and loaded,
1256 * Now we need the Hardware Resource Table. We must ask for
1257 * this next we can't issue random messages yet.
1263 ret
=i2o_parse_hrt(c
);
1267 return i2o_online_controller(c
);
1268 // i2o_report_controller_unit(c, ADAPTER_TID);
1272 int i2o_lct_get(struct i2o_controller
*c
)
1277 m
=i2o_wait_message(c
, "LCTNotify");
1282 msg
=(u32
*)(c
->mem_offset
+m
);
1284 c
->lct
= kmalloc(8192, GFP_KERNEL
);
1287 msg
[0]=FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
1288 msg
[1]= HOST_TID
<<12|ADAPTER_TID
; /* NOP */
1289 i2o_post_message(c
,m
);
1290 printk(KERN_ERR
"No free memory for i2o controller buffer.\n");
1294 memset(c
->lct
, 0, 8192);
1296 msg
[0] = EIGHT_WORD_MSG_SIZE
|SGL_OFFSET_6
;
1297 msg
[1] = I2O_CMD_LCT_NOTIFY
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1298 msg
[2] = 0; /* Context not needed */
1300 msg
[4] = 0xFFFFFFFF; /* All devices */
1301 msg
[5] = 0x00000000; /* Report now */
1302 msg
[6] = 0xD0000000|8192;
1303 msg
[7] = virt_to_bus(c
->lct
);
1305 i2o_post_message(c
,m
);
1309 /* Now wait for a reply */
1310 m
=i2o_wait_reply(c
, "LCTNotify", 5);
1315 msg
=(u32
*)bus_to_virt(m
);
1317 /* TODO: Check TableSize for big LCTs and send new ExecLctNotify
1318 * with bigger workspace */
1321 i2o_report_status(KERN_ERR
, "i2o_core", msg
);
1328 * Bring a controller online. Needs completing for multiple controllers
1331 int i2o_online_controller(struct i2o_controller
*c
)
1344 systab
[4]=0; /* Organisation ID */
1345 systab
[5]=2; /* Ident 2 for now */
1346 systab
[6]=0<<24|0<<16|I2OVERSION
<<12|1; /* Memory mapped, IOPState, v1.5, segment 1 */
1347 systab
[7]=MSG_FRAME_SIZE
>>2; /* Message size */
1348 systab
[8]=0; /* LastChanged */
1349 systab
[9]=0; /* Should be IOP capabilities */
1350 systab
[10]=virt_to_phys(c
->post_port
);
1353 privmem
[0]=c
->priv_mem
; /* Private memory space base address */
1354 privmem
[1]=c
->priv_mem_size
;
1355 privio
[0]=c
->priv_io
; /* Private I/O address */
1356 privio
[1]=c
->priv_io_size
;
1358 m
=i2o_wait_message(c
, "SysTabSet");
1362 /* Now we build the systab */
1363 msg
=(u32
*)(c
->mem_offset
+m
);
1365 msg
[0] = NINE_WORD_MSG_SIZE
|SGL_OFFSET_6
;
1366 msg
[1] = I2O_CMD_SYS_TAB_SET
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1367 msg
[2] = 0; /* Context not needed */
1369 msg
[4] = (1<<16)|(2<<12); /* Host 1 I2O 2 */
1370 msg
[5] = 1; /* Segment 1 */
1373 * Scatter Gather List
1376 msg
[6] = 0x54000000|48; /* One table for now */
1377 msg
[7] = virt_to_phys(systab
);
1378 msg
[8] = 0xD4000000|48; /* One table for now */
1379 msg
[9] = virt_to_phys(privmem
);
1380 /* msg[10] = virt_to_phys(privio); */
1382 i2o_post_message(c
,m
);
1387 * Now wait for a reply
1391 m
=i2o_wait_reply(c
, "SysTabSet", 5);
1396 msg
=(u32
*)bus_to_virt(m
);
1400 i2o_report_status(KERN_ERR
, "i2o_core", msg
);
1402 I2O_REPLY_WRITE32(c
,m
);
1405 * Finally we go online
1408 m
=i2o_wait_message(c
, "SysEnable");
1413 msg
=(u32
*)(c
->mem_offset
+m
);
1415 msg
[0] = FOUR_WORD_MSG_SIZE
|SGL_OFFSET_0
;
1416 msg
[1] = I2O_CMD_SYS_ENABLE
<<24 | HOST_TID
<<12 | ADAPTER_TID
;
1417 msg
[2] = 0; /* Context not needed */
1420 i2o_post_message(c
,m
);
1425 * Now wait for a reply
1429 m
=i2o_wait_reply(c
, "SysEnable", 240);
1434 msg
=(u32
*)bus_to_virt(m
);
1438 i2o_report_status(KERN_ERR
, "i2o_core", msg
);
1440 I2O_REPLY_WRITE32(c
,m
);
1443 * Grab the LCT, see what is attached
1449 /* Maybe we should do also sthg else */
1453 ret
=i2o_parse_lct(c
);
1457 I2O_REPLY_WRITE32(c
,m
);
1463 * Run time support routines
1467 * Generic "post and forget" helpers. This is less efficient - we do
1468 * a memcpy for example that isnt strictly needed, but for most uses
1469 * this is simply not worth optimising
1472 int i2o_post_this(struct i2o_controller
*c
, int tid
, u32
*data
, int len
)
1476 unsigned long t
=jiffies
;
1481 m
= I2O_POST_READ32(c
);
1483 while(m
==0xFFFFFFFF && (jiffies
-t
)<HZ
);
1488 printk(KERN_ERR
"i2o: controller not responding.\n");
1491 msg
= bus_to_virt(c
->mem_offset
+ m
);
1492 memcpy(msg
, data
, len
);
1493 i2o_post_message(c
,m
);
1498 * Post a message and wait for a response flag to be set. This API will
1499 * change to use wait_queue's one day
1502 int i2o_post_wait(struct i2o_controller
*c
, int tid
, u32
*data
, int len
, int *flag
, int timeout
)
1504 unsigned long t
=jiffies
;
1508 if(i2o_post_this(c
, tid
, data
, len
))
1509 return I2O_POST_WAIT_TIMEOUT
;
1511 while(!*flag
&& (jiffies
-t
)<timeout
*HZ
)
1518 return *flag
; /* DetailedStatus */
1521 return I2O_POST_WAIT_TIMEOUT
;
1523 return I2O_POST_WAIT_OK
;
1527 * Issue UTIL_CLAIM messages
1530 int i2o_issue_claim(struct i2o_controller
*c
, int tid
, int context
, int onoff
, int *flag
, u32 type
)
1534 msg
[0] = FIVE_WORD_MSG_SIZE
| SGL_OFFSET_0
;
1536 msg
[1] = I2O_CMD_UTIL_CLAIM
<< 24 | HOST_TID
<<12 | tid
;
1538 msg
[1] = I2O_CMD_UTIL_RELEASE
<< 24 | HOST_TID
<< 12 | tid
;
1540 /* The 0x80000000 convention for flagging is assumed by this helper */
1542 msg
[2] = 0x80000000|context
;
1546 return i2o_post_wait(c
, tid
, msg
, 20, flag
,2);
1549 /* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET
1551 * This function can be used for all UtilParamsGet/Set operations.
1552 * The OperationBlock is given in opblk-buffer,
1553 * and results are returned in resblk-buffer.
1554 * Note that the minimum sized resblk is 8 bytes and contains
1555 * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
1557 int i2o_issue_params(int cmd
,
1558 struct i2o_controller
*iop
, int tid
, int context
,
1559 void *opblk
, int oplen
, void *resblk
, int reslen
,
1563 u8
*res
= (u8
*)resblk
;
1569 msg
[0] = NINE_WORD_MSG_SIZE
| SGL_OFFSET_5
;
1570 msg
[1] = cmd
<< 24 | HOST_TID
<< 12 | tid
;
1571 msg
[2] = context
| 0x80000000;
1574 msg
[5] = 0x54000000 | oplen
; /* OperationBlock */
1575 msg
[6] = virt_to_bus(opblk
);
1576 msg
[7] = 0xD0000000 | reslen
; /* ResultBlock */
1577 msg
[8] = virt_to_bus(resblk
);
1579 wait_status
= i2o_post_wait(iop
, tid
, msg
, sizeof(msg
), flag
, 10);
1580 if (wait_status
< 0)
1581 return wait_status
; /* -DetailedStatus */
1583 if (res
[1]&0x00FF0000) /* BlockStatus != SUCCESS */
1585 printk(KERN_WARNING
"%s - Error:\n ErrorInfoSize = 0x%02x, "
1586 "BlockStatus = 0x%02x, BlockSize = 0x%04x\n",
1587 (cmd
== I2O_CMD_UTIL_PARAMS_SET
) ? "PARAMS_SET"
1589 res
[1]>>24, (res
[1]>>16)&0xFF, res
[1]&0xFFFF);
1590 return -((res
[1] >> 16) & 0xFF); /* -BlockStatus */
1593 res_count
= res
[0] & 0xFFFF; /* # of resultblocks */
1598 blk_size
= (res
[0] & 0xFFFF) << 2;
1603 return bytes
; /* total sizeof Result List in bytes */
1607 * Query one scalar group value or a whole scalar group.
1609 int i2o_query_scalar(struct i2o_controller
*iop
, int tid
, int context
,
1610 int group
, int field
, void *buf
, int buflen
, int *flag
)
1612 u16 opblk
[] = { 1, 0, I2O_PARAMS_FIELD_GET
, group
, 1, field
};
1613 u8 resblk
[8+buflen
]; /* 8 bytes for header */
1616 if (field
== -1) /* whole group */
1619 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET
, iop
, tid
, context
,
1620 opblk
, sizeof(opblk
), resblk
, sizeof(resblk
), flag
);
1625 memcpy(buf
, resblk
+8, buflen
); /* cut off header */
1630 * Set a scalar group value or a whole group.
1632 int i2o_set_scalar(struct i2o_controller
*iop
, int tid
, int context
,
1633 int group
, int field
, void *buf
, int buflen
, int *flag
)
1636 u8 resblk
[8+buflen
]; /* 8 bytes for header */
1639 opblk
= kmalloc(buflen
+64, GFP_KERNEL
);
1642 printk(KERN_ERR
"i2o: no memory for operation buffer.\n");
1646 opblk
[0] = 1; /* operation count */
1647 opblk
[1] = 0; /* pad */
1648 opblk
[2] = I2O_PARAMS_FIELD_SET
;
1651 if(field
== -1) { /* whole group */
1653 memcpy(opblk
+5, buf
, buflen
);
1655 else /* single field */
1659 memcpy(opblk
+6, buf
, buflen
);
1662 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1663 opblk
, 12+buflen
, resblk
, sizeof(resblk
), flag
);
1670 * if oper == I2O_PARAMS_TABLE_GET:
1671 * Get all table group fields from all rows or
1672 * get specific table group fields from all rows.
1674 * if fieldcount == -1 we query all fields from all rows
1675 * ibuf is NULL and ibuflen is 0
1676 * else we query specific fields from all rows
1677 * ibuf contains fieldindexes
1679 * if oper == I2O_PARAMS_LIST_GET:
1680 * Get all table group fields from specified rows or
1681 * get specific table group fields from specified rows.
1683 * if fieldcount == -1 we query all fields from specified rows
1684 * ibuf contains rowcount, keyvalues
1685 * else we query specific fields from specified rows
1686 * ibuf contains fieldindexes, rowcount, keyvalues
1688 * You could also use directly function i2o_issue_params().
1690 int i2o_query_table(int oper
,
1691 struct i2o_controller
*iop
, int tid
, int context
, int group
,
1692 int fieldcount
, void *ibuf
, int ibuflen
,
1693 void *resblk
, int reslen
, int *flag
)
1698 opblk
= kmalloc(10 + ibuflen
, GFP_KERNEL
);
1701 printk(KERN_ERR
"i2o: no memory for query buffer.\n");
1705 opblk
[0] = 1; /* operation count */
1706 opblk
[1] = 0; /* pad */
1709 opblk
[4] = fieldcount
;
1710 memcpy(opblk
+5, ibuf
, ibuflen
); /* other params */
1712 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET
,iop
, tid
, context
,
1713 opblk
, 10+ibuflen
, resblk
, reslen
, flag
);
1720 * Clear table group, i.e. delete all rows.
1723 int i2o_clear_table(struct i2o_controller
*iop
, int tid
, int context
,
1724 int group
, int *flag
)
1726 u16 opblk
[] = { 1, 0, I2O_PARAMS_TABLE_CLEAR
, group
};
1727 u8 resblk
[32]; /* min 8 bytes for result header */
1729 return i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1730 opblk
, sizeof(opblk
), resblk
, sizeof(resblk
), flag
);
1734 * Add a new row into a table group.
1736 * if fieldcount==-1 then we add whole rows
1737 * buf contains rowcount, keyvalues
1738 * else just specific fields are given, rest use defaults
1739 * buf contains fieldindexes, rowcount, keyvalues
1742 int i2o_row_add_table(struct i2o_controller
*iop
, int tid
, int context
,
1743 int group
, int fieldcount
, void *buf
, int buflen
,
1747 u8 resblk
[32]; /* min 8 bytes for header */
1750 opblk
= kmalloc(buflen
+64, GFP_KERNEL
);
1753 printk(KERN_ERR
"i2o: no memory for operation buffer.\n");
1757 opblk
[0] = 1; /* operation count */
1758 opblk
[1] = 0; /* pad */
1759 opblk
[2] = I2O_PARAMS_ROW_ADD
;
1761 opblk
[4] = fieldcount
;
1762 memcpy(opblk
+5, buf
, buflen
);
1764 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1765 opblk
, 10+buflen
, resblk
, sizeof(resblk
), flag
);
1772 * Delete rows from a table group.
1775 int i2o_row_delete_table(struct i2o_controller
*iop
, int tid
, int context
,
1776 int group
, int keycount
, void *keys
, int keyslen
,
1780 u8 resblk
[32]; /* min 8 bytes for header */
1783 opblk
= kmalloc(keyslen
+64, GFP_KERNEL
);
1786 printk(KERN_ERR
"i2o: no memory for operation buffer.\n");
1790 opblk
[0] = 1; /* operation count */
1791 opblk
[1] = 0; /* pad */
1792 opblk
[2] = I2O_PARAMS_ROW_DELETE
;
1794 opblk
[4] = keycount
;
1795 memcpy(opblk
+5, keys
, keyslen
);
1797 size
= i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET
, iop
, tid
, context
,
1798 opblk
, 10+keyslen
, resblk
, sizeof(resblk
), flag
);
1804 void i2o_report_common_status(u8 req_status
)
1806 /* the following reply status strings are common to all classes */
1808 static char *REPLY_STATUS
[] = {
1811 "ABORT_NO_DATA_TRANSFER",
1812 "ABORT_PARTIAL_TRANSFER",
1814 "ERROR_NO_DATA_TRANSFER",
1815 "ERROR_PARTIAL_TRANSFER",
1816 "PROCESS_ABORT_DIRTY",
1817 "PROCESS_ABORT_NO_DATA_TRANSFER",
1818 "PROCESS_ABORT_PARTIAL_TRANSFER",
1819 "TRANSACTION_ERROR",
1823 if (req_status
> I2O_REPLY_STATUS_PROGRESS_REPORT
)
1824 printk("%0#4x / ", req_status
);
1826 printk("%s / ", REPLY_STATUS
[req_status
]);
1831 static void i2o_report_common_dsc(u16 detailed_status
)
1833 /* The following detailed statuscodes are valid
1834 - for executive class, utility class, DDM class and
1835 - for transaction error replies
1838 static char *COMMON_DSC
[] = {
1843 "REPLY_BUFFER_FULL",
1845 "INSUFFICIENT_RESOURCE_SOFT",
1846 "INSUFFICIENT_RESOURCE_HARD",
1848 "CHAIN_BUFFER_TOO_LARGE",
1849 "UNSUPPORTED_FUNCTION",
1852 "INAPPROPRIATE_FUNCTION",
1853 "INVALID_INITIATOR_ADDRESS",
1854 "INVALID_MESSAGE_FLAGS",
1856 "INVALID_PARAMETER",
1858 "INVALID_TARGET_ADDRESS",
1859 "MESSAGE_TOO_LARGE",
1860 "MESSAGE_TOO_SMALL",
1861 "MISSING_PARAMETER",
1865 "UNSUPPORTED_VERSION",
1867 "DEVICE_NOT_AVAILABLE"
1870 if (detailed_status
> I2O_DSC_DEVICE_NOT_AVAILABLE
)
1871 printk("%0#4x.\n", detailed_status
);
1873 printk("%s.\n", COMMON_DSC
[detailed_status
]);
1878 static void i2o_report_lan_dsc(u16 detailed_status
)
1880 static char *LAN_DSC
[] = { // Lan detailed status code strings
1883 "DESTINATION_NOT_FOUND",
1889 "BAD_PACKET_DETECTED",
1892 "IOP_INTERNAL_ERROR",
1894 "INVALID_TRANSACTION_CONTEXT",
1895 "DEST_ADDRESS_DETECTED",
1896 "DEST_ADDRESS_OMITTED",
1897 "PARTIAL_PACKET_RETURNED",
1898 "TEMP_SUSPENDED_STATE", // last Lan detailed status code
1899 "INVALID_REQUEST" // general detailed status code
1902 if (detailed_status
> I2O_DSC_INVALID_REQUEST
)
1903 printk("%0#4x.\n", detailed_status
);
1905 printk("%s.\n", LAN_DSC
[detailed_status
]);
1910 static void i2o_report_util_cmd(u8 cmd
)
1913 case I2O_CMD_UTIL_NOP
:
1914 printk("UTIL_NOP, ");
1916 case I2O_CMD_UTIL_ABORT
:
1917 printk("UTIL_ABORT, ");
1919 case I2O_CMD_UTIL_CLAIM
:
1920 printk("UTIL_CLAIM, ");
1922 case I2O_CMD_UTIL_RELEASE
:
1923 printk("UTIL_CLAIM_RELEASE, ");
1925 case I2O_CMD_UTIL_CONFIG_DIALOG
:
1926 printk("UTIL_CONFIG_DIALOG, ");
1928 case I2O_CMD_UTIL_DEVICE_RESERVE
:
1929 printk("UTIL_DEVICE_RESERVE, ");
1931 case I2O_CMD_UTIL_DEVICE_RELEASE
:
1932 printk("UTIL_DEVICE_RELEASE, ");
1934 case I2O_CMD_UTIL_ACK
:
1935 printk("UTIL_EVENT_ACKNOWLEDGE, ");
1937 case I2O_CMD_UTIL_EVT_REGISTER
:
1938 printk("UTIL_EVENT_REGISTER, ");
1940 case I2O_CMD_UTIL_LOCK
:
1941 printk("UTIL_LOCK, ");
1943 case I2O_CMD_UTIL_LOCK_RELEASE
:
1944 printk("UTIL_LOCK_RELEASE, ");
1946 case I2O_CMD_UTIL_PARAMS_GET
:
1947 printk("UTIL_PARAMS_GET, ");
1949 case I2O_CMD_UTIL_PARAMS_SET
:
1950 printk("UTIL_PARAMS_SET, ");
1952 case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY
:
1953 printk("UTIL_REPLY_FAULT_NOTIFY, ");
1956 printk("%0#2x, ",cmd
);
1963 static void i2o_report_exec_cmd(u8 cmd
)
1966 case I2O_CMD_ADAPTER_ASSIGN
:
1967 printk("EXEC_ADAPTER_ASSIGN, ");
1969 case I2O_CMD_ADAPTER_READ
:
1970 printk("EXEC_ADAPTER_READ, ");
1972 case I2O_CMD_ADAPTER_RELEASE
:
1973 printk("EXEC_ADAPTER_RELEASE, ");
1975 case I2O_CMD_BIOS_INFO_SET
:
1976 printk("EXEC_BIOS_INFO_SET, ");
1978 case I2O_CMD_BOOT_DEVICE_SET
:
1979 printk("EXEC_BOOT_DEVICE_SET, ");
1981 case I2O_CMD_CONFIG_VALIDATE
:
1982 printk("EXEC_CONFIG_VALIDATE, ");
1984 case I2O_CMD_CONN_SETUP
:
1985 printk("EXEC_CONN_SETUP, ");
1987 case I2O_CMD_DDM_DESTROY
:
1988 printk("EXEC_DDM_DESTROY, ");
1990 case I2O_CMD_DDM_ENABLE
:
1991 printk("EXEC_DDM_ENABLE, ");
1993 case I2O_CMD_DDM_QUIESCE
:
1994 printk("EXEC_DDM_QUIESCE, ");
1996 case I2O_CMD_DDM_RESET
:
1997 printk("EXEC_DDM_RESET, ");
1999 case I2O_CMD_DDM_SUSPEND
:
2000 printk("EXEC_DDM_SUSPEND, ");
2002 case I2O_CMD_DEVICE_ASSIGN
:
2003 printk("EXEC_DEVICE_ASSIGN, ");
2005 case I2O_CMD_DEVICE_RELEASE
:
2006 printk("EXEC_DEVICE_RELEASE, ");
2008 case I2O_CMD_HRT_GET
:
2009 printk("EXEC_HRT_GET, ");
2011 case I2O_CMD_ADAPTER_CLEAR
:
2012 printk("EXEC_IOP_CLEAR, ");
2014 case I2O_CMD_ADAPTER_CONNECT
:
2015 printk("EXEC_IOP_CONNECT, ");
2017 case I2O_CMD_ADAPTER_RESET
:
2018 printk("EXEC_IOP_RESET, ");
2020 case I2O_CMD_LCT_NOTIFY
:
2021 printk("EXEC_LCT_NOTIFY, ");
2023 case I2O_CMD_OUTBOUND_INIT
:
2024 printk("EXEC_OUTBOUND_INIT, ");
2026 case I2O_CMD_PATH_ENABLE
:
2027 printk("EXEC_PATH_ENABLE, ");
2029 case I2O_CMD_PATH_QUIESCE
:
2030 printk("EXEC_PATH_QUIESCE, ");
2032 case I2O_CMD_PATH_RESET
:
2033 printk("EXEC_PATH_RESET, ");
2035 case I2O_CMD_STATIC_MF_CREATE
:
2036 printk("EXEC_STATIC_MF_CREATE, ");
2038 case I2O_CMD_STATIC_MF_RELEASE
:
2039 printk("EXEC_STATIC_MF_RELEASE, ");
2041 case I2O_CMD_STATUS_GET
:
2042 printk("EXEC_STATUS_GET, ");
2044 case I2O_CMD_SW_DOWNLOAD
:
2045 printk("EXEC_SW_DOWNLOAD, ");
2047 case I2O_CMD_SW_UPLOAD
:
2048 printk("EXEC_SW_UPLOAD, ");
2050 case I2O_CMD_SW_REMOVE
:
2051 printk("EXEC_SW_REMOVE, ");
2053 case I2O_CMD_SYS_ENABLE
:
2054 printk("EXEC_SYS_ENABLE, ");
2056 case I2O_CMD_SYS_MODIFY
:
2057 printk("EXEC_SYS_MODIFY, ");
2059 case I2O_CMD_SYS_QUIESCE
:
2060 printk("EXEC_SYS_QUIESCE, ");
2062 case I2O_CMD_SYS_TAB_SET
:
2063 printk("EXEC_SYS_TAB_SET, ");
2066 printk("%02x, ",cmd
);
2072 static void i2o_report_lan_cmd(u8 cmd
)
2075 case LAN_PACKET_SEND
:
2076 printk("LAN_PACKET_SEND, ");
2079 printk("LAN_SDU_SEND, ");
2081 case LAN_RECEIVE_POST
:
2082 printk("LAN_RECEIVE_POST, ");
2085 printk("LAN_RESET, ");
2088 printk("LAN_SUSPEND, ");
2091 printk("%02x, ",cmd
);
2097 /* TODO: Add support for other classes */
2098 void i2o_report_status(const char *severity
, const char *module
, u32
*msg
)
2100 u8 cmd
= (msg
[1]>>24)&0xFF;
2101 u8 req_status
= (msg
[4]>>24)&0xFF;
2102 u16 detailed_status
= msg
[4]&0xFFFF;
2104 printk("%s%s: ", severity
, module
);
2106 if (cmd
< 0x1F) { // Utility Class
2107 i2o_report_util_cmd(cmd
);
2108 i2o_report_common_status(req_status
);
2109 i2o_report_common_dsc(detailed_status
);
2113 if (cmd
>= 0x30 && cmd
<= 0x3F) { // LAN class
2114 i2o_report_lan_cmd(cmd
);
2115 i2o_report_common_status(req_status
);
2116 i2o_report_lan_dsc(detailed_status
);
2120 if (cmd
>= 0xA0 && cmd
<= 0xEF) { // Executive class
2121 i2o_report_exec_cmd(cmd
);
2122 i2o_report_common_status(req_status
);
2123 i2o_report_common_dsc(detailed_status
);
2127 printk("%02x, %02x / %04x.\n", cmd
, req_status
, detailed_status
);
2131 /* Used to dump a message to syslog during debugging */
2132 static void i2o_dump_message(u32
*msg
)
2137 printk(KERN_INFO
"Dumping I2O message @ %p\n", msg
);
2138 for(i
= 0; i
< ((msg
[0]>>16)&0xffff); i
++)
2139 printk(KERN_INFO
"\tmsg[%d] = %#10x\n", i
, msg
[i
]);
2145 EXPORT_SYMBOL(i2o_install_handler
);
2146 EXPORT_SYMBOL(i2o_remove_handler
);
2147 EXPORT_SYMBOL(i2o_install_device
);
2148 EXPORT_SYMBOL(i2o_delete_device
);
2149 EXPORT_SYMBOL(i2o_quiesce_controller
);
2150 EXPORT_SYMBOL(i2o_clear_controller
);
2151 EXPORT_SYMBOL(i2o_install_controller
);
2152 EXPORT_SYMBOL(i2o_delete_controller
);
2153 EXPORT_SYMBOL(i2o_unlock_controller
);
2154 EXPORT_SYMBOL(i2o_find_controller
);
2155 EXPORT_SYMBOL(i2o_num_controllers
);
2156 EXPORT_SYMBOL(i2o_claim_device
);
2157 EXPORT_SYMBOL(i2o_release_device
);
2158 EXPORT_SYMBOL(i2o_run_queue
);
2159 EXPORT_SYMBOL(i2o_report_controller_unit
);
2160 EXPORT_SYMBOL(i2o_activate_controller
);
2161 EXPORT_SYMBOL(i2o_online_controller
);
2162 EXPORT_SYMBOL(i2o_get_class_name
);
2164 EXPORT_SYMBOL(i2o_query_scalar
);
2165 EXPORT_SYMBOL(i2o_set_scalar
);
2166 EXPORT_SYMBOL(i2o_query_table
);
2167 EXPORT_SYMBOL(i2o_clear_table
);
2168 EXPORT_SYMBOL(i2o_row_add_table
);
2169 EXPORT_SYMBOL(i2o_row_delete_table
);
2171 EXPORT_SYMBOL(i2o_post_this
);
2172 EXPORT_SYMBOL(i2o_post_wait
);
2173 EXPORT_SYMBOL(i2o_issue_claim
);
2174 EXPORT_SYMBOL(i2o_issue_params
);
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 int __init
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