aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb/linux/modules.py
diff options
context:
space:
mode:
authorTomohiro Misono <misono.tomohiro@jp.fujitsu.com>2018-05-20 21:09:44 -0400
committerDavid Sterba <dsterba@suse.com>2018-05-31 05:35:24 -0400
commit23d0b79dfaed2305b500b0215b0421701ada6b1a (patch)
treeeeb57dfec279e2d7c737e354d6929145745ae5e5 /scripts/gdb/linux/modules.py
parent42e4b520c812daaf5e6177c2e4beec012ce1e2ce (diff)
btrfs: Add unprivileged version of ino_lookup ioctl
Add unprivileged version of ino_lookup ioctl BTRFS_IOC_INO_LOOKUP_USER to allow normal users to call "btrfs subvolume list/show" etc. in combination with BTRFS_IOC_GET_SUBVOL_INFO/BTRFS_IOC_GET_SUBVOL_ROOTREF. This can be used like BTRFS_IOC_INO_LOOKUP but the argument is different. This is because it always searches the fs/file tree correspoinding to the fd with which this ioctl is called and also returns the name of bottom subvolume. The main differences from original ino_lookup ioctl are: 1. Read + Exec permission will be checked using inode_permission() during path construction. -EACCES will be returned in case of failure. 2. Path construction will be stopped at the inode number which corresponds to the fd with which this ioctl is called. If constructed path does not exist under fd's inode, -EACCES will be returned. 3. The name of bottom subvolume is also searched and filled. Note that the maximum length of path is shorter 256 (BTRFS_VOL_NAME_MAX+1) bytes than ino_lookup ioctl because of space of subvolume's name. Reviewed-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Tested-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> [ style fixes ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'scripts/gdb/linux/modules.py')
0 files changed, 0 insertions, 0 deletions
62afe595de7aaac6c140103a34dc8c208afa34e7'>root/drivers/net/s2io.c
blob: 9c4935407f268c298946073361cb5bad09cab5c9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
                                                                         
                                                                      










                                                                          



                                                                       


                                                                         
                                                                  
                                                                       
                                                                     

                                                                      
  

                                                                              

                                                                             
                                                                              
                              

                                                                          
                                                                              
                                                                             
                                                                      







                                                                          
                              












                              
                          
 

                        
                   




                      
                                     
 
                                 
                                            
                                                
 


                                  









                                                                   
  



                                                                 



                                                                       








                                                                          



                                                                 
                            
                                                          























































                                                     


                                 







                                                                 





                                                                 























                                                                            
  






                                                                     

                                 
                                                     
                        
                                                     




                                                     



                                                     







                                                     








                                                     
                             






















                                                     
  



























                                                             

                                               
                                     
                                                





                                                  
                                
                                       


                                      

                                                        

                                                             
 
  
                     
                                                              






                                                        


                                                    

















                                                                       

                                                                  








                                                
                                        

                                          
                          
                      













                                                             


                                                                                 



                                                      
                                




                                                                           


                                                                           



                                                                   
                                                                             



                                                                           

                                                                  
                                                   

                                                                  
                                                   

                                                  
                                                                   
 











                                                                        









                                                                              
                                                               








                                                                                


                                                                    

                                                                                   
                                                           
                                                                                  




                                                           



                                                            

                                                     






                                                                           
                                                   



                                                                           
         



                                                 
                     

                                                   


                                                                       
                                                  


                                                                       
                                                  


                                                  

                                                               

                                                   




                                                                        



                                                                          


                                                                        

                                                    
                                                                        


                                                    













                                                                           



                                                                            


                                                

                                                                                   
                                         
                                                                         
                                                                       

                                                                                  
                                         
                                                                         


                                                                      

                                                                 



                                                             









                                                                            
                                                 
                                                      
                                               






                                                                                
                                                       





















                                                                                


                         






                                                               


                                                                         








                                                            





                                                                   

                                              












                                                                          
                                          














                                                                           



                                                                       

                                                                 

                                                                  
                                                           

                                                                  

                                                           







                                                                           



                                                                        
                 
                                                       

         
                             
                                                   
                                                            
                                               



                                                                        



                                                                    
                                                                       


                 
















                                                                                
                         
                                                        
                 
         








                                                                
   




                                           
                                                    
















                                                      
                                                    
























































                                                                                  
                                         
                                 


                                                                 














                                                    
                     



                                        
                                                     
                                   



                                                                     









                                                                       


                                          
                    
                                       


















                                                             

                                                  
                                                  



                                                                     
                                                               
                                                                      
                                                                        

                                                                      

                                                                       

                                                               
                                                                    
                                                                  

                                                            

                                  





















                                                                             
                                           




                                                                    

                                             













































                                                                         



                                                           

                                                    

                                                           



                                                                          

                                                                   















                                                                        

                                                      


                            




                                                


                                                   

                                                                     


                                                               
                                                                     


                                                               
                                                                     


                                                               
                                                                     


                                                               
                                                                     


                                                               
                                                                     


                                                               
                                                                     


                                                               
                                                                     





                                                               
          

                                           
           
















































































































































































































                                                          


                     
                               

                                                       



















                                                                          
 
                                       
                                                             
 




                                                    
          







                                                                         

                                                                  

                  

                                                             


                                                                    







                                                            
                                           
                                                                         

                                                              



                                              
                                                                        




                                                            
          



















                                                                        





                                                                            
 
                  




















                                                                                
                
 













                                                                                 
 
                                                    
 
                                                     






                                                              
                                                    
 

























                                                                                   
                 

         

                                                                 





                                                                   
                             







                                                          

                                                               






                                                                       
          






















                                                                 

                                                                       





                                                       








                                                                





                                                     

                       


                                         

                                          

                                          




                                                 
 

                                                            



                                                                           

                                                                    
















                                                                           
                          

                                                                       

                                              
                           










                                                                               
                          



                                                                            


                                                           
















                                                                          

                                                                       




                                                                       

                                                                              


                                                                      

                                                                              



                                                                      


                                                                       
















                                                                           


                                                                          


                                                                         


                                                                       















                                                                         

                                                                              

                               
                                                   

                                                                              

















                                                                       
                          
                                                                               
                               


                                                                        

                                                                             














                                                                        
                          
                                               
                           

                                                        


















                                                                             
                          
                                                            
                                                                       


                                                            

                                                                            


















                                                                          

                                                                            









                                                                          
                                                                         



                            
                                                       




                                                                         
                       




                                                                           

                 
                                                       














                                                                           






                                                            



                                                                         
                                                                   

                                                                      
                                   


                                       
                                                                 
 
                          
                                   
                                               
 
                                                     






                                                                           
                                                                     







                                                                 
                



                                                                          
                                






                                                          
                           




                                                   
                                   
                                   



                                                                        

                                                                           
                 







                                                    

                          







                                                   
                                                                               


                                                    

                                                            



                                                                            


                                                    





                                                                           
 
          








                                                                     
                                                     





                                              

                                                                  





                                                              

                                                                    


                                             
                                                                            






                                                                           







                                                                         
 
          
                                                                      



                                                                      








                                                       

                                                    



                                                   
                                                             

         

                                                                  



                                                           


                       

                                                
                                   
                
                               
                      









                                                 
                             





                                                                      
                                                                            




                                                                      

                                                               

                                         




















                                                                         
                                           
                                                                          




                                                                    

                                                                  


         

                                
                                    

                                                                    
















                                                               
                                                          

                                                   









                                                                 


































                                                                             

                                                
                                  

                         






                                                                          

                                                                         






                                                                           
                                                      




                                                 
                          
                      

                                    
                
                      


                            
                                 


                                        

                                                         

                                       
                                                                        
                                
                                                                         
                                

                                                                           
 






                                                                        


                                                               
                                                               
                                                                     
                                          








                                                                             
                                                                     


                                                                    




                                                                      
                                                     
                                                                      

                                                              


                                                              
                                                                     
                                                     

                                 








                                                                        
 


                                          

                                                                        



                                                                      


































































                                                                               
                 
                                                           

                                                              
                      

                                                          
                                                                          
 
                                                  






                                                                      




                                                        








                                                                        


                       




























































                                                                       
   
                                          
                                 
                







                                                             
                                    

                                    




                                                   

                                                         
 



                                                                       








                                                                           
                                                                     








                                                                           
                             


                                                         
                                             

                                    
                                                    

                  
 
                                  


                                        



                                                   




                                                   




                                                                          
                 
















                                                                          
                                  

                 
      









                                                                          
                                  

                 


      

                                          

                                                             
                                                                           

                                                                          



                 
                                                   
 
                                    
                                                                
                                             


                                              

                        
      

                                                         
                                                                    

                                                   
                       

         



                                               
                                                                               




                                        
                                                                   

                                






                                                                                 




                                                                             
                                                   
                               
                 


                                                                




                                                                


                                                                
                                                               

                                                                
                                                               


                                                                
                                                     











                                                                                

                                                



                                                                     
                                            
                                                                             
                                    


                                                                            

                                                                               
 





                                          

                                                                         
      
         
                                   
 

   

                                                



                                                                     




                                         
                                                   
 
                                    



                                                                
                       
 










                                                                

                                                                     
                    


                                                                  
              
                         
                 
 






















                                                                

                                                           





                                                                 
                         
                                     
                 



                                                              








                                                         







                                      
   

                                                 
                                                                        
                                                                       

                                                                        











                                                                





                                                                    

         




                                                                        

                                                             
                                                                    
                                             
                                                                    
                                                                   





                                                                             
                         
                        

                                                             


                 



                                                                       

                                                             






                                                                          
                                                                    














                                                                       
   
                                                            
                                                                           
                       


                                                                     



                                               
                                     


















                                                                        

                                 

                                                                    
                                                                      




                                                       
                           


                                                   
                           
 
                                                                               
                                                                          
 


                                       



                                                                      









                                                                        


                                                                
                                              



                          


                                                       


                                                                 
                                                        


                                                                    
 

                                                             
 


                                                              
 


                                                                

                                                                     

                                                   



                                                   
                                                             

         








                                                                   



                                        

                                                              
                                      
                                                                




                                                          
                                




                                                   
          


















































                                                                             
                                                     
                                                                       
                                                                






                                           

                                                                 










                                                   
                                                                
                                  
                                              

                                           
          
                                                                    
                                                                  














                                        
                                                                

                                              



                                           

                                                                 














                                                                             

                                          
                                                                  



















                                                                   
                                                                  
















                                                                           
                                                                  





















                                                                           
                                                                  
















































                                                                    
                                                                  















































































                                                                                      



                                                               
   




                                                                          
                                                        




                                                                       
                                     


                              

                                            
 

                                                            


                               
                                




                                                                     

                                    

         


                                                                       
                                                              












































                                                                               



                                                               

                                                



                               

                           

                                             
                        
                                         


















                                                                           

                       





                                                
                   














                                                                           
                                      

                              


                        




                                                                  




















                                                                           
















                                                                           
                                                          









                                                                    

                              

                                    



                                       
                                                                     
                                               
                                                        
                                                                    

                                                            

                                   


                  
 






                                                                





                                                                            

                                                                             
                                                                    




                                                            








                                                                          










                                                        

                                                             
                                                 






                                                             
 




                                                          






                                                              


                                                           








                                                                
                                                                           



                                                                     
 





                                              

                 
                  

                                                                           














                                                                        








                                                      

































































































                                                                         

                                             
                                                   











































                                                            




                                                            


                                                                      


                                                                         
                                                                     






                                                                        
              
                              


                                    
                                 


                                       
          




                                                                    
                                                        




                                                           
                                         


                                










                                                                  






                                                                          


                                                                


         

                                              







                                                                          



                                                                

                                           


                                                                    



                                                             
                        










                                                                         
                                                         








                                                            
                                 



                           

























                                                                
                                                             

                                           
                                                                         




                                                      
                                                               




                                    
 


                                       




                                                                





                                                                         
                                    
                                                                     







                                                                          

                                                                         




































                                                                          

                                                     























                                                                  
                                                                     













                                                                      
                                                                  





















                                                                           
                                                            



























                                                                               
                                                            

















                                                                          
                                                       

                                                                     
                                                                   
                               
                                                                     









                                                        
          

                                                                             
                       






















                                                                           
                                                      



                                                                                                 
                                                                        




















                                                                          
                                                       






























                                                                              

                                                                          













                                                                           



                                                                            







                                                                         
                                                                          
                       
                                                                         



























                                                                           
                                                                        
                                                               


                                                                        









                                                   

                                                    















                                                                          
                                                                         

                                                                  
                                                               
                  
                                                                 













                                                               

                                                   













                                                                        
                                                
            
                                                       

                                      
                                                                        








                                                                          

                                                                          






















                                                                          
                                                                          









                                                                         
                                                             



















                                                              
                                                                          


                                                                   
                         
               
                                                                      







                                                                       
                                                       





                                                   




                                                                                 
 








                                                                    
                 

         





















                                                                     








                                                                           
                                                                           







                                                                       
                                                               




                                                   
















                                                                                 
 















                                                                       
                                        



                                      
                 
         





                                                                                                       
                                                                      









                                                                       
                                                                      
 

                     





















                                                                           
                                                                      













                                                                       
                            































                                                                             

                                                                          












                                                                           
                               

                     

                                                










                                                                 




                                                


























                                                                 
                    


   
                                                                          




                                                                          
                                                                     







                                                        


                                         

                                          











                                                                         

                                      
                                                 



                                              

                                                                                                                                                    
                         
         

                                           
                                             

                                                     


                                                   
 

                                                 
                         
                                              

                         

                                                                                                                                                    
                         
         

                                           
                                             
 



                                                     
 


                                                     
 


                                                      
 









                                                       

                     
                    



                                                          
                                                                          
                      
                                                                          



                                                                   
                                                       



























                                                                

                                                                          



                                                                           
                                                                        

















                                                      

                                                                           
                      
                                                               

                           
                                                                 








                                                        
                                              






                                                  
                                                                 


























                                                           
                                                      

                                                         


                                                                         










                                                                  

                                                                         











                                                                  

                                                   



                            
                          
 



                                                             







                                                                           
                                                                
















                                                                         
                               
                                            




                                                             




                                                             









































                                                                     
                            





                                                                           
                                                                





                                                                         
                                                                      


                                                                            
                                                                    











                                                                       
                                                          







                                                                            

                                                                   





                                                                             


                                                                          
















                                                                              

                                                                 



                                                                                
                                                          










                                                                            
                                                              


                                                            

 
                                                     




                                
                                                     




                              
                                                              









                                
                                               



                                   
                                                        


                               

                                                       









                                                              




                                                               
                                                                 








































                                                        
                                          





                                                                           

                                                                          

   
                                                                 














                                                                         
                                                        

                              






                                                                 
                           














                                                                          








                                                                    
                                                                         
                                                                          
                                                                   






















































                                                                          






                                                                    

                                             
                                                                           



                                                              

                                                                               







                                                                      









                                                                             





                                                                

                                                                               





















                                                                   
                                         
                                                                         
                                                        
                           
         










                                                                     
                                                                                 












                                                                          

                       










                                                              
                            



                                                    
                            
                                                    
 




                                        
                       










                                                                     








                                                                          

                                                                         
































                                                                           

                                                                        



                                             
   



                                                               
                                                                  
















                                                                  
 

 

                                                  


























                                                                               
                 








                                                                           
                                                               
 
                                   
                                                               


                                                     
                             
 




                                                                      




                                                       
         
 



                                 

                                                                  
 


























                                                                               



                                                            

                                                                           
                          





                                                                       

                                                                  







                                                       
                                                 
                       






                                                                
     






                                                                
      
                               
                                               









                                                                           

                                                                   



                 
                                    















                                                                         


















                                                                            









                                                                                
                                      


                                                                          
                                          
                                                              
                                              
                                                             
                                          






                                                                
                                                                         
                           
                                                              
                                        
                                                             
                                          



                                                                        

                            
                                  
                                  
                                   

                                               
                                               
                                              





                                              
                               
                                    


                                        
                                       
                                
 
   
                                                   



                                                                            


                                                                           









                                                                    







                                               
                 
                                     
 
                       






                                                                           
      






                                                                       
                                                      

                                                                        
                                               
                                             





                                                                   
                                                             





                                                                        




























                                                                            



















                                                                        
                                     
                                        






                                           
                                      
 





                                                         
                


                                                          
          
                                                       


                                                                        





                                               

                                                                       





                                                            



                                                                           








                                                                     
                                             

                                 

                                                                   


                                                           
                                                  


















                                                                       


                                                             


                                                                        
                                        







































                                                                             


                                                                 
 



                                                                   
                             
                              
                         















                                                            
                                 








                                                                            



















                                                                          

          





















                                                                         




                                                              
                                                             
                                       




                                         




                                      
                                     
 


                                                                 


















                                                                         


                                                                           
                                                          

                                                          










                                                                        

                                                                               






                                                                               
                                               







                                                                          
                                                          

                                                                  










                                                                        
                                                                               







                                                                               





                                                                        
 

                                    



                                                                       
 







                                                                                


                                                                     


                               











                                 







                                                               






                                    
                                     
                                                                         
                                                                         
                                                                        
                                                                         




















                                                              







                                                               
                                    














                                                                            
                                               


                                                                                                  
                      






                                              
/************************************************************************
 * s2io.c: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC
 * Copyright(c) 2002-2005 Neterion Inc.

 * This software may be used and distributed according to the terms of
 * the GNU General Public License (GPL), incorporated herein by reference.
 * Drivers based on or derived from this code fall under the GPL and must
 * retain the authorship, copyright and license notice.  This file is not
 * a complete program and may only be used when the entire operating
 * system is licensed under the GPL.
 * See the file COPYING in this distribution for more information.
 *
 * Credits:
 * Jeff Garzik		: For pointing out the improper error condition
 *			  check in the s2io_xmit routine and also some
 *			  issues in the Tx watch dog function. Also for
 *			  patiently answering all those innumerable
 *			  questions regaring the 2.6 porting issues.
 * Stephen Hemminger	: Providing proper 2.6 porting mechanism for some
 *			  macros available only in 2.6 Kernel.
 * Francois Romieu	: For pointing out all code part that were
 *			  deprecated and also styling related comments.
 * Grant Grundler	: For helping me get rid of some Architecture
 *			  dependent code.
 * Christopher Hellwig	: Some more 2.6 specific issues in the driver.
 *
 * The module loadable parameters that are supported by the driver and a brief
 * explaination of all the variables.
 * rx_ring_num : This can be used to program the number of receive rings used
 * in the driver.
 * rx_ring_sz: This defines the number of descriptors each ring can have. This
 * is also an array of size 8.
 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid
 *		values are 1, 2 and 3.
 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver.
 * tx_fifo_len: This too is an array of 8. Each element defines the number of
 * Tx descriptors that can be associated with each corresponding FIFO.
 ************************************************************************/

#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/stddef.h>
#include <linux/ioctl.h>
#include <linux/timex.h>
#include <linux/sched.h>
#include <linux/ethtool.h>
#include <linux/version.h>
#include <linux/workqueue.h>
#include <linux/if_vlan.h>

#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/io.h>

/* local include */
#include "s2io.h"
#include "s2io-regs.h"

#define DRV_VERSION "Version 2.0.9.3"

/* S2io Driver name & version. */
static char s2io_driver_name[] = "Neterion";
static char s2io_driver_version[] = DRV_VERSION;

int rxd_size[4] = {32,48,48,64};
int rxd_count[4] = {127,85,85,63};

static inline int RXD_IS_UP2DT(RxD_t *rxdp)
{
	int ret;

	ret = ((!(rxdp->Control_1 & RXD_OWN_XENA)) &&
		(GET_RXD_MARKER(rxdp->Control_2) != THE_RXD_MARK));

	return ret;
}

/*
 * Cards with following subsystem_id have a link state indication
 * problem, 600B, 600C, 600D, 640B, 640C and 640D.
 * macro below identifies these cards given the subsystem_id.
 */
#define CARDS_WITH_FAULTY_LINK_INDICATORS(dev_type, subid) \
	(dev_type == XFRAME_I_DEVICE) ?			\
		((((subid >= 0x600B) && (subid <= 0x600D)) || \
		 ((subid >= 0x640B) && (subid <= 0x640D))) ? 1 : 0) : 0

#define LINK_IS_UP(val64) (!(val64 & (ADAPTER_STATUS_RMAC_REMOTE_FAULT | \
				      ADAPTER_STATUS_RMAC_LOCAL_FAULT)))
#define TASKLET_IN_USE test_and_set_bit(0, (&sp->tasklet_status))
#define PANIC	1
#define LOW	2
static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring)
{
	int level = 0;
	mac_info_t *mac_control;

	mac_control = &sp->mac_control;
	if ((mac_control->rings[ring].pkt_cnt - rxb_size) > 16) {
		level = LOW;
		if (rxb_size <= rxd_count[sp->rxd_mode]) {
			level = PANIC;
		}
	}

	return level;
}

/* Ethtool related variables and Macros. */
static char s2io_gstrings[][ETH_GSTRING_LEN] = {
	"Register test\t(offline)",
	"Eeprom test\t(offline)",
	"Link test\t(online)",
	"RLDRAM test\t(offline)",
	"BIST Test\t(offline)"
};

static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
	{"tmac_frms"},
	{"tmac_data_octets"},
	{"tmac_drop_frms"},
	{"tmac_mcst_frms"},
	{"tmac_bcst_frms"},
	{"tmac_pause_ctrl_frms"},
	{"tmac_any_err_frms"},
	{"tmac_vld_ip_octets"},
	{"tmac_vld_ip"},
	{"tmac_drop_ip"},
	{"tmac_icmp"},
	{"tmac_rst_tcp"},
	{"tmac_tcp"},
	{"tmac_udp"},
	{"rmac_vld_frms"},
	{"rmac_data_octets"},
	{"rmac_fcs_err_frms"},
	{"rmac_drop_frms"},
	{"rmac_vld_mcst_frms"},
	{"rmac_vld_bcst_frms"},
	{"rmac_in_rng_len_err_frms"},
	{"rmac_long_frms"},
	{"rmac_pause_ctrl_frms"},
	{"rmac_discarded_frms"},
	{"rmac_usized_frms"},
	{"rmac_osized_frms"},
	{"rmac_frag_frms"},
	{"rmac_jabber_frms"},
	{"rmac_ip"},
	{"rmac_ip_octets"},
	{"rmac_hdr_err_ip"},
	{"rmac_drop_ip"},
	{"rmac_icmp"},
	{"rmac_tcp"},
	{"rmac_udp"},
	{"rmac_err_drp_udp"},
	{"rmac_pause_cnt"},
	{"rmac_accepted_ip"},
	{"rmac_err_tcp"},
	{"\n DRIVER STATISTICS"},
	{"single_bit_ecc_errs"},
	{"double_bit_ecc_errs"},
};

#define S2IO_STAT_LEN sizeof(ethtool_stats_keys)/ ETH_GSTRING_LEN
#define S2IO_STAT_STRINGS_LEN S2IO_STAT_LEN * ETH_GSTRING_LEN

#define S2IO_TEST_LEN	sizeof(s2io_gstrings) / ETH_GSTRING_LEN
#define S2IO_STRINGS_LEN	S2IO_TEST_LEN * ETH_GSTRING_LEN

#define S2IO_TIMER_CONF(timer, handle, arg, exp)		\
			init_timer(&timer);			\
			timer.function = handle;		\
			timer.data = (unsigned long) arg;	\
			mod_timer(&timer, (jiffies + exp))	\

/* Add the vlan */
static void s2io_vlan_rx_register(struct net_device *dev,
					struct vlan_group *grp)
{
	nic_t *nic = dev->priv;
	unsigned long flags;

	spin_lock_irqsave(&nic->tx_lock, flags);
	nic->vlgrp = grp;
	spin_unlock_irqrestore(&nic->tx_lock, flags);
}

/* Unregister the vlan */
static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)
{
	nic_t *nic = dev->priv;
	unsigned long flags;

	spin_lock_irqsave(&nic->tx_lock, flags);
	if (nic->vlgrp)
		nic->vlgrp->vlan_devices[vid] = NULL;
	spin_unlock_irqrestore(&nic->tx_lock, flags);
}

/*
 * Constants to be programmed into the Xena's registers, to configure
 * the XAUI.
 */

#define SWITCH_SIGN	0xA5A5A5A5A5A5A5A5ULL
#define	END_SIGN	0x0

static u64 herc_act_dtx_cfg[] = {
	/* Set address */
	0x8000051536750000ULL, 0x80000515367500E0ULL,
	/* Write data */
	0x8000051536750004ULL, 0x80000515367500E4ULL,
	/* Set address */
	0x80010515003F0000ULL, 0x80010515003F00E0ULL,
	/* Write data */
	0x80010515003F0004ULL, 0x80010515003F00E4ULL,
	/* Set address */
	0x801205150D440000ULL, 0x801205150D4400E0ULL,
	/* Write data */
	0x801205150D440004ULL, 0x801205150D4400E4ULL,
	/* Set address */
	0x80020515F2100000ULL, 0x80020515F21000E0ULL,
	/* Write data */
	0x80020515F2100004ULL, 0x80020515F21000E4ULL,
	/* Done */
	END_SIGN
};

static u64 xena_mdio_cfg[] = {
	/* Reset PMA PLL */
	0xC001010000000000ULL, 0xC0010100000000E0ULL,
	0xC0010100008000E4ULL,
	/* Remove Reset from PMA PLL */
	0xC001010000000000ULL, 0xC0010100000000E0ULL,
	0xC0010100000000E4ULL,
	END_SIGN
};

static u64 xena_dtx_cfg[] = {
	0x8000051500000000ULL, 0x80000515000000E0ULL,
	0x80000515D93500E4ULL, 0x8001051500000000ULL,
	0x80010515000000E0ULL, 0x80010515001E00E4ULL,
	0x8002051500000000ULL, 0x80020515000000E0ULL,
	0x80020515F21000E4ULL,
	/* Set PADLOOPBACKN */
	0x8002051500000000ULL, 0x80020515000000E0ULL,
	0x80020515B20000E4ULL, 0x8003051500000000ULL,
	0x80030515000000E0ULL, 0x80030515B20000E4ULL,
	0x8004051500000000ULL, 0x80040515000000E0ULL,
	0x80040515B20000E4ULL, 0x8005051500000000ULL,
	0x80050515000000E0ULL, 0x80050515B20000E4ULL,
	SWITCH_SIGN,
	/* Remove PADLOOPBACKN */
	0x8002051500000000ULL, 0x80020515000000E0ULL,
	0x80020515F20000E4ULL, 0x8003051500000000ULL,
	0x80030515000000E0ULL, 0x80030515F20000E4ULL,
	0x8004051500000000ULL, 0x80040515000000E0ULL,
	0x80040515F20000E4ULL, 0x8005051500000000ULL,
	0x80050515000000E0ULL, 0x80050515F20000E4ULL,
	END_SIGN
};

/*
 * Constants for Fixing the MacAddress problem seen mostly on
 * Alpha machines.
 */
static u64 fix_mac[] = {
	0x0060000000000000ULL, 0x0060600000000000ULL,
	0x0040600000000000ULL, 0x0000600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0060600000000000ULL,
	0x0020600000000000ULL, 0x0000600000000000ULL,
	0x0040600000000000ULL, 0x0060600000000000ULL,
	END_SIGN
};

/* Module Loadable parameters. */
static unsigned int tx_fifo_num = 1;
static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
    {[0 ...(MAX_TX_FIFOS - 1)] = 0 };
static unsigned int rx_ring_num = 1;
static unsigned int rx_ring_sz[MAX_RX_RINGS] =
    {[0 ...(MAX_RX_RINGS - 1)] = 0 };
static unsigned int rts_frm_len[MAX_RX_RINGS] =
    {[0 ...(MAX_RX_RINGS - 1)] = 0 };
static unsigned int rx_ring_mode = 1;
static unsigned int use_continuous_tx_intrs = 1;
static unsigned int rmac_pause_time = 65535;
static unsigned int mc_pause_threshold_q0q3 = 187;
static unsigned int mc_pause_threshold_q4q7 = 187;
static unsigned int shared_splits;
static unsigned int tmac_util_period = 5;
static unsigned int rmac_util_period = 5;
static unsigned int bimodal = 0;
static unsigned int l3l4hdr_size = 128;
#ifndef CONFIG_S2IO_NAPI
static unsigned int indicate_max_pkts;
#endif
/* Frequency of Rx desc syncs expressed as power of 2 */
static unsigned int rxsync_frequency = 3;
/* Interrupt type. Values can be 0(INTA), 1(MSI), 2(MSI_X) */
static unsigned int intr_type = 0;

/*
 * S2IO device table.
 * This table lists all the devices that this driver supports.
 */
static struct pci_device_id s2io_tbl[] __devinitdata = {
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN,
	 PCI_ANY_ID, PCI_ANY_ID},
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI,
	 PCI_ANY_ID, PCI_ANY_ID},
	{PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_WIN,
         PCI_ANY_ID, PCI_ANY_ID},
        {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_HERC_UNI,
         PCI_ANY_ID, PCI_ANY_ID},
	{0,}
};

MODULE_DEVICE_TABLE(pci, s2io_tbl);

static struct pci_driver s2io_driver = {
      .name = "S2IO",
      .id_table = s2io_tbl,
      .probe = s2io_init_nic,
      .remove = __devexit_p(s2io_rem_nic),
};

/* A simplifier macro used both by init and free shared_mem Fns(). */
#define TXD_MEM_PAGE_CNT(len, per_each) ((len+per_each - 1) / per_each)

/**
 * init_shared_mem - Allocation and Initialization of Memory
 * @nic: Device private variable.
 * Description: The function allocates all the memory areas shared
 * between the NIC and the driver. This includes Tx descriptors,
 * Rx descriptors and the statistics block.
 */

static int init_shared_mem(struct s2io_nic *nic)
{
	u32 size;
	void *tmp_v_addr, *tmp_v_addr_next;
	dma_addr_t tmp_p_addr, tmp_p_addr_next;
	RxD_block_t *pre_rxd_blk = NULL;
	int i, j, blk_cnt, rx_sz, tx_sz;
	int lst_size, lst_per_page;
	struct net_device *dev = nic->dev;
	unsigned long tmp;
	buffAdd_t *ba;

	mac_info_t *mac_control;
	struct config_param *config;

	mac_control = &nic->mac_control;
	config = &nic->config;


	/* Allocation and initialization of TXDLs in FIOFs */
	size = 0;
	for (i = 0; i < config->tx_fifo_num; i++) {
		size += config->tx_cfg[i].fifo_len;
	}
	if (size > MAX_AVAILABLE_TXDS) {
		DBG_PRINT(ERR_DBG, "%s: Requested TxDs too high, ",
			  __FUNCTION__);
		DBG_PRINT(ERR_DBG, "Requested: %d, max supported: 8192\n", size);
		return FAILURE;
	}

	lst_size = (sizeof(TxD_t) * config->max_txds);
	tx_sz = lst_size * size;
	lst_per_page = PAGE_SIZE / lst_size;

	for (i = 0; i < config->tx_fifo_num; i++) {
		int fifo_len = config->tx_cfg[i].fifo_len;
		int list_holder_size = fifo_len * sizeof(list_info_hold_t);
		mac_control->fifos[i].list_info = kmalloc(list_holder_size,
							  GFP_KERNEL);
		if (!mac_control->fifos[i].list_info) {
			DBG_PRINT(ERR_DBG,
				  "Malloc failed for list_info\n");
			return -ENOMEM;
		}
		memset(mac_control->fifos[i].list_info, 0, list_holder_size);
	}
	for (i = 0; i < config->tx_fifo_num; i++) {
		int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
						lst_per_page);
		mac_control->fifos[i].tx_curr_put_info.offset = 0;
		mac_control->fifos[i].tx_curr_put_info.fifo_len =
		    config->tx_cfg[i].fifo_len - 1;
		mac_control->fifos[i].tx_curr_get_info.offset = 0;
		mac_control->fifos[i].tx_curr_get_info.fifo_len =
		    config->tx_cfg[i].fifo_len - 1;
		mac_control->fifos[i].fifo_no = i;
		mac_control->fifos[i].nic = nic;
		mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 1;

		for (j = 0; j < page_num; j++) {
			int k = 0;