[PATCH] tg3: Fix rx hang on MTU change with 5717/5719
This fixes a hang issue seen when changing the MTU size from 1500 MTU to 9000 MTU on both 5717 and 5719 chips. In discussion with Broadcom, they've indicated that these chipsets have the same phy as the 57766 chipset, so the same workarounds apply. This has been tested by IBM on both Power 8 and Power 9 systems as well as by Broadcom on x86 hardware and has been confirmed to resolve the hang issue. Cc: stable <sta...@vger.kernel.org> Signed-off-by: Brian King <brk...@linux.vnet.ibm.com> --- drivers/net/ethernet/broadcom/tg3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index de51c21..d09c5a9 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -14225,7 +14225,9 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) /* Reset PHY, otherwise the read DMA engine will be in a mode that * breaks all requests to 256 bytes. */ - if (tg3_asic_rev(tp) == ASIC_REV_57766) + if (tg3_asic_rev(tp) == ASIC_REV_57766 || + tg3_asic_rev(tp) == ASIC_REV_5717 || + tg3_asic_rev(tp) == ASIC_REV_5719) reset_phy = true; err = tg3_restart_hw(tp, reset_phy); -- 1.8.3.1
Re: [PATCH net-next] ibmveth: v1 calculate correct gso_size and set gso_type
On 10/27/2016 10:26 AM, Eric Dumazet wrote: > On Wed, 2016-10-26 at 11:09 +1100, Jon Maxwell wrote: >> We recently encountered a bug where a few customers using ibmveth on the >> same LPAR hit an issue where a TCP session hung when large receive was >> enabled. Closer analysis revealed that the session was stuck because the >> one side was advertising a zero window repeatedly. >> >> We narrowed this down to the fact the ibmveth driver did not set gso_size >> which is translated by TCP into the MSS later up the stack. The MSS is >> used to calculate the TCP window size and as that was abnormally large, >> it was calculating a zero window, even although the sockets receive buffer >> was completely empty. >> >> We were able to reproduce this and worked with IBM to fix this. Thanks Tom >> and Marcelo for all your help and review on this. >> >> The patch fixes both our internal reproduction tests and our customers tests. >> >> Signed-off-by: Jon Maxwell <jmaxwel...@gmail.com> >> --- >> drivers/net/ethernet/ibm/ibmveth.c | 20 >> 1 file changed, 20 insertions(+) >> >> diff --git a/drivers/net/ethernet/ibm/ibmveth.c >> b/drivers/net/ethernet/ibm/ibmveth.c >> index 29c05d0..c51717e 100644 >> --- a/drivers/net/ethernet/ibm/ibmveth.c >> +++ b/drivers/net/ethernet/ibm/ibmveth.c >> @@ -1182,6 +1182,8 @@ static int ibmveth_poll(struct napi_struct *napi, int >> budget) >> int frames_processed = 0; >> unsigned long lpar_rc; >> struct iphdr *iph; >> +bool large_packet = 0; >> +u16 hdr_len = ETH_HLEN + sizeof(struct tcphdr); >> >> restart_poll: >> while (frames_processed < budget) { >> @@ -1236,10 +1238,28 @@ static int ibmveth_poll(struct napi_struct *napi, >> int budget) >> iph->check = 0; >> iph->check = >> ip_fast_csum((unsigned char *)iph, iph->ihl); >> adapter->rx_large_packets++; >> +large_packet = 1; >> } >> } >> } >> >> +if (skb->len > netdev->mtu) { >> +iph = (struct iphdr *)skb->data; >> +if (be16_to_cpu(skb->protocol) == ETH_P_IP && >> +iph->protocol == IPPROTO_TCP) { >> +hdr_len += sizeof(struct iphdr); >> +skb_shinfo(skb)->gso_type = >> SKB_GSO_TCPV4; >> +skb_shinfo(skb)->gso_size = netdev->mtu >> - hdr_len; >> +} else if (be16_to_cpu(skb->protocol) == >> ETH_P_IPV6 && >> + iph->protocol == IPPROTO_TCP) { >> +hdr_len += sizeof(struct ipv6hdr); >> +skb_shinfo(skb)->gso_type = >> SKB_GSO_TCPV6; >> +skb_shinfo(skb)->gso_size = netdev->mtu >> - hdr_len; >> +} >> +if (!large_packet) >> +adapter->rx_large_packets++; >> +} >> + >> > > This might break forwarding and PMTU discovery. > > You force gso_size to device mtu, regardless of real MSS used by the TCP > sender. > > Don't you have the MSS provided in RX descriptor, instead of guessing > the value ? Eric, We are currently pursuing making changes to the Power Virtual I/O Server to provide the MSS to the ibmveth driver. However, this will take time to go through test and ultimately get released. Although imperfect, this patch does help a real customer hitting this issue right now. Would you object to this patch getting merged as is, with the understanding that when we get the change in the Virtual I/O Server released, we will revert this interim change and apply the new method? Thanks, Brian -- Brian King Power Linux I/O IBM Linux Technology Center
Re: [PATCH net-next] ibmveth: v1 calculate correct gso_size and set gso_type
On 11/06/2016 03:22 PM, Jonathan Maxwell wrote: > On Thu, Nov 3, 2016 at 8:40 AM, Brian King <brk...@linux.vnet.ibm.com> wrote: >> On 10/27/2016 10:26 AM, Eric Dumazet wrote: >>> On Wed, 2016-10-26 at 11:09 +1100, Jon Maxwell wrote: >>>> We recently encountered a bug where a few customers using ibmveth on the >>>> same LPAR hit an issue where a TCP session hung when large receive was >>>> enabled. Closer analysis revealed that the session was stuck because the >>>> one side was advertising a zero window repeatedly. >>>> >>>> We narrowed this down to the fact the ibmveth driver did not set gso_size >>>> which is translated by TCP into the MSS later up the stack. The MSS is >>>> used to calculate the TCP window size and as that was abnormally large, >>>> it was calculating a zero window, even although the sockets receive buffer >>>> was completely empty. >>>> >>>> We were able to reproduce this and worked with IBM to fix this. Thanks Tom >>>> and Marcelo for all your help and review on this. >>>> >>>> The patch fixes both our internal reproduction tests and our customers >>>> tests. >>>> >>>> Signed-off-by: Jon Maxwell <jmaxwel...@gmail.com> >>>> --- >>>> drivers/net/ethernet/ibm/ibmveth.c | 20 >>>> 1 file changed, 20 insertions(+) >>>> >>>> diff --git a/drivers/net/ethernet/ibm/ibmveth.c >>>> b/drivers/net/ethernet/ibm/ibmveth.c >>>> index 29c05d0..c51717e 100644 >>>> --- a/drivers/net/ethernet/ibm/ibmveth.c >>>> +++ b/drivers/net/ethernet/ibm/ibmveth.c >>>> @@ -1182,6 +1182,8 @@ static int ibmveth_poll(struct napi_struct *napi, >>>> int budget) >>>> int frames_processed = 0; >>>> unsigned long lpar_rc; >>>> struct iphdr *iph; >>>> +bool large_packet = 0; >>>> +u16 hdr_len = ETH_HLEN + sizeof(struct tcphdr); >>>> >>>> restart_poll: >>>> while (frames_processed < budget) { >>>> @@ -1236,10 +1238,28 @@ static int ibmveth_poll(struct napi_struct *napi, >>>> int budget) >>>> iph->check = 0; >>>> iph->check = >>>> ip_fast_csum((unsigned char *)iph, iph->ihl); >>>> adapter->rx_large_packets++; >>>> +large_packet = 1; >>>> } >>>> } >>>> } >>>> >>>> +if (skb->len > netdev->mtu) { >>>> +iph = (struct iphdr *)skb->data; >>>> +if (be16_to_cpu(skb->protocol) == ETH_P_IP && >>>> +iph->protocol == IPPROTO_TCP) { >>>> +hdr_len += sizeof(struct iphdr); >>>> +skb_shinfo(skb)->gso_type = >>>> SKB_GSO_TCPV4; >>>> +skb_shinfo(skb)->gso_size = >>>> netdev->mtu - hdr_len; >>>> +} else if (be16_to_cpu(skb->protocol) == >>>> ETH_P_IPV6 && >>>> + iph->protocol == IPPROTO_TCP) { >>>> +hdr_len += sizeof(struct ipv6hdr); >>>> +skb_shinfo(skb)->gso_type = >>>> SKB_GSO_TCPV6; >>>> +skb_shinfo(skb)->gso_size = >>>> netdev->mtu - hdr_len; >>>> +} >>>> +if (!large_packet) >>>> +adapter->rx_large_packets++; >>>> +} >>>> + >>>> >>> >>> This might break forwarding and PMTU discovery. >>> >>> You force gso_size to device mtu, regardless of real MSS used by the TCP >>> sender. >>> >>> Don't you have the MSS provided in RX descriptor, instead of guessing >>> the value ? >> >> We've had some further discussions on this with the Virtual I/O Server (VIOS) >> development team. The large receive aggregation
Re: [PATCH net-next] ibmveth: v1 calculate correct gso_size and set gso_type
On 10/27/2016 10:26 AM, Eric Dumazet wrote: > On Wed, 2016-10-26 at 11:09 +1100, Jon Maxwell wrote: >> We recently encountered a bug where a few customers using ibmveth on the >> same LPAR hit an issue where a TCP session hung when large receive was >> enabled. Closer analysis revealed that the session was stuck because the >> one side was advertising a zero window repeatedly. >> >> We narrowed this down to the fact the ibmveth driver did not set gso_size >> which is translated by TCP into the MSS later up the stack. The MSS is >> used to calculate the TCP window size and as that was abnormally large, >> it was calculating a zero window, even although the sockets receive buffer >> was completely empty. >> >> We were able to reproduce this and worked with IBM to fix this. Thanks Tom >> and Marcelo for all your help and review on this. >> >> The patch fixes both our internal reproduction tests and our customers tests. >> >> Signed-off-by: Jon Maxwell <jmaxwel...@gmail.com> >> --- >> drivers/net/ethernet/ibm/ibmveth.c | 20 >> 1 file changed, 20 insertions(+) >> >> diff --git a/drivers/net/ethernet/ibm/ibmveth.c >> b/drivers/net/ethernet/ibm/ibmveth.c >> index 29c05d0..c51717e 100644 >> --- a/drivers/net/ethernet/ibm/ibmveth.c >> +++ b/drivers/net/ethernet/ibm/ibmveth.c >> @@ -1182,6 +1182,8 @@ static int ibmveth_poll(struct napi_struct *napi, int >> budget) >> int frames_processed = 0; >> unsigned long lpar_rc; >> struct iphdr *iph; >> +bool large_packet = 0; >> +u16 hdr_len = ETH_HLEN + sizeof(struct tcphdr); >> >> restart_poll: >> while (frames_processed < budget) { >> @@ -1236,10 +1238,28 @@ static int ibmveth_poll(struct napi_struct *napi, >> int budget) >> iph->check = 0; >> iph->check = >> ip_fast_csum((unsigned char *)iph, iph->ihl); >> adapter->rx_large_packets++; >> +large_packet = 1; >> } >> } >> } >> >> +if (skb->len > netdev->mtu) { >> +iph = (struct iphdr *)skb->data; >> +if (be16_to_cpu(skb->protocol) == ETH_P_IP && >> +iph->protocol == IPPROTO_TCP) { >> +hdr_len += sizeof(struct iphdr); >> +skb_shinfo(skb)->gso_type = >> SKB_GSO_TCPV4; >> +skb_shinfo(skb)->gso_size = netdev->mtu >> - hdr_len; >> +} else if (be16_to_cpu(skb->protocol) == >> ETH_P_IPV6 && >> + iph->protocol == IPPROTO_TCP) { >> +hdr_len += sizeof(struct ipv6hdr); >> +skb_shinfo(skb)->gso_type = >> SKB_GSO_TCPV6; >> +skb_shinfo(skb)->gso_size = netdev->mtu >> - hdr_len; >> +} >> +if (!large_packet) >> +adapter->rx_large_packets++; >> +} >> + >> > > This might break forwarding and PMTU discovery. > > You force gso_size to device mtu, regardless of real MSS used by the TCP > sender. > > Don't you have the MSS provided in RX descriptor, instead of guessing > the value ? We've had some further discussions on this with the Virtual I/O Server (VIOS) development team. The large receive aggregation in the VIOS (AIX based) is actually being done by software in the VIOS. What they may be able to do is when performing this aggregation, they could look at the packet lengths of all the packets being aggregated and take the largest packet size within the aggregation unit, minus the header length and return that to the virtual ethernet client which we could then stuff into gso_size. They are currently assessing how feasible this would be to do and whether it would impact other bits of the code. However, assuming this does end up being an option, would this address the concerns here or is that going to break something else I'm not thinking of? Unfortunately, I don't think we'd have a good way to get gso_segs set correctly as I don't see how that would get passed back up the interface. Thanks, Brian -- Brian King Power Linux I/O IBM Linux Technology Center
[PATCH 3/6] ibmveth: Add ethtool TSO handlers
Add handlers for get_tso and get_ufo to prevent errors being printed by ethtool. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c |2 ++ 1 file changed, 2 insertions(+) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_get_tso drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_get_tso 2007-08-08 10:46:28.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-08 10:46:28.0 -0500 @@ -767,6 +767,8 @@ static const struct ethtool_ops netdev_e .set_tx_csum= ibmveth_set_tx_csum, .get_rx_csum= ibmveth_get_rx_csum, .set_rx_csum= ibmveth_set_rx_csum, + .get_tso= ethtool_op_get_tso, + .get_ufo= ethtool_op_get_ufo, }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/6] ibmveth: Add ethtool driver stats hooks
Add ethtool hooks to ibmveth to retrieve driver statistics. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 51 1 file changed, 51 insertions(+) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats 2007-08-08 10:46:30.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-08 10:48:08.0 -0500 @@ -112,6 +112,28 @@ MODULE_DESCRIPTION(IBM i/pSeries Virtua MODULE_LICENSE(GPL); MODULE_VERSION(ibmveth_driver_version); +struct ibmveth_stat { + char name[ETH_GSTRING_LEN]; + int offset; +}; + +#define IBMVETH_STAT_OFF(stat) offsetof(struct ibmveth_adapter, stat) +#define IBMVETH_GET_STAT(a, off) *((u64 *)(((unsigned long)(a)) + off)) + +struct ibmveth_stat ibmveth_stats[] = { + { replenish_task_cycles, IBMVETH_STAT_OFF(replenish_task_cycles) }, + { replenish_no_mem, IBMVETH_STAT_OFF(replenish_no_mem) }, + { replenish_add_buff_failure, IBMVETH_STAT_OFF(replenish_add_buff_failure) }, + { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, + { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, + { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, + { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, + { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, + { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, + { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, + { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) }, +}; + /* simple methods of getting data from the current rxq entry */ static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { @@ -758,6 +780,32 @@ static u32 ibmveth_get_rx_csum(struct ne return adapter-rx_csum; } +static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + + if (stringset != ETH_SS_STATS) + return; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++, data += ETH_GSTRING_LEN) + memcpy(data, ibmveth_stats[i].name, ETH_GSTRING_LEN); +} + +static int ibmveth_get_stats_count(struct net_device *dev) +{ + return ARRAY_SIZE(ibmveth_stats); +} + +static void ibmveth_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) +{ + int i; + struct ibmveth_adapter *adapter = dev-priv; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++) + data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, @@ -769,6 +817,9 @@ static const struct ethtool_ops netdev_e .set_rx_csum= ibmveth_set_rx_csum, .get_tso= ethtool_op_get_tso, .get_ufo= ethtool_op_get_ufo, + .get_strings= ibmveth_get_strings, + .get_stats_count= ibmveth_get_stats_count, + .get_ethtool_stats = ibmveth_get_ethtool_stats, }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) diff -puN drivers/net/ibmveth.h~ibmveth_ethtool_driver_stats drivers/net/ibmveth.h _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] ibmveth: Remove dead frag processing code
Removes dead frag processing code from ibmveth. Since NETIF_F_SG was not set, this code was never executed. Also, since the ibmveth interface can only handle 6 fragments, core networking code would need to be modified in order to efficiently enable this support. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 100 +--- linux-2.6-bjking1/drivers/net/ibmveth.h |5 - 2 files changed, 17 insertions(+), 88 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_remove_frag drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_remove_frag 2007-08-09 15:15:18.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-09 15:15:18.0 -0500 @@ -28,7 +28,6 @@ /**/ /* TODO: - - remove frag processing code - no longer needed - add support for sysfs - possibly remove procfs support */ @@ -127,9 +126,6 @@ struct ibmveth_stat ibmveth_stats[] = { { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, - { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, - { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, - { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) }, }; @@ -832,9 +828,8 @@ static int ibmveth_ioctl(struct net_devi static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) { struct ibmveth_adapter *adapter = netdev-priv; - union ibmveth_buf_desc desc[IbmVethMaxSendFrags]; + union ibmveth_buf_desc desc; unsigned long lpar_rc; - int nfrags = 0, curfrag; unsigned long correlator; unsigned long flags; unsigned int retry_count; @@ -844,25 +839,11 @@ static int ibmveth_start_xmit(struct sk_ unsigned int tx_send_failed = 0; unsigned int tx_map_failed = 0; - - if ((skb_shinfo(skb)-nr_frags + 1) IbmVethMaxSendFrags) { - tx_dropped++; - goto out; - } - - memset(desc, 0, sizeof(desc)); - - /* nfrags = number of frags after the initial fragment */ - nfrags = skb_shinfo(skb)-nr_frags; - - if(nfrags) - adapter-tx_multidesc_send++; - - /* map the initial fragment */ - desc[0].fields.length = nfrags ? skb-len - skb-data_len : skb-len; - desc[0].fields.address = dma_map_single(adapter-vdev-dev, skb-data, - desc[0].fields.length, DMA_TO_DEVICE); - desc[0].fields.valid = 1; + desc.desc = 0; + desc.fields.length = skb-len; + desc.fields.address = dma_map_single(adapter-vdev-dev, skb-data, +desc.fields.length, DMA_TO_DEVICE); + desc.fields.valid = 1; if (skb-ip_summed == CHECKSUM_PARTIAL ip_hdr(skb)-protocol != IPPROTO_TCP skb_checksum_help(skb)) { @@ -874,75 +855,34 @@ static int ibmveth_start_xmit(struct sk_ if (skb-ip_summed == CHECKSUM_PARTIAL) { unsigned char *buf = skb_transport_header(skb) + skb-csum_offset; - desc[0].fields.no_csum = 1; - desc[0].fields.csum_good = 1; + desc.fields.no_csum = 1; + desc.fields.csum_good = 1; /* Need to zero out the checksum */ buf[0] = 0; buf[1] = 0; } - if(dma_mapping_error(desc[0].fields.address)) { - ibmveth_error_printk(tx: unable to map initial fragment\n); + if (dma_mapping_error(desc.fields.address)) { + ibmveth_error_printk(tx: unable to map xmit buffer\n); tx_map_failed++; tx_dropped++; goto out; } - curfrag = nfrags; - - /* map fragments past the initial portion if there are any */ - while(curfrag--) { - skb_frag_t *frag = skb_shinfo(skb)-frags[curfrag]; - desc[curfrag+1].fields.address - = dma_map_single(adapter-vdev-dev, - page_address(frag-page) + frag-page_offset, - frag-size, DMA_TO_DEVICE); - desc[curfrag+1].fields.length = frag-size; - desc[curfrag+1].fields.valid = 1; - if (skb-ip_summed == CHECKSUM_PARTIAL) { - desc[curfrag+1].fields.no_csum = 1; - desc[curfrag+1].fields.csum_good = 1; - } - - if(dma_mapping_error(desc[curfrag+1].fields.address)) { - ibmveth_error_printk(tx: unable to map fragment %d\n, curfrag
[PATCH 6/6] ibmveth: Remove use of bitfields
Removes the use of bitfields from the ibmveth driver. This results in slightly smaller object code. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 90 linux-2.6-bjking1/drivers/net/ibmveth.h | 56 --- 2 files changed, 68 insertions(+), 78 deletions(-) diff -puN drivers/net/ibmveth.h~ibmveth_nobitfields drivers/net/ibmveth.h --- linux-2.6/drivers/net/ibmveth.h~ibmveth_nobitfields 2007-08-09 15:15:27.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.h 2007-08-09 15:15:27.0 -0500 @@ -39,6 +39,12 @@ #define IbmVethMcastRemoveFilter 0x2UL #define IbmVethMcastClearFilterTable 0x3UL +#define IBMVETH_ILLAN_PADDED_PKT_CSUM 0x2000ULL +#define IBMVETH_ILLAN_TRUNK_PRI_MASK 0x0F00ULL +#define IBMVETH_ILLAN_IPV6_TCP_CSUM0x0004ULL +#define IBMVETH_ILLAN_IPV4_TCP_CSUM0x0002ULL +#define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0001ULL + /* hcall macros */ #define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac) @@ -150,13 +156,13 @@ struct ibmveth_adapter { }; struct ibmveth_buf_desc_fields { -u32 valid : 1; -u32 toggle : 1; -u32 reserved : 4; -u32 no_csum : 1; -u32 csum_good : 1; -u32 length : 24; -u32 address; + u32 flags_len; +#define IBMVETH_BUF_VALID 0x8000 +#define IBMVETH_BUF_TOGGLE 0x4000 +#define IBMVETH_BUF_NO_CSUM0x0200 +#define IBMVETH_BUF_CSUM_GOOD 0x0100 +#define IBMVETH_BUF_LEN_MASK 0x00FF + u32 address; }; union ibmveth_buf_desc { @@ -164,33 +170,17 @@ union ibmveth_buf_desc { struct ibmveth_buf_desc_fields fields; }; -struct ibmveth_illan_attributes_fields { - u32 reserved; - u32 reserved2 : 18; - u32 csum_offload_padded_pkt_support : 1; - u32 reserved3 : 1; - u32 trunk_priority : 4; - u32 reserved4 : 5; - u32 tcp_csum_offload_ipv6 : 1; - u32 tcp_csum_offload_ipv4 : 1; - u32 active_trunk : 1; -}; - -union ibmveth_illan_attributes { - u64 desc; - struct ibmveth_illan_attributes_fields fields; -}; - struct ibmveth_rx_q_entry { -u16 toggle : 1; -u16 valid : 1; -u16 reserved : 4; -u16 no_csum : 1; -u16 csum_good : 1; -u16 reserved2 : 8; -u16 offset; -u32 length; -u64 correlator; + u32 flags_off; +#define IBMVETH_RXQ_TOGGLE 0x8000 +#define IBMVETH_RXQ_TOGGLE_SHIFT 31 +#define IBMVETH_RXQ_VALID 0x4000 +#define IBMVETH_RXQ_NO_CSUM0x0200 +#define IBMVETH_RXQ_CSUM_GOOD 0x0100 +#define IBMVETH_RXQ_OFF_MASK 0x + + u32 length; + u64 correlator; }; #endif /* _IBMVETH_H */ diff -puN drivers/net/ibmveth.c~ibmveth_nobitfields drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_nobitfields 2007-08-09 15:15:27.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-09 15:15:27.0 -0500 @@ -131,19 +131,29 @@ struct ibmveth_stat ibmveth_stats[] = { }; /* simple methods of getting data from the current rxq entry */ +static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter) +{ + return adapter-rx_queue.queue_addr[adapter-rx_queue.index].flags_off; +} + +static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter) +{ + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_TOGGLE) IBMVETH_RXQ_TOGGLE_SHIFT; +} + static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].toggle == adapter-rx_queue.toggle); + return (ibmveth_rxq_toggle(adapter) == adapter-rx_queue.toggle); } static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].valid); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_VALID); } static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].offset); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_OFF_MASK); } static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) @@ -153,7 +163,7 @@ static inline int ibmveth_rxq_frame_leng static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].csum_good); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_CSUM_GOOD); } /* setup the initial settings for a buffer pool */ @@ -253,9 +263,7 @@ static void ibmveth_replenish_buffer_poo correlator = ((u64)pool-index 32) | index; *(u64*)skb-data = correlator; - desc.desc = 0; - desc.fields.valid = 1
[PATCH 2/6] ibmveth: Implement ethtool hooks to enable/disable checksum offload
This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 125 +++- linux-2.6-bjking1/drivers/net/ibmveth.h |1 2 files changed, 124 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-08-09 15:15:07.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-09 15:15:07.0 -0500 @@ -641,12 +641,132 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) + adapter-rx_csum = 1; + else { + /* +* Since the ibmveth firmware interface does not have the concept of +* separate tx/rx checksum offload enable, if rx checksum is disabled +* we also have to disable tx checksum offload. Once we disable rx +* checksum offload, we are no longer allowed to send tx buffers that +* are not properly checksummed. +*/ + adapter-rx_csum = 0; + dev-features = ~NETIF_F_IP_CSUM; + } +} + +static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) { + dev-features |= NETIF_F_IP_CSUM; + adapter-rx_csum = 1; + } else + dev-features = ~NETIF_F_IP_CSUM; +} + +static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, + void (*done) (struct net_device *, u32)) +{ + struct ibmveth_adapter *adapter = dev-priv; + union ibmveth_illan_attributes set_attr, clr_attr, ret_attr; + long ret; + int rc1 = 0, rc2 = 0; + int restart = 0; + + if (netif_running(dev)) { + restart = 1; + adapter-pool_config = 1; + ibmveth_close(dev); + adapter-pool_config = 0; + } + + set_attr.desc = 0; + clr_attr.desc = 0; + + if (data) + set_attr.fields.tcp_csum_offload_ipv4 = 1; + else + clr_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(adapter-vdev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + ret = h_illan_attributes(adapter-vdev-unit_address, clr_attr.desc, +set_attr.desc, ret_attr.desc); + + if (ret != H_SUCCESS) { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld\n, data, ret); + + ret = h_illan_attributes(adapter-vdev-unit_address, +set_attr.desc, clr_attr.desc, ret_attr.desc); + } else + done(dev, data); + } else { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld ret_attr=%lx\n, data, ret, ret_attr.desc); + } + + if (restart) + rc2 = ibmveth_open(dev); + + return rc1 ? rc1 : rc2; +} + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if ((data adapter-rx_csum) || (!data !adapter-rx_csum)) + return 0; + + return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); +} + +static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + int rc = 0; + + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; + + if (data !adapter-rx_csum) + rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); + else + ibmveth_set_tx_csum_flags(dev, data); + + return rc; +} + +static u32 ibmveth_get_rx_csum(struct net_device *dev) +{ + struct ibmveth_adapter *adapter = dev-priv; + return adapter-rx_csum; +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, .get_link = netdev_get_link, .get_sg = ethtool_op_get_sg, .get_tx_csum
[PATCH 6/6] ibmveth: Remove use of bitfields
Removes the use of bitfields from the ibmveth driver. This results in slightly smaller object code. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 90 linux-2.6-bjking1/drivers/net/ibmveth.h | 56 --- 2 files changed, 68 insertions(+), 78 deletions(-) diff -puN drivers/net/ibmveth.h~ibmveth_nobitfields drivers/net/ibmveth.h --- linux-2.6/drivers/net/ibmveth.h~ibmveth_nobitfields 2007-08-09 15:15:27.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.h 2007-08-09 15:15:27.0 -0500 @@ -39,6 +39,12 @@ #define IbmVethMcastRemoveFilter 0x2UL #define IbmVethMcastClearFilterTable 0x3UL +#define IBMVETH_ILLAN_PADDED_PKT_CSUM 0x2000ULL +#define IBMVETH_ILLAN_TRUNK_PRI_MASK 0x0F00ULL +#define IBMVETH_ILLAN_IPV6_TCP_CSUM0x0004ULL +#define IBMVETH_ILLAN_IPV4_TCP_CSUM0x0002ULL +#define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0001ULL + /* hcall macros */ #define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac) @@ -150,13 +156,13 @@ struct ibmveth_adapter { }; struct ibmveth_buf_desc_fields { -u32 valid : 1; -u32 toggle : 1; -u32 reserved : 4; -u32 no_csum : 1; -u32 csum_good : 1; -u32 length : 24; -u32 address; + u32 flags_len; +#define IBMVETH_BUF_VALID 0x8000 +#define IBMVETH_BUF_TOGGLE 0x4000 +#define IBMVETH_BUF_NO_CSUM0x0200 +#define IBMVETH_BUF_CSUM_GOOD 0x0100 +#define IBMVETH_BUF_LEN_MASK 0x00FF + u32 address; }; union ibmveth_buf_desc { @@ -164,33 +170,17 @@ union ibmveth_buf_desc { struct ibmveth_buf_desc_fields fields; }; -struct ibmveth_illan_attributes_fields { - u32 reserved; - u32 reserved2 : 18; - u32 csum_offload_padded_pkt_support : 1; - u32 reserved3 : 1; - u32 trunk_priority : 4; - u32 reserved4 : 5; - u32 tcp_csum_offload_ipv6 : 1; - u32 tcp_csum_offload_ipv4 : 1; - u32 active_trunk : 1; -}; - -union ibmveth_illan_attributes { - u64 desc; - struct ibmveth_illan_attributes_fields fields; -}; - struct ibmveth_rx_q_entry { -u16 toggle : 1; -u16 valid : 1; -u16 reserved : 4; -u16 no_csum : 1; -u16 csum_good : 1; -u16 reserved2 : 8; -u16 offset; -u32 length; -u64 correlator; + u32 flags_off; +#define IBMVETH_RXQ_TOGGLE 0x8000 +#define IBMVETH_RXQ_TOGGLE_SHIFT 31 +#define IBMVETH_RXQ_VALID 0x4000 +#define IBMVETH_RXQ_NO_CSUM0x0200 +#define IBMVETH_RXQ_CSUM_GOOD 0x0100 +#define IBMVETH_RXQ_OFF_MASK 0x + + u32 length; + u64 correlator; }; #endif /* _IBMVETH_H */ diff -puN drivers/net/ibmveth.c~ibmveth_nobitfields drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_nobitfields 2007-08-09 15:15:27.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-09 15:15:27.0 -0500 @@ -131,19 +131,29 @@ struct ibmveth_stat ibmveth_stats[] = { }; /* simple methods of getting data from the current rxq entry */ +static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter) +{ + return adapter-rx_queue.queue_addr[adapter-rx_queue.index].flags_off; +} + +static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter) +{ + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_TOGGLE) IBMVETH_RXQ_TOGGLE_SHIFT; +} + static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].toggle == adapter-rx_queue.toggle); + return (ibmveth_rxq_toggle(adapter) == adapter-rx_queue.toggle); } static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].valid); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_VALID); } static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].offset); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_OFF_MASK); } static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) @@ -153,7 +163,7 @@ static inline int ibmveth_rxq_frame_leng static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].csum_good); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_CSUM_GOOD); } /* setup the initial settings for a buffer pool */ @@ -253,9 +263,7 @@ static void ibmveth_replenish_buffer_poo correlator = ((u64)pool-index 32) | index; *(u64*)skb-data = correlator; - desc.desc = 0; - desc.fields.valid = 1
[PATCH 3/6] ibmveth: Add ethtool TSO handlers
Add handlers for get_tso and get_ufo to prevent errors being printed by ethtool. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c |2 ++ 1 file changed, 2 insertions(+) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_get_tso drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_get_tso 2007-08-08 10:46:28.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-08 10:46:28.0 -0500 @@ -767,6 +767,8 @@ static const struct ethtool_ops netdev_e .set_tx_csum= ibmveth_set_tx_csum, .get_rx_csum= ibmveth_get_rx_csum, .set_rx_csum= ibmveth_set_rx_csum, + .get_tso= ethtool_op_get_tso, + .get_ufo= ethtool_op_get_ufo, }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/6] ibmveth: Implement ethtool hooks to enable/disable checksum offload
This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 125 +++- linux-2.6-bjking1/drivers/net/ibmveth.h |1 2 files changed, 124 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-08-09 15:15:07.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-09 15:15:07.0 -0500 @@ -641,12 +641,132 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) + adapter-rx_csum = 1; + else { + /* +* Since the ibmveth firmware interface does not have the concept of +* separate tx/rx checksum offload enable, if rx checksum is disabled +* we also have to disable tx checksum offload. Once we disable rx +* checksum offload, we are no longer allowed to send tx buffers that +* are not properly checksummed. +*/ + adapter-rx_csum = 0; + dev-features = ~NETIF_F_IP_CSUM; + } +} + +static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) { + dev-features |= NETIF_F_IP_CSUM; + adapter-rx_csum = 1; + } else + dev-features = ~NETIF_F_IP_CSUM; +} + +static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, + void (*done) (struct net_device *, u32)) +{ + struct ibmveth_adapter *adapter = dev-priv; + union ibmveth_illan_attributes set_attr, clr_attr, ret_attr; + long ret; + int rc1 = 0, rc2 = 0; + int restart = 0; + + if (netif_running(dev)) { + restart = 1; + adapter-pool_config = 1; + ibmveth_close(dev); + adapter-pool_config = 0; + } + + set_attr.desc = 0; + clr_attr.desc = 0; + + if (data) + set_attr.fields.tcp_csum_offload_ipv4 = 1; + else + clr_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(adapter-vdev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + ret = h_illan_attributes(adapter-vdev-unit_address, clr_attr.desc, +set_attr.desc, ret_attr.desc); + + if (ret != H_SUCCESS) { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld\n, data, ret); + + ret = h_illan_attributes(adapter-vdev-unit_address, +set_attr.desc, clr_attr.desc, ret_attr.desc); + } else + done(dev, data); + } else { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld ret_attr=%lx\n, data, ret, ret_attr.desc); + } + + if (restart) + rc2 = ibmveth_open(dev); + + return rc1 ? rc1 : rc2; +} + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if ((data adapter-rx_csum) || (!data !adapter-rx_csum)) + return 0; + + return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); +} + +static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + int rc = 0; + + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; + + if (data !adapter-rx_csum) + rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); + else + ibmveth_set_tx_csum_flags(dev, data); + + return rc; +} + +static u32 ibmveth_get_rx_csum(struct net_device *dev) +{ + struct ibmveth_adapter *adapter = dev-priv; + return adapter-rx_csum; +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, .get_link = netdev_get_link, .get_sg = ethtool_op_get_sg, .get_tx_csum
[PATCH 5/6] ibmveth: Remove dead frag processing code
Removes dead frag processing code from ibmveth. Since NETIF_F_SG was not set, this code was never executed. Also, since the ibmveth interface can only handle 6 fragments, core networking code would need to be modified in order to efficiently enable this support. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 100 +--- linux-2.6-bjking1/drivers/net/ibmveth.h |5 - 2 files changed, 17 insertions(+), 88 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_remove_frag drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_remove_frag 2007-08-09 15:15:18.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-09 15:15:18.0 -0500 @@ -28,7 +28,6 @@ /**/ /* TODO: - - remove frag processing code - no longer needed - add support for sysfs - possibly remove procfs support */ @@ -127,9 +126,6 @@ struct ibmveth_stat ibmveth_stats[] = { { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, - { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, - { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, - { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) }, }; @@ -832,9 +828,8 @@ static int ibmveth_ioctl(struct net_devi static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) { struct ibmveth_adapter *adapter = netdev-priv; - union ibmveth_buf_desc desc[IbmVethMaxSendFrags]; + union ibmveth_buf_desc desc; unsigned long lpar_rc; - int nfrags = 0, curfrag; unsigned long correlator; unsigned long flags; unsigned int retry_count; @@ -844,25 +839,11 @@ static int ibmveth_start_xmit(struct sk_ unsigned int tx_send_failed = 0; unsigned int tx_map_failed = 0; - - if ((skb_shinfo(skb)-nr_frags + 1) IbmVethMaxSendFrags) { - tx_dropped++; - goto out; - } - - memset(desc, 0, sizeof(desc)); - - /* nfrags = number of frags after the initial fragment */ - nfrags = skb_shinfo(skb)-nr_frags; - - if(nfrags) - adapter-tx_multidesc_send++; - - /* map the initial fragment */ - desc[0].fields.length = nfrags ? skb-len - skb-data_len : skb-len; - desc[0].fields.address = dma_map_single(adapter-vdev-dev, skb-data, - desc[0].fields.length, DMA_TO_DEVICE); - desc[0].fields.valid = 1; + desc.desc = 0; + desc.fields.length = skb-len; + desc.fields.address = dma_map_single(adapter-vdev-dev, skb-data, +desc.fields.length, DMA_TO_DEVICE); + desc.fields.valid = 1; if (skb-ip_summed == CHECKSUM_PARTIAL ip_hdr(skb)-protocol != IPPROTO_TCP skb_checksum_help(skb)) { @@ -874,75 +855,34 @@ static int ibmveth_start_xmit(struct sk_ if (skb-ip_summed == CHECKSUM_PARTIAL) { unsigned char *buf = skb_transport_header(skb) + skb-csum_offset; - desc[0].fields.no_csum = 1; - desc[0].fields.csum_good = 1; + desc.fields.no_csum = 1; + desc.fields.csum_good = 1; /* Need to zero out the checksum */ buf[0] = 0; buf[1] = 0; } - if(dma_mapping_error(desc[0].fields.address)) { - ibmveth_error_printk(tx: unable to map initial fragment\n); + if (dma_mapping_error(desc.fields.address)) { + ibmveth_error_printk(tx: unable to map xmit buffer\n); tx_map_failed++; tx_dropped++; goto out; } - curfrag = nfrags; - - /* map fragments past the initial portion if there are any */ - while(curfrag--) { - skb_frag_t *frag = skb_shinfo(skb)-frags[curfrag]; - desc[curfrag+1].fields.address - = dma_map_single(adapter-vdev-dev, - page_address(frag-page) + frag-page_offset, - frag-size, DMA_TO_DEVICE); - desc[curfrag+1].fields.length = frag-size; - desc[curfrag+1].fields.valid = 1; - if (skb-ip_summed == CHECKSUM_PARTIAL) { - desc[curfrag+1].fields.no_csum = 1; - desc[curfrag+1].fields.csum_good = 1; - } - - if(dma_mapping_error(desc[curfrag+1].fields.address)) { - ibmveth_error_printk(tx: unable to map fragment %d\n, curfrag
[PATCH 4/6] ibmveth: Add ethtool driver stats hooks
Add ethtool hooks to ibmveth to retrieve driver statistics. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 51 1 file changed, 51 insertions(+) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats 2007-08-08 10:46:30.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-08 10:48:08.0 -0500 @@ -112,6 +112,28 @@ MODULE_DESCRIPTION(IBM i/pSeries Virtua MODULE_LICENSE(GPL); MODULE_VERSION(ibmveth_driver_version); +struct ibmveth_stat { + char name[ETH_GSTRING_LEN]; + int offset; +}; + +#define IBMVETH_STAT_OFF(stat) offsetof(struct ibmveth_adapter, stat) +#define IBMVETH_GET_STAT(a, off) *((u64 *)(((unsigned long)(a)) + off)) + +struct ibmveth_stat ibmveth_stats[] = { + { replenish_task_cycles, IBMVETH_STAT_OFF(replenish_task_cycles) }, + { replenish_no_mem, IBMVETH_STAT_OFF(replenish_no_mem) }, + { replenish_add_buff_failure, IBMVETH_STAT_OFF(replenish_add_buff_failure) }, + { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, + { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, + { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, + { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, + { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, + { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, + { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, + { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) }, +}; + /* simple methods of getting data from the current rxq entry */ static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { @@ -758,6 +780,32 @@ static u32 ibmveth_get_rx_csum(struct ne return adapter-rx_csum; } +static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + + if (stringset != ETH_SS_STATS) + return; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++, data += ETH_GSTRING_LEN) + memcpy(data, ibmveth_stats[i].name, ETH_GSTRING_LEN); +} + +static int ibmveth_get_stats_count(struct net_device *dev) +{ + return ARRAY_SIZE(ibmveth_stats); +} + +static void ibmveth_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) +{ + int i; + struct ibmveth_adapter *adapter = dev-priv; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++) + data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, @@ -769,6 +817,9 @@ static const struct ethtool_ops netdev_e .set_rx_csum= ibmveth_set_rx_csum, .get_tso= ethtool_op_get_tso, .get_ufo= ethtool_op_get_ufo, + .get_strings= ibmveth_get_strings, + .get_stats_count= ibmveth_get_stats_count, + .get_ethtool_stats = ibmveth_get_ethtool_stats, }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) diff -puN drivers/net/ibmveth.h~ibmveth_ethtool_driver_stats drivers/net/ibmveth.h _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] drivers/net/ibmveth.c: memset fix
Mariusz Kozlowski wrote: Looks like memset() is zeroing wrong nr of bytes. Good catch, however, I think we can just remove this memset altogether since the memory gets allocated via kzalloc. Correct, that memset() is superfluous. Ok. Then this should do it. Acked-by: Brian King [EMAIL PROTECTED] Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED] drivers/net/ibmveth.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- linux-2.6.23-rc1-mm2-a/drivers/net/ibmveth.c 2007-08-01 08:43:46.0 +0200 +++ linux-2.6.23-rc1-mm2-b/drivers/net/ibmveth.c 2007-08-06 23:32:13.0 +0200 @@ -963,7 +963,7 @@ static int __devinit ibmveth_probe(struc { int rc, i; struct net_device *netdev; - struct ibmveth_adapter *adapter = NULL; + struct ibmveth_adapter *adapter; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; @@ -997,7 +997,6 @@ static int __devinit ibmveth_probe(struc SET_MODULE_OWNER(netdev); adapter = netdev-priv; - memset(adapter, 0, sizeof(adapter)); dev-dev.driver_data = netdev; adapter-vdev = dev; - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html -- Brian King Linux on Power Virtualization IBM Linux Technology Center - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/6] ibmveth: Implement ethtool hooks to enable/disable checksum offload
Jeff Garzik wrote: Brian King wrote: This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 118 +++- linux-2.6-bjking1/drivers/net/ibmveth.h |1 2 files changed, 117 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-08-01 14:55:14.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-01 14:55:14.0 -0500 @@ -641,12 +641,125 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ +struct ibmveth_adapter *adapter = dev-priv; + +if (data) +adapter-rx_csum = 1; +else { +adapter-rx_csum = 0; +dev-features = ~NETIF_F_IP_CSUM; why does this RX-related code clear a TX-related flag? Its related to how the pSeries firmware works. The firmware provides an interface to enable checksum offload, which means both tx and rx checksum offload from the firmware's point of view. The firmware does not support enabling checksum offload for only rx. If I disable it for rx I have to disable it for tx as well, otherwise the firmware will reject all future tx buffers I throw at it that are not checksummed. -Brian -- Brian King Linux on Power Virtualization IBM Linux Technology Center - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/6] ibmveth: Enable TCP checksum offload
This patchset enables TCP checksum offload support for IPV4 on ibmveth. This completely eliminates the generation and checking of the checksum for packets that are completely virtual and never touch a physical network. A simple TCP_STREAM netperf run on a virtual network with maximum mtu set yielded a ~30% increase in throughput. This feature is enabled by default on systems that support it, but can be disabled with a module option. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 53 linux-2.6-bjking1/drivers/net/ibmveth.h | 41 +++- 2 files changed, 92 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload2007-08-01 14:55:11.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-01 14:55:11.0 -0500 @@ -47,6 +47,8 @@ #include linux/mm.h #include linux/ethtool.h #include linux/proc_fs.h +#include linux/in.h +#include linux/ip.h #include asm/semaphore.h #include asm/hvcall.h #include asm/atomic.h @@ -131,6 +133,11 @@ static inline int ibmveth_rxq_frame_leng return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].length); } +static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) +{ + return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].csum_good); +} + /* setup the initial settings for a buffer pool */ static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) { @@ -684,6 +691,24 @@ static int ibmveth_start_xmit(struct sk_ desc[0].fields.length, DMA_TO_DEVICE); desc[0].fields.valid = 1; + if (skb-ip_summed == CHECKSUM_PARTIAL + ip_hdr(skb)-protocol != IPPROTO_TCP skb_checksum_help(skb)) { + ibmveth_error_printk(tx: failed to checksum packet\n); + tx_dropped++; + goto out; + } + + if (skb-ip_summed == CHECKSUM_PARTIAL) { + unsigned char *buf = skb_transport_header(skb) + skb-csum_offset; + + desc[0].fields.no_csum = 1; + desc[0].fields.csum_good = 1; + + /* Need to zero out the checksum */ + buf[0] = 0; + buf[1] = 0; + } + if(dma_mapping_error(desc[0].fields.address)) { ibmveth_error_printk(tx: unable to map initial fragment\n); tx_map_failed++; @@ -702,6 +727,10 @@ static int ibmveth_start_xmit(struct sk_ frag-size, DMA_TO_DEVICE); desc[curfrag+1].fields.length = frag-size; desc[curfrag+1].fields.valid = 1; + if (skb-ip_summed == CHECKSUM_PARTIAL) { + desc[curfrag+1].fields.no_csum = 1; + desc[curfrag+1].fields.csum_good = 1; + } if(dma_mapping_error(desc[curfrag+1].fields.address)) { ibmveth_error_printk(tx: unable to map fragment %d\n, curfrag); @@ -792,7 +821,11 @@ static int ibmveth_poll(struct net_devic } else { int length = ibmveth_rxq_frame_length(adapter); int offset = ibmveth_rxq_frame_offset(adapter); + int csum_good = ibmveth_rxq_csum_good(adapter); + skb = ibmveth_rxq_get_buffer(adapter); + if (csum_good) + skb-ip_summed = CHECKSUM_UNNECESSARY; ibmveth_rxq_harvest_buffer(adapter); @@ -962,8 +995,10 @@ static void ibmveth_poll_controller(stru static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) { int rc, i; + long ret; struct net_device *netdev; struct ibmveth_adapter *adapter = NULL; + union ibmveth_illan_attributes set_attr, ret_attr; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; @@ -1058,6 +1093,24 @@ static int __devinit ibmveth_probe(struc ibmveth_debug_printk(registering netdev...\n); + ret = h_illan_attributes(dev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + set_attr.desc = 0; + set_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(dev-unit_address, 0, set_attr.desc, +ret_attr.desc); + + if (ret == H_SUCCESS) + netdev-features |= NETIF_F_IP_CSUM; + else + ret = h_illan_attributes(dev
[PATCH 2/6] ibmveth: Implement ethtool hooks to enable/disable checksum offload
This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 118 +++- linux-2.6-bjking1/drivers/net/ibmveth.h |1 2 files changed, 117 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-08-01 14:55:14.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-01 14:55:14.0 -0500 @@ -641,12 +641,125 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) + adapter-rx_csum = 1; + else { + adapter-rx_csum = 0; + dev-features = ~NETIF_F_IP_CSUM; + } +} + +static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) { + dev-features |= NETIF_F_IP_CSUM; + adapter-rx_csum = 1; + } else + dev-features = ~NETIF_F_IP_CSUM; +} + +static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, + void (*done) (struct net_device *, u32)) +{ + struct ibmveth_adapter *adapter = dev-priv; + union ibmveth_illan_attributes set_attr, clr_attr, ret_attr; + long ret; + int rc1 = 0, rc2 = 0; + int restart = 0; + + if (netif_running(dev)) { + restart = 1; + adapter-pool_config = 1; + ibmveth_close(dev); + adapter-pool_config = 0; + } + + set_attr.desc = 0; + clr_attr.desc = 0; + + if (data) + set_attr.fields.tcp_csum_offload_ipv4 = 1; + else + clr_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(adapter-vdev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + ret = h_illan_attributes(adapter-vdev-unit_address, clr_attr.desc, +set_attr.desc, ret_attr.desc); + + if (ret != H_SUCCESS) { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld\n, data, ret); + + ret = h_illan_attributes(adapter-vdev-unit_address, +set_attr.desc, clr_attr.desc, ret_attr.desc); + } else + done(dev, data); + } else { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld ret_attr=%lx\n, data, ret, ret_attr.desc); + } + + if (restart) + rc2 = ibmveth_open(dev); + + return rc1 ? rc1 : rc2; +} + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if ((data adapter-rx_csum) || (!data !adapter-rx_csum)) + return 0; + + return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); +} + +static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + int rc = 0; + + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; + + if (data !adapter-rx_csum) + rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); + else + ibmveth_set_tx_csum_flags(dev, data); + + return rc; +} + +static u32 ibmveth_get_rx_csum(struct net_device *dev) +{ + struct ibmveth_adapter *adapter = dev-priv; + return adapter-rx_csum; +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, .get_link = netdev_get_link, .get_sg = ethtool_op_get_sg, .get_tx_csum= ethtool_op_get_tx_csum, + .set_tx_csum= ibmveth_set_tx_csum, + .get_rx_csum= ibmveth_get_rx_csum, + .set_rx_csum= ibmveth_set_rx_csum }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) @@ -1104,9 +1217,10 @@ static int __devinit ibmveth_probe(struc ret = h_illan_attributes(dev-unit_address, 0, set_attr.desc
[PATCH 3/6] ibmveth: Add ethtool TSO handlers
Add handlers for get_tso and get_ufo to prevent errors being printed by ethtool. Signed-off-by: Brian King [EMAIL PROTECTED] --- drivers/net/ibmveth.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_get_tso drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_get_tso 2007-07-19 11:18:38.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 11:18:38.0 -0500 @@ -759,7 +759,9 @@ static const struct ethtool_ops netdev_e .get_tx_csum= ethtool_op_get_tx_csum, .set_tx_csum= ibmveth_set_tx_csum, .get_rx_csum= ibmveth_get_rx_csum, - .set_rx_csum= ibmveth_set_rx_csum + .set_rx_csum= ibmveth_set_rx_csum, + .get_tso= ethtool_op_get_tso, + .get_ufo= ethtool_op_get_ufo }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/6] ibmveth: Add ethtool driver stats hooks
Add ethtool hooks to ibmveth to retrieve driver statistics. Signed-off-by: Brian King [EMAIL PROTECTED] --- drivers/net/ibmveth.c | 53 +- 1 file changed, 52 insertions(+), 1 deletion(-) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats 2007-07-19 11:18:41.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 11:18:41.0 -0500 @@ -112,6 +112,28 @@ MODULE_DESCRIPTION(IBM i/pSeries Virtua MODULE_LICENSE(GPL); MODULE_VERSION(ibmveth_driver_version); +struct ibmveth_stat { + char name[ETH_GSTRING_LEN]; + int offset; +}; + +#define IBMVETH_STAT_OFF(stat) offsetof(struct ibmveth_adapter, stat) +#define IBMVETH_GET_STAT(a, off) *((u64 *)(((unsigned long)(a)) + off)) + +struct ibmveth_stat ibmveth_stats[] = { + { replenish_task_cycles, IBMVETH_STAT_OFF(replenish_task_cycles) }, + { replenish_no_mem, IBMVETH_STAT_OFF(replenish_no_mem) }, + { replenish_add_buff_failure, IBMVETH_STAT_OFF(replenish_add_buff_failure) }, + { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, + { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, + { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, + { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, + { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, + { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, + { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, + { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) } +}; + /* simple methods of getting data from the current rxq entry */ static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { @@ -751,6 +773,32 @@ static u32 ibmveth_get_rx_csum(struct ne return adapter-rx_csum; } +static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + + if (stringset != ETH_SS_STATS) + return; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++, data += ETH_GSTRING_LEN) + memcpy(data, ibmveth_stats[i].name, ETH_GSTRING_LEN); +} + +static int ibmveth_get_stats_count(struct net_device *dev) +{ + return ARRAY_SIZE(ibmveth_stats); +} + +static void ibmveth_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) +{ + int i; + struct ibmveth_adapter *adapter = dev-priv; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++) + data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, @@ -761,7 +809,10 @@ static const struct ethtool_ops netdev_e .get_rx_csum= ibmveth_get_rx_csum, .set_rx_csum= ibmveth_set_rx_csum, .get_tso= ethtool_op_get_tso, - .get_ufo= ethtool_op_get_ufo + .get_ufo= ethtool_op_get_ufo, + .get_strings= ibmveth_get_strings, + .get_stats_count= ibmveth_get_stats_count, + .get_ethtool_stats = ibmveth_get_ethtool_stats }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) diff -puN drivers/net/ibmveth.h~ibmveth_ethtool_driver_stats drivers/net/ibmveth.h _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] ibmveth: Remove dead frag processing code
Removes dead frag processing code from ibmveth. Since NETIF_F_SG was not set, this code was never executed. Also, since the ibmveth interface can only handle 6 fragments, core networking code would need to be modified in order to efficiently enable this support. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 100 +--- linux-2.6-bjking1/drivers/net/ibmveth.h |5 - 2 files changed, 17 insertions(+), 88 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_remove_frag drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_remove_frag 2007-08-06 14:11:08.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-06 14:11:39.0 -0500 @@ -28,7 +28,6 @@ /**/ /* TODO: - - remove frag processing code - no longer needed - add support for sysfs - possibly remove procfs support */ @@ -127,9 +126,6 @@ struct ibmveth_stat ibmveth_stats[] = { { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, - { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, - { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, - { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) } }; @@ -825,9 +821,8 @@ static int ibmveth_ioctl(struct net_devi static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) { struct ibmveth_adapter *adapter = netdev-priv; - union ibmveth_buf_desc desc[IbmVethMaxSendFrags]; + union ibmveth_buf_desc desc; unsigned long lpar_rc; - int nfrags = 0, curfrag; unsigned long correlator; unsigned long flags; unsigned int retry_count; @@ -837,25 +832,11 @@ static int ibmveth_start_xmit(struct sk_ unsigned int tx_send_failed = 0; unsigned int tx_map_failed = 0; - - if ((skb_shinfo(skb)-nr_frags + 1) IbmVethMaxSendFrags) { - tx_dropped++; - goto out; - } - - memset(desc, 0, sizeof(desc)); - - /* nfrags = number of frags after the initial fragment */ - nfrags = skb_shinfo(skb)-nr_frags; - - if(nfrags) - adapter-tx_multidesc_send++; - - /* map the initial fragment */ - desc[0].fields.length = nfrags ? skb-len - skb-data_len : skb-len; - desc[0].fields.address = dma_map_single(adapter-vdev-dev, skb-data, - desc[0].fields.length, DMA_TO_DEVICE); - desc[0].fields.valid = 1; + desc.desc = 0; + desc.fields.length = skb-len; + desc.fields.address = dma_map_single(adapter-vdev-dev, skb-data, +desc.fields.length, DMA_TO_DEVICE); + desc.fields.valid = 1; if (skb-ip_summed == CHECKSUM_PARTIAL ip_hdr(skb)-protocol != IPPROTO_TCP skb_checksum_help(skb)) { @@ -867,75 +848,34 @@ static int ibmveth_start_xmit(struct sk_ if (skb-ip_summed == CHECKSUM_PARTIAL) { unsigned char *buf = skb_transport_header(skb) + skb-csum_offset; - desc[0].fields.no_csum = 1; - desc[0].fields.csum_good = 1; + desc.fields.no_csum = 1; + desc.fields.csum_good = 1; /* Need to zero out the checksum */ buf[0] = 0; buf[1] = 0; } - if(dma_mapping_error(desc[0].fields.address)) { - ibmveth_error_printk(tx: unable to map initial fragment\n); + if (dma_mapping_error(desc.fields.address)) { + ibmveth_error_printk(tx: unable to map xmit buffer\n); tx_map_failed++; tx_dropped++; goto out; } - curfrag = nfrags; - - /* map fragments past the initial portion if there are any */ - while(curfrag--) { - skb_frag_t *frag = skb_shinfo(skb)-frags[curfrag]; - desc[curfrag+1].fields.address - = dma_map_single(adapter-vdev-dev, - page_address(frag-page) + frag-page_offset, - frag-size, DMA_TO_DEVICE); - desc[curfrag+1].fields.length = frag-size; - desc[curfrag+1].fields.valid = 1; - if (skb-ip_summed == CHECKSUM_PARTIAL) { - desc[curfrag+1].fields.no_csum = 1; - desc[curfrag+1].fields.csum_good = 1; - } - - if(dma_mapping_error(desc[curfrag+1].fields.address)) { - ibmveth_error_printk(tx: unable to map fragment %d\n, curfrag
[PATCH 6/6] ibmveth: Remove use of bitfields
Removes the use of bitfields from the ibmveth driver. This results in slightly smaller object code. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 90 linux-2.6-bjking1/drivers/net/ibmveth.h | 56 --- 2 files changed, 68 insertions(+), 78 deletions(-) diff -puN drivers/net/ibmveth.h~ibmveth_nobitfields drivers/net/ibmveth.h --- linux-2.6/drivers/net/ibmveth.h~ibmveth_nobitfields 2007-08-06 14:11:11.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.h 2007-08-06 14:11:11.0 -0500 @@ -39,6 +39,12 @@ #define IbmVethMcastRemoveFilter 0x2UL #define IbmVethMcastClearFilterTable 0x3UL +#define IBMVETH_ILLAN_PADDED_PKT_CSUM 0x2000ULL +#define IBMVETH_ILLAN_TRUNK_PRI_MASK 0x0F00ULL +#define IBMVETH_ILLAN_IPV6_TCP_CSUM0x0004ULL +#define IBMVETH_ILLAN_IPV4_TCP_CSUM0x0002ULL +#define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0001ULL + /* hcall macros */ #define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac) @@ -150,13 +156,13 @@ struct ibmveth_adapter { }; struct ibmveth_buf_desc_fields { -u32 valid : 1; -u32 toggle : 1; -u32 reserved : 4; -u32 no_csum : 1; -u32 csum_good : 1; -u32 length : 24; -u32 address; + u32 flags_len; +#define IBMVETH_BUF_VALID 0x8000 +#define IBMVETH_BUF_TOGGLE 0x4000 +#define IBMVETH_BUF_NO_CSUM0x0200 +#define IBMVETH_BUF_CSUM_GOOD 0x0100 +#define IBMVETH_BUF_LEN_MASK 0x00FF + u32 address; }; union ibmveth_buf_desc { @@ -164,33 +170,17 @@ union ibmveth_buf_desc { struct ibmveth_buf_desc_fields fields; }; -struct ibmveth_illan_attributes_fields { - u32 reserved; - u32 reserved2 : 18; - u32 csum_offload_padded_pkt_support : 1; - u32 reserved3 : 1; - u32 trunk_priority : 4; - u32 reserved4 : 5; - u32 tcp_csum_offload_ipv6 : 1; - u32 tcp_csum_offload_ipv4 : 1; - u32 active_trunk : 1; -}; - -union ibmveth_illan_attributes { - u64 desc; - struct ibmveth_illan_attributes_fields fields; -}; - struct ibmveth_rx_q_entry { -u16 toggle : 1; -u16 valid : 1; -u16 reserved : 4; -u16 no_csum : 1; -u16 csum_good : 1; -u16 reserved2 : 8; -u16 offset; -u32 length; -u64 correlator; + u32 flags_off; +#define IBMVETH_RXQ_TOGGLE 0x8000 +#define IBMVETH_RXQ_TOGGLE_SHIFT 31 +#define IBMVETH_RXQ_VALID 0x4000 +#define IBMVETH_RXQ_NO_CSUM0x0200 +#define IBMVETH_RXQ_CSUM_GOOD 0x0100 +#define IBMVETH_RXQ_OFF_MASK 0x + + u32 length; + u64 correlator; }; #endif /* _IBMVETH_H */ diff -puN drivers/net/ibmveth.c~ibmveth_nobitfields drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_nobitfields 2007-08-06 14:11:11.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-06 14:11:11.0 -0500 @@ -131,19 +131,29 @@ struct ibmveth_stat ibmveth_stats[] = { }; /* simple methods of getting data from the current rxq entry */ +static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter) +{ + return adapter-rx_queue.queue_addr[adapter-rx_queue.index].flags_off; +} + +static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter) +{ + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_TOGGLE) IBMVETH_RXQ_TOGGLE_SHIFT; +} + static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].toggle == adapter-rx_queue.toggle); + return (ibmveth_rxq_toggle(adapter) == adapter-rx_queue.toggle); } static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].valid); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_VALID); } static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].offset); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_OFF_MASK); } static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) @@ -153,7 +163,7 @@ static inline int ibmveth_rxq_frame_leng static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) { - return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].csum_good); + return (ibmveth_rxq_flags(adapter) IBMVETH_RXQ_CSUM_GOOD); } /* setup the initial settings for a buffer pool */ @@ -253,9 +263,7 @@ static void ibmveth_replenish_buffer_poo correlator = ((u64)pool-index 32) | index; *(u64*)skb-data = correlator; - desc.desc = 0; - desc.fields.valid = 1
Re: [PATCH] drivers/net/ibmveth.c: memset fix
Mariusz Kozlowski wrote: Hello, Looks like memset() is zeroing wrong nr of bytes. Good catch, however, I think we can just remove this memset altogether since the memory gets allocated via kzalloc. -Brian Signed-off-by: Mariusz Kozlowski [EMAIL PROTECTED] drivers/net/ibmveth.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- linux-2.6.23-rc1-mm2-a/drivers/net/ibmveth.c 2007-08-01 08:43:46.0 +0200 +++ linux-2.6.23-rc1-mm2-b/drivers/net/ibmveth.c 2007-08-06 20:34:44.0 +0200 @@ -963,7 +963,7 @@ static int __devinit ibmveth_probe(struc { int rc, i; struct net_device *netdev; - struct ibmveth_adapter *adapter = NULL; + struct ibmveth_adapter *adapter; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; @@ -997,7 +997,7 @@ static int __devinit ibmveth_probe(struc SET_MODULE_OWNER(netdev); adapter = netdev-priv; - memset(adapter, 0, sizeof(adapter)); + memset(adapter, 0, sizeof(*adapter)); dev-dev.driver_data = netdev; adapter-vdev = dev; - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html -- Brian King Linux on Power Virtualization IBM Linux Technology Center - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/1] ibmveth: Fix rx pool deactivate oops
This fixes the following oops which can occur when trying to deallocate receive buffer pools using sysfs with the ibmveth driver. NIP: d024f954 LR: d024fa58 CTR: c00d7478 REGS: cffef9f0 TRAP: 0300 Not tainted (2.6.22-ppc64) MSR: 80009032 EE,ME,IR,DR CR: 24242442 XER: 0010 DAR: 07f0, DSISR: 4200 TASK = c2f91360[2967] 'bash' THREAD: c0001398c000 CPU: 2 GPR00: cffefc70 d0262d30 c0001c4087a0 GPR04: 000300fe 000f c0579d80 GPR08: 00365688 c0001c408998 07f0 GPR12: d0251e88 c0579d80 200957ec GPR16: 100b8808 100feb30 10084828 GPR20: 1014d4d0 0010 cffefeb0 GPR24: c0001c408000 c0001c408000 b054 GPR28: 00fe 0003 d0262700 c0001c4087a0 NIP [d024f954] .ibmveth_remove_buffer_from_pool+0x38/0x108 [ibmveth] LR [d024fa58] .ibmveth_rxq_harvest_buffer+0x34/0x78 [ibmveth] Call Trace: [cffefc70] [c00280a8] .dma_iommu_unmap_single+0x14/0x28 (unreliable) [cffefd00] [d024fa58] .ibmveth_rxq_harvest_buffer+0x34/0x78 [ibmveth] [cffefd80] [d0250e40] .ibmveth_poll+0xd8/0x434 [ibmveth] [cffefe40] [c032da8c] .net_rx_action+0xdc/0x248 [cffefef0] [c0068b4c] .__do_softirq+0xa8/0x164 [cffeff90] [c002789c] .call_do_softirq+0x14/0x24 [c0001398f6f0] [c000c04c] .do_softirq+0x68/0xac [c0001398f780] [c0068ca0] .irq_exit+0x54/0x6c [c0001398f800] [c000c8e4] .do_IRQ+0x170/0x1ac [c0001398f890] [c0004790] hardware_interrupt_entry+0x18/0x1c Exception: 501 at .plpar_hcall_norets+0x24/0x94 LR = .veth_pool_store+0x15c/0x298 [ibmveth] [c0001398fb80] [d0250b2c] .veth_pool_store+0x5c/0x298 [ibmveth] (unreliable) [c0001398fc30] [c0145530] .sysfs_write_file+0x140/0x1d8 [c0001398fcf0] [c00de89c] .vfs_write+0x120/0x208 [c0001398fd90] [c00df2c8] .sys_write+0x4c/0x8c [c0001398fe30] [c00086ac] syscall_exit+0x0/0x40 Instruction dump: fba1ffe8 fbe1fff8 789d0022 f8010010 f821ff71 789c0020 1d3d00a8 7b8a1f24 3800 7c7f1b78 7d291a14 e9690128 7c0a592a e803 e9690120 80a90100 Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 24 ++-- linux-2.6-bjking1/drivers/net/ibmveth.h |3 --- 2 files changed, 14 insertions(+), 13 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_fixup_pool_deactivate drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_fixup_pool_deactivate 2007-08-01 10:22:37.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-08-01 10:23:20.0 -0500 @@ -1280,24 +1280,28 @@ const char * buf, size_t count) int i; /* Make sure there is a buffer pool with buffers that can hold a packet of the size of the MTU */ - for(i = 0; iIbmVethNumBufferPools; i++) { + for (i = 0; i IbmVethNumBufferPools; i++) { if (pool == adapter-rx_buff_pool[i]) continue; if (!adapter-rx_buff_pool[i].active) continue; - if (mtu adapter-rx_buff_pool[i].buff_size) { - pool-active = 0; - h_free_logical_lan_buffer(adapter- - vdev- - unit_address, - pool- - buff_size); - } + if (mtu = adapter-rx_buff_pool[i].buff_size) + break; } - if (pool-active) { + + if (i == IbmVethNumBufferPools) { ibmveth_error_printk(no active pool = MTU\n); return -EPERM; } + + pool-active = 0; + if (netif_running(netdev)) { + adapter-pool_config = 1; + ibmveth_close(netdev); + adapter-pool_config = 0; + if ((rc = ibmveth_open(netdev))) + return rc
Re: [PATCH 1/4] ibmveth: Enable TCP checksum offload
Jeff Garzik wrote: Brian King wrote: This patchset enables TCP checksum offload support for IPV4 on ibmveth. This completely eliminates the generation and checking of the checksum for packets that are completely virtual and never touch a physical network. A simple TCP_STREAM netperf run on a virtual network with maximum mtu set yielded a ~30% increase in throughput. This feature is enabled by default on systems that support it, but can be disabled with a module option. Signed-off-by: Brian King [EMAIL PROTECTED] this should be controllable purely via ethtool... I'll remove the module parameter and resend. struct ibmveth_rx_q_entry { u16 toggle : 1; u16 valid : 1; -u16 reserved : 14; +u16 reserved : 4; +u16 no_csum : 1; +u16 csum_good : 1; +u16 reserved2 : 8; u16 offset; As a general rule, it would be nice to start moving away from bitfields in this driver I'll take a look at that for a future cleanup patch. Thanks, Brian -- Brian King Linux on Power Virtualization IBM Linux Technology Center - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] ibmveth: Enable TCP checksum offload
This patchset enables TCP checksum offload support for IPV4 on ibmveth. This completely eliminates the generation and checking of the checksum for packets that are completely virtual and never touch a physical network. A simple TCP_STREAM netperf run on a virtual network with maximum mtu set yielded a ~30% increase in throughput. This feature is enabled by default on systems that support it, but can be disabled with a module option. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 53 linux-2.6-bjking1/drivers/net/ibmveth.h | 41 +++- 2 files changed, 92 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload2007-07-18 16:55:06.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 08:36:05.0 -0500 @@ -47,6 +47,8 @@ #include linux/mm.h #include linux/ethtool.h #include linux/proc_fs.h +#include linux/in.h +#include linux/ip.h #include asm/semaphore.h #include asm/hvcall.h #include asm/atomic.h @@ -131,6 +133,11 @@ static inline int ibmveth_rxq_frame_leng return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].length); } +static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) +{ + return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].csum_good); +} + /* setup the initial settings for a buffer pool */ static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) { @@ -684,6 +691,24 @@ static int ibmveth_start_xmit(struct sk_ desc[0].fields.length, DMA_TO_DEVICE); desc[0].fields.valid = 1; + if (skb-ip_summed == CHECKSUM_PARTIAL + ip_hdr(skb)-protocol != IPPROTO_TCP skb_checksum_help(skb)) { + ibmveth_error_printk(tx: failed to checksum packet\n); + tx_dropped++; + goto out; + } + + if (skb-ip_summed == CHECKSUM_PARTIAL) { + unsigned char *buf = skb_transport_header(skb) + skb-csum_offset; + + desc[0].fields.no_csum = 1; + desc[0].fields.csum_good = 1; + + /* Need to zero out the checksum */ + buf[0] = 0; + buf[1] = 0; + } + if(dma_mapping_error(desc[0].fields.address)) { ibmveth_error_printk(tx: unable to map initial fragment\n); tx_map_failed++; @@ -702,6 +727,10 @@ static int ibmveth_start_xmit(struct sk_ frag-size, DMA_TO_DEVICE); desc[curfrag+1].fields.length = frag-size; desc[curfrag+1].fields.valid = 1; + if (skb-ip_summed == CHECKSUM_PARTIAL) { + desc[curfrag+1].fields.no_csum = 1; + desc[curfrag+1].fields.csum_good = 1; + } if(dma_mapping_error(desc[curfrag+1].fields.address)) { ibmveth_error_printk(tx: unable to map fragment %d\n, curfrag); @@ -792,7 +821,11 @@ static int ibmveth_poll(struct net_devic } else { int length = ibmveth_rxq_frame_length(adapter); int offset = ibmveth_rxq_frame_offset(adapter); + int csum_good = ibmveth_rxq_csum_good(adapter); + skb = ibmveth_rxq_get_buffer(adapter); + if (csum_good) + skb-ip_summed = CHECKSUM_UNNECESSARY; ibmveth_rxq_harvest_buffer(adapter); @@ -962,8 +995,10 @@ static void ibmveth_poll_controller(stru static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) { int rc, i; + long ret; struct net_device *netdev; struct ibmveth_adapter *adapter = NULL; + union ibmveth_illan_attributes set_attr, ret_attr; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; @@ -1058,6 +1093,24 @@ static int __devinit ibmveth_probe(struc ibmveth_debug_printk(registering netdev...\n); + ret = h_illan_attributes(dev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + set_attr.desc = 0; + set_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(dev-unit_address, 0, set_attr.desc, +ret_attr.desc); + + if (ret == H_SUCCESS) + netdev-features |= NETIF_F_IP_CSUM; + else + ret = h_illan_attributes(dev
[PATCH 2/4] ibmveth: Implement ethtool hooks to enable/disable checksum offload
This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 120 +++- linux-2.6-bjking1/drivers/net/ibmveth.h |1 2 files changed, 119 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-07-19 08:38:27.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 08:39:08.0 -0500 @@ -641,12 +641,127 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) + adapter-rx_csum = 1; + else { + adapter-rx_csum = 0; + dev-features = ~NETIF_F_IP_CSUM; + } +} + +static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) { + dev-features |= NETIF_F_IP_CSUM; + adapter-rx_csum = 1; + } else + dev-features = ~NETIF_F_IP_CSUM; +} + +static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, + void (*done) (struct net_device *, u32)) +{ + struct ibmveth_adapter *adapter = dev-priv; + union ibmveth_illan_attributes set_attr, clr_attr, ret_attr; + long ret; + int rc1 = 0, rc2 = 0; + int restart = 0; + + if (netif_running(dev)) { + restart = 1; + adapter-pool_config = 1; + ibmveth_close(dev); + adapter-pool_config = 0; + } + + set_attr.desc = 0; + clr_attr.desc = 0; + + if (data) + set_attr.fields.tcp_csum_offload_ipv4 = 1; + else + clr_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(adapter-vdev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + ret = h_illan_attributes(adapter-vdev-unit_address, clr_attr.desc, +set_attr.desc, ret_attr.desc); + + if (ret != H_SUCCESS) { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld\n, data, ret); + + ret = h_illan_attributes(adapter-vdev-unit_address, +set_attr.desc, clr_attr.desc, ret_attr.desc); + } else + done(dev, data); + } else { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld ret_attr=%lx\n, data, ret, ret_attr.desc); + } + + if (restart) + rc2 = ibmveth_open(dev); + + return rc1 ? rc1 : rc2; +} + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data adapter-rx_csum) + return 0; + if (!data !adapter-rx_csum) + return 0; + + return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); +} + +static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + int rc = 0; + + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; + + if (data !adapter-rx_csum) + rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); + else + ibmveth_set_tx_csum_flags(dev, data); + + return rc; +} + +static u32 ibmveth_get_rx_csum(struct net_device *dev) +{ + struct ibmveth_adapter *adapter = dev-priv; + return adapter-rx_csum; +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, .get_link = netdev_get_link, .get_sg = ethtool_op_get_sg, .get_tx_csum= ethtool_op_get_tx_csum, + .set_tx_csum= ibmveth_set_tx_csum, + .get_rx_csum= ibmveth_get_rx_csum, + .set_rx_csum= ibmveth_set_rx_csum }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) @@ -1104,9 +1219,10 @@ static int __devinit ibmveth_probe(struc ret = h_illan_attributes(dev-unit_address, 0
[PATCH 4/4] ibmveth: Add ethtool driver stats hooks
Add ethtool hooks to ibmveth to retrieve driver statistics. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 53 +++- 1 file changed, 52 insertions(+), 1 deletion(-) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats 2007-07-19 08:39:35.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 08:39:35.0 -0500 @@ -112,6 +112,28 @@ MODULE_DESCRIPTION(IBM i/pSeries Virtua MODULE_LICENSE(GPL); MODULE_VERSION(ibmveth_driver_version); +struct ibmveth_stat { + char name[ETH_GSTRING_LEN]; + int offset; +}; + +#define IBMVETH_STAT_OFF(stat) offsetof(struct ibmveth_adapter, stat) +#define IBMVETH_GET_STAT(a, off) *((u64 *)(((unsigned long)(a)) + off)) + +struct ibmveth_stat ibmveth_stats[] = { + { replenish_task_cycles, IBMVETH_STAT_OFF(replenish_task_cycles) }, + { replenish_no_mem, IBMVETH_STAT_OFF(replenish_no_mem) }, + { replenish_add_buff_failure, IBMVETH_STAT_OFF(replenish_add_buff_failure) }, + { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, + { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, + { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, + { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, + { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, + { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, + { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, + { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) } +}; + /* simple methods of getting data from the current rxq entry */ static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { @@ -753,6 +775,32 @@ static u32 ibmveth_get_rx_csum(struct ne return adapter-rx_csum; } +static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + + if (stringset != ETH_SS_STATS) + return; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++, data += ETH_GSTRING_LEN) + memcpy(data, ibmveth_stats[i].name, ETH_GSTRING_LEN); +} + +static int ibmveth_get_stats_count(struct net_device *dev) +{ + return ARRAY_SIZE(ibmveth_stats); +} + +static void ibmveth_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) +{ + int i; + struct ibmveth_adapter *adapter = dev-priv; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++) + data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, @@ -763,7 +811,10 @@ static const struct ethtool_ops netdev_e .get_rx_csum= ibmveth_get_rx_csum, .set_rx_csum= ibmveth_set_rx_csum, .get_tso= ethtool_op_get_tso, - .get_ufo= ethtool_op_get_ufo + .get_ufo= ethtool_op_get_ufo, + .get_strings= ibmveth_get_strings, + .get_stats_count= ibmveth_get_stats_count, + .get_ethtool_stats = ibmveth_get_ethtool_stats }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) diff -puN drivers/net/ibmveth.h~ibmveth_ethtool_driver_stats drivers/net/ibmveth.h _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/4] ibmveth: Add ethtool TSO handlers
Add handlers for get_tso and get_ufo to prevent errors being printed by ethtool. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_get_tso drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_get_tso 2007-07-19 08:39:31.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 08:39:31.0 -0500 @@ -761,7 +761,9 @@ static const struct ethtool_ops netdev_e .get_tx_csum= ethtool_op_get_tx_csum, .set_tx_csum= ibmveth_set_tx_csum, .get_rx_csum= ibmveth_get_rx_csum, - .set_rx_csum= ibmveth_set_rx_csum + .set_rx_csum= ibmveth_set_rx_csum, + .get_tso= ethtool_op_get_tso, + .get_ufo= ethtool_op_get_ufo }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] ibmveth: Implement ethtool hooks to enable/disable checksum offload
Ragner Magalhaes wrote: ext Brian King wrote: + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ +struct ibmveth_adapter *adapter = dev-priv; + Why do not to do if ((data adapter-rx_csum) || (!data !adapter-rx_csum)) return 0; less two lines. Ok. here also, as above ... +if (data (dev-features NETIF_F_IP_CSUM)) +return 0; +if (!data !(dev-features NETIF_F_IP_CSUM)) +return 0; This change would make the line 80 columns, which I prefer to avoid. Updated patch attached which addresses the first comment. Thanks, Brian --- This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- drivers/net/ibmveth.c | 118 +- drivers/net/ibmveth.h |1 2 files changed, 117 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-07-19 11:15:01.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-19 11:17:16.0 -0500 @@ -641,12 +641,125 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) + adapter-rx_csum = 1; + else { + adapter-rx_csum = 0; + dev-features = ~NETIF_F_IP_CSUM; + } +} + +static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) { + dev-features |= NETIF_F_IP_CSUM; + adapter-rx_csum = 1; + } else + dev-features = ~NETIF_F_IP_CSUM; +} + +static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, + void (*done) (struct net_device *, u32)) +{ + struct ibmveth_adapter *adapter = dev-priv; + union ibmveth_illan_attributes set_attr, clr_attr, ret_attr; + long ret; + int rc1 = 0, rc2 = 0; + int restart = 0; + + if (netif_running(dev)) { + restart = 1; + adapter-pool_config = 1; + ibmveth_close(dev); + adapter-pool_config = 0; + } + + set_attr.desc = 0; + clr_attr.desc = 0; + + if (data) + set_attr.fields.tcp_csum_offload_ipv4 = 1; + else + clr_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(adapter-vdev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + ret = h_illan_attributes(adapter-vdev-unit_address, clr_attr.desc, +set_attr.desc, ret_attr.desc); + + if (ret != H_SUCCESS) { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld\n, data, ret); + + ret = h_illan_attributes(adapter-vdev-unit_address, +set_attr.desc, clr_attr.desc, ret_attr.desc); + } else + done(dev, data); + } else { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld ret_attr=%lx\n, data, ret, ret_attr.desc); + } + + if (restart) + rc2 = ibmveth_open(dev); + + return rc1 ? rc1 : rc2; +} + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if ((data adapter-rx_csum) || (!data !adapter-rx_csum)) + return 0; + + return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); +} + +static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + int rc = 0; + + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; + + if (data !adapter-rx_csum) + rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); + else + ibmveth_set_tx_csum_flags(dev, data); + + return rc; +} + +static u32 ibmveth_get_rx_csum(struct net_device *dev) +{ + struct ibmveth_adapter *adapter = dev-priv; + return adapter-rx_csum; +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo
Re: [PATCH 2/4] ibmveth: Implement ethtool hooks to enable/disable checksum offload
Ragner Magalhaes wrote: ext Brian King wrote: Ragner Magalhaes wrote: here also, as above ... + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; This change would make the line 80 columns, which I prefer to avoid. Updated patch attached which addresses the first comment. I think would not be ugly to make. if ((data (dev-features NETIF_F_IP_CSUM)) || (!data !(dev-features NETIF_F_IP_CSUM))) return 0; I find that less readable than what I currently have. -Brian -- Brian King Linux on Power Virtualization IBM Linux Technology Center - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] ibmveth: Enable TCP checksum offload
This patchset enables TCP checksum offload support for IPV4 on ibmveth. This completely eliminates the generation and checking of the checksum for packets that are completely virtual and never touch a physical network. A simple TCP_STREAM netperf run on a virtual network with maximum mtu set yielded a ~30% increase in throughput. This feature is enabled by default on systems that support it, but can be disabled with a module option. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 58 linux-2.6-bjking1/drivers/net/ibmveth.h | 41 +- 2 files changed, 97 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload2007-07-12 08:27:47.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-12 09:35:55.0 -0500 @@ -47,6 +47,8 @@ #include linux/mm.h #include linux/ethtool.h #include linux/proc_fs.h +#include linux/in.h +#include linux/ip.h #include asm/semaphore.h #include asm/hvcall.h #include asm/atomic.h @@ -103,12 +105,15 @@ static struct proc_dir_entry *ibmveth_pr static const char ibmveth_driver_name[] = ibmveth; static const char ibmveth_driver_string[] = IBM i/pSeries Virtual Ethernet Driver; +static unsigned int ibmveth_csum_offload = 1; #define ibmveth_driver_version 1.03 MODULE_AUTHOR(Santiago Leon [EMAIL PROTECTED]); MODULE_DESCRIPTION(IBM i/pSeries Virtual Ethernet Driver); MODULE_LICENSE(GPL); MODULE_VERSION(ibmveth_driver_version); +module_param_named(csum_offload, ibmveth_csum_offload, uint, 0); +MODULE_PARM_DESC(csum_offload, Checksum offload (0/1). Default: 1); /* simple methods of getting data from the current rxq entry */ static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) @@ -131,6 +136,11 @@ static inline int ibmveth_rxq_frame_leng return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].length); } +static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter) +{ + return (adapter-rx_queue.queue_addr[adapter-rx_queue.index].csum_good); +} + /* setup the initial settings for a buffer pool */ static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active) { @@ -684,6 +694,24 @@ static int ibmveth_start_xmit(struct sk_ desc[0].fields.length, DMA_TO_DEVICE); desc[0].fields.valid = 1; + if (skb-ip_summed == CHECKSUM_PARTIAL + ip_hdr(skb)-protocol != IPPROTO_TCP skb_checksum_help(skb)) { + ibmveth_error_printk(tx: failed to checksum packet\n); + tx_dropped++; + goto out; + } + + if (skb-ip_summed == CHECKSUM_PARTIAL) { + unsigned char *buf = skb_transport_header(skb) + skb-csum_offset; + + desc[0].fields.no_csum = 1; + desc[0].fields.csum_good = 1; + + /* Need to zero out the checksum */ + buf[0] = 0; + buf[1] = 0; + } + if(dma_mapping_error(desc[0].fields.address)) { ibmveth_error_printk(tx: unable to map initial fragment\n); tx_map_failed++; @@ -702,6 +730,10 @@ static int ibmveth_start_xmit(struct sk_ frag-size, DMA_TO_DEVICE); desc[curfrag+1].fields.length = frag-size; desc[curfrag+1].fields.valid = 1; + if (skb-ip_summed == CHECKSUM_PARTIAL) { + desc[curfrag+1].fields.no_csum = 1; + desc[curfrag+1].fields.csum_good = 1; + } if(dma_mapping_error(desc[curfrag+1].fields.address)) { ibmveth_error_printk(tx: unable to map fragment %d\n, curfrag); @@ -792,7 +824,11 @@ static int ibmveth_poll(struct net_devic } else { int length = ibmveth_rxq_frame_length(adapter); int offset = ibmveth_rxq_frame_offset(adapter); + int csum_good = ibmveth_rxq_csum_good(adapter); + skb = ibmveth_rxq_get_buffer(adapter); + if (csum_good) + skb-ip_summed = CHECKSUM_UNNECESSARY; ibmveth_rxq_harvest_buffer(adapter); @@ -962,8 +998,10 @@ static void ibmveth_poll_controller(stru static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) { int rc, i; + long ret; struct net_device *netdev; struct ibmveth_adapter *adapter = NULL; + union ibmveth_illan_attributes set_attr, ret_attr; unsigned char *mac_addr_p; unsigned int *mcastFilterSize_p; @@ -1058,6 +1096,26 @@ static int __devinit
[PATCH 2/4] ibmveth: Implement ethtool hooks to enable/disable checksum offload
This patch adds the appropriate ethtool hooks to allow for enabling/disabling of hypervisor assisted checksum offload for TCP. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 120 +++- linux-2.6-bjking1/drivers/net/ibmveth.h |1 2 files changed, 119 insertions(+), 2 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_csum_offload_ethtool 2007-07-12 09:36:01.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-12 09:41:15.0 -0500 @@ -644,12 +644,127 @@ static u32 netdev_get_link(struct net_de return 1; } +static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) + adapter-rx_csum = 1; + else { + adapter-rx_csum = 0; + dev-features = ~NETIF_F_IP_CSUM; + } +} + +static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data) { + dev-features |= NETIF_F_IP_CSUM; + adapter-rx_csum = 1; + } else + dev-features = ~NETIF_F_IP_CSUM; +} + +static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, + void (*done) (struct net_device *, u32)) +{ + struct ibmveth_adapter *adapter = dev-priv; + union ibmveth_illan_attributes set_attr, clr_attr, ret_attr; + long ret; + int rc1 = 0, rc2 = 0; + int restart = 0; + + if (netif_running(dev)) { + restart = 1; + adapter-pool_config = 1; + ibmveth_close(dev); + adapter-pool_config = 0; + } + + set_attr.desc = 0; + clr_attr.desc = 0; + + if (data) + set_attr.fields.tcp_csum_offload_ipv4 = 1; + else + clr_attr.fields.tcp_csum_offload_ipv4 = 1; + + ret = h_illan_attributes(adapter-vdev-unit_address, 0, 0, ret_attr.desc); + + if (ret == H_SUCCESS !ret_attr.fields.active_trunk + !ret_attr.fields.trunk_priority + ret_attr.fields.csum_offload_padded_pkt_support) { + ret = h_illan_attributes(adapter-vdev-unit_address, clr_attr.desc, +set_attr.desc, ret_attr.desc); + + if (ret != H_SUCCESS) { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld\n, data, ret); + + ret = h_illan_attributes(adapter-vdev-unit_address, +set_attr.desc, clr_attr.desc, ret_attr.desc); + } else + done(dev, data); + } else { + rc1 = -EIO; + ibmveth_error_printk(unable to change checksum offload settings. + %d rc=%ld ret_attr=%lx\n, data, ret, ret_attr.desc); + } + + if (restart) + rc2 = ibmveth_open(dev); + + return rc1 ? rc1 : rc2; +} + +static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + + if (data adapter-rx_csum) + return 0; + if (!data !adapter-rx_csum) + return 0; + + return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); +} + +static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) +{ + struct ibmveth_adapter *adapter = dev-priv; + int rc = 0; + + if (data (dev-features NETIF_F_IP_CSUM)) + return 0; + if (!data !(dev-features NETIF_F_IP_CSUM)) + return 0; + + if (data !adapter-rx_csum) + rc = ibmveth_set_csum_offload(dev, data, ibmveth_set_tx_csum_flags); + else + ibmveth_set_tx_csum_flags(dev, data); + + return rc; +} + +static u32 ibmveth_get_rx_csum(struct net_device *dev) +{ + struct ibmveth_adapter *adapter = dev-priv; + return adapter-rx_csum; +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, .get_link = netdev_get_link, .get_sg = ethtool_op_get_sg, .get_tx_csum= ethtool_op_get_tx_csum, + .set_tx_csum= ibmveth_set_tx_csum, + .get_rx_csum= ibmveth_get_rx_csum, + .set_rx_csum= ibmveth_set_rx_csum }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) @@ -1108,9 +1223,10 @@ static int __devinit ibmveth_probe(struc ret = h_illan_attributes(dev
[PATCH 3/4] ibmveth: Add ethtool TSO handlers
Add handlers for get_tso and get_ufo to prevent errors being printed by ethtool. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_get_tso drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_get_tso 2007-07-12 09:39:20.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-12 09:39:20.0 -0500 @@ -764,7 +764,9 @@ static const struct ethtool_ops netdev_e .get_tx_csum= ethtool_op_get_tx_csum, .set_tx_csum= ibmveth_set_tx_csum, .get_rx_csum= ibmveth_get_rx_csum, - .set_rx_csum= ibmveth_set_rx_csum + .set_rx_csum= ibmveth_set_rx_csum, + .get_tso= ethtool_op_get_tso, + .get_ufo= ethtool_op_get_ufo }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/4] ibmveth: Add ethtool driver stats hooks
Add ethtool hooks to ibmveth to retrieve driver statistics. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 53 +++- 1 file changed, 52 insertions(+), 1 deletion(-) diff -puN drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_ethtool_driver_stats 2007-07-12 09:39:23.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-07-12 09:39:23.0 -0500 @@ -115,6 +115,28 @@ MODULE_VERSION(ibmveth_driver_version); module_param_named(csum_offload, ibmveth_csum_offload, uint, 0); MODULE_PARM_DESC(csum_offload, Checksum offload (0/1). Default: 1); +struct ibmveth_stat { + char name[ETH_GSTRING_LEN]; + int offset; +}; + +#define IBMVETH_STAT_OFF(stat) offsetof(struct ibmveth_adapter, stat) +#define IBMVETH_GET_STAT(a, off) *((u64 *)(((unsigned long)(a)) + off)) + +struct ibmveth_stat ibmveth_stats[] = { + { replenish_task_cycles, IBMVETH_STAT_OFF(replenish_task_cycles) }, + { replenish_no_mem, IBMVETH_STAT_OFF(replenish_no_mem) }, + { replenish_add_buff_failure, IBMVETH_STAT_OFF(replenish_add_buff_failure) }, + { replenish_add_buff_success, IBMVETH_STAT_OFF(replenish_add_buff_success) }, + { rx_invalid_buffer, IBMVETH_STAT_OFF(rx_invalid_buffer) }, + { rx_no_buffer, IBMVETH_STAT_OFF(rx_no_buffer) }, + { tx_multidesc_send, IBMVETH_STAT_OFF(tx_multidesc_send) }, + { tx_linearized, IBMVETH_STAT_OFF(tx_linearized) }, + { tx_linearize_failed, IBMVETH_STAT_OFF(tx_linearize_failed) }, + { tx_map_failed, IBMVETH_STAT_OFF(tx_map_failed) }, + { tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) } +}; + /* simple methods of getting data from the current rxq entry */ static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) { @@ -756,6 +778,32 @@ static u32 ibmveth_get_rx_csum(struct ne return adapter-rx_csum; } +static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + + if (stringset != ETH_SS_STATS) + return; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++, data += ETH_GSTRING_LEN) + memcpy(data, ibmveth_stats[i].name, ETH_GSTRING_LEN); +} + +static int ibmveth_get_stats_count(struct net_device *dev) +{ + return ARRAY_SIZE(ibmveth_stats); +} + +static void ibmveth_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) +{ + int i; + struct ibmveth_adapter *adapter = dev-priv; + + for (i = 0; i ARRAY_SIZE(ibmveth_stats); i++) + data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); +} + static const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo= netdev_get_drvinfo, .get_settings = netdev_get_settings, @@ -766,7 +814,10 @@ static const struct ethtool_ops netdev_e .get_rx_csum= ibmveth_get_rx_csum, .set_rx_csum= ibmveth_set_rx_csum, .get_tso= ethtool_op_get_tso, - .get_ufo= ethtool_op_get_ufo + .get_ufo= ethtool_op_get_ufo, + .get_strings= ibmveth_get_strings, + .get_stats_count= ibmveth_get_stats_count, + .get_ethtool_stats = ibmveth_get_ethtool_stats }; static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) diff -puN drivers/net/ibmveth.h~ibmveth_ethtool_driver_stats drivers/net/ibmveth.h _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] ibmveth: Fix h_free_logical_lan error on pool resize
When attempting to activate additional rx buffer pools on an ibmveth interface that was not yet up, the error below was seen. The patch fixes this by only closing and opening the interface to activate the resize if the interface is already opened. (drivers/net/ibmveth.c:597 ua:3004) ERROR: h_free_logical_lan failed with fffc, continuing with close Unable to handle kernel paging request for data at address 0x0ff8 Faulting instruction address: 0xd02540e0 Oops: Kernel access of bad area, sig: 11 [#1] SMP NR_CPUS=128 NUMA PSERIES LPAR Modules linked in: ip6t_REJECT xt_tcpudp ipt_REJECT xt_state iptable_mangle ipta ble_nat ip_nat iptable_filter ip6table_mangle ip_conntrack nfnetlink ip_tables i p6table_filter ip6_tables x_tables ipv6 apparmor aamatch_pcre loop dm_mod ibmvet h sg ibmvscsic sd_mod scsi_mod NIP: D02540E0 LR: D02540D4 CTR: 801AF404 REGS: c0001cd27870 TRAP: 0300 Not tainted (2.6.16.46-0.4-ppc64) MSR: 80009032 EE,ME,IR,DR CR: 24242422 XER: 0007 DAR: 0FF8, DSISR: 4000 TASK = c0001ca7b4e0[1636] 'sh' THREAD: c0001cd24000 CPU: 0 GPR00: D02540D4 C0001CD27AF0 D0265650 C0001C936500 GPR04: 80009032 0007 0002C2EF GPR08: C0652A10 C0652AE0 GPR12: 4000 C04A3300 100A GPR16: 100B8808 100C0F60 10084878 GPR20: 100C0CB0 100AF498 0002 GPR24: 100BA488 C0001C936760 D0258DD0 C0001C936000 GPR28: C0001C936500 D0265180 C0001C936000 NIP [D02540E0] .ibmveth_close+0xc8/0xf4 [ibmveth] LR [D02540D4] .ibmveth_close+0xbc/0xf4 [ibmveth] Call Trace: [C0001CD27AF0] [D02540D4] .ibmveth_close+0xbc/0xf4 [ibmveth] (unreliable) [C0001CD27B80] [D02545FC] .veth_pool_store+0xd0/0x260 [ibmveth] [C0001CD27C40] [C012E0E8] .sysfs_write_file+0x118/0x198 [C0001CD27CF0] [C00CDAF0] .vfs_write+0x130/0x218 [C0001CD27D90] [C00CE52C] .sys_write+0x4c/0x8c [C0001CD27E30] [C000871C] syscall_exit+0x0/0x40 Instruction dump: 419affd8 2fa3 419e0020 e93d e89e8040 38a00255 e87e81b0 80c90018 48001531 e8410028 e93d00e0 7fa3eb78 e8090ff8 f81d0430 4bfffdc9 38210090 Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 53 ++-- 1 file changed, 31 insertions(+), 22 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_large_frames drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_large_frames2007-05-14 15:03:06.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-05-15 09:18:46.0 -0500 @@ -1243,16 +1243,19 @@ const char * buf, size_t count) if (attr == veth_active_attr) { if (value !pool-active) { - if(ibmveth_alloc_buffer_pool(pool)) { -ibmveth_error_printk(unable to alloc pool\n); -return -ENOMEM; -} - pool-active = 1; - adapter-pool_config = 1; - ibmveth_close(netdev); - adapter-pool_config = 0; - if ((rc = ibmveth_open(netdev))) - return rc; + if (netif_running(netdev)) { + if(ibmveth_alloc_buffer_pool(pool)) { + ibmveth_error_printk(unable to alloc pool\n); + return -ENOMEM; + } + pool-active = 1; + adapter-pool_config = 1; + ibmveth_close(netdev); + adapter-pool_config = 0; + if ((rc = ibmveth_open(netdev))) + return rc; + } else + pool-active = 1; } else if (!value pool-active) { int mtu = netdev-mtu + IBMVETH_BUFF_OH; int i; @@ -1281,23 +1284,29 @@ const char * buf, size_t count) if (value = 0 || value IBMVETH_MAX_POOL_COUNT) return -EINVAL; else { - adapter-pool_config = 1; - ibmveth_close(netdev); - adapter-pool_config = 0; - pool-size = value; - if ((rc = ibmveth_open(netdev))) - return rc; + if (netif_running(netdev)) { + adapter-pool_config = 1
[PATCH 2/2] ibmveth: Automatically enable larger rx buffer pools for larger mtu
Currently, ibmveth maintains several rx buffer pools, which can be modified through sysfs. By default, pools are not allocated by default such that jumbo frames cannot be supported without first activating larger rx buffer pools. This results in failures when attempting to change the mtu. This patch makes ibmveth automatically allocate these larger buffer pools when the mtu is changed. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 27 +++ 1 file changed, 23 insertions(+), 4 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_large_mtu drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_large_mtu 2007-05-16 10:47:54.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-05-16 10:47:54.0 -0500 @@ -915,17 +915,36 @@ static int ibmveth_change_mtu(struct net { struct ibmveth_adapter *adapter = dev-priv; int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH; - int i; + int reinit = 0; + int i, rc; if (new_mtu IBMVETH_MAX_MTU) return -EINVAL; + for (i = 0; i IbmVethNumBufferPools; i++) + if (new_mtu_oh adapter-rx_buff_pool[i].buff_size) + break; + + if (i == IbmVethNumBufferPools) + return -EINVAL; + /* Look for an active buffer pool that can hold the new MTU */ for(i = 0; iIbmVethNumBufferPools; i++) { - if (!adapter-rx_buff_pool[i].active) - continue; + if (!adapter-rx_buff_pool[i].active) { + adapter-rx_buff_pool[i].active = 1; + reinit = 1; + } + if (new_mtu_oh adapter-rx_buff_pool[i].buff_size) { - dev-mtu = new_mtu; + if (reinit netif_running(adapter-netdev)) { + adapter-pool_config = 1; + ibmveth_close(adapter-netdev); + adapter-pool_config = 0; + dev-mtu = new_mtu; + if ((rc = ibmveth_open(adapter-netdev))) + return rc; + } else + dev-mtu = new_mtu; return 0; } } _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] ibmveth: Fix h_free_logical_lan error on pool resize
When attempting to activate additional rx buffer pools on an ibmveth interface that was not yet up, the error below was seen. The patch fixes this by only closing and opening the interface to activate the resize if the interface is already opened. (drivers/net/ibmveth.c:597 ua:3004) ERROR: h_free_logical_lan failed with fffc, continuing with close Unable to handle kernel paging request for data at address 0x0ff8 Faulting instruction address: 0xd02540e0 Oops: Kernel access of bad area, sig: 11 [#1] SMP NR_CPUS=128 NUMA PSERIES LPAR Modules linked in: ip6t_REJECT xt_tcpudp ipt_REJECT xt_state iptable_mangle ipta ble_nat ip_nat iptable_filter ip6table_mangle ip_conntrack nfnetlink ip_tables i p6table_filter ip6_tables x_tables ipv6 apparmor aamatch_pcre loop dm_mod ibmvet h sg ibmvscsic sd_mod scsi_mod NIP: D02540E0 LR: D02540D4 CTR: 801AF404 REGS: c0001cd27870 TRAP: 0300 Not tainted (2.6.16.46-0.4-ppc64) MSR: 80009032 EE,ME,IR,DR CR: 24242422 XER: 0007 DAR: 0FF8, DSISR: 4000 TASK = c0001ca7b4e0[1636] 'sh' THREAD: c0001cd24000 CPU: 0 GPR00: D02540D4 C0001CD27AF0 D0265650 C0001C936500 GPR04: 80009032 0007 0002C2EF GPR08: C0652A10 C0652AE0 GPR12: 4000 C04A3300 100A GPR16: 100B8808 100C0F60 10084878 GPR20: 100C0CB0 100AF498 0002 GPR24: 100BA488 C0001C936760 D0258DD0 C0001C936000 GPR28: C0001C936500 D0265180 C0001C936000 NIP [D02540E0] .ibmveth_close+0xc8/0xf4 [ibmveth] LR [D02540D4] .ibmveth_close+0xbc/0xf4 [ibmveth] Call Trace: [C0001CD27AF0] [D02540D4] .ibmveth_close+0xbc/0xf4 [ibmveth] (unreliable) [C0001CD27B80] [D02545FC] .veth_pool_store+0xd0/0x260 [ibmveth] [C0001CD27C40] [C012E0E8] .sysfs_write_file+0x118/0x198 [C0001CD27CF0] [C00CDAF0] .vfs_write+0x130/0x218 [C0001CD27D90] [C00CE52C] .sys_write+0x4c/0x8c [C0001CD27E30] [C000871C] syscall_exit+0x0/0x40 Instruction dump: 419affd8 2fa3 419e0020 e93d e89e8040 38a00255 e87e81b0 80c90018 48001531 e8410028 e93d00e0 7fa3eb78 e8090ff8 f81d0430 4bfffdc9 38210090 Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 53 ++-- 1 file changed, 31 insertions(+), 22 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_large_frames drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_large_frames2007-05-14 15:03:06.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-05-15 09:18:46.0 -0500 @@ -1243,16 +1243,19 @@ const char * buf, size_t count) if (attr == veth_active_attr) { if (value !pool-active) { - if(ibmveth_alloc_buffer_pool(pool)) { -ibmveth_error_printk(unable to alloc pool\n); -return -ENOMEM; -} - pool-active = 1; - adapter-pool_config = 1; - ibmveth_close(netdev); - adapter-pool_config = 0; - if ((rc = ibmveth_open(netdev))) - return rc; + if (netif_running(netdev)) { + if(ibmveth_alloc_buffer_pool(pool)) { + ibmveth_error_printk(unable to alloc pool\n); + return -ENOMEM; + } + pool-active = 1; + adapter-pool_config = 1; + ibmveth_close(netdev); + adapter-pool_config = 0; + if ((rc = ibmveth_open(netdev))) + return rc; + } else + pool-active = 1; } else if (!value pool-active) { int mtu = netdev-mtu + IBMVETH_BUFF_OH; int i; @@ -1281,23 +1284,29 @@ const char * buf, size_t count) if (value = 0 || value IBMVETH_MAX_POOL_COUNT) return -EINVAL; else { - adapter-pool_config = 1; - ibmveth_close(netdev); - adapter-pool_config = 0; - pool-size = value; - if ((rc = ibmveth_open(netdev))) - return rc; + if (netif_running(netdev)) { + adapter-pool_config = 1
[PATCH 2/2] ibmveth: Automatically enable larger rx buffer pools for larger mtu
Currently, ibmveth maintains several rx buffer pools, which can be modified through sysfs. By default, pools are not allocated by default such that jumbo frames cannot be supported without first activating larger rx buffer pools. This results in failures when attempting to change the mtu. This patch makes ibmveth automatically allocate these larger buffer pools when the mtu is changed. Signed-off-by: Brian King [EMAIL PROTECTED] --- linux-2.6-bjking1/drivers/net/ibmveth.c | 27 +++ 1 file changed, 23 insertions(+), 4 deletions(-) diff -puN drivers/net/ibmveth.c~ibmveth_large_mtu drivers/net/ibmveth.c --- linux-2.6/drivers/net/ibmveth.c~ibmveth_large_mtu 2007-05-16 10:47:54.0 -0500 +++ linux-2.6-bjking1/drivers/net/ibmveth.c 2007-05-16 10:47:54.0 -0500 @@ -915,17 +915,36 @@ static int ibmveth_change_mtu(struct net { struct ibmveth_adapter *adapter = dev-priv; int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH; - int i; + int reinit = 0; + int i, rc; if (new_mtu IBMVETH_MAX_MTU) return -EINVAL; + for (i = 0; i IbmVethNumBufferPools; i++) + if (new_mtu_oh adapter-rx_buff_pool[i].buff_size) + break; + + if (i == IbmVethNumBufferPools) + return -EINVAL; + /* Look for an active buffer pool that can hold the new MTU */ for(i = 0; iIbmVethNumBufferPools; i++) { - if (!adapter-rx_buff_pool[i].active) - continue; + if (!adapter-rx_buff_pool[i].active) { + adapter-rx_buff_pool[i].active = 1; + reinit = 1; + } + if (new_mtu_oh adapter-rx_buff_pool[i].buff_size) { - dev-mtu = new_mtu; + if (reinit netif_running(adapter-netdev)) { + adapter-pool_config = 1; + ibmveth_close(adapter-netdev); + adapter-pool_config = 0; + dev-mtu = new_mtu; + if ((rc = ibmveth_open(adapter-netdev))) + return rc; + } else + dev-mtu = new_mtu; return 0; } } _ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html