blob: 4e057010af0ea6b5c768037e3a8a7d660b6f5dde [file] [log] [blame]
Damjan Marion38c61912023-10-17 16:06:26 +00001/* 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 Kushwaha4af3fdf2024-02-06 14:02:43 +05309#include <vnet/flow/flow.h>
Damjan Marion38c61912023-10-17 16:06:26 +000010
11clib_error_t *
12vnet_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 Kushwaha4af3fdf2024-02-06 14:02:43 +053031
32int
33vnet_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}