28 #include <linux/module.h> 29 #include <linux/jiffies.h> 30 #include <linux/slab.h> 38 #define EC_SOE_REQUEST_RESPONSE_TIMEOUT 1000 52 INIT_LIST_HEAD(&req->
list);
61 req->
state = EC_INT_REQUEST_INIT;
149 if (size <= req->mem_size)
154 if (!(req->
data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
155 EC_ERR(
"Failed to allocate %zu bytes of SoE memory.\n", size);
175 const uint8_t *source,
183 memcpy(req->
data, source, size);
199 const uint8_t *source,
205 uint8_t *new_data = (uint8_t *) kmalloc(new_size, GFP_KERNEL);
207 EC_ERR(
"Failed to allocate %zu bytes of SoE memory.\n",
213 req->
data = new_data;
231 req->
state = EC_INT_REQUEST_QUEUED;
246 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.
int ecrt_soe_request_timeout(ec_soe_request_t *req, uint32_t timeout)
Set the timeout for an SoE request.
ec_direction_t dir
Direction.
int 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.
size_t data_size
Size of SDO data.
int ec_soe_request_write(ec_soe_request_t *req)
Request a write operation.
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.
uint8_t * ecrt_soe_request_data(const ec_soe_request_t *req)
Access to the SoE request's data.
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.
size_t ecrt_soe_request_data_size(const ec_soe_request_t *req)
Returns the current IDN data size.
ec_request_state_t ecrt_soe_request_state(const 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.
int ec_soe_request_read(ec_soe_request_t *req)
Request a read operation.
#define EC_ERR(fmt, args...)
Convenience macro for printing EtherCAT-specific errors to syslog.
uint8_t drive_no
Drive number.
EtherCAT SoE request structure.
int ecrt_soe_request_read(ec_soe_request_t *req)
Schedule an SoE IDN read operation.
int ec_soe_request_timed_out(const ec_soe_request_t *req)
Checks, if the timeout was exceeded.
void ec_soe_request_init(ec_soe_request_t *req)
SoE request constructor.
ec_request_state_t
Request state.
unsigned long jiffies_sent
Jiffies, when the upload/download request was sent.
Values written by the master.
int ecrt_soe_request_write(ec_soe_request_t *req)
Schedule an SoE IDN write operation.
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.
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.