38 #define EC_EOE_RESPONSE_TIMEOUT 3000 // [ms] 68 for (i = 0; i < 4; i++) {
69 ((u8 *) dst)[i] = ((
const u8 *) src)[3 - i];
126 int datagram_used = 0;
133 return datagram_used;
136 fsm->
state(fsm, datagram);
147 return datagram_used;
196 return PTR_ERR(data);
200 memset(data, 0, size);
208 ((req->mac_address_included != 0) << 0) |
209 ((req->ip_address_included != 0) << 1) |
210 ((req->subnet_mask_included != 0) << 2) |
211 ((req->gateway_included != 0) << 3) |
212 ((req->dns_included != 0) << 4) |
213 ((req->name_included != 0) << 5)
218 if (req->mac_address_included) {
219 memcpy(cur, req->mac_address, ETH_ALEN);
223 if (req->ip_address_included) {
228 if (req->subnet_mask_included) {
233 if (req->gateway_included) {
238 if (req->dns_included) {
243 if (req->name_included) {
306 EC_SLAVE_ERR(slave,
"Failed to receive EoE set IP parameter" 313 unsigned long diff_ms =
326 EC_SLAVE_ERR(slave,
"Reception of EoE set IP parameter request" 327 " failed after %lu ms: ", diff_ms);
357 EC_SLAVE_ERR(slave,
"Failed to receive EoE mailbox check datagram: ");
365 " datagram failed: ");
371 unsigned long diff_ms =
376 EC_SLAVE_ERR(slave,
"Timeout after %lu ms while waiting for" 377 " set IP parameter response.\n", diff_ms);
403 uint8_t *data, mbox_prot, frame_type;
414 EC_SLAVE_ERR(slave,
"Failed to receive EoE read response datagram: ");
421 EC_SLAVE_ERR(slave,
"Reception of EoE read response failed: ");
437 if (mbox_prot != EC_MBOX_TYPE_EOE) {
439 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
446 EC_SLAVE_ERR(slave,
"Received currupted EoE set IP parameter response" 447 " (%zu bytes)!\n", rec_size);
456 EC_SLAVE_DBG(slave, 0,
"Received no set IP parameter response" 457 " (frame type %x).\n", frame_type);
470 EC_SLAVE_ERR(slave,
"Received no set IP parameter response.\n");
480 EC_SLAVE_DBG(slave, 1,
"EoE set IP parameters failed with result code" 481 " 0x%04X.\n", req->result);
#define EC_FSM_RETRIES
Number of state machine retries on datagram timeout.
int ec_fsm_eoe_exec(ec_fsm_eoe_t *fsm, ec_datagram_t *datagram)
Executes the current state of the state machine.
uint8_t * ec_slave_mbox_prepare_send(const ec_slave_t *slave, ec_datagram_t *datagram, uint8_t type, size_t size)
Prepares a mailbox-send datagram.
unsigned long jiffies_sent
Jiffies, when the datagram was sent.
ec_sii_t sii
Extracted SII data.
uint8_t * ec_slave_mbox_fetch(const ec_slave_t *slave, const ec_datagram_t *datagram, uint8_t *type, size_t *size)
Processes received mailbox data.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
Convenience macro for printing slave-specific debug messages to syslog.
ec_slave_t * slave
slave the FSM runs on
int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram to fetch mailbox data.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
uint16_t working_counter
Working counter.
ec_eoe_request_t * request
EoE request.
void ec_fsm_eoe_init(ec_fsm_eoe_t *fsm)
Constructor.
unsigned long jiffies_sent
Jiffies, when the request was sent.
Sent (still in the queue).
#define EC_MAX_HOSTNAME_SIZE
Maximum hostname size.
Set IP Parameter Request.
EtherCAT EoE set IP parameter state machines.
void ec_fsm_eoe_set_ip_param(ec_fsm_eoe_t *fsm, ec_slave_t *slave, ec_eoe_request_t *request)
Starts to set the EoE IP partameters of a slave.
Global definitions and macros.
EtherCAT master structure.
Initial state of a new datagram.
unsigned long jiffies_start
Timestamp.
void ec_fsm_eoe_set_ip_check(ec_fsm_eoe_t *, ec_datagram_t *)
EoE state: SET IP CHECK.
ec_datagram_state_t state
State.
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
uint16_t mailbox_protocols
Supported mailbox protocols.
unsigned int debug_level
Master debug level.
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
void ec_datagram_print_wc_error(const ec_datagram_t *datagram)
Evaluates the working counter of a single-cast datagram.
void ec_fsm_eoe_set_ip_start(ec_fsm_eoe_t *, ec_datagram_t *)
EoE state: SET IP START.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
int ec_fsm_eoe_success(const ec_fsm_eoe_t *fsm)
Returns, if the state machine terminated with success.
ec_master_t * master
Master owning the slave.
void(* state)(ec_fsm_eoe_t *, ec_datagram_t *)
EoE state function.
void memcpy_swap32(void *, const void *)
Host-architecture-independent 32-bit swap function.
void ec_fsm_eoe_error(ec_fsm_eoe_t *, ec_datagram_t *)
State: ERROR.
Ethernet-over-EtherCAT set IP parameter request.
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
void ec_fsm_eoe_clear(ec_fsm_eoe_t *fsm)
Destructor.
unsigned int frame_type_retries
retries upon wrong frame type.
int ec_slave_mbox_prepare_check(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram for checking the mailbox state.
#define EC_READ_U16(DATA)
Read a 16-bit unsigned value from EtherCAT data.
void ec_fsm_eoe_end(ec_fsm_eoe_t *, ec_datagram_t *)
State: END.
void ec_datagram_print_state(const ec_datagram_t *datagram)
Prints the state of a datagram.
#define EC_EOE_RESPONSE_TIMEOUT
Maximum time to wait for a set IP parameter response.
void ec_fsm_eoe_set_ip_response(ec_fsm_eoe_t *, ec_datagram_t *)
EoE state: SET IP RESPONSE.
#define EC_READ_U8(DATA)
Read an 8-bit unsigned value from EtherCAT data.
unsigned int retries
retries upon datagram timeout
int ec_fsm_eoe_prepare_set(ec_fsm_eoe_t *, ec_datagram_t *)
Prepare a set IP parameters operation.
unsigned long jiffies_received
Jiffies, when the datagram was received.
int ec_slave_mbox_check(const ec_datagram_t *datagram)
Processes a mailbox state checking datagram.
void ec_fsm_eoe_set_ip_request(ec_fsm_eoe_t *, ec_datagram_t *)
EoE state: SET IP REQUEST.
Finite state machines for the Ethernet over EtherCAT protocol.
ec_datagram_t * datagram
Datagram used in the previous step.