提交 8d7a5778 编写于 作者: S shenhao 提交者: Yang Yingliang

net: hns3: optimize FD tuple inspect

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

--------------------------------------------

Currently, proto_support indicates that what kind of flow type does
this device support, with value of BIT(x). Due to 'x' may be extended
to more than 32 even 64, it's not a good way to deal with it. So this
patch eliminates proto_support.
Signed-off-by: NGuojia Liao <liaoguojia@huawei.com>
Signed-off-by: Nshenhao <shenhao21@huawei.com>
Reviewed-by: NZhong Zhaohui <zhongzhaohui@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 8d04f2ed
......@@ -4998,10 +4998,6 @@ static int hclge_init_fd_config(struct hclge_dev *hdev)
return -EOPNOTSUPP;
}
hdev->fd_cfg.proto_support =
BIT(TCP_V4_FLOW) | BIT(UDP_V4_FLOW) | BIT(SCTP_V4_FLOW) |
BIT(TCP_V6_FLOW) | BIT(UDP_V6_FLOW) | BIT(SCTP_V6_FLOW) |
BIT(IPV4_USER_FLOW) | BIT(IPV6_USER_FLOW);
key_cfg = &hdev->fd_cfg.key_cfg[HCLGE_FD_STAGE_1];
key_cfg->key_sel = HCLGE_FD_KEY_BASE_ON_TUPLE,
key_cfg->inner_sipv6_word_en = LOW_2_WORDS;
......@@ -5015,11 +5011,9 @@ static int hclge_init_fd_config(struct hclge_dev *hdev)
BIT(INNER_SRC_PORT) | BIT(INNER_DST_PORT);
/* If use max 400bit key, we can support tuples for ether type */
if (hdev->fd_cfg.max_key_length == MAX_KEY_LENGTH) {
hdev->fd_cfg.proto_support |= BIT(ETHER_FLOW);
if (hdev->fd_cfg.fd_mode == HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1)
key_cfg->tuple_active |=
BIT(INNER_DST_MAC) | BIT(INNER_SRC_MAC);
}
/* roce_type is used to filter roce frames
* dst_vport is used to specify the rule
......@@ -5509,7 +5503,7 @@ static int hclge_fd_check_ext_tuple(struct hclge_dev *hdev,
{
if (fs->flow_type & FLOW_EXT) {
if (fs->h_ext.vlan_etype) {
dev_err(&hdev->pdev->dev, "vlan-etype does not support on this device!\n");
dev_err(&hdev->pdev->dev, "vlan-etype does not support!\n");
return -EOPNOTSUPP;
}
......@@ -5527,8 +5521,10 @@ static int hclge_fd_check_ext_tuple(struct hclge_dev *hdev,
}
if (fs->flow_type & FLOW_MAC_EXT) {
if (!(hdev->fd_cfg.proto_support & BIT(ETHER_FLOW))) {
dev_err(&hdev->pdev->dev, "unsupported protocol of ETHER_FLOW on this device.\n");
if (hdev->fd_cfg.fd_mode !=
HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1) {
dev_err(&hdev->pdev->dev,
"FLOW_MAC_EXT does not support in current FD mode!\n");
return -EOPNOTSUPP;
}
......@@ -5546,7 +5542,7 @@ static int hclge_fd_check_spec(struct hclge_dev *hdev,
u32 *unused_tuple)
{
u32 flow_type;
int ret = 0;
int ret;
if (fs->location >= hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1]) {
dev_err(&hdev->pdev->dev, "failed to config fd rules, invalid rule location: %u, max is %u\n.",
......@@ -5555,19 +5551,13 @@ static int hclge_fd_check_spec(struct hclge_dev *hdev,
return -EINVAL;
}
flow_type = fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT);
if (!(BIT(flow_type) & hdev->fd_cfg.proto_support)) {
dev_err(&hdev->pdev->dev, "unsupported protocol type, protocol type = 0x%x\n",
flow_type);
return -EOPNOTSUPP;
}
if ((fs->flow_type & FLOW_EXT) &&
(fs->h_ext.data[0] != 0 || fs->h_ext.data[1] != 0)) {
dev_err(&hdev->pdev->dev, "user-def bytes are not supported\n");
return -EOPNOTSUPP;
}
flow_type = fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT);
switch (flow_type) {
case SCTP_V4_FLOW:
case TCP_V4_FLOW:
......@@ -5590,15 +5580,24 @@ static int hclge_fd_check_spec(struct hclge_dev *hdev,
unused_tuple);
break;
case ETHER_FLOW:
if (hdev->fd_cfg.fd_mode !=
HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1) {
dev_err(&hdev->pdev->dev,
"ETHER_FLOW does not support in current FD mode!\n");
return -EOPNOTSUPP;
}
ret = hclge_fd_check_ether_tuple(&fs->h_u.ether_spec,
unused_tuple);
break;
default:
dev_err(&hdev->pdev->dev, "unsupported protocol type, protocol type = 0x%x\n",
flow_type);
return -EOPNOTSUPP;
}
if (ret) {
dev_err(&hdev->pdev->dev, "failed to check flow tuple, ret = %d\n",
dev_err(&hdev->pdev->dev, "failed to check flow union tuple, ret = %d\n",
ret);
return ret;
}
......
......@@ -589,7 +589,6 @@ struct hclge_fd_key_cfg {
struct hclge_fd_cfg {
u8 fd_mode;
u16 max_key_length; /* use bit as unit */
u64 proto_support;
u32 rule_num[MAX_STAGE_NUM]; /* rule entry number */
u16 cnt_num[MAX_STAGE_NUM]; /* rule hit counter number */
struct hclge_fd_key_cfg key_cfg[MAX_STAGE_NUM];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册