mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
7c2ce6e60f
This patch adds support for adaptive interrupt coalescing. For small pkts with low pkt rate, we can decrease the coalescing interrupt dynamically which decreases the latency. This however increases the cpu utilization. Based on testing with different coal intr and pkt rate we came up with a table(mod_table) with rx_rate and coalescing interrupt value where we get low latency without significant increase in cpu. mod_table table stores the coalescing timer percentage value for different throughputs. Function enic_calc_int_moderation() calculates the desired coalescing intr timer value. This function is called in driver rx napi_poll. The actual value is set by enic_set_int_moderation() which is called when napi_poll is complete. i.e when we unmask the rx intr. Adaptive coal intr is support only when driver is using msix intr. Because intr is not shared. Struct mod_range is used to store only the default adaptive coalescing intr value. Adaptive coal intr calue is calculated by timer = range_start + ((rx_coal->range_end - range_start) * mod_table[index].range_percent / 100); rx_coal->range_end is the rx-usecs-high value set using ethtool. range_start is rx-usecs-low, set using ethtool, if rx_small_pkt_bytes_cnt is greater than 2 * rx_large_pkt_bytes_cnt. i.e small pkts are dominant. Else its rx-usecs-low + 3. Cc: Christian Benvenuti <benve@cisco.com> Cc: Neel Patel <neepatel@cisco.com> Signed-off-by: Sujith Sankar <ssujith@cisco.com> Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com> Signed-off-by: David S. Miller <davem@davemloft.net>
124 lines
3.4 KiB
C
124 lines
3.4 KiB
C
/*
|
|
* Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
|
|
* Copyright 2007 Nuova Systems, Inc. All rights reserved.
|
|
*
|
|
* This program is free software; you may redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
#ifndef _VNIC_CQ_H_
|
|
#define _VNIC_CQ_H_
|
|
|
|
#include "cq_desc.h"
|
|
#include "vnic_dev.h"
|
|
|
|
/* Completion queue control */
|
|
struct vnic_cq_ctrl {
|
|
u64 ring_base; /* 0x00 */
|
|
u32 ring_size; /* 0x08 */
|
|
u32 pad0;
|
|
u32 flow_control_enable; /* 0x10 */
|
|
u32 pad1;
|
|
u32 color_enable; /* 0x18 */
|
|
u32 pad2;
|
|
u32 cq_head; /* 0x20 */
|
|
u32 pad3;
|
|
u32 cq_tail; /* 0x28 */
|
|
u32 pad4;
|
|
u32 cq_tail_color; /* 0x30 */
|
|
u32 pad5;
|
|
u32 interrupt_enable; /* 0x38 */
|
|
u32 pad6;
|
|
u32 cq_entry_enable; /* 0x40 */
|
|
u32 pad7;
|
|
u32 cq_message_enable; /* 0x48 */
|
|
u32 pad8;
|
|
u32 interrupt_offset; /* 0x50 */
|
|
u32 pad9;
|
|
u64 cq_message_addr; /* 0x58 */
|
|
u32 pad10;
|
|
};
|
|
|
|
struct vnic_rx_bytes_counter {
|
|
unsigned int small_pkt_bytes_cnt;
|
|
unsigned int large_pkt_bytes_cnt;
|
|
};
|
|
|
|
struct vnic_cq {
|
|
unsigned int index;
|
|
struct vnic_dev *vdev;
|
|
struct vnic_cq_ctrl __iomem *ctrl; /* memory-mapped */
|
|
struct vnic_dev_ring ring;
|
|
unsigned int to_clean;
|
|
unsigned int last_color;
|
|
unsigned int interrupt_offset;
|
|
struct vnic_rx_bytes_counter pkt_size_counter;
|
|
unsigned int cur_rx_coal_timeval;
|
|
unsigned int tobe_rx_coal_timeval;
|
|
ktime_t prev_ts;
|
|
};
|
|
|
|
static inline unsigned int vnic_cq_service(struct vnic_cq *cq,
|
|
unsigned int work_to_do,
|
|
int (*q_service)(struct vnic_dev *vdev, struct cq_desc *cq_desc,
|
|
u8 type, u16 q_number, u16 completed_index, void *opaque),
|
|
void *opaque)
|
|
{
|
|
struct cq_desc *cq_desc;
|
|
unsigned int work_done = 0;
|
|
u16 q_number, completed_index;
|
|
u8 type, color;
|
|
|
|
cq_desc = (struct cq_desc *)((u8 *)cq->ring.descs +
|
|
cq->ring.desc_size * cq->to_clean);
|
|
cq_desc_dec(cq_desc, &type, &color,
|
|
&q_number, &completed_index);
|
|
|
|
while (color != cq->last_color) {
|
|
|
|
if ((*q_service)(cq->vdev, cq_desc, type,
|
|
q_number, completed_index, opaque))
|
|
break;
|
|
|
|
cq->to_clean++;
|
|
if (cq->to_clean == cq->ring.desc_count) {
|
|
cq->to_clean = 0;
|
|
cq->last_color = cq->last_color ? 0 : 1;
|
|
}
|
|
|
|
cq_desc = (struct cq_desc *)((u8 *)cq->ring.descs +
|
|
cq->ring.desc_size * cq->to_clean);
|
|
cq_desc_dec(cq_desc, &type, &color,
|
|
&q_number, &completed_index);
|
|
|
|
work_done++;
|
|
if (work_done >= work_to_do)
|
|
break;
|
|
}
|
|
|
|
return work_done;
|
|
}
|
|
|
|
void vnic_cq_free(struct vnic_cq *cq);
|
|
int vnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, unsigned int index,
|
|
unsigned int desc_count, unsigned int desc_size);
|
|
void vnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable,
|
|
unsigned int color_enable, unsigned int cq_head, unsigned int cq_tail,
|
|
unsigned int cq_tail_color, unsigned int interrupt_enable,
|
|
unsigned int cq_entry_enable, unsigned int message_enable,
|
|
unsigned int interrupt_offset, u64 message_addr);
|
|
void vnic_cq_clean(struct vnic_cq *cq);
|
|
|
|
#endif /* _VNIC_CQ_H_ */
|