--- a/master/globals.h Thu Jan 06 17:19:15 2011 +0100
+++ b/master/globals.h Wed Jan 12 14:56:53 2011 +0100
@@ -46,6 +46,10 @@
#endif // KERNEL_VERSION(2,6,24)
#endif // __KERNEL__
+#ifdef CONFIG_TRACING
+//#define USE_TRACE_PRINTK
+#endif
+
/******************************************************************************
* EtherCAT master
*****************************************************************************/
--- a/master/master.c Thu Jan 06 17:19:15 2011 +0100
+++ b/master/master.c Wed Jan 12 14:56:53 2011 +0100
@@ -58,7 +58,11 @@
/** Set to 1 to enable external datagram injection debugging.
*/
+#ifdef USE_TRACE_PRINTK
+#define DEBUG_INJECT 1
+#else
#define DEBUG_INJECT 0
+#endif
#ifdef EC_HAVE_CYCLES
@@ -682,7 +686,7 @@
if (queue_size <= master->max_queue_size) {
list_del_init(&datagram->queue);
#if DEBUG_INJECT
- EC_MASTER_DBG(master, 0, "Injecting fsm datagram %p"
+ EC_MASTER_DBG(master, 2, "Injecting fsm datagram %p"
" size=%zu, queue_size=%zu\n", datagram,
datagram->data_size, queue_size);
#endif
@@ -730,7 +734,7 @@
}
#if DEBUG_INJECT
else {
- EC_MASTER_DBG(master, 0, "Deferred injecting"
+ EC_MASTER_DBG(master, 2, "Deferred injecting"
" of fsm datagram %p"
" size=%zu, queue_size=%zu\n",
datagram, datagram->data_size, queue_size);
@@ -801,7 +805,7 @@
}
#if DEBUG_INJECT
- EC_MASTER_DBG(master, 0, "Requesting fsm datagram %p size=%zu\n",
+ EC_MASTER_DBG(master, 2, "Requesting fsm datagram %p size=%zu\n",
datagram, datagram->data_size);
#endif
@@ -894,8 +898,8 @@
list_add_tail(&datagram->sent, &sent_datagrams);
datagram->index = master->datagram_index++;
- EC_MASTER_DBG(master, 2, "adding datagram 0x%02X\n",
- datagram->index);
+ EC_MASTER_DBG(master, 2, "adding datagram %p i=0x%02X size=%zu\n",datagram,
+ datagram->index,datagram_size);
// set "datagram following" flag in previous frame
if (follows_word)
@@ -921,8 +925,8 @@
unsigned int frame_offset = domain_fmmu->logical_start_address-datagram_address;
memcpy(frame_datagram_data+frame_offset, domain_data, domain_fmmu->data_size);
if (unlikely(master->debug_level > 1)) {
- EC_DBG("sending dg 0x%02X fmmu %u fp=%u dp=%zu size=%u\n",
- datagram->index, i,frame_offset,domain_data-datagram->data,domain_fmmu->data_size);
+ EC_DBG("sending dg %p i=0x%02X fmmu %u fp=%u dp=%zu size=%u\n",
+ datagram,datagram->index, i,frame_offset,domain_data-datagram->data,domain_fmmu->data_size);
ec_print_data(domain_data, domain_fmmu->data_size);
}
}
@@ -1097,8 +1101,9 @@
unsigned int frame_offset = domain_fmmu->logical_start_address-datagram_address;
memcpy(domain_data, frame_datagram_data+frame_offset, domain_fmmu->data_size);
if (unlikely(master->debug_level > 1)) {
- EC_DBG("receiving dg 0x%02X fmmu %u fp=%u dp=%zu size=%u\n",
- datagram->index, i,frame_offset,domain_data-datagram->data,domain_fmmu->data_size);
+ EC_DBG("receiving dg %p i=0x%02X fmmu %u fp=%u dp=%zu size=%u\n",
+ datagram,datagram->index, i,
+ frame_offset,domain_data-datagram->data,domain_fmmu->data_size);
ec_print_data(domain_data, domain_fmmu->data_size);
}
}
@@ -1122,6 +1127,8 @@
datagram->cycles_received = master->main_device.cycles_poll;
#endif
datagram->jiffies_received = master->main_device.jiffies_poll;
+ EC_MASTER_DBG(master, 2, "removing datagram %p i=0x%02X\n",datagram,
+ datagram->index);
list_del_init(&datagram->queue);
}
}
--- a/master/master.h Thu Jan 06 17:19:15 2011 +0100
+++ b/master/master.h Wed Jan 12 14:56:53 2011 +0100
@@ -61,8 +61,16 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
+#define EC_MASTER_INFO(master, fmt, args...) \
+ do { \
+ __trace_printk(_THIS_IP_,"EtherCAT %u: " fmt, master->index, ##args); \
+ printk(KERN_INFO "EtherCAT %u: " fmt, master->index, ##args); \
+ } while (0)
+#else
#define EC_MASTER_INFO(master, fmt, args...) \
printk(KERN_INFO "EtherCAT %u: " fmt, master->index, ##args)
+#endif
/** Convenience macro for printing master-specific errors to syslog.
*
@@ -73,8 +81,16 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
+#define EC_MASTER_ERR(master, fmt, args...) \
+ do { \
+ __trace_printk(_THIS_IP_,"EtherCAT ERROR %u: " fmt, master->index, ##args); \
+ printk(KERN_ERR "EtherCAT ERROR %u: " fmt, master->index, ##args); \
+ } while (0)
+#else
#define EC_MASTER_ERR(master, fmt, args...) \
printk(KERN_ERR "EtherCAT ERROR %u: " fmt, master->index, ##args)
+#endif
/** Convenience macro for printing master-specific warnings to syslog.
*
@@ -85,8 +101,16 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
+#define EC_MASTER_WARN(master, fmt, args...) \
+ do { \
+ __trace_printk(_THIS_IP_,"EtherCAT WARNING %u: " fmt, master->index, ##args); \
+ printk(KERN_WARNING "EtherCAT WARNING %u: " fmt, master->index, ##args); \
+ } while (0)
+#else
#define EC_MASTER_WARN(master, fmt, args...) \
printk(KERN_WARNING "EtherCAT WARNING %u: " fmt, master->index, ##args)
+#endif
/** Convenience macro for printing master-specific debug messages to syslog.
*
@@ -97,13 +121,25 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
#define EC_MASTER_DBG(master, level, fmt, args...) \
do { \
+ __trace_printk(_THIS_IP_,"EtherCAT DEBUG%u %u: " fmt, \
+ level,master->index, ##args); \
if (master->debug_level >= level) { \
printk(KERN_DEBUG "EtherCAT DEBUG %u: " fmt, \
master->index, ##args); \
} \
} while (0)
+#else
+#define EC_MASTER_DBG(master, level, fmt, args...) \
+ do { \
+ if (master->debug_level >= level) { \
+ printk(KERN_DEBUG "EtherCAT DEBUG %u: " fmt, \
+ master->index, ##args); \
+ } \
+ } while (0)
+#endif
/*****************************************************************************/
--- a/master/slave.h Thu Jan 06 17:19:15 2011 +0100
+++ b/master/slave.h Wed Jan 12 14:56:53 2011 +0100
@@ -59,9 +59,19 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
+#define EC_SLAVE_INFO(slave, fmt, args...) \
+ do { \
+ __trace_printk(_THIS_IP_,"EtherCAT %u-%u: " fmt, slave->master->index, \
+ slave->ring_position, ##args); \
+ printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
+ slave->ring_position, ##args); \
+ } while (0)
+#else
#define EC_SLAVE_INFO(slave, fmt, args...) \
printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
slave->ring_position, ##args)
+#endif
/** Convenience macro for printing slave-specific errors to syslog.
*
@@ -73,9 +83,19 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
+#define EC_SLAVE_ERR(slave, fmt, args...) \
+ do { \
+ __trace_printk(_THIS_IP_,"EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
+ slave->ring_position, ##args); \
+ printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
+ slave->ring_position, ##args); \
+ } while (0)
+#else
#define EC_SLAVE_ERR(slave, fmt, args...) \
printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
slave->ring_position, ##args)
+#endif
/** Convenience macro for printing slave-specific warnings to syslog.
*
@@ -87,9 +107,19 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
+#define EC_SLAVE_WARN(slave, fmt, args...) \
+ do { \
+ __trace_printk(_THIS_IP_,"EtherCAT WARNING %u-%u: " fmt, \
+ slave->master->index, slave->ring_position, ##args); \
+ printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
+ slave->master->index, slave->ring_position, ##args); \
+ } while (0)
+#else
#define EC_SLAVE_WARN(slave, fmt, args...) \
printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
slave->master->index, slave->ring_position, ##args)
+#endif
/** Convenience macro for printing slave-specific debug messages to syslog.
*
@@ -101,13 +131,25 @@
* \param fmt format string (like in printf())
* \param args arguments (optional)
*/
+#ifdef USE_TRACE_PRINTK
#define EC_SLAVE_DBG(slave, level, fmt, args...) \
do { \
+ __trace_printk(_THIS_IP_,"EtherCAT DEBUG%u %u-%u: " fmt, \
+ level,slave->master->index, slave->ring_position, ##args); \
if (slave->master->debug_level >= level) { \
printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
slave->master->index, slave->ring_position, ##args); \
} \
} while (0)
+#else
+#define EC_SLAVE_DBG(slave, level, fmt, args...) \
+ do { \
+ if (slave->master->debug_level >= level) { \
+ printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
+ slave->master->index, slave->ring_position, ##args); \
+ } \
+ } while (0)
+#endif
/*****************************************************************************/