forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RDMA/mana_ib: Add a driver for Microsoft Azure Network Adapter
Add a RDMA VF driver for Microsoft Azure Network Adapter (MANA). Signed-off-by: Long Li <longli@microsoft.com>
- Loading branch information
1 parent
8dc701c
commit e448735
Showing
14 changed files
with
1,702 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
config MANA_INFINIBAND | ||
tristate "Microsoft Azure Network Adapter support" | ||
depends on NETDEVICES && ETHERNET && PCI && MICROSOFT_MANA | ||
help | ||
This driver provides low-level RDMA support for | ||
Microsoft Azure Network Adapter (MANA). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
obj-$(CONFIG_MANA_INFINIBAND) += mana_ib.o | ||
|
||
mana_ib-y := main.o wq.o qp.o cq.o mr.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB | ||
/* | ||
* Copyright (c) 2022, Microsoft Corporation. All rights reserved. | ||
*/ | ||
|
||
#include "mana_ib.h" | ||
|
||
int mana_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, | ||
struct ib_udata *udata) | ||
{ | ||
struct mana_ib_create_cq ucmd = {}; | ||
struct ib_device *ibdev = ibcq->device; | ||
struct mana_ib_dev *mdev = | ||
container_of(ibdev, struct mana_ib_dev, ib_dev); | ||
struct mana_ib_cq *cq = container_of(ibcq, struct mana_ib_cq, ibcq); | ||
int err; | ||
|
||
if (udata->inlen < sizeof(ucmd)) | ||
return -EINVAL; | ||
|
||
err = ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen)); | ||
if (err) { | ||
ibdev_dbg(ibdev, | ||
"Failed to copy from udata for create cq, %d\n", err); | ||
return -EFAULT; | ||
} | ||
|
||
if (attr->cqe > MAX_SEND_BUFFERS_PER_QUEUE) { | ||
ibdev_dbg(ibdev, "CQE %d exceeding limit\n", attr->cqe); | ||
return -EINVAL; | ||
} | ||
|
||
cq->cqe = attr->cqe; | ||
cq->umem = ib_umem_get(ibdev, ucmd.buf_addr, cq->cqe * COMP_ENTRY_SIZE, | ||
IB_ACCESS_LOCAL_WRITE); | ||
if (IS_ERR(cq->umem)) { | ||
err = PTR_ERR(cq->umem); | ||
ibdev_dbg(ibdev, "Failed to get umem for create cq, err %d\n", | ||
err); | ||
return err; | ||
} | ||
|
||
err = mana_ib_gd_create_dma_region(mdev, cq->umem, &cq->gdma_region, | ||
PAGE_SIZE); | ||
if (err) { | ||
ibdev_err(ibdev, | ||
"Failed to create dma region for create cq, %d\n", | ||
err); | ||
goto err_release_umem; | ||
} | ||
|
||
ibdev_dbg(ibdev, | ||
"mana_ib_gd_create_dma_region ret %d gdma_region 0x%llx\n", | ||
err, cq->gdma_region); | ||
|
||
/* | ||
* The CQ ID is not known at this time | ||
* The ID is generated at create_qp | ||
*/ | ||
|
||
return 0; | ||
|
||
err_release_umem: | ||
ib_umem_release(cq->umem); | ||
return err; | ||
} | ||
|
||
int mana_ib_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) | ||
{ | ||
struct mana_ib_cq *cq = container_of(ibcq, struct mana_ib_cq, ibcq); | ||
struct ib_device *ibdev = ibcq->device; | ||
struct mana_ib_dev *mdev = | ||
container_of(ibdev, struct mana_ib_dev, ib_dev); | ||
|
||
mana_ib_gd_destroy_dma_region(mdev, cq->gdma_region); | ||
ib_umem_release(cq->umem); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.