Skip to content

Commit

Permalink
alvistack/v80
Browse files Browse the repository at this point in the history
    git clean -xdf
    tar zcvf ../ndctl_80.orig.tar.gz --exclude=.git .
    debuild -uc -us
    cp ndctl.spec ../ndctl_80-1.spec
    cp ndctl.rpmlintrc /osc/home\:alvistack/pmem-ndctl-80/
    cp ../ndctl*80*.{gz,xz,spec,dsc} /osc/home\:alvistack/pmem-ndctl-80/
    rm -rf ../*ndctl*80*.* ../*daxctl*80*.* ../*libcxl*80*.*

See pmem#267
Revert pmem@9873123

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
  • Loading branch information
hswong3i committed Oct 11, 2024
1 parent 04815e5 commit 60a9ee7
Show file tree
Hide file tree
Showing 22 changed files with 669 additions and 205 deletions.
195 changes: 0 additions & 195 deletions cxl/json.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2015-2021 Intel Corporation. All rights reserved.
#include <limits.h>
#include <errno.h>
#include <util/json.h>
#include <util/bitmap.h>
#include <uuid/uuid.h>
#include <cxl/libcxl.h>
#include <json-c/json.h>
#include <json-c/printbuf.h>
#include <ccan/short_types/short_types.h>
#include <tracefs/tracefs.h>

#include "filter.h"
#include "json.h"
#include "../daxctl/json.h"
#include "../util/event_trace.h"

#define CXL_FW_VERSION_STR_LEN 16
#define CXL_FW_MAX_SLOTS 4
Expand Down Expand Up @@ -575,185 +571,6 @@ static struct json_object *util_cxl_memdev_partition_to_json(struct cxl_memdev *
return NULL;
}

/* CXL Spec 3.1 Table 8-140 Media Error Record */
#define CXL_POISON_SOURCE_MAX 7
static const char *const poison_source[] = { "Unknown", "External", "Internal",
"Injected", "Reserved", "Reserved",
"Reserved", "Vendor Specific" };

/* CXL Spec 3.1 Table 8-139 Get Poison List Output Payload */
#define CXL_POISON_FLAG_MORE BIT(0)
#define CXL_POISON_FLAG_OVERFLOW BIT(1)
#define CXL_POISON_FLAG_SCANNING BIT(2)

static int poison_event_to_json(struct tep_event *event,
struct tep_record *record,
struct event_ctx *e_ctx)
{
struct cxl_poison_ctx *p_ctx = e_ctx->poison_ctx;
struct json_object *jp, *jobj, *jpoison = p_ctx->jpoison;
struct cxl_memdev *memdev = p_ctx->memdev;
struct cxl_region *region = p_ctx->region;
unsigned long flags = e_ctx->json_flags;
const char *region_name = NULL;
char flag_str[32] = { '\0' };
bool overflow = false;
u8 source, pflags;
u64 offset, ts;
u32 length;
char *str;
int len;

jp = json_object_new_object();
if (!jp)
return -ENOMEM;

/* Skip records not in this region when listing by region */
if (region)
region_name = cxl_region_get_devname(region);
if (region_name)
str = tep_get_field_raw(NULL, event, "region", record, &len, 0);
if ((region_name) && (strcmp(region_name, str) != 0)) {
json_object_put(jp);
return 0;
}
/* Include offset,length by region (hpa) or by memdev (dpa) */
if (region) {
offset = trace_get_field_u64(event, record, "hpa");
if (offset != ULLONG_MAX) {
offset = offset - cxl_region_get_resource(region);
jobj = util_json_object_hex(offset, flags);
if (jobj)
json_object_object_add(jp, "offset", jobj);
}
} else if (memdev) {
offset = trace_get_field_u64(event, record, "dpa");
if (offset != ULLONG_MAX) {
jobj = util_json_object_hex(offset, flags);
if (jobj)
json_object_object_add(jp, "offset", jobj);
}
}
length = trace_get_field_u32(event, record, "dpa_length");
jobj = util_json_object_size(length, flags);
if (jobj)
json_object_object_add(jp, "length", jobj);

/* Always include the poison source */
source = trace_get_field_u8(event, record, "source");
if (source <= CXL_POISON_SOURCE_MAX)
jobj = json_object_new_string(poison_source[source]);
else
jobj = json_object_new_string("Reserved");
if (jobj)
json_object_object_add(jp, "source", jobj);

/* Include flags and overflow time if present */
pflags = trace_get_field_u8(event, record, "flags");
if (pflags && pflags < UCHAR_MAX) {
if (pflags & CXL_POISON_FLAG_MORE)
strcat(flag_str, "More,");
if (pflags & CXL_POISON_FLAG_SCANNING)
strcat(flag_str, "Scanning,");
if (pflags & CXL_POISON_FLAG_OVERFLOW) {
strcat(flag_str, "Overflow,");
overflow = true;
}
jobj = json_object_new_string(flag_str);
if (jobj)
json_object_object_add(jp, "flags", jobj);
}
if (overflow) {
ts = trace_get_field_u64(event, record, "overflow_ts");
jobj = util_json_object_hex(ts, flags);
if (jobj)
json_object_object_add(jp, "overflow_t", jobj);
}
json_object_array_add(jpoison, jp);

return 0;
}

static struct json_object *
util_cxl_poison_events_to_json(struct tracefs_instance *inst,
struct cxl_poison_ctx *p_ctx,
unsigned long flags)
{
struct event_ctx ectx = {
.event_name = "cxl_poison",
.event_pid = getpid(),
.system = "cxl",
.poison_ctx = p_ctx,
.json_flags = flags,
.parse_event = poison_event_to_json,
};
int rc;

p_ctx->jpoison = json_object_new_array();
if (!p_ctx->jpoison)
return NULL;

rc = trace_event_parse(inst, &ectx);
if (rc < 0) {
fprintf(stderr, "Failed to parse events: %d\n", rc);
goto put_jobj;
}
if (json_object_array_length(p_ctx->jpoison) == 0)
goto put_jobj;

return p_ctx->jpoison;

put_jobj:
json_object_put(p_ctx->jpoison);
return NULL;
}

static struct json_object *
util_cxl_poison_list_to_json(struct cxl_region *region,
struct cxl_memdev *memdev,
unsigned long flags)
{
struct json_object *jpoison = NULL;
struct cxl_poison_ctx p_ctx;
struct tracefs_instance *inst;
int rc;

inst = tracefs_instance_create("cxl list");
if (!inst) {
fprintf(stderr, "tracefs_instance_create() failed\n");
return NULL;
}

rc = trace_event_enable(inst, "cxl", "cxl_poison");
if (rc < 0) {
fprintf(stderr, "Failed to enable trace: %d\n", rc);
goto err_free;
}

if (region)
rc = cxl_region_trigger_poison_list(region);
else
rc = cxl_memdev_trigger_poison_list(memdev);
if (rc)
goto err_free;

rc = trace_event_disable(inst);
if (rc < 0) {
fprintf(stderr, "Failed to disable trace: %d\n", rc);
goto err_free;
}

p_ctx = (struct cxl_poison_ctx){
.region = region,
.memdev = memdev,
};
jpoison = util_cxl_poison_events_to_json(inst, &p_ctx, flags);

err_free:
tracefs_instance_free(inst);
return jpoison;
}

struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
unsigned long flags)
{
Expand Down Expand Up @@ -855,12 +672,6 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,
json_object_object_add(jdev, "firmware", jobj);
}

if (flags & UTIL_JSON_MEDIA_ERRORS) {
jobj = util_cxl_poison_list_to_json(NULL, memdev, flags);
if (jobj)
json_object_object_add(jdev, "media_errors", jobj);
}

json_object_set_userdata(jdev, memdev, NULL);
return jdev;
}
Expand Down Expand Up @@ -1209,12 +1020,6 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region,
json_object_object_add(jregion, "state", jobj);
}

if (flags & UTIL_JSON_MEDIA_ERRORS) {
jobj = util_cxl_poison_list_to_json(region, NULL, flags);
if (jobj)
json_object_object_add(jregion, "media_errors", jobj);
}

util_cxl_mappings_append_json(jregion, region, flags);

if (flags & UTIL_JSON_DAX) {
Expand Down
1 change: 0 additions & 1 deletion cxl/lib/libcxl.sym
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ global:
cxl_mapping_get_first;
cxl_mapping_get_next;
cxl_mapping_get_decoder;
cxl_mapping_get_region;
cxl_mapping_get_position;
cxl_decoder_get_by_name;
cxl_decoder_get_memdev;
Expand Down
1 change: 0 additions & 1 deletion cxl/libcxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ struct cxl_memdev_mapping *cxl_mapping_get_first(struct cxl_region *region);
struct cxl_memdev_mapping *
cxl_mapping_get_next(struct cxl_memdev_mapping *mapping);
struct cxl_decoder *cxl_mapping_get_decoder(struct cxl_memdev_mapping *mapping);
struct cxl_region *cxl_mapping_get_region(struct cxl_memdev_mapping *mapping);
unsigned int cxl_mapping_get_position(struct cxl_memdev_mapping *mapping);

#define cxl_mapping_foreach(region, mapping) \
Expand Down
13 changes: 13 additions & 0 deletions debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.substvars
*debhelper*
.debhelper
files
tmp
daxctl
libcxl-dev
libcxl1
libdaxctl-dev
libdaxctl1
libndctl-dev
libndctl6
ndctl
2 changes: 2 additions & 0 deletions debian/90-daxctl-device.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ACTION=="add", SUBSYSTEM=="dax",\
RUN+="/usr/bin/daxctl -C $env{DEVNAME}"
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ndctl (100:80-1) UNRELEASED; urgency=medium

* https://github.com/pmem/ndctl/releases/tag/v80

-- Wong Hoi Sing Edison <[email protected]> Fri, 11 Oct 2024 14:08:08 +0800
114 changes: 114 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Source: ndctl
Maintainer: Ubuntu Developers <[email protected]>
XSBC-Original-Maintainer: Adam Borowski <[email protected]>
Section: libs
Priority: optional
Standards-Version: 4.5.0
Build-Depends: debhelper-compat (= 10),
debhelper,
pkg-config,
libkmod-dev,
libudev-dev,
uuid-dev,
libjson-c-dev,
bash-completion,
libkeyutils-dev,
libiniparser-dev,
meson,
cmake,
Rules-Requires-Root: no
Homepage: https://github.com/pmem/ndctl/tags
Vcs-Git: https://github.com/kilobyte/ndctl -b debian
Vcs-Browser: https://github.com/kilobyte/ndctl/tree/debian

Package: ndctl
Section: misc
Architecture: linux-any
Multi-Arch: foreign
Depends: ${shlibs:Depends}, ${misc:Depends}
Pre-Depends: ${misc:Pre-Depends}
# RPM-world's name for cxl tools
Provides: cxl-cli
Description: Utility for managing the nvdimm subsystem
The nvdimm subsystem defines a kernel device model and control message
interface for platform NVDIMM resources like those defined by the ACPI 6+ NFIT
(NVDIMM Firmware Interface Table).
.
This package contains a utility for managing the nvdimm (non-volatile memory
device) subsystem in the Linux kernel.

Package: libndctl6
Architecture: linux-any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Utility library for managing the libnvdimm subsystem
The nvdimm subsystem defines a kernel device model and control message
interface for platform NVDIMM resources like those defined by the ACPI 6+ NFIT
(NVDIMM Firmware Interface Table).
.
This package contains a utility library for managing the libnvdimm
(non-volatile memory device) sub-system in the Linux kernel.

Package: libndctl-dev
Section: libdevel
Architecture: linux-any
Multi-Arch: same
Depends: libndctl6 (= ${binary:Version}), ${misc:Depends}
Description: Development files for libndctl
Header files and development library for compiling C programs to link
with the libndctl library and manage the libnvdimm sub-system in the
Linux kernel.

Package: daxctl
Section: misc
Architecture: linux-any
Multi-Arch: foreign
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Utility for managing the device DAX subsystem
"DAX" are file system extensions to bypass the page cache and block layer to
mmap persistent memory, from a PMEM block device, directly into a process
address space.
.
This package contains a utility for managing the device DAX subsystem in the
Linux kernel.

Package: libdaxctl1
Architecture: linux-any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Utility library for managing the device DAX subsystem
"DAX" are file system extensions to bypass the page cache and block layer to
mmap persistent memory, from a PMEM block device, directly into a process
address space.
.
This package contains a utility library used by applications to manage the
device DAX subsystem in the Linux kernel.

Package: libdaxctl-dev
Section: libdevel
Architecture: linux-any
Multi-Arch: same
Depends: libdaxctl1 (= ${binary:Version}), ${misc:Depends}
Description: Development files for libdaxctl
Header files and development library for compiling C programs to link
with the libdaxctl library and manage the device DAX subsystem in the
Linux kernel.

Package: libcxl1
Architecture: linux-any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: utility library for managing Compute Express Link devices
CXL (Compute Express Link) is a family of PCIe-based protocols that can be
used to connect high-speed I/O and memory devices. This library includes
code to enumerate/query/configure such devices.

Package: libcxl-dev
Section: libdevel
Architecture: linux-any
Multi-Arch: same
Depends: libcxl1 (= ${binary:Version}), ${misc:Depends}
Description: Development files for libcxl
Header files and development library for compiling C programs to link
with the libcxl library and manage the Compute Express Link subsystem in
the Linux kernel.
Loading

0 comments on commit 60a9ee7

Please sign in to comment.