| 87 | } |
| 88 | |
| 89 | static int |
| 90 | test_device_reconfigure(struct ml_test *test, struct ml_options *opt) |
| 91 | { |
| 92 | struct rte_ml_dev_config dev_config; |
| 93 | struct rte_ml_dev_qp_conf qp_conf; |
| 94 | struct test_device *t; |
| 95 | uint16_t qp_id = 0; |
| 96 | int ret = 0; |
| 97 | |
| 98 | t = ml_test_priv(test); |
| 99 | |
| 100 | /* configure with default options */ |
| 101 | ret = ml_test_device_configure(test, opt); |
| 102 | if (ret != 0) |
| 103 | return ret; |
| 104 | |
| 105 | /* setup queue pairs with nb_user options */ |
| 106 | for (qp_id = 0; qp_id < opt->queue_pairs; qp_id++) { |
| 107 | qp_conf.nb_desc = opt->queue_size; |
| 108 | qp_conf.cb = NULL; |
| 109 | |
| 110 | ret = rte_ml_dev_queue_pair_setup(opt->dev_id, qp_id, &qp_conf, opt->socket_id); |
| 111 | if (ret != 0) { |
| 112 | ml_err("Failed to setup ML device queue-pair, dev_id = %d, qp_id = %u\n", |
| 113 | opt->dev_id, qp_id); |
| 114 | goto error; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /* start device */ |
| 119 | ret = ml_test_device_start(test, opt); |
| 120 | if (ret != 0) |
| 121 | goto error; |
| 122 | |
| 123 | /* stop device */ |
| 124 | ret = ml_test_device_stop(test, opt); |
| 125 | if (ret != 0) { |
| 126 | ml_err("Failed to stop device"); |
| 127 | goto error; |
| 128 | } |
| 129 | |
| 130 | /* reconfigure device based on dev_info */ |
| 131 | dev_config.socket_id = opt->socket_id; |
| 132 | dev_config.nb_models = t->cmn.dev_info.max_models; |
| 133 | dev_config.nb_queue_pairs = t->cmn.dev_info.max_queue_pairs; |
| 134 | ret = rte_ml_dev_configure(opt->dev_id, &dev_config); |
| 135 | if (ret != 0) { |
| 136 | ml_err("Failed to reconfigure ML device, dev_id = %d\n", opt->dev_id); |
| 137 | return ret; |
| 138 | } |
| 139 | |
| 140 | /* setup queue pairs */ |
| 141 | for (qp_id = 0; qp_id < t->cmn.dev_info.max_queue_pairs; qp_id++) { |
| 142 | qp_conf.nb_desc = t->cmn.dev_info.max_desc; |
| 143 | qp_conf.cb = NULL; |
| 144 | |
| 145 | ret = rte_ml_dev_queue_pair_setup(opt->dev_id, qp_id, &qp_conf, opt->socket_id); |
| 146 | if (ret != 0) { |
no test coverage detected