fp@145: /****************************************************************************** fp@145: * fp@145: * $Id$ fp@145: * fp@197: * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH fp@197: * fp@197: * This file is part of the IgH EtherCAT Master. fp@197: * fp@197: * The IgH EtherCAT Master is free software; you can redistribute it fp@197: * and/or modify it under the terms of the GNU General Public License fp@246: * as published by the Free Software Foundation; either version 2 of the fp@246: * License, or (at your option) any later version. fp@197: * fp@197: * The IgH EtherCAT Master is distributed in the hope that it will be fp@197: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of fp@197: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the fp@197: * GNU General Public License for more details. fp@197: * fp@197: * You should have received a copy of the GNU General Public License fp@197: * along 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@246: * The right to use EtherCAT Technology is granted and comes free of fp@246: * charge under condition of compatibility of product made by fp@246: * Licensee. People intending to distribute/sell products based on the fp@246: * code, have to sign an agreement to guarantee that products using fp@246: * software based on IgH EtherCAT master stay compatible with the actual fp@246: * EtherCAT specification (which are released themselves as an open fp@246: * standard) as the (only) precondition to have the right to use EtherCAT fp@246: * Technology, IP and trade marks. fp@246: * fp@145: *****************************************************************************/ fp@145: fp@199: /** fp@199: \file fp@199: Ethernet-over-EtherCAT (EoE) fp@199: */ fp@199: fp@199: /*****************************************************************************/ fp@199: fp@145: #include fp@203: #include fp@145: fp@145: #include "../include/ecrt.h" 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@251: 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@1745: 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@1719: unsigned long rate_jiffies; /**< time of last rate output */ 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@1716: uint32_t rx_counter; /**< octets received during last second */ fp@1716: uint32_t rx_rate; /**< receive rate (bps) */ fp@212: struct list_head tx_queue; /**< queue for frames to send */ 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@212: spinlock_t tx_queue_lock; /**< spinlock 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@1716: uint32_t tx_counter; /**< octets transmitted during last second */ fp@1716: uint32_t tx_rate; /**< transmit rate (bps) */ fp@218: }; fp@145: fp@145: /*****************************************************************************/ fp@145: fp@1744: 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@1745: void ec_eoe_queue(ec_eoe_t *); fp@1744: int ec_eoe_is_open(const ec_eoe_t *); fp@145: fp@145: /*****************************************************************************/