diff --git a/0001-dsa_test-Use-syscall-write-to-submit-descriptor.patch b/0001-dsa_test-Use-syscall-write-to-submit-descriptor.patch new file mode 100644 index 0000000000000000000000000000000000000000..55c562bec01d225c4783f9c5fb0a9b3d66300807 --- /dev/null +++ b/0001-dsa_test-Use-syscall-write-to-submit-descriptor.patch @@ -0,0 +1,136 @@ +From 99405e8b438b1e9f4b41d94c6d29b657e3cd6ffb Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Tue, 1 Oct 2024 13:23:58 +0800 +Subject: [PATCH 1/2] dsa_test: Use syscall write to submit descriptor + +Intel updated kernel driver to prevent the accelerators from being directly +mapped into unprivileged user applications, because malicious may be +able to cause corrupt memory. + +Align with the kernel change, write the descriptor to cdev instead of +enqcmd by default when submit shared work queue descriptor. Meanwhile, retain +the enqcmd way if force to use it with new option '-u'. + +More details refer to link: +https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-01084.html + +Signed-off-by: Yi Sun +--- + test/accel_test.c | 31 +++++++++++++++++++++---------- + test/accel_test.h | 1 + + test/dsa_test.c | 6 +++++- + 3 files changed, 27 insertions(+), 11 deletions(-) + +diff --git a/test/accel_test.c b/test/accel_test.c +index e7f0e8e..f23295c 100644 +--- a/test/accel_test.c ++++ b/test/accel_test.c +@@ -18,6 +18,7 @@ + + unsigned int ms_timeout = 5000; + int debug_logging; ++int force_enqcmd = 0; + static int umwait_support; + + static inline void cpuid(unsigned int *eax, unsigned int *ebx, +@@ -90,11 +91,13 @@ static int acctest_setup_wq(struct acctest_context *ctx, struct accfg_wq *wq) + return -errno; + } + +- ctx->wq_reg = mmap(NULL, PAGE_SIZE, PROT_WRITE, +- MAP_SHARED | MAP_POPULATE, ctx->fd, 0); +- if (ctx->wq_reg == MAP_FAILED) { +- perror("mmap"); +- return -errno; ++ if (force_enqcmd) { ++ ctx->wq_reg = mmap(NULL, PAGE_SIZE, PROT_WRITE, ++ MAP_SHARED | MAP_POPULATE, ctx->fd, 0); ++ if (ctx->wq_reg == MAP_FAILED) { ++ perror("mmap"); ++ return -errno; ++ } + } + + return 0; +@@ -295,14 +298,22 @@ struct task *acctest_alloc_task(struct acctest_context *ctx) + return tsk; + } + +-static int acctest_enqcmd(struct acctest_context *ctx, struct hw_desc *hw) ++static int acctest_desc_submit_swq(struct acctest_context *ctx, struct hw_desc *hw) + { + int retry_count = 0; + int ret = 0; + + while (retry_count < 3) { +- if (!enqcmd(ctx->wq_reg, hw)) +- break; ++ if (force_enqcmd) { ++ info("Submitting descriptor via ENQCMD\n"); ++ if (!enqcmd(ctx->wq_reg, hw)) ++ break; ++ } else { ++ info("Submitting descriptor via syscall write\n"); ++ ret = write(ctx->fd, hw, sizeof(struct hw_desc)); ++ if (ret == sizeof(struct hw_desc)) ++ break; ++ } + + info("retry\n"); + retry_count++; +@@ -535,7 +546,7 @@ void acctest_desc_submit(struct acctest_context *ctx, struct hw_desc *hw) + /* use MOVDIR64B for DWQ */ + if (ctx->dedicated) + movdir64b(ctx->wq_reg, hw); +- else /* use ENQCMD for SWQ */ +- if (acctest_enqcmd(ctx, hw)) ++ else /* use ENQCMD or write for SWQ */ ++ if (acctest_desc_submit_swq(ctx, hw)) + usleep(10000); + } +diff --git a/test/accel_test.h b/test/accel_test.h +index 1402620..7cdeca6 100644 +--- a/test/accel_test.h ++++ b/test/accel_test.h +@@ -48,6 +48,7 @@ + + extern unsigned int ms_timeout; + extern int debug_logging; ++extern int force_enqcmd; + + struct task { + struct hw_desc *desc; +diff --git a/test/dsa_test.c b/test/dsa_test.c +index c5a2dda..ecadaf2 100644 +--- a/test/dsa_test.c ++++ b/test/dsa_test.c +@@ -35,6 +35,7 @@ static void usage(void) + "-e ; evl pattern :<..>\n" + " ; ::\n" + "-v ; verbose\n" ++ "-u ; use ENQCMD to submit descriptor\n" + "-h ; print this message\n"); + } + +@@ -849,7 +850,7 @@ int main(int argc, char *argv[]) + struct evl_desc_list *edl = NULL; + char *edl_str = NULL; + +- while ((opt = getopt(argc, argv, "e:w:l:f:o:b:c:d:n:t:p:vh")) != -1) { ++ while ((opt = getopt(argc, argv, "e:w:l:f:o:b:c:d:n:t:p:vuh")) != -1) { + switch (opt) { + case 'e': + edl_str = optarg; +@@ -889,6 +890,9 @@ int main(int argc, char *argv[]) + case 'v': + debug_logging = 1; + break; ++ case 'u': ++ force_enqcmd = 1; ++ break; + case 'h': + usage(); + exit(0); +-- +2.43.0 + diff --git a/0002-Update-dsa_config_test_runner.sh.patch b/0002-Update-dsa_config_test_runner.sh.patch new file mode 100644 index 0000000000000000000000000000000000000000..47f6f1589c4b34e6ad894df0628d9f7b981120fd --- /dev/null +++ b/0002-Update-dsa_config_test_runner.sh.patch @@ -0,0 +1,49 @@ +From 96703fa9b15f6d801b7d4cdb36ab0c0623c2d2b9 Mon Sep 17 00:00:00 2001 +From: shangsong2 +Date: Mon, 5 Aug 2024 10:55:48 +0800 +Subject: [PATCH 2/2] Update dsa_config_test_runner.sh + +The op_config '272' test is conflict with the kernel commit 6827738dc684a merged in April 2024, it is better to remove the test. + +Signed-off-by: shangsong +--- + test/dsa_config_test_runner.sh | 23 ----------------------- + 1 file changed, 23 deletions(-) + +diff --git a/test/dsa_config_test_runner.sh b/test/dsa_config_test_runner.sh +index 9068560..59a7a29 100755 +--- a/test/dsa_config_test_runner.sh ++++ b/test/dsa_config_test_runner.sh +@@ -205,29 +205,6 @@ wq_config_test() + "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x1 -b 0x3 -c 2 "${VERBOSE}" && + echo "should fail, but pass" && exit 1 + "$ACCFG" disable-device $DSA +- +- "$ACCFG" config-wq $DSA/$WQ0 -g 0 -m dedicated -y user -n app1 -d user -p 10 -o 272 +- "$ACCFG" config-engine $DSA/$ENG0 -g 0 +- read_ret=$(cat $IDXD_DEVICE_PATH/$DSA/$WQ0/op_config | cut -c 55-) +- if [ "$read_ret" != "00000000,00000272" ]; then +- echo "wq op_config 30 failed" && exit "$EXIT_FAILURE" +- fi +- "$ACCFG" enable-device $DSA +- "$ACCFG" enable-wq $DSA/$WQ0 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x0 "${VERBOSE}" && echo "should fail, but pass" && exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x2 "${VERBOSE}" && echo "should fail, but pass" && exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x3 "${VERBOSE}" && echo "should fail, but pass" && exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x7 "${VERBOSE}" && echo "should fail, but pass" && exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x8 "${VERBOSE}" && echo "should fail, but pass" && exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x4 "${VERBOSE}" || echo "should pass, but fail" || exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x5 "${VERBOSE}" || echo "should pass, but fail" || exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x6 "${VERBOSE}" || echo "should pass, but fail" || exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x9 "${VERBOSE}" || echo "should fail, but pass" || exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x1 -b 0x5 -c 2 "${VERBOSE}" || +- echo "should pass, but fail" || exit 1 +- "$DSATEST" -w 0 -l 4096 -f 0x1 -o 0x1 -b 0x9 -c 2 "${VERBOSE}" || +- echo "should pass, but fail" || exit 1 +- "$ACCFG" disable-device $DSA + fi + } + +-- +2.43.0 + diff --git a/0003-accel-config-Add-options-for-subcommand-enable-disab.patch b/0003-accel-config-Add-options-for-subcommand-enable-disab.patch new file mode 100644 index 0000000000000000000000000000000000000000..f92efd1729fd0cc6aec497f9f9304cb1e5cdf54c --- /dev/null +++ b/0003-accel-config-Add-options-for-subcommand-enable-disab.patch @@ -0,0 +1,145 @@ +From d12007de8ce229fc334e7fc7f49fa221d220c674 Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Mon, 28 Oct 2024 17:39:05 +0800 +Subject: [PATCH] accel-config: Add options for subcommand + enable/disable-device + +For certain reasons, the user needs to batch enable or disable configured +devices. Previously, the user would repeatedly call the 'disable-device' +or 'enable-device' sub-command in a loop. The newly added 'all' 'dsa' +'iax' options for 'disable-device' and 'enable-device' offers a more +convenient solution. + +Example: +----------- +[root@test-machine]# accel-config disable-device all +disable 1 device(s) dsa0 +dsa2 is in disabled state already, skipping... +dsa4 is in disabled state already, skipping... +dsa6 is in disabled state already, skipping... +disable 2 device(s) iax1 +iax3 is in disabled state already, skipping... +iax5 is in disabled state already, skipping... +iax7 is in disabled state already, skipping... + +[root@test-machine]# accel-config config-wq dsa0/wq0.0 -g 0 -m dedicated -y user -n app1 -d user -p 10 -o 0 +[root@test-machine]# accel-config config-wq dsa2/wq2.0 -g 2 -m shared -y user -n app2 -d user -p 10 -o 0 +[root@test-machine]# accel-config config-engine dsa0/engine0.0 -g 0 +[root@test-machine]# accel-config config-engine dsa2/engine2.0 -g 2 +[root@test-machine]# accel-config enable-device all +enable 1 device(s) dsa0 +enable 2 device(s) dsa2 + +NEG cases: +----------- +[root@test-machine]# accel-config disable-device iax +iax1 is in disabled state already, skipping... +iax3 is in disabled state already, skipping... +iax5 is in disabled state already, skipping... +iax7 is in disabled state already, skipping... + +[root@test-machine]# accel-config disable-device dsa +dsa0 is in disabled state already, skipping... +dsa2 is in disabled state already, skipping... +dsa4 is in disabled state already, skipping... +dsa6 is in disabled state already, skipping... + +[root@test-machine]# accel-config disable-device ERR +(return code 0) + +[root@test-machine]# accel-config enable-device all +(return code 0) + +[root@test-machine]# accel-config enable-device dsa +(return code 0) + +[root@test-machine]# accel-config enable-device iax +(return code 0) + +------- +- Change from v1 to v2: + - Remove redundant check. + - Change the dev parameter from hardcode to enum. + - Reword. + +Signed-off-by: Yi Sun +--- + accfg/enable.c | 43 +++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 41 insertions(+), 2 deletions(-) + +diff --git a/accfg/enable.c b/accfg/enable.c +index c27fbff..4e7d716 100644 +--- a/accfg/enable.c ++++ b/accfg/enable.c +@@ -30,6 +30,12 @@ enum wq_action { + WQ_ACTION_DISABLE, + }; + ++enum dev_param { ++ DEV_PARAM_DSA = 1, ++ DEV_PARAM_IAX = 2, ++ DEV_PARAM_ALL = 3, ++}; ++ + static struct { + bool verbose; + bool force; +@@ -91,6 +97,8 @@ static int device_action(int argc, const char **argv, const char *usage, + }; + int i, rc = -EINVAL, success = 0; + enum accfg_device_state state; ++ struct accfg_device *device = NULL; ++ unsigned int bmap_dev = 0; + + argc = parse_options(argc, argv, options, u, 0); + +@@ -101,13 +109,44 @@ static int device_action(int argc, const char **argv, const char *usage, + if (strcmp(argv[i], "all") == 0) { + argv[0] = "all"; + argc = 1; ++ bmap_dev |= DEV_PARAM_ALL; ++ break; ++ } ++ if (strcmp(argv[i], "dsa") == 0) { ++ argv[0] = "dsa"; ++ argc = 1; ++ bmap_dev |= DEV_PARAM_DSA; ++ break; ++ } ++ if (strcmp(argv[i], "iax") == 0) { ++ argv[0] = "iax"; ++ argc = 1; ++ bmap_dev |= DEV_PARAM_IAX; + break; + } + } + +- for (i = 0; i < argc; i++) { +- struct accfg_device *device; ++ if (bmap_dev) { ++ accfg_device_foreach(ctx, device) { ++ if (strstr(accfg_device_get_devname(device), "iax") && ++ (bmap_dev & DEV_PARAM_IAX) == 0) ++ continue; ++ if (strstr(accfg_device_get_devname(device), "dsa") && ++ (bmap_dev & DEV_PARAM_DSA) == 0) ++ continue; ++ ++ rc = dev_action_switch(device, action); ++ if (rc == 0) { ++ success++; ++ fprintf(stderr, "%s %d device(s) %s\n", ++ action == DEV_ACTION_ENABLE ? "enabled" : "disabled", ++ success, accfg_device_get_devname(device)); ++ } ++ } ++ return 0; ++ } + ++ for (i = 0; i < argc; i++) { + if (parse_device_name(ctx, argv[i], &device)) { + if (param.verbose) + fprintf(stderr, +-- +2.43.0 + diff --git a/0004-accel-config-Refine-the-Usage-of-enable-disable-devi.patch b/0004-accel-config-Refine-the-Usage-of-enable-disable-devi.patch new file mode 100644 index 0000000000000000000000000000000000000000..6f634baff55bd5946bad1eed7c12958e438e61ae --- /dev/null +++ b/0004-accel-config-Refine-the-Usage-of-enable-disable-devi.patch @@ -0,0 +1,91 @@ +From a14d345c6dcc231354b98228056cf5b442712681 Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Mon, 28 Oct 2024 18:45:52 +0800 +Subject: [PATCH] accel-config: Refine the Usage of enable/disable-device + +Add the usage for newly added options of enable-device and disable-device. + +Signed-off-by: Yi Sun +--- + .../accfg/accel-config-disable-device.txt | 5 +++++ + .../accfg/accel-config-enable-device.txt | 5 +++++ + accfg/enable.c | 16 ++++++++++++++-- + 3 files changed, 24 insertions(+), 2 deletions(-) + +diff --git a/Documentation/accfg/accel-config-disable-device.txt b/Documentation/accfg/accel-config-disable-device.txt +index 8952980..0662092 100644 +--- a/Documentation/accfg/accel-config-disable-device.txt ++++ b/Documentation/accfg/accel-config-disable-device.txt +@@ -11,10 +11,15 @@ SYNOPSIS + -------- + [verse] + 'accel-config disable-device' ++'accel-config disable-device' ++ dsa: disable all DSA devices ++ iax: disable all IAX devices ++ all: disable all devices + + EXAMPLE + ------- + accel-config disable-device dsa0 ++accel-config disable-device all + + OPTIONS + ------- +diff --git a/Documentation/accfg/accel-config-enable-device.txt b/Documentation/accfg/accel-config-enable-device.txt +index 21aba98..8da2906 100644 +--- a/Documentation/accfg/accel-config-enable-device.txt ++++ b/Documentation/accfg/accel-config-enable-device.txt +@@ -11,10 +11,15 @@ SYNOPSIS + -------- + [verse] + 'accel-config enable-device' ++'accel-config enable-device' ++ dsa: enable all configured DSA devices ++ iax: enable all configured IAX devices ++ all: enable all configured devices + + EXAMPLE + ------- + accel-config enable-device dsa0 ++accel-config enable-device all + + include::../copyright.txt[] + +diff --git a/accfg/enable.c b/accfg/enable.c +index 4e7d716..18b560a 100644 +--- a/accfg/enable.c ++++ b/accfg/enable.c +@@ -285,7 +285,13 @@ static int wq_action(int argc, const char **argv, const char *usage, + int cmd_disable_device(int argc, const char **argv, void *ctx) + { + char *usage = +- "accel-config disable-device [..] []"; ++ "\naccel-config disable-device [..] []\n" ++ "accel-config disable-device \n" ++ " device_type: can be one of following values\n" ++ " dsa: disable all DSA devices\n" ++ " iax: disable all IAX devices\n" ++ " all: disable all devices\n"; ++ + int count = device_action(argc, argv, usage, device_disable_options, + DEV_ACTION_DISABLE, ctx); + return count >= 0 ? 0 : EXIT_FAILURE; +@@ -294,7 +300,13 @@ int cmd_disable_device(int argc, const char **argv, void *ctx) + int cmd_enable_device(int argc, const char **argv, void *ctx) + { + char *usage = +- "accel-config enable-device [..] []"; ++ "\naccel-config enable-device [..] []\n" ++ "accel-config enable-device \n" ++ " device_type: can be one of following values\n" ++ " dsa: enable all configured DSA devices\n" ++ " iax: enable all configured IAX devices\n" ++ " all: enable all configured devices\n"; ++ + int count = device_action(argc, argv, usage, device_options, + DEV_ACTION_ENABLE, ctx); + return count >= 0 ? 0 : EXIT_FAILURE; +-- +2.43.0 + diff --git a/0005-Add-decode-subcommand-info.patch b/0005-Add-decode-subcommand-info.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d8795b947f7ddd48938ccf87d879fe15ffa67de --- /dev/null +++ b/0005-Add-decode-subcommand-info.patch @@ -0,0 +1,231 @@ +From 07b5795208c79274aa29253a73109bad00561bea Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Mon, 28 Oct 2024 17:34:34 +0800 +Subject: [PATCH] Add decode subcommand info + +Decode op_cap to a readable operation name, providing users with easier +access to information about hardware support." + +Example +------------- +[root@testmachine]accel-config info -v + +dsa0 [active] +00000000,00000000,00000000,00000000,00000000,00000000,0000007b,00bf07fd +Batch[-] Drain[+] Memory Move[+] Fill[+] Compare[+] Compare Pattern[+] Create Delta Record[+] Apply Delta Record[+] Memory Copy with Dualcast[+] Translation Fetch[+] CRC Generation[+] Copy with CRC Generation[+] DIF Check[+] DIF Insert[+] DIF Strip[+] DIF Update[+] DIX Generate[+] Cache Flush[+] Update Window[+] Inter-Domain Momery Copy[+] Inter-Domain Fill[+] Inter-Domain Compare[+] Inter-Domain Compare Pattern[+] Inter-Domain Cache Flush[-] + +iax1 +00000000,00000000,00000000,00000000,00000000,004d001c,00000000,00000405 +Drain[+] Translation Fetch[+] Decrypt[-] Encrypt[-] Decompress[+] Compress[+] CRC64[+] Zdecompress32[-] Zdecompress16[-] Zdecompress8 [-] Zcompress32[-] Zcompress16[-] Zcompress8[-] Scan[+] Set Membership[-] Extract[+] Select[+] BLE Burst[-] Find Unique[-] Expand[+] + +- Change from v1 to v2: + - Merge two related patch into a single commit. + - Reword. + +Signed-off-by: Yi Sun +--- + accfg/accel-config.c | 1 + + accfg/list.c | 148 +++++++++++++++++++++++++++++++++++++++++++ + builtin.h | 1 + + 3 files changed, 150 insertions(+) + +diff --git a/accfg/accel-config.c b/accfg/accel-config.c +index 616f2e5..e8a1f71 100644 +--- a/accfg/accel-config.c ++++ b/accfg/accel-config.c +@@ -23,6 +23,7 @@ const char accfg_usage_string[] = + + static struct cmd_struct commands[] = { + {"list", cmd_list}, ++ {"info", cmd_info}, + {"load-config", cmd_config}, + {"save-config", cmd_save}, + {"disable-device", cmd_disable_device}, +diff --git a/accfg/list.c b/accfg/list.c +index 145c523..9164510 100644 +--- a/accfg/list.c ++++ b/accfg/list.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + static struct util_filter_params util_param; + static struct { +@@ -25,6 +26,96 @@ static struct { + bool save_conf; + } list; + ++struct map_op_name { ++ int op_code; ++ const char *op_name; ++}; ++ ++#define BITMAP_SIZE 8 ++#define IAX_OP_CODE_NAME \ ++ {0x02, "Drain"}, \ ++ {0x0A, "Translation Fetch"}, \ ++ {0x40, "Decrypt"}, \ ++ {0x41, "Encrypt"}, \ ++ {0x42, "Decompress"}, \ ++ {0x43, "Compress"}, \ ++ {0x44, "CRC64"}, \ ++ {0x48, "Zdecompress32"}, \ ++ {0x49, "Zdecompress16"}, \ ++ {0x4A, "Zdecompress8"}, \ ++ {0x4C, "Zcompress32"}, \ ++ {0x4D, "Zcompress16"}, \ ++ {0x4E, "Zcompress8"}, \ ++ {0x50, "Scan"}, \ ++ {0x51, "Set Membership"}, \ ++ {0x52, "Extract"}, \ ++ {0x53, "Select"}, \ ++ {0x54, "BLE Burst"}, \ ++ {0x55, "Find Unique"}, \ ++ {0x56, "Expand"} ++ ++struct map_op_name iax_op_code_name[] = { ++ IAX_OP_CODE_NAME, ++ {-1, NULL} ++}; ++ ++#define DSA_OP_CODE_NAME \ ++ {0x01, "Batch"}, \ ++ {0x02, "Drain"}, \ ++ {0x03, "Memory Move"}, \ ++ {0x04, "Fill"}, \ ++ {0x05, "Compare"}, \ ++ {0x06, "Compare Pattern"}, \ ++ {0x07, "Create Delta Record"}, \ ++ {0x08, "Apply Delta Record"}, \ ++ {0x09, "Memory Copy with Dualcast"}, \ ++ {0x0A, "Translation Fetch"}, \ ++ {0x10, "CRC Generation"}, \ ++ {0x11, "Copy with CRC Generation"}, \ ++ {0x12, "DIF Check"}, \ ++ {0x13, "DIF Insert"}, \ ++ {0x14, "DIF Strip"}, \ ++ {0x15, "DIF Update"}, \ ++ {0x17, "DIX Generate"}, \ ++ {0x20, "Cache Flush"}, \ ++ {0x21, "Update Window"}, \ ++ {0x23, "Inter-Domain Momery Copy"}, \ ++ {0x24, "Inter-Domain Fill"}, \ ++ {0x25, "Inter-Domain Compare"}, \ ++ {0x26, "Inter-Domain Compare Pattern"}, \ ++ {0x27, "Inter-Domain Cache Flush"} ++ ++struct map_op_name dsa_op_code_name[] = { ++ DSA_OP_CODE_NAME, ++ {-1, NULL} ++}; ++ ++ ++static const char* get_op_name(struct map_op_name *code_name, int op_code) ++{ ++ int i = 0; ++ while (code_name[i].op_code != -1) { ++ if (code_name[i].op_code == op_code) { ++ return code_name[i].op_name; ++ } ++ i++; ++ } ++ return NULL; ++} ++ ++static int get_bit(struct accfg_op_cap op_cap, int bit_index) ++{ ++ int array_index = (BITMAP_SIZE - 1) - (bit_index / 32); ++ int bit_offset = bit_index % 32; ++ ++ if (bit_index < 0 || bit_index >= 256) { ++ printf("Error: bit_index out of range (0-255)\n"); ++ return -1; ++ } ++ ++ return (op_cap.bits[array_index] & (1 << bit_offset)) != 0; ++} ++ + static uint64_t listopts_to_flags(void) + { + uint64_t flags = 0; +@@ -692,6 +783,63 @@ int cmd_list(int argc, const char **argv, void *ctx) + return 0; + } + ++int cmd_info(int argc, const char **argv, void *ctx) ++{ ++ struct map_op_name *cur_op_name = NULL; ++ struct accfg_device *device; ++ struct accfg_op_cap op_cap; ++ bool verbose = false; ++ const char *dev_name; ++ const char *op_name; ++ int rc, j, has_op; ++ ++ const struct option options[] = { ++ OPT_BOOLEAN('v', "verbose", &verbose, "show more info"), ++ OPT_END(), ++ }; ++ const char *const u[] = { ++ "accel-config info []", ++ NULL ++ }; ++ ++ argc = parse_options(argc, argv, options, u, 0); ++ for (j = 0; j < argc; j++) ++ error("unknown parameter \"%s\"\n", argv[j]); ++ ++ accfg_device_foreach(ctx, device) { ++ dev_name = accfg_device_get_devname(device); ++ fprintf(stdout, "%s %s\n", dev_name, ++ accfg_device_is_active(device)? "[active]" : ""); ++ ++ rc = accfg_device_get_op_cap(device, &op_cap); ++ if (rc) { ++ printf("Error getting op cap\n"); ++ return rc; ++ } ++ ++ for (j = 0; j < BITMAP_SIZE; j++) ++ printf("%08x,", op_cap.bits[j]); ++ printf("\b \n"); ++ ++ if (!verbose) ++ continue; ++ ++ if (strstr(dev_name, "dsa") != NULL) { ++ cur_op_name = dsa_op_code_name; ++ } else if (strstr(dev_name, "iax") != NULL) { ++ cur_op_name = iax_op_code_name; ++ } ++ for (int k = 0; k < 256; k++) { ++ has_op = get_bit(op_cap, k); ++ op_name = get_op_name(cur_op_name, k); ++ if (op_name) ++ printf("%s[%c] ", op_name, has_op? '+' : '-'); ++ } ++ printf("\n"); ++ } ++ ++ return 0; ++} + int cmd_save(int argc, const char **argv, void *ctx) + { + const struct option options[] = { +diff --git a/builtin.h b/builtin.h +index 9554ee5..ff6cb5f 100644 +--- a/builtin.h ++++ b/builtin.h +@@ -19,6 +19,7 @@ struct cmd_struct { + int (*fn) (int, const char **, void *ctx); + }; + int cmd_list(int argc, const char **argv, void *ctx); ++int cmd_info(int argc, const char **argv, void *ctx); + int cmd_config(int argc, const char **argv, void *ctx); + int cmd_save(int argc, const char **argv, void *ctx); + int cmd_disable_device(int argc, const char **argv, void *ctx); +-- +2.43.0 + diff --git a/0006-Doc-Add-document-for-new-added-subcommand-info.patch b/0006-Doc-Add-document-for-new-added-subcommand-info.patch new file mode 100644 index 0000000000000000000000000000000000000000..694f49150164e017e57a5769ec4307a43ca1e0b7 --- /dev/null +++ b/0006-Doc-Add-document-for-new-added-subcommand-info.patch @@ -0,0 +1,85 @@ +From dd55279f82ac6949b07632997028833c1107b441 Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Tue, 17 Dec 2024 15:45:59 +0800 +Subject: [PATCH] Doc: Add document for new added subcommand info + +Signed-off-by: Yi Sun +--- + Documentation/accfg/Makefile.am | 6 ++-- + Documentation/accfg/accel-config-info.txt | 40 +++++++++++++++++++++++ + 2 files changed, 44 insertions(+), 2 deletions(-) + create mode 100644 Documentation/accfg/accel-config-info.txt + +diff --git a/Documentation/accfg/Makefile.am b/Documentation/accfg/Makefile.am +index 4d8d312..8b534c2 100644 +--- a/Documentation/accfg/Makefile.am ++++ b/Documentation/accfg/Makefile.am +@@ -30,7 +30,8 @@ man1_MANS = \ + accel-config-disable-wq.1 \ + accel-config-enable-wq.1 \ + accel-config-enable-device.1 \ +- accel-config-config-user-default.1 ++ accel-config-config-user-default.1 \ ++ accel-config-info.1 + + EXTRA_DIST = \ + $(man1_MANS) \ +@@ -46,7 +47,8 @@ EXTRA_DIST = \ + accel-config-disable-wq.txt \ + accel-config-enable-wq.txt \ + accel-config-enable-device.txt \ +- accel-config-config-user-default.txt ++ accel-config-config-user-default.txt \ ++ accel-config-info.txt + + CLEANFILES = $(man1_MANS) + +diff --git a/Documentation/accfg/accel-config-info.txt b/Documentation/accfg/accel-config-info.txt +new file mode 100644 +index 0000000..c6630ef +--- /dev/null ++++ b/Documentation/accfg/accel-config-info.txt +@@ -0,0 +1,40 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++accel-config info(1) ++==================== ++ ++NAME ++---- ++accel-config-info - dump more idxd device information. ++ ++SYNOPSIS ++-------- ++[verse] ++'accel-config info [-v]' ++ ++EXAMPLE ++------- ++accel-config info -v ++ ++dsa0 [active] ++ ++00000000,00000000,00000000,00000000,00000000,00000000,0000007b,00bf07fd ++ ++Batch[-] Drain[+] Memory Move[+] Fill[+] Compare[+] Compare Pattern[+] Create Delta Record[+] Apply Delta Record[+] Memory Copy with Dualcast[+] Translation Fetch[+] CRC Generation[+] Copy with CRC Generation[+] DIF Check[+] DIF Insert[+] DIF Strip[+] DIF Update[+] DIX Generate[+] Cache Flush[+] Update Window[+] Inter-Domain Momery Copy[+] Inter-Domain Fill[+] Inter-Domain Compare[+] Inter-Domain Compare Pattern[+] Inter-Domain Cache Flush[-] ++ ++iax1 ++ ++00000000,00000000,00000000,00000000,00000000,004d001c,00000000,00000405 ++ ++Drain[+] Translation Fetch[+] Decrypt[-] Encrypt[-] Decompress[+] Compress[+] CRC64[+] Zdecompress32[-] Zdecompress16[-] Zdecompress8 [-] Zcompress32[-] Zcompress16[-] Zcompress8[-] Scan[+] Set Membership[-] Extract[+] Select[+] BLE Burst[-] Find Unique[-] Expand[+] ++ ++OPTIONS ++------- ++-v: ++ Verbose mode. Print more information about the device. ++ ++include::../copyright.txt[] ++ ++SEE ALSO ++-------- ++accel-config info(1) +-- +2.43.0 + diff --git a/0007-iaa_test-Use-syscall-write-to-submit-descriptor.patch b/0007-iaa_test-Use-syscall-write-to-submit-descriptor.patch new file mode 100644 index 0000000000000000000000000000000000000000..72714fa38fbbb6ab4cf05462f6a6bf8fafe190b9 --- /dev/null +++ b/0007-iaa_test-Use-syscall-write-to-submit-descriptor.patch @@ -0,0 +1,50 @@ +From c9fe230b2842c5db32863c6e5aa2b2ce9c5679fd Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Thu, 2 Jan 2025 11:15:54 +0800 +Subject: [PATCH] iaa_test: Use syscall write to submit descriptor + +Align with the kernel change, write the descriptor to cdev instead of +enqcmd by default when submit shared work queue descriptor. + +Do the same change for iaa_test as the what dsa_test, which is reviewed +and merged. + +Signed-off-by: Yi Sun +--- + test/iaa_test.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/test/iaa_test.c b/test/iaa_test.c +index 5854c64..d42fa73 100644 +--- a/test/iaa_test.c ++++ b/test/iaa_test.c +@@ -28,6 +28,7 @@ static void usage(void) + "-n ;descriptor count to submit\n" + "-t ; ms to wait for descs to complete\n" + "-v ; verbose\n" ++ "-u ; use ENQCMD to submit descriptor\n" + "-h ; print this message\n"); + } + +@@ -581,7 +582,7 @@ int main(int argc, char *argv[]) + int dev_wq_id = ACCTEST_DEVICE_ID_NO_INPUT; + unsigned int num_desc = 1; + +- while ((opt = getopt(argc, argv, "w:l:f:1:2:3:a:m:o:b:c:d:n:t:p:vh")) != -1) { ++ while ((opt = getopt(argc, argv, "w:l:f:1:2:3:a:m:o:b:c:d:n:t:p:vuh")) != -1) { + switch (opt) { + case 'w': + wq_type = atoi(optarg); +@@ -624,6 +625,9 @@ int main(int argc, char *argv[]) + case 'v': + debug_logging = 1; + break; ++ case 'u': ++ force_enqcmd = 1; ++ break; + case 'h': + usage(); + exit(0); +-- +2.43.0 + diff --git a/0008-accel_test-Setup-Memmap-for-Dedicated-workqueue.patch b/0008-accel_test-Setup-Memmap-for-Dedicated-workqueue.patch new file mode 100644 index 0000000000000000000000000000000000000000..2d2f1877dbb51b2b33f030b47e28d833a5057ea6 --- /dev/null +++ b/0008-accel_test-Setup-Memmap-for-Dedicated-workqueue.patch @@ -0,0 +1,28 @@ +From 5edcf2349fd1c31127c2e7370dff7b5184ab49bf Mon Sep 17 00:00:00 2001 +From: Yi Sun +Date: Thu, 2 Jan 2025 14:39:48 +0800 +Subject: [PATCH] accel_test: Setup Memmap for Dedicated workqueue + +If tests running via dedicated workqueues, it's necessary to use memmap. + +Signed-off-by: Yi Sun +--- + test/accel_test.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/accel_test.c b/test/accel_test.c +index f23295c..ea7cc3e 100644 +--- a/test/accel_test.c ++++ b/test/accel_test.c +@@ -91,7 +91,7 @@ static int acctest_setup_wq(struct acctest_context *ctx, struct accfg_wq *wq) + return -errno; + } + +- if (force_enqcmd) { ++ if (force_enqcmd || accfg_wq_get_mode(wq) == ACCFG_WQ_DEDICATED) { + ctx->wq_reg = mmap(NULL, PAGE_SIZE, PROT_WRITE, + MAP_SHARED | MAP_POPULATE, ctx->fd, 0); + if (ctx->wq_reg == MAP_FAILED) { +-- +2.43.0 + diff --git a/0009-test-Use-ENQCMD-for-Betch-Testing.patch b/0009-test-Use-ENQCMD-for-Betch-Testing.patch new file mode 100644 index 0000000000000000000000000000000000000000..754943bd2a2b6c02b5a513f29c567dfdcc050cca --- /dev/null +++ b/0009-test-Use-ENQCMD-for-Betch-Testing.patch @@ -0,0 +1,42 @@ +From 2f15749789947060a88086ba0298036e216f8a8c Mon Sep 17 00:00:00 2001 +From: "Sun, Yi" +Date: Thu, 2 Jan 2025 16:45:10 +0800 +Subject: [PATCH] test: Use ENQCMD for Betch Testing + +The idxd tests are suggested to use syscall write to submit instead of +ENQCMD. But so far the write function cannot handle batch tests. + +Use the option '-u' to force the batch tests using ENQCMD. +This is likely a workaround, need to look into the write function of the +cdev supporting the betch function. + +Signed-off-by: Yi Sun +--- + test/dsa_user_test_runner.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/test/dsa_user_test_runner.sh b/test/dsa_user_test_runner.sh +index 2848fed..9375365 100755 +--- a/test/dsa_user_test_runner.sh ++++ b/test/dsa_user_test_runner.sh +@@ -124,7 +124,7 @@ test_op_batch() + -c 16 -f "$flag" t2000 "${VERBOSE}" -d "$DEV" + else + "$DSATEST" -w "$wq_mode_code" -l "$xfer_size" -o 0x1 -b "$opcode" \ +- -c 16 -f "$flag" t2000 "${VERBOSE}" ++ -c 16 -f "$flag" t2000 "${VERBOSE}" -u + fi + done + done +@@ -184,7 +184,7 @@ test_dif_op_batch() + -c 16 -f "$flag" t2000 "${VERBOSE}" -d "$DEV" + else + "$DSATEST" -w "$wq_mode_code" -l "$xfer_size" -o 0x1 -b "$opcode" \ +- -c 16 -f "$flag" t2000 "${VERBOSE}" ++ -c 16 -f "$flag" t2000 "${VERBOSE}" -u + fi + done + done +-- +2.43.0 + diff --git a/0010-fix-accel-config-path-in-common-script.patch b/0010-fix-accel-config-path-in-common-script.patch new file mode 100644 index 0000000000000000000000000000000000000000..b0e5ebf46e05114106ada1c1c08504d8dbb0dda2 --- /dev/null +++ b/0010-fix-accel-config-path-in-common-script.patch @@ -0,0 +1,20 @@ +diff --git a/test/common b/test/common +index 7355c908ac15..e10fafc6f341 100755 +--- a/test/common ++++ b/test/common +@@ -140,13 +140,13 @@ disable_all() { + for wqp in ${device_path}/wq* ; do + [[ $( cat "${wqp}"/state ) == "enabled" ]] && { + wq=${wqp##${DSA_DEVICE_PATH}/} +- accel-config disable-wq "${wq}" ++ $ACCFG disable-wq "${wq}" + echo "-1" > "${wqp}"/group_id + } + done + # Disable device + [[ $( cat "${device_path}"/state ) == "enabled" ]] && { +- accel-config disable-device "${device_path##${DSA_DEVICE_PATH}/}" ++ $ACCFG disable-device "${device_path##${DSA_DEVICE_PATH}/}" + } + # Remove group id of engine + for engine in ${device_path}/engine* ; do diff --git a/accel-config-v3.5.1.tar.gz b/accel-config-v3.5.1.tar.gz deleted file mode 100644 index 04da0f65efe60d80a2667033d443783b265badf1..0000000000000000000000000000000000000000 Binary files a/accel-config-v3.5.1.tar.gz and /dev/null differ diff --git a/accel-config-v4.1.8.tar.gz b/accel-config-v4.1.8.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ece40bf758f8a6250120ab31e33d83546dc58741 Binary files /dev/null and b/accel-config-v4.1.8.tar.gz differ diff --git a/accel-config.spec b/accel-config.spec index 4ad8c153e8311ef493fb106ec17295c04d1871e4..5fac24e2562a7bfb4f2da6d3c8bed71aec752908 100644 --- a/accel-config.spec +++ b/accel-config.spec @@ -1,7 +1,7 @@ %global debug_package %{nil} Name: accel-config -Version: 3.5.1 +Version: 4.1.8 Release: 1 Summary: Configure accelerator subsystem devices Group: Development/Tools @@ -12,6 +12,17 @@ License: GPLv2 and LGPLv2+ and MIT and CC0 URL: https://github.com/intel/idxd-config Source0: %{name}-v%{version}.tar.gz +Patch1: 0001-dsa_test-Use-syscall-write-to-submit-descriptor.patch +Patch2: 0002-Update-dsa_config_test_runner.sh.patch +Patch3: 0003-accel-config-Add-options-for-subcommand-enable-disab.patch +Patch4: 0004-accel-config-Refine-the-Usage-of-enable-disable-devi.patch +Patch5: 0005-Add-decode-subcommand-info.patch +Patch6: 0006-Doc-Add-document-for-new-added-subcommand-info.patch +Patch7: 0007-iaa_test-Use-syscall-write-to-submit-descriptor.patch +Patch8: 0008-accel_test-Setup-Memmap-for-Dedicated-workqueue.patch +Patch9: 0009-test-Use-ENQCMD-for-Betch-Testing.patch +Patch10: 0010-fix-accel-config-path-in-common-script.patch + Requires: %{name}-libs%{?_isa} = %{version}-%{release} BuildRequires: autoconf BuildRequires: asciidoc @@ -22,6 +33,7 @@ BuildRequires: pkgconfig BuildRequires: pkgconfig(uuid) BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(zlib) +BuildRequires: pkgconfig(openssl) BuildRequires: systemd # accel-config is for configuring Intel DSA (Data-Streaming @@ -60,7 +72,7 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release} Tests for accel-config command. %prep -%setup -q -n %{name}-v%{version} +%autosetup -p1 -n %{name}-v%{version} %build echo %{version} > version @@ -97,9 +109,10 @@ make check %files test %license Documentation/COPYING LICENSE_GPL_2_0 %doc test/README.md -%global lib_path lib -%{_prefix}/%{lib_path}/accel-config/test/* +%{_libexecdir}/accel-config/test/* %changelog +* Thu Apr 10 2025 Jason Zeng - 4.1.8-1 +- Update to v4.1.8 * Fri Nov 25 2022 Aichun Shi - 3.5.1-1 - Initial Packaging