blob: 97e6e1ea8c89e5d946e1ac96e6a9805e848e6125 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ibm_emac_core.h
3 *
4 * Ethernet driver for the built in ethernet on the IBM 405 PowerPC
5 * processor.
6 *
7 * Armin Kuster akuster@mvista.com
8 * Sept, 2001
9 *
10 * Orignial driver
11 * Johnnie Peters
12 * jpeters@mvista.com
13 *
14 * Copyright 2000 MontaVista Softare Inc.
15 *
16 * This program is free software; you can redistribute it and/or modify it
17 * under the terms of the GNU General Public License as published by the
18 * Free Software Foundation; either version 2 of the License, or (at your
19 * option) any later version.
20 */
21
22#ifndef _IBM_EMAC_CORE_H_
23#define _IBM_EMAC_CORE_H_
24
25#include <linux/netdevice.h>
26#include <asm/ocp.h>
27#include <asm/mmu.h> /* For phys_addr_t */
28
29#include "ibm_emac.h"
30#include "ibm_emac_phy.h"
31#include "ibm_emac_rgmii.h"
32#include "ibm_emac_zmii.h"
33#include "ibm_emac_mal.h"
34#include "ibm_emac_tah.h"
35
36#ifndef CONFIG_IBM_EMAC_TXB
37#define NUM_TX_BUFF 64
38#define NUM_RX_BUFF 64
39#else
40#define NUM_TX_BUFF CONFIG_IBM_EMAC_TXB
41#define NUM_RX_BUFF CONFIG_IBM_EMAC_RXB
42#endif
43
44/* This does 16 byte alignment, exactly what we need.
45 * The packet length includes FCS, but we don't want to
46 * include that when passing upstream as it messes up
47 * bridging applications.
48 */
49#ifndef CONFIG_IBM_EMAC_SKBRES
50#define SKB_RES 2
51#else
52#define SKB_RES CONFIG_IBM_EMAC_SKBRES
53#endif
54
55/* Note about alignement. alloc_skb() returns a cache line
56 * aligned buffer. However, dev_alloc_skb() will add 16 more
57 * bytes and "reserve" them, so our buffer will actually end
58 * on a half cache line. What we do is to use directly
59 * alloc_skb, allocate 16 more bytes to match the total amount
60 * allocated by dev_alloc_skb(), but we don't reserve.
61 */
62#define MAX_NUM_BUF_DESC 255
63#define DESC_BUF_SIZE 4080 /* max 4096-16 */
64#define DESC_BUF_SIZE_REG (DESC_BUF_SIZE / 16)
65
66/* Transmitter timeout. */
67#define TX_TIMEOUT (2*HZ)
68
69/* MDIO latency delay */
70#define MDIO_DELAY 250
71
72/* Power managment shift registers */
73#define IBM_CPM_EMMII 0 /* Shift value for MII */
74#define IBM_CPM_EMRX 1 /* Shift value for recv */
75#define IBM_CPM_EMTX 2 /* Shift value for MAC */
76#define IBM_CPM_EMAC(x) (((x)>>IBM_CPM_EMMII) | ((x)>>IBM_CPM_EMRX) | ((x)>>IBM_CPM_EMTX))
77
78#define ENET_HEADER_SIZE 14
79#define ENET_FCS_SIZE 4
80#define ENET_DEF_MTU_SIZE 1500
81#define ENET_DEF_BUF_SIZE (ENET_DEF_MTU_SIZE + ENET_HEADER_SIZE + ENET_FCS_SIZE)
82#define EMAC_MIN_FRAME 64
83#define EMAC_MAX_FRAME 9018
84#define EMAC_MIN_MTU (EMAC_MIN_FRAME - ENET_HEADER_SIZE - ENET_FCS_SIZE)
85#define EMAC_MAX_MTU (EMAC_MAX_FRAME - ENET_HEADER_SIZE - ENET_FCS_SIZE)
86
87#ifdef CONFIG_IBM_EMAC_ERRMSG
88void emac_serr_dump_0(struct net_device *dev);
89void emac_serr_dump_1(struct net_device *dev);
90void emac_err_dump(struct net_device *dev, int em0isr);
91void emac_phy_dump(struct net_device *);
92void emac_desc_dump(struct net_device *);
93void emac_mac_dump(struct net_device *);
94void emac_mal_dump(struct net_device *);
95#else
96#define emac_serr_dump_0(dev) do { } while (0)
97#define emac_serr_dump_1(dev) do { } while (0)
98#define emac_err_dump(dev,x) do { } while (0)
99#define emac_phy_dump(dev) do { } while (0)
100#define emac_desc_dump(dev) do { } while (0)
101#define emac_mac_dump(dev) do { } while (0)
102#define emac_mal_dump(dev) do { } while (0)
103#endif
104
105struct ocp_enet_private {
106 struct sk_buff *tx_skb[NUM_TX_BUFF];
107 struct sk_buff *rx_skb[NUM_RX_BUFF];
108 struct mal_descriptor *tx_desc;
109 struct mal_descriptor *rx_desc;
110 struct mal_descriptor *rx_dirty;
111 struct net_device_stats stats;
112 int tx_cnt;
113 int rx_slot;
114 int dirty_rx;
115 int tx_slot;
116 int ack_slot;
117 int rx_buffer_size;
118
119 struct mii_phy phy_mii;
120 int mii_phy_addr;
121 int want_autoneg;
122 int timer_ticks;
123 struct timer_list link_timer;
124 struct net_device *mdio_dev;
125
126 struct ocp_device *rgmii_dev;
127 int rgmii_input;
128
129 struct ocp_device *zmii_dev;
130 int zmii_input;
131
132 struct ibm_ocp_mal *mal;
133 int mal_tx_chan, mal_rx_chan;
134 struct mal_commac commac;
135
136 struct ocp_device *tah_dev;
137
138 int opened;
139 int going_away;
140 int wol_irq;
141 emac_t *emacp;
142 struct ocp_device *ocpdev;
143 struct net_device *ndev;
144 spinlock_t lock;
145};
146#endif /* _IBM_EMAC_CORE_H_ */