diff options
author | Roland Dreier <rolandd@cisco.com> | 2006-01-25 22:43:27 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:35:59 -0800 |
commit | 2c0f0a2da5ff600756fe89417b35eab48c730401 (patch) | |
tree | 97a604c08cfd4dbe0c41fd1442b1beaa3b1a5068 | |
parent | 1991075d6b4770b52c24693ba439d412ab63b42c (diff) | |
download | libibverbs-2c0f0a2da5ff600756fe89417b35eab48c730401.tar.gz |
Move pp_get_local_lid() to common file
Factor out more common pingpong code.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | examples/pingpong.c | 10 | ||||
-rw-r--r-- | examples/pingpong.h | 1 | ||||
-rw-r--r-- | examples/rc_pingpong.c | 12 | ||||
-rw-r--r-- | examples/srq_pingpong.c | 12 | ||||
-rw-r--r-- | examples/uc_pingpong.c | 12 | ||||
-rw-r--r-- | examples/ud_pingpong.c | 12 |
7 files changed, 22 insertions, 44 deletions
@@ -1,3 +1,10 @@ +2006-01-25 Roland Dreier <rdreier@cisco.com> + + * examples/pingpong.c, examples/pingpong.h, + examples/rc_pingpong.c, examples/uc_pingpong.c, + examples/srq_pingpong.c: Move pp_get_local_lid() to pingpong.c to + reduce code duplication. + 2006-01-22 Roland Dreier <rdreier@cisco.com> * Release version 1.0-rc5. diff --git a/examples/pingpong.c b/examples/pingpong.c index b6d637d..e60d29e 100644 --- a/examples/pingpong.c +++ b/examples/pingpong.c @@ -45,3 +45,13 @@ enum ibv_mtu pp_mtu_to_enum(int mtu) default: return -1; } } + +uint16_t pp_get_local_lid(struct ibv_context *context, int port) +{ + struct ibv_port_attr attr; + + if (ibv_query_port(context, port, &attr)) + return 0; + + return attr.lid; +} diff --git a/examples/pingpong.h b/examples/pingpong.h index 67ec641..eccd407 100644 --- a/examples/pingpong.h +++ b/examples/pingpong.h @@ -38,5 +38,6 @@ #include <infiniband/verbs.h> enum ibv_mtu pp_mtu_to_enum(int mtu); +uint16_t pp_get_local_lid(struct ibv_context *context, int port); #endif /* IBV_PINGPONG_H */ diff --git a/examples/rc_pingpong.c b/examples/rc_pingpong.c index 41630c6..c4494ba 100644 --- a/examples/rc_pingpong.c +++ b/examples/rc_pingpong.c @@ -77,16 +77,6 @@ struct pingpong_dest { int psn; }; -static uint16_t pp_get_local_lid(struct pingpong_context *ctx, int port) -{ - struct ibv_port_attr attr; - - if (ibv_query_port(ctx->context, port, &attr)) - return 0; - - return attr.lid; -} - static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, enum ibv_mtu mtu, struct pingpong_dest *dest) { @@ -582,7 +572,7 @@ int main(int argc, char *argv[]) return 1; } - my_dest.lid = pp_get_local_lid(ctx, ib_port); + my_dest.lid = pp_get_local_lid(ctx->context, ib_port); my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; if (!my_dest.lid) { diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c index 48e1ca9..8509e03 100644 --- a/examples/srq_pingpong.c +++ b/examples/srq_pingpong.c @@ -81,16 +81,6 @@ struct pingpong_dest { int psn; }; -static uint16_t pp_get_local_lid(struct pingpong_context *ctx, int port) -{ - struct ibv_port_attr attr; - - if (ibv_query_port(ctx->context, port, &attr)) - return 0; - - return attr.lid; -} - static int pp_connect_ctx(struct pingpong_context *ctx, int port, enum ibv_mtu mtu, const struct pingpong_dest *my_dest, const struct pingpong_dest *dest) @@ -668,7 +658,7 @@ int main(int argc, char *argv[]) for (i = 0; i < num_qp; ++i) { my_dest[i].qpn = ctx->qp[i]->qp_num; my_dest[i].psn = lrand48() & 0xffffff; - my_dest[i].lid = pp_get_local_lid(ctx, ib_port); + my_dest[i].lid = pp_get_local_lid(ctx->context, ib_port); if (!my_dest[i].lid) { fprintf(stderr, "Couldn't get local LID\n"); return 1; diff --git a/examples/uc_pingpong.c b/examples/uc_pingpong.c index aeeb871..41e612e 100644 --- a/examples/uc_pingpong.c +++ b/examples/uc_pingpong.c @@ -77,16 +77,6 @@ struct pingpong_dest { int psn; }; -static uint16_t pp_get_local_lid(struct pingpong_context *ctx, int port) -{ - struct ibv_port_attr attr; - - if (ibv_query_port(ctx->context, port, &attr)) - return 0; - - return attr.lid; -} - static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, enum ibv_mtu mtu, struct pingpong_dest *dest) { @@ -570,7 +560,7 @@ int main(int argc, char *argv[]) return 1; } - my_dest.lid = pp_get_local_lid(ctx, ib_port); + my_dest.lid = pp_get_local_lid(ctx->context, ib_port); my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; if (!my_dest.lid) { diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c index fbaa3f1..f0a8119 100644 --- a/examples/ud_pingpong.c +++ b/examples/ud_pingpong.c @@ -78,16 +78,6 @@ struct pingpong_dest { int psn; }; -static uint16_t pp_get_local_lid(struct pingpong_context *ctx, int port) -{ - struct ibv_port_attr attr; - - if (ibv_query_port(ctx->context, port, &attr)) - return 0; - - return attr.lid; -} - static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, struct pingpong_dest *dest) { @@ -568,7 +558,7 @@ int main(int argc, char *argv[]) return 1; } - my_dest.lid = pp_get_local_lid(ctx, ib_port); + my_dest.lid = pp_get_local_lid(ctx->context, ib_port); my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; if (!my_dest.lid) { |