Skip to content

Commit 693dfd5

Browse files
Erez Shitritdledford
authored andcommitted
IB/mlx5: Enable IPoIB acceleration
Enable mlx5 IPoIB acceleration by declaring mlx5_ib_{alloc,free}_rdma_netdev and assigning the mlx5 IPoIB rdma_netdev callbacks. In addition, this patch brings in sync mlx5's IPoIB parts for net and IB trees. As a precaution, we disabled IPoIB acceleration by default (in the mlx5_core Kconfig file). Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Erez Shitrit <erezsh@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 4ac4d58 commit 693dfd5

File tree

5 files changed

+70
-19
lines changed

5 files changed

+70
-19
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,6 +3530,26 @@ static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
35303530
return num_counters;
35313531
}
35323532

3533+
static struct net_device*
3534+
mlx5_ib_alloc_rdma_netdev(struct ib_device *hca,
3535+
u8 port_num,
3536+
enum rdma_netdev_t type,
3537+
const char *name,
3538+
unsigned char name_assign_type,
3539+
void (*setup)(struct net_device *))
3540+
{
3541+
if (type != RDMA_NETDEV_IPOIB)
3542+
return ERR_PTR(-EOPNOTSUPP);
3543+
3544+
return mlx5_rdma_netdev_alloc(to_mdev(hca)->mdev, hca,
3545+
name, setup);
3546+
}
3547+
3548+
static void mlx5_ib_free_rdma_netdev(struct net_device *netdev)
3549+
{
3550+
return mlx5_rdma_netdev_free(netdev);
3551+
}
3552+
35333553
static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
35343554
{
35353555
struct mlx5_ib_dev *dev;
@@ -3660,6 +3680,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
36603680
dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status;
36613681
dev->ib_dev.get_port_immutable = mlx5_port_immutable;
36623682
dev->ib_dev.get_dev_fw_str = get_dev_fw_str;
3683+
dev->ib_dev.alloc_rdma_netdev = mlx5_ib_alloc_rdma_netdev;
3684+
dev->ib_dev.free_rdma_netdev = mlx5_ib_free_rdma_netdev;
36633685
if (mlx5_core_is_pf(mdev)) {
36643686
dev->ib_dev.get_vf_config = mlx5_ib_get_vf_config;
36653687
dev->ib_dev.set_vf_link_state = mlx5_ib_set_vf_link_state;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ config MLX5_CORE_EN_DCB
3535
config MLX5_CORE_IPOIB
3636
bool "Mellanox Technologies ConnectX-4 IPoIB offloads support"
3737
depends on MLX5_CORE_EN
38-
default y
38+
default n
3939
---help---
4040
MLX5 IPoIB offloads & acceleration support.

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* SOFTWARE.
3131
*/
3232

33+
#include <rdma/ib_verbs.h>
3334
#include <linux/mlx5/fs.h>
3435
#include "en.h"
3536
#include "ipoib.h"
@@ -359,10 +360,10 @@ static int mlx5i_close(struct net_device *netdev)
359360
return 0;
360361
}
361362

362-
#ifdef notusedyet
363363
/* IPoIB RDMA netdev callbacks */
364364
static int mlx5i_attach_mcast(struct net_device *netdev, struct ib_device *hca,
365-
union ib_gid *gid, u16 lid, int set_qkey)
365+
union ib_gid *gid, u16 lid, int set_qkey,
366+
u32 qkey)
366367
{
367368
struct mlx5e_priv *epriv = mlx5i_epriv(netdev);
368369
struct mlx5_core_dev *mdev = epriv->mdev;
@@ -375,6 +376,12 @@ static int mlx5i_attach_mcast(struct net_device *netdev, struct ib_device *hca,
375376
mlx5_core_warn(mdev, "failed attaching QPN 0x%x, MGID %pI6\n",
376377
ipriv->qp.qpn, gid->raw);
377378

379+
if (set_qkey) {
380+
mlx5_core_dbg(mdev, "%s setting qkey 0x%x\n",
381+
netdev->name, qkey);
382+
ipriv->qkey = qkey;
383+
}
384+
378385
return err;
379386
}
380387

@@ -397,15 +404,15 @@ static int mlx5i_detach_mcast(struct net_device *netdev, struct ib_device *hca,
397404
}
398405

399406
static int mlx5i_xmit(struct net_device *dev, struct sk_buff *skb,
400-
struct ib_ah *address, u32 dqpn, u32 dqkey)
407+
struct ib_ah *address, u32 dqpn)
401408
{
402409
struct mlx5e_priv *epriv = mlx5i_epriv(dev);
403410
struct mlx5e_txqsq *sq = epriv->txq2sq[skb_get_queue_mapping(skb)];
404411
struct mlx5_ib_ah *mah = to_mah(address);
412+
struct mlx5i_priv *ipriv = epriv->ppriv;
405413

406-
return mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, dqkey);
414+
return mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey);
407415
}
408-
#endif
409416

410417
static int mlx5i_check_required_hca_cap(struct mlx5_core_dev *mdev)
411418
{
@@ -414,22 +421,23 @@ static int mlx5i_check_required_hca_cap(struct mlx5_core_dev *mdev)
414421

415422
if (!MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads)) {
416423
mlx5_core_warn(mdev, "IPoIB enhanced offloads are not supported\n");
417-
return -ENOTSUPP;
424+
return -EOPNOTSUPP;
418425
}
419426

420427
return 0;
421428
}
422429

423-
static struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
424-
struct ib_device *ibdev,
425-
const char *name,
426-
void (*setup)(struct net_device *))
430+
struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
431+
struct ib_device *ibdev,
432+
const char *name,
433+
void (*setup)(struct net_device *))
427434
{
428435
const struct mlx5e_profile *profile = &mlx5i_nic_profile;
429436
int nch = profile->max_nch(mdev);
430437
struct net_device *netdev;
431438
struct mlx5i_priv *ipriv;
432439
struct mlx5e_priv *epriv;
440+
struct rdma_netdev *rn;
433441
int err;
434442

435443
if (mlx5i_check_required_hca_cap(mdev)) {
@@ -464,13 +472,13 @@ static struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
464472
mlx5e_attach_netdev(epriv);
465473
netif_carrier_off(netdev);
466474

467-
/* TODO: set rdma_netdev func pointers
468-
* rn = &ipriv->rn;
469-
* rn->hca = ibdev;
470-
* rn->send = mlx5i_xmit;
471-
* rn->attach_mcast = mlx5i_attach_mcast;
472-
* rn->detach_mcast = mlx5i_detach_mcast;
473-
*/
475+
/* set rdma_netdev func pointers */
476+
rn = &ipriv->rn;
477+
rn->hca = ibdev;
478+
rn->send = mlx5i_xmit;
479+
rn->attach_mcast = mlx5i_attach_mcast;
480+
rn->detach_mcast = mlx5i_detach_mcast;
481+
474482
return netdev;
475483

476484
err_free_netdev:
@@ -482,7 +490,7 @@ static struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
482490
}
483491
EXPORT_SYMBOL(mlx5_rdma_netdev_alloc);
484492

485-
static void mlx5_rdma_netdev_free(struct net_device *netdev)
493+
void mlx5_rdma_netdev_free(struct net_device *netdev)
486494
{
487495
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
488496
const struct mlx5e_profile *profile = priv->profile;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
/* ipoib rdma netdev's private data structure */
4242
struct mlx5i_priv {
43+
struct rdma_netdev rn; /* keep this first */
4344
struct mlx5_core_qp qp;
45+
u32 qkey;
4446
char *mlx5e_priv[0];
4547
};
4648

include/linux/mlx5/driver.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,25 @@ struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);
11021102
struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev);
11031103
void mlx5_put_uars_page(struct mlx5_core_dev *mdev, struct mlx5_uars_page *up);
11041104

1105+
#ifndef CONFIG_MLX5_CORE_IPOIB
1106+
static inline
1107+
struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
1108+
struct ib_device *ibdev,
1109+
const char *name,
1110+
void (*setup)(struct net_device *))
1111+
{
1112+
return ERR_PTR(-EOPNOTSUPP);
1113+
}
1114+
1115+
static inline void mlx5_rdma_netdev_free(struct net_device *netdev) {}
1116+
#else
1117+
struct net_device *mlx5_rdma_netdev_alloc(struct mlx5_core_dev *mdev,
1118+
struct ib_device *ibdev,
1119+
const char *name,
1120+
void (*setup)(struct net_device *));
1121+
void mlx5_rdma_netdev_free(struct net_device *netdev);
1122+
#endif /* CONFIG_MLX5_CORE_IPOIB */
1123+
11051124
struct mlx5_profile {
11061125
u64 mask;
11071126
u8 log_max_qp;

0 commit comments

Comments
 (0)