Lines Matching full:card

150  * LCS free memory for card and channels.
153 lcs_free_card(struct lcs_card *card) in lcs_free_card() argument
156 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); in lcs_free_card()
157 kfree(card); in lcs_free_card()
161 * LCS alloc memory for card and channels
166 struct lcs_card *card; in lcs_alloc_card() local
171 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA); in lcs_alloc_card()
172 if (card == NULL) in lcs_alloc_card()
174 card->lan_type = LCS_FRAME_TYPE_AUTO; in lcs_alloc_card()
175 card->pkt_seq = 0; in lcs_alloc_card()
176 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT; in lcs_alloc_card()
178 rc = lcs_alloc_channel(&card->read); in lcs_alloc_card()
181 lcs_free_card(card); in lcs_alloc_card()
185 rc = lcs_alloc_channel(&card->write); in lcs_alloc_card()
188 lcs_cleanup_channel(&card->read); in lcs_alloc_card()
189 lcs_free_card(card); in lcs_alloc_card()
194 INIT_LIST_HEAD(&card->ipm_list); in lcs_alloc_card()
196 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); in lcs_alloc_card()
197 return card; in lcs_alloc_card()
204 lcs_setup_read_ccws(struct lcs_card *card) in lcs_setup_read_ccws() argument
210 memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1)); in lcs_setup_read_ccws()
212 card->read.ccws[cnt].cmd_code = LCS_CCW_READ; in lcs_setup_read_ccws()
213 card->read.ccws[cnt].count = LCS_IOBUFFERSIZE; in lcs_setup_read_ccws()
214 card->read.ccws[cnt].flags = in lcs_setup_read_ccws()
220 card->read.ccws[cnt].cda = in lcs_setup_read_ccws()
221 virt_to_dma32(card->read.iob[cnt].data); in lcs_setup_read_ccws()
223 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET; in lcs_setup_read_ccws()
224 card->read.iob[cnt].callback = lcs_get_frames_cb; in lcs_setup_read_ccws()
225 card->read.iob[cnt].state = LCS_BUF_STATE_READY; in lcs_setup_read_ccws()
226 card->read.iob[cnt].count = LCS_IOBUFFERSIZE; in lcs_setup_read_ccws()
228 card->read.ccws[0].flags &= ~CCW_FLAG_PCI; in lcs_setup_read_ccws()
229 card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI; in lcs_setup_read_ccws()
230 card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND; in lcs_setup_read_ccws()
232 card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER; in lcs_setup_read_ccws()
233 card->read.ccws[LCS_NUM_BUFFS].cda = virt_to_dma32(card->read.ccws); in lcs_setup_read_ccws()
235 card->read.state = LCS_CH_STATE_INIT; in lcs_setup_read_ccws()
237 card->read.io_idx = 0; in lcs_setup_read_ccws()
238 card->read.buf_idx = 0; in lcs_setup_read_ccws()
242 lcs_setup_read(struct lcs_card *card) in lcs_setup_read() argument
246 lcs_setup_read_ccws(card); in lcs_setup_read()
248 card->read.irq_tasklet.data = (unsigned long) &card->read; in lcs_setup_read()
249 card->read.irq_tasklet.func = lcs_tasklet; in lcs_setup_read()
251 init_waitqueue_head(&card->read.wait_q); in lcs_setup_read()
258 lcs_setup_write_ccws(struct lcs_card *card) in lcs_setup_write_ccws() argument
264 memset(card->write.ccws, 0, sizeof(struct ccw1) * (LCS_NUM_BUFFS + 1)); in lcs_setup_write_ccws()
266 card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE; in lcs_setup_write_ccws()
267 card->write.ccws[cnt].count = 0; in lcs_setup_write_ccws()
268 card->write.ccws[cnt].flags = in lcs_setup_write_ccws()
274 card->write.ccws[cnt].cda = in lcs_setup_write_ccws()
275 virt_to_dma32(card->write.iob[cnt].data); in lcs_setup_write_ccws()
278 card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER; in lcs_setup_write_ccws()
279 card->write.ccws[LCS_NUM_BUFFS].cda = virt_to_dma32(card->write.ccws); in lcs_setup_write_ccws()
281 card->read.state = LCS_CH_STATE_INIT; in lcs_setup_write_ccws()
283 card->write.io_idx = 0; in lcs_setup_write_ccws()
284 card->write.buf_idx = 0; in lcs_setup_write_ccws()
288 lcs_setup_write(struct lcs_card *card) in lcs_setup_write() argument
292 lcs_setup_write_ccws(card); in lcs_setup_write()
294 card->write.irq_tasklet.data = (unsigned long) &card->write; in lcs_setup_write()
295 card->write.irq_tasklet.func = lcs_tasklet; in lcs_setup_write()
297 init_waitqueue_head(&card->write.wait_q); in lcs_setup_write()
301 lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads) in lcs_set_allowed_threads() argument
305 spin_lock_irqsave(&card->mask_lock, flags); in lcs_set_allowed_threads()
306 card->thread_allowed_mask = threads; in lcs_set_allowed_threads()
307 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_set_allowed_threads()
308 wake_up(&card->wait_q); in lcs_set_allowed_threads()
310 static int lcs_threads_running(struct lcs_card *card, unsigned long threads) in lcs_threads_running() argument
315 spin_lock_irqsave(&card->mask_lock, flags); in lcs_threads_running()
316 rc = (card->thread_running_mask & threads); in lcs_threads_running()
317 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_threads_running()
322 lcs_wait_for_threads(struct lcs_card *card, unsigned long threads) in lcs_wait_for_threads() argument
324 return wait_event_interruptible(card->wait_q, in lcs_wait_for_threads()
325 lcs_threads_running(card, threads) == 0); in lcs_wait_for_threads()
328 static int lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread) in lcs_set_thread_start_bit() argument
332 spin_lock_irqsave(&card->mask_lock, flags); in lcs_set_thread_start_bit()
333 if ( !(card->thread_allowed_mask & thread) || in lcs_set_thread_start_bit()
334 (card->thread_start_mask & thread) ) { in lcs_set_thread_start_bit()
335 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_set_thread_start_bit()
338 card->thread_start_mask |= thread; in lcs_set_thread_start_bit()
339 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_set_thread_start_bit()
344 lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread) in lcs_clear_thread_running_bit() argument
348 spin_lock_irqsave(&card->mask_lock, flags); in lcs_clear_thread_running_bit()
349 card->thread_running_mask &= ~thread; in lcs_clear_thread_running_bit()
350 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_clear_thread_running_bit()
351 wake_up(&card->wait_q); in lcs_clear_thread_running_bit()
354 static int __lcs_do_run_thread(struct lcs_card *card, unsigned long thread) in __lcs_do_run_thread() argument
359 spin_lock_irqsave(&card->mask_lock, flags); in __lcs_do_run_thread()
360 if (card->thread_start_mask & thread){ in __lcs_do_run_thread()
361 if ((card->thread_allowed_mask & thread) && in __lcs_do_run_thread()
362 !(card->thread_running_mask & thread)){ in __lcs_do_run_thread()
364 card->thread_start_mask &= ~thread; in __lcs_do_run_thread()
365 card->thread_running_mask |= thread; in __lcs_do_run_thread()
369 spin_unlock_irqrestore(&card->mask_lock, flags); in __lcs_do_run_thread()
374 lcs_do_run_thread(struct lcs_card *card, unsigned long thread) in lcs_do_run_thread() argument
377 wait_event(card->wait_q, in lcs_do_run_thread()
378 (rc = __lcs_do_run_thread(card, thread)) >= 0); in lcs_do_run_thread()
383 lcs_do_start_thread(struct lcs_card *card, unsigned long thread) in lcs_do_start_thread() argument
388 spin_lock_irqsave(&card->mask_lock, flags); in lcs_do_start_thread()
390 (u8) card->thread_start_mask, in lcs_do_start_thread()
391 (u8) card->thread_allowed_mask, in lcs_do_start_thread()
392 (u8) card->thread_running_mask); in lcs_do_start_thread()
393 rc = (card->thread_start_mask & thread); in lcs_do_start_thread()
394 spin_unlock_irqrestore(&card->mask_lock, flags); in lcs_do_start_thread()
399 * Initialize channels,card and state machines.
402 lcs_setup_card(struct lcs_card *card) in lcs_setup_card() argument
405 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); in lcs_setup_card()
407 lcs_setup_read(card); in lcs_setup_card()
408 lcs_setup_write(card); in lcs_setup_card()
410 card->state = DEV_STATE_DOWN; in lcs_setup_card()
411 card->tx_buffer = NULL; in lcs_setup_card()
412 card->tx_emitted = 0; in lcs_setup_card()
414 init_waitqueue_head(&card->wait_q); in lcs_setup_card()
415 spin_lock_init(&card->lock); in lcs_setup_card()
416 spin_lock_init(&card->ipm_lock); in lcs_setup_card()
417 spin_lock_init(&card->mask_lock); in lcs_setup_card()
419 INIT_LIST_HEAD(&card->ipm_list); in lcs_setup_card()
421 INIT_LIST_HEAD(&card->lancmd_waiters); in lcs_setup_card()
424 static void lcs_clear_multicast_list(struct lcs_card *card) in lcs_clear_multicast_list() argument
432 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_clear_multicast_list()
433 while (!list_empty(&card->ipm_list)){ in lcs_clear_multicast_list()
434 ipm = list_entry(card->ipm_list.next, in lcs_clear_multicast_list()
438 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_clear_multicast_list()
439 lcs_send_delipm(card, ipm); in lcs_clear_multicast_list()
440 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_clear_multicast_list()
444 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_clear_multicast_list()
449 * Cleanup channels,card and state machines.
452 lcs_cleanup_card(struct lcs_card *card) in lcs_cleanup_card() argument
456 LCS_DBF_HEX(2,setup,&card,sizeof(void*)); in lcs_cleanup_card()
458 if (card->dev != NULL) in lcs_cleanup_card()
459 free_netdev(card->dev); in lcs_cleanup_card()
461 lcs_cleanup_channel(&card->write); in lcs_cleanup_card()
462 lcs_cleanup_channel(&card->read); in lcs_cleanup_card()
546 lcs_start_channels(struct lcs_card *card) in lcs_start_channels() argument
552 rc = lcs_start_channel(&card->read); in lcs_start_channels()
556 rc = lcs_start_channel(&card->write); in lcs_start_channels()
558 lcs_stop_channel(&card->read); in lcs_start_channels()
566 lcs_stop_channels(struct lcs_card *card) in lcs_stop_channels() argument
569 lcs_stop_channel(&card->read); in lcs_stop_channels()
570 lcs_stop_channel(&card->write); in lcs_stop_channels()
729 lcs_get_lancmd(struct lcs_card *card, int count) in lcs_get_lancmd() argument
736 wait_event(card->write.wait_q, in lcs_get_lancmd()
737 ((buffer = lcs_get_buffer(&card->write)) != NULL)); in lcs_get_lancmd()
786 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd) in lcs_notify_lancmd_waiters() argument
792 spin_lock(&card->lock); in lcs_notify_lancmd_waiters()
793 list_for_each_safe(l, n, &card->lancmd_waiters) { in lcs_notify_lancmd_waiters()
799 reply->callback(card, cmd); in lcs_notify_lancmd_waiters()
807 spin_unlock(&card->lock); in lcs_notify_lancmd_waiters()
821 spin_lock_irqsave(&reply->card->lock, flags); in lcs_lancmd_timeout()
823 &reply->card->lancmd_waiters,list) { in lcs_lancmd_timeout()
827 spin_unlock_irqrestore(&reply->card->lock, flags); in lcs_lancmd_timeout()
835 spin_unlock_irqrestore(&reply->card->lock, flags); in lcs_lancmd_timeout()
839 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer, in lcs_send_lancmd() argument
850 cmd->sequence_no = card->sequence_no++; in lcs_send_lancmd()
855 reply->card = card; in lcs_send_lancmd()
856 spin_lock_irqsave(&card->lock, flags); in lcs_send_lancmd()
857 list_add_tail(&reply->list, &card->lancmd_waiters); in lcs_send_lancmd()
858 spin_unlock_irqrestore(&card->lock, flags); in lcs_send_lancmd()
861 rc = lcs_ready_buffer(&card->write, buffer); in lcs_send_lancmd()
865 mod_timer(&reply->timer, jiffies + HZ * card->lancmd_timeout); in lcs_send_lancmd()
878 lcs_send_startup(struct lcs_card *card, __u8 initiator) in lcs_send_startup() argument
884 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_startup()
889 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_startup()
896 lcs_send_shutdown(struct lcs_card *card) in lcs_send_shutdown() argument
902 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_shutdown()
906 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_shutdown()
913 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd) in __lcs_lanstat_cb() argument
916 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH); in __lcs_lanstat_cb()
920 lcs_send_lanstat(struct lcs_card *card) in lcs_send_lanstat() argument
926 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_lanstat()
931 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; in lcs_send_lanstat()
932 cmd->cmd.lcs_std_cmd.portno = card->portno; in lcs_send_lanstat()
933 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb); in lcs_send_lanstat()
940 lcs_send_stoplan(struct lcs_card *card, __u8 initiator) in lcs_send_stoplan() argument
946 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_stoplan()
950 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; in lcs_send_stoplan()
951 cmd->cmd.lcs_std_cmd.portno = card->portno; in lcs_send_stoplan()
952 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_stoplan()
959 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd) in __lcs_send_startlan_cb() argument
962 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type; in __lcs_send_startlan_cb()
963 card->portno = cmd->cmd.lcs_std_cmd.portno; in __lcs_send_startlan_cb()
967 lcs_send_startlan(struct lcs_card *card, __u8 initiator) in lcs_send_startlan() argument
973 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_send_startlan()
977 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; in lcs_send_startlan()
978 cmd->cmd.lcs_std_cmd.portno = card->portno; in lcs_send_startlan()
979 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb); in lcs_send_startlan()
987 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list) in lcs_send_setipm() argument
993 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE); in lcs_send_setipm()
997 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; in lcs_send_setipm()
998 cmd->cmd.lcs_qipassist.portno = card->portno; in lcs_send_setipm()
1004 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_setipm()
1011 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list) in lcs_send_delipm() argument
1017 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE); in lcs_send_delipm()
1021 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; in lcs_send_delipm()
1022 cmd->cmd.lcs_qipassist.portno = card->portno; in lcs_send_delipm()
1028 return lcs_send_lancmd(card, buffer, NULL); in lcs_send_delipm()
1035 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd) in __lcs_check_multicast_cb() argument
1038 card->ip_assists_supported = in __lcs_check_multicast_cb()
1040 card->ip_assists_enabled = in __lcs_check_multicast_cb()
1045 lcs_check_multicast_support(struct lcs_card *card) in lcs_check_multicast_support() argument
1053 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); in lcs_check_multicast_support()
1057 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; in lcs_check_multicast_support()
1058 cmd->cmd.lcs_qipassist.portno = card->portno; in lcs_check_multicast_support()
1061 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb); in lcs_check_multicast_support()
1066 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) in lcs_check_multicast_support()
1072 * set or del multicast address on LCS card
1075 lcs_fix_multicast_list(struct lcs_card *card) in lcs_fix_multicast_list() argument
1084 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1086 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){ in lcs_fix_multicast_list()
1092 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1093 rc = lcs_send_setipm(card, ipm); in lcs_fix_multicast_list()
1094 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1105 list_add_tail(&ipm->list, &card->ipm_list); in lcs_fix_multicast_list()
1110 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1111 lcs_send_delipm(card, ipm); in lcs_fix_multicast_list()
1112 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1121 list_move_tail(&ipm->list, &card->ipm_list); in lcs_fix_multicast_list()
1123 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_fix_multicast_list()
1139 static void lcs_remove_mc_addresses(struct lcs_card *card, in lcs_remove_mc_addresses() argument
1149 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_remove_mc_addresses()
1150 list_for_each(l, &card->ipm_list) { in lcs_remove_mc_addresses()
1154 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev); in lcs_remove_mc_addresses()
1163 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_remove_mc_addresses()
1166 static struct lcs_ipm_list *lcs_check_addr_entry(struct lcs_card *card, in lcs_check_addr_entry() argument
1175 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_check_addr_entry()
1176 list_for_each(l, &card->ipm_list) { in lcs_check_addr_entry()
1185 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_check_addr_entry()
1189 static void lcs_set_mc_addresses(struct lcs_card *card, in lcs_set_mc_addresses() argument
1201 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev); in lcs_set_mc_addresses()
1202 ipm = lcs_check_addr_entry(card, im4, buf); in lcs_set_mc_addresses()
1214 spin_lock_irqsave(&card->ipm_lock, flags); in lcs_set_mc_addresses()
1216 list_add(&ipm->list, &card->ipm_list); in lcs_set_mc_addresses()
1217 spin_unlock_irqrestore(&card->ipm_lock, flags); in lcs_set_mc_addresses()
1224 struct lcs_card *card; in lcs_register_mc_addresses() local
1227 card = (struct lcs_card *) data; in lcs_register_mc_addresses()
1229 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD)) in lcs_register_mc_addresses()
1233 in4_dev = in_dev_get(card->dev); in lcs_register_mc_addresses()
1237 lcs_remove_mc_addresses(card,in4_dev); in lcs_register_mc_addresses()
1238 lcs_set_mc_addresses(card, in4_dev); in lcs_register_mc_addresses()
1242 netif_carrier_off(card->dev); in lcs_register_mc_addresses()
1243 netif_tx_disable(card->dev); in lcs_register_mc_addresses()
1244 wait_event(card->write.wait_q, in lcs_register_mc_addresses()
1245 (card->write.state != LCS_CH_STATE_RUNNING)); in lcs_register_mc_addresses()
1246 lcs_fix_multicast_list(card); in lcs_register_mc_addresses()
1247 if (card->state == DEV_STATE_UP) { in lcs_register_mc_addresses()
1248 netif_carrier_on(card->dev); in lcs_register_mc_addresses()
1249 netif_wake_queue(card->dev); in lcs_register_mc_addresses()
1252 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD); in lcs_register_mc_addresses()
1265 struct lcs_card *card; in lcs_set_multicast_list() local
1268 card = (struct lcs_card *) dev->ml_priv; in lcs_set_multicast_list()
1270 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) in lcs_set_multicast_list()
1271 schedule_work(&card->kernel_thread_starter); in lcs_set_multicast_list()
1345 lcs_schedule_recovery(struct lcs_card *card) in lcs_schedule_recovery() argument
1348 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD)) in lcs_schedule_recovery()
1349 schedule_work(&card->kernel_thread_starter); in lcs_schedule_recovery()
1358 struct lcs_card *card; in lcs_irq() local
1366 card = CARD_FROM_DEV(cdev); in lcs_irq()
1367 if (card->read.ccwdev == cdev) in lcs_irq()
1368 channel = &card->read; in lcs_irq()
1370 channel = &card->write; in lcs_irq()
1392 lcs_schedule_recovery(card); in lcs_irq()
1393 wake_up(&card->wait_q); in lcs_irq()
1477 __lcs_emit_txbuffer(struct lcs_card *card) in __lcs_emit_txbuffer() argument
1480 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0; in __lcs_emit_txbuffer()
1481 card->tx_buffer->count += 2; in __lcs_emit_txbuffer()
1482 lcs_ready_buffer(&card->write, card->tx_buffer); in __lcs_emit_txbuffer()
1483 card->tx_buffer = NULL; in __lcs_emit_txbuffer()
1484 card->tx_emitted++; in __lcs_emit_txbuffer()
1493 struct lcs_card *card; in lcs_txbuffer_cb() local
1498 card = container_of(channel, struct lcs_card, write); in lcs_txbuffer_cb()
1499 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev)) in lcs_txbuffer_cb()
1500 netif_wake_queue(card->dev); in lcs_txbuffer_cb()
1501 spin_lock(&card->lock); in lcs_txbuffer_cb()
1502 card->tx_emitted--; in lcs_txbuffer_cb()
1503 if (card->tx_emitted <= 0 && card->tx_buffer != NULL) in lcs_txbuffer_cb()
1508 __lcs_emit_txbuffer(card); in lcs_txbuffer_cb()
1509 spin_unlock(&card->lock); in lcs_txbuffer_cb()
1515 static netdev_tx_t __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, in __lcs_start_xmit() argument
1523 card->stats.tx_dropped++; in __lcs_start_xmit()
1524 card->stats.tx_errors++; in __lcs_start_xmit()
1527 if (card->state != DEV_STATE_UP) { in __lcs_start_xmit()
1529 card->stats.tx_dropped++; in __lcs_start_xmit()
1530 card->stats.tx_errors++; in __lcs_start_xmit()
1531 card->stats.tx_carrier_errors++; in __lcs_start_xmit()
1538 netif_stop_queue(card->dev); in __lcs_start_xmit()
1539 spin_lock(&card->lock); in __lcs_start_xmit()
1540 if (card->tx_buffer != NULL && in __lcs_start_xmit()
1541 card->tx_buffer->count + sizeof(struct lcs_header) + in __lcs_start_xmit()
1544 __lcs_emit_txbuffer(card); in __lcs_start_xmit()
1545 if (card->tx_buffer == NULL) { in __lcs_start_xmit()
1547 card->tx_buffer = lcs_get_buffer(&card->write); in __lcs_start_xmit()
1548 if (card->tx_buffer == NULL) { in __lcs_start_xmit()
1549 card->stats.tx_dropped++; in __lcs_start_xmit()
1553 card->tx_buffer->callback = lcs_txbuffer_cb; in __lcs_start_xmit()
1554 card->tx_buffer->count = 0; in __lcs_start_xmit()
1557 (card->tx_buffer->data + card->tx_buffer->count); in __lcs_start_xmit()
1558 card->tx_buffer->count += skb->len + sizeof(struct lcs_header); in __lcs_start_xmit()
1559 header->offset = card->tx_buffer->count; in __lcs_start_xmit()
1560 header->type = card->lan_type; in __lcs_start_xmit()
1561 header->slot = card->portno; in __lcs_start_xmit()
1563 spin_unlock(&card->lock); in __lcs_start_xmit()
1564 card->stats.tx_bytes += skb->len; in __lcs_start_xmit()
1565 card->stats.tx_packets++; in __lcs_start_xmit()
1567 netif_wake_queue(card->dev); in __lcs_start_xmit()
1568 spin_lock(&card->lock); in __lcs_start_xmit()
1569 if (card->tx_emitted <= 0 && card->tx_buffer != NULL) in __lcs_start_xmit()
1571 __lcs_emit_txbuffer(card); in __lcs_start_xmit()
1573 spin_unlock(&card->lock); in __lcs_start_xmit()
1579 struct lcs_card *card; in lcs_start_xmit() local
1583 card = (struct lcs_card *) dev->ml_priv; in lcs_start_xmit()
1584 rc = __lcs_start_xmit(card, skb, dev); in lcs_start_xmit()
1592 lcs_startlan_auto(struct lcs_card *card) in lcs_startlan_auto() argument
1597 card->lan_type = LCS_FRAME_TYPE_ENET; in lcs_startlan_auto()
1598 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); in lcs_startlan_auto()
1606 lcs_startlan(struct lcs_card *card) in lcs_startlan() argument
1612 if (card->portno != LCS_INVALID_PORT_NO) { in lcs_startlan()
1613 if (card->lan_type == LCS_FRAME_TYPE_AUTO) in lcs_startlan()
1614 rc = lcs_startlan_auto(card); in lcs_startlan()
1616 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); in lcs_startlan()
1619 card->portno = i; in lcs_startlan()
1620 if (card->lan_type != LCS_FRAME_TYPE_AUTO) in lcs_startlan()
1621 rc = lcs_send_startlan(card, in lcs_startlan()
1625 rc = lcs_startlan_auto(card); in lcs_startlan()
1631 return lcs_send_lanstat(card); in lcs_startlan()
1640 lcs_detect(struct lcs_card *card) in lcs_detect() argument
1645 /* start/reset card */ in lcs_detect()
1646 if (card->dev) in lcs_detect()
1647 netif_stop_queue(card->dev); in lcs_detect()
1648 rc = lcs_stop_channels(card); in lcs_detect()
1650 rc = lcs_start_channels(card); in lcs_detect()
1652 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP); in lcs_detect()
1654 rc = lcs_startlan(card); in lcs_detect()
1658 card->state = DEV_STATE_UP; in lcs_detect()
1660 card->state = DEV_STATE_DOWN; in lcs_detect()
1661 card->write.state = LCS_CH_STATE_INIT; in lcs_detect()
1662 card->read.state = LCS_CH_STATE_INIT; in lcs_detect()
1668 * LCS Stop card
1671 lcs_stopcard(struct lcs_card *card) in lcs_stopcard() argument
1677 if (card->read.state != LCS_CH_STATE_STOPPED && in lcs_stopcard()
1678 card->write.state != LCS_CH_STATE_STOPPED && in lcs_stopcard()
1679 card->read.state != LCS_CH_STATE_ERROR && in lcs_stopcard()
1680 card->write.state != LCS_CH_STATE_ERROR && in lcs_stopcard()
1681 card->state == DEV_STATE_UP) { in lcs_stopcard()
1682 lcs_clear_multicast_list(card); in lcs_stopcard()
1683 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP); in lcs_stopcard()
1684 rc = lcs_send_shutdown(card); in lcs_stopcard()
1686 rc = lcs_stop_channels(card); in lcs_stopcard()
1687 card->state = DEV_STATE_DOWN; in lcs_stopcard()
1698 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter); in lcs_start_kernel_thread() local
1700 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) in lcs_start_kernel_thread()
1701 kthread_run(lcs_recovery, card, "lcs_recover"); in lcs_start_kernel_thread()
1703 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD)) in lcs_start_kernel_thread()
1704 kthread_run(lcs_register_mc_addresses, card, "regipm"); in lcs_start_kernel_thread()
1712 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd) in lcs_get_control() argument
1719 lcs_schedule_recovery(card); in lcs_get_control()
1722 if (card->dev) { in lcs_get_control()
1724 card->dev->name); in lcs_get_control()
1725 netif_carrier_off(card->dev); in lcs_get_control()
1733 lcs_notify_lancmd_waiters(card, cmd); in lcs_get_control()
1740 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len) in lcs_get_skb() argument
1745 if (card->dev == NULL || in lcs_get_skb()
1746 card->state != DEV_STATE_UP) in lcs_get_skb()
1747 /* The card isn't up. Ignore the packet. */ in lcs_get_skb()
1752 dev_err(&card->dev->dev, in lcs_get_skb()
1754 card->dev->name); in lcs_get_skb()
1755 card->stats.rx_dropped++; in lcs_get_skb()
1759 skb->protocol = card->lan_type_trans(skb, card->dev); in lcs_get_skb()
1760 card->stats.rx_bytes += skb_len; in lcs_get_skb()
1761 card->stats.rx_packets++; in lcs_get_skb()
1763 *((__u32 *)skb->cb) = ++card->pkt_seq; in lcs_get_skb()
1773 struct lcs_card *card; in lcs_get_frames_cb() local
1783 card = container_of(channel, struct lcs_card, read); in lcs_get_frames_cb()
1790 card->stats.rx_length_errors++; in lcs_get_frames_cb()
1791 card->stats.rx_errors++; in lcs_get_frames_cb()
1795 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr); in lcs_get_frames_cb()
1797 lcs_get_skb(card, (char *)(lcs_hdr + 1), in lcs_get_frames_cb()
1801 dev_info_once(&card->dev->dev, in lcs_get_frames_cb()
1809 lcs_ready_buffer(&card->read, buffer); in lcs_get_frames_cb()
1818 struct lcs_card *card; in lcs_getstats() local
1821 card = (struct lcs_card *) dev->ml_priv; in lcs_getstats()
1822 return &card->stats; in lcs_getstats()
1832 struct lcs_card *card; in lcs_stop_device() local
1836 card = (struct lcs_card *) dev->ml_priv; in lcs_stop_device()
1840 wait_event(card->write.wait_q, in lcs_stop_device()
1841 (card->write.state != LCS_CH_STATE_RUNNING)); in lcs_stop_device()
1842 rc = lcs_stopcard(card); in lcs_stop_device()
1844 dev_err(&card->dev->dev, in lcs_stop_device()
1856 struct lcs_card *card; in lcs_open_device() local
1860 card = (struct lcs_card *) dev->ml_priv; in lcs_open_device()
1862 rc = lcs_detect(card); in lcs_open_device()
1870 card->state = DEV_STATE_UP; in lcs_open_device()
1881 struct lcs_card *card; in lcs_portno_show() local
1883 card = dev_get_drvdata(dev); in lcs_portno_show()
1885 if (!card) in lcs_portno_show()
1888 return sysfs_emit(buf, "%d\n", card->portno); in lcs_portno_show()
1897 struct lcs_card *card; in lcs_portno_store() local
1901 card = dev_get_drvdata(dev); in lcs_portno_store()
1903 if (!card) in lcs_portno_store()
1910 card->portno = value; in lcs_portno_store()
1911 if (card->dev) in lcs_portno_store()
1912 card->dev->dev_port = card->portno; in lcs_portno_store()
1924 "OSA LCS card",
1947 struct lcs_card *card; in lcs_timeout_show() local
1949 card = dev_get_drvdata(dev); in lcs_timeout_show()
1951 return card ? sysfs_emit(buf, "%u\n", card->lancmd_timeout) : 0; in lcs_timeout_show()
1957 struct lcs_card *card; in lcs_timeout_store() local
1961 card = dev_get_drvdata(dev); in lcs_timeout_store()
1963 if (!card) in lcs_timeout_store()
1970 card->lancmd_timeout = value; in lcs_timeout_store()
1982 struct lcs_card *card = dev_get_drvdata(dev); in lcs_dev_recover_store() local
1986 if (!card) in lcs_dev_recover_store()
1988 if (card->state != DEV_STATE_UP) in lcs_dev_recover_store()
1992 lcs_schedule_recovery(card); in lcs_dev_recover_store()
2023 struct lcs_card *card; in lcs_probe_device() local
2029 card = lcs_alloc_card(); in lcs_probe_device()
2030 if (!card) { in lcs_probe_device()
2035 dev_set_drvdata(&ccwgdev->dev, card); in lcs_probe_device()
2038 card->gdev = ccwgdev; in lcs_probe_device()
2039 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread); in lcs_probe_device()
2040 card->thread_start_mask = 0; in lcs_probe_device()
2041 card->thread_allowed_mask = 0; in lcs_probe_device()
2042 card->thread_running_mask = 0; in lcs_probe_device()
2051 struct lcs_card *card; in lcs_register_netdev() local
2054 card = dev_get_drvdata(&ccwgdev->dev); in lcs_register_netdev()
2055 if (card->dev->reg_state != NETREG_UNINITIALIZED) in lcs_register_netdev()
2057 SET_NETDEV_DEV(card->dev, &ccwgdev->dev); in lcs_register_netdev()
2058 return register_netdev(card->dev); in lcs_register_netdev()
2082 struct lcs_card *card; in lcs_new_device() local
2087 card = dev_get_drvdata(&ccwgdev->dev); in lcs_new_device()
2088 if (!card) in lcs_new_device()
2092 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in lcs_new_device()
2093 card->read.ccwdev = ccwgdev->cdev[0]; in lcs_new_device()
2094 card->write.ccwdev = ccwgdev->cdev[1]; in lcs_new_device()
2096 recover_state = card->state; in lcs_new_device()
2097 rc = ccw_device_set_online(card->read.ccwdev); in lcs_new_device()
2100 rc = ccw_device_set_online(card->write.ccwdev); in lcs_new_device()
2106 lcs_setup_card(card); in lcs_new_device()
2107 rc = lcs_detect(card); in lcs_new_device()
2113 lcs_stopcard(card); in lcs_new_device()
2116 if (card->dev) { in lcs_new_device()
2118 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in lcs_new_device()
2121 switch (card->lan_type) { in lcs_new_device()
2123 card->lan_type_trans = eth_type_trans; in lcs_new_device()
2133 card->dev = dev; in lcs_new_device()
2134 card->dev->ml_priv = card; in lcs_new_device()
2135 card->dev->netdev_ops = &lcs_netdev_ops; in lcs_new_device()
2136 card->dev->dev_port = card->portno; in lcs_new_device()
2137 eth_hw_addr_set(card->dev, card->mac); in lcs_new_device()
2139 if (!lcs_check_multicast_support(card)) in lcs_new_device()
2140 card->dev->netdev_ops = &lcs_mc_netdev_ops; in lcs_new_device()
2143 lcs_set_allowed_threads(card,0xffffffff); in lcs_new_device()
2145 lcs_set_multicast_list(card->dev); in lcs_new_device()
2146 card->dev->flags |= IFF_UP; in lcs_new_device()
2147 netif_carrier_on(card->dev); in lcs_new_device()
2148 netif_wake_queue(card->dev); in lcs_new_device()
2149 card->state = DEV_STATE_UP; in lcs_new_device()
2151 lcs_stopcard(card); in lcs_new_device()
2158 pr_info("LCS device %s %s IPv6 support\n", card->dev->name, in lcs_new_device()
2159 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ? in lcs_new_device()
2162 pr_info("LCS device %s %s Multicast support\n", card->dev->name, in lcs_new_device()
2163 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ? in lcs_new_device()
2168 ccw_device_set_offline(card->write.ccwdev); in lcs_new_device()
2170 ccw_device_set_offline(card->read.ccwdev); in lcs_new_device()
2181 struct lcs_card *card; in __lcs_shutdown_device() local
2186 card = dev_get_drvdata(&ccwgdev->dev); in __lcs_shutdown_device()
2187 if (!card) in __lcs_shutdown_device()
2190 lcs_set_allowed_threads(card, 0); in __lcs_shutdown_device()
2191 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD)) in __lcs_shutdown_device()
2194 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in __lcs_shutdown_device()
2195 recover_state = card->state; in __lcs_shutdown_device()
2197 ret = lcs_stop_device(card->dev); in __lcs_shutdown_device()
2198 ret2 = ccw_device_set_offline(card->read.ccwdev); in __lcs_shutdown_device()
2199 ret3 = ccw_device_set_offline(card->write.ccwdev); in __lcs_shutdown_device()
2205 card->state = DEV_STATE_RECOVER; in __lcs_shutdown_device()
2222 struct lcs_card *card; in lcs_recovery() local
2226 card = (struct lcs_card *) ptr; in lcs_recovery()
2229 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD)) in lcs_recovery()
2232 gdev = card->gdev; in lcs_recovery()
2239 card->dev->name); in lcs_recovery()
2242 card->dev->name); in lcs_recovery()
2243 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD); in lcs_recovery()
2248 * lcs_remove_device, free buffers and card
2253 struct lcs_card *card; in lcs_remove_device() local
2255 card = dev_get_drvdata(&ccwgdev->dev); in lcs_remove_device()
2256 if (!card) in lcs_remove_device()
2260 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); in lcs_remove_device()
2264 if (card->dev) in lcs_remove_device()
2265 unregister_netdev(card->dev); in lcs_remove_device()
2266 lcs_cleanup_card(card); in lcs_remove_device()
2267 lcs_free_card(card); in lcs_remove_device()