Skip to contentSkip to conversation

osm_subnet.c

PATCH In review Smith, Stan 6 participants 10 messages Oct 1, 2009 – Nov 13, 2009 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 osm_subnet.c

Set function return type to match that of cl_pfn_fmap_cmp_t to align with how the function is invoked.

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 renamed from opensm/opensm/osm_subnet.c 2009-10-01 12:45:52.000000000 -0700 +1 -1
@@ -397,7 +397,7 @@
 
 /**********************************************************************
  **********************************************************************/
-static long compar_mgids(const void *m1, const void *m2)
+static intn_t compar_mgids(const void *m1, const void *m2)
 {
        return memcmp(m1, m2, sizeof(ib_gid_t));
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

Hi Stan,

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 line 400

Quoted 13 lines · Stan

Set function return type to match that of cl_pfn_fmap_cmp_t to align with how the function is invoked.

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 renamed from opensm/opensm/osm_subnet.c 2009-10-01 12:45:52.000000000 -0700 +1 -1
@@ -397,7 +397,7 @@
 
 /**********************************************************************
  **********************************************************************/
-static long compar_mgids(const void *m1, const void *m2)
+static intn_t compar_mgids(const void *m1, const void *m2)

Any disagreement about changing a prototype of this method (cl_pfn_fmap_cmp_t) in complib to use standard type (long) instead of "homemade" and less clear one ('intn_t')?

Sasha

Quoted 4 lines
opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 renamed from opensm/opensm/osm_subnet.c 2009-10-01 12:45:52.000000000 -0700 +0 -0
 {
        return memcmp(m1, m2, sizeof(ib_gid_t));
 }
#2 lore raw
Quoted 23 lines · Sasha Khapyorsky

Hi Stan,

Quoted 8 lines · Stan

Set function return type to match that of cl_pfn_fmap_cmp_t to align with how the function is invoked.

--- a/opensm/opensm/osm_subnet.c 2009-10-01
12:45:52.000000000 -0700 +++ b/opensm/opensm/osm_subnet.c

Quoted 7 lines
2009-10-01 14:24:18.000000000 -0700 @@ -397,7 +397,7 @@

/**********************************************************************

**********************************************************************/ -static long compar_mgids(const void *m1, const void *m2) +static intn_t compar_mgids(const void *m1, const void *m2)

Any disagreement about changing a prototype of this method (cl_pfn_fmap_cmp_t) in complib to use standard type (long) instead of "homemade" and less clear one ('intn_t')?

Quoted 5 lines

Sasha

Quoted 3 lines
 {
        return memcmp(m1, m2, sizeof(ib_gid_t));

}

How is the processor architecture 'natural' size intn_t less clear than 'long'? In some worlds sizeof(long) != sizeof(void*).

I would prefer leaving the definition as intn_t as that's the way it has been defined for 'years' (think application code not necessarily OFED) which is coded to the intn_t definition. In the Windows world, cl_fleximap.h is not just an OpenSM utilized file, more like something that would live in /usr/include.

A message that is not in the archive (sent off-list or not yet received): 3F6F638B8D880340AB536D29CD4C1E1912C8783C0D-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org

#4 lore raw
Quoted 15 lines · Stan
Quoted 15 lines
Quoted 10 lines

--- a/opensm/opensm/osm_subnet.c 2009-10-01
12:45:52.000000000 -0700 +++ b/opensm/opensm/osm_subnet.c

2009-10-01 14:24:18.000000000 -0700 @@ -397,7 +397,7 @@

/**********************************************************************

**********************************************************************/ -static long compar_mgids(const void *m1, const void *m2) +static intn_t compar_mgids(const void *m1, const void *m2)

Any disagreement about changing a prototype of this method (cl_pfn_fmap_cmp_t) in complib to use standard type (long) instead of "homemade" and less clear one ('intn_t')?

Quoted 7 lines
Quoted 5 lines

Sasha

Quoted 3 lines
 {
        return memcmp(m1, m2, sizeof(ib_gid_t));

}

How is the processor architecture 'natural' size intn_t less clear than 'long'?

'intn_t' is not a standard type, but a hack defined in complib, unlike this 'long' is a very basic C language type (btw I'm fine with 'int' for this particular case).

Quoted 1 line

In some worlds sizeof(long) != sizeof(void*).

This is bad. Fortunately for this case we don't need a "natural" int. And for case where it is really needed a standard types would be more appropriate in general than complib's defined intn_t.

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Sasha Khapyorsky
Quoted 9 lines

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 line 400

Quoted 4 lines

/**********************************************************************
**********************************************************************/

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 renamed from opensm/opensm/osm_subnet.c 2009-10-01 12:45:52.000000000 -0700 +1 -1
-static long compar_mgids(const void *m1, const void *m2)
+static intn_t compar_mgids(const void *m1, const void *m2)

Any disagreement about changing a prototype of this method (cl_pfn_fmap_cmp_t) in complib to use standard type (long) instead of "homemade" and less clear one ('intn_t')?

Quoted 5 lines

Sasha

Quoted 3 lines
 {
        return memcmp(m1, m2, sizeof(ib_gid_t));

}

If the function is simply a wrapper around a single call to memcmp, why keep it at all?

#6 lore raw
Quoted 9 lines · Sean Hefty
Quoted 9 lines

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 line 400

Quoted 4 lines

/**********************************************************************
**********************************************************************/

opensm/opensm/osm_subnet.c 2009-10-01 14:24:18.000000000 -0700 renamed from opensm/opensm/osm_subnet.c 2009-10-01 12:45:52.000000000 -0700 +1 -1
-static long compar_mgids(const void *m1, const void *m2)
+static intn_t compar_mgids(const void *m1, const void *m2)

Any disagreement about changing a prototype of this method (cl_pfn_fmap_cmp_t) in complib to use standard type (long) instead of "homemade" and less clear one ('intn_t')?

Quoted 8 lines
Quoted 5 lines

Sasha

Quoted 3 lines
 {
        return memcmp(m1, m2, sizeof(ib_gid_t));

}

If the function is simply a wrapper around a single call to memcmp, why keep it at all?

The function is used as comparator callback in complib's fleximap implementation (just similar to qsort()'s compar parameter and others) and signed integer (= , > or < 0) should be returned. Using pointer sized int as return value is not needed here. We can do it to match others comparators (qsort, scandir, etc.) prototype exactly:

	int compar(const void *, const void *);

, or to not bother at all and leave it as 'long'.

Hmm, I would prefer to change to 'int' to prevent future confusing. Thoughts?

Sasha

#7 lore raw
Quoted 6 lines
	int compar(const void *, const void *);

, or to not bother at all and leave it as 'long'.

Hmm, I would prefer to change to 'int' to prevent future confusing. Thoughts?

int seems to make the most sense to me.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 81D21ED9D6F34BC1B7DA64F50EE5A7DD-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org

#9 lore raw

PATCH 1/1 opensm: cleanup intn_t uses

In all cases where non standard (defined in complib) intn_t and uintn_t types were used pointer boundary was not required. So clean it up - replace by int and unsigned int types.

---
 opensm/include/opensm/osm_mcast_tbl.h   |    2 +-
 opensm/libvendor/osm_vendor_al.c        |    4 ++--
 opensm/libvendor/osm_vendor_ibumad_sa.c |    6 +++---
 opensm/libvendor/osm_vendor_mlx_sa.c    |    6 +++---
 opensm/opensm/osm_mcast_tbl.c           |   14 +++++---------
 opensm/opensm/osm_sa_multipath_record.c |    5 ++---
 opensm/opensm/osm_sa_path_record.c      |    6 ++----
 7 files changed, 18 insertions(+), 25 deletions(-)
opensm/include/opensm/osm_mcast_tbl.h +1 -1
index 0745b5b..37e2c26 100644
@@ -174,7 +174,7 @@ void osm_mcast_tbl_delete(IN osm_mcast_tbl_t ** pp_tbl);
 *
 * SYNOPSIS
 */
-int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN uintn_t mlid_offset);
+int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN unsigned mlid_offset);
 /*
 * PARAMETERS
 *
opensm/libvendor/osm_vendor_al.c +2 -2
index abf3395..3ac05c9 100644
@@ -489,7 +489,7 @@ Exit:
 static ib_api_status_t
 __osm_vendor_get_ca_guids(IN osm_vendor_t * const p_vend,
 			  IN ib_net64_t ** const p_guids,
-			  IN uintn_t * const p_num_guids)
+			  IN unsigned * const p_num_guids)
 {
 	ib_api_status_t status;
 
@@ -581,7 +581,7 @@ osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
 	ib_api_status_t status;
 
 	uint32_t ca;
-	uintn_t ca_count;
+	unsigned ca_count;
 	uint32_t port_count = 0;
 	uint8_t port_num;
 	uint32_t total_ports = 0;
opensm/libvendor/osm_vendor_ibumad_sa.c +3 -3
index 1a7d5a2..e05a5ef 100644
@@ -129,9 +129,9 @@ __osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
 			if (ib_get_attr_size(p_sa_mad->attr_offset)) {
 				/* we used the offset value to calculate the
 				   number of records in here */
-				query_res.result_cnt = (uintn_t)
-				    ((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
-				     ib_get_attr_size(p_sa_mad->attr_offset));
+				query_res.result_cnt =
+				    (p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+				    ib_get_attr_size(p_sa_mad->attr_offset);
 				OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
 					"Count = %u = %zu / %u (%zu)\n",
 					query_res.result_cnt,
opensm/libvendor/osm_vendor_mlx_sa.c +3 -3
index 0a4e050..e47f072 100644
@@ -141,9 +141,9 @@ __osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
 					"__osmv_sa_mad_rcv_cb: Count = 0\n");
 			}
 			else {
-				query_res.result_cnt = (uintn_t)
-					((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
-					 ib_get_attr_size(p_sa_mad->attr_offset));
+				query_res.result_cnt =
+					(p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+					ib_get_attr_size(p_sa_mad->attr_offset);
 				osm_log(p_bind->p_log, OSM_LOG_DEBUG,
 					"__osmv_sa_mad_rcv_cb: "
 					"Count = %u = %zu / %u (%zu)\n",
opensm/opensm/osm_mcast_tbl.c +5 -9
index 14f8e7a..ee59275 100644
@@ -88,9 +88,7 @@ void osm_mcast_tbl_destroy(IN osm_mcast_tbl_t * p_tbl)
 void osm_mcast_tbl_set(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho,
 		       IN uint8_t port)
 {
-	uintn_t mlid_offset;
-	uintn_t mask_offset;
-	uintn_t bit_mask;
+	unsigned mlid_offset, mask_offset, bit_mask;
 	int16_t block_num;
 
 	CL_ASSERT(p_tbl && p_tbl->p_mask_tbl);
@@ -108,7 +106,7 @@ void osm_mcast_tbl_set(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho,
 		p_tbl->max_block_in_use = (uint16_t) block_num;
 }
 
-int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN uintn_t mlid_offset)
+int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN unsigned mlid_offset)
 {
 	size_t mft_depth, size;
 	uint16_t (*p_mask_tbl)[][IB_MCAST_POSITION_MAX + 1];
@@ -144,9 +142,7 @@ done:
 boolean_t osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * p_tbl,
 				IN uint16_t mlid_ho, IN uint8_t port_num)
 {
-	uintn_t mlid_offset;
-	uintn_t mask_offset;
-	uintn_t bit_mask;
+	unsigned mlid_offset, mask_offset, bit_mask;
 
 	CL_ASSERT(p_tbl);
 
@@ -171,7 +167,7 @@ boolean_t osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * p_tbl,
 boolean_t osm_mcast_tbl_is_any_port(IN const osm_mcast_tbl_t * p_tbl,
 				    IN uint16_t mlid_ho)
 {
-	uintn_t mlid_offset;
+	unsigned mlid_offset;
 	uint8_t position;
 	uint16_t result = 0;
 
@@ -223,7 +219,7 @@ ib_api_status_t osm_mcast_tbl_set_block(IN osm_mcast_tbl_t * p_tbl,
 
 void osm_mcast_tbl_clear_mlid(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho)
 {
-	uintn_t mlid_offset;
+	unsigned mlid_offset;
 
 	CL_ASSERT(p_tbl);
 	CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
opensm/opensm/osm_sa_multipath_record.c +2 -3
index ca3d967..0658480 100644
@@ -872,8 +872,7 @@ static uint32_t mpr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
 	uint16_t dest_lid_ho;
 	uint32_t path_num = 0;
 	uint8_t preference;
-	uintn_t src_offset;
-	uintn_t dest_offset;
+	unsigned src_offset, dest_offset;
 
 	OSM_LOG_ENTER(sa->p_log);
 
@@ -1058,7 +1057,7 @@ static osm_mpr_item_t *mpr_rcv_get_apm_port_pair_paths(IN osm_sa_t * sa,
 	uint16_t dest_lid_max_ho;
 	uint16_t src_lid_ho;
 	uint16_t dest_lid_ho;
-	uintn_t iterations;
+	unsigned iterations;
 	int src_lids, dest_lids;
 
 	OSM_LOG_ENTER(sa->p_log);
opensm/opensm/osm_sa_path_record.c +2 -4
index 457b40c..62a2a8b 100644
@@ -898,9 +898,7 @@ static void pr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
 	uint16_t dest_lid_ho;
 	uint32_t path_num;
 	uint8_t preference;
-	uintn_t iterations;
-	uintn_t src_offset;
-	uintn_t dest_offset;
+	unsigned iterations, src_offset, dest_offset;
 
 	OSM_LOG_ENTER(sa->p_log);
 
@@ -1015,7 +1013,7 @@ static void pr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
 	else if (comp_mask & IB_PR_COMPMASK_NUMBPATH)
 		iterations = ib_path_rec_num_path(p_pr);
 	else
-		iterations = (uintn_t) (-1);
+		iterations = (unsigned) (-1);
 
 	while (path_num < iterations) {
 		/*
Signature · 6 lines
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH 1/1 complib/fleximap: make compar callback to return int

In reply to a message not in the archive

To be consistent with another similar comparator functions (used in qsort, scandir, etc.) make fleximap comparator function to return 'int' instead of 'long'.

---
 opensm/complib/cl_map.c              |    8 ++++----
 opensm/include/complib/cl_fleximap.h |    2 +-
 opensm/opensm/osm_subnet.c           |    2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
opensm/complib/cl_map.c +4 -4
index b49b4b8..d851bf8 100644
@@ -1148,7 +1148,7 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
 			    IN const void *const p_key)
 {
 	cl_fmap_item_t *p_item;
-	intn_t cmp;
+	int cmp;
 
 	CL_ASSERT(p_map);
 	CL_ASSERT(p_map->state == CL_INITIALIZED);
@@ -1175,7 +1175,7 @@ cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
 {
 	cl_fmap_item_t *p_item;
 	cl_fmap_item_t *p_item_found;
-	intn_t cmp;
+	int cmp;
 
 	CL_ASSERT(p_map);
 	CL_ASSERT(p_map->state == CL_INITIALIZED);
@@ -1273,7 +1273,7 @@ cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
 			       IN cl_fmap_item_t * const p_item)
 {
 	cl_fmap_item_t *p_insert_at, *p_comp_item;
-	intn_t cmp = 0;
+	int cmp = 0;
 
 	CL_ASSERT(p_map);
 	CL_ASSERT(p_map->state == CL_INITIALIZED);
@@ -1575,7 +1575,7 @@ void cl_fmap_delta(IN OUT cl_fmap_t * const p_map1,
 		   OUT cl_fmap_t * const p_new, OUT cl_fmap_t * const p_old)
 {
 	cl_fmap_item_t *p_item1, *p_item2;
-	intn_t cmp;
+	int cmp;
 
 	CL_ASSERT(p_map1);
 	CL_ASSERT(p_map2);
opensm/include/complib/cl_fleximap.h +1 -1
index 0af8766..ec008cf 100644
@@ -181,7 +181,7 @@ typedef struct _cl_fmap_item {
 *
 * SYNOPSIS
 */
-typedef intn_t
+typedef int
     (*cl_pfn_fmap_cmp_t) (IN const void *const p_key1,
 			  IN const void *const p_key2);
 /*
opensm/opensm/osm_subnet.c +1 -1
index cac5e94..dd72a3a 100644
@@ -397,7 +397,7 @@ static const opt_rec_t opt_tbl[] = {
 	{0}
 };
 
-static long compar_mgids(const void *m1, const void *m2)
+static int compar_mgids(const void *m1, const void *m2)
 {
 	return memcmp(m1, m2, sizeof(ib_gid_t));
 }
Signature · 6 lines
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 1/1 complib: replace intn_t types by C99 intptr_t

Use C99 standard pointer size integer types intptr_t and uintptr_t instead of privately defined intn_t and uintn_t.

---
 opensm/complib/cl_pool.c              |    2 +-
 opensm/include/complib/cl_types.h     |   12 ++----------
 opensm/include/complib/cl_types_osd.h |    5 +----
 3 files changed, 4 insertions(+), 15 deletions(-)
opensm/complib/cl_pool.c +1 -1
index 1f66284..5a8d637 100644
@@ -128,7 +128,7 @@ cl_status_t cl_qcpool_init(IN cl_qcpool_t * const p_pool,
 		 * are aligned on a natural boundary.
 		 */
 		p_pool->component_sizes[i] =
-		    ROUNDUP(p_pool->component_sizes[i], sizeof(uintn_t));
+		    ROUNDUP(p_pool->component_sizes[i], sizeof(uintptr_t));
 	}
 
 	p_pool->max_objects = max_size ? max_size : ~(size_t) 0;
opensm/include/complib/cl_types.h +2 -10
index 84f629d..2891c6b 100644
@@ -89,7 +89,7 @@ typedef uint64_t net64_t;
 *	The offsetof macro returns the offset of a member within a structure.
 *
 * SYNOPSIS
-*	uintn_t
+*	uintptr_t
 *	offsetof(
 *		IN TYPE,
 *		IN MEMBER );
@@ -110,7 +110,7 @@ typedef uint64_t net64_t;
 *	PARENT_STRUCT
 *********/
 #ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((uintn_t) &((TYPE *)0)->MEMBER)
+#define offsetof(TYPE, MEMBER) ((uintptr_t) &((TYPE *)0)->MEMBER)
 #endif
 
 /****d* Component Library: Pointer Manipulation/PARENT_STRUCT
@@ -245,14 +245,6 @@ typedef uint64_t net64_t;
 *	net64_t
 *		64-bit network byte order value.
 *
-*	intn_t
-*		Signed natural sized integer.  32-bit on a 32-bit platform, 64-bit on
-*		a 64-bit platform.
-*
-*	uintn_t
-*		Unsigned natural sized integer.  32-bit on a 32-bit platform, 64-bit on
-*		a 64-bit platform.
-*
 *	boolean_t
 *		integral sized.  Set to TRUE or FALSE and used in logical expressions.
 *
opensm/include/complib/cl_types_osd.h +1 -4
index d12aa4c..7c6e51d 100644
@@ -37,8 +37,7 @@
  * Abstract:
  *	Defines sized datatypes for Linux User mode
  *  exported sizes are int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t
- *  int64_t, uint64_t. uintn_t is a polymorphic type, size is native size and
- *  also size of the pointer.
+ *  int64_t, uint64_t.
  */
 
 #ifndef _CL_TYPES_OSD_H_
@@ -73,8 +72,6 @@ BEGIN_C_DECLS
 /*
  * Types not explicitly defined are native to the platform.
  */
-typedef unsigned long uintn_t;
-typedef long intn_t;
 typedef int boolean_t;
 typedef volatile int32_t atomic32_t;
 
Signature · 6 lines
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html