23 #ifndef BM_BM_SIM_LEARNING_H_ 
   24 #define BM_BM_SIM_LEARNING_H_ 
   31 #include "device_id.h" 
   32 #include "transport.h" 
   33 #include "phv_forward.h" 
   46   using list_id_t = int;
 
   47   using buffer_id_t = uint64_t;
 
   59     s_device_id_t switch_id;
 
   63     unsigned int num_samples;
 
   64   } __attribute__((packed));
 
   66   using LearnCb = std::function<void(
const msg_hdr_t &, 
size_t,
 
   67                                      std::unique_ptr<
char[]>, 
void *)>;
 
   71   virtual void list_create(list_id_t list_id, 
const std::string &list_name,
 
   72                            size_t max_samples = 1,
 
   73                            unsigned int timeout_ms = 1000) = 0;
 
   75   virtual void list_set_learn_writer(
 
   76       list_id_t list_id, std::shared_ptr<TransportIface> learn_writer) = 0;
 
   78   virtual void list_set_learn_cb(list_id_t list_id, 
const LearnCb &learn_cb,
 
   81   virtual void list_push_back_field(list_id_t list_id, header_id_t header_id,
 
   82                                     int field_offset) = 0;
 
   84   virtual void list_push_back_constant(list_id_t list_id,
 
   85                                        const std::string &hexstring) = 0;
 
   87   virtual void list_init(list_id_t list_id) = 0;
 
   89   virtual LearnErrorCode list_set_timeout(list_id_t list_id,
 
   90                                           unsigned int timeout_ms) = 0;
 
   92   virtual LearnErrorCode list_set_max_samples(list_id_t list_id,
 
   93                                               size_t max_samples) = 0;
 
   95   virtual LearnErrorCode list_get_name_from_id(
 
   96       list_id_t list_id, std::string *list_name) 
const = 0;
 
   98   virtual LearnErrorCode list_get_id_from_name(
 
   99       const std::string &list_name, list_id_t *list_id) 
const = 0;
 
  108   virtual void learn(list_id_t list_id, 
const Packet &pkt) = 0;
 
  110   virtual LearnErrorCode ack(list_id_t list_id, buffer_id_t buffer_id,
 
  112   virtual LearnErrorCode ack(list_id_t list_id, buffer_id_t buffer_id,
 
  113                              const std::vector<int> &sample_ids) = 0;
 
  114   virtual LearnErrorCode ack_buffer(list_id_t list_id,
 
  115                                     buffer_id_t buffer_id) = 0;
 
  117   virtual void reset_state() = 0;
 
  119   static std::unique_ptr<LearnEngineIface> make(device_id_t device_id = 0,
 
  120                                                 cxt_id_t cxt_id = 0);
 
  125 #endif  // BM_BM_SIM_LEARNING_H_