Lines Matching +full:hw +full:- +full:ops
2 SPDX-License-Identifier: BSD-3-Clause
4 Copyright (c) 2001-2020, Intel Corporation
38 * e1000_null_mbx_check_for_flag - No-op function, return 0
39 * @hw: pointer to the HW structure
42 static s32 e1000_null_mbx_check_for_flag(struct e1000_hw E1000_UNUSEDARG *hw, in e1000_null_mbx_check_for_flag() argument
51 * e1000_null_mbx_transact - No-op function, return 0
52 * @hw: pointer to the HW structure
57 static s32 e1000_null_mbx_transact(struct e1000_hw E1000_UNUSEDARG *hw, in e1000_null_mbx_transact() argument
68 * e1000_read_mbx - Reads a message from the mailbox
69 * @hw: pointer to the HW structure
76 s32 e1000_read_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id) in e1000_read_mbx() argument
78 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_read_mbx()
79 s32 ret_val = -E1000_ERR_MBX; in e1000_read_mbx()
84 if (size > mbx->size) in e1000_read_mbx()
85 size = mbx->size; in e1000_read_mbx()
87 if (mbx->ops.read) in e1000_read_mbx()
88 ret_val = mbx->ops.read(hw, msg, size, mbx_id); in e1000_read_mbx()
94 * e1000_write_mbx - Write a message to the mailbox
95 * @hw: pointer to the HW structure
102 s32 e1000_write_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id) in e1000_write_mbx() argument
104 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_write_mbx()
109 if (size > mbx->size) in e1000_write_mbx()
110 ret_val = -E1000_ERR_MBX; in e1000_write_mbx()
112 else if (mbx->ops.write) in e1000_write_mbx()
113 ret_val = mbx->ops.write(hw, msg, size, mbx_id); in e1000_write_mbx()
119 * e1000_check_for_msg - checks to see if someone sent us mail
120 * @hw: pointer to the HW structure
125 s32 e1000_check_for_msg(struct e1000_hw *hw, u16 mbx_id) in e1000_check_for_msg() argument
127 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_check_for_msg()
128 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_msg()
132 if (mbx->ops.check_for_msg) in e1000_check_for_msg()
133 ret_val = mbx->ops.check_for_msg(hw, mbx_id); in e1000_check_for_msg()
139 * e1000_check_for_ack - checks to see if someone sent us ACK
140 * @hw: pointer to the HW structure
145 s32 e1000_check_for_ack(struct e1000_hw *hw, u16 mbx_id) in e1000_check_for_ack() argument
147 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_check_for_ack()
148 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_ack()
152 if (mbx->ops.check_for_ack) in e1000_check_for_ack()
153 ret_val = mbx->ops.check_for_ack(hw, mbx_id); in e1000_check_for_ack()
159 * e1000_check_for_rst - checks to see if other side has reset
160 * @hw: pointer to the HW structure
165 s32 e1000_check_for_rst(struct e1000_hw *hw, u16 mbx_id) in e1000_check_for_rst() argument
167 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_check_for_rst()
168 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_rst()
172 if (mbx->ops.check_for_rst) in e1000_check_for_rst()
173 ret_val = mbx->ops.check_for_rst(hw, mbx_id); in e1000_check_for_rst()
179 * e1000_poll_for_msg - Wait for message notification
180 * @hw: pointer to the HW structure
185 static s32 e1000_poll_for_msg(struct e1000_hw *hw, u16 mbx_id) in e1000_poll_for_msg() argument
187 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_poll_for_msg()
188 int countdown = mbx->timeout; in e1000_poll_for_msg()
192 if (!countdown || !mbx->ops.check_for_msg) in e1000_poll_for_msg()
195 while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) { in e1000_poll_for_msg()
196 countdown--; in e1000_poll_for_msg()
199 usec_delay(mbx->usec_delay); in e1000_poll_for_msg()
204 mbx->timeout = 0; in e1000_poll_for_msg()
206 return countdown ? E1000_SUCCESS : -E1000_ERR_MBX; in e1000_poll_for_msg()
210 * e1000_poll_for_ack - Wait for message acknowledgement
211 * @hw: pointer to the HW structure
216 static s32 e1000_poll_for_ack(struct e1000_hw *hw, u16 mbx_id) in e1000_poll_for_ack() argument
218 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_poll_for_ack()
219 int countdown = mbx->timeout; in e1000_poll_for_ack()
223 if (!countdown || !mbx->ops.check_for_ack) in e1000_poll_for_ack()
226 while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) { in e1000_poll_for_ack()
227 countdown--; in e1000_poll_for_ack()
230 usec_delay(mbx->usec_delay); in e1000_poll_for_ack()
235 mbx->timeout = 0; in e1000_poll_for_ack()
237 return countdown ? E1000_SUCCESS : -E1000_ERR_MBX; in e1000_poll_for_ack()
241 * e1000_read_posted_mbx - Wait for message notification and receive message
242 * @hw: pointer to the HW structure
250 s32 e1000_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id) in e1000_read_posted_mbx() argument
252 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_read_posted_mbx()
253 s32 ret_val = -E1000_ERR_MBX; in e1000_read_posted_mbx()
257 if (!mbx->ops.read) in e1000_read_posted_mbx()
260 ret_val = e1000_poll_for_msg(hw, mbx_id); in e1000_read_posted_mbx()
264 ret_val = mbx->ops.read(hw, msg, size, mbx_id); in e1000_read_posted_mbx()
270 * e1000_write_posted_mbx - Write a message to the mailbox, wait for ack
271 * @hw: pointer to the HW structure
279 s32 e1000_write_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id) in e1000_write_posted_mbx() argument
281 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_write_posted_mbx()
282 s32 ret_val = -E1000_ERR_MBX; in e1000_write_posted_mbx()
287 if (!mbx->ops.write || !mbx->timeout) in e1000_write_posted_mbx()
291 ret_val = mbx->ops.write(hw, msg, size, mbx_id); in e1000_write_posted_mbx()
295 ret_val = e1000_poll_for_ack(hw, mbx_id); in e1000_write_posted_mbx()
301 * e1000_init_mbx_ops_generic - Initialize mbx function pointers
302 * @hw: pointer to the HW structure
304 * Sets the function pointers to no-op functions
306 void e1000_init_mbx_ops_generic(struct e1000_hw *hw) in e1000_init_mbx_ops_generic() argument
308 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_init_mbx_ops_generic()
309 mbx->ops.init_params = e1000_null_ops_generic; in e1000_init_mbx_ops_generic()
310 mbx->ops.read = e1000_null_mbx_transact; in e1000_init_mbx_ops_generic()
311 mbx->ops.write = e1000_null_mbx_transact; in e1000_init_mbx_ops_generic()
312 mbx->ops.check_for_msg = e1000_null_mbx_check_for_flag; in e1000_init_mbx_ops_generic()
313 mbx->ops.check_for_ack = e1000_null_mbx_check_for_flag; in e1000_init_mbx_ops_generic()
314 mbx->ops.check_for_rst = e1000_null_mbx_check_for_flag; in e1000_init_mbx_ops_generic()
315 mbx->ops.read_posted = e1000_read_posted_mbx; in e1000_init_mbx_ops_generic()
316 mbx->ops.write_posted = e1000_write_posted_mbx; in e1000_init_mbx_ops_generic()
320 * e1000_read_v2p_mailbox - read v2p mailbox
321 * @hw: pointer to the HW structure
326 static u32 e1000_read_v2p_mailbox(struct e1000_hw *hw) in e1000_read_v2p_mailbox() argument
328 u32 v2p_mailbox = E1000_READ_REG(hw, E1000_V2PMAILBOX(0)); in e1000_read_v2p_mailbox()
330 v2p_mailbox |= hw->dev_spec.vf.v2p_mailbox; in e1000_read_v2p_mailbox()
331 hw->dev_spec.vf.v2p_mailbox |= v2p_mailbox & E1000_V2PMAILBOX_R2C_BITS; in e1000_read_v2p_mailbox()
337 * e1000_check_for_bit_vf - Determine if a status bit was set
338 * @hw: pointer to the HW structure
344 static s32 e1000_check_for_bit_vf(struct e1000_hw *hw, u32 mask) in e1000_check_for_bit_vf() argument
346 u32 v2p_mailbox = e1000_read_v2p_mailbox(hw); in e1000_check_for_bit_vf()
347 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_bit_vf()
352 hw->dev_spec.vf.v2p_mailbox &= ~mask; in e1000_check_for_bit_vf()
358 * e1000_check_for_msg_vf - checks to see if the PF has sent mail
359 * @hw: pointer to the HW structure
364 static s32 e1000_check_for_msg_vf(struct e1000_hw *hw, in e1000_check_for_msg_vf() argument
367 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_msg_vf()
371 if (!e1000_check_for_bit_vf(hw, E1000_V2PMAILBOX_PFSTS)) { in e1000_check_for_msg_vf()
373 hw->mbx.stats.reqs++; in e1000_check_for_msg_vf()
380 * e1000_check_for_ack_vf - checks to see if the PF has ACK'd
381 * @hw: pointer to the HW structure
386 static s32 e1000_check_for_ack_vf(struct e1000_hw *hw, in e1000_check_for_ack_vf() argument
389 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_ack_vf()
393 if (!e1000_check_for_bit_vf(hw, E1000_V2PMAILBOX_PFACK)) { in e1000_check_for_ack_vf()
395 hw->mbx.stats.acks++; in e1000_check_for_ack_vf()
402 * e1000_check_for_rst_vf - checks to see if the PF has reset
403 * @hw: pointer to the HW structure
408 static s32 e1000_check_for_rst_vf(struct e1000_hw *hw, in e1000_check_for_rst_vf() argument
411 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_rst_vf()
415 if (!e1000_check_for_bit_vf(hw, (E1000_V2PMAILBOX_RSTD | in e1000_check_for_rst_vf()
418 hw->mbx.stats.rsts++; in e1000_check_for_rst_vf()
425 * e1000_obtain_mbx_lock_vf - obtain mailbox lock
426 * @hw: pointer to the HW structure
430 static s32 e1000_obtain_mbx_lock_vf(struct e1000_hw *hw) in e1000_obtain_mbx_lock_vf() argument
432 s32 ret_val = -E1000_ERR_MBX; in e1000_obtain_mbx_lock_vf()
439 E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_VFU); in e1000_obtain_mbx_lock_vf()
442 if (e1000_read_v2p_mailbox(hw) & E1000_V2PMAILBOX_VFU) { in e1000_obtain_mbx_lock_vf()
447 } while (count-- > 0); in e1000_obtain_mbx_lock_vf()
453 * e1000_write_mbx_vf - Write a message to the mailbox
454 * @hw: pointer to the HW structure
461 static s32 e1000_write_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size, in e1000_write_mbx_vf() argument
471 ret_val = e1000_obtain_mbx_lock_vf(hw); in e1000_write_mbx_vf()
476 e1000_check_for_msg_vf(hw, 0); in e1000_write_mbx_vf()
477 e1000_check_for_ack_vf(hw, 0); in e1000_write_mbx_vf()
481 E1000_WRITE_REG_ARRAY(hw, E1000_VMBMEM(0), i, msg[i]); in e1000_write_mbx_vf()
484 hw->mbx.stats.msgs_tx++; in e1000_write_mbx_vf()
487 E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_REQ); in e1000_write_mbx_vf()
494 * e1000_read_mbx_vf - Reads a message from the inbox intended for vf
495 * @hw: pointer to the HW structure
502 static s32 e1000_read_mbx_vf(struct e1000_hw *hw, u32 *msg, u16 size, in e1000_read_mbx_vf() argument
511 ret_val = e1000_obtain_mbx_lock_vf(hw); in e1000_read_mbx_vf()
517 msg[i] = E1000_READ_REG_ARRAY(hw, E1000_VMBMEM(0), i); in e1000_read_mbx_vf()
520 E1000_WRITE_REG(hw, E1000_V2PMAILBOX(0), E1000_V2PMAILBOX_ACK); in e1000_read_mbx_vf()
523 hw->mbx.stats.msgs_rx++; in e1000_read_mbx_vf()
530 * e1000_init_mbx_params_vf - set initial values for vf mailbox
531 * @hw: pointer to the HW structure
533 * Initializes the hw->mbx struct to correct values for vf mailbox
535 s32 e1000_init_mbx_params_vf(struct e1000_hw *hw) in e1000_init_mbx_params_vf() argument
537 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_init_mbx_params_vf()
541 mbx->timeout = 0; in e1000_init_mbx_params_vf()
542 mbx->usec_delay = E1000_VF_MBX_INIT_DELAY; in e1000_init_mbx_params_vf()
544 mbx->size = E1000_VFMAILBOX_SIZE; in e1000_init_mbx_params_vf()
546 mbx->ops.read = e1000_read_mbx_vf; in e1000_init_mbx_params_vf()
547 mbx->ops.write = e1000_write_mbx_vf; in e1000_init_mbx_params_vf()
548 mbx->ops.read_posted = e1000_read_posted_mbx; in e1000_init_mbx_params_vf()
549 mbx->ops.write_posted = e1000_write_posted_mbx; in e1000_init_mbx_params_vf()
550 mbx->ops.check_for_msg = e1000_check_for_msg_vf; in e1000_init_mbx_params_vf()
551 mbx->ops.check_for_ack = e1000_check_for_ack_vf; in e1000_init_mbx_params_vf()
552 mbx->ops.check_for_rst = e1000_check_for_rst_vf; in e1000_init_mbx_params_vf()
554 mbx->stats.msgs_tx = 0; in e1000_init_mbx_params_vf()
555 mbx->stats.msgs_rx = 0; in e1000_init_mbx_params_vf()
556 mbx->stats.reqs = 0; in e1000_init_mbx_params_vf()
557 mbx->stats.acks = 0; in e1000_init_mbx_params_vf()
558 mbx->stats.rsts = 0; in e1000_init_mbx_params_vf()
563 static s32 e1000_check_for_bit_pf(struct e1000_hw *hw, u32 mask) in e1000_check_for_bit_pf() argument
565 u32 mbvficr = E1000_READ_REG(hw, E1000_MBVFICR); in e1000_check_for_bit_pf()
566 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_bit_pf()
570 E1000_WRITE_REG(hw, E1000_MBVFICR, mask); in e1000_check_for_bit_pf()
577 * e1000_check_for_msg_pf - checks to see if the VF has sent mail
578 * @hw: pointer to the HW structure
583 static s32 e1000_check_for_msg_pf(struct e1000_hw *hw, u16 vf_number) in e1000_check_for_msg_pf() argument
585 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_msg_pf()
589 if (!e1000_check_for_bit_pf(hw, E1000_MBVFICR_VFREQ_VF1 << vf_number)) { in e1000_check_for_msg_pf()
591 hw->mbx.stats.reqs++; in e1000_check_for_msg_pf()
598 * e1000_check_for_ack_pf - checks to see if the VF has ACKed
599 * @hw: pointer to the HW structure
604 static s32 e1000_check_for_ack_pf(struct e1000_hw *hw, u16 vf_number) in e1000_check_for_ack_pf() argument
606 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_ack_pf()
610 if (!e1000_check_for_bit_pf(hw, E1000_MBVFICR_VFACK_VF1 << vf_number)) { in e1000_check_for_ack_pf()
612 hw->mbx.stats.acks++; in e1000_check_for_ack_pf()
619 * e1000_check_for_rst_pf - checks to see if the VF has reset
620 * @hw: pointer to the HW structure
625 static s32 e1000_check_for_rst_pf(struct e1000_hw *hw, u16 vf_number) in e1000_check_for_rst_pf() argument
627 u32 vflre = E1000_READ_REG(hw, E1000_VFLRE); in e1000_check_for_rst_pf()
628 s32 ret_val = -E1000_ERR_MBX; in e1000_check_for_rst_pf()
634 E1000_WRITE_REG(hw, E1000_VFLRE, (1 << vf_number)); in e1000_check_for_rst_pf()
635 hw->mbx.stats.rsts++; in e1000_check_for_rst_pf()
642 * e1000_obtain_mbx_lock_pf - obtain mailbox lock
643 * @hw: pointer to the HW structure
648 static s32 e1000_obtain_mbx_lock_pf(struct e1000_hw *hw, u16 vf_number) in e1000_obtain_mbx_lock_pf() argument
650 s32 ret_val = -E1000_ERR_MBX; in e1000_obtain_mbx_lock_pf()
658 E1000_WRITE_REG(hw, E1000_P2VMAILBOX(vf_number), in e1000_obtain_mbx_lock_pf()
662 p2v_mailbox = E1000_READ_REG(hw, E1000_P2VMAILBOX(vf_number)); in e1000_obtain_mbx_lock_pf()
668 } while (count-- > 0); in e1000_obtain_mbx_lock_pf()
675 * e1000_write_mbx_pf - Places a message in the mailbox
676 * @hw: pointer to the HW structure
683 static s32 e1000_write_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size, in e1000_write_mbx_pf() argument
692 ret_val = e1000_obtain_mbx_lock_pf(hw, vf_number); in e1000_write_mbx_pf()
697 e1000_check_for_msg_pf(hw, vf_number); in e1000_write_mbx_pf()
698 e1000_check_for_ack_pf(hw, vf_number); in e1000_write_mbx_pf()
702 E1000_WRITE_REG_ARRAY(hw, E1000_VMBMEM(vf_number), i, msg[i]); in e1000_write_mbx_pf()
705 E1000_WRITE_REG(hw, E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_STS); in e1000_write_mbx_pf()
708 hw->mbx.stats.msgs_tx++; in e1000_write_mbx_pf()
716 * e1000_read_mbx_pf - Read a message from the mailbox
717 * @hw: pointer to the HW structure
726 static s32 e1000_read_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size, in e1000_read_mbx_pf() argument
735 ret_val = e1000_obtain_mbx_lock_pf(hw, vf_number); in e1000_read_mbx_pf()
741 msg[i] = E1000_READ_REG_ARRAY(hw, E1000_VMBMEM(vf_number), i); in e1000_read_mbx_pf()
744 E1000_WRITE_REG(hw, E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_ACK); in e1000_read_mbx_pf()
747 hw->mbx.stats.msgs_rx++; in e1000_read_mbx_pf()
754 * e1000_init_mbx_params_pf - set initial values for pf mailbox
755 * @hw: pointer to the HW structure
757 * Initializes the hw->mbx struct to correct values for pf mailbox
759 s32 e1000_init_mbx_params_pf(struct e1000_hw *hw) in e1000_init_mbx_params_pf() argument
761 struct e1000_mbx_info *mbx = &hw->mbx; in e1000_init_mbx_params_pf()
763 switch (hw->mac.type) { in e1000_init_mbx_params_pf()
767 mbx->timeout = 0; in e1000_init_mbx_params_pf()
768 mbx->usec_delay = 0; in e1000_init_mbx_params_pf()
770 mbx->size = E1000_VFMAILBOX_SIZE; in e1000_init_mbx_params_pf()
772 mbx->ops.read = e1000_read_mbx_pf; in e1000_init_mbx_params_pf()
773 mbx->ops.write = e1000_write_mbx_pf; in e1000_init_mbx_params_pf()
774 mbx->ops.read_posted = e1000_read_posted_mbx; in e1000_init_mbx_params_pf()
775 mbx->ops.write_posted = e1000_write_posted_mbx; in e1000_init_mbx_params_pf()
776 mbx->ops.check_for_msg = e1000_check_for_msg_pf; in e1000_init_mbx_params_pf()
777 mbx->ops.check_for_ack = e1000_check_for_ack_pf; in e1000_init_mbx_params_pf()
778 mbx->ops.check_for_rst = e1000_check_for_rst_pf; in e1000_init_mbx_params_pf()
780 mbx->stats.msgs_tx = 0; in e1000_init_mbx_params_pf()
781 mbx->stats.msgs_rx = 0; in e1000_init_mbx_params_pf()
782 mbx->stats.reqs = 0; in e1000_init_mbx_params_pf()
783 mbx->stats.acks = 0; in e1000_init_mbx_params_pf()
784 mbx->stats.rsts = 0; in e1000_init_mbx_params_pf()