1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018, Intel Corporation. */
4 #include "ice_common.h"
5 #include "ice_adminq_cmd.h"
9 * ice_aq_send_msg_to_vf
10 * @hw: pointer to the hardware structure
11 * @vfid: VF ID to send msg
12 * @v_opcode: opcodes for VF-PF communication
13 * @v_retval: return error code
14 * @msg: pointer to the msg buffer
16 * @cd: pointer to command details
18 * Send message to VF driver (0x0802) using mailbox
19 * queue and asynchronously sending message via
20 * ice_sq_send_cmd() function
23 ice_aq_send_msg_to_vf(struct ice_hw
*hw
, u16 vfid
, u32 v_opcode
, u32 v_retval
,
24 u8
*msg
, u16 msglen
, struct ice_sq_cd
*cd
)
26 struct ice_aqc_pf_vf_msg
*cmd
;
27 struct ice_aq_desc desc
;
29 ice_fill_dflt_direct_cmd_desc(&desc
, ice_mbx_opc_send_msg_to_vf
);
31 cmd
= &desc
.params
.virt
;
32 cmd
->id
= cpu_to_le32(vfid
);
34 desc
.cookie_high
= cpu_to_le32(v_opcode
);
35 desc
.cookie_low
= cpu_to_le32(v_retval
);
38 desc
.flags
|= cpu_to_le16(ICE_AQ_FLAG_RD
);
40 return ice_sq_send_cmd(hw
, &hw
->mailboxq
, &desc
, msg
, msglen
, cd
);
44 * ice_conv_link_speed_to_virtchnl
45 * @adv_link_support: determines the format of the returned link speed
46 * @link_speed: variable containing the link_speed to be converted
48 * Convert link speed supported by HW to link speed supported by virtchnl.
49 * If adv_link_support is true, then return link speed in Mbps. Else return
50 * link speed as a VIRTCHNL_LINK_SPEED_* casted to a u32. Note that the caller
51 * needs to cast back to an enum virtchnl_link_speed in the case where
52 * adv_link_support is false, but when adv_link_support is true the caller can
53 * expect the speed in Mbps.
55 u32
ice_conv_link_speed_to_virtchnl(bool adv_link_support
, u16 link_speed
)
61 case ICE_AQ_LINK_SPEED_10MB
:
62 speed
= ICE_LINK_SPEED_10MBPS
;
64 case ICE_AQ_LINK_SPEED_100MB
:
65 speed
= ICE_LINK_SPEED_100MBPS
;
67 case ICE_AQ_LINK_SPEED_1000MB
:
68 speed
= ICE_LINK_SPEED_1000MBPS
;
70 case ICE_AQ_LINK_SPEED_2500MB
:
71 speed
= ICE_LINK_SPEED_2500MBPS
;
73 case ICE_AQ_LINK_SPEED_5GB
:
74 speed
= ICE_LINK_SPEED_5000MBPS
;
76 case ICE_AQ_LINK_SPEED_10GB
:
77 speed
= ICE_LINK_SPEED_10000MBPS
;
79 case ICE_AQ_LINK_SPEED_20GB
:
80 speed
= ICE_LINK_SPEED_20000MBPS
;
82 case ICE_AQ_LINK_SPEED_25GB
:
83 speed
= ICE_LINK_SPEED_25000MBPS
;
85 case ICE_AQ_LINK_SPEED_40GB
:
86 speed
= ICE_LINK_SPEED_40000MBPS
;
88 case ICE_AQ_LINK_SPEED_50GB
:
89 speed
= ICE_LINK_SPEED_50000MBPS
;
91 case ICE_AQ_LINK_SPEED_100GB
:
92 speed
= ICE_LINK_SPEED_100000MBPS
;
95 speed
= ICE_LINK_SPEED_UNKNOWN
;
99 /* Virtchnl speeds are not defined for every speed supported in
100 * the hardware. To maintain compatibility with older AVF
101 * drivers, while reporting the speed the new speed values are
102 * resolved to the closest known virtchnl speeds
104 switch (link_speed
) {
105 case ICE_AQ_LINK_SPEED_10MB
:
106 case ICE_AQ_LINK_SPEED_100MB
:
107 speed
= (u32
)VIRTCHNL_LINK_SPEED_100MB
;
109 case ICE_AQ_LINK_SPEED_1000MB
:
110 case ICE_AQ_LINK_SPEED_2500MB
:
111 case ICE_AQ_LINK_SPEED_5GB
:
112 speed
= (u32
)VIRTCHNL_LINK_SPEED_1GB
;
114 case ICE_AQ_LINK_SPEED_10GB
:
115 speed
= (u32
)VIRTCHNL_LINK_SPEED_10GB
;
117 case ICE_AQ_LINK_SPEED_20GB
:
118 speed
= (u32
)VIRTCHNL_LINK_SPEED_20GB
;
120 case ICE_AQ_LINK_SPEED_25GB
:
121 speed
= (u32
)VIRTCHNL_LINK_SPEED_25GB
;
123 case ICE_AQ_LINK_SPEED_40GB
:
124 case ICE_AQ_LINK_SPEED_50GB
:
125 case ICE_AQ_LINK_SPEED_100GB
:
126 speed
= (u32
)VIRTCHNL_LINK_SPEED_40GB
;
129 speed
= (u32
)VIRTCHNL_LINK_SPEED_UNKNOWN
;