Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 1 | /* |
Mike Frysinger | 2fb9d6f | 2008-01-30 16:52:24 +0800 | [diff] [blame] | 2 | * Blackfin On-Chip MAC Driver |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 3 | * |
Mike Frysinger | 2fb9d6f | 2008-01-30 16:52:24 +0800 | [diff] [blame] | 4 | * Copyright 2004-2007 Analog Devices Inc. |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 5 | * |
Mike Frysinger | 2fb9d6f | 2008-01-30 16:52:24 +0800 | [diff] [blame] | 6 | * Enter bugs at http://blackfin.uclinux.org/ |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 7 | * |
Mike Frysinger | 2fb9d6f | 2008-01-30 16:52:24 +0800 | [diff] [blame] | 8 | * Licensed under the GPL-2 or later. |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 9 | */ |
Barry Song | fe92afe | 2010-05-17 17:19:40 -0700 | [diff] [blame] | 10 | #ifndef _BFIN_MAC_H_ |
| 11 | #define _BFIN_MAC_H_ |
| 12 | |
| 13 | #include <linux/net_tstamp.h> |
| 14 | #include <linux/clocksource.h> |
| 15 | #include <linux/timecompare.h> |
Sonic Zhang | 4fcc3d3 | 2010-06-11 17:44:31 +0800 | [diff] [blame] | 16 | #include <linux/timer.h> |
Sonic Zhang | 02460d0 | 2010-06-11 10:44:22 +0000 | [diff] [blame] | 17 | #include <linux/etherdevice.h> |
| 18 | #include <linux/bfin_mac.h> |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 19 | |
Sonic Zhang | 2d70a3d | 2011-01-10 02:54:33 +0000 | [diff] [blame] | 20 | /* |
| 21 | * Disable hardware checksum for bug #5600 if writeback cache is |
| 22 | * enabled. Otherwize, corrupted RX packet will be sent up stack |
| 23 | * without error mark. |
| 24 | */ |
| 25 | #ifndef CONFIG_BFIN_EXTMEM_WRITEBACK |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 26 | #define BFIN_MAC_CSUM_OFFLOAD |
Sonic Zhang | 2d70a3d | 2011-01-10 02:54:33 +0000 | [diff] [blame] | 27 | #endif |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 28 | |
Sonic Zhang | 4fcc3d3 | 2010-06-11 17:44:31 +0800 | [diff] [blame] | 29 | #define TX_RECLAIM_JIFFIES (HZ / 5) |
| 30 | |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 31 | struct dma_descriptor { |
| 32 | struct dma_descriptor *next_dma_desc; |
| 33 | unsigned long start_addr; |
| 34 | unsigned short config; |
| 35 | unsigned short x_count; |
| 36 | }; |
| 37 | |
| 38 | struct status_area_rx { |
| 39 | #if defined(BFIN_MAC_CSUM_OFFLOAD) |
| 40 | unsigned short ip_hdr_csum; /* ip header checksum */ |
| 41 | /* ip payload(udp or tcp or others) checksum */ |
| 42 | unsigned short ip_payload_csum; |
| 43 | #endif |
| 44 | unsigned long status_word; /* the frame status word */ |
| 45 | }; |
| 46 | |
| 47 | struct status_area_tx { |
| 48 | unsigned long status_word; /* the frame status word */ |
| 49 | }; |
| 50 | |
| 51 | /* use two descriptors for a packet */ |
| 52 | struct net_dma_desc_rx { |
| 53 | struct net_dma_desc_rx *next; |
| 54 | struct sk_buff *skb; |
| 55 | struct dma_descriptor desc_a; |
| 56 | struct dma_descriptor desc_b; |
| 57 | struct status_area_rx status; |
| 58 | }; |
| 59 | |
| 60 | /* use two descriptors for a packet */ |
| 61 | struct net_dma_desc_tx { |
| 62 | struct net_dma_desc_tx *next; |
| 63 | struct sk_buff *skb; |
| 64 | struct dma_descriptor desc_a; |
| 65 | struct dma_descriptor desc_b; |
| 66 | unsigned char packet[1560]; |
| 67 | struct status_area_tx status; |
| 68 | }; |
| 69 | |
Bryan Wu | 7ef0a7e | 2008-04-25 11:53:10 +0800 | [diff] [blame] | 70 | struct bfin_mac_local { |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 71 | /* |
| 72 | * these are things that the kernel wants me to keep, so users |
| 73 | * can find out semi-useless statistics of how well the card is |
| 74 | * performing |
| 75 | */ |
Bryan Wu | 4ae5a3a | 2007-09-19 23:37:36 +0800 | [diff] [blame] | 76 | struct net_device_stats stats; |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 77 | |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 78 | spinlock_t lock; |
Bryan Wu | 4ae5a3a | 2007-09-19 23:37:36 +0800 | [diff] [blame] | 79 | |
Michael Hennerich | 53fd3f2 | 2010-05-10 05:39:11 +0000 | [diff] [blame] | 80 | int wol; /* Wake On Lan */ |
| 81 | int irq_wake_requested; |
Sonic Zhang | 4fcc3d3 | 2010-06-11 17:44:31 +0800 | [diff] [blame] | 82 | struct timer_list tx_reclaim_timer; |
| 83 | struct net_device *ndev; |
Michael Hennerich | 53fd3f2 | 2010-05-10 05:39:11 +0000 | [diff] [blame] | 84 | |
Mike Frysinger | c599bd6 | 2011-01-10 02:54:32 +0000 | [diff] [blame] | 85 | /* Data for EMAC_VLAN1 regs */ |
| 86 | u16 vlan1_mask, vlan2_mask; |
| 87 | |
Bryan Wu | 4ae5a3a | 2007-09-19 23:37:36 +0800 | [diff] [blame] | 88 | /* MII and PHY stuffs */ |
| 89 | int old_link; /* used by bf537_adjust_link */ |
| 90 | int old_speed; |
| 91 | int old_duplex; |
| 92 | |
| 93 | struct phy_device *phydev; |
Lennert Buytenhek | 298cf9be | 2008-10-08 16:29:57 -0700 | [diff] [blame] | 94 | struct mii_bus *mii_bus; |
Barry Song | fe92afe | 2010-05-17 17:19:40 -0700 | [diff] [blame] | 95 | |
| 96 | #if defined(CONFIG_BFIN_MAC_USE_HWSTAMP) |
| 97 | struct cyclecounter cycles; |
| 98 | struct timecounter clock; |
| 99 | struct timecompare compare; |
| 100 | struct hwtstamp_config stamp_cfg; |
| 101 | #endif |
Bryan Wu | e190d6b | 2007-07-17 14:43:44 +0800 | [diff] [blame] | 102 | }; |
| 103 | |
Mike Frysinger | 9862cc5 | 2007-11-15 21:21:20 +0800 | [diff] [blame] | 104 | extern void bfin_get_ether_addr(char *addr); |
Barry Song | fe92afe | 2010-05-17 17:19:40 -0700 | [diff] [blame] | 105 | |
| 106 | #endif |