Re: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread Eric Dumazet
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote:
> Support scatter gather and TSO.

>  
> - netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
> - netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
> + netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
> + NETIF_F_TSO;
> + netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
> +   NETIF_F_TSO;
>  

Minor nit :

If you use skb_copy_bits(), then you also can add NETIF_F_FRAGLIST here.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread Eric Dumazet
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote:

> +static u32 r8152_xmit_frags(struct r8152 *tp, struct sk_buff *skb, u8 *data)
> +{
> + struct skb_shared_info *info = skb_shinfo(skb);
> + unsigned int cur_frag;
> + u32 total = skb_headlen(skb);
> +
> + memcpy(data, skb->data, total);
> + data += total;
> +
> + for (cur_frag = 0; cur_frag < info->nr_frags; cur_frag++) {
> + const skb_frag_t *frag = info->frags + cur_frag;
> + void *addr;
> + u32 len;
> +
> + len = skb_frag_size(frag);
> + addr = skb_frag_address(frag);
> + memcpy(data, addr, len);
> + data += len;
> + total += len;
>   }
> +
> + return total;
>  }
>  

I would rather use skb_copy_bits(), because it correctly handles
kmap() case. (If a frag resides in high memory)



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread David Laight
From: Eric Dumazet 
> On Tue, 2014-03-04 at 14:35 +, David Laight wrote:
> 
> > Does that mean you are splitting the 64k 'ethernet packet' from TCP
> > is software? I've looked at the ax88179 where the hardware can do it.
> >
> > Is there really a gain doing segmentation here if you have to do the
> > extra data copy?
> 
> There is no 'extra' copy.
> 
> There is _already_ a copy, so what's the deal of doing this copy in a SG
> enabled way ?

Ok.

But there is one more copy than for a normal ethernet chipset which
can use multiple ring entries to send the MAC+IP+TCP headers from a
different buffer to the TCP userdata.

David

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�:+v���zZ+��+zf���h���~i���z��w���?�&�)ߢf��^jǫy�m��@A�a���
0��h���i

RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread Eric Dumazet
On Tue, 2014-03-04 at 14:35 +, David Laight wrote:

> Does that mean you are splitting the 64k 'ethernet packet' from TCP
> is software? I've looked at the ax88179 where the hardware can do it.
> 
> Is there really a gain doing segmentation here if you have to do the
> extra data copy?

There is no 'extra' copy.

There is _already_ a copy, so what's the deal of doing this copy in a SG
enabled way ?



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread David Laight
From: hayeswang 
>  David Laight [mailto:david.lai...@aculab.com]
> > Sent: Tuesday, March 04, 2014 8:12 PM
> > To: 'Hayes Wang'; net...@vger.kernel.org
> > Cc: nic_s...@realtek.com; linux-kernel@vger.kernel.org;
> > linux-...@vger.kernel.org
> > Subject: RE: [PATCH net-next 08/12] r8152: support TSO
> >
> > From: Hayes Wang
> > > Support scatter gather and TSO.
> > >
> > > Adjust the tx checksum function and set the max gso size to fix the
> > > size of the tx aggregation buffer.
> >
> > There is little point supporting TSO unless the usb host controller
> > supports arbitrary aligned scatter-gather.
> > All you do is require that a large skb be allocated (that may well
> > fail), and add it another data copy.
> 
> I think I have done it. For also working for EHCI usb host controller,
> I allocate 16 KB continuous buffer and copy the fragmented packets to
> it and bulk out the buffer.

Does that mean you are splitting the 64k 'ethernet packet' from TCP
is software? I've looked at the ax88179 where the hardware can do it.

Is there really a gain doing segmentation here if you have to do the
extra data copy?

It might be worth packing multiple short packets into a single USB bulk
data packet, but that might require a CBU (crystal ball unit).

I did measure a maximum transmit ethernet frame rate of (IIRC) 25
frames/sec for the ax88179 - probably limited by the USB3 frame rate.
Exceeding that would probably require putting multiple tx packets into
a single URB. OTOH that limit probably doesn't matter

What might be more useful is to set the rx side up to receive into
page-aligned 2k (or 4k) buffers and then separate out the ethernet
frames into the required skb - probably as page list fragments
(I'm not entirely sure how such skb can be created).

I don't know what the r8152 does, but the usbnet code encourages it to
allocate long skb, pass them to the usb stack to fill, and then clone
them if they contain multiple frames.

This isn't really good use of memory or cpu cycles.
The ax88179 driver also lies badly about the skb's truesize.

David



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread hayeswang
 David Laight [mailto:david.lai...@aculab.com] 
> Sent: Tuesday, March 04, 2014 8:12 PM
> To: 'Hayes Wang'; net...@vger.kernel.org
> Cc: nic_s...@realtek.com; linux-kernel@vger.kernel.org; 
> linux-...@vger.kernel.org
> Subject: RE: [PATCH net-next 08/12] r8152: support TSO
> 
> From: Hayes Wang
> > Support scatter gather and TSO.
> > 
> > Adjust the tx checksum function and set the max gso size to fix the
> > size of the tx aggregation buffer.
> 
> There is little point supporting TSO unless the usb host controller
> supports arbitrary aligned scatter-gather.
> All you do is require that a large skb be allocated (that may well
> fail), and add it another data copy.

I think I have done it. For also working for EHCI usb host controller,
I allocate 16 KB continuous buffer and copy the fragmented packets to
it and bulk out the buffer.
 
Best Regards,
Hayes

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread David Laight
From: Hayes Wang
> Support scatter gather and TSO.
> 
> Adjust the tx checksum function and set the max gso size to fix the
> size of the tx aggregation buffer.

There is little point supporting TSO unless the usb host controller
supports arbitrary aligned scatter-gather.
All you do is require that a large skb be allocated (that may well
fail), and add it another data copy.

The xhci controller is almost capable of arbitrary scatter-gather,
but it is currently disabled because the data must be aligned at
the end of the transfer ring (the hardware designers have made it
almost impossible to write efficient software).

Note that the various xhci controllers behave subtly differently.

David



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread David Laight
From: Hayes Wang
 Support scatter gather and TSO.
 
 Adjust the tx checksum function and set the max gso size to fix the
 size of the tx aggregation buffer.

There is little point supporting TSO unless the usb host controller
supports arbitrary aligned scatter-gather.
All you do is require that a large skb be allocated (that may well
fail), and add it another data copy.

The xhci controller is almost capable of arbitrary scatter-gather,
but it is currently disabled because the data must be aligned at
the end of the transfer ring (the hardware designers have made it
almost impossible to write efficient software).

Note that the various xhci controllers behave subtly differently.

David



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread hayeswang
 David Laight [mailto:david.lai...@aculab.com] 
 Sent: Tuesday, March 04, 2014 8:12 PM
 To: 'Hayes Wang'; net...@vger.kernel.org
 Cc: nic_s...@realtek.com; linux-kernel@vger.kernel.org; 
 linux-...@vger.kernel.org
 Subject: RE: [PATCH net-next 08/12] r8152: support TSO
 
 From: Hayes Wang
  Support scatter gather and TSO.
  
  Adjust the tx checksum function and set the max gso size to fix the
  size of the tx aggregation buffer.
 
 There is little point supporting TSO unless the usb host controller
 supports arbitrary aligned scatter-gather.
 All you do is require that a large skb be allocated (that may well
 fail), and add it another data copy.

I think I have done it. For also working for EHCI usb host controller,
I allocate 16 KB continuous buffer and copy the fragmented packets to
it and bulk out the buffer.
 
Best Regards,
Hayes

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread David Laight
From: hayeswang 
  David Laight [mailto:david.lai...@aculab.com]
  Sent: Tuesday, March 04, 2014 8:12 PM
  To: 'Hayes Wang'; net...@vger.kernel.org
  Cc: nic_s...@realtek.com; linux-kernel@vger.kernel.org;
  linux-...@vger.kernel.org
  Subject: RE: [PATCH net-next 08/12] r8152: support TSO
 
  From: Hayes Wang
   Support scatter gather and TSO.
  
   Adjust the tx checksum function and set the max gso size to fix the
   size of the tx aggregation buffer.
 
  There is little point supporting TSO unless the usb host controller
  supports arbitrary aligned scatter-gather.
  All you do is require that a large skb be allocated (that may well
  fail), and add it another data copy.
 
 I think I have done it. For also working for EHCI usb host controller,
 I allocate 16 KB continuous buffer and copy the fragmented packets to
 it and bulk out the buffer.

Does that mean you are splitting the 64k 'ethernet packet' from TCP
is software? I've looked at the ax88179 where the hardware can do it.

Is there really a gain doing segmentation here if you have to do the
extra data copy?

It might be worth packing multiple short packets into a single USB bulk
data packet, but that might require a CBU (crystal ball unit).

I did measure a maximum transmit ethernet frame rate of (IIRC) 25
frames/sec for the ax88179 - probably limited by the USB3 frame rate.
Exceeding that would probably require putting multiple tx packets into
a single URB. OTOH that limit probably doesn't matter

What might be more useful is to set the rx side up to receive into
page-aligned 2k (or 4k) buffers and then separate out the ethernet
frames into the required skb - probably as page list fragments
(I'm not entirely sure how such skb can be created).

I don't know what the r8152 does, but the usbnet code encourages it to
allocate long skb, pass them to the usb stack to fill, and then clone
them if they contain multiple frames.

This isn't really good use of memory or cpu cycles.
The ax88179 driver also lies badly about the skb's truesize.

David



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread Eric Dumazet
On Tue, 2014-03-04 at 14:35 +, David Laight wrote:

 Does that mean you are splitting the 64k 'ethernet packet' from TCP
 is software? I've looked at the ax88179 where the hardware can do it.
 
 Is there really a gain doing segmentation here if you have to do the
 extra data copy?

There is no 'extra' copy.

There is _already_ a copy, so what's the deal of doing this copy in a SG
enabled way ?



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread David Laight
From: Eric Dumazet 
 On Tue, 2014-03-04 at 14:35 +, David Laight wrote:
 
  Does that mean you are splitting the 64k 'ethernet packet' from TCP
  is software? I've looked at the ax88179 where the hardware can do it.
 
  Is there really a gain doing segmentation here if you have to do the
  extra data copy?
 
 There is no 'extra' copy.
 
 There is _already_ a copy, so what's the deal of doing this copy in a SG
 enabled way ?

Ok.

But there is one more copy than for a normal ethernet chipset which
can use multiple ring entries to send the MAC+IP+TCP headers from a
different buffer to the TCP userdata.

David

N�r��yb�X��ǧv�^�)޺{.n�+{zX����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf��^jǫy�m��@A�a���
0��h���i

Re: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread Eric Dumazet
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote:

 +static u32 r8152_xmit_frags(struct r8152 *tp, struct sk_buff *skb, u8 *data)
 +{
 + struct skb_shared_info *info = skb_shinfo(skb);
 + unsigned int cur_frag;
 + u32 total = skb_headlen(skb);
 +
 + memcpy(data, skb-data, total);
 + data += total;
 +
 + for (cur_frag = 0; cur_frag  info-nr_frags; cur_frag++) {
 + const skb_frag_t *frag = info-frags + cur_frag;
 + void *addr;
 + u32 len;
 +
 + len = skb_frag_size(frag);
 + addr = skb_frag_address(frag);
 + memcpy(data, addr, len);
 + data += len;
 + total += len;
   }
 +
 + return total;
  }
  

I would rather use skb_copy_bits(), because it correctly handles
kmap() case. (If a frag resides in high memory)



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH net-next 08/12] r8152: support TSO

2014-03-04 Thread Eric Dumazet
On Tue, 2014-03-04 at 20:01 +0800, Hayes Wang wrote:
 Support scatter gather and TSO.

  
 - netdev-features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
 - netdev-hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
 + netdev-features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
 + NETIF_F_TSO;
 + netdev-hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG |
 +   NETIF_F_TSO;
  

Minor nit :

If you use skb_copy_bits(), then you also can add NETIF_F_FRAGLIST here.



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/