Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of github.com:microsoft/dpdpu into main
Browse files Browse the repository at this point in the history
  • Loading branch information
qizzz committed Dec 10, 2023
2 parents 8ffbd15 + 4acb348 commit e3c61ff
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 36 deletions.
20 changes: 6 additions & 14 deletions DPDPU/Main/NetworkConfig.json
Original file line number Diff line number Diff line change
@@ -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": "",
},
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions DPDPU/NetworkEngine/Include/DDSBOWCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};

Expand Down
6 changes: 4 additions & 2 deletions DPDPU/NetworkEngine/Include/DDSTrafficDirecting.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ ReleaseFwdRules(
int ApplyDirectingRules(
struct DDSBOWAppSignature* Sig,
struct DDSBOWFwdRuleList* RuleList,
char* HostMac
char* HostMac,
char* DPUIP
);

//
Expand All @@ -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_ */
33 changes: 17 additions & 16 deletions DPDPU/NetworkEngine/Source/ActionModifyHeaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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];
Expand Down Expand Up @@ -69,7 +69,7 @@ int ApplyDirectingRules(
cmdDstPort,
cmdSrcPort,
DDSBOW_L2_ADDRESS,
DDSBOW_L3_ADDRESS,
DPUIP,
DDSBOW_INTERFACE
);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -142,7 +142,7 @@ int ApplyDirectingRules(
action mirred egress redirect dev %s 2>&1",
HOST_INTERFACE,
HostL3Address,
DDSBOW_L3_ADDRESS,
DPUIP,
DDSBOW_INTERFACE
);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -333,7 +334,7 @@ int RemoveDirectingRules(
cmdDstPort,
cmdSrcPort,
DDSBOW_L2_ADDRESS,
DDSBOW_L3_ADDRESS,
DPUIP,
DDSBOW_INTERFACE
);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -401,7 +402,7 @@ int RemoveDirectingRules(
action mirred egress redirect dev %s 2>&1",
HOST_INTERFACE,
HostL3Address,
DDSBOW_L3_ADDRESS,
DPUIP,
DDSBOW_INTERFACE
);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
40 changes: 40 additions & 0 deletions DPDPU/NetworkEngine/Source/DDSBOWCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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, "<str>");
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) {
Expand Down
8 changes: 4 additions & 4 deletions DPDPU/NetworkEngine/Source/DDSBOWPipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
}

Expand Down

0 comments on commit e3c61ff

Please sign in to comment.