X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fs390%2Fnet%2Flcs.c;h=f94419b334f7c064c840c831adf9c77eac15e82d;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=cccfed248e701ef939bb022c975558f5097c54ca;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index cccfed248..f94419b33 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -8,11 +8,9 @@ * Author(s): Original Code written by * DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) * Rewritten by - * Frank Pavlic (pavlic@de.ibm.com) and + * Frank Pavlic (fpavlic@de.ibm.com) and * Martin Schwidefsky * - * $Revision: 1.98 $ $Date: 2005/04/18 13:41:29 $ - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -59,9 +57,8 @@ /** * initialization string for output */ -#define VERSION_LCS_C "$Revision: 1.98 $" -static char version[] __initdata = "LCS driver ("VERSION_LCS_C "/" VERSION_LCS_H ")"; +static char version[] __initdata = "LCS driver"; static char debug_buffer[255]; /** @@ -71,6 +68,7 @@ static void lcs_tasklet(unsigned long); static void lcs_start_kernel_thread(struct lcs_card *card); static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *); static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *); +static int lcs_recovery(void *ptr); /** * Debug Facility Stuff @@ -93,17 +91,17 @@ lcs_unregister_debug_facility(void) static int lcs_register_debug_facility(void) { - lcs_dbf_setup = debug_register("lcs_setup", 1, 1, 8); - lcs_dbf_trace = debug_register("lcs_trace", 1, 2, 8); + lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8); + lcs_dbf_trace = debug_register("lcs_trace", 2, 2, 8); if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) { PRINT_ERR("Not enough memory for debug facility.\n"); lcs_unregister_debug_facility(); return -ENOMEM; } debug_register_view(lcs_dbf_setup, &debug_hex_ascii_view); - debug_set_level(lcs_dbf_setup, 4); + debug_set_level(lcs_dbf_setup, 2); debug_register_view(lcs_dbf_trace, &debug_hex_ascii_view); - debug_set_level(lcs_dbf_trace, 4); + debug_set_level(lcs_dbf_trace, 2); return 0; } @@ -118,11 +116,10 @@ lcs_alloc_channel(struct lcs_channel *channel) LCS_DBF_TEXT(2, setup, "ichalloc"); for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) { /* alloc memory fo iobuffer */ - channel->iob[cnt].data = (void *) - kmalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL); + channel->iob[cnt].data = + kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL); if (channel->iob[cnt].data == NULL) break; - memset(channel->iob[cnt].data, 0, LCS_IOBUFFERSIZE); channel->iob[cnt].state = BUF_STATE_EMPTY; } if (cnt < LCS_NUM_BUFFS) { @@ -145,8 +142,7 @@ lcs_free_channel(struct lcs_channel *channel) LCS_DBF_TEXT(2, setup, "ichfree"); for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) { - if (channel->iob[cnt].data != NULL) - kfree(channel->iob[cnt].data); + kfree(channel->iob[cnt].data); channel->iob[cnt].data = NULL; } } @@ -186,10 +182,9 @@ lcs_alloc_card(void) LCS_DBF_TEXT(2, setup, "alloclcs"); - card = kmalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA); + card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA); if (card == NULL) return NULL; - memset(card, 0, sizeof(struct lcs_card)); card->lan_type = LCS_FRAME_TYPE_AUTO; card->pkt_seq = 0; card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT; @@ -435,12 +430,6 @@ lcs_setup_card(struct lcs_card *card) card->tx_buffer = NULL; card->tx_emitted = 0; - /* Initialize kernel thread task used for LGW commands. */ - INIT_WORK(&card->kernel_thread_starter, - (void *)lcs_start_kernel_thread,card); - card->thread_start_mask = 0; - card->thread_allowed_mask = 0; - card->thread_running_mask = 0; init_waitqueue_head(&card->wait_q); spin_lock_init(&card->lock); spin_lock_init(&card->ipm_lock); @@ -797,10 +786,9 @@ lcs_alloc_reply(struct lcs_cmd *cmd) LCS_DBF_TEXT(4, trace, "getreply"); - reply = kmalloc(sizeof(struct lcs_reply), GFP_ATOMIC); + reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC); if (!reply) return NULL; - memset(reply,0,sizeof(struct lcs_reply)); atomic_set(&reply->refcnt,1); reply->sequence_no = cmd->sequence_no; reply->received = 0; @@ -1157,8 +1145,6 @@ list_modified: list_add_tail(&ipm->list, &card->ipm_list); } spin_unlock_irqrestore(&card->ipm_lock, flags); - if (card->state == DEV_STATE_UP) - netif_wake_queue(card->dev); } /** @@ -1241,17 +1227,17 @@ lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev) if (ipm != NULL) continue; /* Address already in list. */ ipm = (struct lcs_ipm_list *) - kmalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC); + kzalloc(sizeof(struct lcs_ipm_list), GFP_ATOMIC); if (ipm == NULL) { PRINT_INFO("Not enough memory to add " "new multicast entry!\n"); break; } - memset(ipm, 0, sizeof(struct lcs_ipm_list)); memcpy(&ipm->ipm.mac_addr, buf, LCS_MAC_LENGTH); ipm->ipm.ip_addr = im4->multiaddr; ipm->ipm_state = LCS_IPM_STATE_SET_REQUIRED; spin_lock_irqsave(&card->ipm_lock, flags); + LCS_DBF_HEX(2,trace,&ipm->ipm.ip_addr,4); list_add(&ipm->list, &card->ipm_list); spin_unlock_irqrestore(&card->ipm_lock, flags); } @@ -1279,7 +1265,15 @@ lcs_register_mc_addresses(void *data) read_unlock(&in4_dev->mc_list_lock); in_dev_put(in4_dev); + netif_carrier_off(card->dev); + netif_tx_disable(card->dev); + wait_event(card->write.wait_q, + (card->write.state != CH_STATE_RUNNING)); lcs_fix_multicast_list(card); + if (card->state == DEV_STATE_UP) { + netif_carrier_on(card->dev); + netif_wake_queue(card->dev); + } out: lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD); return 0; @@ -1296,9 +1290,8 @@ lcs_set_multicast_list(struct net_device *dev) LCS_DBF_TEXT(4, trace, "setmulti"); card = (struct lcs_card *) dev->priv; - if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) { + if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) schedule_work(&card->kernel_thread_starter); - } } #endif /* CONFIG_IP_MULTICAST */ @@ -1329,6 +1322,53 @@ lcs_check_irb_error(struct ccw_device *cdev, struct irb *irb) return PTR_ERR(irb); } +static int +lcs_get_problem(struct ccw_device *cdev, struct irb *irb) +{ + int dstat, cstat; + char *sense; + + sense = (char *) irb->ecw; + cstat = irb->scsw.cstat; + dstat = irb->scsw.dstat; + + if (cstat & (SCHN_STAT_CHN_CTRL_CHK | SCHN_STAT_INTF_CTRL_CHK | + SCHN_STAT_CHN_DATA_CHK | SCHN_STAT_CHAIN_CHECK | + SCHN_STAT_PROT_CHECK | SCHN_STAT_PROG_CHECK)) { + LCS_DBF_TEXT(2, trace, "CGENCHK"); + return 1; + } + if (dstat & DEV_STAT_UNIT_CHECK) { + if (sense[LCS_SENSE_BYTE_1] & + LCS_SENSE_RESETTING_EVENT) { + LCS_DBF_TEXT(2, trace, "REVIND"); + return 1; + } + if (sense[LCS_SENSE_BYTE_0] & + LCS_SENSE_CMD_REJECT) { + LCS_DBF_TEXT(2, trace, "CMDREJ"); + return 0; + } + if ((!sense[LCS_SENSE_BYTE_0]) && + (!sense[LCS_SENSE_BYTE_1]) && + (!sense[LCS_SENSE_BYTE_2]) && + (!sense[LCS_SENSE_BYTE_3])) { + LCS_DBF_TEXT(2, trace, "ZEROSEN"); + return 0; + } + LCS_DBF_TEXT(2, trace, "DGENCHK"); + return 1; + } + return 0; +} + +void +lcs_schedule_recovery(struct lcs_card *card) +{ + LCS_DBF_TEXT(2, trace, "startrec"); + if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD)) + schedule_work(&card->kernel_thread_starter); +} /** * IRQ Handler for LCS channels @@ -1338,7 +1378,8 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) { struct lcs_card *card; struct lcs_channel *channel; - int index; + int rc, index; + int cstat, dstat; if (lcs_check_irb_error(cdev, irb)) return; @@ -1349,17 +1390,30 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) else channel = &card->write; + cstat = irb->scsw.cstat; + dstat = irb->scsw.dstat; LCS_DBF_TEXT_(5, trace, "Rint%s",cdev->dev.bus_id); LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.cstat, irb->scsw.dstat); LCS_DBF_TEXT_(5, trace, "%4x%4x",irb->scsw.fctl, irb->scsw.actl); + /* Check for channel and device errors presented */ + rc = lcs_get_problem(cdev, irb); + if (rc || (dstat & DEV_STAT_UNIT_EXCEP)) { + PRINT_WARN("check on device %s, dstat=0x%X, cstat=0x%X \n", + cdev->dev.bus_id, dstat, cstat); + if (rc) { + lcs_schedule_recovery(card); + wake_up(&card->wait_q); + return; + } + } /* How far in the ccw chain have we processed? */ if ((channel->state != CH_STATE_INIT) && (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) { - index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) + index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) - channel->ccws; if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) || - (irb->scsw.cstat | SCHN_STAT_PCI)) + (irb->scsw.cstat & SCHN_STAT_PCI)) /* Bloody io subsystem tells us lies about cpa... */ index = (index - 1) & (LCS_NUM_BUFFS - 1); while (channel->io_idx != index) { @@ -1378,7 +1432,6 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) else if (irb->scsw.actl & SCSW_ACTL_SUSPENDED) /* CCW execution stopped on a suspend bit. */ channel->state = CH_STATE_SUSPENDED; - if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) { if (irb->scsw.cc != 0) { ccw_device_halt(channel->ccwdev, (addr_t) channel); @@ -1387,7 +1440,6 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) /* The channel has been stopped by halt_IO. */ channel->state = CH_STATE_HALTED; } - if (irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) { channel->state = CH_STATE_CLEARED; } @@ -1463,6 +1515,8 @@ lcs_txbuffer_cb(struct lcs_channel *channel, struct lcs_buffer *buffer) lcs_release_buffer(channel, buffer); card = (struct lcs_card *) ((char *) channel - offsetof(struct lcs_card, write)); + if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev)) + netif_wake_queue(card->dev); spin_lock(&card->lock); card->tx_emitted--; if (card->tx_emitted <= 0 && card->tx_buffer != NULL) @@ -1482,6 +1536,7 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, struct net_device *dev) { struct lcs_header *header; + int rc = 0; LCS_DBF_TEXT(5, trace, "hardxmit"); if (skb == NULL) { @@ -1496,10 +1551,12 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, card->stats.tx_carrier_errors++; return 0; } - if (netif_queue_stopped(dev) ) { - card->stats.tx_dropped++; - return -EBUSY; + if (skb->protocol == htons(ETH_P_IPV6)) { + dev_kfree_skb(skb); + return 0; } + netif_stop_queue(card->dev); + spin_lock(&card->lock); if (card->tx_buffer != NULL && card->tx_buffer->count + sizeof(struct lcs_header) + skb->len + sizeof(u16) > LCS_IOBUFFERSIZE) @@ -1510,7 +1567,8 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, card->tx_buffer = lcs_get_buffer(&card->write); if (card->tx_buffer == NULL) { card->stats.tx_dropped++; - return -EBUSY; + rc = -EBUSY; + goto out; } card->tx_buffer->callback = lcs_txbuffer_cb; card->tx_buffer->count = 0; @@ -1522,13 +1580,18 @@ __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, header->type = card->lan_type; header->slot = card->portno; memcpy(header + 1, skb->data, skb->len); + spin_unlock(&card->lock); card->stats.tx_bytes += skb->len; card->stats.tx_packets++; dev_kfree_skb(skb); - if (card->tx_emitted <= 0) + netif_wake_queue(card->dev); + spin_lock(&card->lock); + if (card->tx_emitted <= 0 && card->tx_buffer != NULL) /* If this is the first tx buffer emit it immediately. */ __lcs_emit_txbuffer(card); - return 0; +out: + spin_unlock(&card->lock); + return rc; } static int @@ -1539,9 +1602,7 @@ lcs_start_xmit(struct sk_buff *skb, struct net_device *dev) LCS_DBF_TEXT(5, trace, "pktxmit"); card = (struct lcs_card *) dev->priv; - spin_lock(&card->lock); rc = __lcs_start_xmit(card, skb, dev); - spin_unlock(&card->lock); return rc; } @@ -1638,30 +1699,6 @@ lcs_detect(struct lcs_card *card) return rc; } -/** - * reset card - */ -static int -lcs_resetcard(struct lcs_card *card) -{ - int retries; - - LCS_DBF_TEXT(2, trace, "rescard"); - for (retries = 0; retries < 10; retries++) { - if (lcs_detect(card) == 0) { - netif_wake_queue(card->dev); - card->state = DEV_STATE_UP; - PRINT_INFO("LCS device %s successfully restarted!\n", - card->dev->name); - return 0; - } - msleep(3000); - } - PRINT_ERR("Error in Reseting LCS card!\n"); - return -EIO; -} - - /** * LCS Stop card */ @@ -1685,111 +1722,6 @@ lcs_stopcard(struct lcs_card *card) return rc; } -/** - * LGW initiated commands - */ -static int -lcs_lgw_startlan_thread(void *data) -{ - struct lcs_card *card; - - card = (struct lcs_card *) data; - daemonize("lgwstpln"); - - if (!lcs_do_run_thread(card, LCS_STARTLAN_THREAD)) - return 0; - LCS_DBF_TEXT(4, trace, "lgwstpln"); - if (card->dev) - netif_stop_queue(card->dev); - if (lcs_startlan(card) == 0) { - netif_wake_queue(card->dev); - card->state = DEV_STATE_UP; - PRINT_INFO("LCS Startlan for device %s succeeded!\n", - card->dev->name); - - } else - PRINT_ERR("LCS Startlan for device %s failed!\n", - card->dev->name); - lcs_clear_thread_running_bit(card, LCS_STARTLAN_THREAD); - return 0; -} - -/** - * Send startup command initiated by Lan Gateway - */ -static int -lcs_lgw_startup_thread(void *data) -{ - int rc; - - struct lcs_card *card; - - card = (struct lcs_card *) data; - daemonize("lgwstaln"); - - if (!lcs_do_run_thread(card, LCS_STARTUP_THREAD)) - return 0; - LCS_DBF_TEXT(4, trace, "lgwstaln"); - if (card->dev) - netif_stop_queue(card->dev); - rc = lcs_send_startup(card, LCS_INITIATOR_LGW); - if (rc != 0) { - PRINT_ERR("Startup for LCS device %s initiated " \ - "by LGW failed!\nReseting card ...\n", - card->dev->name); - /* do a card reset */ - rc = lcs_resetcard(card); - if (rc == 0) - goto Done; - } - rc = lcs_startlan(card); - if (rc == 0) { - netif_wake_queue(card->dev); - card->state = DEV_STATE_UP; - } -Done: - if (rc == 0) - PRINT_INFO("LCS Startup for device %s succeeded!\n", - card->dev->name); - else - PRINT_ERR("LCS Startup for device %s failed!\n", - card->dev->name); - lcs_clear_thread_running_bit(card, LCS_STARTUP_THREAD); - return 0; -} - - -/** - * send stoplan command initiated by Lan Gateway - */ -static int -lcs_lgw_stoplan_thread(void *data) -{ - struct lcs_card *card; - int rc; - - card = (struct lcs_card *) data; - daemonize("lgwstop"); - - if (!lcs_do_run_thread(card, LCS_STOPLAN_THREAD)) - return 0; - LCS_DBF_TEXT(4, trace, "lgwstop"); - if (card->dev) - netif_stop_queue(card->dev); - if (lcs_send_stoplan(card, LCS_INITIATOR_LGW) == 0) - PRINT_INFO("Stoplan for %s initiated by LGW succeeded!\n", - card->dev->name); - else - PRINT_ERR("Stoplan %s initiated by LGW failed!\n", - card->dev->name); - /*Try to reset the card, stop it on failure */ - rc = lcs_resetcard(card); - if (rc != 0) - rc = lcs_stopcard(card); - lcs_clear_thread_running_bit(card, LCS_STOPLAN_THREAD); - return rc; -} - /** * Kernel Thread helper functions for LGW initiated commands */ @@ -1797,15 +1729,12 @@ static void lcs_start_kernel_thread(struct lcs_card *card) { LCS_DBF_TEXT(5, trace, "krnthrd"); - if (lcs_do_start_thread(card, LCS_STARTUP_THREAD)) - kernel_thread(lcs_lgw_startup_thread, (void *) card, SIGCHLD); - if (lcs_do_start_thread(card, LCS_STARTLAN_THREAD)) - kernel_thread(lcs_lgw_startlan_thread, (void *) card, SIGCHLD); - if (lcs_do_start_thread(card, LCS_STOPLAN_THREAD)) - kernel_thread(lcs_lgw_stoplan_thread, (void *) card, SIGCHLD); + if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) + kernel_thread(lcs_recovery, (void *) card, SIGCHLD); #ifdef CONFIG_IP_MULTICAST if (lcs_do_start_thread(card, LCS_SET_MC_THREAD)) - kernel_thread(lcs_register_mc_addresses, (void *) card, SIGCHLD); + kernel_thread(lcs_register_mc_addresses, + (void *) card, SIGCHLD); #endif } @@ -1819,19 +1748,14 @@ lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd) if (cmd->initiator == LCS_INITIATOR_LGW) { switch(cmd->cmd_code) { case LCS_CMD_STARTUP: - if (!lcs_set_thread_start_bit(card, - LCS_STARTUP_THREAD)) - schedule_work(&card->kernel_thread_starter); - break; case LCS_CMD_STARTLAN: - if (!lcs_set_thread_start_bit(card, - LCS_STARTLAN_THREAD)) - schedule_work(&card->kernel_thread_starter); + lcs_schedule_recovery(card); break; case LCS_CMD_STOPLAN: - if (!lcs_set_thread_start_bit(card, - LCS_STOPLAN_THREAD)) - schedule_work(&card->kernel_thread_starter); + PRINT_WARN("Stoplan for %s initiated by LGW.\n", + card->dev->name); + if (card->dev) + netif_carrier_off(card->dev); break; default: PRINT_INFO("UNRECOGNIZED LGW COMMAND\n"); @@ -1947,8 +1871,11 @@ lcs_stop_device(struct net_device *dev) LCS_DBF_TEXT(2, trace, "stopdev"); card = (struct lcs_card *) dev->priv; - netif_stop_queue(dev); + netif_carrier_off(dev); + netif_tx_disable(dev); dev->flags &= ~IFF_UP; + wait_event(card->write.wait_q, + (card->write.state != CH_STATE_RUNNING)); rc = lcs_stopcard(card); if (rc) PRINT_ERR("Try it again!\n "); @@ -1974,6 +1901,7 @@ lcs_open_device(struct net_device *dev) } else { dev->flags |= IFF_UP; + netif_carrier_on(dev); netif_wake_queue(dev); card->state = DEV_STATE_UP; } @@ -1984,7 +1912,7 @@ lcs_open_device(struct net_device *dev) * show function for portno called by cat or similar things */ static ssize_t -lcs_portno_show (struct device *dev, char *buf) +lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf) { struct lcs_card *card; @@ -2000,7 +1928,7 @@ lcs_portno_show (struct device *dev, char *buf) * store the value which is piped to file portno */ static ssize_t -lcs_portno_store (struct device *dev, const char *buf, size_t count) +lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct lcs_card *card; int value; @@ -2021,7 +1949,7 @@ lcs_portno_store (struct device *dev, const char *buf, size_t count) static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store); static ssize_t -lcs_type_show(struct device *dev, char *buf) +lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf) { struct ccwgroup_device *cgdev; @@ -2035,7 +1963,7 @@ lcs_type_show(struct device *dev, char *buf) static DEVICE_ATTR(type, 0444, lcs_type_show, NULL); static ssize_t -lcs_timeout_show(struct device *dev, char *buf) +lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf) { struct lcs_card *card; @@ -2045,7 +1973,7 @@ lcs_timeout_show(struct device *dev, char *buf) } static ssize_t -lcs_timeout_store (struct device *dev, const char *buf, size_t count) +lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct lcs_card *card; int value; @@ -2065,10 +1993,31 @@ lcs_timeout_store (struct device *dev, const char *buf, size_t count) DEVICE_ATTR(lancmd_timeout, 0644, lcs_timeout_show, lcs_timeout_store); +static ssize_t +lcs_dev_recover_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct lcs_card *card = dev->driver_data; + char *tmp; + int i; + + if (!card) + return -EINVAL; + if (card->state != DEV_STATE_UP) + return -EPERM; + i = simple_strtoul(buf, &tmp, 16); + if (i == 1) + lcs_schedule_recovery(card); + return count; +} + +static DEVICE_ATTR(recover, 0200, NULL, lcs_dev_recover_store); + static struct attribute * lcs_attrs[] = { &dev_attr_portno.attr, &dev_attr_type.attr, &dev_attr_lancmd_timeout.attr, + &dev_attr_recover.attr, NULL, }; @@ -2105,6 +2054,12 @@ lcs_probe_device(struct ccwgroup_device *ccwgdev) ccwgdev->dev.driver_data = card; ccwgdev->cdev[0]->handler = lcs_irq; ccwgdev->cdev[1]->handler = lcs_irq; + card->gdev = ccwgdev; + INIT_WORK(&card->kernel_thread_starter, + (void *) lcs_start_kernel_thread, card); + card->thread_start_mask = 0; + card->thread_allowed_mask = 0; + card->thread_running_mask = 0; return 0; } @@ -2206,6 +2161,7 @@ netdev_out: if (recover_state == DEV_STATE_RECOVER) { lcs_set_multicast_list(card->dev); card->dev->flags |= IFF_UP; + netif_carrier_on(card->dev); netif_wake_queue(card->dev); card->state = DEV_STATE_UP; } else { @@ -2235,7 +2191,7 @@ out: * lcs_shutdown_device, called when setting the group device offline. */ static int -lcs_shutdown_device(struct ccwgroup_device *ccwgdev) +__lcs_shutdown_device(struct ccwgroup_device *ccwgdev, int recovery_mode) { struct lcs_card *card; enum lcs_dev_states recover_state; @@ -2245,9 +2201,11 @@ lcs_shutdown_device(struct ccwgroup_device *ccwgdev) card = (struct lcs_card *)ccwgdev->dev.driver_data; if (!card) return -ENODEV; - lcs_set_allowed_threads(card, 0); - if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD)) - return -ERESTARTSYS; + if (recovery_mode == 0) { + lcs_set_allowed_threads(card, 0); + if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD)) + return -ERESTARTSYS; + } LCS_DBF_HEX(3, setup, &card, sizeof(void*)); recover_state = card->state; @@ -2262,6 +2220,43 @@ lcs_shutdown_device(struct ccwgroup_device *ccwgdev) return 0; } +static int +lcs_shutdown_device(struct ccwgroup_device *ccwgdev) +{ + return __lcs_shutdown_device(ccwgdev, 0); +} + +/** + * drive lcs recovery after startup and startlan initiated by Lan Gateway + */ +static int +lcs_recovery(void *ptr) +{ + struct lcs_card *card; + struct ccwgroup_device *gdev; + int rc; + + card = (struct lcs_card *) ptr; + daemonize("lcs_recover"); + + LCS_DBF_TEXT(4, trace, "recover1"); + if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD)) + return 0; + LCS_DBF_TEXT(4, trace, "recover2"); + gdev = card->gdev; + PRINT_WARN("Recovery of device %s started...\n", gdev->dev.bus_id); + rc = __lcs_shutdown_device(gdev, 1); + rc = lcs_new_device(gdev); + if (!rc) + PRINT_INFO("Device %s successfully recovered!\n", + card->dev->name); + else + PRINT_INFO("Device %s could not be recovered!\n", + card->dev->name); + lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD); + return 0; +} + /** * lcs_remove_device, free buffers and card */ @@ -2323,7 +2318,6 @@ __init lcs_init_module(void) PRINT_ERR("Initialization failed\n"); return rc; } - return 0; } @@ -2343,6 +2337,6 @@ __exit lcs_cleanup_module(void) module_init(lcs_init_module); module_exit(lcs_cleanup_module); -MODULE_AUTHOR("Frank Pavlic "); +MODULE_AUTHOR("Frank Pavlic "); MODULE_LICENSE("GPL");