From bd56ead6bc2f855b89ec986bd6ba7fd5f47864c4 Mon Sep 17 00:00:00 2001 From: Florian Pose <fp@igh-essen.com> Date: Thu, 2 Mar 2006 13:08:07 +0000 Subject: [PATCH] Link-Down-Verhalten verbessert. --- devices/8139too.c | 27 +-------------------------- master/device.c | 3 +-- master/domain.c | 37 +++++++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/devices/8139too.c b/devices/8139too.c index eaa32e4a..d74a9e55 100644 --- a/devices/8139too.c +++ b/devices/8139too.c @@ -1925,18 +1925,6 @@ static void rtl8139_tx_interrupt (struct net_device *dev, dirty_tx = tp->dirty_tx; tx_left = tp->cur_tx - dirty_tx; - /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ - -#if 0 - if (EtherCAT_dev_is_ec(rtl_ec_dev, dev)) - { - rtl_ec_dev.tx_intr_cnt++; - rdtscl(rtl_ec_dev.tx_time); // Get CPU cycles - } -#endif - - /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ - while (tx_left > 0) { int entry = dirty_tx % NUM_TX_DESC; int txstatus; @@ -1967,9 +1955,7 @@ static void rtl8139_tx_interrupt (struct net_device *dev, /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ if (EtherCAT_dev_is_ec(rtl_ec_dev, dev)) - { - EtherCAT_dev_state(rtl_ec_dev, EC_DEVICE_STATE_ERROR); - } + EtherCAT_dev_state(rtl_ec_dev, EC_DEVICE_STATE_ERROR); /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ @@ -2156,17 +2142,6 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp, RTL_R16 (RxBufAddr), RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); - /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ -#if 0 - if (EtherCAT_dev_is_ec(rtl_ec_dev, dev)) - { - rtl_ec_dev.rx_intr_cnt++; - rdtscl(rtl_ec_dev.rx_time); // Get CPU cycles - } -#endif - - /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ - while ((EtherCAT_dev_is_ec(rtl_ec_dev, dev) || netif_running(dev)) && received < budget && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { diff --git a/master/device.c b/master/device.c index 8c7306a4..e4ebdf1d 100644 --- a/master/device.c +++ b/master/device.c @@ -168,9 +168,8 @@ void ec_device_send(ec_device_t *device, /**< EtherCAT-Ger { struct ethhdr *eth; - if (unlikely(!device->link_state)) { // Link down + if (unlikely(!device->link_state)) // Link down return; - } // Framegröße auf (jetzt bekannte) Länge abschneiden skb_trim(device->tx_skb, length); diff --git a/master/domain.c b/master/domain.c index 889b1d62..778b8fcd 100644 --- a/master/domain.c +++ b/master/domain.c @@ -180,6 +180,23 @@ int ec_domain_alloc(ec_domain_t *domain, /**< Dom return 0; } +/*****************************************************************************/ + +/** + Gibt die Anzahl der antwortenden Slaves aus. +*/ + +void ec_domain_response_count(ec_domain_t *domain, /**< Domäne */ + unsigned int count /**< Neue Anzahl */ + ) +{ + if (count != domain->response_count) { + domain->response_count = count; + EC_INFO("Domain %08X state change - %i slaves responding.\n", + (u32) domain, count); + } +} + /****************************************************************************** * * Echtzeitschnittstelle @@ -281,6 +298,12 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom ec_cyclic_output(master); + if (unlikely(!master->device.link_state)) { + ec_domain_response_count(domain, working_counter_sum); + ec_device_call_isr(&master->device); + return -1; + } + rdtscl(start_ticks); // Sendezeit nehmen timeout_ticks = domain->timeout_us * cpu_khz / 1000; @@ -297,10 +320,7 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom master->device.state = EC_DEVICE_STATE_READY; master->frames_lost++; ec_cyclic_output(master); - - // Falls Link down... - ec_device_call_isr(&master->device); - + ec_domain_response_count(domain, working_counter_sum); return -1; } @@ -323,12 +343,13 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom master->device.state = EC_DEVICE_STATE_READY; master->frames_lost++; ec_cyclic_output(master); + ec_domain_response_count(domain, working_counter_sum); return -1; } } if (unlikely(ec_frame_receive(frame) < 0)) { - EC_ERR("Receiving process data failed!\n"); + ec_domain_response_count(domain, working_counter_sum); return -1; } @@ -340,11 +361,7 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom offset += size; } - if (working_counter_sum != domain->response_count) { - domain->response_count = working_counter_sum; - EC_INFO("Domain %08X state change - %i slaves responding.\n", - (u32) domain, working_counter_sum); - } + ec_domain_response_count(domain, working_counter_sum); return 0; } -- GitLab