History

Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux

Merge mlx5-next shared branched into net-next, From Bodong Wang: 1) Introduction of ECPF (Embedded CPU Physical Function), and low level bits for mlx5 SmartNic capabilities support. 2) Vport enumeration refactoring that affect mlx5_ib and mlx5_core From Aya Levin, 3) Add support for 50Gbps per lane link modes in the Port Type and Speed register (PTYS) 4) Refactor low level query functions for PTYS register 5) Add support for 50Gbps per lane link modes to mlx5_ib Note: due to a change in API in mlx5/core and a later patch from net-next, a fixup was squashed with this merge commit that replaces FDB_UPLINK_VPORT with MLX5_VPORT_UPLINK which exists only in upstream net-next.

Saeed Mahameed committed 7 years ago

Commit 259fae52 parents 50f444a 08e867636 files · +848 −474Browse files

Unified · Split

36 files
  1. drivers/infiniband/hw/mlx5/cmd.c +37 −0
  2. drivers/infiniband/hw/mlx5/cmd.h +2 −0
  3. drivers/infiniband/hw/mlx5/ib_rep.c +18 −55
  4. drivers/infiniband/hw/mlx5/ib_rep.h +6 −4
  5. drivers/infiniband/hw/mlx5/mad.c +7 −4
  6. drivers/infiniband/hw/mlx5/main.c +77 −18
  7. drivers/infiniband/hw/mlx5/mlx5_ib.h +2 −3
  8. drivers/infiniband/hw/mlx5/mr.c +7 −32
  9. drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 −2
  10. drivers/net/ethernet/mellanox/mlx5/core/cmd.c +52 −5
  11. drivers/net/ethernet/mellanox/mlx5/core/ecpf.c +112 −0
  12. drivers/net/ethernet/mellanox/mlx5/core/ecpf.h +33 −0
  13. drivers/net/ethernet/mellanox/mlx5/core/en/port.c +122 −20
  14. drivers/net/ethernet/mellanox/mlx5/core/en/port.h +14 −2
  15. drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +11 −17
  16. drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +12 −12
  17. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +3 −3
  18. drivers/net/ethernet/mellanox/mlx5/core/eq.c +10 −6
  19. drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +20 −22
  20. drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +0 −2
  21. drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +22 −17
  22. drivers/net/ethernet/mellanox/mlx5/core/events.c +2 −0
  23. drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +1 −0
  24. drivers/net/ethernet/mellanox/mlx5/core/mad.c +0 −75
  25. drivers/net/ethernet/mellanox/mlx5/core/main.c +71 −0
  26. drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +1 −1
  27. drivers/net/ethernet/mellanox/mlx5/core/mr.c +6 −5
  28. drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +38 −16
  29. drivers/net/ethernet/mellanox/mlx5/core/port.c +0 −106
  30. drivers/net/ethernet/mellanox/mlx5/core/sriov.c +1 −1
  31. drivers/net/ethernet/mellanox/mlx5/core/vport.c +4 −4
  32. include/linux/mlx5/device.h +7 −2
  33. include/linux/mlx5/driver.h +47 −14
  34. include/linux/mlx5/mlx5_ifc.h +65 −11
  35. include/linux/mlx5/port.h +19 −11
  36. include/linux/mlx5/vport.h +17 −4
drivers/infiniband/hw/mlx5/cmd.c+37−0
@@ -345,3 +345,40 @@ int mlx5_cmd_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id, · 344 unmodified lines
345 counter_set_id);345 counter_set_id);
346 return err;346 return err;
347}347}
348
349int mlx5_cmd_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
350 u16 opmod, u8 port)
351{
352 int outlen = MLX5_ST_SZ_BYTES(mad_ifc_out);
353 int inlen = MLX5_ST_SZ_BYTES(mad_ifc_in);
354 int err = -ENOMEM;
355 void *data;
356 void *resp;
357 u32 *out;
358 u32 *in;
359
360 in = kzalloc(inlen, GFP_KERNEL);
361 out = kzalloc(outlen, GFP_KERNEL);
362 if (!in || !out)
363 goto out;
364
365 MLX5_SET(mad_ifc_in, in, opcode, MLX5_CMD_OP_MAD_IFC);
366 MLX5_SET(mad_ifc_in, in, op_mod, opmod);
367 MLX5_SET(mad_ifc_in, in, port, port);
368
369 data = MLX5_ADDR_OF(mad_ifc_in, in, mad);
370 memcpy(data, inb, MLX5_FLD_SZ_BYTES(mad_ifc_in, mad));
371
372 err = mlx5_cmd_exec(dev, in, inlen, out, outlen);
373 if (err)
374 goto out;
375
376 resp = MLX5_ADDR_OF(mad_ifc_out, out, response_mad_packet);
377 memcpy(outb, resp,
378 MLX5_FLD_SZ_BYTES(mad_ifc_out, response_mad_packet));
379
380out:
381 kfree(out);
382 kfree(in);
383 return err;
384}
drivers/infiniband/hw/mlx5/cmd.h+2−0
@@ -63,4 +63,6 @@ int mlx5_cmd_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn, u16 uid); · 62 unmodified lines
63int mlx5_cmd_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn, u16 uid);63int mlx5_cmd_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn, u16 uid);
64int mlx5_cmd_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id,64int mlx5_cmd_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id,
65 u16 uid);65 u16 uid);
66int mlx5_cmd_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
67 u16 opmod, u8 port);
66#endif /* MLX5_IB_CMD_H */68#endif /* MLX5_IB_CMD_H */
drivers/infiniband/hw/mlx5/ib_rep.c+18−55
@@ -3,10 +3,11 @@ · 2 unmodified lines
3 * Copyright (c) 2018 Mellanox Technologies. All rights reserved.3 * Copyright (c) 2018 Mellanox Technologies. All rights reserved.
4 */4 */
5 5
6#include <linux/mlx5/vport.h>
6#include "ib_rep.h"7#include "ib_rep.h"
7#include "srq.h"8#include "srq.h"
8 9
9static const struct mlx5_ib_profile rep_profile = {10static const struct mlx5_ib_profile vf_rep_profile = {
10 STAGE_CREATE(MLX5_IB_STAGE_INIT,11 STAGE_CREATE(MLX5_IB_STAGE_INIT,
11 mlx5_ib_stage_init_init,12 mlx5_ib_stage_init_init,
12 mlx5_ib_stage_init_cleanup),13 mlx5_ib_stage_init_cleanup),
@@ -45,31 +46,17 @@ static const struct mlx5_ib_profile rep_profile = { · 32 unmodified lines
45 NULL),46 NULL),
46};47};
47 48
48static int
49mlx5_ib_nic_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
50{
51 struct mlx5_ib_dev *ibdev;
52
53 ibdev = mlx5_ib_rep_to_dev(rep);
54 if (!__mlx5_ib_add(ibdev, ibdev->profile))
55 return -EINVAL;
56 return 0;
57}
58
59static void
60mlx5_ib_nic_rep_unload(struct mlx5_eswitch_rep *rep)
61{
62 struct mlx5_ib_dev *ibdev;
63
64 ibdev = mlx5_ib_rep_to_dev(rep);
65 __mlx5_ib_remove(ibdev, ibdev->profile, MLX5_IB_STAGE_MAX);
66}
67
68static int49static int
69mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)50mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
70{51{
52 const struct mlx5_ib_profile *profile;
71 struct mlx5_ib_dev *ibdev;53 struct mlx5_ib_dev *ibdev;
72 54
55 if (rep->vport == MLX5_VPORT_UPLINK)
56 profile = &uplink_rep_profile;
57 else
58 profile = &vf_rep_profile;
59
73 ibdev = (struct mlx5_ib_dev *)ib_alloc_device(sizeof(*ibdev));60 ibdev = (struct mlx5_ib_dev *)ib_alloc_device(sizeof(*ibdev));
74 if (!ibdev)61 if (!ibdev)
75 return -ENOMEM;62 return -ENOMEM;
@@ -78,7 +65,7 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) · 2 unmodified lines
78 ibdev->mdev = dev;65 ibdev->mdev = dev;
79 ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports),66 ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports),
80 MLX5_CAP_GEN(dev, num_vhca_ports));67 MLX5_CAP_GEN(dev, num_vhca_ports));
81 if (!__mlx5_ib_add(ibdev, &rep_profile))68 if (!__mlx5_ib_add(ibdev, profile))
82 return -EINVAL;69 return -EINVAL;
83 70
84 rep->rep_if[REP_IB].priv = ibdev;71 rep->rep_if[REP_IB].priv = ibdev;
@@ -105,15 +92,14 @@ static void *mlx5_ib_vport_get_proto_dev(struct mlx5_eswitch_rep *rep) · 20 unmodified lines
105 return mlx5_ib_rep_to_dev(rep);92 return mlx5_ib_rep_to_dev(rep);
106}93}
107 94
108static void mlx5_ib_rep_register_vf_vports(struct mlx5_ib_dev *dev)95void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev)
109{96{
110 struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;97 struct mlx5_eswitch *esw = mdev->priv.eswitch;
111 int total_vfs = MLX5_TOTAL_VPORTS(dev->mdev);98 int total_vports = MLX5_TOTAL_VPORTS(mdev);
99 struct mlx5_eswitch_rep_if rep_if = {};
112 int vport;100 int vport;
113 101
114 for (vport = 1; vport < total_vfs; vport++) {102 for (vport = 0; vport < total_vports; vport++) {
115 struct mlx5_eswitch_rep_if rep_if = {};
116
117 rep_if.load = mlx5_ib_vport_rep_load;103 rep_if.load = mlx5_ib_vport_rep_load;
118 rep_if.unload = mlx5_ib_vport_rep_unload;104 rep_if.unload = mlx5_ib_vport_rep_unload;
119 rep_if.get_proto_dev = mlx5_ib_vport_get_proto_dev;105 rep_if.get_proto_dev = mlx5_ib_vport_get_proto_dev;
@@ -121,39 +107,16 @@ static void mlx5_ib_rep_register_vf_vports(struct mlx5_ib_dev *dev) · 1 unmodified line
121 }107 }
122}108}
123 109
124static void mlx5_ib_rep_unregister_vf_vports(struct mlx5_ib_dev *dev)110void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev)
125{111{
126 struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;112 struct mlx5_eswitch *esw = mdev->priv.eswitch;
127 int total_vfs = MLX5_TOTAL_VPORTS(dev->mdev);113 int total_vports = MLX5_TOTAL_VPORTS(mdev);
128 int vport;114 int vport;
129 115
130 for (vport = 1; vport < total_vfs; vport++)116 for (vport = total_vports - 1; vport >= 0; vport--)
131 mlx5_eswitch_unregister_vport_rep(esw, vport, REP_IB);117 mlx5_eswitch_unregister_vport_rep(esw, vport, REP_IB);
132}118}
133 119
134void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev)
135{
136 struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
137 struct mlx5_eswitch_rep_if rep_if = {};
138
139 rep_if.load = mlx5_ib_nic_rep_load;
140 rep_if.unload = mlx5_ib_nic_rep_unload;
141 rep_if.get_proto_dev = mlx5_ib_vport_get_proto_dev;
142 rep_if.priv = dev;
143
144 mlx5_eswitch_register_vport_rep(esw, 0, &rep_if, REP_IB);
145
146 mlx5_ib_rep_register_vf_vports(dev);
147}
148
149void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev)
150{
151 struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
152
153 mlx5_ib_rep_unregister_vf_vports(dev); /* VFs vports */
154 mlx5_eswitch_unregister_vport_rep(esw, 0, REP_IB); /* UPLINK PF*/
155}
156
157u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)120u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)
158{121{
159 return mlx5_eswitch_mode(esw);122 return mlx5_eswitch_mode(esw);
drivers/infiniband/hw/mlx5/ib_rep.h+6−4
@@ -10,14 +10,16 @@ · 9 unmodified lines
10#include "mlx5_ib.h"10#include "mlx5_ib.h"
11 11
12#ifdef CONFIG_MLX5_ESWITCH12#ifdef CONFIG_MLX5_ESWITCH
13extern const struct mlx5_ib_profile uplink_rep_profile;
14
13u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);15u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
14struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,16struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
15 int vport_index);17 int vport_index);
16struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw);18struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw);
17struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,19struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
18 int vport_index);20 int vport_index);
19void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev);21void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev);
20void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev);22void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev);
21int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,23int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
22 struct mlx5_ib_sq *sq);24 struct mlx5_ib_sq *sq);
23struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,25struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw,
@@ -48,8 +50,8 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, · 24 unmodified lines
48 return NULL;50 return NULL;
49}51}
50 52
51static inline void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev) {}53static inline void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev) {}
52static inline void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev) {}54static inline void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev) {}
53static inline int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,55static inline int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
54 struct mlx5_ib_sq *sq)56 struct mlx5_ib_sq *sq)
55{57{
drivers/infiniband/hw/mlx5/mad.c+7−4
@@ -36,6 +36,7 @@ · 35 unmodified lines
36#include <rdma/ib_smi.h>36#include <rdma/ib_smi.h>
37#include <rdma/ib_pma.h>37#include <rdma/ib_pma.h>
38#include "mlx5_ib.h"38#include "mlx5_ib.h"
39#include "cmd.h"
39 40
40enum {41enum {
41 MLX5_IB_VENDOR_CLASS1 = 0x9,42 MLX5_IB_VENDOR_CLASS1 = 0x9,
@@ -51,9 +52,10 @@ static bool can_do_mad_ifc(struct mlx5_ib_dev *dev, u8 port_num, · 9 unmodified lines
51 return dev->mdev->port_caps[port_num - 1].has_smi;52 return dev->mdev->port_caps[port_num - 1].has_smi;
52}53}
53 54
54int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,55static int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey,
55 u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,56 int ignore_bkey, u8 port, const struct ib_wc *in_wc,
56 const void *in_mad, void *response_mad)57 const struct ib_grh *in_grh, const void *in_mad,
58 void *response_mad)
57{59{
58 u8 op_modifier = 0;60 u8 op_modifier = 0;
59 61
@@ -68,7 +70,8 @@ int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey, · 8 unmodified lines
68 if (ignore_bkey || !in_wc)70 if (ignore_bkey || !in_wc)
69 op_modifier |= 0x2;71 op_modifier |= 0x2;
70 72
71 return mlx5_core_mad_ifc(dev->mdev, in_mad, response_mad, op_modifier, port);73 return mlx5_cmd_mad_ifc(dev->mdev, in_mad, response_mad, op_modifier,
74 port);
72}75}
73 76
74static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,77static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
drivers/infiniband/hw/mlx5/main.c+77−18
@@ -331,8 +331,8 @@ out: · 330 unmodified lines
331 spin_unlock(&port->mp.mpi_lock);331 spin_unlock(&port->mp.mpi_lock);
332}332}
333 333
334static int translate_eth_proto_oper(u32 eth_proto_oper, u8 *active_speed,334static int translate_eth_legacy_proto_oper(u32 eth_proto_oper, u8 *active_speed,
335 u8 *active_width)335 u8 *active_width)
336{336{
337 switch (eth_proto_oper) {337 switch (eth_proto_oper) {
338 case MLX5E_PROT_MASK(MLX5E_1000BASE_CX_SGMII):338 case MLX5E_PROT_MASK(MLX5E_1000BASE_CX_SGMII):
@@ -389,10 +389,66 @@ static int translate_eth_proto_oper(u32 eth_proto_oper, u8 *active_speed, · 50 unmodified lines
389 return 0;389 return 0;
390}390}
391 391
392static int translate_eth_ext_proto_oper(u32 eth_proto_oper, u8 *active_speed,
393 u8 *active_width)
394{
395 switch (eth_proto_oper) {
396 case MLX5E_PROT_MASK(MLX5E_SGMII_100M):
397 case MLX5E_PROT_MASK(MLX5E_1000BASE_X_SGMII):
398 *active_width = IB_WIDTH_1X;
399 *active_speed = IB_SPEED_SDR;
400 break;
401 case MLX5E_PROT_MASK(MLX5E_5GBASE_R):
402 *active_width = IB_WIDTH_1X;
403 *active_speed = IB_SPEED_DDR;
404 break;
405 case MLX5E_PROT_MASK(MLX5E_10GBASE_XFI_XAUI_1):
406 *active_width = IB_WIDTH_1X;
407 *active_speed = IB_SPEED_QDR;
408 break;
409 case MLX5E_PROT_MASK(MLX5E_40GBASE_XLAUI_4_XLPPI_4):
410 *active_width = IB_WIDTH_4X;
411 *active_speed = IB_SPEED_QDR;
412 break;
413 case MLX5E_PROT_MASK(MLX5E_25GAUI_1_25GBASE_CR_KR):
414 *active_width = IB_WIDTH_1X;
415 *active_speed = IB_SPEED_EDR;
416 break;
417 case MLX5E_PROT_MASK(MLX5E_50GAUI_2_LAUI_2_50GBASE_CR2_KR2):
418 case MLX5E_PROT_MASK(MLX5E_50GAUI_1_LAUI_1_50GBASE_CR_KR):
419 *active_width = IB_WIDTH_1X;
420 *active_speed = IB_SPEED_HDR;
421 break;
422 case MLX5E_PROT_MASK(MLX5E_100GAUI_2_100GBASE_CR2_KR2):
423 *active_width = IB_WIDTH_2X;
424 *active_speed = IB_SPEED_HDR;
425 break;
426 case MLX5E_PROT_MASK(MLX5E_200GAUI_4_200GBASE_CR4_KR4):
427 *active_width = IB_WIDTH_4X;
428 *active_speed = IB_SPEED_HDR;
429 break;
430 default:
431 return -EINVAL;
432 }
433
434 return 0;
435}
436
437static int translate_eth_proto_oper(u32 eth_proto_oper, u8 *active_speed,
438 u8 *active_width, bool ext)
439{
440 return ext ?
441 translate_eth_ext_proto_oper(eth_proto_oper, active_speed,
442 active_width) :
443 translate_eth_legacy_proto_oper(eth_proto_oper, active_speed,
444 active_width);
445}
446
392static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,447static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
393 struct ib_port_attr *props)448 struct ib_port_attr *props)
394{449{
395 struct mlx5_ib_dev *dev = to_mdev(device);450 struct mlx5_ib_dev *dev = to_mdev(device);
451 u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0};
396 struct mlx5_core_dev *mdev;452 struct mlx5_core_dev *mdev;
397 struct net_device *ndev, *upper;453 struct net_device *ndev, *upper;
398 enum ib_mtu ndev_ib_mtu;454 enum ib_mtu ndev_ib_mtu;
@@ -400,6 +456,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, · 1 unmodified line
400 u16 qkey_viol_cntr;456 u16 qkey_viol_cntr;
401 u32 eth_prot_oper;457 u32 eth_prot_oper;
402 u8 mdev_port_num;458 u8 mdev_port_num;
459 bool ext;
403 int err;460 int err;
404 461
405 mdev = mlx5_ib_get_native_port_mdev(dev, port_num, &mdev_port_num);462 mdev = mlx5_ib_get_native_port_mdev(dev, port_num, &mdev_port_num);
@@ -416,16 +473,18 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, · 10 unmodified lines
416 /* Possible bad flows are checked before filling out props so in case473 /* Possible bad flows are checked before filling out props so in case
417 * of an error it will still be zeroed out.474 * of an error it will still be zeroed out.
418 */475 */
419 err = mlx5_query_port_eth_proto_oper(mdev, &eth_prot_oper,476 err = mlx5_query_port_ptys(mdev, out, sizeof(out), MLX5_PTYS_EN,
420 mdev_port_num);477 mdev_port_num);
421 if (err)478 if (err)
422 goto out;479 goto out;
480 ext = MLX5_CAP_PCAM_FEATURE(dev->mdev, ptys_extended_ethernet);
481 eth_prot_oper = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, eth_proto_oper);
423 482
424 props->active_width = IB_WIDTH_4X;483 props->active_width = IB_WIDTH_4X;
425 props->active_speed = IB_SPEED_QDR;484 props->active_speed = IB_SPEED_QDR;
426 485
427 translate_eth_proto_oper(eth_prot_oper, &props->active_speed,486 translate_eth_proto_oper(eth_prot_oper, &props->active_speed,
428 &props->active_width);487 &props->active_width, ext);
429 488
430 props->port_cap_flags |= IB_PORT_CM_SUP;489 props->port_cap_flags |= IB_PORT_CM_SUP;
431 props->ip_gids = true;490 props->ip_gids = true;
@@ -6386,7 +6445,7 @@ static const struct mlx5_ib_profile pf_profile = { · 5954 unmodified lines
6386 mlx5_ib_stage_delay_drop_cleanup),6445 mlx5_ib_stage_delay_drop_cleanup),
6387};6446};
6388 6447
6389static const struct mlx5_ib_profile nic_rep_profile = {6448const struct mlx5_ib_profile uplink_rep_profile = {
6390 STAGE_CREATE(MLX5_IB_STAGE_INIT,6449 STAGE_CREATE(MLX5_IB_STAGE_INIT,
6391 mlx5_ib_stage_init_init,6450 mlx5_ib_stage_init_init,
6392 mlx5_ib_stage_init_cleanup),6451 mlx5_ib_stage_init_cleanup),
@@ -6479,6 +6538,12 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) · 86 unmodified lines
6479 6538
6480 printk_once(KERN_INFO "%s", mlx5_version);6539 printk_once(KERN_INFO "%s", mlx5_version);
6481 6540
6541 if (MLX5_ESWITCH_MANAGER(mdev) &&
6542 mlx5_ib_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {
6543 mlx5_ib_register_vport_reps(mdev);
6544 return mdev;
6545 }
6546
6482 port_type_cap = MLX5_CAP_GEN(mdev, port_type);6547 port_type_cap = MLX5_CAP_GEN(mdev, port_type);
6483 ll = mlx5_port_type_cap_to_rdma_ll(port_type_cap);6548 ll = mlx5_port_type_cap_to_rdma_ll(port_type_cap);
6484 6549
@@ -6493,14 +6558,6 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) · 8 unmodified lines
6493 dev->num_ports = max(MLX5_CAP_GEN(mdev, num_ports),6558 dev->num_ports = max(MLX5_CAP_GEN(mdev, num_ports),
6494 MLX5_CAP_GEN(mdev, num_vhca_ports));6559 MLX5_CAP_GEN(mdev, num_vhca_ports));
6495 6560
6496 if (MLX5_ESWITCH_MANAGER(mdev) &&
6497 mlx5_ib_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {
6498 dev->rep = mlx5_ib_vport_rep(mdev->priv.eswitch, 0);
6499 dev->profile = &nic_rep_profile;
6500 mlx5_ib_register_vport_reps(dev);
6501 return dev;
6502 }
6503
6504 return __mlx5_ib_add(dev, &pf_profile);6561 return __mlx5_ib_add(dev, &pf_profile);
6505}6562}
6506 6563
@@ -6509,6 +6566,11 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) · 2 unmodified lines
6509 struct mlx5_ib_multiport_info *mpi;6566 struct mlx5_ib_multiport_info *mpi;
6510 struct mlx5_ib_dev *dev;6567 struct mlx5_ib_dev *dev;
6511 6568
6569 if (MLX5_ESWITCH_MANAGER(mdev) && context == mdev) {
6570 mlx5_ib_unregister_vport_reps(mdev);
6571 return;
6572 }
6573
6512 if (mlx5_core_is_mp_slave(mdev)) {6574 if (mlx5_core_is_mp_slave(mdev)) {
6513 mpi = context;6575 mpi = context;
6514 mutex_lock(&mlx5_ib_multiport_mutex);6576 mutex_lock(&mlx5_ib_multiport_mutex);
@@ -6520,10 +6582,7 @@ static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context) · 5 unmodified lines
6520 }6582 }
6521 6583
6522 dev = context;6584 dev = context;
6523 if (dev->profile == &nic_rep_profile)6585 __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
6524 mlx5_ib_unregister_vport_reps(dev);
6525 else
6526 __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
6527 6586
6528 ib_dealloc_device((struct ib_device *)dev);6587 ib_dealloc_device((struct ib_device *)dev);
6529}6588}
drivers/infiniband/hw/mlx5/mlx5_ib.h+2−3
@@ -587,6 +587,7 @@ struct mlx5_ib_mr { · 586 unmodified lines
587 struct mlx5_ib_mr *parent;587 struct mlx5_ib_mr *parent;
588 atomic_t num_leaf_free;588 atomic_t num_leaf_free;
589 wait_queue_head_t q_leaf_free;589 wait_queue_head_t q_leaf_free;
590 struct mlx5_async_work cb_work;
590};591};
591 592
592struct mlx5_ib_mw {593struct mlx5_ib_mw {
@@ -944,6 +945,7 @@ struct mlx5_ib_dev { · 351 unmodified lines
944 struct mlx5_memic memic;945 struct mlx5_memic memic;
945 u16 devx_whitelist_uid;946 u16 devx_whitelist_uid;
946 struct mlx5_srq_table srq_table;947 struct mlx5_srq_table srq_table;
948 struct mlx5_async_ctx async_ctx;
947};949};
948 950
949static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)951static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)
@@ -1038,9 +1040,6 @@ void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db) · 88 unmodified lines
1038void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);1040void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
1039void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);1041void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
1040void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);1042void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);
1041int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
1042 u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
1043 const void *in_mad, void *response_mad);
1044struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,1043struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
1045 u32 flags, struct ib_udata *udata);1044 u32 flags, struct ib_udata *udata);
1046int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);1045int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
drivers/infiniband/hw/mlx5/mr.c+7−32
@@ -123,9 +123,10 @@ static void update_odp_mr(struct mlx5_ib_mr *mr) · 122 unmodified lines
123}123}
124#endif124#endif
125 125
126static void reg_mr_callback(int status, void *context)126static void reg_mr_callback(int status, struct mlx5_async_work *context)
127{127{
128 struct mlx5_ib_mr *mr = context;128 struct mlx5_ib_mr *mr =
129 container_of(context, struct mlx5_ib_mr, cb_work);
129 struct mlx5_ib_dev *dev = mr->dev;130 struct mlx5_ib_dev *dev = mr->dev;
130 struct mlx5_mr_cache *cache = &dev->cache;131 struct mlx5_mr_cache *cache = &dev->cache;
131 int c = order2idx(dev, mr->order);132 int c = order2idx(dev, mr->order);
@@ -216,9 +217,9 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num) · 84 unmodified lines
216 ent->pending++;217 ent->pending++;
217 spin_unlock_irq(&ent->lock);218 spin_unlock_irq(&ent->lock);
218 err = mlx5_core_create_mkey_cb(dev->mdev, &mr->mmkey,219 err = mlx5_core_create_mkey_cb(dev->mdev, &mr->mmkey,
219 in, inlen,220 &dev->async_ctx, in, inlen,
220 mr->out, sizeof(mr->out),221 mr->out, sizeof(mr->out),
221 reg_mr_callback, mr);222 reg_mr_callback, &mr->cb_work);
222 if (err) {223 if (err) {
223 spin_lock_irq(&ent->lock);224 spin_lock_irq(&ent->lock);
224 ent->pending--;225 ent->pending--;
@@ -679,6 +680,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) · 454 unmodified lines
679 return -ENOMEM;680 return -ENOMEM;
680 }681 }
681 682
683 mlx5_cmd_init_async_ctx(dev->mdev, &dev->async_ctx);
682 timer_setup(&dev->delay_timer, delay_time_func, 0);684 timer_setup(&dev->delay_timer, delay_time_func, 0);
683 for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {685 for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
684 ent = &cache->ent[i];686 ent = &cache->ent[i];
@@ -725,33 +727,6 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) · 40 unmodified lines
725 return 0;727 return 0;
726}728}
727 729
728static void wait_for_async_commands(struct mlx5_ib_dev *dev)
729{
730 struct mlx5_mr_cache *cache = &dev->cache;
731 struct mlx5_cache_ent *ent;
732 int total = 0;
733 int i;
734 int j;
735
736 for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
737 ent = &cache->ent[i];
738 for (j = 0 ; j < 1000; j++) {
739 if (!ent->pending)
740 break;
741 msleep(50);
742 }
743 }
744 for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
745 ent = &cache->ent[i];
746 total += ent->pending;
747 }
748
749 if (total)
750 mlx5_ib_warn(dev, "aborted while there are %d pending mr requests\n", total);
751 else
752 mlx5_ib_warn(dev, "done with all pending requests\n");
753}
754
755int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)730int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
756{731{
757 int i;732 int i;
@@ -763,12 +738,12 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) · 5 unmodified lines
763 flush_workqueue(dev->cache.wq);738 flush_workqueue(dev->cache.wq);
764 739
765 mlx5_mr_cache_debugfs_cleanup(dev);740 mlx5_mr_cache_debugfs_cleanup(dev);
741 mlx5_cmd_cleanup_async_ctx(&dev->async_ctx);
766 742
767 for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++)743 for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++)
768 clean_keys(dev, i);744 clean_keys(dev, i);
769 745
770 destroy_workqueue(dev->cache.wq);746 destroy_workqueue(dev->cache.wq);
771 wait_for_async_commands(dev);
772 del_timer_sync(&dev->delay_timer);747 del_timer_sync(&dev->delay_timer);
773 748
774 return 0;749 return 0;
drivers/net/ethernet/mellanox/mlx5/core/Makefile+2−2
@@ -13,7 +13,7 @@ obj-$(CONFIG_MLX5_CORE) += mlx5_core.o · 12 unmodified lines
13#13#
14mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \14mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
15 health.o mcg.o cq.o alloc.o qp.o port.o mr.o pd.o \15 health.o mcg.o cq.o alloc.o qp.o port.o mr.o pd.o \
16 mad.o transobj.o vport.o sriov.o fs_cmd.o fs_core.o \16 transobj.o vport.o sriov.o fs_cmd.o fs_core.o \
17 fs_counters.o rl.o lag.o dev.o events.o wq.o lib/gid.o \17 fs_counters.o rl.o lag.o dev.o events.o wq.o lib/gid.o \
18 lib/devcom.o diag/fs_tracepoint.o diag/fw_tracer.o18 lib/devcom.o diag/fs_tracepoint.o diag/fw_tracer.o
19 19
@@ -35,7 +35,7 @@ mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/tc_tun.o · 15 unmodified lines
35#35#
36# Core extra36# Core extra
37#37#
38mlx5_core-$(CONFIG_MLX5_ESWITCH) += eswitch.o eswitch_offloads.o38mlx5_core-$(CONFIG_MLX5_ESWITCH) += eswitch.o eswitch_offloads.o ecpf.o
39mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o39mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
40mlx5_core-$(CONFIG_VXLAN) += lib/vxlan.o40mlx5_core-$(CONFIG_VXLAN) += lib/vxlan.o
41mlx5_core-$(CONFIG_PTP_1588_CLOCK) += lib/clock.o41mlx5_core-$(CONFIG_PTP_1588_CLOCK) += lib/clock.o
drivers/net/ethernet/mellanox/mlx5/core/cmd.c+52−5
@@ -316,6 +316,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op, · 315 unmodified lines
316 case MLX5_CMD_OP_DESTROY_GENERAL_OBJECT:316 case MLX5_CMD_OP_DESTROY_GENERAL_OBJECT:
317 case MLX5_CMD_OP_DEALLOC_MEMIC:317 case MLX5_CMD_OP_DEALLOC_MEMIC:
318 case MLX5_CMD_OP_PAGE_FAULT_RESUME:318 case MLX5_CMD_OP_PAGE_FAULT_RESUME:
319 case MLX5_CMD_OP_QUERY_HOST_PARAMS:
319 return MLX5_CMD_STAT_OK;320 return MLX5_CMD_STAT_OK;
320 321
321 case MLX5_CMD_OP_QUERY_HCA_CAP:322 case MLX5_CMD_OP_QUERY_HCA_CAP:
@@ -627,6 +628,7 @@ const char *mlx5_command_str(int command) · 305 unmodified lines
627 MLX5_COMMAND_STR_CASE(QUERY_MODIFY_HEADER_CONTEXT);628 MLX5_COMMAND_STR_CASE(QUERY_MODIFY_HEADER_CONTEXT);
628 MLX5_COMMAND_STR_CASE(ALLOC_MEMIC);629 MLX5_COMMAND_STR_CASE(ALLOC_MEMIC);
629 MLX5_COMMAND_STR_CASE(DEALLOC_MEMIC);630 MLX5_COMMAND_STR_CASE(DEALLOC_MEMIC);
631 MLX5_COMMAND_STR_CASE(QUERY_HOST_PARAMS);
630 default: return "unknown command opcode";632 default: return "unknown command opcode";
631 }633 }
632}634}
@@ -1711,12 +1713,57 @@ int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out, · 1078 unmodified lines
1711}1713}
1712EXPORT_SYMBOL(mlx5_cmd_exec);1714EXPORT_SYMBOL(mlx5_cmd_exec);
1713 1715
1714int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size,1716void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev,
1715 void *out, int out_size, mlx5_cmd_cbk_t callback,1717 struct mlx5_async_ctx *ctx)
1716 void *context)
1717{1718{
1718 return cmd_exec(dev, in, in_size, out, out_size, callback, context,1719 ctx->dev = dev;
1719 false);1720 /* Starts at 1 to avoid doing wake_up if we are not cleaning up */
1721 atomic_set(&ctx->num_inflight, 1);
1722 init_waitqueue_head(&ctx->wait);
1723}
1724EXPORT_SYMBOL(mlx5_cmd_init_async_ctx);
1725
1726/**
1727 * mlx5_cmd_cleanup_async_ctx - Clean up an async_ctx
1728 * @ctx: The ctx to clean
1729 *
1730 * Upon return all callbacks given to mlx5_cmd_exec_cb() have been called. The
1731 * caller must ensure that mlx5_cmd_exec_cb() is not called during or after
1732 * the call mlx5_cleanup_async_ctx().
1733 */
1734void mlx5_cmd_cleanup_async_ctx(struct mlx5_async_ctx *ctx)
1735{
1736 atomic_dec(&ctx->num_inflight);
1737 wait_event(ctx->wait, atomic_read(&ctx->num_inflight) == 0);
1738}
1739EXPORT_SYMBOL(mlx5_cmd_cleanup_async_ctx);
1740
1741static void mlx5_cmd_exec_cb_handler(int status, void *_work)
1742{
1743 struct mlx5_async_work *work = _work;
1744 struct mlx5_async_ctx *ctx = work->ctx;
1745
1746 work->user_callback(status, work);
1747 if (atomic_dec_and_test(&ctx->num_inflight))
1748 wake_up(&ctx->wait);
1749}
1750
1751int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
1752 void *out, int out_size, mlx5_async_cbk_t callback,
1753 struct mlx5_async_work *work)
1754{
1755 int ret;
1756
1757 work->ctx = ctx;
1758 work->user_callback = callback;
1759 if (WARN_ON(!atomic_inc_not_zero(&ctx->num_inflight)))
1760 return -EIO;
1761 ret = cmd_exec(ctx->dev, in, in_size, out, out_size,
1762 mlx5_cmd_exec_cb_handler, work, false);
1763 if (ret && atomic_dec_and_test(&ctx->num_inflight))
1764 wake_up(&ctx->wait);
1765
1766 return ret;
1720}1767}
1721EXPORT_SYMBOL(mlx5_cmd_exec_cb);1768EXPORT_SYMBOL(mlx5_cmd_exec_cb);
1722 1769
drivers/net/ethernet/mellanox/mlx5/core/ecpf.c+112−0
@@ -0,0 +1,112 @@
1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2/* Copyright (c) 2019 Mellanox Technologies. */
3
4#include "ecpf.h"
5
6bool mlx5_read_embedded_cpu(struct mlx5_core_dev *dev)
7{
8 return (ioread32be(&dev->iseg->initializing) >> MLX5_ECPU_BIT_NUM) & 1;
9}
10
11static int mlx5_peer_pf_enable_hca(struct mlx5_core_dev *dev)
12{
13 u32 out[MLX5_ST_SZ_DW(enable_hca_out)] = {};
14 u32 in[MLX5_ST_SZ_DW(enable_hca_in)] = {};
15
16 MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
17 MLX5_SET(enable_hca_in, in, function_id, 0);
18 MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0);
19 return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
20}
21
22static int mlx5_peer_pf_disable_hca(struct mlx5_core_dev *dev)
23{
24 u32 out[MLX5_ST_SZ_DW(disable_hca_out)] = {};
25 u32 in[MLX5_ST_SZ_DW(disable_hca_in)] = {};
26
27 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
28 MLX5_SET(disable_hca_in, in, function_id, 0);
29 MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0);
30 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
31}
32
33static int mlx5_peer_pf_init(struct mlx5_core_dev *dev)
34{
35 int err;
36
37 err = mlx5_peer_pf_enable_hca(dev);
38 if (err)
39 mlx5_core_err(dev, "Failed to enable peer PF HCA err(%d)\n",
40 err);
41
42 return err;
43}
44
45static void mlx5_peer_pf_cleanup(struct mlx5_core_dev *dev)
46{
47 int err;
48
49 err = mlx5_peer_pf_disable_hca(dev);
50 if (err) {
51 mlx5_core_err(dev, "Failed to disable peer PF HCA err(%d)\n",
52 err);
53 return;
54 }
55
56 err = mlx5_wait_for_pages(dev, &dev->priv.peer_pf_pages);
57 if (err)
58 mlx5_core_warn(dev, "Timeout reclaiming peer PF pages err(%d)\n",
59 err);
60}
61
62int mlx5_ec_init(struct mlx5_core_dev *dev)
63{
64 int err = 0;
65
66 if (!mlx5_core_is_ecpf(dev))
67 return 0;
68
69 /* ECPF shall enable HCA for peer PF in the same way a PF
70 * does this for its VFs.
71 */
72 err = mlx5_peer_pf_init(dev);
73 if (err)
74 return err;
75
76 return 0;
77}
78
79void mlx5_ec_cleanup(struct mlx5_core_dev *dev)
80{
81 if (!mlx5_core_is_ecpf(dev))
82 return;
83
84 mlx5_peer_pf_cleanup(dev);
85}
86
87static int mlx5_query_host_params_context(struct mlx5_core_dev *dev,
88 u32 *out, int outlen)
89{
90 u32 in[MLX5_ST_SZ_DW(query_host_params_in)] = {};
91
92 MLX5_SET(query_host_params_in, in, opcode,
93 MLX5_CMD_OP_QUERY_HOST_PARAMS);
94
95 return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
96}
97
98int mlx5_query_host_params_num_vfs(struct mlx5_core_dev *dev, int *num_vf)
99{
100 u32 out[MLX5_ST_SZ_DW(query_host_params_out)] = {};
101 int err;
102
103 err = mlx5_query_host_params_context(dev, out, sizeof(out));
104 if (err)
105 return err;
106
107 *num_vf = MLX5_GET(query_host_params_out, out,
108 host_params_context.host_num_of_vfs);
109 mlx5_core_dbg(dev, "host_num_of_vfs %d\n", *num_vf);
110
111 return 0;
112}
drivers/net/ethernet/mellanox/mlx5/core/ecpf.h+33−0
@@ -0,0 +1,33 @@
1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2/* Copyright (c) 2019 Mellanox Technologies. */
3
4#ifndef __MLX5_ECPF_H__
5#define __MLX5_ECPF_H__
6
7#include <linux/mlx5/driver.h>
8#include "mlx5_core.h"
9
10#ifdef CONFIG_MLX5_ESWITCH
11
12enum {
13 MLX5_ECPU_BIT_NUM = 23,
14};
15
16bool mlx5_read_embedded_cpu(struct mlx5_core_dev *dev);
17int mlx5_ec_init(struct mlx5_core_dev *dev);
18void mlx5_ec_cleanup(struct mlx5_core_dev *dev);
19int mlx5_query_host_params_num_vfs(struct mlx5_core_dev *dev, int *num_vf);
20
21#else /* CONFIG_MLX5_ESWITCH */
22
23static inline bool
24mlx5_read_embedded_cpu(struct mlx5_core_dev *dev) { return false; }
25static inline int mlx5_ec_init(struct mlx5_core_dev *dev) { return 0; }
26static inline void mlx5_ec_cleanup(struct mlx5_core_dev *dev) {}
27static inline int
28mlx5_query_host_params_num_vfs(struct mlx5_core_dev *dev, int *num_vf)
29{ return -EOPNOTSUPP; }
30
31#endif /* CONFIG_MLX5_ESWITCH */
32
33#endif /* __MLX5_ECPF_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/port.c+122−20
@@ -63,66 +63,168 @@ static const u32 mlx5e_link_speed[MLX5E_LINK_MODES_NUMBER] = { · 62 unmodified lines
63 [MLX5E_50GBASE_KR2] = 50000,63 [MLX5E_50GBASE_KR2] = 50000,
64};64};
65 65
66u32 mlx5e_port_ptys2speed(u32 eth_proto_oper)66static const u32 mlx5e_ext_link_speed[MLX5E_EXT_LINK_MODES_NUMBER] = {
67 [MLX5E_SGMII_100M] = 100,
68 [MLX5E_1000BASE_X_SGMII] = 1000,
69 [MLX5E_5GBASE_R] = 5000,
70 [MLX5E_10GBASE_XFI_XAUI_1] = 10000,
71 [MLX5E_40GBASE_XLAUI_4_XLPPI_4] = 40000,
72 [MLX5E_25GAUI_1_25GBASE_CR_KR] = 25000,
73 [MLX5E_50GAUI_2_LAUI_2_50GBASE_CR2_KR2] = 50000,
74 [MLX5E_50GAUI_1_LAUI_1_50GBASE_CR_KR] = 50000,
75 [MLX5E_CAUI_4_100GBASE_CR4_KR4] = 100000,
76 [MLX5E_200GAUI_4_200GBASE_CR4_KR4] = 200000,
77 [MLX5E_400GAUI_8] = 400000,
78};
79
80static void mlx5e_port_get_speed_arr(struct mlx5_core_dev *mdev,
81 const u32 **arr, u32 *size)
82{
83 bool ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet);
84
85 *size = ext ? ARRAY_SIZE(mlx5e_ext_link_speed) :
86 ARRAY_SIZE(mlx5e_link_speed);
87 *arr = ext ? mlx5e_ext_link_speed : mlx5e_link_speed;
88}
89
90int mlx5_port_query_eth_proto(struct mlx5_core_dev *dev, u8 port, bool ext,
91 struct mlx5e_port_eth_proto *eproto)
92{
93 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
94 int err;
95
96 if (!eproto)
97 return -EINVAL;
98
99 if (ext != MLX5_CAP_PCAM_FEATURE(dev, ptys_extended_ethernet))
100 return -EOPNOTSUPP;
101
102 err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN, port);
103 if (err)
104 return err;
105
106 eproto->cap = MLX5_GET_ETH_PROTO(ptys_reg, out, ext,
107 eth_proto_capability);
108 eproto->admin = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, eth_proto_admin);
109 eproto->oper = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, eth_proto_oper);
110 return 0;
111}
112
113void mlx5_port_query_eth_autoneg(struct mlx5_core_dev *dev, u8 *an_status,
114 u8 *an_disable_cap, u8 *an_disable_admin)
115{
116 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
117
118 *an_status = 0;
119 *an_disable_cap = 0;
120 *an_disable_admin = 0;
121
122 if (mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN, 1))
123 return;
124
125 *an_status = MLX5_GET(ptys_reg, out, an_status);
126 *an_disable_cap = MLX5_GET(ptys_reg, out, an_disable_cap);
127 *an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin);
128}
129
130int mlx5_port_set_eth_ptys(struct mlx5_core_dev *dev, bool an_disable,
131 u32 proto_admin, bool ext)
132{
133 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
134 u32 in[MLX5_ST_SZ_DW(ptys_reg)];
135 u8 an_disable_admin;
136 u8 an_disable_cap;
137 u8 an_status;
138
139 mlx5_port_query_eth_autoneg(dev, &an_status, &an_disable_cap,
140 &an_disable_admin);
141 if (!an_disable_cap && an_disable)
142 return -EPERM;
143
144 memset(in, 0, sizeof(in));
145
146 MLX5_SET(ptys_reg, in, local_port, 1);
147 MLX5_SET(ptys_reg, in, an_disable_admin, an_disable);
148 MLX5_SET(ptys_reg, in, proto_mask, MLX5_PTYS_EN);
149 if (ext)
150 MLX5_SET(ptys_reg, in, ext_eth_proto_admin, proto_admin);
151 else
152 MLX5_SET(ptys_reg, in, eth_proto_admin, proto_admin);
153
154 return mlx5_core_access_reg(dev, in, sizeof(in), out,
155 sizeof(out), MLX5_REG_PTYS, 0, 1);
156}
157
158u32 mlx5e_port_ptys2speed(struct mlx5_core_dev *mdev, u32 eth_proto_oper)
67{159{
68 unsigned long temp = eth_proto_oper;160 unsigned long temp = eth_proto_oper;
161 const u32 *table;
69 u32 speed = 0;162 u32 speed = 0;
163 u32 max_size;
70 int i;164 int i;
71 165
72 i = find_first_bit(&temp, MLX5E_LINK_MODES_NUMBER);166 mlx5e_port_get_speed_arr(mdev, &table, &max_size);
73 if (i < MLX5E_LINK_MODES_NUMBER)167 i = find_first_bit(&temp, max_size);
74 speed = mlx5e_link_speed[i];168 if (i < max_size)
75 169 speed = table[i];
76 return speed;170 return speed;
77}171}
78 172
79int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)173int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)
80{174{
81 u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {};175 struct mlx5e_port_eth_proto eproto;
82 u32 eth_proto_oper;176 bool ext;
83 int err;177 int err;
84 178
85 err = mlx5_query_port_ptys(mdev, out, sizeof(out), MLX5_PTYS_EN, 1);179 ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet);
180 err = mlx5_port_query_eth_proto(mdev, 1, ext, &eproto);
86 if (err)181 if (err)
87 return err;182 goto out;
88 183
89 eth_proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);184 *speed = mlx5e_port_ptys2speed(mdev, eproto.oper);
90 *speed = mlx5e_port_ptys2speed(eth_proto_oper);
91 if (!(*speed))185 if (!(*speed))
92 err = -EINVAL;186 err = -EINVAL;
93 187
188out:
94 return err;189 return err;
95}190}
96 191
97int mlx5e_port_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)192int mlx5e_port_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed)
98{193{
194 struct mlx5e_port_eth_proto eproto;
99 u32 max_speed = 0;195 u32 max_speed = 0;
100 u32 proto_cap;196 const u32 *table;
197 u32 max_size;
198 bool ext;
101 int err;199 int err;
102 int i;200 int i;
103 201
104 err = mlx5_query_port_proto_cap(mdev, &proto_cap, MLX5_PTYS_EN);202 ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet);
203 err = mlx5_port_query_eth_proto(mdev, 1, ext, &eproto);
105 if (err)204 if (err)
106 return err;205 return err;
107 206
108 for (i = 0; i < MLX5E_LINK_MODES_NUMBER; ++i)207 mlx5e_port_get_speed_arr(mdev, &table, &max_size);
109 if (proto_cap & MLX5E_PROT_MASK(i))208 for (i = 0; i < max_size; ++i)
110 max_speed = max(max_speed, mlx5e_link_speed[i]);209 if (eproto.cap & MLX5E_PROT_MASK(i))
210 max_speed = max(max_speed, table[i]);
111 211
112 *speed = max_speed;212 *speed = max_speed;
113 return 0;213 return 0;
114}214}
115 215
116u32 mlx5e_port_speed2linkmodes(u32 speed)216u32 mlx5e_port_speed2linkmodes(struct mlx5_core_dev *mdev, u32 speed)
117{217{
118 u32 link_modes = 0;218 u32 link_modes = 0;
219 const u32 *table;
220 u32 max_size;
119 int i;221 int i;
120 222
121 for (i = 0; i < MLX5E_LINK_MODES_NUMBER; ++i) {223 mlx5e_port_get_speed_arr(mdev, &table, &max_size);
122 if (mlx5e_link_speed[i] == speed)224 for (i = 0; i < max_size; ++i) {
225 if (table[i] == speed)
123 link_modes |= MLX5E_PROT_MASK(i);226 link_modes |= MLX5E_PROT_MASK(i);
124 }227 }
125
126 return link_modes;228 return link_modes;
127}229}
128 230
drivers/net/ethernet/mellanox/mlx5/core/en/port.h+14−2
@@ -36,10 +36,22 @@ · 35 unmodified lines
36#include <linux/mlx5/driver.h>36#include <linux/mlx5/driver.h>
37#include "en.h"37#include "en.h"
38 38
39u32 mlx5e_port_ptys2speed(u32 eth_proto_oper);39struct mlx5e_port_eth_proto {
40 u32 cap;
41 u32 admin;
42 u32 oper;
43};
44
45int mlx5_port_query_eth_proto(struct mlx5_core_dev *dev, u8 port, bool ext,
46 struct mlx5e_port_eth_proto *eproto);
47void mlx5_port_query_eth_autoneg(struct mlx5_core_dev *dev, u8 *an_status,
48 u8 *an_disable_cap, u8 *an_disable_admin);
49int mlx5_port_set_eth_ptys(struct mlx5_core_dev *dev, bool an_disable,
50 u32 proto_admin, bool ext);
51u32 mlx5e_port_ptys2speed(struct mlx5_core_dev *mdev, u32 eth_proto_oper);
40int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);52int mlx5e_port_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
41int mlx5e_port_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);53int mlx5e_port_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed);
42u32 mlx5e_port_speed2linkmodes(u32 speed);54u32 mlx5e_port_speed2linkmodes(struct mlx5_core_dev *mdev, u32 speed);
43 55
44int mlx5e_port_query_pbmc(struct mlx5_core_dev *mdev, void *out);56int mlx5e_port_query_pbmc(struct mlx5_core_dev *mdev, void *out);
45int mlx5e_port_set_pbmc(struct mlx5_core_dev *mdev, void *in);57int mlx5e_port_set_pbmc(struct mlx5_core_dev *mdev, void *in);
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c+11−17
@@ -695,13 +695,14 @@ static void get_speed_duplex(struct net_device *netdev, · 694 unmodified lines
695 u32 eth_proto_oper,695 u32 eth_proto_oper,
696 struct ethtool_link_ksettings *link_ksettings)696 struct ethtool_link_ksettings *link_ksettings)
697{697{
698 struct mlx5e_priv *priv = netdev_priv(netdev);
698 u32 speed = SPEED_UNKNOWN;699 u32 speed = SPEED_UNKNOWN;
699 u8 duplex = DUPLEX_UNKNOWN;700 u8 duplex = DUPLEX_UNKNOWN;
700 701
701 if (!netif_carrier_ok(netdev))702 if (!netif_carrier_ok(netdev))
702 goto out;703 goto out;
703 704
704 speed = mlx5e_port_ptys2speed(eth_proto_oper);705 speed = mlx5e_port_ptys2speed(priv->mdev, eth_proto_oper);
705 if (!speed) {706 if (!speed) {
706 speed = SPEED_UNKNOWN;707 speed = SPEED_UNKNOWN;
707 goto out;708 goto out;
@@ -885,7 +886,7 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, · 177 unmodified lines
885 const struct ethtool_link_ksettings *link_ksettings)886 const struct ethtool_link_ksettings *link_ksettings)
886{887{
887 struct mlx5_core_dev *mdev = priv->mdev;888 struct mlx5_core_dev *mdev = priv->mdev;
888 u32 eth_proto_cap, eth_proto_admin;889 struct mlx5e_port_eth_proto eproto;
889 bool an_changes = false;890 bool an_changes = false;
890 u8 an_disable_admin;891 u8 an_disable_admin;
891 u8 an_disable_cap;892 u8 an_disable_cap;
@@ -899,16 +900,16 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, · 7 unmodified lines
899 900
900 link_modes = link_ksettings->base.autoneg == AUTONEG_ENABLE ?901 link_modes = link_ksettings->base.autoneg == AUTONEG_ENABLE ?
901 mlx5e_ethtool2ptys_adver_link(link_ksettings->link_modes.advertising) :902 mlx5e_ethtool2ptys_adver_link(link_ksettings->link_modes.advertising) :
902 mlx5e_port_speed2linkmodes(speed);903 mlx5e_port_speed2linkmodes(mdev, speed);
903 904
904 err = mlx5_query_port_proto_cap(mdev, &eth_proto_cap, MLX5_PTYS_EN);905 err = mlx5_port_query_eth_proto(mdev, 1, false, &eproto);
905 if (err) {906 if (err) {
906 netdev_err(priv->netdev, "%s: query port eth proto cap failed: %d\n",907 netdev_err(priv->netdev, "%s: query port eth proto failed: %d\n",
907 __func__, err);908 __func__, err);
908 goto out;909 goto out;
909 }910 }
910 911
911 link_modes = link_modes & eth_proto_cap;912 link_modes = link_modes & eproto.cap;
912 if (!link_modes) {913 if (!link_modes) {
913 netdev_err(priv->netdev, "%s: Not supported link mode(s) requested",914 netdev_err(priv->netdev, "%s: Not supported link mode(s) requested",
914 __func__);915 __func__);
@@ -916,24 +917,17 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, · 1 unmodified line
916 goto out;917 goto out;
917 }918 }
918 919
919 err = mlx5_query_port_proto_admin(mdev, &eth_proto_admin, MLX5_PTYS_EN);920 mlx5_port_query_eth_autoneg(mdev, &an_status, &an_disable_cap,
920 if (err) {921 &an_disable_admin);
921 netdev_err(priv->netdev, "%s: query port eth proto admin failed: %d\n",
922 __func__, err);
923 goto out;
924 }
925
926 mlx5_query_port_autoneg(mdev, MLX5_PTYS_EN, &an_status,
927 &an_disable_cap, &an_disable_admin);
928 922
929 an_disable = link_ksettings->base.autoneg == AUTONEG_DISABLE;923 an_disable = link_ksettings->base.autoneg == AUTONEG_DISABLE;
930 an_changes = ((!an_disable && an_disable_admin) ||924 an_changes = ((!an_disable && an_disable_admin) ||
931 (an_disable && !an_disable_admin));925 (an_disable && !an_disable_admin));
932 926
933 if (!an_changes && link_modes == eth_proto_admin)927 if (!an_changes && link_modes == eproto.admin)
934 goto out;928 goto out;
935 929
936 mlx5_set_port_ptys(mdev, an_disable, link_modes, MLX5_PTYS_EN);930 mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, false);
937 mlx5_toggle_port_link(mdev);931 mlx5_toggle_port_link(mdev);
938 932
939out:933out:
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c+12−12
@@ -153,7 +153,7 @@ static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv) · 152 unmodified lines
153 struct mlx5e_rep_priv *rpriv = priv->ppriv;153 struct mlx5e_rep_priv *rpriv = priv->ppriv;
154 struct mlx5_eswitch_rep *rep = rpriv->rep;154 struct mlx5_eswitch_rep *rep = rpriv->rep;
155 155
156 if (rep->vport == FDB_UPLINK_VPORT)156 if (rep->vport == MLX5_VPORT_UPLINK)
157 mlx5e_uplink_rep_update_hw_counters(priv);157 mlx5e_uplink_rep_update_hw_counters(priv);
158 else158 else
159 mlx5e_vf_rep_update_hw_counters(priv);159 mlx5e_vf_rep_update_hw_counters(priv);
@@ -1119,7 +1119,7 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev, · 959 unmodified lines
1119 if (ret)1119 if (ret)
1120 return ret;1120 return ret;
1121 1121
1122 if (rep->vport == FDB_UPLINK_VPORT)1122 if (rep->vport == MLX5_VPORT_UPLINK)
1123 ret = snprintf(buf, len, "p%d", pf_num);1123 ret = snprintf(buf, len, "p%d", pf_num);
1124 else1124 else
1125 ret = snprintf(buf, len, "pf%dvf%d", pf_num, rep->vport - 1);1125 ret = snprintf(buf, len, "pf%dvf%d", pf_num, rep->vport - 1);
@@ -1206,7 +1206,7 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) · 80 unmodified lines
1206 return false;1206 return false;
1207 1207
1208 rep = rpriv->rep;1208 rep = rpriv->rep;
1209 return (rep->vport == FDB_UPLINK_VPORT);1209 return (rep->vport == MLX5_VPORT_UPLINK);
1210}1210}
1211 1211
1212static bool mlx5e_rep_has_offload_stats(const struct net_device *dev, int attr_id)1212static bool mlx5e_rep_has_offload_stats(const struct net_device *dev, int attr_id)
@@ -1344,7 +1344,7 @@ static void mlx5e_build_rep_params(struct net_device *netdev) · 131 unmodified lines
1344 params->sw_mtu = netdev->mtu;1344 params->sw_mtu = netdev->mtu;
1345 1345
1346 /* SQ */1346 /* SQ */
1347 if (rep->vport == FDB_UPLINK_VPORT)1347 if (rep->vport == MLX5_VPORT_UPLINK)
1348 params->log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;1348 params->log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
1349 else1349 else
1350 params->log_sq_size = MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE;1350 params->log_sq_size = MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE;
@@ -1371,7 +1371,7 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) · 20 unmodified lines
1371 struct mlx5_eswitch_rep *rep = rpriv->rep;1371 struct mlx5_eswitch_rep *rep = rpriv->rep;
1372 struct mlx5_core_dev *mdev = priv->mdev;1372 struct mlx5_core_dev *mdev = priv->mdev;
1373 1373
1374 if (rep->vport == FDB_UPLINK_VPORT) {1374 if (rep->vport == MLX5_VPORT_UPLINK) {
1375 SET_NETDEV_DEV(netdev, &priv->mdev->pdev->dev);1375 SET_NETDEV_DEV(netdev, &priv->mdev->pdev->dev);
1376 netdev->netdev_ops = &mlx5e_netdev_ops_uplink_rep;1376 netdev->netdev_ops = &mlx5e_netdev_ops_uplink_rep;
1377 /* we want a persistent mac for the uplink rep */1377 /* we want a persistent mac for the uplink rep */
@@ -1401,7 +1401,7 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) · 23 unmodified lines
1401 netdev->hw_features |= NETIF_F_TSO6;1401 netdev->hw_features |= NETIF_F_TSO6;
1402 netdev->hw_features |= NETIF_F_RXCSUM;1402 netdev->hw_features |= NETIF_F_RXCSUM;
1403 1403
1404 if (rep->vport != FDB_UPLINK_VPORT)1404 if (rep->vport != MLX5_VPORT_UPLINK)
1405 netdev->features |= NETIF_F_VLAN_CHALLENGED;1405 netdev->features |= NETIF_F_VLAN_CHALLENGED;
1406 1406
1407 netdev->features |= netdev->hw_features;1407 netdev->features |= netdev->hw_features;
@@ -1554,7 +1554,7 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv) · 146 unmodified lines
1554 return err;1554 return err;
1555 }1555 }
1556 1556
1557 if (rpriv->rep->vport == FDB_UPLINK_VPORT) {1557 if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
1558 uplink_priv = &rpriv->uplink_priv;1558 uplink_priv = &rpriv->uplink_priv;
1559 1559
1560 /* init shared tc flow table */1560 /* init shared tc flow table */
@@ -1590,7 +1590,7 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv) · 29 unmodified lines
1590 for (tc = 0; tc < priv->profile->max_tc; tc++)1590 for (tc = 0; tc < priv->profile->max_tc; tc++)
1591 mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);1591 mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);
1592 1592
1593 if (rpriv->rep->vport == FDB_UPLINK_VPORT) {1593 if (rpriv->rep->vport == MLX5_VPORT_UPLINK) {
1594 /* clean indirect TC block notifications */1594 /* clean indirect TC block notifications */
1595 unregister_netdevice_notifier(&rpriv->uplink_priv.netdevice_nb);1595 unregister_netdevice_notifier(&rpriv->uplink_priv.netdevice_nb);
1596 mlx5e_rep_indr_clean_block_privs(rpriv);1596 mlx5e_rep_indr_clean_block_privs(rpriv);
@@ -1709,7 +1709,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) · 112 unmodified lines
1709 rpriv->rep = rep;1709 rpriv->rep = rep;
1710 1710
1711 nch = mlx5e_get_max_num_channels(dev);1711 nch = mlx5e_get_max_num_channels(dev);
1712 profile = (rep->vport == FDB_UPLINK_VPORT) ? &mlx5e_uplink_rep_profile : &mlx5e_vf_rep_profile;1712 profile = (rep->vport == MLX5_VPORT_UPLINK) ? &mlx5e_uplink_rep_profile : &mlx5e_vf_rep_profile;
1713 netdev = mlx5e_create_netdev(dev, profile, nch, rpriv);1713 netdev = mlx5e_create_netdev(dev, profile, nch, rpriv);
1714 if (!netdev) {1714 if (!netdev) {
1715 pr_warn("Failed to create representor netdev for vport %d\n",1715 pr_warn("Failed to create representor netdev for vport %d\n",
@@ -1722,7 +1722,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) · 6 unmodified lines
1722 rep->rep_if[REP_ETH].priv = rpriv;1722 rep->rep_if[REP_ETH].priv = rpriv;
1723 INIT_LIST_HEAD(&rpriv->vport_sqs_list);1723 INIT_LIST_HEAD(&rpriv->vport_sqs_list);
1724 1724
1725 if (rep->vport == FDB_UPLINK_VPORT) {1725 if (rep->vport == MLX5_VPORT_UPLINK) {
1726 err = mlx5e_create_mdev_resources(dev);1726 err = mlx5e_create_mdev_resources(dev);
1727 if (err)1727 if (err)
1728 goto err_destroy_netdev;1728 goto err_destroy_netdev;
@@ -1758,7 +1758,7 @@ err_detach_netdev: · 29 unmodified lines
1758 mlx5e_detach_netdev(netdev_priv(netdev));1758 mlx5e_detach_netdev(netdev_priv(netdev));
1759 1759
1760err_destroy_mdev_resources:1760err_destroy_mdev_resources:
1761 if (rep->vport == FDB_UPLINK_VPORT)1761 if (rep->vport == MLX5_VPORT_UPLINK)
1762 mlx5e_destroy_mdev_resources(dev);1762 mlx5e_destroy_mdev_resources(dev);
1763 1763
1764err_destroy_netdev:1764err_destroy_netdev:
@@ -1778,7 +1778,7 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep) · 13 unmodified lines
1778 unregister_netdev(netdev);1778 unregister_netdev(netdev);
1779 mlx5e_rep_neigh_cleanup(rpriv);1779 mlx5e_rep_neigh_cleanup(rpriv);
1780 mlx5e_detach_netdev(priv);1780 mlx5e_detach_netdev(priv);
1781 if (rep->vport == FDB_UPLINK_VPORT)1781 if (rep->vport == MLX5_VPORT_UPLINK)
1782 mlx5e_destroy_mdev_resources(priv->mdev);1782 mlx5e_destroy_mdev_resources(priv->mdev);
1783 mlx5e_destroy_netdev(priv);1783 mlx5e_destroy_netdev(priv);
1784 kfree(ppriv); /* mlx5e_rep_priv */1784 kfree(ppriv); /* mlx5e_rep_priv */
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+3−3
@@ -1776,7 +1776,7 @@ static int parse_cls_flower(struct mlx5e_priv *priv, · 1775 unmodified lines
1776 1776
1777 if (!err && (flow->flags & MLX5E_TC_FLOW_ESWITCH)) {1777 if (!err && (flow->flags & MLX5E_TC_FLOW_ESWITCH)) {
1778 rep = rpriv->rep;1778 rep = rpriv->rep;
1779 if (rep->vport != FDB_UPLINK_VPORT &&1779 if (rep->vport != MLX5_VPORT_UPLINK &&
1780 (esw->offloads.inline_mode != MLX5_INLINE_MODE_NONE &&1780 (esw->offloads.inline_mode != MLX5_INLINE_MODE_NONE &&
1781 esw->offloads.inline_mode < match_level)) {1781 esw->offloads.inline_mode < match_level)) {
1782 NL_SET_ERR_MSG_MOD(extack,1782 NL_SET_ERR_MSG_MOD(extack,
@@ -2693,7 +2693,7 @@ static struct rhashtable *get_tc_ht(struct mlx5e_priv *priv, int flags) · 910 unmodified lines
2693static bool is_peer_flow_needed(struct mlx5e_tc_flow *flow)2693static bool is_peer_flow_needed(struct mlx5e_tc_flow *flow)
2694{2694{
2695 struct mlx5_esw_flow_attr *attr = flow->esw_attr;2695 struct mlx5_esw_flow_attr *attr = flow->esw_attr;
2696 bool is_rep_ingress = attr->in_rep->vport != FDB_UPLINK_VPORT &&2696 bool is_rep_ingress = attr->in_rep->vport != MLX5_VPORT_UPLINK &&
2697 flow->flags & MLX5E_TC_FLOW_INGRESS;2697 flow->flags & MLX5E_TC_FLOW_INGRESS;
2698 bool act_is_encap = !!(attr->action &2698 bool act_is_encap = !!(attr->action &
2699 MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT);2699 MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT);
@@ -2816,7 +2816,7 @@ static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f, · 116 unmodified lines
2816 * original flow and packets redirected from uplink use the2816 * original flow and packets redirected from uplink use the
2817 * peer mdev.2817 * peer mdev.
2818 */2818 */
2819 if (flow->esw_attr->in_rep->vport == FDB_UPLINK_VPORT)2819 if (flow->esw_attr->in_rep->vport == MLX5_VPORT_UPLINK)
2820 in_mdev = peer_priv->mdev;2820 in_mdev = peer_priv->mdev;
2821 else2821 else
2822 in_mdev = priv->mdev;2822 in_mdev = priv->mdev;
drivers/net/ethernet/mellanox/mlx5/core/eq.c+10−6
@@ -34,6 +34,7 @@ · 33 unmodified lines
34#include <linux/notifier.h>34#include <linux/notifier.h>
35#include <linux/module.h>35#include <linux/module.h>
36#include <linux/mlx5/driver.h>36#include <linux/mlx5/driver.h>
37#include <linux/mlx5/vport.h>
37#include <linux/mlx5/eq.h>38#include <linux/mlx5/eq.h>
38#include <linux/mlx5/cmd.h>39#include <linux/mlx5/cmd.h>
39#ifdef CONFIG_RFS_ACCEL40#ifdef CONFIG_RFS_ACCEL
@@ -114,11 +115,11 @@ static struct mlx5_core_cq *mlx5_eq_cq_get(struct mlx5_eq *eq, u32 cqn) · 74 unmodified lines
114 struct mlx5_cq_table *table = &eq->cq_table;115 struct mlx5_cq_table *table = &eq->cq_table;
115 struct mlx5_core_cq *cq = NULL;116 struct mlx5_core_cq *cq = NULL;
116 117
117 spin_lock(&table->lock);118 rcu_read_lock();
118 cq = radix_tree_lookup(&table->tree, cqn);119 cq = radix_tree_lookup(&table->tree, cqn);
119 if (likely(cq))120 if (likely(cq))
120 mlx5_cq_hold(cq);121 mlx5_cq_hold(cq);
121 spin_unlock(&table->lock);122 rcu_read_unlock();
122 123
123 return cq;124 return cq;
124}125}
@@ -371,9 +372,9 @@ int mlx5_eq_add_cq(struct mlx5_eq *eq, struct mlx5_core_cq *cq) · 246 unmodified lines
371 struct mlx5_cq_table *table = &eq->cq_table;372 struct mlx5_cq_table *table = &eq->cq_table;
372 int err;373 int err;
373 374
374 spin_lock_irq(&table->lock);375 spin_lock(&table->lock);
375 err = radix_tree_insert(&table->tree, cq->cqn, cq);376 err = radix_tree_insert(&table->tree, cq->cqn, cq);
376 spin_unlock_irq(&table->lock);377 spin_unlock(&table->lock);
377 378
378 return err;379 return err;
379}380}
@@ -383,9 +384,9 @@ int mlx5_eq_del_cq(struct mlx5_eq *eq, struct mlx5_core_cq *cq) · 3 unmodified lines
383 struct mlx5_cq_table *table = &eq->cq_table;384 struct mlx5_cq_table *table = &eq->cq_table;
384 struct mlx5_core_cq *tmp;385 struct mlx5_core_cq *tmp;
385 386
386 spin_lock_irq(&table->lock);387 spin_lock(&table->lock);
387 tmp = radix_tree_delete(&table->tree, cq->cqn);388 tmp = radix_tree_delete(&table->tree, cq->cqn);
388 spin_unlock_irq(&table->lock);389 spin_unlock(&table->lock);
389 390
390 if (!tmp) {391 if (!tmp) {
391 mlx5_core_warn(eq->dev, "cq 0x%x not found in eq 0x%x tree\n", eq->eqn, cq->cqn);392 mlx5_core_warn(eq->dev, "cq 0x%x not found in eq 0x%x tree\n", eq->eqn, cq->cqn);
@@ -530,6 +531,9 @@ static u64 gather_async_events_mask(struct mlx5_core_dev *dev) · 138 unmodified lines
530 if (MLX5_CAP_GEN(dev, max_num_of_monitor_counters))531 if (MLX5_CAP_GEN(dev, max_num_of_monitor_counters))
531 async_event_mask |= (1ull << MLX5_EVENT_TYPE_MONITOR_COUNTER);532 async_event_mask |= (1ull << MLX5_EVENT_TYPE_MONITOR_COUNTER);
532 533
534 if (mlx5_core_is_ecpf_esw_manager(dev))
535 async_event_mask |= (1ull << MLX5_EVENT_TYPE_HOST_PARAMS_CHANGE);
536
533 return async_event_mask;537 return async_event_mask;
534}538}
535 539
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c+20−22
@@ -40,8 +40,6 @@ · 39 unmodified lines
40#include "eswitch.h"40#include "eswitch.h"
41#include "fs_core.h"41#include "fs_core.h"
42 42
43#define UPLINK_VPORT 0xFFFF
44
45enum {43enum {
46 MLX5_ACTION_NONE = 0,44 MLX5_ACTION_NONE = 0,
47 MLX5_ACTION_ADD = 1,45 MLX5_ACTION_ADD = 1,
@@ -52,7 +50,7 @@ enum { · 4 unmodified lines
52struct vport_addr {50struct vport_addr {
53 struct l2addr_node node;51 struct l2addr_node node;
54 u8 action;52 u8 action;
55 u32 vport;53 u16 vport;
56 struct mlx5_flow_handle *flow_rule;54 struct mlx5_flow_handle *flow_rule;
57 bool mpfs; /* UC MAC was added to MPFs */55 bool mpfs; /* UC MAC was added to MPFs */
58 /* A flag indicating that mac was added due to mc promiscuous vport */56 /* A flag indicating that mac was added due to mc promiscuous vport */
@@ -115,7 +113,7 @@ static int modify_esw_vport_context_cmd(struct mlx5_core_dev *dev, u16 vport, · 56 unmodified lines
115 return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));113 return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
116}114}
117 115
118static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u32 vport,116static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u16 vport,
119 u16 vlan, u8 qos, u8 set_flags)117 u16 vlan, u8 qos, u8 set_flags)
120{118{
121 u32 in[MLX5_ST_SZ_DW(modify_esw_vport_context_in)] = {0};119 u32 in[MLX5_ST_SZ_DW(modify_esw_vport_context_in)] = {0};
@@ -152,7 +150,7 @@ static int modify_esw_vport_cvlan(struct mlx5_core_dev *dev, u32 vport, · 30 unmodified lines
152 150
153/* E-Switch FDB */151/* E-Switch FDB */
154static struct mlx5_flow_handle *152static struct mlx5_flow_handle *
155__esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule,153__esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u16 vport, bool rx_rule,
156 u8 mac_c[ETH_ALEN], u8 mac_v[ETH_ALEN])154 u8 mac_c[ETH_ALEN], u8 mac_v[ETH_ALEN])
157{155{
158 int match_header = (is_zero_ether_addr(mac_c) ? 0 :156 int match_header = (is_zero_ether_addr(mac_c) ? 0 :
@@ -188,7 +186,7 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule, · 29 unmodified lines
188 misc_parameters);186 misc_parameters);
189 mc_misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,187 mc_misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
190 misc_parameters);188 misc_parameters);
191 MLX5_SET(fte_match_set_misc, mv_misc, source_port, UPLINK_VPORT);189 MLX5_SET(fte_match_set_misc, mv_misc, source_port, MLX5_VPORT_UPLINK);
192 MLX5_SET_TO_ONES(fte_match_set_misc, mc_misc, source_port);190 MLX5_SET_TO_ONES(fte_match_set_misc, mc_misc, source_port);
193 }191 }
194 192
@@ -215,7 +213,7 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule, · 20 unmodified lines
215}213}
216 214
217static struct mlx5_flow_handle *215static struct mlx5_flow_handle *
218esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport)216esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u16 vport)
219{217{
220 u8 mac_c[ETH_ALEN];218 u8 mac_c[ETH_ALEN];
221 219
@@ -224,7 +222,7 @@ esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport) · 2 unmodified lines
224}222}
225 223
226static struct mlx5_flow_handle *224static struct mlx5_flow_handle *
227esw_fdb_set_vport_allmulti_rule(struct mlx5_eswitch *esw, u32 vport)225esw_fdb_set_vport_allmulti_rule(struct mlx5_eswitch *esw, u16 vport)
228{226{
229 u8 mac_c[ETH_ALEN];227 u8 mac_c[ETH_ALEN];
230 u8 mac_v[ETH_ALEN];228 u8 mac_v[ETH_ALEN];
@@ -237,7 +235,7 @@ esw_fdb_set_vport_allmulti_rule(struct mlx5_eswitch *esw, u32 vport) · 6 unmodified lines
237}235}
238 236
239static struct mlx5_flow_handle *237static struct mlx5_flow_handle *
240esw_fdb_set_vport_promisc_rule(struct mlx5_eswitch *esw, u32 vport)238esw_fdb_set_vport_promisc_rule(struct mlx5_eswitch *esw, u16 vport)
241{239{
242 u8 mac_c[ETH_ALEN];240 u8 mac_c[ETH_ALEN];
243 u8 mac_v[ETH_ALEN];241 u8 mac_v[ETH_ALEN];
@@ -377,7 +375,7 @@ typedef int (*vport_addr_action)(struct mlx5_eswitch *esw, · 133 unmodified lines
377static int esw_add_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)375static int esw_add_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)
378{376{
379 u8 *mac = vaddr->node.addr;377 u8 *mac = vaddr->node.addr;
380 u32 vport = vaddr->vport;378 u16 vport = vaddr->vport;
381 int err;379 int err;
382 380
383 /* Skip mlx5_mpfs_add_mac for PFs,381 /* Skip mlx5_mpfs_add_mac for PFs,
@@ -409,7 +407,7 @@ fdb_add: · 25 unmodified lines
409static int esw_del_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)407static int esw_del_uc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr)
410{408{
411 u8 *mac = vaddr->node.addr;409 u8 *mac = vaddr->node.addr;
412 u32 vport = vaddr->vport;410 u16 vport = vaddr->vport;
413 int err = 0;411 int err = 0;
414 412
415 /* Skip mlx5_mpfs_del_mac for PFs,413 /* Skip mlx5_mpfs_del_mac for PFs,
@@ -438,7 +436,7 @@ static void update_allmulti_vports(struct mlx5_eswitch *esw, · 22 unmodified lines
438 struct esw_mc_addr *esw_mc)436 struct esw_mc_addr *esw_mc)
439{437{
440 u8 *mac = vaddr->node.addr;438 u8 *mac = vaddr->node.addr;
441 u32 vport_idx = 0;439 u16 vport_idx = 0;
442 440
443 for (vport_idx = 0; vport_idx < esw->total_vports; vport_idx++) {441 for (vport_idx = 0; vport_idx < esw->total_vports; vport_idx++) {
444 struct mlx5_vport *vport = &esw->vports[vport_idx];442 struct mlx5_vport *vport = &esw->vports[vport_idx];
@@ -485,7 +483,7 @@ static int esw_add_mc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) · 40 unmodified lines
485 struct hlist_head *hash = esw->mc_table;483 struct hlist_head *hash = esw->mc_table;
486 struct esw_mc_addr *esw_mc;484 struct esw_mc_addr *esw_mc;
487 u8 *mac = vaddr->node.addr;485 u8 *mac = vaddr->node.addr;
488 u32 vport = vaddr->vport;486 u16 vport = vaddr->vport;
489 487
490 if (!esw->fdb_table.legacy.fdb)488 if (!esw->fdb_table.legacy.fdb)
491 return 0;489 return 0;
@@ -499,7 +497,7 @@ static int esw_add_mc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) · 7 unmodified lines
499 return -ENOMEM;497 return -ENOMEM;
500 498
501 esw_mc->uplink_rule = /* Forward MC MAC to Uplink */499 esw_mc->uplink_rule = /* Forward MC MAC to Uplink */
502 esw_fdb_set_vport_rule(esw, mac, UPLINK_VPORT);500 esw_fdb_set_vport_rule(esw, mac, MLX5_VPORT_UPLINK);
503 501
504 /* Add this multicast mac to all the mc promiscuous vports */502 /* Add this multicast mac to all the mc promiscuous vports */
505 update_allmulti_vports(esw, vaddr, esw_mc);503 update_allmulti_vports(esw, vaddr, esw_mc);
@@ -525,7 +523,7 @@ static int esw_del_mc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) · 19 unmodified lines
525 struct hlist_head *hash = esw->mc_table;523 struct hlist_head *hash = esw->mc_table;
526 struct esw_mc_addr *esw_mc;524 struct esw_mc_addr *esw_mc;
527 u8 *mac = vaddr->node.addr;525 u8 *mac = vaddr->node.addr;
528 u32 vport = vaddr->vport;526 u16 vport = vaddr->vport;
529 527
530 if (!esw->fdb_table.legacy.fdb)528 if (!esw->fdb_table.legacy.fdb)
531 return 0;529 return 0;
@@ -564,7 +562,7 @@ static int esw_del_mc_addr(struct mlx5_eswitch *esw, struct vport_addr *vaddr) · 32 unmodified lines
564 562
565/* Apply vport UC/MC list to HW l2 table and FDB table */563/* Apply vport UC/MC list to HW l2 table and FDB table */
566static void esw_apply_vport_addr_list(struct mlx5_eswitch *esw,564static void esw_apply_vport_addr_list(struct mlx5_eswitch *esw,
567 u32 vport_num, int list_type)565 u16 vport_num, int list_type)
568{566{
569 struct mlx5_vport *vport = &esw->vports[vport_num];567 struct mlx5_vport *vport = &esw->vports[vport_num];
570 bool is_uc = list_type == MLX5_NVPRT_LIST_TYPE_UC;568 bool is_uc = list_type == MLX5_NVPRT_LIST_TYPE_UC;
@@ -599,7 +597,7 @@ static void esw_apply_vport_addr_list(struct mlx5_eswitch *esw, · 28 unmodified lines
599 597
600/* Sync vport UC/MC list from vport context */598/* Sync vport UC/MC list from vport context */
601static void esw_update_vport_addr_list(struct mlx5_eswitch *esw,599static void esw_update_vport_addr_list(struct mlx5_eswitch *esw,
602 u32 vport_num, int list_type)600 u16 vport_num, int list_type)
603{601{
604 struct mlx5_vport *vport = &esw->vports[vport_num];602 struct mlx5_vport *vport = &esw->vports[vport_num];
605 bool is_uc = list_type == MLX5_NVPRT_LIST_TYPE_UC;603 bool is_uc = list_type == MLX5_NVPRT_LIST_TYPE_UC;
@@ -686,7 +684,7 @@ out: · 80 unmodified lines
686/* Sync vport UC/MC list from vport context684/* Sync vport UC/MC list from vport context
687 * Must be called after esw_update_vport_addr_list685 * Must be called after esw_update_vport_addr_list
688 */686 */
689static void esw_update_vport_mc_promisc(struct mlx5_eswitch *esw, u32 vport_num)687static void esw_update_vport_mc_promisc(struct mlx5_eswitch *esw, u16 vport_num)
690{688{
691 struct mlx5_vport *vport = &esw->vports[vport_num];689 struct mlx5_vport *vport = &esw->vports[vport_num];
692 struct l2addr_node *node;690 struct l2addr_node *node;
@@ -721,7 +719,7 @@ static void esw_update_vport_mc_promisc(struct mlx5_eswitch *esw, u32 vport_num) · 28 unmodified lines
721}719}
722 720
723/* Apply vport rx mode to HW FDB table */721/* Apply vport rx mode to HW FDB table */
724static void esw_apply_vport_rx_mode(struct mlx5_eswitch *esw, u32 vport_num,722static void esw_apply_vport_rx_mode(struct mlx5_eswitch *esw, u16 vport_num,
725 bool promisc, bool mc_promisc)723 bool promisc, bool mc_promisc)
726{724{
727 struct esw_mc_addr *allmulti_addr = &esw->mc_promisc;725 struct esw_mc_addr *allmulti_addr = &esw->mc_promisc;
@@ -736,7 +734,7 @@ static void esw_apply_vport_rx_mode(struct mlx5_eswitch *esw, u32 vport_num, · 8 unmodified lines
736 if (!allmulti_addr->uplink_rule)734 if (!allmulti_addr->uplink_rule)
737 allmulti_addr->uplink_rule =735 allmulti_addr->uplink_rule =
738 esw_fdb_set_vport_allmulti_rule(esw,736 esw_fdb_set_vport_allmulti_rule(esw,
739 UPLINK_VPORT);737 MLX5_VPORT_UPLINK);
740 allmulti_addr->refcnt++;738 allmulti_addr->refcnt++;
741 } else if (vport->allmulti_rule) {739 } else if (vport->allmulti_rule) {
742 mlx5_del_flow_rules(vport->allmulti_rule);740 mlx5_del_flow_rules(vport->allmulti_rule);
@@ -764,7 +762,7 @@ promisc: · 21 unmodified lines
764}762}
765 763
766/* Sync vport rx mode from vport context */764/* Sync vport rx mode from vport context */
767static void esw_update_vport_rx_mode(struct mlx5_eswitch *esw, u32 vport_num)765static void esw_update_vport_rx_mode(struct mlx5_eswitch *esw, u16 vport_num)
768{766{
769 struct mlx5_vport *vport = &esw->vports[vport_num];767 struct mlx5_vport *vport = &esw->vports[vport_num];
770 int promisc_all = 0;768 int promisc_all = 0;
@@ -1633,7 +1631,7 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) · 862 unmodified lines
1633 } else {1631 } else {
1634 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);1632 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
1635 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);1633 mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1636 err = esw_offloads_init(esw, nvfs + 1);1634 err = esw_offloads_init(esw, nvfs + MLX5_SPECIAL_VPORTS);
1637 }1635 }
1638 1636
1639 if (err)1637 if (err)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+0−2
@@ -49,8 +49,6 @@ · 48 unmodified lines
49#define MLX5_MAX_MC_PER_VPORT(dev) \49#define MLX5_MAX_MC_PER_VPORT(dev) \
50 (1 << MLX5_CAP_GEN(dev, log_max_current_mc_list))50 (1 << MLX5_CAP_GEN(dev, log_max_current_mc_list))
51 51
52#define FDB_UPLINK_VPORT 0xffff
53
54#define MLX5_MIN_BW_SHARE 152#define MLX5_MIN_BW_SHARE 1
55 53
56#define MLX5_RATE_TO_BW_SHARE(rate, divider, limit) \54#define MLX5_RATE_TO_BW_SHARE(rate, divider, limit) \
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c+22−17
@@ -46,6 +46,11 @@ enum { · 45 unmodified lines
46 FDB_SLOW_PATH46 FDB_SLOW_PATH
47};47};
48 48
49/* There are two match-all miss flows, one for unicast dst mac and
50 * one for multicast.
51 */
52#define MLX5_ESW_MISS_FLOWS (2)
53
49#define fdb_prio_table(esw, chain, prio, level) \54#define fdb_prio_table(esw, chain, prio, level) \
50 (esw)->fdb_table.offloads.fdb_prio[(chain)][(prio)][(level)]55 (esw)->fdb_table.offloads.fdb_prio[(chain)][(prio)][(level)]
51 56
@@ -360,15 +365,15 @@ static int esw_add_vlan_action_check(struct mlx5_esw_flow_attr *attr, · 308 unmodified lines
360 in_rep = attr->in_rep;365 in_rep = attr->in_rep;
361 out_rep = attr->dests[0].rep;366 out_rep = attr->dests[0].rep;
362 367
363 if (push && in_rep->vport == FDB_UPLINK_VPORT)368 if (push && in_rep->vport == MLX5_VPORT_UPLINK)
364 goto out_notsupp;369 goto out_notsupp;
365 370
366 if (pop && out_rep->vport == FDB_UPLINK_VPORT)371 if (pop && out_rep->vport == MLX5_VPORT_UPLINK)
367 goto out_notsupp;372 goto out_notsupp;
368 373
369 /* vport has vlan push configured, can't offload VF --> wire rules w.o it */374 /* vport has vlan push configured, can't offload VF --> wire rules w.o it */
370 if (!push && !pop && fwd)375 if (!push && !pop && fwd)
371 if (in_rep->vlan && out_rep->vport == FDB_UPLINK_VPORT)376 if (in_rep->vlan && out_rep->vport == MLX5_VPORT_UPLINK)
372 goto out_notsupp;377 goto out_notsupp;
373 378
374 /* protects against (1) setting rules with different vlans to push and379 /* protects against (1) setting rules with different vlans to push and
@@ -410,7 +415,7 @@ int mlx5_eswitch_add_vlan_action(struct mlx5_eswitch *esw, · 35 unmodified lines
410 415
411 if (!push && !pop && fwd) {416 if (!push && !pop && fwd) {
412 /* tracks VF --> wire rules without vlan push action */417 /* tracks VF --> wire rules without vlan push action */
413 if (attr->dests[0].rep->vport == FDB_UPLINK_VPORT) {418 if (attr->dests[0].rep->vport == MLX5_VPORT_UPLINK) {
414 vport->vlan_refcount++;419 vport->vlan_refcount++;
415 attr->vlan_handled = true;420 attr->vlan_handled = true;
416 }421 }
@@ -470,7 +475,7 @@ int mlx5_eswitch_del_vlan_action(struct mlx5_eswitch *esw, · 53 unmodified lines
470 475
471 if (!push && !pop && fwd) {476 if (!push && !pop && fwd) {
472 /* tracks VF --> wire rules without vlan push action */477 /* tracks VF --> wire rules without vlan push action */
473 if (attr->dests[0].rep->vport == FDB_UPLINK_VPORT)478 if (attr->dests[0].rep->vport == MLX5_VPORT_UPLINK)
474 vport->vlan_refcount--;479 vport->vlan_refcount--;
475 480
476 return 0;481 return 0;
@@ -905,8 +910,8 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports) · 428 unmodified lines
905 esw->fdb_table.offloads.fdb_left[i] =910 esw->fdb_table.offloads.fdb_left[i] =
906 ESW_POOLS[i] <= fdb_max ? ESW_SIZE / ESW_POOLS[i] : 0;911 ESW_POOLS[i] <= fdb_max ? ESW_SIZE / ESW_POOLS[i] : 0;
907 912
908 table_size = nvports * MAX_SQ_NVPORTS + MAX_PF_SQ + 2 +913 table_size = nvports * MAX_SQ_NVPORTS + MAX_PF_SQ +
909 esw->total_vports;914 MLX5_ESW_MISS_FLOWS + esw->total_vports;
910 915
911 /* create the slow path fdb with encap set, so further table instances916 /* create the slow path fdb with encap set, so further table instances
912 * can be created at run time while VFs are probed if the FW allows that.917 * can be created at run time while VFs are probed if the FW allows that.
@@ -1000,7 +1005,8 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports) · 87 unmodified lines
1000 dmac[0] = 0x01;1005 dmac[0] = 0x01;
1001 1006
1002 MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, ix);1007 MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, ix);
1003 MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, ix + 2);1008 MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index,
1009 ix + MLX5_ESW_MISS_FLOWS);
1004 1010
1005 g = mlx5_create_flow_group(fdb, flow_group_in);1011 g = mlx5_create_flow_group(fdb, flow_group_in);
1006 if (IS_ERR(g)) {1012 if (IS_ERR(g)) {
@@ -1049,7 +1055,7 @@ static void esw_destroy_offloads_fdb_tables(struct mlx5_eswitch *esw) · 42 unmodified lines
1049 esw_destroy_offloads_fast_fdb_tables(esw);1055 esw_destroy_offloads_fast_fdb_tables(esw);
1050}1056}
1051 1057
1052static int esw_create_offloads_table(struct mlx5_eswitch *esw)1058static int esw_create_offloads_table(struct mlx5_eswitch *esw, int nvports)
1053{1059{
1054 struct mlx5_flow_table_attr ft_attr = {};1060 struct mlx5_flow_table_attr ft_attr = {};
1055 struct mlx5_core_dev *dev = esw->dev;1061 struct mlx5_core_dev *dev = esw->dev;
@@ -1063,7 +1069,7 @@ static int esw_create_offloads_table(struct mlx5_eswitch *esw) · 7 unmodified lines
1063 return -EOPNOTSUPP;1069 return -EOPNOTSUPP;
1064 }1070 }
1065 1071
1066 ft_attr.max_fte = dev->priv.sriov.num_vfs + 2;1072 ft_attr.max_fte = nvports + MLX5_ESW_MISS_FLOWS;
1067 1073
1068 ft_offloads = mlx5_create_flow_table(ns, &ft_attr);1074 ft_offloads = mlx5_create_flow_table(ns, &ft_attr);
1069 if (IS_ERR(ft_offloads)) {1075 if (IS_ERR(ft_offloads)) {
@@ -1083,16 +1089,15 @@ static void esw_destroy_offloads_table(struct mlx5_eswitch *esw) · 13 unmodified lines
1083 mlx5_destroy_flow_table(offloads->ft_offloads);1089 mlx5_destroy_flow_table(offloads->ft_offloads);
1084}1090}
1085 1091
1086static int esw_create_vport_rx_group(struct mlx5_eswitch *esw)1092static int esw_create_vport_rx_group(struct mlx5_eswitch *esw, int nvports)
1087{1093{
1088 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);1094 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
1089 struct mlx5_flow_group *g;1095 struct mlx5_flow_group *g;
1090 struct mlx5_priv *priv = &esw->dev->priv;
1091 u32 *flow_group_in;1096 u32 *flow_group_in;
1092 void *match_criteria, *misc;1097 void *match_criteria, *misc;
1093 int err = 0;1098 int err = 0;
1094 int nvports = priv->sriov.num_vfs + 2;
1095 1099
1100 nvports = nvports + MLX5_ESW_MISS_FLOWS;
1096 flow_group_in = kvzalloc(inlen, GFP_KERNEL);1101 flow_group_in = kvzalloc(inlen, GFP_KERNEL);
1097 if (!flow_group_in)1102 if (!flow_group_in)
1098 return -ENOMEM;1103 return -ENOMEM;
@@ -1228,7 +1233,7 @@ int esw_offloads_init_reps(struct mlx5_eswitch *esw) · 129 unmodified lines
1228 ether_addr_copy(rep->hw_id, hw_id);1233 ether_addr_copy(rep->hw_id, hw_id);
1229 }1234 }
1230 1235
1231 offloads->vport_reps[0].vport = FDB_UPLINK_VPORT;1236 offloads->vport_reps[0].vport = MLX5_VPORT_UPLINK;
1232 1237
1233 return 0;1238 return 0;
1234}1239}
@@ -1408,11 +1413,11 @@ int esw_offloads_init(struct mlx5_eswitch *esw, int nvports) · 173 unmodified lines
1408 if (err)1413 if (err)
1409 return err;1414 return err;
1410 1415
1411 err = esw_create_offloads_table(esw);1416 err = esw_create_offloads_table(esw, nvports);
1412 if (err)1417 if (err)
1413 goto create_ft_err;1418 goto create_ft_err;
1414 1419
1415 err = esw_create_vport_rx_group(esw);1420 err = esw_create_vport_rx_group(esw, nvports);
1416 if (err)1421 if (err)
1417 goto create_fg_err;1422 goto create_fg_err;
1418 1423
@@ -1812,7 +1817,7 @@ void *mlx5_eswitch_get_proto_dev(struct mlx5_eswitch *esw, · 393 unmodified lines
1812 struct mlx5_esw_offload *offloads = &esw->offloads;1817 struct mlx5_esw_offload *offloads = &esw->offloads;
1813 struct mlx5_eswitch_rep *rep;1818 struct mlx5_eswitch_rep *rep;
1814 1819
1815 if (vport == FDB_UPLINK_VPORT)1820 if (vport == MLX5_VPORT_UPLINK)
1816 vport = UPLINK_REP_INDEX;1821 vport = UPLINK_REP_INDEX;
1817 1822
1818 rep = &offloads->vport_reps[vport];1823 rep = &offloads->vport_reps[vport];
drivers/net/ethernet/mellanox/mlx5/core/events.c+2−0
@@ -103,6 +103,8 @@ static const char *eqe_type_str(u8 type) · 102 unmodified lines
103 return "MLX5_EVENT_TYPE_STALL_EVENT";103 return "MLX5_EVENT_TYPE_STALL_EVENT";
104 case MLX5_EVENT_TYPE_CMD:104 case MLX5_EVENT_TYPE_CMD:
105 return "MLX5_EVENT_TYPE_CMD";105 return "MLX5_EVENT_TYPE_CMD";
106 case MLX5_EVENT_TYPE_HOST_PARAMS_CHANGE:
107 return "MLX5_EVENT_TYPE_HOST_PARAMS_CHANGE";
106 case MLX5_EVENT_TYPE_PAGE_REQUEST:108 case MLX5_EVENT_TYPE_PAGE_REQUEST:
107 return "MLX5_EVENT_TYPE_PAGE_REQUEST";109 return "MLX5_EVENT_TYPE_PAGE_REQUEST";
108 case MLX5_EVENT_TYPE_PAGE_FAULT:110 case MLX5_EVENT_TYPE_PAGE_FAULT:
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
32 32
33#include <linux/mutex.h>33#include <linux/mutex.h>
34#include <linux/mlx5/driver.h>34#include <linux/mlx5/driver.h>
35#include <linux/mlx5/vport.h>
35#include <linux/mlx5/eswitch.h>36#include <linux/mlx5/eswitch.h>
36 37
37#include "mlx5_core.h"38#include "mlx5_core.h"
drivers/net/ethernet/mellanox/mlx5/core/mad.c+0−75
@@ -1,75 +0,0 @@
1/*
2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#include <linux/kernel.h>
34#include <linux/module.h>
35#include <linux/mlx5/driver.h>
36#include <linux/mlx5/cmd.h>
37#include "mlx5_core.h"
38
39int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
40 u16 opmod, u8 port)
41{
42 int outlen = MLX5_ST_SZ_BYTES(mad_ifc_out);
43 int inlen = MLX5_ST_SZ_BYTES(mad_ifc_in);
44 int err = -ENOMEM;
45 void *data;
46 void *resp;
47 u32 *out;
48 u32 *in;
49
50 in = kzalloc(inlen, GFP_KERNEL);
51 out = kzalloc(outlen, GFP_KERNEL);
52 if (!in || !out)
53 goto out;
54
55 MLX5_SET(mad_ifc_in, in, opcode, MLX5_CMD_OP_MAD_IFC);
56 MLX5_SET(mad_ifc_in, in, op_mod, opmod);
57 MLX5_SET(mad_ifc_in, in, port, port);
58
59 data = MLX5_ADDR_OF(mad_ifc_in, in, mad);
60 memcpy(data, inb, MLX5_FLD_SZ_BYTES(mad_ifc_in, mad));
61
62 err = mlx5_cmd_exec(dev, in, inlen, out, outlen);
63 if (err)
64 goto out;
65
66 resp = MLX5_ADDR_OF(mad_ifc_out, out, response_mad_packet);
67 memcpy(outb, resp,
68 MLX5_FLD_SZ_BYTES(mad_ifc_out, response_mad_packet));
69
70out:
71 kfree(out);
72 kfree(in);
73 return err;
74}
75EXPORT_SYMBOL_GPL(mlx5_core_mad_ifc);
drivers/net/ethernet/mellanox/mlx5/core/main.c+71−0
@@ -65,6 +65,7 @@ · 64 unmodified lines
65#include "lib/vxlan.h"65#include "lib/vxlan.h"
66#include "lib/devcom.h"66#include "lib/devcom.h"
67#include "diag/fw_tracer.h"67#include "diag/fw_tracer.h"
68#include "ecpf.h"
68 69
69MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");70MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
70MODULE_DESCRIPTION("Mellanox 5th generation network adapters (ConnectX series) core driver");71MODULE_DESCRIPTION("Mellanox 5th generation network adapters (ConnectX series) core driver");
@@ -459,6 +460,50 @@ static int handle_hca_cap_atomic(struct mlx5_core_dev *dev) · 388 unmodified lines
459 return err;460 return err;
460}461}
461 462
463static int handle_hca_cap_odp(struct mlx5_core_dev *dev)
464{
465 void *set_hca_cap;
466 void *set_ctx;
467 int set_sz;
468 int err;
469
470 if (!MLX5_CAP_GEN(dev, pg))
471 return 0;
472
473 err = mlx5_core_get_caps(dev, MLX5_CAP_ODP);
474 if (err)
475 return err;
476
477 if (!(MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive) ||
478 MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive) ||
479 MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive)))
480 return 0;
481
482 set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
483 set_ctx = kzalloc(set_sz, GFP_KERNEL);
484 if (!set_ctx)
485 return -ENOMEM;
486
487 set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability);
488 memcpy(set_hca_cap, dev->caps.hca_cur[MLX5_CAP_ODP],
489 MLX5_ST_SZ_BYTES(odp_cap));
490
491 /* set ODP SRQ support for RC/UD and XRC transports */
492 MLX5_SET(odp_cap, set_hca_cap, ud_odp_caps.srq_receive,
493 MLX5_CAP_ODP_MAX(dev, ud_odp_caps.srq_receive));
494
495 MLX5_SET(odp_cap, set_hca_cap, rc_odp_caps.srq_receive,
496 MLX5_CAP_ODP_MAX(dev, rc_odp_caps.srq_receive));
497
498 MLX5_SET(odp_cap, set_hca_cap, xrc_odp_caps.srq_receive,
499 MLX5_CAP_ODP_MAX(dev, xrc_odp_caps.srq_receive));
500
501 err = set_caps(dev, set_ctx, set_sz, MLX5_SET_HCA_CAP_OP_MOD_ODP);
502
503 kfree(set_ctx);
504 return err;
505}
506
462static int handle_hca_cap(struct mlx5_core_dev *dev)507static int handle_hca_cap(struct mlx5_core_dev *dev)
463{508{
464 void *set_ctx = NULL;509 void *set_ctx = NULL;
@@ -567,6 +612,8 @@ int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id) · 102 unmodified lines
567 612
568 MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);613 MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
569 MLX5_SET(enable_hca_in, in, function_id, func_id);614 MLX5_SET(enable_hca_in, in, function_id, func_id);
615 MLX5_SET(enable_hca_in, in, embedded_cpu_function,
616 dev->caps.embedded_cpu);
570 return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));617 return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
571}618}
572 619
@@ -577,6 +624,8 @@ int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id) · 4 unmodified lines
577 624
578 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);625 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
579 MLX5_SET(disable_hca_in, in, function_id, func_id);626 MLX5_SET(disable_hca_in, in, function_id, func_id);
627 MLX5_SET(enable_hca_in, in, embedded_cpu_function,
628 dev->caps.embedded_cpu);
580 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));629 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
581}630}
582 631
@@ -693,6 +742,11 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct mlx5_priv *priv) · 110 unmodified lines
693 goto err_clr_master;742 goto err_clr_master;
694 }743 }
695 744
745 if (pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP32) &&
746 pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP64) &&
747 pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP128))
748 mlx5_core_dbg(dev, "Enabling pci atomics failed\n");
749
696 dev->iseg_base = pci_resource_start(dev->pdev, 0);750 dev->iseg_base = pci_resource_start(dev->pdev, 0);
697 dev->iseg = ioremap(dev->iseg_base, sizeof(*dev->iseg));751 dev->iseg = ioremap(dev->iseg_base, sizeof(*dev->iseg));
698 if (!dev->iseg) {752 if (!dev->iseg) {
@@ -849,6 +903,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv, · 150 unmodified lines
849 struct pci_dev *pdev = dev->pdev;903 struct pci_dev *pdev = dev->pdev;
850 int err;904 int err;
851 905
906 dev->caps.embedded_cpu = mlx5_read_embedded_cpu(dev);
852 mutex_lock(&dev->intf_state_mutex);907 mutex_lock(&dev->intf_state_mutex);
853 if (test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {908 if (test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
854 dev_warn(&dev->pdev->dev, "%s: interface is up, NOP\n",909 dev_warn(&dev->pdev->dev, "%s: interface is up, NOP\n",
@@ -926,6 +981,12 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv, · 71 unmodified lines
926 goto reclaim_boot_pages;981 goto reclaim_boot_pages;
927 }982 }
928 983
984 err = handle_hca_cap_odp(dev);
985 if (err) {
986 dev_err(&pdev->dev, "handle_hca_cap_odp failed\n");
987 goto reclaim_boot_pages;
988 }
989
929 err = mlx5_satisfy_startup_pages(dev, 0);990 err = mlx5_satisfy_startup_pages(dev, 0);
930 if (err) {991 if (err) {
931 dev_err(&pdev->dev, "failed to allocate init pages\n");992 dev_err(&pdev->dev, "failed to allocate init pages\n");
@@ -1014,6 +1075,12 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv, · 82 unmodified lines
1014 goto err_sriov;1075 goto err_sriov;
1015 }1076 }
1016 1077
1078 err = mlx5_ec_init(dev);
1079 if (err) {
1080 dev_err(&pdev->dev, "Failed to init embedded CPU\n");
1081 goto err_ec;
1082 }
1083
1017 if (mlx5_device_registered(dev)) {1084 if (mlx5_device_registered(dev)) {
1018 mlx5_attach_device(dev);1085 mlx5_attach_device(dev);
1019 } else {1086 } else {
@@ -1031,6 +1098,9 @@ out: · 11 unmodified lines
1031 return 0;1098 return 0;
1032 1099
1033err_reg_dev:1100err_reg_dev:
1101 mlx5_ec_cleanup(dev);
1102
1103err_ec:
1034 mlx5_sriov_detach(dev);1104 mlx5_sriov_detach(dev);
1035 1105
1036err_sriov:1106err_sriov:
@@ -1105,6 +1175,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv, · 68 unmodified lines
1105 if (mlx5_device_registered(dev))1175 if (mlx5_device_registered(dev))
1106 mlx5_detach_device(dev);1176 mlx5_detach_device(dev);
1107 1177
1178 mlx5_ec_cleanup(dev);
1108 mlx5_sriov_detach(dev);1179 mlx5_sriov_detach(dev);
1109 mlx5_cleanup_fs(dev);1180 mlx5_cleanup_fs(dev);
1110 mlx5_accel_ipsec_cleanup(dev);1181 mlx5_accel_ipsec_cleanup(dev);
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h+1−1
@@ -121,7 +121,7 @@ int mlx5_modify_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy, · 120 unmodified lines
121 u32 modify_bitmask);121 u32 modify_bitmask);
122int mlx5_destroy_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,122int mlx5_destroy_scheduling_element_cmd(struct mlx5_core_dev *dev, u8 hierarchy,
123 u32 element_id);123 u32 element_id);
124int mlx5_wait_for_vf_pages(struct mlx5_core_dev *dev);124int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages);
125u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev,125u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev,
126 struct ptp_system_timestamp *sts);126 struct ptp_system_timestamp *sts);
127 127
drivers/net/ethernet/mellanox/mlx5/core/mr.c+6−5
@@ -51,9 +51,10 @@ void mlx5_cleanup_mkey_table(struct mlx5_core_dev *dev) · 50 unmodified lines
51 51
52int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,52int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
53 struct mlx5_core_mkey *mkey,53 struct mlx5_core_mkey *mkey,
54 u32 *in, int inlen,54 struct mlx5_async_ctx *async_ctx, u32 *in,
55 u32 *out, int outlen,55 int inlen, u32 *out, int outlen,
56 mlx5_cmd_cbk_t callback, void *context)56 mlx5_async_cbk_t callback,
57 struct mlx5_async_work *context)
57{58{
58 struct mlx5_mkey_table *table = &dev->priv.mkey_table;59 struct mlx5_mkey_table *table = &dev->priv.mkey_table;
59 u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0};60 u32 lout[MLX5_ST_SZ_DW(create_mkey_out)] = {0};
@@ -71,7 +72,7 @@ int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev, · 11 unmodified lines
71 MLX5_SET(mkc, mkc, mkey_7_0, key);72 MLX5_SET(mkc, mkc, mkey_7_0, key);
72 73
73 if (callback)74 if (callback)
74 return mlx5_cmd_exec_cb(dev, in, inlen, out, outlen,75 return mlx5_cmd_exec_cb(async_ctx, in, inlen, out, outlen,
75 callback, context);76 callback, context);
76 77
77 err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout));78 err = mlx5_cmd_exec(dev, in, inlen, lout, sizeof(lout));
@@ -105,7 +106,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, · 27 unmodified lines
105 struct mlx5_core_mkey *mkey,106 struct mlx5_core_mkey *mkey,
106 u32 *in, int inlen)107 u32 *in, int inlen)
107{108{
108 return mlx5_core_create_mkey_cb(dev, mkey, in, inlen,109 return mlx5_core_create_mkey_cb(dev, mkey, NULL, in, inlen,
109 NULL, 0, NULL, NULL);110 NULL, 0, NULL, NULL);
110}111}
111EXPORT_SYMBOL(mlx5_core_create_mkey);112EXPORT_SYMBOL(mlx5_core_create_mkey);
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c+38−16
@@ -48,6 +48,7 @@ enum { · 47 unmodified lines
48struct mlx5_pages_req {48struct mlx5_pages_req {
49 struct mlx5_core_dev *dev;49 struct mlx5_core_dev *dev;
50 u16 func_id;50 u16 func_id;
51 u8 ec_function;
51 s32 npages;52 s32 npages;
52 struct work_struct work;53 struct work_struct work;
53};54};
@@ -143,6 +144,7 @@ static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id, · 89 unmodified lines
143 MLX5_SET(query_pages_in, in, op_mod, boot ?144 MLX5_SET(query_pages_in, in, op_mod, boot ?
144 MLX5_QUERY_PAGES_IN_OP_MOD_BOOT_PAGES :145 MLX5_QUERY_PAGES_IN_OP_MOD_BOOT_PAGES :
145 MLX5_QUERY_PAGES_IN_OP_MOD_INIT_PAGES);146 MLX5_QUERY_PAGES_IN_OP_MOD_INIT_PAGES);
147 MLX5_SET(query_pages_in, in, embedded_cpu_function, mlx5_core_is_ecpf(dev));
146 148
147 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));149 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
148 if (err)150 if (err)
@@ -253,7 +255,8 @@ err_mapping: · 104 unmodified lines
253 return err;255 return err;
254}256}
255 257
256static void page_notify_fail(struct mlx5_core_dev *dev, u16 func_id)258static void page_notify_fail(struct mlx5_core_dev *dev, u16 func_id,
259 bool ec_function)
257{260{
258 u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};261 u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};
259 u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {0};262 u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {0};
@@ -262,6 +265,7 @@ static void page_notify_fail(struct mlx5_core_dev *dev, u16 func_id) · 2 unmodified lines
262 MLX5_SET(manage_pages_in, in, opcode, MLX5_CMD_OP_MANAGE_PAGES);265 MLX5_SET(manage_pages_in, in, opcode, MLX5_CMD_OP_MANAGE_PAGES);
263 MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_CANT_GIVE);266 MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_CANT_GIVE);
264 MLX5_SET(manage_pages_in, in, function_id, func_id);267 MLX5_SET(manage_pages_in, in, function_id, func_id);
268 MLX5_SET(manage_pages_in, in, embedded_cpu_function, ec_function);
265 269
266 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));270 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
267 if (err)271 if (err)
@@ -270,7 +274,7 @@ static void page_notify_fail(struct mlx5_core_dev *dev, u16 func_id) · 2 unmodified lines
270}274}
271 275
272static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,276static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
273 int notify_fail)277 int notify_fail, bool ec_function)
274{278{
275 u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};279 u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};
276 int inlen = MLX5_ST_SZ_BYTES(manage_pages_in);280 int inlen = MLX5_ST_SZ_BYTES(manage_pages_in);
@@ -305,6 +309,7 @@ retry: · 28 unmodified lines
305 MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_GIVE);309 MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_GIVE);
306 MLX5_SET(manage_pages_in, in, function_id, func_id);310 MLX5_SET(manage_pages_in, in, function_id, func_id);
307 MLX5_SET(manage_pages_in, in, input_num_entries, npages);311 MLX5_SET(manage_pages_in, in, input_num_entries, npages);
312 MLX5_SET(manage_pages_in, in, embedded_cpu_function, ec_function);
308 313
309 err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));314 err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
310 if (err) {315 if (err) {
@@ -316,8 +321,11 @@ retry: · 5 unmodified lines
316 dev->priv.fw_pages += npages;321 dev->priv.fw_pages += npages;
317 if (func_id)322 if (func_id)
318 dev->priv.vfs_pages += npages;323 dev->priv.vfs_pages += npages;
324 else if (mlx5_core_is_ecpf(dev) && !ec_function)
325 dev->priv.peer_pf_pages += npages;
319 326
320 mlx5_core_dbg(dev, "err %d\n", err);327 mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x, err %d\n",
328 npages, ec_function, func_id, err);
321 329
322 kvfree(in);330 kvfree(in);
323 return 0;331 return 0;
@@ -328,7 +336,7 @@ out_4k: · 4 unmodified lines
328out_free:336out_free:
329 kvfree(in);337 kvfree(in);
330 if (notify_fail)338 if (notify_fail)
331 page_notify_fail(dev, func_id);339 page_notify_fail(dev, func_id, ec_function);
332 return err;340 return err;
333}341}
334 342
@@ -364,7 +372,7 @@ static int reclaim_pages_cmd(struct mlx5_core_dev *dev, · 29 unmodified lines
364}372}
365 373
366static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,374static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
367 int *nclaimed)375 int *nclaimed, bool ec_function)
368{376{
369 int outlen = MLX5_ST_SZ_BYTES(manage_pages_out);377 int outlen = MLX5_ST_SZ_BYTES(manage_pages_out);
370 u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {0};378 u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {0};
@@ -385,6 +393,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, · 14 unmodified lines
385 MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_TAKE);393 MLX5_SET(manage_pages_in, in, op_mod, MLX5_PAGES_TAKE);
386 MLX5_SET(manage_pages_in, in, function_id, func_id);394 MLX5_SET(manage_pages_in, in, function_id, func_id);
387 MLX5_SET(manage_pages_in, in, input_num_entries, npages);395 MLX5_SET(manage_pages_in, in, input_num_entries, npages);
396 MLX5_SET(manage_pages_in, in, embedded_cpu_function, ec_function);
388 397
389 mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen);398 mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen);
390 err = reclaim_pages_cmd(dev, in, sizeof(in), out, outlen);399 err = reclaim_pages_cmd(dev, in, sizeof(in), out, outlen);
@@ -410,6 +419,8 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, · 19 unmodified lines
410 dev->priv.fw_pages -= num_claimed;419 dev->priv.fw_pages -= num_claimed;
411 if (func_id)420 if (func_id)
412 dev->priv.vfs_pages -= num_claimed;421 dev->priv.vfs_pages -= num_claimed;
422 else if (mlx5_core_is_ecpf(dev) && !ec_function)
423 dev->priv.peer_pf_pages -= num_claimed;
413 424
414out_free:425out_free:
415 kvfree(out);426 kvfree(out);
@@ -423,9 +434,10 @@ static void pages_work_handler(struct work_struct *work) · 7 unmodified lines
423 int err = 0;434 int err = 0;
424 435
425 if (req->npages < 0)436 if (req->npages < 0)
426 err = reclaim_pages(dev, req->func_id, -1 * req->npages, NULL);437 err = reclaim_pages(dev, req->func_id, -1 * req->npages, NULL,
438 req->ec_function);
427 else if (req->npages > 0)439 else if (req->npages > 0)
428 err = give_pages(dev, req->func_id, req->npages, 1);440 err = give_pages(dev, req->func_id, req->npages, 1, req->ec_function);
429 441
430 if (err)442 if (err)
431 mlx5_core_warn(dev, "%s fail %d\n",443 mlx5_core_warn(dev, "%s fail %d\n",
@@ -434,6 +446,10 @@ static void pages_work_handler(struct work_struct *work) · 2 unmodified lines
434 kfree(req);446 kfree(req);
435}447}
436 448
449enum {
450 EC_FUNCTION_MASK = 0x8000,
451};
452
437static int req_pages_handler(struct notifier_block *nb,453static int req_pages_handler(struct notifier_block *nb,
438 unsigned long type, void *data)454 unsigned long type, void *data)
439{455{
@@ -441,6 +457,7 @@ static int req_pages_handler(struct notifier_block *nb, · 1 unmodified line
441 struct mlx5_core_dev *dev;457 struct mlx5_core_dev *dev;
442 struct mlx5_priv *priv;458 struct mlx5_priv *priv;
443 struct mlx5_eqe *eqe;459 struct mlx5_eqe *eqe;
460 bool ec_function;
444 u16 func_id;461 u16 func_id;
445 s32 npages;462 s32 npages;
446 463
@@ -450,6 +467,7 @@ static int req_pages_handler(struct notifier_block *nb, · 3 unmodified lines
450 467
451 func_id = be16_to_cpu(eqe->data.req_pages.func_id);468 func_id = be16_to_cpu(eqe->data.req_pages.func_id);
452 npages = be32_to_cpu(eqe->data.req_pages.num_pages);469 npages = be32_to_cpu(eqe->data.req_pages.num_pages);
470 ec_function = be16_to_cpu(eqe->data.req_pages.ec_function) & EC_FUNCTION_MASK;
453 mlx5_core_dbg(dev, "page request for func 0x%x, npages %d\n",471 mlx5_core_dbg(dev, "page request for func 0x%x, npages %d\n",
454 func_id, npages);472 func_id, npages);
455 req = kzalloc(sizeof(*req), GFP_ATOMIC);473 req = kzalloc(sizeof(*req), GFP_ATOMIC);
@@ -461,6 +479,7 @@ static int req_pages_handler(struct notifier_block *nb, · 5 unmodified lines
461 req->dev = dev;479 req->dev = dev;
462 req->func_id = func_id;480 req->func_id = func_id;
463 req->npages = npages;481 req->npages = npages;
482 req->ec_function = ec_function;
464 INIT_WORK(&req->work, pages_work_handler);483 INIT_WORK(&req->work, pages_work_handler);
465 queue_work(dev->priv.pg_wq, &req->work);484 queue_work(dev->priv.pg_wq, &req->work);
466 return NOTIFY_OK;485 return NOTIFY_OK;
@@ -479,7 +498,7 @@ int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot) · 12 unmodified lines
479 mlx5_core_dbg(dev, "requested %d %s pages for func_id 0x%x\n",498 mlx5_core_dbg(dev, "requested %d %s pages for func_id 0x%x\n",
480 npages, boot ? "boot" : "init", func_id);499 npages, boot ? "boot" : "init", func_id);
481 500
482 return give_pages(dev, func_id, npages, 0);501 return give_pages(dev, func_id, npages, 0, mlx5_core_is_ecpf(dev));
483}502}
484 503
485enum {504enum {
@@ -513,7 +532,7 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) · 27 unmodified lines
513 fwp = rb_entry(p, struct fw_page, rb_node);532 fwp = rb_entry(p, struct fw_page, rb_node);
514 err = reclaim_pages(dev, fwp->func_id,533 err = reclaim_pages(dev, fwp->func_id,
515 optimal_reclaimed_pages(),534 optimal_reclaimed_pages(),
516 &nclaimed);535 &nclaimed, mlx5_core_is_ecpf(dev));
517 536
518 if (err) {537 if (err) {
519 mlx5_core_warn(dev, "failed reclaiming pages (%d)\n",538 mlx5_core_warn(dev, "failed reclaiming pages (%d)\n",
@@ -535,6 +554,9 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) · 15 unmodified lines
535 WARN(dev->priv.vfs_pages,554 WARN(dev->priv.vfs_pages,
536 "VFs FW pages counter is %d after reclaiming all pages\n",555 "VFs FW pages counter is %d after reclaiming all pages\n",
537 dev->priv.vfs_pages);556 dev->priv.vfs_pages);
557 WARN(dev->priv.peer_pf_pages,
558 "Peer PF FW pages counter is %d after reclaiming all pages\n",
559 dev->priv.peer_pf_pages);
538 560
539 return 0;561 return 0;
540}562}
@@ -567,10 +589,10 @@ void mlx5_pagealloc_stop(struct mlx5_core_dev *dev) · 26 unmodified lines
567 flush_workqueue(dev->priv.pg_wq);589 flush_workqueue(dev->priv.pg_wq);
568}590}
569 591
570int mlx5_wait_for_vf_pages(struct mlx5_core_dev *dev)592int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages)
571{593{
572 unsigned long end = jiffies + msecs_to_jiffies(MAX_RECLAIM_VFS_PAGES_TIME_MSECS);594 unsigned long end = jiffies + msecs_to_jiffies(MAX_RECLAIM_VFS_PAGES_TIME_MSECS);
573 int prev_vfs_pages = dev->priv.vfs_pages;595 int prev_pages = *pages;
574 596
575 /* In case of internal error we will free the pages manually later */597 /* In case of internal error we will free the pages manually later */
576 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {598 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
@@ -578,16 +600,16 @@ int mlx5_wait_for_vf_pages(struct mlx5_core_dev *dev) · 1 unmodified line
578 return 0;600 return 0;
579 }601 }
580 602
581 mlx5_core_dbg(dev, "Waiting for %d pages from %s\n", prev_vfs_pages,603 mlx5_core_dbg(dev, "Waiting for %d pages from %s\n", prev_pages,
582 dev->priv.name);604 dev->priv.name);
583 while (dev->priv.vfs_pages) {605 while (*pages) {
584 if (time_after(jiffies, end)) {606 if (time_after(jiffies, end)) {
585 mlx5_core_warn(dev, "aborting while there are %d pending pages\n", dev->priv.vfs_pages);607 mlx5_core_warn(dev, "aborting while there are %d pending pages\n", *pages);
586 return -ETIMEDOUT;608 return -ETIMEDOUT;
587 }609 }
588 if (dev->priv.vfs_pages < prev_vfs_pages) {610 if (*pages < prev_pages) {
589 end = jiffies + msecs_to_jiffies(MAX_RECLAIM_VFS_PAGES_TIME_MSECS);611 end = jiffies + msecs_to_jiffies(MAX_RECLAIM_VFS_PAGES_TIME_MSECS);
590 prev_vfs_pages = dev->priv.vfs_pages;612 prev_pages = *pages;
591 }613 }
592 msleep(50);614 msleep(50);
593 }615 }
drivers/net/ethernet/mellanox/mlx5/core/port.c+0−106
@@ -30,10 +30,7 @@ · 29 unmodified lines
30 * SOFTWARE.30 * SOFTWARE.
31 */31 */
32 32
33#include <linux/module.h>
34#include <linux/mlx5/driver.h>
35#include <linux/mlx5/port.h>33#include <linux/mlx5/port.h>
36#include <linux/mlx5/cmd.h>
37#include "mlx5_core.h"34#include "mlx5_core.h"
38 35
39int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,36int mlx5_core_access_reg(struct mlx5_core_dev *dev, void *data_in,
@@ -157,44 +154,6 @@ int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration) · 117 unmodified lines
157 sizeof(out), MLX5_REG_MLCR, 0, 1);154 sizeof(out), MLX5_REG_MLCR, 0, 1);
158}155}
159 156
160int mlx5_query_port_proto_cap(struct mlx5_core_dev *dev,
161 u32 *proto_cap, int proto_mask)
162{
163 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
164 int err;
165
166 err = mlx5_query_port_ptys(dev, out, sizeof(out), proto_mask, 1);
167 if (err)
168 return err;
169
170 if (proto_mask == MLX5_PTYS_EN)
171 *proto_cap = MLX5_GET(ptys_reg, out, eth_proto_capability);
172 else
173 *proto_cap = MLX5_GET(ptys_reg, out, ib_proto_capability);
174
175 return 0;
176}
177EXPORT_SYMBOL_GPL(mlx5_query_port_proto_cap);
178
179int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
180 u32 *proto_admin, int proto_mask)
181{
182 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
183 int err;
184
185 err = mlx5_query_port_ptys(dev, out, sizeof(out), proto_mask, 1);
186 if (err)
187 return err;
188
189 if (proto_mask == MLX5_PTYS_EN)
190 *proto_admin = MLX5_GET(ptys_reg, out, eth_proto_admin);
191 else
192 *proto_admin = MLX5_GET(ptys_reg, out, ib_proto_admin);
193
194 return 0;
195}
196EXPORT_SYMBOL_GPL(mlx5_query_port_proto_admin);
197
198int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev,157int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev,
199 u8 *link_width_oper, u8 local_port)158 u8 *link_width_oper, u8 local_port)
200{159{
@@ -211,23 +170,6 @@ int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev, · 10 unmodified lines
211}170}
212EXPORT_SYMBOL_GPL(mlx5_query_port_link_width_oper);171EXPORT_SYMBOL_GPL(mlx5_query_port_link_width_oper);
213 172
214int mlx5_query_port_eth_proto_oper(struct mlx5_core_dev *dev,
215 u32 *proto_oper, u8 local_port)
216{
217 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
218 int err;
219
220 err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN,
221 local_port);
222 if (err)
223 return err;
224
225 *proto_oper = MLX5_GET(ptys_reg, out, eth_proto_oper);
226
227 return 0;
228}
229EXPORT_SYMBOL(mlx5_query_port_eth_proto_oper);
230
231int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,173int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,
232 u8 *proto_oper, u8 local_port)174 u8 *proto_oper, u8 local_port)
233{175{
@@ -245,35 +187,6 @@ int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev, · 11 unmodified lines
245}187}
246EXPORT_SYMBOL(mlx5_query_port_ib_proto_oper);188EXPORT_SYMBOL(mlx5_query_port_ib_proto_oper);
247 189
248int mlx5_set_port_ptys(struct mlx5_core_dev *dev, bool an_disable,
249 u32 proto_admin, int proto_mask)
250{
251 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
252 u32 in[MLX5_ST_SZ_DW(ptys_reg)];
253 u8 an_disable_admin;
254 u8 an_disable_cap;
255 u8 an_status;
256
257 mlx5_query_port_autoneg(dev, proto_mask, &an_status,
258 &an_disable_cap, &an_disable_admin);
259 if (!an_disable_cap && an_disable)
260 return -EPERM;
261
262 memset(in, 0, sizeof(in));
263
264 MLX5_SET(ptys_reg, in, local_port, 1);
265 MLX5_SET(ptys_reg, in, an_disable_admin, an_disable);
266 MLX5_SET(ptys_reg, in, proto_mask, proto_mask);
267 if (proto_mask == MLX5_PTYS_EN)
268 MLX5_SET(ptys_reg, in, eth_proto_admin, proto_admin);
269 else
270 MLX5_SET(ptys_reg, in, ib_proto_admin, proto_admin);
271
272 return mlx5_core_access_reg(dev, in, sizeof(in), out,
273 sizeof(out), MLX5_REG_PTYS, 0, 1);
274}
275EXPORT_SYMBOL_GPL(mlx5_set_port_ptys);
276
277/* This function should be used after setting a port register only */190/* This function should be used after setting a port register only */
278void mlx5_toggle_port_link(struct mlx5_core_dev *dev)191void mlx5_toggle_port_link(struct mlx5_core_dev *dev)
279{192{
@@ -606,25 +519,6 @@ int mlx5_query_port_pfc(struct mlx5_core_dev *dev, u8 *pfc_en_tx, u8 *pfc_en_rx) · 326 unmodified lines
606}519}
607EXPORT_SYMBOL_GPL(mlx5_query_port_pfc);520EXPORT_SYMBOL_GPL(mlx5_query_port_pfc);
608 521
609void mlx5_query_port_autoneg(struct mlx5_core_dev *dev, int proto_mask,
610 u8 *an_status,
611 u8 *an_disable_cap, u8 *an_disable_admin)
612{
613 u32 out[MLX5_ST_SZ_DW(ptys_reg)];
614
615 *an_status = 0;
616 *an_disable_cap = 0;
617 *an_disable_admin = 0;
618
619 if (mlx5_query_port_ptys(dev, out, sizeof(out), proto_mask, 1))
620 return;
621
622 *an_status = MLX5_GET(ptys_reg, out, an_status);
623 *an_disable_cap = MLX5_GET(ptys_reg, out, an_disable_cap);
624 *an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin);
625}
626EXPORT_SYMBOL_GPL(mlx5_query_port_autoneg);
627
628int mlx5_max_tc(struct mlx5_core_dev *mdev)522int mlx5_max_tc(struct mlx5_core_dev *mdev)
629{523{
630 u8 num_tc = MLX5_CAP_GEN(mdev, max_tc) ? : 8;524 u8 num_tc = MLX5_CAP_GEN(mdev, max_tc) ? : 8;
drivers/net/ethernet/mellanox/mlx5/core/sriov.c+1−1
@@ -147,7 +147,7 @@ out: · 146 unmodified lines
147 if (MLX5_ESWITCH_MANAGER(dev))147 if (MLX5_ESWITCH_MANAGER(dev))
148 mlx5_eswitch_disable_sriov(dev->priv.eswitch);148 mlx5_eswitch_disable_sriov(dev->priv.eswitch);
149 149
150 if (mlx5_wait_for_vf_pages(dev))150 if (mlx5_wait_for_pages(dev, &dev->priv.vfs_pages))
151 mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");151 mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");
152}152}
153 153
drivers/net/ethernet/mellanox/mlx5/core/vport.c+4−4
@@ -255,7 +255,7 @@ int mlx5_modify_nic_vport_mtu(struct mlx5_core_dev *mdev, u16 mtu) · 254 unmodified lines
255EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mtu);255EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mtu);
256 256
257int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,257int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
258 u32 vport,258 u16 vport,
259 enum mlx5_list_type list_type,259 enum mlx5_list_type list_type,
260 u8 addr_list[][ETH_ALEN],260 u8 addr_list[][ETH_ALEN],
261 int *list_size)261 int *list_size)
@@ -373,7 +373,7 @@ int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev, · 111 unmodified lines
373EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mac_list);373EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_mac_list);
374 374
375int mlx5_query_nic_vport_vlans(struct mlx5_core_dev *dev,375int mlx5_query_nic_vport_vlans(struct mlx5_core_dev *dev,
376 u32 vport,376 u16 vport,
377 u16 vlans[],377 u16 vlans[],
378 int *size)378 int *size)
379{379{
@@ -526,7 +526,7 @@ int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid) · 146 unmodified lines
526EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_node_guid);526EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_node_guid);
527 527
528int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,528int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
529 u32 vport, u64 node_guid)529 u16 vport, u64 node_guid)
530{530{
531 int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);531 int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
532 void *nic_vport_context;532 void *nic_vport_context;
@@ -827,7 +827,7 @@ int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *dev, · 294 unmodified lines
827EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_node_guid);827EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_node_guid);
828 828
829int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,829int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
830 u32 vport,830 u16 vport,
831 int *promisc_uc,831 int *promisc_uc,
832 int *promisc_mc,832 int *promisc_mc,
833 int *promisc_all)833 int *promisc_all)
include/linux/mlx5/device.h+7−2
@@ -67,7 +67,7 @@ · 66 unmodified lines
67#define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)67#define MLX5_UN_SZ_BYTES(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 8)
68#define MLX5_UN_SZ_DW(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 32)68#define MLX5_UN_SZ_DW(typ) (sizeof(union mlx5_ifc_##typ##_bits) / 32)
69#define MLX5_BYTE_OFF(typ, fld) (__mlx5_bit_off(typ, fld) / 8)69#define MLX5_BYTE_OFF(typ, fld) (__mlx5_bit_off(typ, fld) / 8)
70#define MLX5_ADDR_OF(typ, p, fld) ((char *)(p) + MLX5_BYTE_OFF(typ, fld))70#define MLX5_ADDR_OF(typ, p, fld) ((void *)((uint8_t *)(p) + MLX5_BYTE_OFF(typ, fld)))
71 71
72/* insert a value to a struct */72/* insert a value to a struct */
73#define MLX5_SET(typ, p, fld, v) do { \73#define MLX5_SET(typ, p, fld, v) do { \
@@ -342,6 +342,8 @@ enum mlx5_event { · 268 unmodified lines
342 MLX5_EVENT_TYPE_PAGE_FAULT = 0xc,342 MLX5_EVENT_TYPE_PAGE_FAULT = 0xc,
343 MLX5_EVENT_TYPE_NIC_VPORT_CHANGE = 0xd,343 MLX5_EVENT_TYPE_NIC_VPORT_CHANGE = 0xd,
344 344
345 MLX5_EVENT_TYPE_HOST_PARAMS_CHANGE = 0xe,
346
345 MLX5_EVENT_TYPE_DCT_DRAINED = 0x1c,347 MLX5_EVENT_TYPE_DCT_DRAINED = 0x1c,
346 348
347 MLX5_EVENT_TYPE_FPGA_ERROR = 0x20,349 MLX5_EVENT_TYPE_FPGA_ERROR = 0x20,
@@ -591,7 +593,7 @@ struct mlx5_eqe_cmd { · 243 unmodified lines
591};593};
592 594
593struct mlx5_eqe_page_req {595struct mlx5_eqe_page_req {
594 u8 rsvd0[2];596 __be16 ec_function;
595 __be16 func_id;597 __be16 func_id;
596 __be32 num_pages;598 __be32 num_pages;
597 __be32 rsvd1[5];599 __be32 rsvd1[5];
@@ -1201,6 +1203,9 @@ enum mlx5_qcam_feature_groups { · 603 unmodified lines
1201#define MLX5_CAP_ODP(mdev, cap)\1203#define MLX5_CAP_ODP(mdev, cap)\
1202 MLX5_GET(odp_cap, mdev->caps.hca_cur[MLX5_CAP_ODP], cap)1204 MLX5_GET(odp_cap, mdev->caps.hca_cur[MLX5_CAP_ODP], cap)
1203 1205
1206#define MLX5_CAP_ODP_MAX(mdev, cap)\
1207 MLX5_GET(odp_cap, mdev->caps.hca_max[MLX5_CAP_ODP], cap)
1208
1204#define MLX5_CAP_VECTOR_CALC(mdev, cap) \1209#define MLX5_CAP_VECTOR_CALC(mdev, cap) \
1205 MLX5_GET(vector_calc_cap, \1210 MLX5_GET(vector_calc_cap, \
1206 mdev->caps.hca_cur[MLX5_CAP_VECTOR_CALC], cap)1211 mdev->caps.hca_cur[MLX5_CAP_VECTOR_CALC], cap)
include/linux/mlx5/driver.h+47−14
@@ -522,6 +522,7 @@ struct mlx5_priv { · 521 unmodified lines
522 atomic_t reg_pages;522 atomic_t reg_pages;
523 struct list_head free_list;523 struct list_head free_list;
524 int vfs_pages;524 int vfs_pages;
525 int peer_pf_pages;
525 526
526 struct mlx5_core_health health;527 struct mlx5_core_health health;
527 528
@@ -652,6 +653,7 @@ struct mlx5_core_dev { · 124 unmodified lines
652 u32 mcam[MLX5_ST_SZ_DW(mcam_reg)];653 u32 mcam[MLX5_ST_SZ_DW(mcam_reg)];
653 u32 fpga[MLX5_ST_SZ_DW(fpga_cap)];654 u32 fpga[MLX5_ST_SZ_DW(fpga_cap)];
654 u32 qcam[MLX5_ST_SZ_DW(qcam_reg)];655 u32 qcam[MLX5_ST_SZ_DW(qcam_reg)];
656 u8 embedded_cpu;
655 } caps;657 } caps;
656 u64 sys_image_guid;658 u64 sys_image_guid;
657 phys_addr_t iseg_base;659 phys_addr_t iseg_base;
@@ -850,11 +852,30 @@ void mlx5_cmd_cleanup(struct mlx5_core_dev *dev); · 192 unmodified lines
850void mlx5_cmd_use_events(struct mlx5_core_dev *dev);852void mlx5_cmd_use_events(struct mlx5_core_dev *dev);
851void mlx5_cmd_use_polling(struct mlx5_core_dev *dev);853void mlx5_cmd_use_polling(struct mlx5_core_dev *dev);
852 854
855struct mlx5_async_ctx {
856 struct mlx5_core_dev *dev;
857 atomic_t num_inflight;
858 struct wait_queue_head wait;
859};
860
861struct mlx5_async_work;
862
863typedef void (*mlx5_async_cbk_t)(int status, struct mlx5_async_work *context);
864
865struct mlx5_async_work {
866 struct mlx5_async_ctx *ctx;
867 mlx5_async_cbk_t user_callback;
868};
869
870void mlx5_cmd_init_async_ctx(struct mlx5_core_dev *dev,
871 struct mlx5_async_ctx *ctx);
872void mlx5_cmd_cleanup_async_ctx(struct mlx5_async_ctx *ctx);
873int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
874 void *out, int out_size, mlx5_async_cbk_t callback,
875 struct mlx5_async_work *work);
876
853int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,877int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
854 int out_size);878 int out_size);
855int mlx5_cmd_exec_cb(struct mlx5_core_dev *dev, void *in, int in_size,
856 void *out, int out_size, mlx5_cmd_cbk_t callback,
857 void *context);
858int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,879int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
859 void *out, int out_size);880 void *out, int out_size);
860void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);881void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);
@@ -885,9 +906,10 @@ void mlx5_init_mkey_table(struct mlx5_core_dev *dev); · 24 unmodified lines
885void mlx5_cleanup_mkey_table(struct mlx5_core_dev *dev);906void mlx5_cleanup_mkey_table(struct mlx5_core_dev *dev);
886int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,907int mlx5_core_create_mkey_cb(struct mlx5_core_dev *dev,
887 struct mlx5_core_mkey *mkey,908 struct mlx5_core_mkey *mkey,
888 u32 *in, int inlen,909 struct mlx5_async_ctx *async_ctx, u32 *in,
889 u32 *out, int outlen,910 int inlen, u32 *out, int outlen,
890 mlx5_cmd_cbk_t callback, void *context);911 mlx5_async_cbk_t callback,
912 struct mlx5_async_work *context);
891int mlx5_core_create_mkey(struct mlx5_core_dev *dev,913int mlx5_core_create_mkey(struct mlx5_core_dev *dev,
892 struct mlx5_core_mkey *mkey,914 struct mlx5_core_mkey *mkey,
893 u32 *in, int inlen);915 u32 *in, int inlen);
@@ -897,14 +919,12 @@ int mlx5_core_query_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mkey *mkey, · 3 unmodified lines
897 u32 *out, int outlen);919 u32 *out, int outlen);
898int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn);920int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn);
899int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn);921int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn);
900int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
901 u16 opmod, u8 port);
902int mlx5_pagealloc_init(struct mlx5_core_dev *dev);922int mlx5_pagealloc_init(struct mlx5_core_dev *dev);
903void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);923void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
904void mlx5_pagealloc_start(struct mlx5_core_dev *dev);924void mlx5_pagealloc_start(struct mlx5_core_dev *dev);
905void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);925void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
906void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,926void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
907 s32 npages);927 s32 npages, bool ec_function);
908int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);928int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
909int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);929int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
910void mlx5_register_debugfs(void);930void mlx5_register_debugfs(void);
@@ -1058,11 +1078,24 @@ static inline int mlx5_core_is_pf(struct mlx5_core_dev *dev) · 147 unmodified lines
1058 return !(dev->priv.pci_dev_data & MLX5_PCI_DEV_IS_VF);1078 return !(dev->priv.pci_dev_data & MLX5_PCI_DEV_IS_VF);
1059}1079}
1060 1080
1061#define MLX5_TOTAL_VPORTS(mdev) (1 + pci_sriov_get_totalvfs((mdev)->pdev))1081static inline bool mlx5_core_is_ecpf(struct mlx5_core_dev *dev)
1062#define MLX5_VPORT_MANAGER(mdev) \1082{
1063 (MLX5_CAP_GEN(mdev, vport_group_manager) && \1083 return dev->caps.embedded_cpu;
1064 (MLX5_CAP_GEN(mdev, port_type) == MLX5_CAP_PORT_TYPE_ETH) && \1084}
1065 mlx5_core_is_pf(mdev))1085
1086static inline bool mlx5_core_is_ecpf_esw_manager(struct mlx5_core_dev *dev)
1087{
1088 return dev->caps.embedded_cpu && MLX5_CAP_GEN(dev, eswitch_manager);
1089}
1090
1091#define MLX5_HOST_PF_MAX_VFS (127u)
1092static inline u16 mlx5_core_max_vfs(struct mlx5_core_dev *dev)
1093{
1094 if (mlx5_core_is_ecpf_esw_manager(dev))
1095 return MLX5_HOST_PF_MAX_VFS;
1096 else
1097 return pci_sriov_get_totalvfs(dev->pdev);
1098}
1066 1099
1067static inline int mlx5_get_gid_table_len(u16 param)1100static inline int mlx5_get_gid_table_len(u16 param)
1068{1101{
include/linux/mlx5/mlx5_ifc.h+65−11
@@ -72,6 +72,7 @@ enum { · 71 unmodified lines
72 72
73enum {73enum {
74 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE = 0x0,74 MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE = 0x0,
75 MLX5_SET_HCA_CAP_OP_MOD_ODP = 0x2,
75 MLX5_SET_HCA_CAP_OP_MOD_ATOMIC = 0x3,76 MLX5_SET_HCA_CAP_OP_MOD_ATOMIC = 0x3,
76};77};
77 78
@@ -141,6 +142,7 @@ enum { · 63 unmodified lines
141 MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY = 0x725,142 MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY = 0x725,
142 MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY = 0x726,143 MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY = 0x726,
143 MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS = 0x727,144 MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS = 0x727,
145 MLX5_CMD_OP_QUERY_HOST_PARAMS = 0x740,
144 MLX5_CMD_OP_QUERY_VPORT_STATE = 0x750,146 MLX5_CMD_OP_QUERY_VPORT_STATE = 0x750,
145 MLX5_CMD_OP_MODIFY_VPORT_STATE = 0x751,147 MLX5_CMD_OP_MODIFY_VPORT_STATE = 0x751,
146 MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT = 0x752,148 MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT = 0x752,
@@ -831,7 +833,9 @@ struct mlx5_ifc_odp_cap_bits { · 684 unmodified lines
831 833
832 struct mlx5_ifc_odp_per_transport_service_cap_bits ud_odp_caps;834 struct mlx5_ifc_odp_per_transport_service_cap_bits ud_odp_caps;
833 835
834 u8 reserved_at_e0[0x720];836 struct mlx5_ifc_odp_per_transport_service_cap_bits xrc_odp_caps;
837
838 u8 reserved_at_100[0x700];
835};839};
836 840
837struct mlx5_ifc_calc_op {841struct mlx5_ifc_calc_op {
@@ -4438,7 +4442,8 @@ struct mlx5_ifc_query_pages_out_bits { · 3600 unmodified lines
4438 4442
4439 u8 syndrome[0x20];4443 u8 syndrome[0x20];
4440 4444
4441 u8 reserved_at_40[0x10];4445 u8 embedded_cpu_function[0x1];
4446 u8 reserved_at_41[0xf];
4442 u8 function_id[0x10];4447 u8 function_id[0x10];
4443 4448
4444 u8 num_pages[0x20];4449 u8 num_pages[0x20];
@@ -4457,7 +4462,8 @@ struct mlx5_ifc_query_pages_in_bits { · 12 unmodified lines
4457 u8 reserved_at_20[0x10];4462 u8 reserved_at_20[0x10];
4458 u8 op_mod[0x10];4463 u8 op_mod[0x10];
4459 4464
4460 u8 reserved_at_40[0x10];4465 u8 embedded_cpu_function[0x1];
4466 u8 reserved_at_41[0xf];
4461 u8 function_id[0x10];4467 u8 function_id[0x10];
4462 4468
4463 u8 reserved_at_60[0x20];4469 u8 reserved_at_60[0x20];
@@ -5877,7 +5883,8 @@ struct mlx5_ifc_manage_pages_in_bits { · 1413 unmodified lines
5877 u8 reserved_at_20[0x10];5883 u8 reserved_at_20[0x10];
5878 u8 op_mod[0x10];5884 u8 op_mod[0x10];
5879 5885
5880 u8 reserved_at_40[0x10];5886 u8 embedded_cpu_function[0x1];
5887 u8 reserved_at_41[0xf];
5881 u8 function_id[0x10];5888 u8 function_id[0x10];
5882 5889
5883 u8 input_num_entries[0x20];5890 u8 input_num_entries[0x20];
@@ -6055,7 +6062,8 @@ struct mlx5_ifc_enable_hca_in_bits { · 171 unmodified lines
6055 u8 reserved_at_20[0x10];6062 u8 reserved_at_20[0x10];
6056 u8 op_mod[0x10];6063 u8 op_mod[0x10];
6057 6064
6058 u8 reserved_at_40[0x10];6065 u8 embedded_cpu_function[0x1];
6066 u8 reserved_at_41[0xf];
6059 u8 function_id[0x10];6067 u8 function_id[0x10];
6060 6068
6061 u8 reserved_at_60[0x20];6069 u8 reserved_at_60[0x20];
@@ -6099,7 +6107,8 @@ struct mlx5_ifc_disable_hca_in_bits { · 37 unmodified lines
6099 u8 reserved_at_20[0x10];6107 u8 reserved_at_20[0x10];
6100 u8 op_mod[0x10];6108 u8 op_mod[0x10];
6101 6109
6102 u8 reserved_at_40[0x10];6110 u8 embedded_cpu_function[0x1];
6111 u8 reserved_at_41[0xf];
6103 u8 function_id[0x10];6112 u8 function_id[0x10];
6104 6113
6105 u8 reserved_at_60[0x20];6114 u8 reserved_at_60[0x20];
@@ -7817,21 +7826,23 @@ struct mlx5_ifc_ptys_reg_bits { · 1711 unmodified lines
7817 u8 proto_mask[0x3];7826 u8 proto_mask[0x3];
7818 7827
7819 u8 an_status[0x4];7828 u8 an_status[0x4];
7820 u8 reserved_at_24[0x3c];7829 u8 reserved_at_24[0x1c];
7830
7831 u8 ext_eth_proto_capability[0x20];
7821 7832
7822 u8 eth_proto_capability[0x20];7833 u8 eth_proto_capability[0x20];
7823 7834
7824 u8 ib_link_width_capability[0x10];7835 u8 ib_link_width_capability[0x10];
7825 u8 ib_proto_capability[0x10];7836 u8 ib_proto_capability[0x10];
7826 7837
7827 u8 reserved_at_a0[0x20];7838 u8 ext_eth_proto_admin[0x20];
7828 7839
7829 u8 eth_proto_admin[0x20];7840 u8 eth_proto_admin[0x20];
7830 7841
7831 u8 ib_link_width_admin[0x10];7842 u8 ib_link_width_admin[0x10];
7832 u8 ib_proto_admin[0x10];7843 u8 ib_proto_admin[0x10];
7833 7844
7834 u8 reserved_at_100[0x20];7845 u8 ext_eth_proto_oper[0x20];
7835 7846
7836 u8 eth_proto_oper[0x20];7847 u8 eth_proto_oper[0x20];
7837 7848
@@ -8280,7 +8291,9 @@ struct mlx5_ifc_mpegc_reg_bits { · 442 unmodified lines
8280struct mlx5_ifc_pcam_enhanced_features_bits {8291struct mlx5_ifc_pcam_enhanced_features_bits {
8281 u8 reserved_at_0[0x6d];8292 u8 reserved_at_0[0x6d];
8282 u8 rx_icrc_encapsulated_counter[0x1];8293 u8 rx_icrc_encapsulated_counter[0x1];
8283 u8 reserved_at_6e[0x8];8294 u8 reserved_at_6e[0x4];
8295 u8 ptys_extended_ethernet[0x1];
8296 u8 reserved_at_73[0x3];
8284 u8 pfcc_mask[0x1];8297 u8 pfcc_mask[0x1];
8285 u8 reserved_at_77[0x3];8298 u8 reserved_at_77[0x3];
8286 u8 per_lane_error_counters[0x1];8299 u8 per_lane_error_counters[0x1];
@@ -8746,7 +8759,8 @@ struct mlx5_ifc_initial_seg_bits { · 459 unmodified lines
8746 u8 initializing[0x1];8759 u8 initializing[0x1];
8747 u8 reserved_at_fe1[0x4];8760 u8 reserved_at_fe1[0x4];
8748 u8 nic_interface_supported[0x3];8761 u8 nic_interface_supported[0x3];
8749 u8 reserved_at_fe8[0x18];8762 u8 embedded_cpu[0x1];
8763 u8 reserved_at_fe9[0x17];
8750 8764
8751 struct mlx5_ifc_health_buffer_bits health_buffer;8765 struct mlx5_ifc_health_buffer_bits health_buffer;
8752 8766
@@ -9513,4 +9527,44 @@ struct mlx5_ifc_mtrc_ctrl_bits { · 760 unmodified lines
9513 u8 reserved_at_80[0x180];9527 u8 reserved_at_80[0x180];
9514};9528};
9515 9529
9530struct mlx5_ifc_host_params_context_bits {
9531 u8 host_number[0x8];
9532 u8 reserved_at_8[0x8];
9533 u8 host_num_of_vfs[0x10];
9534
9535 u8 reserved_at_20[0x10];
9536 u8 host_pci_bus[0x10];
9537
9538 u8 reserved_at_40[0x10];
9539 u8 host_pci_device[0x10];
9540
9541 u8 reserved_at_60[0x10];
9542 u8 host_pci_function[0x10];
9543
9544 u8 reserved_at_80[0x180];
9545};
9546
9547struct mlx5_ifc_query_host_params_in_bits {
9548 u8 opcode[0x10];
9549 u8 reserved_at_10[0x10];
9550
9551 u8 reserved_at_20[0x10];
9552 u8 op_mod[0x10];
9553
9554 u8 reserved_at_40[0x40];
9555};
9556
9557struct mlx5_ifc_query_host_params_out_bits {
9558 u8 status[0x8];
9559 u8 reserved_at_8[0x18];
9560
9561 u8 syndrome[0x20];
9562
9563 u8 reserved_at_40[0x40];
9564
9565 struct mlx5_ifc_host_params_context_bits host_params_context;
9566
9567 u8 reserved_at_280[0x180];
9568};
9569
9516#endif /* MLX5_IFC_H */9570#endif /* MLX5_IFC_H */
include/linux/mlx5/port.h+19−11
@@ -92,6 +92,22 @@ enum mlx5e_link_mode { · 91 unmodified lines
92 MLX5E_LINK_MODES_NUMBER,92 MLX5E_LINK_MODES_NUMBER,
93};93};
94 94
95enum mlx5e_ext_link_mode {
96 MLX5E_SGMII_100M = 0,
97 MLX5E_1000BASE_X_SGMII = 1,
98 MLX5E_5GBASE_R = 3,
99 MLX5E_10GBASE_XFI_XAUI_1 = 4,
100 MLX5E_40GBASE_XLAUI_4_XLPPI_4 = 5,
101 MLX5E_25GAUI_1_25GBASE_CR_KR = 6,
102 MLX5E_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 = 7,
103 MLX5E_50GAUI_1_LAUI_1_50GBASE_CR_KR = 8,
104 MLX5E_CAUI_4_100GBASE_CR4_KR4 = 9,
105 MLX5E_100GAUI_2_100GBASE_CR2_KR2 = 10,
106 MLX5E_200GAUI_4_200GBASE_CR4_KR4 = 12,
107 MLX5E_400GAUI_8 = 15,
108 MLX5E_EXT_LINK_MODES_NUMBER,
109};
110
95enum mlx5e_connector_type {111enum mlx5e_connector_type {
96 MLX5E_PORT_UNKNOWN = 0,112 MLX5E_PORT_UNKNOWN = 0,
97 MLX5E_PORT_NONE = 1,113 MLX5E_PORT_NONE = 1,
@@ -106,31 +122,23 @@ enum mlx5e_connector_type { · 8 unmodified lines
106};122};
107 123
108#define MLX5E_PROT_MASK(link_mode) (1 << link_mode)124#define MLX5E_PROT_MASK(link_mode) (1 << link_mode)
125#define MLX5_GET_ETH_PROTO(reg, out, ext, field) \
126 (ext ? MLX5_GET(reg, out, ext_##field) : \
127 MLX5_GET(reg, out, field))
109 128
110int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps);129int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps);
111int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,130int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
112 int ptys_size, int proto_mask, u8 local_port);131 int ptys_size, int proto_mask, u8 local_port);
113int mlx5_query_port_proto_cap(struct mlx5_core_dev *dev,
114 u32 *proto_cap, int proto_mask);
115int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
116 u32 *proto_admin, int proto_mask);
117int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev,132int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev,
118 u8 *link_width_oper, u8 local_port);133 u8 *link_width_oper, u8 local_port);
119int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,134int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,
120 u8 *proto_oper, u8 local_port);135 u8 *proto_oper, u8 local_port);
121int mlx5_query_port_eth_proto_oper(struct mlx5_core_dev *dev,
122 u32 *proto_oper, u8 local_port);
123int mlx5_set_port_ptys(struct mlx5_core_dev *dev, bool an_disable,
124 u32 proto_admin, int proto_mask);
125void mlx5_toggle_port_link(struct mlx5_core_dev *dev);136void mlx5_toggle_port_link(struct mlx5_core_dev *dev);
126int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,137int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
127 enum mlx5_port_status status);138 enum mlx5_port_status status);
128int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,139int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,
129 enum mlx5_port_status *status);140 enum mlx5_port_status *status);
130int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration);141int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration);
131void mlx5_query_port_autoneg(struct mlx5_core_dev *dev, int proto_mask,
132 u8 *an_status,
133 u8 *an_disable_cap, u8 *an_disable_admin);
134 142
135int mlx5_set_port_mtu(struct mlx5_core_dev *dev, u16 mtu, u8 port);143int mlx5_set_port_mtu(struct mlx5_core_dev *dev, u16 mtu, u8 port);
136void mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, u16 *max_mtu, u8 port);144void mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, u16 *max_mtu, u8 port);
include/linux/mlx5/vport.h+17−4
@@ -36,12 +36,25 @@ · 35 unmodified lines
36#include <linux/mlx5/driver.h>36#include <linux/mlx5/driver.h>
37#include <linux/mlx5/device.h>37#include <linux/mlx5/device.h>
38 38
39#define MLX5_VPORT_PF_PLACEHOLDER (1u)
40#define MLX5_SPECIAL_VPORTS (MLX5_VPORT_PF_PLACEHOLDER)
41#define MLX5_TOTAL_VPORTS(mdev) (MLX5_SPECIAL_VPORTS + mlx5_core_max_vfs(mdev))
42
43#define MLX5_VPORT_MANAGER(mdev) \
44 (MLX5_CAP_GEN(mdev, vport_group_manager) && \
45 (MLX5_CAP_GEN(mdev, port_type) == MLX5_CAP_PORT_TYPE_ETH) && \
46 mlx5_core_is_pf(mdev))
47
39enum {48enum {
40 MLX5_CAP_INLINE_MODE_L2,49 MLX5_CAP_INLINE_MODE_L2,
41 MLX5_CAP_INLINE_MODE_VPORT_CONTEXT,50 MLX5_CAP_INLINE_MODE_VPORT_CONTEXT,
42 MLX5_CAP_INLINE_MODE_NOT_REQUIRED,51 MLX5_CAP_INLINE_MODE_NOT_REQUIRED,
43};52};
44 53
54enum {
55 MLX5_VPORT_UPLINK = 0xffff
56};
57
45u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport);58u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport);
46int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,59int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
47 u16 vport, u8 state);60 u16 vport, u8 state);
@@ -60,7 +73,7 @@ int mlx5_query_nic_vport_system_image_guid(struct mlx5_core_dev *mdev, · 12 unmodified lines
60 u64 *system_image_guid);73 u64 *system_image_guid);
61int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid);74int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid);
62int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,75int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
63 u32 vport, u64 node_guid);76 u16 vport, u64 node_guid);
64int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,77int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,
65 u16 *qkey_viol_cntr);78 u16 *qkey_viol_cntr);
66int mlx5_query_hca_vport_gid(struct mlx5_core_dev *dev, u8 other_vport,79int mlx5_query_hca_vport_gid(struct mlx5_core_dev *dev, u8 other_vport,
@@ -78,7 +91,7 @@ int mlx5_query_hca_vport_system_image_guid(struct mlx5_core_dev *dev, · 11 unmodified lines
78int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *dev,91int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *dev,
79 u64 *node_guid);92 u64 *node_guid);
80int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,93int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
81 u32 vport,94 u16 vport,
82 enum mlx5_list_type list_type,95 enum mlx5_list_type list_type,
83 u8 addr_list[][ETH_ALEN],96 u8 addr_list[][ETH_ALEN],
84 int *list_size);97 int *list_size);
@@ -87,7 +100,7 @@ int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev, · 2 unmodified lines
87 u8 addr_list[][ETH_ALEN],100 u8 addr_list[][ETH_ALEN],
88 int list_size);101 int list_size);
89int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,102int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
90 u32 vport,103 u16 vport,
91 int *promisc_uc,104 int *promisc_uc,
92 int *promisc_mc,105 int *promisc_mc,
93 int *promisc_all);106 int *promisc_all);
@@ -96,7 +109,7 @@ int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev, · 2 unmodified lines
96 int promisc_mc,109 int promisc_mc,
97 int promisc_all);110 int promisc_all);
98int mlx5_query_nic_vport_vlans(struct mlx5_core_dev *dev,111int mlx5_query_nic_vport_vlans(struct mlx5_core_dev *dev,
99 u32 vport,112 u16 vport,
100 u16 vlans[],113 u16 vlans[],
101 int *size);114 int *size);
102int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,115int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t