Skip to content

Commit c24a65b

Browse files
dmertmananguy11
authored andcommitted
iidc/ice/irdma: Update IDC to support multiple consumers
In preparation of supporting more than a single core PCI driver for RDMA, move ice specific structs like qset_params, qos_info and qos_params from iidc_rdma.h to iidc_rdma_ice.h. Previously, the ice driver was just exporting its entire PF struct to the auxiliary driver, but since each core driver will have its own different PF struct, implement a universal struct that all core drivers can provide to the auxiliary driver through the probe call. Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Dave Ertman <[email protected]> Co-developed-by: Mustafa Ismail <[email protected]> Signed-off-by: Mustafa Ismail <[email protected]> Co-developed-by: Shiraz Saleem <[email protected]> Signed-off-by: Shiraz Saleem <[email protected]> Co-developed-by: Tatyana Nikolova <[email protected]> Signed-off-by: Tatyana Nikolova <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 8239b77 commit c24a65b

File tree

11 files changed

+348
-200
lines changed

11 files changed

+348
-200
lines changed

drivers/infiniband/hw/irdma/main.c

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
22
/* Copyright (c) 2015 - 2021 Intel Corporation */
33
#include "main.h"
4-
#include "../../../net/ethernet/intel/ice/ice.h"
54

65
MODULE_ALIAS("i40iw");
7-
MODULE_AUTHOR("Intel Corporation, <[email protected]>");
86
MODULE_DESCRIPTION("Intel(R) Ethernet Protocol Driver for RDMA");
97
MODULE_LICENSE("Dual BSD/GPL");
108

@@ -85,9 +83,10 @@ static void irdma_fill_qos_info(struct irdma_l2params *l2params,
8583
}
8684
}
8785

88-
static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_rdma_event *event)
86+
static void irdma_iidc_event_handler(struct iidc_rdma_core_dev_info *cdev_info,
87+
struct iidc_rdma_event *event)
8988
{
90-
struct irdma_device *iwdev = dev_get_drvdata(&pf->adev->dev);
89+
struct irdma_device *iwdev = dev_get_drvdata(&cdev_info->adev->dev);
9190
struct irdma_l2params l2params = {};
9291

9392
if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_MTU_CHANGE)) {
@@ -104,17 +103,18 @@ static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_rdma_event *
104103

105104
irdma_prep_tc_change(iwdev);
106105
} else if (*event->type & BIT(IIDC_RDMA_EVENT_AFTER_TC_CHANGE)) {
107-
struct iidc_rdma_qos_params qos_info = {};
106+
struct iidc_rdma_priv_dev_info *iidc_priv = cdev_info->iidc_priv;
108107

109108
if (!iwdev->vsi.tc_change_pending)
110109
return;
111110

112111
l2params.tc_changed = true;
113112
ibdev_dbg(&iwdev->ibdev, "CLNT: TC Change\n");
114-
ice_get_qos_params(pf, &qos_info);
115-
irdma_fill_qos_info(&l2params, &qos_info);
113+
114+
irdma_fill_qos_info(&l2params, &iidc_priv->qos_info);
116115
if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY)
117-
iwdev->dcb_vlan_mode = qos_info.num_tc > 1 && !l2params.dscp_mode;
116+
iwdev->dcb_vlan_mode =
117+
l2params.num_tc > 1 && !l2params.dscp_mode;
118118
irdma_change_l2params(&iwdev->vsi, &l2params);
119119
} else if (*event->type & BIT(IIDC_RDMA_EVENT_CRIT_ERR)) {
120120
ibdev_warn(&iwdev->ibdev, "ICE OICR event notification: oicr = 0x%08x\n",
@@ -151,10 +151,8 @@ static void irdma_iidc_event_handler(struct ice_pf *pf, struct iidc_rdma_event *
151151
*/
152152
static void irdma_request_reset(struct irdma_pci_f *rf)
153153
{
154-
struct ice_pf *pf = rf->cdev;
155-
156154
ibdev_warn(&rf->iwdev->ibdev, "Requesting a reset\n");
157-
ice_rdma_request_reset(pf, IIDC_PFR);
155+
ice_rdma_request_reset(rf->cdev, IIDC_FUNC_RESET);
158156
}
159157

160158
/**
@@ -166,14 +164,15 @@ static int irdma_lan_register_qset(struct irdma_sc_vsi *vsi,
166164
struct irdma_ws_node *tc_node)
167165
{
168166
struct irdma_device *iwdev = vsi->back_vsi;
169-
struct ice_pf *pf = iwdev->rf->cdev;
167+
struct iidc_rdma_core_dev_info *cdev_info;
170168
struct iidc_rdma_qset_params qset = {};
171169
int ret;
172170

171+
cdev_info = iwdev->rf->cdev;
173172
qset.qs_handle = tc_node->qs_handle;
174173
qset.tc = tc_node->traffic_class;
175174
qset.vport_id = vsi->vsi_idx;
176-
ret = ice_add_rdma_qset(pf, &qset);
175+
ret = ice_add_rdma_qset(cdev_info, &qset);
177176
if (ret) {
178177
ibdev_dbg(&iwdev->ibdev, "WS: LAN alloc_res for rdma qset failed.\n");
179178
return ret;
@@ -194,19 +193,20 @@ static void irdma_lan_unregister_qset(struct irdma_sc_vsi *vsi,
194193
struct irdma_ws_node *tc_node)
195194
{
196195
struct irdma_device *iwdev = vsi->back_vsi;
197-
struct ice_pf *pf = iwdev->rf->cdev;
196+
struct iidc_rdma_core_dev_info *cdev_info;
198197
struct iidc_rdma_qset_params qset = {};
199198

199+
cdev_info = iwdev->rf->cdev;
200200
qset.qs_handle = tc_node->qs_handle;
201201
qset.tc = tc_node->traffic_class;
202202
qset.vport_id = vsi->vsi_idx;
203203
qset.teid = tc_node->l2_sched_node_id;
204204

205-
if (ice_del_rdma_qset(pf, &qset))
205+
if (ice_del_rdma_qset(cdev_info, &qset))
206206
ibdev_dbg(&iwdev->ibdev, "WS: LAN free_res for rdma qset failed.\n");
207207
}
208208

209-
static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
209+
static int irdma_init_interrupts(struct irdma_pci_f *rf, struct iidc_rdma_core_dev_info *cdev)
210210
{
211211
int i;
212212

@@ -217,12 +217,12 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
217217
return -ENOMEM;
218218

219219
for (i = 0; i < rf->msix_count; i++)
220-
if (ice_alloc_rdma_qvector(pf, &rf->msix_entries[i]))
220+
if (ice_alloc_rdma_qvector(cdev, &rf->msix_entries[i]))
221221
break;
222222

223223
if (i < IRDMA_MIN_MSIX) {
224224
for (; i > 0; i--)
225-
ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
225+
ice_free_rdma_qvector(cdev, &rf->msix_entries[i]);
226226

227227
kfree(rf->msix_entries);
228228
return -ENOMEM;
@@ -233,12 +233,12 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
233233
return 0;
234234
}
235235

236-
static void irdma_deinit_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
236+
static void irdma_deinit_interrupts(struct irdma_pci_f *rf, struct iidc_rdma_core_dev_info *cdev)
237237
{
238238
int i;
239239

240240
for (i = 0; i < rf->msix_count; i++)
241-
ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
241+
ice_free_rdma_qvector(cdev, &rf->msix_entries[i]);
242242

243243
kfree(rf->msix_entries);
244244
}
@@ -247,41 +247,49 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
247247
{
248248
struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
249249
struct iidc_rdma_core_auxiliary_dev *iidc_adev;
250-
struct ice_pf *pf;
250+
struct iidc_rdma_core_dev_info *cdev_info;
251251

252252
iidc_adev = container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev);
253-
pf = iidc_adev->pf;
253+
cdev_info = iidc_adev->cdev_info;
254254

255+
ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, false);
255256
irdma_ib_unregister_device(iwdev);
256-
ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, false);
257-
irdma_deinit_interrupts(iwdev->rf, pf);
257+
irdma_deinit_interrupts(iwdev->rf, cdev_info);
258258

259-
pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(pf->pdev->devfn));
259+
pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(cdev_info->pdev->devfn));
260260
}
261261

262-
static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf,
263-
struct ice_vsi *vsi)
262+
static void irdma_fill_device_info(struct irdma_device *iwdev,
263+
struct iidc_rdma_core_dev_info *cdev_info)
264264
{
265+
struct iidc_rdma_priv_dev_info *iidc_priv = cdev_info->iidc_priv;
265266
struct irdma_pci_f *rf = iwdev->rf;
266267

267-
rf->cdev = pf;
268+
rf->sc_dev.hw = &rf->hw;
269+
rf->iwdev = iwdev;
270+
rf->cdev = cdev_info;
271+
rf->hw.hw_addr = iidc_priv->hw_addr;
272+
rf->pcidev = cdev_info->pdev;
273+
rf->hw.device = &rf->pcidev->dev;
274+
rf->pf_id = iidc_priv->pf_id;
268275
rf->gen_ops.register_qset = irdma_lan_register_qset;
269276
rf->gen_ops.unregister_qset = irdma_lan_unregister_qset;
270-
rf->hw.hw_addr = pf->hw.hw_addr;
271-
rf->pcidev = pf->pdev;
272-
rf->pf_id = pf->hw.pf_id;
273-
rf->default_vsi.vsi_idx = vsi->vsi_num;
274-
rf->protocol_used = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ?
275-
IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY;
277+
278+
rf->default_vsi.vsi_idx = iidc_priv->vport_id;
279+
rf->protocol_used =
280+
cdev_info->rdma_protocol == IIDC_RDMA_PROTOCOL_ROCEV2 ?
281+
IRDMA_ROCE_PROTOCOL_ONLY : IRDMA_IWARP_PROTOCOL_ONLY;
276282
rf->rdma_ver = IRDMA_GEN_2;
277283
rf->rsrc_profile = IRDMA_HMC_PROFILE_DEFAULT;
278284
rf->rst_to = IRDMA_RST_TIMEOUT_HZ;
279285
rf->gen_ops.request_reset = irdma_request_reset;
280286
rf->limits_sel = 7;
281287
rf->iwdev = iwdev;
288+
282289
mutex_init(&iwdev->ah_tbl_lock);
283-
iwdev->netdev = vsi->netdev;
284-
iwdev->vsi_num = vsi->vsi_num;
290+
291+
iwdev->netdev = iidc_priv->netdev;
292+
iwdev->vsi_num = iidc_priv->vport_id;
285293
iwdev->init_state = INITIAL_STATE;
286294
iwdev->roce_cwnd = IRDMA_ROCE_CWND_DEFAULT;
287295
iwdev->roce_ackcreds = IRDMA_ROCE_ACKCREDS_DEFAULT;
@@ -294,20 +302,17 @@ static void irdma_fill_device_info(struct irdma_device *iwdev, struct ice_pf *pf
294302
static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_device_id *id)
295303
{
296304
struct iidc_rdma_core_auxiliary_dev *iidc_adev;
297-
struct iidc_rdma_qos_params qos_info = {};
305+
struct iidc_rdma_core_dev_info *cdev_info;
306+
struct iidc_rdma_priv_dev_info *iidc_priv;
298307
struct irdma_l2params l2params = {};
299308
struct irdma_device *iwdev;
300309
struct irdma_pci_f *rf;
301-
struct ice_vsi *vsi;
302-
struct ice_pf *pf;
303310
int err;
304311

305312
iidc_adev = container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev);
306-
pf = iidc_adev->pf;
307-
vsi = ice_get_main_vsi(pf);
313+
cdev_info = iidc_adev->cdev_info;
314+
iidc_priv = cdev_info->iidc_priv;
308315

309-
if (!vsi)
310-
return -EIO;
311316
iwdev = ib_alloc_device(irdma_device, ibdev);
312317
if (!iwdev)
313318
return -ENOMEM;
@@ -317,10 +322,10 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
317322
return -ENOMEM;
318323
}
319324

320-
irdma_fill_device_info(iwdev, pf, vsi);
325+
irdma_fill_device_info(iwdev, cdev_info);
321326
rf = iwdev->rf;
322327

323-
err = irdma_init_interrupts(rf, pf);
328+
err = irdma_init_interrupts(rf, cdev_info);
324329
if (err)
325330
goto err_init_interrupts;
326331

@@ -329,8 +334,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
329334
goto err_ctrl_init;
330335

331336
l2params.mtu = iwdev->netdev->mtu;
332-
ice_get_qos_params(pf, &qos_info);
333-
irdma_fill_qos_info(&l2params, &qos_info);
337+
irdma_fill_qos_info(&l2params, &iidc_priv->qos_info);
334338
if (iwdev->rf->protocol_used != IRDMA_IWARP_PROTOCOL_ONLY)
335339
iwdev->dcb_vlan_mode = l2params.num_tc > 1 && !l2params.dscp_mode;
336340

@@ -342,7 +346,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
342346
if (err)
343347
goto err_ibreg;
344348

345-
ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, true);
349+
ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, true);
346350

347351
ibdev_dbg(&iwdev->ibdev, "INIT: Gen2 PF[%d] device probe success\n", PCI_FUNC(rf->pcidev->devfn));
348352
auxiliary_set_drvdata(aux_dev, iwdev);
@@ -354,7 +358,7 @@ static int irdma_probe(struct auxiliary_device *aux_dev, const struct auxiliary_
354358
err_rt_init:
355359
irdma_ctrl_deinit_hw(rf);
356360
err_ctrl_init:
357-
irdma_deinit_interrupts(rf, pf);
361+
irdma_deinit_interrupts(rf, cdev_info);
358362
err_init_interrupts:
359363
kfree(iwdev->rf);
360364
ib_dealloc_device(&iwdev->ibdev);

drivers/infiniband/hw/irdma/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#endif
3131
#include <linux/auxiliary_bus.h>
3232
#include <linux/net/intel/iidc_rdma.h>
33+
#include <linux/net/intel/iidc_rdma_ice.h>
3334
#include <rdma/ib_smi.h>
3435
#include <rdma/ib_verbs.h>
3536
#include <rdma/ib_pack.h>

drivers/net/ethernet/intel/ice/devlink/devlink.c

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,13 @@ ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
13391339
struct devlink_param_gset_ctx *ctx)
13401340
{
13411341
struct ice_pf *pf = devlink_priv(devlink);
1342+
struct iidc_rdma_core_dev_info *cdev;
13421343

1343-
ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2 ? true : false;
1344+
cdev = pf->cdev_info;
1345+
if (!cdev)
1346+
return -ENODEV;
1347+
1348+
ctx->val.vbool = !!(cdev->rdma_protocol & IIDC_RDMA_PROTOCOL_ROCEV2);
13441349

13451350
return 0;
13461351
}
@@ -1350,19 +1355,24 @@ static int ice_devlink_enable_roce_set(struct devlink *devlink, u32 id,
13501355
struct netlink_ext_ack *extack)
13511356
{
13521357
struct ice_pf *pf = devlink_priv(devlink);
1358+
struct iidc_rdma_core_dev_info *cdev;
13531359
bool roce_ena = ctx->val.vbool;
13541360
int ret;
13551361

1362+
cdev = pf->cdev_info;
1363+
if (!cdev)
1364+
return -ENODEV;
1365+
13561366
if (!roce_ena) {
13571367
ice_unplug_aux_dev(pf);
1358-
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_ROCEV2;
1368+
cdev->rdma_protocol &= ~IIDC_RDMA_PROTOCOL_ROCEV2;
13591369
return 0;
13601370
}
13611371

1362-
pf->rdma_mode |= IIDC_RDMA_PROTOCOL_ROCEV2;
1372+
cdev->rdma_protocol |= IIDC_RDMA_PROTOCOL_ROCEV2;
13631373
ret = ice_plug_aux_dev(pf);
13641374
if (ret)
1365-
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_ROCEV2;
1375+
cdev->rdma_protocol &= ~IIDC_RDMA_PROTOCOL_ROCEV2;
13661376

13671377
return ret;
13681378
}
@@ -1373,11 +1383,16 @@ ice_devlink_enable_roce_validate(struct devlink *devlink, u32 id,
13731383
struct netlink_ext_ack *extack)
13741384
{
13751385
struct ice_pf *pf = devlink_priv(devlink);
1386+
struct iidc_rdma_core_dev_info *cdev;
1387+
1388+
cdev = pf->cdev_info;
1389+
if (!cdev)
1390+
return -ENODEV;
13761391

13771392
if (!test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
13781393
return -EOPNOTSUPP;
13791394

1380-
if (pf->rdma_mode & IIDC_RDMA_PROTOCOL_IWARP) {
1395+
if (cdev->rdma_protocol & IIDC_RDMA_PROTOCOL_IWARP) {
13811396
NL_SET_ERR_MSG_MOD(extack, "iWARP is currently enabled. This device cannot enable iWARP and RoCEv2 simultaneously");
13821397
return -EOPNOTSUPP;
13831398
}
@@ -1390,8 +1405,13 @@ ice_devlink_enable_iw_get(struct devlink *devlink, u32 id,
13901405
struct devlink_param_gset_ctx *ctx)
13911406
{
13921407
struct ice_pf *pf = devlink_priv(devlink);
1408+
struct iidc_rdma_core_dev_info *cdev;
13931409

1394-
ctx->val.vbool = pf->rdma_mode & IIDC_RDMA_PROTOCOL_IWARP;
1410+
cdev = pf->cdev_info;
1411+
if (!cdev)
1412+
return -ENODEV;
1413+
1414+
ctx->val.vbool = !!(cdev->rdma_protocol & IIDC_RDMA_PROTOCOL_IWARP);
13951415

13961416
return 0;
13971417
}
@@ -1401,19 +1421,24 @@ static int ice_devlink_enable_iw_set(struct devlink *devlink, u32 id,
14011421
struct netlink_ext_ack *extack)
14021422
{
14031423
struct ice_pf *pf = devlink_priv(devlink);
1424+
struct iidc_rdma_core_dev_info *cdev;
14041425
bool iw_ena = ctx->val.vbool;
14051426
int ret;
14061427

1428+
cdev = pf->cdev_info;
1429+
if (!cdev)
1430+
return -ENODEV;
1431+
14071432
if (!iw_ena) {
14081433
ice_unplug_aux_dev(pf);
1409-
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_IWARP;
1434+
cdev->rdma_protocol &= ~IIDC_RDMA_PROTOCOL_IWARP;
14101435
return 0;
14111436
}
14121437

1413-
pf->rdma_mode |= IIDC_RDMA_PROTOCOL_IWARP;
1438+
cdev->rdma_protocol |= IIDC_RDMA_PROTOCOL_IWARP;
14141439
ret = ice_plug_aux_dev(pf);
14151440
if (ret)
1416-
pf->rdma_mode &= ~IIDC_RDMA_PROTOCOL_IWARP;
1441+
cdev->rdma_protocol &= ~IIDC_RDMA_PROTOCOL_IWARP;
14171442

14181443
return ret;
14191444
}
@@ -1428,7 +1453,7 @@ ice_devlink_enable_iw_validate(struct devlink *devlink, u32 id,
14281453
if (!test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
14291454
return -EOPNOTSUPP;
14301455

1431-
if (pf->rdma_mode & IIDC_RDMA_PROTOCOL_ROCEV2) {
1456+
if (pf->cdev_info->rdma_protocol & IIDC_RDMA_PROTOCOL_ROCEV2) {
14321457
NL_SET_ERR_MSG_MOD(extack, "RoCEv2 is currently enabled. This device cannot enable iWARP and RoCEv2 simultaneously");
14331458
return -EOPNOTSUPP;
14341459
}

0 commit comments

Comments
 (0)