Skip to content

Commit cc4db57

Browse files
Igor LeshenkoSaeed Mahameed
authored andcommitted
net/mlx5: FPGA, support network cards with standalone FPGA
Not all mlx5 cards with FPGA device use it for network processing. mlx5_core driver configures network connection to FPGA device for all mlx5 cards with installed FPGA. If FPGA is not a part of network path, driver crashes in this case Check FPGA name in function mlx5_fpga_device_start() and continue integrate FPGA into packets flow only for dedicated cards. Currently there are Newton and Edison cards. Signed-off-by: Igor Leshenko <[email protected]> Reviewed-by: Meir Lichtinger <[email protected]> Reviewed-by: Boris Pismenny <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 40416d8 commit cc4db57

File tree

2 files changed

+46
-25
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/fpga

2 files changed

+46
-25
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fpga/cmd.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535

3636
#include <linux/mlx5/driver.h>
3737

38-
enum mlx5_fpga_device_id {
39-
MLX5_FPGA_DEVICE_UNKNOWN = 0,
40-
MLX5_FPGA_DEVICE_KU040 = 1,
41-
MLX5_FPGA_DEVICE_KU060 = 2,
42-
MLX5_FPGA_DEVICE_KU060_2 = 3,
38+
enum mlx5_fpga_id {
39+
MLX5_FPGA_NEWTON = 0,
40+
MLX5_FPGA_EDISON = 1,
41+
MLX5_FPGA_MORSE = 2,
42+
MLX5_FPGA_MORSEQ = 3,
4343
};
4444

4545
enum mlx5_fpga_image {

drivers/net/ethernet/mellanox/mlx5/core/fpga/core.c

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,28 @@ static const char *mlx5_fpga_image_name(enum mlx5_fpga_image image)
8181
}
8282
}
8383

84-
static const char *mlx5_fpga_device_name(u32 device)
84+
static const char *mlx5_fpga_name(u32 fpga_id)
8585
{
86-
switch (device) {
87-
case MLX5_FPGA_DEVICE_KU040:
88-
return "ku040";
89-
case MLX5_FPGA_DEVICE_KU060:
90-
return "ku060";
91-
case MLX5_FPGA_DEVICE_KU060_2:
92-
return "ku060_2";
93-
case MLX5_FPGA_DEVICE_UNKNOWN:
94-
default:
95-
return "unknown";
86+
static char ret[32];
87+
88+
switch (fpga_id) {
89+
case MLX5_FPGA_NEWTON:
90+
return "Newton";
91+
case MLX5_FPGA_EDISON:
92+
return "Edison";
93+
case MLX5_FPGA_MORSE:
94+
return "Morse";
95+
case MLX5_FPGA_MORSEQ:
96+
return "MorseQ";
9697
}
98+
99+
snprintf(ret, sizeof(ret), "Unknown %d", fpga_id);
100+
return ret;
101+
}
102+
103+
static int mlx5_is_fpga_lookaside(u32 fpga_id)
104+
{
105+
return fpga_id != MLX5_FPGA_NEWTON && fpga_id != MLX5_FPGA_EDISON;
97106
}
98107

99108
static int mlx5_fpga_device_load_check(struct mlx5_fpga_device *fdev)
@@ -110,8 +119,12 @@ static int mlx5_fpga_device_load_check(struct mlx5_fpga_device *fdev)
110119
fdev->last_admin_image = query.admin_image;
111120
fdev->last_oper_image = query.oper_image;
112121

113-
mlx5_fpga_dbg(fdev, "Status %u; Admin image %u; Oper image %u\n",
114-
query.status, query.admin_image, query.oper_image);
122+
mlx5_fpga_info(fdev, "Status %u; Admin image %u; Oper image %u\n",
123+
query.status, query.admin_image, query.oper_image);
124+
125+
/* for FPGA lookaside projects FPGA load status is not important */
126+
if (mlx5_is_fpga_lookaside(MLX5_CAP_FPGA(fdev->mdev, fpga_id)))
127+
return 0;
115128

116129
if (query.status != MLX5_FPGA_STATUS_SUCCESS) {
117130
mlx5_fpga_err(fdev, "%s image failed to load; status %u\n",
@@ -167,25 +180,30 @@ int mlx5_fpga_device_start(struct mlx5_core_dev *mdev)
167180
struct mlx5_fpga_device *fdev = mdev->fpga;
168181
unsigned int max_num_qps;
169182
unsigned long flags;
170-
u32 fpga_device_id;
183+
u32 fpga_id;
171184
int err;
172185

173186
if (!fdev)
174187
return 0;
175188

176-
err = mlx5_fpga_device_load_check(fdev);
189+
err = mlx5_fpga_caps(fdev->mdev);
177190
if (err)
178191
goto out;
179192

180-
err = mlx5_fpga_caps(fdev->mdev);
193+
err = mlx5_fpga_device_load_check(fdev);
181194
if (err)
182195
goto out;
183196

184-
fpga_device_id = MLX5_CAP_FPGA(fdev->mdev, fpga_device);
185-
mlx5_fpga_info(fdev, "%s:%u; %s image, version %u; SBU %06x:%04x version %d\n",
186-
mlx5_fpga_device_name(fpga_device_id),
187-
fpga_device_id,
197+
fpga_id = MLX5_CAP_FPGA(fdev->mdev, fpga_id);
198+
mlx5_fpga_info(fdev, "FPGA card %s:%u\n", mlx5_fpga_name(fpga_id), fpga_id);
199+
200+
/* No QPs if FPGA does not participate in net processing */
201+
if (mlx5_is_fpga_lookaside(fpga_id))
202+
goto out;
203+
204+
mlx5_fpga_info(fdev, "%s(%d): image, version %u; SBU %06x:%04x version %d\n",
188205
mlx5_fpga_image_name(fdev->last_oper_image),
206+
fdev->last_oper_image,
189207
MLX5_CAP_FPGA(fdev->mdev, image_version),
190208
MLX5_CAP_FPGA(fdev->mdev, ieee_vendor_id),
191209
MLX5_CAP_FPGA(fdev->mdev, sandbox_product_id),
@@ -264,6 +282,9 @@ void mlx5_fpga_device_stop(struct mlx5_core_dev *mdev)
264282
if (!fdev)
265283
return;
266284

285+
if (mlx5_is_fpga_lookaside(MLX5_CAP_FPGA(fdev->mdev, fpga_id)))
286+
return;
287+
267288
spin_lock_irqsave(&fdev->state_lock, flags);
268289
if (fdev->state != MLX5_FPGA_STATUS_SUCCESS) {
269290
spin_unlock_irqrestore(&fdev->state_lock, flags);

0 commit comments

Comments
 (0)