| 1771 | } |
| 1772 | |
| 1773 | int |
| 1774 | pipeline_table_rule_stats_read(const char *pipeline_name, |
| 1775 | uint32_t table_id, |
| 1776 | struct table_rule_match *match, |
| 1777 | struct rte_table_action_stats_counters *stats, |
| 1778 | int clear) |
| 1779 | { |
| 1780 | struct pipeline *p; |
| 1781 | struct table *table; |
| 1782 | struct pipeline_msg_req *req; |
| 1783 | struct pipeline_msg_rsp *rsp; |
| 1784 | struct table_rule *rule; |
| 1785 | int status; |
| 1786 | |
| 1787 | /* Check input params */ |
| 1788 | if ((pipeline_name == NULL) || |
| 1789 | (match == NULL) || |
| 1790 | (stats == NULL)) |
| 1791 | return -1; |
| 1792 | |
| 1793 | p = pipeline_find(pipeline_name); |
| 1794 | if ((p == NULL) || |
| 1795 | (table_id >= p->n_tables) || |
| 1796 | match_check(match, p, table_id)) |
| 1797 | return -1; |
| 1798 | |
| 1799 | table = &p->table[table_id]; |
| 1800 | rule = table_rule_find(table, match); |
| 1801 | if (rule == NULL) |
| 1802 | return -1; |
| 1803 | |
| 1804 | if (!pipeline_is_running(p)) { |
| 1805 | status = rte_table_action_stats_read(table->a, |
| 1806 | rule->data, |
| 1807 | stats, |
| 1808 | clear); |
| 1809 | |
| 1810 | return status; |
| 1811 | } |
| 1812 | |
| 1813 | /* Allocate request */ |
| 1814 | req = pipeline_msg_alloc(); |
| 1815 | if (req == NULL) |
| 1816 | return -1; |
| 1817 | |
| 1818 | /* Write request */ |
| 1819 | req->type = PIPELINE_REQ_TABLE_RULE_STATS_READ; |
| 1820 | req->id = table_id; |
| 1821 | req->table_rule_stats_read.data = rule->data; |
| 1822 | req->table_rule_stats_read.clear = clear; |
| 1823 | |
| 1824 | /* Send request and wait for response */ |
| 1825 | rsp = pipeline_msg_send_recv(p, req); |
| 1826 | |
| 1827 | /* Read response */ |
| 1828 | status = rsp->status; |
| 1829 | if (status == 0) |
| 1830 | memcpy(stats, &rsp->table_rule_stats_read.stats, sizeof(*stats)); |
no test coverage detected