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

Hefty, Sean
2015-05-04T16:53:22Z

> > > struct ib_port_attr {
> > > enum ib_port_state state;
> > > enum ib_mtu max_mtu;
> > > enum ib_mtu active_mtu;
> > > int gid_tbl_len;
> > > + u64 core_cap_flags;
> > > u32 port_cap_flags;
> > > u32 max_msg_sz;
> > > u32 bad_pkey_cntr;
> > > @@ -1684,6 +1705,7 @@ struct ib_device {
> > > u32 local_dma_lkey;
> > > u8 node_type;
> > > u8 phys_port_cnt;
> > > + u64 *core_cap_flags; /* Per port core
> > > capability flags */
> >
> > Why are the core_cap_flags duplicated in the struct and in port
> attributes?
>
> Because the per port ib_port_attr struct is not visible to the core
> code, it must call ib_query_port each time it wants to see it. In order
> to make the helpers avoid a call, you have to stash the cap_flags into
> the ib_device struct. In the past, the only thing there was the
> node_type, and it was per device and not per node. In order to make all
> of this work and not require calls into the driver all the time, that
> has to change to a per-port array. Eventually we could get rid of the
> node_type element once everything is in place.

I understand why they are in struct ib_device, but why are they duplicated in struct ib_port_attr?