lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <1554260881-44948-6-git-send-email-tanhuazhong@huawei.com> Date: Wed, 3 Apr 2019 11:07:54 +0800 From: Huazhong Tan <tanhuazhong@...wei.com> To: <davem@...emloft.net> CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>, <salil.mehta@...wei.com>, <yisen.zhuang@...wei.com>, <linuxarm@...wei.com>, Yunsheng Lin <linyunsheng@...wei.com>, Peng Li <lipeng321@...wei.com>, Huazhong Tan <tanhuazhong@...wei.com> Subject: [PATCH net-next 05/12] net: hns3: minor optimization for ring_space From: Yunsheng Lin <linyunsheng@...wei.com> 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@...wei.com> Signed-off-by: Peng Li <lipeng321@...wei.com> Signed-off-by: Huazhong Tan <tanhuazhong@...wei.com> --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 75669cd..025d0f7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -577,18 +577,13 @@ union l4_hdr_info { 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) { - return ring->desc_num - - ring_dist(ring, ring->next_to_clean, ring->next_to_use) - 1; + int begin = ring->next_to_clean; + 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) -- 2.7.4
Powered by blists - more mailing lists