Cheng Xu
e77127ff64
RDMA/erdma: Return QP state in erdma_query_qp
...
Fix qp_state and cur_qp_state to return correct values in
struct ib_qp_attr.
Fixes: 1550557717 ("RDMA/erdma: Add verbs implementation")
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://patch.msgid.link/20240902112920.58749-4-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2024-09-09 21:17:09 +03:00
Cheng Xu
b80330f105
RDMA/erdma: Add disassociate ucontext support
...
All IO pages mapped to user space are handled by rdma_user_mmap_io,
so add empty stub for disassociate ucontext.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://patch.msgid.link/20240902112920.58749-3-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2024-09-09 21:17:09 +03:00
Akiva Goldberger
dd6d7f8574
RDMA: Pass entire uverbs attr bundle to create cq function
...
Changes the create_cq verb signature by sending the entire uverbs attr
bundle as a parameter. This allows drivers to send driver specific attrs
through ioctl for the create_cq verb and access them in their driver
specific code.
Also adds a new enum value for driver specific ioctl attributes for
methods already supporting UHW.
Link: https://lore.kernel.org/r/ed147343987c0d43fd391c1b2f85e2f425747387.1719512393.git.leon@kernel.org
Signed-off-by: Akiva Goldberger <agoldberger@nvidia.com >
Signed-off-by: Leon Romanovsky <leonro@nvidia.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
2024-06-27 16:28:21 -03:00
Boshi Yu
fdb09ed15f
RDMA/erdma: Unify the names related to doorbell records
...
There exist two different names for the doorbell records: db_info and
db_record. We use dbrec for cpu address of the doorbell record and
dbrec_dma for dma address of the doorbell recordi uniformly.
Reviewed-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Boshi Yu <boshiyu@linux.alibaba.com >
Link: https://lore.kernel.org/r/20240311113821.22482-3-boshiyu@alibaba-inc.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2024-04-01 14:46:01 +03:00
Boshi Yu
f0697bf078
RDMA/erdma: Allocate doorbell records from dma pool
...
Currently, the 8 byte doorbell record is allocated along with the queue
buffer, which may result in waste of dma space when the queue buffer is
page aligned. To address this issue, we introduce a dma pool named
db_pool and allocate doorbell record from it.
Reviewed-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Boshi Yu <boshiyu@linux.alibaba.com >
Link: https://lore.kernel.org/r/20240311113821.22482-2-boshiyu@alibaba-inc.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2024-04-01 14:46:01 +03:00
Cheng Xu
63a43a675c
RDMA/erdma: Add hardware statistics support
...
First, we add a new command to query hardware statistics, and then
implement two functions: ib_device_ops.alloc_hw_port_stats and
ib_device_ops.get_hw_stats to allow rdma tool can get the statistics
of erdma device.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20231227084800.99091-3-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-12-30 17:23:17 +02:00
Cheng Xu
b2abdffb50
RDMA/erdma: Fix NULL pointer access in regmr_cmd
...
Fix the crash of regmr_cmd called by erdma_ib_alloc_mr. The reason is
that mr->mem.mtt is not initialized but it is accessed in regmr_cmd.
The call trace information:
BUG: kernel NULL pointer dereference, address: 0000000000000000
<...>
RIP: 0010:regmr_cmd+0x170/0x1c0 [erdma]
<...>
Call Trace:
? __die+0x20/0x70
? page_fault_oops+0x66/0x150
? do_user_addr_fault+0x61/0x660
? exc_page_fault+0x65/0x140
? asm_exc_page_fault+0x22/0x30
? regmr_cmd+0x170/0x1c0 [erdma]
? preempt_count_add+0x70/0xa0
? _raw_spin_lock_irqsave+0x19/0x50
? _raw_spin_unlock_irqrestore+0x1b/0x40
? erdma_alloc_idx+0x51/0x90 [erdma]
erdma_get_dma_mr+0xa3/0x120 [erdma]
__ib_alloc_pd+0xeb/0x1c0 [ib_core]
Fixes: 7244b4aa42 ("RDMA/erdma: Refactor the storage structure of MTT entries")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org >
Closes: https://lore.kernel.org/all/3d140c1d-524a-4dbe-a51c-aee4f7ecafdb@moroto.mountain/
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230908060559.80203-1-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-09-18 10:42:19 +03:00
Dan Carpenter
6b5f0749ce
RDMA/erdma: Fix error code in erdma_create_scatter_mtt()
...
The erdma_create_scatter_mtt() function is supposed to return error
pointers. Returning NULL will lead to an Oops.
Fixes: ed10435d35 ("RDMA/erdma: Implement hierarchical MTT")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org >
Link: https://lore.kernel.org/r/1eb400d5-d8a3-4a8e-b3da-c43c6c377f86@moroto.mountain
Acked-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-09-18 09:12:00 +03:00
Cheng Xu
ed10435d35
RDMA/erdma: Implement hierarchical MTT
...
Hierarchical MTT allows large MR registration without the need of
continuous physical address. This commit adds the support of hierarchical
MTT support for erdma.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230817102151.75964-4-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-08-19 14:41:01 +03:00
Cheng Xu
7244b4aa42
RDMA/erdma: Refactor the storage structure of MTT entries
...
Currently our MTT only support inline mtt entries (0 level MTT) and
indirect MTT entries (1 level mtt), which will limit the maximum length
of MRs. In order to implement a multi-level MTT, we refactor the
structure of MTT first.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230817102151.75964-3-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-08-19 14:40:30 +03:00
Cheng Xu
d7cfbba90b
RDMA/erdma: Renaming variable names and field names of struct erdma_mem
...
Currently, variable names and field names of struct erdma_mem contain
'mtt', which is not accurate. Renaming them with 'xxx_mem' or 'mem'.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230817102151.75964-2-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-08-19 14:36:29 +03:00
Julia Lawall
c619af8327
RDMA/erdma: use vmalloc_array and vcalloc
...
Use vmalloc_array and vcalloc to protect against
multiplication overflows.
The changes were done using the following Coccinelle
semantic patch:
// <smpl>
@initialize:ocaml@
@@
let rename alloc =
match alloc with
"vmalloc" -> "vmalloc_array"
| "vzalloc" -> "vcalloc"
| _ -> failwith "unknown"
@@
size_t e1,e2;
constant C1, C2;
expression E1, E2, COUNT, x1, x2, x3;
typedef u8;
typedef __u8;
type t = {u8,__u8,char,unsigned char};
identifier alloc = {vmalloc,vzalloc};
fresh identifier realloc = script:ocaml(alloc) { rename alloc };
@@
(
alloc(x1*x2*x3)
|
alloc(C1 * C2)
|
alloc((sizeof(t)) * (COUNT), ...)
|
- alloc((e1) * (e2))
+ realloc(e1, e2)
|
- alloc((e1) * (COUNT))
+ realloc(COUNT, e1)
|
- alloc((E1) * (E2))
+ realloc(E1, E2)
)
// </smpl>
Link: https://lore.kernel.org/r/20230627144339.144478-6-Julia.Lawall@inria.fr
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
2023-07-21 15:51:58 -03:00
Cheng Xu
3b3dfd58ba
RDMA/erdma: Refactor the original doorbell allocation mechanism
...
The original doorbell allocation mechanism is complex and does not meet
the isolation requirement. So we introduce a new doorbell mechanism and the
original mechanism (only be used with CAP_SYS_RAWIO if hardware does not
support the new mechanism) needs to be kept as simple as possible for
compatibility.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230606055005.80729-5-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-06-11 11:57:01 +03:00
Cheng Xu
6534de1fe3
RDMA/erdma: Associate QPs/CQs with doorbells for authorization
...
For the isolation requirement, each QP/CQ can only issue doorbells from the
allocated mmio space. Configure the relationship between QPs/CQs and
mmio doorbell spaces to hardware in create_qp/create_cq interfaces.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230606055005.80729-4-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-06-11 11:57:00 +03:00
Cheng Xu
7e9a1dada2
RDMA/erdma: Allocate doorbell resources from hardware
...
Each ucontext will try to allocate doorbell resources in the extended bar
space from hardware. For compatibility, we change nothing for the original
bar space, and it will be used only for applications with CAP_SYS_RAWIO
authority in the older HW/FW environments.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230606055005.80729-3-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2023-06-11 11:57:00 +03:00
Cheng Xu
d649c638dc
RDMA/erdma: Use fixed hardware page size
...
Hardware's page size is 4096, but the kernel's page size may vary. Driver
should use hardware's page size when communicating with hardware.
Fixes: 1550557717 ("RDMA/erdma: Add verbs implementation")
Link: https://lore.kernel.org/r/20230307102924.70577-2-chengyou@linux.alibaba.com
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
2023-03-24 11:31:22 -03:00
Miaoqian Lin
ee84146c05
RDMA/erdma: Fix refcount leak in erdma_mmap
...
rdma_user_mmap_entry_get() take reference, we should release it when not
need anymore, add the missing rdma_user_mmap_entry_put() in the error
path to fix it.
Fixes: 1550557717 ("RDMA/erdma: Add verbs implementation")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com >
Link: https://lore.kernel.org/r/20221220121139.1540564-1-linmq006@gmail.com
Acked-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2022-12-28 11:55:34 +02:00
Cheng Xu
54d8fffc2a
RDMA/erdma: Implement the lifecycle of reflushing work for each QP
...
Each QP has a work for reflushing purpose. In the work, driver will report
the latest pi to hardware.
Link: https://lore.kernel.org/r/20221116023107.82835-3-chengyou@linux.alibaba.com
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
2022-11-24 14:58:52 -04:00
Cheng Xu
71c6925f28
RDMA/erdma: Report atomic capacity when hardware supports atomic feature
...
Introduce "capacity flags" field at where hardware put all zeros originally
in "query device" response. Using this field, hardware can report atomic
feature if supports.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20221107021845.44598-3-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2022-11-07 09:55:04 +02:00
Cheng Xu
ece43fad22
RDMA/erdma: Extend access right field of FRMR and REG MR to support atomic
...
To support atomic operations, IB_ACCESS_REMOTE_ATOMIC right should be
passed to hardware for permission check. Since "access mode" field in FRMR
SQE and RegMr command is never used by hw, we remove the "access mode"
field, so that we can then have enough space to extend access fields.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20221107021845.44598-2-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2022-11-07 09:55:04 +02:00
Jason Gunthorpe
33331a728c
Merge tag 'v6.0' into rdma.git for-next
...
Trvial merge conflicts against rdma.git for-rc resolved matching
linux-next:
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_main.c
https://lore.kernel.org/r/20220929124005.105149-1-broonie@kernel.org
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
2022-10-06 19:48:45 -03:00
Cheng Xu
9bdb9350f3
RDMA/erdma: Support dynamic mtu
...
Hardware now support jumbo frame for RDMA. So we introduce a new CMDQ
message to support mtu change notification.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20220909093822.33868-5-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2022-09-21 10:31:24 +03:00
Cheng Xu
93aea72cc5
RDMA/erdma: Remove redundant includes
...
Many of erdma's includes are redundant, because they are already included
indirectly by kernel headers or custom headers. So we remove all the
unnecessary direct-includes. Besides, add linux/pci.h to erdma.h because
it's also used in the file.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20220909093822.33868-3-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2022-09-20 14:27:51 +03:00
Cheng Xu
95f911d949
RDMA/erdma: Eliminate unnecessary casting for erdma_post_cmd_wait
...
erdma_post_cmd_wait does not use the 'u64 *req' input parameter directly.
So it is better to define it to 'void *req', and by this we can eliminate
the casting when calling erdma_post_cmd_wait.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Link: https://lore.kernel.org/r/20220909093822.33868-2-chengyou@linux.alibaba.com
Signed-off-by: Leon Romanovsky <leon@kernel.org >
2022-09-20 14:27:51 +03:00
Cheng Xu
6cd8351c4e
RDMA/erdma: Correct the max_qp and max_cq capacities of the device
...
QP0 in HW is used for CMDQ, and the rest is for RDMA QPs. So the actual
max_qp capacity reported to core should be max_qp (reported by HW) - 1.
So does max_cq.
Fixes: 1550557717 ("RDMA/erdma: Add verbs implementation")
Link: https://lore.kernel.org/all/20220810014320.88026-1-chengyou@linux.alibaba.com
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Leon Romanovsky <leonro@nvidia.com >
2022-08-16 16:29:12 +03:00
Cheng Xu
1550557717
RDMA/erdma: Add verbs implementation
...
The RDMA verbs implementation of erdma is divided into three files:
erdma_qp.c, erdma_cq.c, and erdma_verbs.c. Internal used functions and
datapath functions of QP/CQ are put in erdma_qp.c and erdma_cq.c, the rest
is in erdma_verbs.c.
This commit also fixes some static check warnings.
Link: https://lore.kernel.org/r/20220727014927.76564-8-chengyou@linux.alibaba.com
Reported-by: Dan Carpenter <dan.carpenter@oracle.com >
Reported-by: Abaci Robot <abaci@linux.alibaba.com >
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com >
Reported-by: Hulk Robot <hulkci@huawei.com >
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com >
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
2022-07-27 15:54:39 -03:00