Link-State im Device.

This commit is contained in:
Florian Pose 2006-03-02 11:19:27 +00:00
parent 3a98ea9715
commit 0ffbd968a6
6 changed files with 41 additions and 5 deletions

View File

@ -1471,7 +1471,12 @@ static void rtl_check_media (struct net_device *dev, unsigned int init_media)
{
struct rtl8139_private *tp = netdev_priv(dev);
if (tp->phys[0] >= 0) {
if (EtherCAT_dev_is_ec(rtl_ec_dev, dev)) {
void __iomem *ioaddr = tp->mmio_addr;
uint16_t state = RTL_R16(BasicModeStatus) & BMSR_LSTATUS;
EtherCAT_dev_link_state(rtl_ec_dev, state ? 1 : 0);
}
else if (tp->phys[0] >= 0) {
mii_check_media(&tp->mii, netif_msg_link(tp), init_media);
}
}
@ -2400,9 +2405,6 @@ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
if (EtherCAT_dev_is_ec(rtl_ec_dev, dev))
{
#if 0 // FIXME
rtl_ec_dev.intr_cnt++;
#endif
status = RTL_R16 (IntrStatus);
}
else

View File

@ -40,6 +40,7 @@ void EtherCAT_dev_unregister(unsigned int, ec_device_t *);
int EtherCAT_dev_is_ec(const ec_device_t *, const struct net_device *);
void EtherCAT_dev_state(ec_device_t *, ec_device_state_t);
void EtherCAT_dev_receive(ec_device_t *, const void *, size_t);
void EtherCAT_dev_link_state(ec_device_t *, uint8_t);
/*****************************************************************************/

View File

@ -39,6 +39,7 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT-Ger
device->isr = NULL;
device->module = NULL;
device->error_reported = 0;
device->link_state = 0; // down
if ((device->tx_skb = dev_alloc_skb(ETH_HLEN + EC_MAX_FRAME_SIZE)) == NULL) {
EC_ERR("Error allocating device socket buffer!\n");
@ -101,6 +102,7 @@ int ec_device_open(ec_device_t *device /**< EtherCAT-Ger
// Reset old device state
device->state = EC_DEVICE_STATE_READY;
device->link_state = 0;
if (device->dev->open(device->dev) == 0) device->open = 1;
@ -166,6 +168,10 @@ void ec_device_send(ec_device_t *device, /**< EtherCAT-Ger
{
struct ethhdr *eth;
if (unlikely(!device->link_state)) { // Link down
return;
}
// Framegröße auf (jetzt bekannte) Länge abschneiden
skb_trim(device->tx_skb, length);
@ -375,9 +381,26 @@ void EtherCAT_dev_receive(ec_device_t *device, /**< EtherCAT-Ger
/*****************************************************************************/
/**
Setzt einen neuen Verbindungszustand.
*/
void EtherCAT_dev_link_state(ec_device_t *device, /**< EtherCAT-Gerät */
uint8_t state /**< Verbindungszustand */
)
{
if (state != device->link_state) {
device->link_state = state;
EC_INFO("Link state changed to %s.\n", (state ? "UP" : "DOWN"));
}
}
/*****************************************************************************/
EXPORT_SYMBOL(EtherCAT_dev_is_ec);
EXPORT_SYMBOL(EtherCAT_dev_state);
EXPORT_SYMBOL(EtherCAT_dev_receive);
EXPORT_SYMBOL(EtherCAT_dev_link_state);
/*****************************************************************************/

View File

@ -43,6 +43,7 @@ struct ec_device
Verfügung stellt. */
uint8_t error_reported; /**< Zeigt an, ob ein Fehler im zyklischen Code
bereits gemeldet wurde. */
uint8_t link_state; /**< Verbindungszustand */
};
/*****************************************************************************/

View File

@ -294,7 +294,13 @@ int EtherCAT_rt_domain_xio(ec_domain_t *domain /**< Dom
domain->data + offset);
if (unlikely(ec_frame_send(frame) < 0)) {
EC_ERR("Could not send process data command!\n");
master->device.state = EC_DEVICE_STATE_READY;
master->frames_lost++;
ec_cyclic_output(master);
// Falls Link down...
ec_device_call_isr(&master->device);
return -1;
}

View File

@ -253,6 +253,9 @@ int ec_frame_send(ec_frame_t *frame /**< Rahmen zum Senden */)
unsigned int command_size, frame_size, i;
uint8_t *data;
if (unlikely(!frame->master->device.link_state))
return -1;
if (unlikely(frame->master->debug_level > 0)) {
EC_DBG("ec_frame_send\n");
}