Lines Matching full:card

155  * LCS free memory for card and channels.
158 lcs_free_card(struct lcs_card *card) in lcs_free_card() argument
161 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); in lcs_free_card()
162 kfree(card); in lcs_free_card()
166 * LCS alloc memory for card and channels
171 struct lcs_card *card; in lcs_alloc_card() local
176 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA); in lcs_alloc_card()
177 if (card == NULL) in lcs_alloc_card()
179 card->lan_type = LCS_FRAME_TYPE_AUTO; in lcs_alloc_card()
180 card->pkt_seq = 0; in lcs_alloc_card()
181 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT; in lcs_alloc_card()
183 rc = lcs_alloc_channel(&card->read); in lcs_alloc_card()
186 lcs_free_card(card); in lcs_alloc_card()
190 rc = lcs_alloc_channel(&card->write); in lcs_alloc_card()
193 lcs_cleanup_channel(&card->read); in lcs_alloc_card()
194 lcs_free_card(card); in lcs_alloc_card()
199 INIT_LIST_HEAD(&card->ipm_list); in lcs_alloc_card()
201 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); in lcs_alloc_card()
202 return card; in lcs_alloc_card()
209 lcs_setup_read_ccws(struct lcs_card *card) in lcs_setup_read_ccws() argument
215 memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1)); in lcs_setup_read_ccws()
217 card->read.ccws[cnt].cmd_code = LCS_CCW_READ; in lcs_setup_read_ccws()
218 card->read.ccws[cnt].count = LCS_IOBUFFERSIZE; in lcs_setup_read_ccws()
219 card->read.ccws[cnt].flags = in lcs_setup_read_ccws()
225 card->read.ccws[cnt].cda = in lcs_setup_read_ccws()
226 (__u32)virt_to_phys(card->read.iob[cnt].data); in lcs_setup_read_ccws()
228 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET; in lcs_setup_read_ccws()
229 card->read.iob[cnt].callback = lcs_get_frames_cb; in lcs_setup_read_ccws()
230 card->read.iob[cnt].state = LCS_BUF_STATE_READY; in lcs_setup_read_ccws()
231 card->read.iob[cnt].count = LCS_IOBUFFERSIZE; in lcs_setup_read_ccws()
233 card->read.ccws[0].flags &= ~CCW_FLAG_PCI; in lcs_setup_read_ccws()
234 card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI; in lcs_setup_read_ccws()
235 card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND; in lcs_setup_read_ccws()
237 card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER; in lcs_setup_read_ccws()
238 card->read.ccws[LCS_NUM_BUFFS].cda = in lcs_setup_read_ccws()
239 (__u32)virt_to_phys(card->read.ccws); in lcs_setup_read_ccws()
241 card->read.state = LCS_CH_STATE_INIT; in lcs_setup_read_ccws()
243 card->read.io_idx = 0; in lcs_setup_read_ccws()
244 card->read.buf_idx = 0; in lcs_setup_read_ccws()
248 lcs_setup_read(struct lcs_card *card) in lcs_setup_read() argument
252 lcs_setup_read_ccws(card); in lcs_setup_read()
254 card->read.irq_tasklet.data = (unsigned long) &card->read; in lcs_setup_read()
255 card->read.irq_tasklet.func = lcs_tasklet; in lcs_setup_read()
257 init_waitqueue_head(&card->read.wait_q); in lcs_setup_read()
264 lcs_setup_write_ccws(struct lcs_card *card) in lcs_setup_write_ccws() argument
270 memset(card->write.ccws, 0, sizeof(struct ccw1) * (LCS_NUM_BUFFS + 1)); in lcs_setup_write_ccws()
272 card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE; in lcs_setup_write_ccws()
273 card->write.ccws[cnt].count = 0; in lcs_setup_write_ccws()
274 card->write.ccws[cnt].flags = in lcs_setup_write_ccws()
280 card->write.ccws[cnt].cda = in lcs_setup_write_ccws()
281 (__u32)virt_to_phys(card->write.iob[cnt].data); in lcs_setup_write_ccws()
284 card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER; in lcs_setup_write_ccws()
285 card->write.ccws[LCS_NUM_BUFFS].cda = in lcs_setup_write_ccws()
286 (__u32)virt_to_phys(card->write.ccws); in lcs_setup_write_ccws()
288 card->read.state = LCS_CH_STATE_INIT; in lcs_setup_write_ccws()
290 card->write.io_idx = 0; in lcs_setup_write_ccws()
291 card->write.buf_idx = 0; in lcs_setup_write_ccws()
295 lcs_setup_write(struct lcs_card *card) in lcs_setup_write() argument
299 lcs_setup_write_ccws(card); in lcs_setup_write()
301 card->write.irq_tasklet.data = (unsigned long) &card->write; in lcs_setup_write()
302 card->write.irq_tasklet.func = lcs_tasklet; in lcs_setup_write()
304 init_waitqueue_head(&card->write.wait_q); in lcs_setup_write()
308 lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads) in lcs_set_allowed_threads() argument
312 spin_lock_irqsave(&card->mask_lock, flags); in lcs_set_allowed_threads()
313 card->thread_allowed_mask = threads; in lcs_set_allowed_threads()
314 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_set_allowed_threads()
315 wake_up(&card->wait_q); in lcs_set_allowed_threads()
317 static int lcs_threads_running(struct lcs_card *card, unsigned long threads) in lcs_threads_running() argument
322 spin_lock_irqsave(&card->mask_lock, flags); in lcs_threads_running()
323 rc = (card->thread_running_mask & threads); in lcs_threads_running()
324 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_threads_running()
329 lcs_wait_for_threads(struct lcs_card *card, unsigned long threads) in lcs_wait_for_threads() argument
331 return wait_event_interruptible(card->wait_q, in lcs_wait_for_threads()
332 lcs_threads_running(card, threads) == 0); in lcs_wait_for_threads()
335 static int lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread) in lcs_set_thread_start_bit() argument
339 spin_lock_irqsave(&card->mask_lock, flags); in lcs_set_thread_start_bit()
340 if ( !(card->thread_allowed_mask & thread) || in lcs_set_thread_start_bit()
341 (card->thread_start_mask & thread) ) { in lcs_set_thread_start_bit()
342 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_set_thread_start_bit()
345 card->thread_start_mask |= thread; in lcs_set_thread_start_bit()
346 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_set_thread_start_bit()
351 lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread) in lcs_clear_thread_running_bit() argument
355 spin_lock_irqsave(&card->mask_lock, flags); in lcs_clear_thread_running_bit()
356 card->thread_running_mask &= ~thread; in lcs_clear_thread_running_bit()
357 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_clear_thread_running_bit()
358 wake_up(&card->wait_q); in lcs_clear_thread_running_bit()
361 static int __lcs_do_run_thread(struct lcs_card *card, unsigned long thread) in __lcs_do_run_thread() argument
366 spin_lock_irqsave(&card->mask_lock, flags); in __lcs_do_run_thread()
367 if (card->thread_start_mask & thread){ in __lcs_do_run_thread()
368 if ((card->thread_allowed_mask & thread) && in __lcs_do_run_thread()
369 !(card->thread_running_mask & thread)){ in __lcs_do_run_thread()
371 card->thread_start_mask &= ~thread; in __lcs_do_run_thread()
372 card->thread_running_mask |= thread; in __lcs_do_run_thread()
376 spin_unlock_irqrestore(&card->mask_lock, flags); in __lcs_do_run_thread()
381 lcs_do_run_thread(struct lcs_card *card, unsigned long thread) in lcs_do_run_thread() argument
384 wait_event(card->wait_q, in lcs_do_run_thread()
385 (rc = __lcs_do_run_thread(card, thread)) >= 0); in lcs_do_run_thread()
390 lcs_do_start_thread(struct lcs_card *card, unsigned long thread) in lcs_do_start_thread() argument
395 spin_lock_irqsave(&card->mask_lock, flags); in lcs_do_start_thread()
397 (u8) card->thread_start_mask, in lcs_do_start_thread()
398 (u8) card->thread_allowed_mask, in lcs_do_start_thread()
399 (u8) card->thread_running_mask); in lcs_do_start_thread()
400 rc = (card->thread_start_mask & thread); in lcs_do_start_thread()
401 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_do_start_thread()
406 * Initialize channels,card and state machines.
409 lcs_setup_card(struct lcs_card *card) in lcs_setup_card() argument
412 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); in lcs_setup_card()
414 lcs_setup_read(card); in lcs_setup_card()
415 lcs_setup_write(card); in lcs_setup_card()
417 card->state = DEV_STATE_DOWN; in lcs_setup_card()
418 card->tx_buffer = NULL; in lcs_setup_card()
419 card->tx_emitted = 0; in lcs_setup_card()
421 init_waitqueue_head(&card->wait_q); in lcs_setup_card()
422 spin_lock_init(&card->lock); in lcs_setup_card()
423 spin_lock_init(&card->ipm_lock); in lcs_setup_card()
424 spin_lock_init(&card->mask_lock); in lcs_setup_card()
426 INIT_LIST_HEAD(&card->ipm_list); in lcs_setup_card()
428 INIT_LIST_HEAD(&card->lancmd_waiters); in lcs_setup_card()
431 static void lcs_clear_multicast_list(struct lcs_card *card) in lcs_clear_multicast_list() argument
439 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_clear_multicast_list()
440 while (!list_empty(&card->ipm_list)){ in lcs_clear_multicast_list()
441 ipm = list_entry(card->ipm_list.next, in lcs_clear_multicast_list()
445 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_clear_multicast_list()
446 lcs_send_delipm(card, ipm); in lcs_clear_multicast_list()
447 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_clear_multicast_list()
451 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_clear_multicast_list()
456 * Cleanup channels,card and state machines.
459 lcs_cleanup_card(struct lcs_card *card) in lcs_cleanup_card() argument
463 LCS_DBF_HEX(2,setup,&card,sizeof(void*)); in lcs_cleanup_card()
465 if (card->dev != NULL) in lcs_cleanup_card()
466 free_netdev(card->dev); in lcs_cleanup_card()
468 lcs_cleanup_channel(&card->write); in lcs_cleanup_card()
469 lcs_cleanup_channel(&card->read); in lcs_cleanup_card()
553 lcs_start_channels(struct lcs_card *card) in lcs_start_channels() argument
559 rc = lcs_start_channel(&card->read); in lcs_start_channels()
563 rc = lcs_start_channel(&card->write); in lcs_start_channels()
565 lcs_stop_channel(&card->read); in lcs_start_channels()
573 lcs_stop_channels(struct lcs_card *card) in lcs_stop_channels() argument
576 lcs_stop_channel(&card->read); in lcs_stop_channels()
577 lcs_stop_channel(&card->write); in lcs_stop_channels()
736 lcs_get_lancmd(struct lcs_card *card, int count) in lcs_get_lancmd() argument
743 wait_event(card->write.wait_q, in lcs_get_lancmd()
744 ((buffer = lcs_get_buffer(&card->write)) != NULL)); in lcs_get_lancmd()
793 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd) in lcs_notify_lancmd_waiters() argument
799 spin_lock(&card->lock); in lcs_notify_lancmd_waiters()
800 list_for_each_safe(l, n, &card->lancmd_waiters) { in lcs_notify_lancmd_waiters()
806 reply->callback(card, cmd); in lcs_notify_lancmd_waiters()
814 spin_unlock(&card->lock); in lcs_notify_lancmd_waiters()
828 spin_lock_irqsave(&reply->card->lock, flags); in lcs_lancmd_timeout()
830 &reply->card->lancmd_waiters,list) { in lcs_lancmd_timeout()
834 spin_unlock_irqrestore(&reply->card->lock, flags); in lcs_lancmd_timeout()
842 spin_unlock_irqrestore(&reply->card->lock, flags); in lcs_lancmd_timeout()
846 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer, in lcs_send_lancmd() argument
857 cmd->sequence_no = card->sequence_no++; in lcs_send_lancmd()
862 reply->card = card; in lcs_send_lancmd()
863 spin_lock_irqsave(&card->lock, flags); in lcs_send_lancmd()
864 list_add_tail(&reply->list, &card->lancmd_waiters); in lcs_send_lancmd()
865 spin_unlock_irqrestore(&card->lock, flags); in lcs_send_lancmd()
868 rc = lcs_ready_buffer(&card->write, buffer); in lcs_send_lancmd()
872 mod_timer(&reply->timer, jiffies + HZ * card->lancmd_timeout); in lcs_send_lancmd()
885 lcs_send_startup(struct lcs_card *card, __u8 initiator) in lcs_send_startup() argument
891 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_startup()
896 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_startup()
903 lcs_send_shutdown(struct lcs_card *card) in lcs_send_shutdown() argument
909 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_shutdown()
913 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_shutdown()
920 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd) in __lcs_lanstat_cb() argument
923 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH); in __lcs_lanstat_cb()
927 lcs_send_lanstat(struct lcs_card *card) in lcs_send_lanstat() argument
933 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_lanstat()
938 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; in lcs_send_lanstat()
939 cmd->cmd.lcs_std_cmd.portno = card->portno; in lcs_send_lanstat()
940 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb); in lcs_send_lanstat()
947 lcs_send_stoplan(struct lcs_card *card, __u8 initiator) in lcs_send_stoplan() argument
953 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_stoplan()
957 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; in lcs_send_stoplan()
958 cmd->cmd.lcs_std_cmd.portno = card->portno; in lcs_send_stoplan()
959 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_stoplan()
966 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd) in __lcs_send_startlan_cb() argument
969 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type; in __lcs_send_startlan_cb()
970 card->portno = cmd->cmd.lcs_std_cmd.portno; in __lcs_send_startlan_cb()
974 lcs_send_startlan(struct lcs_card *card, __u8 initiator) in lcs_send_startlan() argument
980 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_startlan()
984 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; in lcs_send_startlan()
985 cmd->cmd.lcs_std_cmd.portno = card->portno; in lcs_send_startlan()
986 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb); in lcs_send_startlan()
994 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list) in lcs_send_setipm() argument
1000 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE); in lcs_send_setipm()
1004 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; in lcs_send_setipm()
1005 cmd->cmd.lcs_qipassist.portno = card->portno; in lcs_send_setipm()
1011 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_setipm()
1018 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list) in lcs_send_delipm() argument
1024 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE); in lcs_send_delipm()
1028 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; in lcs_send_delipm()
1029 cmd->cmd.lcs_qipassist.portno = card->portno; in lcs_send_delipm()
1035 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_delipm()
1042 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd) in __lcs_check_multicast_cb() argument
1045 card->ip_assists_supported = in __lcs_check_multicast_cb()
1047 card->ip_assists_enabled = in __lcs_check_multicast_cb()
1052 lcs_check_multicast_support(struct lcs_card *card) in lcs_check_multicast_support() argument
1060 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_check_multicast_support()
1064 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; in lcs_check_multicast_support()
1065 cmd->cmd.lcs_qipassist.portno = card->portno; in lcs_check_multicast_support()
1068 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb); in lcs_check_multicast_support()
1073 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) in lcs_check_multicast_support()
1079 * set or del multicast address on LCS card
1082 lcs_fix_multicast_list(struct lcs_card *card) in lcs_fix_multicast_list() argument
1091 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1093 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){ in lcs_fix_multicast_list()
1099 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1100 rc = lcs_send_setipm(card, ipm); in lcs_fix_multicast_list()
1101 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1112 list_add_tail(&ipm->list, &card->ipm_list); in lcs_fix_multicast_list()
1117 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1118 lcs_send_delipm(card, ipm); in lcs_fix_multicast_list()
1119 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1128 list_move_tail(&ipm->list, &card->ipm_list); in lcs_fix_multicast_list()
1130 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1146 static void lcs_remove_mc_addresses(struct lcs_card *card, in lcs_remove_mc_addresses() argument
1156 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_remove_mc_addresses()
1157 list_for_each(l, &card->ipm_list) { in lcs_remove_mc_addresses()
1161 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev); in lcs_remove_mc_addresses()
1170 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_remove_mc_addresses()
1173 static struct lcs_ipm_list *lcs_check_addr_entry(struct lcs_card *card, in lcs_check_addr_entry() argument
1182 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_check_addr_entry()
1183 list_for_each(l, &card->ipm_list) { in lcs_check_addr_entry()
1192 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_check_addr_entry()
1196 static void lcs_set_mc_addresses(struct lcs_card *card, in lcs_set_mc_addresses() argument
1208 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev); in lcs_set_mc_addresses()
1209 ipm = lcs_check_addr_entry(card, im4, buf); in lcs_set_mc_addresses()
1221 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_set_mc_addresses()
1223 list_add(&ipm->list, &card->ipm_list); in lcs_set_mc_addresses()
1224 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_set_mc_addresses()
1231 struct lcs_card *card; in lcs_register_mc_addresses() local
1234 card = (struct lcs_card *) data; in lcs_register_mc_addresses()
1236 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD)) in lcs_register_mc_addresses()
1240 in4_dev = in_dev_get(card->dev); in lcs_register_mc_addresses()
1244 lcs_remove_mc_addresses(card,in4_dev); in lcs_register_mc_addresses()
1245 lcs_set_mc_addresses(card, in4_dev); in lcs_register_mc_addresses()
1249 netif_carrier_off(card->dev); in lcs_register_mc_addresses()
1250 netif_tx_disable(card->dev); in lcs_register_mc_addresses()
1251 wait_event(card->write.wait_q, in lcs_register_mc_addresses()
1252 (card->write.state != LCS_CH_STATE_RUNNING)); in lcs_register_mc_addresses()
1253 lcs_fix_multicast_list(card); in lcs_register_mc_addresses()
1254 if (card->state == DEV_STATE_UP) { in lcs_register_mc_addresses()
1255 netif_carrier_on(card->dev); in lcs_register_mc_addresses()
1256 netif_wake_queue(card->dev); in lcs_register_mc_addresses()
1259 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD); in lcs_register_mc_addresses()
1272 struct lcs_card *card; in lcs_set_multicast_list() local
1275 card = (struct lcs_card *) dev->ml_priv; in lcs_set_multicast_list()
1277 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) in lcs_set_multicast_list()
1278 schedule_work(&card->kernel_thread_starter); in lcs_set_multicast_list()
1352 lcs_schedule_recovery(struct lcs_card *card) in lcs_schedule_recovery() argument
1355 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD)) in lcs_schedule_recovery()
1356 schedule_work(&card->kernel_thread_starter); in lcs_schedule_recovery()
1365 struct lcs_card *card; in lcs_irq() local
1373 card = CARD_FROM_DEV(cdev); in lcs_irq()
1374 if (card->read.ccwdev == cdev) in lcs_irq()
1375 channel = &card->read; in lcs_irq()
1377 channel = &card->write; in lcs_irq()
1399 lcs_schedule_recovery(card); in lcs_irq()
1400 wake_up(&card->wait_q); in lcs_irq()
1484 __lcs_emit_txbuffer(struct lcs_card *card) in __lcs_emit_txbuffer() argument
1487 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0; in __lcs_emit_txbuffer()
1488 card->tx_buffer->count += 2; in __lcs_emit_txbuffer()
1489 lcs_ready_buffer(&card->write, card->tx_buffer); in __lcs_emit_txbuffer()
1490 card->tx_buffer = NULL; in __lcs_emit_txbuffer()
1491 card->tx_emitted++; in __lcs_emit_txbuffer()
1500 struct lcs_card *card; in lcs_txbuffer_cb() local
1505 card = container_of(channel, struct lcs_card, write); in lcs_txbuffer_cb()
1506 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev)) in lcs_txbuffer_cb()
1507 netif_wake_queue(card->dev); in lcs_txbuffer_cb()
1508 spin_lock(&card->lock); in lcs_txbuffer_cb()
1509 card->tx_emitted--; in lcs_txbuffer_cb()
1510 if (card->tx_emitted <= 0 && card->tx_buffer != NULL) in lcs_txbuffer_cb()
1515 __lcs_emit_txbuffer(card); in lcs_txbuffer_cb()
1516 spin_unlock(&card->lock); in lcs_txbuffer_cb()
1523 __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, in __lcs_start_xmit() argument
1531 card->stats.tx_dropped++; in __lcs_start_xmit()
1532 card->stats.tx_errors++; in __lcs_start_xmit()
1535 if (card->state != DEV_STATE_UP) { in __lcs_start_xmit()
1537 card->stats.tx_dropped++; in __lcs_start_xmit()
1538 card->stats.tx_errors++; in __lcs_start_xmit()
1539 card->stats.tx_carrier_errors++; in __lcs_start_xmit()
1546 netif_stop_queue(card->dev); in __lcs_start_xmit()
1547 spin_lock(&card->lock); in __lcs_start_xmit()
1548 if (card->tx_buffer != NULL && in __lcs_start_xmit()
1549 card->tx_buffer->count + sizeof(struct lcs_header) + in __lcs_start_xmit()
1552 __lcs_emit_txbuffer(card); in __lcs_start_xmit()
1553 if (card->tx_buffer == NULL) { in __lcs_start_xmit()
1555 card->tx_buffer = lcs_get_buffer(&card->write); in __lcs_start_xmit()
1556 if (card->tx_buffer == NULL) { in __lcs_start_xmit()
1557 card->stats.tx_dropped++; in __lcs_start_xmit()
1561 card->tx_buffer->callback = lcs_txbuffer_cb; in __lcs_start_xmit()
1562 card->tx_buffer->count = 0; in __lcs_start_xmit()
1565 (card->tx_buffer->data + card->tx_buffer->count); in __lcs_start_xmit()
1566 card->tx_buffer->count += skb->len + sizeof(struct lcs_header); in __lcs_start_xmit()
1567 header->offset = card->tx_buffer->count; in __lcs_start_xmit()
1568 header->type = card->lan_type; in __lcs_start_xmit()
1569 header->slot = card->portno; in __lcs_start_xmit()
1571 spin_unlock(&card->lock); in __lcs_start_xmit()
1572 card->stats.tx_bytes += skb->len; in __lcs_start_xmit()
1573 card->stats.tx_packets++; in __lcs_start_xmit()
1575 netif_wake_queue(card->dev); in __lcs_start_xmit()
1576 spin_lock(&card->lock); in __lcs_start_xmit()
1577 if (card->tx_emitted <= 0 && card->tx_buffer != NULL) in __lcs_start_xmit()
1579 __lcs_emit_txbuffer(card); in __lcs_start_xmit()
1581 spin_unlock(&card->lock); in __lcs_start_xmit()
1588 struct lcs_card *card; in lcs_start_xmit() local
1592 card = (struct lcs_card *) dev->ml_priv; in lcs_start_xmit()
1593 rc = __lcs_start_xmit(card, skb, dev); in lcs_start_xmit()
1601 lcs_startlan_auto(struct lcs_card *card) in lcs_startlan_auto() argument
1607 card->lan_type = LCS_FRAME_TYPE_ENET; in lcs_startlan_auto()
1608 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); in lcs_startlan_auto()
1614 card->lan_type = LCS_FRAME_TYPE_FDDI; in lcs_startlan_auto()
1615 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); in lcs_startlan_auto()
1623 lcs_startlan(struct lcs_card *card) in lcs_startlan() argument
1629 if (card->portno != LCS_INVALID_PORT_NO) { in lcs_startlan()
1630 if (card->lan_type == LCS_FRAME_TYPE_AUTO) in lcs_startlan()
1631 rc = lcs_startlan_auto(card); in lcs_startlan()
1633 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); in lcs_startlan()
1636 card->portno = i; in lcs_startlan()
1637 if (card->lan_type != LCS_FRAME_TYPE_AUTO) in lcs_startlan()
1638 rc = lcs_send_startlan(card, in lcs_startlan()
1642 rc = lcs_startlan_auto(card); in lcs_startlan()
1648 return lcs_send_lanstat(card); in lcs_startlan()
1657 lcs_detect(struct lcs_card *card) in lcs_detect() argument
1662 /* start/reset card */ in lcs_detect()
1663 if (card->dev) in lcs_detect()
1664 netif_stop_queue(card->dev); in lcs_detect()
1665 rc = lcs_stop_channels(card); in lcs_detect()
1667 rc = lcs_start_channels(card); in lcs_detect()
1669 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP); in lcs_detect()
1671 rc = lcs_startlan(card); in lcs_detect()
1675 card->state = DEV_STATE_UP; in lcs_detect()
1677 card->state = DEV_STATE_DOWN; in lcs_detect()
1678 card->write.state = LCS_CH_STATE_INIT; in lcs_detect()
1679 card->read.state = LCS_CH_STATE_INIT; in lcs_detect()
1685 * LCS Stop card
1688 lcs_stopcard(struct lcs_card *card) in lcs_stopcard() argument
1694 if (card->read.state != LCS_CH_STATE_STOPPED && in lcs_stopcard()
1695 card->write.state != LCS_CH_STATE_STOPPED && in lcs_stopcard()
1696 card->read.state != LCS_CH_STATE_ERROR && in lcs_stopcard()
1697 card->write.state != LCS_CH_STATE_ERROR && in lcs_stopcard()
1698 card->state == DEV_STATE_UP) { in lcs_stopcard()
1699 lcs_clear_multicast_list(card); in lcs_stopcard()
1700 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP); in lcs_stopcard()
1701 rc = lcs_send_shutdown(card); in lcs_stopcard()
1703 rc = lcs_stop_channels(card); in lcs_stopcard()
1704 card->state = DEV_STATE_DOWN; in lcs_stopcard()
1715 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter); in lcs_start_kernel_thread() local
1717 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) in lcs_start_kernel_thread()
1718 kthread_run(lcs_recovery, card, "lcs_recover"); in lcs_start_kernel_thread()
1720 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD)) in lcs_start_kernel_thread()
1721 kthread_run(lcs_register_mc_addresses, card, "regipm"); in lcs_start_kernel_thread()
1729 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd) in lcs_get_control() argument
1736 lcs_schedule_recovery(card); in lcs_get_control()
1739 if (card->dev) { in lcs_get_control()
1741 card->dev->name); in lcs_get_control()
1742 netif_carrier_off(card->dev); in lcs_get_control()
1750 lcs_notify_lancmd_waiters(card, cmd); in lcs_get_control()
1757 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len) in lcs_get_skb() argument
1762 if (card->dev == NULL || in lcs_get_skb()
1763 card->state != DEV_STATE_UP) in lcs_get_skb()
1764 /* The card isn't up. Ignore the packet. */ in lcs_get_skb()
1769 dev_err(&card->dev->dev, in lcs_get_skb()
1771 card->dev->name); in lcs_get_skb()
1772 card->stats.rx_dropped++; in lcs_get_skb()
1776 skb->protocol = card->lan_type_trans(skb, card->dev); in lcs_get_skb()
1777 card->stats.rx_bytes += skb_len; in lcs_get_skb()
1778 card->stats.rx_packets++; in lcs_get_skb()
1780 *((__u32 *)skb->cb) = ++card->pkt_seq; in lcs_get_skb()
1790 struct lcs_card *card; in lcs_get_frames_cb() local
1800 card = container_of(channel, struct lcs_card, read); in lcs_get_frames_cb()
1807 card->stats.rx_length_errors++; in lcs_get_frames_cb()
1808 card->stats.rx_errors++; in lcs_get_frames_cb()
1814 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr); in lcs_get_frames_cb()
1819 lcs_get_skb(card, (char *)(lcs_hdr + 1), in lcs_get_frames_cb()
1832 lcs_ready_buffer(&card->read, buffer); in lcs_get_frames_cb()
1841 struct lcs_card *card; in lcs_getstats() local
1844 card = (struct lcs_card *) dev->ml_priv; in lcs_getstats()
1845 return &card->stats; in lcs_getstats()
1855 struct lcs_card *card; in lcs_stop_device() local
1859 card = (struct lcs_card *) dev->ml_priv; in lcs_stop_device()
1863 wait_event(card->write.wait_q, in lcs_stop_device()
1864 (card->write.state != LCS_CH_STATE_RUNNING)); in lcs_stop_device()
1865 rc = lcs_stopcard(card); in lcs_stop_device()
1867 dev_err(&card->dev->dev, in lcs_stop_device()
1879 struct lcs_card *card; in lcs_open_device() local
1883 card = (struct lcs_card *) dev->ml_priv; in lcs_open_device()
1885 rc = lcs_detect(card); in lcs_open_device()
1893 card->state = DEV_STATE_UP; in lcs_open_device()
1904 struct lcs_card *card; in lcs_portno_show() local
1906 card = dev_get_drvdata(dev); in lcs_portno_show()
1908 if (!card) in lcs_portno_show()
1911 return sprintf(buf, "%d\n", card->portno); in lcs_portno_show()
1920 struct lcs_card *card; in lcs_portno_store() local
1924 card = dev_get_drvdata(dev); in lcs_portno_store()
1926 if (!card) in lcs_portno_store()
1933 card->portno = value; in lcs_portno_store()
1934 if (card->dev) in lcs_portno_store()
1935 card->dev->dev_port = card->portno; in lcs_portno_store()
1947 "OSA LCS card",
1969 struct lcs_card *card; in lcs_timeout_show() local
1971 card = dev_get_drvdata(dev); in lcs_timeout_show()
1973 return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0; in lcs_timeout_show()
1979 struct lcs_card *card; in lcs_timeout_store() local
1983 card = dev_get_drvdata(dev); in lcs_timeout_store()
1985 if (!card) in lcs_timeout_store()
1992 card->lancmd_timeout = value; in lcs_timeout_store()
2004 struct lcs_card *card = dev_get_drvdata(dev); in lcs_dev_recover_store() local
2008 if (!card) in lcs_dev_recover_store()
2010 if (card->state != DEV_STATE_UP) in lcs_dev_recover_store()
2014 lcs_schedule_recovery(card); in lcs_dev_recover_store()
2045 struct lcs_card *card; in lcs_probe_device() local
2051 card = lcs_alloc_card(); in lcs_probe_device()
2052 if (!card) { in lcs_probe_device()
2057 dev_set_drvdata(&ccwgdev->dev, card); in lcs_probe_device()
2060 card->gdev = ccwgdev; in lcs_probe_device()
2061 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread); in lcs_probe_device()
2062 card->thread_start_mask = 0; in lcs_probe_device()
2063 card->thread_allowed_mask = 0; in lcs_probe_device()
2064 card->thread_running_mask = 0; in lcs_probe_device()
2073 struct lcs_card *card; in lcs_register_netdev() local
2076 card = dev_get_drvdata(&ccwgdev->dev); in lcs_register_netdev()
2077 if (card->dev->reg_state != NETREG_UNINITIALIZED) in lcs_register_netdev()
2079 SET_NETDEV_DEV(card->dev, &ccwgdev->dev); in lcs_register_netdev()
2080 return register_netdev(card->dev); in lcs_register_netdev()
2104 struct lcs_card *card; in lcs_new_device() local
2109 card = dev_get_drvdata(&ccwgdev->dev); in lcs_new_device()
2110 if (!card) in lcs_new_device()
2114 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in lcs_new_device()
2115 card->read.ccwdev = ccwgdev->cdev[0]; in lcs_new_device()
2116 card->write.ccwdev = ccwgdev->cdev[1]; in lcs_new_device()
2118 recover_state = card->state; in lcs_new_device()
2119 rc = ccw_device_set_online(card->read.ccwdev); in lcs_new_device()
2122 rc = ccw_device_set_online(card->write.ccwdev); in lcs_new_device()
2128 lcs_setup_card(card); in lcs_new_device()
2129 rc = lcs_detect(card); in lcs_new_device()
2135 lcs_stopcard(card); in lcs_new_device()
2138 if (card->dev) { in lcs_new_device()
2140 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in lcs_new_device()
2143 switch (card->lan_type) { in lcs_new_device()
2146 card->lan_type_trans = eth_type_trans; in lcs_new_device()
2152 card->lan_type_trans = fddi_type_trans; in lcs_new_device()
2163 card->dev = dev; in lcs_new_device()
2164 card->dev->ml_priv = card; in lcs_new_device()
2165 card->dev->netdev_ops = &lcs_netdev_ops; in lcs_new_device()
2166 card->dev->dev_port = card->portno; in lcs_new_device()
2167 eth_hw_addr_set(card->dev, card->mac); in lcs_new_device()
2169 if (!lcs_check_multicast_support(card)) in lcs_new_device()
2170 card->dev->netdev_ops = &lcs_mc_netdev_ops; in lcs_new_device()
2173 lcs_set_allowed_threads(card,0xffffffff); in lcs_new_device()
2175 lcs_set_multicast_list(card->dev); in lcs_new_device()
2176 card->dev->flags |= IFF_UP; in lcs_new_device()
2177 netif_carrier_on(card->dev); in lcs_new_device()
2178 netif_wake_queue(card->dev); in lcs_new_device()
2179 card->state = DEV_STATE_UP; in lcs_new_device()
2181 lcs_stopcard(card); in lcs_new_device()
2188 pr_info("LCS device %s %s IPv6 support\n", card->dev->name, in lcs_new_device()
2189 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ? in lcs_new_device()
2192 pr_info("LCS device %s %s Multicast support\n", card->dev->name, in lcs_new_device()
2193 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ? in lcs_new_device()
2198 ccw_device_set_offline(card->write.ccwdev); in lcs_new_device()
2200 ccw_device_set_offline(card->read.ccwdev); in lcs_new_device()
2211 struct lcs_card *card; in __lcs_shutdown_device() local
2216 card = dev_get_drvdata(&ccwgdev->dev); in __lcs_shutdown_device()
2217 if (!card) in __lcs_shutdown_device()
2220 lcs_set_allowed_threads(card, 0); in __lcs_shutdown_device()
2221 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD)) in __lcs_shutdown_device()
2224 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in __lcs_shutdown_device()
2225 recover_state = card->state; in __lcs_shutdown_device()
2227 ret = lcs_stop_device(card->dev); in __lcs_shutdown_device()
2228 ret2 = ccw_device_set_offline(card->read.ccwdev); in __lcs_shutdown_device()
2229 ret3 = ccw_device_set_offline(card->write.ccwdev); in __lcs_shutdown_device()
2235 card->state = DEV_STATE_RECOVER; in __lcs_shutdown_device()
2252 struct lcs_card *card; in lcs_recovery() local
2256 card = (struct lcs_card *) ptr; in lcs_recovery()
2259 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD)) in lcs_recovery()
2262 gdev = card->gdev; in lcs_recovery()
2269 card->dev->name); in lcs_recovery()
2272 card->dev->name); in lcs_recovery()
2273 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD); in lcs_recovery()
2278 * lcs_remove_device, free buffers and card
2283 struct lcs_card *card; in lcs_remove_device() local
2285 card = dev_get_drvdata(&ccwgdev->dev); in lcs_remove_device()
2286 if (!card) in lcs_remove_device()
2290 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in lcs_remove_device()
2294 if (card->dev) in lcs_remove_device()
2295 unregister_netdev(card->dev); in lcs_remove_device()
2296 lcs_cleanup_card(card); in lcs_remove_device()
2297 lcs_free_card(card); in lcs_remove_device()