numam-dpdk/drivers/net/hns3/hns3_rss.h
Huisong Li 9a7d3af22c net/hns3: expand number of queues for one TC up to 512
The maximum number of queues for one TC hns3 PF PMD driver supported is
64 based on hns3 network engine with revision_id equals 0x21, while it
is expanded up to 512 on hns3 network engine with revision_id equals
0x30.

So the following points need to be modified to maintain better
compatibility.
1) Using a extended rss_size_max field as the maximum queue number of
   one TC PF driver supported.
2) The data type of the RSS redirection table needs to be changed from
   uint8_t to uint16_t.
3) rss_tc_mode modification
   The bitwidth of tc_offset, meaning the rx queue index, has to expand
   from 10 bit to 11 bits. The tc_size, meaning the exponent with base 2
   of queues supported on TC, needs to expand from 3 bits to 4 bits.
4) RSS indirection table modification
   Currently, a field with 7 bits width is used to record the queue
   index for RSS indirection table. It means that PF needs to expand the
   queue index field to 9 bits. As the RSS indirection table config
   command reserved 4 bytes to configure the RSS queue index, a extern
   field can be added. So an entries of RSS indirection table queue
   index has two fields to set: rss_result_l and rss_result_h, while
   rss_result_l records the lower 8 bits and rss_result_h records the
   higher 1 bit.

In addition, 2~4 modifications is also compatible with hns3 VF PMD
driver.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
2020-10-08 19:58:10 +02:00

112 lines
3.0 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2018-2019 Hisilicon Limited.
*/
#ifndef _HNS3_RSS_H_
#define _HNS3_RSS_H_
#include <rte_ethdev.h>
#include <rte_flow.h>
#define HNS3_ETH_RSS_SUPPORT ( \
ETH_RSS_FRAG_IPV4 | \
ETH_RSS_NONFRAG_IPV4_TCP | \
ETH_RSS_NONFRAG_IPV4_UDP | \
ETH_RSS_NONFRAG_IPV4_SCTP | \
ETH_RSS_NONFRAG_IPV4_OTHER | \
ETH_RSS_FRAG_IPV6 | \
ETH_RSS_NONFRAG_IPV6_TCP | \
ETH_RSS_NONFRAG_IPV6_UDP | \
ETH_RSS_NONFRAG_IPV6_SCTP | \
ETH_RSS_NONFRAG_IPV6_OTHER | \
ETH_RSS_L3_SRC_ONLY | \
ETH_RSS_L3_DST_ONLY | \
ETH_RSS_L4_SRC_ONLY | \
ETH_RSS_L4_DST_ONLY)
#define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */
#define HNS3_RSS_KEY_SIZE 40
#define HNS3_RSS_CFG_TBL_NUM \
(HNS3_RSS_IND_TBL_SIZE / HNS3_RSS_CFG_TBL_SIZE)
#define HNS3_RSS_SET_BITMAP_MSK 0xffff
#define HNS3_RSS_HASH_ALGO_TOEPLITZ 0
#define HNS3_RSS_HASH_ALGO_SIMPLE 1
#define HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP 2
#define HNS3_RSS_HASH_ALGO_MASK 0xf
struct hns3_rss_tuple_cfg {
uint64_t rss_tuple_fields;
};
#define HNS3_RSS_QUEUES_BUFFER_NUM 64 /* Same as the Max rx/tx queue num */
struct hns3_rss_conf {
/* RSS parameters :algorithm, flow_types, key, queue */
struct rte_flow_action_rss conf;
uint8_t hash_algo; /* hash function type definited by hardware */
uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */
struct hns3_rss_tuple_cfg rss_tuple_sets;
uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; /* Shadow table */
uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
bool valid; /* check if RSS rule is valid */
};
#ifndef ilog2
static inline int rss_ilog2(uint32_t x)
{
int log = 0;
x >>= 1;
while (x) {
log++;
x >>= 1;
}
return log;
}
#define ilog2(x) rss_ilog2(x)
#endif
static inline uint32_t fls(uint32_t x)
{
uint32_t position;
uint32_t i;
if (x == 0)
return 0;
for (i = (x >> 1), position = 0; i != 0; ++position)
i >>= 1;
return position + 1;
}
static inline uint32_t roundup_pow_of_two(uint32_t x)
{
return 1UL << fls(x - 1);
}
struct hns3_adapter;
int hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);
int hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
struct rte_eth_rss_conf *rss_conf);
int hns3_dev_rss_reta_update(struct rte_eth_dev *dev,
struct rte_eth_rss_reta_entry64 *reta_conf,
uint16_t reta_size);
int hns3_dev_rss_reta_query(struct rte_eth_dev *dev,
struct rte_eth_rss_reta_entry64 *reta_conf,
uint16_t reta_size);
void hns3_set_default_rss_args(struct hns3_hw *hw);
int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir,
uint16_t size);
int hns3_rss_reset_indir_table(struct hns3_hw *hw);
int hns3_config_rss(struct hns3_adapter *hns);
void hns3_rss_uninit(struct hns3_adapter *hns);
int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
struct hns3_rss_tuple_cfg *tuple,
uint64_t rss_hf);
int hns3_set_rss_algo_key(struct hns3_hw *hw, const uint8_t *key);
int hns3_restore_rss_filter(struct rte_eth_dev *dev);
#endif /* _HNS3_RSS_H_ */