[ofa-general] Re: opensm/osm_port_t struct definition

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Tue Aug 19 04:30:15 PDT 2008


Sasha Khapyorsky wrote:
> Hi Yevgeny,
> 
> On 12:23 Tue 19 Aug     , Yevgeny Kliteynik wrote:
>> I have a general question/concern about osm_port_t:
>>
>> typedef struct osm_port {
>> 	cl_map_item_t map_item;
>> 	cl_list_item_t list_item;
>> 	...
>> } osm_port_t;
>>
>> Here and there in the code I see some comments that
>> map_item and list_item should be first members of the
>> struct,
> 
> I cannot find such comment about list_item.

Here are some examples (there are more):

opensm/include/opensm/osm_prefix_route.h
----------------------------------------

	typedef struct {
		cl_list_item_t list_item;	/* must be first */
		...
	} osm_prefix_route_t;


opensm/include/opensm/osm_service.h
-----------------------------------

	typedef struct osm_svcr {
		cl_list_item_t list_item;
		...
	} osm_svcr_t;
	/*
	* FIELDS
	*	map_item
	*		Map Item for qmap linkage.  Must be first element!!
	...


opensm/include/opensm/osm_mcm_info.h
------------------------------------

	typedef struct osm_mcm_info {
		cl_list_item_t list_item;
		...
	} osm_mcm_info_t;
	/*
	* FIELDS
	*	list_item
	*		Linkage structure for cl_qlist.  MUST BE FIRST MEMBER!
	...


opensm/include/opensm/osm_madw.h
--------------------------------

	typedef struct osm_madw {
		cl_list_item_t list_item;
		...
	} osm_madw_t;
	/*
	* FIELDS
	*	list_item
	*		List linkage for lists.  MUST BE FIRST MEMBER!
	...


opensm/include/opensm/osm_inform.h
----------------------------------

	typedef struct osm_infr {
		cl_list_item_t list_item;
		...
	} osm_infr_t;
	/*
	* FIELDS
	*	list_item
	*		List Item for qlist linkage.  Must be first element!!
	...



> It should not be a first
> member, to access the structure we are using cl_item_obj() macro
> (cl_qlist.h).

I couldn't find any problem with having list_item not only in the
beginning of the struct, but I was confused by all these comments
in the code.
So I guess that only cl_map_item_t has to be first in the struct.

-- Yevgeny

>> which, I guess, means that same object can't be
>> member of both map and list.
>> Do we have a problem here?
> 
> No, both can be used. I don't see any problem here.
> 
> Sasha
> 




More information about the general mailing list