forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/net/ethernet/mellanox/mlx5/core/vport.c
....@@ -34,15 +34,17 @@
3434 #include <linux/etherdevice.h>
3535 #include <linux/mlx5/driver.h>
3636 #include <linux/mlx5/vport.h>
37
+#include <linux/mlx5/eswitch.h>
3738 #include "mlx5_core.h"
3839
3940 /* Mutex to hold while enabling or disabling RoCE */
4041 static DEFINE_MUTEX(mlx5_roce_en_lock);
4142
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)
4444 {
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;
4648
4749 MLX5_SET(query_vport_state_in, in, opcode,
4850 MLX5_CMD_OP_QUERY_VPORT_STATE);
....@@ -51,39 +53,32 @@
5153 if (vport)
5254 MLX5_SET(query_vport_state_in, in, other_vport, 1);
5355
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;
6259
6360 return MLX5_GET(query_vport_state_out, out, state);
6461 }
6562
6663 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)
6865 {
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)] = {};
7167
7268 MLX5_SET(modify_vport_state_in, in, opcode,
7369 MLX5_CMD_OP_MODIFY_VPORT_STATE);
7470 MLX5_SET(modify_vport_state_in, in, op_mod, opmod);
7571 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);
7873 MLX5_SET(modify_vport_state_in, in, admin_state, state);
7974
80
- return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
75
+ return mlx5_cmd_exec_in(mdev, modify_vport_state, in);
8176 }
8277
8378 static int mlx5_query_nic_vport_context(struct mlx5_core_dev *mdev, u16 vport,
84
- u32 *out, int outlen)
79
+ u32 *out)
8580 {
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)] = {};
8782
8883 MLX5_SET(query_nic_vport_context_in, in, opcode,
8984 MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
....@@ -91,26 +86,16 @@
9186 if (vport)
9287 MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
9388
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);
10590 }
10691
10792 int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
10893 u16 vport, u8 *min_inline)
10994 {
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)] = {};
11196 int err;
11297
113
- err = mlx5_query_nic_vport_context(mdev, vport, out, sizeof(out));
98
+ err = mlx5_query_nic_vport_context(mdev, vport, out);
11499 if (!err)
115100 *min_inline = MLX5_GET(query_nic_vport_context_out, out,
116101 nic_vport_context.min_wqe_inline_mode);
....@@ -122,11 +107,12 @@
122107 u8 *min_inline_mode)
123108 {
124109 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;
125114 case MLX5_CAP_INLINE_MODE_L2:
126115 *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);
130116 break;
131117 case MLX5_CAP_INLINE_MODE_NOT_REQUIRED:
132118 *min_inline_mode = MLX5_INLINE_MODE_NONE;
....@@ -138,8 +124,7 @@
138124 int mlx5_modify_nic_vport_min_inline(struct mlx5_core_dev *mdev,
139125 u16 vport, u8 min_inline)
140126 {
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)] = {};
143128 void *nic_vport_ctx;
144129
145130 MLX5_SET(modify_nic_vport_context_in, in,
....@@ -151,36 +136,44 @@
151136 in, nic_vport_context);
152137 MLX5_SET(nic_vport_context, nic_vport_ctx,
153138 min_wqe_inline_mode, min_inline);
139
+ MLX5_SET(modify_nic_vport_context_in, in, opcode,
140
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
154141
155
- return mlx5_modify_nic_vport_context(mdev, in, inlen);
142
+ return mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
156143 }
157144
158145 int mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev,
159
- u16 vport, u8 *addr)
146
+ u16 vport, bool other, u8 *addr)
160147 {
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)] = {};
163150 u8 *out_addr;
164151 int err;
165
-
166
- out = kvzalloc(outlen, GFP_KERNEL);
167
- if (!out)
168
- return -ENOMEM;
169152
170153 out_addr = MLX5_ADDR_OF(query_nic_vport_context_out, out,
171154 nic_vport_context.permanent_address);
172155
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);
174162 if (!err)
175163 ether_addr_copy(addr, &out_addr[2]);
176164
177
- kvfree(out);
178165 return err;
179166 }
180167 EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_mac_address);
181168
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
+
182175 int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *mdev,
183
- u16 vport, u8 *addr)
176
+ u16 vport, const u8 *addr)
184177 {
185178 void *in;
186179 int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
....@@ -195,9 +188,7 @@
195188 MLX5_SET(modify_nic_vport_context_in, in,
196189 field_select.permanent_address, 1);
197190 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);
201192
202193 nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
203194 in, nic_vport_context);
....@@ -205,8 +196,10 @@
205196 permanent_address);
206197
207198 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);
208201
209
- err = mlx5_modify_nic_vport_context(mdev, in, inlen);
202
+ err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
210203
211204 kvfree(in);
212205
....@@ -224,7 +217,7 @@
224217 if (!out)
225218 return -ENOMEM;
226219
227
- err = mlx5_query_nic_vport_context(mdev, 0, out, outlen);
220
+ err = mlx5_query_nic_vport_context(mdev, 0, out);
228221 if (!err)
229222 *mtu = MLX5_GET(query_nic_vport_context_out, out,
230223 nic_vport_context.mtu);
....@@ -246,8 +239,10 @@
246239
247240 MLX5_SET(modify_nic_vport_context_in, in, field_select.mtu, 1);
248241 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);
249244
250
- err = mlx5_modify_nic_vport_context(mdev, in, inlen);
245
+ err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
251246
252247 kvfree(in);
253248 return err;
....@@ -255,7 +250,7 @@
255250 EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mtu);
256251
257252 int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
258
- u32 vport,
253
+ u16 vport,
259254 enum mlx5_list_type list_type,
260255 u8 addr_list[][ETH_ALEN],
261256 int *list_size)
....@@ -281,7 +276,7 @@
281276 req_list_size = max_list_size;
282277 }
283278
284
- out_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
279
+ out_sz = MLX5_ST_SZ_BYTES(query_nic_vport_context_in) +
285280 req_list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
286281
287282 out = kzalloc(out_sz, GFP_KERNEL);
....@@ -292,9 +287,7 @@
292287 MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
293288 MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, list_type);
294289 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);
298291
299292 err = mlx5_cmd_exec(dev, in, sizeof(in), out, out_sz);
300293 if (err)
....@@ -323,7 +316,7 @@
323316 u8 addr_list[][ETH_ALEN],
324317 int list_size)
325318 {
326
- u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
319
+ u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)] = {};
327320 void *nic_vport_ctx;
328321 int max_list_size;
329322 int in_sz;
....@@ -341,7 +334,6 @@
341334 in_sz = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in) +
342335 list_size * MLX5_ST_SZ_BYTES(mac_address_layout);
343336
344
- memset(out, 0, sizeof(out));
345337 in = kzalloc(in_sz, GFP_KERNEL);
346338 if (!in)
347339 return -ENOMEM;
....@@ -371,67 +363,6 @@
371363 return err;
372364 }
373365 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);
435366
436367 int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
437368 u16 vlans[],
....@@ -494,7 +425,7 @@
494425 if (!out)
495426 return -ENOMEM;
496427
497
- mlx5_query_nic_vport_context(mdev, 0, out, outlen);
428
+ mlx5_query_nic_vport_context(mdev, 0, out);
498429
499430 *system_image_guid = MLX5_GET64(query_nic_vport_context_out, out,
500431 nic_vport_context.system_image_guid);
....@@ -514,7 +445,7 @@
514445 if (!out)
515446 return -ENOMEM;
516447
517
- mlx5_query_nic_vport_context(mdev, 0, out, outlen);
448
+ mlx5_query_nic_vport_context(mdev, 0, out);
518449
519450 *node_guid = MLX5_GET64(query_nic_vport_context_out, out,
520451 nic_vport_context.node_guid);
....@@ -526,15 +457,13 @@
526457 EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_node_guid);
527458
528459 int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
529
- u32 vport, u64 node_guid)
460
+ u16 vport, u64 node_guid)
530461 {
531462 int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
532463 void *nic_vport_context;
533464 void *in;
534465 int err;
535466
536
- if (!vport)
537
- return -EINVAL;
538467 if (!MLX5_CAP_GEN(mdev, vport_group_manager))
539468 return -EACCES;
540469
....@@ -545,13 +474,15 @@
545474 MLX5_SET(modify_nic_vport_context_in, in,
546475 field_select.node_guid, 1);
547476 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);
549478
550479 nic_vport_context = MLX5_ADDR_OF(modify_nic_vport_context_in,
551480 in, nic_vport_context);
552481 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);
553484
554
- err = mlx5_modify_nic_vport_context(mdev, in, inlen);
485
+ err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
555486
556487 kvfree(in);
557488
....@@ -568,7 +499,7 @@
568499 if (!out)
569500 return -ENOMEM;
570501
571
- mlx5_query_nic_vport_context(mdev, 0, out, outlen);
502
+ mlx5_query_nic_vport_context(mdev, 0, out);
572503
573504 *qkey_viol_cntr = MLX5_GET(query_nic_vport_context_out, out,
574505 nic_vport_context.qkey_violation_counter);
....@@ -716,7 +647,7 @@
716647 struct mlx5_hca_vport_context *rep)
717648 {
718649 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)] = {};
720651 int is_group_manager;
721652 void *out;
722653 void *ctx;
....@@ -743,7 +674,7 @@
743674 if (MLX5_CAP_GEN(dev, num_ports) == 2)
744675 MLX5_SET(query_hca_vport_context_in, in, port_num, port_num);
745676
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);
747678 if (err)
748679 goto ex;
749680
....@@ -827,7 +758,7 @@
827758 EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_node_guid);
828759
829760 int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
830
- u32 vport,
761
+ u16 vport,
831762 int *promisc_uc,
832763 int *promisc_mc,
833764 int *promisc_all)
....@@ -840,7 +771,7 @@
840771 if (!out)
841772 return -ENOMEM;
842773
843
- err = mlx5_query_nic_vport_context(mdev, vport, out, outlen);
774
+ err = mlx5_query_nic_vport_context(mdev, vport, out);
844775 if (err)
845776 goto out;
846777
....@@ -877,8 +808,10 @@
877808 nic_vport_context.promisc_mc, promisc_mc);
878809 MLX5_SET(modify_nic_vport_context_in, in,
879810 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);
880813
881
- err = mlx5_modify_nic_vport_context(mdev, in, inlen);
814
+ err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
882815
883816 kvfree(in);
884817
....@@ -917,8 +850,10 @@
917850 if (MLX5_CAP_GEN(mdev, disable_local_lb_uc))
918851 MLX5_SET(modify_nic_vport_context_in, in,
919852 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);
920855
921
- err = mlx5_modify_nic_vport_context(mdev, in, inlen);
856
+ err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
922857
923858 if (!err)
924859 mlx5_core_dbg(mdev, "%s local_lb\n",
....@@ -940,7 +875,7 @@
940875 if (!out)
941876 return -ENOMEM;
942877
943
- err = mlx5_query_nic_vport_context(mdev, 0, out, outlen);
878
+ err = mlx5_query_nic_vport_context(mdev, 0, out);
944879 if (err)
945880 goto out;
946881
....@@ -977,8 +912,10 @@
977912 MLX5_SET(modify_nic_vport_context_in, in, field_select.roce_en, 1);
978913 MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.roce_en,
979914 state);
915
+ MLX5_SET(modify_nic_vport_context_in, in, opcode,
916
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
980917
981
- err = mlx5_modify_nic_vport_context(mdev, in, inlen);
918
+ err = mlx5_cmd_exec_in(mdev, modify_nic_vport_context, in);
982919
983920 kvfree(in);
984921
....@@ -1017,16 +954,15 @@
1017954 mutex_unlock(&mlx5_roce_en_lock);
1018955 return err;
1019956 }
1020
-EXPORT_SYMBOL_GPL(mlx5_nic_vport_disable_roce);
957
+EXPORT_SYMBOL(mlx5_nic_vport_disable_roce);
1021958
1022959 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)
1025961 {
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;
1030966
1031967 is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager);
1032968 in = kvzalloc(in_sz, GFP_KERNEL);
....@@ -1049,7 +985,7 @@
1049985 if (MLX5_CAP_GEN(dev, num_ports) == 2)
1050986 MLX5_SET(query_vport_counter_in, in, port_num, port_num);
1051987
1052
- err = mlx5_cmd_exec(dev, in, in_sz, out, out_sz);
988
+ err = mlx5_cmd_exec_inout(dev, query_vport_counter, in, out);
1053989 free:
1054990 kvfree(in);
1055991 return err;
....@@ -1057,21 +993,20 @@
1057993 EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter);
1058994
1059995 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,
1061997 u64 *tx_discard_vport_down)
1062998 {
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)] = {};
10651001 int err;
10661002
10671003 MLX5_SET(query_vnic_env_in, in, opcode,
10681004 MLX5_CMD_OP_QUERY_VNIC_ENV);
10691005 MLX5_SET(query_vnic_env_in, in, op_mod, 0);
10701006 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);
10731008
1074
- err = mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
1009
+ err = mlx5_cmd_exec_inout(mdev, query_vnic_env, in, out);
10751010 if (err)
10761011 return err;
10771012
....@@ -1088,11 +1023,10 @@
10881023 struct mlx5_hca_vport_context *req)
10891024 {
10901025 int in_sz = MLX5_ST_SZ_BYTES(modify_hca_vport_context_in);
1091
- u8 out[MLX5_ST_SZ_BYTES(modify_hca_vport_context_out)];
10921026 int is_group_manager;
1027
+ void *ctx;
10931028 void *in;
10941029 int err;
1095
- void *ctx;
10961030
10971031 mlx5_core_dbg(dev, "vf %d\n", vf);
10981032 is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager);
....@@ -1100,7 +1034,6 @@
11001034 if (!in)
11011035 return -ENOMEM;
11021036
1103
- memset(out, 0, sizeof(out));
11041037 MLX5_SET(modify_hca_vport_context_in, in, opcode, MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT);
11051038 if (other_vport) {
11061039 if (is_group_manager) {
....@@ -1117,27 +1050,17 @@
11171050
11181051 ctx = MLX5_ADDR_OF(modify_hca_vport_context_in, in, hca_vport_context);
11191052 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);
11281060 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);
11411064 ex:
11421065 kfree(in);
11431066 return err;
....@@ -1166,8 +1089,10 @@
11661089 MLX5_SET(modify_nic_vport_context_in, in,
11671090 nic_vport_context.affiliation_criteria,
11681091 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);
11691094
1170
- err = mlx5_modify_nic_vport_context(port_mdev, in, inlen);
1095
+ err = mlx5_cmd_exec_in(port_mdev, modify_nic_vport_context, in);
11711096 if (err)
11721097 mlx5_nic_vport_disable_roce(port_mdev);
11731098
....@@ -1192,8 +1117,10 @@
11921117 nic_vport_context.affiliated_vhca_id, 0);
11931118 MLX5_SET(modify_nic_vport_context_in, in,
11941119 nic_vport_context.affiliation_criteria, 0);
1120
+ MLX5_SET(modify_nic_vport_context_in, in, opcode,
1121
+ MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
11951122
1196
- err = mlx5_modify_nic_vport_context(port_mdev, in, inlen);
1123
+ err = mlx5_cmd_exec_in(port_mdev, modify_nic_vport_context, in);
11971124 if (!err)
11981125 mlx5_nic_vport_disable_roce(port_mdev);
11991126
....@@ -1201,3 +1128,36 @@
12011128 return err;
12021129 }
12031130 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);