author | Florian Pose <fp@igh-essen.com> |
Fri, 25 Apr 2014 16:42:36 +0200 | |
branch | stable-1.5 |
changeset 2556 | 674fcdccc0f3 |
parent 2553 | b0c2762a1a83 |
child 2565 | f7b06b264646 |
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/kfifo.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/kthread.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/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
|
27 |
#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
|
28 |
#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
|
29 |
|
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
30 |
#include "compat.h" |
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
|
31 |
#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
|
32 |
#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
|
33 |
#include "print.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
|
34 |
|
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 |
/** |
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 |
* 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
|
37 |
*/ |
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 |
static const UINT8 frameForwardEthernetFrames[] = { |
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 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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, 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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
}; |
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 |
#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
|
53 |
#define DMA_POLL_DELAY_RANGE_USECS 100, 100 /* time to sleep between rx/tx DMA polls */ |
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 |
#define POLL_DELAY_RANGE_USECS 500, 1000 /* time to sleep between link state polls */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
55 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
56 |
static void ec_poll(struct net_device *dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
57 |
static int run_poll_thread(void *data); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
58 |
static int run_rx_thread(void *data); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
59 |
static int run_tx_thread(void *data); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
60 |
|
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
61 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) |
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
|
62 |
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
|
63 |
*storage); |
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
64 |
#endif |
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
|
65 |
static int ccat_eth_open(struct net_device *dev); |
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 |
static netdev_tx_t ccat_eth_start_xmit(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
|
67 |
struct net_device *dev); |
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 |
static int ccat_eth_stop(struct net_device *dev); |
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 |
static void ccat_eth_xmit_raw(struct net_device *dev, const char *data, |
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 |
size_t len); |
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 |
static const struct net_device_ops ccat_eth_netdev_ops = { |
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
73 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) |
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
|
74 |
.ndo_get_stats64 = ccat_eth_get_stats64, |
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
75 |
#endif |
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
|
76 |
.ndo_open = ccat_eth_open, |
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 |
.ndo_start_xmit = ccat_eth_start_xmit, |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
78 |
.ndo_stop = ccat_eth_stop, |
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 |
}; |
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 |
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
|
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 |
/* 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
|
84 |
} |
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 |
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
|
87 |
{ |
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 |
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
|
89 |
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
|
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 |
|
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 |
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
|
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 |
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
|
95 |
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
|
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 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
98 |
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
|
99 |
{ |
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 |
/* 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
|
101 |
} |
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 |
static void ecdev_tx_fifo_full(struct net_device *const dev, |
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 |
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
|
105 |
{ |
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 |
/* 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
|
107 |
} |
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 |
|
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 |
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
|
110 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
} |
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 |
|
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 |
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
|
117 |
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
|
118 |
|
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 |
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
|
120 |
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
|
121 |
{ |
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 |
const size_t offset = ((void *)(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
|
123 |
const uint32_t addr_and_length = (1 << 31) | offset; |
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 |
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
|
125 |
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
|
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 |
|
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 |
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
|
129 |
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
|
130 |
{ |
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 |
/* 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
|
132 |
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
|
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 void ccat_eth_tx_fifo_full(struct net_device *const dev, |
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 |
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
|
137 |
{ |
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 = netdev_priv(dev); |
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 |
netif_stop_queue(dev); |
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 |
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
|
141 |
wake_up_process(priv->tx_thread); |
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 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
143 |
|
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 |
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
|
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 |
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
|
147 |
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
|
148 |
|
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 |
/* 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
|
150 |
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
|
151 |
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
|
152 |
|
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 |
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
|
154 |
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
|
155 |
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
|
156 |
++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
|
157 |
} |
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 |
} |
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 |
} |
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 |
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
|
162 |
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
|
163 |
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
|
164 |
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
|
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 |
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
|
167 |
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
|
168 |
&priv->ccatdev->pdev->dev)) { |
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 |
pr_info("init DMA%llu memory failed.\n", (uint64_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
|
170 |
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
|
171 |
} |
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 |
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
|
173 |
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
|
174 |
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
|
175 |
} |
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 |
* 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
|
179 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
180 |
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
|
181 |
{ |
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 |
/* 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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
|
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 |
/* 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
|
188 |
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
|
189 |
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
|
190 |
pr_debug("DMA fifo's stopped.\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
|
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 |
/** |
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 |
* 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
|
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 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
|
197 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
198 |
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
|
199 |
(&priv->rx_fifo, priv->reg.rx_fifo, ccat_eth_rx_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
|
200 |
priv->info.rxDmaChn, 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
|
201 |
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
|
202 |
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
|
203 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
204 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
205 |
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
|
206 |
(&priv->tx_fifo, priv->reg.tx_fifo, ccat_eth_tx_fifo_add_free, |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
207 |
priv->info.txDmaChn, 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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
212 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
213 |
/* 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
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
218 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
219 |
/** |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
220 |
* 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
|
221 |
* 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
|
222 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
223 |
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
|
224 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
225 |
CCatInfoBlockOffs offsets; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
226 |
void __iomem *const func_base = |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
227 |
priv->ccatdev->bar[0].ioaddr + priv->info.nAddr; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
228 |
memcpy_fromio(&offsets, func_base, sizeof(offsets)); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
229 |
priv->reg.mii = func_base + offsets.nMMIOffs; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
230 |
priv->reg.tx_fifo = func_base + offsets.nTxFifoOffs; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
231 |
priv->reg.rx_fifo = func_base + offsets.nTxFifoOffs + 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
|
232 |
priv->reg.mac = func_base + offsets.nMacRegOffs; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
233 |
priv->reg.rx_mem = func_base + offsets.nRxMemOffs; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
234 |
priv->reg.tx_mem = func_base + offsets.nTxMemOffs; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
235 |
priv->reg.misc = func_base + offsets.nMiscOffs; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
236 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
237 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
238 |
/** |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
239 |
* 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
|
240 |
* @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
|
241 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
242 |
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
|
243 |
*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
|
244 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
245 |
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
|
246 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
247 |
|
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
248 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) |
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
|
249 |
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
|
250 |
*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
|
251 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
252 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
253 |
CCatMacRegs mac; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
254 |
memcpy_fromio(&mac, priv->reg.mac, sizeof(mac)); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
255 |
storage->rx_packets = mac.rxFrameCnt; /* total 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
|
256 |
storage->tx_packets = mac.txFrameCnt; /* total packets transmitted */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
257 |
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
|
258 |
storage->tx_bytes = atomic64_read(&priv->tx_bytes); /* total bytes transmitted */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
259 |
storage->rx_errors = mac.frameLenErrCnt + mac.dropFrameErrCnt + mac.crcErrCnt + mac.rxErrCnt; /* bad 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
|
260 |
//TODO __u64 tx_errors; /* packet transmit problems */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
261 |
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
|
262 |
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
|
263 |
//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
|
264 |
//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
|
265 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
266 |
/* detailed rx_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
|
267 |
storage->rx_length_errors = mac.frameLenErrCnt; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
268 |
storage->rx_over_errors = mac.dropFrameErrCnt; /* receiver ring buff overflow */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
269 |
storage->rx_crc_errors = mac.crcErrCnt; /* recved pkt with crc error */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
270 |
storage->rx_frame_errors = mac.rxErrCnt; /* recv'd frame alignment error */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
271 |
storage->rx_fifo_errors = mac.dropFrameErrCnt; /* recv'r fifo overrun */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
272 |
//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
|
273 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
274 |
/* 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
|
275 |
//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
|
276 |
//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
|
277 |
//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
|
278 |
//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
|
279 |
//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
|
280 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
281 |
/* 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
|
282 |
//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
|
283 |
//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
|
284 |
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
|
285 |
} |
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2551
diff
changeset
|
286 |
#endif |
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
|
287 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
291 |
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
|
292 |
struct net_device *const netdev = alloc_etherdev(sizeof(*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
|
293 |
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
|
294 |
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
|
295 |
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
|
296 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
297 |
/* 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
|
298 |
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
|
299 |
ccat_eth_priv_init_mappings(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
|
300 |
ccat_print_function_info(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
|
301 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
302 |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
307 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
308 |
/* init netdev with MAC and stack callbacks */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
309 |
memcpy_fromio(netdev->dev_addr, priv->reg.mii + 8, 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
|
310 |
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
|
311 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
312 |
/* use as EtherCAT device? */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
313 |
priv->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
314 |
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
|
315 |
priv->carrier_off = ecdev_carrier_off; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
priv->unregister = unregister_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
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
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
|
328 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
329 |
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
|
330 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
331 |
|
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 |
/* 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
|
333 |
priv->carrier_off = netif_carrier_off; |
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 |
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
|
335 |
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
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
priv->unregister = unregister_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
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
346 |
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
|
347 |
priv->rx_thread = kthread_run(run_rx_thread, netdev, "%s_rx", DRV_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
|
348 |
priv->tx_thread = kthread_run(run_tx_thread, netdev, "%s_tx", DRV_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
|
349 |
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
|
350 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
351 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
352 |
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
|
353 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
354 |
if (priv->rx_thread) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
355 |
kthread_stop(priv->rx_thread); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
356 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
357 |
if (priv->tx_thread) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
358 |
kthread_stop(priv->tx_thread); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
359 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
360 |
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
365 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
366 |
static int ccat_eth_open(struct net_device *dev) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
367 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
368 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
369 |
priv->carrier_off(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
370 |
priv->poll_thread = |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
371 |
kthread_run(run_poll_thread, dev, "%s_poll", DRV_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
|
372 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
373 |
//TODO |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
374 |
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
|
375 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
376 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
377 |
static const size_t CCATRXDESC_HEADER_LEN = 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
|
378 |
static void ccat_eth_receive(struct net_device *const dev, |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
379 |
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
|
380 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
381 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
382 |
const size_t len = frame->length - CCATRXDESC_HEADER_LEN; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
383 |
struct sk_buff *skb = dev_alloc_skb(len + NET_IP_ALIGN); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
384 |
if (!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
|
385 |
pr_info("%s() out of memory :-(\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
|
386 |
atomic64_inc(&priv->rx_dropped); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
387 |
return; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
388 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
389 |
skb->dev = dev; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
390 |
skb_reserve(skb, NET_IP_ALIGN); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
391 |
skb_copy_to_linear_data(skb, frame->data, len); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
392 |
skb_put(skb, len); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
393 |
skb->protocol = eth_type_trans(skb, dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
394 |
skb->ip_summed = CHECKSUM_UNNECESSARY; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
395 |
atomic64_add(len, &priv->rx_bytes); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
396 |
netif_rx(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
|
397 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
398 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
399 |
/** |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
400 |
* Rx handler 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
|
401 |
* priv->ecdev should always be valid! |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
402 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
403 |
static void ec_poll(struct net_device *dev) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
404 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
405 |
static size_t next = 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
|
406 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
407 |
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
|
408 |
((struct ccat_eth_frame *)priv->rx_fifo.dma.virt) + next; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
409 |
if (frame->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
|
410 |
ecdev_receive(priv->ecdev, frame->data, |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
411 |
frame->length - CCATRXDESC_HEADER_LEN); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
412 |
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
|
413 |
ccat_eth_rx_fifo_add(frame, &priv->rx_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
|
414 |
next = (next + 1) % 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
|
415 |
} else { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
416 |
//TODO dev_warn(&dev->dev, "%s(): frame was not ready\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
|
417 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
418 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
419 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
420 |
static netdev_tx_t ccat_eth_start_xmit(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
|
421 |
struct net_device *dev) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
422 |
{ |
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 size_t next = 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
|
424 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
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 |
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
|
426 |
((struct ccat_eth_frame *)priv->tx_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
|
427 |
uint32_t addr_and_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
|
428 |
|
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 |
if (skb_is_nonlinear(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
|
430 |
pr_warn("Non linear skb not supported -> drop frame.\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
|
431 |
atomic64_inc(&priv->tx_dropped); |
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 |
priv->kfree_skb_any(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
|
433 |
return NETDEV_TX_OK; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
434 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
435 |
|
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 |
if (skb->len > sizeof(frame->data)) { |
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 |
pr_warn("skb.len %llu exceeds dma buffer %llu -> drop frame.\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
|
438 |
(uint64_t) skb->len, (uint64_t) sizeof(frame->data)); |
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 |
atomic64_inc(&priv->tx_dropped); |
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 |
priv->kfree_skb_any(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
|
441 |
return NETDEV_TX_OK; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
442 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
443 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
444 |
if (!frame[next].sent) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
445 |
netdev_err(dev, "BUG! Tx Ring full when queue awake!\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
|
446 |
ccat_eth_tx_fifo_full(dev, &frame[next]); |
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 |
return NETDEV_TX_BUSY; |
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 |
|
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 |
/* prepare frame in DMA memory */ |
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 |
frame[next].sent = 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
|
452 |
frame[next].length = skb->len; |
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 |
memcpy(frame[next].data, skb->data, skb->len); |
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 |
|
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 |
priv->kfree_skb_any(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
|
456 |
|
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 |
addr_and_length = 8 + (next * sizeof(*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
|
458 |
addr_and_length += |
2551
000da5069f1a
clean up CCatDefinitions.h
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2550
diff
changeset
|
459 |
((frame[next].length + CCAT_DMA_FRAME_HEADER_LENGTH) / 8) << 24; |
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
|
460 |
iowrite32(addr_and_length, priv->reg.tx_fifo); /* add to 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
|
461 |
atomic64_add(frame[next].length, &priv->tx_bytes); /* update stats */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
462 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
463 |
next = (next + 1) % 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
|
464 |
/* stop queue if tx ring is 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
|
465 |
if (!frame[next].sent) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
466 |
ccat_eth_tx_fifo_full(dev, &frame[next]); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
467 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
468 |
return NETDEV_TX_OK; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
469 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
470 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
471 |
static int ccat_eth_stop(struct net_device *dev) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
472 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
473 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
474 |
priv->stop_queue(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
475 |
if (priv->poll_thread) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
476 |
/* TODO care about smp context? */ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
477 |
kthread_stop(priv->poll_thread); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
478 |
priv->poll_thread = 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
|
479 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
480 |
netdev_info(dev, "stopped.\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
|
481 |
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
|
482 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
483 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
484 |
static void ccat_eth_link_down(struct net_device *dev) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
485 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
486 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
487 |
priv->stop_queue(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
488 |
priv->carrier_off(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
489 |
netdev_info(dev, "NIC Link is Down\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
|
490 |
} |
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 |
|
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 |
static void ccat_eth_link_up(struct net_device *const dev) |
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 |
{ |
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 ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
495 |
netdev_info(dev, "NIC Link is Up\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
|
496 |
/* TODO netdev_info(dev, "NIC Link is Up %u Mbps %s Duplex\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
|
497 |
speed == SPEED_100 ? 100 : 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
|
498 |
cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); */ |
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_eth_dma_fifo_reset(&priv->rx_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
|
501 |
ccat_eth_dma_fifo_reset(&priv->tx_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
|
502 |
ccat_eth_xmit_raw(dev, frameForwardEthernetFrames, |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
503 |
sizeof(frameForwardEthernetFrames)); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
504 |
priv->carrier_on(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
505 |
priv->start_queue(dev); |
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 |
|
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 |
/** |
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 |
* Function to transmit a raw buffer to the network (f.e. frameForwardEthernetFrames) |
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 |
* @dev a valid net_device |
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 |
* @data pointer to your raw buffer |
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 |
* @len number of bytes in the raw buffer to transmit |
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 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
514 |
static void ccat_eth_xmit_raw(struct net_device *dev, const char *const data, |
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 |
size_t len) |
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 |
struct sk_buff *skb = dev_alloc_skb(len); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
518 |
skb->dev = dev; |
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 |
skb_copy_to_linear_data(skb, data, len); |
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 |
skb_put(skb, len); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
521 |
ccat_eth_start_xmit(skb, dev); |
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 |
} |
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 |
|
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 |
/** |
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 |
* Since CCAT doesn't support interrupts until now, we have to poll |
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 |
* some status bits to recognize things like link change 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
|
527 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
528 |
static int run_poll_thread(void *data) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
529 |
{ |
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 |
struct net_device *const dev = (struct net_device *)data; |
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 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
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 |
size_t link = 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
|
533 |
|
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 |
while (!kthread_should_stop()) { |
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 |
if (ccat_eth_priv_read_link_state(priv) != link) { |
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 |
link = !link; |
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 |
link ? ccat_eth_link_up(dev) : ccat_eth_link_down(dev); |
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 |
usleep_range(POLL_DELAY_RANGE_USECS); |
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 |
} |
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 |
pr_debug("%s() stopped.\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
|
542 |
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
|
543 |
} |
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 |
|
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 |
static int run_rx_thread(void *data) |
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 |
{ |
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 |
struct net_device *const dev = (struct net_device *)data; |
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 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
549 |
struct ccat_eth_frame *frame = priv->rx_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
|
550 |
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
|
551 |
|
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 |
while (!kthread_should_stop()) { |
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 |
/* wait until frame was used by DMA for Rx */ |
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 |
while (!kthread_should_stop() && !frame->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
|
555 |
usleep_range(DMA_POLL_DELAY_RANGE_USECS); |
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 |
|
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 |
/* can be NULL, if we are asked to stop! */ |
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 |
if (frame->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
|
560 |
ccat_eth_receive(dev, 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
|
561 |
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
|
562 |
ccat_eth_rx_fifo_add(frame, &priv->rx_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
|
563 |
} |
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 |
if (++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
|
565 |
frame = priv->rx_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
|
566 |
} |
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 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
568 |
pr_debug("%s() stopped.\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
|
569 |
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
|
570 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
571 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
572 |
/** |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
573 |
* Polling of tx dma descriptors in ethernet operating 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
|
574 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
575 |
static int run_tx_thread(void *data) |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
576 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
577 |
struct net_device *const dev = (struct net_device *)data; |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
578 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
579 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
580 |
set_current_state(TASK_INTERRUPTIBLE); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
581 |
while (!kthread_should_stop()) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
582 |
const struct ccat_eth_frame *const frame = priv->next_tx_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
|
583 |
if (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
|
584 |
while (!kthread_should_stop() && !frame->sent) { |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
585 |
usleep_range(DMA_POLL_DELAY_RANGE_USECS); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
586 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
587 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
588 |
netif_wake_queue(dev); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
589 |
schedule(); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
590 |
set_current_state(TASK_INTERRUPTIBLE); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
591 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
592 |
set_current_state(TASK_RUNNING); |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
593 |
pr_debug("%s() stopped.\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
|
594 |
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
|
595 |
} |