author | Dave Page <dave.page@gleeble.com> |
Thu, 26 Mar 2015 15:16:21 -0400 | |
changeset 2609 | 777d1a8b3a27 |
parent 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
Network Driver for Beckhoff CCAT communication controller |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
Copyright (C) 2014 Beckhoff Automation GmbH |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
Author: Patrick Bruenn <p.bruenn@beckhoff.com> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
This program is free software; you can redistribute it and/or modify |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
it under the terms of the GNU General Public License as published by |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
the Free Software Foundation; either version 2 of the License, or |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
(at your option) any later version. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
This program is distributed in the hope that it will be useful, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
GNU General Public License for more details. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
You should have received a copy of the GNU General Public License along |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
with this program; if not, write to the Free Software Foundation, Inc., |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
#include <linux/etherdevice.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
#include <linux/kernel.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
#include <linux/module.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
#include <linux/netdevice.h> |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
#include "module.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
#include "netdev.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* EtherCAT frame to enable forwarding on EtherCAT Terminals |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
static const u8 frameForwardEthernetFrames[] = { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
0x01, 0x01, 0x05, 0x01, 0x00, 0x00, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
0x00, 0x1b, 0x21, 0x36, 0x1b, 0xce, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
0x88, 0xa4, 0x0e, 0x10, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
0x08, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
0x00, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
0x00, 0x00, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
0x00, 0x01, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
0x02, 0x00, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
0x00, 0x00, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
0x00, 0x00, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
0x00, 0x00 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
}; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#define FIFO_LENGTH 64 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
#define POLL_TIME ktime_set(0, 100 * NSEC_PER_USEC) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
* Helper to check if frame in tx dma memory was already marked as sent by CCAT |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
static inline bool ccat_eth_frame_sent(const struct ccat_eth_frame *const frame) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
return le32_to_cpu(frame->tx_flags) & CCAT_FRAME_SENT; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
* Helper to check if frame in tx dma memory was already marked as sent by CCAT |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
static inline bool ccat_eth_frame_received(const struct ccat_eth_frame *const |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
frame) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
return le32_to_cpu(frame->rx_flags) & CCAT_FRAME_RECEIVED; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
static void ecdev_kfree_skb_any(struct sk_buff *skb) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
/* never release a skb in EtherCAT mode */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
static bool ecdev_carrier_ok(const struct net_device *const netdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
struct ccat_eth_priv *const priv = netdev_priv(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
return ecdev_get_link(priv->ecdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
static void ecdev_carrier_on(struct net_device *const netdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
struct ccat_eth_priv *const priv = netdev_priv(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
ecdev_set_link(priv->ecdev, 1); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
static void ecdev_carrier_off(struct net_device *const netdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
struct ccat_eth_priv *const priv = netdev_priv(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
ecdev_set_link(priv->ecdev, 0); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
static void ecdev_nop(struct net_device *const netdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
/* dummy called if nothing has to be done in EtherCAT operation mode */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
static void unregister_ecdev(struct net_device *const netdev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
struct ccat_eth_priv *const priv = netdev_priv(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
ecdev_close(priv->ecdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
ecdev_withdraw(priv->ecdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
static void ccat_eth_fifo_inc(struct ccat_eth_dma_fifo *fifo) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
if (++fifo->next >= fifo->end) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
fifo->next = fifo->dma.virt; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
typedef void (*fifo_add_function) (struct ccat_eth_dma_fifo *, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
struct ccat_eth_frame *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
static void ccat_eth_rx_fifo_add(struct ccat_eth_dma_fifo *fifo, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
struct ccat_eth_frame *frame) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
const size_t offset = ((void *)(frame) - fifo->dma.virt); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
const u32 addr_and_length = (1 << 31) | offset; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
frame->rx_flags = cpu_to_le32(0); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
iowrite32(addr_and_length, fifo->reg); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
static void ccat_eth_tx_fifo_add_free(struct ccat_eth_dma_fifo *fifo, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
struct ccat_eth_frame *frame) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
/* mark frame as ready to use for tx */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
frame->tx_flags = cpu_to_le32(CCAT_FRAME_SENT); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
static void ccat_eth_dma_fifo_reset(struct ccat_eth_dma_fifo *fifo) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
/* reset hw fifo */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
iowrite32(0, fifo->reg + 0x8); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
wmb(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
if (fifo->add) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
fifo->next = fifo->dma.virt; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
do { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
fifo->add(fifo, fifo->next); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
ccat_eth_fifo_inc(fifo); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
} while (fifo->next != fifo->dma.virt); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
static int ccat_eth_dma_fifo_init(struct ccat_eth_dma_fifo *fifo, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
void __iomem * const fifo_reg, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
fifo_add_function add, size_t channel, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
struct ccat_eth_priv *const priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
if (0 != |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
ccat_dma_init(&fifo->dma, channel, priv->ccatdev->bar[2].ioaddr, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
&priv->ccatdev->pdev->dev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
pr_info("init DMA%llu memory failed.\n", (u64) channel); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
fifo->add = add; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
fifo->end = ((struct ccat_eth_frame *)fifo->dma.virt) + FIFO_LENGTH; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
fifo->reg = fifo_reg; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
* Stop both (Rx/Tx) DMA fifo's and free related management structures |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
static void ccat_eth_priv_free_dma(struct ccat_eth_priv *priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
/* reset hw fifo's */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
iowrite32(0, priv->rx_fifo.reg + 0x8); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
iowrite32(0, priv->tx_fifo.reg + 0x8); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
wmb(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
/* release dma */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
ccat_dma_free(&priv->rx_fifo.dma); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
ccat_dma_free(&priv->tx_fifo.dma); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
* Initalizes both (Rx/Tx) DMA fifo's and related management structures |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
static int ccat_eth_priv_init_dma(struct ccat_eth_priv *priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
if (ccat_eth_dma_fifo_init |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
(&priv->rx_fifo, priv->reg.rx_fifo, ccat_eth_rx_fifo_add, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
priv->info.rx_dma_chan, priv)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
pr_warn("init Rx DMA fifo failed.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
if (ccat_eth_dma_fifo_init |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
(&priv->tx_fifo, priv->reg.tx_fifo, ccat_eth_tx_fifo_add_free, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
priv->info.tx_dma_chan, priv)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
pr_warn("init Tx DMA fifo failed.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
ccat_dma_free(&priv->rx_fifo.dma); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
return -1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
/* disable MAC filter */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
iowrite8(0, priv->reg.mii + 0x8 + 6); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
wmb(); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
* Initializes the CCat... members of the ccat_eth_priv structure. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
* Call this function only if info and ioaddr are already initialized! |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
static void ccat_eth_priv_init_mappings(struct ccat_eth_priv *priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
struct ccat_mac_infoblock offsets; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
void __iomem *const func_base = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
priv->ccatdev->bar[0].ioaddr + priv->info.addr; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
memcpy_fromio(&offsets, func_base, sizeof(offsets)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
priv->reg.mii = func_base + offsets.mii; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
priv->reg.tx_fifo = func_base + offsets.tx_fifo; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
priv->reg.rx_fifo = func_base + offsets.tx_fifo + 0x10; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
priv->reg.mac = func_base + offsets.mac; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
priv->reg.rx_mem = func_base + offsets.rx_mem; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
priv->reg.tx_mem = func_base + offsets.tx_mem; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
priv->reg.misc = func_base + offsets.misc; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
static netdev_tx_t ccat_eth_start_xmit(struct sk_buff *skb, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
struct net_device *dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
struct ccat_eth_dma_fifo *const fifo = &priv->tx_fifo; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
u32 addr_and_length; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
if (skb_is_nonlinear(skb)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
pr_warn("Non linear skb not supported -> drop frame.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
atomic64_inc(&priv->tx_dropped); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
priv->kfree_skb_any(skb); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
return NETDEV_TX_OK; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
if (skb->len > sizeof(fifo->next->data)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
pr_warn("skb.len %llu exceeds dma buffer %llu -> drop frame.\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
(u64) skb->len, (u64) sizeof(fifo->next->data)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
atomic64_inc(&priv->tx_dropped); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
priv->kfree_skb_any(skb); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
return NETDEV_TX_OK; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
if (!ccat_eth_frame_sent(fifo->next)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
netdev_err(dev, "BUG! Tx Ring full when queue awake!\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
priv->stop_queue(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
return NETDEV_TX_BUSY; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
/* prepare frame in DMA memory */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
fifo->next->tx_flags = cpu_to_le32(0); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
fifo->next->length = cpu_to_le16(skb->len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
memcpy(fifo->next->data, skb->data, skb->len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
/* Queue frame into CCAT TX-FIFO, CCAT ignores the first 8 bytes of the tx descriptor */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
addr_and_length = offsetof(struct ccat_eth_frame, length); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
addr_and_length += ((void *)fifo->next - fifo->dma.virt); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
addr_and_length += ((skb->len + CCAT_ETH_FRAME_HEAD_LEN) / 8) << 24; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
iowrite32(addr_and_length, priv->reg.tx_fifo); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
/* update stats */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
atomic64_add(skb->len, &priv->tx_bytes); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
priv->kfree_skb_any(skb); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
ccat_eth_fifo_inc(fifo); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
/* stop queue if tx ring is full */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
if (!ccat_eth_frame_sent(fifo->next)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
priv->stop_queue(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
return NETDEV_TX_OK; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
* Function to transmit a raw buffer to the network (f.e. frameForwardEthernetFrames) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
* @dev a valid net_device |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
* @data pointer to your raw buffer |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
* @len number of bytes in the raw buffer to transmit |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
static void ccat_eth_xmit_raw(struct net_device *dev, const char *const data, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
size_t len) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
struct sk_buff *skb = dev_alloc_skb(len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
skb->dev = dev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
skb_copy_to_linear_data(skb, data, len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
skb_put(skb, len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
ccat_eth_start_xmit(skb, dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
static void ccat_eth_receive(struct net_device *const dev, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
const void *const data, const size_t len) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
struct sk_buff *const skb = dev_alloc_skb(len + NET_IP_ALIGN); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
if (!skb) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
pr_info("%s() out of memory :-(\n", __FUNCTION__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
atomic64_inc(&priv->rx_dropped); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
299 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
skb->dev = dev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
301 |
skb_reserve(skb, NET_IP_ALIGN); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
skb_copy_to_linear_data(skb, data, len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
skb_put(skb, len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
skb->protocol = eth_type_trans(skb, dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
skb->ip_summed = CHECKSUM_UNNECESSARY; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
atomic64_add(len, &priv->rx_bytes); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
netif_rx(skb); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
310 |
static void ccat_eth_link_down(struct net_device *const dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
312 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
313 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
314 |
priv->stop_queue(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
315 |
priv->carrier_off(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
316 |
netdev_info(dev, "NIC Link is Down\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
317 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
318 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
319 |
static void ccat_eth_link_up(struct net_device *const dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
321 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
netdev_info(dev, "NIC Link is Up\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
324 |
/* TODO netdev_info(dev, "NIC Link is Up %u Mbps %s Duplex\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
325 |
speed == SPEED_100 ? 100 : 10, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
326 |
cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
328 |
ccat_eth_dma_fifo_reset(&priv->rx_fifo); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
ccat_eth_dma_fifo_reset(&priv->tx_fifo); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
330 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
331 |
/* TODO reset CCAT MAC register */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
333 |
ccat_eth_xmit_raw(dev, frameForwardEthernetFrames, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
sizeof(frameForwardEthernetFrames)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
335 |
priv->carrier_on(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
priv->start_queue(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
* Read link state from CCAT hardware |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
* @return 1 if link is up, 0 if not |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
inline static size_t ccat_eth_priv_read_link_state(const struct ccat_eth_priv |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
*const priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
return (1 << 24) == (ioread32(priv->reg.mii + 0x8 + 4) & (1 << 24)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
347 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
348 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
349 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
* Poll for link state changes |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
351 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
352 |
static void poll_link(struct ccat_eth_priv *const priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
353 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
const size_t link = ccat_eth_priv_read_link_state(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
if (link != priv->carrier_ok(priv->netdev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
357 |
if (link) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
358 |
ccat_eth_link_up(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
359 |
else |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
360 |
ccat_eth_link_down(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
361 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
362 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
363 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
364 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
365 |
* Poll for available rx dma descriptors in ethernet operating mode |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
366 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
367 |
static void poll_rx(struct ccat_eth_priv *const priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
368 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
369 |
static const size_t overhead = CCAT_ETH_FRAME_HEAD_LEN - 4; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
370 |
struct ccat_eth_dma_fifo *const fifo = &priv->rx_fifo; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
371 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
372 |
/* TODO omit possible deadlock in situations with heavy traffic */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
373 |
while (ccat_eth_frame_received(fifo->next)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
374 |
const size_t len = le16_to_cpu(fifo->next->length) - overhead; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
375 |
if (priv->ecdev) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
376 |
ecdev_receive(priv->ecdev, fifo->next->data, len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
377 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
378 |
ccat_eth_receive(priv->netdev, fifo->next->data, len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
379 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
380 |
ccat_eth_rx_fifo_add(fifo, fifo->next); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
ccat_eth_fifo_inc(fifo); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
383 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
384 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
static void ec_poll_rx(struct net_device *dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
387 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
388 |
poll_rx(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
389 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
390 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
391 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
392 |
* Poll for available tx dma descriptors in ethernet operating mode |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
static void poll_tx(struct ccat_eth_priv *const priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
395 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
if (ccat_eth_frame_sent(priv->tx_fifo.next)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
397 |
netif_wake_queue(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
398 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
399 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
400 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
401 |
/** |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
402 |
* Since CCAT doesn't support interrupts until now, we have to poll |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
* some status bits to recognize things like link change etc. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
404 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
static enum hrtimer_restart poll_timer_callback(struct hrtimer *timer) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
406 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
407 |
struct ccat_eth_priv *const priv = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
408 |
container_of(timer, struct ccat_eth_priv, poll_timer); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
410 |
poll_link(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
411 |
if(!priv->ecdev) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
412 |
poll_rx(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
413 |
poll_tx(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
414 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
hrtimer_forward_now(timer, POLL_TIME); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
return HRTIMER_RESTART; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
static struct rtnl_link_stats64 *ccat_eth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
*storage) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
421 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
422 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
struct ccat_mac_register mac; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
424 |
memcpy_fromio(&mac, priv->reg.mac, sizeof(mac)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
storage->rx_packets = mac.rx_frames; /* total packets received */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
storage->tx_packets = mac.tx_frames; /* total packets transmitted */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
storage->rx_bytes = atomic64_read(&priv->rx_bytes); /* total bytes received */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
storage->tx_bytes = atomic64_read(&priv->tx_bytes); /* total bytes transmitted */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
storage->rx_errors = mac.frame_len_err + mac.rx_mem_full + mac.crc_err + mac.rx_err; /* bad packets received */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
storage->tx_errors = mac.tx_mem_full; /* packet transmit problems */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
storage->rx_dropped = atomic64_read(&priv->rx_dropped); /* no space in linux buffers */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
storage->tx_dropped = atomic64_read(&priv->tx_dropped); /* no space available in linux */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
//TODO __u64 multicast; /* multicast packets received */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
//TODO __u64 collisions; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
/* detailed rx_errors: */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
storage->rx_length_errors = mac.frame_len_err; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
438 |
storage->rx_over_errors = mac.rx_mem_full; /* receiver ring buff overflow */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
storage->rx_crc_errors = mac.crc_err; /* recved pkt with crc error */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
storage->rx_frame_errors = mac.rx_err; /* recv'd frame alignment error */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
storage->rx_fifo_errors = mac.rx_mem_full; /* recv'r fifo overrun */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
442 |
//TODO __u64 rx_missed_errors; /* receiver missed packet */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
443 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
444 |
/* detailed tx_errors */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
445 |
//TODO __u64 tx_aborted_errors; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
446 |
//TODO __u64 tx_carrier_errors; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
447 |
//TODO __u64 tx_fifo_errors; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
448 |
//TODO __u64 tx_heartbeat_errors; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
//TODO __u64 tx_window_errors; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
/* for cslip etc */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
//TODO __u64 rx_compressed; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
//TODO __u64 tx_compressed; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
return storage; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
456 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
457 |
static int ccat_eth_open(struct net_device *dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
458 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
459 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
460 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
461 |
hrtimer_init(&priv->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
priv->poll_timer.function = poll_timer_callback; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
hrtimer_start(&priv->poll_timer, POLL_TIME, HRTIMER_MODE_REL); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
466 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
467 |
static int ccat_eth_stop(struct net_device *dev) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
468 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
469 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
470 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
471 |
priv->stop_queue(dev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
472 |
hrtimer_cancel(&priv->poll_timer); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
473 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
static const struct net_device_ops ccat_eth_netdev_ops = { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
477 |
.ndo_get_stats64 = ccat_eth_get_stats64, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
.ndo_open = ccat_eth_open, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
.ndo_start_xmit = ccat_eth_start_xmit, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
480 |
.ndo_stop = ccat_eth_stop, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
481 |
}; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
482 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
483 |
struct ccat_eth_priv *ccat_eth_init(const struct ccat_device *const ccatdev, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
484 |
const void __iomem * const addr) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
485 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
486 |
struct ccat_eth_priv *priv; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
487 |
struct net_device *const netdev = alloc_etherdev(sizeof(*priv)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
489 |
priv = netdev_priv(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
490 |
priv->netdev = netdev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
491 |
priv->ccatdev = ccatdev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
492 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
493 |
/* ccat register mappings */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
494 |
memcpy_fromio(&priv->info, addr, sizeof(priv->info)); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
495 |
ccat_eth_priv_init_mappings(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
496 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
497 |
if (ccat_eth_priv_init_dma(priv)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
498 |
pr_warn("%s(): DMA initialization failed.\n", __FUNCTION__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
499 |
free_netdev(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
500 |
return NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
501 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
502 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
503 |
/* init netdev with MAC and stack callbacks */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
504 |
memcpy_fromio(netdev->dev_addr, priv->reg.mii + 8, netdev->addr_len); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
505 |
netdev->netdev_ops = &ccat_eth_netdev_ops; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
506 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
507 |
/* use as EtherCAT device? */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
508 |
priv->ecdev = ecdev_offer(netdev, ec_poll_rx, THIS_MODULE); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
509 |
if (priv->ecdev) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
510 |
priv->carrier_off = ecdev_carrier_off; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
511 |
priv->carrier_ok = ecdev_carrier_ok; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
512 |
priv->carrier_on = ecdev_carrier_on; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
513 |
priv->kfree_skb_any = ecdev_kfree_skb_any; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
514 |
priv->start_queue = ecdev_nop; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
515 |
priv->stop_queue = ecdev_nop; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
516 |
priv->unregister = unregister_ecdev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
518 |
priv->carrier_off(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
519 |
if (ecdev_open(priv->ecdev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
520 |
pr_info("unable to register network device.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
521 |
ecdev_withdraw(priv->ecdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
522 |
ccat_eth_priv_free_dma(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
523 |
free_netdev(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
524 |
return NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
525 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
526 |
return priv; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
527 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
528 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
529 |
/* EtherCAT disabled -> prepare normal ethernet mode */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
530 |
priv->carrier_off = netif_carrier_off; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
531 |
priv->carrier_ok = netif_carrier_ok; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
532 |
priv->carrier_on = netif_carrier_on; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
533 |
priv->kfree_skb_any = dev_kfree_skb_any; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
534 |
priv->start_queue = netif_start_queue; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
535 |
priv->stop_queue = netif_stop_queue; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
536 |
priv->unregister = unregister_netdev; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
537 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
538 |
priv->carrier_off(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
539 |
if (register_netdev(netdev)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
540 |
pr_info("unable to register network device.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
541 |
ccat_eth_priv_free_dma(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
542 |
free_netdev(netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
543 |
return NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
544 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
545 |
pr_info("registered %s as network device.\n", netdev->name); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
546 |
return priv; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
547 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
548 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
549 |
void ccat_eth_remove(struct ccat_eth_priv *const priv) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
550 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
551 |
priv->unregister(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
552 |
ccat_eth_priv_free_dma(priv); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
553 |
free_netdev(priv->netdev); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
554 |
} |