netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: shironeko@tesaguri.club, Jose Alonso <joalonsof@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org,
	 Soheil Hassas Yeganeh <soheil@google.com>,
	Neal Cardwell <ncardwell@google.com>,
	 Yuchung Cheng <ycheng@google.com>,
	eric.dumazet@gmail.com
Subject: Re: [PATCH net-next] tcp: get rid of sysctl_tcp_adv_win_scale
Date: Tue, 2 Apr 2024 18:23:32 +0200	[thread overview]
Message-ID: <CANn89iKm5X8V7fMD=oLwBBdX2=JuBv3VNQ5_7-G7yFaENYJrjg@mail.gmail.com> (raw)
In-Reply-To: <CANn89iKMS2cvgca7qOrVMhWQOoJMuZ-tJ99WTtkXng1O69rOdQ@mail.gmail.com>

On Tue, Apr 2, 2024 at 5:50 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Tue, Apr 2, 2024 at 5:28 PM <shironeko@tesaguri.club> wrote:
> >
> > Hi all,
> >
> > These parts seems to be causing a regression for a specific USB NIC, I
> > have this on one of home server, and it's network will randomly cut out
> > a few times a week.
> > Seems others have ran into the same issue with this particular NIC as
> > well https://bugzilla.kernel.org/show_bug.cgi?id=218536
> >
> > > +/* inverse of tcp_win_from_space() */
> > > +static inline int tcp_space_from_win(const struct sock *sk, int win)
> > > +{
> > > +     u64 val = (u64)win << TCP_RMEM_TO_WIN_SCALE;
> > > +
> > > +     do_div(val, tcp_sk(sk)->scaling_ratio);
> > > +     return val;
> > > +}
> > > +
> > > +static inline void tcp_scaling_ratio_init(struct sock *sk)
> > > +{
> > > +     /* Assume a conservative default of 1200 bytes of payload per 4K
> > > page.
> > > +      * This may be adjusted later in tcp_measure_rcv_mss().
> > > +      */
> > > +     tcp_sk(sk)->scaling_ratio = (1200 << TCP_RMEM_TO_WIN_SCALE) /
> > > +                                 SKB_TRUESIZE(4096);
> > >  }
> > ...
> > > @@ -740,12 +750,7 @@ void tcp_rcv_space_adjust(struct sock *sk)
> > >               do_div(grow, tp->rcvq_space.space);
> > >               rcvwin += (grow << 1);
> > >
> > > -             rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER);
> > > -             while (tcp_win_from_space(sk, rcvmem) < tp->advmss)
> > > -                     rcvmem += 128;
> > > -
> > > -             do_div(rcvwin, tp->advmss);
> > > -             rcvbuf = min_t(u64, rcvwin * rcvmem,
> > > +             rcvbuf = min_t(u64, tcp_space_from_win(sk, rcvwin),
> > >                              READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[2]));
> > >               if (rcvbuf > sk->sk_rcvbuf) {
> > >                       WRITE_ONCE(sk->sk_rcvbuf, rcvbuf);
> >
> > The NIC:
> > usb 2-2: new SuperSpeed USB device number 4 using xhci_hcd
> > usb 2-2: New USB device found, idVendor=0b95, idProduct=1790, bcdDevice=
> > 1.00
> > usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> > usb 2-2: Product: AX88179
> > usb 2-2: Manufacturer: ASIX Elec. Corp.
> > usb 2-2: SerialNumber: 0000000000009D
> > ax88179_178a 2-2:1.0 eth0: register 'ax88179_178a' at
> > usb-0000:00:14.0-2, ASIX AX88179 USB 3.0 Gigabit Ethernet,
> > 02:5e:c0:4b:a4:f7
> > ax88179_178a 2-2:1.0 eth0: ax88179 - Link status is: 1
> >
> > The dmesg error I get:
> >
>
> Thanks for the report. This driver is probably lying on skb->truesize.
>
> This commit looks suspicious
>
> commit f8ebb3ac881b17712e1d5967c97ab1806b16d3d6
> Author: Jose Alonso <joalonsof@gmail.com>
> Date:   Tue Jun 28 12:13:02 2022 -0300
>
>     net: usb: ax88179_178a: Fix packet receiving

Could you try this patch ?

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 88e084534853dd50505fd730e7ccd07c70f2d8ee..ca33365e49cc3993a974ddbdbf68189ce4df2e82
100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1452,21 +1452,16 @@ static int ax88179_rx_fixup(struct usbnet
*dev, struct sk_buff *skb)
                        /* Skip IP alignment pseudo header */
                        skb_pull(skb, 2);

-                       skb->truesize = SKB_TRUESIZE(pkt_len_plus_padd);
                        ax88179_rx_checksum(skb, pkt_hdr);
                        return 1;
                }

-               ax_skb = skb_clone(skb, GFP_ATOMIC);
+               ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len);
                if (!ax_skb)
                        return 0;
-               skb_trim(ax_skb, pkt_len);
+               skb_put(ax_skb, pkt_len);
+               memcpy(ax_skb->data, skb->data + 2, pkt_len);

-               /* Skip IP alignment pseudo header */
-               skb_pull(ax_skb, 2);
-
-               skb->truesize = pkt_len_plus_padd +
-                               SKB_DATA_ALIGN(sizeof(struct sk_buff));
                ax88179_rx_checksum(ax_skb, pkt_hdr);
                usbnet_skb_return(dev, ax_skb);

  reply	other threads:[~2024-04-02 16:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 15:29 [PATCH net-next] tcp: get rid of sysctl_tcp_adv_win_scale Eric Dumazet
2023-07-17 16:52 ` Soheil Hassas Yeganeh
2023-07-17 17:17   ` Eric Dumazet
2023-07-17 17:20     ` Soheil Hassas Yeganeh
2023-07-19  2:10 ` patchwork-bot+netdevbpf
2023-07-20 15:41 ` Paolo Abeni
2023-07-20 15:50   ` Eric Dumazet
2023-11-03  6:10 ` Jiri Slaby
2023-11-03  6:56   ` Jiri Slaby
2023-11-03  7:07     ` Jiri Slaby
2023-11-03  8:17       ` Eric Dumazet
2023-11-03  9:27         ` Michal Kubecek
2023-11-03  9:53           ` Eric Dumazet
2023-11-03 10:14         ` Jiri Slaby
2023-11-03 10:27           ` Eric Dumazet
2023-11-03 11:07             ` Jiri Slaby
2024-04-02 15:28 ` shironeko
2024-04-02 15:50   ` Eric Dumazet
2024-04-02 16:23     ` Eric Dumazet [this message]
2024-04-02 16:29       ` shironeko
2024-04-06  0:22         ` shironeko
2024-04-06  6:11           ` Eric Dumazet
2024-04-06  7:07             ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANn89iKm5X8V7fMD=oLwBBdX2=JuBv3VNQ5_7-G7yFaENYJrjg@mail.gmail.com' \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=joalonsof@gmail.com \
    --cc=kuba@kernel.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shironeko@tesaguri.club \
    --cc=soheil@google.com \
    --cc=ycheng@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).