X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fs390%2Fnet%2Fqeth_main.c;h=d2efa5ff125def3fc2ea205165c071a6d43a9c64;hb=refs%2Fheads%2Fvserver;hp=290866932345033456941809962527109db6fa7d;hpb=4e76c8a9fa413ccc09d3f7f664183dcce3555d57;p=linux-2.6.git diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 290866932..d2efa5ff1 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -27,7 +27,6 @@ */ -#include #include #include #include @@ -85,6 +84,8 @@ static debug_info_t *qeth_dbf_qerr = NULL; DEFINE_PER_CPU(char[256], qeth_dbf_txt_buf); +static struct lock_class_key qdio_out_skb_queue_key; + /** * some more definitions and declarations */ @@ -470,7 +471,7 @@ qeth_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) channel->state == CH_STATE_UP) qeth_issue_next_read(card); - tasklet_schedule(&channel->irq_tasklet); + qeth_irq_tasklet((unsigned long)channel); return; out: wake_up(&card->wait_q); @@ -949,40 +950,6 @@ qeth_do_run_thread(struct qeth_card *card, unsigned long thread) return rc; } -static int -qeth_register_ip_addresses(void *ptr) -{ - struct qeth_card *card; - - card = (struct qeth_card *) ptr; - daemonize("qeth_reg_ip"); - QETH_DBF_TEXT(trace,4,"regipth1"); - if (!qeth_do_run_thread(card, QETH_SET_IP_THREAD)) - return 0; - QETH_DBF_TEXT(trace,4,"regipth2"); - qeth_set_ip_addr_list(card); - qeth_clear_thread_running_bit(card, QETH_SET_IP_THREAD); - return 0; -} - -/* - * Drive the SET_PROMISC_MODE thread - */ -static int -qeth_set_promisc_mode(void *ptr) -{ - struct qeth_card *card = (struct qeth_card *) ptr; - - daemonize("qeth_setprm"); - QETH_DBF_TEXT(trace,4,"setprm1"); - if (!qeth_do_run_thread(card, QETH_SET_PROMISC_MODE_THREAD)) - return 0; - QETH_DBF_TEXT(trace,4,"setprm2"); - qeth_setadp_promisc_mode(card); - qeth_clear_thread_running_bit(card, QETH_SET_PROMISC_MODE_THREAD); - return 0; -} - static int qeth_recover(void *ptr) { @@ -1038,18 +1005,14 @@ qeth_do_start_thread(struct qeth_card *card, unsigned long thread) } static void -qeth_start_kernel_thread(struct qeth_card *card) +qeth_start_kernel_thread(struct work_struct *work) { + struct qeth_card *card = container_of(work, struct qeth_card, kernel_thread_starter); QETH_DBF_TEXT(trace , 2, "strthrd"); if (card->read.state != CH_STATE_UP && card->write.state != CH_STATE_UP) return; - - if (qeth_do_start_thread(card, QETH_SET_IP_THREAD)) - kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD); - if (qeth_do_start_thread(card, QETH_SET_PROMISC_MODE_THREAD)) - kernel_thread(qeth_set_promisc_mode, (void *)card, SIGCHLD); if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) kernel_thread(qeth_recover, (void *) card, SIGCHLD); } @@ -1072,6 +1035,7 @@ qeth_set_intial_options(struct qeth_card *card) card->options.layer2 = 1; else card->options.layer2 = 0; + card->options.performance_stats = 0; } /** @@ -1101,8 +1065,7 @@ qeth_setup_card(struct qeth_card *card) card->thread_start_mask = 0; card->thread_allowed_mask = 0; card->thread_running_mask = 0; - INIT_WORK(&card->kernel_thread_starter, - (void *)qeth_start_kernel_thread,card); + INIT_WORK(&card->kernel_thread_starter, qeth_start_kernel_thread); INIT_LIST_HEAD(&card->ip_list); card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL); if (!card->ip_tbd_list) { @@ -1611,8 +1574,6 @@ qeth_issue_next_read(struct qeth_card *card) return -ENOMEM; } qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE); - wait_event(card->wait_q, - atomic_cmpxchg(&card->read.irq_pending, 0, 1) == 0); QETH_DBF_TEXT(trace, 6, "noirqpnd"); rc = ccw_device_start(card->read.ccwdev, &card->read.ccw, (addr_t) iob, 0, 0); @@ -1633,6 +1594,7 @@ qeth_alloc_reply(struct qeth_card *card) reply = kzalloc(sizeof(struct qeth_reply), GFP_ATOMIC); if (reply){ atomic_set(&reply->refcnt, 1); + atomic_set(&reply->received, 0); reply->card = card; }; return reply; @@ -1653,31 +1615,6 @@ qeth_put_reply(struct qeth_reply *reply) kfree(reply); } -static void -qeth_cmd_timeout(unsigned long data) -{ - struct qeth_reply *reply, *list_reply, *r; - unsigned long flags; - - reply = (struct qeth_reply *) data; - spin_lock_irqsave(&reply->card->lock, flags); - list_for_each_entry_safe(list_reply, r, - &reply->card->cmd_waiter_list, list) { - if (reply == list_reply){ - qeth_get_reply(reply); - list_del_init(&reply->list); - spin_unlock_irqrestore(&reply->card->lock, flags); - reply->rc = -ETIME; - reply->received = 1; - wake_up(&reply->wait_q); - qeth_put_reply(reply); - return; - } - } - spin_unlock_irqrestore(&reply->card->lock, flags); -} - - static struct qeth_ipa_cmd * qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob) { @@ -1707,6 +1644,7 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob) "IP address reset.\n", QETH_CARD_IFNAME(card), card->info.chpid); + netif_carrier_on(card->dev); qeth_schedule_recovery(card); return NULL; case IPA_CMD_MODCCID: @@ -1742,7 +1680,7 @@ qeth_clear_ipacmd_list(struct qeth_card *card) list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) { qeth_get_reply(reply); reply->rc = -EIO; - reply->received = 1; + atomic_inc(&reply->received); list_del_init(&reply->list); wake_up(&reply->wait_q); qeth_put_reply(reply); @@ -1811,7 +1749,7 @@ qeth_send_control_data_cb(struct qeth_channel *channel, &card->cmd_waiter_list); spin_unlock_irqrestore(&card->lock, flags); } else { - reply->received = 1; + atomic_inc(&reply->received); wake_up(&reply->wait_q); } qeth_put_reply(reply); @@ -1855,7 +1793,7 @@ qeth_send_control_data(struct qeth_card *card, int len, int rc; unsigned long flags; struct qeth_reply *reply = NULL; - struct timer_list timer; + unsigned long timeout; QETH_DBF_TEXT(trace, 2, "sendctl"); @@ -1870,21 +1808,20 @@ qeth_send_control_data(struct qeth_card *card, int len, reply->seqno = QETH_IDX_COMMAND_SEQNO; else reply->seqno = card->seqno.ipa++; - init_timer(&timer); - timer.function = qeth_cmd_timeout; - timer.data = (unsigned long) reply; init_waitqueue_head(&reply->wait_q); spin_lock_irqsave(&card->lock, flags); list_add_tail(&reply->list, &card->cmd_waiter_list); spin_unlock_irqrestore(&card->lock, flags); QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); - wait_event(card->wait_q, - atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0); + + while (atomic_cmpxchg(&card->write.irq_pending, 0, 1)) ; qeth_prepare_control_data(card, len, iob); + if (IS_IPA(iob->data)) - timer.expires = jiffies + QETH_IPA_TIMEOUT; + timeout = jiffies + QETH_IPA_TIMEOUT; else - timer.expires = jiffies + QETH_TIMEOUT; + timeout = jiffies + QETH_TIMEOUT; + QETH_DBF_TEXT(trace, 6, "noirqpnd"); spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); rc = ccw_device_start(card->write.ccwdev, &card->write.ccw, @@ -1903,9 +1840,16 @@ qeth_send_control_data(struct qeth_card *card, int len, wake_up(&card->wait_q); return rc; } - add_timer(&timer); - wait_event(reply->wait_q, reply->received); - del_timer_sync(&timer); + while (!atomic_read(&reply->received)) { + if (time_after(jiffies, timeout)) { + spin_lock_irqsave(&reply->card->lock, flags); + list_del_init(&reply->list); + spin_unlock_irqrestore(&reply->card->lock, flags); + reply->rc = -ETIME; + atomic_inc(&reply->received); + wake_up(&reply->wait_q); + } + }; rc = reply->rc; qeth_put_reply(reply); return rc; @@ -2464,60 +2408,28 @@ qeth_rebuild_skb_fake_ll(struct qeth_card *card, struct sk_buff *skb, } static inline void -qeth_rebuild_skb_vlan(struct qeth_card *card, struct sk_buff *skb, - struct qeth_hdr *hdr) -{ -#ifdef CONFIG_QETH_VLAN - u16 *vlan_tag; - - if (hdr->hdr.l3.ext_flags & - (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) { - vlan_tag = (u16 *) skb_push(skb, VLAN_HLEN); - *vlan_tag = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)? - hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]); - *(vlan_tag + 1) = skb->protocol; - skb->protocol = __constant_htons(ETH_P_8021Q); - } -#endif /* CONFIG_QETH_VLAN */ -} - -static inline __u16 qeth_layer2_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, struct qeth_hdr *hdr) { - unsigned short vlan_id = 0; -#ifdef CONFIG_QETH_VLAN - struct vlan_hdr *vhdr; -#endif - skb->pkt_type = PACKET_HOST; skb->protocol = qeth_type_trans(skb, skb->dev); if (card->options.checksum_type == NO_CHECKSUMMING) skb->ip_summed = CHECKSUM_UNNECESSARY; else skb->ip_summed = CHECKSUM_NONE; -#ifdef CONFIG_QETH_VLAN - if (hdr->hdr.l2.flags[2] & (QETH_LAYER2_FLAG_VLAN)) { - vhdr = (struct vlan_hdr *) skb->data; - skb->protocol = - __constant_htons(vhdr->h_vlan_encapsulated_proto); - vlan_id = hdr->hdr.l2.vlan_id; - skb_pull(skb, VLAN_HLEN); - } -#endif *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno; - return vlan_id; } -static inline void +static inline __u16 qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, struct qeth_hdr *hdr) { + unsigned short vlan_id = 0; #ifdef CONFIG_QETH_IPV6 if (hdr->hdr.l3.flags & QETH_HDR_PASSTHRU) { skb->pkt_type = PACKET_HOST; skb->protocol = qeth_type_trans(skb, card->dev); - return; + return 0; } #endif /* CONFIG_QETH_IPV6 */ skb->protocol = htons((hdr->hdr.l3.flags & QETH_HDR_IPV6)? ETH_P_IPV6 : @@ -2539,7 +2451,13 @@ qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, default: skb->pkt_type = PACKET_HOST; } - qeth_rebuild_skb_vlan(card, skb, hdr); + + if (hdr->hdr.l3.ext_flags & + (QETH_HDR_EXT_VLAN_FRAME | QETH_HDR_EXT_INCLUDE_VLAN_TAG)) { + vlan_id = (hdr->hdr.l3.ext_flags & QETH_HDR_EXT_VLAN_FRAME)? + hdr->hdr.l3.vlan_id : *((u16 *)&hdr->hdr.l3.dest_addr[12]); + } + if (card->options.fake_ll) qeth_rebuild_skb_fake_ll(card, skb, hdr); else @@ -2555,6 +2473,7 @@ qeth_rebuild_skb(struct qeth_card *card, struct sk_buff *skb, else skb->ip_summed = SW_CHECKSUMMING; } + return vlan_id; } static inline void @@ -2571,16 +2490,15 @@ qeth_process_inbound_buffer(struct qeth_card *card, /* get first element of current buffer */ element = (struct qdio_buffer_element *)&buf->buffer->element[0]; offset = 0; -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.bufs_rec++; -#endif + if (card->options.performance_stats) + card->perf_stats.bufs_rec++; while((skb = qeth_get_next_skb(card, buf->buffer, &element, &offset, &hdr))) { skb->dev = card->dev; if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) - vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr); + qeth_layer2_rebuild_skb(card, skb, hdr); else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3) - qeth_rebuild_skb(card, skb, hdr); + vlan_tag = qeth_rebuild_skb(card, skb, hdr); else { /*in case of OSN*/ skb_push(skb, sizeof(struct qeth_hdr)); memcpy(skb->data, hdr, sizeof(struct qeth_hdr)); @@ -2590,14 +2508,19 @@ qeth_process_inbound_buffer(struct qeth_card *card, dev_kfree_skb_any(skb); continue; } + if (card->info.type == QETH_CARD_TYPE_OSN) + rxrc = card->osn_info.data_cb(skb); + else #ifdef CONFIG_QETH_VLAN if (vlan_tag) - vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag); + if (card->vlangrp) + vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag); + else { + dev_kfree_skb_any(skb); + continue; + } else #endif - if (card->info.type == QETH_CARD_TYPE_OSN) - rxrc = card->osn_info.data_cb(skb); - else rxrc = netif_rx(skb); card->dev->last_rx = jiffies; card->stats.rx_packets++; @@ -2625,7 +2548,7 @@ qeth_init_input_buffer(struct qeth_card *card, struct qeth_qdio_buffer *buf) { struct qeth_buffer_pool_entry *pool_entry; int i; - + pool_entry = qeth_get_buffer_pool_entry(card); /* * since the buffer is accessed only from the input_tasklet @@ -2699,17 +2622,18 @@ qeth_queue_input_buffer(struct qeth_card *card, int index) * 'index') un-requeued -> this buffer is the first buffer that * will be requeued the next time */ -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_do_qdio_cnt++; - card->perf_stats.inbound_do_qdio_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.inbound_do_qdio_cnt++; + card->perf_stats.inbound_do_qdio_start_time = + qeth_get_micros(); + } rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT | QDIO_FLAG_UNDER_INTERRUPT, 0, queue->next_buf_to_init, count, NULL); -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_do_qdio_time += qeth_get_micros() - - card->perf_stats.inbound_do_qdio_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.inbound_do_qdio_time += + qeth_get_micros() - + card->perf_stats.inbound_do_qdio_start_time; if (rc){ PRINT_WARN("qeth_queue_input_buffer's do_QDIO " "return %i (device %s).\n", @@ -2745,10 +2669,10 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status, QETH_DBF_TEXT(trace, 6, "qdinput"); card = (struct qeth_card *) card_ptr; net_dev = card->dev; -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_cnt++; - card->perf_stats.inbound_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.inbound_cnt++; + card->perf_stats.inbound_start_time = qeth_get_micros(); + } if (status & QDIO_STATUS_LOOK_FOR_ERROR) { if (status & QDIO_STATUS_ACTIVATE_CHECK_CONDITION){ QETH_DBF_TEXT(trace, 1,"qdinchk"); @@ -2770,10 +2694,9 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status, qeth_put_buffer_pool_entry(card, buffer->pool_entry); qeth_queue_input_buffer(card, index); } -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.inbound_time += qeth_get_micros() - - card->perf_stats.inbound_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.inbound_time += qeth_get_micros() - + card->perf_stats.inbound_start_time; } static inline int @@ -2863,10 +2786,11 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, } queue->card->dev->trans_start = jiffies; -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.outbound_do_qdio_cnt++; - queue->card->perf_stats.outbound_do_qdio_start_time = qeth_get_micros(); -#endif + if (queue->card->options.performance_stats) { + queue->card->perf_stats.outbound_do_qdio_cnt++; + queue->card->perf_stats.outbound_do_qdio_start_time = + qeth_get_micros(); + } if (under_int) rc = do_QDIO(CARD_DDEV(queue->card), QDIO_FLAG_SYNC_OUTPUT | QDIO_FLAG_UNDER_INTERRUPT, @@ -2874,10 +2798,10 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, else rc = do_QDIO(CARD_DDEV(queue->card), QDIO_FLAG_SYNC_OUTPUT, queue->queue_no, index, count, NULL); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.outbound_do_qdio_time += qeth_get_micros() - - queue->card->perf_stats.outbound_do_qdio_start_time; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.outbound_do_qdio_time += + qeth_get_micros() - + queue->card->perf_stats.outbound_do_qdio_start_time; if (rc){ QETH_DBF_TEXT(trace, 2, "flushbuf"); QETH_DBF_TEXT_(trace, 2, " err%d", rc); @@ -2889,9 +2813,8 @@ qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int, return; } atomic_add(count, &queue->used_buffers); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.bufs_sent += count; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.bufs_sent += count; } /* @@ -2906,9 +2829,8 @@ qeth_switch_to_packing_if_needed(struct qeth_qdio_out_q *queue) >= QETH_HIGH_WATERMARK_PACK){ /* switch non-PACKING -> PACKING */ QETH_DBF_TEXT(trace, 6, "np->pack"); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.sc_dp_p++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.sc_dp_p++; queue->do_pack = 1; } } @@ -2931,9 +2853,8 @@ qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) <= QETH_LOW_WATERMARK_PACK) { /* switch PACKING -> non-PACKING */ QETH_DBF_TEXT(trace, 6, "pack->np"); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.sc_p_dp++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.sc_p_dp++; queue->do_pack = 0; /* flush packing buffers */ buffer = &queue->bufs[queue->next_buf_to_fill]; @@ -2945,7 +2866,7 @@ qeth_switch_to_nonpacking_if_needed(struct qeth_qdio_out_q *queue) queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q; - } + } } } return flush_count; @@ -2986,7 +2907,7 @@ qeth_check_outbound_queue(struct qeth_qdio_out_q *queue) */ if ((atomic_read(&queue->used_buffers) <= QETH_LOW_WATERMARK_PACK) || !atomic_read(&queue->set_pci_flags_count)){ - if (atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH) == + if (atomic_xchg(&queue->state, QETH_OUT_Q_LOCKED_FLUSH) == QETH_OUT_Q_UNLOCKED) { /* * If we get in here, there was no action in @@ -3001,11 +2922,10 @@ qeth_check_outbound_queue(struct qeth_qdio_out_q *queue) !atomic_read(&queue->set_pci_flags_count)) flush_cnt += qeth_flush_buffers_on_no_pci(queue); -#ifdef CONFIG_QETH_PERF_STATS - if (q_was_packing) + if (queue->card->options.performance_stats && + q_was_packing) queue->card->perf_stats.bufs_sent_pack += flush_cnt; -#endif if (flush_cnt) qeth_flush_buffers(queue, 1, index, flush_cnt); atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); @@ -3035,10 +2955,11 @@ qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status, return; } } -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_handler_cnt++; - card->perf_stats.outbound_handler_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.outbound_handler_cnt++; + card->perf_stats.outbound_handler_start_time = + qeth_get_micros(); + } for(i = first_element; i < (first_element + count); ++i){ buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; /*we only handle the KICK_IT error by doing a recovery */ @@ -3057,10 +2978,9 @@ qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status, qeth_check_outbound_queue(queue); netif_wake_queue(queue->card->dev); -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_handler_time += qeth_get_micros() - - card->perf_stats.outbound_handler_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.outbound_handler_time += qeth_get_micros() - + card->perf_stats.outbound_handler_start_time; } static void @@ -3184,13 +3104,14 @@ qeth_alloc_qdio_buffers(struct qeth_card *card) QETH_DBF_TEXT(setup, 2, "allcqdbf"); - if (card->qdio.state == QETH_QDIO_ALLOCATED) + if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED, + QETH_QDIO_ALLOCATED) != QETH_QDIO_UNINITIALIZED) return 0; card->qdio.in_q = kmalloc(sizeof(struct qeth_qdio_q), GFP_KERNEL|GFP_DMA); if (!card->qdio.in_q) - return - ENOMEM; + goto out_nomem; QETH_DBF_TEXT(setup, 2, "inq"); QETH_DBF_HEX(setup, 2, &card->qdio.in_q, sizeof(void *)); memset(card->qdio.in_q, 0, sizeof(struct qeth_qdio_q)); @@ -3199,27 +3120,19 @@ qeth_alloc_qdio_buffers(struct qeth_card *card) card->qdio.in_q->bufs[i].buffer = &card->qdio.in_q->qdio_bufs[i]; /* inbound buffer pool */ - if (qeth_alloc_buffer_pool(card)){ - kfree(card->qdio.in_q); - return -ENOMEM; - } + if (qeth_alloc_buffer_pool(card)) + goto out_freeinq; /* outbound */ card->qdio.out_qs = kmalloc(card->qdio.no_out_queues * sizeof(struct qeth_qdio_out_q *), GFP_KERNEL); - if (!card->qdio.out_qs){ - qeth_free_buffer_pool(card); - return -ENOMEM; - } - for (i = 0; i < card->qdio.no_out_queues; ++i){ + if (!card->qdio.out_qs) + goto out_freepool; + for (i = 0; i < card->qdio.no_out_queues; ++i) { card->qdio.out_qs[i] = kmalloc(sizeof(struct qeth_qdio_out_q), GFP_KERNEL|GFP_DMA); - if (!card->qdio.out_qs[i]){ - while (i > 0) - kfree(card->qdio.out_qs[--i]); - kfree(card->qdio.out_qs); - return -ENOMEM; - } + if (!card->qdio.out_qs[i]) + goto out_freeoutq; QETH_DBF_TEXT_(setup, 2, "outq %i", i); QETH_DBF_HEX(setup, 2, &card->qdio.out_qs[i], sizeof(void *)); memset(card->qdio.out_qs[i], 0, sizeof(struct qeth_qdio_out_q)); @@ -3230,11 +3143,25 @@ qeth_alloc_qdio_buffers(struct qeth_card *card) &card->qdio.out_qs[i]->qdio_bufs[j]; skb_queue_head_init(&card->qdio.out_qs[i]->bufs[j]. skb_list); + lockdep_set_class( + &card->qdio.out_qs[i]->bufs[j].skb_list.lock, + &qdio_out_skb_queue_key); INIT_LIST_HEAD(&card->qdio.out_qs[i]->bufs[j].ctx_list); } } - card->qdio.state = QETH_QDIO_ALLOCATED; return 0; + +out_freeoutq: + while (i > 0) + kfree(card->qdio.out_qs[--i]); + kfree(card->qdio.out_qs); +out_freepool: + qeth_free_buffer_pool(card); +out_freeinq: + kfree(card->qdio.in_q); +out_nomem: + atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); + return -ENOMEM; } static void @@ -3243,7 +3170,8 @@ qeth_free_qdio_buffers(struct qeth_card *card) int i, j; QETH_DBF_TEXT(trace, 2, "freeqdbf"); - if (card->qdio.state == QETH_QDIO_UNINITIALIZED) + if (atomic_xchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED) == + QETH_QDIO_UNINITIALIZED) return; kfree(card->qdio.in_q); /* inbound buffer pool */ @@ -3256,7 +3184,6 @@ qeth_free_qdio_buffers(struct qeth_card *card) kfree(card->qdio.out_qs[i]); } kfree(card->qdio.out_qs); - card->qdio.state = QETH_QDIO_UNINITIALIZED; } static void @@ -3278,7 +3205,7 @@ static void qeth_init_qdio_info(struct qeth_card *card) { QETH_DBF_TEXT(setup, 4, "intqdinf"); - card->qdio.state = QETH_QDIO_UNINITIALIZED; + atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); /* inbound */ card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; card->qdio.init_pool.buf_count = QETH_IN_BUF_COUNT_DEFAULT; @@ -3341,7 +3268,7 @@ qeth_qdio_establish(struct qeth_card *card) struct qdio_buffer **in_sbal_ptrs; struct qdio_buffer **out_sbal_ptrs; int i, j, k; - int rc; + int rc = 0; QETH_DBF_TEXT(setup, 2, "qdioest"); @@ -3400,8 +3327,10 @@ qeth_qdio_establish(struct qeth_card *card) init_data.input_sbal_addr_array = (void **) in_sbal_ptrs; init_data.output_sbal_addr_array = (void **) out_sbal_ptrs; - if (!(rc = qdio_initialize(&init_data))) - card->qdio.state = QETH_QDIO_ESTABLISHED; + if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ALLOCATED, + QETH_QDIO_ESTABLISHED) == QETH_QDIO_ALLOCATED) + if ((rc = qdio_initialize(&init_data))) + atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); kfree(out_sbal_ptrs); kfree(in_sbal_ptrs); @@ -3517,13 +3446,20 @@ qeth_qdio_clear_card(struct qeth_card *card, int use_halt) int rc = 0; QETH_DBF_TEXT(trace,3,"qdioclr"); - if (card->qdio.state == QETH_QDIO_ESTABLISHED){ + switch (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ESTABLISHED, + QETH_QDIO_CLEANING)) { + case QETH_QDIO_ESTABLISHED: if ((rc = qdio_cleanup(CARD_DDEV(card), - (card->info.type == QETH_CARD_TYPE_IQD) ? - QDIO_FLAG_CLEANUP_USING_HALT : - QDIO_FLAG_CLEANUP_USING_CLEAR))) + (card->info.type == QETH_CARD_TYPE_IQD) ? + QDIO_FLAG_CLEANUP_USING_HALT : + QDIO_FLAG_CLEANUP_USING_CLEAR))) QETH_DBF_TEXT_(trace, 3, "1err%d", rc); - card->qdio.state = QETH_QDIO_ALLOCATED; + atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); + break; + case QETH_QDIO_CLEANING: + return rc; + default: + break; } if ((rc = qeth_clear_halt_card(card, use_halt))) QETH_DBF_TEXT_(trace, 3, "2err%d", rc); @@ -3683,10 +3619,10 @@ qeth_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) /* return OK; otherwise ksoftirqd goes to 100% */ return NETDEV_TX_OK; } -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_cnt++; - card->perf_stats.outbound_start_time = qeth_get_micros(); -#endif + if (card->options.performance_stats) { + card->perf_stats.outbound_cnt++; + card->perf_stats.outbound_start_time = qeth_get_micros(); + } netif_stop_queue(dev); if ((rc = qeth_send_packet(card, skb))) { if (rc == -EBUSY) { @@ -3700,10 +3636,9 @@ qeth_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } } netif_wake_queue(dev); -#ifdef CONFIG_QETH_PERF_STATS - card->perf_stats.outbound_time += qeth_get_micros() - - card->perf_stats.outbound_start_time; -#endif + if (card->options.performance_stats) + card->perf_stats.outbound_time += qeth_get_micros() - + card->perf_stats.outbound_start_time; return rc; } @@ -3918,49 +3853,68 @@ qeth_get_ip_version(struct sk_buff *skb) } } -static inline int -qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb, - struct qeth_hdr **hdr, int ipv) +static inline struct qeth_hdr * +__qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb, int ipv) { - int rc = 0; #ifdef CONFIG_QETH_VLAN u16 *tag; -#endif - - QETH_DBF_TEXT(trace, 6, "prepskb"); - if (card->info.type == QETH_CARD_TYPE_OSN) { - *hdr = (struct qeth_hdr *)(*skb)->data; - return rc; - } - rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr)); - if (rc) - return rc; -#ifdef CONFIG_QETH_VLAN - if (card->vlangrp && vlan_tx_tag_present(*skb) && + if (card->vlangrp && vlan_tx_tag_present(skb) && ((ipv == 6) || card->options.layer2) ) { /* * Move the mac addresses (6 bytes src, 6 bytes dest) * to the beginning of the new header. We are using three * memcpys instead of one memmove to save cycles. */ - skb_push(*skb, VLAN_HLEN); - memcpy((*skb)->data, (*skb)->data + 4, 4); - memcpy((*skb)->data + 4, (*skb)->data + 8, 4); - memcpy((*skb)->data + 8, (*skb)->data + 12, 4); - tag = (u16 *)((*skb)->data + 12); + skb_push(skb, VLAN_HLEN); + memcpy(skb->data, skb->data + 4, 4); + memcpy(skb->data + 4, skb->data + 8, 4); + memcpy(skb->data + 8, skb->data + 12, 4); + tag = (u16 *)(skb->data + 12); /* * first two bytes = ETH_P_8021Q (0x8100) * second two bytes = VLANID */ *tag = __constant_htons(ETH_P_8021Q); - *(tag + 1) = htons(vlan_tx_tag_get(*skb)); + *(tag + 1) = htons(vlan_tx_tag_get(skb)); } #endif - *hdr = (struct qeth_hdr *) - qeth_push_skb(card, skb, sizeof(struct qeth_hdr)); - if (*hdr == NULL) - return -EINVAL; - return 0; + return ((struct qeth_hdr *) + qeth_push_skb(card, skb, sizeof(struct qeth_hdr))); +} + +static inline void +__qeth_free_new_skb(struct sk_buff *orig_skb, struct sk_buff *new_skb) +{ + if (orig_skb != new_skb) + dev_kfree_skb_any(new_skb); +} + +static inline struct sk_buff * +qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb, + struct qeth_hdr **hdr, int ipv) +{ + struct sk_buff *new_skb, *new_skb2; + + QETH_DBF_TEXT(trace, 6, "prepskb"); + new_skb = skb; + new_skb = qeth_pskb_unshare(skb, GFP_ATOMIC); + if (!new_skb) + return NULL; + new_skb2 = qeth_realloc_headroom(card, new_skb, + sizeof(struct qeth_hdr)); + if (!new_skb2) { + __qeth_free_new_skb(skb, new_skb); + return NULL; + } + if (new_skb != skb) + __qeth_free_new_skb(new_skb2, new_skb); + new_skb = new_skb2; + *hdr = __qeth_prepare_skb(card, new_skb, ipv); + if (*hdr == NULL) { + __qeth_free_new_skb(skb, new_skb); + return NULL; + } + return new_skb; } static inline u8 @@ -4202,9 +4156,8 @@ qeth_fill_buffer(struct qeth_qdio_out_q *queue, flush_cnt = 1; } else { QETH_DBF_TEXT(trace, 6, "fillbfpa"); -#ifdef CONFIG_QETH_PERF_STATS - queue->card->perf_stats.skbs_sent_pack++; -#endif + if (queue->card->options.performance_stats) + queue->card->perf_stats.skbs_sent_pack++; if (buf->next_element_to_fill >= QETH_MAX_BUFFER_ELEMENTS(queue->card)) { /* @@ -4241,21 +4194,15 @@ qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue, * check if buffer is empty to make sure that we do not 'overtake' * ourselves and try to fill a buffer that is already primed */ - if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) { - card->stats.tx_dropped++; - atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); - return -EBUSY; - } + if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) + goto out; if (ctx == NULL) queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) % QDIO_MAX_BUFFERS_PER_Q; else { buffers_needed = qeth_eddp_check_buffers_for_context(queue,ctx); - if (buffers_needed < 0) { - card->stats.tx_dropped++; - atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); - return -EBUSY; - } + if (buffers_needed < 0) + goto out; queue->next_buf_to_fill = (queue->next_buf_to_fill + buffers_needed) % QDIO_MAX_BUFFERS_PER_Q; @@ -4270,6 +4217,9 @@ qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue, qeth_flush_buffers(queue, 0, index, flush_cnt); } return 0; +out: + atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); + return -EBUSY; } static inline int @@ -4295,8 +4245,7 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, * check if buffer is empty to make sure that we do not 'overtake' * ourselves and try to fill a buffer that is already primed */ - if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){ - card->stats.tx_dropped++; + if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) { atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); return -EBUSY; } @@ -4319,7 +4268,6 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, * again */ if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){ - card->stats.tx_dropped++; qeth_flush_buffers(queue, 0, start_index, flush_count); atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED); return -EBUSY; @@ -4330,7 +4278,6 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, * free buffers) to handle eddp context */ if (qeth_eddp_check_buffers_for_context(queue,ctx) < 0){ printk("eddp tx_dropped 1\n"); - card->stats.tx_dropped++; rc = -EBUSY; goto out; } @@ -4342,7 +4289,6 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, tmp = qeth_eddp_fill_buffer(queue,ctx,queue->next_buf_to_fill); if (tmp < 0) { printk("eddp tx_dropped 2\n"); - card->stats.tx_dropped++; rc = - EBUSY; goto out; } @@ -4354,7 +4300,7 @@ out: if (flush_count) qeth_flush_buffers(queue, 0, start_index, flush_count); else if (!atomic_read(&queue->set_pci_flags_count)) - atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH); + atomic_xchg(&queue->state, QETH_OUT_Q_LOCKED_FLUSH); /* * queue->state will go from LOCKED -> UNLOCKED or from * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us @@ -4376,10 +4322,8 @@ out: qeth_flush_buffers(queue, 0, start_index, flush_count); } /* at this point the queue is UNLOCKED again */ -#ifdef CONFIG_QETH_PERF_STATS - if (do_pack) + if (queue->card->options.performance_stats && do_pack) queue->card->perf_stats.bufs_sent_pack += flush_count; -#endif /* CONFIG_QETH_PERF_STATS */ return rc; } @@ -4390,21 +4334,21 @@ qeth_get_elements_no(struct qeth_card *card, void *hdr, { int elements_needed = 0; - if (skb_shinfo(skb)->nr_frags > 0) { + if (skb_shinfo(skb)->nr_frags > 0) elements_needed = (skb_shinfo(skb)->nr_frags + 1); - } - if (elements_needed == 0 ) + if (elements_needed == 0) elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE) + skb->len) >> PAGE_SHIFT); if ((elements_needed + elems) > QETH_MAX_BUFFER_ELEMENTS(card)){ - PRINT_ERR("qeth_do_send_packet: invalid size of " - "IP packet (Number=%d / Length=%d). Discarded.\n", + PRINT_ERR("Invalid size of IP packet " + "(Number=%d / Length=%d). Discarded.\n", (elements_needed+elems), skb->len); return 0; } return elements_needed; } + static inline int qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) { @@ -4417,107 +4361,111 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) struct qeth_eddp_context *ctx = NULL; int tx_bytes = skb->len; unsigned short nr_frags = skb_shinfo(skb)->nr_frags; + unsigned short tso_size = skb_shinfo(skb)->gso_size; + struct sk_buff *new_skb, *new_skb2; int rc; QETH_DBF_TEXT(trace, 6, "sendpkt"); + new_skb = skb; + if ((card->info.type == QETH_CARD_TYPE_OSN) && + (skb->protocol == htons(ETH_P_IPV6))) + return -EPERM; + cast_type = qeth_get_cast_type(card, skb); + if ((cast_type == RTN_BROADCAST) && + (card->info.broadcast_capable == 0)) + return -EPERM; + queue = card->qdio.out_qs + [qeth_get_priority_queue(card, skb, ipv, cast_type)]; if (!card->options.layer2) { ipv = qeth_get_ip_version(skb); if ((card->dev->hard_header == qeth_fake_header) && ipv) { - if ((skb = qeth_pskb_unshare(skb,GFP_ATOMIC)) == NULL) { - card->stats.tx_dropped++; - dev_kfree_skb_irq(skb); - return 0; - } + new_skb = qeth_pskb_unshare(skb, GFP_ATOMIC); + if (!new_skb) + return -ENOMEM; if(card->dev->type == ARPHRD_IEEE802_TR){ - skb_pull(skb, QETH_FAKE_LL_LEN_TR); + skb_pull(new_skb, QETH_FAKE_LL_LEN_TR); } else { - skb_pull(skb, QETH_FAKE_LL_LEN_ETH); + skb_pull(new_skb, QETH_FAKE_LL_LEN_ETH); } } } - if ((card->info.type == QETH_CARD_TYPE_OSN) && - (skb->protocol == htons(ETH_P_IPV6))) { - dev_kfree_skb_any(skb); - return 0; - } - cast_type = qeth_get_cast_type(card, skb); - if ((cast_type == RTN_BROADCAST) && - (card->info.broadcast_capable == 0)){ - card->stats.tx_dropped++; - card->stats.tx_errors++; - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; - } - queue = card->qdio.out_qs - [qeth_get_priority_queue(card, skb, ipv, cast_type)]; - if (skb_is_gso(skb)) large_send = card->options.large_send; - - /*are we able to do TSO ? If so ,prepare and send it from here */ + /* check on OSN device*/ + if (card->info.type == QETH_CARD_TYPE_OSN) + hdr = (struct qeth_hdr *)new_skb->data; + /*are we able to do TSO ? */ if ((large_send == QETH_LARGE_SEND_TSO) && (cast_type == RTN_UNSPEC)) { - rc = qeth_tso_prepare_packet(card, skb, ipv, cast_type); + rc = qeth_tso_prepare_packet(card, new_skb, ipv, cast_type); if (rc) { - card->stats.tx_dropped++; - card->stats.tx_errors++; - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; + __qeth_free_new_skb(skb, new_skb); + return rc; } elements_needed++; - } else { - if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) { - QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc); - return rc; + } else if (card->info.type != QETH_CARD_TYPE_OSN) { + new_skb2 = qeth_prepare_skb(card, new_skb, &hdr, ipv); + if (!new_skb2) { + __qeth_free_new_skb(skb, new_skb); + return -EINVAL; } - if (card->info.type != QETH_CARD_TYPE_OSN) - qeth_fill_header(card, hdr, skb, ipv, cast_type); + if (new_skb != skb) + __qeth_free_new_skb(new_skb2, new_skb); + new_skb = new_skb2; + qeth_fill_header(card, hdr, new_skb, ipv, cast_type); } - if (large_send == QETH_LARGE_SEND_EDDP) { - ctx = qeth_eddp_create_context(card, skb, hdr); + ctx = qeth_eddp_create_context(card, new_skb, hdr); if (ctx == NULL) { + __qeth_free_new_skb(skb, new_skb); PRINT_WARN("could not create eddp context\n"); return -EINVAL; } } else { - int elems = qeth_get_elements_no(card,(void*) hdr, skb, + int elems = qeth_get_elements_no(card,(void*) hdr, new_skb, elements_needed); - if (!elems) + if (!elems) { + __qeth_free_new_skb(skb, new_skb); return -EINVAL; + } elements_needed += elems; } if (card->info.type != QETH_CARD_TYPE_IQD) - rc = qeth_do_send_packet(card, queue, skb, hdr, + rc = qeth_do_send_packet(card, queue, new_skb, hdr, elements_needed, ctx); else - rc = qeth_do_send_packet_fast(card, queue, skb, hdr, + rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr, elements_needed, ctx); - if (!rc){ + if (!rc) { card->stats.tx_packets++; card->stats.tx_bytes += tx_bytes; -#ifdef CONFIG_QETH_PERF_STATS - if (skb_is_gso(skb) && !(large_send == QETH_LARGE_SEND_NO)) { - card->perf_stats.large_send_bytes += skb->len; - card->perf_stats.large_send_cnt++; - } - if (nr_frags > 0){ - card->perf_stats.sg_skbs_sent++; - /* nr_frags + skb->data */ - card->perf_stats.sg_frags_sent += - nr_frags + 1; + if (new_skb != skb) + dev_kfree_skb_any(skb); + if (card->options.performance_stats) { + if (tso_size && + !(large_send == QETH_LARGE_SEND_NO)) { + card->perf_stats.large_send_bytes += tx_bytes; + card->perf_stats.large_send_cnt++; + } + if (nr_frags > 0) { + card->perf_stats.sg_skbs_sent++; + /* nr_frags + skb->data */ + card->perf_stats.sg_frags_sent += + nr_frags + 1; + } } -#endif /* CONFIG_QETH_PERF_STATS */ + } else { + card->stats.tx_dropped++; + __qeth_free_new_skb(skb, new_skb); } if (ctx != NULL) { /* drop creator's reference */ qeth_eddp_put_context(ctx); /* free skb; it's not referenced by a buffer */ - if (rc == 0) - dev_kfree_skb_any(skb); - + if (!rc) + dev_kfree_skb_any(new_skb); } return rc; } @@ -4796,7 +4744,7 @@ static struct qeth_cmd_buffer * qeth_get_setassparms_cmd(struct qeth_card *, enum qeth_ipa_funcs, __u16, __u16, enum qeth_prot_versions); static int -qeth_arp_query(struct qeth_card *card, char *udata) +qeth_arp_query(struct qeth_card *card, char __user *udata) { struct qeth_cmd_buffer *iob; struct qeth_arp_query_info qinfo = {0, }; @@ -4830,9 +4778,11 @@ qeth_arp_query(struct qeth_card *card, char *udata) "(0x%x/%d)\n", QETH_CARD_IFNAME(card), qeth_arp_get_error_cause(&rc), tmp, tmp); - copy_to_user(udata, qinfo.udata, 4); + if (copy_to_user(udata, qinfo.udata, 4)) + rc = -EFAULT; } else { - copy_to_user(udata, qinfo.udata, qinfo.udata_len); + if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) + rc = -EFAULT; } kfree(qinfo.udata); return rc; @@ -4929,7 +4879,7 @@ qeth_get_adapter_cmd(struct qeth_card *card, __u32 command, __u32 cmdlen) * function to send SNMP commands to OSA-E card */ static int -qeth_snmp_command(struct qeth_card *card, char *udata) +qeth_snmp_command(struct qeth_card *card, char __user *udata) { struct qeth_cmd_buffer *iob; struct qeth_ipa_cmd *cmd; @@ -4978,8 +4928,10 @@ qeth_snmp_command(struct qeth_card *card, char *udata) if (rc) PRINT_WARN("SNMP command failed on %s: (0x%x)\n", QETH_CARD_IFNAME(card), rc); - else - copy_to_user(udata, qinfo.udata, qinfo.udata_len); + else { + if (copy_to_user(udata, qinfo.udata, qinfo.udata_len)) + rc = -EFAULT; + } kfree(ureq); kfree(qinfo.udata); @@ -5271,6 +5223,7 @@ qeth_free_vlan_buffer(struct qeth_card *card, struct qeth_qdio_out_buffer *buf, struct sk_buff_head tmp_list; skb_queue_head_init(&tmp_list); + lockdep_set_class(&tmp_list.lock, &qdio_out_skb_queue_key); for(i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i){ while ((skb = skb_dequeue(&buf->skb_list))){ if (vlan_tx_tag_present(skb) && @@ -5529,12 +5482,10 @@ qeth_set_multicast_list(struct net_device *dev) qeth_add_multicast_ipv6(card); #endif out: - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) return; - if (qeth_set_thread_start_bit(card, QETH_SET_PROMISC_MODE_THREAD)==0) - schedule_work(&card->kernel_thread_starter); + qeth_setadp_promisc_mode(card); } static int @@ -6335,6 +6286,42 @@ static struct ethtool_ops qeth_ethtool_ops = { .set_tso = qeth_ethtool_set_tso, }; +static int +qeth_hard_header_parse(struct sk_buff *skb, unsigned char *haddr) +{ + struct qeth_card *card; + struct ethhdr *eth; + + card = qeth_get_card_from_dev(skb->dev); + if (card->options.layer2) + goto haveheader; +#ifdef CONFIG_QETH_IPV6 + /* cause of the manipulated arp constructor and the ARP + flag for OSAE devices we have some nasty exceptions */ + if (card->info.type == QETH_CARD_TYPE_OSAE) { + if (!card->options.fake_ll) { + if ((skb->pkt_type==PACKET_OUTGOING) && + (skb->protocol==ETH_P_IPV6)) + goto haveheader; + else + return 0; + } else { + if ((skb->pkt_type==PACKET_OUTGOING) && + (skb->protocol==ETH_P_IP)) + return 0; + else + goto haveheader; + } + } +#endif + if (!card->options.fake_ll) + return 0; +haveheader: + eth = eth_hdr(skb); + memcpy(haddr, eth->h_source, ETH_ALEN); + return ETH_ALEN; +} + static int qeth_netdev_init(struct net_device *dev) { @@ -6373,7 +6360,10 @@ qeth_netdev_init(struct net_device *dev) if (card->options.fake_ll && (qeth_get_netdev_flags(card) & IFF_NOARP)) dev->hard_header = qeth_fake_header; - dev->hard_header_parse = NULL; + if (dev->type == ARPHRD_IEEE802_TR) + dev->hard_header_parse = NULL; + else + dev->hard_header_parse = qeth_hard_header_parse; dev->set_mac_address = qeth_layer2_set_mac_address; dev->flags |= qeth_get_netdev_flags(card); if ((card->options.fake_broadcast) || @@ -7329,6 +7319,8 @@ qeth_setrouting_v6(struct qeth_card *card) QETH_DBF_TEXT(trace,3,"setrtg6"); #ifdef CONFIG_QETH_IPV6 + if (!qeth_is_supported(card, IPA_IPV6)) + return 0; qeth_correct_routing_type(card, &card->options.route6.type, QETH_PROT_IPV6); @@ -7867,12 +7859,12 @@ __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode) QETH_DBF_TEXT_(setup, 2, "5err%d", rc); goto out_remove; } - card->state = CARD_STATE_SOFTSETUP; if ((rc = qeth_init_qdio_queues(card))){ QETH_DBF_TEXT_(setup, 2, "6err%d", rc); goto out_remove; } + card->state = CARD_STATE_SOFTSETUP; netif_carrier_on(card->dev); qeth_set_allowed_threads(card, 0xffffffff, 0); @@ -7900,9 +7892,9 @@ qeth_set_online(struct ccwgroup_device *gdev) } static struct ccw_device_id qeth_ids[] = { - {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE}, - {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD}, - {CCW_DEVICE(0x1731, 0x06), driver_info:QETH_CARD_TYPE_OSN}, + {CCW_DEVICE(0x1731, 0x01), .driver_info = QETH_CARD_TYPE_OSAE}, + {CCW_DEVICE(0x1731, 0x05), .driver_info = QETH_CARD_TYPE_IQD}, + {CCW_DEVICE(0x1731, 0x06), .driver_info = QETH_CARD_TYPE_OSN}, {}, }; MODULE_DEVICE_TABLE(ccw, qeth_ids); @@ -8050,7 +8042,7 @@ qeth_arp_constructor(struct neighbour *neigh) neigh->parms = neigh_parms_clone(parms); rcu_read_unlock(); - neigh->type = inet_addr_type(*(u32 *) neigh->primary_key); + neigh->type = inet_addr_type(*(__be32 *) neigh->primary_key); neigh->nud_state = NUD_NOARP; neigh->ops = arp_direct_ops; neigh->output = neigh->ops->queue_xmit; @@ -8218,8 +8210,7 @@ qeth_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto, } if (!qeth_add_ip(card, ipaddr)) kfree(ipaddr); - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); return rc; } @@ -8247,8 +8238,7 @@ qeth_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto, return; if (!qeth_delete_ip(card, ipaddr)) kfree(ipaddr); - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); } /* @@ -8291,8 +8281,7 @@ qeth_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto, } if (!qeth_add_ip(card, ipaddr)) kfree(ipaddr); - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); return 0; } @@ -8320,8 +8309,7 @@ qeth_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto, return; if (!qeth_delete_ip(card, ipaddr)) kfree(ipaddr); - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); } /** @@ -8363,15 +8351,14 @@ qeth_ip_event(struct notifier_block *this, default: break; } - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); out: return NOTIFY_DONE; } static struct notifier_block qeth_ip_notifier = { qeth_ip_event, - 0 + NULL, }; #ifdef CONFIG_QETH_IPV6 @@ -8416,15 +8403,14 @@ qeth_ip6_event(struct notifier_block *this, default: break; } - if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) - schedule_work(&card->kernel_thread_starter); + qeth_set_ip_addr_list(card); out: return NOTIFY_DONE; } static struct notifier_block qeth_ip6_notifier = { qeth_ip6_event, - 0 + NULL, }; #endif @@ -8442,16 +8428,17 @@ __qeth_reboot_event_card(struct device *dev, void *data) static int qeth_reboot_event(struct notifier_block *this, unsigned long event, void *ptr) { + int ret; - driver_for_each_device(&qeth_ccwgroup_driver.driver, NULL, NULL, - __qeth_reboot_event_card); - return NOTIFY_DONE; + ret = driver_for_each_device(&qeth_ccwgroup_driver.driver, NULL, NULL, + __qeth_reboot_event_card); + return ret ? NOTIFY_BAD : NOTIFY_DONE; } static struct notifier_block qeth_reboot_notifier = { qeth_reboot_event, - 0 + NULL, }; static int @@ -8500,9 +8487,9 @@ static int qeth_ipv6_init(void) { qeth_old_arp_constructor = arp_tbl.constructor; - write_lock(&arp_tbl.lock); + write_lock_bh(&arp_tbl.lock); arp_tbl.constructor = qeth_arp_constructor; - write_unlock(&arp_tbl.lock); + write_unlock_bh(&arp_tbl.lock); arp_direct_ops = (struct neigh_ops*) kmalloc(sizeof(struct neigh_ops), GFP_KERNEL); @@ -8518,9 +8505,9 @@ qeth_ipv6_init(void) static void qeth_ipv6_uninit(void) { - write_lock(&arp_tbl.lock); + write_lock_bh(&arp_tbl.lock); arp_tbl.constructor = qeth_old_arp_constructor; - write_unlock(&arp_tbl.lock); + write_unlock_bh(&arp_tbl.lock); kfree(arp_direct_ops); } #endif /* CONFIG_QETH_IPV6 */ @@ -8528,34 +8515,44 @@ qeth_ipv6_uninit(void) static void qeth_sysfs_unregister(void) { + s390_root_dev_unregister(qeth_root_dev); qeth_remove_driver_attributes(); ccw_driver_unregister(&qeth_ccw_driver); ccwgroup_driver_unregister(&qeth_ccwgroup_driver); - s390_root_dev_unregister(qeth_root_dev); } + /** * register qeth at sysfs */ static int qeth_sysfs_register(void) { - int rc=0; + int rc; rc = ccwgroup_driver_register(&qeth_ccwgroup_driver); if (rc) - return rc; + goto out; + rc = ccw_driver_register(&qeth_ccw_driver); if (rc) - return rc; + goto out_ccw_driver; + rc = qeth_create_driver_attributes(); if (rc) - return rc; + goto out_qeth_attr; + qeth_root_dev = s390_root_dev_register("qeth"); - if (IS_ERR(qeth_root_dev)) { - rc = PTR_ERR(qeth_root_dev); - return rc; - } - return 0; + rc = IS_ERR(qeth_root_dev) ? PTR_ERR(qeth_root_dev) : 0; + if (!rc) + goto out; + + qeth_remove_driver_attributes(); +out_qeth_attr: + ccw_driver_unregister(&qeth_ccw_driver); +out_ccw_driver: + ccwgroup_driver_unregister(&qeth_ccwgroup_driver); +out: + return rc; } /*** @@ -8564,7 +8561,7 @@ qeth_sysfs_register(void) static int __init qeth_init(void) { - int rc=0; + int rc; PRINT_INFO("loading %s\n", version); @@ -8573,20 +8570,26 @@ qeth_init(void) spin_lock_init(&qeth_notify_lock); rwlock_init(&qeth_card_list.rwlock); - if (qeth_register_dbf_views()) + rc = qeth_register_dbf_views(); + if (rc) goto out_err; - if (qeth_sysfs_register()) - goto out_sysfs; + + rc = qeth_sysfs_register(); + if (rc) + goto out_dbf; #ifdef CONFIG_QETH_IPV6 - if (qeth_ipv6_init()) { - PRINT_ERR("Out of memory during ipv6 init.\n"); + rc = qeth_ipv6_init(); + if (rc) { + PRINT_ERR("Out of memory during ipv6 init code = %d\n", rc); goto out_sysfs; } #endif /* QETH_IPV6 */ - if (qeth_register_notifiers()) + rc = qeth_register_notifiers(); + if (rc) goto out_ipv6; - if (qeth_create_procfs_entries()) + rc = qeth_create_procfs_entries(); + if (rc) goto out_notifiers; return rc; @@ -8596,12 +8599,13 @@ out_notifiers: out_ipv6: #ifdef CONFIG_QETH_IPV6 qeth_ipv6_uninit(); -#endif /* QETH_IPV6 */ out_sysfs: +#endif /* QETH_IPV6 */ qeth_sysfs_unregister(); +out_dbf: qeth_unregister_dbf_views(); out_err: - PRINT_ERR("Initialization failed"); + PRINT_ERR("Initialization failed with code %d\n", rc); return rc; }