add a new constructor for ibvQpVonn and fixed a bug related to qpn generation

This commit is contained in:
zhe 2023-08-06 17:08:38 +02:00
parent 6b3cc41cfc
commit c9b58f0342
3 changed files with 26 additions and 1 deletions

View File

@ -37,6 +37,7 @@ class ibvQpConn {
public:
ibvQpConn(int32_t vfid, string ip_addr, uint32_t n_pages);
ibvQpConn(cProcess* cproc, string ip_addr, uint32_t n_pages);
~ibvQpConn();
// Connection

View File

@ -6,6 +6,8 @@
#include <string>
#include <cstring>
#include <atomic>
#include <iostream>
namespace fpga {
@ -47,6 +49,15 @@ public:
ibvQp() : id(curr_id++) {}
inline uint32_t getId() { return id; }
void print() {
std::cout << "Queue Pair: "
<< "id: " << id << std::endl;
std::cout << "Local Queue: ";
local.print("local"); // Call the print function of ibvQ to print local queue variables
std::cout << "Remote Queue: ";
remote.print("remote"); // Call the print function of ibvQ to print remote queue variables
}
};
/**

View File

@ -40,6 +40,19 @@ ibvQpConn::ibvQpConn(int32_t vfid, string ip_addr, uint32_t n_pages) {
initLocalQueue(ip_addr);
}
/**
* Ctor with user provided cProc
* @param: fdev - attached vFPGA
* @param: n_pages - number of buffer pages
*/
ibvQpConn::ibvQpConn(cProcess* cproc, string ip_addr, uint32_t n_pages): fdev(cproc), n_pages(n_pages) {
// Conn
is_connected = false;
// Initialize local queues
initLocalQueue(ip_addr);
}
/**
* Dtor
*/
@ -94,7 +107,7 @@ void ibvQpConn::initLocalQueue(string ip_addr) {
qpair->local.uintToGid(24, ibv_ip_addr);
// qpn and psn
qpair->local.qpn = ((fdev->getVfid() & nRegMask) << pidBits) || (fdev->getCpid() & pidMask);
qpair->local.qpn = ((fdev->getVfid() & nRegMask) << pidBits) | (fdev->getCpid() & pidMask);
if(qpair->local.qpn == -1)
throw std::runtime_error("Coyote PID incorrect, vfid: " + fdev->getVfid());
qpair->local.psn = distr(rand_gen) & 0xFFFFFF;