Using kernel Ethernet constants.
authorFlorian Pose <fp@igh-essen.com>
Wed, 03 May 2006 07:19:19 +0000
changeset 211 c684b6b7adaf
parent 210 1cc6bcb1e6ae
child 212 82980deb8b00
Using kernel Ethernet constants.
master/device.c
master/globals.h
master/master.c
--- a/master/device.c	Wed Apr 26 16:43:01 2006 +0000
+++ b/master/device.c	Wed May 03 07:19:19 2006 +0000
@@ -61,7 +61,7 @@
     device->open = 0;
     device->link_state = 0; // down
 
-    if (!(device->tx_skb = dev_alloc_skb(ETH_HLEN + EC_MAX_FRAME_SIZE))) {
+    if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) {
         EC_ERR("Error allocating device socket buffer!\n");
         return -1;
     }
--- a/master/globals.h	Wed Apr 26 16:43:01 2006 +0000
+++ b/master/globals.h	Wed May 03 07:19:19 2006 +0000
@@ -53,12 +53,6 @@
  *  EtherCAT protocol
  *****************************************************************************/
 
-/** maximum size of an EtherCAT frame (without header and CRC) */
-#define EC_MAX_FRAME_SIZE 1500
-
-/** minimum size of an EtherCAT frame (without header and CRC) */
-#define EC_MIN_FRAME_SIZE 46
-
 /** size of an EtherCAT frame header */
 #define EC_FRAME_HEADER_SIZE 2
 
@@ -75,7 +69,7 @@
 #define EC_FMMU_SIZE 16
 
 /** resulting maximum data size of a single command in a frame */
-#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE - EC_FRAME_HEADER_SIZE \
+#define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \
                           - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE)
 
 /*****************************************************************************/
--- a/master/master.c	Wed Apr 26 16:43:01 2006 +0000
+++ b/master/master.c	Wed May 03 07:19:19 2006 +0000
@@ -287,7 +287,7 @@
             // does the current command fit in the frame?
             command_size = EC_COMMAND_HEADER_SIZE + command->data_size
                 + EC_COMMAND_FOOTER_SIZE;
-            if (cur_data - frame_data + command_size > EC_MAX_FRAME_SIZE) {
+            if (cur_data - frame_data + command_size > ETH_DATA_LEN) {
                 more_commands_waiting = 1;
                 break;
             }
@@ -332,7 +332,7 @@
                                    - EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000);
 
         // pad frame
-        while (cur_data - frame_data < EC_MIN_FRAME_SIZE)
+        while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN)
             EC_WRITE_U8(cur_data++, 0x00);
 
         if (unlikely(master->debug_level > 0))