From patchwork Tue Aug 9 09:20:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= X-Patchwork-Id: 12939470 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C7A4C19F2D for ; Tue, 9 Aug 2022 09:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240387AbiHIJU3 (ORCPT ); Tue, 9 Aug 2022 05:20:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238876AbiHIJUO (ORCPT ); Tue, 9 Aug 2022 05:20:14 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 86B943AE for ; Tue, 9 Aug 2022 02:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660036812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m2FmAdtZekMEOfi4Ql86ejYMUfWrgl422msA3wiSsuE=; b=ZaQHTQwg2mrAMKwbYRyQEnY0Iyi41ph3Z7lx2/5Zb9uYYFig+s4QcRhthYcaqDP+oWCIqi HU83DLFEzr7OwcxEcdWZcKFZpvs6sk8gkKCCg6mNu7E4VRixgTaKeiqV+eS0PrYVIn0cRo URMbJyK5t3YX43msq3DoyBKfllYU0nk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-612-WXU8DFgEORS987rpwiFl8w-1; Tue, 09 Aug 2022 05:20:11 -0400 X-MC-Unique: WXU8DFgEORS987rpwiFl8w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22451380212A; Tue, 9 Aug 2022 09:20:11 +0000 (UTC) Received: from ihuguet-laptop.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A72740D282F; Tue, 9 Aug 2022 09:20:08 +0000 (UTC) From: =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= To: ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= Subject: [PATCH net-next 1/3] sfc: allow more flexible way of adding filters for PTP Date: Tue, 9 Aug 2022 11:20:00 +0200 Message-Id: <20220809092002.17571-2-ihuguet@redhat.com> In-Reply-To: <20220809092002.17571-1-ihuguet@redhat.com> References: <20220809092002.17571-1-ihuguet@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In preparation for the support of PTP over IPv6/UDP and Ethernet in next patches, allow a more flexible way of adding and removing RX filters for PTP. Right now, only 2 filters are allowed, which are the ones needed for PTP over IPv4/UDP. Signed-off-by: Íñigo Huguet Reviewed-by: Edward Cree --- drivers/net/ethernet/sfc/ptp.c | 72 ++++++++++++++++------------------ 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index 10ad0b93d283..bdf6c09cfac5 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c @@ -118,9 +118,11 @@ #define PTP_MIN_LENGTH 63 -#define PTP_ADDRESS 0xe0000181 /* 224.0.1.129 */ -#define PTP_EVENT_PORT 319 -#define PTP_GENERAL_PORT 320 +#define PTP_RXFILTERS_LEN 2 + +#define PTP_ADDRESS htonl(0xe0000181) /* 224.0.1.129 */ +#define PTP_EVENT_PORT htons(319) +#define PTP_GENERAL_PORT htons(320) /* Annoyingly the format of the version numbers are different between * versions 1 and 2 so it isn't possible to simply look for 1 or 2. @@ -224,9 +226,8 @@ struct efx_ptp_timeset { * @work: Work task * @reset_required: A serious error has occurred and the PTP task needs to be * reset (disable, enable). - * @rxfilter_event: Receive filter when operating - * @rxfilter_general: Receive filter when operating - * @rxfilter_installed: Receive filter installed + * @rxfilters: Receive filters when operating + * @rxfilters_count: Num of installed rxfilters, should be == PTP_RXFILTERS_LEN * @config: Current timestamp configuration * @enabled: PTP operation enabled * @mode: Mode in which PTP operating (PTP version) @@ -295,9 +296,8 @@ struct efx_ptp_data { struct workqueue_struct *workwq; struct work_struct work; bool reset_required; - u32 rxfilter_event; - u32 rxfilter_general; - bool rxfilter_installed; + u32 rxfilters[PTP_RXFILTERS_LEN]; + size_t rxfilters_count; struct hwtstamp_config config; bool enabled; unsigned int mode; @@ -1290,61 +1290,55 @@ static void efx_ptp_remove_multicast_filters(struct efx_nic *efx) { struct efx_ptp_data *ptp = efx->ptp_data; - if (ptp->rxfilter_installed) { - efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, - ptp->rxfilter_general); + while (ptp->rxfilters_count) { + ptp->rxfilters_count--; efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, - ptp->rxfilter_event); - ptp->rxfilter_installed = false; + ptp->rxfilters[ptp->rxfilters_count]); } } -static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) +static int efx_ptp_insert_ipv4_filter(struct efx_nic *efx, __be16 port) { struct efx_ptp_data *ptp = efx->ptp_data; struct efx_filter_spec rxfilter; int rc; - if (!ptp->channel || ptp->rxfilter_installed) - return 0; - - /* Must filter on both event and general ports to ensure - * that there is no packet re-ordering. - */ efx_filter_init_rx(&rxfilter, EFX_FILTER_PRI_REQUIRED, 0, efx_rx_queue_index( efx_channel_get_rx_queue(ptp->channel))); - rc = efx_filter_set_ipv4_local(&rxfilter, IPPROTO_UDP, - htonl(PTP_ADDRESS), - htons(PTP_EVENT_PORT)); - if (rc != 0) - return rc; + + efx_filter_set_ipv4_local(&rxfilter, IPPROTO_UDP, PTP_ADDRESS, port); rc = efx_filter_insert_filter(efx, &rxfilter, true); if (rc < 0) return rc; - ptp->rxfilter_event = rc; - efx_filter_init_rx(&rxfilter, EFX_FILTER_PRI_REQUIRED, 0, - efx_rx_queue_index( - efx_channel_get_rx_queue(ptp->channel))); - rc = efx_filter_set_ipv4_local(&rxfilter, IPPROTO_UDP, - htonl(PTP_ADDRESS), - htons(PTP_GENERAL_PORT)); - if (rc != 0) + ptp->rxfilters[ptp->rxfilters_count] = rc; + ptp->rxfilters_count++; + + return 0; +} + +static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) +{ + struct efx_ptp_data *ptp = efx->ptp_data; + int rc; + + if (!ptp->channel || ptp->rxfilters_count) + return 0; + + rc = efx_ptp_insert_ipv4_filter(efx, PTP_EVENT_PORT); + if (rc < 0) goto fail; - rc = efx_filter_insert_filter(efx, &rxfilter, true); + rc = efx_ptp_insert_ipv4_filter(efx, PTP_GENERAL_PORT); if (rc < 0) goto fail; - ptp->rxfilter_general = rc; - ptp->rxfilter_installed = true; return 0; fail: - efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, - ptp->rxfilter_event); + efx_ptp_remove_multicast_filters(efx); return rc; } From patchwork Tue Aug 9 09:20:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= X-Patchwork-Id: 12939472 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62B02C19F2D for ; Tue, 9 Aug 2022 09:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240497AbiHIJUf (ORCPT ); Tue, 9 Aug 2022 05:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239439AbiHIJUS (ORCPT ); Tue, 9 Aug 2022 05:20:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF27EF43 for ; Tue, 9 Aug 2022 02:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660036815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yis1n3n+f6FcTDfsUECAwl/sX2SHdakns1Mq4yRm014=; b=AARSdmPwXzBHJQT4xZGLvKzFuRgWuBkkJ8OglLFS9SGQjad+n1r2zhxHBTVaoai1JmwtpJ vzS7vfIglo3M/9+xjd5Xg+UyBeFDu1bcpk95AFgam2J/R5s+GTwLMgPxDMbhI3jBxSKAli sP0GrHWZwArq8UMfunW57XwRakJjDB8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-82-cc5R7WrqORKRqVPEj0qFpw-1; Tue, 09 Aug 2022 05:20:14 -0400 X-MC-Unique: cc5R7WrqORKRqVPEj0qFpw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2440A8037B3; Tue, 9 Aug 2022 09:20:14 +0000 (UTC) Received: from ihuguet-laptop.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1902340C1288; Tue, 9 Aug 2022 09:20:11 +0000 (UTC) From: =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= To: ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= Subject: [PATCH net-next 2/3] sfc: support PTP over IPv6/UDP Date: Tue, 9 Aug 2022 11:20:01 +0200 Message-Id: <20220809092002.17571-3-ihuguet@redhat.com> In-Reply-To: <20220809092002.17571-1-ihuguet@redhat.com> References: <20220809092002.17571-1-ihuguet@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org commit bd4a2697e5e2 ("sfc: use hardware tx timestamps for more than PTP") added support for hardware timestamping on TX for cards of the 8000 series and newer, in an effort to provide support for other transports other than IPv4/UDP. However, timestamping was still not working on RX for these other transports. This patch add support for PTP over IPv6/UDP. Tested: sync as master and as slave is correct using ptp4l from linuxptp package, both with IPv4 and IPv6. Suggested-by: Edward Cree Signed-off-by: Íñigo Huguet --- drivers/net/ethernet/sfc/filter.h | 22 +++++++++++ drivers/net/ethernet/sfc/ptp.c | 61 ++++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/sfc/filter.h b/drivers/net/ethernet/sfc/filter.h index 4d928839d292..be72e71da027 100644 --- a/drivers/net/ethernet/sfc/filter.h +++ b/drivers/net/ethernet/sfc/filter.h @@ -9,6 +9,7 @@ #include #include +#include #include /** @@ -223,6 +224,27 @@ efx_filter_set_ipv4_local(struct efx_filter_spec *spec, u8 proto, return 0; } +/** + * efx_filter_set_ipv6_local - specify IPv6 host, transport protocol and port + * @spec: Specification to initialise + * @proto: Transport layer protocol number + * @host: Local host address (network byte order) + * @port: Local port (network byte order) + */ +static inline int +efx_filter_set_ipv6_local(struct efx_filter_spec *spec, u8 proto, + const struct in6_addr *host, __be16 port) +{ + spec->match_flags |= + EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO | + EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT; + spec->ether_type = htons(ETH_P_IPV6); + spec->ip_proto = proto; + memcpy(spec->loc_host, host, sizeof(spec->loc_host)); + spec->loc_port = port; + return 0; +} + /** * efx_filter_set_ipv4_full - specify IPv4 hosts, transport protocol and ports * @spec: Specification to initialise diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index bdf6c09cfac5..1e6a70fce77a 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c @@ -118,9 +118,11 @@ #define PTP_MIN_LENGTH 63 -#define PTP_RXFILTERS_LEN 2 +#define PTP_RXFILTERS_LEN 4 -#define PTP_ADDRESS htonl(0xe0000181) /* 224.0.1.129 */ +#define PTP_ADDR_IPV4 htonl(0xe0000181) /* 224.0.1.129 */ +#define PTP_ADDR_IPV6 {0xff, 0x0e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ + 0, 0x01, 0x81} /* ff0e::181 */ #define PTP_EVENT_PORT htons(319) #define PTP_GENERAL_PORT htons(320) @@ -1297,28 +1299,46 @@ static void efx_ptp_remove_multicast_filters(struct efx_nic *efx) } } -static int efx_ptp_insert_ipv4_filter(struct efx_nic *efx, __be16 port) +static inline void efx_ptp_init_filter(struct efx_nic *efx, + struct efx_filter_spec *rxfilter) { - struct efx_ptp_data *ptp = efx->ptp_data; - struct efx_filter_spec rxfilter; - int rc; - - efx_filter_init_rx(&rxfilter, EFX_FILTER_PRI_REQUIRED, 0, - efx_rx_queue_index( - efx_channel_get_rx_queue(ptp->channel))); + efx_filter_init_rx(rxfilter, EFX_FILTER_PRI_REQUIRED, 0, + efx_rx_queue_index(efx_channel_get_rx_queue( + efx->ptp_data->channel))); +} - efx_filter_set_ipv4_local(&rxfilter, IPPROTO_UDP, PTP_ADDRESS, port); +static inline int efx_ptp_insert_filter(struct efx_nic *efx, + struct efx_filter_spec *rxfilter) +{ + struct efx_ptp_data *ptp = efx->ptp_data; - rc = efx_filter_insert_filter(efx, &rxfilter, true); + int rc = efx_filter_insert_filter(efx, rxfilter, true); if (rc < 0) return rc; - ptp->rxfilters[ptp->rxfilters_count] = rc; ptp->rxfilters_count++; - return 0; } +static int efx_ptp_insert_ipv4_filter(struct efx_nic *efx, __be16 port) +{ + struct efx_filter_spec rxfilter; + + efx_ptp_init_filter(efx, &rxfilter); + efx_filter_set_ipv4_local(&rxfilter, IPPROTO_UDP, PTP_ADDR_IPV4, port); + return efx_ptp_insert_filter(efx, &rxfilter); +} + +static int efx_ptp_insert_ipv6_filter(struct efx_nic *efx, __be16 port) +{ + const struct in6_addr addr = {{PTP_ADDR_IPV6}}; + struct efx_filter_spec rxfilter; + + efx_ptp_init_filter(efx, &rxfilter); + efx_filter_set_ipv6_local(&rxfilter, IPPROTO_UDP, &addr, port); + return efx_ptp_insert_filter(efx, &rxfilter); +} + static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) { struct efx_ptp_data *ptp = efx->ptp_data; @@ -1335,6 +1355,19 @@ static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) if (rc < 0) goto fail; + /* if the NIC supports hw timestamps by the MAC, we can support + * PTP over IPv6 + */ + if (efx_ptp_use_mac_tx_timestamps(efx)) { + rc = efx_ptp_insert_ipv6_filter(efx, PTP_EVENT_PORT); + if (rc < 0) + goto fail; + + rc = efx_ptp_insert_ipv6_filter(efx, PTP_GENERAL_PORT); + if (rc < 0) + goto fail; + } + return 0; fail: From patchwork Tue Aug 9 09:20:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= X-Patchwork-Id: 12939473 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD7CC19F2D for ; Tue, 9 Aug 2022 09:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240157AbiHIJU4 (ORCPT ); Tue, 9 Aug 2022 05:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240009AbiHIJUX (ORCPT ); Tue, 9 Aug 2022 05:20:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F41015FE1 for ; Tue, 9 Aug 2022 02:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660036821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ygiXlnxd2dld7tbaVLug9vKSrTuJvOtbANujlN5ZAkQ=; b=BLcqlqxa1IZ5ywC42GoCafZ50ODne90nU9AbXP9K85f0l34cNoS0noQjbam/7iV3HvaNOM b4Pk9LjKAXgTB23at24evTpHU7aQ+0HUGyix5Xj+M314hBkFbFNXk8yK6b5eaLRDYqbvCn kq4t7gNWZek9D/delAQYsr1y+Rj33/s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-5uwgi0oTOVuYbvugRNuarQ-1; Tue, 09 Aug 2022 05:20:17 -0400 X-MC-Unique: 5uwgi0oTOVuYbvugRNuarQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9BBA8811E81; Tue, 9 Aug 2022 09:20:16 +0000 (UTC) Received: from ihuguet-laptop.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 932B540D282F; Tue, 9 Aug 2022 09:20:14 +0000 (UTC) From: =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= To: ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, =?utf-8?b?w43DsWlnbyBIdWd1ZXQ=?= Subject: [PATCH net-next 3/3] sfc: support PTP over Ethernet Date: Tue, 9 Aug 2022 11:20:02 +0200 Message-Id: <20220809092002.17571-4-ihuguet@redhat.com> In-Reply-To: <20220809092002.17571-1-ihuguet@redhat.com> References: <20220809092002.17571-1-ihuguet@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The previous patch add support for PTP over IPv6/UDP (only for 8000 series and newer) and this one add support for PTP over 802.3. Tested: sync as master and as slave is correct with ptp4l. PTP over IPv4 and IPv6 still works fine. Suggested-by: Edward Cree Signed-off-by: Íñigo Huguet Reviewed-by: Edward Cree --- drivers/net/ethernet/sfc/ptp.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index 1e6a70fce77a..7e8390a5a757 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c @@ -118,13 +118,14 @@ #define PTP_MIN_LENGTH 63 -#define PTP_RXFILTERS_LEN 4 +#define PTP_RXFILTERS_LEN 5 #define PTP_ADDR_IPV4 htonl(0xe0000181) /* 224.0.1.129 */ #define PTP_ADDR_IPV6 {0xff, 0x0e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0x01, 0x81} /* ff0e::181 */ #define PTP_EVENT_PORT htons(319) #define PTP_GENERAL_PORT htons(320) +#define PTP_ADDR_ETHER {0x01, 0x1b, 0x19, 0, 0, 0} /* 01-1B-19-00-00-00 */ /* Annoyingly the format of the version numbers are different between * versions 1 and 2 so it isn't possible to simply look for 1 or 2. @@ -1339,6 +1340,18 @@ static int efx_ptp_insert_ipv6_filter(struct efx_nic *efx, __be16 port) return efx_ptp_insert_filter(efx, &rxfilter); } +static int efx_ptp_insert_eth_filter(struct efx_nic *efx) +{ + const u8 addr[ETH_ALEN] = PTP_ADDR_ETHER; + struct efx_filter_spec rxfilter; + + efx_ptp_init_filter(efx, &rxfilter); + efx_filter_set_eth_local(&rxfilter, EFX_FILTER_VID_UNSPEC, addr); + rxfilter.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE; + rxfilter.ether_type = htons(ETH_P_1588); + return efx_ptp_insert_filter(efx, &rxfilter); +} + static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) { struct efx_ptp_data *ptp = efx->ptp_data; @@ -1356,7 +1369,7 @@ static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) goto fail; /* if the NIC supports hw timestamps by the MAC, we can support - * PTP over IPv6 + * PTP over IPv6 and Ethernet */ if (efx_ptp_use_mac_tx_timestamps(efx)) { rc = efx_ptp_insert_ipv6_filter(efx, PTP_EVENT_PORT); @@ -1366,6 +1379,10 @@ static int efx_ptp_insert_multicast_filters(struct efx_nic *efx) rc = efx_ptp_insert_ipv6_filter(efx, PTP_GENERAL_PORT); if (rc < 0) goto fail; + + rc = efx_ptp_insert_eth_filter(efx); + if (rc < 0) + goto fail; } return 0;