[ofa-general] [PATCH] libmlx4: Re-calculate number of inline segments
Roland Dreier
rdreier at cisco.com
Sun Oct 19 22:10:51 PDT 2008
> Supplying an ibv_qp_cap.max_inline_data value of 460 for mlx4_create_qp
> was getting back ENOMEM when the max should have been 928. Tracked the bug
> to the inline segment calculation. Here's the fix.
I don't see what's wrong with the current code, or why your change is
anything but a more obfuscated way of calculating the same thing. And
indeed, I just adapted a quick test program (below) which tries to
create QPs with max_inline_data of 460, and I get the results:
RC: inline 460 ok (got 928)
UC: inline 460 ok (got 928)
UD: inline 460 ok (got 900)
so it seems to work on my system.
- R.
Here's the test code:
#include <stdio.h>
#include <string.h>
#include <infiniband/verbs.h>
int main(int argc, char *argv)
{
struct ibv_device **dev_list;
struct ibv_device_attr dev_attr;
struct ibv_context *context;
struct ibv_pd *pd;
struct ibv_cq *cq;
struct ibv_qp_init_attr qp_attr;
int t;
static const struct {
enum ibv_qp_type type;
char *name;
} type_tab[] = {
{ IBV_QPT_RC, "RC" },
{ IBV_QPT_UC, "UC" },
{ IBV_QPT_UD, "UD" },
};
dev_list = ibv_get_device_list(NULL);
if (!dev_list) {
printf("No IB devices found\n");
return 1;
}
for (; *dev_list; ++dev_list) {
printf("%s:\n", ibv_get_device_name(*dev_list));
context = ibv_open_device(*dev_list);
if (!context) {
printf(" ibv_open_device failed\n");
continue;
}
if (ibv_query_device(context, &dev_attr)) {
printf(" ibv_query_device failed\n");
continue;
}
cq = ibv_create_cq(context, 1, NULL, NULL, 0);
if (!cq) {
printf(" ibv_create_cq failed\n");
continue;
}
pd = ibv_alloc_pd(context);
if (!pd) {
printf(" ibv_alloc_pd failed\n");
continue;
}
for (t = 0; t < sizeof type_tab / sizeof type_tab[0]; ++t) {
memset(&qp_attr, 0, sizeof qp_attr);
qp_attr.send_cq = cq;
qp_attr.recv_cq = cq;
qp_attr.cap.max_send_wr = 1;
qp_attr.cap.max_recv_wr = 1;
qp_attr.cap.max_send_sge = 1;
qp_attr.cap.max_recv_sge = 1;
qp_attr.cap.max_inline_data = 460;
qp_attr.qp_type = type_tab[t].type;
printf(" %s: inline %d ", type_tab[t].name, qp_attr.cap.max_inline_data);
if (ibv_create_qp(pd, &qp_attr))
printf("ok (got %d)\n",
qp_attr.cap.max_inline_data);
else
printf("FAILED\n");
}
}
return 0;
}
More information about the general
mailing list