Skip to content

Commit 18775aa

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Reorganize the coalescing parameters.
The current IRQ coalescing logic is a little messy. The ethtool parameters are mapped to hardware parameters in a way that is difficult to understand. The first step is to better organize the parameters by adding the new structure bnxt_coal. The structure is used by both the RX and TX sets of coalescing parameters. Adjust the default coal_ticks to 14 us and 28 us for RX and TX. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 49f7972 commit 18775aa

File tree

3 files changed

+79
-52
lines changed

3 files changed

+79
-52
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4569,34 +4569,31 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
45694569
/* Each rx completion (2 records) should be DMAed immediately.
45704570
* DMA 1/4 of the completion buffers at a time.
45714571
*/
4572-
max_buf = min_t(u16, bp->rx_coal_bufs / 4, 2);
4572+
max_buf = min_t(u16, bp->rx_coal.coal_bufs / 4, 2);
45734573
/* max_buf must not be zero */
45744574
max_buf = clamp_t(u16, max_buf, 1, 63);
4575-
max_buf_irq = clamp_t(u16, bp->rx_coal_bufs_irq, 1, 63);
4576-
buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal_ticks);
4575+
max_buf_irq = clamp_t(u16, bp->rx_coal.coal_bufs_irq, 1, 63);
4576+
buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal.coal_ticks);
45774577
/* buf timer set to 1/4 of interrupt timer */
45784578
buf_tmr = max_t(u16, buf_tmr / 4, 1);
4579-
buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal_ticks_irq);
4579+
buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal.coal_ticks_irq);
45804580
buf_tmr_irq = max_t(u16, buf_tmr_irq, 1);
45814581

45824582
flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET;
45834583

4584-
/* RING_IDLE generates more IRQs for lower latency. Enable it only
4585-
* if coal_ticks is less than 25 us.
4586-
*/
4587-
if (bp->rx_coal_ticks < 25)
4584+
if (bp->rx_coal.coal_ticks < bp->rx_coal.idle_thresh)
45884585
flags |= RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_RING_IDLE;
45894586

45904587
bnxt_hwrm_set_coal_params(bp, max_buf_irq << 16 | max_buf,
45914588
buf_tmr_irq << 16 | buf_tmr, flags, &req_rx);
45924589

45934590
/* max_buf must not be zero */
4594-
max_buf = clamp_t(u16, bp->tx_coal_bufs, 1, 63);
4595-
max_buf_irq = clamp_t(u16, bp->tx_coal_bufs_irq, 1, 63);
4596-
buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->tx_coal_ticks);
4591+
max_buf = clamp_t(u16, bp->tx_coal.coal_bufs, 1, 63);
4592+
max_buf_irq = clamp_t(u16, bp->tx_coal.coal_bufs_irq, 1, 63);
4593+
buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->tx_coal.coal_ticks);
45974594
/* buf timer set to 1/4 of interrupt timer */
45984595
buf_tmr = max_t(u16, buf_tmr / 4, 1);
4599-
buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->tx_coal_ticks_irq);
4596+
buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->tx_coal.coal_ticks_irq);
46004597
buf_tmr_irq = max_t(u16, buf_tmr_irq, 1);
46014598

46024599
flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET;
@@ -7146,6 +7143,32 @@ static void bnxt_cleanup_pci(struct bnxt *bp)
71467143
pci_disable_device(bp->pdev);
71477144
}
71487145

7146+
static void bnxt_init_dflt_coal(struct bnxt *bp)
7147+
{
7148+
struct bnxt_coal *coal;
7149+
7150+
/* Tick values in micro seconds.
7151+
* 1 coal_buf x bufs_per_record = 1 completion record.
7152+
*/
7153+
coal = &bp->rx_coal;
7154+
coal->coal_ticks = 14;
7155+
coal->coal_bufs = 30;
7156+
coal->coal_ticks_irq = 1;
7157+
coal->coal_bufs_irq = 2;
7158+
coal->idle_thresh = 25;
7159+
coal->bufs_per_record = 2;
7160+
coal->budget = 64; /* NAPI budget */
7161+
7162+
coal = &bp->tx_coal;
7163+
coal->coal_ticks = 28;
7164+
coal->coal_bufs = 30;
7165+
coal->coal_ticks_irq = 2;
7166+
coal->coal_bufs_irq = 2;
7167+
coal->bufs_per_record = 1;
7168+
7169+
bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS;
7170+
}
7171+
71497172
static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
71507173
{
71517174
int rc;
@@ -7214,18 +7237,7 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
72147237
bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE;
72157238
bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE;
72167239

7217-
/* tick values in micro seconds */
7218-
bp->rx_coal_ticks = 12;
7219-
bp->rx_coal_bufs = 30;
7220-
bp->rx_coal_ticks_irq = 1;
7221-
bp->rx_coal_bufs_irq = 2;
7222-
7223-
bp->tx_coal_ticks = 25;
7224-
bp->tx_coal_bufs = 30;
7225-
bp->tx_coal_ticks_irq = 2;
7226-
bp->tx_coal_bufs_irq = 2;
7227-
7228-
bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS;
7240+
bnxt_init_dflt_coal(bp);
72297241

72307242
setup_timer(&bp->timer, bnxt_timer, (unsigned long)bp);
72317243
bp->current_interval = BNXT_TIMER_INTERVAL;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,17 @@ struct bnxt_test_info {
944944
#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
945945
#define BNXT_CAG_REG_BASE 0x300000
946946

947+
struct bnxt_coal {
948+
u16 coal_ticks;
949+
u16 coal_ticks_irq;
950+
u16 coal_bufs;
951+
u16 coal_bufs_irq;
952+
/* RING_IDLE enabled when coal ticks < idle_thresh */
953+
u16 idle_thresh;
954+
u8 bufs_per_record;
955+
u8 budget;
956+
};
957+
947958
struct bnxt_tc_info {
948959
bool enabled;
949960

@@ -1235,14 +1246,8 @@ struct bnxt {
12351246
u8 port_count;
12361247
u16 br_mode;
12371248

1238-
u16 rx_coal_ticks;
1239-
u16 rx_coal_ticks_irq;
1240-
u16 rx_coal_bufs;
1241-
u16 rx_coal_bufs_irq;
1242-
u16 tx_coal_ticks;
1243-
u16 tx_coal_ticks_irq;
1244-
u16 tx_coal_bufs;
1245-
u16 tx_coal_bufs_irq;
1249+
struct bnxt_coal rx_coal;
1250+
struct bnxt_coal tx_coal;
12461251

12471252
#define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2)
12481253

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,24 @@ static int bnxt_get_coalesce(struct net_device *dev,
4444
struct ethtool_coalesce *coal)
4545
{
4646
struct bnxt *bp = netdev_priv(dev);
47+
struct bnxt_coal *hw_coal;
48+
u16 mult;
4749

4850
memset(coal, 0, sizeof(*coal));
4951

50-
coal->rx_coalesce_usecs = bp->rx_coal_ticks;
51-
/* 2 completion records per rx packet */
52-
coal->rx_max_coalesced_frames = bp->rx_coal_bufs / 2;
53-
coal->rx_coalesce_usecs_irq = bp->rx_coal_ticks_irq;
54-
coal->rx_max_coalesced_frames_irq = bp->rx_coal_bufs_irq / 2;
52+
hw_coal = &bp->rx_coal;
53+
mult = hw_coal->bufs_per_record;
54+
coal->rx_coalesce_usecs = hw_coal->coal_ticks;
55+
coal->rx_max_coalesced_frames = hw_coal->coal_bufs / mult;
56+
coal->rx_coalesce_usecs_irq = hw_coal->coal_ticks_irq;
57+
coal->rx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult;
5558

56-
coal->tx_coalesce_usecs = bp->tx_coal_ticks;
57-
coal->tx_max_coalesced_frames = bp->tx_coal_bufs;
58-
coal->tx_coalesce_usecs_irq = bp->tx_coal_ticks_irq;
59-
coal->tx_max_coalesced_frames_irq = bp->tx_coal_bufs_irq;
59+
hw_coal = &bp->tx_coal;
60+
mult = hw_coal->bufs_per_record;
61+
coal->tx_coalesce_usecs = hw_coal->coal_ticks;
62+
coal->tx_max_coalesced_frames = hw_coal->coal_bufs / mult;
63+
coal->tx_coalesce_usecs_irq = hw_coal->coal_ticks_irq;
64+
coal->tx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult;
6065

6166
coal->stats_block_coalesce_usecs = bp->stats_coal_ticks;
6267

@@ -68,18 +73,23 @@ static int bnxt_set_coalesce(struct net_device *dev,
6873
{
6974
struct bnxt *bp = netdev_priv(dev);
7075
bool update_stats = false;
76+
struct bnxt_coal *hw_coal;
7177
int rc = 0;
72-
73-
bp->rx_coal_ticks = coal->rx_coalesce_usecs;
74-
/* 2 completion records per rx packet */
75-
bp->rx_coal_bufs = coal->rx_max_coalesced_frames * 2;
76-
bp->rx_coal_ticks_irq = coal->rx_coalesce_usecs_irq;
77-
bp->rx_coal_bufs_irq = coal->rx_max_coalesced_frames_irq * 2;
78-
79-
bp->tx_coal_ticks = coal->tx_coalesce_usecs;
80-
bp->tx_coal_bufs = coal->tx_max_coalesced_frames;
81-
bp->tx_coal_ticks_irq = coal->tx_coalesce_usecs_irq;
82-
bp->tx_coal_bufs_irq = coal->tx_max_coalesced_frames_irq;
78+
u16 mult;
79+
80+
hw_coal = &bp->rx_coal;
81+
mult = hw_coal->bufs_per_record;
82+
hw_coal->coal_ticks = coal->rx_coalesce_usecs;
83+
hw_coal->coal_bufs = coal->rx_max_coalesced_frames * mult;
84+
hw_coal->coal_ticks_irq = coal->rx_coalesce_usecs_irq;
85+
hw_coal->coal_bufs_irq = coal->rx_max_coalesced_frames_irq * mult;
86+
87+
hw_coal = &bp->rx_coal;
88+
mult = hw_coal->bufs_per_record;
89+
hw_coal->coal_ticks = coal->tx_coalesce_usecs;
90+
hw_coal->coal_bufs = coal->tx_max_coalesced_frames * mult;
91+
hw_coal->coal_ticks_irq = coal->tx_coalesce_usecs_irq;
92+
hw_coal->coal_bufs_irq = coal->tx_max_coalesced_frames_irq * mult;
8393

8494
if (bp->stats_coal_ticks != coal->stats_block_coalesce_usecs) {
8595
u32 stats_ticks = coal->stats_block_coalesce_usecs;

0 commit comments

Comments
 (0)