author | Florian Pose <fp@igh-essen.com> |
Fri, 20 Nov 2009 19:01:38 +0100 | |
changeset 1562 | 5c249f469b81 |
parent 1543 | 373cd456dc26 |
child 1822 | 74e6ac2369f4 |
permissions | -rw-r--r-- |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3 |
* $Id$ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
5 |
* Copyright (C) 2008 Olav Zarges, imc Messsysteme GmbH |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
11 |
* published by the Free Software Foundation. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
16 |
* Public License for more details. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
\file |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
EtherCAT FoE state machines. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "globals.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "master.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "mailbox.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "fsm_foe.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "foe.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
/** Maximum time in ms to wait for responses when reading out the dictionary. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
#define EC_FSM_FOE_TIMEOUT 3000 |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
1465 | 49 |
/** Mailbox type FoE. |
50 |
*/ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
#define EC_MBOX_TYPE_FILEACCESS 0x04 |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
|
1465 | 53 |
/** Size of the FoE header. |
54 |
*/ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
55 |
#define EC_FOE_HEADER_SIZE 6 |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
56 |
// uint8_t OpCode |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
57 |
// uint8_t reserved |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
58 |
// uint32_t PacketNo, Password, ErrorCode |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
59 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
60 |
//#define DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
61 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
62 |
/*****************************************************************************/ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
63 |
|
1416 | 64 |
/** FoE OpCodes. |
65 |
*/ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
66 |
enum { |
1416 | 67 |
EC_FOE_OPCODE_RRQ = 1, /**< Read request. */ |
68 |
EC_FOE_OPCODE_WRQ = 2, /**< Write request. */ |
|
69 |
EC_FOE_OPCODE_DATA = 3, /**< Data. */ |
|
70 |
EC_FOE_OPCODE_ACK = 4, /**< Acknowledge. */ |
|
71 |
EC_FOE_OPCODE_ERR = 5, /**< Error. */ |
|
72 |
EC_FOE_OPCODE_BUSY = 6 /**< Busy. */ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
73 |
} ec_foe_opcode_t; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
74 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
75 |
/*****************************************************************************/ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
76 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
77 |
int ec_foe_prepare_data_send(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
78 |
int ec_foe_prepare_wrq_send(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
79 |
int ec_foe_prepare_rrq_send(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
80 |
int ec_foe_prepare_send_ack(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
81 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
82 |
void ec_foe_set_tx_error(ec_fsm_foe_t *, uint32_t); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
83 |
void ec_foe_set_rx_error(ec_fsm_foe_t *, uint32_t); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
84 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
85 |
void ec_fsm_foe_write(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
86 |
void ec_fsm_foe_read(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
87 |
void ec_fsm_foe_end(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
88 |
void ec_fsm_foe_error(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
89 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
90 |
void ec_fsm_foe_state_wrq_sent(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
91 |
void ec_fsm_foe_state_rrq_sent(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
92 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
93 |
void ec_fsm_foe_state_ack_check(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
94 |
void ec_fsm_foe_state_ack_read(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
95 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
96 |
void ec_fsm_foe_state_data_sent(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
97 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
98 |
void ec_fsm_foe_state_data_check(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
99 |
void ec_fsm_foe_state_data_read(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
100 |
void ec_fsm_foe_state_sent_ack(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
101 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
102 |
void ec_fsm_foe_write_start(ec_fsm_foe_t *); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
103 |
void ec_fsm_foe_read_start(ec_fsm_foe_t *); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
Constructor. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
void ec_fsm_foe_init(ec_fsm_foe_t *fsm, /**< finite state machine */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
ec_datagram_t *datagram /**< datagram */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
fsm->state = NULL; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
fsm->datagram = datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
fsm->rx_errors = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
fsm->tx_errors = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
Destructor. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
void ec_fsm_foe_clear(ec_fsm_foe_t *fsm /**< finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
Executes the current state of the state machine. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
\return false, if state machine has terminated |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
int ec_fsm_foe_exec(ec_fsm_foe_t *fsm /**< finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
fsm->state(fsm); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
return fsm->state != ec_fsm_foe_end && fsm->state != ec_fsm_foe_error; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
Returns, if the state machine terminated with success. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
\return non-zero if successful. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
int ec_fsm_foe_success(ec_fsm_foe_t *fsm /**< Finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
return fsm->state == ec_fsm_foe_end; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
|
1465 | 159 |
/** Prepares an FoE transfer. |
160 |
*/ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
void ec_fsm_foe_transfer( |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
ec_fsm_foe_t *fsm, /**< State machine. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
ec_foe_request_t *request /**< Sdo request. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
fsm->slave = slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
fsm->request = request; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
if (request->dir == EC_DIR_OUTPUT) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
fsm->state = ec_fsm_foe_write; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
else { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
fsm->state = ec_fsm_foe_read; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
State: ERROR. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
void ec_fsm_foe_error(ec_fsm_foe_t *fsm /**< finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
185 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
186 |
printk("ec_fsm_foe_error()\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
State: END. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
void ec_fsm_foe_end(ec_fsm_foe_t *fsm /**< finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
198 |
#ifdef DEBUG_FOE |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
printk("ec_fsm_foe_end\n"); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
Sends a file or the next fragment. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
208 |
int ec_foe_prepare_data_send(ec_fsm_foe_t *fsm) |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
209 |
{ |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
210 |
size_t remaining_size, current_size; |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
211 |
uint8_t *data; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
remaining_size = fsm->tx_buffer_size - fsm->tx_buffer_offset; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
215 |
if (remaining_size < fsm->slave->configured_tx_mailbox_size |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
216 |
- EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
current_size = remaining_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
fsm->tx_last_packet = 1; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
219 |
} else { |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
220 |
current_size = fsm->slave->configured_tx_mailbox_size |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
221 |
- EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
224 |
data = ec_slave_mbox_prepare_send(fsm->slave, |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
225 |
fsm->datagram, EC_MBOX_TYPE_FILEACCESS, |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
226 |
current_size + EC_FOE_HEADER_SIZE); |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
227 |
if (IS_ERR(data)) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
return -1; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
230 |
EC_WRITE_U8 ( data, EC_FOE_OPCODE_DATA ); // OpCode = DataBlock req. |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
231 |
EC_WRITE_U32( data + 2, fsm->tx_packet_no ); // PacketNo, Password |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
232 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
233 |
memcpy(data + EC_FOE_HEADER_SIZE, |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
234 |
fsm->tx_buffer + fsm->tx_buffer_offset, current_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
fsm->tx_current_size = current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
Prepare a write request (WRQ) with filename |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
245 |
int ec_foe_prepare_wrq_send(ec_fsm_foe_t *fsm) |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
246 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
size_t current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
fsm->tx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
fsm->tx_current_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
253 |
fsm->tx_last_packet = 0; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
current_size = fsm->tx_filename_len; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
257 |
data = ec_slave_mbox_prepare_send(fsm->slave, fsm->datagram, |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
258 |
EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE); |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
259 |
if (IS_ERR(data)) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
return -1; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
262 |
EC_WRITE_U16( data, EC_FOE_OPCODE_WRQ); // fsm write request |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
EC_WRITE_U32( data + 2, fsm->tx_packet_no ); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
memcpy(data + EC_FOE_HEADER_SIZE, fsm->tx_filename, current_size); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
|
1465 | 272 |
/** Start a write operation. |
273 |
*/ |
|
274 |
void ec_fsm_foe_write( |
|
275 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
276 |
) |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
fsm->tx_buffer = fsm->request->buffer; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
fsm->tx_buffer_size = fsm->request->data_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
fsm->tx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
282 |
fsm->tx_filename = fsm->request->file_name; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
283 |
fsm->tx_filename_len = strlen(fsm->tx_filename); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
284 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
285 |
fsm->state = ec_fsm_foe_write_start; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
/*****************************************************************************/ |
1465 | 289 |
|
290 |
/** Initializes the FoE write state machine. |
|
291 |
*/ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
void ec_fsm_foe_write_start(ec_fsm_foe_t *fsm /**< finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
fsm->tx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
fsm->tx_current_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
299 |
fsm->tx_last_packet = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
300 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
301 |
#ifdef DEBUG_FOE |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
printk("ec_fsm_foe_write_start()\n"); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_FOE)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
EC_ERR("Slave %u does not support FoE!\n", slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
310 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
if (ec_foe_prepare_wrq_send(fsm)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
312 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
313 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
314 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
315 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
316 |
fsm->state = ec_fsm_foe_state_wrq_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
317 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
318 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
319 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
|
1465 | 321 |
/** Check for acknowledge. |
322 |
*/ |
|
323 |
void ec_fsm_foe_state_ack_check( |
|
324 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
325 |
) |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
326 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
328 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
330 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
331 |
printk("ec_fsm_foe_ack_check()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
332 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
333 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
335 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
EC_ERR("Failed to receive FoE mailbox check datagram for slave %u" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
" (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
if (datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
343 |
// slave did not put anything in the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
EC_ERR("Reception of FoE mailbox check datagram failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
347 |
ec_datagram_print_wc_error(datagram); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
348 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
349 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
351 |
if (!ec_slave_mbox_check(datagram)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
352 |
unsigned long diff_ms = |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
353 |
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
355 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
EC_ERR("Timeout while waiting for ack response " |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
357 |
"on slave %u.\n", slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
358 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
359 |
} |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
360 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
361 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
362 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
363 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
364 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
365 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
366 |
// Fetch response |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
367 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
368 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
369 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
370 |
fsm->state = ec_fsm_foe_state_ack_read; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
371 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
372 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
373 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
374 |
|
1465 | 375 |
/** Acknowledge a read operation. |
376 |
*/ |
|
377 |
void ec_fsm_foe_state_ack_read( |
|
378 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
379 |
) |
|
380 |
{ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
383 |
uint8_t *data, mbox_prot; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
384 |
uint8_t opCode; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
size_t rec_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
387 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
388 |
printk("ec_fsm_foe_ack_read()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
389 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
390 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
391 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
392 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
EC_ERR("Failed to receive FoE ack response datagram for" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
" slave %u (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
395 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
397 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
398 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
399 |
if (datagram->working_counter != 1) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
400 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
401 |
EC_ERR("Reception of FoE ack response failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
402 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
ec_datagram_print_wc_error(datagram); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
404 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
406 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
407 |
if (!(data = ec_slave_mbox_fetch(fsm->slave, datagram, |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
408 |
&mbox_prot, &rec_size))) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
409 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
410 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
411 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
412 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
413 |
if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
414 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
EC_ERR("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
419 |
opCode = EC_READ_U8(data); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
420 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
421 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
422 |
// slave not ready |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
if (ec_foe_prepare_data_send(fsm)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
424 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
EC_ERR("Slave is busy.\n"); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
426 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
fsm->state = ec_fsm_foe_state_data_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
432 |
if (opCode == EC_FOE_OPCODE_ACK) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
fsm->tx_packet_no++; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
fsm->tx_buffer_offset += fsm->tx_current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
if (fsm->tx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
437 |
fsm->state = ec_fsm_foe_end; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
438 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
if (ec_foe_prepare_data_send(fsm)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
442 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
443 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
444 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
445 |
fsm->state = ec_fsm_foe_state_data_sent; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
446 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
447 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
448 |
ec_foe_set_tx_error(fsm, FOE_ACK_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
/*****************************************************************************/ |
1465 | 452 |
|
453 |
/** State: WRQ SENT. |
|
454 |
* |
|
455 |
* Checks is the previous transmit datagram succeded and sends the next |
|
456 |
* fragment, if necessary. |
|
457 |
*/ |
|
458 |
void ec_fsm_foe_state_wrq_sent( |
|
459 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
460 |
) |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
461 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
465 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
466 |
printk("ec_foe_state_sent_wrq()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
467 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
468 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
469 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
470 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
471 |
EC_ERR("Failed to send FoE WRQ for slave %u" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
472 |
" (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
473 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
477 |
if (datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
478 |
// slave did not put anything in the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
480 |
EC_ERR("Reception of FoE WRQ failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
481 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
482 |
ec_datagram_print_wc_error(datagram); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
483 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
484 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
485 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
486 |
fsm->jiffies_start = datagram->jiffies_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
487 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
ec_slave_mbox_prepare_check(fsm->slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
489 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
490 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
491 |
fsm->state = ec_fsm_foe_state_ack_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
492 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
493 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
494 |
/*****************************************************************************/ |
1465 | 495 |
|
496 |
/** State: WRQ SENT. |
|
497 |
* |
|
498 |
* Checks is the previous transmit datagram succeded and sends the next |
|
499 |
* fragment, if necessary. |
|
500 |
*/ |
|
501 |
void ec_fsm_foe_state_data_sent( |
|
502 |
ec_fsm_foe_t *fsm /**< Foe statemachine. */ |
|
503 |
) |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
504 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
505 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
506 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
507 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
508 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
509 |
printk("ec_fsm_foe_state_data_sent()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
510 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
511 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
512 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
513 |
ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
514 |
EC_ERR("Failed to receive FoE ack response datagram for" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
515 |
" slave %u (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
516 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
518 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
519 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
520 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
521 |
ec_foe_set_tx_error(fsm, FOE_WC_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
522 |
EC_ERR("Reception of FoE data send failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
523 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
524 |
ec_datagram_print_wc_error(datagram); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
525 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
526 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
527 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
528 |
ec_slave_mbox_prepare_check(fsm->slave, fsm->datagram); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
529 |
fsm->jiffies_start = jiffies; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
530 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
531 |
fsm->state = ec_fsm_foe_state_ack_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
532 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
533 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
534 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
535 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
536 |
Prepare a read request (RRQ) with filename |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
537 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
538 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
539 |
int ec_foe_prepare_rrq_send(ec_fsm_foe_t *fsm) |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
540 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
541 |
size_t current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
542 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
543 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
544 |
current_size = fsm->rx_filename_len; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
545 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
546 |
data = ec_slave_mbox_prepare_send(fsm->slave, fsm->datagram, |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
547 |
EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE); |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
548 |
if (IS_ERR(data)) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
549 |
return -1; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
550 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
551 |
EC_WRITE_U16(data, EC_FOE_OPCODE_RRQ); // fsm read request |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
552 |
EC_WRITE_U32(data + 2, 0x00000000); // no passwd |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
553 |
memcpy(data + EC_FOE_HEADER_SIZE, fsm->rx_filename, current_size); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
554 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
555 |
if (fsm->slave->master->debug_level) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
556 |
EC_DBG("FoE Read Request:\n"); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
557 |
ec_print_data(data, current_size + EC_FOE_HEADER_SIZE); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
558 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
559 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
560 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
561 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
562 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
563 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
564 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
565 |
|
1465 | 566 |
/** Prepare to send an acknowledge. |
567 |
*/ |
|
568 |
int ec_foe_prepare_send_ack( |
|
569 |
ec_fsm_foe_t *foe /**< FoE statemachine. */ |
|
570 |
) |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
571 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
572 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
573 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
574 |
data = ec_slave_mbox_prepare_send(foe->slave, foe->datagram, |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
575 |
EC_MBOX_TYPE_FILEACCESS, EC_FOE_HEADER_SIZE); |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
576 |
if (IS_ERR(data)) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
577 |
return -1; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
578 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
579 |
EC_WRITE_U16(data, EC_FOE_OPCODE_ACK); |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
580 |
EC_WRITE_U32(data + 2, foe->rx_expected_packet_no); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
581 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
583 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
585 |
/*****************************************************************************/ |
1465 | 586 |
|
587 |
/** State: RRQ SENT. |
|
588 |
* |
|
589 |
* Checks is the previous transmit datagram succeded and sends the next |
|
590 |
* fragment, if necessary. |
|
591 |
*/ |
|
592 |
void ec_fsm_foe_state_rrq_sent( |
|
593 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
594 |
) |
|
595 |
{ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
596 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
597 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
598 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
599 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
600 |
printk("ec_foe_state_rrq_sent()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
601 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
602 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
603 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
604 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
605 |
EC_ERR("Failed to send FoE RRQ for slave %u" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
606 |
" (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
607 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
608 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
609 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
610 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
611 |
if (datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
612 |
// slave did not put anything in the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
613 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
614 |
EC_ERR("Reception of FoE RRQ failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
615 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
616 |
ec_datagram_print_wc_error(datagram); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
617 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
618 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
619 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
620 |
fsm->jiffies_start = datagram->jiffies_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
621 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
622 |
ec_slave_mbox_prepare_check(fsm->slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
623 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
624 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
625 |
fsm->state = ec_fsm_foe_state_data_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
626 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
627 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
628 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
629 |
|
1465 | 630 |
/** Start a read operation. |
631 |
*/ |
|
632 |
void ec_fsm_foe_read( |
|
633 |
ec_fsm_foe_t *fsm /**< FoE state machine. */ |
|
634 |
) |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
635 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
636 |
fsm->state = ec_fsm_foe_read_start; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
637 |
fsm->rx_filename = fsm->request->file_name; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
638 |
fsm->rx_filename_len = strlen(fsm->rx_filename); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
639 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
640 |
fsm->rx_buffer = fsm->request->buffer; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
641 |
fsm->rx_buffer_size = fsm->request->buffer_size; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
642 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
643 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
644 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
645 |
|
1465 | 646 |
/** Starting state for read operations. |
647 |
*/ |
|
648 |
void ec_fsm_foe_read_start( |
|
649 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
650 |
) |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
651 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
652 |
size_t current_size; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
653 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
654 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
655 |
fsm->rx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
656 |
fsm->rx_current_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
657 |
fsm->rx_packet_no = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
658 |
fsm->rx_expected_packet_no = 1; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
659 |
fsm->rx_last_packet = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
660 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
661 |
current_size = fsm->rx_filename_len; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
662 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
663 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
664 |
printk("ec_fsm_foe_read_start()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
665 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
666 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
667 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_FOE)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
668 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
669 |
EC_ERR("Slave %u does not support FoE!\n", slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
670 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
671 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
672 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
673 |
if (ec_foe_prepare_rrq_send(fsm)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
674 |
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
675 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
676 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
677 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
678 |
fsm->state = ec_fsm_foe_state_rrq_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
679 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
680 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
681 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
682 |
|
1465 | 683 |
/** Check for data. |
684 |
*/ |
|
685 |
void ec_fsm_foe_state_data_check( |
|
686 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
687 |
) |
|
688 |
{ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
689 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
690 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
691 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
692 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
693 |
printk("ec_fsm_foe_state_data_check()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
694 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
695 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
696 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
697 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
698 |
EC_ERR("Failed to send FoE DATA READ for slave %u" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
699 |
" (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
700 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
701 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
702 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
703 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
704 |
if (datagram->working_counter != 1) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
705 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
706 |
EC_ERR("Reception of FoE DATA READ on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
707 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
708 |
ec_datagram_print_wc_error(datagram); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
709 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
710 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
711 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
712 |
if (!ec_slave_mbox_check(datagram)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
713 |
unsigned long diff_ms = |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
714 |
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
715 |
if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
716 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
717 |
EC_ERR("Timeout while waiting for ack response " |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
718 |
"on slave %u.\n", slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
719 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
720 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
721 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
722 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
723 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
724 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
725 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
726 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
727 |
// Fetch response |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
728 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
729 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
730 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
731 |
fsm->state = ec_fsm_foe_state_data_read; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
732 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
733 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
734 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
735 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
736 |
|
1465 | 737 |
/** Start reading data. |
738 |
*/ |
|
739 |
void ec_fsm_foe_state_data_read( |
|
740 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
741 |
) |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
742 |
{ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
743 |
size_t rec_size; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
744 |
uint8_t *data, opCode, packet_no, mbox_prot; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
745 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
746 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
747 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
748 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
749 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
750 |
printk("ec_fsm_foe_state_data_read()\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
751 |
#endif |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
752 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
753 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
754 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
755 |
EC_ERR("Failed to receive FoE DATA READ datagram for" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
756 |
" slave %u (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
757 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
758 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
759 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
760 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
761 |
if (datagram->working_counter != 1) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
762 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
763 |
EC_ERR("Reception of FoE DATA READ failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
764 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
765 |
ec_datagram_print_wc_error(datagram); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
766 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
767 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
768 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
769 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot, &rec_size))) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
770 |
ec_foe_set_rx_error(fsm, FOE_MBOX_FETCH_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
771 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
772 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
773 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
774 |
if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
775 |
EC_ERR("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
776 |
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
777 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
778 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
779 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
780 |
opCode = EC_READ_U8(data); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
781 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
782 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
783 |
if (ec_foe_prepare_send_ack(fsm)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
784 |
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
785 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
786 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
787 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
788 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
789 |
if (opCode == EC_FOE_OPCODE_ERR) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
790 |
fsm->request->error_code = EC_READ_U32(data + 2); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
791 |
EC_ERR("Received FoE Error Request (code 0x%08x) on slave %u.\n", |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
792 |
fsm->request->error_code, slave->ring_position); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
793 |
if (rec_size > 6) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
794 |
uint8_t text[1024]; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
795 |
strncpy(text, data + 6, min(rec_size - 6, sizeof(text))); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
796 |
EC_ERR("FoE Error Text: %s\n", text); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
797 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
798 |
ec_foe_set_rx_error(fsm, FOE_OPCODE_ERROR); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
799 |
return; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
800 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
801 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
802 |
if (opCode != EC_FOE_OPCODE_DATA) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
803 |
EC_ERR("Received OPCODE %x, expected %x on slave %u.\n", |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
804 |
opCode, EC_FOE_OPCODE_DATA, slave->ring_position); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
805 |
fsm->request->error_code = 0x00000000; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
806 |
ec_foe_set_rx_error(fsm, FOE_OPCODE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
807 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
808 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
809 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
810 |
packet_no = EC_READ_U16(data + 2); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
811 |
if (packet_no != fsm->rx_expected_packet_no) { |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
812 |
EC_ERR("Received unexpected packet number on slave %u.\n", |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
813 |
slave->ring_position); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
814 |
ec_foe_set_rx_error(fsm, FOE_PACKETNO_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
815 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
816 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
817 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
818 |
rec_size -= EC_FOE_HEADER_SIZE; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
819 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
820 |
if (fsm->rx_buffer_size >= fsm->rx_buffer_offset + rec_size) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
821 |
memcpy(fsm->rx_buffer + fsm->rx_buffer_offset, |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
822 |
data + EC_FOE_HEADER_SIZE, rec_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
823 |
fsm->rx_buffer_offset += rec_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
824 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
825 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
826 |
fsm->rx_last_packet = |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
827 |
(rec_size + EC_MBOX_HEADER_SIZE + EC_FOE_HEADER_SIZE |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
828 |
!= fsm->slave->configured_rx_mailbox_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
829 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
830 |
if (fsm->rx_last_packet || |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
831 |
(slave->configured_rx_mailbox_size - EC_MBOX_HEADER_SIZE |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
832 |
- EC_FOE_HEADER_SIZE + fsm->rx_buffer_offset) |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
833 |
<= fsm->rx_buffer_size) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
834 |
// either it was the last packet or a new packet will fit into the |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
835 |
// delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
836 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
837 |
printk ("last_packet=true\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
838 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
839 |
if (ec_foe_prepare_send_ack(fsm)) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
840 |
ec_foe_set_rx_error(fsm, FOE_RX_DATA_ACK_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
841 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
842 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
843 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
844 |
fsm->state = ec_fsm_foe_state_sent_ack; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
845 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
846 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
847 |
// no more data fits into the delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
848 |
// ... wait for new read request |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
849 |
printk ("ERROR: data doesn't fit in receive buffer\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
850 |
printk (" rx_buffer_size = %d\n", fsm->rx_buffer_size); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
851 |
printk (" rx_buffer_offset= %d\n", fsm->rx_buffer_offset); |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1465
diff
changeset
|
852 |
printk (" rec_size = %zd\n", rec_size); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
853 |
printk (" rx_mailbox_size = %d\n", |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
854 |
slave->configured_rx_mailbox_size); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
855 |
printk (" rx_last_packet = %d\n", fsm->rx_last_packet); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
856 |
fsm->request->result = FOE_READY; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
857 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
858 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
859 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
860 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
861 |
|
1465 | 862 |
/** Sent an acknowledge. |
863 |
*/ |
|
864 |
void ec_fsm_foe_state_sent_ack( |
|
865 |
ec_fsm_foe_t *fsm /**< FoE statemachine. */ |
|
866 |
) |
|
867 |
{ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
868 |
ec_datagram_t *datagram = fsm->datagram; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
869 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
870 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
871 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
872 |
printk("ec_foe_state_sent_ack()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
873 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
874 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
875 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
876 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
877 |
EC_ERR("Failed to send FoE ACK for slave %u" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
878 |
" (datagram state %u).\n", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
879 |
slave->ring_position, datagram->state); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
880 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
881 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
882 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
883 |
if (datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
884 |
// slave did not put anything into the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
885 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
886 |
EC_ERR("Reception of FoE ACK failed on slave %u: ", |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
887 |
slave->ring_position); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
888 |
ec_datagram_print_wc_error(datagram); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
889 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
890 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
891 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
892 |
fsm->jiffies_start = datagram->jiffies_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
893 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
894 |
ec_slave_mbox_prepare_check(fsm->slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
895 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
896 |
if (fsm->rx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
897 |
fsm->rx_expected_packet_no = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
898 |
fsm->request->data_size = fsm->rx_buffer_offset; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
899 |
fsm->state = ec_fsm_foe_end; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
900 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
901 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
902 |
fsm->rx_expected_packet_no++; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
903 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
904 |
fsm->state = ec_fsm_foe_state_data_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
905 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
906 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
907 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
908 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
909 |
|
1465 | 910 |
/** Set an error code and go to the send error state. |
911 |
*/ |
|
912 |
void ec_foe_set_tx_error( |
|
913 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
914 |
uint32_t errorcode /**< FoE error code. */ |
|
915 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
916 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
917 |
fsm->tx_errors++; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
918 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
919 |
fsm->state = ec_fsm_foe_error; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
920 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
921 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
922 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
923 |
|
1465 | 924 |
/** Set an error code and go to the receive error state. |
925 |
*/ |
|
926 |
void ec_foe_set_rx_error( |
|
927 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
928 |
uint32_t errorcode /**< FoE error code. */ |
|
929 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
930 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
931 |
fsm->rx_errors++; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
932 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
933 |
fsm->state = ec_fsm_foe_error; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
934 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
935 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
936 |
/*****************************************************************************/ |