diff options
Diffstat (limited to 'drivers/infiniband/include/ib_verbs.h')
-rw-r--r-- | drivers/infiniband/include/ib_verbs.h | 149 |
1 files changed, 131 insertions, 18 deletions
diff --git a/drivers/infiniband/include/ib_verbs.h b/drivers/infiniband/include/ib_verbs.h index cf01f044a223..5d24edaa66e6 100644 --- a/drivers/infiniband/include/ib_verbs.h +++ b/drivers/infiniband/include/ib_verbs.h | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright (c) 2004 Intel Corporation. All rights reserved. | 4 | * Copyright (c) 2004 Intel Corporation. All rights reserved. |
5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. | 5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. |
6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. | 6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. |
7 | * Copyright (c) 2005 Cisco Systems. All rights reserved. | ||
7 | * | 8 | * |
8 | * This software is available to you under a choice of one of two | 9 | * This software is available to you under a choice of one of two |
9 | * licenses. You may choose to be licensed under the terms of the GNU | 10 | * licenses. You may choose to be licensed under the terms of the GNU |
@@ -41,7 +42,10 @@ | |||
41 | 42 | ||
42 | #include <linux/types.h> | 43 | #include <linux/types.h> |
43 | #include <linux/device.h> | 44 | #include <linux/device.h> |
45 | |||
44 | #include <asm/atomic.h> | 46 | #include <asm/atomic.h> |
47 | #include <asm/scatterlist.h> | ||
48 | #include <asm/uaccess.h> | ||
45 | 49 | ||
46 | union ib_gid { | 50 | union ib_gid { |
47 | u8 raw[16]; | 51 | u8 raw[16]; |
@@ -285,6 +289,15 @@ struct ib_global_route { | |||
285 | u8 traffic_class; | 289 | u8 traffic_class; |
286 | }; | 290 | }; |
287 | 291 | ||
292 | struct ib_grh { | ||
293 | u32 version_tclass_flow; | ||
294 | u16 paylen; | ||
295 | u8 next_hdr; | ||
296 | u8 hop_limit; | ||
297 | union ib_gid sgid; | ||
298 | union ib_gid dgid; | ||
299 | }; | ||
300 | |||
288 | enum { | 301 | enum { |
289 | IB_MULTICAST_QPN = 0xffffff | 302 | IB_MULTICAST_QPN = 0xffffff |
290 | }; | 303 | }; |
@@ -544,7 +557,7 @@ struct ib_send_wr { | |||
544 | int num_sge; | 557 | int num_sge; |
545 | enum ib_wr_opcode opcode; | 558 | enum ib_wr_opcode opcode; |
546 | int send_flags; | 559 | int send_flags; |
547 | u32 imm_data; | 560 | __be32 imm_data; |
548 | union { | 561 | union { |
549 | struct { | 562 | struct { |
550 | u64 remote_addr; | 563 | u64 remote_addr; |
@@ -562,6 +575,7 @@ struct ib_send_wr { | |||
562 | u32 remote_qpn; | 575 | u32 remote_qpn; |
563 | u32 remote_qkey; | 576 | u32 remote_qkey; |
564 | int timeout_ms; /* valid for MADs only */ | 577 | int timeout_ms; /* valid for MADs only */ |
578 | int retries; /* valid for MADs only */ | ||
565 | u16 pkey_index; /* valid for GSI only */ | 579 | u16 pkey_index; /* valid for GSI only */ |
566 | u8 port_num; /* valid for DR SMPs on switch only */ | 580 | u8 port_num; /* valid for DR SMPs on switch only */ |
567 | } ud; | 581 | } ud; |
@@ -618,29 +632,86 @@ struct ib_fmr_attr { | |||
618 | u8 page_size; | 632 | u8 page_size; |
619 | }; | 633 | }; |
620 | 634 | ||
635 | struct ib_ucontext { | ||
636 | struct ib_device *device; | ||
637 | struct list_head pd_list; | ||
638 | struct list_head mr_list; | ||
639 | struct list_head mw_list; | ||
640 | struct list_head cq_list; | ||
641 | struct list_head qp_list; | ||
642 | struct list_head srq_list; | ||
643 | struct list_head ah_list; | ||
644 | spinlock_t lock; | ||
645 | }; | ||
646 | |||
647 | struct ib_uobject { | ||
648 | u64 user_handle; /* handle given to us by userspace */ | ||
649 | struct ib_ucontext *context; /* associated user context */ | ||
650 | struct list_head list; /* link to context's list */ | ||
651 | u32 id; /* index into kernel idr */ | ||
652 | }; | ||
653 | |||
654 | struct ib_umem { | ||
655 | unsigned long user_base; | ||
656 | unsigned long virt_base; | ||
657 | size_t length; | ||
658 | int offset; | ||
659 | int page_size; | ||
660 | int writable; | ||
661 | struct list_head chunk_list; | ||
662 | }; | ||
663 | |||
664 | struct ib_umem_chunk { | ||
665 | struct list_head list; | ||
666 | int nents; | ||
667 | int nmap; | ||
668 | struct scatterlist page_list[0]; | ||
669 | }; | ||
670 | |||
671 | struct ib_udata { | ||
672 | void __user *inbuf; | ||
673 | void __user *outbuf; | ||
674 | size_t inlen; | ||
675 | size_t outlen; | ||
676 | }; | ||
677 | |||
678 | #define IB_UMEM_MAX_PAGE_CHUNK \ | ||
679 | ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \ | ||
680 | ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \ | ||
681 | (void *) &((struct ib_umem_chunk *) 0)->page_list[0])) | ||
682 | |||
683 | struct ib_umem_object { | ||
684 | struct ib_uobject uobject; | ||
685 | struct ib_umem umem; | ||
686 | }; | ||
687 | |||
621 | struct ib_pd { | 688 | struct ib_pd { |
622 | struct ib_device *device; | 689 | struct ib_device *device; |
623 | atomic_t usecnt; /* count all resources */ | 690 | struct ib_uobject *uobject; |
691 | atomic_t usecnt; /* count all resources */ | ||
624 | }; | 692 | }; |
625 | 693 | ||
626 | struct ib_ah { | 694 | struct ib_ah { |
627 | struct ib_device *device; | 695 | struct ib_device *device; |
628 | struct ib_pd *pd; | 696 | struct ib_pd *pd; |
697 | struct ib_uobject *uobject; | ||
629 | }; | 698 | }; |
630 | 699 | ||
631 | typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); | 700 | typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); |
632 | 701 | ||
633 | struct ib_cq { | 702 | struct ib_cq { |
634 | struct ib_device *device; | 703 | struct ib_device *device; |
635 | ib_comp_handler comp_handler; | 704 | struct ib_uobject *uobject; |
636 | void (*event_handler)(struct ib_event *, void *); | 705 | ib_comp_handler comp_handler; |
637 | void * cq_context; | 706 | void (*event_handler)(struct ib_event *, void *); |
638 | int cqe; | 707 | void * cq_context; |
639 | atomic_t usecnt; /* count number of work queues */ | 708 | int cqe; |
709 | atomic_t usecnt; /* count number of work queues */ | ||
640 | }; | 710 | }; |
641 | 711 | ||
642 | struct ib_srq { | 712 | struct ib_srq { |
643 | struct ib_device *device; | 713 | struct ib_device *device; |
714 | struct ib_uobject *uobject; | ||
644 | struct ib_pd *pd; | 715 | struct ib_pd *pd; |
645 | void *srq_context; | 716 | void *srq_context; |
646 | atomic_t usecnt; | 717 | atomic_t usecnt; |
@@ -652,6 +723,7 @@ struct ib_qp { | |||
652 | struct ib_cq *send_cq; | 723 | struct ib_cq *send_cq; |
653 | struct ib_cq *recv_cq; | 724 | struct ib_cq *recv_cq; |
654 | struct ib_srq *srq; | 725 | struct ib_srq *srq; |
726 | struct ib_uobject *uobject; | ||
655 | void (*event_handler)(struct ib_event *, void *); | 727 | void (*event_handler)(struct ib_event *, void *); |
656 | void *qp_context; | 728 | void *qp_context; |
657 | u32 qp_num; | 729 | u32 qp_num; |
@@ -659,16 +731,18 @@ struct ib_qp { | |||
659 | }; | 731 | }; |
660 | 732 | ||
661 | struct ib_mr { | 733 | struct ib_mr { |
662 | struct ib_device *device; | 734 | struct ib_device *device; |
663 | struct ib_pd *pd; | 735 | struct ib_pd *pd; |
664 | u32 lkey; | 736 | struct ib_uobject *uobject; |
665 | u32 rkey; | 737 | u32 lkey; |
666 | atomic_t usecnt; /* count number of MWs */ | 738 | u32 rkey; |
739 | atomic_t usecnt; /* count number of MWs */ | ||
667 | }; | 740 | }; |
668 | 741 | ||
669 | struct ib_mw { | 742 | struct ib_mw { |
670 | struct ib_device *device; | 743 | struct ib_device *device; |
671 | struct ib_pd *pd; | 744 | struct ib_pd *pd; |
745 | struct ib_uobject *uobject; | ||
672 | u32 rkey; | 746 | u32 rkey; |
673 | }; | 747 | }; |
674 | 748 | ||
@@ -737,7 +811,14 @@ struct ib_device { | |||
737 | int (*modify_port)(struct ib_device *device, | 811 | int (*modify_port)(struct ib_device *device, |
738 | u8 port_num, int port_modify_mask, | 812 | u8 port_num, int port_modify_mask, |
739 | struct ib_port_modify *port_modify); | 813 | struct ib_port_modify *port_modify); |
740 | struct ib_pd * (*alloc_pd)(struct ib_device *device); | 814 | struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device, |
815 | struct ib_udata *udata); | ||
816 | int (*dealloc_ucontext)(struct ib_ucontext *context); | ||
817 | int (*mmap)(struct ib_ucontext *context, | ||
818 | struct vm_area_struct *vma); | ||
819 | struct ib_pd * (*alloc_pd)(struct ib_device *device, | ||
820 | struct ib_ucontext *context, | ||
821 | struct ib_udata *udata); | ||
741 | int (*dealloc_pd)(struct ib_pd *pd); | 822 | int (*dealloc_pd)(struct ib_pd *pd); |
742 | struct ib_ah * (*create_ah)(struct ib_pd *pd, | 823 | struct ib_ah * (*create_ah)(struct ib_pd *pd, |
743 | struct ib_ah_attr *ah_attr); | 824 | struct ib_ah_attr *ah_attr); |
@@ -747,7 +828,8 @@ struct ib_device { | |||
747 | struct ib_ah_attr *ah_attr); | 828 | struct ib_ah_attr *ah_attr); |
748 | int (*destroy_ah)(struct ib_ah *ah); | 829 | int (*destroy_ah)(struct ib_ah *ah); |
749 | struct ib_qp * (*create_qp)(struct ib_pd *pd, | 830 | struct ib_qp * (*create_qp)(struct ib_pd *pd, |
750 | struct ib_qp_init_attr *qp_init_attr); | 831 | struct ib_qp_init_attr *qp_init_attr, |
832 | struct ib_udata *udata); | ||
751 | int (*modify_qp)(struct ib_qp *qp, | 833 | int (*modify_qp)(struct ib_qp *qp, |
752 | struct ib_qp_attr *qp_attr, | 834 | struct ib_qp_attr *qp_attr, |
753 | int qp_attr_mask); | 835 | int qp_attr_mask); |
@@ -762,8 +844,9 @@ struct ib_device { | |||
762 | int (*post_recv)(struct ib_qp *qp, | 844 | int (*post_recv)(struct ib_qp *qp, |
763 | struct ib_recv_wr *recv_wr, | 845 | struct ib_recv_wr *recv_wr, |
764 | struct ib_recv_wr **bad_recv_wr); | 846 | struct ib_recv_wr **bad_recv_wr); |
765 | struct ib_cq * (*create_cq)(struct ib_device *device, | 847 | struct ib_cq * (*create_cq)(struct ib_device *device, int cqe, |
766 | int cqe); | 848 | struct ib_ucontext *context, |
849 | struct ib_udata *udata); | ||
767 | int (*destroy_cq)(struct ib_cq *cq); | 850 | int (*destroy_cq)(struct ib_cq *cq); |
768 | int (*resize_cq)(struct ib_cq *cq, int *cqe); | 851 | int (*resize_cq)(struct ib_cq *cq, int *cqe); |
769 | int (*poll_cq)(struct ib_cq *cq, int num_entries, | 852 | int (*poll_cq)(struct ib_cq *cq, int num_entries, |
@@ -780,6 +863,10 @@ struct ib_device { | |||
780 | int num_phys_buf, | 863 | int num_phys_buf, |
781 | int mr_access_flags, | 864 | int mr_access_flags, |
782 | u64 *iova_start); | 865 | u64 *iova_start); |
866 | struct ib_mr * (*reg_user_mr)(struct ib_pd *pd, | ||
867 | struct ib_umem *region, | ||
868 | int mr_access_flags, | ||
869 | struct ib_udata *udata); | ||
783 | int (*query_mr)(struct ib_mr *mr, | 870 | int (*query_mr)(struct ib_mr *mr, |
784 | struct ib_mr_attr *mr_attr); | 871 | struct ib_mr_attr *mr_attr); |
785 | int (*dereg_mr)(struct ib_mr *mr); | 872 | int (*dereg_mr)(struct ib_mr *mr); |
@@ -817,6 +904,7 @@ struct ib_device { | |||
817 | struct ib_mad *in_mad, | 904 | struct ib_mad *in_mad, |
818 | struct ib_mad *out_mad); | 905 | struct ib_mad *out_mad); |
819 | 906 | ||
907 | struct module *owner; | ||
820 | struct class_device class_dev; | 908 | struct class_device class_dev; |
821 | struct kobject ports_parent; | 909 | struct kobject ports_parent; |
822 | struct list_head port_list; | 910 | struct list_head port_list; |
@@ -852,6 +940,16 @@ void *ib_get_client_data(struct ib_device *device, struct ib_client *client); | |||
852 | void ib_set_client_data(struct ib_device *device, struct ib_client *client, | 940 | void ib_set_client_data(struct ib_device *device, struct ib_client *client, |
853 | void *data); | 941 | void *data); |
854 | 942 | ||
943 | static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len) | ||
944 | { | ||
945 | return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0; | ||
946 | } | ||
947 | |||
948 | static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) | ||
949 | { | ||
950 | return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; | ||
951 | } | ||
952 | |||
855 | int ib_register_event_handler (struct ib_event_handler *event_handler); | 953 | int ib_register_event_handler (struct ib_event_handler *event_handler); |
856 | int ib_unregister_event_handler(struct ib_event_handler *event_handler); | 954 | int ib_unregister_event_handler(struct ib_event_handler *event_handler); |
857 | void ib_dispatch_event(struct ib_event *event); | 955 | void ib_dispatch_event(struct ib_event *event); |
@@ -902,6 +1000,21 @@ int ib_dealloc_pd(struct ib_pd *pd); | |||
902 | struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); | 1000 | struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); |
903 | 1001 | ||
904 | /** | 1002 | /** |
1003 | * ib_create_ah_from_wc - Creates an address handle associated with the | ||
1004 | * sender of the specified work completion. | ||
1005 | * @pd: The protection domain associated with the address handle. | ||
1006 | * @wc: Work completion information associated with a received message. | ||
1007 | * @grh: References the received global route header. This parameter is | ||
1008 | * ignored unless the work completion indicates that the GRH is valid. | ||
1009 | * @port_num: The outbound port number to associate with the address. | ||
1010 | * | ||
1011 | * The address handle is used to reference a local or global destination | ||
1012 | * in all UD QP post sends. | ||
1013 | */ | ||
1014 | struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, | ||
1015 | struct ib_grh *grh, u8 port_num); | ||
1016 | |||
1017 | /** | ||
905 | * ib_modify_ah - Modifies the address vector associated with an address | 1018 | * ib_modify_ah - Modifies the address vector associated with an address |
906 | * handle. | 1019 | * handle. |
907 | * @ah: The address handle to modify. | 1020 | * @ah: The address handle to modify. |