fp@145: /****************************************************************************** fp@145: * fp@145: * $Id$ fp@145: * fp@1326: * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH fp@197: * fp@197: * This file is part of the IgH EtherCAT Master. fp@197: * fp@1326: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1326: * modify it under the terms of the GNU General Public License version 2, as fp@1326: * published by the Free Software Foundation. fp@197: * fp@1326: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1326: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1326: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1326: * Public License for more details. fp@197: * fp@1326: * You should have received a copy of the GNU General Public License along fp@1326: * with the IgH EtherCAT Master; if not, write to the Free Software fp@197: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@197: * fp@1363: * --- fp@1363: * fp@1363: * The license mentioned above concerns the source code only. Using the fp@1363: * EtherCAT technology and brand is only permitted in compliance with the fp@1363: * industrial property and similar rights of Beckhoff Automation GmbH. fp@246: * fp@145: *****************************************************************************/ fp@145: fp@199: /** fp@199: \file fp@1327: Ethernet over EtherCAT (EoE) fp@199: */ fp@199: fp@199: /*****************************************************************************/ fp@199: fp@1485: #ifndef __EC_ETHERNET_H__ fp@1485: #define __EC_ETHERNET_H__ fp@1485: fp@145: #include fp@203: #include fp@2250: fp@2250: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) fp@1974: #include fp@2250: #else fp@2250: #include fp@2250: #endif fp@145: fp@145: #include "globals.h" fp@145: #include "slave.h" fp@293: #include "datagram.h" fp@145: fp@145: /*****************************************************************************/ fp@145: fp@197: /** fp@217: Queued frame structure. fp@217: */ fp@217: fp@217: typedef struct fp@217: { fp@217: struct list_head queue; /**< list item */ fp@217: struct sk_buff *skb; /**< socket buffer */ fp@217: } fp@217: ec_eoe_frame_t; fp@217: fp@217: /*****************************************************************************/ fp@217: fp@286: typedef struct ec_eoe ec_eoe_t; /**< \see ec_eoe */ fp@218: fp@217: /** fp@1327: Ethernet over EtherCAT (EoE) handler. fp@197: The master creates one of these objects for each slave that supports the fp@197: EoE protocol. fp@197: */ fp@197: fp@218: struct ec_eoe fp@145: { fp@197: struct list_head list; /**< list item */ fp@197: ec_slave_t *slave; /**< pointer to the corresponding slave */ fp@293: ec_datagram_t datagram; /**< datagram */ fp@721: unsigned int queue_datagram; /**< the datagram is ready for queuing */ fp@218: void (*state)(ec_eoe_t *); /**< state function for the state machine */ fp@203: struct net_device *dev; /**< net_device for virtual ethernet device */ fp@218: struct net_device_stats stats; /**< device statistics */ fp@235: unsigned int opened; /**< net_device is opened */ fp@344: unsigned long rate_jiffies; /**< time of last rate output */ fp@1489: fp@218: struct sk_buff *rx_skb; /**< current rx socket buffer */ fp@218: off_t rx_skb_offset; /**< current write pointer in the socket buffer */ fp@218: size_t rx_skb_size; /**< size of the allocated socket buffer memory */ fp@218: uint8_t rx_expected_fragment; /**< next expected fragment number */ fp@339: uint32_t rx_counter; /**< octets received during last second */ fp@339: uint32_t rx_rate; /**< receive rate (bps) */ fp@1489: unsigned int rx_idle; /**< Idle flag. */ fp@1489: fp@212: struct list_head tx_queue; /**< queue for frames to send */ fp@1485: unsigned int tx_queue_size; /**< Transmit queue size. */ fp@214: unsigned int tx_queue_active; /**< kernel netif queue started */ fp@218: unsigned int tx_queued_frames; /**< number of frames in the queue */ fp@1489: struct semaphore tx_queue_sem; /**< Semaphore for the send queue. */ fp@217: ec_eoe_frame_t *tx_frame; /**< current TX frame */ fp@217: uint8_t tx_frame_number; /**< number of the transmitted frame */ fp@217: uint8_t tx_fragment_number; /**< number of the fragment */ fp@218: size_t tx_offset; /**< number of octets sent */ fp@336: uint32_t tx_counter; /**< octets transmitted during last second */ fp@336: uint32_t tx_rate; /**< transmit rate (bps) */ fp@1489: unsigned int tx_idle; /**< Idle flag. */ fp@1489: fp@1486: unsigned int tries; /**< Tries. */ fp@218: }; fp@145: fp@145: /*****************************************************************************/ fp@145: fp@661: int ec_eoe_init(ec_eoe_t *, ec_slave_t *); fp@145: void ec_eoe_clear(ec_eoe_t *); fp@145: void ec_eoe_run(ec_eoe_t *); fp@721: void ec_eoe_queue(ec_eoe_t *); fp@661: int ec_eoe_is_open(const ec_eoe_t *); fp@1489: int ec_eoe_is_idle(const ec_eoe_t *); fp@145: fp@145: /*****************************************************************************/ fp@1485: fp@1485: #endif fp@1485: fp@1485: /*****************************************************************************/