hi, This patch adds PCI error recovery support to the s2io 10-Gigabit ethernet device driver. This is modified patch based on previous submitted by Linas Vepstas Signed-off-by: Ananda Raju Cc: Wen Xiong Cc: Linas Vepstas --- diff -upNr linux-2.6.19-rc1/drivers/net/s2io.c pci_err_rec/drivers/net/s2io.c --- linux-2.6.19-rc1/drivers/net/s2io.c 2006-10-26 02:25:36.000000000 +0530 +++ pci_err_rec/drivers/net/s2io.c 2006-10-26 03:20:26.000000000 +0530 @@ -434,11 +434,18 @@ static struct pci_device_id s2io_tbl[] _ MODULE_DEVICE_TABLE(pci, s2io_tbl); +static struct pci_error_handlers s2io_err_handler = { + .error_detected = s2io_io_error_detected, + .slot_reset = s2io_io_slot_reset, + .resume = s2io_io_resume, +}; + static struct pci_driver s2io_driver = { .name = "S2IO", .id_table = s2io_tbl, .probe = s2io_init_nic, .remove = __devexit_p(s2io_rem_nic), + .err_handler = &s2io_err_handler, }; /* A simplifier macro used both by init and free shared_mem Fns(). */ @@ -2580,6 +2587,10 @@ static int s2io_poll(struct net_device * u64 val64 = 0xFFFFFFFFFFFFFFFFULL; int i; + if (atomic_read(&nic->card_state) == CARD_DOWN) { + return 0; + } + atomic_inc(&nic->isr_cnt); mac_control = &nic->mac_control; config = &nic->config; @@ -4175,6 +4186,10 @@ static irqreturn_t s2io_isr(int irq, voi mac_info_t *mac_control; struct config_param *config; + if (atomic_read(&sp->card_state) == CARD_DOWN) { + return IRQ_NONE; + } + atomic_inc(&sp->isr_cnt); mac_control = &sp->mac_control; config = &sp->config; @@ -7568,3 +7583,71 @@ static void lro_append_pkt(nic_t *sp, lr sp->mac_control.stats_info->sw_stat.clubbed_frms_cnt++; return; } + +/** + * s2io_io_error_detected - called when PCI error is detected + * @pdev: Pointer to PCI device + * @state: The current pci conneection state + * + * This function is called after a PCI bus error affecting + * this device has been detected. + */ +static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + nic_t *sp = netdev->priv; + + netif_device_detach(netdev); + atomic_set(&sp->card_state, CARD_DOWN); + pci_disable_device(pdev); + + return PCI_ERS_RESULT_NEED_RESET; +} + +/** + * s2io_io_slot_reset - called after the pci bus has been reset. + * @pdev: Pointer to PCI device + * + * Restart the card from scratch, as if from a cold-boot. + */ +static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + nic_t *sp = netdev->priv; + + if (pci_enable_device(pdev)) { + printk(KERN_ERR "s2io: Cannot re-enable PCI device after reset.\n"); + return PCI_ERS_RESULT_DISCONNECT; + } + + pci_set_master(pdev); + if (netif_running(netdev)) { + s2io_card_down(sp); + sp->device_close_flag = TRUE; /* Device is shut down. */ + } + + return PCI_ERS_RESULT_RECOVERED; +} + +/** + * s2io_io_resume - called when traffic can start flowing again. + * @pdev: Pointer to PCI device + * + * This callback is called when the error recovery driver tells us that + * its OK to resume normal operation. + */ +static void s2io_io_resume(struct pci_dev *pdev) +{ + struct net_device *netdev = pci_get_drvdata(pdev); + nic_t *sp = netdev->priv; + + if (netif_running(netdev)) { + if (s2io_card_up(sp)) { + printk(KERN_ERR "s2io: can't bring device back up after reset\n"); + return; + } + } + + netif_device_attach(netdev); + netif_wake_queue(netdev); +} diff -upNr linux-2.6.19-rc1/drivers/net/s2io.h pci_err_rec/drivers/net/s2io.h --- linux-2.6.19-rc1/drivers/net/s2io.h 2006-10-26 02:25:42.000000000 +0530 +++ pci_err_rec/drivers/net/s2io.h 2006-10-26 03:06:20.000000000 +0530 @@ -1013,6 +1013,11 @@ static void queue_rx_frame(struct sk_buf static void update_L3L4_header(nic_t *sp, lro_t *lro); static void lro_append_pkt(nic_t *sp, lro_t *lro, struct sk_buff *skb, u32 tcp_len); +static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev, + pci_channel_state_t state); +static pci_ers_result_t s2io_io_slot_reset(struct pci_dev *pdev); +static void s2io_io_resume(struct pci_dev *pdev); + #define s2io_tcp_mss(skb) skb_shinfo(skb)->gso_size #define s2io_udp_mss(skb) skb_shinfo(skb)->gso_size #define s2io_offload_type(skb) skb_shinfo(skb)->gso_type