Lines Matching +full:mailbox +full:-

2   SPDX-License-Identifier: BSD-3-Clause
4 Copyright (c) 2001-2020, Intel Corporation
42 * ixgbe_read_mbx - Reads a message from the mailbox
46 * @mbx_id: id of mailbox to read
52 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_read_mbx()
56 /* limit read to size of mailbox */ in ixgbe_read_mbx()
57 if (size > mbx->size) { in ixgbe_read_mbx()
59 "Invalid mailbox message size %u, changing to %u", in ixgbe_read_mbx()
60 size, mbx->size); in ixgbe_read_mbx()
61 size = mbx->size; in ixgbe_read_mbx()
64 if (mbx->ops[mbx_id].read) in ixgbe_read_mbx()
65 return mbx->ops[mbx_id].read(hw, msg, size, mbx_id); in ixgbe_read_mbx()
71 * ixgbe_poll_mbx - Wait for message and read it from the mailbox
75 * @mbx_id: id of mailbox to read
81 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_poll_mbx()
86 if (!mbx->ops[mbx_id].read || !mbx->ops[mbx_id].check_for_msg || in ixgbe_poll_mbx()
87 !mbx->timeout) in ixgbe_poll_mbx()
90 /* limit read to size of mailbox */ in ixgbe_poll_mbx()
91 if (size > mbx->size) { in ixgbe_poll_mbx()
93 "Invalid mailbox message size %u, changing to %u", in ixgbe_poll_mbx()
94 size, mbx->size); in ixgbe_poll_mbx()
95 size = mbx->size; in ixgbe_poll_mbx()
101 return mbx->ops[mbx_id].read(hw, msg, size, mbx_id); in ixgbe_poll_mbx()
107 * ixgbe_write_mbx - Write a message to the mailbox and wait for ACK
111 * @mbx_id: id of mailbox to write
121 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_write_mbx()
130 if (!mbx->ops[mbx_id].write || !mbx->ops[mbx_id].check_for_ack || in ixgbe_write_mbx()
131 !mbx->ops[mbx_id].release || !mbx->timeout) in ixgbe_write_mbx()
134 if (size > mbx->size) { in ixgbe_write_mbx()
137 "Invalid mailbox message size %u", size); in ixgbe_write_mbx()
139 ret_val = mbx->ops[mbx_id].write(hw, msg, size, mbx_id); in ixgbe_write_mbx()
146 * ixgbe_check_for_msg - checks to see if someone sent us mail
148 * @mbx_id: id of mailbox to check
154 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_check_for_msg()
159 if (mbx->ops[mbx_id].check_for_msg) in ixgbe_check_for_msg()
160 ret_val = mbx->ops[mbx_id].check_for_msg(hw, mbx_id); in ixgbe_check_for_msg()
166 * ixgbe_check_for_ack - checks to see if someone sent us ACK
168 * @mbx_id: id of mailbox to check
174 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_check_for_ack()
179 if (mbx->ops[mbx_id].check_for_ack) in ixgbe_check_for_ack()
180 ret_val = mbx->ops[mbx_id].check_for_ack(hw, mbx_id); in ixgbe_check_for_ack()
186 * ixgbe_check_for_rst - checks to see if other side has reset
188 * @mbx_id: id of mailbox to check
194 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_check_for_rst()
199 if (mbx->ops[mbx_id].check_for_rst) in ixgbe_check_for_rst()
200 ret_val = mbx->ops[mbx_id].check_for_rst(hw, mbx_id); in ixgbe_check_for_rst()
206 * ixgbe_clear_mbx - Clear Mailbox Memory
208 * @mbx_id: id of mailbox to write
214 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_clear_mbx()
219 if (mbx->ops[mbx_id].clear) in ixgbe_clear_mbx()
220 ret_val = mbx->ops[mbx_id].clear(hw, mbx_id); in ixgbe_clear_mbx()
226 * ixgbe_poll_for_msg - Wait for message notification
228 * @mbx_id: id of mailbox to write
234 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_poll_for_msg()
235 int countdown = mbx->timeout; in ixgbe_poll_for_msg()
239 if (!countdown || !mbx->ops[mbx_id].check_for_msg) in ixgbe_poll_for_msg()
242 while (countdown && mbx->ops[mbx_id].check_for_msg(hw, mbx_id)) { in ixgbe_poll_for_msg()
243 countdown--; in ixgbe_poll_for_msg()
246 usec_delay(mbx->usec_delay); in ixgbe_poll_for_msg()
251 "Polling for VF%u mailbox message timedout", mbx_id); in ixgbe_poll_for_msg()
259 * ixgbe_poll_for_ack - Wait for message acknowledgment
261 * @mbx_id: id of mailbox to write
267 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_poll_for_ack()
268 int countdown = mbx->timeout; in ixgbe_poll_for_ack()
272 if (!countdown || !mbx->ops[mbx_id].check_for_ack) in ixgbe_poll_for_ack()
275 while (countdown && mbx->ops[mbx_id].check_for_ack(hw, mbx_id)) { in ixgbe_poll_for_ack()
276 countdown--; in ixgbe_poll_for_ack()
279 usec_delay(mbx->usec_delay); in ixgbe_poll_for_ack()
284 "Polling for VF%u mailbox ack timedout", mbx_id); in ixgbe_poll_for_ack()
292 * ixgbe_read_mailbox_vf - read VF's mailbox register
295 * This function is used to read the mailbox register dedicated for VF without
302 vf_mailbox |= hw->mbx.vf_mailbox; in ixgbe_read_mailbox_vf()
303 hw->mbx.vf_mailbox |= vf_mailbox & IXGBE_VFMAILBOX_R2C_BITS; in ixgbe_read_mailbox_vf()
313 hw->mbx.stats.reqs++; in ixgbe_clear_msg_vf()
314 hw->mbx.vf_mailbox &= ~IXGBE_VFMAILBOX_PFSTS; in ixgbe_clear_msg_vf()
323 hw->mbx.stats.acks++; in ixgbe_clear_ack_vf()
324 hw->mbx.vf_mailbox &= ~IXGBE_VFMAILBOX_PFACK; in ixgbe_clear_ack_vf()
333 hw->mbx.stats.rsts++; in ixgbe_clear_rst_vf()
334 hw->mbx.vf_mailbox &= ~(IXGBE_VFMAILBOX_RSTI | in ixgbe_clear_rst_vf()
340 * ixgbe_check_for_bit_vf - Determine if a status bit was set
345 * the V2P mailbox.
358 * ixgbe_check_for_msg_vf - checks to see if the PF has sent mail
360 * @mbx_id: id of mailbox to check
376 * ixgbe_check_for_ack_vf - checks to see if the PF has ACK'd
378 * @mbx_id: id of mailbox to check
397 * ixgbe_check_for_rst_vf - checks to see if the PF has reset
399 * @mbx_id: id of mailbox to check
419 * ixgbe_obtain_mbx_lock_vf - obtain mailbox lock
422 * return SUCCESS if we obtained the mailbox lock
426 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_obtain_mbx_lock_vf()
427 int countdown = mbx->timeout; in ixgbe_obtain_mbx_lock_vf()
433 if (!mbx->timeout) in ixgbe_obtain_mbx_lock_vf()
436 while (countdown--) { in ixgbe_obtain_mbx_lock_vf()
437 /* Reserve mailbox for VF use */ in ixgbe_obtain_mbx_lock_vf()
449 usec_delay(mbx->usec_delay); in ixgbe_obtain_mbx_lock_vf()
454 "Failed to obtain mailbox lock"); in ixgbe_obtain_mbx_lock_vf()
462 * ixgbe_release_mbx_lock_dummy - release mailbox lock
464 * @mbx_id: id of mailbox to read
474 * ixgbe_release_mbx_lock_vf - release mailbox lock
476 * @mbx_id: id of mailbox to read
493 * ixgbe_write_mbx_vf_legacy - Write a message to the mailbox
497 * @mbx_id: id of mailbox to write
510 /* lock the mailbox to prevent pf/vf race condition */ in ixgbe_write_mbx_vf_legacy()
521 /* copy the caller specified message to the mailbox memory buffer */ in ixgbe_write_mbx_vf_legacy()
526 hw->mbx.stats.msgs_tx++; in ixgbe_write_mbx_vf_legacy()
535 * ixgbe_write_mbx_vf - Write a message to the mailbox
539 * @mbx_id: id of mailbox to write
554 /* lock the mailbox to prevent pf/vf race condition */ in ixgbe_write_mbx_vf()
563 /* copy the caller specified message to the mailbox memory buffer */ in ixgbe_write_mbx_vf()
568 hw->mbx.stats.msgs_tx++; in ixgbe_write_mbx_vf()
579 hw->mbx.ops[mbx_id].release(hw, mbx_id); in ixgbe_write_mbx_vf()
585 * ixgbe_read_mbx_vf_legacy - Reads a message from the inbox intended for vf
589 * @mbx_id: id of mailbox to read
602 /* lock the mailbox to prevent pf/vf race condition */ in ixgbe_read_mbx_vf_legacy()
607 /* copy the message from the mailbox memory buffer */ in ixgbe_read_mbx_vf_legacy()
611 /* Acknowledge receipt and release mailbox, then we're done */ in ixgbe_read_mbx_vf_legacy()
615 hw->mbx.stats.msgs_rx++; in ixgbe_read_mbx_vf_legacy()
621 * ixgbe_read_mbx_vf - Reads a message from the inbox intended for vf
625 * @mbx_id: id of mailbox to read
646 /* copy the message from the mailbox memory buffer */ in ixgbe_read_mbx_vf()
656 hw->mbx.stats.msgs_rx++; in ixgbe_read_mbx_vf()
662 * ixgbe_init_mbx_params_vf - set initial values for vf mailbox
665 * Initializes single set the hw->mbx struct to correct values for vf mailbox
670 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_init_mbx_params_vf()
672 mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT; in ixgbe_init_mbx_params_vf()
673 mbx->usec_delay = IXGBE_VF_MBX_INIT_DELAY; in ixgbe_init_mbx_params_vf()
675 mbx->size = IXGBE_VFMAILBOX_SIZE; in ixgbe_init_mbx_params_vf()
677 /* VF has only one mailbox connection, no need for more IDs */ in ixgbe_init_mbx_params_vf()
678 mbx->ops[0].release = ixgbe_release_mbx_lock_dummy; in ixgbe_init_mbx_params_vf()
679 mbx->ops[0].read = ixgbe_read_mbx_vf_legacy; in ixgbe_init_mbx_params_vf()
680 mbx->ops[0].write = ixgbe_write_mbx_vf_legacy; in ixgbe_init_mbx_params_vf()
681 mbx->ops[0].check_for_msg = ixgbe_check_for_msg_vf; in ixgbe_init_mbx_params_vf()
682 mbx->ops[0].check_for_ack = ixgbe_check_for_ack_vf; in ixgbe_init_mbx_params_vf()
683 mbx->ops[0].check_for_rst = ixgbe_check_for_rst_vf; in ixgbe_init_mbx_params_vf()
684 mbx->ops[0].clear = NULL; in ixgbe_init_mbx_params_vf()
686 mbx->stats.msgs_tx = 0; in ixgbe_init_mbx_params_vf()
687 mbx->stats.msgs_rx = 0; in ixgbe_init_mbx_params_vf()
688 mbx->stats.reqs = 0; in ixgbe_init_mbx_params_vf()
689 mbx->stats.acks = 0; in ixgbe_init_mbx_params_vf()
690 mbx->stats.rsts = 0; in ixgbe_init_mbx_params_vf()
694 * ixgbe_upgrade_mbx_params_vf - set initial values for vf mailbox
697 * Initializes the hw->mbx struct to correct values for vf mailbox
701 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_upgrade_mbx_params_vf()
703 mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT; in ixgbe_upgrade_mbx_params_vf()
704 mbx->usec_delay = IXGBE_VF_MBX_INIT_DELAY; in ixgbe_upgrade_mbx_params_vf()
706 mbx->size = IXGBE_VFMAILBOX_SIZE; in ixgbe_upgrade_mbx_params_vf()
708 /* VF has only one mailbox connection, no need for more IDs */ in ixgbe_upgrade_mbx_params_vf()
709 mbx->ops[0].release = ixgbe_release_mbx_lock_vf; in ixgbe_upgrade_mbx_params_vf()
710 mbx->ops[0].read = ixgbe_read_mbx_vf; in ixgbe_upgrade_mbx_params_vf()
711 mbx->ops[0].write = ixgbe_write_mbx_vf; in ixgbe_upgrade_mbx_params_vf()
712 mbx->ops[0].check_for_msg = ixgbe_check_for_msg_vf; in ixgbe_upgrade_mbx_params_vf()
713 mbx->ops[0].check_for_ack = ixgbe_check_for_ack_vf; in ixgbe_upgrade_mbx_params_vf()
714 mbx->ops[0].check_for_rst = ixgbe_check_for_rst_vf; in ixgbe_upgrade_mbx_params_vf()
715 mbx->ops[0].clear = NULL; in ixgbe_upgrade_mbx_params_vf()
717 mbx->stats.msgs_tx = 0; in ixgbe_upgrade_mbx_params_vf()
718 mbx->stats.msgs_rx = 0; in ixgbe_upgrade_mbx_params_vf()
719 mbx->stats.reqs = 0; in ixgbe_upgrade_mbx_params_vf()
720 mbx->stats.acks = 0; in ixgbe_upgrade_mbx_params_vf()
721 mbx->stats.rsts = 0; in ixgbe_upgrade_mbx_params_vf()
733 hw->mbx.stats.reqs++; in ixgbe_clear_msg_pf()
748 hw->mbx.stats.acks++; in ixgbe_clear_ack_pf()
766 * ixgbe_check_for_msg_pf - checks to see if the VF has sent mail
787 * ixgbe_check_for_ack_pf - checks to see if the VF has ACKed
812 * ixgbe_check_for_rst_pf - checks to see if the VF has reset
827 switch (hw->mac.type) { in ixgbe_check_for_rst_pf()
844 hw->mbx.stats.rsts++; in ixgbe_check_for_rst_pf()
851 * ixgbe_obtain_mbx_lock_pf - obtain mailbox lock
855 * return SUCCESS if we obtained the mailbox lock
859 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_obtain_mbx_lock_pf()
860 int countdown = mbx->timeout; in ixgbe_obtain_mbx_lock_pf()
866 if (!mbx->timeout) in ixgbe_obtain_mbx_lock_pf()
869 while (countdown--) { in ixgbe_obtain_mbx_lock_pf()
870 /* Reserve mailbox for PF use */ in ixgbe_obtain_mbx_lock_pf()
889 usec_delay(mbx->usec_delay); in ixgbe_obtain_mbx_lock_pf()
894 "Failed to obtain mailbox lock"); in ixgbe_obtain_mbx_lock_pf()
902 * ixgbe_release_mbx_lock_pf - release mailbox lock
919 * ixgbe_write_mbx_pf_legacy - Places a message in the mailbox
935 /* lock the mailbox to prevent pf/vf race condition */ in ixgbe_write_mbx_pf_legacy()
946 /* copy the caller specified message to the mailbox memory buffer */ in ixgbe_write_mbx_pf_legacy()
954 hw->mbx.stats.msgs_tx++; in ixgbe_write_mbx_pf_legacy()
960 * ixgbe_write_mbx_pf - Places a message in the mailbox
977 /* lock the mailbox to prevent pf/vf race condition */ in ixgbe_write_mbx_pf()
986 /* copy the caller specified message to the mailbox memory buffer */ in ixgbe_write_mbx_pf()
1000 hw->mbx.stats.msgs_tx++; in ixgbe_write_mbx_pf()
1003 hw->mbx.ops[vf_id].release(hw, vf_id); in ixgbe_write_mbx_pf()
1010 * ixgbe_read_mbx_pf_legacy - Read a message from the mailbox
1016 * This function copies a message from the mailbox buffer to the caller's
1028 /* lock the mailbox to prevent pf/vf race condition */ in ixgbe_read_mbx_pf_legacy()
1033 /* copy the message to the mailbox memory buffer */ in ixgbe_read_mbx_pf_legacy()
1041 hw->mbx.stats.msgs_rx++; in ixgbe_read_mbx_pf_legacy()
1047 * ixgbe_read_mbx_pf - Read a message from the mailbox
1053 * This function copies a message from the mailbox buffer to the caller's
1073 /* copy the message to the mailbox memory buffer */ in ixgbe_read_mbx_pf()
1083 hw->mbx.stats.msgs_rx++; in ixgbe_read_mbx_pf()
1089 * ixgbe_clear_mbx_pf - Clear Mailbox Memory
1097 u16 mbx_size = hw->mbx.size; in ixgbe_clear_mbx_pf()
1110 * ixgbe_init_mbx_params_pf_id - set initial values for pf mailbox
1114 * Initializes single set of the hw->mbx struct to correct values for pf mailbox
1119 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_init_mbx_params_pf_id()
1121 mbx->ops[vf_id].release = ixgbe_release_mbx_lock_dummy; in ixgbe_init_mbx_params_pf_id()
1122 mbx->ops[vf_id].read = ixgbe_read_mbx_pf_legacy; in ixgbe_init_mbx_params_pf_id()
1123 mbx->ops[vf_id].write = ixgbe_write_mbx_pf_legacy; in ixgbe_init_mbx_params_pf_id()
1124 mbx->ops[vf_id].check_for_msg = ixgbe_check_for_msg_pf; in ixgbe_init_mbx_params_pf_id()
1125 mbx->ops[vf_id].check_for_ack = ixgbe_check_for_ack_pf; in ixgbe_init_mbx_params_pf_id()
1126 mbx->ops[vf_id].check_for_rst = ixgbe_check_for_rst_pf; in ixgbe_init_mbx_params_pf_id()
1127 mbx->ops[vf_id].clear = ixgbe_clear_mbx_pf; in ixgbe_init_mbx_params_pf_id()
1131 * ixgbe_init_mbx_params_pf - set initial values for pf mailbox
1134 * Initializes all sets of the hw->mbx struct to correct values for pf
1135 * mailbox. One set corresponds to single VF. It also initializes counters
1141 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_init_mbx_params_pf()
1144 if (hw->mac.type != ixgbe_mac_82599EB && in ixgbe_init_mbx_params_pf()
1145 hw->mac.type != ixgbe_mac_X550 && in ixgbe_init_mbx_params_pf()
1146 hw->mac.type != ixgbe_mac_X550EM_x && in ixgbe_init_mbx_params_pf()
1147 hw->mac.type != ixgbe_mac_X550EM_a && in ixgbe_init_mbx_params_pf()
1148 hw->mac.type != ixgbe_mac_X540) in ixgbe_init_mbx_params_pf()
1151 /* Initialize common mailbox settings */ in ixgbe_init_mbx_params_pf()
1152 mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT; in ixgbe_init_mbx_params_pf()
1153 mbx->usec_delay = IXGBE_VF_MBX_INIT_DELAY; in ixgbe_init_mbx_params_pf()
1154 mbx->size = IXGBE_VFMAILBOX_SIZE; in ixgbe_init_mbx_params_pf()
1157 mbx->stats.msgs_tx = 0; in ixgbe_init_mbx_params_pf()
1158 mbx->stats.msgs_rx = 0; in ixgbe_init_mbx_params_pf()
1159 mbx->stats.reqs = 0; in ixgbe_init_mbx_params_pf()
1160 mbx->stats.acks = 0; in ixgbe_init_mbx_params_pf()
1161 mbx->stats.rsts = 0; in ixgbe_init_mbx_params_pf()
1166 * 2. rewrite the code to dynamically allocate mbx->ops[vf_id] for in ixgbe_init_mbx_params_pf()
1174 * ixgbe_upgrade_mbx_params_pf - Upgrade initial values for pf mailbox
1178 * Initializes the hw->mbx struct to new function set for improved
1183 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_upgrade_mbx_params_pf()
1186 if (hw->mac.type != ixgbe_mac_82599EB && in ixgbe_upgrade_mbx_params_pf()
1187 hw->mac.type != ixgbe_mac_X550 && in ixgbe_upgrade_mbx_params_pf()
1188 hw->mac.type != ixgbe_mac_X550EM_x && in ixgbe_upgrade_mbx_params_pf()
1189 hw->mac.type != ixgbe_mac_X550EM_a && in ixgbe_upgrade_mbx_params_pf()
1190 hw->mac.type != ixgbe_mac_X540) in ixgbe_upgrade_mbx_params_pf()
1193 mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT; in ixgbe_upgrade_mbx_params_pf()
1194 mbx->usec_delay = IXGBE_VF_MBX_INIT_DELAY; in ixgbe_upgrade_mbx_params_pf()
1195 mbx->size = IXGBE_VFMAILBOX_SIZE; in ixgbe_upgrade_mbx_params_pf()
1197 mbx->ops[vf_id].release = ixgbe_release_mbx_lock_pf; in ixgbe_upgrade_mbx_params_pf()
1198 mbx->ops[vf_id].read = ixgbe_read_mbx_pf; in ixgbe_upgrade_mbx_params_pf()
1199 mbx->ops[vf_id].write = ixgbe_write_mbx_pf; in ixgbe_upgrade_mbx_params_pf()
1200 mbx->ops[vf_id].check_for_msg = ixgbe_check_for_msg_pf; in ixgbe_upgrade_mbx_params_pf()
1201 mbx->ops[vf_id].check_for_ack = ixgbe_check_for_ack_pf; in ixgbe_upgrade_mbx_params_pf()
1202 mbx->ops[vf_id].check_for_rst = ixgbe_check_for_rst_pf; in ixgbe_upgrade_mbx_params_pf()
1203 mbx->ops[vf_id].clear = ixgbe_clear_mbx_pf; in ixgbe_upgrade_mbx_params_pf()
1205 mbx->stats.msgs_tx = 0; in ixgbe_upgrade_mbx_params_pf()
1206 mbx->stats.msgs_rx = 0; in ixgbe_upgrade_mbx_params_pf()
1207 mbx->stats.reqs = 0; in ixgbe_upgrade_mbx_params_pf()
1208 mbx->stats.acks = 0; in ixgbe_upgrade_mbx_params_pf()
1209 mbx->stats.rsts = 0; in ixgbe_upgrade_mbx_params_pf()