28 #include <linux/module.h> 29 #include <linux/vmalloc.h> 41 #define DEBUG_LATENCY 0 46 #define ATTRIBUTES __attribute__ ((__noinline__)) 52 # include "rtdm_details.h" 55 # define ec_ioctl_lock(lock) do {} while(0) 56 # define ec_ioctl_unlock(lock) do {} while(0) 57 # define ec_ioctl_lock_interruptible(lock) (0) 58 # define ec_copy_to_user(to, from, n, ctx) \ 59 rtdm_safe_copy_to_user(ec_ioctl_to_rtdm(ctx), to, from, n) 60 # define ec_copy_from_user(to, from, n, ctx) \ 61 rtdm_safe_copy_from_user(ec_ioctl_to_rtdm(ctx), to, from, n) 63 # define ec_ioctl_lock(lock) rt_mutex_lock(lock) 64 # define ec_ioctl_unlock(lock) rt_mutex_unlock(lock) 65 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) || \ 66 (defined(CONFIG_PREEMPT_RT_FULL) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)) 67 # define ec_ioctl_lock_interruptible(lock) \ 68 rt_mutex_lock_interruptible(lock) 70 # define ec_ioctl_lock_interruptible(lock) \ 71 rt_mutex_lock_interruptible(lock, 0) 73 # define ec_copy_to_user(to, from, n, ctx) copy_to_user(to, from, n) 74 # define ec_copy_from_user(to, from, n, ctx) copy_from_user(to, from, n) 75 #endif // EC_IOCTL_RTDM 87 strncpy(target, source, EC_IOCTL_STRING_SIZE);
88 target[EC_IOCTL_STRING_SIZE - 1] = 0;
102 ec_ioctl_context_t *ctx
105 ec_ioctl_module_t data;
107 data.ioctl_version_magic = EC_IOCTL_VERSION_MAGIC;
110 if (ec_copy_to_user((
void __user *) arg, &data,
sizeof(data), ctx))
127 ec_ioctl_master_t io;
128 unsigned int dev_idx, j;
141 io.eoe_handler_count = 0;
158 memcpy(io.devices[dev_idx].address, device->
dev->dev_addr,
161 memcpy(io.devices[dev_idx].address,
master->
macs[dev_idx],
164 io.devices[dev_idx].attached = device->
dev ? 1 : 0;
165 io.devices[dev_idx].link_state = device->
link_state ? 1 : 0;
166 io.devices[dev_idx].tx_count = device->
tx_count;
167 io.devices[dev_idx].rx_count = device->
rx_count;
168 io.devices[dev_idx].tx_bytes = device->
tx_bytes;
169 io.devices[dev_idx].rx_bytes = device->
rx_bytes;
170 io.devices[dev_idx].tx_errors = device->
tx_errors;
172 io.devices[dev_idx].tx_frame_rates[j] =
174 io.devices[dev_idx].rx_frame_rates[j] =
176 io.devices[dev_idx].tx_byte_rates[j] =
178 io.devices[dev_idx].rx_byte_rates[j] =
189 io.tx_frame_rates[j] =
191 io.rx_frame_rates[j] =
193 io.tx_byte_rates[j] =
195 io.rx_byte_rates[j] =
208 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
226 ec_ioctl_slave_t data;
230 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
238 master, 0, data.position))) {
264 data.ports[i].desc = slave->
ports[i].
desc;
267 data.ports[i].link.signal_detected =
271 data.ports[i].next_slave =
274 data.ports[i].next_slave = 0xffff;
296 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
313 ec_ioctl_slave_sync_t data;
317 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
325 master, 0, data.slave_position))) {
328 data.slave_position);
334 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
339 sync = &slave->
sii.
syncs[data.sync_index];
344 data.enable = sync->
enable;
349 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
366 ec_ioctl_slave_sync_pdo_t data;
371 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
379 master, 0, data.slave_position))) {
382 data.slave_position);
388 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
393 sync = &slave->
sii.
syncs[data.sync_index];
395 &sync->
pdos, data.pdo_pos))) {
397 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with " 398 "position %u!\n", data.sync_index, data.pdo_pos);
402 data.index = pdo->
index;
408 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
425 ec_ioctl_slave_sync_pdo_entry_t data;
431 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
439 master, 0, data.slave_position))) {
442 data.slave_position);
448 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
453 sync = &slave->
sii.
syncs[data.sync_index];
455 &sync->
pdos, data.pdo_pos))) {
457 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with " 458 "position %u!\n", data.sync_index, data.pdo_pos);
463 pdo, data.entry_pos))) {
465 EC_SLAVE_ERR(slave,
"PDO 0x%04X does not contain an entry with " 466 "position %u!\n", data.pdo_pos, data.entry_pos);
470 data.index = entry->
index;
477 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
494 ec_ioctl_domain_t data;
496 unsigned int dev_idx;
498 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
522 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
539 ec_ioctl_domain_fmmu_t data;
543 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
560 " fmmu configurations.\n",
561 data.domain_index, data.fmmu_index + 1);
565 data.slave_config_alias = fmmu->
sc->
alias;
566 data.slave_config_position = fmmu->
sc->
position;
568 data.dir = fmmu->
dir;
574 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
591 ec_ioctl_domain_data_t data;
594 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
608 if (domain->
data_size != data.data_size) {
615 if (copy_to_user((
void __user *) data.target, domain->
data,
665 ec_ioctl_slave_state_t data;
668 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
676 master, 0, data.slave_position))) {
679 data.slave_position);
700 ec_ioctl_slave_sdo_t data;
704 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
712 master, 0, data.slave_position))) {
715 data.slave_position);
720 slave, data.sdo_position))) {
722 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", data.sdo_position);
726 data.sdo_index = sdo->
index;
732 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
749 ec_ioctl_slave_sdo_entry_t data;
754 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
762 master, 0, data.slave_position))) {
765 data.slave_position);
769 if (data.sdo_spec <= 0) {
771 slave, -data.sdo_spec))) {
773 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", -data.sdo_spec);
778 slave, data.sdo_spec))) {
787 sdo, data.sdo_entry_subindex))) {
789 EC_SLAVE_ERR(slave,
"SDO entry 0x%04X:%02X does not exist!\n",
790 sdo->
index, data.sdo_entry_subindex);
812 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
829 ec_ioctl_slave_sdo_upload_t data;
833 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
837 if (!(target = kmalloc(data.target_size, GFP_KERNEL))) {
839 " for SDO upload.\n", data.target_size);
844 data.sdo_index, data.sdo_entry_subindex, target,
845 data.target_size, &data.data_size, &data.abort_code);
848 if (copy_to_user((
void __user *) data.target,
849 target, data.data_size)) {
857 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
875 ec_ioctl_slave_sdo_download_t data;
879 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
883 if (!(sdo_data = kmalloc(data.data_size, GFP_KERNEL))) {
885 " for SDO download.\n", data.data_size);
889 if (copy_from_user(sdo_data, (
void __user *) data.data, data.data_size)) {
894 if (data.complete_access) {
896 data.sdo_index, sdo_data, data.data_size, &data.abort_code);
899 data.sdo_index, data.sdo_entry_subindex, sdo_data,
900 data.data_size, &data.abort_code);
905 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
923 ec_ioctl_slave_sii_t data;
927 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
935 master, 0, data.slave_position))) {
938 data.slave_position);
943 || data.offset + data.nwords > slave->
sii_nwords) {
945 EC_SLAVE_ERR(slave,
"Invalid SII read offset/size %u/%u for slave SII" 946 " size %zu!\n", data.offset, data.nwords, slave->
sii_nwords);
950 if (copy_to_user((
void __user *) data.words,
951 slave->
sii_words + data.offset, data.nwords * 2))
971 ec_ioctl_slave_sii_t data;
973 unsigned int byte_size;
977 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
985 byte_size =
sizeof(uint16_t) * data.
nwords;
986 if (!(words = kmalloc(byte_size, GFP_KERNEL))) {
988 " for SII contents.\n", byte_size);
992 if (copy_from_user(words,
993 (
void __user *) data.words, byte_size)) {
1004 master, 0, data.slave_position))) {
1007 data.slave_position);
1013 INIT_LIST_HEAD(&request.
list);
1014 request.
slave = slave;
1015 request.
words = words;
1016 request.
offset = data.offset;
1017 request.
nwords = data.nwords;
1018 request.
state = EC_INT_REQUEST_QUEUED;
1027 request.
state != EC_INT_REQUEST_QUEUED)) {
1030 if (request.
state == EC_INT_REQUEST_QUEUED) {
1032 list_del(&request.
list);
1045 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1059 ec_ioctl_slave_reg_t io;
1064 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1089 master, 0, io.slave_position))) {
1104 request.
state != EC_INT_REQUEST_QUEUED)) {
1107 if (request.
state == EC_INT_REQUEST_QUEUED) {
1109 list_del(&request.
list);
1120 if (request.
state == EC_INT_REQUEST_SUCCESS) {
1121 if (copy_to_user((
void __user *) io.data, request.
data, io.size)) {
1127 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1141 ec_ioctl_slave_reg_t io;
1146 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1160 if (copy_from_user(request.
data, (
void __user *) io.data, io.size)) {
1197 request.
state != EC_INT_REQUEST_QUEUED)) {
1200 if (request.
state == EC_INT_REQUEST_QUEUED) {
1202 list_del(&request.
list);
1215 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1229 ec_ioctl_config_t data;
1233 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1241 master, data.config_index))) {
1248 data.alias = sc->
alias;
1255 data.syncs[i].pdo_count =
1266 data.dc_sync[i] = sc->
dc_sync[i];
1271 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1288 ec_ioctl_config_pdo_t data;
1292 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1306 master, data.config_index))) {
1321 data.index = pdo->
index;
1327 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1344 ec_ioctl_config_pdo_entry_t data;
1349 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1363 master, data.config_index))) {
1379 pdo, data.entry_pos))) {
1385 data.index = entry->
index;
1392 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1409 ec_ioctl_config_sdo_t *ioctl;
1413 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1417 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1428 master, ioctl->config_index))) {
1431 ioctl->config_index);
1437 sc, ioctl->sdo_pos))) {
1444 ioctl->index = req->
index;
1447 memcpy(ioctl->data, req->
data,
1448 min((u32) ioctl->size, (u32) EC_MAX_SDO_DATA_SIZE));
1453 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1473 ec_ioctl_config_idn_t *ioctl;
1477 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1481 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1492 master, ioctl->config_index))) {
1495 ioctl->config_index);
1501 sc, ioctl->idn_pos))) {
1509 ioctl->idn = req->
idn;
1512 memcpy(ioctl->data, req->
data,
1513 min((u32) ioctl->size, (u32) EC_MAX_IDN_DATA_SIZE));
1517 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1537 ec_ioctl_config_flag_t *ioctl;
1542 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1546 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1557 master, ioctl->config_index))) {
1560 ioctl->config_index);
1566 sc, ioctl->flag_pos))) {
1573 size = min((u32) strlen(flag->
key), (u32) EC_MAX_FLAG_KEY_SIZE - 1);
1574 memcpy(ioctl->key, flag->
key, size);
1575 ioctl->key[size] = 0x00;
1576 ioctl->value = flag->
value;
1580 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1602 ec_ioctl_eoe_ip_t *ioctl;
1606 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1610 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1623 ioctl->config_index);
1630 ioctl->mac_address_included = req->mac_address_included;
1631 ioctl->ip_address_included = req->ip_address_included;
1632 ioctl->subnet_mask_included = req->subnet_mask_included;
1633 ioctl->gateway_included = req->gateway_included;
1634 ioctl->dns_included = req->dns_included;
1635 ioctl->name_included = req->name_included;
1637 memcpy(ioctl->mac_address, req->mac_address, EC_ETH_ALEN);
1638 ioctl->ip_address = req->ip_address;
1639 ioctl->subnet_mask = req->subnet_mask;
1640 ioctl->gateway = req->gateway;
1641 ioctl->dns = req->dns;
1646 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1670 ec_ioctl_eoe_handler_t data;
1673 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1690 data.slave_position = 0xffff;
1694 data.rx_bytes = eoe->
stats.tx_bytes;
1696 data.tx_bytes = eoe->
stats.rx_bytes;
1703 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1723 ec_ioctl_eoe_ip_t io;
1727 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1734 req.mac_address_included = io.mac_address_included;
1735 req.ip_address_included = io.ip_address_included;
1736 req.subnet_mask_included = io.subnet_mask_included;
1737 req.gateway_included = io.gateway_included;
1738 req.dns_included = io.dns_included;
1739 req.name_included = io.name_included;
1741 memcpy(req.mac_address, io.mac_address, EC_ETH_ALEN);
1742 req.ip_address = io.ip_address;
1743 req.subnet_mask = io.subnet_mask;
1744 req.gateway = io.gateway;
1748 req.
state = EC_INT_REQUEST_QUEUED;
1755 master, 0, io.slave_position))) {
1771 req.
state != EC_INT_REQUEST_QUEUED)) {
1774 if (req.
state == EC_INT_REQUEST_QUEUED) {
1776 list_del(&req.
list);
1786 io.result = req.result;
1788 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
1792 return req.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1805 ec_ioctl_context_t *ctx
1830 ec_ioctl_context_t *ctx
1835 if (unlikely(!ctx->requested))
1840 return PTR_ERR(domain);
1842 return domain->
index;
1854 ec_ioctl_context_t *ctx
1857 ec_ioctl_config_t data;
1860 if (unlikely(!ctx->requested))
1863 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1868 data.vendor_id, data.product_code);
1872 data.config_index = 0;
1880 data.config_index++;
1885 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1900 ec_ioctl_context_t *ctx
1903 unsigned long config_index = (
unsigned long) arg;
1907 if (unlikely(!ctx->requested)) {
1917 if (config_index != 0xFFFFFFFF) {
1941 ec_ioctl_context_t *ctx
1944 ec_ioctl_master_activate_t io;
1949 if (unlikely(!ctx->requested))
1952 io.process_data = NULL;
1956 ctx->process_data_size = 0;
1967 if (ctx->process_data_size) {
1968 ctx->process_data = vmalloc(ctx->process_data_size);
1969 if (!ctx->process_data) {
1970 ctx->process_data_size = 0;
1980 ctx->process_data + offset);
1984 #if defined(EC_IOCTL_RTDM) && !defined(EC_RTDM_XENOMAI_V3) 1991 " memory to user space (code %i).\n", ret);
1997 io.process_data_size = ctx->process_data_size;
1999 #ifndef EC_IOCTL_RTDM 2009 if (copy_to_user((
void __user *) arg, &io,
2010 sizeof(ec_ioctl_master_activate_t)))
2025 ec_ioctl_context_t *ctx
2028 if (unlikely(!ctx->requested))
2043 ec_ioctl_context_t *ctx
2046 size_t send_interval;
2048 if (unlikely(!ctx->requested)) {
2052 if (copy_from_user(&send_interval, (
void __user *) arg,
2053 sizeof(send_interval))) {
2075 ec_ioctl_context_t *ctx
2080 if (unlikely(!ctx->requested)) {
2101 ec_ioctl_context_t *ctx
2106 if (unlikely(!ctx->requested)) {
2127 ec_ioctl_context_t *ctx
2137 if (ec_copy_to_user((
void __user *) arg, &data,
sizeof(data), ctx))
2152 ec_ioctl_context_t *ctx
2155 ec_ioctl_link_state_t ioctl;
2159 if (ec_copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl), ctx)) {
2168 if (ec_copy_to_user((
void __user *) ioctl.state,
2169 &state,
sizeof(state), ctx)) {
2185 ec_ioctl_context_t *ctx
2190 if (unlikely(!ctx->requested))
2193 if (ec_copy_from_user(&time, (
void __user *) arg,
sizeof(time), ctx)) {
2209 ec_ioctl_context_t *ctx
2214 if (unlikely(!ctx->requested)) {
2235 ec_ioctl_context_t *ctx
2241 if (unlikely(!ctx->requested))
2244 if (ec_copy_from_user(&time, (
void __user *) arg,
sizeof(time), ctx)) {
2265 ec_ioctl_context_t *ctx
2270 if (unlikely(!ctx->requested)) {
2291 ec_ioctl_context_t *ctx
2297 if (unlikely(!ctx->requested)) {
2306 if (ec_copy_to_user((
void __user *) arg, &time,
sizeof(time), ctx)) {
2322 ec_ioctl_context_t *ctx
2327 if (unlikely(!ctx->requested)) {
2348 ec_ioctl_context_t *ctx
2353 if (unlikely(!ctx->requested))
2358 if (ec_copy_to_user((
void __user *) arg, &time_diff,
2359 sizeof(time_diff), ctx))
2374 ec_ioctl_context_t *ctx
2377 #ifdef EC_IOCTL_RTDM 2395 ec_ioctl_context_t *ctx
2398 ec_ioctl_config_t data;
2403 if (unlikely(!ctx->requested)) {
2408 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2424 if (data.syncs[i].config_this) {
2426 data.syncs[i].watchdog_mode);
2448 ec_ioctl_context_t *ctx
2451 ec_ioctl_config_t data;
2455 if (unlikely(!ctx->requested)) {
2460 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2493 ec_ioctl_context_t *ctx
2496 ec_ioctl_config_pdo_t data;
2499 if (unlikely(!ctx->requested))
2502 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2527 ec_ioctl_context_t *ctx
2530 ec_ioctl_config_pdo_t data;
2533 if (unlikely(!ctx->requested))
2536 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2561 ec_ioctl_context_t *ctx
2564 ec_ioctl_add_pdo_entry_t data;
2567 if (unlikely(!ctx->requested))
2570 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2584 data.entry_index, data.entry_subindex, data.entry_bit_length);
2596 ec_ioctl_context_t *ctx
2599 ec_ioctl_config_pdo_t data;
2602 if (unlikely(!ctx->requested))
2605 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2630 ec_ioctl_context_t *ctx
2633 ec_ioctl_reg_pdo_entry_t data;
2638 if (unlikely(!ctx->requested))
2641 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2660 data.entry_subindex, domain, &data.bit_position);
2662 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2677 ec_ioctl_context_t *ctx
2680 ec_ioctl_reg_pdo_pos_t io;
2685 if (unlikely(!ctx->requested)) {
2689 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2710 io.pdo_pos, io.entry_pos, domain, &io.bit_position);
2712 if (copy_to_user((
void __user *) arg, &io,
sizeof(io)))
2727 ec_ioctl_context_t *ctx
2730 ec_ioctl_config_t data;
2734 if (unlikely(!ctx->requested))
2737 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2749 data.dc_sync[0].cycle_time,
2750 data.dc_sync[0].shift_time,
2751 data.dc_sync[1].cycle_time,
2752 data.dc_sync[1].shift_time);
2768 ec_ioctl_context_t *ctx
2771 ec_ioctl_sc_sdo_t data;
2773 uint8_t *sdo_data = NULL;
2776 if (unlikely(!ctx->requested))
2779 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2785 if (!(sdo_data = kmalloc(data.size, GFP_KERNEL))) {
2789 if (copy_from_user(sdo_data, (
void __user *) data.data, data.size)) {
2807 if (data.complete_access) {
2809 data.index, sdo_data, data.size);
2827 ec_ioctl_context_t *ctx
2830 ec_ioctl_sc_emerg_t io;
2834 if (unlikely(!ctx->requested))
2837 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io)))
2865 ec_ioctl_context_t *ctx
2868 ec_ioctl_sc_emerg_t io;
2873 if (unlikely(!ctx->requested)) {
2877 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
2893 if (ec_copy_to_user((
void __user *) io.target, msg,
sizeof(msg), ctx)) {
2909 ec_ioctl_context_t *ctx
2912 ec_ioctl_sc_emerg_t io;
2915 if (unlikely(!ctx->requested)) {
2919 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
2942 ec_ioctl_context_t *ctx
2945 ec_ioctl_sc_emerg_t io;
2949 if (unlikely(!ctx->requested)) {
2953 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
2971 if (ec_copy_to_user((
void __user *) arg, &io,
sizeof(io), ctx)) {
2987 ec_ioctl_context_t *ctx
2990 ec_ioctl_sdo_request_t data;
2994 if (unlikely(!ctx->requested))
2997 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3001 data.request_index = 0;
3013 data.request_index++;
3019 data.sdo_subindex, data.size);
3021 return PTR_ERR(req);
3023 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3038 ec_ioctl_context_t *ctx
3041 ec_ioctl_soe_request_t data;
3045 if (unlikely(!ctx->requested))
3048 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3052 data.request_index = 0;
3064 data.request_index++;
3070 data.idn, data.size);
3072 return PTR_ERR(req);
3075 if (copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
3091 ec_ioctl_context_t *ctx
3094 ec_ioctl_reg_request_t io;
3098 if (unlikely(!ctx->requested)) {
3102 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3106 io.request_index = 0;
3126 return PTR_ERR(reg);
3129 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3145 ec_ioctl_context_t *ctx
3148 ec_ioctl_voe_t data;
3152 if (unlikely(!ctx->requested))
3155 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3178 return PTR_ERR(voe);
3180 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3195 ec_ioctl_context_t *ctx
3198 ec_ioctl_sc_state_t data;
3203 if (unlikely(!ctx->requested))
3206 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx)) {
3221 if (ec_copy_to_user((
void __user *) data.state,
3222 &state,
sizeof(state), ctx))
3237 ec_ioctl_context_t *ctx
3240 ec_ioctl_sc_idn_t ioctl;
3242 uint8_t *data = NULL;
3245 if (unlikely(!ctx->requested))
3248 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl)))
3254 if (!(data = kmalloc(ioctl.size, GFP_KERNEL))) {
3258 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.size)) {
3277 sc, ioctl.drive_no, ioctl.idn, ioctl.al_state, data, ioctl.size);
3291 ec_ioctl_context_t *ctx
3294 ec_ioctl_sc_flag_t ioctl;
3299 if (unlikely(!ctx->requested)) {
3303 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
3307 if (!ioctl.key_size) {
3311 if (!(key = kmalloc(ioctl.key_size + 1, GFP_KERNEL))) {
3315 if (copy_from_user(key, (
void __user *) ioctl.key, ioctl.key_size)) {
3319 key[ioctl.key_size] =
'\0';
3348 ec_ioctl_context_t *ctx
3351 ec_ioctl_sc_state_timeout_t ioctl;
3355 if (unlikely(!ctx->requested)) {
3359 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
3375 ioctl.to_state, ioctl.timeout_ms);
3390 ec_ioctl_context_t *ctx
3393 ec_ioctl_eoe_ip_t io;
3396 if (unlikely(!ctx->requested)) {
3400 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3416 if (io.mac_address_included) {
3419 if (io.ip_address_included) {
3422 if (io.subnet_mask_included) {
3425 if (io.gateway_included) {
3428 if (io.dns_included) {
3431 if (io.name_included) {
3449 ec_ioctl_context_t *ctx
3454 if (unlikely(!ctx->requested)) {
3463 if (domain->
index == (
unsigned long) arg) {
3483 ec_ioctl_context_t *ctx
3489 if (unlikely(!ctx->requested))
3497 if (domain->
index == (
unsigned long) arg) {
3517 ec_ioctl_context_t *ctx
3522 if (unlikely(!ctx->requested))
3544 ec_ioctl_context_t *ctx
3550 if (unlikely(!ctx->requested))
3577 ec_ioctl_context_t *ctx
3580 ec_ioctl_domain_state_t data;
3585 if (unlikely(!ctx->requested))
3588 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx)) {
3603 if (ec_copy_to_user((
void __user *) data.state, &state,
sizeof(state),
3619 ec_ioctl_context_t *ctx
3622 ec_ioctl_sdo_request_t data;
3626 if (unlikely(!ctx->requested))
3629 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3655 ec_ioctl_context_t *ctx
3658 ec_ioctl_sdo_request_t data;
3662 if (unlikely(!ctx->requested))
3665 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3693 ec_ioctl_context_t *ctx
3696 ec_ioctl_sdo_request_t data;
3700 if (unlikely(!ctx->requested))
3703 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3723 if (ec_copy_to_user((
void __user *) arg, &data,
sizeof(data), ctx))
3738 ec_ioctl_context_t *ctx
3741 ec_ioctl_sdo_request_t data;
3745 if (unlikely(!ctx->requested))
3748 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3774 ec_ioctl_context_t *ctx
3777 ec_ioctl_sdo_request_t data;
3781 if (unlikely(!ctx->requested))
3784 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3806 if (ec_copy_from_user(req->
data, (
void __user *) data.data,
3823 ec_ioctl_context_t *ctx
3826 ec_ioctl_sdo_request_t data;
3830 if (unlikely(!ctx->requested))
3833 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3863 ec_ioctl_context_t *ctx
3866 ec_ioctl_soe_request_t data;
3870 if (unlikely(!ctx->requested))
3873 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3899 ec_ioctl_context_t *ctx
3902 ec_ioctl_soe_request_t data;
3906 if (unlikely(!ctx->requested))
3909 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3935 ec_ioctl_context_t *ctx
3938 ec_ioctl_soe_request_t data;
3942 if (unlikely(!ctx->requested))
3945 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
3967 if (ec_copy_to_user((
void __user *) arg, &data,
sizeof(data), ctx))
3982 ec_ioctl_context_t *ctx
3985 ec_ioctl_soe_request_t data;
3989 if (unlikely(!ctx->requested))
3992 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4018 ec_ioctl_context_t *ctx
4021 ec_ioctl_soe_request_t data;
4025 if (unlikely(!ctx->requested))
4028 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4050 if (ec_copy_from_user(req->
data, (
void __user *) data.data,
4067 ec_ioctl_context_t *ctx
4070 ec_ioctl_soe_request_t data;
4074 if (unlikely(!ctx->requested))
4077 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4107 ec_ioctl_context_t *ctx
4110 ec_ioctl_reg_request_t io;
4114 if (unlikely(!ctx->requested)) {
4118 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
4122 if (io.mem_size <= 0) {
4138 min(reg->
mem_size, io.mem_size), ctx)) {
4154 ec_ioctl_context_t *ctx
4157 ec_ioctl_reg_request_t io;
4161 if (unlikely(!ctx->requested)) {
4165 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
4183 if (ec_copy_to_user((
void __user *) arg, &io,
sizeof(io), ctx)) {
4199 ec_ioctl_context_t *ctx
4202 ec_ioctl_reg_request_t io;
4206 if (unlikely(!ctx->requested)) {
4210 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
4225 if (io.transfer_size > reg->
mem_size) {
4229 if (ec_copy_from_user(reg->
data, (
void __user *) io.data,
4230 io.transfer_size, ctx)) {
4246 ec_ioctl_context_t *ctx
4249 ec_ioctl_reg_request_t io;
4253 if (unlikely(!ctx->requested)) {
4257 if (ec_copy_from_user(&io, (
void __user *) arg,
sizeof(io), ctx)) {
4272 if (io.transfer_size > reg->
mem_size) {
4288 ec_ioctl_context_t *ctx
4291 ec_ioctl_voe_t data;
4295 uint16_t vendor_type;
4297 if (unlikely(!ctx->requested))
4300 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4303 if (ec_copy_from_user(&vendor_id, data.vendor_id,
sizeof(vendor_id), ctx))
4306 if (ec_copy_from_user(&vendor_type, data.vendor_type,
4307 sizeof(vendor_type), ctx))
4333 ec_ioctl_context_t *ctx
4336 ec_ioctl_voe_t data;
4340 uint16_t vendor_type;
4343 if (unlikely(!ctx->requested))
4346 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4364 if (likely(data.vendor_id))
4365 if (ec_copy_to_user(data.vendor_id, &vendor_id,
4366 sizeof(vendor_id), ctx))
4369 if (likely(data.vendor_type))
4370 if (ec_copy_to_user(data.vendor_type, &vendor_type,
4371 sizeof(vendor_type), ctx))
4386 ec_ioctl_context_t *ctx
4389 ec_ioctl_voe_t data;
4393 if (unlikely(!ctx->requested))
4396 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4422 ec_ioctl_context_t *ctx
4425 ec_ioctl_voe_t data;
4429 if (unlikely(!ctx->requested))
4432 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4458 ec_ioctl_context_t *ctx
4461 ec_ioctl_voe_t data;
4465 if (unlikely(!ctx->requested))
4468 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4487 (
void __user *) data.data, data.size, ctx))
4503 ec_ioctl_context_t *ctx
4506 ec_ioctl_voe_t data;
4510 if (unlikely(!ctx->requested))
4513 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4537 if (ec_copy_to_user((
void __user *) arg, &data,
sizeof(data), ctx))
4552 ec_ioctl_context_t *ctx
4555 ec_ioctl_voe_t data;
4559 if (unlikely(!ctx->requested))
4562 if (ec_copy_from_user(&data, (
void __user *) arg,
sizeof(data), ctx))
4594 ec_ioctl_slave_foe_t io;
4599 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4625 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE read request.\n");
4634 request.
state != EC_INT_REQUEST_QUEUED)) {
4637 if (request.
state == EC_INT_REQUEST_QUEUED) {
4638 list_del(&request.
list);
4650 io.result = request.
result;
4653 if (request.
state != EC_INT_REQUEST_SUCCESS) {
4657 if (request.
data_size > io.buffer_size) {
4658 EC_SLAVE_ERR(slave,
"%s(): Buffer too small.\n", __func__);
4663 if (copy_to_user((
void __user *) io.buffer,
4664 request.
buffer, io.data_size)) {
4671 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
4690 ec_ioctl_slave_foe_t io;
4695 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4707 if (copy_from_user(request.
buffer,
4708 (
void __user *) io.buffer, io.buffer_size)) {
4729 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE write request.\n");
4738 request.
state != EC_INT_REQUEST_QUEUED)) {
4741 if (request.
state == EC_INT_REQUEST_QUEUED) {
4743 list_del(&request.
list);
4754 io.result = request.
result;
4757 ret = request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
4759 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
4778 ec_ioctl_slave_soe_read_t ioctl;
4782 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
4786 data = kmalloc(ioctl.mem_size, GFP_KERNEL);
4794 ioctl.drive_no, ioctl.idn, data, ioctl.mem_size, &ioctl.data_size,
4801 if (copy_to_user((
void __user *) ioctl.data,
4802 data, ioctl.data_size)) {
4808 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
4827 ec_ioctl_slave_soe_write_t ioctl;
4831 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
4835 data = kmalloc(ioctl.data_size, GFP_KERNEL);
4841 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.data_size)) {
4847 ioctl.drive_no, ioctl.idn, data, ioctl.data_size,
4854 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
4871 #ifndef EC_IOCTL_RTDM 4874 ec_ioctl_context_t *ctx,
4888 ec_ioctl_context_t *ctx,
4896 case EC_IOCTL_MODULE:
4899 case EC_IOCTL_MASTER_RESCAN:
4900 if (!ctx->writable) {
4906 case EC_IOCTL_MASTER_STATE:
4909 case EC_IOCTL_MASTER_LINK_STATE:
4912 case EC_IOCTL_SDO_REQUEST_TIMEOUT:
4913 if (!ctx->writable) {
4919 case EC_IOCTL_SDO_REQUEST_DATA:
4922 case EC_IOCTL_SOE_REQUEST_TIMEOUT:
4923 if (!ctx->writable) {
4929 case EC_IOCTL_SOE_REQUEST_DATA:
4932 case EC_IOCTL_REG_REQUEST_DATA:
4935 case EC_IOCTL_VOE_SEND_HEADER:
4936 if (!ctx->writable) {
4942 case EC_IOCTL_VOE_DATA:
4946 #ifdef EC_IOCTL_RTDM 4965 #ifdef EC_IOCTL_RTDM 4966 long ec_ioctl_rtdm_rt
4972 ec_ioctl_context_t *ctx,
4978 cycles_t a = get_cycles(), b;
4985 if (!ctx->writable) {
4991 case EC_IOCTL_RECEIVE:
4992 if (!ctx->writable) {
4998 case EC_IOCTL_APP_TIME:
4999 if (!ctx->writable) {
5005 case EC_IOCTL_SYNC_REF:
5006 if (!ctx->writable) {
5012 case EC_IOCTL_SYNC_REF_TO:
5013 if (!ctx->writable) {
5019 case EC_IOCTL_SYNC_SLAVES:
5020 if (!ctx->writable) {
5026 case EC_IOCTL_REF_CLOCK_TIME:
5027 if (!ctx->writable) {
5033 case EC_IOCTL_SYNC_MON_QUEUE:
5034 if (!ctx->writable) {
5040 case EC_IOCTL_SYNC_MON_PROCESS:
5041 if (!ctx->writable) {
5047 case EC_IOCTL_RESET:
5048 if (!ctx->writable) {
5054 case EC_IOCTL_SC_EMERG_POP:
5055 if (!ctx->writable) {
5061 case EC_IOCTL_SC_EMERG_CLEAR:
5062 if (!ctx->writable) {
5068 case EC_IOCTL_SC_EMERG_OVERRUNS:
5071 case EC_IOCTL_SC_STATE:
5074 case EC_IOCTL_DOMAIN_PROCESS:
5075 if (!ctx->writable) {
5081 case EC_IOCTL_DOMAIN_QUEUE:
5082 if (!ctx->writable) {
5088 case EC_IOCTL_DOMAIN_STATE:
5091 case EC_IOCTL_SDO_REQUEST_INDEX:
5092 if (!ctx->writable) {
5098 case EC_IOCTL_SDO_REQUEST_STATE:
5101 case EC_IOCTL_SDO_REQUEST_READ:
5102 if (!ctx->writable) {
5108 case EC_IOCTL_SDO_REQUEST_WRITE:
5109 if (!ctx->writable) {
5115 case EC_IOCTL_SOE_REQUEST_IDN:
5116 if (!ctx->writable) {
5122 case EC_IOCTL_SOE_REQUEST_STATE:
5125 case EC_IOCTL_SOE_REQUEST_READ:
5126 if (!ctx->writable) {
5132 case EC_IOCTL_SOE_REQUEST_WRITE:
5133 if (!ctx->writable) {
5139 case EC_IOCTL_REG_REQUEST_STATE:
5142 case EC_IOCTL_REG_REQUEST_WRITE:
5143 if (!ctx->writable) {
5149 case EC_IOCTL_REG_REQUEST_READ:
5150 if (!ctx->writable) {
5156 case EC_IOCTL_VOE_REC_HEADER:
5159 case EC_IOCTL_VOE_READ:
5160 if (!ctx->writable) {
5166 case EC_IOCTL_VOE_READ_NOSYNC:
5167 if (!ctx->writable) {
5173 case EC_IOCTL_VOE_WRITE:
5174 if (!ctx->writable) {
5180 case EC_IOCTL_VOE_EXEC:
5181 if (!ctx->writable) {
5194 t = (
unsigned int) ((b - a) * 1000LL) / cpu_khz;
5211 #ifdef EC_IOCTL_RTDM 5212 long ec_ioctl_rtdm_nrt
5218 ec_ioctl_context_t *ctx,
5223 #if DEBUG_LATENCY && !defined(EC_IOCTL_RTDM) 5224 cycles_t a = get_cycles(), b;
5230 case EC_IOCTL_MASTER:
5233 case EC_IOCTL_SLAVE:
5236 case EC_IOCTL_SLAVE_SYNC:
5239 case EC_IOCTL_SLAVE_SYNC_PDO:
5242 case EC_IOCTL_SLAVE_SYNC_PDO_ENTRY:
5245 case EC_IOCTL_DOMAIN:
5248 case EC_IOCTL_DOMAIN_FMMU:
5251 case EC_IOCTL_DOMAIN_DATA:
5254 case EC_IOCTL_MASTER_DEBUG:
5255 if (!ctx->writable) {
5261 case EC_IOCTL_SLAVE_STATE:
5262 if (!ctx->writable) {
5268 case EC_IOCTL_SLAVE_SDO:
5271 case EC_IOCTL_SLAVE_SDO_ENTRY:
5274 case EC_IOCTL_SLAVE_SDO_UPLOAD:
5275 if (!ctx->writable) {
5281 case EC_IOCTL_SLAVE_SDO_DOWNLOAD:
5282 if (!ctx->writable) {
5288 case EC_IOCTL_SLAVE_SII_READ:
5291 case EC_IOCTL_SLAVE_SII_WRITE:
5292 if (!ctx->writable) {
5298 case EC_IOCTL_SLAVE_REG_READ:
5299 if (!ctx->writable) {
5305 case EC_IOCTL_SLAVE_REG_WRITE:
5306 if (!ctx->writable) {
5312 case EC_IOCTL_SLAVE_FOE_READ:
5313 if (!ctx->writable) {
5319 case EC_IOCTL_SLAVE_FOE_WRITE:
5320 if (!ctx->writable) {
5326 case EC_IOCTL_SLAVE_SOE_READ:
5327 if (!ctx->writable) {
5333 case EC_IOCTL_SLAVE_SOE_WRITE:
5334 if (!ctx->writable) {
5341 case EC_IOCTL_SLAVE_EOE_IP_PARAM:
5342 if (!ctx->writable) {
5349 case EC_IOCTL_CONFIG:
5352 case EC_IOCTL_CONFIG_PDO:
5355 case EC_IOCTL_CONFIG_PDO_ENTRY:
5358 case EC_IOCTL_CONFIG_SDO:
5361 case EC_IOCTL_CONFIG_IDN:
5364 case EC_IOCTL_CONFIG_FLAG:
5368 case EC_IOCTL_CONFIG_EOE_IP_PARAM:
5371 case EC_IOCTL_EOE_HANDLER:
5378 case EC_IOCTL_REQUEST:
5379 if (!ctx->writable) {
5385 case EC_IOCTL_CREATE_DOMAIN:
5386 if (!ctx->writable) {
5392 case EC_IOCTL_CREATE_SLAVE_CONFIG:
5393 if (!ctx->writable) {
5399 case EC_IOCTL_SELECT_REF_CLOCK:
5400 if (!ctx->writable) {
5406 case EC_IOCTL_ACTIVATE:
5407 if (!ctx->writable) {
5413 case EC_IOCTL_DEACTIVATE:
5414 if (!ctx->writable) {
5420 case EC_IOCTL_SC_SYNC:
5421 if (!ctx->writable) {
5427 case EC_IOCTL_SC_WATCHDOG:
5428 if (!ctx->writable) {
5434 case EC_IOCTL_SC_ADD_PDO:
5435 if (!ctx->writable) {
5441 case EC_IOCTL_SC_CLEAR_PDOS:
5442 if (!ctx->writable) {
5448 case EC_IOCTL_SC_ADD_ENTRY:
5449 if (!ctx->writable) {
5455 case EC_IOCTL_SC_CLEAR_ENTRIES:
5456 if (!ctx->writable) {
5462 case EC_IOCTL_SC_REG_PDO_ENTRY:
5463 if (!ctx->writable) {
5469 case EC_IOCTL_SC_REG_PDO_POS:
5470 if (!ctx->writable) {
5476 case EC_IOCTL_SC_DC:
5477 if (!ctx->writable) {
5483 case EC_IOCTL_SC_SDO:
5484 if (!ctx->writable) {
5490 case EC_IOCTL_SC_EMERG_SIZE:
5491 if (!ctx->writable) {
5497 case EC_IOCTL_SC_SDO_REQUEST:
5498 if (!ctx->writable) {
5504 case EC_IOCTL_SC_SOE_REQUEST:
5505 if (!ctx->writable) {
5511 case EC_IOCTL_SC_REG_REQUEST:
5512 if (!ctx->writable) {
5518 case EC_IOCTL_SC_VOE:
5519 if (!ctx->writable) {
5525 case EC_IOCTL_SC_IDN:
5526 if (!ctx->writable) {
5532 case EC_IOCTL_SC_FLAG:
5533 if (!ctx->writable) {
5539 case EC_IOCTL_SC_STATE_TIMEOUT:
5540 if (!ctx->writable) {
5547 case EC_IOCTL_SC_EOE_IP_PARAM:
5548 if (!ctx->writable) {
5555 case EC_IOCTL_DOMAIN_SIZE:
5558 case EC_IOCTL_DOMAIN_OFFSET:
5561 case EC_IOCTL_SET_SEND_INTERVAL:
5562 if (!ctx->writable) {
5569 #ifdef EC_IOCTL_RTDM 5577 #if DEBUG_LATENCY && !defined(EC_IOCTL_RTDM) 5579 t = (
unsigned int) ((b - a) * 1000LL) / cpu_khz;
ec_sii_general_flags_t general_flags
General flags.
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.
unsigned int ec_slave_config_flag_count(const ec_slave_config_t *sc)
Get the number of feature flags.
uint16_t offset
SII word offset.
ec_request_state_t ecrt_sdo_request_state(const ec_sdo_request_t *req)
Get the current state of the SDO request.
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.
int ecrt_master_deactivate(ec_master_t *master)
Deactivates the master.
uint16_t boot_rx_mailbox_offset
Bootstrap receive mailbox address.
#define EC_DATAGRAM_NAME_SIZE
Size of the datagram description string.
ec_sii_t sii
Extracted SII data.
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.
static ATTRIBUTES int ec_ioctl_slave_state(ec_master_t *master, void *arg)
Set slave state.
static ATTRIBUTES int ec_ioctl_sdo_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SDO write operation.
int ecrt_sdo_request_write(ec_sdo_request_t *req)
Schedule an SDO write operation.
int ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc, uint8_t sync_index)
Clear a sync manager's PDO assignment.
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.
int ecrt_voe_handler_read(ec_voe_handler_t *voe)
Start a VoE read 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.
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.
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.
int ecrt_master_send(ec_master_t *master)
Sends all datagrams in the queue.
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.
int ecrt_sdo_request_timeout(ec_sdo_request_t *req, uint32_t timeout)
Set the timeout for an SDO request.
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.
static long ec_ioctl_nrt(ec_master_t *master, ec_ioctl_context_t *ctx, unsigned int cmd, void *arg)
ioctl() function to use.
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.
size_t ec_voe_handler_mem_size(const ec_voe_handler_t *voe)
Get usable memory size.
int ecrt_soe_request_timeout(ec_soe_request_t *req, uint32_t timeout)
Set the timeout for an SoE request.
ec_slave_port_t ports[EC_MAX_PORTS]
Ports.
unsigned int tx_queue_size
Transmit queue size.
const ec_flag_t * ec_slave_config_get_flag_by_pos_const(const ec_slave_config_t *sc, unsigned int pos)
Finds a flag via its position in the list.
ec_soe_request_t * ec_slave_config_find_soe_request(ec_slave_config_t *sc, unsigned int pos)
Finds a SoE request via its position in the list.
int ecrt_slave_config_watchdog(ec_slave_config_t *sc, uint16_t divider, uint16_t intervals)
Configure a slave's watchdog times.
uint8_t * ecrt_sdo_request_data(const ec_sdo_request_t *req)
Access to the SDO request's data.
ec_slave_state_t current_state
Current application state.
int ecrt_master_sdo_download_complete(ec_master_t *master, uint16_t slave_position, uint16_t index, const 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.
#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.
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.
#define EC_RATE_COUNT
Number of statistic rate intervals to maintain.
size_t nwords
Number of words.
ec_internal_request_state_t state
SDO request state.
uint16_t address
Register address.
uint16_t bit_length
Data size in bit.
ec_direction_t dir
Direction.
static ATTRIBUTES int ec_ioctl_slave_eoe_ip_param(ec_master_t *master, void *arg)
Request EoE IP parameter setting.
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.
int ecrt_master_sync_reference_clock(ec_master_t *master)
Queues the DC reference clock drift compensation datagram for sending.
void ec_master_internal_receive_cb(void *cb_data)
Internal receiving callback.
uint16_t position
Index after alias.
size_t mem_size
Size of SDO data memory.
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.
int ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state)
Reads the state of a domain.
int ecrt_sdo_request_read(ec_sdo_request_t *req)
Schedule an SDO read operation.
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.
int ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size)
Start a VoE write operation.
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.
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.
unsigned int scan_index
Index of slave currently scanned.
static ATTRIBUTES int ec_ioctl_sync_slaves(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the slave clocks.
u64 dc_ref_time
Common reference timestamp for DC start times.
static ATTRIBUTES int ec_ioctl_sc_state_timeout(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an AL state transition timeout.
unsigned int data_size
Covered PDO size.
struct list_head emerg_reg_requests
Emergency register access requests.
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.
ec_eoe_request_t eoe_ip_param_request
EoE IP parameters.
int ecrt_slave_config_emerg_overruns(const ec_slave_config_t *sc)
Read the number of CoE emergency overruns.
struct list_head reg_requests
Register access requests.
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.
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.
static ATTRIBUTES int ec_ioctl_slave_sdo_entry(ec_master_t *master, void *arg)
Get slave SDO entry information.
int ecrt_slave_config_state_timeout(ec_slave_config_t *sc, ec_al_state_t from, ec_al_state_t to, unsigned int timeout_ms)
Sets the application-layer state transition timeout in ms.
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.
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
int ecrt_slave_config_eoe_dns_address(ec_slave_config_t *sc, struct in_addr dns_address)
Sets the IPv4 address of the DNS server for Ethernet-over-EtherCAT (EoE) operation.
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.
const uint8_t * macs[EC_MAX_NUM_DEVICES]
Device MAC addresses.
uint8_t * ecrt_reg_request_data(const ec_reg_request_t *reg)
Access to the register request's data.
uint32_t result
FoE request abort code.
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.
u64 rx_count
Number of frames received.
#define EC_MAX_HOSTNAME_SIZE
Maximum hostname size.
size_t data_size
Size of SDO data.
wait_queue_head_t request_queue
Wait queue for external requests from user space.
void ec_eoe_request_init(ec_eoe_request_t *req)
EoE request constructor.
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
Provide external memory to store the domain's process data.
int ecrt_slave_config_state(const ec_slave_config_t *sc, ec_slave_config_state_t *state)
Outputs the state of the slave configuration.
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)
int ecrt_master_write_idn(ec_master_t *master, uint16_t slave_position, uint8_t drive_no, uint16_t idn, const uint8_t *data, size_t data_size, uint16_t *error_code)
Executes an SoE write request.
char * key
Flag key (null-terminated ASCII string.
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.
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.
ec_al_state_t al_state
AL state (only valid for IDN config).
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.
int ecrt_domain_queue(ec_domain_t *domain)
(Re-)queues all domain datagrams in the master's datagram queue.
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT]
DC sync signals.
int ecrt_master_reference_clock_time(const ec_master_t *master, uint32_t *time)
Get the lower 32 bit of the reference clock system time.
static ATTRIBUTES int ec_ioctl_soe_request_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets an SoE request's state.
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.
int ecrt_slave_config_emerg_clear(ec_slave_config_t *sc)
Clears CoE emergency ring buffer and the overrun counter.
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.
int ecrt_master_sync_reference_clock_to(ec_master_t *master, uint64_t sync_time)
Queues the DC reference clock drift compensation datagram for sending.
void ec_foe_request_clear(ec_foe_request_t *req)
FoE request destructor.
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.
uint8_t * ecrt_soe_request_data(const ec_soe_request_t *req)
Access to the SoE request's data.
struct irq_work sc_reset_work_kicker
NMI-Safe kicker to trigger reset task above.
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_sdo_request_index(ec_sdo_request_t *req, uint16_t index, uint8_t subindex)
Set the SDO index and subindex.
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.
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.
void(* state)(ec_voe_handler_t *)
State function.
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.
Slave configutation feature flag.
static ATTRIBUTES int ec_ioctl_sc_watchdog(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configure a slave's watchdogs.
size_t ecrt_domain_size(const ec_domain_t *domain)
Returns the current size of the domain's process data.
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.
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.
int ecrt_master_application_time(ec_master_t *master, uint64_t app_time)
Sets the application time.
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.
static ATTRIBUTES int ec_ioctl_sc_flag(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures a feature flag.
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).
struct rt_mutex io_mutex
Mutex used in IDLE and OP phase.
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.
int 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.
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.
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.
unsigned int index
Index (just a number).
s32 tx_byte_rates[EC_RATE_COUNT]
Transmit rates in byte/s for different statistics cycle periods.
size_t ecrt_sdo_request_data_size(const ec_sdo_request_t *req)
Returns the current SDO data size.
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.
long ec_ioctl(ec_master_t *master, ec_ioctl_context_t *ctx, unsigned int cmd, void *arg)
Called when an ioctl() command is issued.
int ecrt_reg_request_write(ec_reg_request_t *reg, uint16_t address, size_t size)
Schedule an register write operation.
uint16_t watchdog_intervals
Process data watchdog intervals (see spec.
int ecrt_slave_config_flag(ec_slave_config_t *sc, const char *key, int32_t value)
Adds a feature flag to a slave configuration.
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.
struct list_head soe_requests
List of SoE requests.
size_t ecrt_soe_request_data_size(const ec_soe_request_t *req)
Returns the current IDN data size.
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.
ec_request_state_t ecrt_soe_request_state(const ec_soe_request_t *req)
Get the current state of the SoE request.
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.
uint8_t has_dc_system_time
The slave supports the DC system time register.
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.
int 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.
ec_request_state_t ecrt_reg_request_state(const ec_reg_request_t *reg)
Get the current state of the register request.
int ecrt_slave_config_eoe_ip_address(ec_slave_config_t *sc, struct in_addr ip_address)
Sets the IP address for Ethernet-over-EtherCAT (EoE) operation.
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_sync_ref_to(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the reference clock.
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.
int ecrt_master_select_reference_clock(ec_master_t *master, ec_slave_config_t *sc)
Selects the reference clock for distributed clocks.
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.
int ecrt_master_sync_monitor_queue(ec_master_t *master)
Queues the DC synchrony monitoring datagram for sending.
uint16_t data_type
Data type.
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 SDO request via its position in the list.
static ATTRIBUTES int ec_ioctl_sc_create_soe_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create an SoE request.
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.
static ATTRIBUTES int ec_ioctl_config_flag(ec_master_t *master, void *arg)
Get slave configuration feature flag information.
static ATTRIBUTES int ec_ioctl_soe_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SoE IDN write operation.
int ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc, uint16_t pdo_index)
Clear the mapping of a given PDO.
Ethernet-over-EtherCAT set IP parameter request.
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.
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.
uint16_t effective_alias
Effective alias address.
size_t data_size
Size of SDO data.
ec_internal_request_state_t state
Request state.
ec_soe_request_t * ecrt_slave_config_create_soe_request_err(ec_slave_config_t *sc, uint8_t drive_no, uint16_t idn, size_t size)
Same as ecrt_slave_config_create_soe_request(), but with ERR_PTR() return value.
static ATTRIBUTES int ec_ioctl_slave_sync(ec_master_t *master, void *arg)
Get slave sync manager information.
struct list_head foe_requests
FoE 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.
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.
int ecrt_domain_process(ec_domain_t *domain)
Determines the states of the domain's datagrams.
static ATTRIBUTES int ec_ioctl_module(void *arg, ec_ioctl_context_t *ctx)
Get module information.
uint8_t enable
Enable bit.
int ecrt_slave_config_eoe_default_gateway(ec_slave_config_t *sc, struct in_addr gateway_address)
Sets the gateway address for Ethernet-over-EtherCAT (EoE) operation.
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.
static long ec_ioctl_both(ec_master_t *master, ec_ioctl_context_t *ctx, unsigned int cmd, void *arg)
Called when an ioctl() command is issued.
uint16_t boot_rx_mailbox_size
Bootstrap receive mailbox size.
#define EC_MAX_PORTS
Maximum number of slave ports.
static ATTRIBUTES int ec_ioctl_soe_request_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Read SoE IDN data.
static ATTRIBUTES int ec_ioctl_config_ip(ec_master_t *master, void *arg)
Get configured EoE IP parameters for a given slave configuration.
int ecrt_master_sdo_download(ec_master_t *master, uint16_t slave_position, uint16_t index, uint8_t subindex, const uint8_t *data, size_t data_size, uint32_t *abort_code)
Executes an SDO download request to write data to a slave.
uint8_t * ecrt_voe_handler_data(const ec_voe_handler_t *voe)
Access to the VoE handler's data.
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.
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.
static ATTRIBUTES int ec_ioctl_soe_request_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SoE IDN read operation.
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.
uint8_t drive_no
Drive number.
uint32_t receive_time
Port receive times for delay measurement.
uint8_t max_subindex
Maximum subindex.
int 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_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.
int ecrt_slave_config_eoe_hostname(ec_slave_config_t *sc, const char *name)
Sets the host name for Ethernet-over-EtherCAT (EoE) operation.
ec_pdo_list_t pdos
Current PDO assignment.
int32_t value
Flag value (meaning depends on key).
static ATTRIBUTES int ec_ioctl_soe_request_index(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an SoE request's drive number and IDN.
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.
static ATTRIBUTES int ec_ioctl_sc_ip(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures EoE IP parameters.
u64 rx_count
Number of frames received.
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.
int ecrt_master_activate(ec_master_t *master)
Finishes the configuration phase and prepares for cyclic operation.
struct work_struct sc_reset_work
Task to reset slave configuration.
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_soe_request_read(ec_soe_request_t *req)
Schedule an SoE IDN read operation.
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe)
Returns the current data size.
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe)
Execute the handler.
static ATTRIBUTES int ec_ioctl_soe_request_timeout(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an CoE request's timeout.
EtherCAT slave configuration.
int ecrt_master_receive(ec_master_t *master)
Fetches received frames from the hardware and processes the datagrams.
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
uint32_t ecrt_master_sync_monitor_process(const ec_master_t *master)
Processes the DC synchrony monitoring datagram.
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.
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.
unsigned int ec_master_config_count(const ec_master_t *master)
Get the number of slave configurations provided by the application.
uint16_t default_length
Data length in bytes.
static ATTRIBUTES int ec_ioctl_voe_exec(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Executes the VoE state machine.
uint32_t product_code
Vendor-specific product code.
ec_direction_t dir
FMMU direction.
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.
int ecrt_slave_config_eoe_mac_address(ec_slave_config_t *sc, const unsigned char *mac_address)
Sets the link/MAC address for Ethernet-over-EtherCAT (EoE) operation.
ec_fsm_master_t fsm
Master state machine.
u64 rx_bytes
Number of bytes received.
int ecrt_soe_request_write(ec_soe_request_t *req)
Schedule an SoE IDN write operation.
#define EC_COE_EMERGENCY_MSG_SIZE
Size of a CoE emergency message in byte.
int ecrt_slave_config_eoe_subnet_mask(ec_slave_config_t *sc, struct in_addr subnet_mask)
Sets the subnet mask for Ethernet-over-EtherCAT (EoE) operation.
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.
int ecrt_slave_config_emerg_size(ec_slave_config_t *sc, size_t elements)
Set the size of the CoE emergency ring buffer.
unsigned int error_flag
Stop processing after an error.
ec_sync_t * syncs
SYNC MANAGER categories.
size_t mem_size
Size of SDO data memory.
uint16_t std_tx_mailbox_size
Standard transmit mailbox size.
struct list_head list
List item.
struct list_head eoe_requests
EoE set IP parameter requests.
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.
uint16_t idn
Sercos ID-Number.
#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.
ec_internal_request_state_t state
Request state.
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.
int ecrt_reg_request_read(ec_reg_request_t *reg, uint16_t address, size_t size)
Schedule a register read operation.
struct list_head list
List item.
static ATTRIBUTES int ec_ioctl_slave_reg_write(ec_master_t *master, void *arg)
Write a slave's registers.
int ecrt_master_sync_slave_clocks(ec_master_t *master)
Queues the DC clock drift compensation datagram for sending.
const uint16_t * words
Pointer to the data words.
int ecrt_master_state(const ec_master_t *master, ec_master_state_t *state)
Reads the current master state.
Sercos-over-EtherCAT request.
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...
uint8_t * data
Pointer to SDO data.
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.
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.
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.
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.
int ecrt_voe_handler_read_nosync(ec_voe_handler_t *voe)
Start a VoE read operation without querying the sync manager status.
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.