xref: /freebsd/sys/dev/ice/ice_vf_mbx.h (revision bc761988b724587fe9ed5b99858b05ef842243ac)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*  Copyright (c) 2025, Intel Corporation
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *
8  *   1. Redistributions of source code must retain the above copyright notice,
9  *      this list of conditions and the following disclaimer.
10  *
11  *   2. Redistributions in binary form must reproduce the above copyright
12  *      notice, this list of conditions and the following disclaimer in the
13  *      documentation and/or other materials provided with the distribution.
14  *
15  *   3. Neither the name of the Intel Corporation nor the names of its
16  *      contributors may be used to endorse or promote products derived from
17  *      this software without specific prior written permission.
18  *
19  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  *  POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _ICE_VF_MBX_H_
33 #define _ICE_VF_MBX_H_
34 
35 #include "ice_type.h"
36 #include "ice_controlq.h"
37 
38 /* Defining the mailbox message threshold as 63 asynchronous
39  * pending messages. Normal VF functionality does not require
40  * sending more than 63 asynchronous pending message.
41  */
42 
43  /* Threshold value should be used to initialize
44   * MBX_VF_IN_FLIGHT_MSGS_AT_PF_CNT register.
45   */
46 #define ICE_ASYNC_VF_MSG_THRESHOLD	63
47 
48 int
49 ice_aq_send_msg_to_pf(struct ice_hw *hw, enum virtchnl_ops v_opcode,
50 		      int v_retval, u8 *msg, u16 msglen,
51 		      struct ice_sq_cd *cd);
52 int
53 ice_aq_send_msg_to_vf(struct ice_hw *hw, u16 vfid, u32 v_opcode, u32 v_retval,
54 		      u8 *msg, u16 msglen, struct ice_sq_cd *cd);
55 
56 u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed);
57 
58 void ice_e830_mbx_vf_dec_trig(struct ice_hw *hw,
59 			      struct ice_rq_event_info *event);
60 void ice_mbx_vf_clear_cnt_e830(struct ice_hw *hw, u16 vf_id);
61 int
62 ice_mbx_vf_state_handler(struct ice_hw *hw, struct ice_mbx_data *mbx_data,
63 			 struct ice_mbx_vf_info *vf_info, bool *report_malvf);
64 void ice_mbx_clear_malvf(struct ice_mbx_vf_info *vf_info);
65 void ice_mbx_init_vf_info(struct ice_hw *hw, struct ice_mbx_vf_info *vf_info);
66 void ice_mbx_init_snapshot(struct ice_hw *hw);
67 #endif /* _ICE_VF_MBX_H_ */
68