aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net/qeth_l3_main.c
diff options
context:
space:
mode:
authorFrank Blaschka <frank.blaschka@de.ibm.com>2009-11-11 19:11:44 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-16 05:42:08 -0500
commitc3b4a740db3688b245282ac957a01f3fb8d1186d (patch)
treeca05c6e683b5b2371ba265aa6db9536441f94f1a /drivers/s390/net/qeth_l3_main.c
parentaa90922479513db0d080239324d0d04701418ba5 (diff)
qeth: rework TSO functions
The maximum TSO size OSA can handle is 15 * PAGE_SIZE. This patch reduces gso_max_size to this value and adds some sanity checks and statistics to the TSO implementation. Since only layer 3 is able to do TSO move all TSO related functions to the qeth_l3 module. Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/s390/net/qeth_l3_main.c')
-rw-r--r--drivers/s390/net/qeth_l3_main.c71
1 files changed, 58 insertions, 13 deletions
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 03f67bb51e99..2048b4354216 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -41,6 +41,32 @@ static int qeth_l3_deregister_addr_entry(struct qeth_card *,
41static int __qeth_l3_set_online(struct ccwgroup_device *, int); 41static int __qeth_l3_set_online(struct ccwgroup_device *, int);
42static int __qeth_l3_set_offline(struct ccwgroup_device *, int); 42static int __qeth_l3_set_offline(struct ccwgroup_device *, int);
43 43
44int qeth_l3_set_large_send(struct qeth_card *card,
45 enum qeth_large_send_types type)
46{
47 int rc = 0;
48
49 card->options.large_send = type;
50 if (card->dev == NULL)
51 return 0;
52
53 if (card->options.large_send == QETH_LARGE_SEND_TSO) {
54 if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) {
55 card->dev->features |= NETIF_F_TSO | NETIF_F_SG |
56 NETIF_F_HW_CSUM;
57 } else {
58 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG |
59 NETIF_F_HW_CSUM);
60 card->options.large_send = QETH_LARGE_SEND_NO;
61 rc = -EOPNOTSUPP;
62 }
63 } else {
64 card->dev->features &= ~(NETIF_F_TSO | NETIF_F_SG |
65 NETIF_F_HW_CSUM);
66 card->options.large_send = QETH_LARGE_SEND_NO;
67 }
68 return rc;
69}
44 70
45static int qeth_l3_isxdigit(char *buf) 71static int qeth_l3_isxdigit(char *buf)
46{ 72{
@@ -2686,6 +2712,24 @@ static void qeth_tx_csum(struct sk_buff *skb)
2686 *(__sum16 *)(skb->data + offset) = csum_fold(csum); 2712 *(__sum16 *)(skb->data + offset) = csum_fold(csum);
2687} 2713}
2688 2714
2715static inline int qeth_l3_tso_elements(struct sk_buff *skb)
2716{
2717 unsigned long tcpd = (unsigned long)tcp_hdr(skb) +
2718 tcp_hdr(skb)->doff * 4;
2719 int tcpd_len = skb->len - (tcpd - (unsigned long)skb->data);
2720 int elements = PFN_UP(tcpd + tcpd_len) - PFN_DOWN(tcpd);
2721 elements += skb_shinfo(skb)->nr_frags;
2722 return elements;
2723}
2724
2725static inline int qeth_l3_tso_check(struct sk_buff *skb)
2726{
2727 int len = ((unsigned long)tcp_hdr(skb) + tcp_hdr(skb)->doff * 4) -
2728 (unsigned long)skb->data;
2729 return (((unsigned long)skb->data & PAGE_MASK) !=
2730 (((unsigned long)skb->data + len) & PAGE_MASK));
2731}
2732
2689static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 2733static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2690{ 2734{
2691 int rc; 2735 int rc;
@@ -2779,16 +2823,21 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2779 /* fix hardware limitation: as long as we do not have sbal 2823 /* fix hardware limitation: as long as we do not have sbal
2780 * chaining we can not send long frag lists 2824 * chaining we can not send long frag lists
2781 */ 2825 */
2782 if ((large_send == QETH_LARGE_SEND_TSO) && 2826 if (large_send == QETH_LARGE_SEND_TSO) {
2783 ((skb_shinfo(new_skb)->nr_frags + 2) > 16)) { 2827 if (qeth_l3_tso_elements(new_skb) + 1 > 16) {
2784 if (skb_linearize(new_skb)) 2828 if (skb_linearize(new_skb))
2785 goto tx_drop; 2829 goto tx_drop;
2830 if (card->options.performance_stats)
2831 card->perf_stats.tx_lin++;
2832 }
2786 } 2833 }
2787 2834
2788 if ((large_send == QETH_LARGE_SEND_TSO) && 2835 if ((large_send == QETH_LARGE_SEND_TSO) &&
2789 (cast_type == RTN_UNSPEC)) { 2836 (cast_type == RTN_UNSPEC)) {
2790 hdr = (struct qeth_hdr *)skb_push(new_skb, 2837 hdr = (struct qeth_hdr *)skb_push(new_skb,
2791 sizeof(struct qeth_hdr_tso)); 2838 sizeof(struct qeth_hdr_tso));
2839 if (qeth_l3_tso_check(new_skb))
2840 QETH_DBF_MESSAGE(2, "tso skb misaligned\n");
2792 memset(hdr, 0, sizeof(struct qeth_hdr_tso)); 2841 memset(hdr, 0, sizeof(struct qeth_hdr_tso));
2793 qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type); 2842 qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type);
2794 qeth_tso_fill_header(card, hdr, new_skb); 2843 qeth_tso_fill_header(card, hdr, new_skb);
@@ -2931,20 +2980,15 @@ static int qeth_l3_ethtool_set_rx_csum(struct net_device *dev, u32 data)
2931static int qeth_l3_ethtool_set_tso(struct net_device *dev, u32 data) 2980static int qeth_l3_ethtool_set_tso(struct net_device *dev, u32 data)
2932{ 2981{
2933 struct qeth_card *card = dev->ml_priv; 2982 struct qeth_card *card = dev->ml_priv;
2983 int rc = 0;
2934 2984
2935 if (data) { 2985 if (data) {
2936 if (card->options.large_send == QETH_LARGE_SEND_NO) { 2986 rc = qeth_l3_set_large_send(card, QETH_LARGE_SEND_TSO);
2937 if (card->info.type == QETH_CARD_TYPE_IQD)
2938 return -EPERM;
2939 else
2940 card->options.large_send = QETH_LARGE_SEND_TSO;
2941 dev->features |= NETIF_F_TSO;
2942 }
2943 } else { 2987 } else {
2944 dev->features &= ~NETIF_F_TSO; 2988 dev->features &= ~NETIF_F_TSO;
2945 card->options.large_send = QETH_LARGE_SEND_NO; 2989 card->options.large_send = QETH_LARGE_SEND_NO;
2946 } 2990 }
2947 return 0; 2991 return rc;
2948} 2992}
2949 2993
2950static const struct ethtool_ops qeth_l3_ethtool_ops = { 2994static const struct ethtool_ops qeth_l3_ethtool_ops = {
@@ -3060,6 +3104,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
3060 NETIF_F_HW_VLAN_RX | 3104 NETIF_F_HW_VLAN_RX |
3061 NETIF_F_HW_VLAN_FILTER; 3105 NETIF_F_HW_VLAN_FILTER;
3062 card->dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; 3106 card->dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
3107 card->dev->gso_max_size = 15 * PAGE_SIZE;
3063 3108
3064 SET_NETDEV_DEV(card->dev, &card->gdev->dev); 3109 SET_NETDEV_DEV(card->dev, &card->gdev->dev);
3065 return register_netdev(card->dev); 3110 return register_netdev(card->dev);
@@ -3189,7 +3234,7 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
3189 goto out_remove; 3234 goto out_remove;
3190 } else 3235 } else
3191 card->lan_online = 1; 3236 card->lan_online = 1;
3192 qeth_set_large_send(card, card->options.large_send); 3237 qeth_l3_set_large_send(card, card->options.large_send);
3193 3238
3194 rc = qeth_l3_setadapter_parms(card); 3239 rc = qeth_l3_setadapter_parms(card);
3195 if (rc) 3240 if (rc)