[06/11] net/hns3: support a maximun 256 FDIR counter
diff mbox series

Message ID 20200825115305.58490-7-huwei013@chinasoftinc.com
State Accepted
Delegated to: Ferruh Yigit
Headers show
  • updates for hns3 PMD driver
Related show


Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Wei Hu (Xavier) Aug. 25, 2020, 11:53 a.m. UTC
From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>

The FDIR counter was used to count the number of FDIR hit, the maximum
number of the counter is 128 based on kunpeng 920, and it was 256 based
on kunpeng 930.

The firmware is responsible to allocate counters for diffent PF devices,
so the available counter number of one PF may be bigger than 128.

Currently, there are two places using the counter in hns3 PMD driver:
1. Configure the counter. Driver uses the command whose opcode is
   HNS3_OPC_FD_AD_OP, now we extend one bit to hold the high bit of
   counter-id in the command format.
2. Query the statistic information of the counter. Driver uses the command
   whose opcode is HNS3_OPC_FD_COUNTER_OP, now the command already support
   16-bit counter-id.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
 drivers/net/hns3/hns3_fdir.c | 5 +++++
 1 file changed, 5 insertions(+)

diff mbox series

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 6ab439d06..5c3dd05f2 100644
--- 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_COUNTER_HIGH_BIT     7
 enum HNS3_PORT_TYPE {
@@ -424,6 +426,9 @@  static int hns3_fd_ad_config(struct hns3_hw *hw, int loc,
 	hns3_set_field(ad_data, HNS3_FD_AD_RULE_ID_M, HNS3_FD_AD_RULE_ID_S,
+	/* 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,