[ofa-general] Issues with _osm_lin_fwd_tbl

Hal Rosenstock hrosenstock at xsigo.com
Wed Jun 11 08:40:37 PDT 2008


Hi Vincent,

On Wed, 2008-06-11 at 16:51 +0200, Vincent Ficet wrote:
> Hi,
> 
> The function opensm/osm_lin_fwd_table.c:osm_lin_tbl_new()  invokes 
> __osm_lin_tbl_compute_obj_size with a 'size' parameter that is obviously 
> a LID (uint16_t). However, the prototype for 
> __osm_lin_tbl_compute_obj_size is:
> 
> static inline size_t __osm_lin_tbl_compute_obj_size(IN const uint32_t 
> num_ports)
> Furthermore, the comments in the osm_lin_fwd_tbl_t declaration say:
> 
> *    port_tbl
> *        The array that specifies the port number which routes the
> *        corresponding LID.  Index is by LID.
> *

I think it comes from the IB spec where LFT block indicates port
(indexed by LID).

> Am I right in saying that the prototype for 
> __osm_lin_tbl_compute_obj_size() should be:
> 
> static inline size_t __osm_lin_tbl_compute_obj_size(IN const uint16_t 
> num_lids)
> 
> This would avoid casting its return value as follows in osm_lin_tbl_new():
> 
> p_tbl->size = (uint16_t) size;

Seems reasonable to me.

> Also, could anyone explain why the osm_lin_fwd_tbl_t is declared as follows:
> 
> typedef struct _osm_lin_fwd_tbl {
>     uint16_t size;
>     uint8_t port_tbl[1];
> } osm_lin_fwd_tbl_t;
> 
> This prototype is obviously quite different than the corresponding 
> malloc'ed space in  __osm_lin_tbl_compute_obj_size():
> 
> return (sizeof(osm_lin_fwd_tbl_t) + (num_ports - 1));

I think this is because the osm_lin_fwd_tbl_t already includes the first
entry so this looks "right" to me.

Do you care to supply a patch for this ?

I also see one other issue in the area of the code you are asking about.

-- Hal

> Thanks,
> 
> Vincent
> 
> 
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general




More information about the general mailing list