Better state-dependent behaviour for EoE-capable slaves.

This commit is contained in:
Florian Pose 2006-05-26 14:28:49 +00:00
parent 7b3672d62b
commit 4950aed6eb
2 changed files with 18 additions and 5 deletions

View File

@ -250,7 +250,6 @@ int ec_eoe_send(ec_eoe_t *eoe /**< EoE handler */)
eoe->tx_offset += current_size;
eoe->tx_fragment_number++;
return 0;
}
@ -302,12 +301,15 @@ void ec_eoe_print(const ec_eoe_t *eoe /**< EoE handler */)
/**
State: RX_START.
Starts a new receiving sequence by queuing a command that checks the
slave's mailbox for a new command.
Starts a new receiving sequence by queueing a command that checks the
slave's mailbox for a new EoE command.
*/
void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */)
{
if (!eoe->slave->online || !eoe->slave->master->device->link_state)
return;
ec_slave_mbox_prepare_check(eoe->slave);
ec_master_queue_command(eoe->slave->master, &eoe->slave->mbox_command);
eoe->state = ec_eoe_state_rx_check;
@ -493,6 +495,9 @@ void ec_eoe_state_tx_start(ec_eoe_t *eoe /**< EoE handler */)
unsigned int wakeup;
#endif
if (!eoe->slave->online || !eoe->slave->master->device->link_state)
return;
spin_lock_bh(&eoe->tx_queue_lock);
if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) {
@ -601,6 +606,7 @@ int ec_eoedev_open(struct net_device *dev /**< EoE net_device */)
EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name);
else {
eoe->slave->requested_state = EC_SLAVE_STATE_OP;
eoe->slave->state_error = 0;
}
return 0;
}
@ -623,6 +629,7 @@ int ec_eoedev_stop(struct net_device *dev /**< EoE net_device */)
EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name);
else {
eoe->slave->requested_state = EC_SLAVE_STATE_INIT;
eoe->slave->state_error = 0;
}
return 0;
}

View File

@ -853,14 +853,20 @@ void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */)
coupled++;
EC_INFO("Coupling device %s to slave %i.\n",
eoe->dev->name, slave->ring_position);
if (eoe->opened)
if (eoe->opened) {
slave->requested_state = EC_SLAVE_STATE_OP;
}
else {
slave->requested_state = EC_SLAVE_STATE_INIT;
}
slave->state_error = 0;
break;
}
if (!found) {
EC_WARN("No EoE handler for slave %i!\n", slave->ring_position);
slave->requested_state = EC_SLAVE_STATE_INIT;
slave->state_error = 0;
}
}
@ -898,6 +904,7 @@ void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */)
list_for_each_entry(eoe, &master->eoe_handlers, list) {
if (eoe->slave) {
eoe->slave->requested_state = EC_SLAVE_STATE_INIT;
eoe->slave->state_error = 0;
eoe->slave = NULL;
}
}
@ -906,7 +913,6 @@ void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */)
}
/*****************************************************************************/
/**
Does the Ethernet-over-EtherCAT processing.
*/