master/device.h
branchstable-1.3
changeset 1744 7bc131b92039
parent 1739 5fcbd29151d2
child 1746 72e7507b3f1b
--- a/master/device.h	Fri Aug 10 15:08:44 2007 +0000
+++ b/master/device.h	Fri Aug 10 15:27:08 2007 +0000
@@ -47,10 +47,29 @@
 #include "../devices/ecdev.h"
 #include "globals.h"
 
-#ifdef EC_DBG_IF
+#define EC_TX_RING_SIZE 2
+
+#ifdef EC_DEBUG_IF
 #include "debug.h"
 #endif
 
+#ifdef EC_DEBUG_RING
+#define EC_DEBUG_RING_SIZE 10
+
+typedef enum {
+    TX, RX
+} ec_debug_frame_dir_t;
+
+typedef struct {
+    ec_debug_frame_dir_t dir;
+    struct timeval t;
+    unsigned int addr;
+    uint8_t data[EC_MAX_DATA_SIZE];
+    unsigned int data_size;
+} ec_debug_frame_t;
+
+#endif
+
 /*****************************************************************************/
 
 /**
@@ -63,26 +82,38 @@
 {
     ec_master_t *master; /**< EtherCAT master */
     struct net_device *dev; /**< pointer to the assigned net_device */
+    ec_pollfunc_t poll; /**< pointer to the device's poll function */
+    struct module *module; /**< pointer to the device's owning module */
     uint8_t open; /**< true, if the net_device has been opened */
-    struct sk_buff *tx_skb; /**< transmit socket buffer */
-    ec_pollfunc_t poll; /**< pointer to the device's poll function */
+    uint8_t link_state; /**< device link state */
+    struct sk_buff *tx_skb[EC_TX_RING_SIZE]; /**< transmit skb ring */
+    unsigned int tx_ring_index;
     cycles_t cycles_poll; /**< cycles of last poll */
+#ifdef EC_DEBUG_RING
+    struct timeval timeval_poll;
+#endif
     unsigned long jiffies_poll; /**< jiffies of last poll */
-    struct module *module; /**< pointer to the device's owning module */
-    uint8_t link_state; /**< device link state */
     unsigned int tx_count; /**< number of frames sent */
     unsigned int rx_count; /**< number of frames received */
-#ifdef EC_DBG_IF
+#ifdef EC_DEBUG_IF
     ec_debug_t dbg; /**< debug device */
 #endif
+#ifdef EC_DEBUG_RING
+    ec_debug_frame_t debug_frames[EC_DEBUG_RING_SIZE];
+    unsigned int debug_frame_index;
+    unsigned int debug_frame_count;
+#endif
 };
 
 /*****************************************************************************/
 
-int ec_device_init(ec_device_t *, ec_master_t *, struct net_device *,
-                   ec_pollfunc_t, struct module *);
+int ec_device_init(ec_device_t *, ec_master_t *);
 void ec_device_clear(ec_device_t *);
 
+void ec_device_attach(ec_device_t *, struct net_device *, ec_pollfunc_t,
+        struct module *);
+void ec_device_detach(ec_device_t *);
+
 int ec_device_open(ec_device_t *);
 int ec_device_close(ec_device_t *);
 
@@ -90,6 +121,12 @@
 uint8_t *ec_device_tx_data(ec_device_t *);
 void ec_device_send(ec_device_t *, size_t);
 
+#ifdef EC_DEBUG_RING
+void ec_device_debug_ring_append(ec_device_t *, ec_debug_frame_dir_t,
+        const void *, size_t);
+void ec_device_debug_ring_print(const ec_device_t *);
+#endif
+
 /*****************************************************************************/
 
 #endif