libpldm: Explicit deprecated, stable and testing ABI classes

Experimenting with new APIs is important, but ABI stability of the
library is also important. We wish to have the freedom to add APIs
without being burdened by them being immediately set in stone.

We implement this wish by introducing three classes of ABI:

1. deprecated
2. stable
3. testing

These are enforced by corresponding function attributes:

1. LIBPLDM_ABI_DEPRECATED
2. LIBPLDM_ABI_STABLE
3. LIBPLDM_ABI_TESTING

Symbol visibility in the library is flipped to 'hidden' by default, so
one of these annotations must be used for the symbol to be exposed.

With these classes in place there are now clear points in time at which
we update the ABI dumps captured under the abi/ directory: When an API
is migrated from the 'testing' class to the 'stable' class, or when
removed from the 'deprecated' class.

Which classes of functions are exposed by the build is controlled by the
new 'abi' meson option. The option is of array type which contains the
list of ABI classes the build should consider. It defaults to enabling
all classes to provide test coverage in CI. The classes used should be
constrained to deprecated and stable (and not test) in any dependent
projects.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I25402e20c7be9c9f264f9ccd7ac36b384823734c
diff --git a/src/base.c b/src/base.c
index 90e9c1e..f0bbe82 100644
--- a/src/base.c
+++ b/src/base.c
@@ -1,9 +1,11 @@
+#include "config.h"
 #include "base.h"
 #include "pldm_types.h"
 #include <endian.h>
 #include <stdint.h>
 #include <string.h>
 
+LIBPLDM_ABI_STABLE
 uint8_t pack_pldm_header(const struct pldm_header_info *hdr,
 			 struct pldm_msg_hdr *msg)
 {
@@ -42,6 +44,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 uint8_t unpack_pldm_header(const struct pldm_msg_hdr *msg,
 			   struct pldm_header_info *hdr)
 {
@@ -63,6 +66,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg)
 {
 	if (msg == NULL) {
@@ -77,6 +81,7 @@
 	return pack_pldm_header(&header, &(msg->hdr));
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version,
 			    struct pldm_msg *msg)
 {
@@ -103,6 +108,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code,
 			  const bitfield8_t *types, struct pldm_msg *msg)
 {
@@ -133,6 +139,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length,
 			    uint8_t *type, ver32_t *version)
 {
@@ -151,6 +158,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code,
 			     const bitfield8_t *commands, struct pldm_msg *msg)
 {
@@ -181,6 +189,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length,
 			  uint8_t *completion_code, bitfield8_t *types)
 {
@@ -205,6 +214,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length,
 			     uint8_t *completion_code, bitfield8_t *commands)
 {
@@ -230,6 +240,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle,
 			   uint8_t transfer_opflag, uint8_t type,
 			   struct pldm_msg *msg)
@@ -259,6 +270,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code,
 			    uint32_t next_transfer_handle,
 			    uint8_t transfer_flag, const ver32_t *version_data,
@@ -291,6 +303,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length,
 			   uint32_t *transfer_handle, uint8_t *transfer_opflag,
 			   uint8_t *type)
@@ -307,6 +320,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length,
 			    uint8_t *completion_code,
 			    uint32_t *next_transfer_handle,
@@ -336,6 +350,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_get_tid_req(uint8_t instance_id, struct pldm_msg *msg)
 {
 	if (msg == NULL) {
@@ -349,6 +364,8 @@
 
 	return pack_pldm_header(&header, &(msg->hdr));
 }
+
+LIBPLDM_ABI_STABLE
 int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code,
 			uint8_t tid, struct pldm_msg *msg)
 {
@@ -374,6 +391,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length,
 			uint8_t *completion_code, uint8_t *tid)
 {
@@ -398,6 +416,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_set_tid_req(uint8_t instance_id, uint8_t tid, struct pldm_msg *msg)
 {
 	if (msg == NULL) {
@@ -425,6 +444,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int decode_multipart_receive_req(const struct pldm_msg *msg,
 				 size_t payload_length, uint8_t *pldm_type,
 				 uint8_t *transfer_opflag,
@@ -478,6 +498,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_cc_only_resp(uint8_t instance_id, uint8_t type, uint8_t command,
 			uint8_t cc, struct pldm_msg *msg)
 {
@@ -501,6 +522,7 @@
 	return PLDM_SUCCESS;
 }
 
+LIBPLDM_ABI_STABLE
 int encode_pldm_header_only(uint8_t msg_type, uint8_t instance_id,
 			    uint8_t pldm_type, uint8_t command,
 			    struct pldm_msg *msg)