]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/infiniband/hw/usnic/usnic_ib.h
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
[karo-tx-linux.git] / drivers / infiniband / hw / usnic / usnic_ib.h
1 /*
2  * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3  *
4  * This program is free software; you may redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15  * SOFTWARE.
16  *
17  */
18
19 #ifndef USNIC_IB_H_
20 #define USNIC_IB_H_
21
22 #include <linux/iommu.h>
23 #include <linux/netdevice.h>
24
25 #include <rdma/ib_verbs.h>
26
27
28 #include "usnic.h"
29 #include "usnic_abi.h"
30 #include "usnic_vnic.h"
31
32 #define USNIC_IB_PORT_CNT               1
33 #define USNIC_IB_NUM_COMP_VECTORS       1
34
35 extern unsigned int usnic_ib_share_vf;
36
37 struct usnic_ib_ucontext {
38         struct ib_ucontext              ibucontext;
39         /* Protected by usnic_ib_dev->usdev_lock */
40         struct list_head                qp_grp_list;
41         struct list_head                link;
42 };
43
44 struct usnic_ib_pd {
45         struct ib_pd                    ibpd;
46         struct usnic_uiom_pd            *umem_pd;
47 };
48
49 struct usnic_ib_mr {
50         struct ib_mr                    ibmr;
51         struct usnic_uiom_reg           *umem;
52 };
53
54 struct usnic_ib_dev {
55         struct ib_device                ib_dev;
56         struct pci_dev                  *pdev;
57         struct net_device               *netdev;
58         struct usnic_fwd_dev            *ufdev;
59         struct list_head                ib_dev_link;
60         struct list_head                vf_dev_list;
61         struct list_head                ctx_list;
62         struct mutex                    usdev_lock;
63
64         /* provisioning information */
65         struct kref                     vf_cnt;
66         unsigned int                    vf_res_cnt[USNIC_VNIC_RES_TYPE_MAX];
67
68         /* sysfs vars for QPN reporting */
69         struct kobject *qpn_kobj;
70 };
71
72 struct usnic_ib_vf {
73         struct usnic_ib_dev             *pf;
74         spinlock_t                      lock;
75         struct usnic_vnic               *vnic;
76         unsigned int                    qp_grp_ref_cnt;
77         struct usnic_ib_pd              *pd;
78         struct list_head                link;
79 };
80
81 static inline
82 struct usnic_ib_dev *to_usdev(struct ib_device *ibdev)
83 {
84         return container_of(ibdev, struct usnic_ib_dev, ib_dev);
85 }
86
87 static inline
88 struct usnic_ib_ucontext *to_ucontext(struct ib_ucontext *ibucontext)
89 {
90         return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
91 }
92
93 static inline
94 struct usnic_ib_pd *to_upd(struct ib_pd *ibpd)
95 {
96         return container_of(ibpd, struct usnic_ib_pd, ibpd);
97 }
98
99 static inline
100 struct usnic_ib_ucontext *to_uucontext(struct ib_ucontext *ibucontext)
101 {
102         return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
103 }
104
105 static inline
106 struct usnic_ib_mr *to_umr(struct ib_mr *ibmr)
107 {
108         return container_of(ibmr, struct usnic_ib_mr, ibmr);
109 }
110 void usnic_ib_log_vf(struct usnic_ib_vf *vf);
111
112 #define UPDATE_PTR_LEFT(N, P, L)                        \
113 do {                                                    \
114         L -= (N);                                       \
115         P += (N);                                       \
116 } while (0)
117
118 #endif /* USNIC_IB_H_ */