master/ethernet.c
branchstable-1.5
changeset 2522 ec403cf308eb
parent 2421 bc2d4bf9cbe5
child 2631 827abf3c50de
equal deleted inserted replaced
2521:3d68bb0047a1 2522:ec403cf308eb
    96 /*****************************************************************************/
    96 /*****************************************************************************/
    97 
    97 
    98 /** EoE constructor.
    98 /** EoE constructor.
    99  *
    99  *
   100  * Initializes the EoE handler, creates a net_device and registers it.
   100  * Initializes the EoE handler, creates a net_device and registers it.
       
   101  *
       
   102  * \return Zero on success, otherwise a negative error code.
   101  */
   103  */
   102 int ec_eoe_init(
   104 int ec_eoe_init(
   103         ec_eoe_t *eoe, /**< EoE handler */
   105         ec_eoe_t *eoe, /**< EoE handler */
   104         ec_slave_t *slave /**< EtherCAT slave */
   106         ec_slave_t *slave /**< EtherCAT slave */
   105         )
   107         )
   244 }
   246 }
   245 
   247 
   246 /*****************************************************************************/
   248 /*****************************************************************************/
   247 
   249 
   248 /** Sends a frame or the next fragment.
   250 /** Sends a frame or the next fragment.
       
   251  *
       
   252  * \return Zero on success, otherwise a negative error code.
   249  */
   253  */
   250 int ec_eoe_send(ec_eoe_t *eoe /**< EoE handler */)
   254 int ec_eoe_send(ec_eoe_t *eoe /**< EoE handler */)
   251 {
   255 {
   252     size_t remaining_size, current_size, complete_offset;
   256     size_t remaining_size, current_size, complete_offset;
   253     unsigned int last_fragment;
   257     unsigned int last_fragment;
   383 /** State: RX_START.
   387 /** State: RX_START.
   384  *
   388  *
   385  * Starts a new receiving sequence by queueing a datagram that checks the
   389  * Starts a new receiving sequence by queueing a datagram that checks the
   386  * slave's mailbox for a new EoE datagram.
   390  * slave's mailbox for a new EoE datagram.
   387  *
   391  *
   388  * \fixme Use both devices.
   392  * \todo Use both devices.
   389  */
   393  */
   390 void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */)
   394 void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */)
   391 {
   395 {
   392     if (eoe->slave->error_flag ||
   396     if (eoe->slave->error_flag ||
   393             !eoe->slave->master->devices[EC_DEVICE_MAIN].link_state) {
   397             !eoe->slave->master->devices[EC_DEVICE_MAIN].link_state) {
   612 /** State: TX START.
   616 /** State: TX START.
   613  *
   617  *
   614  * Starts a new transmit sequence. If no data is available, a new receive
   618  * Starts a new transmit sequence. If no data is available, a new receive
   615  * sequence is started instead.
   619  * sequence is started instead.
   616  *
   620  *
   617  * \fixme Use both devices.
   621  * \todo Use both devices.
   618  */
   622  */
   619 void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */)
   623 void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */)
   620 {
   624 {
   621 #if EOE_DEBUG_LEVEL >= 2
   625 #if EOE_DEBUG_LEVEL >= 2
   622     unsigned int wakeup = 0;
   626     unsigned int wakeup = 0;
   752 /******************************************************************************
   756 /******************************************************************************
   753  *  NET_DEVICE functions
   757  *  NET_DEVICE functions
   754  *****************************************************************************/
   758  *****************************************************************************/
   755 
   759 
   756 /** Opens the virtual network device.
   760 /** Opens the virtual network device.
       
   761  *
       
   762  * \return Always zero (success).
   757  */
   763  */
   758 int ec_eoedev_open(struct net_device *dev /**< EoE net_device */)
   764 int ec_eoedev_open(struct net_device *dev /**< EoE net_device */)
   759 {
   765 {
   760     ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
   766     ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
   761     ec_eoe_flush(eoe);
   767     ec_eoe_flush(eoe);
   772 }
   778 }
   773 
   779 
   774 /*****************************************************************************/
   780 /*****************************************************************************/
   775 
   781 
   776 /** Stops the virtual network device.
   782 /** Stops the virtual network device.
       
   783  *
       
   784  * \return Always zero (success).
   777  */
   785  */
   778 int ec_eoedev_stop(struct net_device *dev /**< EoE net_device */)
   786 int ec_eoedev_stop(struct net_device *dev /**< EoE net_device */)
   779 {
   787 {
   780     ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
   788     ec_eoe_t *eoe = *((ec_eoe_t **) netdev_priv(dev));
   781     netif_stop_queue(dev);
   789     netif_stop_queue(dev);
   792 }
   800 }
   793 
   801 
   794 /*****************************************************************************/
   802 /*****************************************************************************/
   795 
   803 
   796 /** Transmits data via the virtual network device.
   804 /** Transmits data via the virtual network device.
       
   805  *
       
   806  * \return Zero on success, non-zero on failure.
   797  */
   807  */
   798 int ec_eoedev_tx(struct sk_buff *skb, /**< transmit socket buffer */
   808 int ec_eoedev_tx(struct sk_buff *skb, /**< transmit socket buffer */
   799                  struct net_device *dev /**< EoE net_device */
   809                  struct net_device *dev /**< EoE net_device */
   800                 )
   810                 )
   801 {
   811 {
   842 }
   852 }
   843 
   853 
   844 /*****************************************************************************/
   854 /*****************************************************************************/
   845 
   855 
   846 /** Gets statistics about the virtual network device.
   856 /** Gets statistics about the virtual network device.
       
   857  *
       
   858  * \return Statistics.
   847  */
   859  */
   848 struct net_device_stats *ec_eoedev_stats(
   860 struct net_device_stats *ec_eoedev_stats(
   849         struct net_device *dev /**< EoE net_device */
   861         struct net_device *dev /**< EoE net_device */
   850         )
   862         )
   851 {
   863 {