1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef USNIC_VNIC_H_
35 #define USNIC_VNIC_H_
36
37 #include <linux/pci.h>
38
39 #include "vnic_dev.h"
40
41
42 #define USNIC_VNIC_RES_TYPES \
43 DEFINE_USNIC_VNIC_RES_AT(EOL, RES_TYPE_EOL, "EOL", 0) \
44 DEFINE_USNIC_VNIC_RES(WQ, RES_TYPE_WQ, "WQ") \
45 DEFINE_USNIC_VNIC_RES(RQ, RES_TYPE_RQ, "RQ") \
46 DEFINE_USNIC_VNIC_RES(CQ, RES_TYPE_CQ, "CQ") \
47 DEFINE_USNIC_VNIC_RES(INTR, RES_TYPE_INTR_CTRL, "INT") \
48 DEFINE_USNIC_VNIC_RES(MAX, RES_TYPE_MAX, "MAX")\
49
50 #define DEFINE_USNIC_VNIC_RES_AT(usnic_vnic_res_t, vnic_res_type, desc, val) \
51 USNIC_VNIC_RES_TYPE_##usnic_vnic_res_t = val,
52 #define DEFINE_USNIC_VNIC_RES(usnic_vnic_res_t, vnic_res_type, desc) \
53 USNIC_VNIC_RES_TYPE_##usnic_vnic_res_t,
54 enum usnic_vnic_res_type {
55 USNIC_VNIC_RES_TYPES
56 };
57 #undef DEFINE_USNIC_VNIC_RES
58 #undef DEFINE_USNIC_VNIC_RES_AT
59
60 struct usnic_vnic_res {
61 enum usnic_vnic_res_type type;
62 unsigned int vnic_idx;
63 struct usnic_vnic *vnic;
64 void __iomem *ctrl;
65 void *owner;
66 };
67
68 struct usnic_vnic_res_chunk {
69 enum usnic_vnic_res_type type;
70 int cnt;
71 int free_cnt;
72 struct usnic_vnic_res **res;
73 struct usnic_vnic *vnic;
74 };
75
76 struct usnic_vnic_res_desc {
77 enum usnic_vnic_res_type type;
78 uint16_t cnt;
79 };
80
81 struct usnic_vnic_res_spec {
82 struct usnic_vnic_res_desc resources[USNIC_VNIC_RES_TYPE_MAX];
83 };
84
85 const char *usnic_vnic_res_type_to_str(enum usnic_vnic_res_type res_type);
86 const char *usnic_vnic_pci_name(struct usnic_vnic *vnic);
87 int usnic_vnic_dump(struct usnic_vnic *vnic, char *buf, int buf_sz,
88 void *hdr_obj,
89 int (*printtitle)(void *, char*, int),
90 int (*printcols)(char *, int),
91 int (*printrow)(void *, char *, int));
92 void usnic_vnic_res_spec_update(struct usnic_vnic_res_spec *spec,
93 enum usnic_vnic_res_type trgt_type,
94 u16 cnt);
95 int usnic_vnic_res_spec_satisfied(const struct usnic_vnic_res_spec *min_spec,
96 struct usnic_vnic_res_spec *res_spec);
97 int usnic_vnic_spec_dump(char *buf, int buf_sz,
98 struct usnic_vnic_res_spec *res_spec);
99 int usnic_vnic_check_room(struct usnic_vnic *vnic,
100 struct usnic_vnic_res_spec *res_spec);
101 int usnic_vnic_res_cnt(struct usnic_vnic *vnic,
102 enum usnic_vnic_res_type type);
103 int usnic_vnic_res_free_cnt(struct usnic_vnic *vnic,
104 enum usnic_vnic_res_type type);
105 struct usnic_vnic_res_chunk *
106 usnic_vnic_get_resources(struct usnic_vnic *vnic,
107 enum usnic_vnic_res_type type,
108 int cnt,
109 void *owner);
110 void usnic_vnic_put_resources(struct usnic_vnic_res_chunk *chunk);
111 struct pci_dev *usnic_vnic_get_pdev(struct usnic_vnic *vnic);
112 struct vnic_dev_bar *usnic_vnic_get_bar(struct usnic_vnic *vnic,
113 int bar_num);
114 struct usnic_vnic *usnic_vnic_alloc(struct pci_dev *pdev);
115 void usnic_vnic_free(struct usnic_vnic *vnic);
116 u16 usnic_vnic_get_index(struct usnic_vnic *vnic);
117
118 #endif