mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-18 02:46:06 +00:00
RDMA/mana_ib: Adding and deleting GIDs
Implement add_gid and del_gid for RNIC. IPv4 and IPv6 addresses are supported. Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com> Link: https://lore.kernel.org/r/1712738551-22075-6-git-send-email-kotaranov@linux.microsoft.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
8b184e4f1c
commit
faafb8b126
@ -15,6 +15,7 @@ static const struct ib_device_ops mana_ib_dev_ops = {
|
||||
.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 @@ static const struct ib_device_ops mana_ib_dev_ops = {
|
||||
.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,
|
||||
|
@ -722,3 +722,63 @@ int mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 (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 (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;
|
||||
}
|
||||
|
@ -116,6 +116,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 {
|
||||
@ -165,6 +166,28 @@ 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 = 2,
|
||||
};
|
||||
|
||||
enum sgid_entry_type {
|
||||
SGID_TYPE_IPV4 = 1,
|
||||
SGID_TYPE_IPV6 = 2,
|
||||
};
|
||||
|
||||
struct mana_rnic_config_addr_req {
|
||||
struct gdma_req_hdr hdr;
|
||||
mana_handle_t adapter;
|
||||
enum mana_ib_addr_op op;
|
||||
enum sgid_entry_type sgid_type;
|
||||
u8 ip_addr[16];
|
||||
}; /* HW Data */
|
||||
|
||||
struct mana_rnic_config_addr_resp {
|
||||
struct gdma_resp_hdr hdr;
|
||||
}; /* HW Data */
|
||||
|
||||
static inline struct gdma_context *mdev_to_gc(struct mana_ib_dev *mdev)
|
||||
{
|
||||
return mdev->gdma_dev->gdma_context;
|
||||
@ -181,6 +204,14 @@ static inline struct net_device *mana_ib_get_netdev(struct ib_device *ibdev, u32
|
||||
return mc->ports[port - 1];
|
||||
}
|
||||
|
||||
static inline void copy_in_reverse(u8 *dst, const u8 *src, u32 size)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
dst[size - 1 - i] = src[i];
|
||||
}
|
||||
|
||||
int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq);
|
||||
|
||||
int mana_ib_create_zero_offset_dma_region(struct mana_ib_dev *dev, struct ib_umem *umem,
|
||||
@ -270,4 +301,8 @@ int mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev);
|
||||
int mana_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index, u16 *pkey);
|
||||
|
||||
enum rdma_link_layer mana_ib_get_link_layer(struct ib_device *device, u32 port_num);
|
||||
|
||||
int mana_ib_gd_add_gid(const struct ib_gid_attr *attr, void **context);
|
||||
|
||||
int mana_ib_gd_del_gid(const struct ib_gid_attr *attr, void **context);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user