37 #include <linux/module.h> 38 #include <linux/vmalloc.h> 50 #define DEBUG_LATENCY 0 55 #define ATTRIBUTES __attribute__ ((__noinline__)) 63 #define ec_ioctl_lock_down_interruptible(p) 0 64 #define ec_ioctl_lock_up(p) do {} while (0) 66 #define ec_ioctl_lock_down_interruptible(p) ec_lock_down_interruptible(p) 67 #define ec_ioctl_lock_up(p) ec_lock_up(p) 80 strncpy(target, source, EC_IOCTL_STRING_SIZE);
81 target[EC_IOCTL_STRING_SIZE - 1] = 0;
97 ec_ioctl_module_t data;
99 data.ioctl_version_magic = EC_IOCTL_VERSION_MAGIC;
102 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
119 ec_ioctl_master_t io;
120 unsigned int dev_idx, j;
122 if (ec_lock_down_interruptible(&master->
master_sem)) {
132 io.eoe_handler_count = 0;
134 io.phase = (uint8_t) master->
phase;
135 io.active = (uint8_t) master->
active;
140 if (ec_lock_down_interruptible(&master->
device_sem)) {
149 memcpy(io.devices[dev_idx].address, device->
dev->dev_addr,
152 memcpy(io.devices[dev_idx].address, master->
macs[dev_idx],
155 io.devices[dev_idx].attached = device->
dev ? 1 : 0;
156 io.devices[dev_idx].link_state = device->
link_state ? 1 : 0;
157 io.devices[dev_idx].tx_count = device->
tx_count;
158 io.devices[dev_idx].rx_count = device->
rx_count;
159 io.devices[dev_idx].tx_bytes = device->
tx_bytes;
160 io.devices[dev_idx].rx_bytes = device->
rx_bytes;
161 io.devices[dev_idx].tx_errors = device->
tx_errors;
163 io.devices[dev_idx].tx_frame_rates[j] =
165 io.devices[dev_idx].rx_frame_rates[j] =
167 io.devices[dev_idx].tx_byte_rates[j] =
169 io.devices[dev_idx].rx_byte_rates[j] =
180 io.tx_frame_rates[j] =
182 io.rx_frame_rates[j] =
184 io.tx_byte_rates[j] =
186 io.rx_byte_rates[j] =
199 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
217 ec_ioctl_slave_t data;
221 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
225 if (ec_lock_down_interruptible(&master->
master_sem))
229 master, 0, data.position))) {
231 EC_MASTER_DBG(master, 1,
"Slave %u does not exist!\n", data.position);
255 data.ports[i].desc = slave->
ports[i].
desc;
258 data.ports[i].link.signal_detected =
262 data.ports[i].next_slave =
265 data.ports[i].next_slave = 0xffff;
287 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
304 ec_ioctl_slave_sync_t data;
308 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
312 if (ec_lock_down_interruptible(&master->
master_sem))
316 master, 0, data.slave_position))) {
319 data.slave_position);
325 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
330 sync = &slave->
sii.
syncs[data.sync_index];
335 data.enable = sync->
enable;
340 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
357 ec_ioctl_slave_sync_pdo_t data;
362 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
366 if (ec_lock_down_interruptible(&master->
master_sem))
370 master, 0, data.slave_position))) {
373 data.slave_position);
379 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
384 sync = &slave->
sii.
syncs[data.sync_index];
386 &sync->
pdos, data.pdo_pos))) {
388 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with " 389 "position %u!\n", data.sync_index, data.pdo_pos);
393 data.index = pdo->
index;
399 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
416 ec_ioctl_slave_sync_pdo_entry_t data;
422 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
426 if (ec_lock_down_interruptible(&master->
master_sem))
430 master, 0, data.slave_position))) {
433 data.slave_position);
439 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
444 sync = &slave->
sii.
syncs[data.sync_index];
446 &sync->
pdos, data.pdo_pos))) {
448 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with " 449 "position %u!\n", data.sync_index, data.pdo_pos);
454 pdo, data.entry_pos))) {
456 EC_SLAVE_ERR(slave,
"PDO 0x%04X does not contain an entry with " 457 "position %u!\n", data.pdo_pos, data.entry_pos);
461 data.index = entry->
index;
468 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
485 ec_ioctl_domain_t data;
487 unsigned int dev_idx;
489 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
513 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
530 ec_ioctl_domain_fmmu_t data;
534 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
551 " fmmu configurations.\n",
552 data.domain_index, data.fmmu_index + 1);
556 data.slave_config_alias = fmmu->
sc->
alias;
557 data.slave_config_position = fmmu->
sc->
position;
559 data.dir = fmmu->
dir;
565 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
582 ec_ioctl_domain_data_t data;
585 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
599 if (domain->
data_size != data.data_size) {
606 if (copy_to_user((
void __user *) data.target, domain->
data,
656 ec_ioctl_slave_state_t data;
659 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
663 if (ec_lock_down_interruptible(&master->
master_sem))
667 master, 0, data.slave_position))) {
670 data.slave_position);
691 ec_ioctl_slave_sdo_t data;
695 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
699 if (ec_lock_down_interruptible(&master->
master_sem))
703 master, 0, data.slave_position))) {
706 data.slave_position);
711 slave, data.sdo_position))) {
713 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", data.sdo_position);
717 data.sdo_index = sdo->
index;
723 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
740 ec_ioctl_slave_sdo_entry_t data;
745 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
749 if (ec_lock_down_interruptible(&master->
master_sem))
753 master, 0, data.slave_position))) {
756 data.slave_position);
760 if (data.sdo_spec <= 0) {
762 slave, -data.sdo_spec))) {
764 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", -data.sdo_spec);
769 slave, data.sdo_spec))) {
778 sdo, data.sdo_entry_subindex))) {
780 EC_SLAVE_ERR(slave,
"SDO entry 0x%04X:%02X does not exist!\n",
781 sdo->
index, data.sdo_entry_subindex);
803 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
820 ec_ioctl_slave_sdo_upload_t data;
824 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
828 if (!(target = kmalloc(data.target_size, GFP_KERNEL))) {
830 " for SDO upload.\n", data.target_size);
835 data.sdo_index, data.sdo_entry_subindex, target,
836 data.target_size, &data.data_size, &data.abort_code);
839 if (copy_to_user((
void __user *) data.target,
840 target, data.data_size)) {
848 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
866 ec_ioctl_slave_sdo_download_t data;
870 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
874 if (!(sdo_data = kmalloc(data.data_size, GFP_KERNEL))) {
876 " for SDO download.\n", data.data_size);
880 if (copy_from_user(sdo_data, (
const void __user *) data.data, data.data_size)) {
885 if (data.complete_access) {
887 data.sdo_index, sdo_data, data.data_size, &data.abort_code);
890 data.sdo_index, data.sdo_entry_subindex, sdo_data,
891 data.data_size, &data.abort_code);
896 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
914 ec_ioctl_slave_sii_t data;
918 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
922 if (ec_lock_down_interruptible(&master->
master_sem))
926 master, 0, data.slave_position))) {
929 data.slave_position);
934 || data.offset + data.nwords > slave->
sii_nwords) {
936 EC_SLAVE_ERR(slave,
"Invalid SII read offset/size %u/%u for slave SII" 937 " size %zu!\n", data.offset, data.nwords, slave->
sii_nwords);
941 if (copy_to_user((
void __user *) data.words,
942 slave->
sii_words + data.offset, data.nwords * 2))
962 ec_ioctl_slave_sii_t data;
964 unsigned int byte_size;
968 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
976 byte_size =
sizeof(uint16_t) * data.
nwords;
977 if (!(words = kmalloc(byte_size, GFP_KERNEL))) {
979 " for SII contents.\n", byte_size);
983 if (copy_from_user(words,
984 (
void __user *) data.words, byte_size)) {
989 if (ec_lock_down_interruptible(&master->
master_sem)) {
995 master, 0, data.slave_position))) {
998 data.slave_position);
1004 INIT_LIST_HEAD(&request.
list);
1005 request.
slave = slave;
1006 request.
words = words;
1007 request.
offset = data.offset;
1008 request.
nwords = data.nwords;
1009 request.
state = EC_INT_REQUEST_QUEUED;
1018 request.
state != EC_INT_REQUEST_QUEUED)) {
1021 if (request.
state == EC_INT_REQUEST_QUEUED) {
1023 list_del(&request.
list);
1036 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1050 ec_ioctl_slave_reg_t io;
1055 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1071 if (ec_lock_down_interruptible(&master->
master_sem)) {
1077 master, 0, io.slave_position))) {
1092 request.
state != EC_INT_REQUEST_QUEUED)) {
1095 if (request.
state == EC_INT_REQUEST_QUEUED) {
1097 list_del(&request.
list);
1108 if (request.
state == EC_INT_REQUEST_SUCCESS) {
1109 if (copy_to_user((
void __user *) io.data, request.
data, io.size)) {
1115 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1129 ec_ioctl_slave_reg_t io;
1134 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1148 if (copy_from_user(request.
data, (
void __user *) io.data, io.size)) {
1155 if (ec_lock_down_interruptible(&master->
master_sem)) {
1182 request.
state != EC_INT_REQUEST_QUEUED)) {
1185 if (request.
state == EC_INT_REQUEST_QUEUED) {
1187 list_del(&request.
list);
1200 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1214 ec_ioctl_config_t data;
1218 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1222 if (ec_lock_down_interruptible(&master->
master_sem))
1226 master, data.config_index))) {
1233 data.alias = sc->
alias;
1240 data.syncs[i].pdo_count =
1251 data.dc_sync[i] = sc->
dc_sync[i];
1256 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1273 ec_ioctl_config_pdo_t data;
1277 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1287 if (ec_lock_down_interruptible(&master->
master_sem))
1291 master, data.config_index))) {
1306 data.index = pdo->
index;
1312 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1329 ec_ioctl_config_pdo_entry_t data;
1334 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1344 if (ec_lock_down_interruptible(&master->
master_sem))
1348 master, data.config_index))) {
1364 pdo, data.entry_pos))) {
1370 data.index = entry->
index;
1377 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1394 ec_ioctl_config_sdo_t *ioctl;
1398 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1402 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1407 if (ec_lock_down_interruptible(&master->
master_sem)) {
1413 master, ioctl->config_index))) {
1416 ioctl->config_index);
1422 sc, ioctl->sdo_pos))) {
1429 ioctl->index = req->
index;
1432 memcpy(ioctl->data, req->
data,
1433 min((u32) ioctl->size, (u32) EC_MAX_SDO_DATA_SIZE));
1438 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1458 ec_ioctl_config_idn_t *ioctl;
1462 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1466 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1471 if (ec_lock_down_interruptible(&master->
master_sem)) {
1477 master, ioctl->config_index))) {
1480 ioctl->config_index);
1486 sc, ioctl->idn_pos))) {
1494 ioctl->idn = req->
idn;
1495 ioctl->state = req->
state;
1497 memcpy(ioctl->data, req->
data,
1498 min((u32) ioctl->size, (u32) EC_MAX_IDN_DATA_SIZE));
1502 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1522 ec_ioctl_config_flag_t *ioctl;
1527 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1531 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1536 if (ec_lock_down_interruptible(&master->
master_sem)) {
1542 master, ioctl->config_index))) {
1545 ioctl->config_index);
1551 sc, ioctl->flag_pos))) {
1558 size = min((u32) strlen(flag->
key), (u32) EC_MAX_FLAG_KEY_SIZE - 1);
1559 memcpy(ioctl->key, flag->
key, size);
1560 ioctl->key[size] = 0x00;
1561 ioctl->value = flag->
value;
1565 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1587 ec_ioctl_eoe_handler_t data;
1590 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1594 if (ec_lock_down_interruptible(&master->
master_sem))
1607 data.slave_position = 0xffff;
1611 data.rx_bytes = eoe->
stats.tx_bytes;
1613 data.tx_bytes = eoe->
stats.rx_bytes;
1620 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1640 ec_ioctl_slave_eoe_ip_t io;
1644 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1651 req.mac_address_included = io.mac_address_included;
1652 req.ip_address_included = io.ip_address_included;
1653 req.subnet_mask_included = io.subnet_mask_included;
1654 req.gateway_included = io.gateway_included;
1655 req.dns_included = io.dns_included;
1656 req.name_included = io.name_included;
1658 memcpy(req.mac_address, io.mac_address, ETH_ALEN);
1659 req.ip_address = io.ip_address;
1660 req.subnet_mask = io.subnet_mask;
1661 req.gateway = io.gateway;
1665 req.
state = EC_INT_REQUEST_QUEUED;
1667 if (ec_lock_down_interruptible(&master->
master_sem)) {
1672 master, 0, io.slave_position))) {
1688 req.
state != EC_INT_REQUEST_QUEUED)) {
1691 if (req.
state == EC_INT_REQUEST_QUEUED) {
1693 list_del(&req.
list);
1703 io.result = req.result;
1705 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
1709 return req.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1722 ec_ioctl_context_t *ctx
1747 ec_ioctl_context_t *ctx
1752 if (unlikely(!ctx->requested))
1757 return PTR_ERR(domain);
1759 return domain->
index;
1771 ec_ioctl_context_t *ctx
1774 ec_ioctl_config_t data;
1777 if (unlikely(!ctx->requested))
1780 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1785 data.vendor_id, data.product_code);
1789 data.config_index = 0;
1791 if (ec_lock_down_interruptible(&master->
master_sem))
1794 list_for_each_entry(entry, &master->
configs, list) {
1797 data.config_index++;
1802 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1817 ec_ioctl_context_t *ctx
1820 unsigned long config_index = (
unsigned long) arg;
1824 if (unlikely(!ctx->requested)) {
1829 if (ec_lock_down_interruptible(&master->
master_sem)) {
1834 if (config_index != 0xFFFFFFFF) {
1858 ec_ioctl_context_t *ctx
1861 ec_ioctl_master_activate_t io;
1864 #ifdef EC_IOCTL_RTDM 1868 if (unlikely(!ctx->requested))
1872 if (!ctx->process_data)
1874 io.process_data = NULL;
1878 ctx->process_data_size = 0;
1883 list_for_each_entry(domain, &master->
domains, list) {
1887 if (ctx->process_data_size) {
1888 ctx->process_data = vmalloc(ctx->process_data_size);
1889 if (!ctx->process_data) {
1890 ctx->process_data_size = 0;
1898 list_for_each_entry(domain, &master->
domains, list) {
1900 ctx->process_data + offset);
1906 #ifdef EC_IOCTL_RTDM 1913 " memory to user space (code %i).\n", ret);
1921 io.process_data_size = ctx->process_data_size;
1925 io.process_data = NULL;
1926 io.process_data_size = 0;
1930 if (copy_to_user((
void __user *) arg, &io,
1931 sizeof(ec_ioctl_master_activate_t)))
1946 ec_ioctl_context_t *ctx
1949 ec_ioctl_master_activate_t io;
1954 if (unlikely(!ctx->requested))
1958 if (!ctx->process_data)
1960 io.process_data = NULL;
1964 ctx->process_data_size = 0;
1969 list_for_each_entry(domain, &master->
domains, list) {
1973 if (ctx->process_data_size) {
1974 ctx->process_data = vmalloc(ctx->process_data_size);
1975 if (!ctx->process_data) {
1976 ctx->process_data_size = 0;
1984 list_for_each_entry(domain, &master->
domains, list) {
1986 ctx->process_data + offset);
1990 #ifdef EC_IOCTL_RTDM 1997 " memory to user space (code %i).\n", ret);
2005 io.process_data_size = ctx->process_data_size;
2009 io.process_data = NULL;
2010 io.process_data_size = 0;
2013 #ifndef EC_IOCTL_RTDM 2022 if (copy_to_user((
void __user *) arg, &io,
2023 sizeof(ec_ioctl_master_activate_t)))
2038 ec_ioctl_context_t *ctx
2041 if (unlikely(!ctx->requested))
2057 ec_ioctl_context_t *ctx
2060 if (unlikely(!ctx->requested))
2076 ec_ioctl_context_t *ctx
2079 size_t send_interval;
2081 if (unlikely(!ctx->requested)) {
2085 if (copy_from_user(&send_interval, (
void __user *) arg,
2086 sizeof(send_interval))) {
2090 if (ec_lock_down_interruptible(&master->
master_sem))
2108 ec_ioctl_context_t *ctx
2113 if (unlikely(!ctx->requested)) {
2122 if (master->
send_cb != NULL) {
2128 ec_ioctl_lock_up(&master->
io_sem);
2130 if (copy_to_user((
void __user *) arg, &sent_bytes,
sizeof(sent_bytes))) {
2146 ec_ioctl_context_t *ctx
2149 if (unlikely(!ctx->requested)) {
2163 ec_ioctl_lock_up(&master->
io_sem);
2177 ec_ioctl_context_t *ctx
2184 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2199 ec_ioctl_context_t *ctx
2202 ec_ioctl_link_state_t ioctl;
2206 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
2215 if (copy_to_user((
void __user *) ioctl.state, &state,
sizeof(state))) {
2231 ec_ioctl_context_t *ctx
2236 if (unlikely(!ctx->requested))
2239 if (copy_from_user(&time, (
void __user *) arg,
sizeof(time))) {
2256 ec_ioctl_context_t *ctx
2259 if (unlikely(!ctx->requested)) {
2266 ec_ioctl_lock_up(&master->
io_sem);
2279 ec_ioctl_context_t *ctx
2284 if (unlikely(!ctx->requested))
2287 if (copy_from_user(&time, (
void __user *) arg,
sizeof(time))) {
2294 ec_ioctl_lock_up(&master->
io_sem);
2307 ec_ioctl_context_t *ctx
2310 if (unlikely(!ctx->requested)) {
2317 ec_ioctl_lock_up(&master->
io_sem);
2330 ec_ioctl_context_t *ctx
2336 if (unlikely(!ctx->requested)) {
2345 if (copy_to_user((
void __user *) arg, &time,
sizeof(time))) {
2361 ec_ioctl_context_t *ctx
2364 if (unlikely(!ctx->requested)) {
2371 ec_ioctl_lock_up(&master->
io_sem);
2384 ec_ioctl_context_t *ctx
2390 if (unlikely(!ctx->requested)) {
2399 if (copy_to_user((
void __user *) arg, &time,
sizeof(time))) {
2415 ec_ioctl_context_t *ctx
2418 if (unlikely(!ctx->requested)) {
2425 ec_ioctl_lock_up(&master->
io_sem);
2438 ec_ioctl_context_t *ctx
2443 if (unlikely(!ctx->requested))
2448 if (copy_to_user((
void __user *) arg, &time_diff,
sizeof(time_diff)))
2463 ec_ioctl_context_t *ctx
2481 ec_ioctl_context_t *ctx
2484 ec_ioctl_config_t data;
2489 if (unlikely(!ctx->requested)) {
2494 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2499 if (ec_lock_down_interruptible(&master->
master_sem)) {
2510 if (data.syncs[i].config_this) {
2512 data.syncs[i].watchdog_mode);
2534 ec_ioctl_context_t *ctx
2537 ec_ioctl_config_t data;
2541 if (unlikely(!ctx->requested)) {
2546 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2551 if (ec_lock_down_interruptible(&master->
master_sem)) {
2577 ec_ioctl_context_t *ctx
2580 ec_ioctl_config_t data;
2584 if (unlikely(!ctx->requested)) {
2589 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2594 if (ec_lock_down_interruptible(&master->
master_sem)) {
2621 ec_ioctl_context_t *ctx
2624 ec_ioctl_config_pdo_t data;
2627 if (unlikely(!ctx->requested))
2630 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2633 if (ec_lock_down_interruptible(&master->
master_sem))
2655 ec_ioctl_context_t *ctx
2658 ec_ioctl_config_pdo_t data;
2661 if (unlikely(!ctx->requested))
2664 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2667 if (ec_lock_down_interruptible(&master->
master_sem))
2690 ec_ioctl_context_t *ctx
2693 ec_ioctl_add_pdo_entry_t data;
2696 if (unlikely(!ctx->requested))
2699 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2702 if (ec_lock_down_interruptible(&master->
master_sem))
2713 data.entry_index, data.entry_subindex, data.entry_bit_length);
2725 ec_ioctl_context_t *ctx
2728 ec_ioctl_config_pdo_t data;
2731 if (unlikely(!ctx->requested))
2734 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2737 if (ec_lock_down_interruptible(&master->
master_sem))
2760 ec_ioctl_context_t *ctx
2763 ec_ioctl_reg_pdo_entry_t data;
2768 if (unlikely(!ctx->requested))
2771 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2774 if (ec_lock_down_interruptible(&master->
master_sem))
2802 data.entry_subindex, domain, &data.bit_position);
2804 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2819 ec_ioctl_context_t *ctx
2822 ec_ioctl_reg_pdo_pos_t io;
2827 if (unlikely(!ctx->requested)) {
2831 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
2835 if (ec_lock_down_interruptible(&master->
master_sem)) {
2863 io.pdo_pos, io.entry_pos, domain, &io.bit_position);
2865 if (copy_to_user((
void __user *) arg, &io,
sizeof(io)))
2880 ec_ioctl_context_t *ctx
2883 ec_ioctl_config_t data;
2886 if (unlikely(!ctx->requested))
2889 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2892 if (ec_lock_down_interruptible(&master->
master_sem))
2901 data.dc_sync[0].cycle_time,
2902 data.dc_sync[0].shift_time,
2903 data.dc_sync[1].cycle_time,
2904 data.dc_sync[1].shift_time);
2920 ec_ioctl_context_t *ctx
2923 ec_ioctl_sc_sdo_t data;
2925 uint8_t *sdo_data = NULL;
2928 if (unlikely(!ctx->requested))
2931 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
2937 if (!(sdo_data = kmalloc(data.size, GFP_KERNEL))) {
2941 if (copy_from_user(sdo_data, (
void __user *) data.data, data.size)) {
2946 if (ec_lock_down_interruptible(&master->
master_sem)) {
2959 if (data.complete_access) {
2961 data.index, sdo_data, data.size);
2979 ec_ioctl_context_t *ctx
2982 ec_ioctl_sc_emerg_t io;
2986 if (unlikely(!ctx->requested))
2989 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io)))
2992 if (ec_lock_down_interruptible(&master->
master_sem)) {
3017 ec_ioctl_context_t *ctx
3020 ec_ioctl_sc_emerg_t io;
3025 if (unlikely(!ctx->requested)) {
3029 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3045 if (copy_to_user((
void __user *) io.target, msg,
sizeof(msg))) {
3061 ec_ioctl_context_t *ctx
3064 ec_ioctl_sc_emerg_t io;
3067 if (unlikely(!ctx->requested)) {
3071 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3094 ec_ioctl_context_t *ctx
3097 ec_ioctl_sc_emerg_t io;
3101 if (unlikely(!ctx->requested)) {
3105 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3123 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3139 ec_ioctl_context_t *ctx
3142 ec_ioctl_sdo_request_t data;
3146 if (unlikely(!ctx->requested))
3149 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3153 data.request_index = 0;
3155 if (ec_lock_down_interruptible(&master->
master_sem))
3165 data.request_index++;
3171 data.sdo_subindex, data.size);
3173 return PTR_ERR(req);
3175 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3190 ec_ioctl_context_t *ctx
3193 ec_ioctl_reg_request_t io;
3197 if (unlikely(!ctx->requested)) {
3201 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3205 io.request_index = 0;
3207 if (ec_lock_down_interruptible(&master->
master_sem)) {
3225 return PTR_ERR(reg);
3228 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3244 ec_ioctl_context_t *ctx
3247 ec_ioctl_voe_t data;
3251 if (unlikely(!ctx->requested))
3254 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3260 if (ec_lock_down_interruptible(&master->
master_sem))
3277 return PTR_ERR(voe);
3279 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3294 ec_ioctl_context_t *ctx
3297 ec_ioctl_sc_state_t data;
3301 if (unlikely(!ctx->requested))
3304 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3317 if (copy_to_user((
void __user *) data.state, &state,
sizeof(state)))
3332 ec_ioctl_context_t *ctx
3335 ec_ioctl_sc_idn_t ioctl;
3337 uint8_t *data = NULL;
3340 if (unlikely(!ctx->requested))
3343 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl)))
3349 if (!(data = kmalloc(ioctl.size, GFP_KERNEL))) {
3353 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.size)) {
3358 if (ec_lock_down_interruptible(&master->
master_sem)) {
3372 sc, ioctl.drive_no, ioctl.idn, ioctl.al_state, data, ioctl.size);
3386 ec_ioctl_context_t *ctx
3389 ec_ioctl_sc_flag_t ioctl;
3394 if (unlikely(!ctx->requested)) {
3398 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
3402 if (!ioctl.key_size) {
3406 if (!(key = kmalloc(ioctl.key_size + 1, GFP_KERNEL))) {
3410 if (copy_from_user(key, (
void __user *) ioctl.key, ioctl.key_size)) {
3415 if (ec_lock_down_interruptible(&master->
master_sem)) {
3442 ec_ioctl_context_t *ctx
3447 if (unlikely(!ctx->requested)) {
3451 if (ec_lock_down_interruptible(&master->
domains_lock)) {
3455 list_for_each_entry(domain, &master->
domains, list) {
3456 if (domain->
index == (
unsigned long) arg) {
3476 ec_ioctl_context_t *ctx
3482 if (unlikely(!ctx->requested))
3485 if (ec_lock_down_interruptible(&master->
domains_lock)) {
3489 list_for_each_entry(domain, &master->
domains, list) {
3490 if (domain->
index == (
unsigned long) arg) {
3510 ec_ioctl_context_t *ctx
3515 if (unlikely(!ctx->requested))
3543 ec_ioctl_context_t *ctx
3548 if (unlikely(!ctx->requested))
3565 ec_ioctl_lock_up(&master->
io_sem);
3581 ec_ioctl_context_t *ctx
3584 ec_ioctl_domain_state_t data;
3588 if (unlikely(!ctx->requested))
3591 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3607 if (copy_to_user((
void __user *) data.state, &state,
sizeof(state)))
3622 ec_ioctl_context_t *ctx
3625 ec_ioctl_sdo_request_t data;
3629 if (unlikely(!ctx->requested))
3632 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3659 ec_ioctl_context_t *ctx
3662 ec_ioctl_sdo_request_t data;
3666 if (unlikely(!ctx->requested))
3669 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3696 ec_ioctl_context_t *ctx
3699 ec_ioctl_sdo_request_t data;
3703 if (unlikely(!ctx->requested))
3706 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3726 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3741 ec_ioctl_context_t *ctx
3744 ec_ioctl_sdo_request_t data;
3748 if (unlikely(!ctx->requested))
3751 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3778 ec_ioctl_context_t *ctx
3781 ec_ioctl_sdo_request_t data;
3786 if (unlikely(!ctx->requested))
3789 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3793 EC_MASTER_ERR(master,
"SDO download: Data size may not be zero!\n");
3812 if (copy_from_user(req->
data, (
void __user *) data.data, data.size))
3829 ec_ioctl_context_t *ctx
3832 ec_ioctl_sdo_request_t data;
3836 if (unlikely(!ctx->requested))
3839 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3869 ec_ioctl_context_t *ctx
3872 ec_ioctl_reg_request_t io;
3876 if (unlikely(!ctx->requested)) {
3880 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3884 if (io.mem_size <= 0) {
3900 min(reg->
mem_size, io.mem_size))) {
3916 ec_ioctl_context_t *ctx
3919 ec_ioctl_reg_request_t io;
3923 if (unlikely(!ctx->requested)) {
3927 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3945 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3961 ec_ioctl_context_t *ctx
3964 ec_ioctl_reg_request_t io;
3968 if (unlikely(!ctx->requested)) {
3972 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3987 if (io.transfer_size > reg->
mem_size) {
3991 if (copy_from_user(reg->
data, (
void __user *) io.data,
3992 io.transfer_size)) {
4009 ec_ioctl_context_t *ctx
4012 ec_ioctl_reg_request_t io;
4016 if (unlikely(!ctx->requested)) {
4020 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4035 if (io.transfer_size > reg->
mem_size) {
4052 ec_ioctl_context_t *ctx
4055 ec_ioctl_voe_t data;
4059 uint16_t vendor_type;
4061 if (unlikely(!ctx->requested))
4064 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4067 if (get_user(vendor_id, data.vendor_id))
4070 if (get_user(vendor_type, data.vendor_type))
4097 ec_ioctl_context_t *ctx
4100 ec_ioctl_voe_t data;
4104 uint16_t vendor_type;
4106 if (unlikely(!ctx->requested))
4109 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4125 if (likely(data.vendor_id))
4126 if (put_user(vendor_id, data.vendor_id))
4129 if (likely(data.vendor_type))
4130 if (put_user(vendor_type, data.vendor_type))
4145 ec_ioctl_context_t *ctx
4148 ec_ioctl_voe_t data;
4152 if (unlikely(!ctx->requested))
4155 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4182 ec_ioctl_context_t *ctx
4185 ec_ioctl_voe_t data;
4189 if (unlikely(!ctx->requested))
4192 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4219 ec_ioctl_context_t *ctx
4222 ec_ioctl_voe_t data;
4226 if (unlikely(!ctx->requested))
4229 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4248 (
void __user *) data.data, data.size))
4265 ec_ioctl_context_t *ctx
4268 ec_ioctl_voe_t data;
4272 if (unlikely(!ctx->requested))
4275 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4292 ec_ioctl_lock_up(&master->
io_sem);
4298 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
4313 ec_ioctl_context_t *ctx
4316 ec_ioctl_voe_t data;
4320 if (unlikely(!ctx->requested))
4323 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4355 ec_ioctl_slave_foe_t io;
4360 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4374 if (ec_lock_down_interruptible(&master->
master_sem)) {
4387 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE read request.\n");
4396 request.
state != EC_INT_REQUEST_QUEUED)) {
4399 if (request.
state == EC_INT_REQUEST_QUEUED) {
4400 list_del(&request.
list);
4412 io.result = request.
result;
4415 if (request.
state != EC_INT_REQUEST_SUCCESS) {
4419 if (request.
data_size > io.buffer_size) {
4420 EC_SLAVE_ERR(slave,
"%s(): Buffer too small.\n", __func__);
4425 if (copy_to_user((
void __user *) io.buffer,
4426 request.
buffer, io.data_size)) {
4433 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
4452 ec_ioctl_slave_foe_t io;
4457 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4469 if (copy_from_user(request.
buffer,
4470 (
void __user *) io.buffer, io.buffer_size)) {
4479 if (ec_lock_down_interruptible(&master->
master_sem)) {
4492 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE write request.\n");
4501 request.
state != EC_INT_REQUEST_QUEUED)) {
4504 if (request.
state == EC_INT_REQUEST_QUEUED) {
4506 list_del(&request.
list);
4517 io.result = request.
result;
4520 ret = request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
4522 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
4541 ec_ioctl_slave_soe_read_t ioctl;
4545 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
4549 data = kmalloc(ioctl.mem_size, GFP_KERNEL);
4551 EC_MASTER_ERR(master,
"Failed to allocate %zu bytes of IDN data.\n",
4557 ioctl.drive_no, ioctl.idn, data, ioctl.mem_size, &ioctl.data_size,
4564 if (copy_to_user((
void __user *) ioctl.data,
4565 data, ioctl.data_size)) {
4571 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
4590 ec_ioctl_slave_soe_write_t ioctl;
4594 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
4598 data = kmalloc(ioctl.data_size, GFP_KERNEL);
4600 EC_MASTER_ERR(master,
"Failed to allocate %zu bytes of IDN data.\n",
4604 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.data_size)) {
4610 ioctl.drive_no, ioctl.idn, data, ioctl.data_size,
4617 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
4635 ec_ioctl_slave_dict_upload_t data;
4638 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
4642 ret = ec_master_dict_upload(master, data.slave_position);
4651 #ifdef EC_IOCTL_RTDM 4652 #define EC_IOCTL ec_ioctl_rtdm 4654 #define EC_IOCTL ec_ioctl 4663 ec_ioctl_context_t *ctx,
4669 cycles_t a = get_cycles(), b;
4675 case EC_IOCTL_MODULE:
4678 case EC_IOCTL_MASTER:
4681 case EC_IOCTL_SLAVE:
4684 case EC_IOCTL_SLAVE_SYNC:
4687 case EC_IOCTL_SLAVE_SYNC_PDO:
4690 case EC_IOCTL_SLAVE_SYNC_PDO_ENTRY:
4693 case EC_IOCTL_DOMAIN:
4696 case EC_IOCTL_DOMAIN_FMMU:
4699 case EC_IOCTL_DOMAIN_DATA:
4702 case EC_IOCTL_MASTER_DEBUG:
4703 if (!ctx->writable) {
4709 case EC_IOCTL_MASTER_RESCAN:
4710 if (!ctx->writable) {
4716 case EC_IOCTL_SLAVE_STATE:
4717 if (!ctx->writable) {
4723 case EC_IOCTL_SLAVE_SDO:
4726 case EC_IOCTL_SLAVE_SDO_ENTRY:
4729 case EC_IOCTL_SLAVE_SDO_UPLOAD:
4732 case EC_IOCTL_SLAVE_SDO_DOWNLOAD:
4733 if (!ctx->writable) {
4739 case EC_IOCTL_SLAVE_SII_READ:
4742 case EC_IOCTL_SLAVE_SII_WRITE:
4743 if (!ctx->writable) {
4749 case EC_IOCTL_SLAVE_REG_READ:
4752 case EC_IOCTL_SLAVE_REG_WRITE:
4753 if (!ctx->writable) {
4759 case EC_IOCTL_SLAVE_FOE_READ:
4762 case EC_IOCTL_SLAVE_FOE_WRITE:
4763 if (!ctx->writable) {
4769 case EC_IOCTL_SLAVE_SOE_READ:
4773 case EC_IOCTL_SLAVE_EOE_IP_PARAM:
4774 if (!ctx->writable) {
4781 case EC_IOCTL_SLAVE_SOE_WRITE:
4782 if (!ctx->writable) {
4788 case EC_IOCTL_CONFIG:
4791 case EC_IOCTL_CONFIG_PDO:
4794 case EC_IOCTL_CONFIG_PDO_ENTRY:
4797 case EC_IOCTL_CONFIG_SDO:
4800 case EC_IOCTL_CONFIG_IDN:
4803 case EC_IOCTL_CONFIG_FLAG:
4807 case EC_IOCTL_EOE_HANDLER:
4811 case EC_IOCTL_REQUEST:
4812 if (!ctx->writable) {
4818 case EC_IOCTL_CREATE_DOMAIN:
4819 if (!ctx->writable) {
4825 case EC_IOCTL_CREATE_SLAVE_CONFIG:
4826 if (!ctx->writable) {
4832 case EC_IOCTL_SELECT_REF_CLOCK:
4833 if (!ctx->writable) {
4839 case EC_IOCTL_SETUP_DOMAIN_MEMORY:
4840 if (!ctx->writable) {
4846 case EC_IOCTL_ACTIVATE:
4847 if (!ctx->writable) {
4853 case EC_IOCTL_DEACTIVATE_SLAVES:
4854 if (!ctx->writable) {
4860 case EC_IOCTL_DEACTIVATE:
4861 if (!ctx->writable) {
4868 if (!ctx->writable) {
4874 case EC_IOCTL_RECEIVE:
4875 if (!ctx->writable) {
4881 case EC_IOCTL_MASTER_STATE:
4884 case EC_IOCTL_MASTER_LINK_STATE:
4887 case EC_IOCTL_APP_TIME:
4888 if (!ctx->writable) {
4894 case EC_IOCTL_SYNC_REF:
4895 if (!ctx->writable) {
4901 case EC_IOCTL_SYNC_REF_TO:
4902 if (!ctx->writable) {
4908 case EC_IOCTL_SYNC_SLAVES:
4909 if (!ctx->writable) {
4915 case EC_IOCTL_REF_CLOCK_TIME:
4916 if (!ctx->writable) {
4922 case EC_IOCTL_64_REF_CLK_TIME_QUEUE:
4923 if (!ctx->writable) {
4929 case EC_IOCTL_64_REF_CLK_TIME:
4930 if (!ctx->writable) {
4936 case EC_IOCTL_SYNC_MON_QUEUE:
4937 if (!ctx->writable) {
4943 case EC_IOCTL_SYNC_MON_PROCESS:
4944 if (!ctx->writable) {
4950 case EC_IOCTL_RESET:
4951 if (!ctx->writable) {
4957 case EC_IOCTL_SC_SYNC:
4958 if (!ctx->writable) {
4964 case EC_IOCTL_SC_WATCHDOG:
4965 if (!ctx->writable) {
4971 case EC_IOCTL_SC_OVERLAPPING_IO:
4972 if (!ctx->writable) {
4978 case EC_IOCTL_SC_ADD_PDO:
4979 if (!ctx->writable) {
4985 case EC_IOCTL_SC_CLEAR_PDOS:
4986 if (!ctx->writable) {
4992 case EC_IOCTL_SC_ADD_ENTRY:
4993 if (!ctx->writable) {
4999 case EC_IOCTL_SC_CLEAR_ENTRIES:
5000 if (!ctx->writable) {
5006 case EC_IOCTL_SC_REG_PDO_ENTRY:
5007 if (!ctx->writable) {
5013 case EC_IOCTL_SC_REG_PDO_POS:
5014 if (!ctx->writable) {
5020 case EC_IOCTL_SC_DC:
5021 if (!ctx->writable) {
5027 case EC_IOCTL_SC_SDO:
5028 if (!ctx->writable) {
5034 case EC_IOCTL_SC_EMERG_SIZE:
5035 if (!ctx->writable) {
5041 case EC_IOCTL_SC_EMERG_POP:
5042 if (!ctx->writable) {
5048 case EC_IOCTL_SC_EMERG_CLEAR:
5049 if (!ctx->writable) {
5055 case EC_IOCTL_SC_EMERG_OVERRUNS:
5058 case EC_IOCTL_SC_SDO_REQUEST:
5059 if (!ctx->writable) {
5065 case EC_IOCTL_SC_REG_REQUEST:
5066 if (!ctx->writable) {
5072 case EC_IOCTL_SC_VOE:
5073 if (!ctx->writable) {
5079 case EC_IOCTL_SC_STATE:
5082 case EC_IOCTL_SC_IDN:
5083 if (!ctx->writable) {
5089 case EC_IOCTL_SC_FLAG:
5090 if (!ctx->writable) {
5096 case EC_IOCTL_DOMAIN_SIZE:
5099 case EC_IOCTL_DOMAIN_OFFSET:
5102 case EC_IOCTL_DOMAIN_PROCESS:
5103 if (!ctx->writable) {
5109 case EC_IOCTL_DOMAIN_QUEUE:
5110 if (!ctx->writable) {
5116 case EC_IOCTL_DOMAIN_STATE:
5119 case EC_IOCTL_SDO_REQUEST_INDEX:
5120 if (!ctx->writable) {
5126 case EC_IOCTL_SDO_REQUEST_TIMEOUT:
5127 if (!ctx->writable) {
5133 case EC_IOCTL_SDO_REQUEST_STATE:
5136 case EC_IOCTL_SDO_REQUEST_READ:
5137 if (!ctx->writable) {
5143 case EC_IOCTL_SDO_REQUEST_WRITE:
5144 if (!ctx->writable) {
5150 case EC_IOCTL_SDO_REQUEST_DATA:
5153 case EC_IOCTL_REG_REQUEST_DATA:
5156 case EC_IOCTL_REG_REQUEST_STATE:
5159 case EC_IOCTL_REG_REQUEST_WRITE:
5160 if (!ctx->writable) {
5166 case EC_IOCTL_REG_REQUEST_READ:
5167 if (!ctx->writable) {
5173 case EC_IOCTL_VOE_SEND_HEADER:
5174 if (!ctx->writable) {
5180 case EC_IOCTL_VOE_REC_HEADER:
5183 case EC_IOCTL_VOE_READ:
5184 if (!ctx->writable) {
5190 case EC_IOCTL_VOE_READ_NOSYNC:
5191 if (!ctx->writable) {
5197 case EC_IOCTL_VOE_WRITE:
5198 if (!ctx->writable) {
5204 case EC_IOCTL_VOE_EXEC:
5205 if (!ctx->writable) {
5211 case EC_IOCTL_VOE_DATA:
5214 case EC_IOCTL_SET_SEND_INTERVAL:
5215 if (!ctx->writable) {
5221 case EC_IOCTL_SLAVE_DICT_UPLOAD:
5231 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.
ec_internal_request_state_t state
Request state.
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.
uint16_t ring_position
Ring position.
uint32_t revision_number
Revision number.
static ATTRIBUTES int ec_ioctl_slave_sii_write(ec_master_t *master, void *arg)
Write a slave's SII.
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_voe_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts a VoE read operation.
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_domain_queue(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Queue the domain.
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.
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.
uint32_t logical_domain_offset
Logical offset address relative to domain->logical_base_address.
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe)
Returns the current data size.
#define ec_ioctl_lock_down_interruptible(p)
Ioctl locking is disabled for RTDM as the RT app needs to use RTAI locks.
static ATTRIBUTES int ec_ioctl_sdo_request_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SDO read operation.
u64 tx_count
Number of frames sent.
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.
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_config_idn(ec_master_t *master, void *arg)
Get slave configuration IDN information.
static ATTRIBUTES int ec_ioctl_config_pdo(ec_master_t *master, void *arg)
Get slave configuration PDO information.
size_t data_size
Size of the process data.
ec_slave_t * slave
pointer to the corresponding slave
s32 tx_byte_rates[EC_RATE_COUNT]
Transmit rates in byte/s for different statistics cycle periods.
static ATTRIBUTES int ec_ioctl_sc_sdo(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures an SDO.
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.
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.
static ATTRIBUTES int ec_ioctl_deactivate_slaves(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Deactivates the slaves.
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.
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.
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.
ec_slave_state_t current_state
Current application state.
static ATTRIBUTES int ec_ioctl_domain_data(ec_master_t *master, void *arg)
Get domain data.
#define ec_master_num_devices(MASTER)
Number of Ethernet devices.
#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.
size_t mem_size
Size of data memory.
static ATTRIBUTES int ec_ioctl_config_flag(ec_master_t *master, void *arg)
Get slave configuration feature flag information.
void ec_foe_request_write(ec_foe_request_t *req)
Prepares a write request (master to slave).
uint32_t product_code
Slave product code.
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.
static ATTRIBUTES int ec_ioctl_master_rescan(ec_master_t *master, void *arg)
Issue a bus scan.
static ATTRIBUTES int ec_ioctl_sc_clear_pdos(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Clears the PDO assignment.
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.
u64 dc_ref_time
Common reference timestamp for DC start times.
static ATTRIBUTES int ec_ioctl_voe_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Reads the received VoE data.
static ATTRIBUTES int ec_ioctl_set_send_interval(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Set max.
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.
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.
uint16_t alias
Slave alias.
static ATTRIBUTES int ec_ioctl_receive(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Receive frames.
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.
struct list_head domains
List of domains.
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_sdo_request_index(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an SDO request's SDO index and subindex.
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_sync_mon_queue(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Queue the sync monitoring datagram.
uint8_t drive_no
Drive number.
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.
uint8_t * data
Pointer to SDO data.
static ATTRIBUTES int ec_ioctl_setup_domain_memory(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets up domain memory.
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.
ec_lock_t domains_lock
Lock for access to domains list.
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.
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_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.
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.
#define EC_MAX_HOSTNAME_SIZE
Maximum hostname size.
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.
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_reg_request_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets an register request's state.
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
Provide external memory to store the domain's process data.
void 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 ecrt_sdo_request_timeout(ec_sdo_request_t *req, uint32_t timeout)
Set the timeout for an SDO request.
unsigned int sync_count
Number of sync managers.
static ATTRIBUTES int ec_ioctl_64bit_ref_clock_time(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the 64bit system time of the reference clock.
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)
char * key
Flag key (null-terminated ASCII string.
int ecrt_slave_config_flag(ec_slave_config_t *sc, const char *key, int32_t value)
Adds a feature flag to a slave configuration.
uint16_t std_rx_mailbox_size
Standard receive mailbox size.
static ATTRIBUTES int ec_ioctl_sc_create_sdo_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create an SDO request.
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.
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.
static ATTRIBUTES int ec_ioctl_slave_reg_read(ec_master_t *master, void *arg)
Read a slave's registers.
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.
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.
ec_direction_t dir
Direction.
EtherCAT master structure.
uint8_t * data
Memory for the process data.
int ecrt_master_64bit_reference_clock_time(ec_master_t *master, uint64_t *time)
Get the 64 bit DC reference slave clock time.
void * cb_data
Current callback data.
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT]
DC sync signals.
static ATTRIBUTES int ec_ioctl_master_link_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the link state.
#define EC_MASTER_DBG(master, level, fmt, args...)
Convenience macro for printing master-specific debug messages to syslog.
uint16_t boot_tx_mailbox_offset
Bootstrap transmit mailbox address.
static ATTRIBUTES int ec_ioctl_sync_mon_process(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Processes the sync monitoring datagram.
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.
ec_slave_t * slave
EtherCAT slave.
uint16_t index
PDO entry index.
uint8_t loop_closed
Loop closed.
static ATTRIBUTES int ec_ioctl_voe_exec(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Executes the VoE state machine.
ec_lock_t device_sem
Device semaphore.
unsigned int ec_pdo_entry_count(const ec_pdo_t *pdo)
Get the number of PDO entries.
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.
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_slave_sdo_entry(ec_master_t *master, void *arg)
Get slave SDO entry information.
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.
const ec_domain_t * domain
Domain.
char * description
Description.
int ec_master_debug_level(ec_master_t *master, unsigned int level)
Set the debug level.
Slave configuration state.
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_reg_write(ec_master_t *master, void *arg)
Write a slave's registers.
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_sdo_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SDO write operation.
void(* state)(ec_voe_handler_t *)
State function.
struct list_head reg_requests
List of register requests.
ec_master_phase_t phase
Master phase.
static ATTRIBUTES int ec_ioctl_64bit_ref_clock_time_queue(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Queue the 64bit dc reference slave clock datagram.
static ATTRIBUTES int ec_ioctl_slave_eoe_ip_param(ec_master_t *master, void *arg)
Request EoE IP parameter setting.
static ATTRIBUTES int ec_ioctl_master_debug(ec_master_t *master, void *arg)
Set master debug level.
static ATTRIBUTES int ec_ioctl_reset(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Reset configuration.
uint8_t * buffer
Pointer to 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.
uint8_t sync_index
Index of sync manager to use.
Slave configutation feature flag.
static ATTRIBUTES int ec_ioctl_sdo_request_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Read SDO data.
static ATTRIBUTES int ec_ioctl_sc_flag(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures a feature flag.
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.
size_t data_size
Size of SDO data.
static ATTRIBUTES int ec_ioctl_reg_request_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Read register data.
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.
static ATTRIBUTES int ec_ioctl_slave_sdo_upload(ec_master_t *master, void *arg)
Upload SDO.
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
uint16_t std_rx_mailbox_offset
Standard receive mailbox address.
static ATTRIBUTES int ec_ioctl_sync_ref(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the reference clock.
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.
static ATTRIBUTES int ec_ioctl_module(void *arg)
Get module information.
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.
void(* receive_cb)(void *)
Current receive datagrams callback.
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.
unsigned int index
Index (just a number).
s32 tx_byte_rates[EC_RATE_COUNT]
Transmit rates in byte/s for different statistics cycle periods.
#define ATTRIBUTES
Optional compiler attributes fo ioctl() functions.
uint16_t watchdog_intervals
Process data watchdog intervals (see spec.
static ATTRIBUTES int ec_ioctl_slave_sdo_download(ec_master_t *master, void *arg)
Download SDO.
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_master(ec_master_t *master, void *arg)
Get master information.
static ATTRIBUTES int ec_ioctl_sc_emerg_clear(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Clear the emergency ring.
Vendor specific over EtherCAT handler.
unsigned int active
Master has been activated.
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe)
Execute the handler.
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.
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.
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.
#define EC_IOCTL
ioctl() function to use.
void ec_foe_request_init(ec_foe_request_t *req, uint8_t *file_name)
FoE request constructor.
u64 tx_count
Number of frames sent.
static ATTRIBUTES int ec_ioctl_domain_process(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Process the domain.
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_sc_allow_overlapping_pdos(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configure wether a slave allows overlapping PDOs.
#define EC_MASTER_ERR(master, fmt, args...)
Convenience macro for printing master-specific errors to syslog.
uint8_t subindex
PDO entry subindex.
static ATTRIBUTES int ec_ioctl_select_ref_clock(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Select the DC reference clock.
uint8_t control_register
Control register value.
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.
static ATTRIBUTES int ec_ioctl_config_pdo_entry(ec_master_t *master, void *arg)
Get slave configuration PDO entry information.
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.
static ATTRIBUTES int ec_ioctl_domain_fmmu(ec_master_t *master, void *arg)
Get domain FMMU information.
static ATTRIBUTES int ec_ioctl_domain(ec_master_t *master, void *arg)
Get domain information.
uint16_t data_type
Data type.
static ATTRIBUTES int ec_ioctl_sc_watchdog(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configure a slave's watchdogs.
static ATTRIBUTES int ec_ioctl_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Request the master from userspace.
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.
static ATTRIBUTES int ec_ioctl_sync_ref_to(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the reference clock.
unsigned int opened
net_device is opened
static ATTRIBUTES int ec_ioctl_create_slave_config(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a slave 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.
static ATTRIBUTES int ec_ioctl_domain_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the domain state.
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.
size_t data_size
Size of FoE data.
static ATTRIBUTES int ec_ioctl_master_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the master state.
void ecrt_master_sync_monitor_queue(ec_master_t *master)
Queues the DC synchrony monitoring datagram for sending.
void ecrt_master_deactivate_slaves(ec_master_t *master)
Deactivates the slaves distributed clocks and sends the slaves into PREOP.
static ATTRIBUTES int ec_ioctl_sync_slaves(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sync the slave clocks.
void ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size)
Start a VoE write operation.
Ethernet-over-EtherCAT set IP parameter request.
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.
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
static ATTRIBUTES int ec_ioctl_config_sdo(ec_master_t *master, void *arg)
Get slave configuration SDO information.
uint8_t subindex
SDO subindex.
static ATTRIBUTES int ec_ioctl_domain_size(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets the domain's data size.
uint16_t expected_working_counter
Expected working counter.
uint8_t allow_overlapping_pdos
Allow input PDOs use the same frame space as output PDOs.
static ATTRIBUTES int ec_ioctl_config(ec_master_t *master, void *arg)
Get slave configuration 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.
ec_lock_t master_sem
Master semaphore.
ec_internal_request_state_t state
Request state.
static ATTRIBUTES int ec_ioctl_slave_sdo(ec_master_t *master, void *arg)
Get slave SDO information.
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.
struct list_head foe_requests
FoE requests.
ec_direction_t dir
Direction.
u64 tx_bytes
Number of bytes sent.
static ATTRIBUTES int ec_ioctl_slave(ec_master_t *master, void *arg)
Get slave information.
int ecrt_master_activate(ec_master_t *master)
Finishes the configuration phase and prepares for cyclic operation.
uint16_t ec_master_eoe_handler_count(const ec_master_t *master)
Get the number of EoE handlers.
static ATTRIBUTES int ec_ioctl_slave_sync(ec_master_t *master, void *arg)
Get slave sync manager information.
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.
size_t ecrt_master_send(ec_master_t *master)
Sends all datagrams in the queue.
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.
static ATTRIBUTES int ec_ioctl_slave_soe_write(ec_master_t *master, void *arg)
Write an IDN to a slave via SoE.
static ATTRIBUTES int ec_ioctl_slave_soe_read(ec_master_t *master, void *arg)
Read an SoE IDN.
static void ec_ioctl_strcpy(char *target, const char *source)
Copies a string to an ioctl structure.
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.
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_slave_t * next_slave
Connected slaves.
ec_direction_t dir
Direction.
static ATTRIBUTES int ec_ioctl_slave_foe_read(ec_master_t *master, void *arg)
Read a file from a slave via FoE.
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_emerg_size(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Set the emergency ring buffer size.
void ec_master_internal_send_cb(void *cb_data)
Internal sending callback.
ec_pdo_list_t pdos
Current PDO assignment.
int32_t value
Flag value (meaning depends on key).
static ATTRIBUTES int ec_ioctl_sc_idn(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configures an IDN.
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.
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.
size_t sii_nwords
Size of the SII contents in words.
void ecrt_slave_config_overlapping_pdos(ec_slave_config_t *sc, uint8_t allow_overlapping_pdos)
Configure whether a slave allows overlapping PDOs.
unsigned int ec_master_count(void)
Get the number of masters.
void ec_reg_request_clear(ec_reg_request_t *reg)
Register request destructor.
static ATTRIBUTES int ec_ioctl_slave_sii_read(ec_master_t *master, void *arg)
Read a slave's SII.
static ATTRIBUTES int ec_ioctl_slave_sync_pdo_entry(ec_master_t *master, void *arg)
Get slave sync manager PDO entry information.
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.
static ATTRIBUTES int ec_ioctl_reg_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an register write operation.
static ATTRIBUTES int ec_ioctl_sc_sync(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Configure a sync manager.
EtherCAT slave configuration.
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_send(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Send frames.
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.
uint32_t error_code
Error code from an FoE Error Request.
struct net_device * dev
pointer to the assigned net_device
static ATTRIBUTES int ec_ioctl_sc_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Get the slave configuration's state.
EtherCAT master character device IOCTL commands.
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.
static ATTRIBUTES int ec_ioctl_voe_send_header(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets the VoE send header.
int ecrt_master_reference_clock_time(ec_master_t *master, uint32_t *time)
Get the lower 32 bit of the reference clock system time.
static ATTRIBUTES int ec_ioctl_voe_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts a VoE write operation.
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.
void ecrt_master_64bit_reference_clock_time_queue(ec_master_t *master)
Queues the 64 bit DC reference slave clock time value datagram for sending.
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 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.
uint32_t password
Password needed for FoE.
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.
static ATTRIBUTES int ec_ioctl_slave_foe_write(ec_master_t *master, void *arg)
Write a file to a slave via FoE.
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.
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.
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.
static ATTRIBUTES int ec_ioctl_deactivate(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Deactivates the master.
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.
static ATTRIBUTES int ec_ioctl_eoe_handler(ec_master_t *master, void *arg)
Get EoE handler information.
static ATTRIBUTES int ec_ioctl_slave_dict_upload(ec_master_t *master, void *arg)
Upload Dictionary.
#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.
static ATTRIBUTES int ec_ioctl_create_domain(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a domain.
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.
void ecrt_master_sync_reference_clock(ec_master_t *master)
Queues the DC reference clock drift compensation datagram for sending.
uint8_t link_up
Link detected.
static ATTRIBUTES int ec_ioctl_slave_state(ec_master_t *master, void *arg)
Set slave state.
static ATTRIBUTES int ec_ioctl_activate(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Activates the master.
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
ec_device_t devices[EC_MAX_NUM_DEVICES]
EtherCAT devices.
u64 tx_bytes
Number of bytes sent.
static ATTRIBUTES int ec_ioctl_sc_create_reg_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create a register request.
#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.
struct list_head list
List item.
ec_lock_t io_sem
Semaphore protecting the datagram_queue.
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.
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.
void(* send_cb)(void *)
Current send datagrams callback.
struct net_device * dev
net_device for virtual ethernet device
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.
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].
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.
struct list_head list
List item.
unsigned int has_general
General category present.
unsigned int tx_queued_frames
number of frames in the queue
void ecrt_master_receive(ec_master_t *master)
Fetches received frames from the hardware and processes the datagrams.
Sercos-over-EtherCAT request.
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.