Lines Matching +full:mailbox +full:-

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2015 - 2025 Beijing WangXun Technology Co., Ltd. */
9 * wx_obtain_mbx_lock_pf - obtain mailbox lock
13 * Return: return 0 on success and -EBUSY on failure
18 u32 mailbox; in wx_obtain_mbx_lock_pf() local
20 while (count--) { in wx_obtain_mbx_lock_pf()
24 /* reserve mailbox for vf use */ in wx_obtain_mbx_lock_pf()
25 mailbox = rd32(wx, WX_PXMAILBOX(vf)); in wx_obtain_mbx_lock_pf()
26 if (mailbox & WX_PXMAILBOX_PFU) in wx_obtain_mbx_lock_pf()
31 wx_err(wx, "Failed to obtain mailbox lock for PF%d", vf); in wx_obtain_mbx_lock_pf()
33 return -EBUSY; in wx_obtain_mbx_lock_pf()
41 return -EBUSY; in wx_check_for_bit_pf()
48 * wx_check_for_ack_pf - checks to see if the VF has acked
52 * Return: return 0 if the VF has set the status bit or else -EBUSY
65 * wx_check_for_msg_pf - checks to see if the VF has sent mail
69 * Return: return 0 if the VF has got req bit or else -EBUSY
82 * wx_write_mbx_pf - Places a message in the mailbox
88 * Return: return 0 on success and -EINVAL/-EBUSY on failure
92 struct wx_mbx_info *mbx = &wx->mbx; in wx_write_mbx_pf()
95 /* mbx->size is up to 15 */ in wx_write_mbx_pf()
96 if (size > mbx->size) { in wx_write_mbx_pf()
97 wx_err(wx, "Invalid mailbox message size %d", size); in wx_write_mbx_pf()
98 return -EINVAL; in wx_write_mbx_pf()
101 /* lock the mailbox to prevent pf/vf race condition */ in wx_write_mbx_pf()
110 /* copy the caller specified message to the mailbox memory buffer */ in wx_write_mbx_pf()
115 /* set mirrored mailbox flags */ in wx_write_mbx_pf()
123 * wx_read_mbx_pf - Read a message from the mailbox
129 * Return: return 0 on success and -EBUSY on failure
133 struct wx_mbx_info *mbx = &wx->mbx; in wx_read_mbx_pf()
137 /* limit read to size of mailbox and mbx->size is up to 15 */ in wx_read_mbx_pf()
138 if (size > mbx->size) in wx_read_mbx_pf()
139 size = mbx->size; in wx_read_mbx_pf()
141 /* lock the mailbox to prevent pf/vf race condition */ in wx_read_mbx_pf()
150 /* set mirrored mailbox flags */ in wx_read_mbx_pf()
158 * wx_check_for_rst_pf - checks to see if the VF has reset
162 * Return: return 0 on success and -EBUSY on failure
172 return -EBUSY; in wx_check_for_rst_pf()
180 u32 mailbox = rd32(wx, WX_VXMAILBOX); in wx_read_v2p_mailbox() local
182 mailbox |= wx->mbx.mailbox; in wx_read_v2p_mailbox()
183 wx->mbx.mailbox |= mailbox & WX_VXMAILBOX_R2C_BITS; in wx_read_v2p_mailbox()
185 return mailbox; in wx_read_v2p_mailbox()
195 * wx_obtain_mbx_lock_vf - obtain mailbox lock
198 * Return: return 0 on success and -EBUSY on failure
203 u32 mailbox; in wx_obtain_mbx_lock_vf() local
205 ret = readx_poll_timeout_atomic(wx_mailbox_get_lock_vf, wx, mailbox, in wx_obtain_mbx_lock_vf()
206 (mailbox & WX_VXMAILBOX_VFU), in wx_obtain_mbx_lock_vf()
209 wx_err(wx, "Failed to obtain mailbox lock for VF.\n"); in wx_obtain_mbx_lock_vf()
216 u32 mailbox = wx_read_v2p_mailbox(wx); in wx_check_for_bit_vf() local
218 wx->mbx.mailbox &= ~mask; in wx_check_for_bit_vf()
220 return (mailbox & mask ? 0 : -EBUSY); in wx_check_for_bit_vf()
224 * wx_check_for_ack_vf - checks to see if the PF has ACK'd
227 * Return: return 0 if the PF has set the status bit or else -EBUSY
236 * wx_check_for_msg_vf - checks to see if the PF has sent mail
239 * Return: return 0 if the PF has got req bit or else -EBUSY
248 * wx_check_for_rst_vf - checks to see if the PF has reset
251 * Return: return 0 if the PF has set the reset done and -EBUSY on failure
262 * wx_poll_for_msg - Wait for message notification
269 struct wx_mbx_info *mbx = &wx->mbx; in wx_poll_for_msg()
273 (val == 0), mbx->udelay, mbx->timeout); in wx_poll_for_msg()
277 * wx_poll_for_ack - Wait for message acknowledgment
284 struct wx_mbx_info *mbx = &wx->mbx; in wx_poll_for_ack()
288 (val == 0), mbx->udelay, mbx->timeout); in wx_poll_for_ack()
292 * wx_read_posted_mbx - Wait for message notification and receive message
313 * wx_write_posted_mbx - Write a message to the mailbox, wait for ack
335 * wx_write_mbx_vf - Write a message to the mailbox
344 struct wx_mbx_info *mbx = &wx->mbx; in wx_write_mbx_vf()
347 /* mbx->size is up to 15 */ in wx_write_mbx_vf()
348 if (size > mbx->size) { in wx_write_mbx_vf()
349 wx_err(wx, "Invalid mailbox message size %d", size); in wx_write_mbx_vf()
350 return -EINVAL; in wx_write_mbx_vf()
353 /* lock the mailbox to prevent pf/vf race condition */ in wx_write_mbx_vf()
362 /* copy the caller specified message to the mailbox memory buffer */ in wx_write_mbx_vf()
373 * wx_read_mbx_vf - Reads a message from the inbox intended for vf
382 struct wx_mbx_info *mbx = &wx->mbx; in wx_read_mbx_vf()
385 /* limit read to size of mailbox and mbx->size is up to 15 */ in wx_read_mbx_vf()
386 if (size > mbx->size) in wx_read_mbx_vf()
387 size = mbx->size; in wx_read_mbx_vf()
389 /* lock the mailbox to prevent pf/vf race condition */ in wx_read_mbx_vf()
394 /* copy the message from the mailbox memory buffer */ in wx_read_mbx_vf()
398 /* Acknowledge receipt and release mailbox, then we're done */ in wx_read_mbx_vf()
406 wx->vfinfo = kzalloc(sizeof(struct vf_data_storage), in wx_init_mbx_params_vf()
408 if (!wx->vfinfo) in wx_init_mbx_params_vf()
409 return -ENOMEM; in wx_init_mbx_params_vf()
411 /* Initialize mailbox parameters */ in wx_init_mbx_params_vf()
412 wx->mbx.size = WX_VXMAILBOX_SIZE; in wx_init_mbx_params_vf()
413 wx->mbx.mailbox = WX_VXMAILBOX; in wx_init_mbx_params_vf()
414 wx->mbx.udelay = 10; in wx_init_mbx_params_vf()
415 wx->mbx.timeout = 1000; in wx_init_mbx_params_vf()