patch-2.3.9 linux/drivers/net/sonic.h

Next file: linux/drivers/net/yellowfin.c
Previous file: linux/drivers/net/sonic.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.8/linux/drivers/net/sonic.h linux/drivers/net/sonic.h
@@ -15,16 +15,6 @@
 #define SONIC_H
 
 /*
- * Macros to access SONIC registers
- */
-#define SONIC_READ(reg) \
-	*((volatile unsigned int *)base_addr+reg)
-
-#define SONIC_WRITE(reg,val) \
-	*((volatile unsigned int *)base_addr+reg) = val
-
-
-/*
  * SONIC register offsets
  */
  
@@ -242,9 +232,9 @@
 
 typedef struct {
   u16 rx_status;	/* status after reception of a packet */
-  u16 pad0;
+  SREGS_PAD(pad0);
   u16 rx_pktlen;	/* length of the packet incl. CRC */
-  u16 pad1;
+  SREGS_PAD(pad1);
   
   /*
    * Pointers to the location in the receive buffer area (RBA)
@@ -252,22 +242,22 @@
    * a contiguous piece of memory.
    */
   u16 rx_pktptr_l;
-  u16 pad2;
+  SREGS_PAD(pad2);
   u16 rx_pktptr_h;
-  u16 pad3;
+  SREGS_PAD(pad3);
 
   u16 rx_seqno;	/* sequence no. */
-  u16 pad4;
+  SREGS_PAD(pad4);
 
   u16 link;		/* link to next RDD (end if EOL bit set) */
-  u16 pad5;
+  SREGS_PAD(pad5);
 
   /*
    * Owner of this descriptor, 0= driver, 1=sonic
    */
   
   u16 in_use;	
-  u16 pad6;
+  SREGS_PAD(pad6);
 
   caddr_t rda_next;		/* pointer to next RD */
 } sonic_rd_t;
@@ -278,23 +268,23 @@
  */
 typedef struct {
   u16 tx_status;	/* status after transmission of a packet */
-  u16 pad0;		
+  SREGS_PAD(pad0);
   u16 tx_config;	/* transmit configuration for this packet */
-  u16 pad1;		
+  SREGS_PAD(pad1);
   u16 tx_pktsize;	/* size of the packet to be transmitted */
-  u16 pad2;		
+  SREGS_PAD(pad2);
   u16 tx_frag_count;	/* no. of fragments */
-  u16 pad3;		
+  SREGS_PAD(pad3);
 
   u16 tx_frag_ptr_l;
-  u16 pad4;		
+  SREGS_PAD(pad4);
   u16 tx_frag_ptr_h;
-  u16 pad5;		
+  SREGS_PAD(pad5);
   u16 tx_frag_size;
-  u16 pad6;		
+  SREGS_PAD(pad6);
   
   u16 link;		/* ptr to next descriptor */
-  u16 pad7;		
+  SREGS_PAD(pad7);
 } sonic_td_t;
 
 
@@ -304,13 +294,13 @@
 
 typedef struct {
   u16 cam_entry_pointer;
-  u16 pad;
-  u16 cam_frag2;
-  u16 pad2;
-  u16 cam_frag1;
-  u16 pad1;
-  u16 cam_frag0;
-  u16 pad0;
+  SREGS_PAD(pad0);
+  u16 cam_cap0;
+  SREGS_PAD(pad1);
+  u16 cam_cap1;
+  SREGS_PAD(pad2);
+  u16 cam_cap2;
+  SREGS_PAD(pad3);
 } sonic_cd_t;
 
 #define CAM_DESCRIPTORS 16
@@ -319,8 +309,56 @@
 typedef struct {
   sonic_cd_t cam_desc[CAM_DESCRIPTORS];
   u16 cam_enable;
-  u16 pad;
+  SREGS_PAD(pad);
 } sonic_cda_t;
 
+/*
+ * Some tunables for the buffer areas. Power of 2 is required
+ * the current driver uses one receive buffer for each descriptor.
+ */
+#define SONIC_NUM_RRS    16             /* number of receive resources */
+#define SONIC_NUM_RDS    SONIC_NUM_RRS  /* number of receive descriptors */
+#define SONIC_NUM_TDS    16      /* number of transmit descriptors */
+#define SONIC_RBSIZE   1520      /* size of one resource buffer */
+
+#define SONIC_RDS_MASK   (SONIC_NUM_RDS-1)
+#define SONIC_TDS_MASK   (SONIC_NUM_TDS-1)
+
+
+/* Information that need to be kept for each board. */
+struct sonic_local {
+    sonic_cda_t   cda;                     /* virtual CPU address of CDA */
+    sonic_td_t    tda[SONIC_NUM_TDS];      /* transmit descriptor area */
+    sonic_rr_t    rra[SONIC_NUM_RRS];      /* receive resource arrea */
+    sonic_rd_t    rda[SONIC_NUM_RDS];      /* receive descriptor area */
+    struct sk_buff* tx_skb[SONIC_NUM_TDS]; /* skbuffs for packets to transmit */
+    unsigned int  tx_laddr[SONIC_NUM_TDS]; /* logical DMA address fro skbuffs */
+    unsigned char *rba;                    /* start of receive buffer areas */    
+    unsigned int  cda_laddr;               /* logical DMA address of CDA */    
+    unsigned int  tda_laddr;               /* logical DMA address of TDA */
+    unsigned int  rra_laddr;               /* logical DMA address of RRA */    
+    unsigned int  rda_laddr;               /* logical DMA address of RDA */
+    unsigned int  rba_laddr;               /* logical DMA address of RBA */
+    unsigned int  cur_rra;                 /* current indexes to resource areas */
+    unsigned int  cur_rx;
+    unsigned int  cur_tx;
+    unsigned int  dirty_tx;                /* last unacked transmit packet */
+    char tx_full;
+    struct enet_statistics stats;
+};
+
+/* Index to functions, as function prototypes. */
+
+static int sonic_open(struct device *dev);
+static int sonic_send_packet(struct sk_buff *skb, struct device *dev);
+static void sonic_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static void sonic_rx(struct device *dev);
+static int sonic_close(struct device *dev);
+static struct enet_statistics *sonic_get_stats(struct device *dev);
+static void sonic_multicast_list(struct device *dev);
+static int sonic_init(struct device *dev);
+
+static const char *version =
+	"sonic.c:v0.92 20.9.98 tsbogend@alpha.franken.de\n";
 
 #endif /* SONIC_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)