anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

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

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