* Prepare a mlx5 kvargs control. * * @param[out] mkvlist * Pointer to mlx5 kvargs control. * @param[in] devargs * The input string containing the key/value associations. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 159 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 160 | */ |
| 161 | static int |
| 162 | mlx5_kvargs_prepare(struct mlx5_kvargs_ctrl *mkvlist, |
| 163 | const struct rte_devargs *devargs) |
| 164 | { |
| 165 | struct rte_kvargs *kvlist; |
| 166 | uint32_t i; |
| 167 | |
| 168 | if (mkvlist == NULL) |
| 169 | return 0; |
| 170 | MLX5_ASSERT(devargs != NULL && devargs->args != NULL); |
| 171 | kvlist = rte_kvargs_parse(devargs->args, NULL); |
| 172 | if (kvlist == NULL) { |
| 173 | rte_errno = EINVAL; |
| 174 | return -rte_errno; |
| 175 | } |
| 176 | /* |
| 177 | * rte_kvargs_parse enable key without value, in mlx5 PMDs we disable |
| 178 | * this syntax. |
| 179 | */ |
| 180 | for (i = 0; i < kvlist->count; i++) { |
| 181 | const struct rte_kvargs_pair *pair = &kvlist->pairs[i]; |
| 182 | if (pair->value == NULL || *(pair->value) == '\0') { |
| 183 | DRV_LOG(ERR, "Key %s is missing value.", pair->key); |
| 184 | rte_kvargs_free(kvlist); |
| 185 | rte_errno = EINVAL; |
| 186 | return -rte_errno; |
| 187 | } |
| 188 | } |
| 189 | /* Makes sure all devargs used array is false. */ |
| 190 | memset(mkvlist, 0, sizeof(*mkvlist)); |
| 191 | mkvlist->kvlist = kvlist; |
| 192 | DRV_LOG(DEBUG, "Parse successfully %u devargs.", |
| 193 | mkvlist->kvlist->count); |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Release a mlx5 kvargs control. |
no test coverage detected