@@ -555,12 +555,9 @@ static u32 mlx5_gen_pci_id(const struct mlx5_core_dev *dev)
555
555
PCI_SLOT (dev -> pdev -> devfn ));
556
556
}
557
557
558
- static int next_phys_dev (struct device * dev , const void * data )
558
+ static int _next_phys_dev (struct mlx5_core_dev * mdev ,
559
+ const struct mlx5_core_dev * curr )
559
560
{
560
- struct mlx5_adev * madev = container_of (dev , struct mlx5_adev , adev .dev );
561
- struct mlx5_core_dev * mdev = madev -> mdev ;
562
- const struct mlx5_core_dev * curr = data ;
563
-
564
561
if (!mlx5_core_is_pf (mdev ))
565
562
return 0 ;
566
563
@@ -574,16 +571,37 @@ static int next_phys_dev(struct device *dev, const void *data)
574
571
return 1 ;
575
572
}
576
573
577
- /* Must be called with intf_mutex held */
578
- struct mlx5_core_dev * mlx5_get_next_phys_dev (struct mlx5_core_dev * dev )
574
+ static int next_phys_dev (struct device * dev , const void * data )
575
+ {
576
+ struct mlx5_adev * madev = container_of (dev , struct mlx5_adev , adev .dev );
577
+ struct mlx5_core_dev * mdev = madev -> mdev ;
578
+
579
+ return _next_phys_dev (mdev , data );
580
+ }
581
+
582
+ static int next_phys_dev_lag (struct device * dev , const void * data )
583
+ {
584
+ struct mlx5_adev * madev = container_of (dev , struct mlx5_adev , adev .dev );
585
+ struct mlx5_core_dev * mdev = madev -> mdev ;
586
+
587
+ if (!MLX5_CAP_GEN (mdev , vport_group_manager ) ||
588
+ !MLX5_CAP_GEN (mdev , lag_master ) ||
589
+ MLX5_CAP_GEN (mdev , num_lag_ports ) != MLX5_MAX_PORTS )
590
+ return 0 ;
591
+
592
+ return _next_phys_dev (mdev , data );
593
+ }
594
+
595
+ static struct mlx5_core_dev * mlx5_get_next_dev (struct mlx5_core_dev * dev ,
596
+ int (* match )(struct device * dev , const void * data ))
579
597
{
580
598
struct auxiliary_device * adev ;
581
599
struct mlx5_adev * madev ;
582
600
583
601
if (!mlx5_core_is_pf (dev ))
584
602
return NULL ;
585
603
586
- adev = auxiliary_find_device (NULL , dev , & next_phys_dev );
604
+ adev = auxiliary_find_device (NULL , dev , match );
587
605
if (!adev )
588
606
return NULL ;
589
607
@@ -592,6 +610,20 @@ struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev)
592
610
return madev -> mdev ;
593
611
}
594
612
613
+ /* Must be called with intf_mutex held */
614
+ struct mlx5_core_dev * mlx5_get_next_phys_dev (struct mlx5_core_dev * dev )
615
+ {
616
+ lockdep_assert_held (& mlx5_intf_mutex );
617
+ return mlx5_get_next_dev (dev , & next_phys_dev );
618
+ }
619
+
620
+ /* Must be called with intf_mutex held */
621
+ struct mlx5_core_dev * mlx5_get_next_phys_dev_lag (struct mlx5_core_dev * dev )
622
+ {
623
+ lockdep_assert_held (& mlx5_intf_mutex );
624
+ return mlx5_get_next_dev (dev , & next_phys_dev_lag );
625
+ }
626
+
595
627
void mlx5_dev_list_lock (void )
596
628
{
597
629
mutex_lock (& mlx5_intf_mutex );
0 commit comments