libnvme: add support to NBFT

Resolves: #2188516

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
This commit is contained in:
Maurizio Lombardi 2023-05-16 15:20:35 +02:00
parent 86b18a106c
commit 6564ff2ed9
7 changed files with 2279 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
From 670ec98ebc986e62267145abb059b66ac5e51380 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Thu, 13 Apr 2023 15:39:28 +0200
Subject: [PATCH] nbft: Move added symbols to LIBNVME_1_5
---
src/libnvme.map | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libnvme.map b/src/libnvme.map
index 6aa9fd0..28de595 100644
--- a/src/libnvme.map
+++ b/src/libnvme.map
@@ -1,5 +1,11 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
+LIBNVME_1_5 {
+ global:
+ nvme_nbft_read;
+ nvme_nbft_free;
+};
+
LIBNVME_1_4 {
global:
nvme_lookup_keyring;
@@ -7,8 +13,6 @@ LIBNVME_1_4 {
nvme_lookup_key;
nvme_set_keyring;
nvme_insert_tls_key;
- nvme_nbft_read;
- nvme_nbft_free;
};
LIBNVME_1_3 {
--
2.39.1

View File

@ -0,0 +1,36 @@
From 26e4343c2ba2db7a3c5696bbf61bb87942ac02bb Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Thu, 13 Apr 2023 17:28:42 +0200
Subject: [PATCH] nbft: Fix nbft_ssns_flags endianness test
Missing flags endianness conversion leading to ssns_ext_info
not being parsed on s390x and armhf.
---
src/nvme/nbft.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/nvme/nbft.c b/src/nvme/nbft.c
index f91d21b..940dd8e 100644
--- a/src/nvme/nbft.c
+++ b/src/nvme/nbft.c
@@ -169,7 +169,7 @@ static int read_ssns_exended_info(struct nbft_info *nbft,
"invalid ID in SSNS extended info descriptor");
verify(raw_ssns_ei->version == 1,
"invalid version in SSNS extended info descriptor");
- verify(le16_to_cpu(raw_ssns_ei->ssns_index) == le16_to_cpu(ssns->index),
+ verify(le16_to_cpu(raw_ssns_ei->ssns_index) == ssns->index,
"SSNS index doesn't match extended info descriptor index");
if (!(le32_to_cpu(raw_ssns_ei->flags) & NBFT_SSNS_EXT_INFO_VALID))
@@ -292,7 +292,7 @@ static int read_ssns(struct nbft_info *nbft,
goto fail;
/* SSNS extended info */
- if (raw_ssns->flags & NBFT_SSNS_EXTENDED_INFO_IN_USE) {
+ if (le16_to_cpu(raw_ssns->flags) & NBFT_SSNS_EXTENDED_INFO_IN_USE) {
struct nbft_ssns_ext_info *ssns_extended_info;
if (!get_heap_obj(raw_ssns, ssns_extended_info_desc_obj, 0,
--
2.39.1

View File

@ -0,0 +1,25 @@
From 1617d1a3f42a25a2e99073811174609abcffc34d Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Thu, 13 Apr 2023 18:27:39 +0200
Subject: [PATCH] nbft: Parse the {HOSTID,HOSTNQN}_CONFIGURED flags
---
src/nvme/nbft.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/nvme/nbft.c b/src/nvme/nbft.c
index 940dd8e..c0af2b3 100644
--- a/src/nvme/nbft.c
+++ b/src/nvme/nbft.c
@@ -560,6 +560,8 @@ static int parse_raw_nbft(struct nbft_info *nbft)
nbft->host.id = (unsigned char *) &(host->host_id);
if (get_heap_obj(host, host_nqn_obj, 1, &nbft->host.nqn) != 0)
return -EINVAL;
+ nbft->host.host_id_configured = host->flags & NBFT_HOST_HOSTID_CONFIGURED;
+ nbft->host.host_nqn_configured = host->flags & NBFT_HOST_HOSTNQN_CONFIGURED;
/*
* HFI
--
2.39.1

View File

@ -0,0 +1,26 @@
From 00b48dd3c217a9271c1888e8dbeb4aa9d307e5bf Mon Sep 17 00:00:00 2001
From: Martin Belanger <martin.belanger@dell.com>
Date: Thu, 13 Apr 2023 09:27:04 -0400
Subject: [PATCH] nbft: Doc typo - Use nvme_nbft_free() instead of nbft_free()
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
---
src/nvme/nbft.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/nvme/nbft.c b/src/nvme/nbft.c
index c0af2b3..a085768 100644
--- a/src/nvme/nbft.c
+++ b/src/nvme/nbft.c
@@ -663,7 +663,7 @@ void nvme_nbft_free(struct nbft_info *nbft)
* @filename: Filename of the raw NBFT table to read.
*
* Read and parse the specified NBFT file into a struct nbft_info.
- * Free with nbft_free().
+ * Free with nvme_nbft_free().
*
* Return: 0 on success, errno otherwise.
*/
--
2.39.1

View File

@ -0,0 +1,64 @@
From 961606f0d0547c3eebd47b79c363ab28c95a94ea Mon Sep 17 00:00:00 2001
From: Martin Belanger <martin.belanger@dell.com>
Date: Fri, 14 Apr 2023 11:19:23 -0400
Subject: [PATCH] NBFT: Remove documentation from nbft.c since it's also in
nbft.h
Also, replace nbft_free() by nvme_nbft_free() in documentation
found in nbft.h.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
---
src/nvme/nbft.c | 15 ---------------
src/nvme/nbft.h | 2 +-
2 files changed, 1 insertion(+), 16 deletions(-)
diff --git a/src/nvme/nbft.c b/src/nvme/nbft.c
index a085768..a1e17cd 100644
--- a/src/nvme/nbft.c
+++ b/src/nvme/nbft.c
@@ -626,10 +626,6 @@ static int parse_raw_nbft(struct nbft_info *nbft)
return 0;
}
-/**
- * nvme_nbft_free() - Free the struct nbft_info and its contents
- * @nbft: Parsed NBFT table data.
- */
void nvme_nbft_free(struct nbft_info *nbft)
{
struct nbft_info_hfi **hfi;
@@ -656,17 +652,6 @@ void nvme_nbft_free(struct nbft_info *nbft)
free(nbft);
}
-/**
- * nvme_nbft_read() - Read and parse contents of an ACPI NBFT table
- *
- * @nbft: Parsed NBFT table data.
- * @filename: Filename of the raw NBFT table to read.
- *
- * Read and parse the specified NBFT file into a struct nbft_info.
- * Free with nvme_nbft_free().
- *
- * Return: 0 on success, errno otherwise.
- */
int nvme_nbft_read(struct nbft_info **nbft, const char *filename)
{
__u8 *raw_nbft = NULL;
diff --git a/src/nvme/nbft.h b/src/nvme/nbft.h
index c3caa85..6012e16 100644
--- a/src/nvme/nbft.h
+++ b/src/nvme/nbft.h
@@ -1223,7 +1223,7 @@ struct nbft_info {
* @filename: Filename of the raw NBFT table to read.
*
* Read and parse the specified NBFT file into a struct nbft_info.
- * Free with nbft_free().
+ * Free with nvme_nbft_free().
*
* Return: 0 on success, errno otherwise.
*/
--
2.39.1

View File

@ -4,12 +4,18 @@
Name: libnvme
Summary: Linux-native nvme device management library
Version: 1.4
Release: 4%{?dist}
Release: 5%{?dist}
License: LGPLv2+
URL: https://github.com/linux-nvme/libnvme
Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz
Patch0: 0001-fabrics-Do-not-pass-unsupported-options-to-kernel.patch
Patch1: 0002-nbft-add-NBFT-v1.0-table-support.patch
Patch2: 0003-nbft-Move-added-symbols-to-LIBNVME_1_5.patch
Patch3: 0004-nbft-Fix-nbft_ssns_flags-endianness-test.patch
Patch4: 0005-nbft-Parse-the-HOSTID-HOSTNQN-_CONFIGURED-flags.patch
Patch5: 0006-nbft-Doc-typo-Use-nvme_nbft_free-instead-of-nbft_fre.patch
Patch6: 0007-NBFT-Remove-documentation-from-nbft.c-since-it-s-als.patch
BuildRequires: gcc gcc-c++
BuildRequires: swig
@ -95,6 +101,8 @@ mv %{buildroot}/usr/*.rst %{buildroot}%{_pkgdocdir}/
%{python3_sitearch}/libnvme/*
%changelog
* Tue May 16 2023 Maurizio Lombardi <mlombard@redhat.com> - 1.4-5
- Add support to NBFT (BZ2188516)
* Mon May 08 2023 Maurizio Lombardi <mlombard@redhat.com> - 1.4-4
- Fix BZ#2190206