Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
Signed-off-by: Komal, Jain <[email protected]>
  • Loading branch information
komaljai committed Oct 24, 2024
1 parent e7cf274 commit 1aa85c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion backends/tc/ebpfCodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ class EBPFControlPNA : public EBPF::EBPFControlPSA {
}
EBPFHashPNA *getHash(cstring name) const {
auto result = ::P4::get(pna_hashes, name);
BUG_CHECK(result != nullptr, "No hash named %1%", name);
return result;
}
void emitExternDefinition(EBPF::CodeBuilder *builder) {
Expand Down
6 changes: 5 additions & 1 deletion backends/tc/tcExterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,11 @@ void EBPFHashPNA::calculateHash(EBPF::CodeBuilder *builder, const IR::MethodCall
}

void CRCChecksumAlgorithmPNA::emitGet(EBPF::CodeBuilder *builder) {
builder->appendFormat("%s", registerVar.c_str());
if (crcWidth == 16) {
builder->appendFormat("%s", registerVar.c_str());
} else {
builder->appendFormat("%s ^ 0xFFFFFFFF", registerVar.c_str());
}
}

void CRCChecksumAlgorithmPNA::emitAddData(EBPF::CodeBuilder *builder, int dataPos,
Expand Down
4 changes: 3 additions & 1 deletion backends/tc/tcExterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ class CRCChecksumAlgorithmPNA : public EBPF::CRCChecksumAlgorithm {
public:
CRCChecksumAlgorithmPNA(const EBPF::EBPFProgram *program, cstring name, int width)
: EBPF::CRCChecksumAlgorithm(program, name, width) {
BUG_CHECK(width == 16 || width == 32, "Must be 16 bits width or 32 bits width.");
initialValue = "0"_cs;
}
void emitGet(EBPF::CodeBuilder *builder) override;
void emitAddData(EBPF::CodeBuilder *builder, const ArgumentsList &arguments,
const IR::MethodCallExpression *expr);
void emitAddData(EBPF::CodeBuilder *builder, int dataPos, const IR::MethodCallExpression *expr);
void emitAddData(EBPF::CodeBuilder *builder, int dataPos,
const IR::MethodCallExpression *expr) override;
};

class EBPFDigestPNA : public EBPF::EBPFDigestPSA {
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4tc_samples_outputs/hash_control_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static __always_inline int process(struct __sk_buff *skb, struct my_ingress_head
bpf_p4tc_ext_hash_crc32(&hdr->crc.f3, sizeof(hdr->crc.f3), ingress_h_reg);
bpf_p4tc_ext_hash_crc32(&hdr->crc.f4, sizeof(hdr->crc.f4), ingress_h_reg);
hdr->crc.crc = /* h_0.get_hash({hdr->crc.f1, hdr->crc.f2, hdr->crc.f3, hdr->crc.f4}) */
ingress_h_reg;
ingress_h_reg ^ 0xFFFFFFFF;
}
}
{
Expand Down

0 comments on commit 1aa85c6

Please sign in to comment.