Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview for Changes in P4C PR #4850 #23

Open
wants to merge 4 commits into
base: Deploy-branch-Awsome-CSS
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,10 @@ jobs:
- name: Check PR Label
id: check-label
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const hasDocumentationLabel = labels.some(label => label.name === 'documentation');
const hasDocumentationLabel = contains(github.event.pull_request.labels.*.name, 'documentation')
return hasDocumentationLabel;

- name: Find Existing Comment
Expand Down
4 changes: 4 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ cc_library(
"@com_google_absl//absl/container:node_hash_set",
"@com_google_absl//absl/numeric:bits",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:cord",
"@com_google_absl//absl/strings:str_format",
"@com_google_googletest//:gtest",
],
Expand Down Expand Up @@ -246,10 +247,13 @@ cc_library(
"@com_github_p4lang_p4runtime//:p4info_cc_proto",
"@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
"@com_github_p4lang_p4runtime//:p4types_cc_proto",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_protobuf//:protobuf",
],
)
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ find_python_module (re REQUIRED)
# other packages
find_package (Doxygen)
find_package (BMV2)
# If we have found simple switch or psa switch, we also need scapy.
if(SIMPLE_SWITCH OR PSA_SWITCH)
# If we have found simple switch or psa switch or pna_nic, we also need scapy.
if(SIMPLE_SWITCH OR PSA_SWITCH OR PNA_NIC)
find_python_module (scapy REQUIRED)
endif()
# enable CTest
Expand Down Expand Up @@ -547,6 +547,7 @@ add_custom_target(update_includes ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/*.p4 ${P4C_BINARY_DIR}/p4include
COMMAND ${CMAKE_COMMAND} -E make_directory ${P4C_BINARY_DIR}/p4include/bmv2
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/bmv2/psa.p4 ${P4C_BINARY_DIR}/p4include/bmv2
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/bmv2/pna.p4 ${P4C_BINARY_DIR}/p4include/bmv2
COMMAND ${CMAKE_COMMAND} -E make_directory ${P4C_BINARY_DIR}/p4include/dpdk
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/dpdk/psa.p4 ${P4C_BINARY_DIR}/p4include/dpdk
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/dpdk/pna.p4 ${P4C_BINARY_DIR}/p4include/dpdk
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ If you encounter any issues or have suggestions for improvement, please [open an
We welcome feature requests! Please open an issue and provide as much detail as possible about the requested feature and its use case.

Happy coding!

\include{doc} "../docs/CodingStandardPhilosophy.md"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![Bazel Build](https://github.com/p4lang/p4c/actions/workflows/ci-bazel.yml/badge.svg)](https://github.com/p4lang/p4c/actions/workflows/ci-bazel.yml)
[![Validation](https://github.com/p4lang/p4c/actions/workflows/ci-validation-nightly.yml/badge.svg)](https://github.com/p4lang/p4c/actions/workflows/ci-validation-nightly.yml)
[![Docker Container](https://github.com/p4lang/p4c/actions/workflows/ci-container-image.yml/badge.svg)](https://github.com/p4lang/p4c/actions/workflows/ci-container-image.yml)


* [Getting started](#getting-started)
* [Installing packaged versions of P4C](#installing-packaged-versions-of-p4c)
Expand Down Expand Up @@ -42,6 +41,8 @@ P4C is modular; it provides a standard frontend and midend which can be combined
with a target-specific backend to create a complete P4 compiler. The goal is to
make adding new backends easy.

\include{doc} "../docs/doxygen/01_overview.md"

The code contains seven sample backends:
* p4c-bm2-ss: can be used to target the P4 `simple_switch` written using
the [BMv2 behavioral model](https://github.com/p4lang/behavioral-model),
Expand Down
2 changes: 1 addition & 1 deletion Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.4.13
1.2.4.14
35 changes: 33 additions & 2 deletions backends/bmv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/simple_switch/version.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/simple_switch/version.h" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/psa_switch/version.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/psa_switch/version.h" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pna_nic/version.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/pna_nic/version.h" @ONLY)

# sources for backend executable
set (BMV2_SIMPLE_SWITCH_SRCS
Expand All @@ -29,6 +31,15 @@ set (BMV2_SIMPLE_SWITCH_SRCS
simple_switch/simpleSwitch.h
simple_switch/options.h
)

set (PORTABLE_COMMON
portable_common/portable.cpp
portable_common/portable.h
portable_common/options.cpp
portable_common/options.h
portable_common/midend.cpp
portable_common/midend.h
)

set (BMV2_PSA_SWITCH_SRCS
psa_switch/main.cpp
Expand All @@ -40,6 +51,18 @@ set (BMV2_PSA_SWITCH_SRCS
psa_switch/options.h
)

set (BMV2_PNA_NIC_SRCS
pna_nic/main.cpp
pna_nic/midend.cpp
pna_nic/midend.h
pna_nic/pnaNic.cpp
pna_nic/pnaNic.h
pna_nic/pnaProgramStructure.cpp
pna_nic/pnaProgramStructure.h
pna_nic/options.cpp
pna_nic/options.h
)

set (BMV2_BACKEND_COMMON_SRCS
common/JsonObjects.cpp
common/action.cpp
Expand Down Expand Up @@ -85,10 +108,17 @@ target_link_libraries (p4c-bm2-ss bmv2backend ${P4C_LIBRARIES} ${P4C_LIB_DEPS})

install(TARGETS p4c-bm2-ss RUNTIME DESTINATION ${P4C_RUNTIME_OUTPUT_DIRECTORY})

add_library(portable-common STATIC ${PORTABLE_COMMON})
target_link_libraries(portable-common bmv2backend)

add_executable(p4c-bm2-psa ${BMV2_PSA_SWITCH_SRCS})
target_link_libraries (p4c-bm2-psa bmv2backend ${P4C_LIBRARIES} ${P4C_LIB_DEPS})
target_link_libraries (p4c-bm2-psa portable-common ${P4C_LIBRARIES} ${P4C_LIB_DEPS})
install(TARGETS p4c-bm2-psa RUNTIME DESTINATION ${P4C_RUNTIME_OUTPUT_DIRECTORY})

add_executable(p4c-bm2-pna ${BMV2_PNA_NIC_SRCS})
target_link_libraries (p4c-bm2-pna portable-common ${P4C_LIBRARIES} ${P4C_LIB_DEPS})
install(TARGETS p4c-bm2-pna RUNTIME DESTINATION ${P4C_RUNTIME_OUTPUT_DIRECTORY})

file(RELATIVE_PATH
CURRENT_BINARY_DIR_PATH_REL
${P4C_BINARY_DIR}
Expand All @@ -107,6 +137,7 @@ file(RELATIVE_PATH
add_custom_target(linkbmv2
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CURRENT_BINARY_DIR_PATH_REL}/p4c-bm2-ss ${P4C_BINARY_DIR}/p4c-bm2-ss
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CURRENT_BINARY_DIR_PATH_REL}/p4c-bm2-psa ${P4C_BINARY_DIR}/p4c-bm2-psa
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CURRENT_BINARY_DIR_PATH_REL}/p4c-bm2-pna ${P4C_BINARY_DIR}/p4c-bm2-pna
COMMAND ${CMAKE_COMMAND} -E create_symlink ${P4C_BINARY_DIR_PATH_REL}/p4include ${CMAKE_CURRENT_BINARY_DIR}/p4include
COMMAND ${CMAKE_COMMAND} -E create_symlink ${P4C_BINARY_DIR_PATH_REL}/p4_14include ${CMAKE_CURRENT_BINARY_DIR}/p4_14include
DEPENDS update_includes
Expand Down Expand Up @@ -222,4 +253,4 @@ set (GTEST_BMV2_SOURCES
gtest/load_ir_from_json.cpp
)
set (GTEST_SOURCES ${GTEST_SOURCES} ${GTEST_BMV2_SOURCES} PARENT_SCOPE)
set (GTEST_LDADD ${GTEST_LDADD} bmv2backend PARENT_SCOPE)
set (GTEST_LDADD ${GTEST_LDADD} bmv2backend PARENT_SCOPE)
27 changes: 25 additions & 2 deletions backends/bmv2/common/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ enum class BlockConverted {

namespace Standard {

/// We re-use as much code as possible between PSA and v1model. The two
/// We re-use as much code as possible between PSA, PNA and v1model. The two
/// architectures have some differences though, in particular regarding naming
/// (of table properties, extern types, parameter names). We define some
/// "traits" for each extern type, templatized by the architecture name (using
/// the Arch enum class defined below), as a convenient way to access
/// architecture-specific names in the unified code.
/// The V1MODEL2020 is the modified v1model.p4 file with a version
/// >= 20200408
enum class Arch { V1MODEL, PSA, V1MODEL2020 };
enum class Arch { V1MODEL, PSA, PNA, V1MODEL2020 };

/// Traits for the action profile extern, must be specialized for v1model and
/// PSA.
Expand Down Expand Up @@ -107,6 +107,9 @@ struct ActionProfileTraits<Arch::PSA> {
static const cstring sizeParamName() { return "size"_cs; }
};

template <>
struct ActionProfileTraits<Arch::PNA> : public ActionProfileTraits<Arch::PSA> {};

/// Traits for the action selector extern, must be specialized for v1model and
/// PSA. Inherits from ActionProfileTraits because of their similarities.
template <Arch arch>
Expand All @@ -127,6 +130,9 @@ struct ActionSelectorTraits<Arch::PSA> : public ActionProfileTraits<Arch::PSA> {
static const cstring typeName() { return "ActionSelector"_cs; }
};

template <>
struct ActionSelectorTraits<Arch::PNA> : public ActionSelectorTraits<Arch::PSA> {};

/// Traits for the register extern, must be specialized for v1model and PSA.
template <Arch arch>
struct RegisterTraits;
Expand Down Expand Up @@ -158,6 +164,9 @@ struct RegisterTraits<Arch::PSA> {
static std::optional<size_t> indexTypeParamIdx() { return 1; }
};

template <>
struct RegisterTraits<Arch::PNA> : public RegisterTraits<Arch::PSA> {};

template <Arch arch>
struct CounterExtern {};
template <Arch arch>
Expand Down Expand Up @@ -222,6 +231,13 @@ struct CounterlikeTraits<Standard::CounterExtern<Standard::Arch::PSA>> {
static std::optional<size_t> indexTypeParamIdx() { return 1; }
};

/// @ref CounterlikeTraits<> specialization for @ref CounterExtern for PNA
template <>
struct CounterlikeTraits<Standard::CounterExtern<Standard::Arch::PNA>>
: public CounterlikeTraits<Standard::CounterExtern<Standard::Arch::PSA>> {
static const cstring directPropertyName() { return "pna_direct_counter"_cs; }
};

/// @ref CounterlikeTraits<> specialization for @ref MeterExtern for v1model
template <>
struct CounterlikeTraits<Standard::MeterExtern<Standard::Arch::V1MODEL>> {
Expand Down Expand Up @@ -260,6 +276,13 @@ struct CounterlikeTraits<Standard::MeterExtern<Standard::Arch::PSA>> {
static std::optional<size_t> indexTypeParamIdx() { return 0; }
};

/// @ref CounterlikeTraits<> specialization for @ref MeterExtern for PNA
template <>
struct CounterlikeTraits<Standard::MeterExtern<Standard::Arch::PNA>>
: public CounterlikeTraits<Standard::MeterExtern<Standard::Arch::PSA>> {
static const cstring directPropertyName() { return "pna_direct_meter"_cs; }
};

} // namespace Helpers

using BlockTypeMap = std::map<const IR::Block *, const IR::Type *>;
Expand Down
93 changes: 0 additions & 93 deletions backends/bmv2/common/metermap.cpp

This file was deleted.

48 changes: 0 additions & 48 deletions backends/bmv2/common/metermap.h

This file was deleted.

Loading
Loading