Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ neuron-objs += neuron_dmabuf.o
neuron-objs += neuron_log.o
neuron-objs += neuron_power.o
neuron-objs += vc/neuron_dhal_vc.o
neuron-objs += v1/fw_io.o v1/putils.o v1/neuron_dhal_v1.o
neuron-objs += v2/notific.o v2/neuron_dhal_v2.o
neuron-objs += v3/notific.o v3/neuron_dhal_v3.o v3/neuron_pelect.o

neuron-objs += v4/neuron_dhal_v4.o
ccflags-y += -O3 -Wall -Werror -Wno-declaration-after-statement -Wunused-macros -Wunused-local-typedefs
ccflags-y += -I$(src)/
ccflags-y += $(call cc-option,-march=armv8.2-a)
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ Neuron Devices implement a communication channel (FWIO) that allows the driver a
* neuron_cdev.c - char device interface.
* fw_io.[ch] - Communication channel
* udma/* - DMA engines and queues HAL
* v1/address_map.h - Neuron Device address space
* v1/putils.h - Notification HAL
* v1/tdma.h - Additional DMA HAL functionality

# Compiling and Installing

Expand Down
2 changes: 1 addition & 1 deletion dkms.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME=aws-neuronx
PACKAGE_VERSION=2.24.7.0
PACKAGE_VERSION=2.25.4.0
BUILT_MODULE_NAME[0]="neuron"
MAKE[0]="make -C ${kernel_source_dir} M=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build"
CLEAN="make -C ${kernel_source_dir} M=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build clean"
Expand Down
35 changes: 35 additions & 0 deletions neuron_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__

#include "neuron_arch.h"
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
#include <linux/kernel_read_file.h>
#endif

struct neuron_arch_info {
enum neuron_arch arch;
Expand Down Expand Up @@ -55,3 +62,31 @@ bool narch_is_emu(void)
BUG_ON(arch_info.arch == NEURON_ARCH_INVALID);
return arch_info.revision == REVID_EMU;
}

int narch_get_instance_type_name(char *instance_type_name, size_t instance_type_name_size) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
ssize_t len;
ssize_t file_size;
void *buf = kzalloc(PAGE_SIZE, GFP_KERNEL);

if (buf == NULL) {
pr_err("failed to allocate buffer to read instance type");
return -ENOMEM;
}

len = kernel_read_file_from_path("/sys/class/dmi/id/product_name",
0, &buf, 64, &file_size, READING_UNKNOWN);
if (!len) {
pr_err("read instance type failed");
kfree(buf);
return -EIO;
}

snprintf(instance_type_name, instance_type_name_size, "%s", (char *)buf);

kfree(buf);
return 0;
#else
return -ENOSYS;
#endif
}
25 changes: 24 additions & 1 deletion neuron_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@

enum neuron_arch {
NEURON_ARCH_INVALID,
NEURON_ARCH_V1 = 1,
NEURON_ARCH_V2 = 2,
NEURON_ARCH_V3 = 3,
NEURON_ARCH_V4 = 4,
NEURON_ARCH_NUM
};

enum neuron_platform_type {
NEURON_PLATFORM_TYPE_STD = 0,
NEURON_PLATFORM_TYPE_ULTRASERVER = 1,
NEURON_PLATFORM_TYPE_PDS = 2,
NEURON_PLATFORM_TYPE_INVALID,
};

/**
* narch_init() - Set neuron devices architecture and revision.
*
Expand Down Expand Up @@ -55,4 +62,20 @@ bool narch_is_qemu(void);
*/
bool narch_is_emu(void);

/**
* narch_get_instance_type_name() - Reads instance type name from device DMI data.
*
* @instance_type_name: Buffer to store the instance type name string.
* @instance_type_name_size: Size of the instance_type_name buffer.
*
* Note: This function is only available on kernel versions 5.10.0 and above.
*
* Return:
* * 0 if read succeeds,
* * -ENOMEM - Failed to allocate temporary buffer for reading.
* * -EIO - Failed to read the DMI product_name file.
* * -ENOSYS - Kernel version is below 5.10.0, function not supported.
*/
int narch_get_instance_type_name(char *instance_type_name, size_t instance_type_name_size);

#endif
Loading