verbs: Document that pointer-returning verbs set errno on failure
The RETURN VALUE sections of the pointer-returning verbs stated only
that NULL is returned on failure. Where errno was mentioned it described
the paired int-returning sibling (e.g. ibv_dealloc_pd, ibv_free_dm), not
the pointer verb itself; only ibv_import_dm documented that errno is set
on the NULL return.
Document the errno contract on all of these verbs for consistency with
ibv_import_dm and with the sibling int-returning verbs: ibv_reg_mr and
friends, ibv_alloc_pd, ibv_alloc_dm, ibv_reg_dm_mr, ibv_alloc_null_mr,
ibv_create_ah, ibv_create_ah_from_wc, ibv_create_comp_channel,
ibv_create_cq, ibv_create_cq_ex, ibv_create_qp, ibv_create_srq,
ibv_open_device, ibv_import_device, ibv_import_mr and ibv_import_pd. The
ibv_reg_mr path has set errno since commit f9e127a4bffa ("verbs: Set
missing errno in ibv_cmd_reg_mr").
Signed-off-by: Christian Häggström <christian.haggstrom@sambanovasystems.com>
diff --git a/libibverbs/man/ibv_alloc_dm.3 b/libibverbs/man/ibv_alloc_dm.3
index cfaf3fb..5c66639 100644
--- a/libibverbs/man/ibv_alloc_dm.3
+++ b/libibverbs/man/ibv_alloc_dm.3
@@ -91,14 +91,14 @@
.SH "RETURN VALUE"
.B ibv_alloc_dm()
-returns a pointer to an ibv_dm struct or NULL if the request fails.
+returns a pointer to an ibv_dm struct or NULL if the request fails, and errno is set to indicate the reason.
The output dm contains the handle which could be used by user to import this device memory.
.PP
.B ibv_free_dm()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
.PP
.B ibv_reg_dm_mr()
-returns a pointer to an ibv_mr struct on success or NULL if request fails.
+returns a pointer to an ibv_mr struct on success or NULL if request fails, and errno is set to indicate the reason.
.PP
.B ibv_memcpy_to_dm()/ibv_memcpy_from_dm()
returns 0 on success or the failure reason value on failure.
diff --git a/libibverbs/man/ibv_alloc_null_mr.3.md b/libibverbs/man/ibv_alloc_null_mr.3.md
index e0e341f..9140dc7 100644
--- a/libibverbs/man/ibv_alloc_null_mr.3.md
+++ b/libibverbs/man/ibv_alloc_null_mr.3.md
@@ -46,7 +46,7 @@
# RETURN VALUE
-**ibv_alloc_null_mr()** returns a pointer to the allocated MR, or NULL if the request fails.
+**ibv_alloc_null_mr()** returns a pointer to the allocated MR, or NULL if the request fails, and errno is set to indicate the reason.
# SEE ALSO
diff --git a/libibverbs/man/ibv_alloc_pd.3 b/libibverbs/man/ibv_alloc_pd.3
index cc475f4..ebc8c3e 100644
--- a/libibverbs/man/ibv_alloc_pd.3
+++ b/libibverbs/man/ibv_alloc_pd.3
@@ -22,7 +22,7 @@
.I pd\fR.
.SH "RETURN VALUE"
.B ibv_alloc_pd()
-returns a pointer to the allocated PD, or NULL if the request fails.
+returns a pointer to the allocated PD, or NULL if the request fails, and errno is set to indicate the reason.
.PP
.B ibv_dealloc_pd()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
diff --git a/libibverbs/man/ibv_create_ah.3 b/libibverbs/man/ibv_create_ah.3
index 47c78f8..bb4364a 100644
--- a/libibverbs/man/ibv_create_ah.3
+++ b/libibverbs/man/ibv_create_ah.3
@@ -52,7 +52,7 @@
.I ah\fR.
.SH "RETURN VALUE"
.B ibv_create_ah()
-returns a pointer to the created AH, or NULL if the request fails.
+returns a pointer to the created AH, or NULL if the request fails, and errno is set to indicate the reason.
.SH "NOTES"
If port flag IBV_QPF_GRH_REQUIRED is set then
.B ibv_create_ah()
diff --git a/libibverbs/man/ibv_create_ah_from_wc.3 b/libibverbs/man/ibv_create_ah_from_wc.3
index ec7d29f..60a33a2 100644
--- a/libibverbs/man/ibv_create_ah_from_wc.3
+++ b/libibverbs/man/ibv_create_ah_from_wc.3
@@ -45,7 +45,7 @@
returns 0 on success, and \-1 on error.
.PP
.B ibv_create_ah_from_wc()
-returns a pointer to the created AH, or NULL if the request fails.
+returns a pointer to the created AH, or NULL if the request fails, and errno is set to indicate the reason.
.SH "NOTES"
The filled structure
.I ah_attr
diff --git a/libibverbs/man/ibv_create_comp_channel.3 b/libibverbs/man/ibv_create_comp_channel.3
index 7460978..fec476c 100644
--- a/libibverbs/man/ibv_create_comp_channel.3
+++ b/libibverbs/man/ibv_create_comp_channel.3
@@ -24,7 +24,7 @@
.I channel\fR.
.SH "RETURN VALUE"
.B ibv_create_comp_channel()
-returns a pointer to the created completion event channel, or NULL if the request fails.
+returns a pointer to the created completion event channel, or NULL if the request fails, and errno is set to indicate the reason.
.PP
.B ibv_destroy_comp_channel()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
diff --git a/libibverbs/man/ibv_create_cq.3 b/libibverbs/man/ibv_create_cq.3
index 98ea4d2..a4a5b93 100644
--- a/libibverbs/man/ibv_create_cq.3
+++ b/libibverbs/man/ibv_create_cq.3
@@ -38,7 +38,7 @@
.I cq\fR.
.SH "RETURN VALUE"
.B ibv_create_cq()
-returns a pointer to the CQ, or NULL if the request fails.
+returns a pointer to the CQ, or NULL if the request fails, and errno is set to indicate the reason.
.PP
.B ibv_destroy_cq()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
diff --git a/libibverbs/man/ibv_create_cq_ex.3 b/libibverbs/man/ibv_create_cq_ex.3
index f0ea47b..b8d67da 100644
--- a/libibverbs/man/ibv_create_cq_ex.3
+++ b/libibverbs/man/ibv_create_cq_ex.3
@@ -168,7 +168,7 @@
.SH "RETURN VALUE"
.B ibv_create_cq_ex()
-returns a pointer to the CQ, or NULL if the request fails.
+returns a pointer to the CQ, or NULL if the request fails, and errno is set to indicate the reason.
.SH "NOTES"
.B ibv_create_cq_ex()
may create a CQ with size greater than or equal to the requested
diff --git a/libibverbs/man/ibv_create_qp.3 b/libibverbs/man/ibv_create_qp.3
index dfbd245..3055017 100644
--- a/libibverbs/man/ibv_create_qp.3
+++ b/libibverbs/man/ibv_create_qp.3
@@ -58,7 +58,7 @@
.I qp\fR.
.SH "RETURN VALUE"
.B ibv_create_qp()
-returns a pointer to the created QP, or NULL if the request fails.
+returns a pointer to the created QP, or NULL if the request fails, and errno is set to indicate the reason.
Check the QP number (\fBqp_num\fR) in the returned QP.
.PP
.B ibv_destroy_qp()
diff --git a/libibverbs/man/ibv_create_srq.3 b/libibverbs/man/ibv_create_srq.3
index 46ab8dd..a4d4aaf 100644
--- a/libibverbs/man/ibv_create_srq.3
+++ b/libibverbs/man/ibv_create_srq.3
@@ -52,7 +52,7 @@
.I srq\fR.
.SH "RETURN VALUE"
.B ibv_create_srq()
-returns a pointer to the created SRQ, or NULL if the request fails.
+returns a pointer to the created SRQ, or NULL if the request fails, and errno is set to indicate the reason.
.PP
.B ibv_destroy_srq()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
diff --git a/libibverbs/man/ibv_import_device.3.md b/libibverbs/man/ibv_import_device.3.md
index df205dc..6b4a41b 100644
--- a/libibverbs/man/ibv_import_device.3.md
+++ b/libibverbs/man/ibv_import_device.3.md
@@ -35,7 +35,7 @@
# RETURN VALUE
-**ibv_import_device()** returns a pointer to the allocated RDMA context, or NULL if the request fails.
+**ibv_import_device()** returns a pointer to the allocated RDMA context, or NULL if the request fails, and errno is set to indicate the reason.
# SEE ALSO
diff --git a/libibverbs/man/ibv_import_mr.3.md b/libibverbs/man/ibv_import_mr.3.md
index f6346e4..9d7d5d3 100644
--- a/libibverbs/man/ibv_import_mr.3.md
+++ b/libibverbs/man/ibv_import_mr.3.md
@@ -44,7 +44,7 @@
# RETURN VALUE
-**ibv_import_mr()** returns a pointer to the allocated MR, or NULL if the request fails.
+**ibv_import_mr()** returns a pointer to the allocated MR, or NULL if the request fails, and errno is set to indicate the reason.
# NOTES
diff --git a/libibverbs/man/ibv_import_pd.3.md b/libibverbs/man/ibv_import_pd.3.md
index 084bbfe..a18fb78 100644
--- a/libibverbs/man/ibv_import_pd.3.md
+++ b/libibverbs/man/ibv_import_pd.3.md
@@ -46,7 +46,7 @@
# RETURN VALUE
-**ibv_import_pd()** returns a pointer to the allocated PD, or NULL if the request fails.
+**ibv_import_pd()** returns a pointer to the allocated PD, or NULL if the request fails, and errno is set to indicate the reason.
# SEE ALSO
diff --git a/libibverbs/man/ibv_open_device.3 b/libibverbs/man/ibv_open_device.3
index 3a12d2d..4510e3f 100644
--- a/libibverbs/man/ibv_open_device.3
+++ b/libibverbs/man/ibv_open_device.3
@@ -23,7 +23,7 @@
.I context\fR.
.SH "RETURN VALUE"
.B ibv_open_device()
-returns a pointer to the allocated device context, or NULL if the request fails.
+returns a pointer to the allocated device context, or NULL if the request fails, and errno is set to indicate the reason.
.PP
.B ibv_close_device()
returns 0 on success, \-1 on failure.
diff --git a/libibverbs/man/ibv_reg_mr.3 b/libibverbs/man/ibv_reg_mr.3
index bd4aeb3..6a18fce 100644
--- a/libibverbs/man/ibv_reg_mr.3
+++ b/libibverbs/man/ibv_reg_mr.3
@@ -153,6 +153,11 @@
.SH "RETURN VALUE"
.B ibv_reg_mr() / ibv_reg_mr_iova() / ibv_reg_dmabuf_mr() / ibv_reg_mr_ex()
returns a pointer to the registered MR, or NULL if the request fails.
+On failure
+.B errno
+is set to indicate the reason (for example
+.B EINVAL
+for an invalid combination of arguments).
The local key (\fBL_Key\fR) field
.B lkey
is used as the lkey field of struct ibv_sge when posting buffers with