From 528da4b20d03ef0e3d4c08dcd4012ba77f50af69 Mon Sep 17 00:00:00 2001 From: Qizhen Zhang Date: Sun, 10 Dec 2023 02:51:29 -0800 Subject: [PATCH] Configure BOW --- DPDPU/Main/NetworkConfig.json | 20 +++------- DPDPU/NetworkEngine/Include/DDSBOWCore.h | 1 + .../Include/DDSTrafficDirecting.h | 6 ++- .../Source/ActionModifyHeaders.c | 33 +++++++-------- DPDPU/NetworkEngine/Source/DDSBOWCore.c | 40 +++++++++++++++++++ DPDPU/NetworkEngine/Source/DDSBOWPipeline.c | 8 ++-- 6 files changed, 72 insertions(+), 36 deletions(-) diff --git a/DPDPU/Main/NetworkConfig.json b/DPDPU/Main/NetworkConfig.json index 808d791..85fd48f 100644 --- a/DPDPU/Main/NetworkConfig.json +++ b/DPDPU/Main/NetworkConfig.json @@ -1,15 +1,5 @@ { "doca_dpdk_flags":{ - // -a - Add a device to the allow list. - "devices":[ - { - "device": "sf", - "id": "4", - "sft": false - }, - ], - // -c - Hexadecimal bitmask of cores to run on - "core-mask": "0xFF", // Additional DPDK (EAL) flags (if needed) "flags": "", }, @@ -25,15 +15,17 @@ // -o - Set offload predicate file path "udf-path": "../OffloadEngine/UDFSamples/", // -h - Set host MAC address - "host-mac": "b8:3f:d2:04:e2:5c", + "host-mac": "b8:3f:d2:b9:21:fc", + // -i - Set the host IPv4 + "host-ipv4": "10.10.1.2", + // -u - Set the DPU IPv4 + "dpu-ipv4": "10.10.1.12", // -f - Set forwarding rules - "fwd-rules": "192.168.200.133/32 b8:3f:d2:04:e2:54", + "fwd-rules": "10.10.1.1/32 b8:ce:f6:cc:96:e4", // -c - Set the number of cores "num-cores": 4, // -l - Set the core list "core-list": "0,1,2,3", - // -i - Set the host IPv4 - "host-ipv4": "192.168.200.132", // -p - Set the host port "host-port": 3232, // -d - Set if use DPDK diff --git a/DPDPU/NetworkEngine/Include/DDSBOWCore.h b/DPDPU/NetworkEngine/Include/DDSBOWCore.h index 64bc4b4..8f27531 100644 --- a/DPDPU/NetworkEngine/Include/DDSBOWCore.h +++ b/DPDPU/NetworkEngine/Include/DDSBOWCore.h @@ -15,6 +15,7 @@ struct DDSBOWConfig { char HostIPv4[16]; /* Host IPv4 address */ uint16_t HostPort; /* Host port */ char HostMac[18]; /* Host MAC address */ + char DPUIPv4[16]; /* DPU IPv4 address */ char UdfPath[64]; /* Path to the offload predicate and function code */ }; diff --git a/DPDPU/NetworkEngine/Include/DDSTrafficDirecting.h b/DPDPU/NetworkEngine/Include/DDSTrafficDirecting.h index 23655fe..4c90857 100644 --- a/DPDPU/NetworkEngine/Include/DDSTrafficDirecting.h +++ b/DPDPU/NetworkEngine/Include/DDSTrafficDirecting.h @@ -92,7 +92,8 @@ ReleaseFwdRules( int ApplyDirectingRules( struct DDSBOWAppSignature* Sig, struct DDSBOWFwdRuleList* RuleList, - char* HostMac + char* HostMac, + char* DPUIP ); // @@ -102,7 +103,8 @@ int ApplyDirectingRules( int RemoveDirectingRules( struct DDSBOWAppSignature* Sig, struct DDSBOWFwdRuleList* RuleList, - char* HostMac + char* HostMac, + char* DPUIP ); #endif /* DDS_BOW_APP_SIGNATURE_H_ */ diff --git a/DPDPU/NetworkEngine/Source/ActionModifyHeaders.c b/DPDPU/NetworkEngine/Source/ActionModifyHeaders.c index c95ab3a..3ef74c7 100644 --- a/DPDPU/NetworkEngine/Source/ActionModifyHeaders.c +++ b/DPDPU/NetworkEngine/Source/ActionModifyHeaders.c @@ -7,11 +7,10 @@ #include "DDSTrafficDirecting.h" const char* DPU_INTERFACE = "p0"; -const char* DDSBOW_INTERFACE = "en3f0pf0sf3"; +const char* DDSBOW_INTERFACE = "en3f0pf0sf1"; const char* HOST_INTERFACE = "pf0hpf"; -const char* DDSBOW_L2_ADDRESS = "00:00:00:00:03:00"; -const char* DDSBOW_L3_ADDRESS = "192.168.200.32"; +const char* DDSBOW_L2_ADDRESS = "00:00:00:00:01:00"; char HostL2Address[18]; char HostL3Address[16]; @@ -24,7 +23,8 @@ char HostL4Port[6]; int ApplyDirectingRules( struct DDSBOWAppSignature *Sig, struct DDSBOWFwdRuleList* RuleList, - char* HostMac + char* HostMac, + char* DPUIP ) { char cmdProtocol[32]; char cmdDstPort[32]; @@ -69,7 +69,7 @@ int ApplyDirectingRules( cmdDstPort, cmdSrcPort, DDSBOW_L2_ADDRESS, - DDSBOW_L3_ADDRESS, + DPUIP, DDSBOW_INTERFACE ); @@ -108,7 +108,7 @@ int ApplyDirectingRules( munge eth dst set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, HostL3Address, DDSBOW_L2_ADDRESS, HostL2Address, @@ -142,7 +142,7 @@ int ApplyDirectingRules( action mirred egress redirect dev %s 2>&1", HOST_INTERFACE, HostL3Address, - DDSBOW_L3_ADDRESS, + DPUIP, DDSBOW_INTERFACE ); @@ -177,7 +177,7 @@ int ApplyDirectingRules( munge ip src set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, cmdProtocol, HostL2Address, HostL3Address, @@ -213,7 +213,7 @@ int ApplyDirectingRules( munge ip src set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, RuleList->Rules[r].RemoteIPv4, cmdProtocol, HostL2Address, @@ -257,7 +257,7 @@ int ApplyDirectingRules( munge ip src set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, RuleList->Rules[r].RemoteIPv4, cmdProtocol, HostL2Address, @@ -292,7 +292,8 @@ int ApplyDirectingRules( int RemoveDirectingRules( struct DDSBOWAppSignature *Sig, struct DDSBOWFwdRuleList* RuleList, - char* HostMac + char* HostMac, + char* DPUIP ) { char cmdProtocol[32]; char cmdDstPort[32]; @@ -333,7 +334,7 @@ int RemoveDirectingRules( cmdDstPort, cmdSrcPort, DDSBOW_L2_ADDRESS, - DDSBOW_L3_ADDRESS, + DPUIP, DDSBOW_INTERFACE ); @@ -370,7 +371,7 @@ int RemoveDirectingRules( munge eth dst set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, HostL3Address, DDSBOW_L2_ADDRESS, HostL2Address, @@ -401,7 +402,7 @@ int RemoveDirectingRules( action mirred egress redirect dev %s 2>&1", HOST_INTERFACE, HostL3Address, - DDSBOW_L3_ADDRESS, + DPUIP, DDSBOW_INTERFACE ); @@ -433,7 +434,7 @@ int RemoveDirectingRules( munge ip src set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, cmdProtocol, HostL2Address, HostL3Address, @@ -464,7 +465,7 @@ int RemoveDirectingRules( munge ip src set %s \ action mirred egress redirect dev %s 2>&1", DDSBOW_INTERFACE, - DDSBOW_L3_ADDRESS, + DPUIP, RuleList->Rules[r].RemoteIPv4, cmdProtocol, HostL2Address, diff --git a/DPDPU/NetworkEngine/Source/DDSBOWCore.c b/DPDPU/NetworkEngine/Source/DDSBOWCore.c index 57c37eb..f73f3cc 100644 --- a/DPDPU/NetworkEngine/Source/DDSBOWCore.c +++ b/DPDPU/NetworkEngine/Source/DDSBOWCore.c @@ -216,6 +216,27 @@ HostIPv4Callback( return DOCA_SUCCESS; } +/* + * Callback function for setting DPU IPv4 address + * + * @Param [in]: DPU IPv4 string to set + * @Config [out]: application configuration for setting the DPU IPv4 string + * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise + */ +static doca_error_t +DPUIPv4Callback( + void *Param, + void *Config +) { + struct DDSBOWConfig *appConfig = (struct DDSBOWConfig *)Config; + + strcpy(appConfig->DPUIPv4, (char *)Param); + RTE_LOG(NOTICE, USER1, + "DPU IPv4 = %s\n", + appConfig->DPUIPv4); + return DOCA_SUCCESS; +} + /* * Callback function for setting host Mac address * @@ -248,6 +269,7 @@ RegisterDDSBOWParams() { struct doca_argp_param *appSignatureParam, *udfPathParam, *fwdRulesParam; struct doca_argp_param *useDPDKParam, *numCoresParam, *coreListParam; struct doca_argp_param *hostIPv4Param, *hostPortParam, *hostMacParam; + struct doca_argp_param *dpuIPv4Param; /* Create and register HW offload param */ result = doca_argp_param_create(&appSignatureParam); @@ -372,6 +394,24 @@ RegisterDDSBOWParams() { return result; } + /* Create and register DPU IPv4 param */ + result = doca_argp_param_create(&dpuIPv4Param); + if (result != DOCA_SUCCESS) { + DOCA_LOG_ERR("Failed to create ARGP param: %s", doca_get_error_string(result)); + return result; + } + doca_argp_param_set_short_name(dpuIPv4Param, "u"); + doca_argp_param_set_long_name(dpuIPv4Param, "dpu-ipv4"); + doca_argp_param_set_arguments(dpuIPv4Param, ""); + doca_argp_param_set_description(dpuIPv4Param, "Set DPU IPv4 address"); + doca_argp_param_set_callback(dpuIPv4Param, DPUIPv4Callback); + doca_argp_param_set_type(dpuIPv4Param, DOCA_ARGP_TYPE_STRING); + result = doca_argp_register_param(dpuIPv4Param); + if (result != DOCA_SUCCESS) { + DOCA_LOG_ERR("Failed to register program param: %s", doca_get_error_string(result)); + return result; + } + /* Create and register host MAC param */ result = doca_argp_param_create(&hostMacParam); if (result != DOCA_SUCCESS) { diff --git a/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c b/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c index 2101161..dc74fb1 100644 --- a/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c +++ b/DPDPU/NetworkEngine/Source/DDSBOWPipeline.c @@ -96,7 +96,7 @@ RunBOW( // Apply application signature to direct traffic to DDS BOW // // - resultInt = ApplyDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac); + resultInt = ApplyDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac, AppCfg.DPUIPv4); if (resultInt) { DOCA_LOG_ERR("Failed to apply traffic directing rules"); exitStatus = EXIT_FAILURE; @@ -133,7 +133,7 @@ RunBOW( // Apply traffic directing rules in NIC HW // // - resultInt = ApplyDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac); + resultInt = ApplyDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac, AppCfg.DPUIPv4); if (resultInt) { DOCA_LOG_ERR("Failed to apply traffic directing rules"); exitStatus = EXIT_FAILURE; @@ -175,7 +175,7 @@ RunBOW( // Delete traffic directing rules // // - RemoveDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac); + RemoveDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac, AppCfg.DPUIPv4); ReleaseFwdRules(&AppCfg.FwdRules); // /* DPDK cleanup resources */ @@ -194,7 +194,7 @@ RunBOW( // Delete traffic directing rules // // - RemoveDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac); + RemoveDirectingRules(&AppCfg.AppSig, &AppCfg.FwdRules, AppCfg.HostMac, AppCfg.DPUIPv4); ReleaseFwdRules(&AppCfg.FwdRules); }