From: "Íñigo Huguet" <ihuguet@redhat.com>
To: Edward Cree <ecree.xilinx@gmail.com>,
habetsm.xilinx@gmail.com, richardcochran@gmail.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
Yalin Li <yalli@redhat.com>
Subject: Re: [PATCH RESEND net-next v4 3/4] sfc: support unicast PTP
Date: Wed, 15 Mar 2023 09:48:37 +0100 [thread overview]
Message-ID: <698e750d-6e56-7fa3-99f4-e363c8fee90a@redhat.com> (raw)
In-Reply-To: <71e22d1e-336a-8e6a-9b36-708f07c632b2@gmail.com>
El 14/3/23 a las 17:55, Edward Cree escribió:
> On 14/03/2023 10:09, Íñigo Huguet wrote:
>> When sending a PTP event packet, add the correct filters that will make
>> that future incoming unicast PTP event packets will be timestamped.
>> The unicast address for the filter is gotten from the outgoing skb
>> before sending it.
>>
>> Until now they were not timestamped because only filters that match with
>> the PTP multicast addressed were being configured into the NIC for the
>> PTP special channel. Packets received through different channels are not
>> timestamped, getting "received SYNC without timestamp" error in ptp4l.
>>
>> Note that the inserted filters are never removed unless the NIC is stopped
>> or reconfigured, so efx_ptp_stop is called. Removal of old filters will
>> be handled by the next patch.
>>
>> Additionally, cleanup a bit efx_ptp_xmit_skb_mc to use the reverse xmas
>> tree convention and remove an unnecessary assignment to rc variable in
>> void function.
>>
>> Reported-by: Yalin Li <yalli@redhat.com>
>> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
>
> Few nits below, but still
> Acked-by: Edward Cree <ecree.xilinx@gmail.com>
>
>> +static bool efx_ptp_filter_exists(struct list_head *ptp_list,
>> + struct efx_filter_spec *spec)
>> +{
>> + struct efx_ptp_rxfilter *rxfilter;
>> +
>> + list_for_each_entry(rxfilter, ptp_list, list) {
>> + if (rxfilter->ether_type == spec->ether_type &&
>> + rxfilter->loc_port == spec->loc_port &&
>> + !memcmp(rxfilter->loc_host, spec->loc_host, sizeof(spec->loc_host)))
>> + return true;
>> + }
>> +
>> + return false;
>> +}
>
> Technically this could be more efficient if we used an rhashtable
> instead of a list, but I guess we don't expect the list to grow
> very long.
Yes, I expect the list to be short, so I thought better not to optimize prematurely. However, after giving to it a second thought, maybe the list can grow more if the NIC is acting as unicast PTP master? I mainly considered the slave case...
I've never used rhashlist, it would be a good learning exercise. How do you see if I submit that as an optimization in a future patch?
>> +static int efx_ptp_insert_unicast_filter(struct efx_nic *efx,
>> + struct sk_buff *skb)
>> +{
>> + struct efx_ptp_data *ptp = efx->ptp_data;
>> + int rc;
>> +
>> + if (!efx_ptp_valid_unicast_event_pkt(skb))
>> + return -EINVAL;
>> +
>> + if (skb->protocol == htons(ETH_P_IP)) {
>> + __be32 addr = ip_hdr(skb)->saddr;
>> +
>> + rc = efx_ptp_insert_ipv4_filter(efx, &ptp->rxfilters_ucast,
>> + addr, PTP_EVENT_PORT);
>> + if (rc < 0)
>> + goto fail;
>> +
>> + rc = efx_ptp_insert_ipv4_filter(efx, &ptp->rxfilters_ucast,
>> + addr, PTP_GENERAL_PORT);
>> + if (rc < 0)
>> + goto fail;
>> + } else if (efx_ptp_use_mac_tx_timestamps(efx)) {
>> + /* IPv6 PTP only supported by devices with MAC hw timestamp */
>> + struct in6_addr *addr = &ipv6_hdr(skb)->saddr;
>> +
>> + rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_ucast,
>> + addr, PTP_EVENT_PORT);
>> + if (rc < 0)
>> + goto fail;
>> +
>> + rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_ucast,
>> + addr, PTP_GENERAL_PORT);
>> + if (rc < 0)
>> + goto fail;
>> + } else {
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + return 0;
>> +
>> +fail:
>> + efx_ptp_remove_filters(efx, &ptp->rxfilters_ucast);
>> + return rc;
>> +}
>
> Why does failing to insert one filter mean we need to remove *all*
> the unicast filters we have? (I'm not even sure it's necessary
> to remove the new EVENT filter if the GENERAL filter fails.)
Well, my reasoning was that it shouldn't fail in a first place. If it does, it's something very weird. Instead of implementing more complex logic to try checking if the current state is valid or not, just remove all and try to install them again the next time. If it fails again, probably the system is not in a very good state.
next prev parent reply other threads:[~2023-03-15 8:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 10:09 [PATCH RESEND net-next v4 0/4] sfc: support unicast PTP Íñigo Huguet
2023-03-14 10:09 ` [PATCH RESEND net-next v4 1/4] sfc: store PTP filters in a list Íñigo Huguet
2023-03-14 16:25 ` Edward Cree
2023-03-14 10:09 ` [PATCH RESEND net-next v4 2/4] sfc: allow insertion of filters for unicast PTP Íñigo Huguet
2023-03-14 16:28 ` Edward Cree
2023-03-14 10:09 ` [PATCH RESEND net-next v4 3/4] sfc: support " Íñigo Huguet
2023-03-14 16:55 ` Edward Cree
2023-03-15 8:48 ` Íñigo Huguet [this message]
2023-03-15 16:14 ` Edward Cree
2023-03-14 10:09 ` [PATCH RESEND net-next v4 4/4] sfc: remove expired unicast PTP filters Íñigo Huguet
2023-03-14 17:24 ` Edward Cree
2023-03-15 8:54 ` Íñigo Huguet
2023-03-15 16:17 ` Edward Cree
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=698e750d-6e56-7fa3-99f4-e363c8fee90a@redhat.com \
--to=ihuguet@redhat.com \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=habetsm.xilinx@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=yalli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.