Thread (9 messages) flat view 9 messages, 2 authors, 2014-12-22

Re: [PATCH net-next 2/2] r8152: check the status before submittingrx

From: David Miller <davem@davemloft.net>
Date: 2014-12-22 05:22:59
Also in: lkml

From: Hayes Wang <redacted>
Date: Mon, 22 Dec 2014 02:53:42 +0000
 David Miller [mailto:davem@davemloft.net] 
quoted
Sent: Saturday, December 20, 2014 4:44 AM
[...]
quoted
quoted
Don't submit the rx if the device is unplugged, linking down,
or stopped.
 ...
quoted
@@ -1789,6 +1789,11 @@ int r8152_submit_rx(struct r8152 
*tp, struct rx_agg *agg, gfp_t mem_flags)
quoted
 {
 	int ret;
 
+	/* The rx would be stopped, so skip submitting */
+	if (test_bit(RTL8152_UNPLUG, &tp->flags) ||
+	    !test_bit(WORK_ENABLE, &tp->flags) || !(tp->speed & LINK_STATUS))
+		return 0;
+
I think netif_carrier_off() should always be true in all three of those
situations, and would be a much simpler test than what you've coded
here.
When the device is unplugged or stopped, the linking status
may be true, so I add additional checks to avoid the submission.

Besides, in set_carrier() I set netif_carrier_on() after
ops.enable() to avoid any transmission before I finish
starting the tx/rx.

	tp->rtl_ops.enable(tp);
	set_bit(RTL8152_SET_RX_MODE, &tp->flags);
	netif_carrier_on(netdev);

However, the r8152_submit_rx() would be called in ops.enable(),
and the check of netif_carrier_ok() would be always false. That
is why I use tp->speed, not netif_carrier_ok(), to check the
linking stauts.
I stil think your check is way too complicated for this fast path so I
would ask that you arrange things such that the simpler
netif_carrier_off() test works.

Especially because that is what the core networking stack uses
to decide whether to send packets to us as well.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help