aboutsummaryrefslogblamecommitdiffstats
path: root/net/core/devlink.c
blob: 4c63c9a4c09e62fdc8b428ae5a990feb329c47f6 (plain) (tree)
1
2
3
4
5
6
7
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
                                            





                                                                        









                            
                           
                           
                            

                                 






                              
                             


                                 

                                                                     
                                          













                                                                  
















                                                                 
















                                                                 
                                            
                                            










                                                                  
                                                      


                                         
                               
 
                                                                       



                                        







                                                              












                                                                           

                                            















                                                                              
                                                                              









                                                                      

                                                              
























                                                                                





























































































































































                                                                                









                                       



                                                      



                 











                                                                            











                                                                        

                                              
                                              





                                                                    




                                                                           
                






                                              

                                                           


                                                                     

                                                  

                                                                         

                                                    
                 
                                                 
         




                                                                     

                                                  


                                               
                 





                                                           




                                                                             

                                









                                                                               
                                             


                                     
                                            





























                                                                                

                                                                                





























                                                                             






                                                                       

                                                                        

                                              


                                                                     

                                         




                                                                     

















                                                                            
         


                 














                                                                             
 
                                               
                                                                         
                                                 


                                                                     
                                                 







                                                                       
                                                         






                                                                     
                                                         
         
                                                 
                                                         




                                     
                            
                                                 



















































































                                                                               

                                                              



























                                                                       


                                                                     
                                           









                                                                              

                                                             
                                         
                         

                              
                                             

         












                                                                   
                                          

                                                          

                                                    












                                                                           

                                                              












                                                                              

                                                                        

 
                                     

                                                                           















                                                                        
                                                                            

 

                                                                        

 
                                       
                                                                               












                                                                       
                                                                       

 









































































                                                                            
                                           









                                                                            

                                                             
                                         
                         

                              
                                             






































                                                                                


                                                            






















                                                                   
                                       

















































                                                                           
                    



                                                                       
                                               
                                 
                                           




                                                                              

                                                             
                                         
                         
                 
                                             



                                     


                             





                                                                              

                                                                             



                                                     
                             
                                                                      
                                                                      


























                                                                      

                                                                    









                                                                          
                                                     



                      

                                                                    

















                                                                            















                                                                                






















                                                                       
                                            























































                                                                                        
                    

                                   

                                                                       
                                                    
                                 
                                           




                                                                                   

                                                             
                                         
                         
                 
                                             

         

                                     


                             





                                                                          

                                                                   



                                                                   
                                  
                                                                    
                                                                            





















                                                                        
                                                                             









                                                                             
                                                     




                       


                                                                       





















                                                                            

















                                                                           



























                                                                          
                                               













































































                                                                                              
                    

                                   

                                                                       
                                                       
                                 

                                           





                                                                                      

                                                             
                                         
                         
                 
                                             

         

                                     


                             






                                                                           

                                                                      



                                                                   
                                     

                                                                       
                                                                               

































                                                                           
                                                                                

 






                                                                      
                                 










                                                                        
                                  



                                                                         


                                                                                
 
                                                     

                                                   
                  

                    




                                                                            

                                                  
                                     
 







                                                                        



                                                                          
                                             


                                                                       
                                             
         
 








                                                                                   


                              
                
                                 
                   

 

                                                                  

                                                    
                            

                



                                                        

                                                                            








                                        

                                                                  


                                                     

                                                   
                    
                 
 



                                                                           
                                                                         


                                   
 




                                                                               

                                                                        


                                   




                                                                                      

                                                                      



                                   









                                                                             
                                                                          























                                                                                     

                                                                               




















                                                                              
                                                                            























                                                                                      

                                                                               

















                                                                     
                       
 
                                                             
                                                                          



                                                                              
                                                                             





                                                                      
                                    




                                                                                   
         





















































                                                                         

                                
                                 
         


                                                
                                                                            


































                                                                          
                                   







                                        























































                                                                                  

                                                                                     


































                                                                             

                                                                                   



















                                                                     
                                                                          










                                                                                

                                                                                    










                                                                        

                                                                                     









                                                                          
 
                                      
                 










































                                                                            

                                                                           




                                     



















                                                                           





















                                                                         















                                                                          
                           






                                                                            
                                   


                                                 

































                                                                              

                                                                             





















                                                                                                 
                                                                            
                         






                                                                                

                                                                              






































                                                                          

                                
                                 
         


                                                
                                                                              























                                                                               
                                   






                                        





















































                                                                                               

 
                                























                                                                         

                                                                     










                                                                           
                                            




                                          






                                                                           
                                                    



                                                                       
                                                    



                                                                        
                                                                               







                                                                

















                                                                         
                                                                    
                                                                           









                                                                     
          




                                                                   
                                             








                                                                                 

 









                                                                           






                                                                             
                                                                          











                                                                              

                                                    

                                                            






                                                             

                                                                                

















































                                                                             

                                                                           
























                                                                           
                                   






                                        














                                                                         






















                                                                          

























































                                                                                                
                                             






                                                                   




                                                                    














                                                              




                                                                        


                                     











                                                                     


                                                                             
                                    

                
                                                                           






                                                                                     













                                                              
                   

 





































































































                                                                                




















                                                                               










                                                                 




                                                                




                                                                   




                                                              




                                                                       




                                                                       




                                                                  




                                                                          




                                                               
  







































                                                                          










                                                                    















                                                                   








                                                                


























                                                                  

                                                                           








































                                                                              
                                                         




                                                                           
                                                               

















                                                                         

                                                   





                                                                      
                                          







                                                                            
 


                                                


                                                                          
                                                                    












                                                                            

                                                                                  



                                                        
                                        




















                                                                         
                                                         
                                                         





                                                                       


                                                                               



                                                        

                                                                              








                                                                          






                                                                       
                    










                                                                             
                                                                                



                                                                               
                                                        









                                                             


                             



                          


































                                                                     

                














                                                                                      


                                                                                   
                                                            
                                       

                                                                             








                                                                           
                                  
                                                         







                                                                    
                                                                  









                                                                
                                                                             






                                                        
                                                                









                                                                        
                                                                   
                                                                   


                                                                        
 







                                              
                                                                   























                                                                               



                                                                              










                                                              
                                                                   


                 




                                                                
                                                                                


                                                                            
                                                              
                                                              
                                                                   

                                                                        


                                              
                                                                











                                                                           
                                                     
                                                                   



                                                                 
                                                                 
                                                                      

                                                                           


                                              
                                                                         
                             
                                                                   



                                    







                                                                            
                    



















                                                                                
                                                                










                                                                     


                             
































                                                                           





                                                                     


                                                                               

 






                                                                               
                                                                             






















                                                                              

                                                                              
















                                                                                

























                                                                               



                                                                       







                                 



















































                                                                                









                                                                           






































































                                                                                























                                                                                
                                                      


                 







                                                                           
                                                                           










































                                                                              

                                              


























                                                                              
                                                                   
                                                     
                                            









                                              
                                   
                                                                       

                                       
                             
         
 


                                               

                                                      
                                
         


                                                                  

                              
                                
         



                                                                              

                                
                                
         








                                                                         
                                                                             

                                
                                     
         





















                                                                                   

                                         
                                     
         













                                            
        
                                     
                   

 















                                                                                






                                                                           
                                                     
















































                                                                               




































                                                                            
                                    






















                                                                      
                    









                                                                     




                                              





                                                                              
                                              




                                     


                             



                          





































































































































































































                                                                                

                                                                                


                                                                          










































































































                                                                             
                                                                  
 

                      

                
                                                           


                           







                                                                               
 
                                                   




























































                                                                               
                                                                    





















































































                                                                                
 
                                        





                        




























                                                                              




                                                      

                                                                                


                            
                    
                         


                             
                            

  












                                                                      
                                                      






















                                                                             
                                             





















                                                                       
                                         
                                             

                                                                
                                               











                                                                         
                                                       
                                  


                                                         
                                            

                                                       



                                                   
















                                                                               

                                                                         
                                                                               


                


                                                                            


                                    
                                                                 



















                                                                           

                                                                 



















                                                                
                                                    







                                                             
                                                     










                                                                   
                                                             





                                                                       

                                                                     


                                                          
                                                                          













                                                                                 
                                                         


                                           

                                                                       




                                         
                                       

                                                               
 
                                                 

                            
                                                      

                            
                                                                           







                                                                                









                                                                            
                                                                   
                                                 
                                            
                                







                                                                          


                                     


                    



                                                                     


















                                                                            

                                                                            







                                                                  
                                                                          

                                                                       
                                                                              

                                                                          

                                                                                


                                                        

                                                                      






                                                                        



                                                                           
























                                                                          



                              






                                                                              
                         

         



                                              















                                                                      
                                                     












                                                                                              
                                                                       



                                         
                                                       







                                     





                                                               
                






                                                                         



                                                                       








                                                                                               
                                              
                 


                                              

 




                                                                              
                




                                                                        
                                                                            


                                              

 











                                                                               

                                                      
                                   
         

                                    

                                                      
                               
         




                                                
                                                                    











                                                                        
                                              


                   


                                                                           
 
                                                 
                                

                
                                                           


                               
                                   

                                  
         
                                         
                     
                                                                         








                                                                              
 


                                                                        
                                           
    
                                              













                                                                        

                                                      
                                   
         



                                            
                                              


                 




















































































































































































































































































































































































































































































































































































                                                                                               





                                                                          






                                                                   
                                                          
                                                                
                                                               

                                                                         

                                                          


                                                               
                                                                
                                                                
                                                                         

                                                                             

                                                                           


                                                                    


                                                       




                                                 
                                                                                

                                                    
                                                               



                                                            
                                                                                

                                                         




                                                            
                                                                                
                                                     




                                                            
                                                                                
                                                       
                                         

                                                                


                                                
                                                                                
                                                         
                                         

                                                                
          

                                          
                                                                                

                                                       





                                                                
                                                                                

                                                            





                                                                
                                                                                
                                                        





                                                                
                                                                                

                                                                 





                                                             
                                                                                
                                                             





                                                             
                                                                                

                                                                    





                                                             
                                                                                
                                                                



                                                             

                                                   
                                                                                
                                                            

                                                                
                                                          


                                                    
                                                                                
                                                             

                                                                
                                                          
          
         
                                               
                                                                                
                                                        



                                                               
                                               
                                                                                
                                                        
                                         

                                                                
          

                                                   
                                                                                
                                                       
                                                               
                                                            


                                                     
                                                                                
                                                         
                                                               
                                                            


                                                     
                                                                                
                                                         
                                                               
                                                            


                                                            
                                                                                
                                                                


                                                               

                                                
                                                                                
                                                    




                                                               
                                                                                
                                                     
                                                               
                                                            
          

                                          
                                                                                
                                              



                                                                

                                             
                                                                                

                                                          


                                                               

                                             
                                                                                
                                                      


                                                               
         
                                                  
                                                                                

                                                               



                                                            
                                                  
                                                                                
                                                           



                                                            
                                              
                                                                                

                                                           


                                                               

                                              
                                                                                
                                                  


                                                               

                                               

                                                           
                                                            


                                                               

                                            
                                                                                

                                                         


                                                               

                                                       
                                                                                

                                                                    

                                                                

                                                            

                                                       
                                                                                
                                                                
                                         

                                                                
          

                                                           
                                                                                
                                                                    
                                         

                                                                
          

                                                            
                                                                                
                                                                     
                                         

                                                                
          

                                                            

                                                           
                                                                         





                                                                
                                                                                
                                                                       



                                                                

                                                
                                                                                
                                                    


                                                               

























                                                               

  
                                                               


                                               
                                    









                                                        












                                                                              


                            



                                                                    
                                              
                                            
                                          
                                                       
                                                
                                             
                                              
                                                

                                                  
                                   
                                             







                                                    
                           




                                                                 
                                   














                                                        

                                                    






                                                 


































                                                                      





                                                      
                                                
                                      

                                                        







                                                         



                                































                                                                              




                                                     
                                                                     










                                                                          
                                   
                                                             
                                             



                                         
                                        
                                                 
                                                                
                                                  
                                     

                                                                                











                                                                

                                                        
                                                    
                                                                
                                   
                                      
                                     






                                                                      

                                               
                                                    
                                               

                                          
                                                 











                                                                 

                                                              



                                                                       
                                          





                                                                         





                                                                              












                                                                         
                                                                             











                                                                
                                                                           









                                                               
                                                                              
                                                      


                                           






















                                                                      
   
                                                    

                                   
                                     




                                                                         


                                                                          
   
                                                              
                                                              
                                                        


                                                           
 
                                                                
                
 


                                                                 
                       
                             

                                                                
 
                                          
 

























                                                                          



























                                                                          

                                                                               









                                                                
                                                                                
                    


                                                                       







                                                                          


                                                                  



                                                                 






                               
 







                                                                       
                                   

















                                                              
                                     







                                                                          
                                   


                                                                
                                     



                                         










                                                                               
                                   
                                               
                                     












                                                                   
                                   
                                      
                                     








































                                                                         




                                                                           
                                                                         





                                                                             


                                          






                                                    

                                                               
                                   
                                                                    
                                     














                                                               
                                   




                                                                    
                                     


                              
                                     


                                                  




                                                             

                                       

                                                 


                                                        


                                                     
                                                                                     


                                          
                           

                    

                                                                             























                                                                            
                                        








                                           
                                    

                                                   


































































                                                                            






























                                                                              



















































                                                                           










                                                                  
                                                             

                                                                        


                                                                    






                                                     

                                                  
                                      
 

                                                                             










                                          

                                                                             



                                     

                                                                
                                                                

                                                                           

                                                                 





                                                   

                                                                           















                                                                      



                                                                          
 











                                                                       


                                                                            


                                             
   









































                                                                     












                                                                             
                                                             
                                                                           


                                                                     















                                                                       
                                                               
                                                                     

                                                                       


                                                  


                                                                                


                                              
                                                                    







                                                                              



                                                                          


                 
 

                                                             
                                                             



















                                                                                
                                                                   


                 













                                                                             
                                               




                                                                         
















                                                                              
                                                               


                                                                           


                                                      
   















                                                                                
                                               







                                                                              















                                                                               
                                                                        
                                                                              

                                                                                



                                                           









                                                                             







                                                                              
                                                                            


                                               
   


























                                                                               
















                                                                               

































                                                                               
                                                                       

















                                                          
                                               

                                   


                                                                            
                                                              
 
                                

                                                                       




                                          




















                                                                  







                                                                      
                                               



                                                                     
                                                                 




























                                                                                 





                                                               
                                                                           








                                                  







                                                                               








                                                 








                                                              





                                                       








                                                                               


                                         























































































































































































































































































































































































































































                                                                               







                                                                     






























                                                                            

                                


                      
                                         
                                                
                         



                                                            
 
    

                     

 

                                                                              
                                
                
 


                      
                                         



                                                      
 


                                                                         
 
    


                     
                   

 

















                                                                          




                                                                  

                                                                                

                                                                  








                                                                    













                                                                        
                                                      









                                                                                             
                                    
 









                                                          

 
                              
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * net/core/devlink.c - Network physical/parent device Netlink interface
 *
 * Heavily inspired by net/wireless/
 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
 * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/gfp.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <linux/refcount.h>
#include <linux/workqueue.h>
#include <linux/u64_stats_sync.h>
#include <linux/timekeeping.h>
#include <rdma/ib_verbs.h>
#include <net/netlink.h>
#include <net/genetlink.h>
#include <net/rtnetlink.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/devlink.h>
#include <net/drop_monitor.h>
#define CREATE_TRACE_POINTS
#include <trace/events/devlink.h>

static struct devlink_dpipe_field devlink_dpipe_fields_ethernet[] = {
	{
		.name = "destination mac",
		.id = DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,
		.bitwidth = 48,
	},
};

struct devlink_dpipe_header devlink_dpipe_header_ethernet = {
	.name = "ethernet",
	.id = DEVLINK_DPIPE_HEADER_ETHERNET,
	.fields = devlink_dpipe_fields_ethernet,
	.fields_count = ARRAY_SIZE(devlink_dpipe_fields_ethernet),
	.global = true,
};
EXPORT_SYMBOL(devlink_dpipe_header_ethernet);

static struct devlink_dpipe_field devlink_dpipe_fields_ipv4[] = {
	{
		.name = "destination ip",
		.id = DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
		.bitwidth = 32,
	},
};

struct devlink_dpipe_header devlink_dpipe_header_ipv4 = {
	.name = "ipv4",
	.id = DEVLINK_DPIPE_HEADER_IPV4,
	.fields = devlink_dpipe_fields_ipv4,
	.fields_count = ARRAY_SIZE(devlink_dpipe_fields_ipv4),
	.global = true,
};
EXPORT_SYMBOL(devlink_dpipe_header_ipv4);

static struct devlink_dpipe_field devlink_dpipe_fields_ipv6[] = {
	{
		.name = "destination ip",
		.id = DEVLINK_DPIPE_FIELD_IPV6_DST_IP,
		.bitwidth = 128,
	},
};

struct devlink_dpipe_header devlink_dpipe_header_ipv6 = {
	.name = "ipv6",
	.id = DEVLINK_DPIPE_HEADER_IPV6,
	.fields = devlink_dpipe_fields_ipv6,
	.fields_count = ARRAY_SIZE(devlink_dpipe_fields_ipv6),
	.global = true,
};
EXPORT_SYMBOL(devlink_dpipe_header_ipv6);

EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwmsg);
EXPORT_TRACEPOINT_SYMBOL_GPL(devlink_hwerr);

static LIST_HEAD(devlink_list);

/* devlink_mutex
 *
 * An overall lock guarding every operation coming from userspace.
 * It also guards devlink devices list and it is taken when
 * driver registers/unregisters it.
 */
static DEFINE_MUTEX(devlink_mutex);

struct net *devlink_net(const struct devlink *devlink)
{
	return read_pnet(&devlink->_net);
}
EXPORT_SYMBOL_GPL(devlink_net);

static void __devlink_net_set(struct devlink *devlink, struct net *net)
{
	write_pnet(&devlink->_net, net);
}

void devlink_net_set(struct devlink *devlink, struct net *net)
{
	if (WARN_ON(devlink->registered))
		return;
	__devlink_net_set(devlink, net);
}
EXPORT_SYMBOL_GPL(devlink_net_set);

static struct devlink *devlink_get_from_attrs(struct net *net,
					      struct nlattr **attrs)
{
	struct devlink *devlink;
	char *busname;
	char *devname;

	if (!attrs[DEVLINK_ATTR_BUS_NAME] || !attrs[DEVLINK_ATTR_DEV_NAME])
		return ERR_PTR(-EINVAL);

	busname = nla_data(attrs[DEVLINK_ATTR_BUS_NAME]);
	devname = nla_data(attrs[DEVLINK_ATTR_DEV_NAME]);

	lockdep_assert_held(&devlink_mutex);

	list_for_each_entry(devlink, &devlink_list, list) {
		if (strcmp(devlink->dev->bus->name, busname) == 0 &&
		    strcmp(dev_name(devlink->dev), devname) == 0 &&
		    net_eq(devlink_net(devlink), net))
			return devlink;
	}

	return ERR_PTR(-ENODEV);
}

static struct devlink *devlink_get_from_info(struct genl_info *info)
{
	return devlink_get_from_attrs(genl_info_net(info), info->attrs);
}

static struct devlink_port *devlink_port_get_by_index(struct devlink *devlink,
						      unsigned int port_index)
{
	struct devlink_port *devlink_port;

	list_for_each_entry(devlink_port, &devlink->port_list, list) {
		if (devlink_port->index == port_index)
			return devlink_port;
	}
	return NULL;
}

static bool devlink_port_index_exists(struct devlink *devlink,
				      unsigned int port_index)
{
	return devlink_port_get_by_index(devlink, port_index);
}

static struct devlink_port *devlink_port_get_from_attrs(struct devlink *devlink,
							struct nlattr **attrs)
{
	if (attrs[DEVLINK_ATTR_PORT_INDEX]) {
		u32 port_index = nla_get_u32(attrs[DEVLINK_ATTR_PORT_INDEX]);
		struct devlink_port *devlink_port;

		devlink_port = devlink_port_get_by_index(devlink, port_index);
		if (!devlink_port)
			return ERR_PTR(-ENODEV);
		return devlink_port;
	}
	return ERR_PTR(-EINVAL);
}

static struct devlink_port *devlink_port_get_from_info(struct devlink *devlink,
						       struct genl_info *info)
{
	return devlink_port_get_from_attrs(devlink, info->attrs);
}

struct devlink_sb {
	struct list_head list;
	unsigned int index;
	u32 size;
	u16 ingress_pools_count;
	u16 egress_pools_count;
	u16 ingress_tc_count;
	u16 egress_tc_count;
};

static u16 devlink_sb_pool_count(struct devlink_sb *devlink_sb)
{
	return devlink_sb->ingress_pools_count + devlink_sb->egress_pools_count;
}

static struct devlink_sb *devlink_sb_get_by_index(struct devlink *devlink,
						  unsigned int sb_index)
{
	struct devlink_sb *devlink_sb;

	list_for_each_entry(devlink_sb, &devlink->sb_list, list) {
		if (devlink_sb->index == sb_index)
			return devlink_sb;
	}
	return NULL;
}

static bool devlink_sb_index_exists(struct devlink *devlink,
				    unsigned int sb_index)
{
	return devlink_sb_get_by_index(devlink, sb_index);
}

static struct devlink_sb *devlink_sb_get_from_attrs(struct devlink *devlink,
						    struct nlattr **attrs)
{
	if (attrs[DEVLINK_ATTR_SB_INDEX]) {
		u32 sb_index = nla_get_u32(attrs[DEVLINK_ATTR_SB_INDEX]);
		struct devlink_sb *devlink_sb;

		devlink_sb = devlink_sb_get_by_index(devlink, sb_index);
		if (!devlink_sb)
			return ERR_PTR(-ENODEV);
		return devlink_sb;
	}
	return ERR_PTR(-EINVAL);
}

static struct devlink_sb *devlink_sb_get_from_info(struct devlink *devlink,
						   struct genl_info *info)
{
	return devlink_sb_get_from_attrs(devlink, info->attrs);
}

static int devlink_sb_pool_index_get_from_attrs(struct devlink_sb *devlink_sb,
						struct nlattr **attrs,
						u16 *p_pool_index)
{
	u16 val;

	if (!attrs[DEVLINK_ATTR_SB_POOL_INDEX])
		return -EINVAL;

	val = nla_get_u16(attrs[DEVLINK_ATTR_SB_POOL_INDEX]);
	if (val >= devlink_sb_pool_count(devlink_sb))
		return -EINVAL;
	*p_pool_index = val;
	return 0;
}

static int devlink_sb_pool_index_get_from_info(struct devlink_sb *devlink_sb,
					       struct genl_info *info,
					       u16 *p_pool_index)
{
	return devlink_sb_pool_index_get_from_attrs(devlink_sb, info->attrs,
						    p_pool_index);
}

static int
devlink_sb_pool_type_get_from_attrs(struct nlattr **attrs,
				    enum devlink_sb_pool_type *p_pool_type)
{
	u8 val;

	if (!attrs[DEVLINK_ATTR_SB_POOL_TYPE])
		return -EINVAL;

	val = nla_get_u8(attrs[DEVLINK_ATTR_SB_POOL_TYPE]);
	if (val != DEVLINK_SB_POOL_TYPE_INGRESS &&
	    val != DEVLINK_SB_POOL_TYPE_EGRESS)
		return -EINVAL;
	*p_pool_type = val;
	return 0;
}

static int
devlink_sb_pool_type_get_from_info(struct genl_info *info,
				   enum devlink_sb_pool_type *p_pool_type)
{
	return devlink_sb_pool_type_get_from_attrs(info->attrs, p_pool_type);
}

static int
devlink_sb_th_type_get_from_attrs(struct nlattr **attrs,
				  enum devlink_sb_threshold_type *p_th_type)
{
	u8 val;

	if (!attrs[DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE])
		return -EINVAL;

	val = nla_get_u8(attrs[DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE]);
	if (val != DEVLINK_SB_THRESHOLD_TYPE_STATIC &&
	    val != DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC)
		return -EINVAL;
	*p_th_type = val;
	return 0;
}

static int
devlink_sb_th_type_get_from_info(struct genl_info *info,
				 enum devlink_sb_threshold_type *p_th_type)
{
	return devlink_sb_th_type_get_from_attrs(info->attrs, p_th_type);
}

static int
devlink_sb_tc_index_get_from_attrs(struct devlink_sb *devlink_sb,
				   struct nlattr **attrs,
				   enum devlink_sb_pool_type pool_type,
				   u16 *p_tc_index)
{
	u16 val;

	if (!attrs[DEVLINK_ATTR_SB_TC_INDEX])
		return -EINVAL;

	val = nla_get_u16(attrs[DEVLINK_ATTR_SB_TC_INDEX]);
	if (pool_type == DEVLINK_SB_POOL_TYPE_INGRESS &&
	    val >= devlink_sb->ingress_tc_count)
		return -EINVAL;
	if (pool_type == DEVLINK_SB_POOL_TYPE_EGRESS &&
	    val >= devlink_sb->egress_tc_count)
		return -EINVAL;
	*p_tc_index = val;
	return 0;
}

static int
devlink_sb_tc_index_get_from_info(struct devlink_sb *devlink_sb,
				  struct genl_info *info,
				  enum devlink_sb_pool_type pool_type,
				  u16 *p_tc_index)
{
	return devlink_sb_tc_index_get_from_attrs(devlink_sb, info->attrs,
						  pool_type, p_tc_index);
}

struct devlink_region {
	struct devlink *devlink;
	struct list_head list;
	const char *name;
	struct list_head snapshot_list;
	u32 max_snapshots;
	u32 cur_snapshots;
	u64 size;
};

struct devlink_snapshot {
	struct list_head list;
	struct devlink_region *region;
	devlink_snapshot_data_dest_t *data_destructor;
	u8 *data;
	u32 id;
};

static struct devlink_region *
devlink_region_get_by_name(struct devlink *devlink, const char *region_name)
{
	struct devlink_region *region;

	list_for_each_entry(region, &devlink->region_list, list)
		if (!strcmp(region->name, region_name))
			return region;

	return NULL;
}

static struct devlink_snapshot *
devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id)
{
	struct devlink_snapshot *snapshot;

	list_for_each_entry(snapshot, &region->snapshot_list, list)
		if (snapshot->id == id)
			return snapshot;

	return NULL;
}

#define DEVLINK_NL_FLAG_NEED_DEVLINK	BIT(0)
#define DEVLINK_NL_FLAG_NEED_PORT	BIT(1)
#define DEVLINK_NL_FLAG_NEED_SB		BIT(2)

/* The per devlink instance lock is taken by default in the pre-doit
 * operation, yet several commands do not require this. The global
 * devlink lock is taken and protects from disruption by user-calls.
 */
#define DEVLINK_NL_FLAG_NO_LOCK		BIT(3)

static int devlink_nl_pre_doit(const struct genl_ops *ops,
			       struct sk_buff *skb, struct genl_info *info)
{
	struct devlink *devlink;
	int err;

	mutex_lock(&devlink_mutex);
	devlink = devlink_get_from_info(info);
	if (IS_ERR(devlink)) {
		mutex_unlock(&devlink_mutex);
		return PTR_ERR(devlink);
	}
	if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
		mutex_lock(&devlink->lock);
	if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK) {
		info->user_ptr[0] = devlink;
	} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) {
		struct devlink_port *devlink_port;

		devlink_port = devlink_port_get_from_info(devlink, info);
		if (IS_ERR(devlink_port)) {
			err = PTR_ERR(devlink_port);
			goto unlock;
		}
		info->user_ptr[0] = devlink_port;
	}
	if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_SB) {
		struct devlink_sb *devlink_sb;

		devlink_sb = devlink_sb_get_from_info(devlink, info);
		if (IS_ERR(devlink_sb)) {
			err = PTR_ERR(devlink_sb);
			goto unlock;
		}
		info->user_ptr[1] = devlink_sb;
	}
	return 0;

unlock:
	if (~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
		mutex_unlock(&devlink->lock);
	mutex_unlock(&devlink_mutex);
	return err;
}

static void devlink_nl_post_doit(const struct genl_ops *ops,
				 struct sk_buff *skb, struct genl_info *info)
{
	struct devlink *devlink;

	/* When devlink changes netns, it would not be found
	 * by devlink_get_from_info(). So try if it is stored first.
	 */
	if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK) {
		devlink = info->user_ptr[0];
	} else {
		devlink = devlink_get_from_info(info);
		WARN_ON(IS_ERR(devlink));
	}
	if (!IS_ERR(devlink) && ~ops->internal_flags & DEVLINK_NL_FLAG_NO_LOCK)
		mutex_unlock(&devlink->lock);
	mutex_unlock(&devlink_mutex);
}

static struct genl_family devlink_nl_family;

enum devlink_multicast_groups {
	DEVLINK_MCGRP_CONFIG,
};

static const struct genl_multicast_group devlink_nl_mcgrps[] = {
	[DEVLINK_MCGRP_CONFIG] = { .name = DEVLINK_GENL_MCGRP_CONFIG_NAME },
};

static int devlink_nl_put_handle(struct sk_buff *msg, struct devlink *devlink)
{
	if (nla_put_string(msg, DEVLINK_ATTR_BUS_NAME, devlink->dev->bus->name))
		return -EMSGSIZE;
	if (nla_put_string(msg, DEVLINK_ATTR_DEV_NAME, dev_name(devlink->dev)))
		return -EMSGSIZE;
	return 0;
}

static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink,
			   enum devlink_command cmd, u32 portid,
			   u32 seq, int flags)
{
	void *hdr;

	hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
	if (!hdr)
		return -EMSGSIZE;

	if (devlink_nl_put_handle(msg, devlink))
		goto nla_put_failure;
	if (nla_put_u8(msg, DEVLINK_ATTR_RELOAD_FAILED, devlink->reload_failed))
		goto nla_put_failure;

	genlmsg_end(msg, hdr);
	return 0;

nla_put_failure:
	genlmsg_cancel(msg, hdr);
	return -EMSGSIZE;
}

static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
{
	struct sk_buff *msg;
	int err;

	WARN_ON(cmd != DEVLINK_CMD_NEW && cmd != DEVLINK_CMD_DEL);

	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
	if (!msg)
		return;

	err = devlink_nl_fill(msg, devlink, cmd, 0, 0, 0);
	if (err) {
		nlmsg_free(msg);
		return;
	}

	genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink),
				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
}

static int devlink_nl_port_attrs_put(struct sk_buff *msg,
				     struct devlink_port *devlink_port)
{
	struct devlink_port_attrs *attrs = &devlink_port->attrs;

	if (!attrs->set)
		return 0;
	if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
		return -EMSGSIZE;
	switch (devlink_port->attrs.flavour) {
	case DEVLINK_PORT_FLAVOUR_PCI_PF:
		if (nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_PF_NUMBER,
				attrs->pci_pf.pf))
			return -EMSGSIZE;
		break;
	case DEVLINK_PORT_FLAVOUR_PCI_VF:
		if (nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_PF_NUMBER,
				attrs->pci_vf.pf) ||
		    nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_VF_NUMBER,
				attrs->pci_vf.vf))
			return -EMSGSIZE;
		break;
	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
	case DEVLINK_PORT_FLAVOUR_CPU:
	case DEVLINK_PORT_FLAVOUR_DSA:
		if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER,
				attrs->phys.port_number))
			return -EMSGSIZE;
		if (!attrs->split)
			return 0;
		if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_GROUP,
				attrs->phys.port_number))
			return -EMSGSIZE;
		if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
				attrs->phys.split_subport_number))
			return -EMSGSIZE;
		break;
	default:
		break;
	}
	return 0;
}

static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
				struct devlink_port *devlink_port,
				enum devlink_command cmd, u32 portid,
				u32 seq, int flags)
{
	void *hdr;

	hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd);
	if (!hdr)
		return -EMSGSIZE;

	if (devlink_nl_put_handle(msg, devlink))
		goto nla_put_failure;
	if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, devlink_port->index))
		goto nla_put_failure;

	spin_lock_bh(&devlink_port->type_lock);
	if (nla_put_u16(msg, DEVLINK_ATTR_PORT_TYPE, devlink_port->type))
		goto nla_put_failure_type_locked;
	if (devlink_port->desired_type != DEVLINK_PORT_TYPE_NOTSET &&
	    nla_put_u16(msg, DEVLINK_ATTR_PORT_DESIRED_TYPE,
			devlink_port->desired_type))
		goto nla_put_failure_type_locked;
	if (devlink_port->type == DEVLINK_PORT_TYPE_ETH) {
		struct net_device *netdev = devlink_port->type_dev;

		if (netdev &&
		    (nla_put_u32(msg, DEVLINK_ATTR_PORT_NETDEV_IFINDEX,
				 netdev->ifindex) ||
		     nla_put_string(msg, DEVLINK_ATTR_PORT_NETDEV_NAME,
				    netdev->name)))
			goto nla_put_failure_type_locked;
	}
	if (devlink_port->type == DEVLINK_PORT_TYPE_IB) {
		struct ib_device *ibdev = devlink_port->type_dev;

		if (ibdev &&
		    nla_put_string(msg, DEVLINK_ATTR_PORT_IBDEV_NAME,
				   ibdev->name))
			goto nla_put_failure_type_locked;
	}
	spin_unlock_bh(&devlink_port->type_lock);
	if (devlink_nl_port_attrs_put(msg, devlink_port))
		goto nla_put_failure;

	genlmsg_end(msg, hdr);
	return 0;

nla_put_failure_type_locked:
	spin_unlock_bh(&devlink_port->type_lock);
nla_put_failure:
	genlmsg_cancel(msg, hdr);
	return -EMSGSIZE;
}

static void devlink_port_notify(struct devlink_port *devlink_port,
				enum devlink_command cmd)
{
	struct devlink *devlink = devlink_port->devlink;
	struct sk_buff *msg;
	int err;

	if (!devlink_port->registered)
		return;

	WARN_ON(cmd != DEVLINK_CMD_PORT_NEW && cmd != DEVLINK_CMD_PORT_DEL);

	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
	if (!msg)
		return;

	err = devlink_nl_port_fill(msg, devlink, devlink_port, cmd, 0, 0, 0);
	if (err) {
		nlmsg_free(msg);
		return;
	}

	genlmsg_multicast_netns(&devlink_nl_family, devlink_net(devlink),
				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
}

static int devlink_nl_cmd_get_doit(struct sk_buff *skb, struct genl_info *info)
{
	struct devlink *devlink = info->user_ptr[0];
	struct sk_buff *msg;
	int err;

	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
	if (!msg)
		return -ENOMEM;

	err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW,
			      info->snd_portid, info->snd_seq, 0);
	if (err) {
		nlmsg_free(msg);
		return err;
	}

	return genlmsg_reply(msg, info);
}

static int devlink_nl_cmd_get_dumpit(struct sk_buff *msg,
				     struct netlink_callback *cb)
{
	struct devlink *devlink;
	int start = cb->args[0];
	int idx = 0;
	int err;

	mutex_lock(&devlink_mutex);
	list_for_each_entry(devlink, &devlink_list, list) {
		if (!net_eq(devlink_net(devlink), sock_net(msg->sk)))
			continue;
		if (idx < start) {
			idx++;
			continue;
		}
		err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW,
				      NETLINK_CB(cb->skb).portid,
				      cb->nlh->nlmsg_seq, NLM_F_MULTI);
		if (err)
			goto out;
		idx++;
	}
out:
	mutex_unlock(&devlink_mutex);

	cb->args[0] = idx;
	return msg->len;
}

static int devlink_nl_cmd_port_get_doit(struct sk_buff *skb,
					struct genl_info *info)
{
	struct devlink_port *devlink_port = info->user_ptr[0];
	struct devlink *devlink = devlink_port->devlink;
	struct sk_buff *msg;
	int err;

	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
	if (!msg)
		return -ENOMEM;

	err = devlink_nl_port_fill(msg, devlink, devlink_port,
				   DEVLINK_CMD_PORT_NEW,
				   info->snd_portid, info->snd_seq, 0);
	if (err) {
		nlmsg_free(msg);
		return err;
	}

	return genlmsg_reply(msg, info);
}

static int devlink_nl_cmd_port_get_dumpit(struct sk_buff *msg,
					  struct netlink_callback *cb)
{
	struct devlink *devlink;
	struct devlink_port *devlink_port;
	int start = cb->args[0];
	int idx = 0;
	int err;

	mutex_lock(&devlink_mutex);
	list_for_each_entry(devlink, &devlink_list, list) {
		if (!net_eq(devlink_net(devlink), sock_net(msg->sk)))
			continue;
		mutex_lock(&devlink->lock);
		list_for_each_entry(devlink_port, &devlink->port_list, list) {
			if (idx < start) {
				idx++;
				continue;
			}
			err = devlink_nl_port_fill(msg, devlink, devlink_port,
						   DEVLINK_CMD_NEW,
						   NETLINK_CB(cb->skb).portid,
						   cb->nlh->nlmsg_seq,
						   NLM_F_MULTI);
			if (err) {
				mutex_unlock(&devlink->lock);
				goto out;
			}
			idx++;
		}
		mutex_unlock(&devlink->lock);
	}
out:
	mutex_unlock(&devlink_mutex);

	cb->args[0] = idx;
	return msg->len;
}

static int devlink_port_type_set(struct devlink *devlink,
				 struct devlink_port *devlink_port,
				 enum devlink_port_type port_type)

{
	int err;

	if (devlink->ops->port_type_set) {
		if (port_type == DEVLINK_PORT_TYPE_NOTSET)
			return -EINVAL;
		if (port_type == devlink_port->type)
			return 0;
		err = devlink->ops->port_type_set(devlink_port, port_type);
		if (err)
			return err;
		devlink_port->desired_type = port_type;
		devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
		return 0;
	}
	return -EOPNOTSUPP;
}

static int devlink_nl_cmd_port_set_doit(struct sk_buff *skb,
					struct genl_info *info)
{
	struct devlink_port *devlink_port = info->user_ptr[0];
	struct devlink *devlink = devlink_port->devlink;
	int err;

	if (info->attrs[DEVLINK_ATTR_PORT_TYPE]) {
		enum devlink_port_type port_type;

		port_type = nla_get_u16(info->attrs[DEVLINK_ATTR_PORT_TYPE]);
		err = devlink_port_type_set(devlink, devlink_port, port_type);
		if (err)
			return err;
	}
	return 0;
}

static int devlink_port_split(struct devlink *devlink, u32 port_index,
			      u32 count, struct netlink_ext_ack *extack)

{
	if (devlink->ops->port_split)
		return devlink->ops->port_split(devlink, port_index, count,
						extack);
	return -EOPNOTSUPP;
}

static int devlink_nl_cmd_port_split_doit(struct sk_buff *skb,
					  struct genl_info *info)
{
	struct devlink *devlink = info->user_ptr[0];
	u32 port_index;
	u32 count;

	if (!info->attrs[DEVLINK_ATTR_PORT_INDEX] ||
	    !info->attrs[DEVLINK_ATTR_PORT_SPLIT_COUNT])
		return -EINVAL;

	port_index = nla_get_u32(info->attrs[DEVLINK_ATTR_PORT_INDEX]);
	count = nla_get_u32(info->attrs[DEVLINK_ATTR_PORT_SPLIT_COUNT<