Commit 9b476494 authored by Jian Shen's avatar Jian Shen Committed by Paolo Abeni

net: hns3: refine the tcam key convert handle

The result of expression '(k ^ ~v)  & k' is exactly
the same with  'k & v', so simplify it.
(k ^ ~v) & k == k & v
The truth table (in non table form):
k == 0, v == 0:
  (k ^ ~v) & k == (0 ^ ~0) & 0 == (0 ^ 1) & 0 == 1 & 0 == 0
  k & v == 0 & 0 == 0

k == 0, v == 1:
  (k ^ ~v) & k == (0 ^ ~1) & 0 == (0 ^ 0) & 0 == 1 & 0 == 0
  k & v == 0 & 1 == 0

k == 1, v == 0:
  (k ^ ~v) & k == (1 ^ ~0) & 1 == (1 ^ 1) & 1 == 0 & 1 == 0
  k & v == 1 & 0 == 0

k == 1, v == 1:
  (k ^ ~v) & k == (1 ^ ~1) & 1 == (1 ^ 0) & 1 == 1 & 1 == 1
  k & v == 1 & 1 == 1
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent e6988447
...@@ -835,15 +835,10 @@ struct hclge_vf_vlan_cfg { ...@@ -835,15 +835,10 @@ struct hclge_vf_vlan_cfg {
* Then for input key(k) and mask(v), we can calculate the value by * Then for input key(k) and mask(v), we can calculate the value by
* the formulae: * the formulae:
* x = (~k) & v * x = (~k) & v
* y = (k ^ ~v) & k * y = k & v
*/ */
#define calc_x(x, k, v) (x = ~(k) & (v)) #define calc_x(x, k, v) ((x) = ~(k) & (v))
#define calc_y(y, k, v) \ #define calc_y(y, k, v) ((y) = (k) & (v))
do { \
const typeof(k) _k_ = (k); \
const typeof(v) _v_ = (v); \
(y) = (_k_ ^ ~_v_) & (_k_); \
} while (0)
#define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f)) #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
#define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset))) #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment