37 #include <linux/module.h>
38 #include <linux/vmalloc.h>
50 #define DEBUG_LATENCY 0
55 #define ATTRIBUTES __attribute__ ((__noinline__))
70 strncpy(target, source, EC_IOCTL_STRING_SIZE);
71 target[EC_IOCTL_STRING_SIZE - 1] = 0;
87 ec_ioctl_module_t data;
89 data.ioctl_version_magic = EC_IOCTL_VERSION_MAGIC;
92 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
109 ec_ioctl_master_t io;
110 unsigned int dev_idx, j;
112 if (down_interruptible(&master->
master_sem)) {
122 io.phase = (uint8_t) master->
phase;
123 io.active = (uint8_t) master->
active;
128 if (down_interruptible(&master->
device_sem)) {
137 memcpy(io.devices[dev_idx].address, device->
dev->dev_addr,
140 memcpy(io.devices[dev_idx].address, master->
macs[dev_idx],
143 io.devices[dev_idx].attached = device->
dev ? 1 : 0;
144 io.devices[dev_idx].link_state = device->
link_state ? 1 : 0;
145 io.devices[dev_idx].tx_count = device->
tx_count;
146 io.devices[dev_idx].rx_count = device->
rx_count;
147 io.devices[dev_idx].tx_bytes = device->
tx_bytes;
148 io.devices[dev_idx].rx_bytes = device->
rx_bytes;
149 io.devices[dev_idx].tx_errors = device->
tx_errors;
151 io.devices[dev_idx].tx_frame_rates[j] =
153 io.devices[dev_idx].rx_frame_rates[j] =
155 io.devices[dev_idx].tx_byte_rates[j] =
157 io.devices[dev_idx].rx_byte_rates[j] =
168 io.tx_frame_rates[j] =
170 io.rx_frame_rates[j] =
172 io.tx_byte_rates[j] =
174 io.rx_byte_rates[j] =
186 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
204 ec_ioctl_slave_t data;
208 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
216 master, 0, data.position))) {
218 EC_MASTER_ERR(master,
"Slave %u does not exist!\n", data.position);
242 data.ports[i].desc = slave->
ports[i].
desc;
245 data.ports[i].link.signal_detected =
249 data.ports[i].next_slave =
252 data.ports[i].next_slave = 0xffff;
274 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
291 ec_ioctl_slave_sync_t data;
295 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
303 master, 0, data.slave_position))) {
306 data.slave_position);
312 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
317 sync = &slave->
sii.
syncs[data.sync_index];
322 data.enable = sync->
enable;
327 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
344 ec_ioctl_slave_sync_pdo_t data;
349 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
357 master, 0, data.slave_position))) {
360 data.slave_position);
366 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
371 sync = &slave->
sii.
syncs[data.sync_index];
373 &sync->
pdos, data.pdo_pos))) {
375 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with "
376 "position %u!\n", data.sync_index, data.pdo_pos);
380 data.index = pdo->
index;
386 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
403 ec_ioctl_slave_sync_pdo_entry_t data;
409 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
417 master, 0, data.slave_position))) {
420 data.slave_position);
426 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
431 sync = &slave->
sii.
syncs[data.sync_index];
433 &sync->
pdos, data.pdo_pos))) {
435 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with "
436 "position %u!\n", data.sync_index, data.pdo_pos);
441 pdo, data.entry_pos))) {
443 EC_SLAVE_ERR(slave,
"PDO 0x%04X does not contain an entry with "
444 "position %u!\n", data.pdo_pos, data.entry_pos);
448 data.index = entry->
index;
455 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
472 ec_ioctl_domain_t data;
474 unsigned int dev_idx;
476 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
500 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
517 ec_ioctl_domain_fmmu_t data;
521 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
538 " fmmu configurations.\n",
539 data.domain_index, data.fmmu_index + 1);
543 data.slave_config_alias = fmmu->
sc->
alias;
544 data.slave_config_position = fmmu->
sc->
position;
546 data.dir = fmmu->
dir;
552 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
569 ec_ioctl_domain_data_t data;
572 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
586 if (domain->
data_size != data.data_size) {
593 if (copy_to_user((
void __user *) data.target, domain->
data,
643 ec_ioctl_slave_state_t data;
646 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
654 master, 0, data.slave_position))) {
657 data.slave_position);
678 ec_ioctl_slave_sdo_t data;
682 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
690 master, 0, data.slave_position))) {
693 data.slave_position);
698 slave, data.sdo_position))) {
700 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", data.sdo_position);
704 data.sdo_index = sdo->
index;
710 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
727 ec_ioctl_slave_sdo_entry_t data;
732 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
740 master, 0, data.slave_position))) {
743 data.slave_position);
747 if (data.sdo_spec <= 0) {
749 slave, -data.sdo_spec))) {
751 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", -data.sdo_spec);
756 slave, data.sdo_spec))) {
765 sdo, data.sdo_entry_subindex))) {
767 EC_SLAVE_ERR(slave,
"SDO entry 0x%04X:%02X does not exist!\n",
768 sdo->
index, data.sdo_entry_subindex);
790 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
807 ec_ioctl_slave_sdo_upload_t data;
811 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
815 if (!(target = kmalloc(data.target_size, GFP_KERNEL))) {
817 " for SDO upload.\n", data.target_size);
822 data.sdo_index, data.sdo_entry_subindex, target,
823 data.target_size, &data.data_size, &data.abort_code);
826 if (copy_to_user((
void __user *) data.target,
827 target, data.data_size)) {
835 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
853 ec_ioctl_slave_sdo_download_t data;
857 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
861 if (!(sdo_data = kmalloc(data.data_size, GFP_KERNEL))) {
863 " for SDO download.\n", data.data_size);
867 if (copy_from_user(sdo_data, (
void __user *) data.data, data.data_size)) {
872 if (data.complete_access) {
874 data.sdo_index, sdo_data, data.data_size, &data.abort_code);
877 data.sdo_index, data.sdo_entry_subindex, sdo_data,
878 data.data_size, &data.abort_code);
883 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
901 ec_ioctl_slave_sii_t data;
905 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
913 master, 0, data.slave_position))) {
916 data.slave_position);
921 || data.offset + data.nwords > slave->
sii_nwords) {
923 EC_SLAVE_ERR(slave,
"Invalid SII read offset/size %u/%u for slave SII"
924 " size %zu!\n", data.offset, data.nwords, slave->
sii_nwords);
928 if (copy_to_user((
void __user *) data.words,
929 slave->
sii_words + data.offset, data.nwords * 2))
949 ec_ioctl_slave_sii_t data;
951 unsigned int byte_size;
955 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
963 byte_size =
sizeof(uint16_t) * data.
nwords;
964 if (!(words = kmalloc(byte_size, GFP_KERNEL))) {
966 " for SII contents.\n", byte_size);
970 if (copy_from_user(words,
971 (
void __user *) data.words, byte_size)) {
976 if (down_interruptible(&master->
master_sem)) {
982 master, 0, data.slave_position))) {
985 data.slave_position);
991 INIT_LIST_HEAD(&request.
list);
992 request.
slave = slave;
993 request.
words = words;
994 request.
offset = data.offset;
995 request.
nwords = data.nwords;
996 request.
state = EC_INT_REQUEST_QUEUED;
1005 request.
state != EC_INT_REQUEST_QUEUED)) {
1008 if (request.
state == EC_INT_REQUEST_QUEUED) {
1010 list_del(&request.
list);
1023 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1037 ec_ioctl_slave_reg_t io;
1042 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1058 if (down_interruptible(&master->
master_sem)) {
1064 master, 0, io.slave_position))) {
1079 request.
state != EC_INT_REQUEST_QUEUED)) {
1082 if (request.
state == EC_INT_REQUEST_QUEUED) {
1084 list_del(&request.
list);
1095 if (request.
state == EC_INT_REQUEST_SUCCESS) {
1096 if (copy_to_user((
void __user *) io.data, request.
data, io.size)) {
1102 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1116 ec_ioctl_slave_reg_t io;
1121 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1135 if (copy_from_user(request.
data, (
void __user *) io.data, io.size)) {
1142 if (down_interruptible(&master->
master_sem)) {
1169 request.
state != EC_INT_REQUEST_QUEUED)) {
1172 if (request.
state == EC_INT_REQUEST_QUEUED) {
1174 list_del(&request.
list);
1187 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1201 ec_ioctl_config_t data;
1205 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1213 master, data.config_index))) {
1220 data.alias = sc->
alias;
1227 data.syncs[i].pdo_count =
1237 data.dc_sync[i] = sc->
dc_sync[i];
1242 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1259 ec_ioctl_config_pdo_t data;
1263 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1277 master, data.config_index))) {
1292 data.index = pdo->
index;
1298 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1315 ec_ioctl_config_pdo_entry_t data;
1320 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1334 master, data.config_index))) {
1350 pdo, data.entry_pos))) {
1356 data.index = entry->
index;
1363 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1380 ec_ioctl_config_sdo_t *ioctl;
1384 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1388 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1393 if (down_interruptible(&master->
master_sem)) {
1399 master, ioctl->config_index))) {
1402 ioctl->config_index);
1408 sc, ioctl->sdo_pos))) {
1415 ioctl->index = req->
index;
1418 memcpy(ioctl->data, req->
data,
1419 min((u32) ioctl->size, (u32) EC_MAX_SDO_DATA_SIZE));
1424 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1444 ec_ioctl_config_idn_t *ioctl;
1448 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1452 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1457 if (down_interruptible(&master->
master_sem)) {
1463 master, ioctl->config_index))) {
1466 ioctl->config_index);
1472 sc, ioctl->idn_pos))) {
1480 ioctl->idn = req->
idn;
1481 ioctl->state = req->
state;
1483 memcpy(ioctl->data, req->
data,
1484 min((u32) ioctl->size, (u32) EC_MAX_IDN_DATA_SIZE));
1488 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1510 ec_ioctl_eoe_handler_t data;
1513 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1530 data.slave_position = 0xffff;
1534 data.rx_bytes = eoe->
stats.tx_bytes;
1536 data.tx_bytes = eoe->
stats.rx_bytes;
1543 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1560 ec_ioctl_context_t *ctx
1585 ec_ioctl_context_t *ctx
1590 if (unlikely(!ctx->requested))
1595 return PTR_ERR(domain);
1597 return domain->
index;
1609 ec_ioctl_context_t *ctx
1612 ec_ioctl_config_t data;
1615 if (unlikely(!ctx->requested))
1618 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1623 data.vendor_id, data.product_code);
1627 data.config_index = 0;
1632 list_for_each_entry(entry, &master->
configs, list) {
1635 data.config_index++;
1640 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1655 ec_ioctl_context_t *ctx
1658 unsigned long config_index = (
unsigned long) arg;
1662 if (unlikely(!ctx->requested)) {
1667 if (down_interruptible(&master->
master_sem)) {
1672 if (config_index != 0xFFFFFFFF) {
1696 ec_ioctl_context_t *ctx
1699 ec_ioctl_master_activate_t io;
1704 if (unlikely(!ctx->requested))
1707 io.process_data = NULL;
1711 ctx->process_data_size = 0;
1716 list_for_each_entry(domain, &master->
domains, list) {
1722 if (ctx->process_data_size) {
1723 ctx->process_data = vmalloc(ctx->process_data_size);
1724 if (!ctx->process_data) {
1725 ctx->process_data_size = 0;
1733 list_for_each_entry(domain, &master->
domains, list) {
1735 ctx->process_data + offset);
1739 #ifdef EC_IOCTL_RTDM
1746 " memory to user space (code %i).\n", ret);
1752 io.process_data_size = ctx->process_data_size;
1754 #ifndef EC_IOCTL_RTDM
1763 if (copy_to_user((
void __user *) arg, &io,
1764 sizeof(ec_ioctl_master_activate_t)))
1779 ec_ioctl_context_t *ctx
1782 if (unlikely(!ctx->requested))
1798 ec_ioctl_context_t *ctx
1801 size_t send_interval;
1803 if (unlikely(!ctx->requested)) {
1807 if (copy_from_user(&send_interval, (
void __user *) arg,
1808 sizeof(send_interval))) {
1830 ec_ioctl_context_t *ctx
1833 if (unlikely(!ctx->requested)) {
1850 ec_ioctl_context_t *ctx
1853 if (unlikely(!ctx->requested)) {
1870 ec_ioctl_context_t *ctx
1877 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1892 ec_ioctl_context_t *ctx
1895 ec_ioctl_link_state_t ioctl;
1899 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
1908 if (copy_to_user((
void __user *) ioctl.state, &state,
sizeof(state))) {
1924 ec_ioctl_context_t *ctx
1927 ec_ioctl_app_time_t data;
1929 if (unlikely(!ctx->requested))
1932 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1949 ec_ioctl_context_t *ctx
1952 if (unlikely(!ctx->requested)) {
1969 ec_ioctl_context_t *ctx
1972 if (unlikely(!ctx->requested)) {
1989 ec_ioctl_context_t *ctx
1995 if (unlikely(!ctx->requested)) {
2004 if (copy_to_user((
void __user *) arg, &time,
sizeof(time))) {
2020 ec_ioctl_context_t *ctx
2023 if (unlikely(!ctx->requested)) {
2040 ec_ioctl_context_t *ctx
2045 if (unlikely(!ctx->requested))
2050 if (copy_to_user((
void __user *) arg, &time_diff,
sizeof(time_diff)))
2065 ec_ioctl_context_t *ctx
2083 ec_ioctl_context_t *ctx
2086 ec_ioctl_config_t data;
2091 if (unlikely(!ctx->requested)) {
2096 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2101 if (down_interruptible(&master->
master_sem)) {
2112 if (data.syncs[i].config_this) {
2114 data.syncs[i].watchdog_mode);
2136 ec_ioctl_context_t *ctx
2139 ec_ioctl_config_t data;
2143 if (unlikely(!ctx->requested)) {
2148 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2153 if (down_interruptible(&master->
master_sem)) {
2181 ec_ioctl_context_t *ctx
2184 ec_ioctl_config_pdo_t data;
2187 if (unlikely(!ctx->requested))
2190 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2215 ec_ioctl_context_t *ctx
2218 ec_ioctl_config_pdo_t data;
2221 if (unlikely(!ctx->requested))
2224 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2250 ec_ioctl_context_t *ctx
2253 ec_ioctl_add_pdo_entry_t data;
2256 if (unlikely(!ctx->requested))
2259 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2273 data.entry_index, data.entry_subindex, data.entry_bit_length);
2285 ec_ioctl_context_t *ctx
2288 ec_ioctl_config_pdo_t data;
2291 if (unlikely(!ctx->requested))
2294 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2320 ec_ioctl_context_t *ctx
2323 ec_ioctl_reg_pdo_entry_t data;
2328 if (unlikely(!ctx->requested))
2331 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2350 data.entry_subindex, domain, &data.bit_position);
2352 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2367 ec_ioctl_context_t *ctx
2370 ec_ioctl_reg_pdo_pos_t io;
2375 if (unlikely(!ctx->requested)) {
2379 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2383 if (down_interruptible(&master->
master_sem)) {
2400 io.pdo_pos, io.entry_pos, domain, &io.bit_position);
2402 if (copy_to_user((
void __user *) arg, &io,
sizeof(io)))
2417 ec_ioctl_context_t *ctx
2420 ec_ioctl_config_t data;
2423 if (unlikely(!ctx->requested))
2426 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2438 data.dc_sync[0].cycle_time,
2439 data.dc_sync[0].shift_time,
2440 data.dc_sync[1].cycle_time,
2441 data.dc_sync[1].shift_time);
2457 ec_ioctl_context_t *ctx
2460 ec_ioctl_sc_sdo_t data;
2462 uint8_t *sdo_data = NULL;
2465 if (unlikely(!ctx->requested))
2468 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2474 if (!(sdo_data = kmalloc(data.size, GFP_KERNEL))) {
2478 if (copy_from_user(sdo_data, (
void __user *) data.data, data.size)) {
2483 if (down_interruptible(&master->
master_sem)) {
2496 if (data.complete_access) {
2498 data.index, sdo_data, data.size);
2516 ec_ioctl_context_t *ctx
2519 ec_ioctl_sc_emerg_t io;
2523 if (unlikely(!ctx->requested))
2526 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io)))
2529 if (down_interruptible(&master->
master_sem)) {
2554 ec_ioctl_context_t *ctx
2557 ec_ioctl_sc_emerg_t io;
2562 if (unlikely(!ctx->requested)) {
2566 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2582 if (copy_to_user((
void __user *) io.target, msg,
sizeof(msg))) {
2598 ec_ioctl_context_t *ctx
2601 ec_ioctl_sc_emerg_t io;
2604 if (unlikely(!ctx->requested)) {
2608 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2631 ec_ioctl_context_t *ctx
2634 ec_ioctl_sc_emerg_t io;
2638 if (unlikely(!ctx->requested)) {
2642 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2660 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
2676 ec_ioctl_context_t *ctx
2679 ec_ioctl_sdo_request_t data;
2683 if (unlikely(!ctx->requested))
2686 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2690 data.request_index = 0;
2702 data.request_index++;
2708 data.sdo_subindex, data.size);
2710 return PTR_ERR(req);
2712 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2727 ec_ioctl_context_t *ctx
2730 ec_ioctl_reg_request_t io;
2734 if (unlikely(!ctx->requested)) {
2738 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2742 io.request_index = 0;
2744 if (down_interruptible(&master->
master_sem)) {
2762 return PTR_ERR(reg);
2765 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
2781 ec_ioctl_context_t *ctx
2784 ec_ioctl_voe_t data;
2788 if (unlikely(!ctx->requested))
2791 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2814 return PTR_ERR(voe);
2816 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2831 ec_ioctl_context_t *ctx
2834 ec_ioctl_sc_state_t data;
2838 if (unlikely(!ctx->requested))
2841 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2854 if (copy_to_user((
void __user *) data.state, &state,
sizeof(state)))
2869 ec_ioctl_context_t *ctx
2872 ec_ioctl_sc_idn_t ioctl;
2874 uint8_t *data = NULL;
2877 if (unlikely(!ctx->requested))
2880 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl)))
2886 if (!(data = kmalloc(ioctl.size, GFP_KERNEL))) {
2890 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.size)) {
2895 if (down_interruptible(&master->
master_sem)) {
2909 sc, ioctl.drive_no, ioctl.idn, ioctl.al_state, data, ioctl.size);
2923 ec_ioctl_context_t *ctx
2928 if (unlikely(!ctx->requested)) {
2932 if (down_interruptible(&master->
master_sem)) {
2936 list_for_each_entry(domain, &master->
domains, list) {
2937 if (domain->
index == (
unsigned long) arg) {
2957 ec_ioctl_context_t *ctx
2963 if (unlikely(!ctx->requested))
2966 if (down_interruptible(&master->
master_sem)) {
2970 list_for_each_entry(domain, &master->
domains, list) {
2971 if (domain->
index == (
unsigned long) arg) {
2991 ec_ioctl_context_t *ctx
2996 if (unlikely(!ctx->requested))
3019 ec_ioctl_context_t *ctx
3024 if (unlikely(!ctx->requested))
3047 ec_ioctl_context_t *ctx
3050 ec_ioctl_domain_state_t data;
3054 if (unlikely(!ctx->requested))
3057 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3070 if (copy_to_user((
void __user *) data.state, &state,
sizeof(state)))
3085 ec_ioctl_context_t *ctx
3088 ec_ioctl_sdo_request_t data;
3092 if (unlikely(!ctx->requested))
3095 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3122 ec_ioctl_context_t *ctx
3125 ec_ioctl_sdo_request_t data;
3129 if (unlikely(!ctx->requested))
3132 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3159 ec_ioctl_context_t *ctx
3162 ec_ioctl_sdo_request_t data;
3166 if (unlikely(!ctx->requested))
3169 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3189 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3204 ec_ioctl_context_t *ctx
3207 ec_ioctl_sdo_request_t data;
3211 if (unlikely(!ctx->requested))
3214 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3241 ec_ioctl_context_t *ctx
3244 ec_ioctl_sdo_request_t data;
3249 if (unlikely(!ctx->requested))
3252 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3256 EC_MASTER_ERR(master,
"SDO download: Data size may not be zero!\n");
3275 if (copy_from_user(req->
data, (
void __user *) data.data, data.size))
3292 ec_ioctl_context_t *ctx
3295 ec_ioctl_sdo_request_t data;
3299 if (unlikely(!ctx->requested))
3302 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3332 ec_ioctl_context_t *ctx
3335 ec_ioctl_reg_request_t io;
3339 if (unlikely(!ctx->requested)) {
3343 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3347 if (io.mem_size <= 0) {
3363 min(reg->
mem_size, io.mem_size))) {
3379 ec_ioctl_context_t *ctx
3382 ec_ioctl_reg_request_t io;
3386 if (unlikely(!ctx->requested)) {
3390 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3408 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3424 ec_ioctl_context_t *ctx
3427 ec_ioctl_reg_request_t io;
3431 if (unlikely(!ctx->requested)) {
3435 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3450 if (io.transfer_size > reg->
mem_size) {
3454 if (copy_from_user(reg->
data, (
void __user *) io.data,
3455 io.transfer_size)) {
3472 ec_ioctl_context_t *ctx
3475 ec_ioctl_reg_request_t io;
3479 if (unlikely(!ctx->requested)) {
3483 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3498 if (io.transfer_size > reg->
mem_size) {
3515 ec_ioctl_context_t *ctx
3518 ec_ioctl_voe_t data;
3522 uint16_t vendor_type;
3524 if (unlikely(!ctx->requested))
3527 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3530 if (get_user(vendor_id, data.vendor_id))
3533 if (get_user(vendor_type, data.vendor_type))
3560 ec_ioctl_context_t *ctx
3563 ec_ioctl_voe_t data;
3567 uint16_t vendor_type;
3569 if (unlikely(!ctx->requested))
3572 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3588 if (likely(data.vendor_id))
3589 if (put_user(vendor_id, data.vendor_id))
3592 if (likely(data.vendor_type))
3593 if (put_user(vendor_type, data.vendor_type))
3608 ec_ioctl_context_t *ctx
3611 ec_ioctl_voe_t data;
3615 if (unlikely(!ctx->requested))
3618 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3645 ec_ioctl_context_t *ctx
3648 ec_ioctl_voe_t data;
3652 if (unlikely(!ctx->requested))
3655 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3682 ec_ioctl_context_t *ctx
3685 ec_ioctl_voe_t data;
3689 if (unlikely(!ctx->requested))
3692 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3711 (
void __user *) data.data, data.size))
3728 ec_ioctl_context_t *ctx
3731 ec_ioctl_voe_t data;
3735 if (unlikely(!ctx->requested))
3738 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3758 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3773 ec_ioctl_context_t *ctx
3776 ec_ioctl_voe_t data;
3780 if (unlikely(!ctx->requested))
3783 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3815 ec_ioctl_slave_foe_t io;
3820 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3833 if (down_interruptible(&master->
master_sem)) {
3846 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE read request.\n");
3855 request.
state != EC_INT_REQUEST_QUEUED)) {
3858 if (request.
state == EC_INT_REQUEST_QUEUED) {
3859 list_del(&request.
list);
3871 io.result = request.
result;
3874 if (request.
state != EC_INT_REQUEST_SUCCESS) {
3878 if (request.
data_size > io.buffer_size) {
3884 if (copy_to_user((
void __user *) io.buffer,
3885 request.
buffer, io.data_size)) {
3892 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3911 ec_ioctl_slave_foe_t io;
3916 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3928 if (copy_from_user(request.
buffer,
3929 (
void __user *) io.buffer, io.buffer_size)) {
3937 if (down_interruptible(&master->
master_sem)) {
3950 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE write request.\n");
3959 request.
state != EC_INT_REQUEST_QUEUED)) {
3962 if (request.
state == EC_INT_REQUEST_QUEUED) {
3964 list_del(&request.
list);
3975 io.result = request.
result;
3978 ret = request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
3980 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3999 ec_ioctl_slave_soe_read_t ioctl;
4003 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
4007 data = kmalloc(ioctl.mem_size, GFP_KERNEL);
4009 EC_MASTER_ERR(master,
"Failed to allocate %zu bytes of IDN data.\n",
4015 ioctl.drive_no, ioctl.idn, data, ioctl.mem_size, &ioctl.data_size,
4022 if (copy_to_user((
void __user *) ioctl.data,
4023 data, ioctl.data_size)) {
4029 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
4048 ec_ioctl_slave_soe_write_t ioctl;
4052 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
4056 data = kmalloc(ioctl.data_size, GFP_KERNEL);
4058 EC_MASTER_ERR(master,
"Failed to allocate %zu bytes of IDN data.\n",
4062 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.data_size)) {
4068 ioctl.drive_no, ioctl.idn, data, ioctl.data_size,
4075 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
4087 #ifdef EC_IOCTL_RTDM
4088 #define EC_IOCTL ec_ioctl_rtdm
4090 #define EC_IOCTL ec_ioctl
4099 ec_ioctl_context_t *ctx,
4105 cycles_t a = get_cycles(), b;
4111 case EC_IOCTL_MODULE:
4114 case EC_IOCTL_MASTER:
4117 case EC_IOCTL_SLAVE:
4120 case EC_IOCTL_SLAVE_SYNC:
4123 case EC_IOCTL_SLAVE_SYNC_PDO:
4126 case EC_IOCTL_SLAVE_SYNC_PDO_ENTRY:
4129 case EC_IOCTL_DOMAIN:
4132 case EC_IOCTL_DOMAIN_FMMU:
4135 case EC_IOCTL_DOMAIN_DATA:
4138 case EC_IOCTL_MASTER_DEBUG:
4139 if (!ctx->writable) {
4145 case EC_IOCTL_MASTER_RESCAN:
4146 if (!ctx->writable) {
4152 case EC_IOCTL_SLAVE_STATE:
4153 if (!ctx->writable) {
4159 case EC_IOCTL_SLAVE_SDO:
4162 case EC_IOCTL_SLAVE_SDO_ENTRY:
4165 case EC_IOCTL_SLAVE_SDO_UPLOAD:
4168 case EC_IOCTL_SLAVE_SDO_DOWNLOAD:
4169 if (!ctx->writable) {
4175 case EC_IOCTL_SLAVE_SII_READ:
4178 case EC_IOCTL_SLAVE_SII_WRITE:
4179 if (!ctx->writable) {
4185 case EC_IOCTL_SLAVE_REG_READ:
4188 case EC_IOCTL_SLAVE_REG_WRITE:
4189 if (!ctx->writable) {
4195 case EC_IOCTL_SLAVE_FOE_READ:
4198 case EC_IOCTL_SLAVE_FOE_WRITE:
4199 if (!ctx->writable) {
4205 case EC_IOCTL_SLAVE_SOE_READ:
4208 case EC_IOCTL_SLAVE_SOE_WRITE:
4209 if (!ctx->writable) {
4215 case EC_IOCTL_CONFIG:
4218 case EC_IOCTL_CONFIG_PDO:
4221 case EC_IOCTL_CONFIG_PDO_ENTRY:
4224 case EC_IOCTL_CONFIG_SDO:
4227 case EC_IOCTL_CONFIG_IDN:
4231 case EC_IOCTL_EOE_HANDLER:
4235 case EC_IOCTL_REQUEST:
4236 if (!ctx->writable) {
4242 case EC_IOCTL_CREATE_DOMAIN:
4243 if (!ctx->writable) {
4249 case EC_IOCTL_CREATE_SLAVE_CONFIG:
4250 if (!ctx->writable) {
4256 case EC_IOCTL_SELECT_REF_CLOCK:
4257 if (!ctx->writable) {
4263 case EC_IOCTL_ACTIVATE:
4264 if (!ctx->writable) {
4270 case EC_IOCTL_DEACTIVATE:
4271 if (!ctx->writable) {
4278 if (!ctx->writable) {
4284 case EC_IOCTL_RECEIVE:
4285 if (!ctx->writable) {
4291 case EC_IOCTL_MASTER_STATE:
4294 case EC_IOCTL_MASTER_LINK_STATE:
4297 case EC_IOCTL_APP_TIME:
4298 if (!ctx->writable) {
4304 case EC_IOCTL_SYNC_REF:
4305 if (!ctx->writable) {
4311 case EC_IOCTL_SYNC_SLAVES:
4312 if (!ctx->writable) {
4318 case EC_IOCTL_REF_CLOCK_TIME:
4319 if (!ctx->writable) {
4325 case EC_IOCTL_SYNC_MON_QUEUE:
4326 if (!ctx->writable) {
4332 case EC_IOCTL_SYNC_MON_PROCESS:
4333 if (!ctx->writable) {
4339 case EC_IOCTL_RESET:
4340 if (!ctx->writable) {
4346 case EC_IOCTL_SC_SYNC:
4347 if (!ctx->writable) {
4353 case EC_IOCTL_SC_WATCHDOG:
4354 if (!ctx->writable) {
4360 case EC_IOCTL_SC_ADD_PDO:
4361 if (!ctx->writable) {
4367 case EC_IOCTL_SC_CLEAR_PDOS:
4368 if (!ctx->writable) {
4374 case EC_IOCTL_SC_ADD_ENTRY:
4375 if (!ctx->writable) {
4381 case EC_IOCTL_SC_CLEAR_ENTRIES:
4382 if (!ctx->writable) {
4388 case EC_IOCTL_SC_REG_PDO_ENTRY:
4389 if (!ctx->writable) {
4395 case EC_IOCTL_SC_REG_PDO_POS:
4396 if (!ctx->writable) {
4402 case EC_IOCTL_SC_DC:
4403 if (!ctx->writable) {
4409 case EC_IOCTL_SC_SDO:
4410 if (!ctx->writable) {
4416 case EC_IOCTL_SC_EMERG_SIZE:
4417 if (!ctx->writable) {
4423 case EC_IOCTL_SC_EMERG_POP:
4424 if (!ctx->writable) {
4430 case EC_IOCTL_SC_EMERG_CLEAR:
4431 if (!ctx->writable) {
4437 case EC_IOCTL_SC_EMERG_OVERRUNS:
4440 case EC_IOCTL_SC_SDO_REQUEST:
4441 if (!ctx->writable) {
4447 case EC_IOCTL_SC_REG_REQUEST:
4448 if (!ctx->writable) {
4454 case EC_IOCTL_SC_VOE:
4455 if (!ctx->writable) {
4461 case EC_IOCTL_SC_STATE:
4464 case EC_IOCTL_SC_IDN:
4465 if (!ctx->writable) {
4471 case EC_IOCTL_DOMAIN_SIZE:
4474 case EC_IOCTL_DOMAIN_OFFSET:
4477 case EC_IOCTL_DOMAIN_PROCESS:
4478 if (!ctx->writable) {
4484 case EC_IOCTL_DOMAIN_QUEUE:
4485 if (!ctx->writable) {
4491 case EC_IOCTL_DOMAIN_STATE:
4494 case EC_IOCTL_SDO_REQUEST_INDEX:
4495 if (!ctx->writable) {
4501 case EC_IOCTL_SDO_REQUEST_TIMEOUT:
4502 if (!ctx->writable) {
4508 case EC_IOCTL_SDO_REQUEST_STATE:
4511 case EC_IOCTL_SDO_REQUEST_READ:
4512 if (!ctx->writable) {
4518 case EC_IOCTL_SDO_REQUEST_WRITE:
4519 if (!ctx->writable) {
4525 case EC_IOCTL_SDO_REQUEST_DATA:
4528 case EC_IOCTL_REG_REQUEST_DATA:
4531 case EC_IOCTL_REG_REQUEST_STATE:
4534 case EC_IOCTL_REG_REQUEST_WRITE:
4535 if (!ctx->writable) {
4541 case EC_IOCTL_REG_REQUEST_READ:
4542 if (!ctx->writable) {
4548 case EC_IOCTL_VOE_SEND_HEADER:
4549 if (!ctx->writable) {
4555 case EC_IOCTL_VOE_REC_HEADER:
4558 case EC_IOCTL_VOE_READ:
4559 if (!ctx->writable) {
4565 case EC_IOCTL_VOE_READ_NOSYNC:
4566 if (!ctx->writable) {
4572 case EC_IOCTL_VOE_WRITE:
4573 if (!ctx->writable) {
4579 case EC_IOCTL_VOE_EXEC:
4580 if (!ctx->writable) {
4586 case EC_IOCTL_VOE_DATA:
4589 case EC_IOCTL_SET_SEND_INTERVAL:
4590 if (!ctx->writable) {
4603 t = (
unsigned int) ((b - a) * 1000LL) / cpu_khz;
size_t ecrt_domain_size(const ec_domain_t *domain)
Returns the current size of the domain's process data.
ec_sii_general_flags_t general_flags
General flags.
void ecrt_reg_request_write(ec_reg_request_t *reg, uint16_t address, size_t size)
Schedule an register write operation.
uint16_t ring_position
Ring position for emergency requests.
const ec_slave_config_t * sc
EtherCAT slave config.
static ATTRIBUTES int ec_ioctl_domain(ec_master_t *master, void *arg)
Get domain information.
ec_internal_request_state_t state
Request state.
static ATTRIBUTES int ec_ioctl_sdo_request_timeout(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an SDO request's timeout.
uint16_t offset
SII word offset.
uint16_t ring_position
Ring position.
uint32_t revision_number
Revision number.
const ec_sdo_entry_t * ec_sdo_get_entry_const(const ec_sdo_t *sdo, uint8_t subindex)
Get an SDO entry from an SDO via its subindex.
static ATTRIBUTES int ec_ioctl_sc_emerg_clear(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Clear the emergency ring.
uint16_t ec_slave_sdo_count(const ec_slave_t *slave)
Get the number of SDOs in the dictionary.
uint16_t boot_rx_mailbox_offset
Bootstrap receive mailbox address.
int ecrt_slave_config_emerg_size(ec_slave_config_t *sc, size_t elements)
Set the size of the CoE emergency ring buffer.
#define EC_DATAGRAM_NAME_SIZE
Size of the datagram description string.
ec_sii_t sii
Extracted SII data.
uint32_t ecrt_master_sync_monitor_process(ec_master_t *master)
Processes the DC synchrony monitoring datagram.
ec_reg_request_t * ec_slave_config_find_reg_request(ec_slave_config_t *sc, unsigned int pos)
Finds a register handler via its position in the list.
void ecrt_voe_handler_received_header(const ec_voe_handler_t *voe, uint32_t *vendor_id, uint16_t *vendor_type)
Reads the header data of a received VoE message.
static ATTRIBUTES int ec_ioctl_slave_state(ec_master_t *master, void *arg)
Set slave state.
void ecrt_reg_request_read(ec_reg_request_t *reg, uint16_t address, size_t size)
Schedule a register read operation.
uint8_t * data
Pointer to SDO data.
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe)
Returns the current data size.
static ATTRIBUTES int ec_ioctl_sdo_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SDO write operation.
static ATTRIBUTES int ec_ioctl_config_sdo(ec_master_t *master, void *arg)
Get slave configuration SDO information.
static ATTRIBUTES int ec_ioctl_master_link_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the link state.
u64 tx_count
Number of frames sent.
static ATTRIBUTES int ec_ioctl_slave_reg_read(ec_master_t *master, void *arg)
Read a slave's registers.
struct list_head sii_requests
SII write requests.
void ecrt_master_sync_slave_clocks(ec_master_t *master)
Queues the DC clock drift compensation datagram for sending.
static ATTRIBUTES int ec_ioctl_domain_offset(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets the domain's offset in the total process data.
static ATTRIBUTES int ec_ioctl_create_slave_config(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a slave configuration.
const ec_soe_request_t * ec_slave_config_get_idn_by_pos_const(const ec_slave_config_t *sc, unsigned int pos)
Finds an IDN configuration via its position in the list.
int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, const uint8_t *data, size_t size)
Add an SDO configuration.
ec_sdo_request_t * ecrt_slave_config_create_sdo_request_err(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, size_t size)
Same as ecrt_slave_config_create_sdo_request(), but with ERR_PTR() return value.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
Convenience macro for printing slave-specific debug messages to syslog.
static ATTRIBUTES int ec_ioctl_reg_request_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an register read operation.
static ATTRIBUTES int ec_ioctl_slave_sdo_upload(ec_master_t *master, void *arg)
Upload SDO.
size_t data_size
Size of the process data.
ec_slave_t * slave
pointer to the corresponding slave
static ATTRIBUTES int ec_ioctl_voe_send_header(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets the VoE send header.
s32 tx_byte_rates[EC_RATE_COUNT]
Transmit rates in byte/s for different statistics cycle periods.
ec_internal_request_state_t state
State of the request.
ec_slave_config_t * ec_master_get_config(const ec_master_t *master, unsigned int pos)
Get a slave configuration via its position in the list.
int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc, uint8_t sync_index, uint16_t pdo_index)
Add a PDO to a sync manager's PDO assignment.
size_t ec_voe_handler_mem_size(const ec_voe_handler_t *voe)
Get usable memory size.
int ecrt_master_link_state(const ec_master_t *master, unsigned int dev_idx, ec_master_link_state_t *state)
Reads the current state of a redundant link.
ec_slave_port_t ports[EC_MAX_PORTS]
Ports.
void ecrt_master_application_time(ec_master_t *master, uint64_t app_time)
Sets the application time.
unsigned int tx_queue_size
Transmit queue size.
ec_slave_state_t current_state
Current application state.
#define ec_master_num_devices(MASTER)
Number of Ethernet devices.
static ATTRIBUTES int ec_ioctl_domain_process(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Process the domain.
#define EC_RATE_COUNT
Number of statistic rate intervals to maintain.
static ATTRIBUTES int ec_ioctl_module(void *arg)
Get module information.
size_t nwords
Number of words.
ec_internal_request_state_t state
SDO request state.
uint16_t address
Register address.
int ecrt_master_sdo_download_complete(ec_master_t *master, uint16_t slave_position, uint16_t index, uint8_t *data, size_t data_size, uint32_t *abort_code)
Executes an SDO download request to write data to a slave via complete access.
uint16_t bit_length
Data size in bit.
size_t mem_size
Size of data memory.
void ec_foe_request_write(ec_foe_request_t *req)
Prepares a write request (master to slave).
static ATTRIBUTES int ec_ioctl_reg_request_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets an register request's state.
static ATTRIBUTES int ec_ioctl_reg_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an register write operation.
uint32_t product_code
Slave product code.
static ATTRIBUTES int ec_ioctl_ref_clock_time(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the system time of the reference clock.
ec_slave_port_link_t link
Port link status.
void ec_master_internal_receive_cb(void *cb_data)
Internal receiving callback.
uint16_t position
Index after alias.
const ec_slave_t * ec_master_find_slave_const(const ec_master_t *master, uint16_t alias, uint16_t position)
Finds a slave in the bus, given the alias and position.
unsigned int rescan_required
A bus rescan is required.
void ecrt_master_callbacks(ec_master_t *master, void(*send_cb)(void *), void(*receive_cb)(void *), void *cb_data)
Sets the locking callbacks.
const ec_sdo_request_t * ec_slave_config_get_sdo_by_pos_const(const ec_slave_config_t *sc, unsigned int pos)
Finds an SDO configuration via its position in the list.
uint32_t serial_number
Serial number.
int ec_foe_request_alloc(ec_foe_request_t *req, size_t size)
Pre-allocates the data memory.
s32 tx_frame_rates[EC_RATE_COUNT]
Transmit rates in frames/s for different statistics cycle periods.
ec_sii_coe_details_t coe_details
CoE detail flags.
char * order
Order number.
int ec_reg_request_init(ec_reg_request_t *reg, size_t size)
Register request constructor.
const ec_domain_t * ec_master_find_domain_const(const ec_master_t *master, unsigned int index)
Get a domain via its position in the list.
const ec_eoe_t * ec_master_get_eoe_handler_const(const ec_master_t *master, uint16_t index)
Get an EoE handler via its position in the list.
static ATTRIBUTES int ec_ioctl_sync_slaves(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the slave clocks.
unsigned int data_size
Covered PDO size.
struct list_head emerg_reg_requests
Emergency register access requests.
ec_internal_request_state_t state
Request state.
uint16_t alias
Slave alias.
static ATTRIBUTES int ec_ioctl_sc_create_reg_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a register request.
struct list_head domains
List of domains.
static ATTRIBUTES int ec_ioctl_slave_soe_read(ec_master_t *master, void *arg)
Read an SoE IDN.
int ecrt_slave_config_reg_pdo_entry_pos(ec_slave_config_t *sc, uint8_t sync_index, unsigned int pdo_pos, unsigned int entry_pos, ec_domain_t *domain, unsigned int *bit_position)
Registers a PDO entry using its position.
struct list_head reg_requests
Register access requests.
static ATTRIBUTES int ec_ioctl_slave_sdo_entry(ec_master_t *master, void *arg)
Get slave SDO entry information.
uint8_t drive_no
Drive number.
uint8_t * data
Pointer to SDO data.
static ATTRIBUTES int ec_ioctl_config_pdo(ec_master_t *master, void *arg)
Get slave configuration PDO information.
int16_t current_on_ebus
Power consumption in mA.
void ecrt_voe_handler_read(ec_voe_handler_t *voe)
Start a VoE read operation.
ec_slave_t * ec_master_find_slave(ec_master_t *master, uint16_t alias, uint16_t position)
Finds a slave in the bus, given the alias and position.
static ATTRIBUTES int ec_ioctl_sc_add_entry(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Add an entry to a PDO's mapping.
uint8_t link_state
device link state
unsigned int ec_pdo_list_count(const ec_pdo_list_t *pl)
Get the number of PDOs in the list.
ec_master_t * ecrt_request_master_err(unsigned int)
Request a master.
uint16_t boot_tx_mailbox_size
Bootstrap transmit mailbox size.
uint8_t signal_detected
Detected signal on RX port.
#define EC_IOCTL
ioctl() function to use.
const uint8_t * macs[EC_MAX_NUM_DEVICES]
Device MAC addresses.
uint32_t result
FoE request abort code.
void ecrt_master_state(const ec_master_t *master, ec_master_state_t *state)
Reads the current master state.
u64 rx_count
Number of frames received.
void ecrt_voe_handler_read_nosync(ec_voe_handler_t *voe)
Start a VoE read operation without querying the sync manager status.
wait_queue_head_t request_queue
Wait queue for external requests from user space.
int ecrt_slave_config_emerg_clear(ec_slave_config_t *sc)
Clears CoE emergency ring buffer and the overrun counter.
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
Provide external memory to store the domain's process data.
void ecrt_sdo_request_timeout(ec_sdo_request_t *req, uint32_t timeout)
Set the timeout for an SDO request.
static ATTRIBUTES int ec_ioctl_config_pdo_entry(ec_master_t *master, void *arg)
Get slave configuration PDO entry information.
unsigned int sync_count
Number of sync managers.
struct list_head list
List head.
ec_domain_t * ecrt_master_create_domain_err(ec_master_t *master)
Same as ecrt_master_create_domain(), but with ERR_PTR() return value.
uint32_t tx_rate
transmit rate (bps)
uint16_t std_rx_mailbox_size
Standard receive mailbox size.
static ATTRIBUTES int ec_ioctl_slave_foe_read(ec_master_t *master, void *arg)
Read a file from a slave via FoE.
const ec_slave_config_t * ec_master_get_config_const(const ec_master_t *master, unsigned int pos)
Get a slave configuration via its position in the list.
void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate, uint32_t sync0_cycle_time, int32_t sync0_shift_time, uint32_t sync1_cycle_time, int32_t sync1_shift_time)
Configure distributed clocks.
uint16_t std_tx_mailbox_offset
Standard transmit mailbox address.
s32 rx_frame_rates[EC_RATE_COUNT]
Receive rates in frames/s for different statistics cycle periods.
uint8_t * ecrt_sdo_request_data(ec_sdo_request_t *req)
Access to the SDO request's data.
static ATTRIBUTES int ec_ioctl_master_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the master state.
ec_direction_t dir
Direction.
static ATTRIBUTES int ec_ioctl_sc_emerg_overruns(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the number of emergency overruns.
EtherCAT master structure.
uint8_t * data
Memory for the process data.
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT]
DC sync signals.
static ATTRIBUTES int ec_ioctl_slave_foe_write(ec_master_t *master, void *arg)
Write a file to a slave via FoE.
#define EC_MASTER_DBG(master, level, fmt, args...)
Convenience macro for printing master-specific debug messages to syslog.
static ATTRIBUTES int ec_ioctl_master_rescan(ec_master_t *master, void *arg)
Issue a bus scan.
uint16_t boot_tx_mailbox_offset
Bootstrap transmit mailbox address.
const ec_pdo_entry_t * ec_pdo_find_entry_by_pos_const(const ec_pdo_t *pdo, unsigned int pos)
Finds a PDO entry via its position in the list.
static ATTRIBUTES int ec_ioctl_sc_create_sdo_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create an SDO request.
ec_slave_t * slave
EtherCAT slave.
uint16_t index
PDO entry index.
struct semaphore master_sem
Master semaphore.
uint8_t loop_closed
Loop closed.
static ATTRIBUTES int ec_ioctl_sdo_request_index(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an SDO request's SDO index and subindex.
unsigned int ec_pdo_entry_count(const ec_pdo_t *pdo)
Get the number of PDO entries.
uint32_t logical_start_address
Logical start address.
void ec_foe_request_clear(ec_foe_request_t *req)
FoE request destructor.
void ecrt_sdo_request_read(ec_sdo_request_t *req)
Schedule an SDO read operation.
size_t buffer_size
Size of FoE data memory.
static ATTRIBUTES int ec_ioctl_sdo_request_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SDO read operation.
static ATTRIBUTES int ec_ioctl_domain_fmmu(ec_master_t *master, void *arg)
Get domain FMMU information.
ec_voe_handler_t * ecrt_slave_config_create_voe_handler_err(ec_slave_config_t *sc, size_t size)
Same as ecrt_slave_config_create_voe_handler(), but with ERR_PTR() return value.
static ATTRIBUTES int ec_ioctl_sdo_request_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets an SDO request's state.
int ecrt_slave_config_complete_sdo(ec_slave_config_t *sc, uint16_t index, const uint8_t *data, size_t size)
Add configuration data for a complete SDO.
char * description
Description.
int ec_master_debug_level(ec_master_t *master, unsigned int level)
Set the debug level.
#define ATTRIBUTES
Optional compiler attributes fo ioctl() functions.
Slave configuration state.
void(* state)(ec_voe_handler_t *)
State function.
s32 tx_frame_rates[EC_RATE_COUNT]
Transmit rates in frames/s for different statistics cycle periods.
s32 rx_byte_rates[EC_RATE_COUNT]
Receive rates in byte/s for different statistics cycle periods.
Ethernet over EtherCAT (EoE)
ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]
Sync manager configurations.
ec_device_stats_t device_stats
Device statistics.
static ATTRIBUTES int ec_ioctl_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Request the master from userspace.
struct list_head reg_requests
List of register requests.
static ATTRIBUTES int ec_ioctl_app_time(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Set the master DC application time.
ec_master_phase_t phase
Master phase.
static ATTRIBUTES int ec_ioctl_sc_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the slave configuration's state.
static ATTRIBUTES int ec_ioctl_domain_data(ec_master_t *master, void *arg)
Get domain data.
uint8_t * buffer
Pointer to FoE data.
uint8_t sync_index
Index of sync manager to use.
static ATTRIBUTES int ec_ioctl_sc_watchdog(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configure a slave's watchdogs.
struct semaphore device_sem
Device semaphore.
static ATTRIBUTES int ec_ioctl_sc_add_pdo(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Add a PDO to the assignment.
s32 rx_byte_rates[EC_RATE_COUNT]
Receive rates in byte/s for different statistics cycle periods.
struct list_head sdo_requests
List of SDO requests.
int ecrt_master_sdo_download(ec_master_t *master, uint16_t slave_position, uint16_t index, uint8_t subindex, uint8_t *data, size_t data_size, uint32_t *abort_code)
Executes an SDO download request to write data to a slave.
uint16_t * sii_words
Complete SII image.
uint16_t mailbox_protocols
Supported mailbox protocols.
ec_domain_t * ec_master_find_domain(ec_master_t *master, unsigned int index)
Get a domain via its position in the list.
size_t data_size
Size of SDO data.
static ATTRIBUTES int ec_ioctl_sc_dc(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets the DC AssignActivate word and the sync signal times.
ec_reg_request_t * ecrt_slave_config_create_reg_request_err(ec_slave_config_t *sc, size_t size)
Same as ecrt_slave_config_create_reg_request(), but with ERR_PTR() return value.
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
unsigned int ec_master_domain_count(const ec_master_t *master)
Get the number of domains.
ec_slave_dc_range_t base_dc_range
DC range.
uint8_t bit_length
entry length in bit
static ATTRIBUTES int ec_ioctl_master_debug(ec_master_t *master, void *arg)
Set master debug level.
uint16_t std_rx_mailbox_offset
Standard receive mailbox address.
uint8_t base_fmmu_bit_operation
FMMU bit operation is supported.
s32 loss_rates[EC_RATE_COUNT]
Frame loss rates for different statistics cycle periods.
uint32_t transmission_delay
DC system time transmission delay (offset from reference clock).
int ecrt_master_select_reference_clock(ec_master_t *master, ec_slave_config_t *sc)
Selects the reference clock for distributed clocks.
unsigned int slave_count
Number of slaves on the bus.
unsigned int scan_busy
Current scan state.
ec_pdo_list_t pdos
Current PDO assignment.
struct list_head voe_handlers
List of VoE handlers.
uint16_t dc_assign_activate
Vendor-specific AssignActivate word.
s32 rx_frame_rates[EC_RATE_COUNT]
Receive rates in frames/s for different statistics cycle periods.
static ATTRIBUTES int ec_ioctl_slave_sii_read(ec_master_t *master, void *arg)
Read a slave's SII.
unsigned int index
Index (just a number).
s32 tx_byte_rates[EC_RATE_COUNT]
Transmit rates in byte/s for different statistics cycle periods.
static ATTRIBUTES int ec_ioctl_send(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Send frames.
static ATTRIBUTES int ec_ioctl_slave(ec_master_t *master, void *arg)
Get slave information.
uint16_t watchdog_intervals
Process data watchdog intervals (see spec.
ec_slave_port_desc_t desc
Port descriptors.
#define EC_MASTER_WARN(master, fmt, args...)
Convenience macro for printing master-specific warnings to syslog.
static ATTRIBUTES int ec_ioctl_config_idn(ec_master_t *master, void *arg)
Get slave configuration IDN information.
static ATTRIBUTES int ec_ioctl_config(ec_master_t *master, void *arg)
Get slave configuration information.
Vendor specific over EtherCAT handler.
unsigned int active
Master has been activated.
static ATTRIBUTES int ec_ioctl_set_send_interval(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Set max.
ec_master_t * master
Master owning the slave.
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe)
Execute the handler.
static ATTRIBUTES int ec_ioctl_voe_read_nosync(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts a VoE read operation without sending a sync message first.
unsigned int ec_slave_config_sdo_count(const ec_slave_config_t *sc)
Get the number of SDO configurations.
const ec_sdo_t * ec_slave_get_sdo_by_pos_const(const ec_slave_t *slave, uint16_t sdo_position)
Get an SDO from the dictionary, given its position in the list.
static ATTRIBUTES int ec_ioctl_master(ec_master_t *master, void *arg)
Get master information.
static ATTRIBUTES int ec_ioctl_reg_request_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Read register data.
u64 rx_bytes
Number of bytes received.
int ecrt_master_sdo_upload(ec_master_t *master, uint16_t slave_position, uint16_t index, uint8_t subindex, uint8_t *target, size_t target_size, size_t *result_size, uint32_t *abort_code)
Executes an SDO upload request to read data from a slave.
uint8_t has_dc_system_time
The slave supports the DC system time register.
void ec_foe_request_init(ec_foe_request_t *req, uint8_t *file_name)
FoE request constructor.
static ATTRIBUTES int ec_ioctl_sc_sync(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configure a sync manager.
u64 tx_count
Number of frames sent.
unsigned int ec_domain_fmmu_count(const ec_domain_t *domain)
Get the number of FMMU configurations of the domain.
static ATTRIBUTES int ec_ioctl_slave_sii_write(ec_master_t *master, void *arg)
Write a slave's SII.
static ATTRIBUTES int ec_ioctl_sync_mon_queue(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Queue the sync monitoring datagram.
#define EC_MASTER_ERR(master, fmt, args...)
Convenience macro for printing master-specific errors to syslog.
uint8_t subindex
PDO entry subindex.
uint8_t control_register
Control register value.
static ATTRIBUTES int ec_ioctl_sync_ref(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the reference clock.
Values read by the master.
ec_direction_t dir
Sync manager direction.
int ec_rtdm_mmap(ec_ioctl_context_t *ioctl_ctx, void **user_address)
Memory-map process data to user space.
uint16_t data_type
Data type.
ec_request_state_t ecrt_sdo_request_state(const ec_sdo_request_t *req)
Get the current state of the SDO request.
struct list_head configs
List of slave configurations.
ec_slave_t * slave
Slave pointer.
unsigned int opened
net_device is opened
static ATTRIBUTES int ec_ioctl_create_domain(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a domain.
static ATTRIBUTES int ec_ioctl_reset(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Reset configuration.
uint16_t watchdog_divider
Watchdog divider as a number of 40ns intervals (see spec.
ec_sdo_request_t * ec_slave_config_find_sdo_request(ec_slave_config_t *sc, unsigned int pos)
Finds a CoE handler via its position in the list.
int ecrt_slave_config_idn(ec_slave_config_t *sc, uint8_t drive_no, uint16_t idn, ec_al_state_t state, const uint8_t *data, size_t size)
Add an SoE IDN configuration.
void ecrt_master_reset(ec_master_t *master)
Retry configuring slaves.
static ATTRIBUTES int ec_ioctl_voe_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts a VoE write operation.
static ATTRIBUTES int ec_ioctl_domain_queue(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Queue the domain.
size_t data_size
Size of FoE data.
static ATTRIBUTES int ec_ioctl_voe_rec_header(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets the received VoE header.
void ecrt_master_sync_monitor_queue(ec_master_t *master)
Queues the DC synchrony monitoring datagram for sending.
void ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size)
Start a VoE write operation.
static ATTRIBUTES int ec_ioctl_receive(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Receive frames.
uint16_t working_counter[EC_MAX_NUM_DEVICES]
Last working counter values.
uint8_t * file_name
Pointer to the filename.
const ec_sdo_t * ec_slave_get_sdo_const(const ec_slave_t *slave, uint16_t index)
Get an SDO from the dictionary.
uint32_t logical_base_address
Logical offset address of the process data.
static ATTRIBUTES int ec_ioctl_sc_emerg_size(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Set the emergency ring buffer size.
uint8_t read_access[EC_SDO_ENTRY_ACCESS_COUNT]
Read access.
int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc, uint16_t pdo_index, uint16_t entry_index, uint8_t entry_subindex, uint8_t entry_bit_length)
Add a PDO entry to the given PDO's mapping.
ec_watchdog_mode_t watchdog_mode
Watchdog mode.
struct net_device_stats stats
device statistics
uint8_t subindex
SDO subindex.
uint16_t expected_working_counter
Expected working counter.
static ATTRIBUTES int ec_ioctl_slave_sync_pdo_entry(ec_master_t *master, void *arg)
Get slave sync manager PDO entry information.
unsigned int ec_slave_config_idn_count(const ec_slave_config_t *sc)
Get the number of IDN configurations.
u64 tx_errors
Number of transmit errors.
int ecrt_slave_config_reg_pdo_entry(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, ec_domain_t *domain, unsigned int *bit_position)
Registers a PDO entry for process data exchange in a domain.
uint16_t effective_alias
Effective alias address.
size_t data_size
Size of SDO data.
int ecrt_master_read_idn(ec_master_t *master, uint16_t slave_position, uint8_t drive_no, uint16_t idn, uint8_t *target, size_t target_size, size_t *result_size, uint16_t *error_code)
Executes an SoE read request.
static ATTRIBUTES int ec_ioctl_slave_sync(ec_master_t *master, void *arg)
Get slave sync manager information.
struct list_head foe_requests
FoE write requests.
ec_direction_t dir
Direction.
static ATTRIBUTES int ec_ioctl_voe_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts a VoE read operation.
u64 tx_bytes
Number of bytes sent.
int ecrt_master_activate(ec_master_t *master)
Finishes the configuration phase and prepares for cyclic operation.
static ATTRIBUTES int ec_ioctl_sc_create_voe_handler(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a VoE handler.
uint16_t ec_master_eoe_handler_count(const ec_master_t *master)
Get the number of EoE handlers.
size_t ecrt_sdo_request_data_size(const ec_sdo_request_t *req)
Returns the current SDO data size.
void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc, uint16_t pdo_index)
Clear the mapping of a given PDO.
uint8_t enable
Enable bit.
static ATTRIBUTES int ec_ioctl_sc_clear_pdos(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Clears the PDO assignment.
uint8_t * data
Pointer to data memory.
Vendor specific over EtherCAT protocol handler.
uint16_t boot_rx_mailbox_size
Bootstrap receive mailbox size.
#define EC_MAX_PORTS
Maximum number of slave ports.
ec_slave_t * next_slave
Connected slaves.
ec_direction_t dir
Direction.
static ATTRIBUTES int ec_ioctl_deactivate(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Deactivates the master.
uint32_t vendor_id
Slave vendor ID.
uint32_t receive_time
Port receive times for delay measurement.
uint8_t max_subindex
Maximum subindex.
static ATTRIBUTES int ec_ioctl_sc_sdo(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures an SDO.
void ec_master_internal_send_cb(void *cb_data)
Internal sending callback.
ec_pdo_list_t pdos
Current PDO assignment.
static ATTRIBUTES int ec_ioctl_sc_reg_pdo_entry(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Registers a PDO entry.
static ATTRIBUTES int ec_ioctl_activate(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Activates the master.
u64 app_time
Time of the last ecrt_master_sync() call.
void ec_slave_request_state(ec_slave_t *slave, ec_slave_state_t state)
Request a slave state and resets the error flag.
uint16_t physical_start_address
Physical start address.
static ATTRIBUTES int ec_ioctl_domain_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the domain state.
void ec_foe_request_read(ec_foe_request_t *req)
Prepares a read request (slave to master).
uint8_t base_dc_supported
Distributed clocks are supported.
u64 rx_count
Number of frames received.
void ecrt_slave_config_watchdog(ec_slave_config_t *sc, uint16_t divider, uint16_t intervals)
Configure a slave's watchdog times.
void ecrt_master_deactivate(ec_master_t *master)
Deactivates the master.
static ATTRIBUTES int ec_ioctl_slave_sdo(ec_master_t *master, void *arg)
Get slave SDO information.
size_t sii_nwords
Size of the SII contents in words.
unsigned int ec_master_count(void)
Get the number of masters.
void ec_reg_request_clear(ec_reg_request_t *reg)
Register request destructor.
int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index, ec_direction_t dir, ec_watchdog_mode_t watchdog_mode)
Configure a sync manager.
int ecrt_master_write_idn(ec_master_t *master, uint16_t slave_position, uint8_t drive_no, uint16_t idn, uint8_t *data, size_t data_size, uint16_t *error_code)
Executes an SoE write request.
EtherCAT slave configuration.
void ecrt_voe_handler_send_header(ec_voe_handler_t *voe, uint32_t vendor_id, uint16_t vendor_type)
Sets the VoE header for future send operations.
static ATTRIBUTES int ec_ioctl_sc_emerg_pop(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get an emergency message from the ring.
uint32_t error_code
Error code from an FoE Error Request.
static ATTRIBUTES int ec_ioctl_domain_size(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets the domain's data size.
struct net_device * dev
pointer to the assigned net_device
EtherCAT master character device IOCTL commands.
static void ec_ioctl_strcpy(char *target, const char *source)
Copies a string to an ioctl structure.
Request was processed successfully.
EtherCAT slave configuration structure.
uint16_t idn
Sercos ID-Number.
ec_internal_request_state_t state
FoE request state.
uint8_t write_access[EC_SDO_ENTRY_ACCESS_COUNT]
Write access.
ec_slave_config_t * ecrt_master_slave_config_err(ec_master_t *master, uint16_t alias, uint16_t position, uint32_t vendor_id, uint32_t product_code)
Same as ecrt_master_slave_config(), but with ERR_PTR() return value.
ec_device_index_t device_index
Index of device the slave responds on.
uint8_t * ecrt_reg_request_data(ec_reg_request_t *reg)
Access to the register request's data.
int ecrt_master_reference_clock_time(ec_master_t *master, uint32_t *time)
Get the lower 32 bit of the reference clock system time.
unsigned int ec_master_config_count(const ec_master_t *master)
Get the number of slave configurations provided by the application.
void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state)
Reads the state of a domain.
uint16_t default_length
Data length in bytes.
int ecrt_slave_config_emerg_pop(ec_slave_config_t *sc, uint8_t *target)
Read and remove one record from the CoE emergency ring buffer.
static ATTRIBUTES int ec_ioctl_voe_exec(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Executes the VoE state machine.
void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc, uint8_t sync_index)
Clear a sync manager's PDO assignment.
int ec_sdo_request_alloc(ec_sdo_request_t *req, size_t size)
Pre-allocates the data memory.
uint32_t product_code
Vendor-specific product code.
void ecrt_domain_process(ec_domain_t *domain)
Determines the states of the domain's datagrams.
ec_direction_t dir
FMMU direction.
void ecrt_slave_config_state(const ec_slave_config_t *sc, ec_slave_config_state_t *state)
Outputs the state of the slave configuration.
const ec_pdo_t * ec_pdo_list_find_pdo_by_pos_const(const ec_pdo_list_t *pl, unsigned int pos)
Finds a PDO via its position in the list.
Ethernet over EtherCAT (EoE) handler.
ec_fsm_master_t fsm
Master state machine.
u64 rx_bytes
Number of bytes received.
void ecrt_domain_queue(ec_domain_t *domain)
(Re-)queues all domain datagrams in the master's datagram queue.
#define EC_COE_EMERGENCY_MSG_SIZE
Size of a CoE emergency message in byte.
unsigned int error_flag
Stop processing after an error.
ec_sync_t * syncs
SYNC MANAGER categories.
uint16_t std_tx_mailbox_size
Standard transmit mailbox size.
struct list_head list
List item.
void ecrt_master_sync_reference_clock(ec_master_t *master)
Queues the DC reference clock drift compensation datagram for sending.
static ATTRIBUTES int ec_ioctl_sc_reg_pdo_pos(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Registers a PDO entry by its position.
uint8_t link_up
Link detected.
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
ec_device_t devices[EC_MAX_NUM_DEVICES]
EtherCAT devices.
static ATTRIBUTES int ec_ioctl_slave_soe_write(ec_master_t *master, void *arg)
Write an IDN to a slave via SoE.
u64 tx_bytes
Number of bytes sent.
static ATTRIBUTES int ec_ioctl_slave_sync_pdo(ec_master_t *master, void *arg)
Get slave sync manager PDO information.
static ATTRIBUTES int ec_ioctl_select_ref_clock(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Select the DC reference clock.
#define EC_SYNC_SIGNAL_COUNT
Number of DC sync signals.
uint8_t * ecrt_voe_handler_data(ec_voe_handler_t *voe)
Access to the VoE handler's data.
void ecrt_sdo_request_write(ec_sdo_request_t *req)
Schedule an SDO write operation.
static ATTRIBUTES int ec_ioctl_slave_reg_write(ec_master_t *master, void *arg)
Write a slave's registers.
int ecrt_slave_config_emerg_overruns(ec_slave_config_t *sc)
Read the number of CoE emergency overruns.
const uint16_t * words
Pointer to the data words.
static ATTRIBUTES int ec_ioctl_voe_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Reads the received VoE data.
void ec_master_set_send_interval(ec_master_t *master, unsigned int send_interval)
Sets the expected interval between calls to ecrt_master_send and calculates the maximum amount of dat...
ec_request_state_t ecrt_reg_request_state(const ec_reg_request_t *reg)
Get the current state of the register request.
static ATTRIBUTES int ec_ioctl_sdo_request_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Read SDO data.
struct net_device * dev
net_device for virtual ethernet device
static ATTRIBUTES int ec_ioctl_sync_mon_process(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Processes the sync monitoring datagram.
static ATTRIBUTES int ec_ioctl_eoe_handler(ec_master_t *master, void *arg)
Get EoE handler information.
uint32_t vendor_id
Vendor ID.
uint8_t complete_access
SDO shall be transferred completely.
uint32_t delay_to_next_dc
Delay to next slave with DC support behind this port [ns].
static ATTRIBUTES int ec_ioctl_slave_sdo_download(ec_master_t *master, void *arg)
Download SDO.
void ecrt_sdo_request_index(ec_sdo_request_t *req, uint16_t index, uint8_t subindex)
Set the SDO index and subindex.
ec_slave_t * dc_ref_clock
DC reference clock slave.
ec_voe_handler_t * ec_slave_config_find_voe_handler(ec_slave_config_t *sc, unsigned int pos)
Finds a VoE handler via its position in the list.
ec_master_t * master
EtherCAT master owning the domain.
static ATTRIBUTES int ec_ioctl_sc_idn(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures an IDN.
struct list_head list
List item.
unsigned int has_general
General category present.
unsigned int tx_queued_frames
number of frames in the queue
static ATTRIBUTES int ec_ioctl_sc_clear_entries(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Clears the mapping of a PDO.
void ecrt_master_receive(ec_master_t *master)
Fetches received frames from the hardware and processes the datagrams.
Sercos-over-EtherCAT request.
void ecrt_master_send(ec_master_t *master)
Sends all datagrams in the queue.
const ec_fmmu_config_t * ec_domain_find_fmmu(const ec_domain_t *domain, unsigned int pos)
Get a certain FMMU configuration via its position in the list.