From: Leon Romanovsky <leon@kernel.org>
To: Konstantin Taranov <kotaranov@linux.microsoft.com>
Cc: kotaranov@microsoft.com, sharmaajay@microsoft.com,
longli@microsoft.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH rdma-next v2 5/5] RDMA/mana_ib: Adding and deleting GIDs
Date: Sun, 4 Feb 2024 14:43:00 +0200 [thread overview]
Message-ID: <20240204124300.GF5400@unreal> (raw)
In-Reply-To: <1706886397-16600-6-git-send-email-kotaranov@linux.microsoft.com>
On Fri, Feb 02, 2024 at 07:06:37AM -0800, Konstantin Taranov wrote:
> Implement add_gid and del_gid for RNIC.
> We support ipv4 and ipv6 addresses.
>
> Signed-off-by: Konstantin Taranov <kotaranov@linux.microsoft.com>
> ---
> drivers/infiniband/hw/mana/device.c | 2 ++
> drivers/infiniband/hw/mana/main.c | 66 ++++++++++++++++++++++++++++++++++++
> drivers/infiniband/hw/mana/mana_ib.h | 37 ++++++++++++++++++++
> 3 files changed, 105 insertions(+)
>
> diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c
> index 2b362f5..9fb515b 100644
> --- a/drivers/infiniband/hw/mana/device.c
> +++ b/drivers/infiniband/hw/mana/device.c
> @@ -15,6 +15,7 @@
> .driver_id = RDMA_DRIVER_MANA,
> .uverbs_abi_ver = MANA_IB_UVERBS_ABI_VERSION,
>
> + .add_gid = mana_ib_gd_add_gid,
> .alloc_pd = mana_ib_alloc_pd,
> .alloc_ucontext = mana_ib_alloc_ucontext,
> .create_cq = mana_ib_create_cq,
> @@ -23,6 +24,7 @@
> .create_wq = mana_ib_create_wq,
> .dealloc_pd = mana_ib_dealloc_pd,
> .dealloc_ucontext = mana_ib_dealloc_ucontext,
> + .del_gid = mana_ib_gd_del_gid,
> .dereg_mr = mana_ib_dereg_mr,
> .destroy_cq = mana_ib_destroy_cq,
> .destroy_qp = mana_ib_destroy_qp,
> diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c
> index 645abf3..282c024 100644
> --- a/drivers/infiniband/hw/mana/main.c
> +++ b/drivers/infiniband/hw/mana/main.c
> @@ -675,3 +675,69 @@ void mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev)
> mdev->adapter_handle = INVALID_MANA_HANDLE;
> mana_ib_destroy_eqs(mdev);
> }
> +
> +int mana_ib_gd_add_gid(const struct ib_gid_attr *attr, void **context)
> +{
> + struct mana_ib_dev *mdev = container_of(attr->device, struct mana_ib_dev, ib_dev);
> + enum rdma_network_type ntype = rdma_gid_attr_network_type(attr);
> + struct mana_rnic_config_addr_resp resp = {};
> + struct gdma_context *gc = mdev_to_gc(mdev);
> + struct mana_rnic_config_addr_req req = {};
> + int err;
> +
> + if (!rnic_is_enabled(mdev))
> + return -EINVAL;
Set .add_gid./del_gid callbacks only when RNIC is enabled.
ib_set_device_ops() allows partial set of the callbacks.
> +
> + if (ntype != RDMA_NETWORK_IPV4 && ntype != RDMA_NETWORK_IPV6) {
> + ibdev_dbg(&mdev->ib_dev, "Unsupported rdma network type %d", ntype);
> + return -EINVAL;
> + }
> +
> + mana_gd_init_req_hdr(&req.hdr, MANA_IB_CONFIG_IP_ADDR, sizeof(req), sizeof(resp));
> + req.hdr.dev_id = gc->mana_ib.dev_id;
> + req.adapter = mdev->adapter_handle;
> + req.op = ADDR_OP_ADD;
> + req.sgid_type = (ntype == RDMA_NETWORK_IPV6) ? SGID_TYPE_IPV6 : SGID_TYPE_IPV4;
> + copy_in_reverse(req.ip_addr, attr->gid.raw, sizeof(union ib_gid));
> +
> + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
> + if (err) {
> + ibdev_err(&mdev->ib_dev, "Failed to config IP addr err %d\n", err);
> + return err;
> + }
> +
> + return 0;
> +}
> +
> +int mana_ib_gd_del_gid(const struct ib_gid_attr *attr, void **context)
> +{
> + struct mana_ib_dev *mdev = container_of(attr->device, struct mana_ib_dev, ib_dev);
> + enum rdma_network_type ntype = rdma_gid_attr_network_type(attr);
> + struct mana_rnic_config_addr_resp resp = {};
> + struct gdma_context *gc = mdev_to_gc(mdev);
> + struct mana_rnic_config_addr_req req = {};
> + int err;
> +
> + if (!rnic_is_enabled(mdev))
> + return -EINVAL;
> +
> + if (ntype != RDMA_NETWORK_IPV4 && ntype != RDMA_NETWORK_IPV6) {
> + ibdev_dbg(&mdev->ib_dev, "Unsupported rdma network type %d", ntype);
> + return -EINVAL;
> + }
> +
> + mana_gd_init_req_hdr(&req.hdr, MANA_IB_CONFIG_IP_ADDR, sizeof(req), sizeof(resp));
> + req.hdr.dev_id = gc->mana_ib.dev_id;
> + req.adapter = mdev->adapter_handle;
> + req.op = ADDR_OP_REMOVE;
> + req.sgid_type = (ntype == RDMA_NETWORK_IPV6) ? SGID_TYPE_IPV6 : SGID_TYPE_IPV4;
> + copy_in_reverse(req.ip_addr, attr->gid.raw, sizeof(union ib_gid));
> +
> + err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
> + if (err) {
> + ibdev_err(&mdev->ib_dev, "Failed to config IP addr err %d\n", err);
> + return err;
> + }
> +
> + return 0;
> +}
> diff --git a/drivers/infiniband/hw/mana/mana_ib.h b/drivers/infiniband/hw/mana/mana_ib.h
> index 196f3c8..2a3e3b0 100644
> --- a/drivers/infiniband/hw/mana/mana_ib.h
> +++ b/drivers/infiniband/hw/mana/mana_ib.h
> @@ -118,6 +118,7 @@ enum mana_ib_command_code {
> MANA_IB_GET_ADAPTER_CAP = 0x30001,
> MANA_IB_CREATE_ADAPTER = 0x30002,
> MANA_IB_DESTROY_ADAPTER = 0x30003,
> + MANA_IB_CONFIG_IP_ADDR = 0x30004,
> };
>
> struct mana_ib_query_adapter_caps_req {
> @@ -167,6 +168,30 @@ struct mana_rnic_destroy_adapter_resp {
> struct gdma_resp_hdr hdr;
> }; /* HW Data */
>
> +enum mana_ib_addr_op {
> + ADDR_OP_ADD = 1,
> + ADDR_OP_REMOVE,
> +};
> +
> +enum sgid_entry_type {
> + SGID_TYPE_INVALID = 0,
> + SGID_TYPE_IPV4 = 1,
> + SGID_TYPE_IPV6 = 2,
> + SGID_TYPE_HYBRID = 3
This is not used, please remove it.
Thanks
prev parent reply other threads:[~2024-02-04 12:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 15:06 [PATCH rdma-next v2 0/5] RDMA/mana_ib: Enable RNIC adapter and populate it with GIDs Konstantin Taranov
2024-02-02 15:06 ` [PATCH rdma-next v2 1/5] RDMA/mana_ib: Add EQ creation for rnic adapter Konstantin Taranov
2024-02-04 12:25 ` Leon Romanovsky
2024-02-02 15:06 ` [PATCH rdma-next v2 2/5] RDMA/mana_ib: Create and destroy " Konstantin Taranov
2024-02-04 12:30 ` Leon Romanovsky
2024-02-04 15:50 ` [EXTERNAL] " Konstantin Taranov
2024-02-04 16:51 ` Leon Romanovsky
2024-02-04 17:17 ` Konstantin Taranov
2024-02-05 7:54 ` Leon Romanovsky
2024-02-05 9:15 ` Konstantin Taranov
2024-02-05 9:57 ` Leon Romanovsky
2024-02-06 14:20 ` Konstantin Taranov
2024-02-06 14:32 ` Jason Gunthorpe
2024-02-02 15:06 ` [PATCH rdma-next v2 3/5] RDMA/mana_ib: Implement port parameters Konstantin Taranov
2024-02-02 15:06 ` [PATCH rdma-next v2 4/5] RDMA/mana_ib: Enable RoCE on port 1 Konstantin Taranov
2024-02-02 15:06 ` [PATCH rdma-next v2 5/5] RDMA/mana_ib: Adding and deleting GIDs Konstantin Taranov
2024-02-04 12:43 ` Leon Romanovsky [this message]
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=20240204124300.GF5400@unreal \
--to=leon@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kotaranov@linux.microsoft.com \
--cc=kotaranov@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=sharmaajay@microsoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).