提交 80cf1130 编写于 作者: Y Yunsheng Lin 提交者: Xie XiuQi

net: hns3: refactor hns3_get_new_int_gl function

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

This patch adds a new hns3_get_new_flow_lvl function to calculate
the packet flow level, which is used to decide the interrupt
coalescence parameter, in order to make the flow level calculation
code more readable and make the future calculation ajdustment easier.
Signed-off-by: NYunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 75977f4d
......@@ -3036,18 +3036,37 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget,
return recv_pkts;
}
static enum hns3_flow_level_range hns3_get_new_flow_level(
struct hns3_enet_ring_group *ring_group,
enum hns3_flow_level_range new_flow_level,
int packets_per_msecs, int bytes_per_msecs)
static bool hns3_get_new_flow_lvl(struct hns3_enet_ring_group *ring_group)
{
struct hns3_enet_tqp_vector *tqp_vector =
ring_group->ring->tqp_vector;
#define HNS3_RX_LOW_BYTE_RATE 10000
#define HNS3_RX_MID_BYTE_RATE 20000
#define HNS3_RX_ULTRA_PACKET_RATE 40
enum hns3_flow_level_range new_flow_level;
struct hns3_enet_tqp_vector *tqp_vector;
int packets_per_msecs, bytes_per_msecs;
u32 time_passed_ms;
tqp_vector = ring_group->ring->tqp_vector;
time_passed_ms =
jiffies_to_msecs(jiffies - tqp_vector->last_jiffies);
if (!time_passed_ms)
return false;
do_div(ring_group->total_packets, time_passed_ms);
packets_per_msecs = ring_group->total_packets;
do_div(ring_group->total_bytes, time_passed_ms);
bytes_per_msecs = ring_group->total_bytes;
new_flow_level = ring_group->coal.flow_level;
/* Simple throttlerate management
* 0-10MB/s lower (50000 ints/s)
* 10-20MB/s middle (20000 ints/s)
* 20-1249MB/s high (18000 ints/s)
* > 40000pps ultra (8000 ints/s)
*/
switch (new_flow_level) {
case HNS3_FLOW_LOW:
if (bytes_per_msecs > HNS3_RX_LOW_BYTE_RATE)
......@@ -3067,25 +3086,23 @@ static enum hns3_flow_level_range hns3_get_new_flow_level(
break;
}
#define HNS3_RX_ULTRA_PACKET_RATE 40
if (packets_per_msecs > HNS3_RX_ULTRA_PACKET_RATE &&
&tqp_vector->rx_group == ring_group)
new_flow_level = HNS3_FLOW_ULTRA;
return new_flow_level;
ring_group->total_bytes = 0;
ring_group->total_packets = 0;
ring_group->coal.flow_level = new_flow_level;
return true;
}
static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group)
{
struct hns3_enet_tqp_vector *tqp_vector =
ring_group->ring->tqp_vector;
enum hns3_flow_level_range new_flow_level;
int packets_per_msecs;
int bytes_per_msecs;
u32 time_passed_ms;
struct hns3_enet_tqp_vector *tqp_vector;
u16 new_int_gl;
tqp_vector = ring_group->ring->tqp_vector;
if (!tqp_vector->last_jiffies)
return false;
......@@ -3095,30 +3112,11 @@ static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group)
return true;
}
/* Simple throttlerate management
* 0-10MB/s lower (50000 ints/s)
* 10-20MB/s middle (20000 ints/s)
* 20-1249MB/s high (18000 ints/s)
* > 40000pps ultra (8000 ints/s)
*/
new_flow_level = ring_group->coal.flow_level;
new_int_gl = ring_group->coal.int_gl;
time_passed_ms =
jiffies_to_msecs(jiffies - tqp_vector->last_jiffies);
if (!time_passed_ms)
if (!hns3_get_new_flow_lvl(ring_group))
return false;
do_div(ring_group->total_packets, time_passed_ms);
packets_per_msecs = ring_group->total_packets;
do_div(ring_group->total_bytes, time_passed_ms);
bytes_per_msecs = ring_group->total_bytes;
new_flow_level = hns3_get_new_flow_level(ring_group, new_flow_level,
packets_per_msecs,
bytes_per_msecs);
switch (new_flow_level) {
new_int_gl = ring_group->coal.int_gl;
switch (ring_group->coal.flow_level) {
case HNS3_FLOW_LOW:
new_int_gl = HNS3_INT_GL_50K;
break;
......@@ -3135,9 +3133,6 @@ static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group)
break;
}
ring_group->total_bytes = 0;
ring_group->total_packets = 0;
ring_group->coal.flow_level = new_flow_level;
if (new_int_gl != ring_group->coal.int_gl) {
ring_group->coal.int_gl = new_int_gl;
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册