Commit eaa5607d authored by Jie Wang's avatar Jie Wang Committed by David S. Miller

net: hns3: refactor hclge_cmd_send with new hclge_comm_cmd_send API

This patch firstly uses new hardware description struct hclge_comm_hw as
child member of hclge_hw and deletes the original child memebers of
hclge_hw. All the hclge_hw variables used in PF module is modified
according to the new hclge_hw.

Secondly hclge_cmd_send is refactored to use hclge_comm_cmd_send APIs. The
old functions called by hclge_cmd_send are deleted and hclge_cmd_send is
kept to avoid too many meaningless modifications.
Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8d307f8e
...@@ -16,10 +16,13 @@ hns3-objs = hns3_enet.o hns3_ethtool.o hns3_debugfs.o ...@@ -16,10 +16,13 @@ hns3-objs = hns3_enet.o hns3_ethtool.o hns3_debugfs.o
hns3-$(CONFIG_HNS3_DCB) += hns3_dcbnl.o hns3-$(CONFIG_HNS3_DCB) += hns3_dcbnl.o
obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o
hclgevf-objs = hns3vf/hclgevf_main.o hns3vf/hclgevf_cmd.o hns3vf/hclgevf_mbx.o hns3vf/hclgevf_devlink.o
hclgevf-objs = hns3vf/hclgevf_main.o hns3vf/hclgevf_cmd.o hns3vf/hclgevf_mbx.o hns3vf/hclgevf_devlink.o \
hns3_common/hclge_comm_cmd.o
obj-$(CONFIG_HNS3_HCLGE) += hclge.o obj-$(CONFIG_HNS3_HCLGE) += hclge.o
hclge-objs = hns3pf/hclge_main.o hns3pf/hclge_cmd.o hns3pf/hclge_mdio.o hns3pf/hclge_tm.o \ hclge-objs = hns3pf/hclge_main.o hns3pf/hclge_cmd.o hns3pf/hclge_mdio.o hns3pf/hclge_tm.o \
hns3pf/hclge_mbx.o hns3pf/hclge_err.o hns3pf/hclge_debugfs.o hns3pf/hclge_ptp.o hns3pf/hclge_devlink.o hns3pf/hclge_mbx.o hns3pf/hclge_err.o hns3pf/hclge_debugfs.o hns3pf/hclge_ptp.o hns3pf/hclge_devlink.o \
hns3_common/hclge_comm_cmd.o
hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o
...@@ -11,63 +11,18 @@ ...@@ -11,63 +11,18 @@
#define HCLGE_CMDQ_TX_TIMEOUT 30000 #define HCLGE_CMDQ_TX_TIMEOUT 30000
#define HCLGE_CMDQ_CLEAR_WAIT_TIME 200 #define HCLGE_CMDQ_CLEAR_WAIT_TIME 200
#define HCLGE_DESC_DATA_LEN 6
struct hclge_dev; struct hclge_dev;
#define HCLGE_CMDQ_RX_INVLD_B 0 #define HCLGE_CMDQ_RX_INVLD_B 0
#define HCLGE_CMDQ_RX_OUTVLD_B 1 #define HCLGE_CMDQ_RX_OUTVLD_B 1
struct hclge_cmq_ring {
dma_addr_t desc_dma_addr;
struct hclge_desc *desc;
struct hclge_dev *dev;
u32 head;
u32 tail;
u16 buf_size;
u16 desc_num;
int next_to_use;
int next_to_clean;
u8 ring_type; /* cmq ring type */
spinlock_t lock; /* Command queue lock */
};
enum hclge_cmd_return_status {
HCLGE_CMD_EXEC_SUCCESS = 0,
HCLGE_CMD_NO_AUTH = 1,
HCLGE_CMD_NOT_SUPPORTED = 2,
HCLGE_CMD_QUEUE_FULL = 3,
HCLGE_CMD_NEXT_ERR = 4,
HCLGE_CMD_UNEXE_ERR = 5,
HCLGE_CMD_PARA_ERR = 6,
HCLGE_CMD_RESULT_ERR = 7,
HCLGE_CMD_TIMEOUT = 8,
HCLGE_CMD_HILINK_ERR = 9,
HCLGE_CMD_QUEUE_ILLEGAL = 10,
HCLGE_CMD_INVALID = 11,
};
enum hclge_cmd_status {
HCLGE_STATUS_SUCCESS = 0,
HCLGE_ERR_CSQ_FULL = -1,
HCLGE_ERR_CSQ_TIMEOUT = -2,
HCLGE_ERR_CSQ_ERROR = -3,
};
struct hclge_misc_vector { struct hclge_misc_vector {
u8 __iomem *addr; u8 __iomem *addr;
int vector_irq; int vector_irq;
char name[HNAE3_INT_NAME_LEN]; char name[HNAE3_INT_NAME_LEN];
}; };
struct hclge_cmq {
struct hclge_cmq_ring csq;
struct hclge_cmq_ring crq;
u16 tx_timeout;
enum hclge_cmd_status last_status;
};
#define HCLGE_CMD_FLAG_IN BIT(0) #define HCLGE_CMD_FLAG_IN BIT(0)
#define HCLGE_CMD_FLAG_OUT BIT(1) #define HCLGE_CMD_FLAG_OUT BIT(1)
#define HCLGE_CMD_FLAG_NEXT BIT(2) #define HCLGE_CMD_FLAG_NEXT BIT(2)
...@@ -1239,25 +1194,6 @@ struct hclge_caps_bit_map { ...@@ -1239,25 +1194,6 @@ struct hclge_caps_bit_map {
}; };
int hclge_cmd_init(struct hclge_dev *hdev); int hclge_cmd_init(struct hclge_dev *hdev);
static inline void hclge_write_reg(void __iomem *base, u32 reg, u32 value)
{
writel(value, base + reg);
}
#define hclge_write_dev(a, reg, value) \
hclge_write_reg((a)->io_base, reg, value)
#define hclge_read_dev(a, reg) \
hclge_read_reg((a)->io_base, reg)
static inline u32 hclge_read_reg(u8 __iomem *base, u32 reg)
{
u8 __iomem *reg_addr = READ_ONCE(base);
return readl(reg_addr + reg);
}
#define HCLGE_SEND_SYNC(flag) \
((flag) & HCLGE_CMD_FLAG_NO_INTR)
struct hclge_hw; struct hclge_hw;
int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num); int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num);
...@@ -1265,9 +1201,9 @@ void hclge_cmd_setup_basic_desc(struct hclge_desc *desc, ...@@ -1265,9 +1201,9 @@ void hclge_cmd_setup_basic_desc(struct hclge_desc *desc,
enum hclge_opcode_type opcode, bool is_read); enum hclge_opcode_type opcode, bool is_read);
void hclge_cmd_reuse_desc(struct hclge_desc *desc, bool is_read); void hclge_cmd_reuse_desc(struct hclge_desc *desc, bool is_read);
enum hclge_cmd_status hclge_cmd_mdio_write(struct hclge_hw *hw, enum hclge_comm_cmd_status hclge_cmd_mdio_write(struct hclge_hw *hw,
struct hclge_desc *desc); struct hclge_desc *desc);
enum hclge_cmd_status hclge_cmd_mdio_read(struct hclge_hw *hw, enum hclge_comm_cmd_status hclge_cmd_mdio_read(struct hclge_hw *hw,
struct hclge_desc *desc); struct hclge_desc *desc);
void hclge_cmd_uninit(struct hclge_dev *hdev); void hclge_cmd_uninit(struct hclge_dev *hdev);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "hclge_err.h" #include "hclge_err.h"
#include "hnae3.h" #include "hnae3.h"
#include "hclge_devlink.h" #include "hclge_devlink.h"
#include "hclge_comm_cmd.h"
#define HCLGE_NAME "hclge" #define HCLGE_NAME "hclge"
...@@ -1764,11 +1765,11 @@ static int hclge_alloc_tqps(struct hclge_dev *hdev) ...@@ -1764,11 +1765,11 @@ static int hclge_alloc_tqps(struct hclge_dev *hdev)
* HCLGE_TQP_MAX_SIZE_DEV_V2 * HCLGE_TQP_MAX_SIZE_DEV_V2
*/ */
if (i < HCLGE_TQP_MAX_SIZE_DEV_V2) if (i < HCLGE_TQP_MAX_SIZE_DEV_V2)
tqp->q.io_base = hdev->hw.io_base + tqp->q.io_base = hdev->hw.hw.io_base +
HCLGE_TQP_REG_OFFSET + HCLGE_TQP_REG_OFFSET +
i * HCLGE_TQP_REG_SIZE; i * HCLGE_TQP_REG_SIZE;
else else
tqp->q.io_base = hdev->hw.io_base + tqp->q.io_base = hdev->hw.hw.io_base +
HCLGE_TQP_REG_OFFSET + HCLGE_TQP_REG_OFFSET +
HCLGE_TQP_EXT_REG_OFFSET + HCLGE_TQP_EXT_REG_OFFSET +
(i - HCLGE_TQP_MAX_SIZE_DEV_V2) * (i - HCLGE_TQP_MAX_SIZE_DEV_V2) *
...@@ -1912,7 +1913,7 @@ static int hclge_vport_setup(struct hclge_vport *vport, u16 num_tqps) ...@@ -1912,7 +1913,7 @@ static int hclge_vport_setup(struct hclge_vport *vport, u16 num_tqps)
nic->pdev = hdev->pdev; nic->pdev = hdev->pdev;
nic->ae_algo = &ae_algo; nic->ae_algo = &ae_algo;
nic->numa_node_mask = hdev->numa_node_mask; nic->numa_node_mask = hdev->numa_node_mask;
nic->kinfo.io_base = hdev->hw.io_base; nic->kinfo.io_base = hdev->hw.hw.io_base;
ret = hclge_knic_setup(vport, num_tqps, ret = hclge_knic_setup(vport, num_tqps,
hdev->num_tx_desc, hdev->num_rx_desc); hdev->num_tx_desc, hdev->num_rx_desc);
...@@ -2597,8 +2598,8 @@ static int hclge_init_roce_base_info(struct hclge_vport *vport) ...@@ -2597,8 +2598,8 @@ static int hclge_init_roce_base_info(struct hclge_vport *vport)
roce->rinfo.base_vector = hdev->num_nic_msi; roce->rinfo.base_vector = hdev->num_nic_msi;
roce->rinfo.netdev = nic->kinfo.netdev; roce->rinfo.netdev = nic->kinfo.netdev;
roce->rinfo.roce_io_base = hdev->hw.io_base; roce->rinfo.roce_io_base = hdev->hw.hw.io_base;
roce->rinfo.roce_mem_base = hdev->hw.mem_base; roce->rinfo.roce_mem_base = hdev->hw.hw.mem_base;
roce->pdev = nic->pdev; roce->pdev = nic->pdev;
roce->ae_algo = nic->ae_algo; roce->ae_algo = nic->ae_algo;
...@@ -3503,7 +3504,7 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) ...@@ -3503,7 +3504,7 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval)
if (BIT(HCLGE_VECTOR0_IMPRESET_INT_B) & msix_src_reg) { if (BIT(HCLGE_VECTOR0_IMPRESET_INT_B) & msix_src_reg) {
dev_info(&hdev->pdev->dev, "IMP reset interrupt\n"); dev_info(&hdev->pdev->dev, "IMP reset interrupt\n");
set_bit(HNAE3_IMP_RESET, &hdev->reset_pending); set_bit(HNAE3_IMP_RESET, &hdev->reset_pending);
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
*clearval = BIT(HCLGE_VECTOR0_IMPRESET_INT_B); *clearval = BIT(HCLGE_VECTOR0_IMPRESET_INT_B);
hdev->rst_stats.imp_rst_cnt++; hdev->rst_stats.imp_rst_cnt++;
return HCLGE_VECTOR0_EVENT_RST; return HCLGE_VECTOR0_EVENT_RST;
...@@ -3511,7 +3512,7 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) ...@@ -3511,7 +3512,7 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval)
if (BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B) & msix_src_reg) { if (BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B) & msix_src_reg) {
dev_info(&hdev->pdev->dev, "global reset interrupt\n"); dev_info(&hdev->pdev->dev, "global reset interrupt\n");
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
set_bit(HNAE3_GLOBAL_RESET, &hdev->reset_pending); set_bit(HNAE3_GLOBAL_RESET, &hdev->reset_pending);
*clearval = BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B); *clearval = BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B);
hdev->rst_stats.global_rst_cnt++; hdev->rst_stats.global_rst_cnt++;
...@@ -3645,7 +3646,7 @@ static void hclge_get_misc_vector(struct hclge_dev *hdev) ...@@ -3645,7 +3646,7 @@ static void hclge_get_misc_vector(struct hclge_dev *hdev)
vector->vector_irq = pci_irq_vector(hdev->pdev, 0); vector->vector_irq = pci_irq_vector(hdev->pdev, 0);
vector->addr = hdev->hw.io_base + HCLGE_MISC_VECTOR_REG_BASE; vector->addr = hdev->hw.hw.io_base + HCLGE_MISC_VECTOR_REG_BASE;
hdev->vector_status[0] = 0; hdev->vector_status[0] = 0;
hdev->num_msi_left -= 1; hdev->num_msi_left -= 1;
...@@ -3829,7 +3830,7 @@ static int hclge_set_all_vf_rst(struct hclge_dev *hdev, bool reset) ...@@ -3829,7 +3830,7 @@ static int hclge_set_all_vf_rst(struct hclge_dev *hdev, bool reset)
static void hclge_mailbox_service_task(struct hclge_dev *hdev) static void hclge_mailbox_service_task(struct hclge_dev *hdev)
{ {
if (!test_and_clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state) || if (!test_and_clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state) ||
test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state) || test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state) ||
test_and_set_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state)) test_and_set_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state))
return; return;
...@@ -4076,7 +4077,7 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev) ...@@ -4076,7 +4077,7 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev)
* any mailbox handling or command to firmware is only valid * any mailbox handling or command to firmware is only valid
* after hclge_cmd_init is called. * after hclge_cmd_init is called.
*/ */
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
hdev->rst_stats.pf_rst_cnt++; hdev->rst_stats.pf_rst_cnt++;
break; break;
case HNAE3_FLR_RESET: case HNAE3_FLR_RESET:
...@@ -4630,11 +4631,11 @@ static void hclge_get_vector_info(struct hclge_dev *hdev, u16 idx, ...@@ -4630,11 +4631,11 @@ static void hclge_get_vector_info(struct hclge_dev *hdev, u16 idx,
/* need an extend offset to config vector >= 64 */ /* need an extend offset to config vector >= 64 */
if (idx - 1 < HCLGE_PF_MAX_VECTOR_NUM_DEV_V2) if (idx - 1 < HCLGE_PF_MAX_VECTOR_NUM_DEV_V2)
vector_info->io_addr = hdev->hw.io_base + vector_info->io_addr = hdev->hw.hw.io_base +
HCLGE_VECTOR_REG_BASE + HCLGE_VECTOR_REG_BASE +
(idx - 1) * HCLGE_VECTOR_REG_OFFSET; (idx - 1) * HCLGE_VECTOR_REG_OFFSET;
else else
vector_info->io_addr = hdev->hw.io_base + vector_info->io_addr = hdev->hw.hw.io_base +
HCLGE_VECTOR_EXT_REG_BASE + HCLGE_VECTOR_EXT_REG_BASE +
(idx - 1) / HCLGE_PF_MAX_VECTOR_NUM_DEV_V2 * (idx - 1) / HCLGE_PF_MAX_VECTOR_NUM_DEV_V2 *
HCLGE_VECTOR_REG_OFFSET_H + HCLGE_VECTOR_REG_OFFSET_H +
...@@ -5272,7 +5273,7 @@ int hclge_bind_ring_with_vector(struct hclge_vport *vport, ...@@ -5272,7 +5273,7 @@ int hclge_bind_ring_with_vector(struct hclge_vport *vport,
struct hclge_desc desc; struct hclge_desc desc;
struct hclge_ctrl_vector_chain_cmd *req = struct hclge_ctrl_vector_chain_cmd *req =
(struct hclge_ctrl_vector_chain_cmd *)desc.data; (struct hclge_ctrl_vector_chain_cmd *)desc.data;
enum hclge_cmd_status status; enum hclge_comm_cmd_status status;
enum hclge_opcode_type op; enum hclge_opcode_type op;
u16 tqp_type_and_id; u16 tqp_type_and_id;
int i; int i;
...@@ -7808,7 +7809,7 @@ static bool hclge_get_cmdq_stat(struct hnae3_handle *handle) ...@@ -7808,7 +7809,7 @@ static bool hclge_get_cmdq_stat(struct hnae3_handle *handle)
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
return test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); return test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
} }
static bool hclge_ae_dev_resetting(struct hnae3_handle *handle) static bool hclge_ae_dev_resetting(struct hnae3_handle *handle)
...@@ -9038,7 +9039,7 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport, ...@@ -9038,7 +9039,7 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport,
char format_mac_addr[HNAE3_FORMAT_MAC_ADDR_LEN]; char format_mac_addr[HNAE3_FORMAT_MAC_ADDR_LEN];
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
struct hclge_mac_vlan_tbl_entry_cmd req; struct hclge_mac_vlan_tbl_entry_cmd req;
enum hclge_cmd_status status; enum hclge_comm_cmd_status status;
struct hclge_desc desc[3]; struct hclge_desc desc[3];
/* mac addr check */ /* mac addr check */
...@@ -11536,10 +11537,11 @@ static int hclge_dev_mem_map(struct hclge_dev *hdev) ...@@ -11536,10 +11537,11 @@ static int hclge_dev_mem_map(struct hclge_dev *hdev)
if (!(pci_select_bars(pdev, IORESOURCE_MEM) & BIT(HCLGE_MEM_BAR))) if (!(pci_select_bars(pdev, IORESOURCE_MEM) & BIT(HCLGE_MEM_BAR)))
return 0; return 0;
hw->mem_base = devm_ioremap_wc(&pdev->dev, hw->hw.mem_base =
devm_ioremap_wc(&pdev->dev,
pci_resource_start(pdev, HCLGE_MEM_BAR), pci_resource_start(pdev, HCLGE_MEM_BAR),
pci_resource_len(pdev, HCLGE_MEM_BAR)); pci_resource_len(pdev, HCLGE_MEM_BAR));
if (!hw->mem_base) { if (!hw->hw.mem_base) {
dev_err(&pdev->dev, "failed to map device memory\n"); dev_err(&pdev->dev, "failed to map device memory\n");
return -EFAULT; return -EFAULT;
} }
...@@ -11578,8 +11580,8 @@ static int hclge_pci_init(struct hclge_dev *hdev) ...@@ -11578,8 +11580,8 @@ static int hclge_pci_init(struct hclge_dev *hdev)
pci_set_master(pdev); pci_set_master(pdev);
hw = &hdev->hw; hw = &hdev->hw;
hw->io_base = pcim_iomap(pdev, 2, 0); hw->hw.io_base = pcim_iomap(pdev, 2, 0);
if (!hw->io_base) { if (!hw->hw.io_base) {
dev_err(&pdev->dev, "Can't map configuration register space\n"); dev_err(&pdev->dev, "Can't map configuration register space\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_clr_master; goto err_clr_master;
...@@ -11594,7 +11596,7 @@ static int hclge_pci_init(struct hclge_dev *hdev) ...@@ -11594,7 +11596,7 @@ static int hclge_pci_init(struct hclge_dev *hdev)
return 0; return 0;
err_unmap_io_base: err_unmap_io_base:
pcim_iounmap(pdev, hdev->hw.io_base); pcim_iounmap(pdev, hdev->hw.hw.io_base);
err_clr_master: err_clr_master:
pci_clear_master(pdev); pci_clear_master(pdev);
pci_release_regions(pdev); pci_release_regions(pdev);
...@@ -11608,10 +11610,10 @@ static void hclge_pci_uninit(struct hclge_dev *hdev) ...@@ -11608,10 +11610,10 @@ static void hclge_pci_uninit(struct hclge_dev *hdev)
{ {
struct pci_dev *pdev = hdev->pdev; struct pci_dev *pdev = hdev->pdev;
if (hdev->hw.mem_base) if (hdev->hw.hw.mem_base)
devm_iounmap(&pdev->dev, hdev->hw.mem_base); devm_iounmap(&pdev->dev, hdev->hw.hw.mem_base);
pcim_iounmap(pdev, hdev->hw.io_base); pcim_iounmap(pdev, hdev->hw.hw.io_base);
pci_free_irq_vectors(pdev); pci_free_irq_vectors(pdev);
pci_clear_master(pdev); pci_clear_master(pdev);
pci_release_mem_regions(pdev); pci_release_mem_regions(pdev);
...@@ -11668,7 +11670,7 @@ static void hclge_reset_prepare_general(struct hnae3_ae_dev *ae_dev, ...@@ -11668,7 +11670,7 @@ static void hclge_reset_prepare_general(struct hnae3_ae_dev *ae_dev,
/* disable misc vector before reset done */ /* disable misc vector before reset done */
hclge_enable_vector(&hdev->misc_vector, false); hclge_enable_vector(&hdev->misc_vector, false);
set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); set_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state);
if (hdev->reset_type == HNAE3_FLR_RESET) if (hdev->reset_type == HNAE3_FLR_RESET)
hdev->rst_stats.flr_rst_cnt++; hdev->rst_stats.flr_rst_cnt++;
...@@ -11955,7 +11957,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -11955,7 +11957,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
err_devlink_uninit: err_devlink_uninit:
hclge_devlink_uninit(hdev); hclge_devlink_uninit(hdev);
err_pci_uninit: err_pci_uninit:
pcim_iounmap(pdev, hdev->hw.io_base); pcim_iounmap(pdev, hdev->hw.hw.io_base);
pci_clear_master(pdev); pci_clear_master(pdev);
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
......
...@@ -228,7 +228,6 @@ enum HCLGE_DEV_STATE { ...@@ -228,7 +228,6 @@ enum HCLGE_DEV_STATE {
HCLGE_STATE_MBX_HANDLING, HCLGE_STATE_MBX_HANDLING,
HCLGE_STATE_ERR_SERVICE_SCHED, HCLGE_STATE_ERR_SERVICE_SCHED,
HCLGE_STATE_STATISTICS_UPDATING, HCLGE_STATE_STATISTICS_UPDATING,
HCLGE_STATE_CMD_DISABLE,
HCLGE_STATE_LINK_UPDATING, HCLGE_STATE_LINK_UPDATING,
HCLGE_STATE_RST_FAIL, HCLGE_STATE_RST_FAIL,
HCLGE_STATE_FD_TBL_CHANGED, HCLGE_STATE_FD_TBL_CHANGED,
...@@ -294,11 +293,9 @@ struct hclge_mac { ...@@ -294,11 +293,9 @@ struct hclge_mac {
}; };
struct hclge_hw { struct hclge_hw {
void __iomem *io_base; struct hclge_comm_hw hw;
void __iomem *mem_base;
struct hclge_mac mac; struct hclge_mac mac;
int num_vec; int num_vec;
struct hclge_cmq cmq;
}; };
/* TQP stats */ /* TQP stats */
...@@ -641,6 +638,11 @@ struct key_info { ...@@ -641,6 +638,11 @@ struct key_info {
#define MAX_FD_FILTER_NUM 4096 #define MAX_FD_FILTER_NUM 4096
#define HCLGE_ARFS_EXPIRE_INTERVAL 5UL #define HCLGE_ARFS_EXPIRE_INTERVAL 5UL
#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)
enum HCLGE_FD_ACTIVE_RULE_TYPE { enum HCLGE_FD_ACTIVE_RULE_TYPE {
HCLGE_FD_RULE_NONE, HCLGE_FD_RULE_NONE,
HCLGE_FD_ARFS_ACTIVE, HCLGE_FD_ARFS_ACTIVE,
......
...@@ -33,7 +33,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, ...@@ -33,7 +33,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport,
{ {
struct hclge_mbx_pf_to_vf_cmd *resp_pf_to_vf; struct hclge_mbx_pf_to_vf_cmd *resp_pf_to_vf;
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
enum hclge_cmd_status status; enum hclge_comm_cmd_status status;
struct hclge_desc desc; struct hclge_desc desc;
u16 resp; u16 resp;
...@@ -90,7 +90,7 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len, ...@@ -90,7 +90,7 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
{ {
struct hclge_mbx_pf_to_vf_cmd *resp_pf_to_vf; struct hclge_mbx_pf_to_vf_cmd *resp_pf_to_vf;
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
enum hclge_cmd_status status; enum hclge_comm_cmd_status status;
struct hclge_desc desc; struct hclge_desc desc;
resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data; resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data;
...@@ -663,7 +663,7 @@ static bool hclge_cmd_crq_empty(struct hclge_hw *hw) ...@@ -663,7 +663,7 @@ static bool hclge_cmd_crq_empty(struct hclge_hw *hw)
{ {
u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG); u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG);
return tail == hw->cmq.crq.next_to_use; return tail == hw->hw.cmq.crq.next_to_use;
} }
static void hclge_handle_ncsi_error(struct hclge_dev *hdev) static void hclge_handle_ncsi_error(struct hclge_dev *hdev)
...@@ -694,7 +694,7 @@ static void hclge_handle_vf_tbl(struct hclge_vport *vport, ...@@ -694,7 +694,7 @@ static void hclge_handle_vf_tbl(struct hclge_vport *vport,
void hclge_mbx_handler(struct hclge_dev *hdev) void hclge_mbx_handler(struct hclge_dev *hdev)
{ {
struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq; struct hclge_comm_cmq_ring *crq = &hdev->hw.hw.cmq.crq;
struct hclge_respond_to_vf_msg resp_msg; struct hclge_respond_to_vf_msg resp_msg;
struct hclge_mbx_vf_to_pf_cmd *req; struct hclge_mbx_vf_to_pf_cmd *req;
struct hclge_vport *vport; struct hclge_vport *vport;
...@@ -705,7 +705,8 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -705,7 +705,8 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
/* handle all the mailbox requests in the queue */ /* handle all the mailbox requests in the queue */
while (!hclge_cmd_crq_empty(&hdev->hw)) { while (!hclge_cmd_crq_empty(&hdev->hw)) {
if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) { if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE,
&hdev->hw.hw.comm_state)) {
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"command queue needs re-initializing\n"); "command queue needs re-initializing\n");
return; return;
......
...@@ -47,7 +47,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum, ...@@ -47,7 +47,7 @@ static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum,
struct hclge_desc desc; struct hclge_desc desc;
int ret; int ret;
if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state))
return 0; return 0;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, false);
...@@ -85,7 +85,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum) ...@@ -85,7 +85,7 @@ static int hclge_mdio_read(struct mii_bus *bus, int phyid, int regnum)
struct hclge_desc desc; struct hclge_desc desc;
int ret; int ret;
if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) if (test_bit(HCLGE_COMM_STATE_CMD_DISABLE, &hdev->hw.hw.comm_state))
return 0; return 0;
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true); hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MDIO_CONFIG, true);
......
...@@ -464,7 +464,7 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev) ...@@ -464,7 +464,7 @@ static int hclge_ptp_create_clock(struct hclge_dev *hdev)
} }
spin_lock_init(&ptp->lock); spin_lock_init(&ptp->lock);
ptp->io_base = hdev->hw.io_base + HCLGE_PTP_REG_OFFSET; ptp->io_base = hdev->hw.hw.io_base + HCLGE_PTP_REG_OFFSET;
ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE; ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF; ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF;
hdev->ptp = ptp; hdev->ptp = ptp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment