net: hns3: minor optimization for ring_space
This patch optimizes the ring_space by calculating the ring space without calling ring_dist. Also ring_dist is only used by ring_space, so this patch removes it when it is no longer used. Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com> Signed-off-by: Peng Li <lipeng321@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
72110b5674
Коммит
0aa3d88a91
|
@ -577,18 +577,13 @@ union l4_hdr_info {
|
||||||
unsigned char *hdr;
|
unsigned char *hdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* the distance between [begin, end) in a ring buffer
|
|
||||||
* note: there is a unuse slot between the begin and the end
|
|
||||||
*/
|
|
||||||
static inline int ring_dist(struct hns3_enet_ring *ring, int begin, int end)
|
|
||||||
{
|
|
||||||
return (end - begin + ring->desc_num) % ring->desc_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int ring_space(struct hns3_enet_ring *ring)
|
static inline int ring_space(struct hns3_enet_ring *ring)
|
||||||
{
|
{
|
||||||
return ring->desc_num -
|
int begin = ring->next_to_clean;
|
||||||
ring_dist(ring, ring->next_to_clean, ring->next_to_use) - 1;
|
int end = ring->next_to_use;
|
||||||
|
|
||||||
|
return ((end >= begin) ? (ring->desc_num - end + begin) :
|
||||||
|
(begin - end)) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int is_ring_empty(struct hns3_enet_ring *ring)
|
static inline int is_ring_empty(struct hns3_enet_ring *ring)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче