Netdev Archive on
 help / color / Atom feed
From: Hayes Wang <>
To: Eric Dumazet <>,
	"" <>
Cc: nic_swsd <>,
	"" <>
Subject: RE: [PATCH net-next] r8152: divide the tx and rx bottom functions
Date: Fri, 16 Aug 2019 09:08:41 +0000
Message-ID: <> (raw)
In-Reply-To: <>

Eric Dumazet []
> Sent: Friday, August 16, 2019 4:20 PM
> Which callback ?

The USB device has two endpoints for Tx and Rx.
If I submit tx or rx URB to the USB host controller,
the relative callback functions would be called, when
they are finished. For rx, it is read_bulk_callback.
For tx, it is write_bulk_callback.

> After an idle period (no activity, no prior packets being tx-completed ...),
> a packet is sent by the upper stack, enters the ndo_start_xmit() of a network
> driver.
> This driver ndo_start_xmit() simply adds an skb to a local list, and returns.

Base on the current method (without tasklet), when
ndo_start_xmit() is called, napi_schedule is called only
if there is at least one free buffer (!list_empty(&tp->tx_free))
to transmit the packet. Then, the flow would be as following.

    - Call r8152_poll
     -- Call bottom_half
      --- Call tx_bottom
       ---- Call r8152_tx_agg_fill
        ----- submit tx urb

    - Call write_bulk_callback if tx is completed

When the tx transfer is completed, write_bulk_callback would
be called. And it would check if there is any tx packet
in &tp->tx_queue and determine whether it is necessary to
schedule the napi again or not.

> Where/how is scheduled this callback ?

For tx, you could find the following code in r8152_tx_agg_fill().

	usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2),
			  agg->head, (int)(tx_data - (u8 *)agg->head),
			  (usb_complete_t)write_bulk_callback, agg);
	ret = usb_submit_urb(agg->urb, GFP_ATOMIC);

For rx you could find the following code in r8152_submit_rx().

	usb_fill_bulk_urb(agg->urb, tp->udev, usb_rcvbulkpipe(tp->udev, 1),
			  agg->buffer, tp->rx_buf_sz,
			  (usb_complete_t)read_bulk_callback, agg);

	ret = usb_submit_urb(agg->urb, mem_flags);

> Some kind of timer ?
> An (unrelated) incoming packet ?

When the rx or tx is completed, a interrupt of USB
host controller would be triggered. Then, the callback
functions would be called.

Best Regards,

  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14  8:30 Hayes Wang
2019-08-15 20:58 ` David Miller
2019-08-16  2:59   ` Hayes Wang
2019-08-16  5:17     ` David Miller
2019-08-16  6:39 ` Eric Dumazet
2019-08-16  8:10   ` Hayes Wang
2019-08-16  8:19     ` Eric Dumazet
2019-08-16  9:08       ` Hayes Wang [this message]
2019-08-16  9:27         ` Eric Dumazet
2019-08-16 10:04           ` Hayes Wang
2019-08-19  6:40 ` [PATCH net-next v2] " Hayes Wang
2019-08-20 19:19   ` David Miller

Reply instructions:

You may reply publically 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:

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

  git send-email \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Netdev Archive on

Archives are clonable:
	git clone --mirror netdev/git/0.git
	git clone --mirror netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ \
	public-inbox-index netdev

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox