test/nvme: add g_ prefix to aer global variables

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I41b9461f2f992a65c3a8906f3a5f7c9a743aa496

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452803
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jim Harris 2019-05-01 14:34:17 -07:00
parent 4de00fed67
commit 3d9f193624

View File

@ -50,41 +50,41 @@ struct dev {
static void get_feature_test(struct dev *dev); static void get_feature_test(struct dev *dev);
static struct dev devs[MAX_DEVS]; static struct dev g_devs[MAX_DEVS];
static int num_devs = 0; static int g_num_devs = 0;
#define foreach_dev(iter) \ #define foreach_dev(iter) \
for (iter = devs; iter - devs < num_devs; iter++) for (iter = g_devs; iter - g_devs < g_num_devs; iter++)
static int outstanding_commands = 0; static int g_outstanding_commands = 0;
static int aer_done = 0; static int g_aer_done = 0;
static int temperature_done = 0; static int g_temperature_done = 0;
static int failed = 0; static int g_failed = 0;
static struct spdk_nvme_transport_id g_trid; static struct spdk_nvme_transport_id g_trid;
/* Enable AER temperature test */ /* Enable AER temperature test */
static int enable_temp_test = 0; static int g_enable_temp_test = 0;
/* Enable AER namespace attribute notice test, this variable holds /* Enable AER namespace attribute notice test, this variable holds
* the NSID that is expected to be in the Changed NS List. * the NSID that is expected to be in the Changed NS List.
*/ */
static uint32_t expected_ns_test = 0; static uint32_t g_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)
{ {
struct dev *dev = cb_arg; struct dev *dev = cb_arg;
outstanding_commands--; g_outstanding_commands--;
if (spdk_nvme_cpl_is_error(cpl)) { if (spdk_nvme_cpl_is_error(cpl)) {
printf("%s: set feature (temp threshold) failed\n", dev->name); printf("%s: set feature (temp threshold) failed\n", dev->name);
failed = 1; g_failed = 1;
return; return;
} }
/* Admin command completions are synchronized by the NVMe driver, /* Admin command completions are synchronized by the NVMe driver,
* so we don't need to do any special locking here. */ * so we don't need to do any special locking here. */
temperature_done++; g_temperature_done++;
} }
static int static int
@ -99,7 +99,7 @@ set_temp_threshold(struct dev *dev, uint32_t temp)
rc = spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, NULL, 0, set_temp_completion, dev); rc = spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, NULL, 0, set_temp_completion, dev);
if (rc == 0) { if (rc == 0) {
outstanding_commands++; g_outstanding_commands++;
} }
return rc; return rc;
@ -110,11 +110,11 @@ get_temp_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
{ {
struct dev *dev = cb_arg; struct dev *dev = cb_arg;
outstanding_commands--; g_outstanding_commands--;
if (spdk_nvme_cpl_is_error(cpl)) { if (spdk_nvme_cpl_is_error(cpl)) {
printf("%s: get feature (temp threshold) failed\n", dev->name); printf("%s: get feature (temp threshold) failed\n", dev->name);
failed = 1; g_failed = 1;
return; return;
} }
@ -122,7 +122,7 @@ get_temp_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
printf("%s: original temperature threshold: %u Kelvin (%d Celsius)\n", printf("%s: original temperature threshold: %u Kelvin (%d Celsius)\n",
dev->name, dev->orig_temp_threshold, dev->orig_temp_threshold - 273); dev->name, dev->orig_temp_threshold, dev->orig_temp_threshold - 273);
temperature_done++; g_temperature_done++;
} }
static int static int
@ -136,7 +136,7 @@ get_temp_threshold(struct dev *dev)
rc = spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, NULL, 0, get_temp_completion, dev); rc = spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, NULL, 0, get_temp_completion, dev);
if (rc == 0) { if (rc == 0) {
outstanding_commands++; g_outstanding_commands++;
} }
return rc; return rc;
@ -154,16 +154,16 @@ get_health_log_page_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
{ {
struct dev *dev = cb_arg; struct dev *dev = cb_arg;
outstanding_commands --; g_outstanding_commands --;
if (spdk_nvme_cpl_is_error(cpl)) { if (spdk_nvme_cpl_is_error(cpl)) {
printf("%s: get log page failed\n", dev->name); printf("%s: get log page failed\n", dev->name);
failed = 1; g_failed = 1;
return; return;
} }
print_health_page(dev, dev->health_page); print_health_page(dev, dev->health_page);
aer_done++; g_aer_done++;
} }
static void static void
@ -173,11 +173,11 @@ get_changed_ns_log_page_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl
bool found = false; bool found = false;
uint32_t i; uint32_t i;
outstanding_commands --; g_outstanding_commands --;
if (spdk_nvme_cpl_is_error(cpl)) { if (spdk_nvme_cpl_is_error(cpl)) {
printf("%s: get log page failed\n", dev->name); printf("%s: get log page failed\n", dev->name);
failed = 1; g_failed = 1;
return; return;
} }
@ -186,9 +186,9 @@ get_changed_ns_log_page_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl
*/ */
if (dev->changed_ns_list->ns_list[0] != 0xffffffffu) { if (dev->changed_ns_list->ns_list[0] != 0xffffffffu) {
for (i = 0; i < sizeof(*dev->changed_ns_list) / sizeof(uint32_t); i++) { for (i = 0; i < sizeof(*dev->changed_ns_list) / sizeof(uint32_t); i++) {
if (expected_ns_test == dev->changed_ns_list->ns_list[i]) { if (g_expected_ns_test == dev->changed_ns_list->ns_list[i]) {
printf("%s: changed NS list contains expected NSID: %u\n", printf("%s: changed NS list contains expected NSID: %u\n",
dev->name, expected_ns_test); dev->name, g_expected_ns_test);
found = true; found = true;
break; break;
} }
@ -196,11 +196,11 @@ get_changed_ns_log_page_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl
} }
if (!found) { if (!found) {
printf("%s: Error: Can't find expected NSID %u\n", dev->name, expected_ns_test); printf("%s: Error: Can't find expected NSID %u\n", dev->name, g_expected_ns_test);
failed = 1; g_failed = 1;
} }
aer_done++; g_aer_done++;
} }
static int static int
@ -213,7 +213,7 @@ get_health_log_page(struct dev *dev)
get_health_log_page_completion, dev); get_health_log_page_completion, dev);
if (rc == 0) { if (rc == 0) {
outstanding_commands++; g_outstanding_commands++;
} }
return rc; return rc;
@ -230,7 +230,7 @@ get_changed_ns_log_page(struct dev *dev)
get_changed_ns_log_page_completion, dev); get_changed_ns_log_page_completion, dev);
if (rc == 0) { if (rc == 0) {
outstanding_commands++; g_outstanding_commands++;
} }
return rc; return rc;
@ -259,7 +259,7 @@ aer_cb(void *arg, const struct spdk_nvme_cpl *cpl)
if (spdk_nvme_cpl_is_error(cpl)) { if (spdk_nvme_cpl_is_error(cpl)) {
printf("%s: AER failed\n", dev->name); printf("%s: AER failed\n", dev->name);
failed = 1; g_failed = 1;
return; return;
} }
@ -317,7 +317,7 @@ parse_args(int argc, char **argv)
fprintf(stderr, "Invalid NS attribute notice ID\n"); fprintf(stderr, "Invalid NS attribute notice ID\n");
return val; return val;
} }
expected_ns_test = (uint32_t)val; g_expected_ns_test = (uint32_t)val;
break; break;
case 'r': case 'r':
if (spdk_nvme_transport_id_parse(&g_trid, optarg) != 0) { if (spdk_nvme_transport_id_parse(&g_trid, optarg) != 0) {
@ -341,7 +341,7 @@ parse_args(int argc, char **argv)
#endif #endif
break; break;
case 'T': case 'T':
enable_temp_test = 1; g_enable_temp_test = 1;
break; break;
case 'H': case 'H':
default: default:
@ -369,7 +369,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
struct dev *dev; struct dev *dev;
/* add to dev list */ /* add to dev list */
dev = &devs[num_devs++]; dev = &g_devs[g_num_devs++];
dev->ctrlr = ctrlr; dev->ctrlr = ctrlr;
@ -381,12 +381,12 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
dev->health_page = spdk_dma_zmalloc(sizeof(*dev->health_page), 4096, NULL); dev->health_page = spdk_dma_zmalloc(sizeof(*dev->health_page), 4096, NULL);
if (dev->health_page == NULL) { if (dev->health_page == NULL) {
printf("Allocation error (health page)\n"); printf("Allocation error (health page)\n");
failed = 1; g_failed = 1;
} }
dev->changed_ns_list = spdk_dma_zmalloc(sizeof(*dev->changed_ns_list), 4096, NULL); dev->changed_ns_list = spdk_dma_zmalloc(sizeof(*dev->changed_ns_list), 4096, NULL);
if (dev->changed_ns_list == NULL) { if (dev->changed_ns_list == NULL) {
printf("Allocation error (changed namespace list page)\n"); printf("Allocation error (changed namespace list page)\n");
failed = 1; g_failed = 1;
} }
} }
@ -395,15 +395,15 @@ get_feature_test_cb(void *cb_arg, const struct spdk_nvme_cpl *cpl)
{ {
struct dev *dev = cb_arg; struct dev *dev = cb_arg;
outstanding_commands--; g_outstanding_commands--;
if (spdk_nvme_cpl_is_error(cpl)) { if (spdk_nvme_cpl_is_error(cpl)) {
printf("%s: get number of queues failed\n", dev->name); printf("%s: get number of queues failed\n", dev->name);
failed = 1; g_failed = 1;
return; return;
} }
if (aer_done < num_devs) { if (g_aer_done < g_num_devs) {
/* /*
* Resubmit Get Features command to continue filling admin queue * Resubmit Get Features command to continue filling admin queue
* while the test is running. * while the test is running.
@ -423,11 +423,11 @@ get_feature_test(struct dev *dev)
if (spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, NULL, 0, if (spdk_nvme_ctrlr_cmd_admin_raw(dev->ctrlr, &cmd, NULL, 0,
get_feature_test_cb, dev) != 0) { get_feature_test_cb, dev) != 0) {
printf("Failed to send Get Features command for dev=%p\n", dev); printf("Failed to send Get Features command for dev=%p\n", dev);
failed = 1; g_failed = 1;
return; return;
} }
outstanding_commands++; g_outstanding_commands++;
} }
static int static int
@ -441,25 +441,25 @@ spdk_aer_temperature_test(void)
get_temp_threshold(dev); get_temp_threshold(dev);
} }
while (!failed && temperature_done < num_devs) { while (!g_failed && g_temperature_done < g_num_devs) {
foreach_dev(dev) { foreach_dev(dev) {
spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr); spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr);
} }
} }
if (failed) { if (g_failed) {
return failed; return g_failed;
} }
temperature_done = 0; g_temperature_done = 0;
aer_done = 0; g_aer_done = 0;
/* Send admin commands to test admin queue wraparound while waiting for the AER */ /* Send admin commands to test admin queue wraparound while waiting for the AER */
foreach_dev(dev) { foreach_dev(dev) {
get_feature_test(dev); get_feature_test(dev);
} }
if (failed) { if (g_failed) {
return failed; return g_failed;
} }
printf("Waiting for all controllers to trigger AER...\n"); printf("Waiting for all controllers to trigger AER...\n");
@ -468,18 +468,18 @@ spdk_aer_temperature_test(void)
set_temp_threshold(dev, 200); set_temp_threshold(dev, 200);
} }
if (failed) { if (g_failed) {
return failed; return g_failed;
} }
while (!failed && (aer_done < num_devs || temperature_done < num_devs)) { while (!g_failed && (g_aer_done < g_num_devs || g_temperature_done < g_num_devs)) {
foreach_dev(dev) { foreach_dev(dev) {
spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr); spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr);
} }
} }
if (failed) { if (g_failed) {
return failed; return g_failed;
} }
return 0; return 0;
@ -490,7 +490,7 @@ spdk_aer_changed_ns_test(void)
{ {
struct dev *dev; struct dev *dev;
aer_done = 0; g_aer_done = 0;
printf("Starting namespce attribute notice tests for all controllers...\n"); printf("Starting namespce attribute notice tests for all controllers...\n");
@ -498,18 +498,18 @@ spdk_aer_changed_ns_test(void)
get_feature_test(dev); get_feature_test(dev);
} }
if (failed) { if (g_failed) {
return failed; return g_failed;
} }
while (!failed && (aer_done < num_devs)) { while (!g_failed && (g_aer_done < g_num_devs)) {
foreach_dev(dev) { foreach_dev(dev) {
spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr); spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr);
} }
} }
if (failed) { if (g_failed) {
return failed; return g_failed;
} }
return 0; return 0;
@ -542,7 +542,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
if (failed) { if (g_failed) {
goto done; goto done;
} }
@ -552,14 +552,14 @@ int main(int argc, char **argv)
} }
/* AER temperature test */ /* AER temperature test */
if (enable_temp_test) { if (g_enable_temp_test) {
if (spdk_aer_temperature_test()) { if (spdk_aer_temperature_test()) {
goto done; goto done;
} }
} }
/* AER changed namespace list test */ /* AER changed namespace list test */
if (expected_ns_test) { if (g_expected_ns_test) {
if (spdk_aer_changed_ns_test()) { if (spdk_aer_changed_ns_test()) {
goto done; goto done;
} }
@ -567,7 +567,7 @@ int main(int argc, char **argv)
printf("Cleaning up...\n"); printf("Cleaning up...\n");
while (outstanding_commands) { while (g_outstanding_commands) {
foreach_dev(dev) { foreach_dev(dev) {
spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr); spdk_nvme_ctrlr_process_admin_completions(dev->ctrlr);
} }
@ -578,8 +578,8 @@ int main(int argc, char **argv)
spdk_nvme_ctrlr_register_aer_callback(dev->ctrlr, NULL, NULL); spdk_nvme_ctrlr_register_aer_callback(dev->ctrlr, NULL, NULL);
} }
for (i = 0; i < num_devs; i++) { for (i = 0; i < g_num_devs; i++) {
struct dev *dev = &devs[i]; struct dev *dev = &g_devs[i];
spdk_nvme_detach(dev->ctrlr); spdk_nvme_detach(dev->ctrlr);
} }
@ -587,5 +587,5 @@ int main(int argc, char **argv)
done: done:
cleanup(); cleanup();
return failed; return g_failed;
} }