Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / s390 / net / qeth_eddp.c
index f94f1f2..0bab60a 100644 (file)
@@ -1,6 +1,5 @@
 /*
- *
- * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.13 $)
+ * linux/drivers/s390/net/qeth_eddp.c
  *
  * Enhanced Device Driver Packing (EDDP) support for the qeth driver.
  *
@@ -8,8 +7,6 @@
  *
  *    Author(s): Thomas Spatzier <tspat@de.ibm.com>
  *
- *    $Revision: 1.13 $         $Date: 2005/05/04 20:19:18 $
- *
  */
 #include <linux/config.h>
 #include <linux/errno.h>
@@ -62,8 +59,7 @@ qeth_eddp_free_context(struct qeth_eddp_context *ctx)
        for (i = 0; i < ctx->num_pages; ++i)
                free_page((unsigned long)ctx->pages[i]);
        kfree(ctx->pages);
-       if (ctx->elements != NULL)
-               kfree(ctx->elements);
+       kfree(ctx->elements);
        kfree(ctx);
 }
 
@@ -85,7 +81,7 @@ void
 qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf)
 {
        struct qeth_eddp_context_reference *ref;
-       
+
        QETH_DBF_TEXT(trace, 6, "eddprctx");
        while (!list_empty(&buf->ctx_list)){
                ref = list_entry(buf->ctx_list.next,
@@ -139,7 +135,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
                                           "buffer!\n");
                                goto out;
                        }
-               }               
+               }
                /* check if the whole next skb fits into current buffer */
                if ((QETH_MAX_BUFFER_ELEMENTS(queue->card) -
                                        buf->next_element_to_fill)
@@ -152,7 +148,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
                         * and increment ctx's refcnt */
                        must_refcnt = 1;
                        continue;
-               }       
+               }
                if (must_refcnt){
                        must_refcnt = 0;
                        if (qeth_eddp_buf_ref_context(buf, ctx)){
@@ -270,7 +266,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
        int left_in_frag;
        int copy_len;
        u8 *src;
-       
+
        QETH_DBF_TEXT(trace, 5, "eddpcdtc");
        if (skb_shinfo(eddp->skb)->nr_frags == 0) {
                memcpy(dst, eddp->skb->data + eddp->skb_offset, len);
@@ -393,9 +389,8 @@ qeth_eddp_create_eddp_data(struct qeth_hdr *qh, u8 *nh, u8 nhl, u8 *th, u8 thl)
        struct qeth_eddp_data *eddp;
 
        QETH_DBF_TEXT(trace, 5, "eddpcrda");
-       eddp = kmalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
+       eddp = kzalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
        if (eddp){
-               memset(eddp, 0, sizeof(struct qeth_eddp_data));
                eddp->nhl = nhl;
                eddp->thl = thl;
                memcpy(&eddp->qh, qh, sizeof(struct qeth_hdr));
@@ -413,9 +408,16 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
        struct tcphdr *tcph;
        int data_len;
        u32 hcsum;
-       
+
        QETH_DBF_TEXT(trace, 5, "eddpftcp");
        eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl;
+       if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
+               eddp->skb_offset += sizeof(struct ethhdr);
+#ifdef CONFIG_QETH_VLAN
+               if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q))
+                       eddp->skb_offset += VLAN_HLEN;
+#endif /* CONFIG_QETH_VLAN */
+       }
        tcph = eddp->skb->h.th;
        while (eddp->skb_offset < eddp->skb->len) {
                data_len = min((int)skb_shinfo(eddp->skb)->tso_size,
@@ -463,13 +465,13 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
                eddp->th.tcp.h.seq += data_len;
        }
 }
-                          
+
 static inline int
 qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
                           struct sk_buff *skb, struct qeth_hdr *qhdr)
 {
        struct qeth_eddp_data *eddp = NULL;
-       
+
        QETH_DBF_TEXT(trace, 5, "eddpficx");
        /* create our segmentation headers and copy original headers */
        if (skb->protocol == ETH_P_IP)
@@ -486,6 +488,7 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
                return -ENOMEM;
        }
        if (qhdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
+               skb->mac.raw = (skb->data) + sizeof(struct qeth_hdr);
                memcpy(&eddp->mac, eth_hdr(skb), ETH_HLEN);
 #ifdef CONFIG_QETH_VLAN
                if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) {
@@ -509,7 +512,7 @@ qeth_eddp_calc_num_pages(struct qeth_eddp_context *ctx, struct sk_buff *skb,
                         int hdr_len)
 {
        int skbs_per_page;
-       
+
        QETH_DBF_TEXT(trace, 5, "eddpcanp");
        /* can we put multiple skbs in one page? */
        skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->tso_size + hdr_len);
@@ -538,12 +541,11 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
 
        QETH_DBF_TEXT(trace, 5, "creddpcg");
        /* create the context and allocate pages */
-       ctx = kmalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
+       ctx = kzalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
        if (ctx == NULL){
                QETH_DBF_TEXT(trace, 2, "ceddpcn1");
                return NULL;
        }
-       memset(ctx, 0, sizeof(struct qeth_eddp_context));
        ctx->type = QETH_LARGE_SEND_EDDP;
        qeth_eddp_calc_num_pages(ctx, skb, hdr_len);
        if (ctx->elements_per_skb > QETH_MAX_BUFFER_ELEMENTS(card)){
@@ -551,13 +553,12 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
                kfree(ctx);
                return NULL;
        }
-       ctx->pages = kmalloc(ctx->num_pages * sizeof(u8 *), GFP_ATOMIC);
+       ctx->pages = kcalloc(ctx->num_pages, sizeof(u8 *), GFP_ATOMIC);
        if (ctx->pages == NULL){
                QETH_DBF_TEXT(trace, 2, "ceddpcn2");
                kfree(ctx);
                return NULL;
        }
-       memset(ctx->pages, 0, ctx->num_pages * sizeof(u8 *));
        for (i = 0; i < ctx->num_pages; ++i){
                addr = (u8 *)__get_free_page(GFP_ATOMIC);
                if (addr == NULL){
@@ -569,15 +570,13 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
                memset(addr, 0, PAGE_SIZE);
                ctx->pages[i] = addr;
        }
-       ctx->elements = kmalloc(ctx->num_elements *
+       ctx->elements = kcalloc(ctx->num_elements,
                                sizeof(struct qeth_eddp_element), GFP_ATOMIC);
        if (ctx->elements == NULL){
                QETH_DBF_TEXT(trace, 2, "ceddpcn4");
                qeth_eddp_free_context(ctx);
                return NULL;
        }
-       memset(ctx->elements, 0,
-              ctx->num_elements * sizeof(struct qeth_eddp_element));
        /* reset num_elements; will be incremented again in fill_buffer to
         * reflect number of actually used elements */
        ctx->num_elements = 0;
@@ -589,7 +588,7 @@ qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
                             struct qeth_hdr *qhdr)
 {
        struct qeth_eddp_context *ctx = NULL;
-       
+
        QETH_DBF_TEXT(trace, 5, "creddpct");
        if (skb->protocol == ETH_P_IP)
                ctx = qeth_eddp_create_context_generic(card, skb,