| 5523 | " - line format: <tc_id> <tc_queue_id> <color>, with <color> as: g | y | r\n"; |
| 5524 | |
| 5525 | static int |
| 5526 | load_dscp_table(struct rte_table_action_dscp_table *dscp_table, |
| 5527 | const char *file_name, |
| 5528 | uint32_t *line_number) |
| 5529 | { |
| 5530 | FILE *f = NULL; |
| 5531 | uint32_t dscp, l; |
| 5532 | |
| 5533 | /* Check input arguments */ |
| 5534 | if ((dscp_table == NULL) || |
| 5535 | (file_name == NULL) || |
| 5536 | (line_number == NULL)) { |
| 5537 | if (line_number) |
| 5538 | *line_number = 0; |
| 5539 | return -EINVAL; |
| 5540 | } |
| 5541 | |
| 5542 | /* Open input file */ |
| 5543 | f = fopen(file_name, "r"); |
| 5544 | if (f == NULL) { |
| 5545 | *line_number = 0; |
| 5546 | return -EINVAL; |
| 5547 | } |
| 5548 | |
| 5549 | /* Read file */ |
| 5550 | for (dscp = 0, l = 1; ; l++) { |
| 5551 | char line[64]; |
| 5552 | char *tokens[3]; |
| 5553 | enum rte_color color; |
| 5554 | uint32_t tc_id, tc_queue_id, n_tokens = RTE_DIM(tokens); |
| 5555 | |
| 5556 | if (fgets(line, sizeof(line), f) == NULL) |
| 5557 | break; |
| 5558 | |
| 5559 | if (is_comment(line)) |
| 5560 | continue; |
| 5561 | |
| 5562 | if (parse_tokenize_string(line, tokens, &n_tokens)) { |
| 5563 | *line_number = l; |
| 5564 | fclose(f); |
| 5565 | return -EINVAL; |
| 5566 | } |
| 5567 | |
| 5568 | if (n_tokens == 0) |
| 5569 | continue; |
| 5570 | |
| 5571 | if ((dscp >= RTE_DIM(dscp_table->entry)) || |
| 5572 | (n_tokens != RTE_DIM(tokens)) || |
| 5573 | parser_read_uint32(&tc_id, tokens[0]) || |
| 5574 | (tc_id >= RTE_TABLE_ACTION_TC_MAX) || |
| 5575 | parser_read_uint32(&tc_queue_id, tokens[1]) || |
| 5576 | (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) || |
| 5577 | (strlen(tokens[2]) != 1)) { |
| 5578 | *line_number = l; |
| 5579 | fclose(f); |
| 5580 | return -EINVAL; |
| 5581 | } |
| 5582 |
no test coverage detected