@@ -121,6 +121,54 @@ int bnxt_set_vf_spoofchk(struct net_device *dev, int vf_id, bool setting)
121
121
return rc ;
122
122
}
123
123
124
+ static int bnxt_hwrm_func_qcfg_flags (struct bnxt * bp , struct bnxt_vf_info * vf )
125
+ {
126
+ struct hwrm_func_qcfg_output * resp = bp -> hwrm_cmd_resp_addr ;
127
+ struct hwrm_func_qcfg_input req = {0 };
128
+ int rc ;
129
+
130
+ bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_FUNC_QCFG , -1 , -1 );
131
+ req .fid = cpu_to_le16 (vf -> fw_fid );
132
+ mutex_lock (& bp -> hwrm_cmd_lock );
133
+ rc = _hwrm_send_message (bp , & req , sizeof (req ), HWRM_CMD_TIMEOUT );
134
+ if (rc ) {
135
+ mutex_unlock (& bp -> hwrm_cmd_lock );
136
+ return - EIO ;
137
+ }
138
+ vf -> func_qcfg_flags = le16_to_cpu (resp -> flags );
139
+ mutex_unlock (& bp -> hwrm_cmd_lock );
140
+ return 0 ;
141
+ }
142
+
143
+ static bool bnxt_is_trusted_vf (struct bnxt * bp , struct bnxt_vf_info * vf )
144
+ {
145
+ if (!(bp -> fw_cap & BNXT_FW_CAP_TRUSTED_VF ))
146
+ return !!(vf -> flags & BNXT_VF_TRUST );
147
+
148
+ bnxt_hwrm_func_qcfg_flags (bp , vf );
149
+ return !!(vf -> func_qcfg_flags & FUNC_QCFG_RESP_FLAGS_TRUSTED_VF );
150
+ }
151
+
152
+ static int bnxt_hwrm_set_trusted_vf (struct bnxt * bp , struct bnxt_vf_info * vf )
153
+ {
154
+ struct hwrm_func_cfg_input req = {0 };
155
+ int rc ;
156
+
157
+ if (!(bp -> fw_cap & BNXT_FW_CAP_TRUSTED_VF ))
158
+ return 0 ;
159
+
160
+ bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_FUNC_CFG , -1 , -1 );
161
+ req .fid = cpu_to_le16 (vf -> fw_fid );
162
+ if (vf -> flags & BNXT_VF_TRUST )
163
+ req .flags = cpu_to_le32 (FUNC_CFG_REQ_FLAGS_TRUSTED_VF_ENABLE );
164
+ else
165
+ req .flags = cpu_to_le32 (FUNC_CFG_REQ_FLAGS_TRUSTED_VF_DISABLE );
166
+ rc = hwrm_send_message (bp , & req , sizeof (req ), HWRM_CMD_TIMEOUT );
167
+ if (rc )
168
+ return - EIO ;
169
+ return 0 ;
170
+ }
171
+
124
172
int bnxt_set_vf_trust (struct net_device * dev , int vf_id , bool trusted )
125
173
{
126
174
struct bnxt * bp = netdev_priv (dev );
@@ -135,6 +183,7 @@ int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trusted)
135
183
else
136
184
vf -> flags &= ~BNXT_VF_TRUST ;
137
185
186
+ bnxt_hwrm_set_trusted_vf (bp , vf );
138
187
return 0 ;
139
188
}
140
189
@@ -164,7 +213,7 @@ int bnxt_get_vf_config(struct net_device *dev, int vf_id,
164
213
else
165
214
ivi -> qos = 0 ;
166
215
ivi -> spoofchk = !!(vf -> flags & BNXT_VF_SPOOFCHK );
167
- ivi -> trusted = !!( vf -> flags & BNXT_VF_TRUST );
216
+ ivi -> trusted = bnxt_is_trusted_vf ( bp , vf );
168
217
if (!(vf -> flags & BNXT_VF_LINK_FORCED ))
169
218
ivi -> linkstate = IFLA_VF_LINK_STATE_AUTO ;
170
219
else if (vf -> flags & BNXT_VF_LINK_UP )
@@ -935,9 +984,10 @@ static int bnxt_vf_configure_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
935
984
* if the PF assigned MAC address is zero
936
985
*/
937
986
if (req -> enables & cpu_to_le32 (FUNC_VF_CFG_REQ_ENABLES_DFLT_MAC_ADDR )) {
987
+ bool trust = bnxt_is_trusted_vf (bp , vf );
988
+
938
989
if (is_valid_ether_addr (req -> dflt_mac_addr ) &&
939
- ((vf -> flags & BNXT_VF_TRUST ) ||
940
- !is_valid_ether_addr (vf -> mac_addr ) ||
990
+ (trust || !is_valid_ether_addr (vf -> mac_addr ) ||
941
991
ether_addr_equal (req -> dflt_mac_addr , vf -> mac_addr ))) {
942
992
ether_addr_copy (vf -> vf_mac_addr , req -> dflt_mac_addr );
943
993
return bnxt_hwrm_exec_fwd_resp (bp , vf , msg_size );
@@ -962,7 +1012,7 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
962
1012
* Otherwise, it must match the VF MAC address if firmware spec >=
963
1013
* 1.2.2
964
1014
*/
965
- if (vf -> flags & BNXT_VF_TRUST ) {
1015
+ if (bnxt_is_trusted_vf ( bp , vf ) ) {
966
1016
mac_ok = true;
967
1017
} else if (is_valid_ether_addr (vf -> mac_addr )) {
968
1018
if (ether_addr_equal ((const u8 * )req -> l2_addr , vf -> mac_addr ))
0 commit comments