This source file includes following definitions.
- ixgbevf_poll_for_msg
- ixgbevf_poll_for_ack
- ixgbevf_read_posted_mbx
- ixgbevf_write_posted_mbx
- ixgbevf_read_v2p_mailbox
- ixgbevf_check_for_bit_vf
- ixgbevf_check_for_msg_vf
- ixgbevf_check_for_ack_vf
- ixgbevf_check_for_rst_vf
- ixgbevf_obtain_mbx_lock_vf
- ixgbevf_write_mbx_vf
- ixgbevf_read_mbx_vf
- ixgbevf_init_mbx_params_vf
1
2
3
4 #include "mbx.h"
5 #include "ixgbevf.h"
6
7
8
9
10
11
12
13 static s32 ixgbevf_poll_for_msg(struct ixgbe_hw *hw)
14 {
15 struct ixgbe_mbx_info *mbx = &hw->mbx;
16 int countdown = mbx->timeout;
17
18 while (countdown && mbx->ops.check_for_msg(hw)) {
19 countdown--;
20 udelay(mbx->udelay);
21 }
22
23
24 if (!countdown)
25 mbx->timeout = 0;
26
27 return countdown ? 0 : IXGBE_ERR_MBX;
28 }
29
30
31
32
33
34
35
36 static s32 ixgbevf_poll_for_ack(struct ixgbe_hw *hw)
37 {
38 struct ixgbe_mbx_info *mbx = &hw->mbx;
39 int countdown = mbx->timeout;
40
41 while (countdown && mbx->ops.check_for_ack(hw)) {
42 countdown--;
43 udelay(mbx->udelay);
44 }
45
46
47 if (!countdown)
48 mbx->timeout = 0;
49
50 return countdown ? 0 : IXGBE_ERR_MBX;
51 }
52
53
54
55
56
57
58
59
60
61
62 static s32 ixgbevf_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size)
63 {
64 struct ixgbe_mbx_info *mbx = &hw->mbx;
65 s32 ret_val = IXGBE_ERR_MBX;
66
67 if (!mbx->ops.read)
68 goto out;
69
70 ret_val = ixgbevf_poll_for_msg(hw);
71
72
73 if (!ret_val)
74 ret_val = mbx->ops.read(hw, msg, size);
75 out:
76 return ret_val;
77 }
78
79
80
81
82
83
84
85
86
87
88 static s32 ixgbevf_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size)
89 {
90 struct ixgbe_mbx_info *mbx = &hw->mbx;
91 s32 ret_val = IXGBE_ERR_MBX;
92
93
94 if (!mbx->ops.write || !mbx->timeout)
95 goto out;
96
97
98 ret_val = mbx->ops.write(hw, msg, size);
99
100
101 if (!ret_val)
102 ret_val = ixgbevf_poll_for_ack(hw);
103 out:
104 return ret_val;
105 }
106
107
108
109
110
111
112
113
114 static u32 ixgbevf_read_v2p_mailbox(struct ixgbe_hw *hw)
115 {
116 u32 v2p_mailbox = IXGBE_READ_REG(hw, IXGBE_VFMAILBOX);
117
118 v2p_mailbox |= hw->mbx.v2p_mailbox;
119 hw->mbx.v2p_mailbox |= v2p_mailbox & IXGBE_VFMAILBOX_R2C_BITS;
120
121 return v2p_mailbox;
122 }
123
124
125
126
127
128
129
130
131
132 static s32 ixgbevf_check_for_bit_vf(struct ixgbe_hw *hw, u32 mask)
133 {
134 u32 v2p_mailbox = ixgbevf_read_v2p_mailbox(hw);
135 s32 ret_val = IXGBE_ERR_MBX;
136
137 if (v2p_mailbox & mask)
138 ret_val = 0;
139
140 hw->mbx.v2p_mailbox &= ~mask;
141
142 return ret_val;
143 }
144
145
146
147
148
149
150
151 static s32 ixgbevf_check_for_msg_vf(struct ixgbe_hw *hw)
152 {
153 s32 ret_val = IXGBE_ERR_MBX;
154
155 if (!ixgbevf_check_for_bit_vf(hw, IXGBE_VFMAILBOX_PFSTS)) {
156 ret_val = 0;
157 hw->mbx.stats.reqs++;
158 }
159
160 return ret_val;
161 }
162
163
164
165
166
167
168
169 static s32 ixgbevf_check_for_ack_vf(struct ixgbe_hw *hw)
170 {
171 s32 ret_val = IXGBE_ERR_MBX;
172
173 if (!ixgbevf_check_for_bit_vf(hw, IXGBE_VFMAILBOX_PFACK)) {
174 ret_val = 0;
175 hw->mbx.stats.acks++;
176 }
177
178 return ret_val;
179 }
180
181
182
183
184
185
186
187 static s32 ixgbevf_check_for_rst_vf(struct ixgbe_hw *hw)
188 {
189 s32 ret_val = IXGBE_ERR_MBX;
190
191 if (!ixgbevf_check_for_bit_vf(hw, (IXGBE_VFMAILBOX_RSTD |
192 IXGBE_VFMAILBOX_RSTI))) {
193 ret_val = 0;
194 hw->mbx.stats.rsts++;
195 }
196
197 return ret_val;
198 }
199
200
201
202
203
204
205
206 static s32 ixgbevf_obtain_mbx_lock_vf(struct ixgbe_hw *hw)
207 {
208 s32 ret_val = IXGBE_ERR_MBX;
209
210
211 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_VFU);
212
213
214 if (ixgbevf_read_v2p_mailbox(hw) & IXGBE_VFMAILBOX_VFU)
215 ret_val = 0;
216
217 return ret_val;
218 }
219
220
221
222
223
224
225
226
227
228 static s32 ixgbevf_write_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size)
229 {
230 s32 ret_val;
231 u16 i;
232
233
234 ret_val = ixgbevf_obtain_mbx_lock_vf(hw);
235 if (ret_val)
236 goto out_no_write;
237
238
239 ixgbevf_check_for_msg_vf(hw);
240 ixgbevf_check_for_ack_vf(hw);
241
242
243 for (i = 0; i < size; i++)
244 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]);
245
246
247 hw->mbx.stats.msgs_tx++;
248
249
250 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_REQ);
251
252 out_no_write:
253 return ret_val;
254 }
255
256
257
258
259
260
261
262
263
264 static s32 ixgbevf_read_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size)
265 {
266 s32 ret_val = 0;
267 u16 i;
268
269
270 ret_val = ixgbevf_obtain_mbx_lock_vf(hw);
271 if (ret_val)
272 goto out_no_read;
273
274
275 for (i = 0; i < size; i++)
276 msg[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_VFMBMEM, i);
277
278
279 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_ACK);
280
281
282 hw->mbx.stats.msgs_rx++;
283
284 out_no_read:
285 return ret_val;
286 }
287
288
289
290
291
292
293
294 static s32 ixgbevf_init_mbx_params_vf(struct ixgbe_hw *hw)
295 {
296 struct ixgbe_mbx_info *mbx = &hw->mbx;
297
298
299
300
301 mbx->timeout = 0;
302 mbx->udelay = IXGBE_VF_MBX_INIT_DELAY;
303
304 mbx->size = IXGBE_VFMAILBOX_SIZE;
305
306 mbx->stats.msgs_tx = 0;
307 mbx->stats.msgs_rx = 0;
308 mbx->stats.reqs = 0;
309 mbx->stats.acks = 0;
310 mbx->stats.rsts = 0;
311
312 return 0;
313 }
314
315 const struct ixgbe_mbx_operations ixgbevf_mbx_ops = {
316 .init_params = ixgbevf_init_mbx_params_vf,
317 .read = ixgbevf_read_mbx_vf,
318 .write = ixgbevf_write_mbx_vf,
319 .read_posted = ixgbevf_read_posted_mbx,
320 .write_posted = ixgbevf_write_posted_mbx,
321 .check_for_msg = ixgbevf_check_for_msg_vf,
322 .check_for_ack = ixgbevf_check_for_ack_vf,
323 .check_for_rst = ixgbevf_check_for_rst_vf,
324 };
325
326
327
328
329
330
331
332
333 const struct ixgbe_mbx_operations ixgbevf_hv_mbx_ops = {
334 .init_params = ixgbevf_init_mbx_params_vf,
335 .check_for_rst = ixgbevf_check_for_rst_vf,
336 };