| 1390 | } |
| 1391 | |
| 1392 | static int |
| 1393 | pipeline_selector_group_members_add(struct rte_swx_ctl_pipeline *p, |
| 1394 | const char *selector_name, |
| 1395 | FILE *file, |
| 1396 | uint32_t *file_line_number) |
| 1397 | { |
| 1398 | char *line = NULL; |
| 1399 | uint32_t line_id = 0; |
| 1400 | int status = 0; |
| 1401 | |
| 1402 | /* Buffer allocation. */ |
| 1403 | line = malloc(MAX_LINE_SIZE); |
| 1404 | if (!line) |
| 1405 | return -ENOMEM; |
| 1406 | |
| 1407 | /* File read. */ |
| 1408 | for (line_id = 1; ; line_id++) { |
| 1409 | uint32_t group_id, member_id, weight; |
| 1410 | int is_blank_or_comment; |
| 1411 | |
| 1412 | if (fgets(line, MAX_LINE_SIZE, file) == NULL) |
| 1413 | break; |
| 1414 | |
| 1415 | status = pipeline_selector_group_member_read(line, |
| 1416 | &group_id, |
| 1417 | &member_id, |
| 1418 | &weight, |
| 1419 | &is_blank_or_comment); |
| 1420 | if (status) { |
| 1421 | if (is_blank_or_comment) |
| 1422 | continue; |
| 1423 | |
| 1424 | goto error; |
| 1425 | } |
| 1426 | |
| 1427 | status = rte_swx_ctl_pipeline_selector_group_member_add(p, |
| 1428 | selector_name, |
| 1429 | group_id, |
| 1430 | member_id, |
| 1431 | weight); |
| 1432 | if (status) |
| 1433 | goto error; |
| 1434 | } |
| 1435 | |
| 1436 | error: |
| 1437 | free(line); |
| 1438 | *file_line_number = line_id; |
| 1439 | return status; |
| 1440 | } |
| 1441 | |
| 1442 | static const char cmd_pipeline_selector_group_member_add_help[] = |
| 1443 | "pipeline <pipeline_name> selector <selector_name> group member add <file_name>"; |
no test coverage detected