Open Ethernet Networking (OpEN) API Guide and Reference Manual  3.6.0.3
openapi_instru_bhd.h
Go to the documentation of this file.
1 
9 /*********************************************************************
10 *
11 * Copyright 2016-2018 Broadcom
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 **********************************************************************
26 *
27 * @filename openapi_instru_bhd.h
28 *
29 * @purpose Instrumentation BHD Specific APIs
30 *
31 * @component OPEN
32 *
33 * @create 7/19/2016
34 *
35 * @end
36 *
37 **********************************************************************/
38 
39 
40 #ifndef OPENAPI_BHD_H_INCLUDED
41 #define OPENAPI_BHD_H_INCLUDED
42 #include <string.h>
43 #include <stdio.h>
44 #include <stdbool.h>
45 
46 #include <netinet/in.h>
47 #include "openapi_common.h"
48 #include "openapi_instru_nos.h"
49 
50 #define OPEN_BHD_MAX_PACKET_SIZE OPEN_INSTRU_MAX_PACKET_SIZE
51 
52 /* Maximum number of ports supported to participate in BHD */
53 #define BVIEW_BHD_MAX_SUPPORTED_PORTS OPEN_ASIC_MAX_PORTS
54 
55 /* Maximum size of the sampled packet reported in asynchronous BHD event reports */
56 #define BVIEW_BHD_MAX_UNITS 1
57 
58 #define BVIEW_BHD_WATERMARK_MIN 100
59 #define BVIEW_BHD_WATERMARK_MAX 10000
60 
61 #define BVIEW_BHD_SAMPLE_PERIODICITY_MIN 1
62 #define BVIEW_BHD_SAMPLE_PERIODICITY_MAX (60*60)
63 
64 #define BVIEW_BHD_SAMPLE_COUNT_MIN 0
65 #define BVIEW_BHD_SAMPLE_COUNT_MAX 30
66 
67 #define BVIEW_BHD_VLAN_MIN 1
68 #define BVIEW_BHD_VLAN_MAX 4094
69 
70 #define BVIEW_BHD_SOURCE_UDP_PORT_MIN 1
71 #define BVIEW_BHD_SOURCE_UDP_PORT_MAX 65535
72 
73 #define BVIEW_BHD_DEST_UDP_PORT_MIN 1
74 #define BVIEW_BHD_DEST_UDP_PORT_MAX 65535
75 
76 #define BVIEW_BHD_SAMP_POOL_SIZE_MIN 1024
77 #define BVIEW_BHD_SAMP_POOL_SIZE_MAX 100000
78 
79 #define OPEN_BHD_MAX_PORT_LIST_STR 256
80 #define OPEN_BHD_MAX_PORT_STR 8
81 
82 #define OPEN_BHD_SFLOW_AGENT_NUM 1
83 #define OPEN_BHD_SFLOW_SESSION 1
84 
85 /* Black Holed packet Sampling methods*/
86 typedef enum
87 {
88  /* Agent sampling */
89  OPEN_BHD_AGENT_SAMPLING = (1 << 0),
90  /* sFlow sampling */
91  OPEN_BHD_SFLOW_SAMPLING = (1 << 1),
92  OPEN_BHD_MAX_SAMPLING_METHOD
93 
94 }OPEN_BHD_PKT_SAMPLING_METHOD_t;
95 
96 #define BVIEW_BHD_DEFAULT_PKT_SAMPLING_METHOD BVIEW_BHD_AGENT_SAMPLING
97 
98 /* Sampling Parameters */
99 typedef union
100 {
102  {
103  /* This represents the traffic rate above
104  which traffic is considered as Black holed.
105  Sampling would start only after the water-mark level is crossed */
106  uint32_t water_mark;
107  /* Time interval in seconds. */
108  uint32_t sample_periodicity;
109  /* Number of samples to be sent with in sample_periodicity interval */
110  uint32_t sample_count;
111 
112  } agent_sampling_params;
113 
115  {
116  /* vlan-id of sflow encapsulation header */
117  uint32_t encap_vlan_id;
118  /* Destination IP address sflow encapsulation header */
119  struct in_addr encap_dest_ip_addr;
120  /* Source udp port number of sflow encapsulation header */
121  uint16_t encap_src_udp_port;
122  /* Destination udp port number of sflow encapsulation header */
123  uint16_t encap_dest_udp_port;
124  /* Mirror Port number on which sflow encapsulated
125  sample packet is sent out */
126  uint32_t mirror_port;
127  char mirror_port_str[OPEN_BHD_MAX_PORT_STR];
128 
129  /* Represents the packet pool size for sampling.
130  One packet is sampled for each pool. Minimum is 1024 */
131  uint32_t sample_pool_size;
132 
133  } sflow_sampling_params;
134 
136 
137 
138 /* Sampling configuration */
139 typedef struct
140 {
141  /* sampling method */
142  OPEN_BHD_PKT_SAMPLING_METHOD_t sampling_method;
143  /* Sampling Parameters */
144  OPEN_BHD_PKT_SAMPLING_PARAMS_t sampling_params;
145 
147 
148 typedef struct
149 {
150  /* List of ports participating in BHD */
151  OPEN_PORT_MASK_t black_hole_port_mask;
152  uint8_t black_hole_port_list_str[OPEN_BHD_MAX_PORT_LIST_STR];
153 
154  /* Pkt sampling configuration */
155  OPEN_BHD_PKT_SAMPLING_CONFIG_t sampling_config;
156 
158 
159 /*sFlow sampling status per port */
160 typedef struct
161 {
162  /* Ingress port number */
163  int32_t port;
164  char portStr[OPEN_BHD_MAX_PORT_STR];
165  /* sFlow sampling is enabled or not */
166  bool sflowSamplingEnabled;
167  /* Total number of packets sampled since sflow sampling is enabled */
168  uint32_t sampled_pkt_count;
169  /* Total number of packets black holed since sflow sampling is enabled */
170  uint32_t black_holed_pkt_count;
171 
173 
174 /*****************************************************************/
190  int32_t asic,
191  int32_t port,
192  open_buffdesc *port_list,
194 
195 
196 /*****************************************************************/
211  int32_t asic, int32_t sFlow, open_buffdesc *port_list);
212 
213 /*****************************************************************/
227  int32_t asic,
228  OPEN_BLACK_HOLE_CONFIG_t *config);
229 
230 /*****************************************************************/
244  int32_t asic,
245  int32_t *sampling_capabilities);
246 
247 /*****************************************************************/
261  int32_t asic,
262  uint64_t *count);
263 #endif
264 
open_error_t openapiBhdSflowSamplingStatusGet(openapiClientHandle_t *clientHandle, int32_t asic, int32_t port, open_buffdesc *port_list, OPEN_BHD_PORT_SFLOW_SAMPLING_STATUS_t *status)
BHD feature sflow configuration get function.
open_error_t
OPEN uses these enumerators to indicate the error codes.
open_error_t openapiBhdBlackHoleCancel(openapiClientHandle_t *clientHandle, int32_t asic, int32_t sFlow, open_buffdesc *port_list)
BHD feature, cancel black hole.
open_error_t openapiBhdBlackHoleConfigure(openapiClientHandle_t *clientHandle, int32_t asic, OPEN_BLACK_HOLE_CONFIG_t *config)
BHD feature, configure black hole.
open_error_t openapiBhdAsicCapabilitiesGet(openapiClientHandle_t *clientHandle, int32_t asic, int32_t *sampling_capabilities)
BHD feature, asic sampling capabilities get.
open_error_t openapiBhdPacketCountGet(openapiClientHandle_t *clientHandle, int32_t asic, uint64_t *count)
BHD feature, Black holed packet count get.