@@ -1234,6 +1234,39 @@ static void qed_iov_vf_mbx_acquire(struct qed_hwfn *p_hwfn,
12341234 sizeof (struct pfvf_acquire_resp_tlv ), vfpf_status );
12351235}
12361236
1237+ static int __qed_iov_spoofchk_set (struct qed_hwfn * p_hwfn ,
1238+ struct qed_vf_info * p_vf , bool val )
1239+ {
1240+ struct qed_sp_vport_update_params params ;
1241+ int rc ;
1242+
1243+ if (val == p_vf -> spoof_chk ) {
1244+ DP_VERBOSE (p_hwfn , QED_MSG_IOV ,
1245+ "Spoofchk value[%d] is already configured\n" , val );
1246+ return 0 ;
1247+ }
1248+
1249+ memset (& params , 0 , sizeof (struct qed_sp_vport_update_params ));
1250+ params .opaque_fid = p_vf -> opaque_fid ;
1251+ params .vport_id = p_vf -> vport_id ;
1252+ params .update_anti_spoofing_en_flg = 1 ;
1253+ params .anti_spoofing_en = val ;
1254+
1255+ rc = qed_sp_vport_update (p_hwfn , & params , QED_SPQ_MODE_EBLOCK , NULL );
1256+ if (rc ) {
1257+ p_vf -> spoof_chk = val ;
1258+ p_vf -> req_spoofchk_val = p_vf -> spoof_chk ;
1259+ DP_VERBOSE (p_hwfn , QED_MSG_IOV ,
1260+ "Spoofchk val[%d] configured\n" , val );
1261+ } else {
1262+ DP_VERBOSE (p_hwfn , QED_MSG_IOV ,
1263+ "Spoofchk configuration[val:%d] failed for VF[%d]\n" ,
1264+ val , p_vf -> relative_vf_id );
1265+ }
1266+
1267+ return rc ;
1268+ }
1269+
12371270static int qed_iov_reconfigure_unicast_vlan (struct qed_hwfn * p_hwfn ,
12381271 struct qed_vf_info * p_vf )
12391272{
@@ -1476,6 +1509,8 @@ static void qed_iov_vf_mbx_start_vport(struct qed_hwfn *p_hwfn,
14761509
14771510 /* Force configuration if needed on the newly opened vport */
14781511 qed_iov_configure_vport_forced (p_hwfn , vf , * p_bitmap );
1512+
1513+ __qed_iov_spoofchk_set (p_hwfn , vf , vf -> req_spoofchk_val );
14791514 }
14801515 qed_iov_prepare_resp (p_hwfn , p_ptt , vf , CHANNEL_TLV_VPORT_START ,
14811516 sizeof (struct pfvf_def_resp_tlv ), status );
@@ -1489,6 +1524,7 @@ static void qed_iov_vf_mbx_stop_vport(struct qed_hwfn *p_hwfn,
14891524 int rc ;
14901525
14911526 vf -> vport_instance -- ;
1527+ vf -> spoof_chk = false;
14921528
14931529 rc = qed_sp_vport_stop (p_hwfn , vf -> opaque_fid , vf -> vport_id );
14941530 if (rc != 0 ) {
@@ -2782,6 +2818,17 @@ void qed_iov_bulletin_set_forced_vlan(struct qed_hwfn *p_hwfn,
27822818 qed_iov_configure_vport_forced (p_hwfn , vf_info , feature );
27832819}
27842820
2821+ static bool qed_iov_vf_has_vport_instance (struct qed_hwfn * p_hwfn , int vfid )
2822+ {
2823+ struct qed_vf_info * p_vf_info ;
2824+
2825+ p_vf_info = qed_iov_get_vf_info (p_hwfn , (u16 ) vfid , true);
2826+ if (!p_vf_info )
2827+ return false;
2828+
2829+ return !!p_vf_info -> vport_instance ;
2830+ }
2831+
27852832bool qed_iov_is_vf_stopped (struct qed_hwfn * p_hwfn , int vfid )
27862833{
27872834 struct qed_vf_info * p_vf_info ;
@@ -2793,6 +2840,34 @@ bool qed_iov_is_vf_stopped(struct qed_hwfn *p_hwfn, int vfid)
27932840 return p_vf_info -> state == VF_STOPPED ;
27942841}
27952842
2843+ int qed_iov_spoofchk_set (struct qed_hwfn * p_hwfn , int vfid , bool val )
2844+ {
2845+ struct qed_vf_info * vf ;
2846+ int rc = - EINVAL ;
2847+
2848+ if (!qed_iov_pf_sanity_check (p_hwfn , vfid )) {
2849+ DP_NOTICE (p_hwfn ,
2850+ "SR-IOV sanity check failed, can't set spoofchk\n" );
2851+ goto out ;
2852+ }
2853+
2854+ vf = qed_iov_get_vf_info (p_hwfn , (u16 ) vfid , true);
2855+ if (!vf )
2856+ goto out ;
2857+
2858+ if (!qed_iov_vf_has_vport_instance (p_hwfn , vfid )) {
2859+ /* After VF VPORT start PF will configure spoof check */
2860+ vf -> req_spoofchk_val = val ;
2861+ rc = 0 ;
2862+ goto out ;
2863+ }
2864+
2865+ rc = __qed_iov_spoofchk_set (p_hwfn , vf , val );
2866+
2867+ out :
2868+ return rc ;
2869+ }
2870+
27962871static u8 * qed_iov_bulletin_get_forced_mac (struct qed_hwfn * p_hwfn ,
27972872 u16 rel_vf_id )
27982873{
@@ -3179,6 +3254,21 @@ static int qed_set_vf_link_state(struct qed_dev *cdev,
31793254 return 0 ;
31803255}
31813256
3257+ static int qed_spoof_configure (struct qed_dev * cdev , int vfid , bool val )
3258+ {
3259+ int i , rc = - EINVAL ;
3260+
3261+ for_each_hwfn (cdev , i ) {
3262+ struct qed_hwfn * p_hwfn = & cdev -> hwfns [i ];
3263+
3264+ rc = qed_iov_spoofchk_set (p_hwfn , vfid , val );
3265+ if (rc )
3266+ break ;
3267+ }
3268+
3269+ return rc ;
3270+ }
3271+
31823272static int qed_configure_max_vf_rate (struct qed_dev * cdev , int vfid , int rate )
31833273{
31843274 int i ;
@@ -3417,5 +3507,6 @@ const struct qed_iov_hv_ops qed_iov_ops_pass = {
34173507 .set_mac = & qed_sriov_pf_set_mac ,
34183508 .set_vlan = & qed_sriov_pf_set_vlan ,
34193509 .set_link_state = & qed_set_vf_link_state ,
3510+ .set_spoof = & qed_spoof_configure ,
34203511 .set_rate = & qed_set_vf_rate ,
34213512};
0 commit comments