Commit | Line | Data |
---|---|---|
25a3ba61 AK |
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_PORT_H | |
17 | #define HINIC_PORT_H | |
18 | ||
19 | #include <linux/types.h> | |
20 | #include <linux/etherdevice.h> | |
c4d06d2d | 21 | #include <linux/bitops.h> |
25a3ba61 AK |
22 | |
23 | #include "hinic_dev.h" | |
24 | ||
c4d06d2d AK |
25 | enum hinic_rx_mode { |
26 | HINIC_RX_MODE_UC = BIT(0), | |
27 | HINIC_RX_MODE_MC = BIT(1), | |
28 | HINIC_RX_MODE_BC = BIT(2), | |
29 | HINIC_RX_MODE_MC_ALL = BIT(3), | |
30 | HINIC_RX_MODE_PROMISC = BIT(4), | |
31 | }; | |
32 | ||
33 | enum hinic_port_link_state { | |
34 | HINIC_LINK_STATE_DOWN, | |
35 | HINIC_LINK_STATE_UP, | |
36 | }; | |
37 | ||
38 | enum hinic_port_state { | |
39 | HINIC_PORT_DISABLE = 0, | |
40 | HINIC_PORT_ENABLE = 3, | |
41 | }; | |
42 | ||
e2585ea7 AK |
43 | enum hinic_func_port_state { |
44 | HINIC_FUNC_PORT_DISABLE = 0, | |
45 | HINIC_FUNC_PORT_ENABLE = 2, | |
46 | }; | |
47 | ||
edd384f6 AK |
48 | enum hinic_autoneg_cap { |
49 | HINIC_AUTONEG_UNSUPPORTED, | |
50 | HINIC_AUTONEG_SUPPORTED, | |
51 | }; | |
52 | ||
53 | enum hinic_autoneg_state { | |
54 | HINIC_AUTONEG_DISABLED, | |
55 | HINIC_AUTONEG_ACTIVE, | |
56 | }; | |
57 | ||
58 | enum hinic_duplex { | |
59 | HINIC_DUPLEX_HALF, | |
60 | HINIC_DUPLEX_FULL, | |
61 | }; | |
62 | ||
63 | enum hinic_speed { | |
64 | HINIC_SPEED_10MB_LINK = 0, | |
65 | HINIC_SPEED_100MB_LINK, | |
66 | HINIC_SPEED_1000MB_LINK, | |
67 | HINIC_SPEED_10GB_LINK, | |
68 | HINIC_SPEED_25GB_LINK, | |
69 | HINIC_SPEED_40GB_LINK, | |
70 | HINIC_SPEED_100GB_LINK, | |
71 | ||
72 | HINIC_SPEED_UNKNOWN = 0xFF, | |
73 | }; | |
74 | ||
cc18a754 ZC |
75 | enum hinic_tso_state { |
76 | HINIC_TSO_DISABLE = 0, | |
77 | HINIC_TSO_ENABLE = 1, | |
78 | }; | |
79 | ||
25a3ba61 AK |
80 | struct hinic_port_mac_cmd { |
81 | u8 status; | |
82 | u8 version; | |
83 | u8 rsvd0[6]; | |
84 | ||
85 | u16 func_idx; | |
86 | u16 vlan_id; | |
87 | u16 rsvd1; | |
88 | unsigned char mac[ETH_ALEN]; | |
89 | }; | |
90 | ||
91 | struct hinic_port_mtu_cmd { | |
92 | u8 status; | |
93 | u8 version; | |
94 | u8 rsvd0[6]; | |
95 | ||
96 | u16 func_idx; | |
97 | u16 rsvd1; | |
98 | u32 mtu; | |
99 | }; | |
100 | ||
101 | struct hinic_port_vlan_cmd { | |
102 | u8 status; | |
103 | u8 version; | |
104 | u8 rsvd0[6]; | |
105 | ||
106 | u16 func_idx; | |
107 | u16 vlan_id; | |
108 | }; | |
109 | ||
c4d06d2d AK |
110 | struct hinic_port_rx_mode_cmd { |
111 | u8 status; | |
112 | u8 version; | |
113 | u8 rsvd0[6]; | |
114 | ||
115 | u16 func_idx; | |
116 | u16 rsvd; | |
117 | u32 rx_mode; | |
118 | }; | |
119 | ||
120 | struct hinic_port_link_cmd { | |
121 | u8 status; | |
122 | u8 version; | |
123 | u8 rsvd0[6]; | |
124 | ||
125 | u16 func_idx; | |
126 | u8 state; | |
127 | u8 rsvd1; | |
128 | }; | |
129 | ||
130 | struct hinic_port_state_cmd { | |
131 | u8 status; | |
132 | u8 version; | |
133 | u8 rsvd0[6]; | |
134 | ||
135 | u8 state; | |
136 | u8 rsvd1[3]; | |
137 | }; | |
138 | ||
139 | struct hinic_port_link_status { | |
140 | u8 status; | |
141 | u8 version; | |
142 | u8 rsvd0[6]; | |
143 | ||
144 | u16 rsvd1; | |
145 | u8 link; | |
146 | u8 rsvd2; | |
147 | }; | |
148 | ||
e2585ea7 AK |
149 | struct hinic_port_func_state_cmd { |
150 | u8 status; | |
151 | u8 version; | |
152 | u8 rsvd0[6]; | |
153 | ||
154 | u16 func_idx; | |
155 | u16 rsvd1; | |
156 | u8 state; | |
157 | u8 rsvd2[3]; | |
158 | }; | |
159 | ||
edd384f6 AK |
160 | struct hinic_port_cap { |
161 | u8 status; | |
162 | u8 version; | |
163 | u8 rsvd0[6]; | |
164 | ||
165 | u16 func_idx; | |
166 | u16 rsvd1; | |
167 | u8 port_type; | |
168 | u8 autoneg_cap; | |
169 | u8 autoneg_state; | |
170 | u8 duplex; | |
171 | u8 speed; | |
172 | u8 rsvd2[3]; | |
173 | }; | |
174 | ||
cc18a754 ZC |
175 | struct hinic_tso_config { |
176 | u8 status; | |
177 | u8 version; | |
178 | u8 rsvd0[6]; | |
179 | ||
180 | u16 func_id; | |
181 | u16 rsvd1; | |
182 | u8 tso_en; | |
183 | u8 resv2[3]; | |
184 | }; | |
185 | ||
25a3ba61 AK |
186 | int hinic_port_add_mac(struct hinic_dev *nic_dev, const u8 *addr, |
187 | u16 vlan_id); | |
188 | ||
189 | int hinic_port_del_mac(struct hinic_dev *nic_dev, const u8 *addr, | |
190 | u16 vlan_id); | |
191 | ||
192 | int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr); | |
193 | ||
194 | int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu); | |
195 | ||
196 | int hinic_port_add_vlan(struct hinic_dev *nic_dev, u16 vlan_id); | |
197 | ||
198 | int hinic_port_del_vlan(struct hinic_dev *nic_dev, u16 vlan_id); | |
199 | ||
c4d06d2d AK |
200 | int hinic_port_set_rx_mode(struct hinic_dev *nic_dev, u32 rx_mode); |
201 | ||
202 | int hinic_port_link_state(struct hinic_dev *nic_dev, | |
203 | enum hinic_port_link_state *link_state); | |
204 | ||
205 | int hinic_port_set_state(struct hinic_dev *nic_dev, | |
206 | enum hinic_port_state state); | |
207 | ||
e2585ea7 AK |
208 | int hinic_port_set_func_state(struct hinic_dev *nic_dev, |
209 | enum hinic_func_port_state state); | |
210 | ||
edd384f6 AK |
211 | int hinic_port_get_cap(struct hinic_dev *nic_dev, |
212 | struct hinic_port_cap *port_cap); | |
213 | ||
cc18a754 ZC |
214 | int hinic_port_set_tso(struct hinic_dev *nic_dev, enum hinic_tso_state state); |
215 | ||
25a3ba61 | 216 | #endif |