Mellanox / SAI-P4-BM

37 stars 19 forks source link

Miscellaneous Issues #6

Open hesingh opened 5 years ago

hesingh commented 5 years ago

I am using Ubuntu 18.04. I already have behavioral-model working on my machine since its used by p4c. Thus, the machine has all dependencies that the behavioral-model needs. But, still, using the behavioral-model in sai-p4-bm, I run into build problems.

  1. First the README.md file in the top-level directory should say, "use --recursive" to git clone the software or the behavioral-model is not downloaded.
  2. The submodule of behavioral-model does not seem to be a correct version because it fails to compile spdlog.h. I removed the behavioral-model from SAI-P4-BM/p4-switch/ and downloaded the latest one from github and then behavioral-model build successfully.
  3. However, the make in SAI-P4-BM/p4-switch/ fails. The failure is due to these four files:

p4-switch/sai-p4-target/main.cpp p4-switch/sai-p4-target/primitives.cpp p4-switch/sai-p4-target/simple_switch.cpp /p4-switch/sai-p4-target/simple_switch.h

I had to change simple_switch.h to fix the compilation 'override' error.

diff --git a/p4-switch/sai-p4-target/simple_switch.h b/p4-switch/sai-p4-target/simple_switch.h
index fbdaf77..80495d6 100644
--- a/p4-switch/sai-p4-target/simple_switch.h
+++ b/p4-switch/sai-p4-target/simple_switch.h
@@ -75,11 +75,11 @@ class SimpleSwitch : public Switch {
   // by default, swapping is off
   explicit SimpleSwitch(int max_port = 256, bool enable_swap = false);

-  int receive(int port_num, const char *buffer, int len) override;
+  int receive(int port_num, const char *buffer, int len) /*override*/;

-  void start_and_return() override;
+  void start_and_return() /*override*/;

-  void reset_target_state() override;
+  void reset_target_state() /*override*/;

   int mirroring_mapping_add(mirror_id_t mirror_id, int egress_port) {
     mirroring_map[mirror_id] = egress_port;

I also had to comment out code in simple_switch.cpp to fix its compilation.

diff --git a/p4-switch/sai-p4-target/simple_switch.cpp b/p4-switch/sai-p4-target/simple_switch.cpp
index 36d9650..5e4f0b4 100644
--- a/p4-switch/sai-p4-target/simple_switch.cpp
+++ b/p4-switch/sai-p4-target/simple_switch.cpp
@@ -276,10 +276,12 @@ SimpleSwitch::copy_ingress_pkt(
   phv_copy->reset_metadata();
   FieldList *field_list = this->get_field_list(field_list_id);
   const PHV *phv = packet->get_phv();
-  for (const auto &p : *field_list) {
+#if 0  
+  for (const auto &p : field_list) {
     phv_copy->get_field(p.header, p.offset)
         .set(phv->get_field(p.header, p.offset));
   }
+#endif  
   phv_copy->get_field("standard_metadata.instance_type").set(copy_type);
   return packet_copy;
 }
@@ -483,10 +485,12 @@ SimpleSwitch::egress_thread(size_t worker_id) {
             packet->clone_with_phv_reset_metadata_ptr();
         PHV *phv_copy = packet_copy->get_phv();
         FieldList *field_list = this->get_field_list(field_list_id);
+#if 0      
         for (const auto &p : *field_list) {
           phv_copy->get_field(p.header, p.offset)
             .set(phv->get_field(p.header, p.offset));
         }
+#endif     
         phv_copy->get_field("standard_metadata.instance_type")
             .set(PKT_INSTANCE_TYPE_EGRESS_CLONE);
         enqueue(egress_port, std::move(packet_copy));
@@ -522,10 +526,12 @@ SimpleSwitch::egress_thread(size_t worker_id) {
         std::unique_ptr<Packet> packet_copy = packet->clone_no_phv_ptr();
         PHV *phv_copy = packet_copy->get_phv();
         phv_copy->reset_metadata();
+#if 0      
         for (const auto &p : *field_list) {
           phv_copy->get_field(p.header, p.offset)
               .set(phv->get_field(p.header, p.offset));
         }
+#endif     
         phv_copy->get_field("standard_metadata.instance_type")
             .set(PKT_INSTANCE_TYPE_RECIRC);

See log below.

/SimpleSwitch_server.o
primitives.cpp: In member function ‘virtual void exit_::operator()()’:
primitives.cpp:148:15: error: invalid use of incomplete type ‘class bm::Packet’
     get_packet().mark_for_exit();
     ~~~~~~~~~~^~
In file included from ../behavioral-model/include/bm/bm_sim/actions.h:83:0,
                 from primitives.cpp:21:
../behavioral-model/include/bm/bm_sim/phv.h:74:16: note: forward declaration of ‘class bm::Packet’
   friend class Packet;
                ^~~~~~
primitives.cpp: In member function ‘virtual void add_header::operator()(bm::Header&)’:
primitives.cpp:172:7: error: invalid use of incomplete type ‘class bm::Packet’
       packet.set_register(0, packet.get_register(0) + hdr.get_nbytes_packet());
       ^~~~~~
In file included from ../behavioral-model/include/bm/bm_sim/actions.h:83:0,
                 from primitives.cpp:21:
../behavioral-model/include/bm/bm_sim/phv.h:74:16: note: forward declaration of ‘class bm::Packet’
   friend class Packet;
                ^~~~~~
primitives.cpp:172:30: error: invalid use of incomplete type ‘class bm::Packet’
       packet.set_register(0, packet.get_register(0) + hdr.get_nbytes_packet());
                              ^~~~~~
In file included from ../behavioral-model/include/bm/bm_sim/actions.h:83:0,
                 from primitives.cpp:21:
../behavioral-model/include/bm/bm_sim/phv.h:74:16: note: forward declaration of ‘class bm::Packet’
   friend class Packet;
                ^~~~~~
primitives.cpp: In member function ‘virtual void remove_header::operator()(bm::Header&)’:
primitives.cpp:192:7: error: invalid use of incomplete type ‘class bm::Packet’
       packet.set_register(0, packet.get_register(0) - hdr.get_nbytes_packet());
       ^~~~~~
In file included from ../behavioral-model/include/bm/bm_sim/actions.h:83:0,
                 from primitives.cpp:21:
../behavioral-model/include/bm/bm_sim/phv.h:74:16: note: forward declaration of ‘class bm::Packet’
   friend class Packet;
                ^~~~~~
primitives.cpp:192:30: error: invalid use of incomplete type ‘class bm::Packet’
       packet.set_register(0, packet.get_register(0) - hdr.get_nbytes_packet());
                              ^~~~~~
In file included from ../behavioral-model/include/bm/bm_sim/actions.h:83:0,
                 from primitives.cpp:21:
../behavioral-model/include/bm/bm_sim/phv.h:74:16: note: forward declaration of ‘class bm::Packet’
   friend class Packet;
                ^~~~~~
primitives.cpp: In member function ‘virtual void modify_field_with_hash_based_offset::operator()(bm::Data&, const bm::Data&, const bm::NamedCalculation&, const bm::Data&)’:
primitives.cpp:268:8: error: invalid use of incomplete type ‘const class bm::NamedCalculation’
       (hash.output(get_packet()) % size.get<uint64_t>()) + base.get<uint64_t>();
        ^~~~
In file included from primitives.cpp:21:0:
../behavioral-model/include/bm/bm_sim/actions.h:95:7: note: forward declaration of ‘class bm::NamedCalculation’
 class NamedCalculation;
       ^~~~~~~~~~~~~~~~
primitives.cpp: In member function ‘virtual void execute_meter::operator()(bm::MeterArray&, const bm::Data&, bm::Field&)’:
primitives.cpp:286:13: error: invalid use of incomplete type ‘class bm::MeterArray’
     dst.set(meter_array.execute_meter(get_packet(), idx.get_uint()));
             ^~~~~~~~~~~
In file included from primitives.cpp:21:0:
../behavioral-model/include/bm/bm_sim/actions.h:96:7: note: forward declaration of ‘class bm::MeterArray’
 class MeterArray;
       ^~~~~~~~~~
primitives.cpp: In member function ‘virtual void count::operator()(bm::CounterArray&, const bm::Data&)’:
primitives.cpp:294:5: error: invalid use of incomplete type ‘class bm::CounterArray’
     counter_array.get_counter(idx.get_uint()).increment_counter(get_packet());
     ^~~~~~~~~~~~~
In file included from primitives.cpp:21:0:
../behavioral-model/include/bm/bm_sim/actions.h:97:7: note: forward declaration of ‘class bm::CounterArray’
 class CounterArray;
       ^~~~~~~~~~~~
primitives.cpp: In member function ‘virtual void truncate_::operator()(const bm::Data&)’:
primitives.cpp:352:15: error: invalid use of incomplete type ‘class bm::Packet’
     get_packet().truncate(truncated_length.get<size_t>());
     ~~~~~~~~~~^~
In file included from ../behavioral-model/include/bm/bm_sim/actions.h:83:0,
                 from primitives.cpp:21:
../behavioral-model/include/bm/bm_sim/phv.h:74:16: note: forward declaration of ‘class bm::Packet’
   friend class Packet;
                ^~~~~~
Makefile:701: recipe for target 'primitives.lo' failed
make[2]: *** [primitives.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from simple_switch.cpp:31:0:
simple_switch.h:78:7: error: ‘int SimpleSwitch::receive(int, const char*, int)’ marked ‘override’, but does not override
   int receive(int port_num, const char *buffer, int len) override;
       ^~~~~~~
simple_switch.h:80:8: error: ‘void SimpleSwitch::start_and_return()’ marked ‘override’, but does not override
   void start_and_return() override;
        ^~~~~~~~~~~~~~~~
simple_switch.h:82:8: error: ‘void SimpleSwitch::reset_target_state()’ marked ‘override’, but does not override
   void reset_target_state() override;
        ^~~~~~~~~~~~~~~~~~
simple_switch.cpp: In member function ‘std::unique_ptr<bm::Packet> SimpleSwitch::copy_ingress_pkt(const std::unique_ptr<bm::Packet>&, SimpleSwitch::PktInstanceType, bm::p4object_id_t)’:
simple_switch.cpp:279:25: error: ‘begin’ was not declared in this scope
   for (const auto &p : *field_list) {
                         ^~~~~~~~~~
simple_switch.cpp:279:25: note: suggested alternatives:
In file included from /usr/include/c++/7/string:51:0,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:27,
                 from simple_switch.cpp:21:
/usr/include/c++/7/bits/range_access.h:87:5: note:   ‘std::begin’
     begin(_Tp (&__arr)[_Nm])
     ^~~~~
In file included from /usr/include/boost/range/functions.hpp:18:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/begin.hpp:106:61: note:   ‘boost::range_adl_barrier::begin’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
                                                             ^~~~~
In file included from /usr/include/boost/mpl/begin_end.hpp:17:0,
                 from /usr/include/boost/mpl/iter_fold_if.hpp:18,
                 from /usr/include/boost/mpl/find_if.hpp:19,
                 from /usr/include/boost/multiprecision/number.hpp:13,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/mpl/begin_end_fwd.hpp:22:38: note:   ‘boost::mpl::begin’
 template< typename Sequence > struct begin;
                                      ^~~~~
In file included from /usr/include/boost/range/functions.hpp:18:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/begin.hpp:106:61: note:   ‘boost::range_adl_barrier::begin’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
                                                             ^~~~~
simple_switch.cpp:279:25: error: ‘end’ was not declared in this scope
   for (const auto &p : *field_list) {
                         ^~~~~~~~~~
simple_switch.cpp:279:25: note: suggested alternatives:
In file included from /usr/include/c++/7/string:51:0,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:27,
                 from simple_switch.cpp:21:
/usr/include/c++/7/bits/range_access.h:97:5: note:   ‘std::end’
     end(_Tp (&__arr)[_Nm])
     ^~~
In file included from /usr/include/boost/range/functions.hpp:19:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/end.hpp:100:61: note:   ‘boost::range_adl_barrier::end’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
                                                             ^~~
In file included from /usr/include/boost/mpl/begin_end.hpp:17:0,
                 from /usr/include/boost/mpl/iter_fold_if.hpp:18,
                 from /usr/include/boost/mpl/find_if.hpp:19,
                 from /usr/include/boost/multiprecision/number.hpp:13,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/mpl/begin_end_fwd.hpp:23:38: note:   ‘boost::mpl::end’
 template< typename Sequence > struct end;
                                      ^~~
In file included from /usr/include/boost/range/functions.hpp:19:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/end.hpp:100:61: note:   ‘boost::range_adl_barrier::end’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
                                                             ^~~
simple_switch.cpp: In member function ‘void SimpleSwitch::egress_thread(size_t)’:
simple_switch.cpp:486:31: error: ‘begin’ was not declared in this scope
         for (const auto &p : *field_list) {
                               ^~~~~~~~~~
simple_switch.cpp:486:31: note: suggested alternatives:
In file included from /usr/include/c++/7/string:51:0,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:27,
                 from simple_switch.cpp:21:
/usr/include/c++/7/bits/range_access.h:87:5: note:   ‘std::begin’
     begin(_Tp (&__arr)[_Nm])
     ^~~~~
In file included from /usr/include/boost/range/functions.hpp:18:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/begin.hpp:106:61: note:   ‘boost::range_adl_barrier::begin’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
                                                             ^~~~~
In file included from /usr/include/boost/mpl/begin_end.hpp:17:0,
                 from /usr/include/boost/mpl/iter_fold_if.hpp:18,
                 from /usr/include/boost/mpl/find_if.hpp:19,
                 from /usr/include/boost/multiprecision/number.hpp:13,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/mpl/begin_end_fwd.hpp:22:38: note:   ‘boost::mpl::begin’
 template< typename Sequence > struct begin;
                                      ^~~~~
In file included from /usr/include/boost/range/functions.hpp:18:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/begin.hpp:106:61: note:   ‘boost::range_adl_barrier::begin’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
                                                             ^~~~~
simple_switch.cpp:486:31: error: ‘end’ was not declared in this scope
         for (const auto &p : *field_list) {
                               ^~~~~~~~~~
simple_switch.cpp:486:31: note: suggested alternatives:
In file included from /usr/include/c++/7/string:51:0,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:27,
                 from simple_switch.cpp:21:
/usr/include/c++/7/bits/range_access.h:97:5: note:   ‘std::end’
     end(_Tp (&__arr)[_Nm])
     ^~~
In file included from /usr/include/boost/range/functions.hpp:19:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/end.hpp:100:61: note:   ‘boost::range_adl_barrier::end’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
                                                             ^~~
In file included from /usr/include/boost/mpl/begin_end.hpp:17:0,
                 from /usr/include/boost/mpl/iter_fold_if.hpp:18,
                 from /usr/include/boost/mpl/find_if.hpp:19,
                 from /usr/include/boost/multiprecision/number.hpp:13,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/mpl/begin_end_fwd.hpp:23:38: note:   ‘boost::mpl::end’
 template< typename Sequence > struct end;
                                      ^~~
In file included from /usr/include/boost/range/functions.hpp:19:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/end.hpp:100:61: note:   ‘boost::range_adl_barrier::end’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
                                                             ^~~
simple_switch.cpp:525:31: error: ‘begin’ was not declared in this scope
         for (const auto &p : *field_list) {
                               ^~~~~~~~~~
simple_switch.cpp:525:31: note: suggested alternatives:
In file included from /usr/include/c++/7/string:51:0,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:27,
                 from simple_switch.cpp:21:
/usr/include/c++/7/bits/range_access.h:87:5: note:   ‘std::begin’
     begin(_Tp (&__arr)[_Nm])
     ^~~~~
In file included from /usr/include/boost/range/functions.hpp:18:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/begin.hpp:106:61: note:   ‘boost::range_adl_barrier::begin’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
                                                             ^~~~~
In file included from /usr/include/boost/mpl/begin_end.hpp:17:0,
                 from /usr/include/boost/mpl/iter_fold_if.hpp:18,
                 from /usr/include/boost/mpl/find_if.hpp:19,
                 from /usr/include/boost/multiprecision/number.hpp:13,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/mpl/begin_end_fwd.hpp:22:38: note:   ‘boost::mpl::begin’
 template< typename Sequence > struct begin;
                                      ^~~~~
In file included from /usr/include/boost/range/functions.hpp:18:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/begin.hpp:106:61: note:   ‘boost::range_adl_barrier::begin’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
                                                             ^~~~~
simple_switch.cpp:525:31: error: ‘end’ was not declared in this scope
         for (const auto &p : *field_list) {
                               ^~~~~~~~~~
simple_switch.cpp:525:31: note: suggested alternatives:
In file included from /usr/include/c++/7/string:51:0,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:27,
                 from simple_switch.cpp:21:
/usr/include/c++/7/bits/range_access.h:97:5: note:   ‘std::end’
     end(_Tp (&__arr)[_Nm])
     ^~~
In file included from /usr/include/boost/range/functions.hpp:19:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/end.hpp:100:61: note:   ‘boost::range_adl_barrier::end’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
                                                             ^~~
In file included from /usr/include/boost/mpl/begin_end.hpp:17:0,
                 from /usr/include/boost/mpl/iter_fold_if.hpp:18,
                 from /usr/include/boost/mpl/find_if.hpp:19,
                 from /usr/include/boost/multiprecision/number.hpp:13,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/mpl/begin_end_fwd.hpp:23:38: note:   ‘boost::mpl::end’
 template< typename Sequence > struct end;
                                      ^~~
In file included from /usr/include/boost/range/functions.hpp:19:0,
                 from /usr/include/boost/range/iterator_range_core.hpp:38,
                 from /usr/include/boost/lexical_cast.hpp:30,
                 from /usr/include/boost/multiprecision/detail/number_base.hpp:18,
                 from /usr/include/boost/multiprecision/detail/default_ops.hpp:10,
                 from /usr/include/boost/multiprecision/detail/generic_interconvert.hpp:9,
                 from /usr/include/boost/multiprecision/number.hpp:22,
                 from /usr/include/boost/multiprecision/gmp.hpp:9,
                 from ../behavioral-model/include/bm/bm_sim/bignum.h:25,
                 from ../behavioral-model/include/bm/bm_sim/data.h:34,
                 from ../behavioral-model/include/bm/bm_sim/stateful.h:46,
                 from ../behavioral-model/include/bm/bm_sim/parser.h:36,
                 from simple_switch.cpp:21:
/usr/include/boost/range/end.hpp:100:61: note:   ‘boost::range_adl_barrier::end’
 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
                                                             ^~~
In file included from thrift/src/SimpleSwitch_server.cpp:42:0:
./simple_switch.h:78:7: error: ‘int SimpleSwitch::receive(int, const char*, int)’ marked ‘override’, but does not override
   int receive(int port_num, const char *buffer, int len) override;
       ^~~~~~~
./simple_switch.h:80:8: error: ‘void SimpleSwitch::start_and_return()’ marked ‘override’, but does not override
   void start_and_return() override;
        ^~~~~~~~~~~~~~~~
./simple_switch.h:82:8: error: ‘void SimpleSwitch::reset_target_state()’ marked ‘override’, but does not override
   void reset_target_state() override;
        ^~~~~~~~~~~~~~~~~~
Makefile:701: recipe for target 'simple_switch.lo' failed
make[2]: *** [simple_switch.lo] Error 1
Makefile:701: recipe for target 'thrift/src/SimpleSwitch_server.lo' failed
make[2]: *** [thrift/src/SimpleSwitch_server.lo] Error 1
make[2]: Leaving directory '/home/hemant/SAI-P4-BM/p4-switch/sai-p4-target'
Makefile:472: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/hemant/SAI-P4-BM/p4-switch/sai-p4-target'
Makefile:396: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
  1. When can one expect the p4src to be ported to P4-16? If I can get past my failures above, I can test porting to P4-16.
hesingh commented 5 years ago

The following code changes to SAI-P4-BM/p4-switch/behavioral-model have fixed the build. I wonder why these changes do not exist in this repo's behavioral-model?

diff --git a/include/bm/bm_apps/packet_pipe.h b/include/bm/bm_apps/packet_pipe.h
index 0478b29..c8ed181 100644
--- a/include/bm/bm_apps/packet_pipe.h
+++ b/include/bm/bm_apps/packet_pipe.h
@@ -25,6 +25,7 @@
 #include <thread>
 #include <mutex>
 #include <memory>
+#include <functional>

 namespace bm_apps {

@@ -33,8 +34,8 @@ class PacketInjectImp;
 class PacketInject {
  public:
   // the library owns the memory, make a copy if you need before returning
-  typedef std::function<void(int port_num, const char *buffer, int len,
-                             void *cookie)> PacketReceiveCb;
+  using PacketReceiveCb = std::function<void(int port_num, const char *buffer,
+                                             int len, void *cookie)>;

   explicit PacketInject(const std::string &addr);

diff --git a/include/bm/bm_sim/packet_handler.h b/include/bm/bm_sim/packet_handler.h
index 53ae69e..6d5825e 100644
--- a/include/bm/bm_sim/packet_handler.h
+++ b/include/bm/bm_sim/packet_handler.h
@@ -16,12 +16,14 @@
 #ifndef BM_BM_SIM_PACKET_HANDLER_H_
 #define BM_BM_SIM_PACKET_HANDLER_H_

+#include <functional>
+
 namespace bm {

 class PacketDispatcherIface {
  public:
-  typedef std::function<void(int port_num, const char *buffer,
-                             int len, void* cookie)> PacketHandler;
+  using PacketHandler = std::function<void(int port_num, const char *buffer,
+                                           int len, void* cookie)>;
   enum class ReturnCode {
     SUCCESS,
     UNSUPPORTED,
diff --git a/src/bm_sim/pcap_file.cpp b/src/bm_sim/pcap_file.cpp
index 6c682c5..4b646eb 100644
--- a/src/bm_sim/pcap_file.cpp
+++ b/src/bm_sim/pcap_file.cpp
@@ -150,9 +150,12 @@ PcapFileIn::current() const {
     }
   case State::Opened:
     pcap_fatal_error("Must call moveNext() before calling current()");
+    break;
   case State::AtEnd:
     pcap_fatal_error("Cannot read past end-of-file");
+    break;
   case State::Uninitialized:
+    /* fallthrough */
   default:
     pcap_fatal_error("Unexpected state");
   }
@@ -192,9 +195,9 @@ PcapFilesReader::scan() {
     }

     int earliest_index = -1;
-    const struct timeval *earliest_time;
+    const struct timeval *earliest_time = nullptr;

-    for (unsigned i=0; i < files.size(); i++) {
+    for (unsigned int i = 0; i < files.size(); i++) {
       auto file = files.at(i).get();
       if (file->atEOF()) continue;

@@ -211,7 +214,7 @@ PcapFilesReader::scan() {
       }
     }

-    assert(earliest_index >= 0);
+    assert(earliest_index >= 0 && earliest_time != nullptr);
     struct timeval delay;

     BMLOG_DEBUG("Pcap reader: first packet to send {}",
diff --git a/third_party/spdlog/bm/spdlog/spdlog.h b/third_party/spdlog/bm/spdlog/spdlog.h
index aef0406..5596ecd 100644
--- a/third_party/spdlog/bm/spdlog/spdlog.h
+++ b/third_party/spdlog/bm/spdlog/spdlog.h
@@ -32,6 +32,8 @@
 #include "common.h"
 #include "logger.h"

+#include <functional>
+
 namespace spdlog
 {
 // Return an existing logger or nullptr if a logger with such name doesn't exist.
YonatanPitz commented 5 years ago

Hi,

I've changed README with the --recursive flag. Can you send these other changes in a PR so it will be easier to review? by the way, I've lately managed to install this repo successfully on a clean ubuntu 16.04 machine

Regarding P4_16, as you understand this repo is not actively maintained at the moment, some of the work to do so was done, but currently we postponed working on this project.

Thanks, Yonatan