34 #include <linux/module.h> 35 #include <linux/jiffies.h> 36 #include <linux/slab.h> 44 #define EC_SOE_REQUEST_RESPONSE_TIMEOUT 1000 58 INIT_LIST_HEAD(&req->
list);
67 req->
state = EC_INT_REQUEST_INIT;
155 if (size <= req->mem_size)
160 if (!(req->
data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
161 EC_ERR(
"Failed to allocate %zu bytes of SoE memory.\n", size);
181 const uint8_t *source,
189 memcpy(req->
data, source, size);
205 const uint8_t *source,
211 uint8_t *new_data = (uint8_t *) kmalloc(new_size, GFP_KERNEL);
213 EC_ERR(
"Failed to allocate %zu bytes of SoE memory.\n",
219 req->
data = new_data;
237 req->
state = EC_INT_REQUEST_QUEUED;
251 req->
state = EC_INT_REQUEST_QUEUED;
uint16_t error_code
SoE error code.
void ec_soe_request_set_idn(ec_soe_request_t *req, uint16_t idn)
Set IDN.
ec_direction_t dir
Direction.
void ec_soe_request_read(ec_soe_request_t *req)
Request a read operation.
uint8_t * ecrt_soe_request_data(ec_soe_request_t *req)
Access to the SoE request's data.
size_t data_size
Size of SDO data.
void ecrt_soe_request_idn(ec_soe_request_t *req, uint8_t drive_no, uint16_t idn)
Set the request's drive and Sercos ID numbers.
ec_al_state_t al_state
AL state (only valid for IDN config).
unsigned long jiffies_start
Jiffies, when the request was issued.
int ec_soe_request_copy_data(ec_soe_request_t *req, const uint8_t *source, size_t size)
Copies SoE data from an external source.
uint32_t issue_timeout
Maximum time in ms, the processing of the request may take.
void ec_soe_request_set_drive_no(ec_soe_request_t *req, uint8_t drive_no)
Set drive number.
struct list_head list
List item.
void ec_soe_request_clear(ec_soe_request_t *req)
SoE request destructor.
void ec_soe_request_clear_data(ec_soe_request_t *)
Free allocated memory.
ec_request_state_t ecrt_soe_request_state(ec_soe_request_t *req)
Get the current state of the SoE request.
Values read by the master.
int ec_soe_request_append_data(ec_soe_request_t *req, const uint8_t *source, size_t size)
Copies SoE data from an external source.
int ec_soe_request_alloc(ec_soe_request_t *req, size_t size)
Pre-allocates the data memory.
#define EC_ERR(fmt, args...)
Convenience macro for printing EtherCAT-specific errors to syslog.
uint8_t drive_no
Drive number.
void ecrt_soe_request_write(ec_soe_request_t *req)
Schedule an SoE IDN write operation.
void ecrt_soe_request_read(ec_soe_request_t *req)
Schedule an SoE IDN read operation.
EtherCAT SoE request structure.
int ec_soe_request_timed_out(const ec_soe_request_t *req)
Checks, if the timeout was exceeded.
void ec_soe_request_write(ec_soe_request_t *req)
Request a write operation.
void ec_soe_request_init(ec_soe_request_t *req)
SoE request constructor.
void ecrt_soe_request_timeout(ec_soe_request_t *req, uint32_t timeout)
Set the timeout for an SoE request.
ec_request_state_t
Request state.
unsigned long jiffies_sent
Jiffies, when the upload/download request was sent.
Values written by the master.
const ec_request_state_t ec_request_state_translation_table[]
Global request state type translation table.
size_t mem_size
Size of SDO data memory.
size_t ecrt_soe_request_data_size(const ec_soe_request_t *req)
Returns the current IDN data size.
uint16_t idn
Sercos ID-Number.
ec_internal_request_state_t state
Request state.
Sercos-over-EtherCAT request.
uint8_t * data
Pointer to SDO data.
int ec_soe_request_copy(ec_soe_request_t *req, const ec_soe_request_t *other)
Copy another SoE request.