Skip to content

Commit f2281c2

Browse files
committed
Merge tag 'mlx5-updates-2019-02-15' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== Support Mellanox BlueField SmartNIC (mlx5-updates-2019-02-15) Bodong Wang says, BlueField device is a multi-core ARM processor in a highly integrated system on chip coupled with the ConnectX interconnect controller. BlueField device can be presented in one out of two modes: - SEPARATED_HOST: ARM processors as a separated and orthogonal host like any other external host in the multi-host virtualization model. - EMBEDDED_CPU: ARM processors as Embedded CPU (EC) and part of the external hosts virtualization model. While existing driver already supports the device on separated_host mode, this patch series focus on the functionalities of embedded_cpu mode. On embedded_cpu mode, BlueField device exposes regular network controller PCI function in the BlueField host(e.g, x86). However, a separate PCI function called Embedded CPU Physical Function(ECPF) is also added to the ARM host side, where standard Linux distributions is able to run on the ARM cores. Depends on the NV configuration from firmware, ECPF can be the e-switch manager and firmware pages supplier. If ECPF is configured as e-switch manager and page supplier, it will take over the responsibilities from the PF on BlueField host includes: - Owns, controls and manages all e-switch parts, and takes e-switch traffic by default. It also should perform ENABLE_HCA for the host PF just like a PF does for its VFs. - Provides and manages the ICM host memory required for the HCA to store various contexts for itself, the PF and VFs belong the e-switch it manages. The PF on BlueField host side is still responsible for: - Control its own permanent MAC. - PCI and SRIOV configurations and perform ENABLE_HCA for its VFs. The ECPF can also retrieve information about the external host it controls, like host identifier, PCI BDF and number of virtual functions. As these parameters may be changed dynamically, an event will be triggered to the driver on ECPF side. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents bb015f2 + c96692f commit f2281c2

38 files changed

Lines changed: 1450 additions & 659 deletions

‎drivers/infiniband/hw/mlx5/cmd.c‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,40 @@ int mlx5_cmd_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id,
345345
counter_set_id);
346346
return err;
347347
}
348+
349+
int 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+
380+
out:
381+
kfree(out);
382+
kfree(in);
383+
return err;
384+
}

‎drivers/infiniband/hw/mlx5/cmd.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ int mlx5_cmd_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn, u16 uid);
6363
int mlx5_cmd_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn, u16 uid);
6464
int mlx5_cmd_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id,
6565
u16 uid);
66+
int mlx5_cmd_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb,
67+
u16 opmod, u8 port);
6668
#endif /* MLX5_IB_CMD_H */

‎drivers/infiniband/hw/mlx5/ib_rep.c‎

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
* Copyright (c) 2018 Mellanox Technologies. All rights reserved.
44
*/
55

6+
#include <linux/mlx5/vport.h>
67
#include "ib_rep.h"
78
#include "srq.h"
89

9-
static const struct mlx5_ib_profile rep_profile = {
10+
static const struct mlx5_ib_profile vf_rep_profile = {
1011
STAGE_CREATE(MLX5_IB_STAGE_INIT,
1112
mlx5_ib_stage_init_init,
1213
mlx5_ib_stage_init_cleanup),
@@ -45,31 +46,17 @@ static const struct mlx5_ib_profile rep_profile = {
4546
NULL),
4647
};
4748

48-
static int
49-
mlx5_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-
59-
static void
60-
mlx5_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-
6849
static int
6950
mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
7051
{
52+
const struct mlx5_ib_profile *profile;
7153
struct mlx5_ib_dev *ibdev;
7254

55+
if (rep->vport == MLX5_VPORT_UPLINK)
56+
profile = &uplink_rep_profile;
57+
else
58+
profile = &vf_rep_profile;
59+
7360
ibdev = (struct mlx5_ib_dev *)ib_alloc_device(sizeof(*ibdev));
7461
if (!ibdev)
7562
return -ENOMEM;
@@ -78,7 +65,7 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
7865
ibdev->mdev = dev;
7966
ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports),
8067
MLX5_CAP_GEN(dev, num_vhca_ports));
81-
if (!__mlx5_ib_add(ibdev, &rep_profile))
68+
if (!__mlx5_ib_add(ibdev, profile))
8269
return -EINVAL;
8370

8471
rep->rep_if[REP_IB].priv = ibdev;
@@ -105,53 +92,23 @@ static void *mlx5_ib_vport_get_proto_dev(struct mlx5_eswitch_rep *rep)
10592
return mlx5_ib_rep_to_dev(rep);
10693
}
10794

108-
static void mlx5_ib_rep_register_vf_vports(struct mlx5_ib_dev *dev)
109-
{
110-
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
111-
int total_vfs = MLX5_TOTAL_VPORTS(dev->mdev);
112-
int vport;
113-
114-
for (vport = 1; vport < total_vfs; vport++) {
115-
struct mlx5_eswitch_rep_if rep_if = {};
116-
117-
rep_if.load = mlx5_ib_vport_rep_load;
118-
rep_if.unload = mlx5_ib_vport_rep_unload;
119-
rep_if.get_proto_dev = mlx5_ib_vport_get_proto_dev;
120-
mlx5_eswitch_register_vport_rep(esw, vport, &rep_if, REP_IB);
121-
}
122-
}
123-
124-
static void mlx5_ib_rep_unregister_vf_vports(struct mlx5_ib_dev *dev)
95+
void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev)
12596
{
126-
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
127-
int total_vfs = MLX5_TOTAL_VPORTS(dev->mdev);
128-
int vport;
129-
130-
for (vport = 1; vport < total_vfs; vport++)
131-
mlx5_eswitch_unregister_vport_rep(esw, vport, REP_IB);
132-
}
133-
134-
void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev)
135-
{
136-
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
97+
struct mlx5_eswitch *esw = mdev->priv.eswitch;
13798
struct mlx5_eswitch_rep_if rep_if = {};
13899

139-
rep_if.load = mlx5_ib_nic_rep_load;
140-
rep_if.unload = mlx5_ib_nic_rep_unload;
100+
rep_if.load = mlx5_ib_vport_rep_load;
101+
rep_if.unload = mlx5_ib_vport_rep_unload;
141102
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);
145103

146-
mlx5_ib_rep_register_vf_vports(dev);
104+
mlx5_eswitch_register_vport_reps(esw, &rep_if, REP_IB);
147105
}
148106

149-
void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev)
107+
void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev)
150108
{
151-
struct mlx5_eswitch *esw = dev->mdev->priv.eswitch;
109+
struct mlx5_eswitch *esw = mdev->priv.eswitch;
152110

153-
mlx5_ib_rep_unregister_vf_vports(dev); /* VFs vports */
154-
mlx5_eswitch_unregister_vport_rep(esw, 0, REP_IB); /* UPLINK PF*/
111+
mlx5_eswitch_unregister_vport_reps(esw, REP_IB);
155112
}
156113

157114
u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw)

‎drivers/infiniband/hw/mlx5/ib_rep.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
#include "mlx5_ib.h"
1111

1212
#ifdef CONFIG_MLX5_ESWITCH
13+
extern const struct mlx5_ib_profile uplink_rep_profile;
14+
1315
u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw);
1416
struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw,
1517
int vport_index);
1618
struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw);
1719
struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw,
1820
int vport_index);
19-
void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev);
20-
void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev);
21+
void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev);
22+
void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev);
2123
int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
2224
struct mlx5_ib_sq *sq);
2325
struct 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,
4850
return NULL;
4951
}
5052

51-
static inline void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev) {}
52-
static inline void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev) {}
53+
static inline void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev) {}
54+
static inline void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev) {}
5355
static inline int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev,
5456
struct mlx5_ib_sq *sq)
5557
{

‎drivers/infiniband/hw/mlx5/mad.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <rdma/ib_smi.h>
3737
#include <rdma/ib_pma.h>
3838
#include "mlx5_ib.h"
39+
#include "cmd.h"
3940

4041
enum {
4142
MLX5_IB_VENDOR_CLASS1 = 0x9,
@@ -51,9 +52,10 @@ static bool can_do_mad_ifc(struct mlx5_ib_dev *dev, u8 port_num,
5152
return dev->mdev->port_caps[port_num - 1].has_smi;
5253
}
5354

54-
int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
55-
u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
56-
const void *in_mad, void *response_mad)
55+
static int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey,
56+
int ignore_bkey, u8 port, const struct ib_wc *in_wc,
57+
const struct ib_grh *in_grh, const void *in_mad,
58+
void *response_mad)
5759
{
5860
u8 op_modifier = 0;
5961

@@ -68,7 +70,8 @@ int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
6870
if (ignore_bkey || !in_wc)
6971
op_modifier |= 0x2;
7072

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);
7275
}
7376

7477
static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,

0 commit comments

Comments
 (0)