Commit dfb5b894 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Store irq coalescing timer values in micro seconds.

Don't convert these to internal hardware tick values before storing
them.  This avoids the confusion of ethtool -c returning slightly
different values than the ones set using ethtool -C when we convert
hardware tick values back to micro seconds.  Add better comments for
the hardware settings.

Also, rename the current set of coalescing fields with rx_ prefix.
The next patch will add support of tx coalescing values.
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 19241368
...@@ -3532,20 +3532,25 @@ int bnxt_hwrm_set_coal(struct bnxt *bp) ...@@ -3532,20 +3532,25 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS, bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS,
-1, -1); -1, -1);
/* Each rx completion (2 records) should be DMAed immediately */ /* Each rx completion (2 records) should be DMAed immediately.
max_buf = min_t(u16, bp->coal_bufs / 4, 2); * DMA 1/4 of the completion buffers at a time.
*/
max_buf = min_t(u16, bp->rx_coal_bufs / 4, 2);
/* max_buf must not be zero */ /* max_buf must not be zero */
max_buf = clamp_t(u16, max_buf, 1, 63); max_buf = clamp_t(u16, max_buf, 1, 63);
max_buf_irq = clamp_t(u16, bp->coal_bufs_irq, 1, 63); max_buf_irq = clamp_t(u16, bp->rx_coal_bufs_irq, 1, 63);
buf_tmr = max_t(u16, bp->coal_ticks / 4, 1); buf_tmr = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal_ticks);
buf_tmr_irq = max_t(u16, bp->coal_ticks_irq, 1); /* buf timer set to 1/4 of interrupt timer */
buf_tmr = max_t(u16, buf_tmr / 4, 1);
buf_tmr_irq = BNXT_USEC_TO_COAL_TIMER(bp->rx_coal_ticks_irq);
buf_tmr_irq = max_t(u16, buf_tmr_irq, 1);
flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET; flags = RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_TIMER_RESET;
/* RING_IDLE generates more IRQs for lower latency. Enable it only /* RING_IDLE generates more IRQs for lower latency. Enable it only
* if coal_ticks is less than 25 us. * if coal_ticks is less than 25 us.
*/ */
if (BNXT_COAL_TIMER_TO_USEC(bp->coal_ticks) < 25) if (bp->rx_coal_ticks < 25)
flags |= RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_RING_IDLE; flags |= RING_CMPL_RING_CFG_AGGINT_PARAMS_REQ_FLAGS_RING_IDLE;
req.flags = cpu_to_le16(flags); req.flags = cpu_to_le16(flags);
...@@ -3553,9 +3558,10 @@ int bnxt_hwrm_set_coal(struct bnxt *bp) ...@@ -3553,9 +3558,10 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
req.num_cmpl_dma_aggr_during_int = cpu_to_le16(max_buf_irq); req.num_cmpl_dma_aggr_during_int = cpu_to_le16(max_buf_irq);
req.cmpl_aggr_dma_tmr = cpu_to_le16(buf_tmr); req.cmpl_aggr_dma_tmr = cpu_to_le16(buf_tmr);
req.cmpl_aggr_dma_tmr_during_int = cpu_to_le16(buf_tmr_irq); req.cmpl_aggr_dma_tmr_during_int = cpu_to_le16(buf_tmr_irq);
req.int_lat_tmr_min = cpu_to_le16(buf_tmr); /* Minimum time between 2 interrupts set to buf_tmr x 2 */
req.int_lat_tmr_max = cpu_to_le16(bp->coal_ticks); req.int_lat_tmr_min = cpu_to_le16(buf_tmr * 2);
req.num_cmpl_aggr_int = cpu_to_le16(bp->coal_bufs); req.int_lat_tmr_max = cpu_to_le16(buf_tmr * 4);
req.num_cmpl_aggr_int = cpu_to_le16(max_buf * 4);
mutex_lock(&bp->hwrm_cmd_lock); mutex_lock(&bp->hwrm_cmd_lock);
for (i = 0; i < bp->cp_nr_rings; i++) { for (i = 0; i < bp->cp_nr_rings; i++) {
...@@ -5295,10 +5301,11 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) ...@@ -5295,10 +5301,11 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE; bp->rx_ring_size = BNXT_DEFAULT_RX_RING_SIZE;
bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE; bp->tx_ring_size = BNXT_DEFAULT_TX_RING_SIZE;
bp->coal_ticks = BNXT_USEC_TO_COAL_TIMER(4); /* tick values in micro seconds */
bp->coal_bufs = 20; bp->rx_coal_ticks = 4;
bp->coal_ticks_irq = BNXT_USEC_TO_COAL_TIMER(1); bp->rx_coal_bufs = 20;
bp->coal_bufs_irq = 2; bp->rx_coal_ticks_irq = 1;
bp->rx_coal_bufs_irq = 2;
init_timer(&bp->timer); init_timer(&bp->timer);
bp->timer.data = (unsigned long)bp; bp->timer.data = (unsigned long)bp;
......
...@@ -968,13 +968,12 @@ struct bnxt { ...@@ -968,13 +968,12 @@ struct bnxt {
__le16 vxlan_fw_dst_port_id; __le16 vxlan_fw_dst_port_id;
u8 nge_port_cnt; u8 nge_port_cnt;
__le16 nge_fw_dst_port_id; __le16 nge_fw_dst_port_id;
u16 coal_ticks; u16 rx_coal_ticks;
u16 coal_ticks_irq; u16 rx_coal_ticks_irq;
u16 coal_bufs; u16 rx_coal_bufs;
u16 coal_bufs_irq; u16 rx_coal_bufs_irq;
#define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2) #define BNXT_USEC_TO_COAL_TIMER(x) ((x) * 25 / 2)
#define BNXT_COAL_TIMER_TO_USEC(x) ((x) * 2 / 25)
struct work_struct sp_task; struct work_struct sp_task;
unsigned long sp_event; unsigned long sp_event;
......
...@@ -41,12 +41,11 @@ static int bnxt_get_coalesce(struct net_device *dev, ...@@ -41,12 +41,11 @@ static int bnxt_get_coalesce(struct net_device *dev,
memset(coal, 0, sizeof(*coal)); memset(coal, 0, sizeof(*coal));
coal->rx_coalesce_usecs = coal->rx_coalesce_usecs = bp->rx_coal_ticks;
max_t(u16, BNXT_COAL_TIMER_TO_USEC(bp->coal_ticks), 1); /* 2 completion records per rx packet */
coal->rx_max_coalesced_frames = bp->coal_bufs / 2; coal->rx_max_coalesced_frames = bp->rx_coal_bufs / 2;
coal->rx_coalesce_usecs_irq = coal->rx_coalesce_usecs_irq = bp->rx_coal_ticks_irq;
max_t(u16, BNXT_COAL_TIMER_TO_USEC(bp->coal_ticks_irq), 1); coal->rx_max_coalesced_frames_irq = bp->rx_coal_bufs_irq / 2;
coal->rx_max_coalesced_frames_irq = bp->coal_bufs_irq / 2;
return 0; return 0;
} }
...@@ -57,11 +56,11 @@ static int bnxt_set_coalesce(struct net_device *dev, ...@@ -57,11 +56,11 @@ static int bnxt_set_coalesce(struct net_device *dev,
struct bnxt *bp = netdev_priv(dev); struct bnxt *bp = netdev_priv(dev);
int rc = 0; int rc = 0;
bp->coal_ticks = BNXT_USEC_TO_COAL_TIMER(coal->rx_coalesce_usecs); bp->rx_coal_ticks = coal->rx_coalesce_usecs;
bp->coal_bufs = coal->rx_max_coalesced_frames * 2; /* 2 completion records per rx packet */
bp->coal_ticks_irq = bp->rx_coal_bufs = coal->rx_max_coalesced_frames * 2;
BNXT_USEC_TO_COAL_TIMER(coal->rx_coalesce_usecs_irq); bp->rx_coal_ticks_irq = coal->rx_coalesce_usecs_irq;
bp->coal_bufs_irq = coal->rx_max_coalesced_frames_irq * 2; bp->rx_coal_bufs_irq = coal->rx_max_coalesced_frames_irq * 2;
if (netif_running(dev)) if (netif_running(dev))
rc = bnxt_hwrm_set_coal(bp); rc = bnxt_hwrm_set_coal(bp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment