From 47c61cc542a7864b185f819a2548142c908ba196 Mon Sep 17 00:00:00 2001 From: Sandeep Nagapattinam Date: Thu, 12 Oct 2023 00:51:33 +0530 Subject: [PATCH] Program nexthop table as a ternary match. (#59) The P4 program has been modified to move the NextHop table from the SEM block (exact match) to the WCM block (ternary match). This requires a corresponding change in the Kernel Monitor. This is a breaking change. Newer versions of krnlmon are incompatible with older versions of the P4 program. Signed-off-by: Sandeep N Co-authored-by: Derek G Foster --- README.md | 6 ++++++ switchapi/es2k/switch_pd_routing.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 9a62bfb..170b735 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # ipdk-io/krnlmon The Kernel Monitor receives RFC 3549 messages from the Linux Kernel over a Netlink socket when changes are made to the kernel networking data structures. + +## Breaking changes + +### 11 Oct 2023 + +- https://github.com/ipdk-io/krnlmon/pull/59: The NextHop table in the P4 program has been moved from the SEM block (exact match) to the WCM block (ternary block). The Kernel Monitor must use a different API to write the entry to the WCM block. krnlmon is no longer compatible with older versions of the P4 program. diff --git a/switchapi/es2k/switch_pd_routing.c b/switchapi/es2k/switch_pd_routing.c index a9b637c..15539b5 100644 --- a/switchapi/es2k/switch_pd_routing.c +++ b/switchapi/es2k/switch_pd_routing.c @@ -25,6 +25,9 @@ #include "port_mgr/dpdk/bf_dpdk_port_if.h" +// Table match type definitions. +#define NEXTHOP_TABLE_TERNARY_MATCH 1 + switch_status_t switch_routing_table_entry ( switch_device_t device, const switch_pd_routing_info_t *api_routing_info, @@ -180,10 +183,20 @@ switch_status_t switch_pd_nexthop_table_entry( goto dealloc_resources; } +#if NEXTHOP_TABLE_TERNARY_MATCH + // When Nexthop table is of type ternary Match + status = tdi_key_field_set_value_and_mask(key_hdl, field_id, + (api_nexthop_pd_info->nexthop_handle & + ~(SWITCH_HANDLE_TYPE_NHOP << + SWITCH_HANDLE_TYPE_SHIFT)), 0xFFFF); +#else + // When Nexthop table is of type exact Match status = tdi_key_field_set_value(key_hdl, field_id, (api_nexthop_pd_info->nexthop_handle & ~(SWITCH_HANDLE_TYPE_NHOP << SWITCH_HANDLE_TYPE_SHIFT))); +#endif + if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to set value for key ID: %d for nexthop_table," " error: %d", field_id, status);