[openib-general] [PATCH 08/12] SRP: Changing ibsrpdm
Ishai Rabinovitz
ishai at mellanox.co.il
Mon May 1 04:29:53 PDT 2006
Use constants for bits in masks. Improves readability.
Signed-off-by: Ishai Rabinovitz <ishai at mellanox.co.il>
Index: last_stable/src/userspace/srptools/src/srp-dm.c
===================================================================
--- last_stable.orig/src/userspace/srptools/src/srp-dm.c 2006-04-21 01:18:55.000000000 +0300
+++ last_stable/src/userspace/srptools/src/srp-dm.c 2006-04-21 03:41:39.000000000 +0300
@@ -70,6 +70,14 @@ static inline uint64_t ntohll(uint64_t x
static inline uint64_t htonll(uint64_t x) { return x; }
#endif
+#define IS_DM_MASK (1 << 19)
+
+#define SIZE_OF_QUERY_RESPONSE (1 << 18)
+
+#define N_COMP_MASK_NODE_TYPE htonll(1 << 4);
+
+#define N_COMP_MASK_LID htonll(1);
+
static char *sysfs_path = "/sys";
static void usage(const char *argv0)
@@ -474,7 +482,7 @@ static int get_port_info(int fd, uint32_
out_sa_mad->mgmt_class = SRP_MGMT_CLASS_SA;
out_sa_mad->class_version = 2;
- out_sa_mad->comp_mask = htonll(1); /* LID */
+ out_sa_mad->comp_mask = N_COMP_MASK_LID;
port_info = (void *) out_sa_mad->data;
port_info->endport_lid = htons(dlid);
@@ -495,7 +503,7 @@ again:
port_info = (void *) in_sa_mad->data;
*subnet_prefix = ntohll(port_info->subnet_prefix);
- *isdm = !!(ntohl(port_info->capability_mask) & (1 << 19));
+ *isdm = !!(ntohl(port_info->capability_mask) & IS_DM_MASK);
return 0;
}
@@ -519,7 +527,7 @@ static int get_port_list(int fd, uint32_
sm_lid = strtol(val, NULL, 0);
- in_mad = alloca(1 << 18);
+ in_mad = alloca(SIZE_OF_QUERY_RESPONSE);
in_sa_mad = (void *) in_mad->data;
out_sa_mad = (void *) out_mad.data;
@@ -529,7 +537,7 @@ static int get_port_list(int fd, uint32_
out_sa_mad->mgmt_class = SRP_MGMT_CLASS_SA;
out_sa_mad->method = SRP_SA_METHOD_GET_TABLE;
out_sa_mad->class_version = 2;
- out_sa_mad->comp_mask = htonll(1ul << 4); /* node type */
+ out_sa_mad->comp_mask = N_COMP_MASK_NODE_TYPE;
out_sa_mad->rmpp_version = 1;
out_sa_mad->rmpp_type = 1;
node = (void *) out_sa_mad->data;
@@ -541,7 +549,7 @@ again:
return -1;
}
- len = read(fd, in_mad, 1 << 18);
+ len = read(fd, in_mad, SIZE_OF_QUERY_RESPONSE);
if (len < 0) {
fprintf(stderr, "%s/%d: ", __func__, __LINE__);
perror("read");
--
Ishai Rabinovitz
More information about the general
mailing list