git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/hns3: replace max private macro
[dpdk.git]
/
drivers
/
net
/
hns3
/
hns3_fdir.c
diff --git
a/drivers/net/hns3/hns3_fdir.c
b/drivers/net/hns3/hns3_fdir.c
index
ca3c78e
..
5c3dd05
100644
(file)
--- a/
drivers/net/hns3/hns3_fdir.c
+++ b/
drivers/net/hns3/hns3_fdir.c
@@
-41,6
+41,8
@@
#define HNS3_FD_AD_WR_RULE_ID_B 0
#define HNS3_FD_AD_RULE_ID_S 1
#define HNS3_FD_AD_RULE_ID_M GENMASK(13, 1)
#define HNS3_FD_AD_WR_RULE_ID_B 0
#define HNS3_FD_AD_RULE_ID_S 1
#define HNS3_FD_AD_RULE_ID_M GENMASK(13, 1)
+#define HNS3_FD_AD_COUNTER_HIGH_BIT 7
+#define HNS3_FD_AD_COUNTER_HIGH_BIT_B 26
enum HNS3_PORT_TYPE {
HOST_PORT,
enum HNS3_PORT_TYPE {
HOST_PORT,
@@
-424,6
+426,9
@@
static int hns3_fd_ad_config(struct hns3_hw *hw, int loc,
action->write_rule_id_to_bd);
hns3_set_field(ad_data, HNS3_FD_AD_RULE_ID_M, HNS3_FD_AD_RULE_ID_S,
action->rule_id);
action->write_rule_id_to_bd);
hns3_set_field(ad_data, HNS3_FD_AD_RULE_ID_M, HNS3_FD_AD_RULE_ID_S,
action->rule_id);
+ /* set extend bit if counter_id is in [128 ~ 255] */
+ if (action->counter_id & BIT(HNS3_FD_AD_COUNTER_HIGH_BIT))
+ hns3_set_bit(ad_data, HNS3_FD_AD_COUNTER_HIGH_BIT_B, 1);
ad_data <<= HNS3_FD_AD_DATA_S;
hns3_set_bit(ad_data, HNS3_FD_AD_DROP_B, action->drop_packet);
hns3_set_bit(ad_data, HNS3_FD_AD_DIRECT_QID_B,
ad_data <<= HNS3_FD_AD_DATA_S;
hns3_set_bit(ad_data, HNS3_FD_AD_DROP_B, action->drop_packet);
hns3_set_bit(ad_data, HNS3_FD_AD_DIRECT_QID_B,
@@
-619,7
+624,7
@@
static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg,
uint8_t *key_x, uint8_t *key_y)
{
uint16_t meta_data = 0;
uint8_t *key_x, uint8_t *key_y)
{
uint16_t meta_data = 0;
- uint
16
_t port_number;
+ uint
32
_t port_number;
uint8_t cur_pos = 0;
uint8_t tuple_size;
uint8_t shift_bits;
uint8_t cur_pos = 0;
uint8_t tuple_size;
uint8_t shift_bits;
@@
-637,7
+642,7
@@
static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg,
rule->key_conf.spec.tunnel_type ? 1 : 0);
cur_pos += tuple_size;
} else if (i == VLAN_NUMBER) {
rule->key_conf.spec.tunnel_type ? 1 : 0);
cur_pos += tuple_size;
} else if (i == VLAN_NUMBER) {
- uint
8
_t vlan_tag;
+ uint
32
_t vlan_tag;
uint8_t vlan_num;
if (rule->key_conf.spec.tunnel_type == 0)
vlan_num = rule->key_conf.vlan_num;
uint8_t vlan_num;
if (rule->key_conf.spec.tunnel_type == 0)
vlan_num = rule->key_conf.vlan_num;
@@
-686,8
+691,8
@@
static int hns3_config_key(struct hns3_adapter *hns,
struct hns3_fd_key_cfg *key_cfg;
uint8_t *cur_key_x;
uint8_t *cur_key_y;
struct hns3_fd_key_cfg *key_cfg;
uint8_t *cur_key_x;
uint8_t *cur_key_y;
- uint8_t key_x[MAX_KEY_BYTES] __
attribute__((aligned(4))
);
- uint8_t key_y[MAX_KEY_BYTES] __
attribute__((aligned(4))
);
+ uint8_t key_x[MAX_KEY_BYTES] __
rte_aligned(4
);
+ uint8_t key_y[MAX_KEY_BYTES] __
rte_aligned(4
);
uint8_t vf_id = rule->vf_id;
uint8_t meta_data_region;
uint8_t tuple_size;
uint8_t vf_id = rule->vf_id;
uint8_t meta_data_region;
uint8_t tuple_size;
@@
-772,6
+777,20
@@
static int hns3_config_action(struct hns3_hw *hw, struct hns3_fdir_rule *rule)
return hns3_fd_ad_config(hw, ad_data.ad_id, &ad_data);
}
return hns3_fd_ad_config(hw, ad_data.ad_id, &ad_data);
}
+static int hns3_fd_clear_all_rules(struct hns3_hw *hw, uint32_t rule_num)
+{
+ uint32_t i;
+ int ret;
+
+ for (i = 0; i < rule_num; i++) {
+ ret = hns3_fd_tcam_config(hw, true, i, NULL, false);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
int hns3_fdir_filter_init(struct hns3_adapter *hns)
{
struct hns3_pf *pf = &hns->pf;
int hns3_fdir_filter_init(struct hns3_adapter *hns)
{
struct hns3_pf *pf = &hns->pf;
@@
-785,6
+804,13
@@
int hns3_fdir_filter_init(struct hns3_adapter *hns)
.hash_func = rte_hash_crc,
.hash_func_init_val = 0,
};
.hash_func = rte_hash_crc,
.hash_func_init_val = 0,
};
+ int ret;
+
+ ret = hns3_fd_clear_all_rules(&hns->hw, rule_num);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "Clear all fd rules fail! ret = %d", ret);
+ return ret;
+ }
fdir_hash_params.socket_id = rte_socket_id();
TAILQ_INIT(&fdir_info->fdir_list);
fdir_hash_params.socket_id = rte_socket_id();
TAILQ_INIT(&fdir_info->fdir_list);
@@
-872,7
+898,7
@@
static int hns3_insert_fdir_filter(struct hns3_hw *hw,
if (ret < 0) {
rte_spinlock_unlock(&fdir_info->flows_lock);
hns3_err(hw, "Hash table full? err:%d(%s)!", ret,
if (ret < 0) {
rte_spinlock_unlock(&fdir_info->flows_lock);
hns3_err(hw, "Hash table full? err:%d(%s)!", ret,
- strerror(ret));
+ strerror(
-
ret));
return ret;
}
return ret;
}
@@
-924,12
+950,12
@@
int hns3_fdir_filter_program(struct hns3_adapter *hns,
false);
if (ret)
hns3_err(hw, "Failed to delete fdir: %d src_ip:%x "
false);
if (ret)
hns3_err(hw, "Failed to delete fdir: %d src_ip:%x "
- "dst_ip:%x src_port:%d dst_port:%d",
+ "dst_ip:%x src_port:%d dst_port:%d
ret = %d
",
rule->location,
rule->key_conf.spec.src_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.dst_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.src_port,
rule->location,
rule->key_conf.spec.src_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.dst_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.src_port,
- rule->key_conf.spec.dst_port);
+ rule->key_conf.spec.dst_port
, ret
);
else
hns3_remove_fdir_filter(hw, fdir_info, &rule->key_conf);
else
hns3_remove_fdir_filter(hw, fdir_info, &rule->key_conf);
@@
-965,12
+991,12
@@
int hns3_fdir_filter_program(struct hns3_adapter *hns,
rte_spinlock_unlock(&fdir_info->flows_lock);
if (ret) {
hns3_err(hw, "Failed to config fdir: %d src_ip:%x dst_ip:%x "
rte_spinlock_unlock(&fdir_info->flows_lock);
if (ret) {
hns3_err(hw, "Failed to config fdir: %d src_ip:%x dst_ip:%x "
- "src_port:%d dst_port:%d",
+ "src_port:%d dst_port:%d
ret = %d
",
rule->location,
rule->key_conf.spec.src_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.dst_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.src_port,
rule->location,
rule->key_conf.spec.src_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.dst_ip[IP_ADDR_KEY_ID],
rule->key_conf.spec.src_port,
- rule->key_conf.spec.dst_port);
+ rule->key_conf.spec.dst_port
, ret
);
(void)hns3_remove_fdir_filter(hw, fdir_info, &rule->key_conf);
}
(void)hns3_remove_fdir_filter(hw, fdir_info, &rule->key_conf);
}
@@
-1002,7
+1028,7
@@
int hns3_clear_all_fdir_filter(struct hns3_adapter *hns)
}
if (ret) {
}
if (ret) {
- hns3_err(hw, "Fail to delete FDIR filter
!"
);
+ hns3_err(hw, "Fail to delete FDIR filter
, ret = %d", ret
);
ret = -EIO;
}
return ret;
ret = -EIO;
}
return ret;
@@
-1029,7
+1055,7
@@
int hns3_restore_all_fdir_filter(struct hns3_adapter *hns)
}
if (err) {
}
if (err) {
- hns3_err(hw, "Fail to restore FDIR filter
!"
);
+ hns3_err(hw, "Fail to restore FDIR filter
, ret = %d", ret
);
return -EIO;
}
return 0;
return -EIO;
}
return 0;