Yonghyeon PYUN wrote:> On Wed, Aug 19, 2015 at 09:51:44AM +0200, Hans Petter Selasky wrote: > > On 08/19/15 09:42, Yonghyeon PYUN wrote: > > >On Wed, Aug 19, 2015 at 09:00:52AM +0200, Hans Petter Selasky wrote: > > >>On 08/18/15 23:54, Rick Macklem wrote: > > >>>Ouch! Yes, I now see that the code that counts the # of mbufs is before > > >>>the > > >>>code that adds the tcp/ip header mbuf. > > >>> > > >>>In my opinion, this should be fixed by setting if_hw_tsomaxsegcount to > > >>>whatever > > >>>the driver provides - 1. It is not the driver's responsibility to know > > >>>if > > >>>a tcp/ip > > >>>header mbuf will be added and is a lot less confusing that expecting the > > >>>driver > > >>>author to know to subtract one. (I had mistakenly thought that > > >>>tcp_output() had > > >>>added the tc/ip header mbuf before the loop that counts mbufs in the > > >>>list. > > >>>Btw, > > >>>this tcp/ip header mbuf also has leading space for the MAC layer > > >>>header.) > > >>> > > >> > > >>Hi Rick, > > >> > > >>Your question is good. With the Mellanox hardware we have separate > > >>so-called inline data space for the TCP/IP headers, so if the TCP stack > > >>subtracts something, then we would need to add something to the limit, > > >>because then the scatter gather list is only used for the data part. > > >> > > > > > >I think all drivers in tree don't subtract 1 for > > >if_hw_tsomaxsegcount. Probably touching Mellanox driver would be > > >simpler than fixing all other drivers in tree. > > > > Hi, > > > > If you change the behaviour don't forget to update and/or add comments > > describing it. Maybe the amount of subtraction could be defined by some > > macro? Then drivers which inline the headers can subtract it? > > > > I'm also ok with your suggestion. > > > Your suggestion is fine by me. > > > > > The initial TSO limits were tried to be preserved, and I believe that > > TSO limits never accounted for IP/TCP/ETHERNET/VLAN headers! > > > > I guess FreeBSD used to follow MS LSOv1 specification with minor > exception in pseudo checksum computation. If I recall correctly the > specification says upper stack can generate up to IP_MAXPACKET sized > packet. Other L2 headers like ethernet/vlan header size is not > included in the packet and it's drivers responsibility to allocate > additional DMA buffers/segments for L2 headers. >Yep. The default for if_hw_tsomax was reduced from IP_MAXPACKET to 32 * MCLBYTES - max_ethernet_header_size as a workaround/hack so that devices limited to 32 transmit segments would work (ie. the entire packet, including MAC header would fit in 32 MCLBYTE clusters). This implied that many drivers did end up using m_defrag() to copy the mbuf list to one made up of 32 MCLBYTE clusters. If a driver sets if_hw_tsomaxsegcount correctly, then it can set if_hw_tsomax to whatever it can handle as the largest TSO packet (without MAC header) the hardware can handle. If it can handle > IP_MAXPACKET, then it can set it to that. rick> > > > > >>Maybe it can be controlled by some kind of flag, if all the three TSO > > >>limits should include the TCP/IP/ethernet headers too. I'm pretty sure > > >>we want both versions. > > >> > > > > > >Hmm, I'm afraid it's already complex. Drivers have to tell almost > > >the same information to both bus_dma(9) and network stack. > > > > You're right it's complicated. Not sure if bus_dma can provide an API > > for this though. > > > > --HPS > _______________________________________________ > freebsd-net at freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org" >
On Wed, Aug 19, 2015 at 08:13:59AM -0400, Rick Macklem wrote:> Yonghyeon PYUN wrote: > > On Wed, Aug 19, 2015 at 09:51:44AM +0200, Hans Petter Selasky wrote: > > > On 08/19/15 09:42, Yonghyeon PYUN wrote: > > > >On Wed, Aug 19, 2015 at 09:00:52AM +0200, Hans Petter Selasky wrote: > > > >>On 08/18/15 23:54, Rick Macklem wrote: > > > >>>Ouch! Yes, I now see that the code that counts the # of mbufs is before > > > >>>the > > > >>>code that adds the tcp/ip header mbuf. > > > >>> > > > >>>In my opinion, this should be fixed by setting if_hw_tsomaxsegcount to > > > >>>whatever > > > >>>the driver provides - 1. It is not the driver's responsibility to know > > > >>>if > > > >>>a tcp/ip > > > >>>header mbuf will be added and is a lot less confusing that expecting the > > > >>>driver > > > >>>author to know to subtract one. (I had mistakenly thought that > > > >>>tcp_output() had > > > >>>added the tc/ip header mbuf before the loop that counts mbufs in the > > > >>>list. > > > >>>Btw, > > > >>>this tcp/ip header mbuf also has leading space for the MAC layer > > > >>>header.) > > > >>> > > > >> > > > >>Hi Rick, > > > >> > > > >>Your question is good. With the Mellanox hardware we have separate > > > >>so-called inline data space for the TCP/IP headers, so if the TCP stack > > > >>subtracts something, then we would need to add something to the limit, > > > >>because then the scatter gather list is only used for the data part. > > > >> > > > > > > > >I think all drivers in tree don't subtract 1 for > > > >if_hw_tsomaxsegcount. Probably touching Mellanox driver would be > > > >simpler than fixing all other drivers in tree. > > > > > > Hi, > > > > > > If you change the behaviour don't forget to update and/or add comments > > > describing it. Maybe the amount of subtraction could be defined by some > > > macro? Then drivers which inline the headers can subtract it? > > > > > > > I'm also ok with your suggestion. > > > > > Your suggestion is fine by me. > > > > > > > > The initial TSO limits were tried to be preserved, and I believe that > > > TSO limits never accounted for IP/TCP/ETHERNET/VLAN headers! > > > > > > > I guess FreeBSD used to follow MS LSOv1 specification with minor > > exception in pseudo checksum computation. If I recall correctly the > > specification says upper stack can generate up to IP_MAXPACKET sized > > packet. Other L2 headers like ethernet/vlan header size is not > > included in the packet and it's drivers responsibility to allocate > > additional DMA buffers/segments for L2 headers. > > > Yep. The default for if_hw_tsomax was reduced from IP_MAXPACKET to > 32 * MCLBYTES - max_ethernet_header_size as a workaround/hack so that > devices limited to 32 transmit segments would work (ie. the entire packet, > including MAC header would fit in 32 MCLBYTE clusters). > This implied that many drivers did end up using m_defrag() to copy the mbuf > list to one made up of 32 MCLBYTE clusters. > > If a driver sets if_hw_tsomaxsegcount correctly, then it can set if_hw_tsomax > to whatever it can handle as the largest TSO packet (without MAC header) the > hardware can handle. If it can handle > IP_MAXPACKET, then it can set it to that. >I thought the upper limit was still IP_MAXPACKET. If driver increase it (i.e. > IP_MAXPACKET, the length field in the IP header would overflow which in turn may break firewalls and other packet handling in IPv4/IPv6 code path. If the limit no longer apply to network stack, that's great. Some controllers can handle up to 256KB TCP/UDP segmentation and supporting that feature wouldn't be hard.