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
22 #include <linux/iommu.h>
23 #include <linux/netdevice.h>
24 #include <linux/version.h>
26 #include <rdma/ib_verbs.h>
30 #include "usnic_abi.h"
31 #include "usnic_vnic.h"
33 #define USNIC_IB_PORT_CNT 1
34 #define USNIC_IB_NUM_COMP_VECTORS 1
36 extern unsigned int usnic_ib_share_vf;
38 struct usnic_ib_ucontext {
39 struct ib_ucontext ibucontext;
40 /* Protected by usnic_ib_dev->usdev_lock */
41 struct list_head qp_grp_list;
42 struct list_head link;
47 struct usnic_uiom_pd *umem_pd;
52 struct usnic_uiom_reg *umem;
56 struct ib_device ib_dev;
58 struct net_device *netdev;
59 struct usnic_fwd_dev *ufdev;
60 struct list_head ib_dev_link;
61 struct list_head vf_dev_list;
62 struct list_head ctx_list;
63 struct mutex usdev_lock;
65 /* provisioning information */
67 unsigned int vf_res_cnt[USNIC_VNIC_RES_TYPE_MAX];
69 /* sysfs vars for QPN reporting */
70 struct kobject *qpn_kobj;
74 struct usnic_ib_dev *pf;
76 struct usnic_vnic *vnic;
77 unsigned int qp_grp_ref_cnt;
78 struct usnic_ib_pd *pd;
79 struct list_head link;
83 struct usnic_ib_dev *to_usdev(struct ib_device *ibdev)
85 return container_of(ibdev, struct usnic_ib_dev, ib_dev);
89 struct usnic_ib_ucontext *to_ucontext(struct ib_ucontext *ibucontext)
91 return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
95 struct usnic_ib_pd *to_upd(struct ib_pd *ibpd)
97 return container_of(ibpd, struct usnic_ib_pd, ibpd);
101 struct usnic_ib_ucontext *to_uucontext(struct ib_ucontext *ibucontext)
103 return container_of(ibucontext, struct usnic_ib_ucontext, ibucontext);
107 struct usnic_ib_mr *to_umr(struct ib_mr *ibmr)
109 return container_of(ibmr, struct usnic_ib_mr, ibmr);
111 void usnic_ib_log_vf(struct usnic_ib_vf *vf);
113 #define UPDATE_PTR_LEFT(N, P, L) \
119 #endif /* USNIC_IB_H_ */