master/ethernet.c
changeset 261 44a3a5833c49
parent 251 c1d0b63a9302
child 279 12f48c1cb143
equal deleted inserted replaced
260:5fe7df7f2433 261:44a3a5833c49
   248     memcpy(data + 4, eoe->tx_frame->skb->data + eoe->tx_offset, current_size);
   248     memcpy(data + 4, eoe->tx_frame->skb->data + eoe->tx_offset, current_size);
   249     ec_master_queue_command(eoe->slave->master, &eoe->slave->mbox_command);
   249     ec_master_queue_command(eoe->slave->master, &eoe->slave->mbox_command);
   250 
   250 
   251     eoe->tx_offset += current_size;
   251     eoe->tx_offset += current_size;
   252     eoe->tx_fragment_number++;
   252     eoe->tx_fragment_number++;
   253 
       
   254     return 0;
   253     return 0;
   255 }
   254 }
   256 
   255 
   257 /*****************************************************************************/
   256 /*****************************************************************************/
   258 
   257 
   300  *  STATE PROCESSING FUNCTIONS
   299  *  STATE PROCESSING FUNCTIONS
   301  *****************************************************************************/
   300  *****************************************************************************/
   302 
   301 
   303 /**
   302 /**
   304    State: RX_START.
   303    State: RX_START.
   305    Starts a new receiving sequence by queuing a command that checks the
   304    Starts a new receiving sequence by queueing a command that checks the
   306    slave's mailbox for a new command.
   305    slave's mailbox for a new EoE command.
   307 */
   306 */
   308 
   307 
   309 void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */)
   308 void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */)
   310 {
   309 {
       
   310     if (!eoe->slave->online || !eoe->slave->master->device->link_state)
       
   311         return;
       
   312 
   311     ec_slave_mbox_prepare_check(eoe->slave);
   313     ec_slave_mbox_prepare_check(eoe->slave);
   312     ec_master_queue_command(eoe->slave->master, &eoe->slave->mbox_command);
   314     ec_master_queue_command(eoe->slave->master, &eoe->slave->mbox_command);
   313     eoe->state = ec_eoe_state_rx_check;
   315     eoe->state = ec_eoe_state_rx_check;
   314 }
   316 }
   315 
   317 
   491 {
   493 {
   492 #if EOE_DEBUG_LEVEL > 0
   494 #if EOE_DEBUG_LEVEL > 0
   493     unsigned int wakeup;
   495     unsigned int wakeup;
   494 #endif
   496 #endif
   495 
   497 
       
   498     if (!eoe->slave->online || !eoe->slave->master->device->link_state)
       
   499         return;
       
   500 
   496     spin_lock_bh(&eoe->tx_queue_lock);
   501     spin_lock_bh(&eoe->tx_queue_lock);
   497 
   502 
   498     if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) {
   503     if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) {
   499         spin_unlock_bh(&eoe->tx_queue_lock);
   504         spin_unlock_bh(&eoe->tx_queue_lock);
   500         // no data available.
   505         // no data available.
   599     EC_INFO("%s opened.\n", dev->name);
   604     EC_INFO("%s opened.\n", dev->name);
   600     if (!eoe->slave)
   605     if (!eoe->slave)
   601         EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name);
   606         EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name);
   602     else {
   607     else {
   603         eoe->slave->requested_state = EC_SLAVE_STATE_OP;
   608         eoe->slave->requested_state = EC_SLAVE_STATE_OP;
       
   609         eoe->slave->state_error = 0;
   604     }
   610     }
   605     return 0;
   611     return 0;
   606 }
   612 }
   607 
   613 
   608 /*****************************************************************************/
   614 /*****************************************************************************/
   621     EC_INFO("%s stopped.\n", dev->name);
   627     EC_INFO("%s stopped.\n", dev->name);
   622     if (!eoe->slave)
   628     if (!eoe->slave)
   623         EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name);
   629         EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name);
   624     else {
   630     else {
   625         eoe->slave->requested_state = EC_SLAVE_STATE_INIT;
   631         eoe->slave->requested_state = EC_SLAVE_STATE_INIT;
       
   632         eoe->slave->state_error = 0;
   626     }
   633     }
   627     return 0;
   634     return 0;
   628 }
   635 }
   629 
   636 
   630 /*****************************************************************************/
   637 /*****************************************************************************/