/samples/

it/stats/drivers/scsi/qla2xxx/qla_os.c'>stats
path: root/drivers/scsi/qla2xxx/qla_os.c
blob: e4fd19281943f9e5bd73e45d6e9d18ee2071b0ab (plain) (tree)
1
2
3
4
5
6
7
8
9
10
  
                                  
                                              
  
                                                           




                              
                        
                          
                        
                          
                       




                                   

                       




                             

                        


                       
                                     
 



                                     



                           
 
                            




                                                                            
                          
                                             


                                                   
                      
                                              
                                   
                                                                           

                                       



                                                                               
                                                                              

                                                              
                            
                                                


                                                                               
                        
                                            




                                                                             
                               
                                                               
                                            









                                                                                     


                                                                           
                                                                                
 
                         
                                             



                                                                     

                                                   
                     
                                           
                                

                                                             
 



                                                  

                                                           
 

                                          

                                      

                                                                  
 
                              

                                                          




                                                                      
 
                      
                                            



                                                               
                      
                                          

                                      

                                                                  

                     
                                             



                                                                           

                  
                                                  
                               

                                                                                



                                                   
                  
                                          



                                                       
                 
                                             
                          


                                                                       
 
                        
                                            



                                                    
                    
                                            


                                                                 
 
                       
                                               


                                                                             

                     
                                                     
                                  


                                                      
 





                                                                          



                                                              
                                                                              
 
                     


                                           

                                                   
 
  
                                  

                                                                
                                                     

                                                                         
                                                        
                                                                            

                                                       
                                                       

                                                     
 
                                                                      

                                                                
                                                     
                                              
                                                      
                                                       


                                                           
                                                           






                                                          

                                                        

                                                             





                                                    
                                                     

                                                 

  
                                                                         
                                                                        
 



                          
 
               
                                                                             
 





                                                            


                  
                                                                   
 
                                           


                                                              
                       
         
 
                                                        

 
                      
                                        
 

                                    

 



                                               

                                                                      
                                                       
                                                   
 
                                                                                

                                                                            
 
                                                         
                                                                              

                                            

                                                                           


                                  
                                                                              

                                            

                                                                            

                                  





                                                                              










                                    
                                                                             
 








                                                      










                                                                             





                                                       
                                                        
                                         
                                              
         

                             






                                                        

 





                                                        
                                           

                                                              

                          
                               




                                                                   

                                                                 

                                  
                                                                          




                                                                             

                                                                          


                                           
                                                   







                                                                            



                                   

                                  
                                    

                         


                                                    


                 
             
                                                          
 
                                         



















                                                         
             
                                                          

                                                                     
                                         


                         
                                          



                                                    
                                           






                                                                          
                                                
                                     
                                                


























                                                                
             
                                                            

                        
                                         
 
































                                                           
             
                                                            
 
                                         
 

                                                                              
                   

 

                                         
 



                                                     
 


                                            
         
 



















                                                                     
 


































                                                                    

 
          
                                                                   
 
                                                
                                                                     
                                                                            

                                                                   


                  
                                 
                                                            
                                                       

                                                                        
                                                           
                        
                                                       
                                                                      
                                                        
                 


                                       


                                              
                                                               

                                                                              


                                       

                                                            


                                                                            


                                                           





                                                   

                                                                     
                                                                          



                                                                              


                                                           
                                      

         
                                                          
                
                                    
 






                                       
                                           
                                  
                                                               
                                                                          
                                            
         
 


                       
                                    
 
               

                                      


                                        
                  
                            



                 





                                                                   
                                    





                   
                                                 
 

                                                                      
                                                  

                                                             
                              
 
                                                                            

                                                 


                           
                                            
                                             


                                          
 
                   



                              
                                                     




                                               

        






                                               
   
                                                 
 

                                      

                                                              
 
                                                        



                                                                     


                             
                                   
                                            


                                                    


                               

















                                                                     
          



















                                                                        

                                                               



                             



























                                                                        





                                   












                                                                           
                                                            
                                                                           
          

                                       
                                                             
                  
                
                             
                            
                     
                                         
 
                         
                               
 




                                    

                               
 
                                                     




                                                                  
 
                                         

                                                                
 

                                                         
 
                                                          
                                             
                             
                                                 
                                                               
                
                                                 
                                                                

                         

                                                     
                            
                                                          
 



                                                              
                                                  
                   
                                                                     
                                                        
                                                                      
                                     
                 
         
 
                                        

                                                                
 

                   
 
   
                                                                          
                                                  
 
                               
                            
                                         
                            
                  
                              
 
                             
 
                                                     
                       



                                                        
                                 
                                             
                                 


                                                           
                                     




                                  
                                                     

                              

                                                        
                              
                 



                                                                  
                                                         
                                                             
         
                                                          

                      

 





                                          
 
          
                                                                 
                                                                                
 
                                                             
                                                                     
                
 
                      
                              
         
 



                                    
                                        
                                                                            
                                                    
 
                


                                                                     
                                     
         
                
                                                                     


                                                          
                                     
         
                
                                                                      

                                                     
                                                                       
                                     
         
 
                                        

                                                                  


                       
                
                                        


                                                                               

                      
 


                                              

                                                             
 

                                                                  

 
          
                                              
 

                                                             
 

                                                                     

 














                                                                           
          

                                           
                                                             
                                                                     
                         
                             
 

                               
 
                      
                           
         
 




                                    
                                        
                                                                          
 
                                                              

                                                                    
                                       

         


                                                   

                                       
 
                                         
                                                                         


                                                           
                             
         
 
                  
                                        
                                              
                                                                             
 
                   
















                                                                           
          

                                            
                                                             
                                         
                         
                             
                                                              
 

                               
 
                                        
                                                                              
 
                                                             
                                        
 

                                              
                                                
                







                                                           


                                                
                                                                
                                                       



                                                                          


                                                                              
                                                        
                         

                                                                  
         
 
                                                      
                                                                         
                            
                              
 
                   


                                                                             
 

                   










                                  
   
                                        
 
                
                               
                                         
 
                                                                    





                                                                      


                                                                         



                         
                                                                     
                                                  
                                         

                                                         



                                                                  

         
                                         
                                             
                                       

                                                             

         
                                                                          
                               
 
                           

 
    
                                                     
 
                     

                            
                                         
                            

                                                     
                                                        
                                         



                                                                      
                                 
                                                                  
                                                       
                         




                                                          

                                             
 
                                                                     
 
                                                     
                              
 
                                                       
 

                 
 


                                                 
                                                      
                                       
 


                                                                         
                                   
                                                          
            
                                                            

                 
 



                                               

 






                                                                           
                                              

                                                                          





                                                                               













                                                                               
                                      

                                                                          

 
          
                                                                            
 










                                                                               
                                   
         
 

















                                                                     







                                                                        
                                                     
 
                                      
                                              
 
                                                              

                                                                 
                                                                               
                                                                 
                                                              

                                                                               
                               
                 
         
 

                                                                

 
           
                                            













                                                               
                                             












                                                               
                                            











                                                                 
                                             



                                                                 

                                  






                                                          






                                              





































































































                                                                              

























































































                                                                              














                                                            

                                                       














                                                              
                                                     
                                                    
                                                         
















                                                            

                                                       














                                                              
                                                     
                                                    
                                                         
















                                                            

                                                       














                                                            
                                                     
                                                    
                                                         

  














                                                            

                                                       











                                                            
                                                           

                                                            
                                                         
                                                    
                                                         

  







                                                            
                                                    













                                                            

                                       


                                                     
                                                       


                                                            
                                                         
                                                    
                                                         










                                                            
                                                       















                                                            


                                                     




                                                            
                                                         

  




































                                                            
                  
                                             





                                                    
                                                               



                                                    
                                                               


                                              
                                                    
                                                               


                                              
                                                    
                                                               


                                              
                                                    


                                                           
                                                               


                                              
                                                               


                                              
                                                               


                                              
                                                    
                                           
                                            
                                                               


                                              
                                                    
                                           
                                            
                                                               
                      






                                                               

                                              
                                           
                                                               
                      

                                              
                                           
                                                               
                      




                                                    
                                                               
                      






                                                               







                                                               















                                                               
         
 





                                                                                



                                    
                                                 
                                                                
                                                                    

 
           

                                           
                                                 
 


                                           



                                                     




                                                                  
                                                 
 
                       
                         
                                                  

                         
                                                           

 


                       

                                                                       
 
                              
                               

                                         
                          
                                     
                                       
                               
                                                

                                   
 
                                                                     
                                       
                                                           
                                                           
                                                           
                                                           
                                                           
                                                           
                                                           


                                                           
                                                             
                             

                                                     
         

                                             
 






                                                
 

                                              
 

                                                             

                                                           
                               
         

                                                 
                        
                                                  

                                 
                        
                                
                                           
                                         
                                        
 

                                       

                                                                  

                                                                 
                                       
 




                                                
                                             
                             
                                                               
                                                            


                                                        
                                           



                                        
                                               
                                    
                                                               
                                                            


                                                        
                                           



                                        
                                               
                                    
                                                               
                                                       


                                                        
                                           

                                                           



                                        
                                               
                                         
                                                               
                                                       

                                                     
                                                            
                                                        
                                                                   
                                           
                                                   
                                                             
                                               



                                                            
                                    
                                                               
                                                       

                                                     
                                                            
                                                        
                                                                   

                                                   
                                                             
                                               




                                                            
                                                               






                                                                   
                                                             




                                                                 
                                    
                                                               






                                                                   
                                                             




                                                            
                                    
                                                        
                                                               












                                                                   
         
 


                                                              

                                                                         

                                                                      
                                                        




                                                                         








                                                     
                                    


                                            
                                        
 
                                                     
 
                                          



                                                          
                                                                        
                   

                                                                          
 


                                     
                                       
                                                           

                                                 


                                                
                              
                                     

                                              
                                     

         

                                        
                              
                            

                                            
                                                                   
            

                                                                 








                                                        




                                                            
                                             

                                        
                                                   


                                              
                                          
                                   
                                                      
                                                                       
 


                                                                        
                                                                        



                                                                








                                                                     
                                           
 


                                            
                                       


                             
                                  

                       
 




                                                      
                                             



                                                                   

         





                                                                 













                                                                                       
 



                                                                         
 


                                                                
                                                    
                                               

                                                              

                 
                              


                                  

                                                   

                                                                                             


                                      
 


                                      


                                                          
                                                           
                                          
                                     

                                                      
                                              

                                  

                                                  
 







                                                                          













                                                                             
         

                                                     

                                   
                                                                     





                                              
 
                                                     
                                                
                                            
                                                             

                                                                                  

                                                                  
                                                
                                                             
                                                        

                                                        
                                                        
                                                          







                                                                               



                                                             

                                      



                                              


                                      


                                              




                                                                              
 
                                           
 
                                         
 
                                    
 







                                                                          
                                                           
 

                                     

                 
                  
                                      

                                      
                                      

                                      
                                                    
 
             









                                                       
                                      
 
                                      
 
                










                                                                         


                                                         
 
          
                                 
                   
 
 
           















                                                   



































                                                           
                                        
 
                                        
                                
                            
 






                                                                             


                                         

                                         
                                                 


                                            
 
                                                           
 



                                                                                
 




                                                                
 
                                            
         
                                      
 







                                                                        

                                                               
                                     
 
                                   
 





                                             






                                                














                                                              










                                                           
                                        
 
                                          
 
                                       
 
                                         
 
                                      
 
                                      
 
                             



                                             





                                                                         
 

                                              


                                                   
         
 


                                                         
 

                                               
                                 

                                    

           
                                         
 
                                         
 





                                                          
                                     
 
                                   
                                  
                                                           
 
                    
                                               
 
                                                
                                          
 

                              
                                             

                                         
                                               
         
 
                               
 

                                  
                             
 

                             
                                

 





                                                                           
                                              




                              
                  
                                                                        

              
                               
                                  
                            





                              
                                                          
                                                               
                                       
                                                                    

                                                                    
                
                                             

                                                 

 
  







                                                                          
                                                                      
                            
 
                                                        
                                                 
                                                                  

                                                               
          



                                                                           
                                                                  




                                       

                                                                 
 

                                                
                                                        





                                                               
















                                                      
                                                              


                          
                                                             
                                                                           
                                 
 





                                                                           
                                                                
                                                                          

                                                                               
                                                                    

                                                                               








                                
                     
  
          

                                                                             

                         
 
                                                                          
                                              
                         
                          
 


                                       

                                                                          
                          
                                       
 

                                                                            
                                        
 












                                                                       


                                                         

         


                                                        
                                           
 






                                                                  



                                                                        
                                              


                                                                       

                                                                            





                                                                             

                                                                                  

                                              


                                                             

         

                                               
                                                              
                                                                
                                                                          
                                 
                                           
                                                         
                                                   
                
                                                         
                                                                        
                                          
                                 

                                                                 
                                                               
                                                                                

                                               


                                                         

         
                                              

                                                           

                                                            

                              




                                                         

                                                                 


                                               

                                                           

                                                            

                              





                                                          

                                                                 

                                   

                           




                                                                     


                                                                       
                                                     
                                     

                                                                          



                                            
 
                                                             
                                                   



                                                                           

                                                         

         

                                          





                                                                         

                                                         

         
                                     











                                                                                

                 

                                                                          

                             




                                                                
              
                    
         



                                                                
              
                    




                                                                    



                                                                    
              
                                              



                                                        
                                              



                                                  

                                         


                         


                                         


                                         
                   

                                                                    
                          

                             

                         




                                                                        
     

                                            
                       


  

                            

        
                                   
  
           
                                            
 

                                                                    
                                 
 


                                                         
                                                                                

                                   




















                                          



                                                                                

                                                 
 



                                                                     



                                                                  

                                                                             
                                              


                                                                            
                                            
 


                                                                              


                                                                            
                           

                                                            
 


                                                                              


                                                 
                         

                                                                            
 























                                                                          

                         

                                                                   
                                                      

                                 
                             
                       
                               
 
                               
                               





                            

                            

                               

                             

                              

                                     
 

                             



                                  
 
 




                                                                         
 

                                                             

                                                                                














                                                

                                        
                                                                            




                                                             



                   

 
                            
                                                                      

                               




                                     
 
                                                             

                                           
                            
         






                                     
          
                                                                    
 
                            
 
                                                  
                                                 
                                                       
                              
 



                           
                                                                              



                               
                                                 




                                           
                                         

 




                                                                  
                                                     



                                                                         
                                         

 






















                                                                

                                                              
 






























                                                                           
    
                                          
 


                                     
 




                                                       
                                        


                                  
                                                                            

                                                          


                                                              














                                                                         







                                                                        


                                                                   


                                                 


                                                                     
         
 
 





                                               
                   

                                         
                         





                                                             

                                                                               
                                              
                                                                
                                                                    





                                                                              










                                                                           
                                                            
                                                                        







                                                                               
                                        

                                                                          







                                                                      


                                                                              



                                                                           



                                                                        


                                                                      


                                                                          





                                                                         


                                                                              




                                                                              
                                                              


                                                                  
         

 









































                                                                               
                                                                               




















                                                                             
                                                                          










                                                                    
          




































                                                                       






                                                               








































































                                                                                 
          

























































                                                                              
          





































































































































































































                                                                                
           





































                                                                               
          

















































































































































                                                                                















                                                                           
                             

                                  
 

                                             
 

                                    
                                              
                                        

                                                    
 

                                                  
 

                                                                      
 
                                         

                                                                  
                                      

                 

                                   


                                                                     
 
                                          
 




                                                                        
                                                            
                                                       

                                                                     






                                                                       

                                                                       












                                                                               

                                                                    


                         

                                                                        
 

                                                            
                                                                
                                                     
 
                                                                       

                                                                 
                                                                  
                                 

                                                                      

                         

                                                            

                 

                                                            
                                                         
                 
 









                                                                            
                                                                         

                                                            














                                                                              
                         

                                                            

                 


                                                                                
 

                                                            

                                                                      

                                                            


                                                               



                                                                          
 

                                                            
                                                  

                                                            

                 

                                                                                
 

                                                            

                                                                  
                                                     
 
                                                                     
 

                                                                      

                         

                                                            

                 



                                                                            

                 
                                       
                                                      
 


                                                              
 
                                                 
 
                                   
         
                                                      
                               
                                          
 

                                            



                                                           

                           


                                                               



                 
                                           
 
                                         

                                               
                                                       
                                   


  






                                    
                                     
 


                                                             
                    
                                                                        




                                                                               


                                                                      


         







                                                                            
    
                                   
 
                                      


                                      
                          
                                         
                            
 
                                 


                                                    



                                                           


                                                                             
 

                                                                      




                                                                  
                                
                                                     

                                                               
                                       
 

                                                         
 

                                                                                      
 

                                                                        
 



                                                                          
                                                            
                                           

                                                                     
                                                       




                                                                     
                                                                          

                                                         
                                                                     
                                                         
                                                          
                                                                             
                                                         
 




                                                                              
                                                                         


                                                                          
                                                                           
                         



                                                                             
                                                                      
                                                                   
                                                                

                                                                   





                                                                      

                         


                                                          

         

                                                                            




                                                                      

         
                                        
                                         

                            
                                                


                                                              
                        

                                                             

                                                               
                                                       


















                                                                     
                                      
         
 
                                                   

 

                                  
                          



                         
                         
                         
                         
                         

                         
 




                                       
                                       
                                       
                                       

                                       
 
                                 

                                                




                                                                             
                                     
                                     
                                     

                                     


                
                                              
 
                                         

                             



                                                 
                                                                        
                                                 
                                                      
                                                 
                                         
                                                 

                                                 

                                                 

                                                 



                                                 

                            

         
                                 



                                                                      

                                                                         





                                
                                   







                              
                                 
                                            
                                                       
                                   

 


                                                                           


                                                     

                                                      
 

                                   
                                       

                                                  
                                       

                                                                  
                                                      

                                                                                   
                 
                                       
                                         

                                                             

                                                 

                                                                  










                                                 

                                                          


                                                                   


                                                
















                                                                 

                                                                        
                                                  





                                                 

                                                 






                                              

                                            












                                                        

                                                                    







                                                                               


                                                                             







                                                


                                                          


                                                        
                                              




                                                                       

                                                        











                                                                         

                                                             

                                                                
                                                
                        

                                                             
                                                                
                                               
                                               
                                                      







                                                                    


                                                              
                                                                
                                         
                                                      










                                                             



                                                         

                                                          

                             
 

                                            
 







                                                                   




                                                                        



                                                 
 
                 
                                                     
                                                                 
                                     
         
 

                                          
                                     
 
                                              








                                                                      
 

                                                
 
                                                        
                                                            
                                                
                                                          
 
 
                

                                            
 





                                        

                                                          

                

                                            
 
                                                    
                                 

                                                                               
         
 

                                                     
                               

 
                                                              





                                                     
                                                 








                                                                           
                                                                           

                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           



                                          
                                               
                                              


                                              
                                          
                                            
                                             
                                           
                                               

  

                                             
                              

  





                                               

                    
                                      
                                                                        
                                      
                                 

                                                                       


                               














                                                                          

                                                     
                                       

                                                      

                                                              

                                               

                                                                     
                           
                               
         


                                                                        

                                                                            

         



                                                                    
                           
                                                                 

                                                                           
                               
         

                                                     
                                 
                                                       

                                               
                           
                                                                 
                                                                       


                                                                           

                   







                                        
                                                        
                                                   
                                   
                                       
                   

                                               
                                                         
                                                               








                                                      




                                 
                                 
/*
 * QLogic Fibre Channel HBA Driver
 * Copyright (c)  2003-2012 QLogic Corporation
 *
 * See LICENSE.qla2xxx for copyright and licensing details.
 */
#include "qla_def.h"

#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
#include <linux/kobject.h>
#include <linux/slab.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsicam.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_fc.h>

#include "qla_target.h"

/*
 * Driver version
 */
char qla2x00_version_str[40];

static int apidev_major;

/*
 * SRB allocation cache
 */
static struct kmem_cache *srb_cachep;

/*
 * CT6 CTX allocation cache
 */
static struct kmem_cache *ctx_cachep;
/*
 * error level for logging
 */
int ql_errlev = ql_log_all;

static int ql2xenableclass2;
module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR);
MODULE_PARM_DESC(ql2xenableclass2,
		"Specify if Class 2 operations are supported from the very "
		"beginning. Default is 0 - class 2 not supported.");

int ql2xlogintimeout = 20;
module_param(ql2xlogintimeout, int, S_IRUGO);
MODULE_PARM_DESC(ql2xlogintimeout,
		"Login timeout value in seconds.");

int qlport_down_retry;
module_param(qlport_down_retry, int, S_IRUGO);
MODULE_PARM_DESC(qlport_down_retry,
		"Maximum number of command retries to a port that returns "
		"a PORT-DOWN status.");

int ql2xplogiabsentdevice;
module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(ql2xplogiabsentdevice,
		"Option to enable PLOGI to devices that are not present after "
		"a Fabric scan.  This is needed for several broken switches. "
		"Default is 0 - no PLOGI. 1 - perfom PLOGI.");

int ql2xloginretrycount = 0;
module_param(ql2xloginretrycount, int, S_IRUGO);
MODULE_PARM_DESC(ql2xloginretrycount,
		"Specify an alternate value for the NVRAM login retry count.");

int ql2xallocfwdump = 1;
module_param(ql2xallocfwdump, int, S_IRUGO);
MODULE_PARM_DESC(ql2xallocfwdump,
		"Option to enable allocation of memory for a firmware dump "
		"during HBA initialization.  Memory allocation requirements "
		"vary by ISP type.  Default is 1 - allocate memory.");

int ql2xextended_error_logging;
module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(ql2xextended_error_logging,
		"Option to enable extended error logging,\n"
		"\t\tDefault is 0 - no logging.  0x40000000 - Module Init & Probe.\n"
		"\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n"
		"\t\t0x08000000 - IO tracing.    0x04000000 - DPC Thread.\n"
		"\t\t0x02000000 - Async events.  0x01000000 - Timer routines.\n"
		"\t\t0x00800000 - User space.    0x00400000 - Task Management.\n"
		"\t\t0x00200000 - AER/EEH.       0x00100000 - Multi Q.\n"
		"\t\t0x00080000 - P3P Specific.  0x00040000 - Virtual Port.\n"
		"\t\t0x00020000 - Buffer Dump.   0x00010000 - Misc.\n"
		"\t\t0x7fffffff - For enabling all logs, can be too many logs.\n"
		"\t\t0x1e400000 - Preferred value for capturing essential "
		"debug information (equivalent to old "
		"ql2xextended_error_logging=1).\n"
		"\t\tDo LOGICAL OR of the value to enable more than one level");

int ql2xshiftctondsd = 6;
module_param(ql2xshiftctondsd, int, S_IRUGO);
MODULE_PARM_DESC(ql2xshiftctondsd,
		"Set to control shifting of command type processing "
		"based on total number of SG elements.");

static void qla2x00_free_device(scsi_qla_host_t *);

int ql2xfdmienable=1;
module_param(ql2xfdmienable, int, S_IRUGO);
MODULE_PARM_DESC(ql2xfdmienable,
		"Enables FDMI registrations. "
		"0 - no FDMI. Default is 1 - perform FDMI.");

#define MAX_Q_DEPTH    32