<commit_before># Copyright 2013-present Barefoot Networks, Inc. 
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

//:: # P4 Thrift RPC Input Template
# P4 Thrift RPC Input

//:: api_prefix = p4_prefix + "_"

include "res.thrift"

namespace py p4_pd_rpc
namespace cpp p4_pd_rpc
namespace c_glib p4_pd_rpc

typedef i32 EntryHandle_t
typedef i32 MemberHandle_t
typedef i32 GroupHandle_t
typedef binary MacAddr_t
typedef binary IPv6_t


//:: # match_fields is list of tuples (name, type)
//:: def gen_match_params(match_fields, field_info):
//::   params = []
//::   for field, type in match_fields:
//::     if type == "valid":
//::       params += [(field + "_valid", 1)]
//::       continue
//::     #endif
//::     f_info = field_info[field]
//::     bytes_needed = (f_info["bit_width"] + 7 ) / 8
//::     params += [(field, bytes_needed)]
//::     if type == "lpm": params += [(field + "_prefix_length", 2)]
//::     if type == "ternary": params += [(field + "_mask", bytes_needed)]
//::   #endfor
//::   return params
//:: #enddef
//::
//:: def gen_action_params(names, byte_widths, _get_thrift_type = get_thrift_type):
//::   params = []
//::   for name, width in zip(names, byte_widths):
//::     name = "action_" + name
//::     params += [(name, width)]
//::   #endfor
//::   return params
//:: #enddef
//::
//::

# Match structs

//:: for table, t_info in table_info.items():
//::   if not t_info["match_fields"]:
//::     continue
//::   #endif
//::   match_params = gen_match_params(t_info["match_fields"], field_info)
struct ${api_prefix}${table}_match_spec_t {
//::   id = 1
//::   for name, width in match_params:
//::     type_ = get_thrift_type(width)
  ${id}: required ${type_} ${name};
//::   id += 1
//::   #endfor
}

//:: #endfor


# Action structs

//:: for action, a_info in action_info.items():
//::   if not a_info["param_names"]:
//::     continue
//::   #endif
//::   action_params = gen_action_params(a_info["param_names"],
//::                                     a_info["param_byte_widths"])
struct ${api_prefix}${action}_action_spec_t {
//::   id = 1
//::   for name, width in action_params:
//::     type_ = get_thrift_type(width)
  ${id}: required ${type_} ${name};
//::     id += 1<commit_msg>Update p4_pd_rpc.thrift<commit_after># Copyright 2013-present Barefoot Networks, Inc. 
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

//:: # P4 Thrift RPC Input Template
# P4 Thrift RPC Input

//:: api_prefix = p4_prefix + "_"

include "res.thrift"

namespace py p4_pd_rpc
namespace cpp p4_pd_rpc
namespace c_glib p4_pd_rpc

typedef i32 EntryHandle_t
typedef i32 MemberHandle_t
typedef i32 GroupHandle_t
typedef binary MacAddr_t
typedef binary IPv6_t


//:: # match_fields is list of tuples (name, type)
//:: def gen_match_params(match_fields, field_info):
//::   params = []
//::   for field, type in match_fields:
//::     if type == "valid":
//::       params += [(field + "_valid", 1)]
//::       continue
//::     #endif
//::     f_info = field_info[field]
//::     bytes_needed = (f_info["bit_width"] + 7 ) / 8
//::     params += [(field, bytes_needed)]
//::     if type == "lpm": params += [(field + "_prefix_length", 2)]
//::     if type == "ternary": params += [(field + "_mask", bytes_needed)]
//::   #endfor
//::   return params
//:: #enddef
//::
//:: def gen_action_params(names, byte_widths, _get_thrift_type = get_thrift_type):
//::   params = []
//::   for name, width in zip(names, byte_widths):
//::     name = "action_" + name
//::     params += [(name, width)]
//::   #endfor
//::   return params
//:: #enddef
//::
//::

# Match structs

//:: for table, t_info in table_info.items():
//::   match_params = gen_match_params(t_info["match_fields"], field_info)
struct ${api_prefix}${table}_match_spec_t {
//::   id = 1
//::   for name, width in match_params:
//::     type_ = get_thrift_type(width)
  ${id}: required ${type_} ${name};
//::   id += 1
//::   #endfor
}

//:: #endfor


# Action structs

//:: for action, a_info in action_info.items():
//::   if not a_info["param_names"]:
//::     continue
//::   #endif
//::   action_params = gen_action_params(a_info["param_names"],
//::                                     a_info["param_byte_widths"])
struct ${api_prefix}${action}_action_spec_t {
//::   id = 1
//::   for name, width in action_params:
//::     type_ = get_thrift_type(width)
  ${id}: required ${type_} ${name};
//::     id += 1
{'fraction_non_alphanumeric': 0.16691422205718529, 'fraction_numerical': 0.010954326030449314, 'mean_word_length': 3.2118842845973417, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3003636', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1793, 'n_words': 517}