]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
ibacm: support performance query by endpoint index
authorKaike Wan <kaike.wan@intel.com>
Fri, 13 Jun 2014 19:32:07 +0000 (12:32 -0700)
committerSean Hefty <sean.hefty@intel.com>
Fri, 13 Jun 2014 19:32:07 +0000 (12:32 -0700)
Enable a consumer application to query the ibacm service for
performance data for an endpoint with an index.  Provide a mechanism
to retrieve performance data for all endpoints through a loop.

Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/acm.c

index 7dc95d821ef2c16a900983db3a4aa1924758accd..6d18ac53a16e10db8b324d84d4c16fb88878bfe4 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -966,25 +966,35 @@ static int acm_svr_perf_query(struct acmc_client *client, struct acm_msg *msg)
        int ret, i;
        uint16_t len;
        struct acmc_addr *addr;
-       struct acmc_ep *ep;
+       struct acmc_ep *ep = NULL;
+       int index;
 
        acm_log(2, "client %d\n", client->index);
+       index = msg->hdr.data[1];
        msg->hdr.opcode |= ACM_OP_ACK;
        msg->hdr.status = ACM_STATUS_SUCCESS;
-       msg->hdr.data[1] = 0;
        msg->hdr.data[2] = 0;
 
-       if (ntohs(msg->hdr.length) < (ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH) ||
-           !(msg->resolve_data[0].flags & ACM_EP_FLAG_SOURCE)) {
+       if ((ntohs(msg->hdr.length) < (ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH)
+           && index < 1) || 
+           ((ntohs(msg->hdr.length) >= (ACM_MSG_HDR_LENGTH + ACM_MSG_EP_LENGTH)
+           && !(msg->resolve_data[0].flags & ACM_EP_FLAG_SOURCE)))) {
                for (i = 0; i < ACM_MAX_COUNTER; i++)
                        msg->perf_data[i] = htonll((uint64_t) atomic_get(&counter[i]));
 
                msg->hdr.data[0] = ACM_MAX_COUNTER;
                len = ACM_MSG_HDR_LENGTH + (ACM_MAX_COUNTER * sizeof(uint64_t));
        } else {
-               addr = acm_get_ep_address(&msg->resolve_data[0]);
-               if (addr) {
-                       ep = container_of(addr->addr.endpoint, struct acmc_ep, endpoint);
+               if (index >= 1) {
+                       ep = acm_get_ep(index - 1);
+               } else {
+                       addr = acm_get_ep_address(&msg->resolve_data[0]);
+                       if (addr) 
+                               ep = container_of(addr->addr.endpoint, 
+                                                 struct acmc_ep, endpoint);
+               }
+
+               if (ep) {
                        ep->port->prov->query_perf(ep->prov_ep_context,
                                                   msg->perf_data, &msg->hdr.data[0]);
                        len = ACM_MSG_HDR_LENGTH + (msg->hdr.data[0] * sizeof(uint64_t));