aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net/qeth_core_offl.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--drivers/s390/net/qeth_core_offl.c (renamed from drivers/s390/net/qeth_eddp.c)345
1 files changed, 206 insertions, 139 deletions
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_core_offl.c
index e3c268cfbffe..822df8362856 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_core_offl.c
@@ -1,13 +1,11 @@
/*
- * linux/drivers/s390/net/qeth_eddp.c
- *
- * Enhanced Device Driver Packing (EDDP) support for the qeth driver.
- *
- * Copyright 2004 IBM Corporation
- *
- * Author(s): Thomas Spatzier <tspat@de.ibm.com>
+ * drivers/s390/net/qeth_core_offl.c
*
+ * Copyright IBM Corp. 2007
+ * Author(s): Thomas Spatzier <tspat@de.ibm.com>,
+ * Frank Blaschka <frank.blaschka@de.ibm.com>
*/
+
#include <linux/errno.h>
#include <linux/ip.h>
#include <linux/inetdevice.h>
@@ -18,14 +16,14 @@
#include <linux/skbuff.h>
#include <net/ip.h>
+#include <net/ip6_checksum.h>
-#include "qeth.h"
-#include "qeth_mpc.h"
-#include "qeth_eddp.h"
+#include "qeth_core.h"
+#include "qeth_core_mpc.h"
+#include "qeth_core_offl.h"
-int
-qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *queue,
- struct qeth_eddp_context *ctx)
+int qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *queue,
+ struct qeth_eddp_context *ctx)
{
int index = queue->next_buf_to_fill;
int elements_needed = ctx->num_elements;
@@ -33,8 +31,8 @@ qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *queue,
int skbs_in_buffer;
int buffers_needed = 0;
- QETH_DBF_TEXT(trace, 5, "eddpcbfc");
- while(elements_needed > 0) {
+ QETH_DBF_TEXT(TRACE, 5, "eddpcbfc");
+ while (elements_needed > 0) {
buffers_needed++;
if (atomic_read(&queue->bufs[index].state) !=
QETH_QDIO_BUF_EMPTY)
@@ -49,12 +47,11 @@ qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *queue,
return buffers_needed;
}
-static void
-qeth_eddp_free_context(struct qeth_eddp_context *ctx)
+static void qeth_eddp_free_context(struct qeth_eddp_context *ctx)
{
int i;
- QETH_DBF_TEXT(trace, 5, "eddpfctx");
+ QETH_DBF_TEXT(TRACE, 5, "eddpfctx");
for (i = 0; i < ctx->num_pages; ++i)
free_page((unsigned long)ctx->pages[i]);
kfree(ctx->pages);
@@ -63,26 +60,24 @@ qeth_eddp_free_context(struct qeth_eddp_context *ctx)
}
-static inline void
-qeth_eddp_get_context(struct qeth_eddp_context *ctx)
+static void qeth_eddp_get_context(struct qeth_eddp_context *ctx)
{
atomic_inc(&ctx->refcnt);
}
-void
-qeth_eddp_put_context(struct qeth_eddp_context *ctx)
+void qeth_eddp_put_context(struct qeth_eddp_context *ctx)
{
if (atomic_dec_return(&ctx->refcnt) == 0)
qeth_eddp_free_context(ctx);
}
+EXPORT_SYMBOL_GPL(qeth_eddp_put_context);
-void
-qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf)
+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)){
+ QETH_DBF_TEXT(TRACE, 6, "eddprctx");
+ while (!list_empty(&buf->ctx_list)) {
ref = list_entry(buf->ctx_list.next,
struct qeth_eddp_context_reference, list);
qeth_eddp_put_context(ref->ctx);
@@ -91,13 +86,12 @@ qeth_eddp_buf_release_contexts(struct qeth_qdio_out_buffer *buf)
}
}
-static int
-qeth_eddp_buf_ref_context(struct qeth_qdio_out_buffer *buf,
- struct qeth_eddp_context *ctx)
+static int qeth_eddp_buf_ref_context(struct qeth_qdio_out_buffer *buf,
+ struct qeth_eddp_context *ctx)
{
struct qeth_eddp_context_reference *ref;
- QETH_DBF_TEXT(trace, 6, "eddprfcx");
+ QETH_DBF_TEXT(TRACE, 6, "eddprfcx");
ref = kmalloc(sizeof(struct qeth_eddp_context_reference), GFP_ATOMIC);
if (ref == NULL)
return -ENOMEM;
@@ -107,10 +101,8 @@ qeth_eddp_buf_ref_context(struct qeth_qdio_out_buffer *buf,
return 0;
}
-int
-qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
- struct qeth_eddp_context *ctx,
- int index)
+int qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
+ struct qeth_eddp_context *ctx, int index)
{
struct qeth_qdio_out_buffer *buf = NULL;
struct qdio_buffer *buffer;
@@ -120,10 +112,10 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
int must_refcnt = 1;
int i;
- QETH_DBF_TEXT(trace, 5, "eddpfibu");
+ QETH_DBF_TEXT(TRACE, 5, "eddpfibu");
while (elements > 0) {
buf = &queue->bufs[index];
- if (atomic_read(&buf->state) != QETH_QDIO_BUF_EMPTY){
+ if (atomic_read(&buf->state) != QETH_QDIO_BUF_EMPTY) {
/* normally this should not happen since we checked for
* available elements in qeth_check_elements_for_context
*/
@@ -148,9 +140,9 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
must_refcnt = 1;
continue;
}
- if (must_refcnt){
+ if (must_refcnt) {
must_refcnt = 0;
- if (qeth_eddp_buf_ref_context(buf, ctx)){
+ if (qeth_eddp_buf_ref_context(buf, ctx)) {
PRINT_WARN("no memory to create eddp context "
"reference\n");
goto out_check;
@@ -158,7 +150,7 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
}
buffer = buf->buffer;
/* fill one skb into buffer */
- for (i = 0; i < ctx->elements_per_skb; ++i){
+ for (i = 0; i < ctx->elements_per_skb; ++i) {
if (ctx->elements[element].length != 0) {
buffer->element[buf->next_element_to_fill].
addr = ctx->elements[element].addr;
@@ -174,16 +166,16 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
}
out_check:
if (!queue->do_pack) {
- QETH_DBF_TEXT(trace, 6, "fillbfnp");
+ QETH_DBF_TEXT(TRACE, 6, "fillbfnp");
/* set state to PRIMED -> will be flushed */
- if (buf->next_element_to_fill > 0){
+ if (buf->next_element_to_fill > 0) {
atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED);
flush_cnt++;
}
} else {
if (queue->card->options.performance_stats)
queue->card->perf_stats.skbs_sent_pack++;
- QETH_DBF_TEXT(trace, 6, "fillbfpa");
+ QETH_DBF_TEXT(TRACE, 6, "fillbfpa");
if (buf->next_element_to_fill >=
QETH_MAX_BUFFER_ELEMENTS(queue->card)) {
/*
@@ -198,9 +190,8 @@ out:
return flush_cnt;
}
-static void
-qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
- struct qeth_eddp_data *eddp, int data_len)
+static void qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
+ struct qeth_eddp_data *eddp, int data_len)
{
u8 *page;
int page_remainder;
@@ -208,7 +199,7 @@ qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
int pkt_len;
struct qeth_eddp_element *element;
- QETH_DBF_TEXT(trace, 5, "eddpcrsh");
+ QETH_DBF_TEXT(TRACE, 5, "eddpcrsh");
page = ctx->pages[ctx->offset >> PAGE_SHIFT];
page_offset = ctx->offset % PAGE_SIZE;
element = &ctx->elements[ctx->num_elements];
@@ -220,7 +211,7 @@ qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
pkt_len += VLAN_HLEN;
/* does complete packet fit in current page ? */
page_remainder = PAGE_SIZE - page_offset;
- if (page_remainder < (sizeof(struct qeth_hdr) + pkt_len)){
+ if (page_remainder < (sizeof(struct qeth_hdr) + pkt_len)) {
/* no -> go to start of next page */
ctx->offset += page_remainder;
page = ctx->pages[ctx->offset >> PAGE_SHIFT];
@@ -232,14 +223,14 @@ qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
ctx->offset += sizeof(struct qeth_hdr);
page_offset += sizeof(struct qeth_hdr);
/* add mac header (?) */
- if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2){
+ if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
memcpy(page + page_offset, &eddp->mac, ETH_HLEN);
element->length += ETH_HLEN;
ctx->offset += ETH_HLEN;
page_offset += ETH_HLEN;
}
/* add VLAN tag */
- if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)){
+ if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) {
memcpy(page + page_offset, &eddp->vlan, VLAN_HLEN);
element->length += VLAN_HLEN;
ctx->offset += VLAN_HLEN;
@@ -258,16 +249,15 @@ qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
ctx->offset += eddp->thl;
}
-static void
-qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
- __wsum *hcsum)
+static void qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp,
+ int len, __wsum *hcsum)
{
struct skb_frag_struct *frag;
int left_in_frag;
int copy_len;
u8 *src;
- QETH_DBF_TEXT(trace, 5, "eddpcdtc");
+ QETH_DBF_TEXT(TRACE, 5, "eddpcdtc");
if (skb_shinfo(eddp->skb)->nr_frags == 0) {
skb_copy_from_linear_data_offset(eddp->skb, eddp->skb_offset,
dst, len);
@@ -278,16 +268,17 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
while (len > 0) {
if (eddp->frag < 0) {
/* we're in skb->data */
- left_in_frag = (eddp->skb->len - eddp->skb->data_len)
+ left_in_frag = (eddp->skb->len -
+ eddp->skb->data_len)
- eddp->skb_offset;
src = eddp->skb->data + eddp->skb_offset;
} else {
- frag = &skb_shinfo(eddp->skb)->
- frags[eddp->frag];
+ frag = &skb_shinfo(eddp->skb)->frags[
+ eddp->frag];
left_in_frag = frag->size - eddp->frag_offset;
- src = (u8 *)(
- (page_to_pfn(frag->page) << PAGE_SHIFT)+
- frag->page_offset + eddp->frag_offset);
+ src = (u8 *)((page_to_pfn(frag->page) <<
+ PAGE_SHIFT) + frag->page_offset +
+ eddp->frag_offset);
}
if (left_in_frag <= 0) {
eddp->frag++;
@@ -305,10 +296,8 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
}
}
-static void
-qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
- struct qeth_eddp_data *eddp, int data_len,
- __wsum hcsum)
+static void qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
+ struct qeth_eddp_data *eddp, int data_len, __wsum hcsum)
{
u8 *page;
int page_remainder;
@@ -316,13 +305,13 @@ qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
struct qeth_eddp_element *element;
int first_lap = 1;
- QETH_DBF_TEXT(trace, 5, "eddpcsdt");
+ QETH_DBF_TEXT(TRACE, 5, "eddpcsdt");
page = ctx->pages[ctx->offset >> PAGE_SHIFT];
page_offset = ctx->offset % PAGE_SIZE;
element = &ctx->elements[ctx->num_elements];
- while (data_len){
+ while (data_len) {
page_remainder = PAGE_SIZE - page_offset;
- if (page_remainder < data_len){
+ if (page_remainder < data_len) {
qeth_eddp_copy_data_tcp(page + page_offset, eddp,
page_remainder, &hcsum);
element->length += page_remainder;
@@ -352,12 +341,12 @@ qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
((struct tcphdr *)eddp->th_in_ctx)->check = csum_fold(hcsum);
}
-static __wsum
-qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len)
+static __wsum qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp,
+ int data_len)
{
__wsum phcsum; /* pseudo header checksum */
- QETH_DBF_TEXT(trace, 5, "eddpckt4");
+ QETH_DBF_TEXT(TRACE, 5, "eddpckt4");
eddp->th.tcp.h.check = 0;
/* compute pseudo header checksum */
phcsum = csum_tcpudp_nofold(eddp->nh.ip4.h.saddr, eddp->nh.ip4.h.daddr,
@@ -366,13 +355,13 @@ qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len)
return csum_partial((u8 *)&eddp->th, eddp->thl, phcsum);
}
-static __wsum
-qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len)
+static __wsum qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp,
+ int data_len)
{
__be32 proto;
__wsum phcsum; /* pseudo header checksum */
- QETH_DBF_TEXT(trace, 5, "eddpckt6");
+ QETH_DBF_TEXT(TRACE, 5, "eddpckt6");
eddp->th.tcp.h.check = 0;
/* compute pseudo header checksum */
phcsum = csum_partial((u8 *)&eddp->nh.ip6.h.saddr,
@@ -384,14 +373,14 @@ qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len)
return phcsum;
}
-static struct qeth_eddp_data *
-qeth_eddp_create_eddp_data(struct qeth_hdr *qh, u8 *nh, u8 nhl, u8 *th, u8 thl)
+static struct qeth_eddp_data *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");
+ QETH_DBF_TEXT(TRACE, 5, "eddpcrda");
eddp = kzalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
- if (eddp){
+ if (eddp) {
eddp->nhl = nhl;
eddp->thl = thl;
memcpy(&eddp->qh, qh, sizeof(struct qeth_hdr));
@@ -402,40 +391,35 @@ qeth_eddp_create_eddp_data(struct qeth_hdr *qh, u8 *nh, u8 nhl, u8 *th, u8 thl)
return eddp;
}
-static void
-__qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
- struct qeth_eddp_data *eddp)
+static void __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
+ struct qeth_eddp_data *eddp)
{
struct tcphdr *tcph;
int data_len;
__wsum hcsum;
- QETH_DBF_TEXT(trace, 5, "eddpftcp");
+ 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 */
- }
+ if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
+ eddp->skb_offset += sizeof(struct ethhdr);
+ if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q))
+ eddp->skb_offset += VLAN_HLEN;
+ }
tcph = tcp_hdr(eddp->skb);
while (eddp->skb_offset < eddp->skb->len) {
data_len = min((int)skb_shinfo(eddp->skb)->gso_size,
(int)(eddp->skb->len - eddp->skb_offset));
/* prepare qdio hdr */
- if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2){
+ if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
eddp->qh.hdr.l2.pkt_length = data_len + ETH_HLEN +
eddp->nhl + eddp->thl;
-#ifdef CONFIG_QETH_VLAN
if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q))
eddp->qh.hdr.l2.pkt_length += VLAN_HLEN;
-#endif /* CONFIG_QETH_VLAN */
} else
eddp->qh.hdr.l3.length = data_len + eddp->nhl +
eddp->thl;
/* prepare ip hdr */
- if (eddp->skb->protocol == htons(ETH_P_IP)){
+ if (eddp->skb->protocol == htons(ETH_P_IP)) {
eddp->nh.ip4.h.tot_len = htons(data_len + eddp->nhl +
eddp->thl);
eddp->nh.ip4.h.check = 0;
@@ -443,9 +427,10 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
ip_fast_csum((u8 *)&eddp->nh.ip4.h,
eddp->nh.ip4.h.ihl);
} else
- eddp->nh.ip6.h.payload_len = htons(data_len + eddp->thl);
+ eddp->nh.ip6.h.payload_len = htons(data_len +
+ eddp->thl);
/* prepare tcp hdr */
- if (data_len == (eddp->skb->len - eddp->skb_offset)){
+ if (data_len == (eddp->skb->len - eddp->skb_offset)) {
/* last segment -> set FIN and PSH flags */
eddp->th.tcp.h.fin = tcph->fin;
eddp->th.tcp.h.psh = tcph->psh;
@@ -462,17 +447,17 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
/* prepare headers for next round */
if (eddp->skb->protocol == htons(ETH_P_IP))
eddp->nh.ip4.h.id = htons(ntohs(eddp->nh.ip4.h.id) + 1);
- eddp->th.tcp.h.seq = htonl(ntohl(eddp->th.tcp.h.seq) + data_len);
+ eddp->th.tcp.h.seq = htonl(ntohl(eddp->th.tcp.h.seq) +
+ data_len);
}
}
-static int
-qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
- struct sk_buff *skb, struct qeth_hdr *qhdr)
+static 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");
+ QETH_DBF_TEXT(TRACE, 5, "eddpficx");
/* create our segmentation headers and copy original headers */
if (skb->protocol == htons(ETH_P_IP))
eddp = qeth_eddp_create_eddp_data(qhdr,
@@ -488,18 +473,16 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
tcp_hdrlen(skb));
if (eddp == NULL) {
- QETH_DBF_TEXT(trace, 2, "eddpfcnm");
+ QETH_DBF_TEXT(TRACE, 2, "eddpfcnm");
return -ENOMEM;
}
if (qhdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) {
skb_set_mac_header(skb, 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)) {
eddp->vlan[0] = skb->protocol;
eddp->vlan[1] = htons(vlan_tx_tag_get(skb));
}
-#endif /* CONFIG_QETH_VLAN */
}
/* the next flags will only be set on the last segment */
eddp->th.tcp.h.fin = 0;
@@ -511,16 +494,15 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
return 0;
}
-static void
-qeth_eddp_calc_num_pages(struct qeth_eddp_context *ctx, struct sk_buff *skb,
- int hdr_len)
+static void 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");
+ QETH_DBF_TEXT(TRACE, 5, "eddpcanp");
/* can we put multiple skbs in one page? */
skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->gso_size + hdr_len);
- if (skbs_per_page > 1){
+ if (skbs_per_page > 1) {
ctx->num_pages = (skb_shinfo(skb)->gso_segs + 1) /
skbs_per_page + 1;
ctx->elements_per_skb = 1;
@@ -535,49 +517,47 @@ qeth_eddp_calc_num_pages(struct qeth_eddp_context *ctx, struct sk_buff *skb,
(skb_shinfo(skb)->gso_segs + 1);
}
-static struct qeth_eddp_context *
-qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
- int hdr_len)
+static struct qeth_eddp_context *qeth_eddp_create_context_generic(
+ struct qeth_card *card, struct sk_buff *skb, int hdr_len)
{
struct qeth_eddp_context *ctx = NULL;
u8 *addr;
int i;
- QETH_DBF_TEXT(trace, 5, "creddpcg");
+ QETH_DBF_TEXT(TRACE, 5, "creddpcg");
/* create the context and allocate pages */
ctx = kzalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
- if (ctx == NULL){
- QETH_DBF_TEXT(trace, 2, "ceddpcn1");
+ if (ctx == NULL) {
+ QETH_DBF_TEXT(TRACE, 2, "ceddpcn1");
return NULL;
}
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)){
- QETH_DBF_TEXT(trace, 2, "ceddpcis");
+ if (ctx->elements_per_skb > QETH_MAX_BUFFER_ELEMENTS(card)) {
+ QETH_DBF_TEXT(TRACE, 2, "ceddpcis");
kfree(ctx);
return NULL;
}
ctx->pages = kcalloc(ctx->num_pages, sizeof(u8 *), GFP_ATOMIC);
- if (ctx->pages == NULL){
- QETH_DBF_TEXT(trace, 2, "ceddpcn2");
+ if (ctx->pages == NULL) {
+ QETH_DBF_TEXT(TRACE, 2, "ceddpcn2");
kfree(ctx);
return NULL;
}
- for (i = 0; i < ctx->num_pages; ++i){
- addr = (u8 *)__get_free_page(GFP_ATOMIC);
- if (addr == NULL){
- QETH_DBF_TEXT(trace, 2, "ceddpcn3");
+ for (i = 0; i < ctx->num_pages; ++i) {
+ addr = (u8 *)get_zeroed_page(GFP_ATOMIC);
+ if (addr == NULL) {
+ QETH_DBF_TEXT(TRACE, 2, "ceddpcn3");
ctx->num_pages = i;
qeth_eddp_free_context(ctx);
return NULL;
}
- memset(addr, 0, PAGE_SIZE);
ctx->pages[i] = addr;
}
ctx->elements = kcalloc(ctx->num_elements,
sizeof(struct qeth_eddp_element), GFP_ATOMIC);
- if (ctx->elements == NULL){
- QETH_DBF_TEXT(trace, 2, "ceddpcn4");
+ if (ctx->elements == NULL) {
+ QETH_DBF_TEXT(TRACE, 2, "ceddpcn4");
qeth_eddp_free_context(ctx);
return NULL;
}
@@ -587,31 +567,31 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
return ctx;
}
-static struct qeth_eddp_context *
-qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
- struct qeth_hdr *qhdr)
+static struct qeth_eddp_context *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");
+ QETH_DBF_TEXT(TRACE, 5, "creddpct");
if (skb->protocol == htons(ETH_P_IP))
ctx = qeth_eddp_create_context_generic(card, skb,
- (sizeof(struct qeth_hdr) +
- ip_hdrlen(skb) +
- tcp_hdrlen(skb)));
+ (sizeof(struct qeth_hdr) +
+ ip_hdrlen(skb) +
+ tcp_hdrlen(skb)));
else if (skb->protocol == htons(ETH_P_IPV6))
ctx = qeth_eddp_create_context_generic(card, skb,
sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) +
tcp_hdrlen(skb));
else
- QETH_DBF_TEXT(trace, 2, "cetcpinv");
+ QETH_DBF_TEXT(TRACE, 2, "cetcpinv");
if (ctx == NULL) {
- QETH_DBF_TEXT(trace, 2, "creddpnl");
+ QETH_DBF_TEXT(TRACE, 2, "creddpnl");
return NULL;
}
- if (qeth_eddp_fill_context_tcp(ctx, skb, qhdr)){
- QETH_DBF_TEXT(trace, 2, "ceddptfe");
+ if (qeth_eddp_fill_context_tcp(ctx, skb, qhdr)) {
+ QETH_DBF_TEXT(TRACE, 2, "ceddptfe");
qeth_eddp_free_context(ctx);
return NULL;
}
@@ -619,16 +599,103 @@ qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
return ctx;
}
-struct qeth_eddp_context *
-qeth_eddp_create_context(struct qeth_card *card, struct sk_buff *skb,
- struct qeth_hdr *qhdr, unsigned char sk_protocol)
+struct qeth_eddp_context *qeth_eddp_create_context(struct qeth_card *card,
+ struct sk_buff *skb, struct qeth_hdr *qhdr,
+ unsigned char sk_protocol)
{
- QETH_DBF_TEXT(trace, 5, "creddpc");
+ QETH_DBF_TEXT(TRACE, 5, "creddpc");
switch (sk_protocol) {
case IPPROTO_TCP:
return qeth_eddp_create_context_tcp(card, skb, qhdr);
default:
- QETH_DBF_TEXT(trace, 2, "eddpinvp");
+ QETH_DBF_TEXT(TRACE, 2, "eddpinvp");
}
return NULL;
}
+EXPORT_SYMBOL_GPL(qeth_eddp_create_context);
+
+void qeth_tso_fill_header(struct qeth_card *card, struct qeth_hdr *qhdr,
+ struct sk_buff *skb)
+{
+ struct qeth_hdr_tso *hdr = (struct qeth_hdr_tso *)qhdr;
+ struct tcphdr *tcph = tcp_hdr(skb);
+ struct iphdr *iph = ip_hdr(skb);
+ struct ipv6hdr *ip6h = ipv6_hdr(skb);
+
+ QETH_DBF_TEXT(TRACE, 5, "tsofhdr");
+
+ /*fix header to TSO values ...*/
+ hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
+ /*set values which are fix for the first approach ...*/
+ hdr->ext.hdr_tot_len = (__u16) sizeof(struct qeth_hdr_ext_tso);
+ hdr->ext.imb_hdr_no = 1;
+ hdr->ext.hdr_type = 1;
+ hdr->ext.hdr_version = 1;
+ hdr->ext.hdr_len = 28;
+ /*insert non-fix values */
+ hdr->ext.mss = skb_shinfo(skb)->gso_size;
+ hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4);
+ hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len -
+ sizeof(struct qeth_hdr_tso));
+ tcph->check = 0;
+ if (skb->protocol == ETH_P_IPV6) {
+ ip6h->payload_len = 0;
+ tcph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
+ 0, IPPROTO_TCP, 0);
+ } else {
+ /*OSA want us to set these values ...*/
+ tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
+ 0, IPPROTO_TCP, 0);
+ iph->tot_len = 0;
+ iph->check = 0;
+ }
+}
+EXPORT_SYMBOL_GPL(qeth_tso_fill_header);
+
+void qeth_tx_csum(struct sk_buff *skb)
+{
+ int tlen;
+ if (skb->protocol == htons(ETH_P_IP)) {
+ tlen = ntohs(ip_hdr(skb)->tot_len) - (ip_hdr(skb)->ihl << 2);
+ switch (ip_hdr(skb)->protocol) {
+ case IPPROTO_TCP:
+ tcp_hdr(skb)->check = 0;
+ tcp_hdr(skb)->check = csum_tcpudp_magic(
+ ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
+ tlen, ip_hdr(skb)->protocol,
+ skb_checksum(skb, skb_transport_offset(skb),
+ tlen, 0));
+ break;
+ case IPPROTO_UDP:
+ udp_hdr(skb)->check = 0;
+ udp_hdr(skb)->check = csum_tcpudp_magic(
+ ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
+ tlen, ip_hdr(skb)->protocol,
+ skb_checksum(skb, skb_transport_offset(skb),
+ tlen, 0));
+ break;
+ }
+ } else if (skb->protocol == htons(ETH_P_IPV6)) {
+ switch (ipv6_hdr(skb)->nexthdr) {
+ case IPPROTO_TCP:
+ tcp_hdr(skb)->check = 0;
+ tcp_hdr(skb)->check = csum_ipv6_magic(
+ &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
+ ipv6_hdr(skb)->payload_len,
+ ipv6_hdr(skb)->nexthdr,
+ skb_checksum(skb, skb_transport_offset(skb),
+ ipv6_hdr(skb)->payload_len, 0));
+ break;
+ case IPPROTO_UDP:
+ udp_hdr(skb)->check = 0;
+ udp_hdr(skb)->check = csum_ipv6_magic(
+ &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
+ ipv6_hdr(skb)->payload_len,
+ ipv6_hdr(skb)->nexthdr,
+ skb_checksum(skb, skb_transport_offset(skb),
+ ipv6_hdr(skb)->payload_len, 0));
+ break;
+ }
+ }
+}
+EXPORT_SYMBOL_GPL(qeth_tx_csum);