blob: aed68bed2365827aad8e38235fec216d57775db2 [file] [log] [blame]
Bryan Wue190d6b2007-07-17 14:43:44 +08001/*
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08002 * Blackfin On-Chip MAC Driver
Bryan Wue190d6b2007-07-17 14:43:44 +08003 *
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08004 * Copyright 2004-2007 Analog Devices Inc.
Bryan Wue190d6b2007-07-17 14:43:44 +08005 *
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08006 * Enter bugs at http://blackfin.uclinux.org/
Bryan Wue190d6b2007-07-17 14:43:44 +08007 *
Mike Frysinger2fb9d6f2008-01-30 16:52:24 +08008 * Licensed under the GPL-2 or later.
Bryan Wue190d6b2007-07-17 14:43:44 +08009 */
Barry Songfe92afe2010-05-17 17:19:40 -070010#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 Zhang4fcc3d32010-06-11 17:44:31 +080016#include <linux/timer.h>
Sonic Zhang02460d02010-06-11 10:44:22 +000017#include <linux/etherdevice.h>
18#include <linux/bfin_mac.h>
Bryan Wue190d6b2007-07-17 14:43:44 +080019
Bryan Wue190d6b2007-07-17 14:43:44 +080020#define BFIN_MAC_CSUM_OFFLOAD
21
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080022#define TX_RECLAIM_JIFFIES (HZ / 5)
23
Bryan Wue190d6b2007-07-17 14:43:44 +080024struct dma_descriptor {
25 struct dma_descriptor *next_dma_desc;
26 unsigned long start_addr;
27 unsigned short config;
28 unsigned short x_count;
29};
30
31struct status_area_rx {
32#if defined(BFIN_MAC_CSUM_OFFLOAD)
33 unsigned short ip_hdr_csum; /* ip header checksum */
34 /* ip payload(udp or tcp or others) checksum */
35 unsigned short ip_payload_csum;
36#endif
37 unsigned long status_word; /* the frame status word */
38};
39
40struct status_area_tx {
41 unsigned long status_word; /* the frame status word */
42};
43
44/* use two descriptors for a packet */
45struct net_dma_desc_rx {
46 struct net_dma_desc_rx *next;
47 struct sk_buff *skb;
48 struct dma_descriptor desc_a;
49 struct dma_descriptor desc_b;
50 struct status_area_rx status;
51};
52
53/* use two descriptors for a packet */
54struct net_dma_desc_tx {
55 struct net_dma_desc_tx *next;
56 struct sk_buff *skb;
57 struct dma_descriptor desc_a;
58 struct dma_descriptor desc_b;
59 unsigned char packet[1560];
60 struct status_area_tx status;
61};
62
Bryan Wu7ef0a7e2008-04-25 11:53:10 +080063struct bfin_mac_local {
Bryan Wue190d6b2007-07-17 14:43:44 +080064 /*
65 * these are things that the kernel wants me to keep, so users
66 * can find out semi-useless statistics of how well the card is
67 * performing
68 */
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080069 struct net_device_stats stats;
Bryan Wue190d6b2007-07-17 14:43:44 +080070
Bryan Wue190d6b2007-07-17 14:43:44 +080071 unsigned char Mac[6]; /* MAC address of the board */
72 spinlock_t lock;
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080073
Michael Hennerich53fd3f22010-05-10 05:39:11 +000074 int wol; /* Wake On Lan */
75 int irq_wake_requested;
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080076 struct timer_list tx_reclaim_timer;
77 struct net_device *ndev;
Michael Hennerich53fd3f22010-05-10 05:39:11 +000078
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080079 /* MII and PHY stuffs */
80 int old_link; /* used by bf537_adjust_link */
81 int old_speed;
82 int old_duplex;
83
84 struct phy_device *phydev;
Lennert Buytenhek298cf9b2008-10-08 16:29:57 -070085 struct mii_bus *mii_bus;
Barry Songfe92afe2010-05-17 17:19:40 -070086
87#if defined(CONFIG_BFIN_MAC_USE_HWSTAMP)
88 struct cyclecounter cycles;
89 struct timecounter clock;
90 struct timecompare compare;
91 struct hwtstamp_config stamp_cfg;
92#endif
Bryan Wue190d6b2007-07-17 14:43:44 +080093};
94
Mike Frysinger9862cc52007-11-15 21:21:20 +080095extern void bfin_get_ether_addr(char *addr);
Barry Songfe92afe2010-05-17 17:19:40 -070096
97#endif