/drivers/power/

='switch'/> [ARCHIVE] Old LITMUS^RT 2008 version (for reference).Bjoern Brandenburg
aboutsummaryrefslogblamecommitdiffstats
path: root/drivers/net/hp100.c
blob: 844c136e9920cc92c98d5abbb60c7a8a7767a14c (plain) (tree)
1
2
3
4
5
6
7
8
  
          




                                                                      
                                                 


                                                                             
  

                                           
                                 

                                                


                                                               
  













































                                                                              
  






                                                             
                                                

                                                               
                         


















                                                                      








                            
                              




                              


                         
                          








































































                                                                                    
                 



                                       
      






















































                                                                                         
                                                          



























                                                                        
                                                                     








                                                                            
                                                













































                                                                         
                 



















                                                                      
                                                   


















                                                                      
                                              


                                                  
                           











                                                                
                       
 
                                           























                                                                              
                   



                            
                                  
























                                                                      
                                                    









































                                                                                                     
                                                    
































































                                                                                                          
                                                                         


































































































































                                                                                                                                                                            
                             
                                                                             
                                                        

























                                                                                                                                                                 
                                                                                  



















































                                                                                                                       



                                   
                 

                            

                                                                     


                                                                                


                                                  
                   








































































                                                                                
                                                                          
















                                                                                     
 

  
                                                       
                                                           
























                                                                                              
                          









































































                                                                                            
                                                                                   





























































































                                                                                            
                                                                     



















































                                                                                 
 

  
                                     














































                                                                                                
 
















                                                                          
          

                                                                            
                                                                        

























                                                                                                              
                                                                          
                                                                        
                         


















                                                       
                                                                        




                                                                         
                  










                                                                                      
                                                                                 
                                                                                    

                                                                              










                                                                                         
                                                                























































































































                                                                                                                        
                                                                        














                                                                                             
                                                                  





































                                                                                             
  






















                                                                           
 

                                                                        







                                                                                      
                                                                













































































                                                                                                                                            
 





                                                                          
                                       

































































                                                                                                                       
                                                                  
































































                                                                                                           



                                                                                         























                                                                                        
 


                                        
                                                                     


                                                                      
                



































                                                                                                             
                                                         






























                                                                                         


                                                                             






























                                                                                                              
  



















                                                                                                           
                                                                                           











                                                                                                        
                                             

























































































































































                                                                                                                        
 











































































































































                                                                                                                         
                                                         


































                                                                                                                


                                                                                 









                                                                                                              
          
























                                                                                         



                                                                                 











                                                                  

                                                                            



                                                           


                                                                             



                                                           
          





















































































































































































                                                                                                                          

                                                     


                                                                
 





















                                                                             

                                                          














                                                                           

                                                          




































                                                                                              

                                                                  









                                                                             

                                                          










                                                                            

                                                          
















































                                                                                         

                                                                  

































                                                                                           

                                                                  





















                                                                                                      

                                                                          
































































































































                                                                                                                                                          

                                                                    























                                                                               
                  
                                                                    



                                  


























































                                                                                              
 

                                                             
                
                          
 




                                                                            





































































                                                                                              


                                                     





                                         
                                          






















                                                          
                                  



                                                 
                                  



































                                                                                                                
/*
** hp100.c
** HP CASCADE Architecture Driver for 100VG-AnyLan Network Adapters
**
** $Id: hp100.c,v 1.58 2001/09/24 18:03:01 perex Exp perex $
**
** Based on the HP100 driver written by Jaroslav Kysela <perex@jcu.cz>
** Extended for new busmaster capable chipsets by
** Siegfried "Frieder" Loeffler (dg1sek) <floeff@mathematik.uni-stuttgart.de>
**
** Maintained by: Jaroslav Kysela <perex@suse.cz>
**
** This driver has only been tested with
** -- HP J2585B 10/100 Mbit/s PCI Busmaster
** -- HP J2585A 10/100 Mbit/s PCI
** -- HP J2970A 10 Mbit/s PCI Combo 10base-T/BNC
** -- HP J2973A 10 Mbit/s PCI 10base-T
** -- HP J2573  10/100 ISA
** -- Compex ReadyLink ENET100-VG4  10/100 Mbit/s PCI / EISA
** -- Compex FreedomLine 100/VG  10/100 Mbit/s ISA / EISA / PCI
**
** but it should also work with the other CASCADE based adapters.
**
** TODO:
**       -  J2573 seems to hang sometimes when in shared memory mode.
**       -  Mode for Priority TX
**       -  Check PCI registers, performance might be improved?
**       -  To reduce interrupt load in busmaster, one could switch off
**          the interrupts that are used to refill the queues whenever the
**          queues are filled up to more than a certain threshold.
**       -  some updates for EISA version of card
**
**
**   This code is free software; you can redistribute it and/or modify
**   it under the terms of the GNU General Public License as published by
**   the Free Software Foundation; either version 2 of the License, or
**   (at your option) any later version.
**
**   This code is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**   GNU General Public License for more details.
**
**   You should have received a copy of the GNU General Public License
**   along with this program; if not, write to the Free Software
**   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** 1.57c -> 1.58
**   - used indent to change coding-style
**   - added KTI DP-200 EISA ID
**   - ioremap is also used for low (<1MB) memory (multi-architecture support)
**
** 1.57b -> 1.57c - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
**   - release resources on failure in init_module
**
** 1.57 -> 1.57b - Jean II
**   - fix spinlocks, SMP is now working !
**
** 1.56 -> 1.57
**   - updates for new PCI interface for 2.1 kernels
**
** 1.55 -> 1.56
**   - removed printk in misc. interrupt and update statistics to allow
**     monitoring of card status
**   - timing changes in xmit routines, relogin to 100VG hub added when
**     driver does reset
**   - included fix for Compex FreedomLine PCI adapter
**
** 1.54 -> 1.55
**   - fixed bad initialization in init_module
**   - added Compex FreedomLine adapter
**   - some fixes in card initialization
**
** 1.53 -> 1.54
**   - added hardware multicast filter support (doesn't work)
**   - little changes in hp100_sense_lan routine
**     - added support for Coax and AUI (J2970)
**   - fix for multiple cards and hp100_mode parameter (insmod)
**   - fix for shared IRQ
**
** 1.52 -> 1.53
**   - fixed bug in multicast support
**
*/

#define HP100_DEFAULT_PRIORITY_TX 0

#undef HP100_DEBUG
#undef HP100_DEBUG_B		/* Trace  */
#undef HP100_DEBUG_BM		/* Debug busmaster code (PDL stuff) */

#undef HP100_DEBUG_TRAINING	/* Debug login-to-hub procedure */
#undef HP100_DEBUG_TX
#undef HP100_DEBUG_IRQ
#undef HP100_DEBUG_RX

#undef HP100_MULTICAST_FILTER	/* Need to be debugged... */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/eisa.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/spinlock.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/bitops.h>
#include <linux/jiffies.h>

#include <asm/io.h>

#include "hp100.h"

/*
 *  defines
 */

#define HP100_BUS_ISA     0
#define HP100_BUS_EISA    1
#define HP100_BUS_PCI     2

#define HP100_REGION_SIZE	0x20	/* for ioports */
#define HP100_SIG_LEN		8	/* same as EISA_SIG_LEN */

#define HP100_MAX_PACKET_SIZE	(1536+4)
#define HP100_MIN_PACKET_SIZE	60

#ifndef HP100_DEFAULT_RX_RATIO
/* default - 75% onboard memory on the card are used for RX packets */
#define HP100_DEFAULT_RX_RATIO	75
#endif

#ifndef HP100_DEFAULT_PRIORITY_TX
/* default - don't enable transmit outgoing packets as priority */
#define HP100_DEFAULT_PRIORITY_TX 0
#endif

/*
 *  structures
 */

struct hp100_private {
	spinlock_t lock;
	char id[HP100_SIG_LEN];
	u_short chip;
	u_short soft_model;
	u_int memory_size;
	u_int virt_memory_size;
	u_short rx_ratio;	/* 1 - 99 */
	u_short priority_tx;	/* != 0 - priority tx */
	u_short mode;		/* PIO, Shared Mem or Busmaster */
	u_char bus;
	struct pci_dev *pci_dev;
	short mem_mapped;	/* memory mapped access */
	void __iomem *mem_ptr_virt;	/* virtual memory mapped area, maybe NULL */
	unsigned long mem_ptr_phys;	/* physical memory mapped area */
	short lan_type;		/* 10Mb/s, 100Mb/s or -1 (error) */
	int hub_status;		/* was login to hub successful? */
	u_char mac1_mode;
	u_char mac2_mode;
	u_char hash_bytes[8];
	struct net_device_stats stats;

	/* Rings for busmaster mode: */
	hp100_ring_t *rxrhead;	/* Head (oldest) index into rxring */
	hp100_ring_t *rxrtail;	/* Tail (newest) index into rxring */
	hp100_ring_t *txrhead;	/* Head (oldest) index into txring */
	hp100_ring_t *txrtail;	/* Tail (newest) index into txring */

	hp100_ring_t rxring[MAX_RX_PDL];
	hp100_ring_t txring[MAX_TX_PDL];

	u_int *page_vaddr_algn;	/* Aligned virtual address of allocated page */
	u_long whatever_offset;	/* Offset to bus/phys/dma address */
	int rxrcommit;		/* # Rx PDLs commited to adapter */
	int txrcommit;		/* # Tx PDLs commited to adapter */
};

/*
 *  variables
 */
#ifdef CONFIG_ISA
static const char *hp100_isa_tbl[] = {
	"HWPF150", /* HP J2573 rev A */
	"HWP1950", /* HP J2573 */
};
#endif

#ifdef CONFIG_EISA
static struct eisa_device_id hp100_eisa_tbl[] = {
	{ "HWPF180" }, /* HP J2577 rev A */
	{ "HWP1920" }, /* HP 27248B */
	{ "HWP1940" }, /* HP J2577 */
	{ "HWP1990" }, /* HP J2577 */
	{ "CPX0301" }, /* ReadyLink ENET100-VG4 */
	{ "CPX0401" }, /* FreedomLine 100/VG */
	{ "" }	       /* Mandatory final entry ! */
};
MODULE_DEVICE_TABLE(eisa, hp100_eisa_tbl);
#endif

#ifdef CONFIG_PCI
static struct pci_device_id hp100_pci_tbl[] = {
	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A, PCI_ANY_ID, PCI_ANY_ID,},
	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585B, PCI_ANY_ID, PCI_ANY_ID,},
	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2970A, PCI_ANY_ID, PCI_ANY_ID,},
	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2973A, PCI_ANY_ID, PCI_ANY_ID,},
	{PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_ENET100VG4, PCI_ANY_ID, PCI_ANY_ID,},
	{PCI_VENDOR_ID_COMPEX2, PCI_DEVICE_ID_COMPEX2_100VG, PCI_ANY_ID, PCI_ANY_ID,},
/*	{PCI_VENDOR_ID_KTI, PCI_DEVICE_ID_KTI_DP200, PCI_ANY_ID, PCI_ANY_ID }, */
	{}			/* Terminating entry */
};
MODULE_DEVICE_TABLE(pci, hp100_pci_tbl);
#endif

static int hp100_rx_ratio = HP100_DEFAULT_RX_RATIO;
static int hp100_priority_tx = HP100_DEFAULT_PRIORITY_TX;
static int hp100_mode = 1;

module_param(hp100_rx_ratio, int, 0);
module_param(hp100_priority_tx, int, 0);
module_param(hp100_mode, int, 0);

/*
 *  prototypes
 */

static int hp100_probe1(struct net_device *dev, int ioaddr, u_char bus,
			struct pci_dev *pci_dev);


static int hp100_open(struct net_device *dev);
static int hp100_close(struct net_device *dev);
static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev);
static int hp100_start_xmit_bm(struct sk_buff *skb,
			       struct net_device *dev);
static void hp100_rx(struct net_device *dev);
static struct net_device_stats *hp100_get_stats(struct net_device *dev);
static void hp100_misc_interrupt(struct net_device *dev);
static void hp100_update_stats(struct net_device *dev);
static void hp100_clear_stats(struct hp100_private *lp, int ioaddr);
static void hp100_set_multicast_list(struct net_device *dev);
static irqreturn_t hp100_interrupt(int irq, void *dev_id);
static void hp100_start_interface(struct net_device *dev);
static void hp100_stop_interface(struct net_device *dev);
static void hp100_load_eeprom(struct net_device *dev, u_short ioaddr);
static int hp100_sense_lan(struct net_device *dev);
static int hp100_login_to_vg_hub(struct net_device *dev,
				 u_short force_relogin);
static int hp100_down_vg_link(struct net_device *dev);
static void hp100_cascade_reset(struct net_device *dev, u_short enable);
static void hp100_BM_shutdown(struct net_device *dev);
static void hp100_mmuinit(struct net_device *dev);
static void hp100_init_pdls(struct net_device *dev);
static int hp100_init_rxpdl(struct net_device *dev,
			    register hp100_ring_t * ringptr,
			    register u_int * pdlptr);
static int hp100_init_txpdl(struct net_device *dev,
			    register hp100_ring_t * ringptr,
			    register u_int * pdlptr);
static void hp100_rxfill(struct net_device *dev);
static void hp100_hwinit(struct net_device *dev);
static void hp100_clean_txring(struct net_device *dev);
#ifdef HP100_DEBUG
static void hp100_RegisterDump(struct net_device *dev);
#endif

/* Conversion to new PCI API :
 * Convert an address in a kernel buffer to a bus/phys/dma address.