Skip to content

Commit 48935bb

Browse files
Saeed Mahameeddavem330
authored andcommitted
net/mlx5e: IPoIB, Add netdevice profile skeleton
Create mlx5e IPoIB netdevice profile skeleton in the new ipoib.c file with empty implementation. Downstream patches will provide the full mlx5 rdma netdevice acceleration support for IPoIB into this new file, by using the mlx5e netdevice profile and new mlx5_channels APIs and infrastructures. Same as already done in mlx5e NIC netdevice and switchdev mode VF representors. Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Erez Shitrit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2c3b5be commit 48935bb

File tree

6 files changed

+249
-9
lines changed

6 files changed

+249
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ config MLX5_CORE_EN_DCB
3131
This flag is depended on the kernel's DCB support.
3232

3333
If unsure, set to Y
34+
35+
config MLX5_CORE_IPOIB
36+
bool "Mellanox Technologies ConnectX-4 IPoIB offloads support"
37+
depends on MLX5_CORE_EN
38+
default y
39+
---help---
40+
MLX5 IPoIB offloads & acceleration support.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += wq.o eswitch.o eswitch_offloads.o \
1111
en_tc.o en_arfs.o en_rep.o en_fs_ethtool.o en_selftest.o
1212

1313
mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o
14+
15+
mlx5_core-$(CONFIG_MLX5_CORE_IPOIB) += ipoib.o

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/timecounter.h>
3838
#include <linux/net_tstamp.h>
3939
#include <linux/ptp_clock_kernel.h>
40+
#include <linux/crash_dump.h>
4041
#include <linux/mlx5/driver.h>
4142
#include <linux/mlx5/qp.h>
4243
#include <linux/mlx5/cq.h>
@@ -153,6 +154,14 @@ static inline int mlx5_max_log_rq_size(int wq_type)
153154
}
154155
}
155156

157+
static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
158+
{
159+
return is_kdump_kernel() ?
160+
MLX5E_MIN_NUM_CHANNELS :
161+
min_t(int, mdev->priv.eq_table.num_comp_vectors,
162+
MLX5E_MAX_NUM_CHANNELS);
163+
}
164+
156165
struct mlx5e_tx_wqe {
157166
struct mlx5_wqe_ctrl_seg ctrl;
158167
struct mlx5_wqe_eth_seg eth;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
*/
3232

3333
#include <net/tc_act/tc_gact.h>
34-
#include <linux/crash_dump.h>
3534
#include <net/pkt_cls.h>
3635
#include <linux/mlx5/fs.h>
3736
#include <net/vxlan.h>
@@ -1710,14 +1709,6 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
17101709
return err;
17111710
}
17121711

1713-
static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
1714-
{
1715-
return is_kdump_kernel() ?
1716-
MLX5E_MIN_NUM_CHANNELS :
1717-
min_t(int, mdev->priv.eq_table.num_comp_vectors,
1718-
MLX5E_MAX_NUM_CHANNELS);
1719-
}
1720-
17211712
static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
17221713
struct mlx5e_params *params,
17231714
struct mlx5e_channel_param *cparam,
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
* Copyright (c) 2017, 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/mlx5/fs.h>
34+
#include "en.h"
35+
#include "ipoib.h"
36+
37+
/* IPoIB mlx5 netdev profile */
38+
39+
/* Called directly after IPoIB netdevice was created to initialize SW structs */
40+
static void mlx5i_init(struct mlx5_core_dev *mdev,
41+
struct net_device *netdev,
42+
const struct mlx5e_profile *profile,
43+
void *ppriv)
44+
{
45+
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
46+
47+
priv->ppriv = ppriv;
48+
/* TODO: init netdev and mlx5e_params here */
49+
}
50+
51+
/* Called directly before IPoIB netdevice is destroyed to cleanup SW structs */
52+
static void mlx5i_cleanup(struct mlx5e_priv *priv)
53+
{
54+
/* Do nothing .. */
55+
}
56+
57+
static int mlx5i_init_tx(struct mlx5e_priv *priv)
58+
{
59+
/* TODO: Create IPoIB underlay QP */
60+
/* TODO: create IPoIB TX HW TIS */
61+
return 0;
62+
}
63+
64+
static void mlx5i_cleanup_tx(struct mlx5e_priv *priv)
65+
{
66+
}
67+
68+
static int mlx5i_init_rx(struct mlx5e_priv *priv)
69+
{
70+
/* TODO: create IPoIB RX HW steering contexts */
71+
return 0;
72+
}
73+
74+
static void mlx5i_cleanup_rx(struct mlx5e_priv *priv)
75+
{
76+
}
77+
78+
static const struct mlx5e_profile mlx5i_nic_profile = {
79+
.init = mlx5i_init,
80+
.cleanup = mlx5i_cleanup,
81+
.init_tx = mlx5i_init_tx,
82+
.cleanup_tx = mlx5i_cleanup_tx,
83+
.init_rx = mlx5i_init_rx,
84+
.cleanup_rx = mlx5i_cleanup_rx,
85+
.enable = NULL, /* mlx5i_enable */
86+
.disable = NULL, /* mlx5i_disable */
87+
.update_stats = NULL, /* mlx5i_update_stats */
88+
.max_nch = mlx5e_get_max_num_channels,
89+
.max_tc = MLX5I_MAX_NUM_TC,
90+
};
91+
92+
/* IPoIB RDMA netdev callbacks */
93+
94+
static int mlx5i_check_required_hca_cap(struct mlx5_core_dev *mdev)
95+
{
96+
if (MLX5_CAP_GEN(mdev, port_type) != MLX5_CAP_PORT_TYPE_IB)
97+
return -EOPNOTSUPP;
98+
99+
if (!MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads)) {
100+
mlx5_core_warn(mdev, "IPoIB enhanced offloads are not supported\n");
101+
return -ENOTSUPP;
102+
}
103+
104+
return 0;
105+
}
106+
107+
struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
108+
struct ib_device *ibdev,
109+
const char *name,
110+
void (*setup)(struct net_device *))
111+
{
112+
const struct mlx5e_profile *profile = &mlx5i_nic_profile;
113+
int nch = profile->max_nch(mdev);
114+
struct net_device *netdev;
115+
struct mlx5i_priv *ipriv;
116+
struct mlx5e_priv *epriv;
117+
int err;
118+
119+
if (mlx5i_check_required_hca_cap(mdev)) {
120+
mlx5_core_warn(mdev, "Accelerated mode is not supported\n");
121+
return ERR_PTR(-EOPNOTSUPP);
122+
}
123+
124+
/* This function should only be called once per mdev */
125+
err = mlx5e_create_mdev_resources(mdev);
126+
if (err)
127+
return NULL;
128+
129+
netdev = alloc_netdev_mqs(sizeof(struct mlx5i_priv) + sizeof(struct mlx5e_priv),
130+
name, NET_NAME_UNKNOWN,
131+
setup,
132+
nch * MLX5E_MAX_NUM_TC,
133+
nch);
134+
if (!netdev) {
135+
mlx5_core_warn(mdev, "alloc_netdev_mqs failed\n");
136+
goto free_mdev_resources;
137+
}
138+
139+
ipriv = netdev_priv(netdev);
140+
epriv = mlx5i_epriv(netdev);
141+
142+
epriv->wq = create_singlethread_workqueue("mlx5i");
143+
if (!epriv->wq)
144+
goto err_free_netdev;
145+
146+
profile->init(mdev, netdev, profile, ipriv);
147+
148+
mlx5e_attach_netdev(epriv);
149+
netif_carrier_off(netdev);
150+
151+
/* TODO: set rdma_netdev func pointers
152+
* rn = &ipriv->rn;
153+
* rn->hca = ibdev;
154+
* rn->send = mlx5i_xmit;
155+
* rn->attach_mcast = mlx5i_attach_mcast;
156+
* rn->detach_mcast = mlx5i_detach_mcast;
157+
*/
158+
return netdev;
159+
160+
free_mdev_resources:
161+
mlx5e_destroy_mdev_resources(mdev);
162+
err_free_netdev:
163+
free_netdev(netdev);
164+
return NULL;
165+
}
166+
EXPORT_SYMBOL(mlx5_rdma_netdev_alloc);
167+
168+
void mlx5_rdma_netdev_free(struct net_device *netdev)
169+
{
170+
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
171+
const struct mlx5e_profile *profile = priv->profile;
172+
173+
mlx5e_detach_netdev(priv);
174+
profile->cleanup(priv);
175+
destroy_workqueue(priv->wq);
176+
free_netdev(netdev);
177+
178+
mlx5e_destroy_mdev_resources(priv->mdev);
179+
}
180+
EXPORT_SYMBOL(mlx5_rdma_netdev_free);
181+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2017, 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+
#ifndef __MLX5E_IPOB_H__
34+
#define __MLX5E_IPOB_H__
35+
36+
#include <linux/mlx5/fs.h>
37+
#include "en.h"
38+
39+
#define MLX5I_MAX_NUM_TC 1
40+
41+
/* ipoib rdma netdev's private data structure */
42+
struct mlx5i_priv {
43+
struct mlx5_core_qp qp;
44+
char *mlx5e_priv[0];
45+
};
46+
47+
/* Extract mlx5e_priv from IPoIB netdev */
48+
#define mlx5i_epriv(netdev) ((void *)(((struct mlx5i_priv *)netdev_priv(netdev))->mlx5e_priv))
49+
50+
#endif /* __MLX5E_IPOB_H__ */

0 commit comments

Comments
 (0)