Replaced ec_isr_t by ec_pollfunc_t; added poll function s in network drivers.
This commit is contained in:
parent
dfdc30a6d8
commit
291d63856b
6
NEWS
6
NEWS
|
|
@ -6,7 +6,7 @@ $Id$
|
|||
|
||||
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 @@ Changes in version 1.2.0:
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -709,6 +709,9 @@ static int rtl8139_poll(struct net_device *dev, int *budget);
|
|||
#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 @@ static int rtl8139_poll(struct net_device *dev, int *budget)
|
|||
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 @@ static int __init rtl8139_init_module (void)
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -711,6 +711,9 @@ static int rtl8139_poll(struct net_device *dev, int *budget);
|
|||
#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 @@ static int rtl8139_poll(struct net_device *dev, int *budget)
|
|||
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 @@ static int __init rtl8139_init_module (void)
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -710,6 +710,9 @@ static int rtl8139_poll(struct net_device *dev, int *budget);
|
|||
#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 @@ static int rtl8139_poll(struct net_device *dev, int *budget)
|
|||
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 @@ static int __init rtl8139_init_module (void)
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,16 +58,16 @@ struct ec_device;
|
|||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@ int ec_device_open(ec_device_t *device /**< EtherCAT device */)
|
|||
}
|
||||
|
||||
// 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 @@ void ec_device_send(ec_device_t *device, /**< EtherCAT device */
|
|||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
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 */)
|
||||
void ec_device_poll(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);
|
||||
device->cycles_poll = get_cycles();
|
||||
device->jiffies_poll = jiffies;
|
||||
device->poll(device->dev);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ struct ec_device
|
|||
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 @@ struct ec_device
|
|||
/*****************************************************************************/
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -757,8 +757,8 @@ void ec_master_receive_datagrams(ec_master_t *master, /**< EtherCAT master */
|
|||
|
||||
// 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 @@ void ecrt_master_send(ec_master_t *master /**< EtherCAT master */)
|
|||
}
|
||||
|
||||
// query link state
|
||||
ec_device_call_isr(master->device);
|
||||
ec_device_poll(master->device);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1511,7 +1511,7 @@ void ecrt_master_receive(ec_master_t *master /**< EtherCAT master */)
|
|||
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 @@ void ecrt_master_receive(ec_master_t *master /**< EtherCAT master */)
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ size_t ec_state_string(uint8_t states, /**< slave states */
|
|||
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 @@ ec_device_t *ecdev_register(unsigned int master_index, /**< master index */
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue