Blame SOURCES/0043-Documentation-cxl-add-library-API-documentation.patch

e0018b
From 62fe17528d362110e258d56d8a2f44f2798f3f45 Mon Sep 17 00:00:00 2001
e0018b
From: Vishal Verma <vishal.l.verma@intel.com>
e0018b
Date: Thu, 7 Oct 2021 02:21:36 -0600
e0018b
Subject: [PATCH 043/217] Documentation/cxl: add library API documentation
e0018b
e0018b
Add library API documentation for libcxl(3) using the existing
e0018b
asciidoc(tor) build system. Add a section 3 man page for 'libcxl' that
e0018b
provides an overview of the library and its usage, and a man page for
e0018b
the 'cxl_new()' API.
e0018b
e0018b
Cc: Ben Widawsky <ben.widawsky@intel.com>
e0018b
Cc: Dan Williams <dan.j.williams@intel.com>
e0018b
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 .gitignore                        |  3 ++
e0018b
 Documentation/cxl/lib/Makefile.am | 58 +++++++++++++++++++++++++++++++
e0018b
 Documentation/cxl/lib/cxl_new.txt | 43 +++++++++++++++++++++++
e0018b
 Documentation/cxl/lib/libcxl.txt  | 56 +++++++++++++++++++++++++++++
e0018b
 Makefile.am                       |  1 +
e0018b
 configure.ac                      |  1 +
e0018b
 6 files changed, 162 insertions(+)
e0018b
 create mode 100644 Documentation/cxl/lib/Makefile.am
e0018b
 create mode 100644 Documentation/cxl/lib/cxl_new.txt
e0018b
 create mode 100644 Documentation/cxl/lib/libcxl.txt
e0018b
e0018b
diff --git a/.gitignore b/.gitignore
e0018b
index 6a97b92..6468c7a 100644
e0018b
--- a/.gitignore
e0018b
+++ b/.gitignore
e0018b
@@ -14,12 +14,15 @@ Makefile.in
e0018b
 /libtool
e0018b
 /stamp-h1
e0018b
 *.1
e0018b
+*.3
e0018b
 Documentation/daxctl/asciidoc.conf
e0018b
 Documentation/ndctl/asciidoc.conf
e0018b
 Documentation/cxl/asciidoc.conf
e0018b
+Documentation/cxl/lib/asciidoc.conf
e0018b
 Documentation/daxctl/asciidoctor-extensions.rb
e0018b
 Documentation/ndctl/asciidoctor-extensions.rb
e0018b
 Documentation/cxl/asciidoctor-extensions.rb
e0018b
+Documentation/cxl/lib/asciidoctor-extensions.rb
e0018b
 Documentation/ndctl/attrs.adoc
e0018b
 .dirstamp
e0018b
 daxctl/config.h
e0018b
diff --git a/Documentation/cxl/lib/Makefile.am b/Documentation/cxl/lib/Makefile.am
e0018b
new file mode 100644
e0018b
index 0000000..41e3a5f
e0018b
--- /dev/null
e0018b
+++ b/Documentation/cxl/lib/Makefile.am
e0018b
@@ -0,0 +1,58 @@
e0018b
+# SPDX-License-Identifier: GPL-2.0
e0018b
+# Copyright (C) 2020-2021 Intel Corporation. All rights reserved.
e0018b
+
e0018b
+if USE_ASCIIDOCTOR
e0018b
+
e0018b
+do_subst = sed -e 's,@Utility@,Libcxl,g' -e's,@utility@,libcxl,g'
e0018b
+CONFFILE = asciidoctor-extensions.rb
e0018b
+asciidoctor-extensions.rb: ../../asciidoctor-extensions.rb.in
e0018b
+	$(AM_V_GEN) $(do_subst) < $< > $@
e0018b
+
e0018b
+else
e0018b
+
e0018b
+do_subst = sed -e 's,UTILITY,libcxl,g'
e0018b
+CONFFILE = asciidoc.conf
e0018b
+asciidoc.conf: ../../asciidoc.conf.in
e0018b
+	$(AM_V_GEN) $(do_subst) < $< > $@
e0018b
+
e0018b
+endif
e0018b
+
e0018b
+man3_MANS = \
e0018b
+	libcxl.3 \
e0018b
+	cxl_new.3
e0018b
+
e0018b
+EXTRA_DIST = $(man3_MANS)
e0018b
+
e0018b
+CLEANFILES = $(man3_MANS)
e0018b
+
e0018b
+XML_DEPS = \
e0018b
+	../../../version.m4 \
e0018b
+	../../copyright.txt \
e0018b
+	Makefile \
e0018b
+	$(CONFFILE)
e0018b
+
e0018b
+RM ?= rm -f
e0018b
+
e0018b
+if USE_ASCIIDOCTOR
e0018b
+
e0018b
+%.3: %.txt $(XML_DEPS)
e0018b
+	$(AM_V_GEN)$(RM) $@+ $@ && \
e0018b
+		$(ASCIIDOC) -b manpage -d manpage -acompat-mode \
e0018b
+		-I. -rasciidoctor-extensions \
e0018b
+		-amansource=libcxl -amanmanual="libcxl Manual" \
e0018b
+		-andctl_version=$(VERSION) -o $@+ $< && \
e0018b
+		mv $@+ $@
e0018b
+
e0018b
+else
e0018b
+
e0018b
+%.xml: %.txt $(XML_DEPS)
e0018b
+	$(AM_V_GEN)$(RM) $@+ $@ && \
e0018b
+		$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
e0018b
+		--unsafe -alibcxl_version=$(VERSION) -o $@+ $< && \
e0018b
+		mv $@+ $@
e0018b
+
e0018b
+%.3: %.xml $(XML_DEPS)
e0018b
+	$(AM_V_GEN)$(RM) $@ && \
e0018b
+		$(XMLTO) -o . -m ../../manpage-normal.xsl man $<
e0018b
+
e0018b
+endif
e0018b
diff --git a/Documentation/cxl/lib/cxl_new.txt b/Documentation/cxl/lib/cxl_new.txt
e0018b
new file mode 100644
e0018b
index 0000000..147d4e0
e0018b
--- /dev/null
e0018b
+++ b/Documentation/cxl/lib/cxl_new.txt
e0018b
@@ -0,0 +1,43 @@
e0018b
+// SPDX-License-Identifier: LGPL-2.0
e0018b
+
e0018b
+cxl_new(3)
e0018b
+==========
e0018b
+
e0018b
+NAME
e0018b
+----
e0018b
+cxl_new - Create a new library context object that acts as a handle for all
e0018b
+library operations
e0018b
+
e0018b
+SYNOPSIS
e0018b
+--------
e0018b
+[verse]
e0018b
+----
e0018b
+#include <cxl/libcxl.h>
e0018b
+
e0018b
+int cxl_new(struct cxl_ctx **ctx);
e0018b
+----
e0018b
+
e0018b
+DESCRIPTION
e0018b
+-----------
e0018b
+Instantiates a new library context, and stores an opaque pointer in ctx. The
e0018b
+context is freed by linklibcxl:cxl_unref[3], i.e. cxl_new(3) implies an
e0018b
+internal linklibcxl:cxl_ref[3].
e0018b
+
e0018b
+
e0018b
+RETURN VALUE
e0018b
+------------
e0018b
+Returns 0 on success, and a negative errno on failure.
e0018b
+Possible error codes are:
e0018b
+
e0018b
+ * -ENOMEM
e0018b
+ * -ENXIO
e0018b
+
e0018b
+EXAMPLE
e0018b
+-------
e0018b
+See example usage in test/libcxl.c
e0018b
+
e0018b
+include::../../copyright.txt[]
e0018b
+
e0018b
+SEE ALSO
e0018b
+--------
e0018b
+linklibcxl:cxl_ref[3], linklibcxl:cxl_unref[3]
e0018b
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
e0018b
new file mode 100644
e0018b
index 0000000..2539369
e0018b
--- /dev/null
e0018b
+++ b/Documentation/cxl/lib/libcxl.txt
e0018b
@@ -0,0 +1,56 @@
e0018b
+// SPDX-License-Identifier: LGPL-2.0
e0018b
+
e0018b
+libcxl(3)
e0018b
+=========
e0018b
+
e0018b
+NAME
e0018b
+----
e0018b
+libcxl - A library to interact with CXL devices through sysfs(5)
e0018b
+and ioctl(2) interfaces
e0018b
+
e0018b
+SYNOPSIS
e0018b
+--------
e0018b
+[verse]
e0018b
+#include <cxl/libcxl.h>
e0018b
+cc ... -lcxl
e0018b
+
e0018b
+DESCRIPTION
e0018b
+-----------
e0018b
+libcxl provides interfaces to interact with CXL devices in Linux, using sysfs
e0018b
+interfaces for most kernel interactions, and the ioctl() interface for command
e0018b
+submission.
e0018b
+
e0018b
+The starting point for all library interfaces is a 'cxl_ctx' object, returned
e0018b
+by linklibcxl:cxl_new[3]. CXL 'Type 3' memory devices are children of the
e0018b
+cxl_ctx object, and can be iterated through using an iterator API.
e0018b
+
e0018b
+Library level interfaces that are agnostic to any device, or a specific
e0018b
+subclass of operations have the prefix 'cxl_'
e0018b
+
e0018b
+The object representing a CXL Type 3 device is 'cxl_memdev'. Library interfaces
e0018b
+related to these devices have the prefix 'cxl_memdev_'. These interfaces are
e0018b
+mostly associated with sysfs interactions (unless otherwise noted in their
e0018b
+respective documentation pages). They are typically used to retrieve data
e0018b
+published by the kernel, or to send data or trigger kernel operations for a
e0018b
+given device.
e0018b
+
e0018b
+A 'cxl_cmd' is a reference counted object which is used to perform 'Mailbox'
e0018b
+commands as described in the CXL Specification. A 'cxl_cmd' object is tied to a
e0018b
+'cxl_memdev'. Associated library interfaces have the prefix 'cxl_cmd_'. Within
e0018b
+this sub-class of interfaces, there are:
e0018b
+
e0018b
+ * 'cxl_cmd_new_*' interfaces that allocate a new cxl_cmd object for a given
e0018b
+   command type.
e0018b
+
e0018b
+ * 'cxl_cmd_submit' which submits the command via ioctl()
e0018b
+
e0018b
+ * 'cxl_cmd_<name>_get_<field>' interfaces that get specific fields out of the
e0018b
+   command response
e0018b
+
e0018b
+ * 'cxl_cmd_get_*' interfaces to get general command related information.
e0018b
+
e0018b
+include::../../copyright.txt[]
e0018b
+
e0018b
+SEE ALSO
e0018b
+--------
e0018b
+linklibcxl:cxl[1]
e0018b
diff --git a/Makefile.am b/Makefile.am
e0018b
index 4904ee7..e2f6bef 100644
e0018b
--- a/Makefile.am
e0018b
+++ b/Makefile.am
e0018b
@@ -4,6 +4,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
e0018b
 SUBDIRS = . cxl/lib daxctl/lib ndctl/lib cxl ndctl daxctl
e0018b
 if ENABLE_DOCS
e0018b
 SUBDIRS += Documentation/ndctl Documentation/daxctl Documentation/cxl
e0018b
+SUBDIRS += Documentation/cxl/lib
e0018b
 endif
e0018b
 SUBDIRS += test
e0018b
 
e0018b
diff --git a/configure.ac b/configure.ac
e0018b
index dadae0a..00497ae 100644
e0018b
--- a/configure.ac
e0018b
+++ b/configure.ac
e0018b
@@ -231,6 +231,7 @@ AC_CONFIG_FILES([
e0018b
         Documentation/ndctl/Makefile
e0018b
         Documentation/daxctl/Makefile
e0018b
         Documentation/cxl/Makefile
e0018b
+        Documentation/cxl/lib/Makefile
e0018b
 ])
e0018b
 
e0018b
 AC_OUTPUT
e0018b
-- 
e0018b
2.27.0
e0018b