36
36
#include <linux/mlx5/vport.h>
37
37
#include <linux/mlx5/fs.h>
38
38
#include "mlx5_core.h"
39
+ #include "lib/eq.h"
39
40
#include "eswitch.h"
40
41
#include "fs_core.h"
41
42
#include "lib/eq.h"
@@ -1568,7 +1569,6 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
1568
1569
/* Mark this vport as disabled to discard new events */
1569
1570
vport -> enabled = false;
1570
1571
1571
- mlx5_eq_synchronize_async_irq (esw -> dev );
1572
1572
/* Wait for current already scheduled events to complete */
1573
1573
flush_workqueue (esw -> work_queue );
1574
1574
/* Disable events from this vport */
@@ -1594,10 +1594,25 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
1594
1594
mutex_unlock (& esw -> state_lock );
1595
1595
}
1596
1596
1597
+ static int eswitch_vport_event (struct notifier_block * nb ,
1598
+ unsigned long type , void * data )
1599
+ {
1600
+ struct mlx5_eswitch * esw = mlx5_nb_cof (nb , struct mlx5_eswitch , nb );
1601
+ struct mlx5_eqe * eqe = data ;
1602
+ struct mlx5_vport * vport ;
1603
+ u16 vport_num ;
1604
+
1605
+ vport_num = be16_to_cpu (eqe -> data .vport_change .vport_num );
1606
+ vport = & esw -> vports [vport_num ];
1607
+ if (vport -> enabled )
1608
+ queue_work (esw -> work_queue , & vport -> vport_change_handler );
1609
+
1610
+ return NOTIFY_OK ;
1611
+ }
1612
+
1597
1613
/* Public E-Switch API */
1598
1614
#define ESW_ALLOWED (esw ) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
1599
1615
1600
-
1601
1616
int mlx5_eswitch_enable_sriov (struct mlx5_eswitch * esw , int nvfs , int mode )
1602
1617
{
1603
1618
int err ;
@@ -1641,6 +1656,11 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
1641
1656
for (i = 0 ; i <= nvfs ; i ++ )
1642
1657
esw_enable_vport (esw , i , enabled_events );
1643
1658
1659
+ if (mode == SRIOV_LEGACY ) {
1660
+ MLX5_NB_INIT (& esw -> nb , eswitch_vport_event , NIC_VPORT_CHANGE );
1661
+ mlx5_eq_notifier_register (esw -> dev , & esw -> nb );
1662
+ }
1663
+
1644
1664
esw_info (esw -> dev , "SRIOV enabled: active vports(%d)\n" ,
1645
1665
esw -> enabled_vports );
1646
1666
return 0 ;
@@ -1670,6 +1690,9 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
1670
1690
mc_promisc = & esw -> mc_promisc ;
1671
1691
nvports = esw -> enabled_vports ;
1672
1692
1693
+ if (esw -> mode == SRIOV_LEGACY )
1694
+ mlx5_eq_notifier_unregister (esw -> dev , & esw -> nb );
1695
+
1673
1696
for (i = 0 ; i < esw -> total_vports ; i ++ )
1674
1697
esw_disable_vport (esw , i );
1675
1698
@@ -1778,23 +1801,6 @@ void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
1778
1801
kfree (esw );
1779
1802
}
1780
1803
1781
- void mlx5_eswitch_vport_event (struct mlx5_eswitch * esw , struct mlx5_eqe * eqe )
1782
- {
1783
- struct mlx5_eqe_vport_change * vc_eqe = & eqe -> data .vport_change ;
1784
- u16 vport_num = be16_to_cpu (vc_eqe -> vport_num );
1785
- struct mlx5_vport * vport ;
1786
-
1787
- if (!esw ) {
1788
- pr_warn ("MLX5 E-Switch: vport %d got an event while eswitch is not initialized\n" ,
1789
- vport_num );
1790
- return ;
1791
- }
1792
-
1793
- vport = & esw -> vports [vport_num ];
1794
- if (vport -> enabled )
1795
- queue_work (esw -> work_queue , & vport -> vport_change_handler );
1796
- }
1797
-
1798
1804
/* Vport Administration */
1799
1805
#define LEGAL_VPORT (esw , vport ) (vport >= 0 && vport < esw->total_vports)
1800
1806
0 commit comments