From 8812d5bf73c487112a20e231c2b1bb1a9692e775 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 22 Jan 2016 10:11:58 +0100 Subject: [PATCH 1/6] Always clear PDO assignment of configured sync managers. --- lib/slave_config.c | 3 ++- master/slave_config.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/slave_config.c b/lib/slave_config.c index 943ca2bb..d8cab06c 100644 --- a/lib/slave_config.c +++ b/lib/slave_config.c @@ -232,8 +232,9 @@ int ecrt_slave_config_pdos(ec_slave_config_t *sc, if (ret) return ret; + ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); + if (sync_info->n_pdos && sync_info->pdos) { - ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); for (j = 0; j < sync_info->n_pdos; j++) { pdo_info = &sync_info->pdos[j]; diff --git a/master/slave_config.c b/master/slave_config.c index 38347872..b0d2c934 100644 --- a/master/slave_config.c +++ b/master/slave_config.c @@ -702,8 +702,9 @@ int ecrt_slave_config_pdos(ec_slave_config_t *sc, if (ret) return ret; + ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); + if (sync_info->n_pdos && sync_info->pdos) { - ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); for (j = 0; j < sync_info->n_pdos; j++) { pdo_info = &sync_info->pdos[j]; From 1362f30a059bb44bc00a30e2e894fbdd0d6d5459 Mon Sep 17 00:00:00 2001 From: Patrick Bruenn Date: Tue, 12 Apr 2016 11:17:36 +0200 Subject: [PATCH 2/6] devices/ccat: revert "limit rx processing to one frame per poll" revert "limit rx processing to one frame per poll", which caused etherlab frame timeouts in setups with more than one frame per cycle. --- devices/ccat/module.h | 2 +- devices/ccat/netdev.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/devices/ccat/module.h b/devices/ccat/module.h index b0d139b6..529334d3 100644 --- a/devices/ccat/module.h +++ b/devices/ccat/module.h @@ -29,7 +29,7 @@ #include "../ecdev.h" #define DRV_EXTRAVERSION "-ec" -#define DRV_VERSION "0.14" DRV_EXTRAVERSION +#define DRV_VERSION "0.15" DRV_EXTRAVERSION #define DRV_DESCRIPTION "Beckhoff CCAT Ethernet/EtherCAT Network Driver" #undef pr_fmt diff --git a/devices/ccat/netdev.c b/devices/ccat/netdev.c index c8afc3c1..f104dbbf 100644 --- a/devices/ccat/netdev.c +++ b/devices/ccat/netdev.c @@ -291,7 +291,7 @@ static int ccat_dma_init(struct ccat_dma_mem *const dma, size_t channel, iowrite32((u32) phys | ((phys_hi) > 0), ioaddr); iowrite32(phys_hi, ioaddr + 4); - pr_debug + pr_info ("DMA%llu mem initialized\n base: 0x%p\n start: 0x%p\n phys: 0x%09llx\n pci addr: 0x%01x%08x\n size: %llu |%llx bytes.\n", (u64) channel, dma->base, fifo->dma.start, (u64) dma->phys, ioread32(ioaddr + 4), ioread32(ioaddr), @@ -749,12 +749,14 @@ static void poll_link(struct ccat_eth_priv *const priv) static void poll_rx(struct ccat_eth_priv *const priv) { struct ccat_eth_fifo *const fifo = &priv->rx_fifo; - const size_t len = fifo->ops->ready(fifo); + size_t rx_per_poll = FIFO_LENGTH / 2; + size_t len = fifo->ops->ready(fifo); - if (len) { + while (len && --rx_per_poll) { priv->receive(priv, len); fifo->ops->add(fifo); ccat_eth_fifo_inc(fifo); + len = fifo->ops->ready(fifo); } } From 8f599d1eb8cd3b56a85e7ab3d6deba87b036a218 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 16 Sep 2016 11:56:10 +0200 Subject: [PATCH 3/6] Always clear PDO mapping in ecrt_slave_config_pdos(). --- lib/slave_config.c | 4 ++-- master/slave_config.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/slave_config.c b/lib/slave_config.c index d8cab06c..6a2c4cc0 100644 --- a/lib/slave_config.c +++ b/lib/slave_config.c @@ -244,9 +244,9 @@ int ecrt_slave_config_pdos(ec_slave_config_t *sc, if (ret) return ret; - if (pdo_info->n_entries && pdo_info->entries) { - ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index); + ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index); + if (pdo_info->n_entries && pdo_info->entries) { for (k = 0; k < pdo_info->n_entries; k++) { entry_info = &pdo_info->entries[k]; diff --git a/master/slave_config.c b/master/slave_config.c index b0d2c934..cf5d501f 100644 --- a/master/slave_config.c +++ b/master/slave_config.c @@ -714,9 +714,9 @@ int ecrt_slave_config_pdos(ec_slave_config_t *sc, if (ret) return ret; - if (pdo_info->n_entries && pdo_info->entries) { - ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index); + ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index); + if (pdo_info->n_entries && pdo_info->entries) { for (k = 0; k < pdo_info->n_entries; k++) { entry_info = &pdo_info->entries[k]; From 545d4e548c6ae18d190182e76260103dc8734912 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 16 Sep 2016 12:35:09 +0200 Subject: [PATCH 4/6] Use SYNC0 + SYNC1 cycle times for cyclic start time generation. --- master/fsm_slave_config.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/master/fsm_slave_config.c b/master/fsm_slave_config.c index 2ca63f0c..5c968768 100644 --- a/master/fsm_slave_config.c +++ b/master/fsm_slave_config.c @@ -1365,6 +1365,7 @@ void ec_fsm_slave_config_state_dc_sync_check( uint32_t abs_sync_diff; unsigned long diff_ms; ec_sync_signal_t *sync0 = &config->dc_sync[0]; + ec_sync_signal_t *sync1 = &config->dc_sync[1]; u64 start_time; if (!config) { // config removed in the meantime @@ -1420,19 +1421,19 @@ void ec_fsm_slave_config_state_dc_sync_check( // find correct phase if (master->has_app_time) { u64 diff, start; - u32 remainder; + u32 remainder, cycle; diff = start_time - master->app_start_time; - remainder = do_div(diff, sync0->cycle_time); + cycle = sync0->cycle_time + sync1->cycle_time; + remainder = do_div(diff, cycle); - start = start_time + - sync0->cycle_time - remainder + sync0->shift_time; + start = start_time + cycle - remainder + sync0->shift_time; EC_SLAVE_DBG(slave, 1, "app_start_time=%llu\n", master->app_start_time); EC_SLAVE_DBG(slave, 1, " app_time=%llu\n", master->app_time); EC_SLAVE_DBG(slave, 1, " start_time=%llu\n", start_time); - EC_SLAVE_DBG(slave, 1, " cycle_time=%u\n", sync0->cycle_time); + EC_SLAVE_DBG(slave, 1, " cycle=%u\n", cycle); EC_SLAVE_DBG(slave, 1, " shift_time=%i\n", sync0->shift_time); EC_SLAVE_DBG(slave, 1, " remainder=%u\n", remainder); EC_SLAVE_DBG(slave, 1, " start=%llu\n", start); From b6cace3df1f501c89dbc91daa90008b40f04938c Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 18 Oct 2016 10:20:21 +0200 Subject: [PATCH 5/6] Support changed tty_prepare_flip_string() interface from kernel 3.9. --- tty/module.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tty/module.c b/tty/module.c index f512c6b3..48058a9d 100644 --- a/tty/module.c +++ b/tty/module.c @@ -337,7 +337,11 @@ void ec_tty_wakeup(unsigned long data) to_recv = ec_tty_rx_size(tty); if (to_recv && tty->tty) { unsigned char *cbuf; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) + int space = tty_prepare_flip_string(tty->tty->port, &cbuf, to_recv); +#else int space = tty_prepare_flip_string(tty->tty, &cbuf, to_recv); +#endif if (space < to_recv) { printk(KERN_WARNING PFX "Insufficient space to_recv=%d space=%d\n", @@ -362,7 +366,11 @@ void ec_tty_wakeup(unsigned long data) tty->rx_read_idx = (tty->rx_read_idx + 1) % EC_TTY_RX_BUFFER_SIZE; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) + tty_flip_buffer_push(tty->tty->port); +#else tty_flip_buffer_push(tty->tty); +#endif } } From 5281569032d4cecb75e2849cebc363f822bdd77c Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 18 Oct 2016 10:20:47 +0200 Subject: [PATCH 6/6] Support changed sock_create_kern() interface from Linux 4.2. --- devices/generic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devices/generic.c b/devices/generic.c index 63c4aba2..0feab284 100644 --- a/devices/generic.c +++ b/devices/generic.c @@ -212,8 +212,13 @@ int ec_gen_device_create_socket( return -ENOMEM; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) + ret = sock_create_kern(&init_net, PF_PACKET, SOCK_RAW, + htons(ETH_P_ETHERCAT), &dev->socket); +#else ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT), &dev->socket); +#endif if (ret) { printk(KERN_ERR PFX "Failed to create socket (ret = %i).\n", ret); return ret;