Skip to content

Commit

Permalink
Merge pull request #32 from xXxSiMoNxXx/master
Browse files Browse the repository at this point in the history
Adding bug fixes and missing documentation
  • Loading branch information
SimonRaviv authored May 6, 2018
2 parents 79a890d + a066e91 commit 27ab0f2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
18 changes: 11 additions & 7 deletions src/perftest_parameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection
printf(" Note (2): When using PP rate_units is forced to Kbps.\n");

printf(" --rate_limit_type=<type>");
printf(" [HW/SW/PP] Limit the QP's by HW, PP or by SW. Disabled by default. When rate_limit Not is specified HW limit is Default.\n");
printf(" [HW/SW/PP] Limit the QP's by HW, PP or by SW. Disabled by default. When rate_limit is not specified HW limit is Default.\n");
printf(" Note: in Latency under load test SW rate limit is forced\n");

}
Expand Down Expand Up @@ -599,6 +599,10 @@ void usage_raw_ethernet(TestType tst)
printf(" send IPv6 Packets.\n");
#endif

if (tst == BW) {
printf(" --raw_mcast ");
printf(" send raw ethernet multicast traffic. No need to specify dest MAC address\n");
}

printf("\n");

Expand Down Expand Up @@ -661,7 +665,7 @@ static void init_perftest_params(struct perftest_parameters *user_param)
user_param->burst_size = 0;
user_param->typical_pkt_size = 0;
user_param->rate_limit = 0;
user_param->valid_hw_rate_limit = 0;
user_param->valid_hw_rate_limit_index = 0;
user_param->rate_units = GIGA_BIT_PS;
user_param->rate_limit_type = DISABLE_RATE_LIMIT;
user_param->is_rate_limit_type = 0;
Expand Down Expand Up @@ -1231,22 +1235,22 @@ static void force_dependecies(struct perftest_parameters *user_param)
break;
case PACKET_PS:
printf(RESULT_LINE);
fprintf(stderr, " Failed: pps rate limit units is not supported when setting HW rate limit\n");
fprintf(stderr, " Failed: pps rate limit units is not supported when setting HW rate limit\n");
exit(1);
default:
printf(RESULT_LINE);
fprintf(stderr, " Failed: Unknown rate limit units\n");
exit(1);
}
if (rate_limit_gbps > 0) {
int rate_to_set = -1;
get_gbps_str_by_ibv_rate(user_param->rate_limit_str, &rate_to_set);
if (rate_to_set == -1) {
int rate_index_to_set = -1;
get_gbps_str_by_ibv_rate(user_param->rate_limit_str, &rate_index_to_set);
if (rate_index_to_set == -1) {
printf(RESULT_LINE);
fprintf(stderr, " Failed: Unknown rate limit value\n");
exit(1);
}
user_param->valid_hw_rate_limit = rate_to_set;
user_param->valid_hw_rate_limit_index = rate_index_to_set;
}
} else if (user_param->rate_limit_type == PP_RATE_LIMIT) {
if (user_param->rate_limit < 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/perftest_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ struct perftest_parameters {
/* Rate Limiter */
char *rate_limit_str;
double rate_limit;
int valid_hw_rate_limit;
int valid_hw_rate_limit_index;
int burst_size;
int typical_pkt_size;
enum rate_limiter_units rate_units;
Expand Down
72 changes: 39 additions & 33 deletions src/perftest_resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ int create_single_mr(struct pingpong_context *ctx, struct perftest_parameters *u
posix_memalign(&ctx->buf[qp_index], user_param->cycle_buffer, ctx->buff_size);
#else
if (user_param->use_hugepages) {
if (alloc_hugepage_region(ctx) != SUCCESS){
if (alloc_hugepage_region(ctx, qp_index) != SUCCESS){
fprintf(stderr, "Failed to allocate hugepage region.\n");
return FAILURE;
}
Expand Down Expand Up @@ -1326,34 +1326,34 @@ int create_mr(struct pingpong_context *ctx, struct perftest_parameters *user_par
#define SHMAT_FLAGS (0)

#if !defined(__FreeBSD__)
int alloc_hugepage_region (struct pingpong_context *ctx)
int alloc_hugepage_region (struct pingpong_context *ctx, int qp_index)
{
int buf_size;
int alignment = (((ctx->cycle_buffer + HUGEPAGE_ALIGN -1) / HUGEPAGE_ALIGN) * HUGEPAGE_ALIGN);
buf_size = (((ctx->buff_size + alignment -1 ) / alignment ) * alignment);

/* create hugepage shared region */
ctx->huge_shmid = shmget(IPC_PRIVATE, buf_size,
SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
if (ctx->huge_shmid < 0) {
fprintf(stderr, "Failed to allocate hugepages. Please configure hugepages\n");
return FAILURE;
}

/* attach shared memory */
ctx->buf = (void *) shmat(ctx->huge_shmid, SHMAT_ADDR, SHMAT_FLAGS);
if (ctx->buf == (void *) -1) {
fprintf(stderr, "Failed to attach shared memory region\n");
return FAILURE;
}
int buf_size;
int alignment = (((ctx->cycle_buffer + HUGEPAGE_ALIGN -1) / HUGEPAGE_ALIGN) * HUGEPAGE_ALIGN);
buf_size = (((ctx->buff_size + alignment -1 ) / alignment ) * alignment);

/* create hugepage shared region */
ctx->huge_shmid = shmget(IPC_PRIVATE, buf_size,
SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
if (ctx->huge_shmid < 0) {
fprintf(stderr, "Failed to allocate hugepages. Please configure hugepages\n");
return FAILURE;
}

/* Mark shmem for removal */
if (shmctl(ctx->huge_shmid, IPC_RMID, 0) != 0) {
fprintf(stderr, "Failed to mark shm for removal\n");
return FAILURE;
}
/* attach shared memory */
ctx->buf[qp_index] = (void *) shmat(ctx->huge_shmid, SHMAT_ADDR, SHMAT_FLAGS);
if (ctx->buf == (void *) -1) {
fprintf(stderr, "Failed to attach shared memory region\n");
return FAILURE;
}

return SUCCESS;
/* Mark shmem for removal */
if (shmctl(ctx->huge_shmid, IPC_RMID, 0) != 0) {
fprintf(stderr, "Failed to mark shm for removal\n");
return FAILURE;
}

return SUCCESS;
}
#endif

Expand Down Expand Up @@ -1876,15 +1876,19 @@ struct ibv_qp* ctx_qp_create(struct pingpong_context *ctx,
}

if (user_param->work_rdma_cm) {
if (rdma_create_qp(ctx->cm_id,ctx->pd,&attr)) {
fprintf(stderr, " Couldn't create rdma QP - %s\n",strerror(errno));
return NULL;
if (rdma_create_qp(ctx->cm_id, ctx->pd, &attr)) {
fprintf(stderr, "Couldn't create rdma QP - %s\n", strerror(errno));
} else {
qp = ctx->cm_id->qp;
}
qp = ctx->cm_id->qp;

} else {
qp = ibv_create_qp(ctx->pd,&attr);
}
if (errno == ENOMEM)
fprintf(stderr, "Requested SQ size might be too big. Try reducing TX depth and/or inline size.\n");
fprintf(stderr, "Current TX depth is %d and inline size is %d .\n", user_param->tx_depth, user_param->inline_size);

return qp;
}

Expand Down Expand Up @@ -2392,7 +2396,7 @@ int ctx_connect(struct pingpong_context *ctx,
memset(&attr, 0, sizeof attr);

if (user_param->rate_limit_type == HW_RATE_LIMIT)
attr.ah_attr.static_rate = user_param->valid_hw_rate_limit;
attr.ah_attr.static_rate = user_param->valid_hw_rate_limit_index;

#if defined (HAVE_PACKET_PACING_EXP) || defined (HAVE_PACKET_PACING)
if (user_param->rate_limit_type == PP_RATE_LIMIT) {
Expand Down Expand Up @@ -2473,7 +2477,7 @@ int ctx_connect(struct pingpong_context *ctx,
if (user_param->rate_limit_type == HW_RATE_LIMIT) {
struct ibv_qp_attr qp_attr;
struct ibv_qp_init_attr init_attr;
int err, qp_static_rate=0;
int err, qp_static_rate = 0;

memset(&qp_attr,0,sizeof(struct ibv_qp_attr));
memset(&init_attr,0,sizeof(struct ibv_qp_init_attr));
Expand All @@ -2485,7 +2489,9 @@ int ctx_connect(struct pingpong_context *ctx,
qp_static_rate = (int)(qp_attr.ah_attr.static_rate);

//- Fall back to SW Limit only if flag undefined
if(err || (qp_static_rate != user_param->valid_hw_rate_limit)) {
if(err ||
qp_static_rate != user_param->valid_hw_rate_limit_index ||
user_param->link_type != IBV_LINK_LAYER_INFINIBAND) {
if(!user_param->is_rate_limit_type) {
user_param->rate_limit_type = SW_RATE_LIMIT;
fprintf(stderr, "\x1b[31mThe QP failed to accept HW rate limit, providing SW rate limit \x1b[0m\n");
Expand Down
2 changes: 1 addition & 1 deletion src/perftest_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ int create_mr(struct pingpong_context *ctx,
* Return Value : SUCCESS, FAILURE.
*
*/
int alloc_hugepage_region (struct pingpong_context *ctx);
int alloc_hugepage_region (struct pingpong_context *ctx, int qp_index);

/* run_iter_fs_rate
*
Expand Down

0 comments on commit 27ab0f2

Please sign in to comment.