2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.8 $)
4 * Header file for qeth TCP Segmentation Offload support.
6 * Copyright 2004 IBM Corporation
8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com>
10 * $Revision: 1.8 $ $Date: 2005/05/04 20:19:18 $
13 #ifndef __QETH_TSO_H__
14 #define __QETH_TSO_H__
16 #include <linux/skbuff.h>
17 #include <linux/tcp.h>
19 #include <linux/ipv6.h>
20 #include <net/ip6_checksum.h>
25 static inline struct qeth_hdr_tso *
26 qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb)
28 QETH_DBF_TEXT(trace, 5, "tsoprsk");
29 return qeth_push_skb(card, skb, sizeof(struct qeth_hdr_tso));
33 * fill header for a TSO packet
36 qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
38 struct qeth_hdr_tso *hdr;
42 QETH_DBF_TEXT(trace, 5, "tsofhdr");
44 hdr = (struct qeth_hdr_tso *) skb->data;
47 /*fix header to TSO values ...*/
48 hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
49 /*set values which are fix for the first approach ...*/
50 hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso);
51 hdr->ext.imb_hdr_no = 1;
52 hdr->ext.hdr_type = 1;
53 hdr->ext.hdr_version = 1;
54 hdr->ext.hdr_len = 28;
55 /*insert non-fix values */
56 hdr->ext.mss = skb_shinfo(skb)->tso_size;
57 hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4);
58 hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len -
59 sizeof(struct qeth_hdr_tso));
63 * change some header values as requested by hardware
66 qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
77 if (skb->protocol == ETH_P_IPV6) {
78 ip6h->payload_len = 0;
79 tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
83 /*OSA want us to set these values ...*/
84 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
91 qeth_tso_prepare_packet(struct qeth_card *card, struct sk_buff *skb,
92 int ipv, int cast_type)
94 struct qeth_hdr_tso *hdr;
96 QETH_DBF_TEXT(trace, 5, "tsoprep");
98 hdr = (struct qeth_hdr_tso *) qeth_tso_prepare_skb(card, &skb);
100 QETH_DBF_TEXT(trace, 4, "tsoperr");
103 memset(hdr, 0, sizeof(struct qeth_hdr_tso));
104 /*fill first 32 bytes of qdio header as used
105 *FIXME: TSO has two struct members
106 * with different names but same size
108 qeth_fill_header(card, &hdr->hdr, skb, ipv, cast_type);
109 qeth_tso_fill_header(card, skb);
110 qeth_tso_set_tcpip_header(card, skb);
115 __qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer,
116 int is_tso, int *next_element_to_fill)
118 struct skb_frag_struct *frag;
121 int element, cnt, dlen;
123 fragno = skb_shinfo(skb)->nr_frags;
124 element = *next_element_to_fill;
128 buffer->element[element].flags =
129 SBAL_FLAGS_MIDDLE_FRAG;
131 buffer->element[element].flags =
132 SBAL_FLAGS_FIRST_FRAG;
133 if ( (dlen = (skb->len - skb->data_len)) ) {
134 buffer->element[element].addr = skb->data;
135 buffer->element[element].length = dlen;
138 for (cnt = 0; cnt < fragno; cnt++) {
139 frag = &skb_shinfo(skb)->frags[cnt];
140 addr = (page_to_pfn(frag->page) << PAGE_SHIFT) +
142 buffer->element[element].addr = (char *)addr;
143 buffer->element[element].length = frag->size;
144 if (cnt < (fragno - 1))
145 buffer->element[element].flags =
146 SBAL_FLAGS_MIDDLE_FRAG;
148 buffer->element[element].flags =
149 SBAL_FLAGS_LAST_FRAG;
152 *next_element_to_fill = element;
154 #endif /* __QETH_TSO_H__ */