Subject: Re: [PATCH net-next] macvlan: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to real device

From: Miroslav Lichvar <[email-masked]>
Date: Tue, 23 Apr 2019 11:32:13 +0200

On Tue, Apr 23, 2019 at 05:15:43PM +0800, Hangbin Liu wrote:
> On Tue, Apr 23, 2019 at 10:31:41AM +0200, Miroslav Lichvar wrote:
> > V2_L4_SYNC is already selected, only the following filters could be
> > selected on the macvlan interface:
> > 
> > 	HWTSTAMP_FILTER_PTP_V2_L4_SYNC,
> > 	HWTSTAMP_FILTER_PTP_V2_L4_EVENT,
> > 	HWTSTAMP_FILTER_PTP_V2_SYNC,
> > 	HWTSTAMP_FILTER_PTP_V2_EVENT,
> > 	HWTSTAMP_FILTER_ALL,
> > 
> > I think one way to check this would be to assign each filter a
> > (16-bit?) value where the individual bits correspond to the message
> > types and the newly selected filter would have to contain all bits of
> > the old one.
> 
> Just like I said, how to compare with different types.

If those values I described above were in an array called ts_map
indexed by the RX filter enum, I think the check could just be:

	(ts_map[old_filter] & ts_map[new_filter]) == tsmap[old_filter]

The individual bits would correspond to:

PTP_V1_L4_SYNC
PTP_V1_L4_DELAY_REQ
PTP_V2_L4_SYNC
PTP_V2_L4_DELAY_REQ
PTP_V2_L2_SYNC
PTP_V2_L2_DELAY_REQ
NTP_ALL

And the remaining RX filters would be combinations of those.

-- 
Miroslav Lichvar