1 /* ds.c: Domain Services driver for Logical Domains
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/module.h>
10 #include <linux/string.h>
11 #include <linux/slab.h>
12 #include <linux/sched.h>
13 #include <linux/delay.h>
14 #include <linux/mutex.h>
15 #include <linux/kthread.h>
16 #include <linux/cpu.h>
20 #include <asm/power.h>
21 #include <asm/mdesc.h>
25 #define DRV_MODULE_NAME "ds"
26 #define PFX DRV_MODULE_NAME ": "
27 #define DRV_MODULE_VERSION "1.0"
28 #define DRV_MODULE_RELDATE "Jul 11, 2007"
30 static char version[] __devinitdata =
31 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
32 MODULE_AUTHOR("David S. Miller (davem@davemloft.net)");
33 MODULE_DESCRIPTION("Sun LDOM domain services driver");
34 MODULE_LICENSE("GPL");
35 MODULE_VERSION(DRV_MODULE_VERSION);
39 #define DS_INIT_REQ 0x00
40 #define DS_INIT_ACK 0x01
41 #define DS_INIT_NACK 0x02
42 #define DS_REG_REQ 0x03
43 #define DS_REG_ACK 0x04
44 #define DS_REG_NACK 0x05
45 #define DS_UNREG_REQ 0x06
46 #define DS_UNREG_ACK 0x07
47 #define DS_UNREG_NACK 0x08
56 #define DS_REG_VER_NACK 0x01
57 #define DS_REG_DUP 0x02
58 #define DS_INV_HDL 0x03
59 #define DS_TYPE_UNKNOWN 0x04
67 struct ds_msg_tag tag;
68 struct ds_version ver;
72 struct ds_msg_tag tag;
77 struct ds_msg_tag tag;
82 struct ds_msg_tag tag;
90 struct ds_msg_tag tag;
96 struct ds_msg_tag tag;
101 struct ds_unreg_req {
102 struct ds_msg_tag tag;
106 struct ds_unreg_ack {
107 struct ds_msg_tag tag;
111 struct ds_unreg_nack {
112 struct ds_msg_tag tag;
117 struct ds_msg_tag tag;
121 struct ds_data_nack {
122 struct ds_msg_tag tag;
127 struct ds_cap_state {
130 void (*data)(struct ldc_channel *lp,
131 struct ds_cap_state *cp,
134 const char *service_id;
137 #define CAP_STATE_UNKNOWN 0x00
138 #define CAP_STATE_REG_SENT 0x01
139 #define CAP_STATE_REGISTERED 0x02
142 static void md_update_data(struct ldc_channel *lp, struct ds_cap_state *cp,
144 static void domain_shutdown_data(struct ldc_channel *lp,
145 struct ds_cap_state *cp,
147 static void domain_panic_data(struct ldc_channel *lp,
148 struct ds_cap_state *cp,
150 #ifdef CONFIG_HOTPLUG_CPU
151 static void dr_cpu_data(struct ldc_channel *lp,
152 struct ds_cap_state *cp,
155 static void ds_pri_data(struct ldc_channel *lp,
156 struct ds_cap_state *cp,
158 static void ds_var_data(struct ldc_channel *lp,
159 struct ds_cap_state *cp,
162 struct ds_cap_state ds_states[] = {
164 .service_id = "md-update",
165 .data = md_update_data,
168 .service_id = "domain-shutdown",
169 .data = domain_shutdown_data,
172 .service_id = "domain-panic",
173 .data = domain_panic_data,
175 #ifdef CONFIG_HOTPLUG_CPU
177 .service_id = "dr-cpu",
186 .service_id = "var-config",
190 .service_id = "var-config-backup",
195 static DEFINE_SPINLOCK(ds_lock);
198 struct ldc_channel *lp;
200 #define DS_HS_START 0x01
201 #define DS_HS_DONE 0x02
207 static struct ds_info *ds_info;
209 static struct ds_cap_state *find_cap(u64 handle)
211 unsigned int index = handle >> 32;
213 if (index >= ARRAY_SIZE(ds_states))
215 return &ds_states[index];
218 static struct ds_cap_state *find_cap_by_string(const char *name)
222 for (i = 0; i < ARRAY_SIZE(ds_states); i++) {
223 if (strcmp(ds_states[i].service_id, name))
226 return &ds_states[i];
231 static int ds_send(struct ldc_channel *lp, void *data, int len)
233 int err, limit = 1000;
236 while (limit-- > 0) {
237 err = ldc_write(lp, data, len);
238 if (!err || (err != -EAGAIN))
246 struct ds_md_update_req {
250 struct ds_md_update_res {
255 static void md_update_data(struct ldc_channel *lp,
256 struct ds_cap_state *dp,
259 struct ds_data *dpkt = buf;
260 struct ds_md_update_req *rp;
263 struct ds_md_update_res res;
266 rp = (struct ds_md_update_req *) (dpkt + 1);
268 printk(KERN_INFO PFX "Machine description update.\n");
270 memset(&pkt, 0, sizeof(pkt));
271 pkt.data.tag.type = DS_DATA;
272 pkt.data.tag.len = sizeof(pkt) - sizeof(struct ds_msg_tag);
273 pkt.data.handle = dp->handle;
274 pkt.res.req_num = rp->req_num;
275 pkt.res.result = DS_OK;
277 ds_send(lp, &pkt, sizeof(pkt));
282 struct ds_shutdown_req {
287 struct ds_shutdown_res {
293 static void domain_shutdown_data(struct ldc_channel *lp,
294 struct ds_cap_state *dp,
297 struct ds_data *dpkt = buf;
298 struct ds_shutdown_req *rp;
301 struct ds_shutdown_res res;
304 rp = (struct ds_shutdown_req *) (dpkt + 1);
306 printk(KERN_ALERT PFX "Shutdown request from "
307 "LDOM manager received.\n");
309 memset(&pkt, 0, sizeof(pkt));
310 pkt.data.tag.type = DS_DATA;
311 pkt.data.tag.len = sizeof(pkt) - sizeof(struct ds_msg_tag);
312 pkt.data.handle = dp->handle;
313 pkt.res.req_num = rp->req_num;
314 pkt.res.result = DS_OK;
315 pkt.res.reason[0] = 0;
317 ds_send(lp, &pkt, sizeof(pkt));
322 struct ds_panic_req {
326 struct ds_panic_res {
332 static void domain_panic_data(struct ldc_channel *lp,
333 struct ds_cap_state *dp,
336 struct ds_data *dpkt = buf;
337 struct ds_panic_req *rp;
340 struct ds_panic_res res;
343 rp = (struct ds_panic_req *) (dpkt + 1);
345 printk(KERN_ALERT PFX "Panic request from "
346 "LDOM manager received.\n");
348 memset(&pkt, 0, sizeof(pkt));
349 pkt.data.tag.type = DS_DATA;
350 pkt.data.tag.len = sizeof(pkt) - sizeof(struct ds_msg_tag);
351 pkt.data.handle = dp->handle;
352 pkt.res.req_num = rp->req_num;
353 pkt.res.result = DS_OK;
354 pkt.res.reason[0] = 0;
356 ds_send(lp, &pkt, sizeof(pkt));
358 panic("PANIC requested by LDOM manager.");
361 #ifdef CONFIG_HOTPLUG_CPU
365 #define DR_CPU_CONFIGURE 0x43
366 #define DR_CPU_UNCONFIGURE 0x55
367 #define DR_CPU_FORCE_UNCONFIGURE 0x46
368 #define DR_CPU_STATUS 0x53
371 #define DR_CPU_OK 0x6f
372 #define DR_CPU_ERROR 0x65
377 struct dr_cpu_resp_entry {
380 #define DR_CPU_RES_OK 0x00
381 #define DR_CPU_RES_FAILURE 0x01
382 #define DR_CPU_RES_BLOCKED 0x02
383 #define DR_CPU_RES_CPU_NOT_RESPONDING 0x03
384 #define DR_CPU_RES_NOT_IN_MD 0x04
387 #define DR_CPU_STAT_NOT_PRESENT 0x00
388 #define DR_CPU_STAT_UNCONFIGURED 0x01
389 #define DR_CPU_STAT_CONFIGURED 0x02
394 /* DR cpu requests get queued onto the work list by the
395 * dr_cpu_data() callback. The list is protected by
396 * ds_lock, and processed by dr_cpu_process() in order.
398 static LIST_HEAD(dr_cpu_work_list);
399 static DECLARE_WAIT_QUEUE_HEAD(dr_cpu_wait);
401 struct dr_cpu_queue_entry {
402 struct list_head list;
406 static void __dr_cpu_send_error(struct ds_cap_state *cp, struct ds_data *data)
408 struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1);
409 struct ds_info *dp = ds_info;
412 struct dr_cpu_tag tag;
416 memset(&pkt, 0, sizeof(pkt));
417 pkt.data.tag.type = DS_DATA;
418 pkt.data.handle = cp->handle;
419 pkt.tag.req_num = tag->req_num;
420 pkt.tag.type = DR_CPU_ERROR;
421 pkt.tag.num_records = 0;
423 msg_len = (sizeof(struct ds_data) +
424 sizeof(struct dr_cpu_tag));
426 pkt.data.tag.len = msg_len - sizeof(struct ds_msg_tag);
428 ds_send(dp->lp, &pkt, msg_len);
431 static void dr_cpu_send_error(struct ds_cap_state *cp, struct ds_data *data)
435 spin_lock_irqsave(&ds_lock, flags);
436 __dr_cpu_send_error(cp, data);
437 spin_unlock_irqrestore(&ds_lock, flags);
440 #define CPU_SENTINEL 0xffffffff
442 static void purge_dups(u32 *list, u32 num_ents)
446 for (i = 0; i < num_ents; i++) {
450 if (cpu == CPU_SENTINEL)
453 for (j = i + 1; j < num_ents; j++) {
455 list[j] = CPU_SENTINEL;
460 static int dr_cpu_size_response(int ncpus)
462 return (sizeof(struct ds_data) +
463 sizeof(struct dr_cpu_tag) +
464 (sizeof(struct dr_cpu_resp_entry) * ncpus));
467 static void dr_cpu_init_response(struct ds_data *resp, u64 req_num,
468 u64 handle, int resp_len, int ncpus,
469 cpumask_t *mask, u32 default_stat)
471 struct dr_cpu_resp_entry *ent;
472 struct dr_cpu_tag *tag;
475 tag = (struct dr_cpu_tag *) (resp + 1);
476 ent = (struct dr_cpu_resp_entry *) (tag + 1);
478 resp->tag.type = DS_DATA;
479 resp->tag.len = resp_len - sizeof(struct ds_msg_tag);
480 resp->handle = handle;
481 tag->req_num = req_num;
482 tag->type = DR_CPU_OK;
483 tag->num_records = ncpus;
486 for_each_cpu_mask(cpu, *mask) {
488 ent[i].result = DR_CPU_RES_OK;
489 ent[i].stat = default_stat;
495 static void dr_cpu_mark(struct ds_data *resp, int cpu, int ncpus,
498 struct dr_cpu_resp_entry *ent;
499 struct dr_cpu_tag *tag;
502 tag = (struct dr_cpu_tag *) (resp + 1);
503 ent = (struct dr_cpu_resp_entry *) (tag + 1);
505 for (i = 0; i < ncpus; i++) {
506 if (ent[i].cpu != cpu)
514 static int dr_cpu_configure(struct ds_cap_state *cp, u64 req_num,
517 struct ds_data *resp;
518 int resp_len, ncpus, cpu;
521 ncpus = cpus_weight(*mask);
522 resp_len = dr_cpu_size_response(ncpus);
523 resp = kzalloc(resp_len, GFP_KERNEL);
527 dr_cpu_init_response(resp, req_num, cp->handle,
528 resp_len, ncpus, mask,
529 DR_CPU_STAT_CONFIGURED);
531 mdesc_fill_in_cpu_data(*mask);
533 for_each_cpu_mask(cpu, *mask) {
536 printk(KERN_INFO PFX "Starting cpu %d...\n", cpu);
539 __u32 res = DR_CPU_RES_FAILURE;
540 __u32 stat = DR_CPU_STAT_UNCONFIGURED;
542 if (!cpu_present(cpu)) {
543 /* CPU not present in MD */
544 res = DR_CPU_RES_NOT_IN_MD;
545 stat = DR_CPU_STAT_NOT_PRESENT;
546 } else if (err == -ENODEV) {
547 /* CPU did not call in successfully */
548 res = DR_CPU_RES_CPU_NOT_RESPONDING;
551 printk(KERN_INFO PFX "CPU startup failed err=%d\n",
553 dr_cpu_mark(resp, cpu, ncpus, res, stat);
557 spin_lock_irqsave(&ds_lock, flags);
558 ds_send(ds_info->lp, resp, resp_len);
559 spin_unlock_irqrestore(&ds_lock, flags);
563 /* Redistribute IRQs, taking into account the new cpus. */
569 static int dr_cpu_unconfigure(struct ds_cap_state *cp, u64 req_num,
572 struct ds_data *resp;
573 int resp_len, ncpus, cpu;
576 ncpus = cpus_weight(*mask);
577 resp_len = dr_cpu_size_response(ncpus);
578 resp = kzalloc(resp_len, GFP_KERNEL);
582 dr_cpu_init_response(resp, req_num, cp->handle,
583 resp_len, ncpus, mask,
584 DR_CPU_STAT_UNCONFIGURED);
586 for_each_cpu_mask(cpu, *mask) {
589 printk(KERN_INFO PFX "CPU[%d]: Shutting down cpu %d...\n",
590 smp_processor_id(), cpu);
593 dr_cpu_mark(resp, cpu, ncpus,
595 DR_CPU_STAT_CONFIGURED);
598 spin_lock_irqsave(&ds_lock, flags);
599 ds_send(ds_info->lp, resp, resp_len);
600 spin_unlock_irqrestore(&ds_lock, flags);
607 static void process_dr_cpu_list(struct ds_cap_state *cp)
609 struct dr_cpu_queue_entry *qp, *tmp;
614 spin_lock_irqsave(&ds_lock, flags);
615 list_splice(&dr_cpu_work_list, &todo);
616 INIT_LIST_HEAD(&dr_cpu_work_list);
617 spin_unlock_irqrestore(&ds_lock, flags);
619 list_for_each_entry_safe(qp, tmp, &todo, list) {
620 struct ds_data *data = (struct ds_data *) qp->req;
621 struct dr_cpu_tag *tag = (struct dr_cpu_tag *) (data + 1);
622 u32 *cpu_list = (u32 *) (tag + 1);
623 u64 req_num = tag->req_num;
628 case DR_CPU_CONFIGURE:
629 case DR_CPU_UNCONFIGURE:
630 case DR_CPU_FORCE_UNCONFIGURE:
634 dr_cpu_send_error(cp, data);
638 purge_dups(cpu_list, tag->num_records);
641 for (i = 0; i < tag->num_records; i++) {
642 if (cpu_list[i] == CPU_SENTINEL)
645 if (cpu_list[i] < NR_CPUS)
646 cpu_set(cpu_list[i], mask);
649 if (tag->type == DR_CPU_CONFIGURE)
650 err = dr_cpu_configure(cp, req_num, &mask);
652 err = dr_cpu_unconfigure(cp, req_num, &mask);
655 dr_cpu_send_error(cp, data);
663 static int dr_cpu_thread(void *__unused)
665 struct ds_cap_state *cp;
668 cp = find_cap_by_string("dr-cpu");
671 prepare_to_wait(&dr_cpu_wait, &wait, TASK_INTERRUPTIBLE);
672 if (list_empty(&dr_cpu_work_list))
674 finish_wait(&dr_cpu_wait, &wait);
676 if (kthread_should_stop())
679 process_dr_cpu_list(cp);
685 static void dr_cpu_data(struct ldc_channel *lp,
686 struct ds_cap_state *dp,
689 struct dr_cpu_queue_entry *qp;
690 struct ds_data *dpkt = buf;
691 struct dr_cpu_tag *rp;
693 rp = (struct dr_cpu_tag *) (dpkt + 1);
695 qp = kmalloc(sizeof(struct dr_cpu_queue_entry) + len, GFP_ATOMIC);
697 struct ds_cap_state *cp;
699 cp = find_cap_by_string("dr-cpu");
700 __dr_cpu_send_error(cp, dpkt);
702 memcpy(&qp->req, buf, len);
703 list_add_tail(&qp->list, &dr_cpu_work_list);
704 wake_up(&dr_cpu_wait);
712 #define DS_PRI_REQUEST 0x00
713 #define DS_PRI_DATA 0x01
714 #define DS_PRI_UPDATE 0x02
717 static void ds_pri_data(struct ldc_channel *lp,
718 struct ds_cap_state *dp,
721 struct ds_data *dpkt = buf;
722 struct ds_pri_msg *rp;
724 rp = (struct ds_pri_msg *) (dpkt + 1);
726 printk(KERN_INFO PFX "PRI REQ [%lx:%lx], len=%d\n",
727 rp->req_num, rp->type, len);
732 #define DS_VAR_SET_REQ 0x00
733 #define DS_VAR_DELETE_REQ 0x01
734 #define DS_VAR_SET_RESP 0x02
735 #define DS_VAR_DELETE_RESP 0x03
738 struct ds_var_set_msg {
739 struct ds_var_hdr hdr;
740 char name_and_value[0];
743 struct ds_var_delete_msg {
744 struct ds_var_hdr hdr;
749 struct ds_var_hdr hdr;
751 #define DS_VAR_SUCCESS 0x00
752 #define DS_VAR_NO_SPACE 0x01
753 #define DS_VAR_INVALID_VAR 0x02
754 #define DS_VAR_INVALID_VAL 0x03
755 #define DS_VAR_NOT_PRESENT 0x04
758 static DEFINE_MUTEX(ds_var_mutex);
759 static int ds_var_doorbell;
760 static int ds_var_response;
762 static void ds_var_data(struct ldc_channel *lp,
763 struct ds_cap_state *dp,
766 struct ds_data *dpkt = buf;
767 struct ds_var_resp *rp;
769 rp = (struct ds_var_resp *) (dpkt + 1);
771 if (rp->hdr.type != DS_VAR_SET_RESP &&
772 rp->hdr.type != DS_VAR_DELETE_RESP)
775 ds_var_response = rp->result;
780 void ldom_set_var(const char *var, const char *value)
782 struct ds_info *dp = ds_info;
783 struct ds_cap_state *cp;
785 cp = find_cap_by_string("var-config");
786 if (cp->state != CAP_STATE_REGISTERED)
787 cp = find_cap_by_string("var-config-backup");
789 if (cp->state == CAP_STATE_REGISTERED) {
793 struct ds_var_set_msg msg;
801 memset(&pkt, 0, sizeof(pkt));
802 pkt.header.data.tag.type = DS_DATA;
803 pkt.header.data.handle = cp->handle;
804 pkt.header.msg.hdr.type = DS_VAR_SET_REQ;
805 base = p = &pkt.header.msg.name_and_value[0];
807 p += strlen(var) + 1;
809 p += strlen(value) + 1;
811 msg_len = (sizeof(struct ds_data) +
812 sizeof(struct ds_var_set_msg) +
814 msg_len = (msg_len + 3) & ~3;
815 pkt.header.data.tag.len = msg_len - sizeof(struct ds_msg_tag);
817 mutex_lock(&ds_var_mutex);
819 spin_lock_irqsave(&ds_lock, flags);
821 ds_var_response = -1;
823 ds_send(dp->lp, &pkt, msg_len);
824 spin_unlock_irqrestore(&ds_lock, flags);
827 while (ds_var_doorbell == 0) {
834 mutex_unlock(&ds_var_mutex);
836 if (ds_var_doorbell == 0 ||
837 ds_var_response != DS_VAR_SUCCESS)
838 printk(KERN_ERR PFX "var-config [%s:%s] "
839 "failed, response(%d).\n",
843 printk(KERN_ERR PFX "var-config not registered so "
844 "could not set (%s) variable to (%s).\n",
849 void ldom_reboot(const char *boot_command)
851 /* Don't bother with any of this if the boot_command
854 if (boot_command && strlen(boot_command)) {
855 char full_boot_str[256];
857 strcpy(full_boot_str, "boot ");
858 strcpy(full_boot_str + strlen("boot "), boot_command);
860 ldom_set_var("reboot-command", full_boot_str);
865 void ldom_power_off(void)
870 static void ds_conn_reset(struct ds_info *dp)
872 printk(KERN_ERR PFX "ds_conn_reset() from %p\n",
873 __builtin_return_address(0));
876 static int register_services(struct ds_info *dp)
878 struct ldc_channel *lp = dp->lp;
881 for (i = 0; i < ARRAY_SIZE(ds_states); i++) {
883 struct ds_reg_req req;
886 struct ds_cap_state *cp = &ds_states[i];
890 if (cp->state == CAP_STATE_REGISTERED)
893 new_count = sched_clock() & 0xffffffff;
894 cp->handle = ((u64) i << 32) | new_count;
896 msg_len = (sizeof(struct ds_reg_req) +
897 strlen(cp->service_id));
899 memset(&pbuf, 0, sizeof(pbuf));
900 pbuf.req.tag.type = DS_REG_REQ;
901 pbuf.req.tag.len = (msg_len - sizeof(struct ds_msg_tag));
902 pbuf.req.handle = cp->handle;
905 strcpy(pbuf.req.svc_id, cp->service_id);
907 err = ds_send(lp, &pbuf, msg_len);
909 cp->state = CAP_STATE_REG_SENT;
914 static int ds_handshake(struct ds_info *dp, struct ds_msg_tag *pkt)
917 if (dp->hs_state == DS_HS_START) {
918 if (pkt->type != DS_INIT_ACK)
921 dp->hs_state = DS_HS_DONE;
923 return register_services(dp);
926 if (dp->hs_state != DS_HS_DONE)
929 if (pkt->type == DS_REG_ACK) {
930 struct ds_reg_ack *ap = (struct ds_reg_ack *) pkt;
931 struct ds_cap_state *cp = find_cap(ap->handle);
934 printk(KERN_ERR PFX "REG ACK for unknown handle %lx\n",
938 printk(KERN_INFO PFX "Registered %s service.\n",
940 cp->state = CAP_STATE_REGISTERED;
941 } else if (pkt->type == DS_REG_NACK) {
942 struct ds_reg_nack *np = (struct ds_reg_nack *) pkt;
943 struct ds_cap_state *cp = find_cap(np->handle);
946 printk(KERN_ERR PFX "REG NACK for "
947 "unknown handle %lx\n",
951 printk(KERN_INFO PFX "Could not register %s service\n",
953 cp->state = CAP_STATE_UNKNOWN;
963 static int ds_data(struct ds_info *dp, struct ds_msg_tag *pkt, int len)
965 struct ds_data *dpkt = (struct ds_data *) pkt;
966 struct ds_cap_state *cp = find_cap(dpkt->handle);
969 struct ds_data_nack nack = {
972 .len = (sizeof(struct ds_data_nack) -
973 sizeof(struct ds_msg_tag)),
975 .handle = dpkt->handle,
976 .result = DS_INV_HDL,
979 printk(KERN_ERR PFX "Data for unknown handle %lu\n",
981 ds_send(dp->lp, &nack, sizeof(nack));
983 cp->data(dp->lp, cp, dpkt, len);
988 static void ds_up(struct ds_info *dp)
990 struct ldc_channel *lp = dp->lp;
991 struct ds_ver_req req;
994 req.tag.type = DS_INIT_REQ;
995 req.tag.len = sizeof(req) - sizeof(struct ds_msg_tag);
999 err = ds_send(lp, &req, sizeof(req));
1001 dp->hs_state = DS_HS_START;
1004 static void ds_event(void *arg, int event)
1006 struct ds_info *dp = arg;
1007 struct ldc_channel *lp = dp->lp;
1008 unsigned long flags;
1011 spin_lock_irqsave(&ds_lock, flags);
1013 if (event == LDC_EVENT_UP) {
1015 spin_unlock_irqrestore(&ds_lock, flags);
1019 if (event != LDC_EVENT_DATA_READY) {
1020 printk(KERN_WARNING PFX "Unexpected LDC event %d\n", event);
1021 spin_unlock_irqrestore(&ds_lock, flags);
1027 struct ds_msg_tag *tag;
1029 err = ldc_read(lp, dp->rcv_buf, sizeof(*tag));
1031 if (unlikely(err < 0)) {
1032 if (err == -ECONNRESET)
1040 err = ldc_read(lp, tag + 1, tag->len);
1042 if (unlikely(err < 0)) {
1043 if (err == -ECONNRESET)
1050 if (tag->type < DS_DATA)
1051 err = ds_handshake(dp, dp->rcv_buf);
1053 err = ds_data(dp, dp->rcv_buf,
1054 sizeof(*tag) + err);
1055 if (err == -ECONNRESET)
1059 spin_unlock_irqrestore(&ds_lock, flags);
1062 static int __devinit ds_probe(struct vio_dev *vdev,
1063 const struct vio_device_id *id)
1065 static int ds_version_printed;
1066 struct ldc_channel_config ds_cfg = {
1069 .mode = LDC_MODE_STREAM,
1071 struct ldc_channel *lp;
1075 if (ds_version_printed++ == 0)
1076 printk(KERN_INFO "%s", version);
1078 dp = kzalloc(sizeof(*dp), GFP_KERNEL);
1083 dp->rcv_buf = kzalloc(4096, GFP_KERNEL);
1087 dp->rcv_buf_len = 4096;
1089 ds_cfg.tx_irq = vdev->tx_irq;
1090 ds_cfg.rx_irq = vdev->rx_irq;
1092 lp = ldc_alloc(vdev->channel_id, &ds_cfg, dp);
1095 goto out_free_rcv_buf;
1099 err = ldc_bind(lp, "DS");
1122 static int ds_remove(struct vio_dev *vdev)
1127 static struct vio_device_id ds_match[] = {
1129 .type = "domain-services-port",
1134 static struct vio_driver ds_driver = {
1135 .id_table = ds_match,
1137 .remove = ds_remove,
1140 .owner = THIS_MODULE,
1144 static int __init ds_init(void)
1148 for (i = 0; i < ARRAY_SIZE(ds_states); i++)
1149 ds_states[i].handle = ((u64)i << 32);
1151 #ifdef CONFIG_HOTPLUG_CPU
1152 kthread_run(dr_cpu_thread, NULL, "kdrcpud");
1155 return vio_register_driver(&ds_driver);
1158 subsys_initcall(ds_init);