| 1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 |
// Copyright (c) 2021-2021 Hisilicon Limited. |
| 3 |
|
| 4 |
#ifndef __HCLGE_COMM_RSS_H |
| 5 |
#define __HCLGE_COMM_RSS_H |
| 6 |
#include <linux/types.h> |
| 7 |
|
| 8 |
#include "hnae3.h" |
| 9 |
#include "hclge_comm_cmd.h" |
| 10 |
|
| 11 |
#define HCLGE_COMM_RSS_HASH_ALGO_TOEPLITZ 0 |
| 12 |
#define HCLGE_COMM_RSS_HASH_ALGO_SIMPLE 1 |
| 13 |
#define HCLGE_COMM_RSS_HASH_ALGO_SYMMETRIC 2 |
| 14 |
|
| 15 |
#define HCLGE_COMM_RSS_INPUT_TUPLE_OTHER GENMASK(3, 0) |
| 16 |
#define HCLGE_COMM_RSS_INPUT_TUPLE_SCTP GENMASK(4, 0) |
| 17 |
|
| 18 |
#define HCLGE_COMM_D_PORT_BIT BIT(0) |
| 19 |
#define HCLGE_COMM_S_PORT_BIT BIT(1) |
| 20 |
#define HCLGE_COMM_D_IP_BIT BIT(2) |
| 21 |
#define HCLGE_COMM_S_IP_BIT BIT(3) |
| 22 |
#define HCLGE_COMM_V_TAG_BIT BIT(4) |
| 23 |
#define HCLGE_COMM_RSS_INPUT_TUPLE_SCTP_NO_PORT \ |
| 24 |
(HCLGE_COMM_D_IP_BIT | HCLGE_COMM_S_IP_BIT | HCLGE_COMM_V_TAG_BIT) |
| 25 |
#define HCLGE_COMM_MAX_TC_NUM 8 |
| 26 |
|
| 27 |
#define HCLGE_COMM_RSS_TC_OFFSET_S 0 |
| 28 |
#define HCLGE_COMM_RSS_TC_OFFSET_M GENMASK(10, 0) |
| 29 |
#define HCLGE_COMM_RSS_TC_SIZE_MSB_B 11 |
| 30 |
#define HCLGE_COMM_RSS_TC_SIZE_S 12 |
| 31 |
#define HCLGE_COMM_RSS_TC_SIZE_M GENMASK(14, 12) |
| 32 |
#define HCLGE_COMM_RSS_TC_VALID_B 15 |
| 33 |
#define HCLGE_COMM_RSS_TC_SIZE_MSB_OFFSET 3 |
| 34 |
|
| 35 |
struct hclge_comm_rss_tuple_cfg { |
| 36 |
u8 ipv4_tcp_en; |
| 37 |
u8 ipv4_udp_en; |
| 38 |
u8 ipv4_sctp_en; |
| 39 |
u8 ipv4_fragment_en; |
| 40 |
u8 ipv6_tcp_en; |
| 41 |
u8 ipv6_udp_en; |
| 42 |
u8 ipv6_sctp_en; |
| 43 |
u8 ipv6_fragment_en; |
| 44 |
}; |
| 45 |
|
| 46 |
#define HCLGE_COMM_RSS_KEY_SIZE 40 |
| 47 |
#define HCLGE_COMM_RSS_CFG_TBL_SIZE 16 |
| 48 |
#define HCLGE_COMM_RSS_CFG_TBL_BW_H 2U |
| 49 |
#define HCLGE_COMM_RSS_CFG_TBL_BW_L 8U |
| 50 |
#define HCLGE_COMM_RSS_CFG_TBL_SIZE_H 4 |
| 51 |
#define HCLGE_COMM_RSS_SET_BITMAP_MSK GENMASK(15, 0) |
| 52 |
#define HCLGE_COMM_RSS_HASH_ALGO_MASK GENMASK(3, 0) |
| 53 |
#define HCLGE_COMM_RSS_HASH_KEY_OFFSET_B 4 |
| 54 |
|
| 55 |
#define HCLGE_COMM_RSS_HASH_KEY_NUM 16 |
| 56 |
struct hclge_comm_rss_config_cmd { |
| 57 |
u8 hash_config; |
| 58 |
u8 rsv[7]; |
| 59 |
u8 hash_key[HCLGE_COMM_RSS_HASH_KEY_NUM]; |
| 60 |
}; |
| 61 |
|
| 62 |
struct hclge_comm_rss_cfg { |
| 63 |
u8 rss_hash_key[HCLGE_COMM_RSS_KEY_SIZE]; /* user configured hash keys */ |
| 64 |
|
| 65 |
/* shadow table */ |
| 66 |
u16 *rss_indirection_tbl; |
| 67 |
u32 rss_algo; |
| 68 |
|
| 69 |
struct hclge_comm_rss_tuple_cfg rss_tuple_sets; |
| 70 |
u32 rss_size; |
| 71 |
}; |
| 72 |
|
| 73 |
struct hclge_comm_rss_input_tuple_cmd { |
| 74 |
u8 ipv4_tcp_en; |
| 75 |
u8 ipv4_udp_en; |
| 76 |
u8 ipv4_sctp_en; |
| 77 |
u8 ipv4_fragment_en; |
| 78 |
u8 ipv6_tcp_en; |
| 79 |
u8 ipv6_udp_en; |
| 80 |
u8 ipv6_sctp_en; |
| 81 |
u8 ipv6_fragment_en; |
| 82 |
u8 rsv[16]; |
| 83 |
}; |
| 84 |
|
| 85 |
struct hclge_comm_rss_ind_tbl_cmd { |
| 86 |
__le16 start_table_index; |
| 87 |
__le16 rss_set_bitmap; |
| 88 |
u8 rss_qid_h[HCLGE_COMM_RSS_CFG_TBL_SIZE_H]; |
| 89 |
u8 rss_qid_l[HCLGE_COMM_RSS_CFG_TBL_SIZE]; |
| 90 |
}; |
| 91 |
|
| 92 |
struct hclge_comm_rss_tc_mode_cmd { |
| 93 |
__le16 rss_tc_mode[HCLGE_COMM_MAX_TC_NUM]; |
| 94 |
u8 rsv[8]; |
| 95 |
}; |
| 96 |
|
| 97 |
u32 hclge_comm_get_rss_key_size(struct hnae3_handle *handle); |
| 98 |
void hclge_comm_rss_indir_init_cfg(struct hnae3_ae_dev *ae_dev, |
| 99 |
struct hclge_comm_rss_cfg *rss_cfg); |
| 100 |
int hclge_comm_get_rss_tuple(struct hclge_comm_rss_cfg *rss_cfg, int flow_type, |
| 101 |
u8 *tuple_sets); |
| 102 |
int hclge_comm_parse_rss_hfunc(struct hclge_comm_rss_cfg *rss_cfg, |
| 103 |
const u8 hfunc, u8 *hash_algo); |
| 104 |
void hclge_comm_get_rss_hash_info(struct hclge_comm_rss_cfg *rss_cfg, u8 *key, |
| 105 |
u8 *hfunc); |
| 106 |
void hclge_comm_get_rss_indir_tbl(struct hclge_comm_rss_cfg *rss_cfg, |
| 107 |
u32 *indir, u16 rss_ind_tbl_size); |
| 108 |
int hclge_comm_set_rss_algo_key(struct hclge_comm_hw *hw, const u8 hfunc, |
| 109 |
const u8 *key); |
| 110 |
int hclge_comm_init_rss_tuple_cmd(struct hclge_comm_rss_cfg *rss_cfg, |
| 111 |
const struct ethtool_rxfh_fields *nfc, |
| 112 |
struct hnae3_ae_dev *ae_dev, |
| 113 |
struct hclge_comm_rss_input_tuple_cmd *req); |
| 114 |
u64 hclge_comm_convert_rss_tuple(u8 tuple_sets); |
| 115 |
int hclge_comm_set_rss_input_tuple(struct hclge_comm_hw *hw, |
| 116 |
struct hclge_comm_rss_cfg *rss_cfg); |
| 117 |
int hclge_comm_set_rss_indir_table(struct hnae3_ae_dev *ae_dev, |
| 118 |
struct hclge_comm_hw *hw, const u16 *indir); |
| 119 |
int hclge_comm_rss_init_cfg(struct hnae3_handle *nic, |
| 120 |
struct hnae3_ae_dev *ae_dev, |
| 121 |
struct hclge_comm_rss_cfg *rss_cfg); |
| 122 |
void hclge_comm_get_rss_tc_info(u16 rss_size, u8 hw_tc_map, u16 *tc_offset, |
| 123 |
u16 *tc_valid, u16 *tc_size); |
| 124 |
int hclge_comm_set_rss_tc_mode(struct hclge_comm_hw *hw, u16 *tc_offset, |
| 125 |
u16 *tc_valid, u16 *tc_size); |
| 126 |
int hclge_comm_set_rss_hash_key(struct hclge_comm_rss_cfg *rss_cfg, |
| 127 |
struct hclge_comm_hw *hw, const u8 *key, |
| 128 |
const u8 hfunc); |
| 129 |
int hclge_comm_set_rss_tuple(struct hnae3_ae_dev *ae_dev, |
| 130 |
struct hclge_comm_hw *hw, |
| 131 |
struct hclge_comm_rss_cfg *rss_cfg, |
| 132 |
const struct ethtool_rxfh_fields *nfc); |
| 133 |
#endif |