PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / infiniband / hw / usnic / usnic_ib.h
blobe5a9297dd1bd3eac9f2dda97f2954e002a31ca4f
1 /*
2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
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.
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.
19 #ifndef USNIC_IB_H_
20 #define USNIC_IB_H_
22 #include <linux/iommu.h>
23 #include <linux/netdevice.h>
25 #include <rdma/ib_verbs.h>
28 #include "usnic.h"
29 #include "usnic_abi.h"
30 #include "usnic_vnic.h"
32 #define USNIC_IB_PORT_CNT 1
33 #define USNIC_IB_NUM_COMP_VECTORS 1
35 extern unsigned int usnic_ib_share_vf;
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;
44 struct usnic_ib_pd {
45 struct ib_pd ibpd;
46 struct usnic_uiom_pd *umem_pd;
49 struct usnic_ib_mr {
50 struct ib_mr ibmr;
51 struct usnic_uiom_reg *umem;
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;
64 /* provisioning information */
65 struct kref vf_cnt;
66 unsigned int vf_res_cnt[USNIC_VNIC_RES_TYPE_MAX];
68 /* sysfs vars for QPN reporting */
69 struct kobject *qpn_kobj;
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;
81 static inline
82 struct usnic_ib_dev *to_usdev(struct ib_device *ibdev)
84 return container_of(ibdev, struct usnic_ib_dev, ib_dev);
87 static inline
88 struct usnic_ib_ucontext *to_ucontext(struct ib_ucontext *ibucontext)
90 return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
93 static inline
94 struct usnic_ib_pd *to_upd(struct ib_pd *ibpd)
96 return container_of(ibpd, struct usnic_ib_pd, ibpd);
99 static inline
100 struct usnic_ib_ucontext *to_uucontext(struct ib_ucontext *ibucontext)
102 return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
105 static inline
106 struct usnic_ib_mr *to_umr(struct ib_mr *ibmr)
108 return container_of(ibmr, struct usnic_ib_mr, ibmr);
110 void usnic_ib_log_vf(struct usnic_ib_vf *vf);
112 #define UPDATE_PTR_LEFT(N, P, L) \
113 do { \
114 L -= (N); \
115 P += (N); \
116 } while (0)
118 #endif /* USNIC_IB_H_ */