2019-11-02 17:14:42 +05:30
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2018-07-19 15:47:06 +01:00
|
|
|
// Copyright (c) 2016-2017 Hisilicon Limited.
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
#ifndef __HCLGE_MAIN_H
|
|
|
|
#define __HCLGE_MAIN_H
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/phy.h>
|
2018-05-01 19:56:04 +01:00
|
|
|
#include <linux/if_vlan.h>
|
2019-04-19 11:05:45 +08:00
|
|
|
#include <linux/kfifo.h>
|
2024-08-13 14:33:49 +01:00
|
|
|
|
2021-07-26 10:47:02 +08:00
|
|
|
#include <net/devlink.h>
|
2024-08-13 14:33:49 +01:00
|
|
|
#include <net/ipv6.h>
|
2018-05-01 19:56:04 +01:00
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
#include "hclge_cmd.h"
|
2021-06-10 21:38:56 +08:00
|
|
|
#include "hclge_ptp.h"
|
2017-08-02 16:59:48 +01:00
|
|
|
#include "hnae3.h"
|
2022-01-05 22:20:04 +08:00
|
|
|
#include "hclge_comm_rss.h"
|
2022-01-05 22:20:13 +08:00
|
|
|
#include "hclge_comm_tqp_stats.h"
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2018-05-19 16:53:19 +01:00
|
|
|
#define HCLGE_MOD_VERSION "1.0"
|
2017-08-02 16:59:48 +01:00
|
|
|
#define HCLGE_DRIVER_NAME "hclge"
|
|
|
|
|
2018-10-05 18:03:26 +01:00
|
|
|
#define HCLGE_MAX_PF_NUM 8
|
|
|
|
|
2021-02-05 16:32:46 +08:00
|
|
|
#define HCLGE_VF_VPORT_START_NUM 1
|
|
|
|
|
2019-01-23 07:39:37 +08:00
|
|
|
#define HCLGE_RD_FIRST_STATS_NUM 2
|
|
|
|
#define HCLGE_RD_OTHER_STATS_NUM 4
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
#define HCLGE_INVALID_VPORT 0xffff
|
|
|
|
|
|
|
|
#define HCLGE_PF_CFG_BLOCK_SIZE 32
|
|
|
|
#define HCLGE_PF_CFG_DESC_NUM \
|
|
|
|
(HCLGE_PF_CFG_BLOCK_SIZE / HCLGE_CFG_RD_LEN_BYTES)
|
|
|
|
|
|
|
|
#define HCLGE_VECTOR_REG_BASE 0x20000
|
net: hns3: add support for pf querying new interrupt resources
For HNAE3_DEVICE_VERSION_V3, a maximum of 1281 interrupt
resources are supported. To utilize these new resources,
extend the corresponding field or variable to 16bit type,
and remove the restriction of NIC client that only use a
maximum of 65 interrupt vectors. In addition, the I/O address
of the extended interrupt resources are different, so an extra
handler is needed.
Currently, the total number of interrupts is the sum of RoCE's
number and RoCE's offset (RoCE is in front of NIC), since
the number of both NIC and RoCE are same. For readability,
rewrite the corresponding field of the command, rename the
RoCE's offset field as the number of NIC interrupts, then
the total number of interrupts is sum of the number of RoCE
and NIC, and replace vport->back with hdev in
hclge_init_roce_base_info() for simplifying the code.
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-20 17:16:21 +08:00
|
|
|
#define HCLGE_VECTOR_EXT_REG_BASE 0x30000
|
2017-11-02 20:45:18 +08:00
|
|
|
#define HCLGE_MISC_VECTOR_REG_BASE 0x20400
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
#define HCLGE_VECTOR_REG_OFFSET 0x4
|
net: hns3: add support for pf querying new interrupt resources
For HNAE3_DEVICE_VERSION_V3, a maximum of 1281 interrupt
resources are supported. To utilize these new resources,
extend the corresponding field or variable to 16bit type,
and remove the restriction of NIC client that only use a
maximum of 65 interrupt vectors. In addition, the I/O address
of the extended interrupt resources are different, so an extra
handler is needed.
Currently, the total number of interrupts is the sum of RoCE's
number and RoCE's offset (RoCE is in front of NIC), since
the number of both NIC and RoCE are same. For readability,
rewrite the corresponding field of the command, rename the
RoCE's offset field as the number of NIC interrupts, then
the total number of interrupts is sum of the number of RoCE
and NIC, and replace vport->back with hdev in
hclge_init_roce_base_info() for simplifying the code.
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-11-20 17:16:21 +08:00
|
|
|
#define HCLGE_VECTOR_REG_OFFSET_H 0x1000
|
2017-08-02 16:59:48 +01:00
|
|
|
#define HCLGE_VECTOR_VF_OFFSET 0x100000
|
|
|
|
|
2021-08-27 17:28:23 +08:00
|
|
|
#define HCLGE_NIC_CSQ_DEPTH_REG 0x27008
|
2018-11-29 16:40:59 +00:00
|
|
|
|
|
|
|
/* bar registers for common func */
|
|
|
|
#define HCLGE_GRO_EN_REG 0x28000
|
2021-05-14 11:25:09 +08:00
|
|
|
#define HCLGE_RXD_ADV_LAYOUT_EN_REG 0x28008
|
2018-11-29 16:40:59 +00:00
|
|
|
|
|
|
|
/* bar registers for rcb */
|
|
|
|
#define HCLGE_RING_RX_ADDR_L_REG 0x80000
|
|
|
|
#define HCLGE_RING_RX_ADDR_H_REG 0x80004
|
|
|
|
#define HCLGE_RING_RX_BD_NUM_REG 0x80008
|
|
|
|
#define HCLGE_RING_RX_BD_LENGTH_REG 0x8000C
|
|
|
|
#define HCLGE_RING_RX_MERGE_EN_REG 0x80014
|
|
|
|
#define HCLGE_RING_RX_TAIL_REG 0x80018
|
|
|
|
#define HCLGE_RING_RX_HEAD_REG 0x8001C
|
|
|
|
#define HCLGE_RING_RX_FBD_NUM_REG 0x80020
|
|
|
|
#define HCLGE_RING_RX_OFFSET_REG 0x80024
|
|
|
|
#define HCLGE_RING_RX_FBD_OFFSET_REG 0x80028
|
|
|
|
#define HCLGE_RING_RX_STASH_REG 0x80030
|
|
|
|
#define HCLGE_RING_RX_BD_ERR_REG 0x80034
|
|
|
|
#define HCLGE_RING_TX_ADDR_L_REG 0x80040
|
|
|
|
#define HCLGE_RING_TX_ADDR_H_REG 0x80044
|
|
|
|
#define HCLGE_RING_TX_BD_NUM_REG 0x80048
|
|
|
|
#define HCLGE_RING_TX_PRIORITY_REG 0x8004C
|
|
|
|
#define HCLGE_RING_TX_TC_REG 0x80050
|
|
|
|
#define HCLGE_RING_TX_MERGE_EN_REG 0x80054
|
|
|
|
#define HCLGE_RING_TX_TAIL_REG 0x80058
|
|
|
|
#define HCLGE_RING_TX_HEAD_REG 0x8005C
|
|
|
|
#define HCLGE_RING_TX_FBD_NUM_REG 0x80060
|
|
|
|
#define HCLGE_RING_TX_OFFSET_REG 0x80064
|
|
|
|
#define HCLGE_RING_TX_EBD_NUM_REG 0x80068
|
|
|
|
#define HCLGE_RING_TX_EBD_OFFSET_REG 0x80070
|
|
|
|
#define HCLGE_RING_TX_BD_ERR_REG 0x80074
|
|
|
|
#define HCLGE_RING_EN_REG 0x80090
|
|
|
|
|
|
|
|
/* bar registers for tqp interrupt */
|
|
|
|
#define HCLGE_TQP_INTR_CTRL_REG 0x20000
|
|
|
|
#define HCLGE_TQP_INTR_GL0_REG 0x20100
|
|
|
|
#define HCLGE_TQP_INTR_GL1_REG 0x20200
|
|
|
|
#define HCLGE_TQP_INTR_GL2_REG 0x20300
|
|
|
|
#define HCLGE_TQP_INTR_RL_REG 0x20900
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
#define HCLGE_RSS_IND_TBL_SIZE 512
|
2017-10-10 16:42:05 +08:00
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
#define HCLGE_RSS_TC_SIZE_0 1
|
|
|
|
#define HCLGE_RSS_TC_SIZE_1 2
|
|
|
|
#define HCLGE_RSS_TC_SIZE_2 4
|
|
|
|
#define HCLGE_RSS_TC_SIZE_3 8
|
|
|
|
#define HCLGE_RSS_TC_SIZE_4 16
|
|
|
|
#define HCLGE_RSS_TC_SIZE_5 32
|
|
|
|
#define HCLGE_RSS_TC_SIZE_6 64
|
|
|
|
#define HCLGE_RSS_TC_SIZE_7 128
|
|
|
|
|
2018-10-05 18:03:26 +01:00
|
|
|
#define HCLGE_UMV_TBL_SIZE 3072
|
|
|
|
#define HCLGE_DEFAULT_UMV_SPACE_PER_PF \
|
|
|
|
(HCLGE_UMV_TBL_SIZE / HCLGE_MAX_PF_NUM)
|
|
|
|
|
2019-08-28 22:23:12 +08:00
|
|
|
#define HCLGE_TQP_RESET_TRY_TIMES 200
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
#define HCLGE_PHY_PAGE_MDIX 0
|
|
|
|
#define HCLGE_PHY_PAGE_COPPER 0
|
|
|
|
|
|
|
|
/* Page Selection Reg. */
|
|
|
|
#define HCLGE_PHY_PAGE_REG 22
|
|
|
|
|
|
|
|
/* Copper Specific Control Register */
|
|
|
|
#define HCLGE_PHY_CSC_REG 16
|
|
|
|
|
|
|
|
/* Copper Specific Status Register */
|
|
|
|
#define HCLGE_PHY_CSS_REG 17
|
|
|
|
|
2018-07-19 15:47:00 +01:00
|
|
|
#define HCLGE_PHY_MDIX_CTRL_S 5
|
2017-10-09 15:43:58 +08:00
|
|
|
#define HCLGE_PHY_MDIX_CTRL_M GENMASK(6, 5)
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2018-07-19 15:47:00 +01:00
|
|
|
#define HCLGE_PHY_MDIX_STATUS_B 6
|
|
|
|
#define HCLGE_PHY_SPEED_DUP_RESOLVE_B 11
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2020-01-21 16:42:08 +08:00
|
|
|
#define HCLGE_GET_DFX_REG_TYPE_CNT 4
|
|
|
|
|
2017-12-22 12:21:46 +08:00
|
|
|
/* Factor used to calculate offset and bitmap of VF num */
|
|
|
|
#define HCLGE_VF_NUM_PER_CMD 64
|
|
|
|
|
2021-02-05 16:32:49 +08:00
|
|
|
#define HCLGE_MAX_QSET_NUM 1024
|
|
|
|
|
2021-05-14 11:25:18 +08:00
|
|
|
#define HCLGE_DBG_RESET_INFO_LEN 1024
|
|
|
|
|
2018-10-01 12:46:42 +01:00
|
|
|
enum HLCGE_PORT_TYPE {
|
|
|
|
HOST_PORT,
|
|
|
|
NETWORK_PORT
|
|
|
|
};
|
|
|
|
|
net: hns3: not allow SSU loopback while execute ethtool -t dev
The current loopback mode is to add 0x1F to the SMAC address
as the DMAC address and enable the promiscuous mode.
However, if the VF address is the same as the DMAC address,
the loopback test fails.
Loopback can be enabled in three places: SSU, MAC, and serdes.
By default, SSU loopback is enabled, so if the SMAC and the DMAC
are the same, the packets are looped back in the SSU. If SSU loopback
is disabled, packets can reach MAC even if SMAC is the same as DMAC.
Therefore, this patch disables the SSU loopback before the loopback
test. In this way, the SMAC and DMAC can be the same, and the
promiscuous mode does not need to be enabled. And this is not
valid in version 0x20.
This patch also uses a macro to replace 0x1F.
Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-28 22:23:16 +08:00
|
|
|
#define PF_VPORT_ID 0
|
|
|
|
|
2018-10-01 12:46:42 +01:00
|
|
|
#define HCLGE_PF_ID_S 0
|
|
|
|
#define HCLGE_PF_ID_M GENMASK(2, 0)
|
|
|
|
#define HCLGE_VF_ID_S 3
|
|
|
|
#define HCLGE_VF_ID_M GENMASK(10, 3)
|
|
|
|
#define HCLGE_PORT_TYPE_B 11
|
|
|
|
#define HCLGE_NETWORK_PORT_ID_S 0
|
|
|
|
#define HCLGE_NETWORK_PORT_ID_M GENMASK(3, 0)
|
|
|
|
|
2017-11-02 20:45:19 +08:00
|
|
|
/* Reset related Registers */
|
2018-11-09 22:07:53 +08:00
|
|
|
#define HCLGE_PF_OTHER_INT_REG 0x20600
|
2017-11-02 20:45:19 +08:00
|
|
|
#define HCLGE_MISC_RESET_STS_REG 0x20700
|
2018-07-16 16:36:22 +01:00
|
|
|
#define HCLGE_MISC_VECTOR_INT_STS 0x20800
|
2017-11-02 20:45:19 +08:00
|
|
|
#define HCLGE_GLOBAL_RESET_REG 0x20A00
|
2018-07-19 15:47:02 +01:00
|
|
|
#define HCLGE_GLOBAL_RESET_BIT 0
|
|
|
|
#define HCLGE_CORE_RESET_BIT 1
|
net: hns3: add error handler for hclge_reset()
When hclge_reset() is called, it may fail for several reasons.
For example, an higher-level reset event occurs, memory allocation
failure, hardware reset timeout, etc. Therefore, it is necessary
to add corresponding error handling for these situations.
1. A high-level reset is required due to a high-level reset failure.
2. For memory allocation failure, a high-level reset is initiated by
the timer to recover. The reason for using the timer is to prevent this
new high-level reset to interrupt the reset process of other pf/vf;
3. For the case of hardware reset timeout, reschedule the reset task
to wait for the hardware to complete the reset.
For memory allocation failure and reset timeouts, in order to prevent
an infinite number of scheduled reset tasks, the number of error
recovery needs to be limited.
This patch also add some reset related debug log printing.
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-11-07 12:06:17 +08:00
|
|
|
#define HCLGE_IMP_RESET_BIT 2
|
2019-11-20 10:07:15 +08:00
|
|
|
#define HCLGE_RESET_INT_M GENMASK(7, 5)
|
2017-11-02 20:45:19 +08:00
|
|
|
#define HCLGE_FUN_RST_ING 0x20C00
|
|
|
|
#define HCLGE_FUN_RST_ING_B 0
|
|
|
|
|
|
|
|
/* Vector0 register bits define */
|
2021-06-10 21:38:56 +08:00
|
|
|
#define HCLGE_VECTOR0_REG_PTP_INT_B 0
|
2017-11-02 20:45:19 +08:00
|
|
|
#define HCLGE_VECTOR0_GLOBALRESET_INT_B 5
|
|
|
|
#define HCLGE_VECTOR0_CORERESET_INT_B 6
|
|
|
|
#define HCLGE_VECTOR0_IMPRESET_INT_B 7
|
|
|
|
|
2017-12-14 18:03:09 +00:00
|
|
|
/* Vector0 interrupt CMDQ event source register(RW) */
|
|
|
|
#define HCLGE_VECTOR0_CMDQ_SRC_REG 0x27100
|
|
|
|
/* CMDQ register bits for RX event(=MBX event) */
|
|
|
|
#define HCLGE_VECTOR0_RX_CMDQ_INT_B 1
|
|
|
|
|
2018-11-09 22:07:53 +08:00
|
|
|
#define HCLGE_VECTOR0_IMP_RESET_INT_B 1
|
2019-08-28 22:23:13 +08:00
|
|
|
#define HCLGE_VECTOR0_IMP_CMDQ_ERR_B 4U
|
|
|
|
#define HCLGE_VECTOR0_IMP_RD_POISON_B 5U
|
2021-06-08 21:08:27 +08:00
|
|
|
#define HCLGE_VECTOR0_ALL_MSIX_ERR_B 6U
|
2021-08-10 21:28:48 +08:00
|
|
|
#define HCLGE_TRIGGER_IMP_RESET_B 7U
|
2018-11-09 22:07:53 +08:00
|
|
|
|
2022-02-07 09:44:23 +08:00
|
|
|
#define HCLGE_TQP_MEM_SIZE 0x10000
|
|
|
|
#define HCLGE_MEM_BAR 4
|
|
|
|
/* in the bar4, the first half is for roce, and the second half is for nic */
|
|
|
|
#define HCLGE_NIC_MEM_OFFSET(hdev) \
|
|
|
|
(pci_resource_len((hdev)->pdev, HCLGE_MEM_BAR) >> 1)
|
|
|
|
#define HCLGE_TQP_MEM_OFFSET(hdev, i) \
|
|
|
|
(HCLGE_NIC_MEM_OFFSET(hdev) + HCLGE_TQP_MEM_SIZE * (i))
|
|
|
|
|
2018-01-05 18:18:19 +08:00
|
|
|
#define HCLGE_MAC_DEFAULT_FRAME \
|
2018-11-18 03:19:10 +00:00
|
|
|
(ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN + ETH_DATA_LEN)
|
2018-01-05 18:18:19 +08:00
|
|
|
#define HCLGE_MAC_MIN_FRAME 64
|
|
|
|
#define HCLGE_MAC_MAX_FRAME 9728
|
|
|
|
|
2018-03-21 15:49:27 +08:00
|
|
|
#define HCLGE_SUPPORT_1G_BIT BIT(0)
|
|
|
|
#define HCLGE_SUPPORT_10G_BIT BIT(1)
|
|
|
|
#define HCLGE_SUPPORT_25G_BIT BIT(2)
|
2023-10-24 11:20:34 +08:00
|
|
|
#define HCLGE_SUPPORT_50G_R2_BIT BIT(3)
|
|
|
|
#define HCLGE_SUPPORT_100G_R4_BIT BIT(4)
|
2019-05-03 17:50:37 +08:00
|
|
|
/* to be compatible with exsit board */
|
|
|
|
#define HCLGE_SUPPORT_40G_BIT BIT(5)
|
2019-02-20 10:32:43 +08:00
|
|
|
#define HCLGE_SUPPORT_100M_BIT BIT(6)
|
|
|
|
#define HCLGE_SUPPORT_10M_BIT BIT(7)
|
2024-03-07 09:01:09 +08:00
|
|
|
#define HCLGE_SUPPORT_200G_R4_EXT_BIT BIT(8)
|
2023-10-24 11:20:34 +08:00
|
|
|
#define HCLGE_SUPPORT_50G_R1_BIT BIT(9)
|
|
|
|
#define HCLGE_SUPPORT_100G_R2_BIT BIT(10)
|
2024-03-07 09:01:09 +08:00
|
|
|
#define HCLGE_SUPPORT_200G_R4_BIT BIT(11)
|
2023-10-24 11:20:34 +08:00
|
|
|
|
2019-02-20 10:32:43 +08:00
|
|
|
#define HCLGE_SUPPORT_GE \
|
|
|
|
(HCLGE_SUPPORT_1G_BIT | HCLGE_SUPPORT_100M_BIT | HCLGE_SUPPORT_10M_BIT)
|
2023-10-24 11:20:34 +08:00
|
|
|
#define HCLGE_SUPPORT_50G_BITS \
|
|
|
|
(HCLGE_SUPPORT_50G_R2_BIT | HCLGE_SUPPORT_50G_R1_BIT)
|
|
|
|
#define HCLGE_SUPPORT_100G_BITS \
|
|
|
|
(HCLGE_SUPPORT_100G_R4_BIT | HCLGE_SUPPORT_100G_R2_BIT)
|
2024-03-07 09:01:09 +08:00
|
|
|
#define HCLGE_SUPPORT_200G_BITS \
|
|
|
|
(HCLGE_SUPPORT_200G_R4_EXT_BIT | HCLGE_SUPPORT_200G_R4_BIT)
|
2018-03-21 15:49:27 +08:00
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
enum HCLGE_DEV_STATE {
|
|
|
|
HCLGE_STATE_REINITING,
|
|
|
|
HCLGE_STATE_DOWN,
|
|
|
|
HCLGE_STATE_DISABLED,
|
|
|
|
HCLGE_STATE_REMOVING,
|
2019-05-28 17:02:54 +08:00
|
|
|
HCLGE_STATE_NIC_REGISTERED,
|
2019-05-28 17:02:55 +08:00
|
|
|
HCLGE_STATE_ROCE_REGISTERED,
|
2017-08-02 16:59:48 +01:00
|
|
|
HCLGE_STATE_SERVICE_INITED,
|
2017-12-04 01:29:54 +00:00
|
|
|
HCLGE_STATE_RST_SERVICE_SCHED,
|
|
|
|
HCLGE_STATE_RST_HANDLING,
|
2017-12-14 18:03:09 +00:00
|
|
|
HCLGE_STATE_MBX_SERVICE_SCHED,
|
2017-08-02 16:59:48 +01:00
|
|
|
HCLGE_STATE_MBX_HANDLING,
|
2021-06-07 19:18:10 +08:00
|
|
|
HCLGE_STATE_ERR_SERVICE_SCHED,
|
2018-01-05 18:18:10 +08:00
|
|
|
HCLGE_STATE_STATISTICS_UPDATING,
|
2019-12-14 10:06:38 +08:00
|
|
|
HCLGE_STATE_LINK_UPDATING,
|
2019-12-14 10:06:41 +08:00
|
|
|
HCLGE_STATE_RST_FAIL,
|
net: hns3: refactor flow director configuration
Currently, the flow director rule of aRFS is configured in
the IO path. It's time-consuming. So move out the configuration,
and configure it asynchronously. And keep ethtool and tc flower
rule using synchronous way, otherwise the application maybe
unable to know the rule is installed or pending.
Add a state member for each flow director rule to indicate the
rule state. There are 4 states:
TO_ADD: the rule is waiting to add to hardware
TO_DEL: the rule is waiting to remove from hardware
DELETED: the rule has been removed from hardware. It's a middle
state, used to remove the rule node in the fd_rule_list.
ACTIVE: the rule is already added in hardware
For asynchronous way, when receive a new request to add or delete
flow director rule by aRFS, update the rule list, then request to
schedule the service task to finish the configuration.
For synchronous way, when receive a new request to add or delete
flow director rule by ethtool or tc flower, configure hardware
directly, then update the rule list if success.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-22 11:52:00 +08:00
|
|
|
HCLGE_STATE_FD_TBL_CHANGED,
|
|
|
|
HCLGE_STATE_FD_CLEAR_ALL,
|
2021-03-22 11:52:02 +08:00
|
|
|
HCLGE_STATE_FD_USER_DEF_CHANGED,
|
2021-06-10 21:38:56 +08:00
|
|
|
HCLGE_STATE_PTP_EN,
|
|
|
|
HCLGE_STATE_PTP_TX_HANDLING,
|
2022-09-06 17:12:22 +08:00
|
|
|
HCLGE_STATE_FEC_STATS_UPDATING,
|
2017-08-02 16:59:48 +01:00
|
|
|
HCLGE_STATE_MAX
|
|
|
|
};
|
|
|
|
|
2017-12-04 01:29:53 +00:00
|
|
|
enum hclge_evt_cause {
|
|
|
|
HCLGE_VECTOR0_EVENT_RST,
|
|
|
|
HCLGE_VECTOR0_EVENT_MBX,
|
2018-12-07 21:08:06 +00:00
|
|
|
HCLGE_VECTOR0_EVENT_ERR,
|
2021-06-10 21:38:56 +08:00
|
|
|
HCLGE_VECTOR0_EVENT_PTP,
|
2017-12-04 01:29:53 +00:00
|
|
|
HCLGE_VECTOR0_EVENT_OTHER,
|
|
|
|
};
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
enum HCLGE_MAC_SPEED {
|
2018-11-26 18:43:00 +00:00
|
|
|
HCLGE_MAC_SPEED_UNKNOWN = 0, /* unknown */
|
2017-08-02 16:59:48 +01:00
|
|
|
HCLGE_MAC_SPEED_10M = 10, /* 10 Mbps */
|
|
|
|
HCLGE_MAC_SPEED_100M = 100, /* 100 Mbps */
|
|
|
|
HCLGE_MAC_SPEED_1G = 1000, /* 1000 Mbps = 1 Gbps */
|
|
|
|
HCLGE_MAC_SPEED_10G = 10000, /* 10000 Mbps = 10 Gbps */
|
|
|
|
HCLGE_MAC_SPEED_25G = 25000, /* 25000 Mbps = 25 Gbps */
|
|
|
|
HCLGE_MAC_SPEED_40G = 40000, /* 40000 Mbps = 40 Gbps */
|
|
|
|
HCLGE_MAC_SPEED_50G = 50000, /* 50000 Mbps = 50 Gbps */
|
2020-09-25 08:26:17 +08:00
|
|
|
HCLGE_MAC_SPEED_100G = 100000, /* 100000 Mbps = 100 Gbps */
|
|
|
|
HCLGE_MAC_SPEED_200G = 200000 /* 200000 Mbps = 200 Gbps */
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum HCLGE_MAC_DUPLEX {
|
|
|
|
HCLGE_MAC_HALF,
|
|
|
|
HCLGE_MAC_FULL
|
|
|
|
};
|
|
|
|
|
2024-03-07 09:01:10 +08:00
|
|
|
/* hilink version */
|
|
|
|
enum hclge_hilink_version {
|
|
|
|
HCLGE_HILINK_H32 = 0,
|
|
|
|
HCLGE_HILINK_H60 = 1,
|
|
|
|
};
|
|
|
|
|
2019-05-03 17:50:37 +08:00
|
|
|
#define QUERY_SFP_SPEED 0
|
|
|
|
#define QUERY_ACTIVE_SPEED 1
|
|
|
|
|
2023-03-27 21:55:04 +08:00
|
|
|
struct hclge_wol_info {
|
|
|
|
u32 wol_support_mode; /* store the wake on lan info */
|
|
|
|
u32 wol_current_mode;
|
|
|
|
u8 wol_sopass[SOPASS_MAX];
|
|
|
|
u8 wol_sopass_size;
|
|
|
|
};
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_mac {
|
2020-02-19 09:23:32 +08:00
|
|
|
u8 mac_id;
|
2017-08-02 16:59:48 +01:00
|
|
|
u8 phy_addr;
|
|
|
|
u8 flag;
|
2019-05-03 17:50:37 +08:00
|
|
|
u8 media_type; /* port media type, e.g. fibre/copper/backplane */
|
2017-08-02 16:59:48 +01:00
|
|
|
u8 mac_addr[ETH_ALEN];
|
|
|
|
u8 autoneg;
|
2024-05-07 21:42:18 +08:00
|
|
|
u8 req_autoneg;
|
2017-08-02 16:59:48 +01:00
|
|
|
u8 duplex;
|
2024-05-07 21:42:18 +08:00
|
|
|
u8 req_duplex;
|
2019-05-03 17:50:37 +08:00
|
|
|
u8 support_autoneg;
|
|
|
|
u8 speed_type; /* 0: sfp speed, 1: active speed */
|
2022-09-06 17:12:23 +08:00
|
|
|
u8 lane_num;
|
2017-08-02 16:59:48 +01:00
|
|
|
u32 speed;
|
2024-05-07 21:42:18 +08:00
|
|
|
u32 req_speed;
|
2019-10-08 09:20:07 +08:00
|
|
|
u32 max_speed;
|
2019-05-03 17:50:37 +08:00
|
|
|
u32 speed_ability; /* speed ability supported by current media */
|
|
|
|
u32 module_type; /* sub media type, e.g. kr/cr/sr/lr */
|
2019-05-03 17:50:39 +08:00
|
|
|
u32 fec_mode; /* active fec mode */
|
|
|
|
u32 user_fec_mode;
|
|
|
|
u32 fec_ability;
|
2020-09-08 10:59:50 +08:00
|
|
|
int link; /* store the link status of mac & phy (if phy exists) */
|
2023-03-27 21:55:04 +08:00
|
|
|
struct hclge_wol_info wol;
|
2017-08-02 16:59:48 +01:00
|
|
|
struct phy_device *phydev;
|
|
|
|
struct mii_bus *mdio_bus;
|
|
|
|
phy_interface_t phy_if;
|
2018-03-21 15:49:27 +08:00
|
|
|
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
|
|
|
|
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_hw {
|
2021-12-31 18:22:35 +08:00
|
|
|
struct hclge_comm_hw hw;
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_mac mac;
|
|
|
|
int num_vec;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum hclge_fc_mode {
|
|
|
|
HCLGE_FC_NONE,
|
|
|
|
HCLGE_FC_RX_PAUSE,
|
|
|
|
HCLGE_FC_TX_PAUSE,
|
|
|
|
HCLGE_FC_FULL,
|
|
|
|
HCLGE_FC_PFC,
|
|
|
|
HCLGE_FC_DEFAULT
|
|
|
|
};
|
|
|
|
|
2021-05-31 10:38:45 +08:00
|
|
|
#define HCLGE_FILTER_TYPE_VF 0
|
|
|
|
#define HCLGE_FILTER_TYPE_PORT 1
|
|
|
|
#define HCLGE_FILTER_FE_EGRESS_V1_B BIT(0)
|
|
|
|
#define HCLGE_FILTER_FE_NIC_INGRESS_B BIT(0)
|
|
|
|
#define HCLGE_FILTER_FE_NIC_EGRESS_B BIT(1)
|
|
|
|
#define HCLGE_FILTER_FE_ROCE_INGRESS_B BIT(2)
|
|
|
|
#define HCLGE_FILTER_FE_ROCE_EGRESS_B BIT(3)
|
|
|
|
#define HCLGE_FILTER_FE_EGRESS (HCLGE_FILTER_FE_NIC_EGRESS_B \
|
|
|
|
| HCLGE_FILTER_FE_ROCE_EGRESS_B)
|
|
|
|
#define HCLGE_FILTER_FE_INGRESS (HCLGE_FILTER_FE_NIC_INGRESS_B \
|
|
|
|
| HCLGE_FILTER_FE_ROCE_INGRESS_B)
|
|
|
|
|
2021-05-31 10:38:42 +08:00
|
|
|
enum hclge_vlan_fltr_cap {
|
|
|
|
HCLGE_VLAN_FLTR_DEF,
|
|
|
|
HCLGE_VLAN_FLTR_CAN_MDF,
|
|
|
|
};
|
2019-08-01 11:55:34 +08:00
|
|
|
enum hclge_link_fail_code {
|
|
|
|
HCLGE_LF_NORMAL,
|
|
|
|
HCLGE_LF_REF_CLOCK_LOST,
|
|
|
|
HCLGE_LF_XSFP_TX_DISABLE,
|
|
|
|
HCLGE_LF_XSFP_ABSENT,
|
|
|
|
};
|
|
|
|
|
2020-07-21 19:03:54 +08:00
|
|
|
#define HCLGE_LINK_STATUS_DOWN 0
|
|
|
|
#define HCLGE_LINK_STATUS_UP 1
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
#define HCLGE_PG_NUM 4
|
|
|
|
#define HCLGE_SCH_MODE_SP 0
|
|
|
|
#define HCLGE_SCH_MODE_DWRR 1
|
|
|
|
struct hclge_pg_info {
|
|
|
|
u8 pg_id;
|
|
|
|
u8 pg_sch_mode; /* 0: sp; 1: dwrr */
|
|
|
|
u8 tc_bit_map;
|
|
|
|
u32 bw_limit;
|
|
|
|
u8 tc_dwrr[HNAE3_MAX_TC];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_tc_info {
|
|
|
|
u8 tc_id;
|
|
|
|
u8 tc_sch_mode; /* 0: sp; 1: dwrr */
|
|
|
|
u8 pgid;
|
|
|
|
u32 bw_limit;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_cfg {
|
|
|
|
u8 tc_num;
|
2021-05-31 10:38:42 +08:00
|
|
|
u8 vlan_fliter_cap;
|
2017-08-02 16:59:48 +01:00
|
|
|
u16 tqp_desc_num;
|
|
|
|
u16 rx_buf_len;
|
2020-12-10 11:42:10 +08:00
|
|
|
u16 vf_rss_size_max;
|
|
|
|
u16 pf_rss_size_max;
|
2017-08-02 16:59:48 +01:00
|
|
|
u8 phy_addr;
|
|
|
|
u8 media_type;
|
|
|
|
u8 mac_addr[ETH_ALEN];
|
|
|
|
u8 default_speed;
|
|
|
|
u32 numa_node_map;
|
2021-06-16 14:36:14 +08:00
|
|
|
u32 tx_spare_buf_size;
|
2020-09-25 08:26:17 +08:00
|
|
|
u16 speed_ability;
|
2018-10-05 18:03:26 +01:00
|
|
|
u16 umv_space;
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_tm_info {
|
|
|
|
u8 num_tc;
|
|
|
|
u8 num_pg; /* It must be 1 if vNET-Base schd */
|
|
|
|
u8 pg_dwrr[HCLGE_PG_NUM];
|
2017-09-20 18:52:58 +08:00
|
|
|
u8 prio_tc[HNAE3_MAX_USER_PRIO];
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_pg_info pg_info[HCLGE_PG_NUM];
|
|
|
|
struct hclge_tc_info tc_info[HNAE3_MAX_TC];
|
|
|
|
enum hclge_fc_mode fc_mode;
|
|
|
|
u8 hw_pfc_map; /* Allow for packet drop or not on this TC */
|
2019-01-23 07:39:38 +08:00
|
|
|
u8 pfc_en; /* PFC enabled or not for user priority */
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
2021-10-24 17:41:11 +08:00
|
|
|
/* max number of mac statistics on each version */
|
2021-11-10 21:42:54 +08:00
|
|
|
#define HCLGE_MAC_STATS_MAX_NUM_V1 87
|
2021-10-24 17:41:11 +08:00
|
|
|
#define HCLGE_MAC_STATS_MAX_NUM_V2 105
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_comm_stats_str {
|
|
|
|
char desc[ETH_GSTRING_LEN];
|
2021-10-24 17:41:11 +08:00
|
|
|
u32 stats_num;
|
2017-08-02 16:59:48 +01:00
|
|
|
unsigned long offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* mac stats ,opcode id: 0x0032 */
|
|
|
|
struct hclge_mac_stats {
|
|
|
|
u64 mac_tx_mac_pause_num;
|
|
|
|
u64 mac_rx_mac_pause_num;
|
2021-10-24 17:41:09 +08:00
|
|
|
u64 rsv0;
|
2017-08-02 16:59:48 +01:00
|
|
|
u64 mac_tx_pfc_pri0_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri1_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri2_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri3_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri4_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri5_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri6_pkt_num;
|
|
|
|
u64 mac_tx_pfc_pri7_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri0_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri1_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri2_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri3_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri4_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri5_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri6_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pri7_pkt_num;
|
|
|
|
u64 mac_tx_total_pkt_num;
|
|
|
|
u64 mac_tx_total_oct_num;
|
|
|
|
u64 mac_tx_good_pkt_num;
|
|
|
|
u64 mac_tx_bad_pkt_num;
|
|
|
|
u64 mac_tx_good_oct_num;
|
|
|
|
u64 mac_tx_bad_oct_num;
|
|
|
|
u64 mac_tx_uni_pkt_num;
|
|
|
|
u64 mac_tx_multi_pkt_num;
|
|
|
|
u64 mac_tx_broad_pkt_num;
|
|
|
|
u64 mac_tx_undersize_pkt_num;
|
2018-01-05 18:18:08 +08:00
|
|
|
u64 mac_tx_oversize_pkt_num;
|
2017-08-02 16:59:48 +01:00
|
|
|
u64 mac_tx_64_oct_pkt_num;
|
|
|
|
u64 mac_tx_65_127_oct_pkt_num;
|
|
|
|
u64 mac_tx_128_255_oct_pkt_num;
|
|
|
|
u64 mac_tx_256_511_oct_pkt_num;
|
|
|
|
u64 mac_tx_512_1023_oct_pkt_num;
|
|
|
|
u64 mac_tx_1024_1518_oct_pkt_num;
|
2018-01-05 18:18:24 +08:00
|
|
|
u64 mac_tx_1519_2047_oct_pkt_num;
|
|
|
|
u64 mac_tx_2048_4095_oct_pkt_num;
|
|
|
|
u64 mac_tx_4096_8191_oct_pkt_num;
|
2021-10-24 17:41:09 +08:00
|
|
|
u64 rsv1;
|
2018-05-01 19:56:05 +01:00
|
|
|
u64 mac_tx_8192_9216_oct_pkt_num;
|
|
|
|
u64 mac_tx_9217_12287_oct_pkt_num;
|
2018-01-05 18:18:24 +08:00
|
|
|
u64 mac_tx_12288_16383_oct_pkt_num;
|
|
|
|
u64 mac_tx_1519_max_good_oct_pkt_num;
|
|
|
|
u64 mac_tx_1519_max_bad_oct_pkt_num;
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
u64 mac_rx_total_pkt_num;
|
|
|
|
u64 mac_rx_total_oct_num;
|
|
|
|
u64 mac_rx_good_pkt_num;
|
|
|
|
u64 mac_rx_bad_pkt_num;
|
|
|
|
u64 mac_rx_good_oct_num;
|
|
|
|
u64 mac_rx_bad_oct_num;
|
|
|
|
u64 mac_rx_uni_pkt_num;
|
|
|
|
u64 mac_rx_multi_pkt_num;
|
|
|
|
u64 mac_rx_broad_pkt_num;
|
|
|
|
u64 mac_rx_undersize_pkt_num;
|
2018-01-05 18:18:08 +08:00
|
|
|
u64 mac_rx_oversize_pkt_num;
|
2017-08-02 16:59:48 +01:00
|
|
|
u64 mac_rx_64_oct_pkt_num;
|
|
|
|
u64 mac_rx_65_127_oct_pkt_num;
|
|
|
|
u64 mac_rx_128_255_oct_pkt_num;
|
|
|
|
u64 mac_rx_256_511_oct_pkt_num;
|
|
|
|
u64 mac_rx_512_1023_oct_pkt_num;
|
|
|
|
u64 mac_rx_1024_1518_oct_pkt_num;
|
2018-01-05 18:18:24 +08:00
|
|
|
u64 mac_rx_1519_2047_oct_pkt_num;
|
|
|
|
u64 mac_rx_2048_4095_oct_pkt_num;
|
|
|
|
u64 mac_rx_4096_8191_oct_pkt_num;
|
2021-10-24 17:41:09 +08:00
|
|
|
u64 rsv2;
|
2018-05-01 19:56:05 +01:00
|
|
|
u64 mac_rx_8192_9216_oct_pkt_num;
|
|
|
|
u64 mac_rx_9217_12287_oct_pkt_num;
|
2018-01-05 18:18:24 +08:00
|
|
|
u64 mac_rx_12288_16383_oct_pkt_num;
|
|
|
|
u64 mac_rx_1519_max_good_oct_pkt_num;
|
|
|
|
u64 mac_rx_1519_max_bad_oct_pkt_num;
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2018-01-05 18:18:07 +08:00
|
|
|
u64 mac_tx_fragment_pkt_num;
|
|
|
|
u64 mac_tx_undermin_pkt_num;
|
|
|
|
u64 mac_tx_jabber_pkt_num;
|
|
|
|
u64 mac_tx_err_all_pkt_num;
|
|
|
|
u64 mac_tx_from_app_good_pkt_num;
|
|
|
|
u64 mac_tx_from_app_bad_pkt_num;
|
|
|
|
u64 mac_rx_fragment_pkt_num;
|
|
|
|
u64 mac_rx_undermin_pkt_num;
|
|
|
|
u64 mac_rx_jabber_pkt_num;
|
|
|
|
u64 mac_rx_fcs_err_pkt_num;
|
|
|
|
u64 mac_rx_send_app_good_pkt_num;
|
|
|
|
u64 mac_rx_send_app_bad_pkt_num;
|
2019-01-23 07:39:37 +08:00
|
|
|
u64 mac_tx_pfc_pause_pkt_num;
|
|
|
|
u64 mac_rx_pfc_pause_pkt_num;
|
|
|
|
u64 mac_tx_ctrl_pkt_num;
|
|
|
|
u64 mac_rx_ctrl_pkt_num;
|
2021-10-24 17:41:11 +08:00
|
|
|
|
|
|
|
/* duration of pfc */
|
|
|
|
u64 mac_tx_pfc_pri0_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri1_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri2_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri3_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri4_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri5_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri6_xoff_time;
|
|
|
|
u64 mac_tx_pfc_pri7_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri0_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri1_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri2_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri3_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri4_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri5_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri6_xoff_time;
|
|
|
|
u64 mac_rx_pfc_pri7_xoff_time;
|
|
|
|
|
|
|
|
/* duration of pause */
|
|
|
|
u64 mac_tx_pause_xoff_time;
|
|
|
|
u64 mac_rx_pause_xoff_time;
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
2019-12-14 10:06:38 +08:00
|
|
|
#define HCLGE_STATS_TIMER_INTERVAL 300UL
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2022-09-06 17:12:22 +08:00
|
|
|
/* fec stats ,opcode id: 0x0316 */
|
|
|
|
#define HCLGE_FEC_STATS_MAX_LANES 8
|
|
|
|
struct hclge_fec_stats {
|
|
|
|
/* fec rs mode total stats */
|
|
|
|
u64 rs_corr_blocks;
|
|
|
|
u64 rs_uncorr_blocks;
|
|
|
|
u64 rs_error_blocks;
|
|
|
|
/* fec base-r mode per lanes stats */
|
|
|
|
u64 base_r_lane_num;
|
|
|
|
u64 base_r_corr_blocks;
|
|
|
|
u64 base_r_uncorr_blocks;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u64 base_r_corr_per_lanes[HCLGE_FEC_STATS_MAX_LANES];
|
|
|
|
u64 base_r_uncorr_per_lanes[HCLGE_FEC_STATS_MAX_LANES];
|
|
|
|
};
|
|
|
|
u64 per_lanes[HCLGE_FEC_STATS_MAX_LANES * 2];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-12-22 12:21:46 +08:00
|
|
|
struct hclge_vlan_type_cfg {
|
|
|
|
u16 rx_ot_fst_vlan_type;
|
|
|
|
u16 rx_ot_sec_vlan_type;
|
|
|
|
u16 rx_in_fst_vlan_type;
|
|
|
|
u16 rx_in_sec_vlan_type;
|
|
|
|
u16 tx_ot_vlan_type;
|
|
|
|
u16 tx_in_vlan_type;
|
|
|
|
};
|
|
|
|
|
2018-10-01 12:46:41 +01:00
|
|
|
enum HCLGE_FD_MODE {
|
|
|
|
HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1,
|
|
|
|
HCLGE_FD_MODE_DEPTH_1K_WIDTH_400B_STAGE_2,
|
|
|
|
HCLGE_FD_MODE_DEPTH_4K_WIDTH_200B_STAGE_1,
|
|
|
|
HCLGE_FD_MODE_DEPTH_2K_WIDTH_200B_STAGE_2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum HCLGE_FD_KEY_TYPE {
|
|
|
|
HCLGE_FD_KEY_BASE_ON_PTYPE,
|
|
|
|
HCLGE_FD_KEY_BASE_ON_TUPLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum HCLGE_FD_STAGE {
|
|
|
|
HCLGE_FD_STAGE_1,
|
|
|
|
HCLGE_FD_STAGE_2,
|
2019-06-07 10:03:09 +08:00
|
|
|
MAX_STAGE_NUM,
|
2018-10-01 12:46:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* OUTER_XXX indicates tuples in tunnel header of tunnel packet
|
|
|
|
* INNER_XXX indicate tuples in tunneled header of tunnel packet or
|
|
|
|
* tuples of non-tunnel packet
|
|
|
|
*/
|
|
|
|
enum HCLGE_FD_TUPLE {
|
|
|
|
OUTER_DST_MAC,
|
|
|
|
OUTER_SRC_MAC,
|
|
|
|
OUTER_VLAN_TAG_FST,
|
|
|
|
OUTER_VLAN_TAG_SEC,
|
|
|
|
OUTER_ETH_TYPE,
|
|
|
|
OUTER_L2_RSV,
|
|
|
|
OUTER_IP_TOS,
|
|
|
|
OUTER_IP_PROTO,
|
|
|
|
OUTER_SRC_IP,
|
|
|
|
OUTER_DST_IP,
|
|
|
|
OUTER_L3_RSV,
|
|
|
|
OUTER_SRC_PORT,
|
|
|
|
OUTER_DST_PORT,
|
|
|
|
OUTER_L4_RSV,
|
|
|
|
OUTER_TUN_VNI,
|
|
|
|
OUTER_TUN_FLOW_ID,
|
|
|
|
INNER_DST_MAC,
|
|
|
|
INNER_SRC_MAC,
|
|
|
|
INNER_VLAN_TAG_FST,
|
|
|
|
INNER_VLAN_TAG_SEC,
|
|
|
|
INNER_ETH_TYPE,
|
|
|
|
INNER_L2_RSV,
|
|
|
|
INNER_IP_TOS,
|
|
|
|
INNER_IP_PROTO,
|
|
|
|
INNER_SRC_IP,
|
|
|
|
INNER_DST_IP,
|
|
|
|
INNER_L3_RSV,
|
|
|
|
INNER_SRC_PORT,
|
|
|
|
INNER_DST_PORT,
|
|
|
|
INNER_L4_RSV,
|
|
|
|
MAX_TUPLE,
|
|
|
|
};
|
|
|
|
|
2021-03-22 11:52:02 +08:00
|
|
|
#define HCLGE_FD_TUPLE_USER_DEF_TUPLES \
|
|
|
|
(BIT(INNER_L2_RSV) | BIT(INNER_L3_RSV) | BIT(INNER_L4_RSV))
|
|
|
|
|
2018-10-01 12:46:41 +01:00
|
|
|
enum HCLGE_FD_META_DATA {
|
|
|
|
PACKET_TYPE_ID,
|
|
|
|
IP_FRAGEMENT,
|
|
|
|
ROCE_TYPE,
|
|
|
|
NEXT_KEY,
|
|
|
|
VLAN_NUMBER,
|
|
|
|
SRC_VPORT,
|
|
|
|
DST_VPORT,
|
|
|
|
TUNNEL_PACKET,
|
|
|
|
MAX_META_DATA,
|
|
|
|
};
|
|
|
|
|
2021-03-22 11:51:58 +08:00
|
|
|
enum HCLGE_FD_KEY_OPT {
|
|
|
|
KEY_OPT_U8,
|
|
|
|
KEY_OPT_LE16,
|
|
|
|
KEY_OPT_LE32,
|
|
|
|
KEY_OPT_MAC,
|
|
|
|
KEY_OPT_IP,
|
|
|
|
KEY_OPT_VNI,
|
|
|
|
};
|
|
|
|
|
2018-10-01 12:46:41 +01:00
|
|
|
struct key_info {
|
|
|
|
u8 key_type;
|
2019-06-07 10:03:09 +08:00
|
|
|
u8 key_length; /* use bit as unit */
|
2021-03-22 11:51:58 +08:00
|
|
|
enum HCLGE_FD_KEY_OPT key_opt;
|
|
|
|
int offset;
|
|
|
|
int moffset;
|
2018-10-01 12:46:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_KEY_LENGTH 400
|
|
|
|
#define MAX_KEY_DWORDS DIV_ROUND_UP(MAX_KEY_LENGTH / 8, 4)
|
|
|
|
#define MAX_KEY_BYTES (MAX_KEY_DWORDS * 4)
|
|
|
|
#define MAX_META_DATA_LENGTH 32
|
|
|
|
|
2021-03-22 11:52:02 +08:00
|
|
|
#define HCLGE_FD_MAX_USER_DEF_OFFSET 9000
|
|
|
|
#define HCLGE_FD_USER_DEF_DATA GENMASK(15, 0)
|
|
|
|
#define HCLGE_FD_USER_DEF_OFFSET GENMASK(15, 0)
|
|
|
|
#define HCLGE_FD_USER_DEF_OFFSET_UNMASK GENMASK(15, 0)
|
|
|
|
|
2019-05-24 19:19:46 +08:00
|
|
|
/* assigned by firmware, the real filter number for each pf may be less */
|
|
|
|
#define MAX_FD_FILTER_NUM 4096
|
2019-12-14 10:06:38 +08:00
|
|
|
#define HCLGE_ARFS_EXPIRE_INTERVAL 5UL
|
2019-05-24 19:19:46 +08:00
|
|
|
|
2021-12-31 18:22:35 +08:00
|
|
|
#define hclge_read_dev(a, reg) \
|
|
|
|
hclge_comm_read_reg((a)->hw.io_base, reg)
|
|
|
|
#define hclge_write_dev(a, reg, value) \
|
|
|
|
hclge_comm_write_reg((a)->hw.io_base, reg, value)
|
|
|
|
|
2019-05-24 19:19:46 +08:00
|
|
|
enum HCLGE_FD_ACTIVE_RULE_TYPE {
|
|
|
|
HCLGE_FD_RULE_NONE,
|
|
|
|
HCLGE_FD_ARFS_ACTIVE,
|
|
|
|
HCLGE_FD_EP_ACTIVE,
|
2020-12-10 11:42:09 +08:00
|
|
|
HCLGE_FD_TC_FLOWER_ACTIVE,
|
2019-05-24 19:19:46 +08:00
|
|
|
};
|
|
|
|
|
2018-10-01 12:46:41 +01:00
|
|
|
enum HCLGE_FD_PACKET_TYPE {
|
|
|
|
NIC_PACKET,
|
|
|
|
ROCE_PACKET,
|
|
|
|
};
|
|
|
|
|
2018-10-01 12:46:42 +01:00
|
|
|
enum HCLGE_FD_ACTION {
|
2020-12-10 11:42:08 +08:00
|
|
|
HCLGE_FD_ACTION_SELECT_QUEUE,
|
2018-10-01 12:46:42 +01:00
|
|
|
HCLGE_FD_ACTION_DROP_PACKET,
|
2020-12-10 11:42:08 +08:00
|
|
|
HCLGE_FD_ACTION_SELECT_TC,
|
2018-10-01 12:46:42 +01:00
|
|
|
};
|
|
|
|
|
net: hns3: refactor flow director configuration
Currently, the flow director rule of aRFS is configured in
the IO path. It's time-consuming. So move out the configuration,
and configure it asynchronously. And keep ethtool and tc flower
rule using synchronous way, otherwise the application maybe
unable to know the rule is installed or pending.
Add a state member for each flow director rule to indicate the
rule state. There are 4 states:
TO_ADD: the rule is waiting to add to hardware
TO_DEL: the rule is waiting to remove from hardware
DELETED: the rule has been removed from hardware. It's a middle
state, used to remove the rule node in the fd_rule_list.
ACTIVE: the rule is already added in hardware
For asynchronous way, when receive a new request to add or delete
flow director rule by aRFS, update the rule list, then request to
schedule the service task to finish the configuration.
For synchronous way, when receive a new request to add or delete
flow director rule by ethtool or tc flower, configure hardware
directly, then update the rule list if success.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-22 11:52:00 +08:00
|
|
|
enum HCLGE_FD_NODE_STATE {
|
|
|
|
HCLGE_FD_TO_ADD,
|
|
|
|
HCLGE_FD_TO_DEL,
|
|
|
|
HCLGE_FD_ACTIVE,
|
|
|
|
HCLGE_FD_DELETED,
|
|
|
|
};
|
|
|
|
|
2021-03-22 11:52:02 +08:00
|
|
|
enum HCLGE_FD_USER_DEF_LAYER {
|
|
|
|
HCLGE_FD_USER_DEF_NONE,
|
|
|
|
HCLGE_FD_USER_DEF_L2,
|
|
|
|
HCLGE_FD_USER_DEF_L3,
|
|
|
|
HCLGE_FD_USER_DEF_L4,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HCLGE_FD_USER_DEF_LAYER_NUM 3
|
|
|
|
struct hclge_fd_user_def_cfg {
|
|
|
|
u16 ref_cnt;
|
|
|
|
u16 offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_fd_user_def_info {
|
|
|
|
enum HCLGE_FD_USER_DEF_LAYER layer;
|
|
|
|
u16 data;
|
|
|
|
u16 data_mask;
|
|
|
|
u16 offset;
|
|
|
|
};
|
|
|
|
|
2018-10-01 12:46:41 +01:00
|
|
|
struct hclge_fd_key_cfg {
|
|
|
|
u8 key_sel;
|
|
|
|
u8 inner_sipv6_word_en;
|
|
|
|
u8 inner_dipv6_word_en;
|
|
|
|
u8 outer_sipv6_word_en;
|
|
|
|
u8 outer_dipv6_word_en;
|
|
|
|
u32 tuple_active;
|
|
|
|
u32 meta_data_active;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_fd_cfg {
|
|
|
|
u8 fd_mode;
|
2019-06-07 10:03:09 +08:00
|
|
|
u16 max_key_length; /* use bit as unit */
|
|
|
|
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];
|
2021-03-22 11:52:02 +08:00
|
|
|
struct hclge_fd_user_def_cfg user_def_cfg[HCLGE_FD_USER_DEF_LAYER_NUM];
|
2018-10-01 12:46:41 +01:00
|
|
|
};
|
|
|
|
|
2019-06-07 10:03:09 +08:00
|
|
|
#define IPV4_INDEX 3
|
2024-08-13 14:33:49 +01:00
|
|
|
|
2018-10-01 12:46:42 +01:00
|
|
|
struct hclge_fd_rule_tuples {
|
2019-06-07 10:03:09 +08:00
|
|
|
u8 src_mac[ETH_ALEN];
|
|
|
|
u8 dst_mac[ETH_ALEN];
|
|
|
|
/* Be compatible for ip address of both ipv4 and ipv6.
|
|
|
|
* For ipv4 address, we store it in src/dst_ip[3].
|
|
|
|
*/
|
2024-08-13 14:33:49 +01:00
|
|
|
u32 src_ip[IPV6_ADDR_WORDS];
|
|
|
|
u32 dst_ip[IPV6_ADDR_WORDS];
|
2018-10-01 12:46:42 +01:00
|
|
|
u16 src_port;
|
|
|
|
u16 dst_port;
|
|
|
|
u16 vlan_tag1;
|
|
|
|
u16 ether_proto;
|
2021-03-22 11:52:02 +08:00
|
|
|
u16 l2_user_def;
|
|
|
|
u16 l3_user_def;
|
|
|
|
u32 l4_user_def;
|
2018-10-01 12:46:42 +01:00
|
|
|
u8 ip_tos;
|
|
|
|
u8 ip_proto;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_fd_rule {
|
|
|
|
struct hlist_node rule_node;
|
|
|
|
struct hclge_fd_rule_tuples tuples;
|
|
|
|
struct hclge_fd_rule_tuples tuples_mask;
|
|
|
|
u32 unused_tuple;
|
|
|
|
u32 flow_type;
|
2020-12-10 11:42:09 +08:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
unsigned long cookie;
|
|
|
|
u8 tc;
|
|
|
|
} cls_flower;
|
|
|
|
struct {
|
|
|
|
u16 flow_id; /* only used for arfs */
|
|
|
|
} arfs;
|
2021-03-22 11:52:02 +08:00
|
|
|
struct {
|
|
|
|
struct hclge_fd_user_def_info user_def;
|
|
|
|
} ep;
|
2020-12-10 11:42:09 +08:00
|
|
|
};
|
2018-10-01 12:46:42 +01:00
|
|
|
u16 queue_id;
|
2020-12-10 11:42:09 +08:00
|
|
|
u16 vf_id;
|
2018-10-01 12:46:42 +01:00
|
|
|
u16 location;
|
2019-05-24 19:19:46 +08:00
|
|
|
enum HCLGE_FD_ACTIVE_RULE_TYPE rule_type;
|
net: hns3: refactor flow director configuration
Currently, the flow director rule of aRFS is configured in
the IO path. It's time-consuming. So move out the configuration,
and configure it asynchronously. And keep ethtool and tc flower
rule using synchronous way, otherwise the application maybe
unable to know the rule is installed or pending.
Add a state member for each flow director rule to indicate the
rule state. There are 4 states:
TO_ADD: the rule is waiting to add to hardware
TO_DEL: the rule is waiting to remove from hardware
DELETED: the rule has been removed from hardware. It's a middle
state, used to remove the rule node in the fd_rule_list.
ACTIVE: the rule is already added in hardware
For asynchronous way, when receive a new request to add or delete
flow director rule by aRFS, update the rule list, then request to
schedule the service task to finish the configuration.
For synchronous way, when receive a new request to add or delete
flow director rule by ethtool or tc flower, configure hardware
directly, then update the rule list if success.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-22 11:52:00 +08:00
|
|
|
enum HCLGE_FD_NODE_STATE state;
|
2020-12-10 11:42:09 +08:00
|
|
|
u8 action;
|
2018-10-01 12:46:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_fd_ad_data {
|
|
|
|
u16 ad_id;
|
|
|
|
u8 drop_packet;
|
|
|
|
u8 forward_to_direct_queue;
|
|
|
|
u16 queue_id;
|
|
|
|
u8 use_counter;
|
|
|
|
u8 counter_id;
|
|
|
|
u8 use_next_stage;
|
|
|
|
u8 write_rule_id_to_bd;
|
|
|
|
u8 next_input_key;
|
|
|
|
u16 rule_id;
|
2020-12-10 11:42:08 +08:00
|
|
|
u16 tc_size;
|
|
|
|
u8 override_tc;
|
2018-10-01 12:46:42 +01:00
|
|
|
};
|
|
|
|
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
enum HCLGE_MAC_NODE_STATE {
|
|
|
|
HCLGE_MAC_TO_ADD,
|
|
|
|
HCLGE_MAC_TO_DEL,
|
|
|
|
HCLGE_MAC_ACTIVE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_mac_node {
|
2019-02-20 10:32:48 +08:00
|
|
|
struct list_head node;
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
enum HCLGE_MAC_NODE_STATE state;
|
2019-02-20 10:32:48 +08:00
|
|
|
u8 mac_addr[ETH_ALEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum HCLGE_MAC_ADDR_TYPE {
|
|
|
|
HCLGE_MAC_ADDR_UC,
|
|
|
|
HCLGE_MAC_ADDR_MC
|
|
|
|
};
|
|
|
|
|
2019-02-20 10:32:49 +08:00
|
|
|
struct hclge_vport_vlan_cfg {
|
|
|
|
struct list_head node;
|
|
|
|
int hd_tbl_status;
|
|
|
|
u16 vlan_id;
|
|
|
|
};
|
|
|
|
|
2019-04-19 11:05:36 +08:00
|
|
|
struct hclge_rst_stats {
|
|
|
|
u32 reset_done_cnt; /* the number of reset has completed */
|
|
|
|
u32 hw_reset_done_cnt; /* the number of HW reset has completed */
|
|
|
|
u32 pf_rst_cnt; /* the number of PF reset */
|
|
|
|
u32 flr_rst_cnt; /* the number of FLR */
|
|
|
|
u32 global_rst_cnt; /* the number of GLOBAL */
|
|
|
|
u32 imp_rst_cnt; /* the number of IMP reset */
|
|
|
|
u32 reset_cnt; /* the number of reset */
|
2019-09-11 10:40:39 +08:00
|
|
|
u32 reset_fail_cnt; /* the number of reset fail */
|
2019-04-19 11:05:36 +08:00
|
|
|
};
|
|
|
|
|
2019-04-19 11:05:45 +08:00
|
|
|
/* time and register status when mac tunnel interruption occur */
|
|
|
|
struct hclge_mac_tnl_stats {
|
|
|
|
u64 time;
|
|
|
|
u32 status;
|
|
|
|
};
|
|
|
|
|
2019-06-07 10:03:10 +08:00
|
|
|
#define HCLGE_RESET_INTERVAL (10 * HZ)
|
2019-06-20 16:52:43 +08:00
|
|
|
#define HCLGE_WAIT_RESET_DONE 100
|
2019-06-07 10:03:10 +08:00
|
|
|
|
2019-06-13 17:12:32 +08:00
|
|
|
#pragma pack(1)
|
|
|
|
struct hclge_vf_vlan_cfg {
|
|
|
|
u8 mbx_cmd;
|
|
|
|
u8 subcode;
|
2021-05-31 10:38:41 +08:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u8 is_kill;
|
2022-05-09 15:55:30 +08:00
|
|
|
__le16 vlan;
|
|
|
|
__le16 proto;
|
2021-05-31 10:38:41 +08:00
|
|
|
};
|
|
|
|
u8 enable;
|
|
|
|
};
|
2019-06-13 17:12:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack()
|
|
|
|
|
2018-10-01 12:46:42 +01:00
|
|
|
/* For each bit of TCAM entry, it uses a pair of 'x' and
|
|
|
|
* 'y' to indicate which value to match, like below:
|
|
|
|
* ----------------------------------
|
|
|
|
* | bit x | bit y | search value |
|
|
|
|
* ----------------------------------
|
|
|
|
* | 0 | 0 | always hit |
|
|
|
|
* ----------------------------------
|
|
|
|
* | 1 | 0 | match '0' |
|
|
|
|
* ----------------------------------
|
|
|
|
* | 0 | 1 | match '1' |
|
|
|
|
* ----------------------------------
|
|
|
|
* | 1 | 1 | invalid |
|
|
|
|
* ----------------------------------
|
|
|
|
* Then for input key(k) and mask(v), we can calculate the value by
|
|
|
|
* the formulae:
|
|
|
|
* x = (~k) & v
|
2023-06-21 20:33:07 +08:00
|
|
|
* y = k & v
|
2018-10-01 12:46:42 +01:00
|
|
|
*/
|
2023-06-21 20:33:07 +08:00
|
|
|
#define calc_x(x, k, v) ((x) = ~(k) & (v))
|
|
|
|
#define calc_y(y, k, v) ((y) = (k) & (v))
|
2018-10-01 12:46:42 +01:00
|
|
|
|
2021-11-10 21:42:51 +08:00
|
|
|
#define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f))
|
|
|
|
#define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset)))
|
|
|
|
|
2019-04-19 11:05:45 +08:00
|
|
|
#define HCLGE_MAC_TNL_LOG_SIZE 8
|
2018-05-01 19:56:04 +01:00
|
|
|
#define HCLGE_VPORT_NUM 256
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_dev {
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
struct hnae3_ae_dev *ae_dev;
|
|
|
|
struct hclge_hw hw;
|
2017-11-02 20:45:18 +08:00
|
|
|
struct hclge_misc_vector misc_vector;
|
2019-12-14 10:06:38 +08:00
|
|
|
struct hclge_mac_stats mac_stats;
|
2022-09-06 17:12:22 +08:00
|
|
|
struct hclge_fec_stats fec_stats;
|
2017-08-02 16:59:48 +01:00
|
|
|
unsigned long state;
|
2018-11-09 22:07:54 +08:00
|
|
|
unsigned long flr_state;
|
2018-11-07 12:06:14 +08:00
|
|
|
unsigned long last_reset_time;
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2017-11-02 20:45:19 +08:00
|
|
|
enum hnae3_reset_type reset_type;
|
2018-11-07 12:06:14 +08:00
|
|
|
enum hnae3_reset_type reset_level;
|
2018-11-07 12:06:08 +08:00
|
|
|
unsigned long default_reset_request;
|
2017-12-04 01:29:54 +00:00
|
|
|
unsigned long reset_request; /* reset has been requested */
|
2017-12-04 01:29:53 +00:00
|
|
|
unsigned long reset_pending; /* client rst is pending to be served */
|
2019-04-19 11:05:36 +08:00
|
|
|
struct hclge_rst_stats rst_stats;
|
net: hns3: refactor the precedure of PF FLR
Currently, the actual work of PF FLR is handled in the reset task,
which is asynchronous. So in some case, if the preparing and
rebuilding are not done, then the PF FLR will trigger some problems,
for example, makes hardware go into chaos.
So this patch separates the process of PF FLR from reset task, and
adds a semaphore to serialize this reset and others.
When FLR's preparing fails, if there has other higher level reset
pending or failing times less than the HCLGE_FLR_RETRY_CNT, this
preparing should be retried, otherwise PF and its VF may get into
wrong state.
BTW, while the hardware reports misc interrupt during pcie_flr(),
the driver can not receive this interrupt anymore, so disable it
when hclge_flr_prepare() return, and re-enable it when enter
hclge_flr_done().
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-01-11 16:33:49 +08:00
|
|
|
struct semaphore reset_sem; /* protect reset process */
|
2017-08-02 16:59:48 +01:00
|
|
|
u32 fw_version;
|
|
|
|
u16 num_tqps; /* Num task queue pairs of this PF */
|
|
|
|
u16 num_req_vfs; /* Num VFs requested for this PF */
|
|
|
|
|
2018-07-19 15:47:01 +01:00
|
|
|
u16 base_tqp_pid; /* Base task tqp physical id of this PF */
|
2017-08-02 16:59:48 +01:00
|
|
|
u16 alloc_rss_size; /* Allocated RSS task queue */
|
2020-12-10 11:42:10 +08:00
|
|
|
u16 vf_rss_size_max; /* HW defined VF max RSS task queue */
|
|
|
|
u16 pf_rss_size_max; /* HW defined PF max RSS task queue */
|
2021-06-16 14:36:14 +08:00
|
|
|
u32 tx_spare_buf_size; /* HW defined TX spare buffer size */
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2018-07-19 15:47:01 +01:00
|
|
|
u16 fdir_pf_filter_count; /* Num of guaranteed filters for this PF */
|
2017-08-02 16:59:48 +01:00
|
|
|
u16 num_alloc_vport; /* Num vports this driver supports */
|
2024-05-07 21:42:20 +08:00
|
|
|
nodemask_t numa_node_mask;
|
2017-08-02 16:59:48 +01:00
|
|
|
u16 rx_buf_len;
|
2019-02-23 17:22:15 +08:00
|
|
|
u16 num_tx_desc; /* desc num of per tx queue */
|
|
|
|
u16 num_rx_desc; /* desc num of per rx queue */
|
2017-08-02 16:59:48 +01:00
|
|
|
u8 hw_tc_map;
|
|
|
|
enum hclge_fc_mode fc_mode_last_time;
|
2018-11-26 18:43:00 +00:00
|
|
|
u8 support_sfp_query;
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
#define HCLGE_FLAG_TC_BASE_SCH_MODE 1
|
|
|
|
#define HCLGE_FLAG_VNET_BASE_SCH_MODE 2
|
|
|
|
u8 tx_sch_mode;
|
2017-09-27 09:45:29 +08:00
|
|
|
u8 tc_max;
|
|
|
|
u8 pfc_max;
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
u8 default_up;
|
2017-09-27 09:45:29 +08:00
|
|
|
u8 dcbx_cap;
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_tm_info tm_info;
|
|
|
|
|
|
|
|
u16 num_msi;
|
|
|
|
u16 num_msi_left;
|
|
|
|
u16 num_msi_used;
|
|
|
|
u16 *vector_status;
|
2017-11-13 11:39:38 +00:00
|
|
|
int *vector_irq;
|
2019-10-18 11:42:59 +08:00
|
|
|
u16 num_nic_msi; /* Num of nic vectors for this PF */
|
2017-11-13 11:39:38 +00:00
|
|
|
u16 num_roce_msi; /* Num of roce vectors for this PF */
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
unsigned long service_timer_period;
|
|
|
|
unsigned long service_timer_previous;
|
net: hns3: add error handler for hclge_reset()
When hclge_reset() is called, it may fail for several reasons.
For example, an higher-level reset event occurs, memory allocation
failure, hardware reset timeout, etc. Therefore, it is necessary
to add corresponding error handling for these situations.
1. A high-level reset is required due to a high-level reset failure.
2. For memory allocation failure, a high-level reset is initiated by
the timer to recover. The reason for using the timer is to prevent this
new high-level reset to interrupt the reset process of other pf/vf;
3. For the case of hardware reset timeout, reschedule the reset task
to wait for the hardware to complete the reset.
For memory allocation failure and reset timeouts, in order to prevent
an infinite number of scheduled reset tasks, the number of error
recovery needs to be limited.
This patch also add some reset related debug log printing.
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-11-07 12:06:17 +08:00
|
|
|
struct timer_list reset_timer;
|
2019-07-29 10:53:28 +08:00
|
|
|
struct delayed_work service_task;
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
bool cur_promisc;
|
|
|
|
int num_alloc_vfs; /* Actual number of VFs allocated */
|
|
|
|
|
2022-01-05 22:20:13 +08:00
|
|
|
struct hclge_comm_tqp *htqp;
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_vport *vport;
|
|
|
|
|
|
|
|
struct dentry *hclge_dbgfs;
|
|
|
|
|
|
|
|
struct hnae3_client *nic_client;
|
|
|
|
struct hnae3_client *roce_client;
|
|
|
|
|
2017-11-13 11:39:38 +00:00
|
|
|
#define HCLGE_FLAG_MAIN BIT(0)
|
|
|
|
#define HCLGE_FLAG_DCB_CAPABLE BIT(1)
|
2017-08-02 16:59:48 +01:00
|
|
|
u32 flag;
|
|
|
|
|
|
|
|
u32 pkt_buf_size; /* Total pf buf size for tx/rx */
|
2018-12-18 19:37:57 +08:00
|
|
|
u32 tx_buf_size; /* Tx buffer size for each TC */
|
|
|
|
u32 dv_buf_size; /* Dv buffer size for each TC */
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
u32 mps; /* Max packet size */
|
2018-11-18 03:19:13 +00:00
|
|
|
/* vport_lock protect resource shared by vports */
|
|
|
|
struct mutex vport_lock;
|
2017-08-02 16:59:48 +01:00
|
|
|
|
2017-12-22 12:21:46 +08:00
|
|
|
struct hclge_vlan_type_cfg vlan_type_cfg;
|
2018-01-19 14:41:12 +08:00
|
|
|
|
2018-05-01 19:56:04 +01:00
|
|
|
unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)];
|
2019-06-03 10:09:14 +08:00
|
|
|
unsigned long vf_vlan_full[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
|
2018-10-01 12:46:41 +01:00
|
|
|
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
unsigned long vport_config_block[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
|
|
|
|
|
2018-10-01 12:46:41 +01:00
|
|
|
struct hclge_fd_cfg fd_cfg;
|
2018-10-01 12:46:43 +01:00
|
|
|
struct hlist_head fd_rule_list;
|
2019-05-24 19:19:46 +08:00
|
|
|
spinlock_t fd_rule_lock; /* protect fd_rule_list and fd_bmap */
|
2018-10-01 12:46:43 +01:00
|
|
|
u16 hclge_fd_rule_num;
|
2019-12-14 10:06:38 +08:00
|
|
|
unsigned long serv_processed_cnt;
|
|
|
|
unsigned long last_serv_processed;
|
2021-11-24 09:06:51 +08:00
|
|
|
unsigned long last_rst_scheduled;
|
|
|
|
unsigned long last_mbx_scheduled;
|
2019-05-24 19:19:46 +08:00
|
|
|
unsigned long fd_bmap[BITS_TO_LONGS(MAX_FD_FILTER_NUM)];
|
|
|
|
enum HCLGE_FD_ACTIVE_RULE_TYPE fd_active_type;
|
2019-01-31 04:55:52 +08:00
|
|
|
u8 fd_en;
|
2021-08-26 19:22:00 +08:00
|
|
|
bool gro_en;
|
2018-10-05 18:03:26 +01:00
|
|
|
|
|
|
|
u16 wanted_umv_size;
|
|
|
|
/* max available unicast mac vlan space */
|
|
|
|
u16 max_umv_size;
|
|
|
|
/* private unicast mac vlan space, it's same for PF and its VFs */
|
|
|
|
u16 priv_umv_size;
|
|
|
|
/* unicast mac vlan space shared by PF and its VFs */
|
|
|
|
u16 share_umv_size;
|
2021-09-14 20:11:17 +08:00
|
|
|
/* multicast mac address number used by PF and its VFs */
|
|
|
|
u16 used_mc_mac_num;
|
2019-02-20 10:32:48 +08:00
|
|
|
|
2019-04-19 11:05:45 +08:00
|
|
|
DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats,
|
|
|
|
HCLGE_MAC_TNL_LOG_SIZE);
|
2019-07-29 10:53:29 +08:00
|
|
|
|
2021-06-10 21:38:56 +08:00
|
|
|
struct hclge_ptp *ptp;
|
2021-07-26 10:47:02 +08:00
|
|
|
struct devlink *devlink;
|
2022-01-05 22:20:04 +08:00
|
|
|
struct hclge_comm_rss_cfg rss_cfg;
|
2017-12-22 12:21:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* VPort level vlan tag configuration for TX direction */
|
|
|
|
struct hclge_tx_vtag_cfg {
|
2018-05-25 19:42:57 +01:00
|
|
|
bool accept_tag1; /* Whether accept tag1 packet from host */
|
|
|
|
bool accept_untag1; /* Whether accept untag1 packet from host */
|
|
|
|
bool accept_tag2;
|
|
|
|
bool accept_untag2;
|
2017-12-22 12:21:46 +08:00
|
|
|
bool insert_tag1_en; /* Whether insert inner vlan tag */
|
|
|
|
bool insert_tag2_en; /* Whether insert outer vlan tag */
|
|
|
|
u16 default_tag1; /* The default inner vlan tag to insert */
|
|
|
|
u16 default_tag2; /* The default outer vlan tag to insert */
|
net: hns3: refine the VLAN tag handle for port based VLAN
For DEVICE_VERSION_V2, the hardware only supports max two layer
VLAN tags, including port based tag inserted by hardware, tag in
tx buffer descriptor(get from skb->tci) and tag in packet.
For transmit packet:
If port based VLAN disabled, and vf driver gets a VLAN tag from
skb, the VLAN tag must be filled to the Outer_VLAN_TAG field
(tag near to DMAC) of tx buffer descriptor, otherwise it may
be inserted after the tag in packet.
If port based VLAN enabled, and vf driver gets a VLAN tag from
skb, the VLAN tag must be filled to the VLAN_TAG field (tag
far to DMAC) of tx buffer descriptor, otherwise it may be
conflicted with port based VLAN, and raise a hardware error.
For receive packet:
The hardware will strip the VLAN tags and fill them in the rx
buffer descriptor, no matter port based VLAN enable or not.
Because port based VLAN tag is useless for stack, so vf driver
needs to discard the port based VLAN tag get from rx buffer
descriptor when port based VLAN enabled.
So vf must know about the port based VLAN state.
For DEVICE_VERSION_V3, the hardware provides some new
configuration to improve it.
For transmit packet:
When enable tag shift mode, hardware will handle the VLAN tag
in outer_VLAN_TAG field as VLAN_TAG, so it won't conflict with
port based VLAN. And hardware also make sure the tag before
the tag in packet. So vf driver doesn't need to specify the tag
position according to the port based VLAN state anymore.
For receive packet:
When enable discard mode, hardware will strip and discard the
port based VLAN tag, so vf driver doesn't need to identify it
from rx buffer descriptor.
So modify the port based VLAN configuration, simplify the process
for vf handling the VLAN tag.
Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-12-06 12:06:15 +08:00
|
|
|
bool tag_shift_mode_en;
|
2017-12-22 12:21:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* VPort level vlan tag configuration for RX direction */
|
|
|
|
struct hclge_rx_vtag_cfg {
|
net: hns3: refine the VLAN tag handle for port based VLAN
For DEVICE_VERSION_V2, the hardware only supports max two layer
VLAN tags, including port based tag inserted by hardware, tag in
tx buffer descriptor(get from skb->tci) and tag in packet.
For transmit packet:
If port based VLAN disabled, and vf driver gets a VLAN tag from
skb, the VLAN tag must be filled to the Outer_VLAN_TAG field
(tag near to DMAC) of tx buffer descriptor, otherwise it may
be inserted after the tag in packet.
If port based VLAN enabled, and vf driver gets a VLAN tag from
skb, the VLAN tag must be filled to the VLAN_TAG field (tag
far to DMAC) of tx buffer descriptor, otherwise it may be
conflicted with port based VLAN, and raise a hardware error.
For receive packet:
The hardware will strip the VLAN tags and fill them in the rx
buffer descriptor, no matter port based VLAN enable or not.
Because port based VLAN tag is useless for stack, so vf driver
needs to discard the port based VLAN tag get from rx buffer
descriptor when port based VLAN enabled.
So vf must know about the port based VLAN state.
For DEVICE_VERSION_V3, the hardware provides some new
configuration to improve it.
For transmit packet:
When enable tag shift mode, hardware will handle the VLAN tag
in outer_VLAN_TAG field as VLAN_TAG, so it won't conflict with
port based VLAN. And hardware also make sure the tag before
the tag in packet. So vf driver doesn't need to specify the tag
position according to the port based VLAN state anymore.
For receive packet:
When enable discard mode, hardware will strip and discard the
port based VLAN tag, so vf driver doesn't need to identify it
from rx buffer descriptor.
So modify the port based VLAN configuration, simplify the process
for vf handling the VLAN tag.
Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-12-06 12:06:15 +08:00
|
|
|
bool rx_vlan_offload_en; /* Whether enable rx vlan offload */
|
|
|
|
bool strip_tag1_en; /* Whether strip inner vlan tag */
|
|
|
|
bool strip_tag2_en; /* Whether strip outer vlan tag */
|
|
|
|
bool vlan1_vlan_prionly; /* Inner vlan tag up to descriptor enable */
|
|
|
|
bool vlan2_vlan_prionly; /* Outer vlan tag up to descriptor enable */
|
|
|
|
bool strip_tag1_discard_en; /* Inner vlan tag discard for BD enable */
|
|
|
|
bool strip_tag2_discard_en; /* Outer vlan tag discard for BD enable */
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
2018-11-18 03:19:12 +00:00
|
|
|
enum HCLGE_VPORT_STATE {
|
|
|
|
HCLGE_VPORT_STATE_ALIVE,
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
HCLGE_VPORT_STATE_MAC_TBL_CHANGE,
|
2021-05-24 17:30:42 +08:00
|
|
|
HCLGE_VPORT_STATE_PROMISC_CHANGE,
|
2021-05-31 10:38:42 +08:00
|
|
|
HCLGE_VPORT_STATE_VLAN_FLTR_CHANGE,
|
2022-12-28 14:27:49 +08:00
|
|
|
HCLGE_VPORT_STATE_INITED,
|
2018-11-18 03:19:12 +00:00
|
|
|
HCLGE_VPORT_STATE_MAX
|
|
|
|
};
|
|
|
|
|
2022-12-28 14:27:49 +08:00
|
|
|
enum HCLGE_VPORT_NEED_NOTIFY {
|
|
|
|
HCLGE_VPORT_NEED_NOTIFY_RESET,
|
|
|
|
HCLGE_VPORT_NEED_NOTIFY_VF_VLAN,
|
|
|
|
};
|
|
|
|
|
2019-04-14 09:47:35 +08:00
|
|
|
struct hclge_vlan_info {
|
|
|
|
u16 vlan_proto; /* so far support 802.1Q only */
|
|
|
|
u16 qos;
|
|
|
|
u16 vlan_tag;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hclge_port_base_vlan_config {
|
|
|
|
u16 state;
|
2022-03-24 20:54:48 +08:00
|
|
|
bool tbl_sta;
|
2019-04-14 09:47:35 +08:00
|
|
|
struct hclge_vlan_info vlan_info;
|
2022-03-24 20:54:48 +08:00
|
|
|
struct hclge_vlan_info old_vlan_info;
|
2019-04-14 09:47:35 +08:00
|
|
|
};
|
|
|
|
|
2019-10-08 09:20:04 +08:00
|
|
|
struct hclge_vf_info {
|
|
|
|
int link_state;
|
|
|
|
u8 mac[ETH_ALEN];
|
2019-10-08 09:20:05 +08:00
|
|
|
u32 spoofchk;
|
2019-10-08 09:20:07 +08:00
|
|
|
u32 max_tx_rate;
|
2019-10-08 09:20:06 +08:00
|
|
|
u32 trusted;
|
2021-05-24 17:30:42 +08:00
|
|
|
u8 request_uc_en;
|
|
|
|
u8 request_mc_en;
|
|
|
|
u8 request_bc_en;
|
2019-10-08 09:20:04 +08:00
|
|
|
};
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_vport {
|
|
|
|
u16 alloc_tqps; /* Allocated Tx/Rx queues */
|
|
|
|
|
|
|
|
u16 qs_offset;
|
2019-04-15 21:48:39 +08:00
|
|
|
u32 bw_limit; /* VSI BW Limit (0 = disabled) */
|
2017-08-02 16:59:48 +01:00
|
|
|
u8 dwrr;
|
|
|
|
|
2021-05-31 10:38:42 +08:00
|
|
|
bool req_vlan_fltr_en;
|
|
|
|
bool cur_vlan_fltr_en;
|
2019-06-20 16:52:37 +08:00
|
|
|
unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)];
|
2019-04-14 09:47:35 +08:00
|
|
|
struct hclge_port_base_vlan_config port_base_vlan_cfg;
|
2017-12-22 12:21:46 +08:00
|
|
|
struct hclge_tx_vtag_cfg txvlan_cfg;
|
|
|
|
struct hclge_rx_vtag_cfg rxvlan_cfg;
|
|
|
|
|
2018-10-05 18:03:26 +01:00
|
|
|
u16 used_umv_num;
|
|
|
|
|
2019-06-13 17:12:32 +08:00
|
|
|
u16 vport_id;
|
2017-08-02 16:59:48 +01:00
|
|
|
struct hclge_dev *back; /* Back reference to associated dev */
|
|
|
|
struct hnae3_handle nic;
|
|
|
|
struct hnae3_handle roce;
|
2018-11-18 03:19:12 +00:00
|
|
|
|
|
|
|
unsigned long state;
|
2022-12-28 14:27:49 +08:00
|
|
|
unsigned long need_notify;
|
2018-11-18 03:19:12 +00:00
|
|
|
unsigned long last_active_jiffies;
|
2018-11-18 03:19:13 +00:00
|
|
|
u32 mps; /* Max packet size */
|
2019-10-08 09:20:04 +08:00
|
|
|
struct hclge_vf_info vf_info;
|
2019-02-20 10:32:48 +08:00
|
|
|
|
2020-04-24 10:23:11 +08:00
|
|
|
u8 overflow_promisc_flags;
|
|
|
|
u8 last_promisc_flags;
|
|
|
|
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
spinlock_t mac_list_lock; /* protect mac address need to add/detele */
|
2019-02-20 10:32:48 +08:00
|
|
|
struct list_head uc_mac_list; /* Store VF unicast table */
|
|
|
|
struct list_head mc_mac_list; /* Store VF multicast table */
|
2022-03-24 20:54:49 +08:00
|
|
|
|
2019-02-20 10:32:49 +08:00
|
|
|
struct list_head vlan_list; /* Store VF vlan table */
|
2017-08-02 16:59:48 +01:00
|
|
|
};
|
|
|
|
|
2021-08-28 14:55:18 +08:00
|
|
|
struct hclge_speed_bit_map {
|
|
|
|
u32 speed;
|
|
|
|
u32 speed_bit;
|
|
|
|
};
|
|
|
|
|
2021-11-29 22:00:22 +08:00
|
|
|
struct hclge_mac_speed_map {
|
|
|
|
u32 speed_drv; /* speed defined in driver */
|
|
|
|
u32 speed_fw; /* speed defined in firmware */
|
|
|
|
};
|
|
|
|
|
2023-10-24 11:20:34 +08:00
|
|
|
struct hclge_link_mode_bmap {
|
|
|
|
u16 support_bit;
|
|
|
|
enum ethtool_link_mode_bit_indices link_mode;
|
|
|
|
};
|
|
|
|
|
2019-10-08 09:20:06 +08:00
|
|
|
int hclge_set_vport_promisc_mode(struct hclge_vport *vport, bool en_uc_pmc,
|
|
|
|
bool en_mc_pmc, bool en_bc_pmc);
|
2017-08-02 16:59:48 +01:00
|
|
|
int hclge_add_uc_addr_common(struct hclge_vport *vport,
|
|
|
|
const unsigned char *addr);
|
|
|
|
int hclge_rm_uc_addr_common(struct hclge_vport *vport,
|
|
|
|
const unsigned char *addr);
|
|
|
|
int hclge_add_mc_addr_common(struct hclge_vport *vport,
|
|
|
|
const unsigned char *addr);
|
|
|
|
int hclge_rm_mc_addr_common(struct hclge_vport *vport,
|
|
|
|
const unsigned char *addr);
|
|
|
|
|
|
|
|
struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle);
|
2017-12-14 18:03:08 +00:00
|
|
|
int hclge_bind_ring_with_vector(struct hclge_vport *vport,
|
|
|
|
int vector_id, bool en,
|
|
|
|
struct hnae3_ring_chain_node *ring_chain);
|
|
|
|
|
2017-08-02 16:59:48 +01:00
|
|
|
static inline int hclge_get_queue_id(struct hnae3_queue *queue)
|
|
|
|
{
|
2022-01-05 22:20:13 +08:00
|
|
|
struct hclge_comm_tqp *tqp =
|
|
|
|
container_of(queue, struct hclge_comm_tqp, q);
|
2017-08-02 16:59:48 +01:00
|
|
|
|
|
|
|
return tqp->index;
|
|
|
|
}
|
|
|
|
|
net: hns3: adjust VF's reset process
Currently when VF need to reset itself, it will send a cmd to PF,
after receiving the VF reset requset, PF sends a cmd to inform
VF to enter the reset process and send a cmd to firmware to do the
actual reset for the VF, it is possible that firmware has resetted
the VF, but VF has not entered the reset process, which may cause
IO not stopped problem when firmware is resetting VF.
This patch fixes it by adjusting the VF reset process, when VF
need to reset itself, it will enter the reset process first, and
it will tell the PF to send cmd to firmware to reset itself.
Add member reset_pending to struct hclgevf_dev, which indicates that
there is reset event need to be processed by the VF's reset task, and
the VF's reset task chooses the highest-level one and clears other
low-level one when it processes reset_pending.
hclge_inform_reset_assert_to_vf function is unused now, but it will
be used to support the PF reset with VF working, so declare it in
the header file.
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-11-09 22:07:47 +08:00
|
|
|
int hclge_inform_reset_assert_to_vf(struct hclge_vport *vport);
|
2022-09-06 17:12:23 +08:00
|
|
|
int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex, u8 lane_num);
|
2018-05-01 19:56:04 +01:00
|
|
|
int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto,
|
|
|
|
u16 vlan_id, bool is_kill);
|
2018-05-03 17:28:11 +01:00
|
|
|
int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable);
|
2017-09-27 09:45:28 +08:00
|
|
|
|
|
|
|
int hclge_buffer_alloc(struct hclge_dev *hdev);
|
|
|
|
int hclge_rss_init_hw(struct hclge_dev *hdev);
|
2017-12-14 18:03:07 +00:00
|
|
|
|
|
|
|
void hclge_mbx_handler(struct hclge_dev *hdev);
|
2021-03-29 11:57:49 +08:00
|
|
|
int hclge_reset_tqp(struct hnae3_handle *handle);
|
2017-12-22 12:21:52 +08:00
|
|
|
int hclge_cfg_flowctrl(struct hclge_dev *hdev);
|
2018-03-22 14:29:00 +00:00
|
|
|
int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);
|
2018-11-18 03:19:12 +00:00
|
|
|
int hclge_vport_start(struct hclge_vport *vport);
|
|
|
|
void hclge_vport_stop(struct hclge_vport *vport);
|
2018-11-18 03:19:13 +00:00
|
|
|
int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu);
|
2025-07-14 14:10:32 +08:00
|
|
|
int hclge_dbg_get_read_func(struct hnae3_handle *handle, enum hnae3_dbg_cmd cmd,
|
|
|
|
read_func *func);
|
2018-12-15 15:31:57 +00:00
|
|
|
u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id);
|
2019-01-18 16:13:13 +08:00
|
|
|
int hclge_notify_client(struct hclge_dev *hdev,
|
|
|
|
enum hnae3_reset_notify_type type);
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
int hclge_update_mac_list(struct hclge_vport *vport,
|
|
|
|
enum HCLGE_MAC_NODE_STATE state,
|
|
|
|
enum HCLGE_MAC_ADDR_TYPE mac_type,
|
|
|
|
const unsigned char *addr);
|
|
|
|
int hclge_update_mac_node_for_dev_addr(struct hclge_vport *vport,
|
|
|
|
const u8 *old_addr, const u8 *new_addr);
|
2019-02-20 10:32:48 +08:00
|
|
|
void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list,
|
|
|
|
enum HCLGE_MAC_ADDR_TYPE mac_type);
|
2019-02-20 10:32:49 +08:00
|
|
|
void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list);
|
|
|
|
void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev);
|
net: hns3: refactor the MAC address configure
Currently, the HNS3 driver sync and unsync MAC address in function
hns3_set_rx_mode(). For PF, it adds and deletes MAC address directly
in the path of dev_set_rx_mode(). If failed, it won't retry until
next calling of hns3_set_rx_mode(). On the other hand, if request
add and remove a same address many times at a short interval, each
request must be done one by one, can't be merged. For VF, it sends
mailbox messages to PF to request adding or deleting MAC address in
the path of function hns3_set_rx_mode(), no matter the address is
configured success.
This patch refines it by recording the MAC address in function
hns3_set_rx_mode(), and updating MAC address in the service task.
If failed, it will retry by the next calling of periodical service
task. It also uses some state to mark the state of each MAC address
in the MAC list, which can help merge configure request for a same
address. With these changes, when global reset or IMP reset occurs,
we can restore the MAC table with the MAC list.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-24 10:23:09 +08:00
|
|
|
void hclge_restore_mac_table_common(struct hclge_vport *vport);
|
2022-03-24 20:54:48 +08:00
|
|
|
void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev);
|
2020-04-24 10:23:13 +08:00
|
|
|
void hclge_restore_vport_vlan_table(struct hclge_vport *vport);
|
2019-04-14 09:47:37 +08:00
|
|
|
int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
|
|
|
|
struct hclge_vlan_info *vlan_info);
|
2019-04-14 09:47:38 +08:00
|
|
|
int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
|
2021-05-31 10:38:39 +08:00
|
|
|
u16 state,
|
|
|
|
struct hclge_vlan_info *vlan_info);
|
2019-08-01 11:55:34 +08:00
|
|
|
void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time);
|
2019-08-28 22:23:13 +08:00
|
|
|
void hclge_report_hw_error(struct hclge_dev *hdev,
|
|
|
|
enum hnae3_hw_error_type type);
|
2021-05-14 11:25:18 +08:00
|
|
|
int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len);
|
2021-04-15 10:20:38 +08:00
|
|
|
int hclge_push_vf_link_status(struct hclge_vport *vport);
|
2021-05-31 10:38:44 +08:00
|
|
|
int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en);
|
2021-11-10 21:42:51 +08:00
|
|
|
int hclge_mac_update_stats(struct hclge_dev *hdev);
|
2023-10-07 11:12:15 +08:00
|
|
|
struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf);
|
|
|
|
int hclge_inform_vf_reset(struct hclge_vport *vport, u16 reset_type);
|
2024-04-10 20:53:54 +08:00
|
|
|
int hclge_query_scc_version(struct hclge_dev *hdev, u32 *scc_version);
|
2017-08-02 16:59:48 +01:00
|
|
|
#endif
|