blob: 57f042c3111ca58b042b22ac87b07c0e151d9605 [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>
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080014#include <linux/timer.h>
Sonic Zhang02460d02010-06-11 10:44:22 +000015#include <linux/etherdevice.h>
16#include <linux/bfin_mac.h>
Bryan Wue190d6b2007-07-17 14:43:44 +080017
Sonic Zhang2d70a3d2011-01-10 02:54:33 +000018/*
19 * Disable hardware checksum for bug #5600 if writeback cache is
20 * enabled. Otherwize, corrupted RX packet will be sent up stack
21 * without error mark.
22 */
23#ifndef CONFIG_BFIN_EXTMEM_WRITEBACK
Bryan Wue190d6b2007-07-17 14:43:44 +080024#define BFIN_MAC_CSUM_OFFLOAD
Sonic Zhang2d70a3d2011-01-10 02:54:33 +000025#endif
Bryan Wue190d6b2007-07-17 14:43:44 +080026
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080027#define TX_RECLAIM_JIFFIES (HZ / 5)
28
Bryan Wue190d6b2007-07-17 14:43:44 +080029struct dma_descriptor {
30 struct dma_descriptor *next_dma_desc;
31 unsigned long start_addr;
32 unsigned short config;
33 unsigned short x_count;
34};
35
36struct status_area_rx {
37#if defined(BFIN_MAC_CSUM_OFFLOAD)
38 unsigned short ip_hdr_csum; /* ip header checksum */
39 /* ip payload(udp or tcp or others) checksum */
40 unsigned short ip_payload_csum;
41#endif
42 unsigned long status_word; /* the frame status word */
43};
44
45struct status_area_tx {
46 unsigned long status_word; /* the frame status word */
47};
48
49/* use two descriptors for a packet */
50struct net_dma_desc_rx {
51 struct net_dma_desc_rx *next;
52 struct sk_buff *skb;
53 struct dma_descriptor desc_a;
54 struct dma_descriptor desc_b;
55 struct status_area_rx status;
56};
57
58/* use two descriptors for a packet */
59struct net_dma_desc_tx {
60 struct net_dma_desc_tx *next;
61 struct sk_buff *skb;
62 struct dma_descriptor desc_a;
63 struct dma_descriptor desc_b;
64 unsigned char packet[1560];
65 struct status_area_tx status;
66};
67
Bryan Wu7ef0a7e2008-04-25 11:53:10 +080068struct bfin_mac_local {
Bryan Wue190d6b2007-07-17 14:43:44 +080069 /*
70 * these are things that the kernel wants me to keep, so users
71 * can find out semi-useless statistics of how well the card is
72 * performing
73 */
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080074 struct net_device_stats stats;
Bryan Wue190d6b2007-07-17 14:43:44 +080075
Bryan Wue190d6b2007-07-17 14:43:44 +080076 spinlock_t lock;
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080077
Michael Hennerich53fd3f22010-05-10 05:39:11 +000078 int wol; /* Wake On Lan */
79 int irq_wake_requested;
Sonic Zhang4fcc3d32010-06-11 17:44:31 +080080 struct timer_list tx_reclaim_timer;
81 struct net_device *ndev;
Michael Hennerich53fd3f22010-05-10 05:39:11 +000082
Mike Frysingerc599bd62011-01-10 02:54:32 +000083 /* Data for EMAC_VLAN1 regs */
84 u16 vlan1_mask, vlan2_mask;
85
Bryan Wu4ae5a3a2007-09-19 23:37:36 +080086 /* MII and PHY stuffs */
87 int old_link; /* used by bf537_adjust_link */
88 int old_speed;
89 int old_duplex;
90
91 struct phy_device *phydev;
Lennert Buytenhek298cf9b2008-10-08 16:29:57 -070092 struct mii_bus *mii_bus;
Barry Songfe92afe2010-05-17 17:19:40 -070093
94#if defined(CONFIG_BFIN_MAC_USE_HWSTAMP)
Richard Cochranbc3c5f62012-10-31 06:27:23 +000095 u32 addend;
96 unsigned int shift;
Barry Songfe92afe2010-05-17 17:19:40 -070097 struct hwtstamp_config stamp_cfg;
98#endif
Bryan Wue190d6b2007-07-17 14:43:44 +080099};
100
Danny Kukawka5055d2f2012-02-16 07:09:31 +0000101extern int bfin_get_ether_addr(char *addr);
Barry Songfe92afe2010-05-17 17:19:40 -0700102
103#endif