2020-12-10 03:50:31

by Huazhong Tan

[permalink] [raw]
Subject: [PATCH net-next 3/7] net: hns3: add support for forwarding packet to queues of specified TC when flow director rule hit

From: Jian Shen <[email protected]>

For some new device, it supports forwarding packet to queues
of specified TC when flow director rule hit. So extend the
command handle to support it.

Signed-off-by: Jian Shen <[email protected]>
Signed-off-by: Huazhong Tan <[email protected]>
---
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 2 ++
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 3 +++
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 21 +++++++++++++++++----
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 6 +++++-
4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index 85986c7..b728be4 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -359,6 +359,8 @@ static void hclge_parse_capability(struct hclge_dev *hdev,
set_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, ae_dev->caps);
if (hnae3_get_bit(caps, HCLGE_CAP_UDP_TUNNEL_CSUM_B))
set_bit(HNAE3_DEV_SUPPORT_UDP_TUNNEL_CSUM_B, ae_dev->caps);
+ if (hnae3_get_bit(caps, HCLGE_CAP_FD_FORWARD_TC_B))
+ set_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, ae_dev->caps);
}

static enum hclge_cmd_status
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 52a6f9b..df5417d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -1051,6 +1051,9 @@ struct hclge_fd_tcam_config_3_cmd {
#define HCLGE_FD_AD_WR_RULE_ID_B 0
#define HCLGE_FD_AD_RULE_ID_S 1
#define HCLGE_FD_AD_RULE_ID_M GENMASK(13, 1)
+#define HCLGE_FD_AD_TC_OVRD_B 16
+#define HCLGE_FD_AD_TC_SIZE_S 17
+#define HCLGE_FD_AD_TC_SIZE_M GENMASK(20, 17)

struct hclge_fd_ad_config_cmd {
u8 stage;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 366920b..0b6102e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -5099,6 +5099,7 @@ static int hclge_fd_tcam_config(struct hclge_dev *hdev, u8 stage, bool sel_x,
static int hclge_fd_ad_config(struct hclge_dev *hdev, u8 stage, int loc,
struct hclge_fd_ad_data *action)
{
+ struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
struct hclge_fd_ad_config_cmd *req;
struct hclge_desc desc;
u64 ad_data = 0;
@@ -5114,6 +5115,12 @@ static int hclge_fd_ad_config(struct hclge_dev *hdev, u8 stage, int loc,
action->write_rule_id_to_bd);
hnae3_set_field(ad_data, HCLGE_FD_AD_RULE_ID_M, HCLGE_FD_AD_RULE_ID_S,
action->rule_id);
+ if (test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, ae_dev->caps)) {
+ hnae3_set_bit(ad_data, HCLGE_FD_AD_TC_OVRD_B,
+ action->override_tc);
+ hnae3_set_field(ad_data, HCLGE_FD_AD_TC_SIZE_M,
+ HCLGE_FD_AD_TC_SIZE_S, (u32)action->tc_size);
+ }
ad_data <<= 32;
hnae3_set_bit(ad_data, HCLGE_FD_AD_DROP_B, action->drop_packet);
hnae3_set_bit(ad_data, HCLGE_FD_AD_DIRECT_QID_B,
@@ -5357,16 +5364,22 @@ static int hclge_config_key(struct hclge_dev *hdev, u8 stage,
static int hclge_config_action(struct hclge_dev *hdev, u8 stage,
struct hclge_fd_rule *rule)
{
+ struct hclge_vport *vport = hdev->vport;
+ struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
struct hclge_fd_ad_data ad_data;

+ memset(&ad_data, 0, sizeof(struct hclge_fd_ad_data));
ad_data.ad_id = rule->location;

if (rule->action == HCLGE_FD_ACTION_DROP_PACKET) {
ad_data.drop_packet = true;
- ad_data.forward_to_direct_queue = false;
- ad_data.queue_id = 0;
+ } else if (rule->action == HCLGE_FD_ACTION_SELECT_TC) {
+ ad_data.override_tc = true;
+ ad_data.queue_id =
+ kinfo->tc_info.tqp_offset[rule->tc];
+ ad_data.tc_size =
+ ilog2(kinfo->tc_info.tqp_count[rule->tc]);
} else {
- ad_data.drop_packet = false;
ad_data.forward_to_direct_queue = true;
ad_data.queue_id = rule->queue_id;
}
@@ -5937,7 +5950,7 @@ static int hclge_add_fd_entry(struct hnae3_handle *handle,
return -EINVAL;
}

- action = HCLGE_FD_ACTION_ACCEPT_PACKET;
+ action = HCLGE_FD_ACTION_SELECT_QUEUE;
q_index = ring;
}

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index b3c1301..a481064 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -572,8 +572,9 @@ enum HCLGE_FD_PACKET_TYPE {
};

enum HCLGE_FD_ACTION {
- HCLGE_FD_ACTION_ACCEPT_PACKET,
+ HCLGE_FD_ACTION_SELECT_QUEUE,
HCLGE_FD_ACTION_DROP_PACKET,
+ HCLGE_FD_ACTION_SELECT_TC,
};

struct hclge_fd_key_cfg {
@@ -619,6 +620,7 @@ struct hclge_fd_rule {
u32 unused_tuple;
u32 flow_type;
u8 action;
+ u8 tc;
u16 vf_id;
u16 queue_id;
u16 location;
@@ -637,6 +639,8 @@ struct hclge_fd_ad_data {
u8 write_rule_id_to_bd;
u8 next_input_key;
u16 rule_id;
+ u16 tc_size;
+ u8 override_tc;
};

enum HCLGE_MAC_NODE_STATE {
--
2.7.4


2020-12-10 07:20:47

by Saeed Mahameed

[permalink] [raw]
Subject: Re: [PATCH net-next 3/7] net: hns3: add support for forwarding packet to queues of specified TC when flow director rule hit

On Thu, 2020-12-10 at 11:42 +0800, Huazhong Tan wrote:
> From: Jian Shen <[email protected]>
>
> For some new device, it supports forwarding packet to queues
> of specified TC when flow director rule hit. So extend the
> command handle to support it.
>

...

> static int hclge_config_action(struct hclge_dev *hdev, u8 stage,
> struct hclge_fd_rule *rule)
> {
> + struct hclge_vport *vport = hdev->vport;
> + struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
> struct hclge_fd_ad_data ad_data;
>
> + memset(&ad_data, 0, sizeof(struct hclge_fd_ad_data));
> ad_data.ad_id = rule->location;
>
> if (rule->action == HCLGE_FD_ACTION_DROP_PACKET) {
> ad_data.drop_packet = true;
> - ad_data.forward_to_direct_queue = false;
> - ad_data.queue_id = 0;
> + } else if (rule->action == HCLGE_FD_ACTION_SELECT_TC) {
> + ad_data.override_tc = true;
> + ad_data.queue_id =
> + kinfo->tc_info.tqp_offset[rule->tc];
> + ad_data.tc_size =
> + ilog2(kinfo->tc_info.tqp_count[rule->tc]);

In the previous patch you copied this info from mqprio, which is an
egress qdisc feature, this patch is clearly about rx flow director, I
think the patch is missing some context otherwise it doesn't make any
sense.

> } else {
> - ad_data.drop_packet = false;
> ad_data.forward_to_direct_queue = true;
> ad_data.queue_id = rule->queue_id;
> }
> @@ -5937,7 +5950,7 @@ static int hclge_add_fd_entry(struct
> hnae3_handle *handle,
> return -EINVAL;
> }
>
> - action = HCLGE_FD_ACTION_ACCEPT_PACKET;
> + action = HCLGE_FD_ACTION_SELECT_QUEUE;
> q_index = ring;
> }
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> index b3c1301..a481064 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> @@ -572,8 +572,9 @@ enum HCLGE_FD_PACKET_TYPE {
> };
>
> enum HCLGE_FD_ACTION {
> - HCLGE_FD_ACTION_ACCEPT_PACKET,
> + HCLGE_FD_ACTION_SELECT_QUEUE,
> HCLGE_FD_ACTION_DROP_PACKET,
> + HCLGE_FD_ACTION_SELECT_TC,

what is SELECT_TC ? you never actually write this value anywhere in
this patch.


2020-12-10 12:27:15

by Huazhong Tan

[permalink] [raw]
Subject: Re: [PATCH net-next 3/7] net: hns3: add support for forwarding packet to queues of specified TC when flow director rule hit



On 2020/12/10 13:40, Saeed Mahameed wrote:
> On Thu, 2020-12-10 at 11:42 +0800, Huazhong Tan wrote:
>> From: Jian Shen <[email protected]>
>>
>> For some new device, it supports forwarding packet to queues
>> of specified TC when flow director rule hit. So extend the
>> command handle to support it.
>>
>
> ...
>
>> static int hclge_config_action(struct hclge_dev *hdev, u8 stage,
>> struct hclge_fd_rule *rule)
>> {
>> + struct hclge_vport *vport = hdev->vport;
>> + struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
>> struct hclge_fd_ad_data ad_data;
>>
>> + memset(&ad_data, 0, sizeof(struct hclge_fd_ad_data));
>> ad_data.ad_id = rule->location;
>>
>> if (rule->action == HCLGE_FD_ACTION_DROP_PACKET) {
>> ad_data.drop_packet = true;
>> - ad_data.forward_to_direct_queue = false;
>> - ad_data.queue_id = 0;
>> + } else if (rule->action == HCLGE_FD_ACTION_SELECT_TC) {
>> + ad_data.override_tc = true;
>> + ad_data.queue_id =
>> + kinfo->tc_info.tqp_offset[rule->tc];
>> + ad_data.tc_size =
>> + ilog2(kinfo->tc_info.tqp_count[rule->tc]);
>
> In the previous patch you copied this info from mqprio, which is an
> egress qdisc feature, this patch is clearly about rx flow director, I
> think the patch is missing some context otherwise it doesn't make any
> sense.
>

Since tx and rx are in the same tqp, what we do here is to make tx and
rx in the same tc when rule is hit.

>> } else {
>> - ad_data.drop_packet = false;
>> ad_data.forward_to_direct_queue = true;
>> ad_data.queue_id = rule->queue_id;
>> }
>> @@ -5937,7 +5950,7 @@ static int hclge_add_fd_entry(struct
>> hnae3_handle *handle,
>> return -EINVAL;
>> }
>>
>> - action = HCLGE_FD_ACTION_ACCEPT_PACKET;
>> + action = HCLGE_FD_ACTION_SELECT_QUEUE;
>> q_index = ring;
>> }
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> index b3c1301..a481064 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>> @@ -572,8 +572,9 @@ enum HCLGE_FD_PACKET_TYPE {
>> };
>>
>> enum HCLGE_FD_ACTION {
>> - HCLGE_FD_ACTION_ACCEPT_PACKET,
>> + HCLGE_FD_ACTION_SELECT_QUEUE,
>> HCLGE_FD_ACTION_DROP_PACKET,
>> + HCLGE_FD_ACTION_SELECT_TC,
>
> what is SELECT_TC ? you never actually write this value anywhere in
> this patch.
>

HCLGE_FD_ACTION_SELECT_TC means that the packet will be forwarded into
the queue of specified TC when rule is hit.

the assignment is in the next patch, maybe these two patch should be
merged for making it more readable.


Thanks.
Huazhong.

>
>
> .
>

2020-12-10 20:52:46

by Saeed Mahameed

[permalink] [raw]
Subject: Re: [PATCH net-next 3/7] net: hns3: add support for forwarding packet to queues of specified TC when flow director rule hit

On Thu, 2020-12-10 at 20:24 +0800, tanhuazhong wrote:
>
> On 2020/12/10 13:40, Saeed Mahameed wrote:
> > On Thu, 2020-12-10 at 11:42 +0800, Huazhong Tan wrote:
> > > From: Jian Shen <[email protected]>
> > >
> > > For some new device, it supports forwarding packet to queues
> > > of specified TC when flow director rule hit. So extend the
> > > command handle to support it.
> > >
> >
> > ...
> >
> > > static int hclge_config_action(struct hclge_dev *hdev, u8
> > > stage,
> > > struct hclge_fd_rule *rule)
> > > {
> > > + struct hclge_vport *vport = hdev->vport;
> > > + struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
> > > struct hclge_fd_ad_data ad_data;
> > >
> > > + memset(&ad_data, 0, sizeof(struct hclge_fd_ad_data));
> > > ad_data.ad_id = rule->location;
> > >
> > > if (rule->action == HCLGE_FD_ACTION_DROP_PACKET) {
> > > ad_data.drop_packet = true;
> > > - ad_data.forward_to_direct_queue = false;
> > > - ad_data.queue_id = 0;
> > > + } else if (rule->action == HCLGE_FD_ACTION_SELECT_TC) {
> > > + ad_data.override_tc = true;
> > > + ad_data.queue_id =
> > > + kinfo->tc_info.tqp_offset[rule->tc];
> > > + ad_data.tc_size =
> > > + ilog2(kinfo->tc_info.tqp_count[rule->tc]);
> >
> > In the previous patch you copied this info from mqprio, which is an
> > egress qdisc feature, this patch is clearly about rx flow director,
> > I
> > think the patch is missing some context otherwise it doesn't make
> > any
> > sense.
> >
>
> Since tx and rx are in the same tqp, what we do here is to make tx
> and
> rx in the same tc when rule is hit.
>

this needs more clarification, even if tx and rx are the same hw
object, AFAIK there is not correlation between mqprio and tc rx
classifiers.

> > > } else {
> > > - ad_data.drop_packet = false;
> > > ad_data.forward_to_direct_queue = true;
> > > ad_data.queue_id = rule->queue_id;
> > > }
> > > @@ -5937,7 +5950,7 @@ static int hclge_add_fd_entry(struct
> > > hnae3_handle *handle,
> > > return -EINVAL;
> > > }
> > >
> > > - action = HCLGE_FD_ACTION_ACCEPT_PACKET;
> > > + action = HCLGE_FD_ACTION_SELECT_QUEUE;
> > > q_index = ring;
> > > }
> > >
> > > diff --git
> > > a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> > > b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> > > index b3c1301..a481064 100644
> > > --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> > > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
> > > @@ -572,8 +572,9 @@ enum HCLGE_FD_PACKET_TYPE {
> > > };
> > >
> > > enum HCLGE_FD_ACTION {
> > > - HCLGE_FD_ACTION_ACCEPT_PACKET,
> > > + HCLGE_FD_ACTION_SELECT_QUEUE,
> > > HCLGE_FD_ACTION_DROP_PACKET,
> > > + HCLGE_FD_ACTION_SELECT_TC,
> >
> > what is SELECT_TC ? you never actually write this value
> > anywhere in
> > this patch.
> >
>
> HCLGE_FD_ACTION_SELECT_TC means that the packet will be forwarded
> into
> the queue of specified TC when rule is hit.
>
what is "specified TC" in this context ?

Are we talking about ethtool nfc steering here ? because clearly this
was the purpose of HCLGE_FD_ACTION_ACCEPT_PACKET before it got removed.


> the assignment is in the next patch, maybe these two patch should be
> merged for making it more readable.
>
>
> Thanks.
> Huazhong.
>
> >
> > .
> >

2020-12-12 04:14:46

by Huazhong Tan

[permalink] [raw]
Subject: Re: [PATCH net-next 3/7] net: hns3: add support for forwarding packet to queues of specified TC when flow director rule hit



On 2020/12/11 4:46, Saeed Mahameed wrote:
> On Thu, 2020-12-10 at 20:24 +0800, tanhuazhong wrote:
>>
>> On 2020/12/10 13:40, Saeed Mahameed wrote:
>>> On Thu, 2020-12-10 at 11:42 +0800, Huazhong Tan wrote:
>>>> From: Jian Shen <[email protected]>
>>>>
>>>> For some new device, it supports forwarding packet to queues
>>>> of specified TC when flow director rule hit. So extend the
>>>> command handle to support it.
>>>>
>>>
>>> ...
>>>
>>>> static int hclge_config_action(struct hclge_dev *hdev, u8
>>>> stage,
>>>> struct hclge_fd_rule *rule)
>>>> {
>>>> + struct hclge_vport *vport = hdev->vport;
>>>> + struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
>>>> struct hclge_fd_ad_data ad_data;
>>>>
>>>> + memset(&ad_data, 0, sizeof(struct hclge_fd_ad_data));
>>>> ad_data.ad_id = rule->location;
>>>>
>>>> if (rule->action == HCLGE_FD_ACTION_DROP_PACKET) {
>>>> ad_data.drop_packet = true;
>>>> - ad_data.forward_to_direct_queue = false;
>>>> - ad_data.queue_id = 0;
>>>> + } else if (rule->action == HCLGE_FD_ACTION_SELECT_TC) {
>>>> + ad_data.override_tc = true;
>>>> + ad_data.queue_id =
>>>> + kinfo->tc_info.tqp_offset[rule->tc];
>>>> + ad_data.tc_size =
>>>> + ilog2(kinfo->tc_info.tqp_count[rule->tc]);
>>>
>>> In the previous patch you copied this info from mqprio, which is an
>>> egress qdisc feature, this patch is clearly about rx flow director,
>>> I
>>> think the patch is missing some context otherwise it doesn't make
>>> any
>>> sense.
>>>
>>
>> Since tx and rx are in the same tqp, what we do here is to make tx
>> and
>> rx in the same tc when rule is hit.
>>
>
> this needs more clarification, even if tx and rx are the same hw
> object, AFAIK there is not correlation between mqprio and tc rx
> classifiers.
>

Could comment below make the code more readable?
"Since tx and rx are in the same tqp, if hit rule, forward the packet to
the rx queues pair with specified TC"

>>>> } else {
>>>> - ad_data.drop_packet = false;
>>>> ad_data.forward_to_direct_queue = true;
>>>> ad_data.queue_id = rule->queue_id;
>>>> }
>>>> @@ -5937,7 +5950,7 @@ static int hclge_add_fd_entry(struct
>>>> hnae3_handle *handle,
>>>> return -EINVAL;
>>>> }
>>>>
>>>> - action = HCLGE_FD_ACTION_ACCEPT_PACKET;
>>>> + action = HCLGE_FD_ACTION_SELECT_QUEUE;
>>>> q_index = ring;
>>>> }
>>>>
>>>> diff --git
>>>> a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>>>> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>>>> index b3c1301..a481064 100644
>>>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>>>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
>>>> @@ -572,8 +572,9 @@ enum HCLGE_FD_PACKET_TYPE {
>>>> };
>>>>
>>>> enum HCLGE_FD_ACTION {
>>>> - HCLGE_FD_ACTION_ACCEPT_PACKET,
>>>> + HCLGE_FD_ACTION_SELECT_QUEUE,
>>>> HCLGE_FD_ACTION_DROP_PACKET,
>>>> + HCLGE_FD_ACTION_SELECT_TC,
>>>
>>> what is SELECT_TC ? you never actually write this value
>>> anywhere in
>>> this patch.
>>>
>>
>> HCLGE_FD_ACTION_SELECT_TC means that the packet will be forwarded
>> into
>> the queue of specified TC when rule is hit.
>>
> what is "specified TC" in this context ?

TC specified by 'tc flower'

>
> Are we talking about ethtool nfc steering here ? because clearly this
> was the purpose of HCLGE_FD_ACTION_ACCEPT_PACKET before it got removed.
>

In fact, HCLGE_FD_ACTION_ACCEPT_PACKET is splitted in to
HCLGE_FD_ACTION_SELECT_QUEUE and HCLGE_FD_ACTION_SELECT_TC.
HCLGE_FD_ACTION_SELECT_QUEUE is configured by 'ethtool -U' (nfc
steering) or aRFS.
HCLGE_FD_ACTION_SELECT_TC is configured by 'tc flower' so far.


>
>> the assignment is in the next patch, maybe these two patch should be
>> merged for making it more readable.
>>
>>
>> Thanks.
>> Huazhong.
>>
>>>
>>> .
>>>
>
>
> .
>