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.phase = (uint8_t) master->
phase;
133 io.active = (uint8_t) master->
active;
138 if (ec_lock_down_interruptible(&master->
device_sem)) {
147 memcpy(io.devices[dev_idx].address, device->
dev->dev_addr,
150 memcpy(io.devices[dev_idx].address, master->
macs[dev_idx],
153 io.devices[dev_idx].attached = device->
dev ? 1 : 0;
154 io.devices[dev_idx].link_state = device->
link_state ? 1 : 0;
155 io.devices[dev_idx].tx_count = device->
tx_count;
156 io.devices[dev_idx].rx_count = device->
rx_count;
157 io.devices[dev_idx].tx_bytes = device->
tx_bytes;
158 io.devices[dev_idx].rx_bytes = device->
rx_bytes;
159 io.devices[dev_idx].tx_errors = device->
tx_errors;
161 io.devices[dev_idx].tx_frame_rates[j] =
163 io.devices[dev_idx].rx_frame_rates[j] =
165 io.devices[dev_idx].tx_byte_rates[j] =
167 io.devices[dev_idx].rx_byte_rates[j] =
178 io.tx_frame_rates[j] =
180 io.rx_frame_rates[j] =
182 io.tx_byte_rates[j] =
184 io.rx_byte_rates[j] =
203 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
221 ec_ioctl_slave_t data;
225 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
229 if (ec_lock_down_interruptible(&master->
master_sem))
233 master, 0, data.position))) {
235 EC_MASTER_DBG(master, 1,
"Slave %u does not exist!\n", data.position);
267 data.vendor_id = 0x00000000;
268 data.product_code = 0x00000000;
269 data.revision_number = 0x00000000;
270 data.serial_number = 0x00000000;
271 data.boot_rx_mailbox_offset = 0x0000;
272 data.boot_rx_mailbox_size = 0x0000;
273 data.boot_tx_mailbox_offset = 0x0000;
274 data.boot_tx_mailbox_size = 0x0000;
275 data.std_rx_mailbox_offset = 0x0000;
276 data.std_rx_mailbox_size = 0x0000;
277 data.std_tx_mailbox_offset = 0x0000;
278 data.std_tx_mailbox_size = 0x0000;
279 data.mailbox_protocols = 0;
280 data.has_general_category = 0;
281 data.coe_details.enable_pdo_assign = 0;
282 data.coe_details.enable_pdo_configuration = 0;
283 data.coe_details.enable_sdo = 0;
284 data.coe_details.enable_sdo_complete_access = 0;
285 data.coe_details.enable_sdo_info = 0;
286 data.coe_details.enable_upload_at_startup = 0;
287 data.general_flags.enable_not_lrw = 0;
288 data.general_flags.enable_safeop = 0;
298 data.ports[i].desc = slave->
ports[i].
desc;
301 data.ports[i].link.signal_detected =
306 data.ports[i].next_slave =
309 data.ports[i].next_slave = 0xffff;
327 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
344 ec_ioctl_slave_sync_t data;
348 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
352 if (ec_lock_down_interruptible(&master->
master_sem))
356 master, 0, data.slave_position))) {
359 data.slave_position);
366 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
376 data.enable = sync->
enable;
380 EC_SLAVE_INFO(slave,
"No access to SII data for SyncManager %u!\n",
383 data.physical_start_address = 0;
384 data.default_size = 0;
385 data.control_register = 0;
391 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
408 ec_ioctl_slave_sync_pdo_t data;
413 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
417 if (ec_lock_down_interruptible(&master->
master_sem))
421 master, 0, data.slave_position))) {
424 data.slave_position);
431 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
438 &sync->
pdos, data.pdo_pos))) {
440 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with " 441 "position %u!\n", data.sync_index, data.pdo_pos);
445 data.index = pdo->
index;
450 EC_SLAVE_INFO(slave,
"No access to SII data for SyncManager %u!\n",
454 data.entry_count = 0;
459 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
476 ec_ioctl_slave_sync_pdo_entry_t data;
482 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
486 if (ec_lock_down_interruptible(&master->
master_sem))
490 master, 0, data.slave_position))) {
493 data.slave_position);
500 EC_SLAVE_ERR(slave,
"Sync manager %u does not exist!\n",
507 &sync->
pdos, data.pdo_pos))) {
509 EC_SLAVE_ERR(slave,
"Sync manager %u does not contain a PDO with " 510 "position %u!\n", data.sync_index, data.pdo_pos);
515 pdo, data.entry_pos))) {
517 EC_SLAVE_ERR(slave,
"PDO 0x%04X does not contain an entry with " 518 "position %u!\n", data.pdo_pos, data.entry_pos);
522 data.index = entry->
index;
528 EC_SLAVE_INFO(slave,
"No access to SII data for Sync manager %u!\n",
538 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
555 ec_ioctl_domain_t data;
557 unsigned int dev_idx;
559 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
563 if (ec_lock_down_interruptible(&master->
master_sem))
583 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
600 ec_ioctl_domain_fmmu_t data;
604 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
608 if (ec_lock_down_interruptible(&master->
master_sem))
621 " fmmu configurations.\n",
622 data.domain_index, data.fmmu_index + 1);
626 data.slave_config_alias = fmmu->
sc->
alias;
627 data.slave_config_position = fmmu->
sc->
position;
629 data.dir = fmmu->
dir;
635 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
652 ec_ioctl_domain_data_t data;
655 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
659 if (ec_lock_down_interruptible(&master->
master_sem))
669 if (domain->
data_size != data.data_size) {
676 if (copy_to_user((
void __user *) data.target, domain->
data,
697 ec_ioctl_pcap_data_t data;
707 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
711 if (ec_lock_down_interruptible(&master->
master_sem))
715 data_size = curr_data - master->
pcap_data;
723 if (data.data_size > total_size) {
724 data.data_size = total_size;
728 pcaphdr.magic_number = 0xa1b2c3d4;
729 pcaphdr.version_major = 2;
730 pcaphdr.version_minor = 4;
731 pcaphdr.thiszone = 0;
733 pcaphdr.snaplen = 65535;
735 if (copy_to_user((
void __user *) data.target, &pcaphdr,
742 if ( (data_size > 0) &&
743 (copy_to_user((
void __user *) (data.target +
sizeof(
pcap_hdr_t)),
745 copy_to_user((
void __user *) arg, &data,
sizeof(data)))) {
752 if (data.reset_data) {
800 ec_ioctl_slave_state_t data;
803 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
807 if (ec_lock_down_interruptible(&master->
master_sem))
811 master, 0, data.slave_position))) {
814 data.slave_position);
835 ec_ioctl_slave_reboot_t io;
838 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
842 if (ec_lock_down_interruptible(&master->
master_sem)) {
875 ec_ioctl_slave_sdo_t data;
879 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
883 if (ec_lock_down_interruptible(&master->
master_sem))
887 master, 0, data.slave_position))) {
890 data.slave_position);
895 slave, data.sdo_position))) {
897 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", data.sdo_position);
901 data.sdo_index = sdo->
index;
907 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
924 ec_ioctl_slave_sdo_entry_t data;
929 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
933 if (ec_lock_down_interruptible(&master->
master_sem))
937 master, 0, data.slave_position))) {
940 data.slave_position);
944 if (data.sdo_spec <= 0) {
946 slave, -data.sdo_spec))) {
948 EC_SLAVE_ERR(slave,
"SDO %u does not exist!\n", -data.sdo_spec);
953 slave, data.sdo_spec))) {
962 sdo, data.sdo_entry_subindex))) {
964 EC_SLAVE_ERR(slave,
"SDO entry 0x%04X:%02X does not exist!\n",
965 sdo->
index, data.sdo_entry_subindex);
987 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1004 ec_ioctl_slave_sdo_upload_t data;
1008 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1012 if (!(target = kmalloc(data.target_size, GFP_KERNEL))) {
1014 " for SDO upload.\n", data.target_size);
1018 if (data.complete_access) {
1020 data.sdo_index, target, data.target_size,
1021 &data.data_size, &data.abort_code);
1024 data.sdo_index, data.sdo_entry_subindex, target,
1025 data.target_size, &data.data_size, &data.abort_code);
1029 if (copy_to_user((
void __user *) data.target,
1030 target, data.data_size)) {
1038 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
1056 ec_ioctl_slave_sdo_download_t data;
1060 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1064 if (!(sdo_data = kmalloc(data.data_size, GFP_KERNEL))) {
1066 " for SDO download.\n", data.data_size);
1070 if (copy_from_user(sdo_data, (
const void __user *) data.data, data.data_size)) {
1075 if (data.complete_access) {
1077 data.sdo_index, sdo_data, data.data_size, &data.abort_code);
1080 data.sdo_index, data.sdo_entry_subindex, sdo_data,
1081 data.data_size, &data.abort_code);
1086 if (__copy_to_user((
void __user *) arg, &data,
sizeof(data))) {
1104 ec_ioctl_slave_sii_t data;
1108 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1112 if (ec_lock_down_interruptible(&master->
master_sem))
1116 master, 0, data.slave_position))) {
1119 data.slave_position);
1124 EC_SLAVE_INFO(slave,
"No access to SII data. Try again!\n");
1131 EC_SLAVE_ERR(slave,
"Invalid SII read offset/size %u/%u for slave SII" 1136 if (copy_to_user((
void __user *) data.words,
1137 slave->
sii_image->words + data.offset, data.nwords * 2))
1157 ec_ioctl_slave_sii_t data;
1159 unsigned int byte_size;
1163 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1171 byte_size =
sizeof(uint16_t) * data.
nwords;
1172 if (!(words = kmalloc(byte_size, GFP_KERNEL))) {
1174 " for SII contents.\n", byte_size);
1178 if (copy_from_user(words,
1179 (
void __user *) data.words, byte_size)) {
1184 if (ec_lock_down_interruptible(&master->
master_sem)) {
1190 master, 0, data.slave_position))) {
1193 data.slave_position);
1199 INIT_LIST_HEAD(&request.
list);
1200 request.
slave = slave;
1201 request.
words = words;
1202 request.
offset = data.offset;
1203 request.
nwords = data.nwords;
1204 request.
state = EC_INT_REQUEST_QUEUED;
1213 request.
state != EC_INT_REQUEST_QUEUED)) {
1216 if (request.
state == EC_INT_REQUEST_QUEUED) {
1218 list_del(&request.
list);
1231 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1245 ec_ioctl_slave_reg_t io;
1250 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1266 if (ec_lock_down_interruptible(&master->
master_sem)) {
1272 master, 0, io.slave_position))) {
1287 request.
state != EC_INT_REQUEST_QUEUED)) {
1290 if (request.
state == EC_INT_REQUEST_QUEUED) {
1292 list_del(&request.
list);
1303 if (request.
state == EC_INT_REQUEST_SUCCESS) {
1304 if (copy_to_user((
void __user *) io.data, request.
data, io.size)) {
1310 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1324 ec_ioctl_slave_reg_t io;
1329 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1343 if (copy_from_user(request.
data, (
void __user *) io.data, io.size)) {
1350 if (ec_lock_down_interruptible(&master->
master_sem)) {
1377 request.
state != EC_INT_REQUEST_QUEUED)) {
1380 if (request.
state == EC_INT_REQUEST_QUEUED) {
1382 list_del(&request.
list);
1395 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1409 ec_ioctl_slave_reg_t io;
1414 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1428 if (copy_from_user(request.
data, (
void __user *) io.data, io.size)) {
1435 if (ec_lock_down_interruptible(&master->
master_sem)) {
1461 request.
state != EC_INT_REQUEST_QUEUED)) {
1464 if (request.
state == EC_INT_REQUEST_QUEUED) {
1466 list_del(&request.
list);
1477 if (request.
state == EC_INT_REQUEST_SUCCESS) {
1478 if (copy_to_user((
void __user *) io.data, request.
data, io.size)) {
1484 return request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1498 ec_ioctl_config_t data;
1502 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1506 if (ec_lock_down_interruptible(&master->
master_sem))
1510 master, data.config_index))) {
1517 data.alias = sc->
alias;
1524 data.syncs[i].pdo_count =
1534 data.dc_sync[i] = sc->
dc_sync[i];
1539 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1556 ec_ioctl_config_pdo_t data;
1560 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1570 if (ec_lock_down_interruptible(&master->
master_sem))
1574 master, data.config_index))) {
1589 data.index = pdo->
index;
1595 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1612 ec_ioctl_config_pdo_entry_t data;
1617 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1627 if (ec_lock_down_interruptible(&master->
master_sem))
1631 master, data.config_index))) {
1647 pdo, data.entry_pos))) {
1653 data.index = entry->
index;
1660 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1677 ec_ioctl_config_sdo_t *ioctl;
1681 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1685 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1690 if (ec_lock_down_interruptible(&master->
master_sem)) {
1696 master, ioctl->config_index))) {
1699 ioctl->config_index);
1705 sc, ioctl->sdo_pos))) {
1712 ioctl->index = req->
index;
1715 memcpy(ioctl->data, req->
data,
1716 min((u32) ioctl->size, (u32) EC_MAX_SDO_DATA_SIZE));
1721 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1741 ec_ioctl_config_idn_t *ioctl;
1745 if (!(ioctl = kmalloc(
sizeof(*ioctl), GFP_KERNEL))) {
1749 if (copy_from_user(ioctl, (
void __user *) arg,
sizeof(*ioctl))) {
1754 if (ec_lock_down_interruptible(&master->
master_sem)) {
1760 master, ioctl->config_index))) {
1763 ioctl->config_index);
1769 sc, ioctl->idn_pos))) {
1777 ioctl->idn = req->
idn;
1778 ioctl->state = req->
state;
1780 memcpy(ioctl->data, req->
data,
1781 min((u32) ioctl->size, (u32) EC_MAX_IDN_DATA_SIZE));
1785 if (copy_to_user((
void __user *) arg, ioctl,
sizeof(*ioctl))) {
1807 ec_ioctl_eoe_handler_t data;
1810 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
1814 if (ec_lock_down_interruptible(&master->
master_sem))
1827 data.slave_position = 0xffff;
1831 data.rx_bytes = eoe->
stats.rx_bytes;
1833 data.tx_bytes = eoe->
stats.tx_bytes;
1855 EC_MASTER_DBG(master, 1,
" tx_queued_frames: %u\n", data.tx_queued_frames);
1866 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
1886 ec_ioctl_slave_eoe_ip_t io;
1890 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
1897 req.mac_address_included = io.mac_address_included;
1898 req.ip_address_included = io.ip_address_included;
1899 req.subnet_mask_included = io.subnet_mask_included;
1900 req.gateway_included = io.gateway_included;
1901 req.dns_included = io.dns_included;
1902 req.name_included = io.name_included;
1904 memcpy(req.mac_address, io.mac_address, ETH_ALEN);
1905 req.ip_address = io.ip_address;
1906 req.subnet_mask = io.subnet_mask;
1907 req.gateway = io.gateway;
1911 req.
state = EC_INT_REQUEST_QUEUED;
1913 if (ec_lock_down_interruptible(&master->
master_sem)) {
1918 master, 0, io.slave_position))) {
1934 req.
state != EC_INT_REQUEST_QUEUED)) {
1937 if (req.
state == EC_INT_REQUEST_QUEUED) {
1939 list_del(&req.
list);
1949 io.result = req.result;
1951 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
1955 return req.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
1968 ec_ioctl_context_t *ctx
1986 #if defined(EC_RTDM) && defined(EC_EOE) 1996 ec_ioctl_context_t *ctx
1999 if (unlikely(!ctx->requested)) {
2003 return ec_master_eoe_is_open(master);
2016 ec_ioctl_context_t *ctx
2019 if (unlikely(!ctx->requested)) {
2023 return ec_master_eoe_process(master);
2037 ec_ioctl_context_t *ctx
2042 if (unlikely(!ctx->requested))
2047 return PTR_ERR(domain);
2049 return domain->
index;
2061 ec_ioctl_context_t *ctx
2064 ec_ioctl_config_t data;
2067 if (unlikely(!ctx->requested))
2070 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2075 data.vendor_id, data.product_code);
2079 data.config_index = 0;
2081 if (ec_lock_down_interruptible(&master->
master_sem))
2084 list_for_each_entry(entry, &master->
configs, list) {
2087 data.config_index++;
2092 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2107 ec_ioctl_context_t *ctx
2110 unsigned long config_index = (
unsigned long) arg;
2114 if (unlikely(!ctx->requested)) {
2119 if (ec_lock_down_interruptible(&master->
master_sem)) {
2124 if (config_index != 0xFFFFFFFF) {
2148 ec_ioctl_context_t *ctx
2151 ec_ioctl_master_activate_t io;
2154 #ifdef EC_IOCTL_RTDM 2158 if (unlikely(!ctx->requested))
2162 if (!ctx->process_data)
2164 io.process_data = NULL;
2168 ctx->process_data_size = 0;
2170 if (ec_lock_down_interruptible(&master->
master_sem))
2173 list_for_each_entry(domain, &master->
domains, list) {
2179 if (ctx->process_data_size) {
2180 ctx->process_data = vmalloc(ctx->process_data_size);
2181 if (!ctx->process_data) {
2182 ctx->process_data_size = 0;
2190 list_for_each_entry(domain, &master->
domains, list) {
2192 ctx->process_data + offset);
2196 #ifdef EC_IOCTL_RTDM 2203 " memory to user space (code %i).\n", ret);
2209 io.process_data_size = ctx->process_data_size;
2213 io.process_data = NULL;
2214 io.process_data_size = 0;
2218 if (copy_to_user((
void __user *) arg, &io,
2219 sizeof(ec_ioctl_master_activate_t)))
2234 ec_ioctl_context_t *ctx
2237 ec_ioctl_master_activate_t io;
2242 if (unlikely(!ctx->requested))
2246 if (!ctx->process_data)
2248 io.process_data = NULL;
2252 ctx->process_data_size = 0;
2254 if (ec_lock_down_interruptible(&master->
master_sem))
2257 list_for_each_entry(domain, &master->
domains, list) {
2263 if (ctx->process_data_size) {
2264 ctx->process_data = vmalloc(ctx->process_data_size);
2265 if (!ctx->process_data) {
2266 ctx->process_data_size = 0;
2274 list_for_each_entry(domain, &master->
domains, list) {
2276 ctx->process_data + offset);
2280 #ifdef EC_IOCTL_RTDM 2287 " memory to user space (code %i).\n", ret);
2293 io.process_data_size = ctx->process_data_size;
2297 io.process_data = NULL;
2298 io.process_data_size = 0;
2301 #ifndef EC_IOCTL_RTDM 2310 if (copy_to_user((
void __user *) arg, &io,
2311 sizeof(ec_ioctl_master_activate_t)))
2326 ec_ioctl_context_t *ctx
2329 if (unlikely(!ctx->requested))
2345 ec_ioctl_context_t *ctx
2348 if (unlikely(!ctx->requested))
2364 ec_ioctl_context_t *ctx
2367 size_t send_interval;
2369 if (unlikely(!ctx->requested)) {
2373 if (copy_from_user(&send_interval, (
void __user *) arg,
2374 sizeof(send_interval))) {
2378 if (ec_lock_down_interruptible(&master->
master_sem))
2396 ec_ioctl_context_t *ctx
2401 if (unlikely(!ctx->requested)) {
2410 #if defined(EC_RTDM) && defined(EC_EOE) 2413 if (master->
send_cb != NULL) {
2422 if (copy_to_user((
void __user *) arg, &sent_bytes,
sizeof(sent_bytes))) {
2438 ec_ioctl_context_t *ctx
2441 if (unlikely(!ctx->requested)) {
2450 #if defined(EC_RTDM) && defined(EC_EOE) 2466 #if defined(EC_RTDM) && defined(EC_EOE) 2475 ec_ioctl_context_t *ctx
2480 if (unlikely(!ctx->requested)) {
2486 if (copy_to_user((
void __user *) arg, &sent_bytes,
sizeof(sent_bytes))) {
2504 ec_ioctl_context_t *ctx
2511 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
2526 ec_ioctl_context_t *ctx
2529 ec_ioctl_link_state_t ioctl;
2533 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
2542 if (copy_to_user((
void __user *) ioctl.state, &state,
sizeof(state))) {
2558 ec_ioctl_context_t *ctx
2563 if (unlikely(!ctx->requested))
2566 if (copy_from_user(&time, (
void __user *) arg,
sizeof(time))) {
2583 ec_ioctl_context_t *ctx
2586 if (unlikely(!ctx->requested)) {
2603 ec_ioctl_context_t *ctx
2608 if (unlikely(!ctx->requested))
2611 if (copy_from_user(&time, (
void __user *) arg,
sizeof(time))) {
2628 ec_ioctl_context_t *ctx
2631 if (unlikely(!ctx->requested)) {
2648 ec_ioctl_context_t *ctx
2654 if (unlikely(!ctx->requested)) {
2663 if (copy_to_user((
void __user *) arg, &time,
sizeof(time))) {
2679 ec_ioctl_context_t *ctx
2682 if (unlikely(!ctx->requested)) {
2699 ec_ioctl_context_t *ctx
2705 if (unlikely(!ctx->requested)) {
2714 if (copy_to_user((
void __user *) arg, &time,
sizeof(time))) {
2730 ec_ioctl_context_t *ctx
2733 if (unlikely(!ctx->requested)) {
2750 ec_ioctl_context_t *ctx
2755 if (unlikely(!ctx->requested))
2760 if (copy_to_user((
void __user *) arg, &time_diff,
sizeof(time_diff)))
2776 ec_ioctl_context_t *ctx
2779 unsigned long rt_slave_requests = (
unsigned long) arg;
2782 if (unlikely(!ctx->requested)) {
2787 if (ec_lock_down_interruptible(&master->
master_sem)) {
2809 ec_ioctl_context_t *ctx
2812 if (unlikely(!ctx->requested)) {
2830 ec_ioctl_context_t *ctx
2848 ec_ioctl_context_t *ctx
2851 ec_ioctl_config_t data;
2856 if (unlikely(!ctx->requested)) {
2861 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2866 if (ec_lock_down_interruptible(&master->
master_sem)) {
2877 if (data.syncs[i].config_this) {
2879 data.syncs[i].watchdog_mode);
2901 ec_ioctl_context_t *ctx
2904 ec_ioctl_config_t data;
2908 if (unlikely(!ctx->requested)) {
2913 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2918 if (ec_lock_down_interruptible(&master->
master_sem)) {
2944 ec_ioctl_context_t *ctx
2947 ec_ioctl_config_t data;
2951 if (unlikely(!ctx->requested)) {
2956 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
2961 if (ec_lock_down_interruptible(&master->
master_sem)) {
2988 ec_ioctl_context_t *ctx
2991 ec_ioctl_config_pdo_t data;
2994 if (unlikely(!ctx->requested))
2997 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3000 if (ec_lock_down_interruptible(&master->
master_sem))
3022 ec_ioctl_context_t *ctx
3025 ec_ioctl_config_pdo_t data;
3028 if (unlikely(!ctx->requested))
3031 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3034 if (ec_lock_down_interruptible(&master->
master_sem))
3057 ec_ioctl_context_t *ctx
3060 ec_ioctl_add_pdo_entry_t data;
3063 if (unlikely(!ctx->requested))
3066 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3069 if (ec_lock_down_interruptible(&master->
master_sem))
3080 data.entry_index, data.entry_subindex, data.entry_bit_length);
3092 ec_ioctl_context_t *ctx
3095 ec_ioctl_config_pdo_t data;
3098 if (unlikely(!ctx->requested))
3101 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3104 if (ec_lock_down_interruptible(&master->
master_sem))
3127 ec_ioctl_context_t *ctx
3130 ec_ioctl_reg_pdo_entry_t data;
3135 if (unlikely(!ctx->requested))
3138 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3141 if (ec_lock_down_interruptible(&master->
master_sem))
3157 data.entry_subindex, domain, &data.bit_position);
3159 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3174 ec_ioctl_context_t *ctx
3177 ec_ioctl_reg_pdo_pos_t io;
3182 if (unlikely(!ctx->requested)) {
3186 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3190 if (ec_lock_down_interruptible(&master->
master_sem)) {
3207 io.pdo_pos, io.entry_pos, domain, &io.bit_position);
3209 if (copy_to_user((
void __user *) arg, &io,
sizeof(io)))
3224 ec_ioctl_context_t *ctx
3227 ec_ioctl_config_t data;
3230 if (unlikely(!ctx->requested))
3233 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3236 if (ec_lock_down_interruptible(&master->
master_sem))
3245 data.dc_sync[0].cycle_time,
3246 data.dc_sync[0].shift_time,
3247 data.dc_sync[1].cycle_time,
3248 data.dc_sync[1].shift_time);
3264 ec_ioctl_context_t *ctx
3267 ec_ioctl_sc_sdo_t data;
3269 uint8_t *sdo_data = NULL;
3272 if (unlikely(!ctx->requested))
3275 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3281 if (!(sdo_data = kmalloc(data.size, GFP_KERNEL))) {
3285 if (copy_from_user(sdo_data, (
void __user *) data.data, data.size)) {
3290 if (ec_lock_down_interruptible(&master->
master_sem)) {
3303 if (data.complete_access) {
3305 data.index, sdo_data, data.size);
3323 ec_ioctl_context_t *ctx
3326 ec_ioctl_sc_emerg_t io;
3330 if (unlikely(!ctx->requested))
3333 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io)))
3336 if (ec_lock_down_interruptible(&master->
master_sem)) {
3361 ec_ioctl_context_t *ctx
3364 ec_ioctl_sc_emerg_t io;
3369 if (unlikely(!ctx->requested)) {
3373 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3389 if (copy_to_user((
void __user *) io.target, msg,
sizeof(msg))) {
3405 ec_ioctl_context_t *ctx
3408 ec_ioctl_sc_emerg_t io;
3411 if (unlikely(!ctx->requested)) {
3415 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3438 ec_ioctl_context_t *ctx
3441 ec_ioctl_sc_emerg_t io;
3445 if (unlikely(!ctx->requested)) {
3449 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3467 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3483 ec_ioctl_context_t *ctx
3486 ec_ioctl_sdo_request_t data;
3490 if (unlikely(!ctx->requested))
3493 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3497 data.request_index = 0;
3499 if (ec_lock_down_interruptible(&master->
master_sem))
3509 data.request_index++;
3515 data.sdo_subindex, data.complete_access, data.size);
3517 return PTR_ERR(req);
3519 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3534 ec_ioctl_context_t *ctx
3537 ec_ioctl_foe_request_t data;
3541 if (unlikely(!ctx->requested))
3544 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3548 data.request_index = 0;
3550 if (ec_lock_down_interruptible(&master->
master_sem))
3560 data.request_index++;
3567 return PTR_ERR(req);
3569 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3584 ec_ioctl_context_t *ctx
3587 ec_ioctl_reg_request_t io;
3591 if (unlikely(!ctx->requested)) {
3595 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
3599 io.request_index = 0;
3601 if (ec_lock_down_interruptible(&master->
master_sem)) {
3619 return PTR_ERR(reg);
3622 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
3638 ec_ioctl_context_t *ctx
3641 ec_ioctl_voe_t data;
3645 if (unlikely(!ctx->requested))
3648 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3654 if (ec_lock_down_interruptible(&master->
master_sem))
3671 return PTR_ERR(voe);
3673 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
3688 ec_ioctl_context_t *ctx
3691 ec_ioctl_sc_state_t data;
3695 if (unlikely(!ctx->requested))
3698 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3711 if (copy_to_user((
void __user *) data.state, &state,
sizeof(state)))
3726 ec_ioctl_context_t *ctx
3729 ec_ioctl_sc_idn_t ioctl;
3731 uint8_t *data = NULL;
3734 if (unlikely(!ctx->requested))
3737 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl)))
3743 if (!(data = kmalloc(ioctl.size, GFP_KERNEL))) {
3747 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.size)) {
3752 if (ec_lock_down_interruptible(&master->
master_sem)) {
3766 sc, ioctl.drive_no, ioctl.idn, ioctl.al_state, data, ioctl.size);
3780 ec_ioctl_context_t *ctx
3785 if (unlikely(!ctx->requested)) {
3789 if (ec_lock_down_interruptible(&master->
master_sem)) {
3793 list_for_each_entry(domain, &master->
domains, list) {
3794 if (domain->
index == (
unsigned long) arg) {
3814 ec_ioctl_context_t *ctx
3820 if (unlikely(!ctx->requested))
3823 if (ec_lock_down_interruptible(&master->
master_sem)) {
3827 list_for_each_entry(domain, &master->
domains, list) {
3828 if (domain->
index == (
unsigned long) arg) {
3848 ec_ioctl_context_t *ctx
3853 if (unlikely(!ctx->requested))
3881 ec_ioctl_context_t *ctx
3886 if (unlikely(!ctx->requested))
3915 ec_ioctl_context_t *ctx
3918 ec_ioctl_domain_state_t data;
3922 if (unlikely(!ctx->requested))
3925 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
3938 if (copy_to_user((
void __user *) data.state, &state,
sizeof(state)))
3953 ec_ioctl_context_t *ctx
3956 ec_ioctl_sdo_request_t data;
3960 if (unlikely(!ctx->requested))
3963 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
3977 if (data.complete_access) {
3994 ec_ioctl_context_t *ctx
3997 ec_ioctl_sdo_request_t data;
4001 if (unlikely(!ctx->requested))
4004 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4031 ec_ioctl_context_t *ctx
4034 ec_ioctl_sdo_request_t data;
4038 if (unlikely(!ctx->requested))
4041 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4061 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
4076 ec_ioctl_context_t *ctx
4079 ec_ioctl_sdo_request_t data;
4083 if (unlikely(!ctx->requested))
4086 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4113 ec_ioctl_context_t *ctx
4116 ec_ioctl_sdo_request_t data;
4121 if (unlikely(!ctx->requested))
4124 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4128 EC_MASTER_ERR(master,
"SDO download: Data size may not be zero!\n");
4147 if (copy_from_user(req->
data, (
void __user *) data.data, data.size))
4164 ec_ioctl_context_t *ctx
4167 ec_ioctl_sdo_request_t data;
4171 if (unlikely(!ctx->requested))
4174 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4204 ec_ioctl_context_t *ctx
4207 ec_ioctl_foe_request_t data;
4211 if (unlikely(!ctx->requested))
4214 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4241 ec_ioctl_context_t *ctx
4244 ec_ioctl_foe_request_t data;
4248 if (unlikely(!ctx->requested))
4251 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4278 ec_ioctl_context_t *ctx
4281 ec_ioctl_foe_request_t data;
4285 if (unlikely(!ctx->requested))
4288 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4308 data.result = req->
result;
4311 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
4326 ec_ioctl_context_t *ctx
4329 ec_ioctl_foe_request_t data;
4333 if (unlikely(!ctx->requested))
4336 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4363 ec_ioctl_context_t *ctx
4366 ec_ioctl_foe_request_t data;
4371 if (unlikely(!ctx->requested))
4374 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4408 ec_ioctl_context_t *ctx
4411 ec_ioctl_foe_request_t data;
4415 if (unlikely(!ctx->requested))
4418 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4448 ec_ioctl_context_t *ctx
4451 ec_ioctl_reg_request_t io;
4455 if (unlikely(!ctx->requested)) {
4459 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4463 if (io.mem_size <= 0) {
4479 min(reg->
mem_size, io.mem_size))) {
4495 ec_ioctl_context_t *ctx
4498 ec_ioctl_reg_request_t io;
4502 if (unlikely(!ctx->requested)) {
4506 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4525 if (copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
4541 ec_ioctl_context_t *ctx
4544 ec_ioctl_reg_request_t io;
4548 if (unlikely(!ctx->requested)) {
4552 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4567 if (io.transfer_size > reg->
mem_size) {
4571 if (copy_from_user(reg->
data, (
void __user *) io.data,
4572 io.transfer_size)) {
4589 ec_ioctl_context_t *ctx
4592 ec_ioctl_reg_request_t io;
4596 if (unlikely(!ctx->requested)) {
4600 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4615 if (io.transfer_size > reg->
mem_size) {
4632 ec_ioctl_context_t *ctx
4635 ec_ioctl_reg_request_t io;
4639 if (unlikely(!ctx->requested)) {
4643 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4658 if (io.transfer_size > reg->
mem_size) {
4662 if (copy_from_user(reg->
data, (
void __user *) io.data,
4663 io.transfer_size)) {
4680 ec_ioctl_context_t *ctx
4683 ec_ioctl_voe_t data;
4687 uint16_t vendor_type;
4689 if (unlikely(!ctx->requested))
4692 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4695 if (get_user(vendor_id, data.vendor_id))
4698 if (get_user(vendor_type, data.vendor_type))
4725 ec_ioctl_context_t *ctx
4728 ec_ioctl_voe_t data;
4732 uint16_t vendor_type;
4734 if (unlikely(!ctx->requested))
4737 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4753 if (likely(data.vendor_id))
4754 if (put_user(vendor_id, data.vendor_id))
4757 if (likely(data.vendor_type))
4758 if (put_user(vendor_type, data.vendor_type))
4773 ec_ioctl_context_t *ctx
4776 ec_ioctl_voe_t data;
4780 if (unlikely(!ctx->requested))
4783 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4810 ec_ioctl_context_t *ctx
4813 ec_ioctl_voe_t data;
4817 if (unlikely(!ctx->requested))
4820 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4847 ec_ioctl_context_t *ctx
4850 ec_ioctl_voe_t data;
4854 if (unlikely(!ctx->requested))
4857 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4876 (
void __user *) data.data, data.size))
4893 ec_ioctl_context_t *ctx
4896 ec_ioctl_voe_t data;
4900 if (unlikely(!ctx->requested))
4903 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4923 if (copy_to_user((
void __user *) arg, &data,
sizeof(data)))
4938 ec_ioctl_context_t *ctx
4941 ec_ioctl_voe_t data;
4945 if (unlikely(!ctx->requested))
4948 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data)))
4980 ec_ioctl_slave_foe_t io;
4985 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
4999 if (ec_lock_down_interruptible(&master->
master_sem)) {
5012 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE read request.\n");
5021 request.
state != EC_INT_REQUEST_QUEUED)) {
5024 if (request.
state == EC_INT_REQUEST_QUEUED) {
5025 list_del(&request.
list);
5037 io.result = request.
result;
5040 if (request.
state != EC_INT_REQUEST_SUCCESS) {
5044 if (request.
data_size > io.buffer_size) {
5045 EC_SLAVE_ERR(slave,
"%s(): Buffer too small.\n", __func__);
5050 if (copy_to_user((
void __user *) io.buffer,
5051 request.
buffer, io.data_size)) {
5058 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
5077 ec_ioctl_slave_foe_t io;
5082 if (copy_from_user(&io, (
void __user *) arg,
sizeof(io))) {
5094 if (copy_from_user(request.
buffer,
5095 (
void __user *) io.buffer, io.buffer_size)) {
5103 if (ec_lock_down_interruptible(&master->
master_sem)) {
5116 EC_SLAVE_DBG(slave, 1,
"Scheduling FoE write request.\n");
5125 request.
state != EC_INT_REQUEST_QUEUED)) {
5128 if (request.
state == EC_INT_REQUEST_QUEUED) {
5130 list_del(&request.
list);
5141 io.result = request.
result;
5144 ret = request.
state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO;
5146 if (__copy_to_user((
void __user *) arg, &io,
sizeof(io))) {
5165 ec_ioctl_slave_soe_read_t ioctl;
5169 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
5173 data = kmalloc(ioctl.mem_size, GFP_KERNEL);
5175 EC_MASTER_ERR(master,
"Failed to allocate %zu bytes of IDN data.\n",
5181 ioctl.drive_no, ioctl.idn, data, ioctl.mem_size, &ioctl.data_size,
5188 if (copy_to_user((
void __user *) ioctl.data,
5189 data, ioctl.data_size)) {
5195 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
5214 ec_ioctl_slave_soe_write_t ioctl;
5218 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
5222 data = kmalloc(ioctl.data_size, GFP_KERNEL);
5224 EC_MASTER_ERR(master,
"Failed to allocate %zu bytes of IDN data.\n",
5228 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.data_size)) {
5234 ioctl.drive_no, ioctl.idn, data, ioctl.data_size,
5241 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
5259 ec_ioctl_slave_dict_upload_t data;
5262 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
5266 ret = ec_master_dict_upload(master, data.slave_position);
5282 ec_ioctl_context_t *ctx
5286 ec_ioctl_eoe_if_t data;
5288 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
5292 ret = ecrt_master_eoe_addif(master, data.alias, data.position);
5306 ec_ioctl_context_t *ctx
5310 ec_ioctl_eoe_if_t data;
5312 if (copy_from_user(&data, (
void __user *) arg,
sizeof(data))) {
5316 ret = ecrt_master_eoe_delif(master, data.alias, data.position);
5332 ec_ioctl_context_t *ctx
5335 ec_ioctl_mbox_gateway_t ioctl;
5339 if (copy_from_user(&ioctl, (
void __user *) arg,
sizeof(ioctl))) {
5349 if (ioctl.data_size > ioctl.buff_size) {
5353 data = kmalloc(ioctl.buff_size, GFP_KERNEL);
5356 " mailbox gateway data.\n", ioctl.buff_size);
5359 if (copy_from_user(data, (
void __user *) ioctl.data, ioctl.data_size)) {
5365 retval = ec_master_mbox_gateway(master, data,
5366 &ioctl.data_size, ioctl.buff_size);
5372 if (copy_to_user((
void __user *) ioctl.data,
5373 data, ioctl.data_size)) {
5379 if (__copy_to_user((
void __user *) arg, &ioctl,
sizeof(ioctl))) {
5383 EC_MASTER_DBG(master, 1,
"Finished Mailbox Gateway request.\n");
5391 #ifdef EC_IOCTL_RTDM 5392 #define EC_IOCTL ec_ioctl_rtdm 5394 #define EC_IOCTL ec_ioctl 5403 ec_ioctl_context_t *ctx,
5409 cycles_t a = get_cycles(), b;
5415 case EC_IOCTL_MODULE:
5418 case EC_IOCTL_MASTER:
5421 case EC_IOCTL_SLAVE:
5424 case EC_IOCTL_SLAVE_SYNC:
5427 case EC_IOCTL_SLAVE_SYNC_PDO:
5430 case EC_IOCTL_SLAVE_SYNC_PDO_ENTRY:
5433 case EC_IOCTL_DOMAIN:
5436 case EC_IOCTL_DOMAIN_FMMU:
5439 case EC_IOCTL_DOMAIN_DATA:
5442 case EC_IOCTL_PCAP_DATA:
5445 case EC_IOCTL_MASTER_DEBUG:
5446 if (!ctx->writable) {
5452 case EC_IOCTL_MASTER_RESCAN:
5453 if (!ctx->writable) {
5459 case EC_IOCTL_SLAVE_STATE:
5460 if (!ctx->writable) {
5466 case EC_IOCTL_SLAVE_REBOOT:
5467 if (!ctx->writable) {
5473 case EC_IOCTL_SLAVE_SDO:
5476 case EC_IOCTL_SLAVE_SDO_ENTRY:
5479 case EC_IOCTL_SLAVE_SDO_UPLOAD:
5482 case EC_IOCTL_SLAVE_SDO_DOWNLOAD:
5483 if (!ctx->writable) {
5489 case EC_IOCTL_SLAVE_SII_READ:
5492 case EC_IOCTL_SLAVE_SII_WRITE:
5493 if (!ctx->writable) {
5499 case EC_IOCTL_SLAVE_REG_READ:
5502 case EC_IOCTL_SLAVE_REG_WRITE:
5503 if (!ctx->writable) {
5509 case EC_IOCTL_SLAVE_REG_READWRITE:
5510 if (!ctx->writable) {
5516 case EC_IOCTL_SLAVE_FOE_READ:
5519 case EC_IOCTL_SLAVE_FOE_WRITE:
5520 if (!ctx->writable) {
5526 case EC_IOCTL_SLAVE_SOE_READ:
5530 case EC_IOCTL_SLAVE_EOE_IP_PARAM:
5531 if (!ctx->writable) {
5538 case EC_IOCTL_SLAVE_SOE_WRITE:
5539 if (!ctx->writable) {
5545 case EC_IOCTL_CONFIG:
5548 case EC_IOCTL_CONFIG_PDO:
5551 case EC_IOCTL_CONFIG_PDO_ENTRY:
5554 case EC_IOCTL_CONFIG_SDO:
5557 case EC_IOCTL_CONFIG_IDN:
5561 case EC_IOCTL_EOE_HANDLER:
5565 case EC_IOCTL_REQUEST:
5566 if (!ctx->writable) {
5572 #if defined(EC_RTDM) && defined(EC_EOE) 5573 case EC_IOCTL_EOE_IS_OPEN:
5574 ret = ec_ioctl_eoe_is_open(master, arg, ctx);
5576 case EC_IOCTL_EOE_PROCESS:
5577 ret = ec_ioctl_eoe_process(master, arg, ctx);
5580 case EC_IOCTL_CREATE_DOMAIN:
5581 if (!ctx->writable) {
5587 case EC_IOCTL_CREATE_SLAVE_CONFIG:
5588 if (!ctx->writable) {
5594 case EC_IOCTL_SELECT_REF_CLOCK:
5595 if (!ctx->writable) {
5601 case EC_IOCTL_SETUP_DOMAIN_MEMORY:
5602 if (!ctx->writable) {
5608 case EC_IOCTL_ACTIVATE:
5609 if (!ctx->writable) {
5615 case EC_IOCTL_DEACTIVATE_SLAVES:
5616 if (!ctx->writable) {
5622 case EC_IOCTL_DEACTIVATE:
5623 if (!ctx->writable) {
5630 if (!ctx->writable) {
5636 case EC_IOCTL_RECEIVE:
5637 if (!ctx->writable) {
5643 #if defined(EC_RTDM) && defined(EC_EOE) 5644 case EC_IOCTL_SEND_EXT:
5645 if (!ctx->writable) {
5649 ret = ec_ioctl_send_ext(master, arg, ctx);
5652 case EC_IOCTL_MASTER_STATE:
5655 case EC_IOCTL_MASTER_LINK_STATE:
5658 case EC_IOCTL_APP_TIME:
5659 if (!ctx->writable) {
5665 case EC_IOCTL_SYNC_REF:
5666 if (!ctx->writable) {
5672 case EC_IOCTL_SYNC_REF_TO:
5673 if (!ctx->writable) {
5679 case EC_IOCTL_SYNC_SLAVES:
5680 if (!ctx->writable) {
5686 case EC_IOCTL_REF_CLOCK_TIME:
5687 if (!ctx->writable) {
5693 case EC_IOCTL_64_REF_CLK_TIME_QUEUE:
5694 if (!ctx->writable) {
5700 case EC_IOCTL_64_REF_CLK_TIME:
5701 if (!ctx->writable) {
5707 case EC_IOCTL_SYNC_MON_QUEUE:
5708 if (!ctx->writable) {
5714 case EC_IOCTL_SYNC_MON_PROCESS:
5715 if (!ctx->writable) {
5721 case EC_IOCTL_RT_SLAVE_REQUESTS:
5722 if (!ctx->writable) {
5728 case EC_IOCTL_EXEC_SLAVE_REQUESTS:
5729 if (!ctx->writable) {
5735 case EC_IOCTL_RESET:
5736 if (!ctx->writable) {
5742 case EC_IOCTL_SC_SYNC:
5743 if (!ctx->writable) {
5749 case EC_IOCTL_SC_WATCHDOG:
5750 if (!ctx->writable) {
5756 case EC_IOCTL_SC_OVERLAPPING_IO:
5757 if (!ctx->writable) {
5763 case EC_IOCTL_SC_ADD_PDO:
5764 if (!ctx->writable) {
5770 case EC_IOCTL_SC_CLEAR_PDOS:
5771 if (!ctx->writable) {
5777 case EC_IOCTL_SC_ADD_ENTRY:
5778 if (!ctx->writable) {
5784 case EC_IOCTL_SC_CLEAR_ENTRIES:
5785 if (!ctx->writable) {
5791 case EC_IOCTL_SC_REG_PDO_ENTRY:
5792 if (!ctx->writable) {
5798 case EC_IOCTL_SC_REG_PDO_POS:
5799 if (!ctx->writable) {
5805 case EC_IOCTL_SC_DC:
5806 if (!ctx->writable) {
5812 case EC_IOCTL_SC_SDO:
5813 if (!ctx->writable) {
5819 case EC_IOCTL_SC_EMERG_SIZE:
5820 if (!ctx->writable) {
5826 case EC_IOCTL_SC_EMERG_POP:
5827 if (!ctx->writable) {
5833 case EC_IOCTL_SC_EMERG_CLEAR:
5834 if (!ctx->writable) {
5840 case EC_IOCTL_SC_EMERG_OVERRUNS:
5843 case EC_IOCTL_SC_SDO_REQUEST:
5844 if (!ctx->writable) {
5850 case EC_IOCTL_SC_FOE_REQUEST:
5851 if (!ctx->writable) {
5857 case EC_IOCTL_SC_REG_REQUEST:
5858 if (!ctx->writable) {
5864 case EC_IOCTL_SC_VOE:
5865 if (!ctx->writable) {
5871 case EC_IOCTL_SC_STATE:
5874 case EC_IOCTL_SC_IDN:
5875 if (!ctx->writable) {
5881 case EC_IOCTL_DOMAIN_SIZE:
5884 case EC_IOCTL_DOMAIN_OFFSET:
5887 case EC_IOCTL_DOMAIN_PROCESS:
5888 if (!ctx->writable) {
5894 case EC_IOCTL_DOMAIN_QUEUE:
5895 if (!ctx->writable) {
5901 case EC_IOCTL_DOMAIN_STATE:
5904 case EC_IOCTL_SDO_REQUEST_INDEX:
5905 if (!ctx->writable) {
5911 case EC_IOCTL_SDO_REQUEST_TIMEOUT:
5912 if (!ctx->writable) {
5918 case EC_IOCTL_SDO_REQUEST_STATE:
5921 case EC_IOCTL_SDO_REQUEST_READ:
5922 if (!ctx->writable) {
5928 case EC_IOCTL_SDO_REQUEST_WRITE:
5929 if (!ctx->writable) {
5935 case EC_IOCTL_SDO_REQUEST_DATA:
5938 case EC_IOCTL_FOE_REQUEST_FILE:
5939 if (!ctx->writable) {
5945 case EC_IOCTL_FOE_REQUEST_TIMEOUT:
5946 if (!ctx->writable) {
5952 case EC_IOCTL_FOE_REQUEST_STATE:
5955 case EC_IOCTL_FOE_REQUEST_READ:
5956 if (!ctx->writable) {
5962 case EC_IOCTL_FOE_REQUEST_WRITE:
5963 if (!ctx->writable) {
5969 case EC_IOCTL_FOE_REQUEST_DATA:
5972 case EC_IOCTL_REG_REQUEST_DATA:
5975 case EC_IOCTL_REG_REQUEST_STATE:
5978 case EC_IOCTL_REG_REQUEST_WRITE:
5979 if (!ctx->writable) {
5985 case EC_IOCTL_REG_REQUEST_READ:
5986 if (!ctx->writable) {
5992 case EC_IOCTL_REG_REQUEST_READWRITE:
5993 if (!ctx->writable) {
5999 case EC_IOCTL_VOE_SEND_HEADER:
6000 if (!ctx->writable) {
6006 case EC_IOCTL_VOE_REC_HEADER:
6009 case EC_IOCTL_VOE_READ:
6010 if (!ctx->writable) {
6016 case EC_IOCTL_VOE_READ_NOSYNC:
6017 if (!ctx->writable) {
6023 case EC_IOCTL_VOE_WRITE:
6024 if (!ctx->writable) {
6030 case EC_IOCTL_VOE_EXEC:
6031 if (!ctx->writable) {
6037 case EC_IOCTL_VOE_DATA:
6040 case EC_IOCTL_SET_SEND_INTERVAL:
6041 if (!ctx->writable) {
6047 case EC_IOCTL_SLAVE_DICT_UPLOAD:
6051 case EC_IOCTL_EOE_ADDIF:
6052 if (!ctx->writable) {
6058 case EC_IOCTL_EOE_DELIF:
6059 if (!ctx->writable) {
6066 case EC_IOCTL_MBOX_GATEWAY:
6067 if (!ctx->writable) {
6080 t = (
unsigned int) ((b - a) * 1000LL) / cpu_khz;
unsigned int tx_ring_size
Transmit ring size.
ec_request_state_t ecrt_foe_request_state(const ec_foe_request_t *req)
Get the current state of the FoE request.
static ATTRIBUTES int ec_ioctl_eoe_delif(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
delete an EOE interface
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.
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.
uint8_t upstream_port
Index of master-facing port.
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.
void ecrt_sdo_request_index_complete(ec_sdo_request_t *req, uint16_t index)
Set the SDO index and prepare for complete-access.
uint16_t boot_rx_mailbox_offset
Bootstrap receive mailbox address.
static ATTRIBUTES int ec_ioctl_foe_request_write(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an FoE write operation.
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.
uint32_t ecrt_master_sync_monitor_process(ec_master_t *master)
Processes the DC synchrony monitoring datagram.
ec_sdo_request_t * ecrt_slave_config_create_sdo_request_err(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, uint8_t complete, size_t size)
Same as ecrt_slave_config_create_sdo_request(), but with ERR_PTR() return value.
uint32_t tx_counter
octets transmitted during last second
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.
size_t ecrt_foe_request_data_size(const ec_foe_request_t *req)
Returns the data size.
static ATTRIBUTES int ec_ioctl_sdo_request_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an SDO read operation.
void * pcap_curr_data
pcap debug output current memory pointer
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.
#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.
uint8_t tx_fragment_number
number of the fragment
ec_slave_t * slave
pointer to the corresponding slave
unsigned int tx_ring_count
Transmit ring count.
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.
static ATTRIBUTES int ec_ioctl_exec_slave_requests(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Call to process slave requests explicitly from application.
void * pcap_data
pcap debug output memory pointer
struct list_head foe_requests
List of FoE requests.
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.
static ATTRIBUTES int ec_ioctl_eoe_addif(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
add an EOE interface
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.
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.
void ec_foe_request_init(ec_foe_request_t *req)
FoE request constructor.
int ec_fsm_slave_is_ready(const ec_fsm_slave_t *fsm)
Returns, if the FSM is currently not busy and ready to execute.
size_t rx_skb_size
size of the allocated socket buffer memory
ec_slave_state_t current_state
Current application state.
size_t tx_offset
number of octets sent
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.
uint32_t product_code
Slave product code.
ec_slave_port_link_t link
Port link status.
static ATTRIBUTES int ec_ioctl_pcap_data(ec_master_t *master, void *arg)
Get pcap data.
static ATTRIBUTES int ec_ioctl_foe_request_read(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an FoE read operation.
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.
size_t ecrt_master_send_ext(ec_master_t *master)
Sends non-application datagrams.
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.
unsigned int tx_queue_active
kernel netif queue started
size_t data_size
Size of FoE data.
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.
ec_fsm_slave_t fsm
Slave state machine.
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.
uint8_t link_state
device link state
static ATTRIBUTES int ec_ioctl_slave_reboot(ec_master_t *master, void *arg)
Reboot a slave (if supported).
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_foe_request_timeout(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an FoE request's timeout.
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.
void ecrt_foe_request_timeout(ec_foe_request_t *req, uint32_t timeout)
Set the request timeout.
void ecrt_foe_request_write(ec_foe_request_t *req, size_t data_size)
Prepares a write request (master to slave).
const uint8_t * macs[EC_MAX_NUM_DEVICES]
Device MAC addresses.
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)
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.
uint8_t rx_expected_fragment
next expected fragment number
size_t ecrt_foe_request_progress(const ec_foe_request_t *req)
Returns the progress of the current transfer.
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 64bit dc reference slave clock time.
void * cb_data
Current callback data.
uint8_t file_name[255]
FoE filename.
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.
int ecrt_master_sdo_upload_complete(ec_master_t *master, uint16_t slave_position, uint16_t index, 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 via complete access.
#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.
static ATTRIBUTES int ec_ioctl_mbox_gateway(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Process an EtherCAT Mailbox Gateway message.
unsigned int tx_next_to_use
index of frames added to the ring
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.
ec_sii_image_t * sii_image
Current complete SII image.
s32 rx_byte_rates[EC_RATE_COUNT]
Receive rates in byte/s for different statistics cycle periods.
void ecrt_foe_request_read(ec_foe_request_t *req)
Prepares a read request (slave to master).
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_slave_reg_readwrite(ec_master_t *master, void *arg)
Read & Write a slave's registers.
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.
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 * buffer
Pointer to FoE data.
uint8_t sync_index
Index of sync manager to use.
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_foe_request_state(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Gets an FoE request's state.
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 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.
uint8_t * ecrt_foe_request_data(ec_foe_request_t *req)
Returns a pointer to the request's data.
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.
unsigned int tx_next_to_clean
index of frames being used from the ring
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 long rate_jiffies
time of last rate output
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 have_mbox_lock
flag to track if we have the mbox lock
unsigned int index
Index (just a number).
void ecrt_reg_request_readwrite(ec_reg_request_t *reg, uint16_t address, size_t size)
Schedule a register read-write operation.
void ec_slave_request_reboot(ec_slave_t *slave)
Request a slave reboot (some slaves will ignore this).
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.
static ATTRIBUTES int ec_ioctl_foe_request_file(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Sets an FoE request's FoE filename and password.
void ecrt_master_exec_slave_requests(ec_master_t *master)
Explicit call to process slave requests.
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.
uint32_t error_code
Error code from an FoE Error Request.
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.
static ATTRIBUTES int ec_ioctl_reg_request_readwrite(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Starts an register read-write operation.
Values read and written by the master.
#define EC_IOCTL
ioctl() function to use.
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.
struct list_head list
List item.
void ecrt_foe_request_file(ec_foe_request_t *req, const char *file_name, uint32_t password)
Selects a new file for the request.
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.
ec_foe_error_t result
FoE request abort code.
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.
#define EC_MBOX_HEADER_SIZE
Mailbox header size.
ec_foe_request_t * ec_slave_config_find_foe_request(ec_slave_config_t *sc, unsigned int pos)
Finds an FoE handler via its position in the list.
#define EC_SLAVE_INFO(slave, fmt, args...)
Convenience macro for printing slave-specific information to syslog.
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.
off_t rx_skb_offset
current write pointer in the socket buffer
ec_direction_t dir
Direction.
uint16_t working_counter[EC_MAX_NUM_DEVICES]
Last working counter values.
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.
unsigned int ec_eoe_tx_queued_frames(const ec_eoe_t *eoe)
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.
static ATTRIBUTES int ec_ioctl_rt_slave_requests(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Call to set whether processing slave requests explicitly from the application is active or not...
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.
unsigned int tx_idle
Idle flag.
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.
uint32_t rx_rate
receive rate (bps)
ec_direction_t dir
Direction.
size_t buffer_size
Size of FoE data memory.
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.
ec_foe_request_t * ecrt_slave_config_create_foe_request_err(ec_slave_config_t *sc, size_t size)
Same as ecrt_slave_config_create_foe_request(), but with ERR_PTR() return value.
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.
struct sk_buff * rx_skb
current rx socket buffer
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.
uint8_t bypassed
Packets are bypassing this port (eg.
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 tx_frame_number
number of the transmitted frame
uint8_t max_subindex
Maximum subindex.
void ec_master_reboot_slaves(ec_master_t *master)
Requests that all slaves on this master be rebooted (if supported).
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.
uint32_t rx_counter
octets received during last second
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.
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.
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.
static ATTRIBUTES int ec_ioctl_foe_request_data(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Read FoE data.
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.
unsigned long pcap_size
Pcap buffer size in bytes.
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.
ec_sii_t sii
Extracted SII data.
uint16_t idn
Sercos ID-Number.
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 64bit 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.
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.
size_t nwords
Size of the SII contents in words.
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.
uint8_t scan_required
Scan required.
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.
unsigned int rx_idle
Idle flag.
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.
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].
unsigned int queue_datagram
the datagram is ready for queuing
void ecrt_sdo_request_index(ec_sdo_request_t *req, uint16_t index, uint8_t subindex)
Set the SDO index and subindex and prepare for non-complete-access.
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.
ec_internal_request_state_t state
FoE request state.
unsigned int has_general
General category present.
int ecrt_master_rt_slave_requests(ec_master_t *master, unsigned int rt_slave_requests)
Selects whether to process slave requests by the application or the master.
void ecrt_master_receive(ec_master_t *master)
Fetches received frames from the hardware and processes the datagrams.
static ATTRIBUTES int ec_ioctl_sc_create_foe_request(ec_master_t *master, void *arg, ec_ioctl_context_t *ctx)
Create an FoE request.
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.