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