Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | #ifndef SRC_VNET_SESSION_SESSION_DEBUG_H_ |
| 16 | #define SRC_VNET_SESSION_SESSION_DEBUG_H_ |
| 17 | |
| 18 | #include <vnet/session/transport.h> |
| 19 | #include <vnet/session/session.h> |
| 20 | #include <vlib/vlib.h> |
| 21 | |
| 22 | #define foreach_session_dbg_evt \ |
| 23 | _(ENQ, "enqueue") \ |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame^] | 24 | _(DEQ, "dequeue") \ |
| 25 | _(DEQ_NODE, "dequeue") |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 26 | |
| 27 | typedef enum _session_evt_dbg |
| 28 | { |
| 29 | #define _(sym, str) SESSION_EVT_##sym, |
| 30 | foreach_session_dbg_evt |
| 31 | #undef _ |
| 32 | } session_evt_dbg_e; |
| 33 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame^] | 34 | #define SESSION_DBG (0) |
| 35 | #define SESSION_DEQ_NODE_EVTS (0) |
| 36 | |
| 37 | #if TRANSPORT_DEBUG && SESSION_DBG |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 38 | |
| 39 | #define DEC_SESSION_ETD(_s, _e, _size) \ |
| 40 | struct \ |
| 41 | { \ |
| 42 | u32 data[_size]; \ |
| 43 | } * ed; \ |
| 44 | transport_proto_vft_t *vft = \ |
| 45 | session_get_transport_vft (_s->session_type); \ |
| 46 | transport_connection_t *_tc = \ |
| 47 | vft->get_connection (_s->connection_index, _s->thread_index); \ |
| 48 | ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \ |
| 49 | _e, _tc->elog_track) |
| 50 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame^] | 51 | #define DEC_SESSION_ED(_e, _size) \ |
| 52 | struct \ |
| 53 | { \ |
| 54 | u32 data[_size]; \ |
| 55 | } * ed; \ |
| 56 | ed = ELOG_DATA (&vlib_global_main.elog_main, _e) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 57 | |
| 58 | #define SESSION_EVT_DEQ_HANDLER(_s, _body) \ |
| 59 | { \ |
| 60 | ELOG_TYPE_DECLARE (_e) = \ |
| 61 | { \ |
| 62 | .format = "deq: id %d len %d rd %d wnd %d", \ |
| 63 | .format_args = "i4i4i4i4", \ |
| 64 | }; \ |
| 65 | DEC_SESSION_ETD(_s, _e, 4); \ |
| 66 | do { _body; } while (0); \ |
| 67 | } |
| 68 | |
| 69 | #define SESSION_EVT_ENQ_HANDLER(_s, _body) \ |
| 70 | { \ |
| 71 | ELOG_TYPE_DECLARE (_e) = \ |
| 72 | { \ |
| 73 | .format = "enq: id %d length %d", \ |
| 74 | .format_args = "i4i4", \ |
| 75 | }; \ |
| 76 | DEC_SESSION_ETD(_s, _e, 2); \ |
| 77 | do { _body; } while (0); \ |
| 78 | } |
| 79 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame^] | 80 | #if SESSION_DEQ_NODE_EVTS |
| 81 | #define SESSION_EVT_DEQ_NODE_HANDLER(_node_evt) \ |
| 82 | { \ |
| 83 | ELOG_TYPE_DECLARE (_e) = \ |
| 84 | { \ |
| 85 | .format = "deq-node: %s", \ |
| 86 | .format_args = "t4", \ |
| 87 | .n_enum_strings = 2, \ |
| 88 | .enum_strings = { \ |
| 89 | "start", \ |
| 90 | "end", \ |
| 91 | }, \ |
| 92 | }; \ |
| 93 | DEC_SESSION_ED(_e, 1); \ |
| 94 | ed->data[0] = _node_evt; \ |
| 95 | } |
| 96 | #else |
| 97 | #define SESSION_EVT_DEQ_NODE_HANDLER(_node_evt) |
| 98 | #endif |
| 99 | |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 100 | #define CONCAT_HELPER(_a, _b) _a##_b |
| 101 | #define CC(_a, _b) CONCAT_HELPER(_a, _b) |
| 102 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame^] | 103 | #define SESSION_EVT_DBG(_evt, _args...) CC(_evt, _HANDLER)(_args) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 104 | |
| 105 | #else |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame^] | 106 | #define SESSION_EVT_DBG(_evt, _args...) |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 107 | #endif |
| 108 | |
| 109 | #endif /* SRC_VNET_SESSION_SESSION_DEBUG_H_ */ |
| 110 | /* |
| 111 | * fd.io coding-style-patch-verification: ON |
| 112 | * |
| 113 | * Local Variables: |
| 114 | * eval: (c-set-style "gnu") |
| 115 | * End: |
| 116 | */ |