<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.
 */

/*
 * <NAME> (<EMAIL>)
 * <NAME> (<EMAIL>)
 *
 */

#ifndef _BM_SIMPLE_PRE_H_
#define _BM_SIMPLE_PRE_H_

#include <unordered_map>

#include "handle_mgr.h"
#include "pre.h"
#include <boost/thread/shared_mutex.hpp>

class McSimplePre {
public:
  typedef unsigned int mgrp_t;
  typedef unsigned int rid_t;
  typedef unsigned int egress_port_t;
  typedef uintptr_t mgrp_hdl_t;
  typedef uintptr_t l1_hdl_t;
  typedef uintptr_t l2_hdl_t;
  
public:
  enum McReturnCode {
    SUCCESS = 0,
    TABLE_FULL,
    INVALID_MGID,
    INVALID_L1_HANDLE,
    INVALID_L2_HANDLE,
    ERROR
  };
  
  struct McIn {
    mgrp_t mgid;
  };
  
  struct McOut {
    rid_t rid;
    egress_port_t egress_port;
  };

public:
  static constexpr size_t PORT_MAP_SIZE = 512;
  typedef McPre::Set<PORT_MAP_SIZE> PortMap;

  static constexpr size_t LAG_MAP_SIZE = 256;
  typedef McPre::Set<LAG_MAP_SIZE> LagMap;
  
  McSimplePre() {}
  McReturnCode mc_mgrp_create(const mgrp_t, mgrp_hdl_t *);
  McReturnCode mc_mgrp_destroy(const mgrp_hdl_t);
  McReturnCode mc_node_create(const rid_t,
		              const PortMap &port_map,
                              l1_hdl_t *l1_hdl);
  McReturnCode mc_node_associate(const mgrp_hdl_t, const l1_hdl_t);
  McReturnCode mc_node_dissociate(const mgrp_hdl_t, const l1_hdl_t);
  McReturnCode mc_node_disassociate(const mgrp_hdl_t, const l1_hdl_t);
  McReturnCode mc_node_destroy(const l1_hdl_t);
  McReturnCode mc_node_update(const l1_hdl_t l1_hdl,<commit_msg>adjusted max number of ports for simple_pre, need to find a better way (not hardcoded) to set this value<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.
 */

/*
 * <NAME> (<EMAIL>)
 * <NAME> (<EMAIL>)
 *
 */

#ifndef _BM_SIMPLE_PRE_H_
#define _BM_SIMPLE_PRE_H_

#include <unordered_map>

#include "handle_mgr.h"
#include "pre.h"
#include <boost/thread/shared_mutex.hpp>

class McSimplePre {
public:
  typedef unsigned int mgrp_t;
  typedef unsigned int rid_t;
  typedef unsigned int egress_port_t;
  typedef uintptr_t mgrp_hdl_t;
  typedef uintptr_t l1_hdl_t;
  typedef uintptr_t l2_hdl_t;
  
public:
  enum McReturnCode {
    SUCCESS = 0,
    TABLE_FULL,
    INVALID_MGID,
    INVALID_L1_HANDLE,
    INVALID_L2_HANDLE,
    ERROR
  };
  
  struct McIn {
    mgrp_t mgid;
  };
  
  struct McOut {
    rid_t rid;
    egress_port_t egress_port;
  };

public:
  static constexpr size_t PORT_MAP_SIZE = 256;
  typedef McPre::Set<PORT_MAP_SIZE> PortMap;

  static constexpr size_t LAG_MAP_SIZE = 256;
  typedef McPre::Set<LAG_MAP_SIZE> LagMap;
  
  McSimplePre() {}
  McReturnCode mc_mgrp_create(const mgrp_t, mgrp_hdl_t *);
  McReturnCode mc_mgrp_destroy(const mgrp_hdl_t);
  McReturnCode mc_node_create(const rid_t,
		              const PortMap &port_map,
                              l1_hdl_t *l1_hdl);
  McReturnCode mc_node_associate(const mgrp_hdl_t, const l1_hdl_t);
  McReturnCode mc_node_dissociate(const mgrp_hdl_t, const l1_hdl_t);
  McReturnCode mc_node_disassociate(const mgrp_hdl_t, const l1_hdl_t);
  McReturnCode mc_node_destroy(const l1_hdl_t);
  McReturnCode mc_node_update(const l1_hdl_t l1_hdl,
{'fraction_non_alphanumeric': 0.07656286583938188, 'fraction_numerical': 0.01264340903769609, 'mean_word_length': 3.961672473867596, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6708359', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1550, 'n_words': 415}