Skip to content

Commit 2ad49ae

Browse files
mustafakismailrleon
authored andcommitted
RDMA/irdma: Introduce GEN3 vPort driver support
In the IPU model, a function can host one or more logical network endpoints called vPorts. Each vPort may be associated with either a physical or an internal communication port, and can be RDMA capable. A vPort features a netdev and, if RDMA capable, must have an associated ib_dev. This change introduces a GEN3 auxiliary vPort driver responsible for registering a verbs device for every RDMA-capable vPort. Additionally, the UAPI is updated to prevent the binding of GEN3 devices to older user-space providers. Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com> Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com> Link: https://patch.msgid.link/20250827152545.2056-8-tatyana.e.nikolova@intel.com Tested-by: Jacob Moroni <jmoroni@google.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent da278cb commit 2ad49ae

4 files changed

Lines changed: 132 additions & 1 deletion

File tree

drivers/infiniband/hw/irdma/main.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
22
/* Copyright (c) 2015 - 2021 Intel Corporation */
33
#include "main.h"
4+
#include <linux/net/intel/iidc_rdma_idpf.h>
45

56
MODULE_ALIAS("i40iw");
67
MODULE_DESCRIPTION("Intel(R) Ethernet Protocol Driver for RDMA");
@@ -46,6 +47,113 @@ void irdma_log_invalid_mtu(u16 mtu, struct irdma_sc_dev *dev)
4647
ibdev_warn(to_ibdev(dev), "MTU setting [%d] too low for RDMA traffic. Minimum MTU is 1280 for IPv6\\n", mtu);
4748
}
4849

50+
static void ig3rdma_idc_vport_event_handler(struct iidc_rdma_vport_dev_info *cdev_info,
51+
struct iidc_rdma_event *event)
52+
{
53+
struct irdma_device *iwdev = auxiliary_get_drvdata(cdev_info->adev);
54+
struct irdma_l2params l2params = {};
55+
56+
if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_MTU_CHANGE)) {
57+
ibdev_dbg(&iwdev->ibdev, "CLNT: new MTU = %d\n", iwdev->netdev->mtu);
58+
if (iwdev->vsi.mtu != iwdev->netdev->mtu) {
59+
l2params.mtu = iwdev->netdev->mtu;
60+
l2params.mtu_changed = true;
61+
irdma_log_invalid_mtu(l2params.mtu, &iwdev->rf->sc_dev);
62+
irdma_change_l2params(&iwdev->vsi, &l2params);
63+
}
64+
}
65+
}
66+
67+
static int ig3rdma_vport_probe(struct auxiliary_device *aux_dev,
68+
const struct auxiliary_device_id *id)
69+
{
70+
struct iidc_rdma_vport_auxiliary_dev *idc_adev =
71+
container_of(aux_dev, struct iidc_rdma_vport_auxiliary_dev, adev);
72+
struct auxiliary_device *aux_core_dev = idc_adev->vdev_info->core_adev;
73+
struct irdma_pci_f *rf = auxiliary_get_drvdata(aux_core_dev);
74+
struct irdma_l2params l2params = {};
75+
struct irdma_device *iwdev;
76+
int err;
77+
78+
if (!rf) {
79+
WARN_ON_ONCE(1);
80+
return -ENOMEM;
81+
}
82+
iwdev = ib_alloc_device(irdma_device, ibdev);
83+
/* Fill iwdev info */
84+
iwdev->is_vport = true;
85+
iwdev->rf = rf;
86+
iwdev->vport_id = idc_adev->vdev_info->vport_id;
87+
iwdev->netdev = idc_adev->vdev_info->netdev;
88+
iwdev->init_state = INITIAL_STATE;
89+
iwdev->roce_cwnd = IRDMA_ROCE_CWND_DEFAULT;
90+
iwdev->roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT;
91+
iwdev->rcv_wnd = IRDMA_CM_DEFAULT_RCV_WND_SCALED;
92+
iwdev->rcv_wscale = IRDMA_CM_DEFAULT_RCV_WND_SCALE;
93+
iwdev->roce_mode = true;
94+
iwdev->push_mode = false;
95+
96+
l2params.mtu = iwdev->netdev->mtu;
97+
98+
err = irdma_rt_init_hw(iwdev, &l2params);
99+
if (err)
100+
goto err_rt_init;
101+
102+
err = irdma_ib_register_device(iwdev);
103+
if (err)
104+
goto err_ibreg;
105+
106+
auxiliary_set_drvdata(aux_dev, iwdev);
107+
108+
ibdev_dbg(&iwdev->ibdev,
109+
"INIT: Gen[%d] vport[%d] probe success. dev_name = %s, core_dev_name = %s, netdev=%s\n",
110+
rf->rdma_ver, idc_adev->vdev_info->vport_id,
111+
dev_name(&aux_dev->dev),
112+
dev_name(&idc_adev->vdev_info->core_adev->dev),
113+
netdev_name(idc_adev->vdev_info->netdev));
114+
115+
return 0;
116+
err_ibreg:
117+
irdma_rt_deinit_hw(iwdev);
118+
err_rt_init:
119+
ib_dealloc_device(&iwdev->ibdev);
120+
121+
return err;
122+
}
123+
124+
static void ig3rdma_vport_remove(struct auxiliary_device *aux_dev)
125+
{
126+
struct iidc_rdma_vport_auxiliary_dev *idc_adev =
127+
container_of(aux_dev, struct iidc_rdma_vport_auxiliary_dev, adev);
128+
struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
129+
130+
ibdev_dbg(&iwdev->ibdev,
131+
"INIT: Gen[%d] dev_name = %s, core_dev_name = %s, netdev=%s\n",
132+
iwdev->rf->rdma_ver, dev_name(&aux_dev->dev),
133+
dev_name(&idc_adev->vdev_info->core_adev->dev),
134+
netdev_name(idc_adev->vdev_info->netdev));
135+
136+
irdma_ib_unregister_device(iwdev);
137+
}
138+
139+
static const struct auxiliary_device_id ig3rdma_vport_auxiliary_id_table[] = {
140+
{.name = "idpf.8086.rdma.vdev", },
141+
{},
142+
};
143+
144+
MODULE_DEVICE_TABLE(auxiliary, ig3rdma_vport_auxiliary_id_table);
145+
146+
static struct iidc_rdma_vport_auxiliary_drv ig3rdma_vport_auxiliary_drv = {
147+
.adrv = {
148+
.name = "vdev",
149+
.id_table = ig3rdma_vport_auxiliary_id_table,
150+
.probe = ig3rdma_vport_probe,
151+
.remove = ig3rdma_vport_remove,
152+
},
153+
.event_handler = ig3rdma_idc_vport_event_handler,
154+
};
155+
156+
49157
static int __init irdma_init_module(void)
50158
{
51159
int ret;
@@ -74,6 +182,17 @@ static int __init irdma_init_module(void)
74182

75183
return ret;
76184
}
185+
186+
ret = auxiliary_driver_register(&ig3rdma_vport_auxiliary_drv.adrv);
187+
if (ret) {
188+
auxiliary_driver_unregister(&ig3rdma_core_auxiliary_drv.adrv);
189+
auxiliary_driver_unregister(&icrdma_core_auxiliary_drv.adrv);
190+
auxiliary_driver_unregister(&i40iw_auxiliary_drv);
191+
pr_err("Failed ig3rdma vport auxiliary_driver_register() ret=%d\n",
192+
ret);
193+
194+
return ret;
195+
}
77196
irdma_register_notifiers();
78197

79198
return 0;
@@ -85,6 +204,7 @@ static void __exit irdma_exit_module(void)
85204
auxiliary_driver_unregister(&icrdma_core_auxiliary_drv.adrv);
86205
auxiliary_driver_unregister(&i40iw_auxiliary_drv);
87206
auxiliary_driver_unregister(&ig3rdma_core_auxiliary_drv.adrv);
207+
auxiliary_driver_unregister(&ig3rdma_vport_auxiliary_drv.adrv);
88208
}
89209

90210
module_init(irdma_init_module);

drivers/infiniband/hw/irdma/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,14 @@ struct irdma_device {
354354
u32 rcv_wnd;
355355
u16 mac_ip_table_idx;
356356
u16 vsi_num;
357+
u16 vport_id;
357358
u8 rcv_wscale;
358359
u8 iw_status;
359360
bool roce_mode:1;
360361
bool roce_dcqcn_en:1;
361362
bool dcb_vlan_mode:1;
362363
bool iw_ooo:1;
364+
bool is_vport:1;
363365
enum init_completion_state init_state;
364366

365367
wait_queue_head_t suspend_wq;

drivers/infiniband/hw/irdma/verbs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ static int irdma_alloc_ucontext(struct ib_ucontext *uctx,
292292
ucontext->iwdev = iwdev;
293293
ucontext->abi_ver = req.userspace_ver;
294294

295+
if (!(req.comp_mask & IRDMA_SUPPORT_WQE_FORMAT_V2) &&
296+
uk_attrs->hw_rev >= IRDMA_GEN_3)
297+
return -EOPNOTSUPP;
298+
295299
if (req.comp_mask & IRDMA_ALLOC_UCTX_USE_RAW_ATTR)
296300
ucontext->use_raw_attrs = true;
297301

@@ -4891,5 +4895,9 @@ void irdma_ib_dealloc_device(struct ib_device *ibdev)
48914895
struct irdma_device *iwdev = to_iwdev(ibdev);
48924896

48934897
irdma_rt_deinit_hw(iwdev);
4894-
irdma_ctrl_deinit_hw(iwdev->rf);
4898+
if (!iwdev->is_vport) {
4899+
irdma_ctrl_deinit_hw(iwdev->rf);
4900+
if (iwdev->rf->vchnl_wq)
4901+
destroy_workqueue(iwdev->rf->vchnl_wq);
4902+
}
48954903
}

include/uapi/rdma/irdma-abi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ enum irdma_memreg_type {
2525
enum {
2626
IRDMA_ALLOC_UCTX_USE_RAW_ATTR = 1 << 0,
2727
IRDMA_ALLOC_UCTX_MIN_HW_WQ_SIZE = 1 << 1,
28+
IRDMA_SUPPORT_WQE_FORMAT_V2 = 1 << 3,
2829
};
2930

3031
struct irdma_alloc_ucontext_req {

0 commit comments

Comments
 (0)