hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_STASH_B, 1);
}
+static uint32_t
+hns3_build_api_caps(void)
+{
+ uint32_t api_caps = 0;
+
+ hns3_set_bit(api_caps, HNS3_API_CAP_FLEX_RSS_TBL_B, 1);
+
+ return rte_cpu_to_le_32(api_caps);
+}
+
static enum hns3_cmd_status
hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw)
{
hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_FW_VER, 1);
resp = (struct hns3_query_version_cmd *)desc.data;
+ resp->api_caps = hns3_build_api_caps();
/* Initialize the cmd function */
ret = hns3_cmd_send(hw, &desc, 1);
HNS3_CAPS_HW_PAD_B,
HNS3_CAPS_STASH_B,
};
+
+enum HNS3_API_CAP_BITS {
+ HNS3_API_CAP_FLEX_RSS_TBL_B,
+};
+
#define HNS3_QUERY_CAP_LENGTH 3
struct hns3_query_version_cmd {
uint32_t firmware;
uint32_t hardware;
- uint32_t rsv;
+ uint32_t api_caps;
uint32_t caps[HNS3_QUERY_CAP_LENGTH]; /* capabilities of device */
};
* stage of the reset process.
*/
if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) {
- for (i = 0; i < HNS3_RSS_IND_TBL_SIZE; i++)
+ for (i = 0; i < hw->rss_ind_tbl_size; i++)
rss_cfg->rss_indirection_tbl[i] =
i % hw->alloc_rss_size;
}
info->vmdq_queue_num = 0;
- info->reta_size = HNS3_RSS_IND_TBL_SIZE;
+ info->reta_size = hw->rss_ind_tbl_size;
info->hash_key_size = HNS3_RSS_KEY_SIZE;
info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT;
hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max);
}
+static int
+hns3_check_dev_specifications(struct hns3_hw *hw)
+{
+ if (hw->rss_ind_tbl_size == 0 ||
+ hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) {
+ hns3_err(hw, "the size of hash lookup table configured (%u)"
+ " exceeds the maximum(%u)", hw->rss_ind_tbl_size,
+ HNS3_RSS_IND_TBL_SIZE_MAX);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int
hns3_query_dev_specifications(struct hns3_hw *hw)
{
hns3_parse_dev_specifications(hw, desc);
- return 0;
+ return hns3_check_dev_specifications(hw);
}
static int
info->vmdq_queue_num = 0;
- info->reta_size = HNS3_RSS_IND_TBL_SIZE;
+ info->reta_size = hw->rss_ind_tbl_size;
info->hash_key_size = HNS3_RSS_KEY_SIZE;
info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT;
info->default_rxportconf.ring_size = HNS3_DEFAULT_RING_DESC;
hw->intr.int_ql_max = rte_le_to_cpu_16(req0->intr_ql_max);
}
+static int
+hns3vf_check_dev_specifications(struct hns3_hw *hw)
+{
+ if (hw->rss_ind_tbl_size == 0 ||
+ hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) {
+ hns3_warn(hw, "the size of hash lookup table configured (%u)"
+ " exceeds the maximum(%u)", hw->rss_ind_tbl_size,
+ HNS3_RSS_IND_TBL_SIZE_MAX);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int
hns3vf_query_dev_specifications(struct hns3_hw *hw)
{
hns3vf_parse_dev_specifications(hw, desc);
- return 0;
+ return hns3vf_check_dev_specifications(hw);
}
static int
{
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE];
+ uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
uint16_t j;
uint32_t i;
/* Fill in redirection table */
memcpy(indir_tbl, hw->rss_info.rss_indirection_tbl,
sizeof(hw->rss_info.rss_indirection_tbl));
- for (i = 0, j = 0; i < HNS3_RSS_IND_TBL_SIZE; i++, j++) {
+ for (i = 0, j = 0; i < hw->rss_ind_tbl_size; i++, j++) {
j %= num;
if (conf->queue[j] >= hw->alloc_rss_size) {
hns3_err(hw, "queue id(%u) set to redirection table "
indir_tbl[i] = conf->queue[j];
}
- return hns3_set_rss_indir_table(hw, indir_tbl, HNS3_RSS_IND_TBL_SIZE);
+ return hns3_set_rss_indir_table(hw, indir_tbl, hw->rss_ind_tbl_size);
}
static int
/* Update redirection table of hw */
memcpy(hw->rss_info.rss_indirection_tbl, indir,
- sizeof(hw->rss_info.rss_indirection_tbl));
+ sizeof(uint16_t) * size);
return 0;
}
int ret;
lut = rte_zmalloc("hns3_rss_lut",
- HNS3_RSS_IND_TBL_SIZE * sizeof(uint16_t), 0);
+ hw->rss_ind_tbl_size * sizeof(uint16_t), 0);
if (lut == NULL) {
hns3_err(hw, "No hns3_rss_lut memory can be allocated");
return -ENOMEM;
}
- ret = hns3_set_rss_indir_table(hw, lut, HNS3_RSS_IND_TBL_SIZE);
+ ret = hns3_set_rss_indir_table(hw, lut, hw->rss_ind_tbl_size);
if (ret)
hns3_err(hw, "RSS uninit indir table failed: %d", ret);
rte_free(lut);
} else if (rss_hf && rss_cfg->conf.types == 0) {
/* Enable RSS, restore indirection table by hw's config */
ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
- HNS3_RSS_IND_TBL_SIZE);
+ hw->rss_ind_tbl_size);
if (ret)
goto conf_err;
}
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_conf *rss_cfg = &hw->rss_info;
- uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */
- uint16_t indirection_tbl[HNS3_RSS_IND_TBL_SIZE];
+ uint16_t indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
uint16_t idx, shift;
+ uint16_t i;
int ret;
- if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) {
+ if (reta_size != hw->rss_ind_tbl_size) {
hns3_err(hw, "The size of hash lookup table configured (%u)"
"doesn't match the number hardware can supported"
- "(%u)", reta_size, indir_size);
+ "(%u)", reta_size, hw->rss_ind_tbl_size);
return -EINVAL;
}
rte_spinlock_lock(&hw->lock);
}
ret = hns3_set_rss_indir_table(hw, indirection_tbl,
- HNS3_RSS_IND_TBL_SIZE);
+ hw->rss_ind_tbl_size);
rte_spinlock_unlock(&hw->lock);
return ret;
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_conf *rss_cfg = &hw->rss_info;
- uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */
uint16_t idx, shift;
+ uint16_t i;
- if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) {
+ if (reta_size != hw->rss_ind_tbl_size) {
hns3_err(hw, "The size of hash lookup table configured (%u)"
" doesn't match the number hardware can supported"
- "(%u)", reta_size, indir_size);
+ "(%u)", reta_size, hw->rss_ind_tbl_size);
return -EINVAL;
}
rte_spinlock_lock(&hw->lock);
memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE);
/* Initialize RSS indirection table */
- for (i = 0; i < HNS3_RSS_IND_TBL_SIZE; i++)
+ for (i = 0; i < hw->rss_ind_tbl_size; i++)
rss_cfg->rss_indirection_tbl[i] = i % queue_num;
}
*/
if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG)) {
ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
- HNS3_RSS_IND_TBL_SIZE);
+ hw->rss_ind_tbl_size);
if (ret)
goto rss_tuple_uninit;
}
ETH_RSS_L4_DST_ONLY)
#define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */
+#define HNS3_RSS_IND_TBL_SIZE_MAX 2048
#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
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 rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
bool valid; /* check if RSS rule is valid */
/*