1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2019 Hisilicon Limited.
7 #include <rte_ethdev.h>
10 #define HNS3_ETH_RSS_SUPPORT ( \
12 ETH_RSS_NONFRAG_IPV4_TCP | \
13 ETH_RSS_NONFRAG_IPV4_UDP | \
14 ETH_RSS_NONFRAG_IPV4_SCTP | \
15 ETH_RSS_NONFRAG_IPV4_OTHER | \
17 ETH_RSS_NONFRAG_IPV6_TCP | \
18 ETH_RSS_NONFRAG_IPV6_UDP | \
19 ETH_RSS_NONFRAG_IPV6_SCTP | \
20 ETH_RSS_NONFRAG_IPV6_OTHER)
22 #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */
23 #define HNS3_RSS_KEY_SIZE 40
24 #define HNS3_RSS_CFG_TBL_NUM \
25 (HNS3_RSS_IND_TBL_SIZE / HNS3_RSS_CFG_TBL_SIZE)
26 #define HNS3_RSS_SET_BITMAP_MSK 0xffff
28 #define HNS3_RSS_HASH_ALGO_TOEPLITZ 0
29 #define HNS3_RSS_HASH_ALGO_SIMPLE 1
30 #define HNS3_RSS_HASH_ALGO_SYMMETRIC 2
31 #define HNS3_RSS_HASH_ALGO_MASK 0xf
33 #define HNS3_RSS_INPUT_TUPLE_OTHER GENMASK(3, 0)
34 #define HNS3_RSS_INPUT_TUPLE_SCTP GENMASK(4, 0)
35 #define HNS3_IP_FRAG_BIT_MASK GENMASK(3, 2)
36 #define HNS3_IP_OTHER_BIT_MASK GENMASK(1, 0)
38 struct hns3_rss_tuple_cfg {
39 uint8_t ipv4_tcp_en; /* Bit8.0~8.3 */
40 uint8_t ipv4_udp_en; /* Bit9.0~9.3 */
41 uint8_t ipv4_sctp_en; /* Bit10.0~10.4 */
42 uint8_t ipv4_fragment_en; /* Bit11.0~11.3 */
43 uint8_t ipv6_tcp_en; /* Bit12.0~12.3 */
44 uint8_t ipv6_udp_en; /* Bit13.0~13.3 */
45 uint8_t ipv6_sctp_en; /* Bit14.0~14.4 */
46 uint8_t ipv6_fragment_en; /* Bit15.0~15.3 */
49 #define HNS3_RSS_QUEUES_BUFFER_NUM 64 /* Same as the Max rx/tx queue num */
50 struct hns3_rss_conf {
51 /* RSS parameters :algorithm, flow_types, key, queue */
52 struct rte_flow_action_rss conf;
53 uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */
54 struct hns3_rss_tuple_cfg rss_tuple_sets;
55 uint8_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; /* Shadow table */
56 uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
60 #define HNS3_INSET_IPV4_SRC 0x00000100UL
61 #define HNS3_INSET_IPV4_DST 0x00000200UL
62 #define HNS3_INSET_IPV6_SRC 0x00000400UL
63 #define HNS3_INSET_IPV6_DST 0x00000800UL
64 #define HNS3_INSET_SRC_PORT 0x00001000UL
65 #define HNS3_INSET_DST_PORT 0x00002000UL
66 #define HNS3_INSET_SCTP_VT 0x00004000UL
69 static inline int rss_ilog2(uint32_t x)
80 #define ilog2(x) rss_ilog2(x)
83 static inline uint32_t fls(uint32_t x)
91 for (i = (x >> 1), position = 0; i != 0; ++position)
97 static inline uint32_t roundup_pow_of_two(uint32_t x)
99 return 1UL << fls(x - 1);
104 int hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
105 struct rte_eth_rss_conf *rss_conf);
106 int hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
107 struct rte_eth_rss_conf *rss_conf);
108 int hns3_dev_rss_reta_update(struct rte_eth_dev *dev,
109 struct rte_eth_rss_reta_entry64 *reta_conf,
111 int hns3_dev_rss_reta_query(struct rte_eth_dev *dev,
112 struct rte_eth_rss_reta_entry64 *reta_conf,
114 void hns3_set_default_rss_args(struct hns3_hw *hw);
115 int hns3_set_rss_indir_table(struct hns3_hw *hw, uint8_t *indir, uint16_t size);
116 int hns3_rss_reset_indir_table(struct hns3_hw *hw);
117 int hns3_config_rss(struct hns3_adapter *hns);
118 void hns3_rss_uninit(struct hns3_adapter *hns);
119 int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
120 struct hns3_rss_tuple_cfg *tuple,
122 int hns3_set_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo,
124 #endif /* _HNS3_RSS_H_ */