Re: [PATCHv9 09/12] ib_core: Add VLAN support to IBoE

Eli Cohen
2010-08-16T12:51:28Z

On Fri, Aug 06, 2010 at 10:49:15AM -0600, Jason Gunthorpe wrote:
> On Fri, Aug 06, 2010 at 05:41:53PM +0300, Eli Cohen wrote:
> > -static inline void iboe_mac_to_ll(union ib_gid *gid, u8 *mac)
> > +static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid)
> > {
> > memset(gid->raw, 0, 16);
> > *((u32 *)gid->raw) = cpu_to_be32(0xfe800000);
> > - gid->raw[12] = 0xfe;
> > - gid->raw[11] = 0xff;
> > + if (vid) {
> > + gid->raw[12] = vid & 0xff;
> > + gid->raw[11] = vid >> 8;
> > + } else {
> > + gid->raw[12] = 0xfe;
> > + gid->raw[11] = 0xff;
> > + }
> > memcpy(gid->raw + 13, mac + 3, 3);
> > memcpy(gid->raw + 8, mac, 3);
> > gid->raw[8] ^= 2;
>
> My general comment on this would be the same I made for userspace:
> Don't assume VID == 0 means no vlan tag. Use 0xFFFF or something that
> is actually invalid.
>
I was looking for a way to distinguish between the case of none VLAN
and that of VLAN and saw places (in the bonding code) that treat 0 as
a none VLAN case. So now I will use the following function to get the
VLAN ID and code 0xffff as the none VLAN case.

+static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)
+{
+ return dev->priv_flags & IFF_802_1Q_VLAN ?
+ vlan_dev_vlan_id(dev) : 0xffff;
+}
+

0xffff will signify none VLAN but will be coded as 0xfffe in the GID
as is the case with IPv6 link local addresses.

I will send a v10 series with these changes.