All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com>
Cc: shannon.nelson@amd.com, brett.creeley@amd.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, corbet@lwn.net, jgg@ziepe.ca, leon@kernel.org,
	andrew+netdev@lunn.ch, allen.hubbe@amd.com,
	nikhil.agarwal@amd.com, linux-rdma@vger.kernel.org,
	netdev@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, Andrew Boyer <andrew.boyer@amd.com>
Subject: Re: [PATCH v2 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter
Date: Thu, 8 May 2025 14:53:05 +0530	[thread overview]
Message-ID: <86be353f-4255-ca71-82db-4aa77331dcfb@amd.com> (raw)
In-Reply-To: <CAH-L+nM86KduwFfEUDdGOSx865Dq=YHaVfUZU8GRqb2C3tq7dQ@mail.gmail.com>


On 5/8/25 13:06, Kalesh Anakkur Purayil wrote:
> On Thu, May 8, 2025 at 10:33 AM Abhijit Gangurde
> <abhijit.gangurde@amd.com> wrote:
>> Register auxiliary module to create ibdevice for ionic
>> ethernet adapter.
>>
>> Co-developed-by: Andrew Boyer <andrew.boyer@amd.com>
>> Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
>> Co-developed-by: Allen Hubbe <allen.hubbe@amd.com>
>> Signed-off-by: Allen Hubbe <allen.hubbe@amd.com>
>> Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
>> ---
>> v1->v2
>>    - Removed netdev references from ionic RDMA driver
>>    - Moved to ionic_lif* instead of void* to convey information between
>>      aux devices and drivers.
>>
>>   drivers/infiniband/hw/ionic/ionic_ibdev.c   | 135 ++++++++++++++++++++
>>   drivers/infiniband/hw/ionic/ionic_ibdev.h   |  21 +++
>>   drivers/infiniband/hw/ionic/ionic_lif_cfg.c | 121 ++++++++++++++++++
>>   drivers/infiniband/hw/ionic/ionic_lif_cfg.h |  65 ++++++++++
>>   4 files changed, 342 insertions(+)
>>   create mode 100644 drivers/infiniband/hw/ionic/ionic_ibdev.c
>>   create mode 100644 drivers/infiniband/hw/ionic/ionic_ibdev.h
>>   create mode 100644 drivers/infiniband/hw/ionic/ionic_lif_cfg.c
>>   create mode 100644 drivers/infiniband/hw/ionic/ionic_lif_cfg.h
>>
>> diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.c b/drivers/infiniband/hw/ionic/ionic_ibdev.c
>> new file mode 100644
>> index 000000000000..ca047a789378
>> --- /dev/null
>> +++ b/drivers/infiniband/hw/ionic/ionic_ibdev.c
>> @@ -0,0 +1,135 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */
>> +
>> +#include <linux/module.h>
>> +#include <linux/printk.h>
>> +#include <net/addrconf.h>
>> +
>> +#include "ionic_ibdev.h"
>> +
>> +#define DRIVER_DESCRIPTION "AMD Pensando RoCE HCA driver"
>> +#define DEVICE_DESCRIPTION "AMD Pensando RoCE HCA"
>> +
>> +MODULE_AUTHOR("Allen Hubbe <allen.hubbe@amd.com>");
>> +MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
>> +MODULE_LICENSE("GPL");
>> +MODULE_IMPORT_NS("NET_IONIC");
>> +
>> +static const struct auxiliary_device_id ionic_aux_id_table[] = {
>> +       { .name = "ionic.rdma", },
>> +       {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(auxiliary, ionic_aux_id_table);
>> +
>> +static void ionic_destroy_ibdev(struct ionic_ibdev *dev)
>> +{
>> +       ib_unregister_device(&dev->ibdev);
>> +       ib_dealloc_device(&dev->ibdev);
>> +}
>> +
>> +static struct ionic_ibdev *ionic_create_ibdev(struct ionic_aux_dev *ionic_adev)
>> +{
>> +       struct ib_device *ibdev;
>> +       struct ionic_ibdev *dev;
>> +       int rc;
>> +
>> +       rc = ionic_version_check(&ionic_adev->adev.dev, ionic_adev->lif);
>> +       if (rc)
>> +               goto err_dev;
> You can return directly from here
Sure. Will correct this.
>> +
>> +       dev = ib_alloc_device(ionic_ibdev, ibdev);
>> +       if (!dev) {
>> +               rc = -ENOMEM;
>> +               goto err_dev;
> You can return directly from here
Sure. Will correct this.
>> +       }
>> +
>> +       ionic_fill_lif_cfg(ionic_adev->lif, &dev->lif_cfg);
>> +
>> +       ibdev = &dev->ibdev;
>> +       ibdev->dev.parent = dev->lif_cfg.hwdev;
>> +
>> +       strscpy(ibdev->name, "ionic_%d", IB_DEVICE_NAME_MAX);
>> +       strscpy(ibdev->node_desc, DEVICE_DESCRIPTION, IB_DEVICE_NODE_DESC_MAX);
>> +
>> +       ibdev->node_type = RDMA_NODE_IB_CA;
>> +       ibdev->phys_port_cnt = 1;
>> +
>> +       /* the first two eq are reserved for async events */
>> +       ibdev->num_comp_vectors = dev->lif_cfg.eq_count - 2;
>> +
>> +       addrconf_ifid_eui48((u8 *)&ibdev->node_guid,
>> +                           ionic_lif_netdev(ionic_adev->lif));
>> +
>> +       rc = ib_device_set_netdev(ibdev, ionic_lif_netdev(ionic_adev->lif), 1);
>> +       if (rc)
>> +               goto err_admin;
>> +
>> +       rc = ib_register_device(ibdev, "ionic_%d", ibdev->dev.parent);
>> +       if (rc)
>> +               goto err_register;
>> +
>> +       return dev;
>> +
>> +err_register:
> Unnecessary label
Because of logical split , this used in patch #13.
>> +err_admin:
>> +       ib_dealloc_device(&dev->ibdev);
>> +err_dev:
>> +       return ERR_PTR(rc);
>> +}
>> +
>> +static int ionic_aux_probe(struct auxiliary_device *adev,
>> +                          const struct auxiliary_device_id *id)
>> +{
>> +       struct ionic_aux_dev *ionic_adev;
>> +       struct ionic_ibdev *dev;
>> +
>> +       ionic_adev = container_of(adev, struct ionic_aux_dev, adev);
>> +       dev = ionic_create_ibdev(ionic_adev);
>> +       if (IS_ERR(dev))
>> +               return dev_err_probe(&adev->dev, PTR_ERR(dev),
>> +                                    "Failed to register ibdev\n");
>> +
>> +       auxiliary_set_drvdata(adev, dev);
>> +       ibdev_dbg(&dev->ibdev, "registered\n");
>> +
>> +       return 0;
>> +}
>> +
>> +static void ionic_aux_remove(struct auxiliary_device *adev)
>> +{
>> +       struct ionic_ibdev *dev = auxiliary_get_drvdata(adev);
>> +
>> +       dev_dbg(&adev->dev, "unregister ibdev\n");
>> +       ionic_destroy_ibdev(dev);
>> +       dev_dbg(&adev->dev, "unregistered\n");
>> +}
>> +
>> +static struct auxiliary_driver ionic_aux_r_driver = {
>> +       .name = "rdma",
>> +       .probe = ionic_aux_probe,
>> +       .remove = ionic_aux_remove,
>> +       .id_table = ionic_aux_id_table,
>> +};
>> +
>> +static int __init ionic_mod_init(void)
>> +{
>> +       int rc;
>> +
>> +       rc = auxiliary_driver_register(&ionic_aux_r_driver);
>> +       if (rc)
>> +               goto err_aux;
>> +
>> +       return 0;
>> +
>> +err_aux:
>> +       return rc;
> You can simplify this function as "return
> auxiliary_driver_register(&ionic_aux_r_driver);"
Because of logical split, err_aux this used in patch #9.
>> +}
>> +
>> +static void __exit ionic_mod_exit(void)
>> +{
>> +       auxiliary_driver_unregister(&ionic_aux_r_driver);
>> +}
>> +
>> +module_init(ionic_mod_init);
>> +module_exit(ionic_mod_exit);
>> diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
>> new file mode 100644
>> index 000000000000..e13adff390d7
>> --- /dev/null
>> +++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
>> @@ -0,0 +1,21 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */
>> +
>> +#ifndef _IONIC_IBDEV_H_
>> +#define _IONIC_IBDEV_H_
>> +
>> +#include <rdma/ib_verbs.h>
>> +#include <ionic_api.h>
>> +
>> +#include "ionic_lif_cfg.h"
>> +
>> +#define IONIC_MIN_RDMA_VERSION 0
>> +#define IONIC_MAX_RDMA_VERSION 2
>> +
>> +struct ionic_ibdev {
>> +       struct ib_device        ibdev;
>> +
>> +       struct ionic_lif_cfg    lif_cfg;
>> +};
>> +
>> +#endif /* _IONIC_IBDEV_H_ */
>> diff --git a/drivers/infiniband/hw/ionic/ionic_lif_cfg.c b/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
>> new file mode 100644
>> index 000000000000..a02eb2f5bd45
>> --- /dev/null
>> +++ b/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
>> @@ -0,0 +1,121 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */
>> +
>> +#include <linux/kernel.h>
>> +
>> +#include <ionic.h>
>> +#include <ionic_lif.h>
>> +
>> +#include "ionic_lif_cfg.h"
>> +
>> +#define IONIC_MIN_RDMA_VERSION 0
>> +#define IONIC_MAX_RDMA_VERSION 2
>> +
>> +static u8 ionic_get_expdb(struct ionic_lif *lif)
>> +{
>> +       u8 expdb_support = 0;
>> +
>> +       if (lif->ionic->idev.phy_cmb_expdb64_pages)
>> +               expdb_support |= IONIC_EXPDB_64B_WQE;
>> +       if (lif->ionic->idev.phy_cmb_expdb128_pages)
>> +               expdb_support |= IONIC_EXPDB_128B_WQE;
>> +       if (lif->ionic->idev.phy_cmb_expdb256_pages)
>> +               expdb_support |= IONIC_EXPDB_256B_WQE;
>> +       if (lif->ionic->idev.phy_cmb_expdb512_pages)
>> +               expdb_support |= IONIC_EXPDB_512B_WQE;
>> +
>> +       return expdb_support;
>> +}
>> +
>> +void ionic_fill_lif_cfg(struct ionic_lif *lif, struct ionic_lif_cfg *cfg)
>> +{
>> +       union ionic_lif_identity *ident = &lif->ionic->ident.lif;
>> +
>> +       cfg->lif = lif;
>> +       cfg->hwdev = &lif->ionic->pdev->dev;
>> +       cfg->lif_index = lif->index;
>> +       cfg->lif_hw_index = lif->hw_index;
>> +
>> +       cfg->dbid = lif->kern_pid;
>> +       cfg->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif);
>> +       cfg->dbpage = lif->kern_dbpage;
>> +       cfg->intr_ctrl = lif->ionic->idev.intr_ctrl;
>> +
>> +       cfg->db_phys = lif->ionic->bars[IONIC_PCI_BAR_DBELL].bus_addr;
>> +
>> +       if (IONIC_VERSION(ident->rdma.version, ident->rdma.minor_version) >=
>> +           IONIC_VERSION(2, 1))
>> +               cfg->page_size_supported =
>> +                   cpu_to_le64(ident->rdma.page_size_cap);
>> +       else
>> +               cfg->page_size_supported = IONIC_PAGE_SIZE_SUPPORTED;
>> +
>> +       cfg->rdma_version = ident->rdma.version;
>> +       cfg->qp_opcodes = ident->rdma.qp_opcodes;
>> +       cfg->admin_opcodes = ident->rdma.admin_opcodes;
>> +
>> +       cfg->stats_type = cpu_to_le16(ident->rdma.stats_type);
>> +       cfg->npts_per_lif = le32_to_cpu(ident->rdma.npts_per_lif);
>> +       cfg->nmrs_per_lif = le32_to_cpu(ident->rdma.nmrs_per_lif);
>> +       cfg->nahs_per_lif = le32_to_cpu(ident->rdma.nahs_per_lif);
>> +
>> +       cfg->aq_base = le32_to_cpu(ident->rdma.aq_qtype.qid_base);
>> +       cfg->cq_base = le32_to_cpu(ident->rdma.cq_qtype.qid_base);
>> +       cfg->eq_base = le32_to_cpu(ident->rdma.eq_qtype.qid_base);
>> +
>> +       /*
>> +        * ionic_create_rdma_admin() may reduce aq_count or eq_count if
>> +        * it is unable to allocate all that were requested.
>> +        * aq_count is tunable; see ionic_aq_count
>> +        * eq_count is tunable; see ionic_eq_count
>> +        */
>> +       cfg->aq_count = le32_to_cpu(ident->rdma.aq_qtype.qid_count);
>> +       cfg->eq_count = le32_to_cpu(ident->rdma.eq_qtype.qid_count);
>> +       cfg->cq_count = le32_to_cpu(ident->rdma.cq_qtype.qid_count);
>> +       cfg->qp_count = le32_to_cpu(ident->rdma.sq_qtype.qid_count);
>> +       cfg->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif);
>> +
>> +       cfg->aq_qtype = ident->rdma.aq_qtype.qtype;
>> +       cfg->sq_qtype = ident->rdma.sq_qtype.qtype;
>> +       cfg->rq_qtype = ident->rdma.rq_qtype.qtype;
>> +       cfg->cq_qtype = ident->rdma.cq_qtype.qtype;
>> +       cfg->eq_qtype = ident->rdma.eq_qtype.qtype;
>> +       cfg->udma_qgrp_shift = ident->rdma.udma_shift;
>> +       cfg->udma_count = 2;
>> +
>> +       cfg->max_stride = ident->rdma.max_stride;
>> +       cfg->expdb_mask = ionic_get_expdb(lif);
>> +
>> +       cfg->sq_expdb =
>> +           !!(lif->qtype_info[IONIC_QTYPE_TXQ].features & IONIC_QIDENT_F_EXPDB);
>> +       cfg->rq_expdb =
>> +           !!(lif->qtype_info[IONIC_QTYPE_RXQ].features & IONIC_QIDENT_F_EXPDB);
>> +}
>> +
>> +struct net_device *ionic_lif_netdev(struct ionic_lif *lif)
>> +{
>> +       return lif->netdev;
>> +}
>> +
>> +int ionic_version_check(const struct device *dev, struct ionic_lif *lif)
>> +{
>> +       union ionic_lif_identity *ident = &lif->ionic->ident.lif;
>> +       int rc;
> local variable "rc" is not needed here, you can return directly.

sure. Will remove it.

Thanks,
Abhijit

>> +
>> +       if (ident->rdma.version < IONIC_MIN_RDMA_VERSION ||
>> +           ident->rdma.version > IONIC_MAX_RDMA_VERSION) {
>> +               rc = -EINVAL;
>> +               dev_err_probe(dev, rc,
>> +                             "ionic_rdma: incompatible version, fw ver %u\n",
>> +                             ident->rdma.version);
>> +               dev_err_probe(dev, rc,
>> +                             "ionic_rdma: Driver Min Version %u\n",
>> +                             IONIC_MIN_RDMA_VERSION);
>> +               dev_err_probe(dev, rc,
>> +                             "ionic_rdma: Driver Max Version %u\n",
>> +                             IONIC_MAX_RDMA_VERSION);
>> +               return rc;
>> +       }
>> +
>> +       return 0;
>> +}
>> diff --git a/drivers/infiniband/hw/ionic/ionic_lif_cfg.h b/drivers/infiniband/hw/ionic/ionic_lif_cfg.h
>> new file mode 100644
>> index 000000000000..b095637c54cf
>> --- /dev/null
>> +++ b/drivers/infiniband/hw/ionic/ionic_lif_cfg.h
>> @@ -0,0 +1,65 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/* Copyright (C) 2018-2025, Advanced Micro Devices, Inc. */
>> +
>> +#ifndef _IONIC_LIF_CFG_H_
>> +
>> +#define IONIC_VERSION(a, b) (((a) << 16) + ((b) << 8))
>> +#define IONIC_PAGE_SIZE_SUPPORTED      0x40201000 /* 4kb, 2Mb, 1Gb */
>> +
>> +#define IONIC_EXPDB_64B_WQE    BIT(0)
>> +#define IONIC_EXPDB_128B_WQE   BIT(1)
>> +#define IONIC_EXPDB_256B_WQE   BIT(2)
>> +#define IONIC_EXPDB_512B_WQE   BIT(3)
>> +
>> +struct ionic_lif_cfg {
>> +       struct device *hwdev;
>> +       struct ionic_lif *lif;
>> +
>> +       int lif_index;
>> +       int lif_hw_index;
>> +
>> +       u32 dbid;
>> +       int dbid_count;
>> +       u64 __iomem *dbpage;
>> +       struct ionic_intr __iomem *intr_ctrl;
>> +       phys_addr_t db_phys;
>> +
>> +       u64 page_size_supported;
>> +       u32 npts_per_lif;
>> +       u32 nmrs_per_lif;
>> +       u32 nahs_per_lif;
>> +
>> +       u32 aq_base;
>> +       u32 cq_base;
>> +       u32 eq_base;
>> +
>> +       int aq_count;
>> +       int eq_count;
>> +       int cq_count;
>> +       int qp_count;
>> +
>> +       u16 stats_type;
>> +       u8 aq_qtype;
>> +       u8 sq_qtype;
>> +       u8 rq_qtype;
>> +       u8 cq_qtype;
>> +       u8 eq_qtype;
>> +
>> +       u8 udma_count;
>> +       u8 udma_qgrp_shift;
>> +
>> +       u8 rdma_version;
>> +       u8 qp_opcodes;
>> +       u8 admin_opcodes;
>> +
>> +       u8 max_stride;
>> +       bool sq_expdb;
>> +       bool rq_expdb;
>> +       u8 expdb_mask;
>> +};
>> +
>> +int ionic_version_check(const struct device *dev, struct ionic_lif *lif);
>> +void ionic_fill_lif_cfg(struct ionic_lif *lif, struct ionic_lif_cfg *cfg);
>> +struct net_device *ionic_lif_netdev(struct ionic_lif *lif);
>> +
>> +#endif /* _IONIC_LIF_CFG_H_ */
>> --
>> 2.34.1
>>
>>
>

  reply	other threads:[~2025-05-08  9:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08  4:59 [PATCH v2 00/14] Introduce AMD Pensando RDMA driver Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 01/14] net: ionic: Create an auxiliary device for rdma driver Abhijit Gangurde
2025-05-09 20:30   ` Simon Horman
2025-05-12  5:49     ` Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 02/14] net: ionic: Update LIF identity with additional RDMA capabilities Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 03/14] net: ionic: Export the APIs from net driver to support device commands Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 04/14] net: ionic: Provide RDMA reset support for the RDMA driver Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 05/14] net: ionic: Provide interrupt allocation " Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 06/14] net: ionic: Provide doorbell and CMB region information Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 07/14] RDMA: Add IONIC to rdma_driver_id definition Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter Abhijit Gangurde
2025-05-08  7:36   ` Kalesh Anakkur Purayil
2025-05-08  9:23     ` Abhijit Gangurde [this message]
2025-05-08  4:59 ` [PATCH v2 09/14] RDMA/ionic: Create device queues to support admin operations Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 10/14] RDMA/ionic: Register device ops for control path Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 11/14] RDMA/ionic: Register device ops for datapath Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 12/14] RDMA/ionic: Register device ops for miscellaneous functionality Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 13/14] RDMA/ionic: Implement device stats ops Abhijit Gangurde
2025-05-08  4:59 ` [PATCH v2 14/14] RDMA/ionic: Add Makefile/Kconfig to kernel build environment Abhijit Gangurde
2025-05-09 20:33   ` Simon Horman
2025-05-12  5:54     ` Abhijit Gangurde
2025-05-19 22:37 ` [PATCH v2 00/14] Introduce AMD Pensando RDMA driver Jason Gunthorpe
2025-05-22 11:28   ` Abhijit Gangurde
2025-05-26 13:19     ` Jason Gunthorpe
2025-05-26 15:41       ` Jason Gunthorpe
2025-05-28 15:12         ` Abhijit Gangurde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86be353f-4255-ca71-82db-4aa77331dcfb@amd.com \
    --to=abhijit.gangurde@amd.com \
    --cc=allen.hubbe@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew.boyer@amd.com \
    --cc=brett.creeley@amd.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jgg@ziepe.ca \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikhil.agarwal@amd.com \
    --cc=pabeni@redhat.com \
    --cc=shannon.nelson@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.