Lines Matching +full:mailbox +full:-
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2018 Intel Corporation. */
7 * igb_read_mbx - Reads a message from the mailbox
11 * @mbx_id: id of mailbox to read
19 struct e1000_mbx_info *mbx = &hw->mbx; in igb_read_mbx()
20 s32 ret_val = -E1000_ERR_MBX; in igb_read_mbx()
22 /* limit read to size of mailbox */ in igb_read_mbx()
23 if (size > mbx->size) in igb_read_mbx()
24 size = mbx->size; in igb_read_mbx()
26 if (mbx->ops.read) in igb_read_mbx()
27 ret_val = mbx->ops.read(hw, msg, size, mbx_id, unlock); in igb_read_mbx()
33 * igb_write_mbx - Write a message to the mailbox
37 * @mbx_id: id of mailbox to write
43 struct e1000_mbx_info *mbx = &hw->mbx; in igb_write_mbx()
46 if (size > mbx->size) in igb_write_mbx()
47 ret_val = -E1000_ERR_MBX; in igb_write_mbx()
49 else if (mbx->ops.write) in igb_write_mbx()
50 ret_val = mbx->ops.write(hw, msg, size, mbx_id); in igb_write_mbx()
56 * igb_check_for_msg - checks to see if someone sent us mail
58 * @mbx_id: id of mailbox to check
64 struct e1000_mbx_info *mbx = &hw->mbx; in igb_check_for_msg()
65 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_msg()
67 if (mbx->ops.check_for_msg) in igb_check_for_msg()
68 ret_val = mbx->ops.check_for_msg(hw, mbx_id); in igb_check_for_msg()
74 * igb_check_for_ack - checks to see if someone sent us ACK
76 * @mbx_id: id of mailbox to check
82 struct e1000_mbx_info *mbx = &hw->mbx; in igb_check_for_ack()
83 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_ack()
85 if (mbx->ops.check_for_ack) in igb_check_for_ack()
86 ret_val = mbx->ops.check_for_ack(hw, mbx_id); in igb_check_for_ack()
92 * igb_check_for_rst - checks to see if other side has reset
94 * @mbx_id: id of mailbox to check
100 struct e1000_mbx_info *mbx = &hw->mbx; in igb_check_for_rst()
101 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_rst()
103 if (mbx->ops.check_for_rst) in igb_check_for_rst()
104 ret_val = mbx->ops.check_for_rst(hw, mbx_id); in igb_check_for_rst()
110 * igb_unlock_mbx - unlock the mailbox
112 * @mbx_id: id of mailbox to check
114 * returns SUCCESS if the mailbox was unlocked or else ERR_MBX
118 struct e1000_mbx_info *mbx = &hw->mbx; in igb_unlock_mbx()
119 s32 ret_val = -E1000_ERR_MBX; in igb_unlock_mbx()
121 if (mbx->ops.unlock) in igb_unlock_mbx()
122 ret_val = mbx->ops.unlock(hw, mbx_id); in igb_unlock_mbx()
128 * igb_poll_for_msg - Wait for message notification
130 * @mbx_id: id of mailbox to write
136 struct e1000_mbx_info *mbx = &hw->mbx; in igb_poll_for_msg()
137 int countdown = mbx->timeout; in igb_poll_for_msg()
139 if (!countdown || !mbx->ops.check_for_msg) in igb_poll_for_msg()
142 while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) { in igb_poll_for_msg()
143 countdown--; in igb_poll_for_msg()
146 udelay(mbx->usec_delay); in igb_poll_for_msg()
151 mbx->timeout = 0; in igb_poll_for_msg()
153 return countdown ? 0 : -E1000_ERR_MBX; in igb_poll_for_msg()
157 * igb_poll_for_ack - Wait for message acknowledgement
159 * @mbx_id: id of mailbox to write
165 struct e1000_mbx_info *mbx = &hw->mbx; in igb_poll_for_ack()
166 int countdown = mbx->timeout; in igb_poll_for_ack()
168 if (!countdown || !mbx->ops.check_for_ack) in igb_poll_for_ack()
171 while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) { in igb_poll_for_ack()
172 countdown--; in igb_poll_for_ack()
175 udelay(mbx->usec_delay); in igb_poll_for_ack()
180 mbx->timeout = 0; in igb_poll_for_ack()
182 return countdown ? 0 : -E1000_ERR_MBX; in igb_poll_for_ack()
186 * igb_read_posted_mbx - Wait for message notification and receive message
190 * @mbx_id: id of mailbox to write
198 struct e1000_mbx_info *mbx = &hw->mbx; in igb_read_posted_mbx()
199 s32 ret_val = -E1000_ERR_MBX; in igb_read_posted_mbx()
201 if (!mbx->ops.read) in igb_read_posted_mbx()
207 ret_val = mbx->ops.read(hw, msg, size, mbx_id, true); in igb_read_posted_mbx()
213 * igb_write_posted_mbx - Write a message to the mailbox, wait for ack
217 * @mbx_id: id of mailbox to write
225 struct e1000_mbx_info *mbx = &hw->mbx; in igb_write_posted_mbx()
226 s32 ret_val = -E1000_ERR_MBX; in igb_write_posted_mbx()
229 if (!mbx->ops.write || !mbx->timeout) in igb_write_posted_mbx()
233 ret_val = mbx->ops.write(hw, msg, size, mbx_id); in igb_write_posted_mbx()
245 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_bit_pf()
256 * igb_check_for_msg_pf - checks to see if the VF has sent mail
264 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_msg_pf()
268 hw->mbx.stats.reqs++; in igb_check_for_msg_pf()
275 * igb_check_for_ack_pf - checks to see if the VF has ACKed
283 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_ack_pf()
287 hw->mbx.stats.acks++; in igb_check_for_ack_pf()
294 * igb_check_for_rst_pf - checks to see if the VF has reset
303 s32 ret_val = -E1000_ERR_MBX; in igb_check_for_rst_pf()
308 hw->mbx.stats.rsts++; in igb_check_for_rst_pf()
315 * igb_obtain_mbx_lock_pf - obtain mailbox lock
319 * return SUCCESS if we obtained the mailbox lock
323 s32 ret_val = -E1000_ERR_MBX; in igb_obtain_mbx_lock_pf()
331 /* reserve mailbox for vf use */ in igb_obtain_mbx_lock_pf()
338 } while (count-- > 0); in igb_obtain_mbx_lock_pf()
344 * igb_release_mbx_lock_pf - release mailbox lock
348 * return SUCCESS if we released the mailbox lock
354 /* drop PF lock of mailbox, if set */ in igb_release_mbx_lock_pf()
364 * igb_write_mbx_pf - Places a message in the mailbox
378 /* lock the mailbox to prevent pf/vf race condition */ in igb_write_mbx_pf()
387 /* copy the caller specified message to the mailbox memory buffer */ in igb_write_mbx_pf()
395 hw->mbx.stats.msgs_tx++; in igb_write_mbx_pf()
403 * igb_read_mbx_pf - Read a message from the mailbox
408 * @unlock: unlock the mailbox when done?
410 * This function copies a message from the mailbox buffer to the caller's
420 /* lock the mailbox to prevent pf/vf race condition */ in igb_read_mbx_pf()
425 /* copy the message to the mailbox memory buffer */ in igb_read_mbx_pf()
429 /* Acknowledge the message and release mailbox lock (or not) */ in igb_read_mbx_pf()
437 hw->mbx.stats.msgs_rx++; in igb_read_mbx_pf()
444 * igb_init_mbx_params_pf - set initial values for pf mailbox
447 * Initializes the hw->mbx struct to correct values for pf mailbox
451 struct e1000_mbx_info *mbx = &hw->mbx; in igb_init_mbx_params_pf()
453 mbx->timeout = 0; in igb_init_mbx_params_pf()
454 mbx->usec_delay = 0; in igb_init_mbx_params_pf()
456 mbx->size = E1000_VFMAILBOX_SIZE; in igb_init_mbx_params_pf()
458 mbx->ops.read = igb_read_mbx_pf; in igb_init_mbx_params_pf()
459 mbx->ops.write = igb_write_mbx_pf; in igb_init_mbx_params_pf()
460 mbx->ops.read_posted = igb_read_posted_mbx; in igb_init_mbx_params_pf()
461 mbx->ops.write_posted = igb_write_posted_mbx; in igb_init_mbx_params_pf()
462 mbx->ops.check_for_msg = igb_check_for_msg_pf; in igb_init_mbx_params_pf()
463 mbx->ops.check_for_ack = igb_check_for_ack_pf; in igb_init_mbx_params_pf()
464 mbx->ops.check_for_rst = igb_check_for_rst_pf; in igb_init_mbx_params_pf()
465 mbx->ops.unlock = igb_release_mbx_lock_pf; in igb_init_mbx_params_pf()
467 mbx->stats.msgs_tx = 0; in igb_init_mbx_params_pf()
468 mbx->stats.msgs_rx = 0; in igb_init_mbx_params_pf()
469 mbx->stats.reqs = 0; in igb_init_mbx_params_pf()
470 mbx->stats.acks = 0; in igb_init_mbx_params_pf()
471 mbx->stats.rsts = 0; in igb_init_mbx_params_pf()