]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h
1cd8159766d41f08ef0746b543af2c804f640311
[mirror_ubuntu-bionic-kernel.git] / drivers / net / ethernet / huawei / hinic / hinic_hw_dev.h
1 /*
2 * Huawei HiNIC PCI Express Linux driver
3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
4 *
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.
8 *
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
12 * for more details.
13 *
14 */
15
16 #ifndef HINIC_HW_DEV_H
17 #define HINIC_HW_DEV_H
18
19 #include <linux/pci.h>
20 #include <linux/types.h>
21 #include <linux/bitops.h>
22
23 #include "hinic_hw_if.h"
24 #include "hinic_hw_eqs.h"
25 #include "hinic_hw_mgmt.h"
26
27 #define HINIC_MAX_QPS 32
28
29 #define HINIC_MGMT_NUM_MSG_CMD (HINIC_MGMT_MSG_CMD_MAX - \
30 HINIC_MGMT_MSG_CMD_BASE)
31
32 struct hinic_cap {
33 u16 max_qps;
34 u16 num_qps;
35 };
36
37 enum hinic_port_cmd {
38 HINIC_PORT_CMD_CHANGE_MTU = 2,
39
40 HINIC_PORT_CMD_ADD_VLAN = 3,
41 HINIC_PORT_CMD_DEL_VLAN = 4,
42
43 HINIC_PORT_CMD_SET_MAC = 9,
44 HINIC_PORT_CMD_GET_MAC = 10,
45 HINIC_PORT_CMD_DEL_MAC = 11,
46
47 HINIC_PORT_CMD_SET_RX_MODE = 12,
48
49 HINIC_PORT_CMD_GET_LINK_STATE = 24,
50
51 HINIC_PORT_CMD_SET_PORT_STATE = 41,
52
53 HINIC_PORT_CMD_FWCTXT_INIT = 69,
54
55 HINIC_PORT_CMD_SET_FUNC_STATE = 93,
56
57 HINIC_PORT_CMD_GET_GLOBAL_QPN = 102,
58
59 HINIC_PORT_CMD_GET_CAP = 170,
60 };
61
62 enum hinic_mgmt_msg_cmd {
63 HINIC_MGMT_MSG_CMD_BASE = 160,
64
65 HINIC_MGMT_MSG_CMD_LINK_STATUS = 160,
66
67 HINIC_MGMT_MSG_CMD_MAX,
68 };
69
70 enum hinic_cb_state {
71 HINIC_CB_ENABLED = BIT(0),
72 HINIC_CB_RUNNING = BIT(1),
73 };
74
75 struct hinic_hwdev {
76 struct hinic_hwif *hwif;
77 struct msix_entry *msix_entries;
78
79 struct hinic_aeqs aeqs;
80
81 struct hinic_cap nic_cap;
82 };
83
84 struct hinic_nic_cb {
85 void (*handler)(void *handle, void *buf_in,
86 u16 in_size, void *buf_out,
87 u16 *out_size);
88
89 void *handle;
90 unsigned long cb_state;
91 };
92
93 struct hinic_pfhwdev {
94 struct hinic_hwdev hwdev;
95
96 struct hinic_pf_to_mgmt pf_to_mgmt;
97
98 struct hinic_nic_cb nic_cb[HINIC_MGMT_NUM_MSG_CMD];
99 };
100
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,
105 u16 *out_size));
106
107 void hinic_hwdev_cb_unregister(struct hinic_hwdev *hwdev,
108 enum hinic_mgmt_msg_cmd cmd);
109
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,
112 u16 *out_size);
113
114 struct hinic_hwdev *hinic_init_hwdev(struct pci_dev *pdev);
115
116 void hinic_free_hwdev(struct hinic_hwdev *hwdev);
117
118 int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev);
119
120 #endif