Re: [RFC PATCH 1/5] IB/core: Add Core Capability flags to ib_device

Jason Gunthorpe
2015-05-04T23:52:05Z

On Mon, May 04, 2015 at 07:16:23PM -0400, ira.weiny wrote:
> > > Pull pkey_tbl_len, gid_tbl_len and your new thing into a single struct
> > > and allocate an array of them.
> > >
> > > Actually, why not just allocate an array of ib_port_attrs and fill
> > > that? Then you can use it for the mad size too.
> >
> > That was debated before and I was hoping to leave that for another day.
> >
> > It does make some sense to roll it in here.
>
> I remember more details now...
>
> This came up in my original OPA patch series when Sean objected to me calling
> the port attributes "cached_port_attr".

Yeah, not a great name for storing immutable values. port_properties
or something.

> There are a number of values in the ib_port_attr structure which are not fixed
> (state, active_mtu, lid, sm_lid, etc...)

Yes, there are alot of those..

So, a new struct is better, and this has just gotten so messy.

- Update ib_alloc_device to accept a num_ports argument and
create the port-port array at that point
- Have the drivers fill in their per port values before calling
ib_register. Delete read_port_table_lengths
- Get ib_dealloc_device to free the list instead of unregister,
feels like keeping that memory around for the duration of the kref
is smarter..
- Drop gid_tbl_len and pkey_tbl_len for the new scheme
- Mark all the old immutable attrs in ib_port_attrs as deprecated and
if any are easy to remove then do so..
- Don't add the caps or the max mad size immutables to port_attrs

> <quote>
> > 3rd add gets the work
> > to fix it up I guess.
> </quote>
> I don't understand this comment?

gid_tbl_len, pkey_tbl_len were the first two to use a 'shortcut' here,
your caps and/or max mad size are the third to take the 'shortcut'.

Rule of threes: The third person to extend the same badly designed
widget gets to fix it properly.

Jason