@@ -470,10 +470,43 @@ static int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp)
470
470
return hwrm_send_message (bp , & req , sizeof (req ), HWRM_CMD_TIMEOUT );
471
471
}
472
472
473
+ /* Caller holds bp->hwrm_cmd_lock mutex lock */
474
+ static void __bnxt_set_vf_params (struct bnxt * bp , int vf_id )
475
+ {
476
+ struct hwrm_func_cfg_input req = {0 };
477
+ struct bnxt_vf_info * vf ;
478
+
479
+ vf = & bp -> pf .vf [vf_id ];
480
+ bnxt_hwrm_cmd_hdr_init (bp , & req , HWRM_FUNC_CFG , -1 , -1 );
481
+ req .fid = cpu_to_le16 (vf -> fw_fid );
482
+ req .flags = cpu_to_le32 (vf -> func_flags );
483
+
484
+ if (is_valid_ether_addr (vf -> mac_addr )) {
485
+ req .enables |= cpu_to_le32 (FUNC_CFG_REQ_ENABLES_DFLT_MAC_ADDR );
486
+ memcpy (req .dflt_mac_addr , vf -> mac_addr , ETH_ALEN );
487
+ }
488
+ if (vf -> vlan ) {
489
+ req .enables |= cpu_to_le32 (FUNC_CFG_REQ_ENABLES_DFLT_VLAN );
490
+ req .dflt_vlan = cpu_to_le16 (vf -> vlan );
491
+ }
492
+ if (vf -> max_tx_rate ) {
493
+ req .enables |= cpu_to_le32 (FUNC_CFG_REQ_ENABLES_MAX_BW );
494
+ req .max_bw = cpu_to_le32 (vf -> max_tx_rate );
495
+ #ifdef HAVE_IFLA_TX_RATE
496
+ req .enables |= cpu_to_le32 (FUNC_CFG_REQ_ENABLES_MIN_BW );
497
+ req .min_bw = cpu_to_le32 (vf -> min_tx_rate );
498
+ #endif
499
+ }
500
+ if (vf -> flags & BNXT_VF_TRUST )
501
+ req .flags |= cpu_to_le32 (FUNC_CFG_REQ_FLAGS_TRUSTED_VF_ENABLE );
502
+
503
+ _hwrm_send_message (bp , & req , sizeof (req ), HWRM_CMD_TIMEOUT );
504
+ }
505
+
473
506
/* Only called by PF to reserve resources for VFs, returns actual number of
474
507
* VFs configured, or < 0 on error.
475
508
*/
476
- static int bnxt_hwrm_func_vf_resc_cfg (struct bnxt * bp , int num_vfs )
509
+ static int bnxt_hwrm_func_vf_resc_cfg (struct bnxt * bp , int num_vfs , bool reset )
477
510
{
478
511
struct hwrm_func_vf_resource_cfg_input req = {0 };
479
512
struct bnxt_hw_resc * hw_resc = & bp -> hw_resc ;
@@ -545,6 +578,9 @@ static int bnxt_hwrm_func_vf_resc_cfg(struct bnxt *bp, int num_vfs)
545
578
546
579
mutex_lock (& bp -> hwrm_cmd_lock );
547
580
for (i = 0 ; i < num_vfs ; i ++ ) {
581
+ if (reset )
582
+ __bnxt_set_vf_params (bp , i );
583
+
548
584
req .vf_id = cpu_to_le16 (pf -> first_vf_id + i );
549
585
rc = _hwrm_send_message (bp , & req , sizeof (req ),
550
586
HWRM_CMD_TIMEOUT );
@@ -659,15 +695,15 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)
659
695
return rc ;
660
696
}
661
697
662
- static int bnxt_func_cfg (struct bnxt * bp , int num_vfs )
698
+ static int bnxt_func_cfg (struct bnxt * bp , int num_vfs , bool reset )
663
699
{
664
700
if (BNXT_NEW_RM (bp ))
665
- return bnxt_hwrm_func_vf_resc_cfg (bp , num_vfs );
701
+ return bnxt_hwrm_func_vf_resc_cfg (bp , num_vfs , reset );
666
702
else
667
703
return bnxt_hwrm_func_cfg (bp , num_vfs );
668
704
}
669
705
670
- int bnxt_cfg_hw_sriov (struct bnxt * bp , int * num_vfs )
706
+ int bnxt_cfg_hw_sriov (struct bnxt * bp , int * num_vfs , bool reset )
671
707
{
672
708
int rc ;
673
709
@@ -677,7 +713,7 @@ int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs)
677
713
return rc ;
678
714
679
715
/* Reserve resources for VFs */
680
- rc = bnxt_func_cfg (bp , * num_vfs );
716
+ rc = bnxt_func_cfg (bp , * num_vfs , reset );
681
717
if (rc != * num_vfs ) {
682
718
if (rc <= 0 ) {
683
719
netdev_warn (bp -> dev , "Unable to reserve resources for SRIOV.\n" );
@@ -758,7 +794,7 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs)
758
794
if (rc )
759
795
goto err_out1 ;
760
796
761
- rc = bnxt_cfg_hw_sriov (bp , num_vfs );
797
+ rc = bnxt_cfg_hw_sriov (bp , num_vfs , false );
762
798
if (rc )
763
799
goto err_out2 ;
764
800
@@ -1144,7 +1180,7 @@ int bnxt_approve_mac(struct bnxt *bp, u8 *mac, bool strict)
1144
1180
}
1145
1181
#else
1146
1182
1147
- int bnxt_cfg_hw_sriov (struct bnxt * bp , int * num_vfs )
1183
+ int bnxt_cfg_hw_sriov (struct bnxt * bp , int * num_vfs , bool reset )
1148
1184
{
1149
1185
if (* num_vfs )
1150
1186
return - EOPNOTSUPP ;
0 commit comments