| 137 | } |
| 138 | |
| 139 | static int |
| 140 | parse_config(char *q_arg) |
| 141 | { |
| 142 | struct lcore_option *lo; |
| 143 | char s[256]; |
| 144 | const char *p, *p0 = q_arg; |
| 145 | char *end; |
| 146 | enum fieldnames { |
| 147 | FLD_LCORE = 0, |
| 148 | FLD_CID, |
| 149 | FLD_QID, |
| 150 | _NUM_FLD |
| 151 | }; |
| 152 | uint32_t flds[_NUM_FLD]; |
| 153 | char *str_fld[_NUM_FLD]; |
| 154 | uint32_t i; |
| 155 | uint32_t size; |
| 156 | |
| 157 | while ((p = strchr(p0, '(')) != NULL) { |
| 158 | ++p; |
| 159 | p0 = strchr(p, ')'); |
| 160 | if (p0 == NULL) |
| 161 | return -1; |
| 162 | |
| 163 | size = p0 - p; |
| 164 | if (size >= sizeof(s)) |
| 165 | return -1; |
| 166 | |
| 167 | snprintf(s, sizeof(s), "%.*s", size, p); |
| 168 | if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != |
| 169 | _NUM_FLD) |
| 170 | return -1; |
| 171 | for (i = 0; i < _NUM_FLD; i++) { |
| 172 | errno = 0; |
| 173 | flds[i] = strtoul(str_fld[i], &end, 0); |
| 174 | if (errno != 0 || end == str_fld[i] || flds[i] > 255) |
| 175 | return -EINVAL; |
| 176 | } |
| 177 | |
| 178 | if (flds[FLD_LCORE] > RTE_MAX_LCORE) |
| 179 | return -EINVAL; |
| 180 | |
| 181 | i = find_lo(flds[FLD_LCORE]); |
| 182 | if (i == UINT32_MAX) { |
| 183 | if (options.nb_los == MAX_NB_WORKER_CORES) |
| 184 | return -ENOMEM; |
| 185 | lo = &options.los[options.nb_los]; |
| 186 | options.nb_los++; |
| 187 | } else |
| 188 | lo = &options.los[i]; |
| 189 | |
| 190 | lo->lcore_id = flds[FLD_LCORE]; |
| 191 | lo->cid = flds[FLD_CID]; |
| 192 | lo->qid = flds[FLD_QID]; |
| 193 | } |
| 194 | |
| 195 | return 0; |
| 196 | } |
no test coverage detected