# HG changeset patch # User Florian Pose # Date 1168612113 0 # Node ID acdd1f9ef7ab93df7a16803a7b58ff3a9320d4a0 # Parent 092ac0fa23fed6a3d660c23fa29f243fbb8d329c Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers. diff -r 092ac0fa23fe -r acdd1f9ef7ab NEWS --- a/NEWS Fri Jan 12 12:50:52 2007 +0000 +++ b/NEWS Fri Jan 12 14:28:33 2007 +0000 @@ -6,7 +6,7 @@ Changes in version 1.2.0: -* Interface changes: +* Realtime interface changes: - Re-introduced ecrt_domain_queue() to allow datagram queuing apart from datagram processing. The queuing of a domain's datagrams is not done in ecrt_domain_process() any more! @@ -20,6 +20,10 @@ ecrt_domain_register_pdo_list() and ecrt_domain_register_pdo_range() may not be NULL any more. - Removed ecrt_slave_pdo_size(). This function was deprecated long before. +* Device interface changes: + - ec_isr_t was replaced by ec_pollfunc_t, the device driver has to supply + a poll function to call its ISR. This was introduced because some network + drivers' interrupt functions have different arguments. * State machines now try to re-send datagrams on datagram timeout. * New option -c of the lsec script, displays slave current consumptions and remaining current. diff -r 092ac0fa23fe -r acdd1f9ef7ab devices/8139too-2.6.13-ethercat.c --- a/devices/8139too-2.6.13-ethercat.c Fri Jan 12 12:50:52 2007 +0000 +++ b/devices/8139too-2.6.13-ethercat.c Fri Jan 12 14:28:33 2007 +0000 @@ -709,6 +709,9 @@ #ifdef CONFIG_NET_POLL_CONTROLLER static void rtl8139_poll_controller(struct net_device *dev); #endif +/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ +void ec_poll(struct net_device *); +/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance, struct pt_regs *regs); static int rtl8139_close (struct net_device *dev); @@ -2337,6 +2340,15 @@ return !done; } +/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ + +void ec_poll(struct net_device *dev) +{ + rtl8139_interrupt(0, dev, NULL); +} + +/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ + /* The interrupt handler does all of the Rx thread work and cleans up after the Tx thread. */ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance, @@ -2903,7 +2915,7 @@ if (rtl_ec_net_dev) { printk(KERN_INFO "Registering EtherCAT device...\n"); if (!(rtl_ec_dev = ecdev_register(ec_device_master_index, - rtl_ec_net_dev, rtl8139_interrupt, THIS_MODULE))) { + rtl_ec_net_dev, ec_poll, THIS_MODULE))) { printk(KERN_ERR "Failed to register EtherCAT device!\n"); goto out_pci; } diff -r 092ac0fa23fe -r acdd1f9ef7ab devices/8139too-2.6.17-ethercat.c --- a/devices/8139too-2.6.17-ethercat.c Fri Jan 12 12:50:52 2007 +0000 +++ b/devices/8139too-2.6.17-ethercat.c Fri Jan 12 14:28:33 2007 +0000 @@ -711,6 +711,9 @@ #ifdef CONFIG_NET_POLL_CONTROLLER static void rtl8139_poll_controller(struct net_device *dev); #endif +/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ +void ec_poll(struct net_device *); +/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance, struct pt_regs *regs); static int rtl8139_close (struct net_device *dev); @@ -2344,6 +2347,15 @@ return !done; } +/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ + +void ec_poll(struct net_device *dev) +{ + rtl8139_interrupt(0, dev, NULL); +} + +/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ + /* The interrupt handler does all of the Rx thread work and cleans up after the Tx thread. */ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance, @@ -2901,7 +2913,7 @@ if (rtl_ec_net_dev) { printk(KERN_INFO "Registering EtherCAT device...\n"); if (!(rtl_ec_dev = ecdev_register(ec_device_master_index, - rtl_ec_net_dev, rtl8139_interrupt, THIS_MODULE))) { + rtl_ec_net_dev, ec_poll, THIS_MODULE))) { printk(KERN_ERR "Failed to register EtherCAT device!\n"); goto out_pci; } diff -r 092ac0fa23fe -r acdd1f9ef7ab devices/8139too-2.6.18-ethercat.c --- a/devices/8139too-2.6.18-ethercat.c Fri Jan 12 12:50:52 2007 +0000 +++ b/devices/8139too-2.6.18-ethercat.c Fri Jan 12 14:28:33 2007 +0000 @@ -710,6 +710,9 @@ #ifdef CONFIG_NET_POLL_CONTROLLER static void rtl8139_poll_controller(struct net_device *dev); #endif +/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ +void ec_poll(struct net_device *); +/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance, struct pt_regs *regs); static int rtl8139_close (struct net_device *dev); @@ -2349,6 +2352,15 @@ return !done; } +/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ + +void ec_poll(struct net_device *dev) +{ + rtl8139_interrupt(0, dev, NULL); +} + +/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ + /* The interrupt handler does all of the Rx thread work and cleans up after the Tx thread. */ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance, @@ -2906,7 +2918,7 @@ if (rtl_ec_net_dev) { printk(KERN_INFO "Registering EtherCAT device...\n"); if (!(rtl_ec_dev = ecdev_register(ec_device_master_index, - rtl_ec_net_dev, rtl8139_interrupt, THIS_MODULE))) { + rtl_ec_net_dev, ec_poll, THIS_MODULE))) { printk(KERN_ERR "Failed to register EtherCAT device!\n"); goto out_pci; } diff -r 092ac0fa23fe -r acdd1f9ef7ab devices/ecdev.h --- a/devices/ecdev.h Fri Jan 12 12:50:52 2007 +0000 +++ b/devices/ecdev.h Fri Jan 12 14:28:33 2007 +0000 @@ -58,16 +58,16 @@ typedef struct ec_device ec_device_t; /**< \see ec_device */ /** - Interrupt-Service-Routine Type + Device poll function type. */ -typedef irqreturn_t (*ec_isr_t)(int, void *, struct pt_regs *); +typedef void (*ec_pollfunc_t)(struct net_device *); /*****************************************************************************/ // Registration functions ec_device_t *ecdev_register(unsigned int master_index, - struct net_device *net_dev, ec_isr_t isr, + struct net_device *net_dev, ec_pollfunc_t poll, struct module *module); void ecdev_unregister(unsigned int master_index, ec_device_t *device); diff -r 092ac0fa23fe -r acdd1f9ef7ab master/device.c --- a/master/device.c Fri Jan 12 12:50:52 2007 +0000 +++ b/master/device.c Fri Jan 12 14:28:33 2007 +0000 @@ -57,16 +57,15 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */ ec_master_t *master, /**< master owning the device */ struct net_device *net_dev, /**< net_device structure */ - ec_isr_t isr, /**< pointer to device's ISR */ - struct module *module /**< pointer to the owning module */ + ec_pollfunc_t poll, /**< pointer to device's poll function */ + struct module *module /**< the device's module */ ) { struct ethhdr *eth; device->master = master; device->dev = net_dev; - device->isr = isr; - device->module = module; + device->poll = poll; device->open = 0; device->link_state = 0; // down @@ -146,7 +145,7 @@ } // device could have received frames before - for (i = 0; i < 4; i++) ec_device_call_isr(device); + for (i = 0; i < 4; i++) ec_device_poll(device); device->link_state = 0; device->tx_count = 0; @@ -228,17 +227,17 @@ /*****************************************************************************/ /** - Calls the interrupt service routine of the assigned net_device. + Calls the poll function of the assigned net_device. The master itself works without using interrupts. Therefore the processing of received data and status changes of the network device has to be done by the master calling the ISR "manually". */ -void ec_device_call_isr(ec_device_t *device /**< EtherCAT device */) -{ - device->cycles_isr = get_cycles(); - device->jiffies_isr = jiffies; - if (likely(device->isr)) device->isr(0, device->dev, NULL); +void ec_device_poll(ec_device_t *device /**< EtherCAT device */) +{ + device->cycles_poll = get_cycles(); + device->jiffies_poll = jiffies; + device->poll(device->dev); } /****************************************************************************** diff -r 092ac0fa23fe -r acdd1f9ef7ab master/device.h --- a/master/device.h Fri Jan 12 12:50:52 2007 +0000 +++ b/master/device.h Fri Jan 12 14:28:33 2007 +0000 @@ -65,9 +65,9 @@ struct net_device *dev; /**< pointer to the assigned net_device */ uint8_t open; /**< true, if the net_device has been opened */ struct sk_buff *tx_skb; /**< transmit socket buffer */ - ec_isr_t isr; /**< pointer to the device's interrupt service routine */ - cycles_t cycles_isr; /**< cycles of last ISR call */ - unsigned long jiffies_isr; /**< jiffies of last ISR call */ + ec_pollfunc_t poll; /**< pointer to the device's poll function */ + cycles_t cycles_poll; /**< cycles of last poll */ + unsigned long jiffies_poll; /**< jiffies of last poll */ struct module *module; /**< pointer to the device's owning module */ uint8_t link_state; /**< device link state */ unsigned int tx_count; /**< number of frames sent */ @@ -80,13 +80,13 @@ /*****************************************************************************/ int ec_device_init(ec_device_t *, ec_master_t *, struct net_device *, - ec_isr_t, struct module *); + ec_pollfunc_t, struct module *); void ec_device_clear(ec_device_t *); int ec_device_open(ec_device_t *); int ec_device_close(ec_device_t *); -void ec_device_call_isr(ec_device_t *); +void ec_device_poll(ec_device_t *); uint8_t *ec_device_tx_data(ec_device_t *); void ec_device_send(ec_device_t *, size_t); diff -r 092ac0fa23fe -r acdd1f9ef7ab master/master.c --- a/master/master.c Fri Jan 12 12:50:52 2007 +0000 +++ b/master/master.c Fri Jan 12 14:28:33 2007 +0000 @@ -757,8 +757,8 @@ // dequeue the received datagram datagram->state = EC_DATAGRAM_RECEIVED; - datagram->cycles_received = master->device->cycles_isr; - datagram->jiffies_received = master->device->jiffies_isr; + datagram->cycles_received = master->device->cycles_poll; + datagram->jiffies_received = master->device->jiffies_poll; list_del_init(&datagram->queue); } } @@ -1490,7 +1490,7 @@ } // query link state - ec_device_call_isr(master->device); + ec_device_poll(master->device); return; } @@ -1511,7 +1511,7 @@ cycles_t cycles_timeout; // receive datagrams - ec_device_call_isr(master->device); + ec_device_poll(master->device); cycles_timeout = (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000); @@ -1519,7 +1519,7 @@ list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue) { if (datagram->state != EC_DATAGRAM_SENT) continue; - if (master->device->cycles_isr - datagram->cycles_sent + if (master->device->cycles_poll - datagram->cycles_sent > cycles_timeout) { list_del_init(&datagram->queue); datagram->state = EC_DATAGRAM_TIMED_OUT; diff -r 092ac0fa23fe -r acdd1f9ef7ab master/module.c --- a/master/module.c Fri Jan 12 12:50:52 2007 +0000 +++ b/master/module.c Fri Jan 12 14:28:33 2007 +0000 @@ -282,7 +282,7 @@ ec_device_t *ecdev_register(unsigned int master_index, /**< master index */ struct net_device *net_dev, /**< net_device of the device */ - ec_isr_t isr, /**< interrupt service routine */ + ec_pollfunc_t poll, /**< device poll function */ struct module *module /**< pointer to the module */ ) { @@ -306,7 +306,7 @@ goto out_up; } - if (ec_device_init(master->device, master, net_dev, isr, module)) { + if (ec_device_init(master->device, master, net_dev, poll, module)) { EC_ERR("Failed to init device!\n"); goto out_free; }