Damjan Marion | 38c6191 | 2023-10-17 16:06:26 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright (c) 2023 Cisco Systems, Inc. |
| 3 | */ |
| 4 | |
| 5 | #include <vnet/vnet.h> |
| 6 | #include <vnet/ethernet/ethernet.h> |
| 7 | #include <vnet/dev/dev.h> |
| 8 | #include <vnet/dev/counters.h> |
Monendra Singh Kushwaha | 4af3fdf | 2024-02-06 14:02:43 +0530 | [diff] [blame] | 9 | #include <vnet/flow/flow.h> |
Damjan Marion | 38c6191 | 2023-10-17 16:06:26 +0000 | [diff] [blame] | 10 | |
| 11 | clib_error_t * |
| 12 | vnet_dev_port_err (vlib_main_t *vm, vnet_dev_port_t *port, vnet_dev_rv_t rv, |
| 13 | char *fmt, ...) |
| 14 | { |
| 15 | clib_error_t *err; |
| 16 | va_list va; |
| 17 | u8 *s; |
| 18 | |
| 19 | if (rv == VNET_DEV_OK) |
| 20 | return 0; |
| 21 | |
| 22 | va_start (va, fmt); |
| 23 | s = va_format (0, fmt, &va); |
| 24 | va_end (va); |
| 25 | |
| 26 | err = clib_error_return (0, "%s port %u: %U (%v)", port->dev->device_id, |
| 27 | port->port_id, format_vnet_dev_rv, rv, s); |
| 28 | vec_free (s); |
| 29 | return err; |
| 30 | } |
Monendra Singh Kushwaha | 4af3fdf | 2024-02-06 14:02:43 +0530 | [diff] [blame] | 31 | |
| 32 | int |
| 33 | vnet_dev_flow_err (vlib_main_t *vm, vnet_dev_rv_t rv) |
| 34 | { |
| 35 | if (rv == VNET_DEV_OK) |
| 36 | return 0; |
| 37 | |
| 38 | switch (rv) |
| 39 | { |
| 40 | /* clang-format off */ |
| 41 | #define _(n, e, s) \ |
| 42 | case VNET_DEV_ERR_##e: \ |
| 43 | return VNET_FLOW_ERROR_##e; |
| 44 | foreach_flow_error; |
| 45 | #undef _ |
| 46 | /* clang-format on */ |
| 47 | default: |
| 48 | ASSERT (0); |
| 49 | } |
| 50 | |
| 51 | ASSERT (0); |
| 52 | |
| 53 | return 0; |
| 54 | } |