Skip to content

Commit 4a04a31

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5: SD, Introduce SD lib
Add Socket-Direct API with empty/minimal implementation. We fill-in the implementation gradually in downstream patches. Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent e04984a commit 4a04a31

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en/rqt.o en/tir.o en/rss.o en/rx_res.o \
2929
en/reporter_tx.o en/reporter_rx.o en/params.o en/xsk/pool.o \
3030
en/xsk/setup.o en/xsk/rx.o en/xsk/tx.o en/devlink.o en/ptp.o \
3131
en/qos.o en/htb.o en/trap.o en/fs_tt_redirect.o en/selq.o \
32-
lib/crypto.o
32+
lib/crypto.o lib/sd.o
3333

3434
#
3535
# Netdev extra

drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,15 @@ static inline struct net_device *mlx5_uplink_netdev_get(struct mlx5_core_dev *md
5454
{
5555
return mdev->mlx5e_res.uplink_netdev;
5656
}
57+
58+
struct mlx5_sd;
59+
60+
static inline struct mlx5_sd *mlx5_get_sd(struct mlx5_core_dev *dev)
61+
{
62+
return NULL;
63+
}
64+
65+
static inline void mlx5_set_sd(struct mlx5_core_dev *dev, struct mlx5_sd *sd)
66+
{
67+
}
5768
#endif
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2+
/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3+
4+
#include "lib/sd.h"
5+
#include "mlx5_core.h"
6+
7+
#define sd_info(__dev, format, ...) \
8+
dev_info((__dev)->device, "Socket-Direct: " format, ##__VA_ARGS__)
9+
#define sd_warn(__dev, format, ...) \
10+
dev_warn((__dev)->device, "Socket-Direct: " format, ##__VA_ARGS__)
11+
12+
struct mlx5_sd {
13+
};
14+
15+
static int mlx5_sd_get_host_buses(struct mlx5_core_dev *dev)
16+
{
17+
return 1;
18+
}
19+
20+
struct mlx5_core_dev *
21+
mlx5_sd_primary_get_peer(struct mlx5_core_dev *primary, int idx)
22+
{
23+
if (idx == 0)
24+
return primary;
25+
26+
return NULL;
27+
}
28+
29+
int mlx5_sd_ch_ix_get_dev_ix(struct mlx5_core_dev *dev, int ch_ix)
30+
{
31+
return ch_ix % mlx5_sd_get_host_buses(dev);
32+
}
33+
34+
int mlx5_sd_ch_ix_get_vec_ix(struct mlx5_core_dev *dev, int ch_ix)
35+
{
36+
return ch_ix / mlx5_sd_get_host_buses(dev);
37+
}
38+
39+
struct mlx5_core_dev *mlx5_sd_ch_ix_get_dev(struct mlx5_core_dev *primary, int ch_ix)
40+
{
41+
int mdev_idx = mlx5_sd_ch_ix_get_dev_ix(primary, ch_ix);
42+
43+
return mlx5_sd_primary_get_peer(primary, mdev_idx);
44+
}
45+
46+
int mlx5_sd_init(struct mlx5_core_dev *dev)
47+
{
48+
return 0;
49+
}
50+
51+
void mlx5_sd_cleanup(struct mlx5_core_dev *dev)
52+
{
53+
}
54+
55+
struct auxiliary_device *mlx5_sd_get_adev(struct mlx5_core_dev *dev,
56+
struct auxiliary_device *adev,
57+
int idx)
58+
{
59+
return adev;
60+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2+
/* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3+
4+
#ifndef __MLX5_LIB_SD_H__
5+
#define __MLX5_LIB_SD_H__
6+
7+
#define MLX5_SD_MAX_GROUP_SZ 2
8+
9+
struct mlx5_sd;
10+
11+
struct mlx5_core_dev *mlx5_sd_primary_get_peer(struct mlx5_core_dev *primary, int idx);
12+
int mlx5_sd_ch_ix_get_dev_ix(struct mlx5_core_dev *dev, int ch_ix);
13+
int mlx5_sd_ch_ix_get_vec_ix(struct mlx5_core_dev *dev, int ch_ix);
14+
struct mlx5_core_dev *mlx5_sd_ch_ix_get_dev(struct mlx5_core_dev *primary, int ch_ix);
15+
struct auxiliary_device *mlx5_sd_get_adev(struct mlx5_core_dev *dev,
16+
struct auxiliary_device *adev,
17+
int idx);
18+
19+
int mlx5_sd_init(struct mlx5_core_dev *dev);
20+
void mlx5_sd_cleanup(struct mlx5_core_dev *dev);
21+
22+
#define mlx5_sd_for_each_dev_from_to(i, primary, ix_from, to, pos) \
23+
for (i = ix_from; \
24+
(pos = mlx5_sd_primary_get_peer(primary, i)) && pos != (to); i++)
25+
26+
#define mlx5_sd_for_each_dev(i, primary, pos) \
27+
mlx5_sd_for_each_dev_from_to(i, primary, 0, NULL, pos)
28+
29+
#define mlx5_sd_for_each_dev_to(i, primary, to, pos) \
30+
mlx5_sd_for_each_dev_from_to(i, primary, 0, to, pos)
31+
32+
#define mlx5_sd_for_each_secondary(i, primary, pos) \
33+
mlx5_sd_for_each_dev_from_to(i, primary, 1, NULL, pos)
34+
35+
#define mlx5_sd_for_each_secondary_to(i, primary, to, pos) \
36+
mlx5_sd_for_each_dev_from_to(i, primary, 1, to, pos)
37+
38+
#endif /* __MLX5_LIB_SD_H__ */

0 commit comments

Comments
 (0)