test/nvme/aer: add changed namespace list log test
Change-Id: I2cc6c494bacbeec1ba725b4b3d78a1f4a2ed39d1 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/406166 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1831b086d0
commit
e9ee09f153
@ -42,6 +42,7 @@
|
|||||||
struct dev {
|
struct dev {
|
||||||
struct spdk_nvme_ctrlr *ctrlr;
|
struct spdk_nvme_ctrlr *ctrlr;
|
||||||
struct spdk_nvme_health_information_page *health_page;
|
struct spdk_nvme_health_information_page *health_page;
|
||||||
|
struct spdk_nvme_ns_list *changed_ns_list;
|
||||||
uint32_t orig_temp_threshold;
|
uint32_t orig_temp_threshold;
|
||||||
char name[SPDK_NVMF_TRADDR_MAX_LEN + 1];
|
char name[SPDK_NVMF_TRADDR_MAX_LEN + 1];
|
||||||
};
|
};
|
||||||
@ -62,6 +63,10 @@ static struct spdk_nvme_transport_id g_trid;
|
|||||||
|
|
||||||
/* Enable AER temperature test */
|
/* Enable AER temperature test */
|
||||||
static int enable_temp_test = 0;
|
static int enable_temp_test = 0;
|
||||||
|
/* Enable AER namespace attribute notice test, this variable holds
|
||||||
|
* the NSID that is expected to be in the Changed NS List.
|
||||||
|
*/
|
||||||
|
static uint32_t expected_ns_test = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_temp_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
|
set_temp_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
|
||||||
@ -160,6 +165,43 @@ get_health_log_page_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
|
|||||||
aer_done++;
|
aer_done++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_changed_ns_log_page_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
|
||||||
|
{
|
||||||
|
struct dev *dev = cb_arg;
|
||||||
|
bool found = false;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
outstanding_commands --;
|
||||||
|
|
||||||
|
if (spdk_nvme_cpl_is_error(cpl)) {
|
||||||
|
printf("%s: get log page failed\n", dev->name);
|
||||||
|
failed = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Let's compare the expected namespce ID is
|
||||||
|
* in changed namespace list
|
||||||
|
*/
|
||||||
|
if (dev->changed_ns_list->ns_list[0] != 0xffffffffu) {
|
||||||
|
for (i = 0; i < sizeof(*dev->changed_ns_list) / sizeof(uint32_t); i++) {
|
||||||
|
if (expected_ns_test == dev->changed_ns_list->ns_list[i]) {
|
||||||
|
printf("%s: changed NS list contains expected NSID: %u\n",
|
||||||
|
dev->name, expected_ns_test);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
printf("%s: Error: Cann't find expected NSID %u\n", dev->name, expected_ns_test);
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
aer_done++;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_health_log_page(struct dev *dev)
|
get_health_log_page(struct dev *dev)
|
||||||
{
|
{
|
||||||
@ -168,6 +210,24 @@ get_health_log_page(struct dev *dev)
|
|||||||
rc = spdk_nvme_ctrlr_cmd_get_log_page(dev->ctrlr, SPDK_NVME_LOG_HEALTH_INFORMATION,
|
rc = spdk_nvme_ctrlr_cmd_get_log_page(dev->ctrlr, SPDK_NVME_LOG_HEALTH_INFORMATION,
|
||||||
SPDK_NVME_GLOBAL_NS_TAG, dev->health_page, sizeof(*dev->health_page), 0,
|
SPDK_NVME_GLOBAL_NS_TAG, dev->health_page, sizeof(*dev->health_page), 0,
|
||||||
get_health_log_page_completion, dev);
|
get_health_log_page_completion, dev);
|
||||||
|
|
||||||
|
if (rc == 0) {
|
||||||
|
outstanding_commands++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
get_changed_ns_log_page(struct dev *dev)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = spdk_nvme_ctrlr_cmd_get_log_page(dev->ctrlr, SPDK_NVME_LOG_CHANGED_NS_LIST,
|
||||||
|
SPDK_NVME_GLOBAL_NS_TAG, dev->changed_ns_list,
|
||||||
|
sizeof(*dev->changed_ns_list), 0,
|
||||||
|
get_changed_ns_log_page_completion, dev);
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
outstanding_commands++;
|
outstanding_commands++;
|
||||||
}
|
}
|
||||||
@ -184,6 +244,9 @@ cleanup(void)
|
|||||||
if (dev->health_page) {
|
if (dev->health_page) {
|
||||||
spdk_dma_free(dev->health_page);
|
spdk_dma_free(dev->health_page);
|
||||||
}
|
}
|
||||||
|
if (dev->changed_ns_list) {
|
||||||
|
spdk_dma_free(dev->changed_ns_list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,12 +264,15 @@ aer_cb(void *arg, const struct spdk_nvme_cpl *cpl)
|
|||||||
|
|
||||||
printf("%s: aer_cb for log page %d\n", dev->name, log_page_id);
|
printf("%s: aer_cb for log page %d\n", dev->name, log_page_id);
|
||||||
|
|
||||||
/* Set the temperature threshold back to the original value
|
if (log_page_id == SPDK_NVME_LOG_HEALTH_INFORMATION) {
|
||||||
* so the AER doesn't trigger again.
|
/* Set the temperature threshold back to the original value
|
||||||
*/
|
* so the AER doesn't trigger again.
|
||||||
set_temp_threshold(dev, dev->orig_temp_threshold);
|
*/
|
||||||
|
set_temp_threshold(dev, dev->orig_temp_threshold);
|
||||||
get_health_log_page(dev);
|
get_health_log_page(dev);
|
||||||
|
} else if (log_page_id == SPDK_NVME_LOG_CHANGED_NS_LIST) {
|
||||||
|
get_changed_ns_log_page(dev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -216,6 +282,7 @@ usage(const char *program_name)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
printf("options:\n");
|
printf("options:\n");
|
||||||
printf(" -T enable temperature tests\n");
|
printf(" -T enable temperature tests\n");
|
||||||
|
printf(" -n expected Namespace attribute notice ID\n");
|
||||||
printf(" -r trid remote NVMe over Fabrics target address\n");
|
printf(" -r trid remote NVMe over Fabrics target address\n");
|
||||||
printf(" Format: 'key:value [key:value] ...'\n");
|
printf(" Format: 'key:value [key:value] ...'\n");
|
||||||
printf(" Keys:\n");
|
printf(" Keys:\n");
|
||||||
@ -240,8 +307,11 @@ parse_args(int argc, char **argv)
|
|||||||
g_trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
g_trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||||
snprintf(g_trid.subnqn, sizeof(g_trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
snprintf(g_trid.subnqn, sizeof(g_trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||||
|
|
||||||
while ((op = getopt(argc, argv, "r:t:H:T")) != -1) {
|
while ((op = getopt(argc, argv, "n:r:t:H:T")) != -1) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
case 'n':
|
||||||
|
expected_ns_test = atoi(optarg);
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
rc = spdk_log_set_trace_flag(optarg);
|
rc = spdk_log_set_trace_flag(optarg);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@ -306,6 +376,11 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
|||||||
printf("Allocation error (health page)\n");
|
printf("Allocation error (health page)\n");
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
|
dev->changed_ns_list = spdk_dma_zmalloc(sizeof(*dev->changed_ns_list), 4096, NULL);
|
||||||
|
if (dev->changed_ns_list == NULL) {
|
||||||
|
printf("Allocation error (changed namespace list page)\n");
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -403,6 +478,36 @@ spdk_aer_temperature_test(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
spdk_aer_changed_ns_test(void)
|
||||||
|
{
|
||||||
|
struct dev *dev;
|
||||||
|
|
||||||
|
aer_done = 0;
|
||||||
|
|
||||||
|
printf("Starting namespce attribute notice tests for all controllers...\n");
|
||||||
|
|
||||||
|
foreach_dev(dev) {
|
||||||
|
get_feature_test(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!failed && (aer_done < num_devs)) {
|
||||||
|
foreach_dev(dev) {
|
||||||
|
spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct dev *dev;
|
struct dev *dev;
|
||||||
@ -418,6 +523,7 @@ int main(int argc, char **argv)
|
|||||||
spdk_env_opts_init(&opts);
|
spdk_env_opts_init(&opts);
|
||||||
opts.name = "aer";
|
opts.name = "aer";
|
||||||
opts.core_mask = "0x1";
|
opts.core_mask = "0x1";
|
||||||
|
opts.mem_size = 64;
|
||||||
if (spdk_env_init(&opts) < 0) {
|
if (spdk_env_init(&opts) < 0) {
|
||||||
fprintf(stderr, "Unable to initialize SPDK env\n");
|
fprintf(stderr, "Unable to initialize SPDK env\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -446,6 +552,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* AER changed namespace list test */
|
||||||
|
if (expected_ns_test) {
|
||||||
|
if (spdk_aer_changed_ns_test()) {
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("Cleaning up...\n");
|
printf("Cleaning up...\n");
|
||||||
|
|
||||||
while (outstanding_commands) {
|
while (outstanding_commands) {
|
||||||
|
@ -16,15 +16,10 @@ if [ -z $NVMF_FIRST_TARGET_IP ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if check_ip_is_soft_roce $NVMF_FIRST_TARGET_IP; then
|
|
||||||
echo "Bypass AER tests for softRoCE NIC"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
timing_enter aer
|
timing_enter aer
|
||||||
timing_enter start_nvmf_tgt
|
timing_enter start_nvmf_tgt
|
||||||
|
|
||||||
$NVMF_APP -c $testdir/../nvmf.conf &
|
$NVMF_APP -s 512 -c $testdir/../nvmf.conf &
|
||||||
nvmfpid=$!
|
nvmfpid=$!
|
||||||
|
|
||||||
trap "killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
|
trap "killprocess $nvmfpid; exit 1" SIGINT SIGTERM EXIT
|
||||||
@ -48,41 +43,23 @@ $rpc_py construct_nvmf_subsystem nqn.2016-06.io.spdk:cnode1 "trtype:RDMA traddr:
|
|||||||
# trsvcid:$NVMF_PORT \
|
# trsvcid:$NVMF_PORT \
|
||||||
# subnqn:nqn.2014-08.org.nvmexpress.discovery"
|
# subnqn:nqn.2014-08.org.nvmexpress.discovery"
|
||||||
|
|
||||||
# Namespace Attribute Notice Tests with kernel initiator
|
# Namespace Attribute Notice Tests
|
||||||
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
$rootdir/test/nvme/aer/aer -r "\
|
||||||
sleep 2
|
trtype:RDMA \
|
||||||
sync
|
adrfam:IPv4 \
|
||||||
|
traddr:$NVMF_FIRST_TARGET_IP \
|
||||||
|
trsvcid:$NVMF_PORT \
|
||||||
|
subnqn:nqn.2016-06.io.spdk:cnode1" -n 2 &
|
||||||
|
aerpid=$!
|
||||||
|
|
||||||
function get_nvme_name {
|
# Waiting for aer start to work
|
||||||
bdevs=$(lsblk -d | cut -d " " -f 1 | grep "^nvme[0-9]n2") || true
|
sleep 5
|
||||||
}
|
|
||||||
|
|
||||||
bdevs=""
|
|
||||||
get_nvme_name
|
|
||||||
|
|
||||||
if [ -n "$bdevs" ]; then
|
|
||||||
echo "Ignore adding Namespace 2 test"
|
|
||||||
$rpc_py delete_bdev Malloc0
|
|
||||||
nvmfcleanup
|
|
||||||
killprocess $nvmfpid
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add a new namespace
|
# Add a new namespace
|
||||||
$rpc_py construct_malloc_bdev 128 4096 --name Malloc1
|
$rpc_py construct_malloc_bdev 64 4096 --name Malloc1
|
||||||
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 -n 2
|
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 -n 2
|
||||||
sleep 3
|
|
||||||
sync
|
|
||||||
|
|
||||||
bdevs=""
|
wait $aerpid
|
||||||
get_nvme_name
|
|
||||||
|
|
||||||
if [ -z "$bdevs" ]; then
|
|
||||||
echo "AER for adding a Namespace test failed"
|
|
||||||
nvmfcleanup
|
|
||||||
killprocess $nvmfpid
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
$rpc_py delete_bdev Malloc0
|
$rpc_py delete_bdev Malloc0
|
||||||
$rpc_py delete_bdev Malloc1
|
$rpc_py delete_bdev Malloc1
|
||||||
|
@ -39,8 +39,7 @@ run_test test/nvmf/host/bdevperf.sh
|
|||||||
run_test test/nvmf/host/identify.sh
|
run_test test/nvmf/host/identify.sh
|
||||||
run_test test/nvmf/host/perf.sh
|
run_test test/nvmf/host/perf.sh
|
||||||
run_test test/nvmf/host/identify_kernel_nvmf.sh
|
run_test test/nvmf/host/identify_kernel_nvmf.sh
|
||||||
# Disable aer.sh for now while some intermittent failures are investigated.
|
run_test test/nvmf/host/aer.sh
|
||||||
#run_test test/nvmf/host/aer.sh
|
|
||||||
run_test test/nvmf/host/fio.sh
|
run_test test/nvmf/host/fio.sh
|
||||||
|
|
||||||
timing_exit host
|
timing_exit host
|
||||||
|
Loading…
Reference in New Issue
Block a user