Commit 05e08a2a authored by Frank Pavlic's avatar Frank Pavlic Committed by Jeff Garzik

[PATCH] s390: qeth bug fixes

[patch 10/10] s390: qeth bug fixes.

From: Frank Pavlic <pavlic@de.ibm.com>

qeth network driver related changes:
 - due to OSA hardware changes in TCP Segmentation Offload
   support we are able now to pack TSO packets too.
   This fits perfectly in design of qeth buffer handling and
   sending data respectively.
 - remove skb_realloc_headroom from the sending path since
   hard_header_len value provides enough headroom now.
 - device recovery behaviour improvement
 - bug fixed in Enhanced Device Driver Packing functionality
Signed-off-by: default avatarFrank Pavlic <pavlic@de.ibm.com>
parent 9a455819
...@@ -10,6 +10,6 @@ obj-$(CONFIG_SMSGIUCV) += smsgiucv.o ...@@ -10,6 +10,6 @@ obj-$(CONFIG_SMSGIUCV) += smsgiucv.o
obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o
obj-$(CONFIG_LCS) += lcs.o cu3088.o obj-$(CONFIG_LCS) += lcs.o cu3088.o
obj-$(CONFIG_CLAW) += claw.o cu3088.o obj-$(CONFIG_CLAW) += claw.o cu3088.o
qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o qeth_tso.o qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o
qeth-$(CONFIG_PROC_FS) += qeth_proc.o qeth-$(CONFIG_PROC_FS) += qeth_proc.o
obj-$(CONFIG_QETH) += qeth.o obj-$(CONFIG_QETH) += qeth.o
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "qeth_mpc.h" #include "qeth_mpc.h"
#define VERSION_QETH_H "$Revision: 1.137 $" #define VERSION_QETH_H "$Revision: 1.139 $"
#ifdef CONFIG_QETH_IPV6 #ifdef CONFIG_QETH_IPV6
#define QETH_VERSION_IPV6 ":IPv6" #define QETH_VERSION_IPV6 ":IPv6"
...@@ -370,6 +370,25 @@ struct qeth_hdr { ...@@ -370,6 +370,25 @@ struct qeth_hdr {
} hdr; } hdr;
} __attribute__ ((packed)); } __attribute__ ((packed));
/*TCP Segmentation Offload header*/
struct qeth_hdr_ext_tso {
__u16 hdr_tot_len;
__u8 imb_hdr_no;
__u8 reserved;
__u8 hdr_type;
__u8 hdr_version;
__u16 hdr_len;
__u32 payload_len;
__u16 mss;
__u16 dg_hdr_len;
__u8 padding[16];
} __attribute__ ((packed));
struct qeth_hdr_tso {
struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/
struct qeth_hdr_ext_tso ext;
} __attribute__ ((packed));
/* flags for qeth_hdr.flags */ /* flags for qeth_hdr.flags */
#define QETH_HDR_PASSTHRU 0x10 #define QETH_HDR_PASSTHRU 0x10
...@@ -867,16 +886,6 @@ qeth_push_skb(struct qeth_card *card, struct sk_buff **skb, int size) ...@@ -867,16 +886,6 @@ qeth_push_skb(struct qeth_card *card, struct sk_buff **skb, int size)
return hdr; return hdr;
} }
static inline int
qeth_get_skb_data_len(struct sk_buff *skb)
{
int len = skb->len;
int i;
for (i = 0; i < skb_shinfo(skb)->nr_frags; ++i)
len -= skb_shinfo(skb)->frags[i].size;
return len;
}
inline static int inline static int
qeth_get_hlen(__u8 link_type) qeth_get_hlen(__u8 link_type)
...@@ -885,19 +894,19 @@ qeth_get_hlen(__u8 link_type) ...@@ -885,19 +894,19 @@ qeth_get_hlen(__u8 link_type)
switch (link_type) { switch (link_type) {
case QETH_LINK_TYPE_HSTR: case QETH_LINK_TYPE_HSTR:
case QETH_LINK_TYPE_LANE_TR: case QETH_LINK_TYPE_LANE_TR:
return sizeof(struct qeth_hdr) + TR_HLEN; return sizeof(struct qeth_hdr_tso) + TR_HLEN;
default: default:
#ifdef CONFIG_QETH_VLAN #ifdef CONFIG_QETH_VLAN
return sizeof(struct qeth_hdr) + VLAN_ETH_HLEN; return sizeof(struct qeth_hdr_tso) + VLAN_ETH_HLEN;
#else #else
return sizeof(struct qeth_hdr) + ETH_HLEN; return sizeof(struct qeth_hdr_tso) + ETH_HLEN;
#endif #endif
} }
#else /* CONFIG_QETH_IPV6 */ #else /* CONFIG_QETH_IPV6 */
#ifdef CONFIG_QETH_VLAN #ifdef CONFIG_QETH_VLAN
return sizeof(struct qeth_hdr) + VLAN_HLEN; return sizeof(struct qeth_hdr_tso) + VLAN_HLEN;
#else #else
return sizeof(struct qeth_hdr); return sizeof(struct qeth_hdr_tso);
#endif #endif
#endif /* CONFIG_QETH_IPV6 */ #endif /* CONFIG_QETH_IPV6 */
} }
......
/* /*
* *
* linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.12 $) * linux/drivers/s390/net/qeth_eddp.c ($Revision: 1.13 $)
* *
* Enhanced Device Driver Packing (EDDP) support for the qeth driver. * Enhanced Device Driver Packing (EDDP) support for the qeth driver.
* *
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Author(s): Thomas Spatzier <tspat@de.ibm.com> * Author(s): Thomas Spatzier <tspat@de.ibm.com>
* *
* $Revision: 1.12 $ $Date: 2005/04/01 21:40:40 $ * $Revision: 1.13 $ $Date: 2005/05/04 20:19:18 $
* *
*/ */
#include <linux/config.h> #include <linux/config.h>
...@@ -204,27 +204,27 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue, ...@@ -204,27 +204,27 @@ qeth_eddp_fill_buffer(struct qeth_qdio_out_q *queue,
static inline void static inline void
qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx, qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
struct qeth_eddp_data *eddp) struct qeth_eddp_data *eddp, int data_len)
{ {
u8 *page; u8 *page;
int page_remainder; int page_remainder;
int page_offset; int page_offset;
int hdr_len; int pkt_len;
struct qeth_eddp_element *element; 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 = ctx->pages[ctx->offset >> PAGE_SHIFT];
page_offset = ctx->offset % PAGE_SIZE; page_offset = ctx->offset % PAGE_SIZE;
element = &ctx->elements[ctx->num_elements]; element = &ctx->elements[ctx->num_elements];
hdr_len = eddp->nhl + eddp->thl; pkt_len = eddp->nhl + eddp->thl + data_len;
/* FIXME: layer2 and VLAN !!! */ /* FIXME: layer2 and VLAN !!! */
if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2) if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2)
hdr_len += ETH_HLEN; pkt_len += ETH_HLEN;
if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q))
hdr_len += VLAN_HLEN; pkt_len += VLAN_HLEN;
/* does complete header fit in current page ? */ /* does complete packet fit in current page ? */
page_remainder = PAGE_SIZE - page_offset; page_remainder = PAGE_SIZE - page_offset;
if (page_remainder < (sizeof(struct qeth_hdr) + hdr_len)){ if (page_remainder < (sizeof(struct qeth_hdr) + pkt_len)){
/* no -> go to start of next page */ /* no -> go to start of next page */
ctx->offset += page_remainder; ctx->offset += page_remainder;
page = ctx->pages[ctx->offset >> PAGE_SHIFT]; page = ctx->pages[ctx->offset >> PAGE_SHIFT];
...@@ -281,7 +281,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len, ...@@ -281,7 +281,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
while (len > 0) { while (len > 0) {
if (eddp->frag < 0) { if (eddp->frag < 0) {
/* we're in skb->data */ /* we're in skb->data */
left_in_frag = qeth_get_skb_data_len(eddp->skb) left_in_frag = (eddp->skb->len - eddp->skb->data_len)
- eddp->skb_offset; - eddp->skb_offset;
src = eddp->skb->data + eddp->skb_offset; src = eddp->skb->data + eddp->skb_offset;
} else { } else {
...@@ -453,7 +453,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx, ...@@ -453,7 +453,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
else else
hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len); hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len);
/* fill the next segment into the context */ /* fill the next segment into the context */
qeth_eddp_create_segment_hdrs(ctx, eddp); qeth_eddp_create_segment_hdrs(ctx, eddp, data_len);
qeth_eddp_create_segment_data_tcp(ctx, eddp, data_len, hcsum); qeth_eddp_create_segment_data_tcp(ctx, eddp, data_len, hcsum);
if (eddp->skb_offset >= eddp->skb->len) if (eddp->skb_offset >= eddp->skb->len)
break; break;
......
/* /*
* *
* linux/drivers/s390/net/qeth_main.c ($Revision: 1.210 $) * linux/drivers/s390/net/qeth_main.c ($Revision: 1.214 $)
* *
* Linux on zSeries OSA Express and HiperSockets support * Linux on zSeries OSA Express and HiperSockets support
* *
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Frank Pavlic (pavlic@de.ibm.com) and * Frank Pavlic (pavlic@de.ibm.com) and
* Thomas Spatzier <tspat@de.ibm.com> * Thomas Spatzier <tspat@de.ibm.com>
* *
* $Revision: 1.210 $ $Date: 2005/04/18 17:27:39 $ * $Revision: 1.214 $ $Date: 2005/05/04 20:19:18 $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -80,7 +80,7 @@ qeth_eyecatcher(void) ...@@ -80,7 +80,7 @@ qeth_eyecatcher(void)
#include "qeth_eddp.h" #include "qeth_eddp.h"
#include "qeth_tso.h" #include "qeth_tso.h"
#define VERSION_QETH_C "$Revision: 1.210 $" #define VERSION_QETH_C "$Revision: 1.214 $"
static const char *version = "qeth S/390 OSA-Express driver"; static const char *version = "qeth S/390 OSA-Express driver";
/** /**
...@@ -158,6 +158,9 @@ qeth_irq_tasklet(unsigned long); ...@@ -158,6 +158,9 @@ qeth_irq_tasklet(unsigned long);
static int static int
qeth_set_online(struct ccwgroup_device *); qeth_set_online(struct ccwgroup_device *);
static int
__qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode);
static struct qeth_ipaddr * static struct qeth_ipaddr *
qeth_get_addr_buffer(enum qeth_prot_versions); qeth_get_addr_buffer(enum qeth_prot_versions);
...@@ -510,10 +513,10 @@ qeth_irq_tasklet(unsigned long data) ...@@ -510,10 +513,10 @@ qeth_irq_tasklet(unsigned long data)
wake_up(&card->wait_q); wake_up(&card->wait_q);
} }
static int qeth_stop_card(struct qeth_card *); static int qeth_stop_card(struct qeth_card *, int);
static int static int
qeth_set_offline(struct ccwgroup_device *cgdev) __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
{ {
struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data; struct qeth_card *card = (struct qeth_card *) cgdev->dev.driver_data;
int rc = 0; int rc = 0;
...@@ -523,7 +526,7 @@ qeth_set_offline(struct ccwgroup_device *cgdev) ...@@ -523,7 +526,7 @@ qeth_set_offline(struct ccwgroup_device *cgdev)
QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
recover_flag = card->state; recover_flag = card->state;
if (qeth_stop_card(card) == -ERESTARTSYS){ if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){
PRINT_WARN("Stopping card %s interrupted by user!\n", PRINT_WARN("Stopping card %s interrupted by user!\n",
CARD_BUS_ID(card)); CARD_BUS_ID(card));
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -539,6 +542,12 @@ qeth_set_offline(struct ccwgroup_device *cgdev) ...@@ -539,6 +542,12 @@ qeth_set_offline(struct ccwgroup_device *cgdev)
return 0; return 0;
} }
static int
qeth_set_offline(struct ccwgroup_device *cgdev)
{
return __qeth_set_offline(cgdev, 0);
}
static int static int
qeth_wait_for_threads(struct qeth_card *card, unsigned long threads); qeth_wait_for_threads(struct qeth_card *card, unsigned long threads);
...@@ -953,8 +962,8 @@ qeth_recover(void *ptr) ...@@ -953,8 +962,8 @@ qeth_recover(void *ptr)
PRINT_WARN("Recovery of device %s started ...\n", PRINT_WARN("Recovery of device %s started ...\n",
CARD_BUS_ID(card)); CARD_BUS_ID(card));
card->use_hard_stop = 1; card->use_hard_stop = 1;
qeth_set_offline(card->gdev); __qeth_set_offline(card->gdev,1);
rc = qeth_set_online(card->gdev); rc = __qeth_set_online(card->gdev,1);
if (!rc) if (!rc)
PRINT_INFO("Device %s successfully recovered!\n", PRINT_INFO("Device %s successfully recovered!\n",
CARD_BUS_ID(card)); CARD_BUS_ID(card));
...@@ -3786,16 +3795,12 @@ static inline int ...@@ -3786,16 +3795,12 @@ static inline int
qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb, qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb,
struct qeth_hdr **hdr, int ipv) struct qeth_hdr **hdr, int ipv)
{ {
int rc = 0;
#ifdef CONFIG_QETH_VLAN #ifdef CONFIG_QETH_VLAN
u16 *tag; u16 *tag;
#endif #endif
QETH_DBF_TEXT(trace, 6, "prepskb"); QETH_DBF_TEXT(trace, 6, "prepskb");
rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr));
if (rc)
return rc;
#ifdef CONFIG_QETH_VLAN #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) ) { ((ipv == 6) || card->options.layer2) ) {
...@@ -3977,25 +3982,28 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, ...@@ -3977,25 +3982,28 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
static inline void static inline void
__qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer, __qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer,
int *next_element_to_fill) int is_tso, int *next_element_to_fill)
{ {
int length = skb->len; int length = skb->len;
int length_here; int length_here;
int element; int element;
char *data; char *data;
int first_lap = 1; int first_lap ;
element = *next_element_to_fill; element = *next_element_to_fill;
data = skb->data; data = skb->data;
first_lap = (is_tso == 0 ? 1 : 0);
while (length > 0) { while (length > 0) {
/* length_here is the remaining amount of data in this page */ /* length_here is the remaining amount of data in this page */
length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE); length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE);
if (length < length_here) if (length < length_here)
length_here = length; length_here = length;
buffer->element[element].addr = data; buffer->element[element].addr = data;
buffer->element[element].length = length_here; buffer->element[element].length = length_here;
length -= length_here; length -= length_here;
if (!length){ if (!length) {
if (first_lap) if (first_lap)
buffer->element[element].flags = 0; buffer->element[element].flags = 0;
else else
...@@ -4022,17 +4030,35 @@ qeth_fill_buffer(struct qeth_qdio_out_q *queue, ...@@ -4022,17 +4030,35 @@ qeth_fill_buffer(struct qeth_qdio_out_q *queue,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct qdio_buffer *buffer; struct qdio_buffer *buffer;
int flush_cnt = 0; struct qeth_hdr_tso *hdr;
int flush_cnt = 0, hdr_len, large_send = 0;
QETH_DBF_TEXT(trace, 6, "qdfillbf"); QETH_DBF_TEXT(trace, 6, "qdfillbf");
buffer = buf->buffer; buffer = buf->buffer;
atomic_inc(&skb->users); atomic_inc(&skb->users);
skb_queue_tail(&buf->skb_list, skb); skb_queue_tail(&buf->skb_list, skb);
hdr = (struct qeth_hdr_tso *) skb->data;
/*check first on TSO ....*/
if (hdr->hdr.hdr.l3.id == QETH_HEADER_TYPE_TSO) {
int element = buf->next_element_to_fill;
hdr_len = sizeof(struct qeth_hdr_tso) + hdr->ext.dg_hdr_len;
/*fill first buffer entry only with header information */
buffer->element[element].addr = skb->data;
buffer->element[element].length = hdr_len;
buffer->element[element].flags = SBAL_FLAGS_FIRST_FRAG;
buf->next_element_to_fill++;
skb->data += hdr_len;
skb->len -= hdr_len;
large_send = 1;
}
if (skb_shinfo(skb)->nr_frags == 0) if (skb_shinfo(skb)->nr_frags == 0)
__qeth_fill_buffer(skb, buffer, __qeth_fill_buffer(skb, buffer, large_send,
(int *)&buf->next_element_to_fill); (int *)&buf->next_element_to_fill);
else else
__qeth_fill_buffer_frag(skb, buffer, 0, __qeth_fill_buffer_frag(skb, buffer, large_send,
(int *)&buf->next_element_to_fill); (int *)&buf->next_element_to_fill);
if (!queue->do_pack) { if (!queue->do_pack) {
...@@ -4224,6 +4250,25 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, ...@@ -4224,6 +4250,25 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
return rc; return rc;
} }
static inline int
qeth_get_elements_no(struct qeth_card *card, void *hdr, struct sk_buff *skb)
{
int elements_needed = 0;
if (skb_shinfo(skb)->nr_frags > 0) {
elements_needed = (skb_shinfo(skb)->nr_frags + 1);
}
if (elements_needed == 0 )
elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE)
+ skb->len) >> PAGE_SHIFT);
if (elements_needed > QETH_MAX_BUFFER_ELEMENTS(card)){
PRINT_ERR("qeth_do_send_packet: invalid size of "
"IP packet. Discarded.");
return 0;
}
return elements_needed;
}
static inline int static inline int
qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
{ {
...@@ -4266,19 +4311,25 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) ...@@ -4266,19 +4311,25 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
if (skb_shinfo(skb)->tso_size) if (skb_shinfo(skb)->tso_size)
large_send = card->options.large_send; large_send = card->options.large_send;
if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))){
QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc);
return rc;
}
/*are we able to do TSO ? If so ,prepare and send it from here */ /*are we able to do TSO ? If so ,prepare and send it from here */
if ((large_send == QETH_LARGE_SEND_TSO) && if ((large_send == QETH_LARGE_SEND_TSO) &&
(cast_type == RTN_UNSPEC)) { (cast_type == RTN_UNSPEC)) {
rc = qeth_tso_send_packet(card, skb, queue, rc = qeth_tso_prepare_packet(card, skb, ipv, cast_type);
ipv, cast_type); if (rc) {
goto do_statistics; card->stats.tx_dropped++;
card->stats.tx_errors++;
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
}
elements_needed++;
} else {
if ((rc = qeth_prepare_skb(card, &skb, &hdr, ipv))) {
QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc);
return rc;
} }
qeth_fill_header(card, hdr, skb, ipv, cast_type); qeth_fill_header(card, hdr, skb, ipv, cast_type);
}
if (large_send == QETH_LARGE_SEND_EDDP) { if (large_send == QETH_LARGE_SEND_EDDP) {
ctx = qeth_eddp_create_context(card, skb, hdr); ctx = qeth_eddp_create_context(card, skb, hdr);
if (ctx == NULL) { if (ctx == NULL) {
...@@ -4286,7 +4337,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) ...@@ -4286,7 +4337,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
return -EINVAL; return -EINVAL;
} }
} else { } else {
elements_needed = qeth_get_elements_no(card,(void*) hdr, skb); elements_needed += qeth_get_elements_no(card,(void*) hdr, skb);
if (!elements_needed) if (!elements_needed)
return -EINVAL; return -EINVAL;
} }
...@@ -4297,12 +4348,12 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb) ...@@ -4297,12 +4348,12 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
else else
rc = qeth_do_send_packet_fast(card, queue, skb, hdr, rc = qeth_do_send_packet_fast(card, queue, skb, hdr,
elements_needed, ctx); elements_needed, ctx);
do_statistics:
if (!rc){ if (!rc){
card->stats.tx_packets++; card->stats.tx_packets++;
card->stats.tx_bytes += skb->len; card->stats.tx_bytes += skb->len;
#ifdef CONFIG_QETH_PERF_STATS #ifdef CONFIG_QETH_PERF_STATS
if (skb_shinfo(skb)->tso_size) { if (skb_shinfo(skb)->tso_size &&
!(large_send == QETH_LARGE_SEND_NO)) {
card->perf_stats.large_send_bytes += skb->len; card->perf_stats.large_send_bytes += skb->len;
card->perf_stats.large_send_cnt++; card->perf_stats.large_send_cnt++;
} }
...@@ -7199,7 +7250,7 @@ qeth_wait_for_threads(struct qeth_card *card, unsigned long threads) ...@@ -7199,7 +7250,7 @@ qeth_wait_for_threads(struct qeth_card *card, unsigned long threads)
} }
static int static int
qeth_stop_card(struct qeth_card *card) qeth_stop_card(struct qeth_card *card, int recovery_mode)
{ {
int rc = 0; int rc = 0;
...@@ -7212,9 +7263,13 @@ qeth_stop_card(struct qeth_card *card) ...@@ -7212,9 +7263,13 @@ qeth_stop_card(struct qeth_card *card)
if (card->read.state == CH_STATE_UP && if (card->read.state == CH_STATE_UP &&
card->write.state == CH_STATE_UP && card->write.state == CH_STATE_UP &&
(card->state == CARD_STATE_UP)) { (card->state == CARD_STATE_UP)) {
if(recovery_mode) {
qeth_stop(card->dev);
} else {
rtnl_lock(); rtnl_lock();
dev_close(card->dev); dev_close(card->dev);
rtnl_unlock(); rtnl_unlock();
}
if (!card->use_hard_stop) { if (!card->use_hard_stop) {
__u8 *mac = &card->dev->dev_addr[0]; __u8 *mac = &card->dev->dev_addr[0];
rc = qeth_layer2_send_delmac(card, mac); rc = qeth_layer2_send_delmac(card, mac);
...@@ -7386,13 +7441,17 @@ qeth_register_netdev(struct qeth_card *card) ...@@ -7386,13 +7441,17 @@ qeth_register_netdev(struct qeth_card *card)
} }
static void static void
qeth_start_again(struct qeth_card *card) qeth_start_again(struct qeth_card *card, int recovery_mode)
{ {
QETH_DBF_TEXT(setup ,2, "startag"); QETH_DBF_TEXT(setup ,2, "startag");
if(recovery_mode) {
qeth_open(card->dev);
} else {
rtnl_lock(); rtnl_lock();
dev_open(card->dev); dev_open(card->dev);
rtnl_unlock(); rtnl_unlock();
}
/* this also sets saved unicast addresses */ /* this also sets saved unicast addresses */
qeth_set_multicast_list(card->dev); qeth_set_multicast_list(card->dev);
} }
...@@ -7449,7 +7508,7 @@ static void qeth_make_parameters_consistent(struct qeth_card *card) ...@@ -7449,7 +7508,7 @@ static void qeth_make_parameters_consistent(struct qeth_card *card)
static int static int
qeth_set_online(struct ccwgroup_device *gdev) __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode)
{ {
struct qeth_card *card = gdev->dev.driver_data; struct qeth_card *card = gdev->dev.driver_data;
int rc = 0; int rc = 0;
...@@ -7509,12 +7568,12 @@ qeth_set_online(struct ccwgroup_device *gdev) ...@@ -7509,12 +7568,12 @@ qeth_set_online(struct ccwgroup_device *gdev)
* we can also use this state for recovery purposes*/ * we can also use this state for recovery purposes*/
qeth_set_allowed_threads(card, 0xffffffff, 0); qeth_set_allowed_threads(card, 0xffffffff, 0);
if (recover_flag == CARD_STATE_RECOVER) if (recover_flag == CARD_STATE_RECOVER)
qeth_start_again(card); qeth_start_again(card, recovery_mode);
qeth_notify_processes(); qeth_notify_processes();
return 0; return 0;
out_remove: out_remove:
card->use_hard_stop = 1; card->use_hard_stop = 1;
qeth_stop_card(card); qeth_stop_card(card, 0);
ccw_device_set_offline(CARD_DDEV(card)); ccw_device_set_offline(CARD_DDEV(card));
ccw_device_set_offline(CARD_WDEV(card)); ccw_device_set_offline(CARD_WDEV(card));
ccw_device_set_offline(CARD_RDEV(card)); ccw_device_set_offline(CARD_RDEV(card));
...@@ -7525,6 +7584,12 @@ qeth_set_online(struct ccwgroup_device *gdev) ...@@ -7525,6 +7584,12 @@ qeth_set_online(struct ccwgroup_device *gdev)
return -ENODEV; return -ENODEV;
} }
static int
qeth_set_online(struct ccwgroup_device *gdev)
{
return __qeth_set_online(gdev, 0);
}
static struct ccw_device_id qeth_ids[] = { static struct ccw_device_id qeth_ids[] = {
{CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE}, {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE},
{CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD}, {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD},
......
/*
* linux/drivers/s390/net/qeth_tso.c ($Revision: 1.7 $)
*
* Header file for qeth TCP Segmentation Offload support.
*
* Copyright 2004 IBM Corporation
*
* Author(s): Frank Pavlic <pavlic@de.ibm.com>
*
* $Revision: 1.7 $ $Date: 2005/04/01 21:40:41 $
*
*/
#include <linux/skbuff.h>
#include <linux/tcp.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <net/ip6_checksum.h>
#include "qeth.h"
#include "qeth_mpc.h"
#include "qeth_tso.h"
/**
* skb already partially prepared
* classic qdio header in skb->data
* */
static inline struct qeth_hdr_tso *
qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb)
{
int rc = 0;
QETH_DBF_TEXT(trace, 5, "tsoprsk");
rc = qeth_realloc_headroom(card, skb,sizeof(struct qeth_hdr_ext_tso));
if (rc)
return NULL;
return qeth_push_skb(card, skb, sizeof(struct qeth_hdr_ext_tso));
}
/**
* fill header for a TSO packet
*/
static inline void
qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
{
struct qeth_hdr_tso *hdr;
struct tcphdr *tcph;
struct iphdr *iph;
QETH_DBF_TEXT(trace, 5, "tsofhdr");
hdr = (struct qeth_hdr_tso *) skb->data;
iph = skb->nh.iph;
tcph = skb->h.th;
/*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)->tso_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));
}
/**
* change some header values as requested by hardware
*/
static inline void
qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
{
struct iphdr *iph;
struct ipv6hdr *ip6h;
struct tcphdr *tcph;
iph = skb->nh.iph;
ip6h = skb->nh.ipv6h;
tcph = skb->h.th;
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);
return;
}
/*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;
}
static inline struct qeth_hdr_tso *
qeth_tso_prepare_packet(struct qeth_card *card, struct sk_buff *skb,
int ipv, int cast_type)
{
struct qeth_hdr_tso *hdr;
int rc = 0;
QETH_DBF_TEXT(trace, 5, "tsoprep");
/*get headroom for tso qdio header */
hdr = (struct qeth_hdr_tso *) qeth_tso_prepare_skb(card, &skb);
if (hdr == NULL) {
QETH_DBF_TEXT_(trace, 4, "2err%d", rc);
return NULL;
}
memset(hdr, 0, sizeof(struct qeth_hdr_tso));
/*fill first 32 bytes of qdio header as used
*FIXME: TSO has two struct members
* with different names but same size
* */
qeth_fill_header(card, &hdr->hdr, skb, ipv, cast_type);
qeth_tso_fill_header(card, skb);
qeth_tso_set_tcpip_header(card, skb);
return hdr;
}
static inline int
qeth_tso_get_queue_buffer(struct qeth_qdio_out_q *queue)
{
struct qeth_qdio_out_buffer *buffer;
int flush_cnt = 0;
QETH_DBF_TEXT(trace, 5, "tsobuf");
/* force to non-packing*/
if (queue->do_pack)
queue->do_pack = 0;
buffer = &queue->bufs[queue->next_buf_to_fill];
/* get a new buffer if current is already in use*/
if ((atomic_read(&buffer->state) == QETH_QDIO_BUF_EMPTY) &&
(buffer->next_element_to_fill > 0)) {
atomic_set(&buffer->state, QETH_QDIO_BUF_PRIMED);
queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) %
QDIO_MAX_BUFFERS_PER_Q;
flush_cnt++;
}
return flush_cnt;
}
static inline int
qeth_tso_fill_buffer(struct qeth_qdio_out_buffer *buf,
struct sk_buff *skb)
{
int length, length_here, element;
int hdr_len;
struct qdio_buffer *buffer;
struct qeth_hdr_tso *hdr;
char *data;
QETH_DBF_TEXT(trace, 3, "tsfilbuf");
/*increment user count and queue skb ...*/
atomic_inc(&skb->users);
skb_queue_tail(&buf->skb_list, skb);
/*initialize all variables...*/
buffer = buf->buffer;
hdr = (struct qeth_hdr_tso *)skb->data;
hdr_len = sizeof(struct qeth_hdr_tso) + hdr->ext.dg_hdr_len;
data = skb->data + hdr_len;
length = skb->len - hdr_len;
element = buf->next_element_to_fill;
/*fill first buffer entry only with header information */
buffer->element[element].addr = skb->data;
buffer->element[element].length = hdr_len;
buffer->element[element].flags = SBAL_FLAGS_FIRST_FRAG;
buf->next_element_to_fill++;
/*check if we have frags ...*/
if (skb_shinfo(skb)->nr_frags > 0) {
skb->len = length;
skb->data = data;
__qeth_fill_buffer_frag(skb, buffer,1,
(int *)&buf->next_element_to_fill);
goto out;
}
/*... if not, use this */
element++;
while (length > 0) {
/* length_here is the remaining amount of data in this page */
length_here = PAGE_SIZE - ((unsigned long) data % PAGE_SIZE);
if (length < length_here)
length_here = length;
buffer->element[element].addr = data;
buffer->element[element].length = length_here;
length -= length_here;
if (!length)
buffer->element[element].flags =
SBAL_FLAGS_LAST_FRAG;
else
buffer->element[element].flags =
SBAL_FLAGS_MIDDLE_FRAG;
data += length_here;
element++;
}
buf->next_element_to_fill = element;
out:
/*prime buffer now ...*/
atomic_set(&buf->state, QETH_QDIO_BUF_PRIMED);
return 1;
}
int
qeth_tso_send_packet(struct qeth_card *card, struct sk_buff *skb,
struct qeth_qdio_out_q *queue, int ipv, int cast_type)
{
int flush_cnt = 0;
struct qeth_hdr_tso *hdr;
struct qeth_qdio_out_buffer *buffer;
int start_index;
QETH_DBF_TEXT(trace, 3, "tsosend");
if (!(hdr = qeth_tso_prepare_packet(card, skb, ipv, cast_type)))
return -ENOMEM;
/*check if skb fits in one SBAL ...*/
if (!(qeth_get_elements_no(card, (void*)hdr, skb)))
return -EINVAL;
/*lock queue, force switching to non-packing and send it ...*/
while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED,
QETH_OUT_Q_LOCKED,
&queue->state));
start_index = queue->next_buf_to_fill;
buffer = &queue->bufs[queue->next_buf_to_fill];
/*check if card is too busy ...*/
if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY){
card->stats.tx_dropped++;
goto out;
}
/*let's force to non-packing and get a new SBAL*/
flush_cnt += qeth_tso_get_queue_buffer(queue);
buffer = &queue->bufs[queue->next_buf_to_fill];
if (atomic_read(&buffer->state) != QETH_QDIO_BUF_EMPTY) {
card->stats.tx_dropped++;
goto out;
}
flush_cnt += qeth_tso_fill_buffer(buffer, skb);
queue->next_buf_to_fill = (queue->next_buf_to_fill + 1) %
QDIO_MAX_BUFFERS_PER_Q;
out:
atomic_set(&queue->state, QETH_OUT_Q_UNLOCKED);
if (flush_cnt)
qeth_flush_buffers(queue, 0, start_index, flush_cnt);
/*do some statistics */
card->stats.tx_packets++;
card->stats.tx_bytes += skb->len;
return 0;
}
/* /*
* linux/drivers/s390/net/qeth_tso.h ($Revision: 1.5 $) * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.7 $)
* *
* Header file for qeth TCP Segmentation Offload support. * Header file for qeth TCP Segmentation Offload support.
* *
...@@ -7,97 +7,148 @@ ...@@ -7,97 +7,148 @@
* *
* Author(s): Frank Pavlic <pavlic@de.ibm.com> * Author(s): Frank Pavlic <pavlic@de.ibm.com>
* *
* $Revision: 1.5 $ $Date: 2005/04/01 21:40:41 $ * $Revision: 1.7 $ $Date: 2005/05/04 20:19:18 $
* *
*/ */
#ifndef __QETH_TSO_H__ #ifndef __QETH_TSO_H__
#define __QETH_TSO_H__ #define __QETH_TSO_H__
#include <linux/skbuff.h>
#include <linux/tcp.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <net/ip6_checksum.h>
#include "qeth.h"
#include "qeth_mpc.h"
extern int
qeth_tso_send_packet(struct qeth_card *, struct sk_buff *,
struct qeth_qdio_out_q *, int , int);
struct qeth_hdr_ext_tso { static inline struct qeth_hdr_tso *
__u16 hdr_tot_len; qeth_tso_prepare_skb(struct qeth_card *card, struct sk_buff **skb)
__u8 imb_hdr_no; {
__u8 reserved; QETH_DBF_TEXT(trace, 5, "tsoprsk");
__u8 hdr_type; return qeth_push_skb(card, skb, sizeof(struct qeth_hdr_tso));
__u8 hdr_version; }
__u16 hdr_len;
__u32 payload_len; /**
__u16 mss; * fill header for a TSO packet
__u16 dg_hdr_len; */
__u8 padding[16]; static inline void
} __attribute__ ((packed)); qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
{
struct qeth_hdr_tso *hdr;
struct tcphdr *tcph;
struct iphdr *iph;
QETH_DBF_TEXT(trace, 5, "tsofhdr");
hdr = (struct qeth_hdr_tso *) skb->data;
iph = skb->nh.iph;
tcph = skb->h.th;
/*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)->tso_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));
}
/**
* change some header values as requested by hardware
*/
static inline void
qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
{
struct iphdr *iph;
struct ipv6hdr *ip6h;
struct tcphdr *tcph;
struct qeth_hdr_tso { iph = skb->nh.iph;
struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/ ip6h = skb->nh.ipv6h;
struct qeth_hdr_ext_tso ext; tcph = skb->h.th;
} __attribute__ ((packed));
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);
return;
}
/*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;
}
/*some helper functions*/
static inline int static inline int
qeth_get_elements_no(struct qeth_card *card, void *hdr, struct sk_buff *skb) qeth_tso_prepare_packet(struct qeth_card *card, struct sk_buff *skb,
int ipv, int cast_type)
{ {
int elements_needed = 0; struct qeth_hdr_tso *hdr;
if (skb_shinfo(skb)->nr_frags > 0) QETH_DBF_TEXT(trace, 5, "tsoprep");
elements_needed = (skb_shinfo(skb)->nr_frags + 1);
if (elements_needed == 0 ) hdr = (struct qeth_hdr_tso *) qeth_tso_prepare_skb(card, &skb);
elements_needed = 1 + (((((unsigned long) hdr) % PAGE_SIZE) if (hdr == NULL) {
+ skb->len) >> PAGE_SHIFT); QETH_DBF_TEXT(trace, 4, "tsoperr");
if (elements_needed > QETH_MAX_BUFFER_ELEMENTS(card)){ return -ENOMEM;
PRINT_ERR("qeth_do_send_packet: invalid size of "
"IP packet. Discarded.");
return 0;
} }
return elements_needed; memset(hdr, 0, sizeof(struct qeth_hdr_tso));
/*fill first 32 bytes of qdio header as used
*FIXME: TSO has two struct members
* with different names but same size
* */
qeth_fill_header(card, &hdr->hdr, skb, ipv, cast_type);
qeth_tso_fill_header(card, skb);
qeth_tso_set_tcpip_header(card, skb);
return 0;
} }
static inline void static inline void
__qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer, __qeth_fill_buffer_frag(struct sk_buff *skb, struct qdio_buffer *buffer,
int is_tso, int *next_element_to_fill) int is_tso, int *next_element_to_fill)
{ {
int length = skb->len;
struct skb_frag_struct *frag; struct skb_frag_struct *frag;
int fragno; int fragno;
unsigned long addr; unsigned long addr;
int element; int element, cnt, dlen;
int first_lap = 1;
fragno = skb_shinfo(skb)->nr_frags; /* start with last frag */ fragno = skb_shinfo(skb)->nr_frags;
element = *next_element_to_fill + fragno; element = *next_element_to_fill;
while (length > 0) { dlen = 0;
if (fragno > 0) {
frag = &skb_shinfo(skb)->frags[fragno - 1]; if (is_tso)
addr = (page_to_pfn(frag->page) << PAGE_SHIFT) +
frag->page_offset;
buffer->element[element].addr = (char *)addr;
buffer->element[element].length = frag->size;
length -= frag->size;
if (first_lap)
buffer->element[element].flags = buffer->element[element].flags =
SBAL_FLAGS_LAST_FRAG; SBAL_FLAGS_MIDDLE_FRAG;
else else
buffer->element[element].flags = buffer->element[element].flags =
SBAL_FLAGS_MIDDLE_FRAG; SBAL_FLAGS_FIRST_FRAG;
} else { if ( (dlen = (skb->len - skb->data_len)) ) {
buffer->element[element].addr = skb->data; buffer->element[element].addr = skb->data;
buffer->element[element].length = length; buffer->element[element].length = dlen;
length = 0; element++;
if (is_tso) }
for (cnt = 0; cnt < fragno; cnt++) {
frag = &skb_shinfo(skb)->frags[cnt];
addr = (page_to_pfn(frag->page) << PAGE_SHIFT) +
frag->page_offset;
buffer->element[element].addr = (char *)addr;
buffer->element[element].length = frag->size;
if (cnt < (fragno - 1))
buffer->element[element].flags = buffer->element[element].flags =
SBAL_FLAGS_MIDDLE_FRAG; SBAL_FLAGS_MIDDLE_FRAG;
else else
buffer->element[element].flags = buffer->element[element].flags =
SBAL_FLAGS_FIRST_FRAG; SBAL_FLAGS_LAST_FRAG;
} element++;
element--;
fragno--;
first_lap = 0;
} }
*next_element_to_fill += skb_shinfo(skb)->nr_frags + 1; *next_element_to_fill = element;
} }
#endif /* __QETH_TSO_H__ */ #endif /* __QETH_TSO_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment