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

infiniband soft_RoCE implement #1603

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
64cbd61
add infinibandlayer rxe for pcapp
FlashBarryAllen Sep 10, 2024
9f6016f
add bth definiction
FlashBarryAllen Sep 10, 2024
bb61530
Merge branch 'dev' into master
FlashBarryAllen Oct 4, 2024
3a7dfaf
fix C-cast and add override to code
FlashBarryAllen Oct 4, 2024
05333c8
fix pre-commit errors
FlashBarryAllen Oct 4, 2024
008eab7
fix macro and coding style
FlashBarryAllen Oct 5, 2024
86d3a58
IB toString use more efficient style
FlashBarryAllen Oct 5, 2024
5cbc3f9
IB coding style fix
FlashBarryAllen Oct 5, 2024
b6f3c04
add documentation of IB
FlashBarryAllen Oct 13, 2024
b7a2a74
add IB creation test case
FlashBarryAllen Oct 13, 2024
5d2402e
Merge branch 'dev' into master
FlashBarryAllen Oct 13, 2024
9579f68
fix IB code format
FlashBarryAllen Oct 14, 2024
33308c1
Merge branch 'dev' into master
FlashBarryAllen Oct 14, 2024
342367e
doxygen fix
FlashBarryAllen Oct 15, 2024
d9aaee5
Merge branch 'master' of github.com:FlashBarryAllen/PcapPlusPlus
FlashBarryAllen Oct 15, 2024
254231f
Merge branch 'dev' into master
FlashBarryAllen Oct 19, 2024
09a9e92
IB code style fix
FlashBarryAllen Oct 19, 2024
451aa5c
Merge branch 'master' of github.com:FlashBarryAllen/PcapPlusPlus
FlashBarryAllen Oct 19, 2024
1f0935e
Merge branch 'dev' into master
FlashBarryAllen Oct 22, 2024
0623403
Merge branch 'dev' into master
FlashBarryAllen Oct 26, 2024
8a05842
IB add pcap
FlashBarryAllen Oct 26, 2024
4a02168
Merge branch 'dev' into master
FlashBarryAllen Nov 3, 2024
e2d8f04
fix IB argument type
FlashBarryAllen Nov 3, 2024
dd63809
Merge branch 'master' of github.com:FlashBarryAllen/PcapPlusPlus
FlashBarryAllen Nov 3, 2024
6db4619
Merge branch 'dev' into master
FlashBarryAllen Nov 9, 2024
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
2 changes: 1 addition & 1 deletion 3rdParty/OUIDataset/PCPP_OUIDataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -75756,7 +75756,7 @@
"vendor": "Lear"
},
"8933597": {
"vendor": "Infiniband Trade Association"
"vendor": "InfiniBand Trade Association"
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
},
"8933622": {
"vendor": "Shenzhen Jingxun Software Telecommunication Technology Co.,Ltd"
Expand Down
2 changes: 2 additions & 0 deletions Packet++/CMakeLists.txt
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_library(
src/IcmpLayer.cpp
src/IcmpV6Layer.cpp
src/IgmpLayer.cpp
src/InfiniBandLayer.cpp
src/IPReassembly.cpp
src/IPSecLayer.cpp
src/IPv4Layer.cpp
Expand Down Expand Up @@ -88,6 +89,7 @@ set(public_headers
header/IcmpLayer.h
header/IcmpV6Layer.h
header/IgmpLayer.h
header/InfiniBandLayer.h
header/IPLayer.h
header/IPReassembly.h
header/IPSecLayer.h
Expand Down
263 changes: 263 additions & 0 deletions Packet++/header/InfiniBandLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
#pragma once

#include "Layer.h"

/// @file

/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
namespace pcpp
{
/**
* @class InfiniBandLayer
* Represents an InfiniBand protocol layer
*/
class InfiniBandLayer : public Layer
{
private:
/**
* @struct bth
* Represents an Base Transport Header
*/
#pragma pack(push, 1)
struct rxe_bth
{
uint8_t opcode;
uint8_t flags;
uint16_t pkey;
uint32_t qpn;
uint32_t apsn;
};
#pragma pack(pop)

public:
/**
* A constructor that creates the layer from an existing packet raw data
* @param[in] data A pointer to the raw data (will be casted to bth_header)
* @param[in] dataLen Size of the data in bytes
* @param[in] prevLayer A pointer to the previous layer
* @param[in] packet A pointer to the Packet instance where layer will be stored in
*/
InfiniBandLayer(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet)
: Layer(data, dataLen, prevLayer, packet, InfiniBand)
{}

/**
* A constructor that creates a new rxe_bth header and allocates the data
* @param[in] opcode The operation code
* @param[in] se The solicited event
* @param[in] mig The migration state
* @param[in] pad The pad count
* @param[in] pkey The partition key
* @param[in] qpn The destination queue pair (QP) number
* @param[in] ack_req The acknowledgment request
* @param[in] psn The packet sequence number
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
*/
InfiniBandLayer(uint8_t opcode, int soliciteEvent, int migrationState, int padCount, uint16_t partitionKey,
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
uint32_t queuePairNumber, int ackReq, uint32_t packetSequenceNumber);

/**
* Get a pointer to the BTH header. Notice this points directly to the data, so every change will change
* the actual packet data
* @return A pointer to the bth_header
*/
rxe_bth* getBthHeader() const
{
return reinterpret_cast<rxe_bth*>(m_Data);
}
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return The operation code which defines the interpretation of the remaining header and payload bytes
*/
uint8_t getOpcode() const;

/**
* Set operation code
* @param[in] opcode The opcode to set
*/
void setOpcode(uint8_t opcode) const;

/**
* @return solicited event that the responder shall invoke the CQ event handler
*/
uint8_t getSoliciteEvent() const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* Set solicited event
* @param[in] se The solicited event to set
*/
void setSolicitedEvent(int se) const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return migreq which used to communicate migration state
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is migreq? 🤔

*/
uint8_t getMigrationState() const;

/**
* Set migreq
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: What is migreq?

* @param[in] mig The migration state to set. If set to one, indicates the connection or EE context has been
* migrated; if set to zero, it means there is no change in the current migration state.
*/
void setMigrationState(uint8_t mig) const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return PadCount which Packet payloads are sent as a multiple of 4-byte quantities.
* Pad count indicates the number of pad bytes - 0 to 3 - that are appended to the packetpayload.
* Pads are used to “stretch” the payload (payloads may be zero or more bytes in length) to be a multiple of 4
* bytes
*/
uint8_t getPadCount() const;

/**
* Set PadCount
* @param[in] pad The PadCount to set
*/
void setPadCount(uint8_t pad) const;

/**
* @return Transport Header Version that specifies the version of the IBA Transport used for this packet
*/
uint8_t getTransportHeaderVersion() const;

/**
* Set Transport Header Version
* @param[in] tvr The transport header version to set
*/
void setTransportHeaderVersion(uint8_t tver) const;

/**
* @return partition key identifying the partition
* that the destination QP (RC, UC, UD, XRC) or EE Context (RD) is a member.
*/
uint16_t getPartitionKey() const;

/**
* Set partition key
* @param[in] pkey The partition key to set
*/
void setPartitionKey(uint16_t pkey) const;

/**
* @return destination queue pair (QP) identifier
*/
uint32_t getQueuePairNumber() const;

/**
* Set Queue Pair Number
* @param[in] qpn The queue pair number to set
*/
void setQueuePairNumber(uint32_t qpn) const;

/**
* @return FECN
* F (FECN): false indicates that a FECN indication was not received.
* true indicates that the packet went through a point of congestion
*/
bool getFecn() const;

/**
* Set Fecn
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
* @param[in] fecn The FECN to set
*/
void setFecn(int fecn) const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return BECN
* B (BECN): false the packet did not go through a point of congestion or went
* through a point of congestion but was not marked. true indicates that the
* packet indicated by this header was subject to forward congestion. The B
* bit is set in an ACK or CN BTH
*/
bool getBecn() const;

/**
* Set BECN
* @param[in] becn The BECN to set
*/
void setbecn(int becn) const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return Reserved (variant) - 6 bits. Transmitted as 0, ignored on receive.
*/
uint8_t getResv6a() const;

/**
* Set Reserved 6 bits
*/
void setResv6a() const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return ackreq that requests responder to schedule an acknowledgment on the associated QP.
*/
int getAck() const;

/**
* Set acknowledgment for requests
* @param[in] ack The acknowledgment to set
*/
void setAck(int ack) const;

/**
* Transmitted as 0, ignored on receive.
*/
void setResv7() const;
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return packet sequence number that is used to identify the position of a packet
* within a sequence of packets.
*/
uint32_t getPacketSequenceNumber() const;

/**
* Set packet sequence number
* @param[in] psn The packet sequence number to set
*/
void setPacketSequenceNumber(uint32_t psn) const;

/**
* Currently identifies the following next layers sets to PayloadLayer
*/
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
void parseNextLayer() override;

/**
* @return Size of rxe_bth header
*/
size_t getHeaderLen() const override
{
return sizeof(rxe_bth);
}

/**
* Calculate @ref udphdr#headerChecksum field
*/
FlashBarryAllen marked this conversation as resolved.
Show resolved Hide resolved
void computeCalculateFields() override;

std::string toString() const override;

OsiModelLayer getOsiModelLayer() const override
{
return OsiModelTransportLayer;
}

/**
* A static method that check whether is inifiniband RoCE port
* @param[in] port The port from UDP destination port
* @return True if the port is inifiniband RoCE and can represent an rxe packet
*/
static inline bool isInfiniBandPort(uint16_t port)
{
return (port == 4791);
}

/**
* The static method makes validation of UDP data
* @param[in] udpData The pointer to the UDP payload data. It points to the first byte of rxe_bth header.
* @param[in] udpDataLen The payload data size
* @return True if the data is valid and can represent the rxe_bth packet
*/
static bool isDataValid(const uint8_t* udpData, size_t udpDataLen);
};

} // namespace pcpp
5 changes: 5 additions & 0 deletions Packet++/header/ProtocolType.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ namespace pcpp
*/
const ProtocolType WireGuard = 56;

/*
* InfiniBand protocol
*/
const ProtocolType InfiniBand = 57;

/**
* An enum representing OSI model layers
*/
Expand Down
Loading
Loading