.. | .. |
---|
34 | 34 | #include <linux/etherdevice.h> |
---|
35 | 35 | #include <linux/mlx5/driver.h> |
---|
36 | 36 | #include <linux/mlx5/vport.h> |
---|
| 37 | +#include <linux/mlx5/eswitch.h> |
---|
37 | 38 | #include "mlx5_core.h" |
---|
38 | 39 | |
---|
39 | 40 | /* Mutex to hold while enabling or disabling RoCE */ |
---|
40 | 41 | static DEFINE_MUTEX(mlx5_roce_en_lock); |
---|
41 | 42 | |
---|
42 | | -static int _mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, |
---|
43 | | - u16 vport, u32 *out, int outlen) |
---|
| 43 | +u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport) |
---|
44 | 44 | { |
---|
45 | | - u32 in[MLX5_ST_SZ_DW(query_vport_state_in)] = {0}; |
---|
| 45 | + u32 out[MLX5_ST_SZ_DW(query_vport_state_out)] = {}; |
---|
| 46 | + u32 in[MLX5_ST_SZ_DW(query_vport_state_in)] = {}; |
---|
| 47 | + int err; |
---|
46 | 48 | |
---|
47 | 49 | MLX5_SET(query_vport_state_in, in, opcode, |
---|
48 | 50 | MLX5_CMD_OP_QUERY_VPORT_STATE); |
---|
.. | .. |
---|
51 | 53 | if (vport) |
---|
52 | 54 | MLX5_SET(query_vport_state_in, in, other_vport, 1); |
---|
53 | 55 | |
---|
54 | | - return mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen); |
---|
55 | | -} |
---|
56 | | - |
---|
57 | | -u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport) |
---|
58 | | -{ |
---|
59 | | - u32 out[MLX5_ST_SZ_DW(query_vport_state_out)] = {0}; |
---|
60 | | - |
---|
61 | | - _mlx5_query_vport_state(mdev, opmod, vport, out, sizeof(out)); |
---|
| 56 | + err = mlx5_cmd_exec_inout(mdev, query_vport_state, in, out); |
---|
| 57 | + if (err) |
---|
| 58 | + return 0; |
---|
62 | 59 | |
---|
63 | 60 | return MLX5_GET(query_vport_state_out, out, state); |
---|
64 | 61 | } |
---|
65 | 62 | |
---|
66 | 63 | int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, |
---|
67 | | - u16 vport, u8 state) |
---|
| 64 | + u16 vport, u8 other_vport, u8 state) |
---|
68 | 65 | { |
---|
69 | | - u32 in[MLX5_ST_SZ_DW(modify_vport_state_in)] = {0}; |
---|
70 | | - u32 out[MLX5_ST_SZ_DW(modify_vport_state_out)] = {0}; |
---|
| 66 | + u32 in[MLX5_ST_SZ_DW(modify_vport_state_in)] = {}; |
---|
71 | 67 | |
---|
72 | 68 | MLX5_SET(modify_vport_state_in, in, opcode, |
---|
73 | 69 | MLX5_CMD_OP_MODIFY_VPORT_STATE); |
---|
74 | 70 | MLX5_SET(modify_vport_state_in, in, op_mod, opmod); |
---|
75 | 71 | MLX5_SET(modify_vport_state_in, in, vport_number, vport); |
---|
76 | | - if (vport) |
---|
77 | | - MLX5_SET(modify_vport_state_in, in, other_vport, 1); |
---|
| 72 | + MLX5_SET(modify_vport_state_in, in, other_vport, other_vport); |
---|
78 | 73 | MLX5_SET(modify_vport_state_in, in, admin_state, state); |
---|
79 | 74 | |
---|
80 | | - return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out)); |
---|
| 75 | + return mlx5_cmd_exec_in(mdev, modify_vport_state, in); |
---|
81 | 76 | } |
---|
82 | 77 | |
---|
83 | 78 | static int mlx5_query_nic_vport_context(struct mlx5_core_dev *mdev, u16 vport, |
---|
84 | | - u32 *out, int outlen) |
---|
| 79 | + u32 *out) |
---|
85 | 80 | { |
---|
86 | | - u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)] = {0}; |
---|
| 81 | + u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)] = {}; |
---|
87 | 82 | |
---|
88 | 83 | MLX5_SET(query_nic_vport_context_in, in, opcode, |
---|
89 | 84 | MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT); |
---|
.. | .. |
---|
91 | 86 | if (vport) |
---|
92 | 87 | MLX5_SET(query_nic_vport_context_in, in, other_vport, 1); |
---|
93 | 88 | |
---|
94 | | - return mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen); |
---|
95 | | -} |
---|
96 | | - |
---|
97 | | -static int mlx5_modify_nic_vport_context(struct mlx5_core_dev *mdev, void *in, |
---|
98 | | - int inlen) |
---|
99 | | -{ |
---|
100 | | - u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)] = {0}; |
---|
101 | | - |
---|
102 | | - MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
103 | | - MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
104 | | - return mlx5_cmd_exec(mdev, in, inlen, out, sizeof(out)); |
---|
| 89 | + return mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out); |
---|
105 | 90 | } |
---|
106 | 91 | |
---|
107 | 92 | int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev, |
---|
108 | 93 | u16 vport, u8 *min_inline) |
---|
109 | 94 | { |
---|
110 | | - u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {0}; |
---|
| 95 | + u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {}; |
---|
111 | 96 | int err; |
---|
112 | 97 | |
---|
113 | | - err = mlx5_query_nic_vport_context(mdev, vport, out, sizeof(out)); |
---|
| 98 | + err = mlx5_query_nic_vport_context(mdev, vport, out); |
---|
114 | 99 | if (!err) |
---|
115 | 100 | *min_inline = MLX5_GET(query_nic_vport_context_out, out, |
---|
116 | 101 | nic_vport_context.min_wqe_inline_mode); |
---|
.. | .. |
---|
122 | 107 | u8 *min_inline_mode) |
---|
123 | 108 | { |
---|
124 | 109 | switch (MLX5_CAP_ETH(mdev, wqe_inline_mode)) { |
---|
| 110 | + case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT: |
---|
| 111 | + if (!mlx5_query_nic_vport_min_inline(mdev, 0, min_inline_mode)) |
---|
| 112 | + break; |
---|
| 113 | + fallthrough; |
---|
125 | 114 | case MLX5_CAP_INLINE_MODE_L2: |
---|
126 | 115 | *min_inline_mode = MLX5_INLINE_MODE_L2; |
---|
127 | | - break; |
---|
128 | | - case MLX5_CAP_INLINE_MODE_VPORT_CONTEXT: |
---|
129 | | - mlx5_query_nic_vport_min_inline(mdev, 0, min_inline_mode); |
---|
130 | 116 | break; |
---|
131 | 117 | case MLX5_CAP_INLINE_MODE_NOT_REQUIRED: |
---|
132 | 118 | *min_inline_mode = MLX5_INLINE_MODE_NONE; |
---|
.. | .. |
---|
138 | 124 | int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev, |
---|
139 | 125 | u16 vport, u8 min_inline) |
---|
140 | 126 | { |
---|
141 | | - u32 in[MLX5_ST_SZ_DW(modify_nic_vport_context_in)] = {0}; |
---|
142 | | - int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); |
---|
| 127 | + u32 in[MLX5_ST_SZ_DW(modify_nic_vport_context_in)] = {}; |
---|
143 | 128 | void *nic_vport_ctx; |
---|
144 | 129 | |
---|
145 | 130 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
.. | .. |
---|
151 | 136 | in, nic_vport_context); |
---|
152 | 137 | MLX5_SET(nic_vport_context, nic_vport_ctx, |
---|
153 | 138 | min_wqe_inline_mode, min_inline); |
---|
| 139 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 140 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
154 | 141 | |
---|
155 | | - return mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 142 | + return mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
156 | 143 | } |
---|
157 | 144 | |
---|
158 | 145 | int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev, |
---|
159 | | - u16 vport, u8 *addr) |
---|
| 146 | + u16 vport, bool other, u8 *addr) |
---|
160 | 147 | { |
---|
161 | | - u32 *out; |
---|
162 | | - int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); |
---|
| 148 | + u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {}; |
---|
| 149 | + u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)] = {}; |
---|
163 | 150 | u8 *out_addr; |
---|
164 | 151 | int err; |
---|
165 | | - |
---|
166 | | - out = kvzalloc(outlen, GFP_KERNEL); |
---|
167 | | - if (!out) |
---|
168 | | - return -ENOMEM; |
---|
169 | 152 | |
---|
170 | 153 | out_addr = MLX5_ADDR_OF(query_nic_vport_context_out, out, |
---|
171 | 154 | nic_vport_context.permanent_address); |
---|
172 | 155 | |
---|
173 | | - err = mlx5_query_nic_vport_context(mdev, vport, out, outlen); |
---|
| 156 | + MLX5_SET(query_nic_vport_context_in, in, opcode, |
---|
| 157 | + MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT); |
---|
| 158 | + MLX5_SET(query_nic_vport_context_in, in, vport_number, vport); |
---|
| 159 | + MLX5_SET(query_nic_vport_context_in, in, other_vport, other); |
---|
| 160 | + |
---|
| 161 | + err = mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out); |
---|
174 | 162 | if (!err) |
---|
175 | 163 | ether_addr_copy(addr, &out_addr[2]); |
---|
176 | 164 | |
---|
177 | | - kvfree(out); |
---|
178 | 165 | return err; |
---|
179 | 166 | } |
---|
180 | 167 | EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_mac_address); |
---|
181 | 168 | |
---|
| 169 | +int mlx5_query_mac_address(struct mlx5_core_dev *mdev, u8 *addr) |
---|
| 170 | +{ |
---|
| 171 | + return mlx5_query_nic_vport_mac_address(mdev, 0, false, addr); |
---|
| 172 | +} |
---|
| 173 | +EXPORT_SYMBOL_GPL(mlx5_query_mac_address); |
---|
| 174 | + |
---|
182 | 175 | int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *mdev, |
---|
183 | | - u16 vport, u8 *addr) |
---|
| 176 | + u16 vport, const u8 *addr) |
---|
184 | 177 | { |
---|
185 | 178 | void *in; |
---|
186 | 179 | int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); |
---|
.. | .. |
---|
195 | 188 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
196 | 189 | field_select.permanent_address, 1); |
---|
197 | 190 | MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); |
---|
198 | | - |
---|
199 | | - if (vport) |
---|
200 | | - MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1); |
---|
| 191 | + MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1); |
---|
201 | 192 | |
---|
202 | 193 | nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, |
---|
203 | 194 | in, nic_vport_context); |
---|
.. | .. |
---|
205 | 196 | permanent_address); |
---|
206 | 197 | |
---|
207 | 198 | ether_addr_copy(&perm_mac[2], addr); |
---|
| 199 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 200 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
208 | 201 | |
---|
209 | | - err = mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 202 | + err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
210 | 203 | |
---|
211 | 204 | kvfree(in); |
---|
212 | 205 | |
---|
.. | .. |
---|
224 | 217 | if (!out) |
---|
225 | 218 | return -ENOMEM; |
---|
226 | 219 | |
---|
227 | | - err = mlx5_query_nic_vport_context(mdev, 0, out, outlen); |
---|
| 220 | + err = mlx5_query_nic_vport_context(mdev, 0, out); |
---|
228 | 221 | if (!err) |
---|
229 | 222 | *mtu = MLX5_GET(query_nic_vport_context_out, out, |
---|
230 | 223 | nic_vport_context.mtu); |
---|
.. | .. |
---|
246 | 239 | |
---|
247 | 240 | MLX5_SET(modify_nic_vport_context_in, in, field_select.mtu, 1); |
---|
248 | 241 | MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.mtu, mtu); |
---|
| 242 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 243 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
249 | 244 | |
---|
250 | | - err = mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 245 | + err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
251 | 246 | |
---|
252 | 247 | kvfree(in); |
---|
253 | 248 | return err; |
---|
.. | .. |
---|
255 | 250 | EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mtu); |
---|
256 | 251 | |
---|
257 | 252 | int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev, |
---|
258 | | - u32 vport, |
---|
| 253 | + u16 vport, |
---|
259 | 254 | enum mlx5_list_type list_type, |
---|
260 | 255 | u8 addr_list[][ETH_ALEN], |
---|
261 | 256 | int *list_size) |
---|
.. | .. |
---|
281 | 276 | req_list_size = max_list_size; |
---|
282 | 277 | } |
---|
283 | 278 | |
---|
284 | | - out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) + |
---|
| 279 | + out_sz = MLX5_ST_SZ_BYTES(query_nic_vport_context_in) + |
---|
285 | 280 | req_list_size * MLX5_ST_SZ_BYTES(mac_address_layout); |
---|
286 | 281 | |
---|
287 | 282 | out = kzalloc(out_sz, GFP_KERNEL); |
---|
.. | .. |
---|
292 | 287 | MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT); |
---|
293 | 288 | MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, list_type); |
---|
294 | 289 | MLX5_SET(query_nic_vport_context_in, in, vport_number, vport); |
---|
295 | | - |
---|
296 | | - if (vport) |
---|
297 | | - MLX5_SET(query_nic_vport_context_in, in, other_vport, 1); |
---|
| 290 | + MLX5_SET(query_nic_vport_context_in, in, other_vport, 1); |
---|
298 | 291 | |
---|
299 | 292 | err = mlx5_cmd_exec(dev, in, sizeof(in), out, out_sz); |
---|
300 | 293 | if (err) |
---|
.. | .. |
---|
323 | 316 | u8 addr_list[][ETH_ALEN], |
---|
324 | 317 | int list_size) |
---|
325 | 318 | { |
---|
326 | | - u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)]; |
---|
| 319 | + u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)] = {}; |
---|
327 | 320 | void *nic_vport_ctx; |
---|
328 | 321 | int max_list_size; |
---|
329 | 322 | int in_sz; |
---|
.. | .. |
---|
341 | 334 | in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) + |
---|
342 | 335 | list_size * MLX5_ST_SZ_BYTES(mac_address_layout); |
---|
343 | 336 | |
---|
344 | | - memset(out, 0, sizeof(out)); |
---|
345 | 337 | in = kzalloc(in_sz, GFP_KERNEL); |
---|
346 | 338 | if (!in) |
---|
347 | 339 | return -ENOMEM; |
---|
.. | .. |
---|
371 | 363 | return err; |
---|
372 | 364 | } |
---|
373 | 365 | EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mac_list); |
---|
374 | | - |
---|
375 | | -int mlx5_query_nic_vport_vlans(struct mlx5_core_dev *dev, |
---|
376 | | - u32 vport, |
---|
377 | | - u16 vlans[], |
---|
378 | | - int *size) |
---|
379 | | -{ |
---|
380 | | - u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)]; |
---|
381 | | - void *nic_vport_ctx; |
---|
382 | | - int req_list_size; |
---|
383 | | - int max_list_size; |
---|
384 | | - int out_sz; |
---|
385 | | - void *out; |
---|
386 | | - int err; |
---|
387 | | - int i; |
---|
388 | | - |
---|
389 | | - req_list_size = *size; |
---|
390 | | - max_list_size = 1 << MLX5_CAP_GEN(dev, log_max_vlan_list); |
---|
391 | | - if (req_list_size > max_list_size) { |
---|
392 | | - mlx5_core_warn(dev, "Requested list size (%d) > (%d) max list size\n", |
---|
393 | | - req_list_size, max_list_size); |
---|
394 | | - req_list_size = max_list_size; |
---|
395 | | - } |
---|
396 | | - |
---|
397 | | - out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) + |
---|
398 | | - req_list_size * MLX5_ST_SZ_BYTES(vlan_layout); |
---|
399 | | - |
---|
400 | | - memset(in, 0, sizeof(in)); |
---|
401 | | - out = kzalloc(out_sz, GFP_KERNEL); |
---|
402 | | - if (!out) |
---|
403 | | - return -ENOMEM; |
---|
404 | | - |
---|
405 | | - MLX5_SET(query_nic_vport_context_in, in, opcode, |
---|
406 | | - MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT); |
---|
407 | | - MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, |
---|
408 | | - MLX5_NVPRT_LIST_TYPE_VLAN); |
---|
409 | | - MLX5_SET(query_nic_vport_context_in, in, vport_number, vport); |
---|
410 | | - |
---|
411 | | - if (vport) |
---|
412 | | - MLX5_SET(query_nic_vport_context_in, in, other_vport, 1); |
---|
413 | | - |
---|
414 | | - err = mlx5_cmd_exec(dev, in, sizeof(in), out, out_sz); |
---|
415 | | - if (err) |
---|
416 | | - goto out; |
---|
417 | | - |
---|
418 | | - nic_vport_ctx = MLX5_ADDR_OF(query_nic_vport_context_out, out, |
---|
419 | | - nic_vport_context); |
---|
420 | | - req_list_size = MLX5_GET(nic_vport_context, nic_vport_ctx, |
---|
421 | | - allowed_list_size); |
---|
422 | | - |
---|
423 | | - *size = req_list_size; |
---|
424 | | - for (i = 0; i < req_list_size; i++) { |
---|
425 | | - void *vlan_addr = MLX5_ADDR_OF(nic_vport_context, |
---|
426 | | - nic_vport_ctx, |
---|
427 | | - current_uc_mac_address[i]); |
---|
428 | | - vlans[i] = MLX5_GET(vlan_layout, vlan_addr, vlan); |
---|
429 | | - } |
---|
430 | | -out: |
---|
431 | | - kfree(out); |
---|
432 | | - return err; |
---|
433 | | -} |
---|
434 | | -EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_vlans); |
---|
435 | 366 | |
---|
436 | 367 | int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev, |
---|
437 | 368 | u16 vlans[], |
---|
.. | .. |
---|
494 | 425 | if (!out) |
---|
495 | 426 | return -ENOMEM; |
---|
496 | 427 | |
---|
497 | | - mlx5_query_nic_vport_context(mdev, 0, out, outlen); |
---|
| 428 | + mlx5_query_nic_vport_context(mdev, 0, out); |
---|
498 | 429 | |
---|
499 | 430 | *system_image_guid = MLX5_GET64(query_nic_vport_context_out, out, |
---|
500 | 431 | nic_vport_context.system_image_guid); |
---|
.. | .. |
---|
514 | 445 | if (!out) |
---|
515 | 446 | return -ENOMEM; |
---|
516 | 447 | |
---|
517 | | - mlx5_query_nic_vport_context(mdev, 0, out, outlen); |
---|
| 448 | + mlx5_query_nic_vport_context(mdev, 0, out); |
---|
518 | 449 | |
---|
519 | 450 | *node_guid = MLX5_GET64(query_nic_vport_context_out, out, |
---|
520 | 451 | nic_vport_context.node_guid); |
---|
.. | .. |
---|
526 | 457 | EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_node_guid); |
---|
527 | 458 | |
---|
528 | 459 | int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev, |
---|
529 | | - u32 vport, u64 node_guid) |
---|
| 460 | + u16 vport, u64 node_guid) |
---|
530 | 461 | { |
---|
531 | 462 | int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); |
---|
532 | 463 | void *nic_vport_context; |
---|
533 | 464 | void *in; |
---|
534 | 465 | int err; |
---|
535 | 466 | |
---|
536 | | - if (!vport) |
---|
537 | | - return -EINVAL; |
---|
538 | 467 | if (!MLX5_CAP_GEN(mdev, vport_group_manager)) |
---|
539 | 468 | return -EACCES; |
---|
540 | 469 | |
---|
.. | .. |
---|
545 | 474 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
546 | 475 | field_select.node_guid, 1); |
---|
547 | 476 | MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); |
---|
548 | | - MLX5_SET(modify_nic_vport_context_in, in, other_vport, !!vport); |
---|
| 477 | + MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1); |
---|
549 | 478 | |
---|
550 | 479 | nic_vport_context = MLX5_ADDR_OF(modify_nic_vport_context_in, |
---|
551 | 480 | in, nic_vport_context); |
---|
552 | 481 | MLX5_SET64(nic_vport_context, nic_vport_context, node_guid, node_guid); |
---|
| 482 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 483 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
553 | 484 | |
---|
554 | | - err = mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 485 | + err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
555 | 486 | |
---|
556 | 487 | kvfree(in); |
---|
557 | 488 | |
---|
.. | .. |
---|
568 | 499 | if (!out) |
---|
569 | 500 | return -ENOMEM; |
---|
570 | 501 | |
---|
571 | | - mlx5_query_nic_vport_context(mdev, 0, out, outlen); |
---|
| 502 | + mlx5_query_nic_vport_context(mdev, 0, out); |
---|
572 | 503 | |
---|
573 | 504 | *qkey_viol_cntr = MLX5_GET(query_nic_vport_context_out, out, |
---|
574 | 505 | nic_vport_context.qkey_violation_counter); |
---|
.. | .. |
---|
716 | 647 | struct mlx5_hca_vport_context *rep) |
---|
717 | 648 | { |
---|
718 | 649 | int out_sz = MLX5_ST_SZ_BYTES(query_hca_vport_context_out); |
---|
719 | | - int in[MLX5_ST_SZ_DW(query_hca_vport_context_in)] = {0}; |
---|
| 650 | + int in[MLX5_ST_SZ_DW(query_hca_vport_context_in)] = {}; |
---|
720 | 651 | int is_group_manager; |
---|
721 | 652 | void *out; |
---|
722 | 653 | void *ctx; |
---|
.. | .. |
---|
743 | 674 | if (MLX5_CAP_GEN(dev, num_ports) == 2) |
---|
744 | 675 | MLX5_SET(query_hca_vport_context_in, in, port_num, port_num); |
---|
745 | 676 | |
---|
746 | | - err = mlx5_cmd_exec(dev, in, sizeof(in), out, out_sz); |
---|
| 677 | + err = mlx5_cmd_exec_inout(dev, query_hca_vport_context, in, out); |
---|
747 | 678 | if (err) |
---|
748 | 679 | goto ex; |
---|
749 | 680 | |
---|
.. | .. |
---|
827 | 758 | EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_node_guid); |
---|
828 | 759 | |
---|
829 | 760 | int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev, |
---|
830 | | - u32 vport, |
---|
| 761 | + u16 vport, |
---|
831 | 762 | int *promisc_uc, |
---|
832 | 763 | int *promisc_mc, |
---|
833 | 764 | int *promisc_all) |
---|
.. | .. |
---|
840 | 771 | if (!out) |
---|
841 | 772 | return -ENOMEM; |
---|
842 | 773 | |
---|
843 | | - err = mlx5_query_nic_vport_context(mdev, vport, out, outlen); |
---|
| 774 | + err = mlx5_query_nic_vport_context(mdev, vport, out); |
---|
844 | 775 | if (err) |
---|
845 | 776 | goto out; |
---|
846 | 777 | |
---|
.. | .. |
---|
877 | 808 | nic_vport_context.promisc_mc, promisc_mc); |
---|
878 | 809 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
879 | 810 | nic_vport_context.promisc_all, promisc_all); |
---|
| 811 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 812 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
880 | 813 | |
---|
881 | | - err = mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 814 | + err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
882 | 815 | |
---|
883 | 816 | kvfree(in); |
---|
884 | 817 | |
---|
.. | .. |
---|
917 | 850 | if (MLX5_CAP_GEN(mdev, disable_local_lb_uc)) |
---|
918 | 851 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
919 | 852 | field_select.disable_uc_local_lb, 1); |
---|
| 853 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 854 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
920 | 855 | |
---|
921 | | - err = mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 856 | + err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
922 | 857 | |
---|
923 | 858 | if (!err) |
---|
924 | 859 | mlx5_core_dbg(mdev, "%s local_lb\n", |
---|
.. | .. |
---|
940 | 875 | if (!out) |
---|
941 | 876 | return -ENOMEM; |
---|
942 | 877 | |
---|
943 | | - err = mlx5_query_nic_vport_context(mdev, 0, out, outlen); |
---|
| 878 | + err = mlx5_query_nic_vport_context(mdev, 0, out); |
---|
944 | 879 | if (err) |
---|
945 | 880 | goto out; |
---|
946 | 881 | |
---|
.. | .. |
---|
977 | 912 | MLX5_SET(modify_nic_vport_context_in, in, field_select.roce_en, 1); |
---|
978 | 913 | MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.roce_en, |
---|
979 | 914 | state); |
---|
| 915 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 916 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
980 | 917 | |
---|
981 | | - err = mlx5_modify_nic_vport_context(mdev, in, inlen); |
---|
| 918 | + err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in); |
---|
982 | 919 | |
---|
983 | 920 | kvfree(in); |
---|
984 | 921 | |
---|
.. | .. |
---|
1017 | 954 | mutex_unlock(&mlx5_roce_en_lock); |
---|
1018 | 955 | return err; |
---|
1019 | 956 | } |
---|
1020 | | -EXPORT_SYMBOL_GPL(mlx5_nic_vport_disable_roce); |
---|
| 957 | +EXPORT_SYMBOL(mlx5_nic_vport_disable_roce); |
---|
1021 | 958 | |
---|
1022 | 959 | int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport, |
---|
1023 | | - int vf, u8 port_num, void *out, |
---|
1024 | | - size_t out_sz) |
---|
| 960 | + int vf, u8 port_num, void *out) |
---|
1025 | 961 | { |
---|
1026 | | - int in_sz = MLX5_ST_SZ_BYTES(query_vport_counter_in); |
---|
1027 | | - int is_group_manager; |
---|
1028 | | - void *in; |
---|
1029 | | - int err; |
---|
| 962 | + int in_sz = MLX5_ST_SZ_BYTES(query_vport_counter_in); |
---|
| 963 | + int is_group_manager; |
---|
| 964 | + void *in; |
---|
| 965 | + int err; |
---|
1030 | 966 | |
---|
1031 | 967 | is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager); |
---|
1032 | 968 | in = kvzalloc(in_sz, GFP_KERNEL); |
---|
.. | .. |
---|
1049 | 985 | if (MLX5_CAP_GEN(dev, num_ports) == 2) |
---|
1050 | 986 | MLX5_SET(query_vport_counter_in, in, port_num, port_num); |
---|
1051 | 987 | |
---|
1052 | | - err = mlx5_cmd_exec(dev, in, in_sz, out, out_sz); |
---|
| 988 | + err = mlx5_cmd_exec_inout(dev, query_vport_counter, in, out); |
---|
1053 | 989 | free: |
---|
1054 | 990 | kvfree(in); |
---|
1055 | 991 | return err; |
---|
.. | .. |
---|
1057 | 993 | EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter); |
---|
1058 | 994 | |
---|
1059 | 995 | int mlx5_query_vport_down_stats(struct mlx5_core_dev *mdev, u16 vport, |
---|
1060 | | - u64 *rx_discard_vport_down, |
---|
| 996 | + u8 other_vport, u64 *rx_discard_vport_down, |
---|
1061 | 997 | u64 *tx_discard_vport_down) |
---|
1062 | 998 | { |
---|
1063 | | - u32 out[MLX5_ST_SZ_DW(query_vnic_env_out)] = {0}; |
---|
1064 | | - u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {0}; |
---|
| 999 | + u32 out[MLX5_ST_SZ_DW(query_vnic_env_out)] = {}; |
---|
| 1000 | + u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {}; |
---|
1065 | 1001 | int err; |
---|
1066 | 1002 | |
---|
1067 | 1003 | MLX5_SET(query_vnic_env_in, in, opcode, |
---|
1068 | 1004 | MLX5_CMD_OP_QUERY_VNIC_ENV); |
---|
1069 | 1005 | MLX5_SET(query_vnic_env_in, in, op_mod, 0); |
---|
1070 | 1006 | MLX5_SET(query_vnic_env_in, in, vport_number, vport); |
---|
1071 | | - if (vport) |
---|
1072 | | - MLX5_SET(query_vnic_env_in, in, other_vport, 1); |
---|
| 1007 | + MLX5_SET(query_vnic_env_in, in, other_vport, other_vport); |
---|
1073 | 1008 | |
---|
1074 | | - err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out)); |
---|
| 1009 | + err = mlx5_cmd_exec_inout(mdev, query_vnic_env, in, out); |
---|
1075 | 1010 | if (err) |
---|
1076 | 1011 | return err; |
---|
1077 | 1012 | |
---|
.. | .. |
---|
1088 | 1023 | struct mlx5_hca_vport_context *req) |
---|
1089 | 1024 | { |
---|
1090 | 1025 | int in_sz = MLX5_ST_SZ_BYTES(modify_hca_vport_context_in); |
---|
1091 | | - u8 out[MLX5_ST_SZ_BYTES(modify_hca_vport_context_out)]; |
---|
1092 | 1026 | int is_group_manager; |
---|
| 1027 | + void *ctx; |
---|
1093 | 1028 | void *in; |
---|
1094 | 1029 | int err; |
---|
1095 | | - void *ctx; |
---|
1096 | 1030 | |
---|
1097 | 1031 | mlx5_core_dbg(dev, "vf %d\n", vf); |
---|
1098 | 1032 | is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager); |
---|
.. | .. |
---|
1100 | 1034 | if (!in) |
---|
1101 | 1035 | return -ENOMEM; |
---|
1102 | 1036 | |
---|
1103 | | - memset(out, 0, sizeof(out)); |
---|
1104 | 1037 | MLX5_SET(modify_hca_vport_context_in, in, opcode, MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT); |
---|
1105 | 1038 | if (other_vport) { |
---|
1106 | 1039 | if (is_group_manager) { |
---|
.. | .. |
---|
1117 | 1050 | |
---|
1118 | 1051 | ctx = MLX5_ADDR_OF(modify_hca_vport_context_in, in, hca_vport_context); |
---|
1119 | 1052 | MLX5_SET(hca_vport_context, ctx, field_select, req->field_select); |
---|
1120 | | - MLX5_SET(hca_vport_context, ctx, sm_virt_aware, req->sm_virt_aware); |
---|
1121 | | - MLX5_SET(hca_vport_context, ctx, has_smi, req->has_smi); |
---|
1122 | | - MLX5_SET(hca_vport_context, ctx, has_raw, req->has_raw); |
---|
1123 | | - MLX5_SET(hca_vport_context, ctx, vport_state_policy, req->policy); |
---|
1124 | | - MLX5_SET(hca_vport_context, ctx, port_physical_state, req->phys_state); |
---|
1125 | | - MLX5_SET(hca_vport_context, ctx, vport_state, req->vport_state); |
---|
1126 | | - MLX5_SET64(hca_vport_context, ctx, port_guid, req->port_guid); |
---|
1127 | | - MLX5_SET64(hca_vport_context, ctx, node_guid, req->node_guid); |
---|
| 1053 | + if (req->field_select & MLX5_HCA_VPORT_SEL_STATE_POLICY) |
---|
| 1054 | + MLX5_SET(hca_vport_context, ctx, vport_state_policy, |
---|
| 1055 | + req->policy); |
---|
| 1056 | + if (req->field_select & MLX5_HCA_VPORT_SEL_PORT_GUID) |
---|
| 1057 | + MLX5_SET64(hca_vport_context, ctx, port_guid, req->port_guid); |
---|
| 1058 | + if (req->field_select & MLX5_HCA_VPORT_SEL_NODE_GUID) |
---|
| 1059 | + MLX5_SET64(hca_vport_context, ctx, node_guid, req->node_guid); |
---|
1128 | 1060 | MLX5_SET(hca_vport_context, ctx, cap_mask1, req->cap_mask1); |
---|
1129 | | - MLX5_SET(hca_vport_context, ctx, cap_mask1_field_select, req->cap_mask1_perm); |
---|
1130 | | - MLX5_SET(hca_vport_context, ctx, cap_mask2, req->cap_mask2); |
---|
1131 | | - MLX5_SET(hca_vport_context, ctx, cap_mask2_field_select, req->cap_mask2_perm); |
---|
1132 | | - MLX5_SET(hca_vport_context, ctx, lid, req->lid); |
---|
1133 | | - MLX5_SET(hca_vport_context, ctx, init_type_reply, req->init_type_reply); |
---|
1134 | | - MLX5_SET(hca_vport_context, ctx, lmc, req->lmc); |
---|
1135 | | - MLX5_SET(hca_vport_context, ctx, subnet_timeout, req->subnet_timeout); |
---|
1136 | | - MLX5_SET(hca_vport_context, ctx, sm_lid, req->sm_lid); |
---|
1137 | | - MLX5_SET(hca_vport_context, ctx, sm_sl, req->sm_sl); |
---|
1138 | | - MLX5_SET(hca_vport_context, ctx, qkey_violation_counter, req->qkey_violation_counter); |
---|
1139 | | - MLX5_SET(hca_vport_context, ctx, pkey_violation_counter, req->pkey_violation_counter); |
---|
1140 | | - err = mlx5_cmd_exec(dev, in, in_sz, out, sizeof(out)); |
---|
| 1061 | + MLX5_SET(hca_vport_context, ctx, cap_mask1_field_select, |
---|
| 1062 | + req->cap_mask1_perm); |
---|
| 1063 | + err = mlx5_cmd_exec_in(dev, modify_hca_vport_context, in); |
---|
1141 | 1064 | ex: |
---|
1142 | 1065 | kfree(in); |
---|
1143 | 1066 | return err; |
---|
.. | .. |
---|
1166 | 1089 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
1167 | 1090 | nic_vport_context.affiliation_criteria, |
---|
1168 | 1091 | MLX5_CAP_GEN(port_mdev, affiliate_nic_vport_criteria)); |
---|
| 1092 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 1093 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
1169 | 1094 | |
---|
1170 | | - err = mlx5_modify_nic_vport_context(port_mdev, in, inlen); |
---|
| 1095 | + err = mlx5_cmd_exec_in(port_mdev, modify_nic_vport_context, in); |
---|
1171 | 1096 | if (err) |
---|
1172 | 1097 | mlx5_nic_vport_disable_roce(port_mdev); |
---|
1173 | 1098 | |
---|
.. | .. |
---|
1192 | 1117 | nic_vport_context.affiliated_vhca_id, 0); |
---|
1193 | 1118 | MLX5_SET(modify_nic_vport_context_in, in, |
---|
1194 | 1119 | nic_vport_context.affiliation_criteria, 0); |
---|
| 1120 | + MLX5_SET(modify_nic_vport_context_in, in, opcode, |
---|
| 1121 | + MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
---|
1195 | 1122 | |
---|
1196 | | - err = mlx5_modify_nic_vport_context(port_mdev, in, inlen); |
---|
| 1123 | + err = mlx5_cmd_exec_in(port_mdev, modify_nic_vport_context, in); |
---|
1197 | 1124 | if (!err) |
---|
1198 | 1125 | mlx5_nic_vport_disable_roce(port_mdev); |
---|
1199 | 1126 | |
---|
.. | .. |
---|
1201 | 1128 | return err; |
---|
1202 | 1129 | } |
---|
1203 | 1130 | EXPORT_SYMBOL_GPL(mlx5_nic_vport_unaffiliate_multiport); |
---|
| 1131 | + |
---|
| 1132 | +u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev) |
---|
| 1133 | +{ |
---|
| 1134 | + int port_type_cap = MLX5_CAP_GEN(mdev, port_type); |
---|
| 1135 | + u64 tmp = 0; |
---|
| 1136 | + |
---|
| 1137 | + if (mdev->sys_image_guid) |
---|
| 1138 | + return mdev->sys_image_guid; |
---|
| 1139 | + |
---|
| 1140 | + if (port_type_cap == MLX5_CAP_PORT_TYPE_ETH) |
---|
| 1141 | + mlx5_query_nic_vport_system_image_guid(mdev, &tmp); |
---|
| 1142 | + else |
---|
| 1143 | + mlx5_query_hca_vport_system_image_guid(mdev, &tmp); |
---|
| 1144 | + |
---|
| 1145 | + mdev->sys_image_guid = tmp; |
---|
| 1146 | + |
---|
| 1147 | + return tmp; |
---|
| 1148 | +} |
---|
| 1149 | +EXPORT_SYMBOL_GPL(mlx5_query_nic_system_image_guid); |
---|
| 1150 | + |
---|
| 1151 | +/** |
---|
| 1152 | + * mlx5_eswitch_get_total_vports - Get total vports of the eswitch |
---|
| 1153 | + * |
---|
| 1154 | + * @dev: Pointer to core device |
---|
| 1155 | + * |
---|
| 1156 | + * mlx5_eswitch_get_total_vports returns total number of vports for |
---|
| 1157 | + * the eswitch. |
---|
| 1158 | + */ |
---|
| 1159 | +u16 mlx5_eswitch_get_total_vports(const struct mlx5_core_dev *dev) |
---|
| 1160 | +{ |
---|
| 1161 | + return MLX5_SPECIAL_VPORTS(dev) + mlx5_core_max_vfs(dev); |
---|
| 1162 | +} |
---|
| 1163 | +EXPORT_SYMBOL_GPL(mlx5_eswitch_get_total_vports); |
---|