Added --enable-eoe conditional.
authorFlorian Pose <fp@igh-essen.com>
Wed, 12 Sep 2007 13:10:15 +0000
changeset 715 f12ff7c08623
parent 714 898f87414af1
child 716 ac2a81a33d3d
Added --enable-eoe conditional.
configure.ac
master/Kbuild
master/fsm_master.c
master/master.c
master/master.h
--- a/configure.ac	Wed Sep 12 12:30:48 2007 +0000
+++ b/configure.ac	Wed Sep 12 13:10:15 2007 +0000
@@ -414,6 +414,31 @@
 AM_CONDITIONAL(ENABLE_DUMMY, test "x$dummy" = "x1")
 
 #------------------------------------------------------------------------------
+# Ethernet-over-EtherCAT support
+#------------------------------------------------------------------------------
+
+AC_ARG_ENABLE([eoe],
+    AS_HELP_STRING([--enable-eoe],
+                   [Enable EoE support (default: yes)]),
+    [
+        case "${enableval}" in
+            yes) eoe=1
+                ;;
+            no) eoe=0
+                ;;
+            *) AC_MSG_ERROR([Invalid value for --enable-eoe])
+                ;;
+        esac
+    ],
+    [eoe=1]
+)
+
+if test "x${eoe}" = "x1"; then
+    AC_DEFINE([EC_EOE], [1], [EoE support enabled])
+fi
+AM_CONDITIONAL(ENABLE_EOE, test "x$eoe" = "x1")
+
+#------------------------------------------------------------------------------
 
 # Create config.kbuild
 
@@ -433,6 +458,7 @@
 MSR_DIR := "${msrdir}"
 ENABLE_DEBUG_IF := ${dbg}
 ENABLE_DUMMY := ${dummy}
+ENABLE_EOE := ${eoe}
 EOF
 
 #------------------------------------------------------------------------------
--- a/master/Kbuild	Wed Sep 12 12:30:48 2007 +0000
+++ b/master/Kbuild	Wed Sep 12 13:10:15 2007 +0000
@@ -36,9 +36,12 @@
 obj-m := ec_master.o
 
 ec_master-objs := module.o master.o device.o pdo.o sync.o fmmu.o slave.o \
-    datagram.o domain.o mailbox.o canopen.o ethernet.o fsm_sii.o fsm_change.o \
+    datagram.o domain.o mailbox.o canopen.o fsm_sii.o fsm_change.o \
     fsm_coe.o fsm_mapping.o fsm_slave.o fsm_master.o xmldev.o
 
+ifeq ($(ENABLE_EOE),1)
+	ec_master-objs += ethernet.o
+endif
 ifeq ($(ENABLE_DEBUG_IF),1)
 	ec_master-objs += debug.o
 endif
--- a/master/fsm_master.c	Wed Sep 12 12:30:48 2007 +0000
+++ b/master/fsm_master.c	Wed Sep 12 13:10:15 2007 +0000
@@ -41,7 +41,9 @@
 #include "globals.h"
 #include "master.h"
 #include "mailbox.h"
+#ifdef EC_EOE
 #include "ethernet.h"
+#endif
 #include "fsm_master.h"
 
 /*****************************************************************************/
@@ -238,8 +240,10 @@
             fsm->idle = 0;
             fsm->scan_jiffies = jiffies;
 
+#ifdef EC_EOE
             ec_master_eoe_stop(master);
             ec_master_clear_eoe_handlers(master);
+#endif
             ec_master_destroy_slaves(master);
 
             master->slave_count = datagram->working_counter;
@@ -812,6 +816,7 @@
     if (ec_fsm_slave_exec(&fsm->fsm_slave)) // execute slave state machine
         return;
 
+#ifdef EC_EOE
     if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
         // create EoE handler for this slave
         ec_eoe_t *eoe;
@@ -828,6 +833,7 @@
             list_add_tail(&eoe->list, &master->eoe_handlers);
         }
     }
+#endif
 
     // another slave to fetch?
     if (slave->list.next != &master->slaves) {
@@ -841,7 +847,9 @@
             (u32) (jiffies - fsm->scan_jiffies) * 1000 / HZ);
 
     // check if EoE processing has to be started
+#ifdef EC_EOE
     ec_master_eoe_start(master);
+#endif
 
     master->scan_state = EC_REQUEST_COMPLETE;
     wake_up_interruptible(&master->scan_queue);
--- a/master/master.c	Wed Sep 12 12:30:48 2007 +0000
+++ b/master/master.c	Wed Sep 12 13:10:15 2007 +0000
@@ -50,7 +50,9 @@
 #include "slave.h"
 #include "device.h"
 #include "datagram.h"
+#ifdef EC_EOE
 #include "ethernet.h"
+#endif
 
 /*****************************************************************************/
 
@@ -58,7 +60,9 @@
 void ec_master_sync_io(ec_master_t *);
 static int ec_master_idle_thread(ec_master_t *);
 static int ec_master_operation_thread(ec_master_t *);
+#ifdef EC_EOE
 void ec_master_eoe_run(unsigned long);
+#endif
 void ec_master_check_sdo(unsigned long);
 int ec_master_measure_bus_time(ec_master_t *);
 ssize_t ec_show_master_attribute(struct kobject *, struct attribute *, char *);
@@ -145,9 +149,12 @@
 
     for (i = 0; i < HZ; i++) {
         master->idle_cycle_times[i] = 0;
+#ifdef EC_EOE
         master->eoe_cycle_times[i] = 0;
+#endif
     }
     master->idle_cycle_time_pos = 0;
+#ifdef EC_EOE
     master->eoe_cycle_time_pos = 0;
 
     init_timer(&master->eoe_timer);
@@ -155,6 +162,7 @@
     master->eoe_timer.data = (unsigned long) master;
     master->eoe_running = 0;
     INIT_LIST_HEAD(&master->eoe_handlers);
+#endif
 
     master->internal_lock = SPIN_LOCK_UNLOCKED;
     master->request_cb = NULL;
@@ -228,7 +236,9 @@
         ec_master_t *master /**< EtherCAT master */
         )
 {
+#ifdef EC_EOE
     ec_master_clear_eoe_handlers(master);
+#endif
     ec_master_destroy_slaves(master);
     ec_master_destroy_domains(master);
     ec_fsm_master_clear(&master->fsm);
@@ -243,6 +253,7 @@
 
 /*****************************************************************************/
 
+#ifdef EC_EOE
 /**
  * Clear and free all EoE handlers.
  */
@@ -259,6 +270,7 @@
         kfree(eoe);
     }
 }
+#endif
 
 /*****************************************************************************/
 
@@ -394,7 +406,9 @@
 {
     master->mode = EC_MASTER_MODE_ORPHANED;
     
+#ifdef EC_EOE
     ec_master_eoe_stop(master);
+#endif
     ec_master_thread_stop(master);
     ec_master_destroy_slaves(master);
 }
@@ -408,7 +422,9 @@
 int ec_master_enter_operation_mode(ec_master_t *master /**< EtherCAT master */)
 {
     ec_slave_t *slave;
+#ifdef EC_EOE
     ec_eoe_t *eoe;
+#endif
 
     down(&master->config_sem);
     master->allow_config = 0; // temporarily disable slave configuration
@@ -442,11 +458,13 @@
     list_for_each_entry(slave, &master->slaves, list) {
         ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP);
     }
+#ifdef EC_EOE
     // ... but set EoE slaves to OP
     list_for_each_entry(eoe, &master->eoe_handlers, list) {
         if (ec_eoe_is_open(eoe))
             ec_slave_request_state(eoe->slave, EC_SLAVE_STATE_OP);
     }
+#endif
 
     if (master->debug_level)
         EC_DBG("Switching to operation mode.\n");
@@ -475,11 +493,15 @@
                                     /**< EtherCAT master */)
 {
     ec_slave_t *slave;
+#ifdef EC_EOE
     ec_eoe_t *eoe;
+#endif
 
     master->mode = EC_MASTER_MODE_IDLE;
 
+#ifdef EC_EOE
     ec_master_eoe_stop(master);
+#endif
     ec_master_thread_stop(master);
     
     master->request_cb = ec_master_request_cb;
@@ -491,17 +513,21 @@
         ec_slave_reset(slave);
         ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP);
     }
+#ifdef EC_EOE
     // ... but leave EoE slaves in OP
     list_for_each_entry(eoe, &master->eoe_handlers, list) {
         if (ec_eoe_is_open(eoe))
             ec_slave_request_state(eoe->slave, EC_SLAVE_STATE_OP);
     }
+#endif
 
     ec_master_destroy_domains(master);
     
     if (ec_master_thread_start(master, ec_master_idle_thread))
         EC_WARN("Failed to restart master thread!\n");
+#ifdef EC_EOE
     ec_master_eoe_start(master);
+#endif
 
     master->allow_scan = 1;
     master->allow_config = 1;
@@ -941,7 +967,9 @@
                        )
 {
     off_t off = 0;
+#ifdef EC_EOE
     ec_eoe_t *eoe;
+#endif
     uint32_t cur, sum, min, max, pos, i;
 
     off += sprintf(buffer + off, "\nMode: ");
@@ -990,6 +1018,7 @@
     off += sprintf(buffer + off, "  Idle cycle: %u / %u.%u / %u\n",
                    min, sum / HZ, (sum * 100 / HZ) % 100, max);
 
+#ifdef EC_EOE
     sum = 0;
     min = 0xFFFFFFFF;
     max = 0;
@@ -1010,6 +1039,7 @@
                        eoe->dev->name, eoe->rx_rate, eoe->tx_rate,
                        ((eoe->rx_rate + eoe->tx_rate) / 8 + 512) / 1024);
     }
+#endif
 
     off += sprintf(buffer + off, "\n");
 
@@ -1079,6 +1109,7 @@
 
 /*****************************************************************************/
 
+#ifdef EC_EOE
 /**
    Starts Ethernet-over-EtherCAT processing on demand.
 */
@@ -1136,6 +1167,7 @@
     cycles_t cycles_start, cycles_end;
     unsigned long restart_jiffies;
 
+
     list_for_each_entry(eoe, &master->eoe_handlers, list) {
         if (ec_eoe_is_open(eoe)) {
             none_open = 0;
@@ -1173,6 +1205,7 @@
     master->eoe_timer.expires += restart_jiffies;
     add_timer(&master->eoe_timer);
 }
+#endif
 
 /*****************************************************************************/
 
@@ -1435,7 +1468,9 @@
     }
     
     // restart EoE process and master thread with new locking
+#ifdef EC_EOE
     ec_master_eoe_stop(master);
+#endif
     ec_master_thread_stop(master);
 
     ec_master_prepare(master); // prepare asynchronous IO
@@ -1453,7 +1488,9 @@
         EC_ERR("Failed to start master thread!\n");
         return -1;
     }
+#ifdef EC_EOE
     ec_master_eoe_start(master);
+#endif
     return 0;
 }
 
--- a/master/master.h	Wed Sep 12 12:30:48 2007 +0000
+++ b/master/master.h	Wed Sep 12 13:10:15 2007 +0000
@@ -145,11 +145,13 @@
     uint32_t idle_cycle_times[HZ]; /**< Idle cycle times ring */
     unsigned int idle_cycle_time_pos; /**< time ring buffer position */
 
+#ifdef EC_EOE
     struct timer_list eoe_timer; /**< EoE timer object */
     unsigned int eoe_running; /**< non-zero, if EoE processing is active. */
     struct list_head eoe_handlers; /**< Ethernet-over-EtherCAT handlers */
     uint32_t eoe_cycle_times[HZ]; /**< EoE cycle times ring */
     unsigned int eoe_cycle_time_pos; /**< time ring buffer position */
+#endif
 
     spinlock_t internal_lock; /**< spinlock used in idle mode */
     int (*request_cb)(void *); /**< lock request callback */
@@ -185,9 +187,11 @@
 int ec_master_enter_operation_mode(ec_master_t *);
 void ec_master_leave_operation_mode(ec_master_t *);
 
+#ifdef EC_EOE
 // EoE
 void ec_master_eoe_start(ec_master_t *);
 void ec_master_eoe_stop(ec_master_t *);
+#endif
 
 // datagram IO
 void ec_master_receive_datagrams(ec_master_t *, const uint8_t *, size_t);
@@ -195,7 +199,9 @@
 
 // misc.
 void ec_master_output_stats(ec_master_t *);
+#ifdef EC_EOE
 void ec_master_clear_eoe_handlers(ec_master_t *);
+#endif
 void ec_master_destroy_slaves(ec_master_t *);
 
 /*****************************************************************************/