Skip to content

Commit 194fad5

Browse files
vikasbrcmkuba-moo
authored andcommitted
bnxt_en: Refactor bnxt_rdma_aux_device_init/uninit functions
In its current form, bnxt_rdma_aux_device_init() not only initializes the necessary data structures of the newly created aux device but also adds the aux device into the aux bus subsytem. Refactor the logic into separate functions, first function to initialize the aux device along with the required resources and second, to actually add the device to the aux bus subsytem. This separation helps to create bnxt_en_dev much earlier and save its resources separately. Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://lore.kernel.org/r/20240409215431.41424-5-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b58f5a9 commit 194fad5

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14786,10 +14786,13 @@ static void bnxt_remove_one(struct pci_dev *pdev)
1478614786
if (BNXT_PF(bp))
1478714787
bnxt_sriov_disable(bp);
1478814788

14789-
bnxt_rdma_aux_device_uninit(bp);
14789+
bnxt_rdma_aux_device_del(bp);
1479014790

1479114791
bnxt_ptp_clear(bp);
1479214792
unregister_netdev(dev);
14793+
14794+
bnxt_rdma_aux_device_uninit(bp);
14795+
1479314796
bnxt_free_l2_filters(bp, true);
1479414797
bnxt_free_ntp_fltrs(bp, true);
1479514798
if (BNXT_SUPPORTS_MULTI_RSS_CTX(bp))
@@ -15408,20 +15411,23 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1540815411
if (BNXT_SUPPORTS_NTUPLE_VNIC(bp))
1540915412
bnxt_init_multi_rss_ctx(bp);
1541015413

15414+
bnxt_rdma_aux_device_init(bp);
15415+
1541115416
rc = register_netdev(dev);
1541215417
if (rc)
1541315418
goto init_err_cleanup;
1541415419

1541515420
bnxt_dl_fw_reporters_create(bp);
1541615421

15417-
bnxt_rdma_aux_device_init(bp);
15422+
bnxt_rdma_aux_device_add(bp);
1541815423

1541915424
bnxt_print_device_info(bp);
1542015425

1542115426
pci_save_state(pdev);
1542215427

1542315428
return 0;
1542415429
init_err_cleanup:
15430+
bnxt_rdma_aux_device_uninit(bp);
1542515431
bnxt_dl_unregister(bp);
1542615432
init_err_dl:
1542715433
bnxt_shutdown_tc(bp);

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ void bnxt_rdma_aux_device_uninit(struct bnxt *bp)
291291

292292
aux_priv = bp->aux_priv;
293293
adev = &aux_priv->aux_dev;
294-
auxiliary_device_delete(adev);
295294
auxiliary_device_uninit(adev);
296295
}
297296

@@ -309,6 +308,14 @@ static void bnxt_aux_dev_release(struct device *dev)
309308
bp->aux_priv = NULL;
310309
}
311310

311+
void bnxt_rdma_aux_device_del(struct bnxt *bp)
312+
{
313+
if (!bp->edev)
314+
return;
315+
316+
auxiliary_device_delete(&bp->aux_priv->aux_dev);
317+
}
318+
312319
static void bnxt_set_edev_info(struct bnxt_en_dev *edev, struct bnxt *bp)
313320
{
314321
edev->net = bp->dev;
@@ -332,6 +339,23 @@ static void bnxt_set_edev_info(struct bnxt_en_dev *edev, struct bnxt *bp)
332339
edev->ulp_tbl->msix_requested = bnxt_get_ulp_msix_num(bp);
333340
}
334341

342+
void bnxt_rdma_aux_device_add(struct bnxt *bp)
343+
{
344+
struct auxiliary_device *aux_dev;
345+
int rc;
346+
347+
if (!bp->edev)
348+
return;
349+
350+
aux_dev = &bp->aux_priv->aux_dev;
351+
rc = auxiliary_device_add(aux_dev);
352+
if (rc) {
353+
netdev_warn(bp->dev, "Failed to add auxiliary device for ROCE\n");
354+
auxiliary_device_uninit(aux_dev);
355+
bp->flags &= ~BNXT_FLAG_ROCE_CAP;
356+
}
357+
}
358+
335359
void bnxt_rdma_aux_device_init(struct bnxt *bp)
336360
{
337361
struct auxiliary_device *aux_dev;
@@ -386,13 +410,6 @@ void bnxt_rdma_aux_device_init(struct bnxt *bp)
386410
bp->edev = edev;
387411
bnxt_set_edev_info(edev, bp);
388412

389-
rc = auxiliary_device_add(aux_dev);
390-
if (rc) {
391-
netdev_warn(bp->dev,
392-
"Failed to add auxiliary device for ROCE\n");
393-
goto aux_dev_uninit;
394-
}
395-
396413
return;
397414

398415
aux_dev_uninit:

drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ void bnxt_ulp_irq_stop(struct bnxt *bp);
103103
void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
104104
void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
105105
void bnxt_rdma_aux_device_uninit(struct bnxt *bp);
106+
void bnxt_rdma_aux_device_del(struct bnxt *bp);
107+
void bnxt_rdma_aux_device_add(struct bnxt *bp);
106108
void bnxt_rdma_aux_device_init(struct bnxt *bp);
107109
int bnxt_register_dev(struct bnxt_en_dev *edev, struct bnxt_ulp_ops *ulp_ops,
108110
void *handle);

0 commit comments

Comments
 (0)