2 * Huawei HiNIC PCI Express Linux driver
3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #ifndef HINIC_HW_DEV_H
17 #define HINIC_HW_DEV_H
19 #include <linux/pci.h>
20 #include <linux/types.h>
21 #include <linux/bitops.h>
23 #include "hinic_hw_if.h"
24 #include "hinic_hw_eqs.h"
25 #include "hinic_hw_mgmt.h"
27 #define HINIC_MAX_QPS 32
29 #define HINIC_MGMT_NUM_MSG_CMD (HINIC_MGMT_MSG_CMD_MAX - \
30 HINIC_MGMT_MSG_CMD_BASE)
38 HINIC_PORT_CMD_CHANGE_MTU
= 2,
40 HINIC_PORT_CMD_ADD_VLAN
= 3,
41 HINIC_PORT_CMD_DEL_VLAN
= 4,
43 HINIC_PORT_CMD_SET_MAC
= 9,
44 HINIC_PORT_CMD_GET_MAC
= 10,
45 HINIC_PORT_CMD_DEL_MAC
= 11,
47 HINIC_PORT_CMD_SET_RX_MODE
= 12,
49 HINIC_PORT_CMD_GET_LINK_STATE
= 24,
51 HINIC_PORT_CMD_SET_PORT_STATE
= 41,
53 HINIC_PORT_CMD_FWCTXT_INIT
= 69,
55 HINIC_PORT_CMD_SET_FUNC_STATE
= 93,
57 HINIC_PORT_CMD_GET_GLOBAL_QPN
= 102,
59 HINIC_PORT_CMD_GET_CAP
= 170,
62 enum hinic_mgmt_msg_cmd
{
63 HINIC_MGMT_MSG_CMD_BASE
= 160,
65 HINIC_MGMT_MSG_CMD_LINK_STATUS
= 160,
67 HINIC_MGMT_MSG_CMD_MAX
,
71 HINIC_CB_ENABLED
= BIT(0),
72 HINIC_CB_RUNNING
= BIT(1),
76 struct hinic_hwif
*hwif
;
77 struct msix_entry
*msix_entries
;
79 struct hinic_aeqs aeqs
;
81 struct hinic_cap nic_cap
;
85 void (*handler
)(void *handle
, void *buf_in
,
86 u16 in_size
, void *buf_out
,
90 unsigned long cb_state
;
93 struct hinic_pfhwdev
{
94 struct hinic_hwdev hwdev
;
96 struct hinic_pf_to_mgmt pf_to_mgmt
;
98 struct hinic_nic_cb nic_cb
[HINIC_MGMT_NUM_MSG_CMD
];
101 void hinic_hwdev_cb_register(struct hinic_hwdev
*hwdev
,
102 enum hinic_mgmt_msg_cmd cmd
, void *handle
,
103 void (*handler
)(void *handle
, void *buf_in
,
104 u16 in_size
, void *buf_out
,
107 void hinic_hwdev_cb_unregister(struct hinic_hwdev
*hwdev
,
108 enum hinic_mgmt_msg_cmd cmd
);
110 int hinic_port_msg_cmd(struct hinic_hwdev
*hwdev
, enum hinic_port_cmd cmd
,
111 void *buf_in
, u16 in_size
, void *buf_out
,
114 struct hinic_hwdev
*hinic_init_hwdev(struct pci_dev
*pdev
);
116 void hinic_free_hwdev(struct hinic_hwdev
*hwdev
);
118 int hinic_hwdev_num_qps(struct hinic_hwdev
*hwdev
);