From 70ada0c508c1aa2e9556e9ef4acca7fd740e1f1e Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Fri, 17 Sep 2021 22:43:18 +0800 Subject: [PATCH] net/ice/base: add helper function to aggregate flags Add internal helper function ice_xlt_kb_flg_get to aggregate 64 bit packet flag into 16 bit key builder flags. Signed-off-by: Qi Zhang Acked-by: Junfeng Guo --- drivers/net/ice/base/ice_xlt_kb.c | 27 +++++++++++++++++++++++++++ drivers/net/ice/base/ice_xlt_kb.h | 1 + 2 files changed, 28 insertions(+) diff --git a/drivers/net/ice/base/ice_xlt_kb.c b/drivers/net/ice/base/ice_xlt_kb.c index 8b4043a836..4c1ab747cf 100644 --- a/drivers/net/ice/base/ice_xlt_kb.c +++ b/drivers/net/ice/base/ice_xlt_kb.c @@ -187,3 +187,30 @@ struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw) { return _xlt_kb_get(hw, ICE_SID_XLT_KEY_BUILDER_RSS); } + +/** + * ice_xlt_kb_flag_get - aggregate 64 bits packet flag into 16 bits xlt flag + * @kb: xlt key build + * @pkt_flag: 64 bits packet flag + */ +u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag) +{ + struct ice_xlt_kb_entry *entry = &kb->entries[0]; + u16 flg = 0; + int i; + + /* check flag 15 */ + if (kb->flag15 & pkt_flag) + flg = (u16)(1u << 15); + + /* check flag 0 - 14 */ + for (i = 0; i < 15; i++) { + /* only check first entry */ + u16 idx = (u16)(entry->flg0_14_sel[i] & 0x3f); + + if (pkt_flag & (1ul << idx)) + flg |= (u16)(1u << i); + } + + return flg; +} diff --git a/drivers/net/ice/base/ice_xlt_kb.h b/drivers/net/ice/base/ice_xlt_kb.h index a95d845f89..ec802b663a 100644 --- a/drivers/net/ice/base/ice_xlt_kb.h +++ b/drivers/net/ice/base/ice_xlt_kb.h @@ -30,4 +30,5 @@ struct ice_xlt_kb *ice_xlt_kb_get_sw(struct ice_hw *hw); struct ice_xlt_kb *ice_xlt_kb_get_acl(struct ice_hw *hw); struct ice_xlt_kb *ice_xlt_kb_get_fd(struct ice_hw *hw); struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw); +u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag); #endif /* _ICE_XLT_KB_H */ -- 2.20.1