author | Florian Pose <fp@igh-essen.com> |
Fri, 16 Sep 2016 11:56:10 +0200 | |
branch | stable-1.5 |
changeset 2655 | a5c9005fe7a8 |
parent 2638 | 5995331a55fe |
child 2654 | b3f6b3e5ef29 |
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 |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
3 |
Copyright (C) 2014 - 2015 Beckhoff Automation GmbH |
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
|
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/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
|
23 |
#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
|
24 |
#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
|
25 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
26 |
#ifdef CONFIG_PCI |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
27 |
#include <asm/dma.h> |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
28 |
#else |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
29 |
#define free_dma(X) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
30 |
#define request_dma(X, Y) ((int)(-EINVAL)) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
31 |
#endif |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
32 |
|
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
|
33 |
#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
|
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 |
*/ |
2567
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
38 |
static const u8 frameForwardEthernetFrames[] = { |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
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 |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
53 |
#define POLL_TIME ktime_set(0, 50 * NSEC_PER_USEC) |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
54 |
#define CCAT_ALIGNMENT ((size_t)(128 * 1024)) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
55 |
#define CCAT_ALIGN_CHANNEL(x, c) ((typeof(x))(ALIGN((size_t)((x) + ((c) * CCAT_ALIGNMENT)), CCAT_ALIGNMENT))) |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
56 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
57 |
struct ccat_dma_frame_hdr { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
58 |
__le32 reserved1; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
59 |
__le32 rx_flags; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
60 |
#define CCAT_FRAME_RECEIVED 0x1 |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
61 |
__le16 length; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
62 |
__le16 reserved3; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
63 |
__le32 tx_flags; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
64 |
#define CCAT_FRAME_SENT 0x1 |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
65 |
__le64 timestamp; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
66 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
67 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
68 |
struct ccat_eim_frame_hdr { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
69 |
__le16 length; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
70 |
__le16 reserved3; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
71 |
__le32 tx_flags; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
72 |
__le64 timestamp; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
73 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
74 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
75 |
struct ccat_eth_frame { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
76 |
u8 placeholder[0x800]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
77 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
78 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
79 |
struct ccat_dma_frame { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
80 |
struct ccat_dma_frame_hdr hdr; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
81 |
u8 data[sizeof(struct ccat_eth_frame) - |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
82 |
sizeof(struct ccat_dma_frame_hdr)]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
83 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
84 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
85 |
struct ccat_eim_frame { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
86 |
struct ccat_eim_frame_hdr hdr; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
87 |
u8 data[sizeof(struct ccat_eth_frame) - |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
88 |
sizeof(struct ccat_eim_frame_hdr)]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
89 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
90 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
91 |
#define MAX_PAYLOAD_SIZE \ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
92 |
(sizeof(struct ccat_eth_frame) - max(sizeof(struct ccat_dma_frame_hdr), sizeof(struct ccat_eim_frame_hdr))) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
93 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
94 |
/** |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
95 |
* struct ccat_eth_register - CCAT register addresses in the PCI BAR |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
96 |
* @mii: address of the CCAT management interface register |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
97 |
* @mac: address of the CCAT media access control register |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
98 |
* @rx_mem: address of the CCAT register holding the RX DMA address |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
99 |
* @tx_mem: address of the CCAT register holding the TX DMA address |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
100 |
* @misc: address of a CCAT register holding miscellaneous information |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
101 |
*/ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
102 |
struct ccat_eth_register { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
103 |
void __iomem *mii; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
104 |
void __iomem *mac; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
105 |
void __iomem *rx_mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
106 |
void __iomem *tx_mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
107 |
void __iomem *misc; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
108 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
109 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
110 |
/** |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
111 |
* struct ccat_dma_mem - CCAT DMA channel configuration |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
112 |
* @size: number of bytes in the associated DMA memory |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
113 |
* @phys: device-viewed address(physical) of the associated DMA memory |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
114 |
* @channel: CCAT DMA channel number |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
115 |
* @dev: valid struct device pointer |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
116 |
* @base: CPU-viewed address(virtual) of the associated DMA memory |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
117 |
*/ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
118 |
struct ccat_dma_mem { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
119 |
size_t size; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
120 |
dma_addr_t phys; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
121 |
size_t channel; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
122 |
struct device *dev; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
123 |
void *base; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
124 |
}; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
125 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
126 |
/** |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
127 |
* struct ccat_dma/eim/mem |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
128 |
* @next: pointer to the next frame in fifo ring buffer |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
129 |
* @start: aligned CPU-viewed address(virtual) of the associated memory |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
130 |
*/ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
131 |
struct ccat_dma { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
132 |
struct ccat_dma_frame *next; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
133 |
void *start; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
134 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
135 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
136 |
struct ccat_eim { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
137 |
struct ccat_eim_frame __iomem *next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
138 |
void __iomem *start; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
139 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
140 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
141 |
struct ccat_mem { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
142 |
struct ccat_eth_frame *next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
143 |
void *start; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
144 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
145 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
146 |
/** |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
147 |
* struct ccat_eth_fifo - CCAT RX or TX fifo |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
148 |
* @ops: function pointer table for dma/eim and rx/tx specific fifo functions |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
149 |
* @reg: PCI register address of this fifo |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
150 |
* @rx_bytes: number of bytes processed -> reported with ndo_get_stats64() |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
151 |
* @rx_dropped: number of dropped frames -> reported with ndo_get_stats64() |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
152 |
* @mem/dma/eim: information about the associated memory |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
153 |
*/ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
154 |
struct ccat_eth_fifo { |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
155 |
const struct ccat_eth_fifo_operations *ops; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
156 |
const struct ccat_eth_frame *end; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
157 |
void __iomem *reg; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
158 |
atomic64_t bytes; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
159 |
atomic64_t dropped; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
160 |
union { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
161 |
struct ccat_mem mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
162 |
struct ccat_dma dma; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
163 |
struct ccat_eim eim; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
164 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
165 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
166 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
167 |
/** |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
168 |
* struct ccat_eth_fifo_operations |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
169 |
* @ready: callback used to test the next frames ready bit |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
170 |
* @add: callback used to add a frame to this fifo |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
171 |
* @copy_to_skb: callback used to copy from rx fifos to skbs |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
172 |
* @skb: callback used to queue skbs into tx fifos |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
173 |
*/ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
174 |
struct ccat_eth_fifo_operations { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
175 |
size_t(*ready) (struct ccat_eth_fifo *); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
176 |
void (*add) (struct ccat_eth_fifo *); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
177 |
union { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
178 |
void (*copy_to_skb) (struct ccat_eth_fifo *, struct sk_buff *, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
179 |
size_t); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
180 |
void (*skb) (struct ccat_eth_fifo *, struct sk_buff *); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
181 |
} queue; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
182 |
}; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
183 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
184 |
/** |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
185 |
* same as: typedef struct _CCatInfoBlockOffs from CCatDefinitions.h |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
186 |
*/ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
187 |
struct ccat_mac_infoblock { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
188 |
u32 reserved; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
189 |
u32 mii; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
190 |
u32 tx_fifo; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
191 |
u32 mac; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
192 |
u32 rx_mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
193 |
u32 tx_mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
194 |
u32 misc; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
195 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
196 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
197 |
/** |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
198 |
* struct ccat_eth_priv - CCAT Ethernet/EtherCAT Master function (netdev) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
199 |
* @func: pointer to the parent struct ccat_function |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
200 |
* @netdev: the net_device structure used by the kernel networking stack |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
201 |
* @reg: register addresses in PCI config space of the Ethernet/EtherCAT Master function |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
202 |
* @rx_fifo: fifo used for RX descriptors |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
203 |
* @tx_fifo: fifo used for TX descriptors |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
204 |
* @poll_timer: interval timer used to poll CCAT for events like link changed, rx done, tx done |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
205 |
*/ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
206 |
struct ccat_eth_priv { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
207 |
struct ccat_function *func; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
208 |
struct net_device *netdev; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
209 |
struct ccat_eth_register reg; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
210 |
struct ccat_eth_fifo rx_fifo; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
211 |
struct ccat_eth_fifo tx_fifo; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
212 |
struct hrtimer poll_timer; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
213 |
struct ccat_dma_mem dma_mem; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
214 |
ec_device_t *ecdev; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
215 |
void (*carrier_off) (struct net_device * netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
216 |
bool(*carrier_ok) (const struct net_device * netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
217 |
void (*carrier_on) (struct net_device * netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
218 |
void (*kfree_skb_any) (struct sk_buff * skb); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
219 |
void (*receive) (struct ccat_eth_priv *, size_t); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
220 |
void (*start_queue) (struct net_device * netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
221 |
void (*stop_queue) (struct net_device * netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
222 |
void (*unregister) (struct net_device * netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
223 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
224 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
225 |
struct ccat_mac_register { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
226 |
/** MAC error register @+0x0 */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
227 |
u8 frame_len_err; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
228 |
u8 rx_err; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
229 |
u8 crc_err; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
230 |
u8 link_lost_err; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
231 |
u32 reserved1; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
232 |
/** Buffer overflow errors @+0x8 */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
233 |
u8 rx_mem_full; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
234 |
u8 reserved2[7]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
235 |
/** MAC frame counter @+0x10 */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
236 |
u32 tx_frames; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
237 |
u32 rx_frames; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
238 |
u64 reserved3; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
239 |
/** MAC fifo level @+0x20 */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
240 |
u8 tx_fifo_level:7; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
241 |
u8 reserved4:1; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
242 |
u8 reserved5[7]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
243 |
/** TX memory full error @+0x28 */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
244 |
u8 tx_mem_full; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
245 |
u8 reserved6[7]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
246 |
u64 reserved8[9]; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
247 |
/** Connection @+0x78 */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
248 |
u8 mii_connected; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
249 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
250 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
251 |
static void fifo_set_end(struct ccat_eth_fifo *const fifo, size_t size) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
252 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
253 |
fifo->end = fifo->mem.start + size - sizeof(struct ccat_eth_frame); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
254 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
255 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
256 |
static void ccat_dma_free(struct ccat_eth_priv *const priv) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
257 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
258 |
if (priv->dma_mem.base) { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
259 |
const struct ccat_dma_mem tmp = priv->dma_mem; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
260 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
261 |
memset(&priv->dma_mem, 0, sizeof(priv->dma_mem)); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
262 |
dma_free_coherent(tmp.dev, tmp.size, tmp.base, tmp.phys); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
263 |
free_dma(priv->func->info.tx_dma_chan); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
264 |
free_dma(priv->func->info.rx_dma_chan); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
265 |
} |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
266 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
267 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
268 |
/** |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
269 |
* ccat_dma_init() - Initialize CCAT and host memory for DMA transfer |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
270 |
* @dma object for management data which will be initialized |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
271 |
* @channel number of the DMA channel |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
272 |
* @ioaddr of the pci bar2 configspace used to calculate the address of the pci dma configuration |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
273 |
* @dev which should be configured for DMA |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
274 |
*/ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
275 |
static int ccat_dma_init(struct ccat_dma_mem *const dma, size_t channel, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
276 |
void __iomem * const bar2, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
277 |
struct ccat_eth_fifo *const fifo) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
278 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
279 |
void __iomem *const ioaddr = bar2 + 0x1000 + (sizeof(u64) * channel); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
280 |
const dma_addr_t phys = CCAT_ALIGN_CHANNEL(dma->phys, channel); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
281 |
const u32 phys_hi = (sizeof(phys) > sizeof(u32)) ? phys >> 32 : 0; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
282 |
fifo->dma.start = CCAT_ALIGN_CHANNEL(dma->base, channel); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
283 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
284 |
fifo_set_end(fifo, CCAT_ALIGNMENT); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
285 |
if (request_dma(channel, KBUILD_MODNAME)) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
286 |
pr_info("request dma channel %llu failed\n", (u64) channel); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
287 |
return -EINVAL; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
288 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
289 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
290 |
/** bit 0 enables 64 bit mode on ccat */ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
291 |
iowrite32((u32) phys | ((phys_hi) > 0), ioaddr); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
292 |
iowrite32(phys_hi, ioaddr + 4); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
293 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
294 |
pr_debug |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
295 |
("DMA%llu mem initialized\n base: 0x%p\n start: 0x%p\n phys: 0x%09llx\n pci addr: 0x%01x%08x\n size: %llu |%llx bytes.\n", |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
296 |
(u64) channel, dma->base, fifo->dma.start, (u64) dma->phys, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
297 |
ioread32(ioaddr + 4), ioread32(ioaddr), |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
298 |
(u64) dma->size, (u64) dma->size); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
299 |
return 0; |
2576 | 300 |
} |
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
|
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 |
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
|
303 |
{ |
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 |
/* 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
|
305 |
} |
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 |
|
2570
144e11d93e99
- don't use compat.h in the mainline driver
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2569
diff
changeset
|
307 |
static bool ecdev_carrier_ok(const struct net_device *const netdev) |
2567
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
308 |
{ |
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
309 |
struct ccat_eth_priv *const priv = netdev_priv(netdev); |
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
310 |
return ecdev_get_link(priv->ecdev); |
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
311 |
} |
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
312 |
|
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
|
313 |
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
|
314 |
{ |
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 |
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
|
316 |
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
|
317 |
} |
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 |
|
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 |
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
|
320 |
{ |
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 |
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
|
322 |
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
|
323 |
} |
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 |
|
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 |
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
|
326 |
{ |
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 |
/* 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
|
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 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
330 |
static void ecdev_receive_dma(struct ccat_eth_priv *const priv, size_t len) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
331 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
332 |
ecdev_receive(priv->ecdev, priv->rx_fifo.dma.next->data, len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
333 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
334 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
335 |
static void ecdev_receive_eim(struct ccat_eth_priv *const priv, size_t len) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
336 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
337 |
ecdev_receive(priv->ecdev, priv->rx_fifo.eim.next->data, len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
338 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
339 |
|
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
|
340 |
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
|
341 |
{ |
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 |
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
|
343 |
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
|
344 |
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
|
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 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
347 |
static inline size_t fifo_eim_tx_ready(struct ccat_eth_fifo *const fifo) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
348 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
349 |
struct ccat_eth_priv *const priv = |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
350 |
container_of(fifo, struct ccat_eth_priv, tx_fifo); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
351 |
static const size_t TX_FIFO_LEVEL_OFFSET = 0x20; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
352 |
static const u8 TX_FIFO_LEVEL_MASK = 0x3F; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
353 |
void __iomem *addr = priv->reg.mac + TX_FIFO_LEVEL_OFFSET; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
354 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
355 |
return !(ioread8(addr) & TX_FIFO_LEVEL_MASK); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
356 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
357 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
358 |
static inline size_t fifo_eim_rx_ready(struct ccat_eth_fifo *const fifo) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
359 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
360 |
static const size_t OVERHEAD = sizeof(struct ccat_eim_frame_hdr); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
361 |
const size_t len = ioread16(&fifo->eim.next->hdr.length); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
362 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
363 |
return (len < OVERHEAD) ? 0 : len - OVERHEAD; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
364 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
365 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
366 |
static void ccat_eth_fifo_inc(struct ccat_eth_fifo *fifo) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
367 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
368 |
if (++fifo->mem.next > fifo->end) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
369 |
fifo->mem.next = fifo->mem.start; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
370 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
371 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
372 |
static void fifo_eim_rx_add(struct ccat_eth_fifo *const fifo) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
373 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
374 |
struct ccat_eim_frame __iomem *frame = fifo->eim.next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
375 |
iowrite16(0, frame); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
376 |
wmb(); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
377 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
378 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
379 |
static void fifo_eim_tx_add(struct ccat_eth_fifo *const fifo) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
380 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
381 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
382 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
383 |
#define memcpy_from_ccat(DEST, SRC, LEN) memcpy(DEST,(__force void*)(SRC), LEN) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
384 |
#define memcpy_to_ccat(DEST, SRC, LEN) memcpy((__force void*)(DEST),SRC, LEN) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
385 |
static void fifo_eim_copy_to_linear_skb(struct ccat_eth_fifo *const fifo, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
386 |
struct sk_buff *skb, const size_t len) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
387 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
388 |
memcpy_from_ccat(skb->data, fifo->eim.next->data, len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
389 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
390 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
391 |
static void fifo_eim_queue_skb(struct ccat_eth_fifo *const fifo, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
392 |
struct sk_buff *skb) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
393 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
394 |
struct ccat_eim_frame __iomem *frame = fifo->eim.next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
395 |
const u32 addr_and_length = |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
396 |
(void __iomem *)frame - (void __iomem *)fifo->eim.start; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
397 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
398 |
const __le16 length = cpu_to_le16(skb->len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
399 |
memcpy_to_ccat(&frame->hdr.length, &length, sizeof(length)); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
400 |
memcpy_to_ccat(frame->data, skb->data, skb->len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
401 |
iowrite32(addr_and_length, fifo->reg); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
402 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
403 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
404 |
static void ccat_eth_fifo_hw_reset(struct ccat_eth_fifo *const fifo) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
405 |
{ |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
406 |
if (fifo->reg) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
407 |
iowrite32(0, fifo->reg + 0x8); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
408 |
wmb(); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
409 |
} |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
410 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
411 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
412 |
static void ccat_eth_fifo_reset(struct ccat_eth_fifo *const fifo) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
413 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
414 |
ccat_eth_fifo_hw_reset(fifo); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
415 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
416 |
if (fifo->ops->add) { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
417 |
fifo->mem.next = fifo->mem.start; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
418 |
do { |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
419 |
fifo->ops->add(fifo); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
420 |
ccat_eth_fifo_inc(fifo); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
421 |
} while (fifo->mem.next != fifo->mem.start); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
422 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
423 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
424 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
425 |
static inline size_t fifo_dma_tx_ready(struct ccat_eth_fifo *const fifo) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
426 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
427 |
const struct ccat_dma_frame *frame = fifo->dma.next; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
428 |
return le32_to_cpu(frame->hdr.tx_flags) & CCAT_FRAME_SENT; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
429 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
430 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
431 |
static inline size_t fifo_dma_rx_ready(struct ccat_eth_fifo *const fifo) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
432 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
433 |
static const size_t OVERHEAD = |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
434 |
offsetof(struct ccat_dma_frame_hdr, rx_flags); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
435 |
const struct ccat_dma_frame *const frame = fifo->dma.next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
436 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
437 |
if (le32_to_cpu(frame->hdr.rx_flags) & CCAT_FRAME_RECEIVED) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
438 |
const size_t len = le16_to_cpu(frame->hdr.length); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
439 |
return (len < OVERHEAD) ? 0 : len - OVERHEAD; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
440 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
441 |
return 0; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
442 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
443 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
444 |
static void ccat_eth_rx_fifo_dma_add(struct ccat_eth_fifo *const fifo) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
445 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
446 |
struct ccat_dma_frame *const frame = fifo->dma.next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
447 |
const size_t offset = (void *)frame - fifo->dma.start; |
2567
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
448 |
const u32 addr_and_length = (1 << 31) | offset; |
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
449 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
450 |
frame->hdr.rx_flags = cpu_to_le32(0); |
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
|
451 |
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
|
452 |
} |
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 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
454 |
static void ccat_eth_tx_fifo_dma_add_free(struct ccat_eth_fifo *const fifo) |
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
|
455 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
456 |
/* mark frame as ready to use for tx */ |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
457 |
fifo->dma.next->hdr.tx_flags = cpu_to_le32(CCAT_FRAME_SENT); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
458 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
459 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
460 |
static void fifo_dma_copy_to_linear_skb(struct ccat_eth_fifo *const fifo, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
461 |
struct sk_buff *skb, const size_t len) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
462 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
463 |
skb_copy_to_linear_data(skb, fifo->dma.next->data, len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
464 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
465 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
466 |
static void fifo_dma_queue_skb(struct ccat_eth_fifo *const fifo, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
467 |
struct sk_buff *skb) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
468 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
469 |
struct ccat_dma_frame *frame = fifo->dma.next; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
470 |
u32 addr_and_length; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
471 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
472 |
frame->hdr.tx_flags = cpu_to_le32(0); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
473 |
frame->hdr.length = cpu_to_le16(skb->len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
474 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
475 |
memcpy(frame->data, skb->data, skb->len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
476 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
477 |
/* Queue frame into CCAT TX-FIFO, CCAT ignores the first 8 bytes of the tx descriptor */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
478 |
addr_and_length = offsetof(struct ccat_dma_frame_hdr, length); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
479 |
addr_and_length += ((void *)frame - fifo->dma.start); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
480 |
addr_and_length += |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
481 |
((skb->len + sizeof(struct ccat_dma_frame_hdr)) / 8) << 24; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
482 |
iowrite32(addr_and_length, fifo->reg); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
483 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
484 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
485 |
static const struct ccat_eth_fifo_operations dma_rx_fifo_ops = { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
486 |
.add = ccat_eth_rx_fifo_dma_add, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
487 |
.ready = fifo_dma_rx_ready, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
488 |
.queue.copy_to_skb = fifo_dma_copy_to_linear_skb, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
489 |
}; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
490 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
491 |
static const struct ccat_eth_fifo_operations dma_tx_fifo_ops = { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
492 |
.add = ccat_eth_tx_fifo_dma_add_free, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
493 |
.ready = fifo_dma_tx_ready, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
494 |
.queue.skb = fifo_dma_queue_skb, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
495 |
}; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
496 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
497 |
static const struct ccat_eth_fifo_operations eim_rx_fifo_ops = { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
498 |
.add = fifo_eim_rx_add, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
499 |
.queue.copy_to_skb = fifo_eim_copy_to_linear_skb, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
500 |
.ready = fifo_eim_rx_ready, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
501 |
}; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
502 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
503 |
static const struct ccat_eth_fifo_operations eim_tx_fifo_ops = { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
504 |
.add = fifo_eim_tx_add, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
505 |
.queue.skb = fifo_eim_queue_skb, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
506 |
.ready = fifo_eim_tx_ready, |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
507 |
}; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
508 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
509 |
static void ccat_eth_priv_free(struct ccat_eth_priv *priv) |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
510 |
{ |
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 |
/* reset hw fifo's */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
512 |
ccat_eth_fifo_hw_reset(&priv->rx_fifo); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
513 |
ccat_eth_fifo_hw_reset(&priv->tx_fifo); |
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
|
514 |
|
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 |
/* release dma */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
516 |
ccat_dma_free(priv); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
517 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
518 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
519 |
static int ccat_hw_disable_mac_filter(struct ccat_eth_priv *priv) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
520 |
{ |
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
|
521 |
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
|
522 |
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
|
523 |
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
|
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 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
526 |
/** |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
527 |
* Initalizes both (Rx/Tx) DMA fifo's and related management structures |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
528 |
*/ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
529 |
static int ccat_eth_priv_init_dma(struct ccat_eth_priv *priv) |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
530 |
{ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
531 |
struct ccat_dma_mem *const dma = &priv->dma_mem; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
532 |
struct pci_dev *const pdev = priv->func->ccat->pdev; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
533 |
void __iomem *const bar_2 = priv->func->ccat->bar_2; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
534 |
const u8 rx_chan = priv->func->info.rx_dma_chan; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
535 |
const u8 tx_chan = priv->func->info.tx_dma_chan; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
536 |
int status = 0; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
537 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
538 |
dma->dev = &pdev->dev; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
539 |
dma->size = CCAT_ALIGNMENT * 3; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
540 |
dma->base = |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
541 |
dma_zalloc_coherent(dma->dev, dma->size, &dma->phys, GFP_KERNEL); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
542 |
if (!dma->base || !dma->phys) { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
543 |
pr_err("init DMA memory failed.\n"); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
544 |
return -ENOMEM; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
545 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
546 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
547 |
priv->rx_fifo.ops = &dma_rx_fifo_ops; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
548 |
status = ccat_dma_init(dma, rx_chan, bar_2, &priv->rx_fifo); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
549 |
if (status) { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
550 |
pr_info("init RX DMA memory failed.\n"); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
551 |
ccat_dma_free(priv); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
552 |
return status; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
553 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
554 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
555 |
priv->tx_fifo.ops = &dma_tx_fifo_ops; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
556 |
status = ccat_dma_init(dma, tx_chan, bar_2, &priv->tx_fifo); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
557 |
if (status) { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
558 |
pr_info("init TX DMA memory failed.\n"); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
559 |
ccat_dma_free(priv); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
560 |
return status; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
561 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
562 |
return ccat_hw_disable_mac_filter(priv); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
563 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
564 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
565 |
static int ccat_eth_priv_init_eim(struct ccat_eth_priv *priv) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
566 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
567 |
priv->rx_fifo.eim.start = priv->reg.rx_mem; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
568 |
priv->rx_fifo.ops = &eim_rx_fifo_ops; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
569 |
fifo_set_end(&priv->rx_fifo, sizeof(struct ccat_eth_frame)); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
570 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
571 |
priv->tx_fifo.eim.start = priv->reg.tx_mem; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
572 |
priv->tx_fifo.ops = &eim_tx_fifo_ops; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
573 |
fifo_set_end(&priv->tx_fifo, priv->func->info.tx_size); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
574 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
575 |
return ccat_hw_disable_mac_filter(priv); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
576 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
577 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
578 |
/** |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
579 |
* Initializes a struct ccat_eth_register with data from a corresponding |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
580 |
* CCAT function. |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
581 |
*/ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
582 |
static void ccat_eth_priv_init_reg(struct ccat_eth_priv *const priv) |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
583 |
{ |
2569
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
584 |
struct ccat_mac_infoblock offsets; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
585 |
struct ccat_eth_register *const reg = &priv->reg; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
586 |
const struct ccat_function *const func = priv->func; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
587 |
void __iomem *const func_base = func->ccat->bar_0 + func->info.addr; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
588 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
589 |
/* struct ccat_eth_fifo contains a union of ccat_dma, ccat_eim and ccat_mem |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
590 |
* the members next and start have to overlay the exact same memory, |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
591 |
* to support 'polymorphic' usage of them */ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
592 |
BUILD_BUG_ON(offsetof(struct ccat_dma, next) != |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
593 |
offsetof(struct ccat_mem, next)); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
594 |
BUILD_BUG_ON(offsetof(struct ccat_dma, start) != |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
595 |
offsetof(struct ccat_mem, start)); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
596 |
BUILD_BUG_ON(offsetof(struct ccat_dma, next) != |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
597 |
offsetof(struct ccat_eim, next)); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
598 |
BUILD_BUG_ON(offsetof(struct ccat_dma, start) != |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
599 |
offsetof(struct ccat_eim, start)); |
2567
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
600 |
|
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
|
601 |
memcpy_fromio(&offsets, func_base, sizeof(offsets)); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
602 |
reg->mii = func_base + offsets.mii; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
603 |
priv->tx_fifo.reg = func_base + offsets.tx_fifo; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
604 |
priv->rx_fifo.reg = func_base + offsets.tx_fifo + 0x10; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
605 |
reg->mac = func_base + offsets.mac; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
606 |
reg->rx_mem = func_base + offsets.rx_mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
607 |
reg->tx_mem = func_base + offsets.tx_mem; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
608 |
reg->misc = func_base + offsets.misc; |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
609 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
610 |
|
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
611 |
static netdev_tx_t ccat_eth_start_xmit(struct sk_buff *skb, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
612 |
struct net_device *dev) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
613 |
{ |
2576 | 614 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
615 |
struct ccat_eth_fifo *const fifo = &priv->tx_fifo; |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
616 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
617 |
if (skb_is_nonlinear(skb)) { |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
618 |
pr_warn("Non linear skb not supported -> drop frame.\n"); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
619 |
atomic64_inc(&fifo->dropped); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
620 |
priv->kfree_skb_any(skb); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
621 |
return NETDEV_TX_OK; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
622 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
623 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
624 |
if (skb->len > MAX_PAYLOAD_SIZE) { |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
625 |
pr_warn("skb.len %llu exceeds dma buffer %llu -> drop frame.\n", |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
626 |
(u64) skb->len, (u64) MAX_PAYLOAD_SIZE); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
627 |
atomic64_inc(&fifo->dropped); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
628 |
priv->kfree_skb_any(skb); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
629 |
return NETDEV_TX_OK; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
630 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
631 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
632 |
if (!fifo->ops->ready(fifo)) { |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
633 |
netdev_err(dev, "BUG! Tx Ring full when queue awake!\n"); |
2576 | 634 |
priv->stop_queue(priv->netdev); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
635 |
return NETDEV_TX_BUSY; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
636 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
637 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
638 |
/* prepare frame in DMA memory */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
639 |
fifo->ops->queue.skb(fifo, skb); |
2576 | 640 |
|
641 |
/* update stats */ |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
642 |
atomic64_add(skb->len, &fifo->bytes); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
643 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
644 |
priv->kfree_skb_any(skb); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
645 |
|
2576 | 646 |
ccat_eth_fifo_inc(fifo); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
647 |
/* stop queue if tx ring is full */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
648 |
if (!fifo->ops->ready(fifo)) { |
2576 | 649 |
priv->stop_queue(priv->netdev); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
650 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
651 |
return NETDEV_TX_OK; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
652 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
653 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
654 |
/** |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
655 |
* Function to transmit a raw buffer to the network (f.e. frameForwardEthernetFrames) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
656 |
* @dev a valid net_device |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
657 |
* @data pointer to your raw buffer |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
658 |
* @len number of bytes in the raw buffer to transmit |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
659 |
*/ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
660 |
static void ccat_eth_xmit_raw(struct net_device *dev, const char *const data, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
661 |
size_t len) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
662 |
{ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
663 |
struct sk_buff *skb = dev_alloc_skb(len); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
664 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
665 |
skb->dev = dev; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
666 |
skb_copy_to_linear_data(skb, data, len); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
667 |
skb_put(skb, len); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
668 |
ccat_eth_start_xmit(skb, dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
669 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
670 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
671 |
static void ccat_eth_receive(struct ccat_eth_priv *const priv, const size_t len) |
2576 | 672 |
{ |
673 |
struct sk_buff *const skb = dev_alloc_skb(len + NET_IP_ALIGN); |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
674 |
struct ccat_eth_fifo *const fifo = &priv->rx_fifo; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
675 |
struct net_device *const dev = priv->netdev; |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
676 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
677 |
if (!skb) { |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
678 |
pr_info("%s() out of memory :-(\n", __FUNCTION__); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
679 |
atomic64_inc(&fifo->dropped); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
680 |
return; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
681 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
682 |
skb->dev = dev; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
683 |
skb_reserve(skb, NET_IP_ALIGN); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
684 |
fifo->ops->queue.copy_to_skb(fifo, skb, len); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
685 |
skb_put(skb, len); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
686 |
skb->protocol = eth_type_trans(skb, dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
687 |
skb->ip_summed = CHECKSUM_UNNECESSARY; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
688 |
atomic64_add(len, &fifo->bytes); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
689 |
netif_rx(skb); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
690 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
691 |
|
2576 | 692 |
static void ccat_eth_link_down(struct net_device *const dev) |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
693 |
{ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
694 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
695 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
696 |
priv->stop_queue(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
697 |
priv->carrier_off(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
698 |
netdev_info(dev, "NIC Link is Down\n"); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
699 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
700 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
701 |
static void ccat_eth_link_up(struct net_device *const dev) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
702 |
{ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
703 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
704 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
705 |
netdev_info(dev, "NIC Link is Up\n"); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
706 |
/* TODO netdev_info(dev, "NIC Link is Up %u Mbps %s Duplex\n", |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
707 |
speed == SPEED_100 ? 100 : 10, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
708 |
cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); */ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
709 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
710 |
ccat_eth_fifo_reset(&priv->rx_fifo); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
711 |
ccat_eth_fifo_reset(&priv->tx_fifo); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
712 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
713 |
/* TODO reset CCAT MAC register */ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
714 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
715 |
ccat_eth_xmit_raw(dev, frameForwardEthernetFrames, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
716 |
sizeof(frameForwardEthernetFrames)); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
717 |
priv->carrier_on(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
718 |
priv->start_queue(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
719 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
720 |
|
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
|
721 |
/** |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
722 |
* 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
|
723 |
* @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
|
724 |
*/ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
725 |
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
|
726 |
*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
|
727 |
{ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
728 |
return ! !(ioread32(priv->reg.mii + 0x8 + 4) & (1 << 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
|
729 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
730 |
|
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
731 |
/** |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
732 |
* Poll for link state changes |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
733 |
*/ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
734 |
static void poll_link(struct ccat_eth_priv *const priv) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
735 |
{ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
736 |
const size_t link = ccat_eth_priv_read_link_state(priv); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
737 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
738 |
if (link != priv->carrier_ok(priv->netdev)) { |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
739 |
if (link) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
740 |
ccat_eth_link_up(priv->netdev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
741 |
else |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
742 |
ccat_eth_link_down(priv->netdev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
743 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
744 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
745 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
746 |
/** |
2576 | 747 |
* Poll for available rx dma descriptors in ethernet operating mode |
748 |
*/ |
|
749 |
static void poll_rx(struct ccat_eth_priv *const priv) |
|
750 |
{ |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
751 |
struct ccat_eth_fifo *const fifo = &priv->rx_fifo; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
752 |
const size_t len = fifo->ops->ready(fifo); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
753 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
754 |
if (len) { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
755 |
priv->receive(priv, len); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
756 |
fifo->ops->add(fifo); |
2576 | 757 |
ccat_eth_fifo_inc(fifo); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
758 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
759 |
} |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
760 |
|
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
761 |
static void ec_poll(struct net_device *dev) |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
762 |
{ |
2576 | 763 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
764 |
poll_link(priv); |
2576 | 765 |
poll_rx(priv); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
766 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
767 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
768 |
/** |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
769 |
* Poll for available tx dma descriptors in ethernet operating mode |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
770 |
*/ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
771 |
static void poll_tx(struct ccat_eth_priv *const priv) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
772 |
{ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
773 |
if (priv->tx_fifo.ops->ready(&priv->tx_fifo)) { |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
774 |
netif_wake_queue(priv->netdev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
775 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
776 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
777 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
778 |
/** |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
779 |
* Since CCAT doesn't support interrupts until now, we have to poll |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
780 |
* some status bits to recognize things like link change etc. |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
781 |
*/ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
782 |
static enum hrtimer_restart poll_timer_callback(struct hrtimer *timer) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
783 |
{ |
2576 | 784 |
struct ccat_eth_priv *const priv = |
785 |
container_of(timer, struct ccat_eth_priv, poll_timer); |
|
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
786 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
787 |
poll_link(priv); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
788 |
poll_rx(priv); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
789 |
poll_tx(priv); |
2576 | 790 |
hrtimer_forward_now(timer, POLL_TIME); |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
791 |
return HRTIMER_RESTART; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
792 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
793 |
|
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
|
794 |
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
|
795 |
*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
|
796 |
{ |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
797 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
2569
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
798 |
struct ccat_mac_register mac; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
799 |
|
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
|
800 |
memcpy_fromio(&mac, priv->reg.mac, sizeof(mac)); |
2569
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
801 |
storage->rx_packets = mac.rx_frames; /* total packets received */ |
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
802 |
storage->tx_packets = mac.tx_frames; /* total packets transmitted */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
803 |
storage->rx_bytes = atomic64_read(&priv->rx_fifo.bytes); /* total bytes received */ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
804 |
storage->tx_bytes = atomic64_read(&priv->tx_fifo.bytes); /* total bytes transmitted */ |
2569
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
805 |
storage->rx_errors = mac.frame_len_err + mac.rx_mem_full + mac.crc_err + mac.rx_err; /* bad packets received */ |
2573
ad9a35065387
remove print.* from release tree
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2572
diff
changeset
|
806 |
storage->tx_errors = mac.tx_mem_full; /* packet transmit problems */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
807 |
storage->rx_dropped = atomic64_read(&priv->rx_fifo.dropped); /* no space in linux buffers */ |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
808 |
storage->tx_dropped = atomic64_read(&priv->tx_fifo.dropped); /* no space available in linux */ |
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
|
809 |
//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
|
810 |
//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
|
811 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
812 |
/* detailed rx_errors: */ |
2569
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
813 |
storage->rx_length_errors = mac.frame_len_err; |
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
814 |
storage->rx_over_errors = mac.rx_mem_full; /* receiver ring buff overflow */ |
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
815 |
storage->rx_crc_errors = mac.crc_err; /* recved pkt with crc error */ |
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
816 |
storage->rx_frame_errors = mac.rx_err; /* recv'd frame alignment error */ |
720172a7563f
make ccat driver more linux compliant
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2568
diff
changeset
|
817 |
storage->rx_fifo_errors = mac.rx_mem_full; /* recv'r fifo overrun */ |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
818 |
//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
|
819 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
820 |
/* 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
|
821 |
//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
|
822 |
//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
|
823 |
//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
|
824 |
//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
|
825 |
//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
|
826 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
827 |
/* 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
|
828 |
//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
|
829 |
//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
|
830 |
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
|
831 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
832 |
|
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
833 |
static int ccat_eth_open(struct net_device *dev) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
834 |
{ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
835 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
836 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
837 |
if (!priv->ecdev) { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
838 |
hrtimer_init(&priv->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
839 |
priv->poll_timer.function = poll_timer_callback; |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
840 |
hrtimer_start(&priv->poll_timer, POLL_TIME, HRTIMER_MODE_REL); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
841 |
} |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
842 |
return 0; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
843 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
844 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
845 |
static int ccat_eth_stop(struct net_device *dev) |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
846 |
{ |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
847 |
struct ccat_eth_priv *const priv = netdev_priv(dev); |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
848 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
849 |
priv->stop_queue(dev); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
850 |
if (!priv->ecdev) { |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
851 |
hrtimer_cancel(&priv->poll_timer); |
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
852 |
} |
2572
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
853 |
return 0; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
854 |
} |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
855 |
|
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
856 |
static const struct net_device_ops ccat_eth_netdev_ops = { |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
857 |
.ndo_get_stats64 = ccat_eth_get_stats64, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
858 |
.ndo_open = ccat_eth_open, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
859 |
.ndo_start_xmit = ccat_eth_start_xmit, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
860 |
.ndo_stop = ccat_eth_stop, |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
861 |
}; |
0bc1ec2711b1
reorder functions in netdev.c to avoid forward declarations
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2570
diff
changeset
|
862 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
863 |
static struct ccat_eth_priv *ccat_eth_alloc_netdev(struct ccat_function *func) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
864 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
865 |
struct ccat_eth_priv *priv = NULL; |
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
|
866 |
struct net_device *const netdev = alloc_etherdev(sizeof(*priv)); |
2567
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
867 |
|
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
868 |
if (netdev) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
869 |
priv = netdev_priv(netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
870 |
memset(priv, 0, sizeof(*priv)); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
871 |
priv->netdev = netdev; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
872 |
priv->func = func; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
873 |
ccat_eth_priv_init_reg(priv); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
874 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
875 |
return priv; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
876 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
877 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
878 |
static int ccat_eth_init_netdev(struct ccat_eth_priv *priv) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
879 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
880 |
int status; |
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
|
881 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
882 |
/* init netdev with MAC and stack callbacks */ |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
883 |
memcpy_fromio(priv->netdev->dev_addr, priv->reg.mii + 8, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
884 |
priv->netdev->addr_len); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
885 |
priv->netdev->netdev_ops = &ccat_eth_netdev_ops; |
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
|
886 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
887 |
/* use as EtherCAT device? */ |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
888 |
priv->carrier_off = ecdev_carrier_off; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
889 |
priv->carrier_ok = ecdev_carrier_ok; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
890 |
priv->carrier_on = ecdev_carrier_on; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
891 |
priv->kfree_skb_any = ecdev_kfree_skb_any; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
892 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
893 |
/* It would be more intuitive to check for: |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
894 |
* if (priv->func->drv->type == CCATINFO_ETHERCAT_MASTER_DMA) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
895 |
* unfortunately priv->func->drv is not initialized until probe() returns. |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
896 |
* So we check if there is a rx dma fifo registered to determine dma/io mode */ |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
897 |
if (&dma_rx_fifo_ops == priv->rx_fifo.ops) { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
898 |
priv->receive = ecdev_receive_dma; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
899 |
} else { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
900 |
priv->receive = ecdev_receive_eim; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
901 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
902 |
priv->start_queue = ecdev_nop; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
903 |
priv->stop_queue = ecdev_nop; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
904 |
priv->unregister = unregister_ecdev; |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
905 |
priv->ecdev = ecdev_offer(priv->netdev, ec_poll, THIS_MODULE); |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
906 |
if (priv->ecdev) { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
907 |
priv->carrier_off(priv->netdev); |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
908 |
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
|
909 |
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
|
910 |
ecdev_withdraw(priv->ecdev); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
911 |
ccat_eth_priv_free(priv); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
912 |
free_netdev(priv->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
913 |
return -1; // TODO return better error code |
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
|
914 |
} |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
915 |
priv->func->private_data = priv; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
916 |
return 0; |
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
|
917 |
} |
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
918 |
|
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
919 |
/* 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
|
920 |
priv->carrier_off = netif_carrier_off; |
2567
d70aad2f131f
- use short kernel types, add empty lines after variable declaration to conform better with linux coding style
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2565
diff
changeset
|
921 |
priv->carrier_ok = netif_carrier_ok; |
2550
7e25950ea941
replace not working symlinks with real copies from the ccat main repository(git)
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2549
diff
changeset
|
922 |
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
|
923 |
priv->kfree_skb_any = dev_kfree_skb_any; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
924 |
priv->receive = ccat_eth_receive; |
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
|
925 |
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
|
926 |
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
|
927 |
priv->unregister = unregister_netdev; |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
928 |
priv->carrier_off(priv->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
929 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
930 |
status = register_netdev(priv->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
931 |
if (status) { |
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
|
932 |
pr_info("unable to register network device.\n"); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
933 |
ccat_eth_priv_free(priv); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
934 |
free_netdev(priv->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
935 |
return status; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
936 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
937 |
pr_info("registered %s as network device.\n", priv->netdev->name); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
938 |
priv->func->private_data = priv; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
939 |
return 0; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
940 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
941 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
942 |
static int ccat_eth_dma_probe(struct ccat_function *func) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
943 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
944 |
struct ccat_eth_priv *priv = ccat_eth_alloc_netdev(func); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
945 |
int status; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
946 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
947 |
if (!priv) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
948 |
return -ENOMEM; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
949 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
950 |
status = ccat_eth_priv_init_dma(priv); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
951 |
if (status) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
952 |
pr_warn("%s(): DMA initialization failed.\n", __FUNCTION__); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
953 |
free_netdev(priv->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
954 |
return status; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
955 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
956 |
return ccat_eth_init_netdev(priv); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
957 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
958 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
959 |
static void ccat_eth_dma_remove(struct ccat_function *func) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
960 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
961 |
struct ccat_eth_priv *const eth = func->private_data; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
962 |
eth->unregister(eth->netdev); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
963 |
ccat_eth_priv_free(eth); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
964 |
free_netdev(eth->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
965 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
966 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
967 |
const struct ccat_driver eth_dma_driver = { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
968 |
.type = CCATINFO_ETHERCAT_MASTER_DMA, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
969 |
.probe = ccat_eth_dma_probe, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
970 |
.remove = ccat_eth_dma_remove, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
971 |
}; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
972 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
973 |
static int ccat_eth_eim_probe(struct ccat_function *func) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
974 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
975 |
struct ccat_eth_priv *priv = ccat_eth_alloc_netdev(func); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
976 |
int status; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
977 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
978 |
if (!priv) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
979 |
return -ENOMEM; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
980 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
981 |
status = ccat_eth_priv_init_eim(priv); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
982 |
if (status) { |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
983 |
pr_warn("%s(): memory initialization failed.\n", __FUNCTION__); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
984 |
free_netdev(priv->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
985 |
return status; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
986 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
987 |
return ccat_eth_init_netdev(priv); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
988 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
989 |
|
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
990 |
static void ccat_eth_eim_remove(struct ccat_function *func) |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
991 |
{ |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
992 |
struct ccat_eth_priv *const eth = func->private_data; |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
993 |
eth->unregister(eth->netdev); |
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
994 |
ccat_eth_priv_free(eth); |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
995 |
free_netdev(eth->netdev); |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
996 |
} |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
997 |
|
2638
5995331a55fe
update ccat driver to v0.14
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2636
diff
changeset
|
998 |
const struct ccat_driver eth_eim_driver = { |
2636
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
999 |
.type = CCATINFO_ETHERCAT_NODMA, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
1000 |
.probe = ccat_eth_eim_probe, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
1001 |
.remove = ccat_eth_eim_remove, |
0613017547fe
update ccat driver to v0.13
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
2578
diff
changeset
|
1002 |
}; |