From: "Íñigo Huguet" <ihuguet@redhat.com>
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,
"Íñigo Huguet" <ihuguet@redhat.com>
Subject: [PATCH net-next v2 1/3] sfc: allow more flexible way of adding filters for PTP
Date: Fri, 19 Aug 2022 10:19:59 +0200 [thread overview]
Message-ID: <20220819082001.15439-2-ihuguet@redhat.com> (raw)
In-Reply-To: <20220819082001.15439-1-ihuguet@redhat.com>
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 <ihuguet@redhat.com>
---
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;
}
--
2.34.1
next prev parent reply other threads:[~2022-08-19 8:20 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 9:19 [PATCH net-next 0/3] sfc: add support for PTP over IPv6 and 802.3 Íñigo Huguet
2022-08-09 9:20 ` [PATCH net-next 1/3] sfc: allow more flexible way of adding filters for PTP Íñigo Huguet
2022-08-09 13:21 ` Edward Cree
2022-08-09 9:20 ` [PATCH net-next 2/3] sfc: support PTP over IPv6/UDP Íñigo Huguet
2022-08-09 13:21 ` Edward Cree
2022-08-09 9:20 ` [PATCH net-next 3/3] sfc: support PTP over Ethernet Íñigo Huguet
2022-08-09 13:22 ` Edward Cree
2022-08-19 8:19 ` [PATCH net-next v2 0/3] sfc: add support for PTP over IPv6 and 802.3 Íñigo Huguet
2022-08-19 8:19 ` Íñigo Huguet [this message]
2022-08-19 19:38 ` [PATCH net-next v2 1/3] sfc: allow more flexible way of adding filters for PTP kernel test robot
2022-08-19 21:19 ` kernel test robot
2022-08-19 8:20 ` [PATCH net-next v2 2/3] sfc: support PTP over IPv6/UDP Íñigo Huguet
2022-08-19 8:20 ` [PATCH net-next v2 3/3] sfc: support PTP over Ethernet Íñigo Huguet
2022-08-25 9:02 ` [PATCH net-next v3 0/3] sfc: add support for PTP over IPv6 and 802.3 Íñigo Huguet
2022-08-25 9:02 ` [PATCH net-next v3 1/3] sfc: allow more flexible way of adding filters for PTP Íñigo Huguet
2022-08-25 9:02 ` [PATCH net-next v3 2/3] sfc: support PTP over IPv6/UDP Íñigo Huguet
2022-08-26 1:32 ` Jakub Kicinski
2022-08-26 6:39 ` Íñigo Huguet
2022-08-26 23:27 ` Jakub Kicinski
2022-08-29 7:03 ` Íñigo Huguet
2022-08-30 0:28 ` Jakub Kicinski
2022-08-30 6:11 ` Íñigo Huguet
2022-08-30 15:47 ` Edward Cree
2022-08-25 9:02 ` [PATCH net-next v3 3/3] sfc: support PTP over Ethernet Íñigo Huguet
2022-08-25 16:16 ` [PATCH net-next v3 0/3] sfc: add support for PTP over IPv6 and 802.3 Andrew Lunn
2022-08-26 6:58 ` Íñigo Huguet
2022-08-26 12:52 ` Andrew Lunn
2022-08-29 7:09 ` Íñigo Huguet
2022-08-29 14:38 ` Richard Cochran
2022-08-29 16:15 ` Andrew Lunn
2022-08-30 0:30 ` Jakub Kicinski
2022-08-31 10:16 ` [PATCH net-next v4 " Íñigo Huguet
2022-08-31 10:16 ` [PATCH net-next v4 1/3] sfc: allow more flexible way of adding filters for PTP Íñigo Huguet
2022-08-31 15:17 ` Edward Cree
2022-08-31 10:16 ` [PATCH net-next v4 2/3] sfc: support PTP over IPv6/UDP Íñigo Huguet
2022-08-31 15:49 ` Edward Cree
2022-08-31 10:16 ` [PATCH net-next v4 3/3] sfc: support PTP over Ethernet Íñigo Huguet
2022-08-31 13:47 ` [PATCH net-next v4 0/3] sfc: add support for PTP over IPv6 and 802.3 Richard Cochran
2022-09-05 8:23 ` [PATCH net-next v5 " Íñigo Huguet
2022-09-05 8:23 ` [PATCH net-next v5 1/3] sfc: allow more flexible way of adding filters for PTP Íñigo Huguet
2022-09-05 8:23 ` [PATCH net-next v5 2/3] sfc: support PTP over IPv6/UDP Íñigo Huguet
2022-09-05 8:23 ` [PATCH net-next v5 3/3] sfc: support PTP over Ethernet Íñigo Huguet
2022-09-05 16:08 ` [PATCH net-next v5 0/3] sfc: add support for PTP over IPv6 and 802.3 Edward Cree
2022-09-07 11:40 ` patchwork-bot+netdevbpf
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=20220819082001.15439-2-ihuguet@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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).