Skip to content

Commit b59768c

Browse files
edumazetdavem330
authored andcommitted
bnx2x: remove bnx2x_low_latency_recv() support
Switch to native NAPI polling, as this reduces overhead and complexity. Normal path is faster, since one cmpxchg() is not anymore requested, and busy polling with the NAPI polling has same performance. Tested: lpk50:~# cat /proc/sys/net/core/busy_read 70 lpk50:~# nstat >/dev/null;./netperf -H lpk55 -t TCP_RR;nstat MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to lpk55.prod.google.com () port 0 AF_INET : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec 16384 87380 1 1 10.00 40095.07 16384 87380 IpInReceives 401062 0.0 IpInDelivers 401062 0.0 IpOutRequests 401079 0.0 TcpActiveOpens 7 0.0 TcpPassiveOpens 3 0.0 TcpAttemptFails 3 0.0 TcpEstabResets 5 0.0 TcpInSegs 401036 0.0 TcpOutSegs 401052 0.0 TcpOutRsts 38 0.0 UdpInDatagrams 26 0.0 UdpOutDatagrams 27 0.0 Ip6OutNoRoutes 1 0.0 TcpExtDelayedACKs 1 0.0 TcpExtTCPPrequeued 98 0.0 TcpExtTCPDirectCopyFromPrequeue 98 0.0 TcpExtTCPHPHits 4 0.0 TcpExtTCPHPHitsToUser 98 0.0 TcpExtTCPPureAcks 5 0.0 TcpExtTCPHPAcks 101 0.0 TcpExtTCPAbortOnData 6 0.0 TcpExtBusyPollRxPackets 400832 0.0 TcpExtTCPOrigDataSent 400983 0.0 IpExtInOctets 21273867 0.0 IpExtOutOctets 21261254 0.0 IpExtInNoECTPkts 401064 0.0 Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 44fb6fb commit b59768c

File tree

4 files changed

+2
-167
lines changed

4 files changed

+2
-167
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,6 @@ struct bnx2x_fastpath {
540540

541541
struct napi_struct napi;
542542

543-
#ifdef CONFIG_NET_RX_BUSY_POLL
544-
unsigned long busy_poll_state;
545-
#endif
546-
547543
union host_hc_status_block status_blk;
548544
/* chip independent shortcuts into sb structure */
549545
__le16 *sb_index_values;
@@ -617,115 +613,6 @@ struct bnx2x_fastpath {
617613
#define bnx2x_fp_stats(bp, fp) (&((bp)->fp_stats[(fp)->index]))
618614
#define bnx2x_fp_qstats(bp, fp) (&((bp)->fp_stats[(fp)->index].eth_q_stats))
619615

620-
#ifdef CONFIG_NET_RX_BUSY_POLL
621-
622-
enum bnx2x_fp_state {
623-
BNX2X_STATE_FP_NAPI = BIT(0), /* NAPI handler owns the queue */
624-
625-
BNX2X_STATE_FP_NAPI_REQ_BIT = 1, /* NAPI would like to own the queue */
626-
BNX2X_STATE_FP_NAPI_REQ = BIT(1),
627-
628-
BNX2X_STATE_FP_POLL_BIT = 2,
629-
BNX2X_STATE_FP_POLL = BIT(2), /* busy_poll owns the queue */
630-
631-
BNX2X_STATE_FP_DISABLE_BIT = 3, /* queue is dismantled */
632-
};
633-
634-
static inline void bnx2x_fp_busy_poll_init(struct bnx2x_fastpath *fp)
635-
{
636-
WRITE_ONCE(fp->busy_poll_state, 0);
637-
}
638-
639-
/* called from the device poll routine to get ownership of a FP */
640-
static inline bool bnx2x_fp_lock_napi(struct bnx2x_fastpath *fp)
641-
{
642-
unsigned long prev, old = READ_ONCE(fp->busy_poll_state);
643-
644-
while (1) {
645-
switch (old) {
646-
case BNX2X_STATE_FP_POLL:
647-
/* make sure bnx2x_fp_lock_poll() wont starve us */
648-
set_bit(BNX2X_STATE_FP_NAPI_REQ_BIT,
649-
&fp->busy_poll_state);
650-
/* fallthrough */
651-
case BNX2X_STATE_FP_POLL | BNX2X_STATE_FP_NAPI_REQ:
652-
return false;
653-
default:
654-
break;
655-
}
656-
prev = cmpxchg(&fp->busy_poll_state, old, BNX2X_STATE_FP_NAPI);
657-
if (unlikely(prev != old)) {
658-
old = prev;
659-
continue;
660-
}
661-
return true;
662-
}
663-
}
664-
665-
static inline void bnx2x_fp_unlock_napi(struct bnx2x_fastpath *fp)
666-
{
667-
smp_wmb();
668-
fp->busy_poll_state = 0;
669-
}
670-
671-
/* called from bnx2x_low_latency_poll() */
672-
static inline bool bnx2x_fp_lock_poll(struct bnx2x_fastpath *fp)
673-
{
674-
return cmpxchg(&fp->busy_poll_state, 0, BNX2X_STATE_FP_POLL) == 0;
675-
}
676-
677-
static inline void bnx2x_fp_unlock_poll(struct bnx2x_fastpath *fp)
678-
{
679-
smp_mb__before_atomic();
680-
clear_bit(BNX2X_STATE_FP_POLL_BIT, &fp->busy_poll_state);
681-
}
682-
683-
/* true if a socket is polling */
684-
static inline bool bnx2x_fp_ll_polling(struct bnx2x_fastpath *fp)
685-
{
686-
return READ_ONCE(fp->busy_poll_state) & BNX2X_STATE_FP_POLL;
687-
}
688-
689-
/* false if fp is currently owned */
690-
static inline bool bnx2x_fp_ll_disable(struct bnx2x_fastpath *fp)
691-
{
692-
set_bit(BNX2X_STATE_FP_DISABLE_BIT, &fp->busy_poll_state);
693-
return !bnx2x_fp_ll_polling(fp);
694-
695-
}
696-
#else
697-
static inline void bnx2x_fp_busy_poll_init(struct bnx2x_fastpath *fp)
698-
{
699-
}
700-
701-
static inline bool bnx2x_fp_lock_napi(struct bnx2x_fastpath *fp)
702-
{
703-
return true;
704-
}
705-
706-
static inline void bnx2x_fp_unlock_napi(struct bnx2x_fastpath *fp)
707-
{
708-
}
709-
710-
static inline bool bnx2x_fp_lock_poll(struct bnx2x_fastpath *fp)
711-
{
712-
return false;
713-
}
714-
715-
static inline void bnx2x_fp_unlock_poll(struct bnx2x_fastpath *fp)
716-
{
717-
}
718-
719-
static inline bool bnx2x_fp_ll_polling(struct bnx2x_fastpath *fp)
720-
{
721-
return false;
722-
}
723-
static inline bool bnx2x_fp_ll_disable(struct bnx2x_fastpath *fp)
724-
{
725-
return true;
726-
}
727-
#endif /* CONFIG_NET_RX_BUSY_POLL */
728-
729616
/* Use 2500 as a mini-jumbo MTU for FCoE */
730617
#define BNX2X_FCOE_MINI_JUMBO_MTU 2500
731618

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
10961096

10971097
skb_mark_napi_id(skb, &fp->napi);
10981098

1099-
if (bnx2x_fp_ll_polling(fp))
1100-
netif_receive_skb(skb);
1101-
else
1102-
napi_gro_receive(&fp->napi, skb);
1099+
napi_gro_receive(&fp->napi, skb);
11031100
next_rx:
11041101
rx_buf->data = NULL;
11051102

@@ -1869,7 +1866,6 @@ static void bnx2x_napi_enable_cnic(struct bnx2x *bp)
18691866
int i;
18701867

18711868
for_each_rx_queue_cnic(bp, i) {
1872-
bnx2x_fp_busy_poll_init(&bp->fp[i]);
18731869
napi_enable(&bnx2x_fp(bp, i, napi));
18741870
}
18751871
}
@@ -1879,7 +1875,6 @@ static void bnx2x_napi_enable(struct bnx2x *bp)
18791875
int i;
18801876

18811877
for_each_eth_queue(bp, i) {
1882-
bnx2x_fp_busy_poll_init(&bp->fp[i]);
18831878
napi_enable(&bnx2x_fp(bp, i, napi));
18841879
}
18851880
}
@@ -1890,8 +1885,6 @@ static void bnx2x_napi_disable_cnic(struct bnx2x *bp)
18901885

18911886
for_each_rx_queue_cnic(bp, i) {
18921887
napi_disable(&bnx2x_fp(bp, i, napi));
1893-
while (!bnx2x_fp_ll_disable(&bp->fp[i]))
1894-
usleep_range(1000, 2000);
18951888
}
18961889
}
18971890

@@ -1901,8 +1894,6 @@ static void bnx2x_napi_disable(struct bnx2x *bp)
19011894

19021895
for_each_eth_queue(bp, i) {
19031896
napi_disable(&bnx2x_fp(bp, i, napi));
1904-
while (!bnx2x_fp_ll_disable(&bp->fp[i]))
1905-
usleep_range(1000, 2000);
19061897
}
19071898
}
19081899

@@ -3232,9 +3223,6 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
32323223
return 0;
32333224
}
32343225
#endif
3235-
if (!bnx2x_fp_lock_napi(fp))
3236-
return budget;
3237-
32383226
for_each_cos_in_tx_queue(fp, cos)
32393227
if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
32403228
bnx2x_tx_int(bp, fp->txdata_ptr[cos]);
@@ -3243,14 +3231,10 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
32433231
work_done += bnx2x_rx_int(fp, budget - work_done);
32443232

32453233
/* must not complete if we consumed full budget */
3246-
if (work_done >= budget) {
3247-
bnx2x_fp_unlock_napi(fp);
3234+
if (work_done >= budget)
32483235
break;
3249-
}
32503236
}
32513237

3252-
bnx2x_fp_unlock_napi(fp);
3253-
32543238
/* Fall out from the NAPI loop if needed */
32553239
if (!(bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
32563240

@@ -3294,32 +3278,6 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
32943278
return work_done;
32953279
}
32963280

3297-
#ifdef CONFIG_NET_RX_BUSY_POLL
3298-
/* must be called with local_bh_disable()d */
3299-
int bnx2x_low_latency_recv(struct napi_struct *napi)
3300-
{
3301-
struct bnx2x_fastpath *fp = container_of(napi, struct bnx2x_fastpath,
3302-
napi);
3303-
struct bnx2x *bp = fp->bp;
3304-
int found = 0;
3305-
3306-
if ((bp->state == BNX2X_STATE_CLOSED) ||
3307-
(bp->state == BNX2X_STATE_ERROR) ||
3308-
(bp->dev->features & (NETIF_F_LRO | NETIF_F_GRO)))
3309-
return LL_FLUSH_FAILED;
3310-
3311-
if (!bnx2x_fp_lock_poll(fp))
3312-
return LL_FLUSH_BUSY;
3313-
3314-
if (bnx2x_has_rx_work(fp))
3315-
found = bnx2x_rx_int(fp, 4);
3316-
3317-
bnx2x_fp_unlock_poll(fp);
3318-
3319-
return found;
3320-
}
3321-
#endif
3322-
33233281
/* we split the first BD into headers and data BDs
33243282
* to ease the pain of our fellow microcode engineers
33253283
* we use one mapping for both BDs

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,6 @@ int bnx2x_enable_msix(struct bnx2x *bp);
569569
*/
570570
int bnx2x_enable_msi(struct bnx2x *bp);
571571

572-
/**
573-
* bnx2x_low_latency_recv - LL callback
574-
*
575-
* @napi: napi structure
576-
*/
577-
int bnx2x_low_latency_recv(struct napi_struct *napi);
578-
579572
/**
580573
* bnx2x_alloc_mem_bp - allocate memories outsize main driver structure
581574
*

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13004,9 +13004,6 @@ static const struct net_device_ops bnx2x_netdev_ops = {
1300413004
.ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn,
1300513005
#endif
1300613006

13007-
#ifdef CONFIG_NET_RX_BUSY_POLL
13008-
.ndo_busy_poll = bnx2x_low_latency_recv,
13009-
#endif
1301013007
.ndo_get_phys_port_id = bnx2x_get_phys_port_id,
1301113008
.ndo_set_vf_link_state = bnx2x_set_vf_link_state,
1301213009
.ndo_features_check = bnx2x_features_check,

0 commit comments

Comments
 (0)