diff options
author | HsiuWen Yen <y.hsiuwen@gmail.com> | 2019-01-07 16:29:35 +0800 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2019-01-07 15:40:51 +0100 |
commit | 6b9bdbd4935d3a9c8f22dde5d84abd173a1573ce (patch) | |
tree | c2f91c461ef725fde133b3f349cd08545949d07a /target/linux/ramips/files-4.14/drivers/net | |
parent | b3664bc7028b5c628e973e0b0f6dd9611067d78f (diff) | |
download | upstream-6b9bdbd4935d3a9c8f22dde5d84abd173a1573ce.tar.gz upstream-6b9bdbd4935d3a9c8f22dde5d84abd173a1573ce.tar.bz2 upstream-6b9bdbd4935d3a9c8f22dde5d84abd173a1573ce.zip |
ramips: add two-way hashing scheme for MT7621
Sometimes the tuples might be hashed to the same FOE entry.
When this hash collision problem occurs, some of the
connections will not be bound and consequently the CPU
idle rate cannot reach 100%. Therefore, two-way hashing
is adopted to alleviate this problem.
Signed-off-by: HsiuWen Yen <y.hsiuwen@gmail.com>
Diffstat (limited to 'target/linux/ramips/files-4.14/drivers/net')
-rw-r--r-- | target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c index 3001c081f7..d0d0790ad9 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c @@ -118,6 +118,13 @@ mtk_foe_set_mac(struct mtk_foe_entry *entry, u8 *smac, u8 *dmac) entry->ipv4_hnapt.smac_lo = swab16(*((u16*) &smac[4])); } +static int +mtk_check_hashcollision(struct mtk_eth *eth, u32 hash) +{ + struct mtk_foe_entry entry = ((struct mtk_foe_entry *)eth->foe_table)[hash]; + return (entry.bfib1.state != BIND)? 0:1; +} + static void mtk_foe_write(struct mtk_eth *eth, u32 hash, struct mtk_foe_entry *entry) @@ -173,6 +180,10 @@ int mtk_flow_offload(struct mtk_eth *eth, goto write; } + if(mtk_check_hashcollision(eth, ohash)) // Two-way hash: when hash collision occurs, the hash value will be shifted to the next position. + ohash += 1; + if(mtk_check_hashcollision(eth, rhash)) + rhash += 1; mtk_foe_set_mac(&orig, dest->eth_src, dest->eth_dest); mtk_foe_set_mac(&reply, src->eth_src, src->eth_dest); |