mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <shaojijie@huawei.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <pabeni@redhat.com>,
	<andrew+netdev@lunn.ch>, <horms@kernel.org>,
	<shenjian15@huawei.com>, <liuyonglong@huawei.com>,
	<chenhao418@huawei.com>, <huangdonghua3@h-partners.com>,
	<yangshuaisong@h-partners.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V3 net-next 3/6] net: hns3: support two more actions for tc flow
Date: Wed, 10 Jun 2026 11:59:17 +0800	[thread overview]
Message-ID: <479aefe2-cca3-4868-9796-97c17b4436f5@huawei.com> (raw)
In-Reply-To: <20260605174021.7d4c6ec4@kernel.org>


on 2026/6/6 8:40, Jakub Kicinski wrote:
> On Tue, 2 Jun 2026 21:33:34 +0800 Jijie Shao wrote:
>> Currently, the driver supports only one action:HCLGE_FD_ACTION_SELECT_TC.
>>
>> This patch adds support for HCLGE_FD_ACTION_SELECT_QUEUE and
>> HCLGE_FD_ACTION_DROP_PACKET.
>>
>> A rule can have only one action. Therefore, the driver intercepts rules
>> that have multiple actions or no action.
>>
>> Note: The driver considers cls_flower->classid as an action:
>> HCLGE_FD_ACTION_SELECT_TC.
>>
>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>> ---
>>   .../hisilicon/hns3/hns3pf/hclge_main.c        | 59 ++++++++++++++++---
>>   1 file changed, 52 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
>> index 5e1f76513622..aa85abda2909 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
>> @@ -7344,18 +7344,45 @@ static int hclge_get_tc_flower_action(struct hclge_dev *hdev,
>>   				      struct flow_cls_offload *cls_flower,
>>   				      struct hclge_fd_rule *rule)
>>   {
>> +	struct flow_rule *flow = flow_cls_offload_flow_rule(cls_flower);
>>   	struct hnae3_handle *handle = &hdev->vport[0].nic;
>> +	struct flow_action *action = &flow->action;
>> +	struct flow_action_entry *act;
>>   	int tc;
>>   
>> -	tc = tc_classid_to_hwtc(handle->netdev, cls_flower->classid);
>> -	if (tc < 0 || tc > hdev->tc_max) {
>> -		dev_err(&hdev->pdev->dev, "invalid traffic class: %d\n", tc);
>> -		return -EINVAL;
>> +	if (!flow_action_has_entries(&flow->action)) {
>> +		tc = tc_classid_to_hwtc(handle->netdev, cls_flower->classid);
>> +		if (tc < 0 || tc > hdev->tc_max) {
>> +			dev_err(&hdev->pdev->dev,
>> +				"invalid traffic class: %d\n", tc);
>> +			return -EINVAL;
>> +		}
>> +
>> +		rule->action = HCLGE_FD_ACTION_SELECT_TC;
>> +		rule->cls_flower.tc = tc;
>> +		return 0;
>>   	}
>>   
>> -	rule->action = HCLGE_FD_ACTION_SELECT_TC;
>> -	rule->cls_flower.tc = tc;
>> -	return 0;
>> +	act = &action->entries[0];
>> +	switch (act->id) {
>> +	case FLOW_ACTION_RX_QUEUE_MAPPING:
>> +		if (act->rx_queue >= handle->kinfo.num_tqps) {
>> +			dev_err(&hdev->pdev->dev,
>> +				"queue id (%u) should be less than %u\n",
>> +				act->rx_queue, handle->kinfo.num_tqps);
>> +			return -EINVAL;
>> +		}
>> +
>> +		rule->queue_id = act->rx_queue;
>> +		rule->action = HCLGE_FD_ACTION_SELECT_QUEUE;
>> +		return 0;
>> +	case FLOW_ACTION_DROP:
>> +		rule->action = HCLGE_FD_ACTION_DROP_PACKET;
>> +		return 0;
>> +	default:
>> +		dev_err(&hdev->pdev->dev, "unsupported action(%d)\n", act->id);
>> +		return -EOPNOTSUPP;
>> +	}
>>   }
>>   
>>   static int hclge_parse_cls_flower(struct hclge_dev *hdev,
>> @@ -7412,6 +7439,24 @@ static int hclge_check_cls_flower(struct hclge_dev *hdev,
>>   		return -EOPNOTSUPP;
>>   	}
>>   
>> +	/* driver will parses classid into an action */
>> +	if (cls_flower->classid && flow_action_has_entries(&flow->action)) {
>> +		dev_err(&hdev->pdev->dev,
>> +			"please not set classid and action together\n");
>> +		return -EOPNOTSUPP;
>> +	}
>> +
>> +	if (!flow_action_has_entries(&flow->action) && !cls_flower->classid) {
>> +		dev_err(&hdev->pdev->dev, "please set action or classid\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (flow_action_has_entries(&flow->action) &&
>> +	    !flow_offload_has_one_action(&flow->action)) {
>> +		dev_err(&hdev->pdev->dev, "unsupported multiple actions\n");
>> +		return -EOPNOTSUPP;
>> +	}
>> +
>>   	return 0;
> Please use struct flow_cls_offload::common:extack and
> NL_SET_ERR_MSG_MOD() to return these to the caller instead of dumping
> them into the system logs.

Okay, I will modify all the error logs under hclge_add_cls_flower() to NL_SET_ERR_MSG_MOD().

Thanks,
Jijie Shao


  reply	other threads:[~2026-06-10  3:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 13:33 [PATCH V3 net-next 0/6] net: hns3: enhance tc flow offload support Jijie Shao
2026-06-02 13:33 ` [PATCH V3 net-next 1/6] net: hns3: adjust add_cls_flower() for support more action Jijie Shao
2026-06-02 13:33 ` [PATCH V3 net-next 2/6] net: hns3: improve the unused_tuple parameter setting Jijie Shao
2026-06-02 13:33 ` [PATCH V3 net-next 3/6] net: hns3: support two more actions for tc flow Jijie Shao
2026-06-06  0:40   ` Jakub Kicinski
2026-06-10  3:59     ` Jijie Shao [this message]
2026-06-02 13:33 ` [PATCH V3 net-next 4/6] net: hns3: support IP and tunnel VNI dissectors " Jijie Shao
2026-06-06  0:44   ` Jakub Kicinski
2026-06-02 13:33 ` [PATCH V3 net-next 5/6] net: hns3: debugfs support for dumping fd rules Jijie Shao
2026-06-02 13:33 ` [PATCH V3 net-next 6/6] net: hns3: move fd code to a separate file Jijie Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=479aefe2-cca3-4868-9796-97c17b4436f5@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=huangdonghua3@h-partners.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shenjian15@huawei.com \
    --cc=yangshuaisong@h-partners.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®