Lines Matching +full:hw +full:- +full:ops

2   SPDX-License-Identifier: BSD-3-Clause
4 Copyright (c) 2001-2020, Intel Corporation
38 static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id);
39 static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id);
42 * ixgbe_read_mbx - Reads a message from the mailbox
43 * @hw: pointer to the HW structure
50 s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) in ixgbe_read_mbx() argument
52 struct ixgbe_mbx_info *mbx = &hw->mbx; in ixgbe_read_mbx()
57 if (size > mbx->size) { 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
72 * @hw: pointer to the HW structure
79 s32 ixgbe_poll_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) in ixgbe_poll_mbx() argument
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()
91 if (size > mbx->size) { in ixgbe_poll_mbx()
94 size, mbx->size); in ixgbe_poll_mbx()
95 size = mbx->size; in ixgbe_poll_mbx()
98 ret_val = ixgbe_poll_for_msg(hw, mbx_id); 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
108 * @hw: pointer to the HW structure
119 s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) in ixgbe_write_mbx() argument
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()
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
147 * @hw: pointer to the HW structure
152 s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_check_for_msg() argument
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
167 * @hw: pointer to the HW structure
172 s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_check_for_ack() argument
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
187 * @hw: pointer to the HW structure
192 s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_check_for_rst() argument
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
207 * @hw: pointer to the HW structure
212 s32 ixgbe_clear_mbx(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_clear_mbx() argument
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
227 * @hw: pointer to the HW structure
232 static s32 ixgbe_poll_for_msg(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_poll_for_msg() argument
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()
259 * ixgbe_poll_for_ack - Wait for message acknowledgment
260 * @hw: pointer to the HW structure
265 static s32 ixgbe_poll_for_ack(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_poll_for_ack() argument
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()
292 * ixgbe_read_mailbox_vf - read VF's mailbox register
293 * @hw: pointer to the HW structure
298 static u32 ixgbe_read_mailbox_vf(struct ixgbe_hw *hw) in ixgbe_read_mailbox_vf() argument
300 u32 vf_mailbox = IXGBE_READ_REG(hw, IXGBE_VFMAILBOX); in ixgbe_read_mailbox_vf()
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()
308 static void ixgbe_clear_msg_vf(struct ixgbe_hw *hw) in ixgbe_clear_msg_vf() argument
310 u32 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_clear_msg_vf()
313 hw->mbx.stats.reqs++; in ixgbe_clear_msg_vf()
314 hw->mbx.vf_mailbox &= ~IXGBE_VFMAILBOX_PFSTS; in ixgbe_clear_msg_vf()
318 static void ixgbe_clear_ack_vf(struct ixgbe_hw *hw) in ixgbe_clear_ack_vf() argument
320 u32 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_clear_ack_vf()
323 hw->mbx.stats.acks++; in ixgbe_clear_ack_vf()
324 hw->mbx.vf_mailbox &= ~IXGBE_VFMAILBOX_PFACK; in ixgbe_clear_ack_vf()
328 static void ixgbe_clear_rst_vf(struct ixgbe_hw *hw) in ixgbe_clear_rst_vf() argument
330 u32 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_clear_rst_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
341 * @hw: pointer to the HW structure
347 static s32 ixgbe_check_for_bit_vf(struct ixgbe_hw *hw, u32 mask) in ixgbe_check_for_bit_vf() argument
349 u32 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_check_for_bit_vf()
358 * ixgbe_check_for_msg_vf - checks to see if the PF has sent mail
359 * @hw: pointer to the HW structure
364 static s32 ixgbe_check_for_msg_vf(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_check_for_msg_vf() argument
369 if (!ixgbe_check_for_bit_vf(hw, IXGBE_VFMAILBOX_PFSTS)) in ixgbe_check_for_msg_vf()
376 * ixgbe_check_for_ack_vf - checks to see if the PF has ACK'd
377 * @hw: pointer to the HW structure
382 static s32 ixgbe_check_for_ack_vf(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_check_for_ack_vf() argument
387 if (!ixgbe_check_for_bit_vf(hw, IXGBE_VFMAILBOX_PFACK)) { in ixgbe_check_for_ack_vf()
389 ixgbe_clear_ack_vf(hw); in ixgbe_check_for_ack_vf()
397 * ixgbe_check_for_rst_vf - checks to see if the PF has reset
398 * @hw: pointer to the HW structure
403 static s32 ixgbe_check_for_rst_vf(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_check_for_rst_vf() argument
408 if (!ixgbe_check_for_bit_vf(hw, IXGBE_VFMAILBOX_RSTI | in ixgbe_check_for_rst_vf()
411 ixgbe_clear_rst_vf(hw); in ixgbe_check_for_rst_vf()
419 * ixgbe_obtain_mbx_lock_vf - obtain mailbox lock
420 * @hw: pointer to the HW structure
424 static s32 ixgbe_obtain_mbx_lock_vf(struct ixgbe_hw *hw) in ixgbe_obtain_mbx_lock_vf() argument
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()
438 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_obtain_mbx_lock_vf()
440 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, vf_mailbox); in ixgbe_obtain_mbx_lock_vf()
443 if (ixgbe_read_mailbox_vf(hw) & IXGBE_VFMAILBOX_VFU) { in ixgbe_obtain_mbx_lock_vf()
449 usec_delay(mbx->usec_delay); in ixgbe_obtain_mbx_lock_vf()
462 * ixgbe_release_mbx_lock_dummy - release mailbox lock
463 * @hw: pointer to the HW structure
466 static void ixgbe_release_mbx_lock_dummy(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_release_mbx_lock_dummy() argument
468 UNREFERENCED_2PARAMETER(hw, mbx_id); in ixgbe_release_mbx_lock_dummy()
474 * ixgbe_release_mbx_lock_vf - release mailbox lock
475 * @hw: pointer to the HW structure
478 static void ixgbe_release_mbx_lock_vf(struct ixgbe_hw *hw, u16 mbx_id) in ixgbe_release_mbx_lock_vf() argument
487 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_release_mbx_lock_vf()
489 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, vf_mailbox); in ixgbe_release_mbx_lock_vf()
493 * ixgbe_write_mbx_vf_legacy - Write a message to the mailbox
494 * @hw: pointer to the HW structure
501 static s32 ixgbe_write_mbx_vf_legacy(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_write_mbx_vf_legacy() argument
511 ret_val = ixgbe_obtain_mbx_lock_vf(hw); in ixgbe_write_mbx_vf_legacy()
516 ixgbe_check_for_msg_vf(hw, 0); in ixgbe_write_mbx_vf_legacy()
517 ixgbe_clear_msg_vf(hw); in ixgbe_write_mbx_vf_legacy()
518 ixgbe_check_for_ack_vf(hw, 0); in ixgbe_write_mbx_vf_legacy()
519 ixgbe_clear_ack_vf(hw); in ixgbe_write_mbx_vf_legacy()
523 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]); in ixgbe_write_mbx_vf_legacy()
526 hw->mbx.stats.msgs_tx++; in ixgbe_write_mbx_vf_legacy()
529 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_REQ); in ixgbe_write_mbx_vf_legacy()
535 * ixgbe_write_mbx_vf - Write a message to the mailbox
536 * @hw: pointer to the HW structure
543 static s32 ixgbe_write_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_write_mbx_vf() argument
555 ret_val = ixgbe_obtain_mbx_lock_vf(hw); in ixgbe_write_mbx_vf()
560 ixgbe_clear_msg_vf(hw); in ixgbe_write_mbx_vf()
561 ixgbe_clear_ack_vf(hw); in ixgbe_write_mbx_vf()
565 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_VFMBMEM, i, msg[i]); in ixgbe_write_mbx_vf()
568 hw->mbx.stats.msgs_tx++; in ixgbe_write_mbx_vf()
571 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_write_mbx_vf()
573 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, vf_mailbox); in ixgbe_write_mbx_vf()
576 ixgbe_poll_for_ack(hw, mbx_id); 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
586 * @hw: pointer to the HW structure
593 static s32 ixgbe_read_mbx_vf_legacy(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_read_mbx_vf_legacy() argument
603 ret_val = ixgbe_obtain_mbx_lock_vf(hw); in ixgbe_read_mbx_vf_legacy()
609 msg[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_VFMBMEM, i); in ixgbe_read_mbx_vf_legacy()
612 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, IXGBE_VFMAILBOX_ACK); 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
622 * @hw: pointer to the HW structure
629 static s32 ixgbe_read_mbx_vf(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_read_mbx_vf() argument
640 ret_val = ixgbe_check_for_msg_vf(hw, 0); in ixgbe_read_mbx_vf()
644 ixgbe_clear_msg_vf(hw); in ixgbe_read_mbx_vf()
648 msg[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_VFMBMEM, i); in ixgbe_read_mbx_vf()
651 vf_mailbox = ixgbe_read_mailbox_vf(hw); in ixgbe_read_mbx_vf()
653 IXGBE_WRITE_REG(hw, IXGBE_VFMAILBOX, vf_mailbox); 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
663 * @hw: pointer to the HW structure
665 * Initializes single set the hw->mbx struct to correct values for vf mailbox
668 void ixgbe_init_mbx_params_vf(struct ixgbe_hw *hw) in ixgbe_init_mbx_params_vf() argument
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()
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
695 * @hw: pointer to the HW structure
697 * Initializes the hw->mbx struct to correct values for vf mailbox
699 void ixgbe_upgrade_mbx_params_vf(struct ixgbe_hw *hw) in ixgbe_upgrade_mbx_params_vf() argument
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()
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()
724 static void ixgbe_clear_msg_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_clear_msg_pf() argument
730 pfmbicr = IXGBE_READ_REG(hw, IXGBE_PFMBICR(index)); in ixgbe_clear_msg_pf()
733 hw->mbx.stats.reqs++; in ixgbe_clear_msg_pf()
735 IXGBE_WRITE_REG(hw, IXGBE_PFMBICR(index), in ixgbe_clear_msg_pf()
739 static void ixgbe_clear_ack_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_clear_ack_pf() argument
745 pfmbicr = IXGBE_READ_REG(hw, IXGBE_PFMBICR(index)); in ixgbe_clear_ack_pf()
748 hw->mbx.stats.acks++; in ixgbe_clear_ack_pf()
750 IXGBE_WRITE_REG(hw, IXGBE_PFMBICR(index), in ixgbe_clear_ack_pf()
754 static s32 ixgbe_check_for_bit_pf(struct ixgbe_hw *hw, u32 mask, s32 index) in ixgbe_check_for_bit_pf() argument
756 u32 pfmbicr = IXGBE_READ_REG(hw, IXGBE_PFMBICR(index)); in ixgbe_check_for_bit_pf()
766 * ixgbe_check_for_msg_pf - checks to see if the VF has sent mail
767 * @hw: pointer to the HW structure
772 static s32 ixgbe_check_for_msg_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_check_for_msg_pf() argument
779 if (!ixgbe_check_for_bit_pf(hw, IXGBE_PFMBICR_VFREQ_VF1 << vf_shift, in ixgbe_check_for_msg_pf()
787 * ixgbe_check_for_ack_pf - checks to see if the VF has ACKed
788 * @hw: pointer to the HW structure
793 static s32 ixgbe_check_for_ack_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_check_for_ack_pf() argument
801 if (!ixgbe_check_for_bit_pf(hw, IXGBE_PFMBICR_VFACK_VF1 << vf_shift, in ixgbe_check_for_ack_pf()
805 ixgbe_clear_ack_pf(hw, vf_id); in ixgbe_check_for_ack_pf()
812 * ixgbe_check_for_rst_pf - checks to see if the VF has reset
813 * @hw: pointer to the HW structure
818 static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_check_for_rst_pf() argument
827 switch (hw->mac.type) { in ixgbe_check_for_rst_pf()
829 vflre = IXGBE_READ_REG(hw, IXGBE_PFVFLRE(index)); in ixgbe_check_for_rst_pf()
835 vflre = IXGBE_READ_REG(hw, IXGBE_PFVFLREC(index)); in ixgbe_check_for_rst_pf()
843 IXGBE_WRITE_REG(hw, IXGBE_PFVFLREC(index), (1 << vf_shift)); 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
852 * @hw: pointer to the HW structure
857 static s32 ixgbe_obtain_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_obtain_mbx_lock_pf() argument
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()
871 pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id)); in ixgbe_obtain_mbx_lock_pf()
878 IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), pf_mailbox); in ixgbe_obtain_mbx_lock_pf()
881 pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id)); in ixgbe_obtain_mbx_lock_pf()
889 usec_delay(mbx->usec_delay); in ixgbe_obtain_mbx_lock_pf()
902 * ixgbe_release_mbx_lock_pf - release mailbox lock
903 * @hw: pointer to the HW structure
906 static void ixgbe_release_mbx_lock_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_release_mbx_lock_pf() argument
913 pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id)); in ixgbe_release_mbx_lock_pf()
915 IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), pf_mailbox); in ixgbe_release_mbx_lock_pf()
919 * ixgbe_write_mbx_pf_legacy - Places a message in the mailbox
920 * @hw: pointer to the HW structure
927 static s32 ixgbe_write_mbx_pf_legacy(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_write_mbx_pf_legacy() argument
936 ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_id); in ixgbe_write_mbx_pf_legacy()
941 ixgbe_check_for_msg_pf(hw, vf_id); in ixgbe_write_mbx_pf_legacy()
942 ixgbe_clear_msg_pf(hw, vf_id); in ixgbe_write_mbx_pf_legacy()
943 ixgbe_check_for_ack_pf(hw, vf_id); in ixgbe_write_mbx_pf_legacy()
944 ixgbe_clear_ack_pf(hw, vf_id); in ixgbe_write_mbx_pf_legacy()
948 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_id), i, msg[i]); in ixgbe_write_mbx_pf_legacy()
951 IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), IXGBE_PFMAILBOX_STS); 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
961 * @hw: pointer to the HW structure
968 static s32 ixgbe_write_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_write_mbx_pf() argument
978 ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_id); in ixgbe_write_mbx_pf()
983 ixgbe_clear_msg_pf(hw, vf_id); in ixgbe_write_mbx_pf()
984 ixgbe_clear_ack_pf(hw, vf_id); in ixgbe_write_mbx_pf()
988 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_id), i, msg[i]); in ixgbe_write_mbx_pf()
991 pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id)); in ixgbe_write_mbx_pf()
993 IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), pf_mailbox); in ixgbe_write_mbx_pf()
997 ixgbe_poll_for_ack(hw, vf_id); 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
1011 * @hw: pointer to the HW structure
1020 static s32 ixgbe_read_mbx_pf_legacy(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_read_mbx_pf_legacy() argument
1029 ret_val = ixgbe_obtain_mbx_lock_pf(hw, vf_id); in ixgbe_read_mbx_pf_legacy()
1035 msg[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_id), i); in ixgbe_read_mbx_pf_legacy()
1038 IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), IXGBE_PFMAILBOX_ACK); 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
1048 * @hw: pointer to the HW structure
1057 static s32 ixgbe_read_mbx_pf(struct ixgbe_hw *hw, u32 *msg, u16 size, in ixgbe_read_mbx_pf() argument
1067 ret_val = ixgbe_check_for_msg_pf(hw, vf_id); in ixgbe_read_mbx_pf()
1071 ixgbe_clear_msg_pf(hw, vf_id); in ixgbe_read_mbx_pf()
1075 msg[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_id), i); in ixgbe_read_mbx_pf()
1078 pf_mailbox = IXGBE_READ_REG(hw, IXGBE_PFMAILBOX(vf_id)); in ixgbe_read_mbx_pf()
1080 IXGBE_WRITE_REG(hw, IXGBE_PFMAILBOX(vf_id), pf_mailbox); in ixgbe_read_mbx_pf()
1083 hw->mbx.stats.msgs_rx++; in ixgbe_read_mbx_pf()
1089 * ixgbe_clear_mbx_pf - Clear Mailbox Memory
1090 * @hw: pointer to the HW structure
1095 static s32 ixgbe_clear_mbx_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_clear_mbx_pf() argument
1097 u16 mbx_size = hw->mbx.size; in ixgbe_clear_mbx_pf()
1104 IXGBE_WRITE_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_id), i, 0x0); in ixgbe_clear_mbx_pf()
1110 * ixgbe_init_mbx_params_pf_id - set initial values for pf mailbox
1111 * @hw: pointer to the HW structure
1114 * Initializes single set of the hw->mbx struct to correct values for pf mailbox
1117 void ixgbe_init_mbx_params_pf_id(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_init_mbx_params_pf_id() argument
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
1132 * @hw: pointer to the HW structure
1134 * Initializes all sets of the hw->mbx struct to correct values for pf
1138 void ixgbe_init_mbx_params_pf(struct ixgbe_hw *hw) in ixgbe_init_mbx_params_pf() argument
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()
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()
1170 ixgbe_init_mbx_params_pf_id(hw, i); in ixgbe_init_mbx_params_pf()
1174 * ixgbe_upgrade_mbx_params_pf - Upgrade initial values for pf mailbox
1175 * @hw: pointer to the HW structure
1178 * Initializes the hw->mbx struct to new function set for improved
1181 void ixgbe_upgrade_mbx_params_pf(struct ixgbe_hw *hw, u16 vf_id) in ixgbe_upgrade_mbx_params_pf() argument
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()