From 59200fd71a135cca8022525de81f2205b45d04ab Mon Sep 17 00:00:00 2001 From: "Wei Hu (Xavier)" Date: Tue, 25 Aug 2020 19:53:00 +0800 Subject: [PATCH] net/hns3: support maximum 256 flow director counter 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 different PF devices, so the available counter number of one PF may be bigger than 128. Currently, there are two places using the counter in 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 Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_fdir.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c index 6ab439d06b..5c3dd05f21 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 +#define HNS3_FD_AD_COUNTER_HIGH_BIT_B 26 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); + /* 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, -- 2.20.1