diff mbox series

[net-next,v2,1/3] sfc: allow more flexible way of adding filters for PTP

Message ID 20220819082001.15439-2-ihuguet@redhat.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series sfc: add support for PTP over IPv6 and 802.3 | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 85 this patch: 88
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 85 this patch: 88
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 121 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Íñigo Huguet Aug. 19, 2022, 8:19 a.m. UTC
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(-)

Comments

kernel test robot Aug. 19, 2022, 7:38 p.m. UTC | #1
Hi "Íñigo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/igo-Huguet/sfc-allow-more-flexible-way-of-adding-filters-for-PTP/20220819-172020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 268603d79cc48dba671e9caf108fab32315b86a2
config: riscv-randconfig-s032-20220820 (https://download.01.org/0day-ci/archive/20220820/202208200349.DAfcHJLZ-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/b2ecd6ff1d511bc31dbb222211226ce141b0852b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review igo-Huguet/sfc-allow-more-flexible-way-of-adding-filters-for-PTP/20220819-172020
        git checkout b2ecd6ff1d511bc31dbb222211226ce141b0852b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=riscv SHELL=/bin/bash drivers/net/ethernet/sfc/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
   WARNING: invalid argument to '-march': '_zihintpause'
>> drivers/net/ethernet/sfc/ptp.c:1636:39: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned short [usertype] val @@     got restricted __be16 [usertype] @@
   drivers/net/ethernet/sfc/ptp.c:1636:39: sparse:     expected unsigned short [usertype] val
   drivers/net/ethernet/sfc/ptp.c:1636:39: sparse:     got restricted __be16 [usertype]
   drivers/net/ethernet/sfc/ptp.c:1636:39: sparse: sparse: cast from restricted __be16
   drivers/net/ethernet/sfc/ptp.c:1636:39: sparse: sparse: cast from restricted __be16
   drivers/net/ethernet/sfc/ptp.c:1697:58: sparse: sparse: restricted __be16 degrades to integer
   drivers/net/ethernet/sfc/ptp.c:1736:36: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned short [usertype] val @@     got restricted __be16 [usertype] @@
   drivers/net/ethernet/sfc/ptp.c:1736:36: sparse:     expected unsigned short [usertype] val
   drivers/net/ethernet/sfc/ptp.c:1736:36: sparse:     got restricted __be16 [usertype]
   drivers/net/ethernet/sfc/ptp.c:1736:36: sparse: sparse: cast from restricted __be16
   drivers/net/ethernet/sfc/ptp.c:1736:36: sparse: sparse: cast from restricted __be16

vim +1636 drivers/net/ethernet/sfc/ptp.c

7c236c43b83822 Stuart Hodgson 2012-09-03  1620  
7c236c43b83822 Stuart Hodgson 2012-09-03  1621  /* Determine whether this packet should be processed by the PTP module
7c236c43b83822 Stuart Hodgson 2012-09-03  1622   * or transmitted conventionally.
7c236c43b83822 Stuart Hodgson 2012-09-03  1623   */
7c236c43b83822 Stuart Hodgson 2012-09-03  1624  bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb)
7c236c43b83822 Stuart Hodgson 2012-09-03  1625  {
7c236c43b83822 Stuart Hodgson 2012-09-03  1626  	return efx->ptp_data &&
7c236c43b83822 Stuart Hodgson 2012-09-03  1627  		efx->ptp_data->enabled &&
7c236c43b83822 Stuart Hodgson 2012-09-03  1628  		skb->len >= PTP_MIN_LENGTH &&
7c236c43b83822 Stuart Hodgson 2012-09-03  1629  		skb->len <= MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM &&
7c236c43b83822 Stuart Hodgson 2012-09-03  1630  		likely(skb->protocol == htons(ETH_P_IP)) &&
e5a498e943fbc4 Ben Hutchings  2013-12-06  1631  		skb_transport_header_was_set(skb) &&
e5a498e943fbc4 Ben Hutchings  2013-12-06  1632  		skb_network_header_len(skb) >= sizeof(struct iphdr) &&
7c236c43b83822 Stuart Hodgson 2012-09-03  1633  		ip_hdr(skb)->protocol == IPPROTO_UDP &&
e5a498e943fbc4 Ben Hutchings  2013-12-06  1634  		skb_headlen(skb) >=
e5a498e943fbc4 Ben Hutchings  2013-12-06  1635  		skb_transport_offset(skb) + sizeof(struct udphdr) &&
7c236c43b83822 Stuart Hodgson 2012-09-03 @1636  		udp_hdr(skb)->dest == htons(PTP_EVENT_PORT);
7c236c43b83822 Stuart Hodgson 2012-09-03  1637  }
7c236c43b83822 Stuart Hodgson 2012-09-03  1638
kernel test robot Aug. 19, 2022, 9:19 p.m. UTC | #2
Hi "Íñigo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/igo-Huguet/sfc-allow-more-flexible-way-of-adding-filters-for-PTP/20220819-172020
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 268603d79cc48dba671e9caf108fab32315b86a2
config: sparc-randconfig-s043-20220820 (https://download.01.org/0day-ci/archive/20220820/202208200516.VBfWImxe-lkp@intel.com/config)
compiler: sparc-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/b2ecd6ff1d511bc31dbb222211226ce141b0852b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review igo-Huguet/sfc-allow-more-flexible-way-of-adding-filters-for-PTP/20220819-172020
        git checkout b2ecd6ff1d511bc31dbb222211226ce141b0852b
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc SHELL=/bin/bash drivers/net/ethernet/sfc/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/sfc/ptp.c:1636:39: sparse: sparse: cast from restricted __be16
>> drivers/net/ethernet/sfc/ptp.c:1697:58: sparse: sparse: restricted __be16 degrades to integer
   drivers/net/ethernet/sfc/ptp.c:1736:36: sparse: sparse: cast from restricted __be16

vim +1636 drivers/net/ethernet/sfc/ptp.c

7c236c43b838221 Stuart Hodgson  2012-09-03  1620  
7c236c43b838221 Stuart Hodgson  2012-09-03  1621  /* Determine whether this packet should be processed by the PTP module
7c236c43b838221 Stuart Hodgson  2012-09-03  1622   * or transmitted conventionally.
7c236c43b838221 Stuart Hodgson  2012-09-03  1623   */
7c236c43b838221 Stuart Hodgson  2012-09-03  1624  bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb)
7c236c43b838221 Stuart Hodgson  2012-09-03  1625  {
7c236c43b838221 Stuart Hodgson  2012-09-03  1626  	return efx->ptp_data &&
7c236c43b838221 Stuart Hodgson  2012-09-03  1627  		efx->ptp_data->enabled &&
7c236c43b838221 Stuart Hodgson  2012-09-03  1628  		skb->len >= PTP_MIN_LENGTH &&
7c236c43b838221 Stuart Hodgson  2012-09-03  1629  		skb->len <= MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM &&
7c236c43b838221 Stuart Hodgson  2012-09-03  1630  		likely(skb->protocol == htons(ETH_P_IP)) &&
e5a498e943fbc49 Ben Hutchings   2013-12-06  1631  		skb_transport_header_was_set(skb) &&
e5a498e943fbc49 Ben Hutchings   2013-12-06  1632  		skb_network_header_len(skb) >= sizeof(struct iphdr) &&
7c236c43b838221 Stuart Hodgson  2012-09-03  1633  		ip_hdr(skb)->protocol == IPPROTO_UDP &&
e5a498e943fbc49 Ben Hutchings   2013-12-06  1634  		skb_headlen(skb) >=
e5a498e943fbc49 Ben Hutchings   2013-12-06  1635  		skb_transport_offset(skb) + sizeof(struct udphdr) &&
7c236c43b838221 Stuart Hodgson  2012-09-03 @1636  		udp_hdr(skb)->dest == htons(PTP_EVENT_PORT);
7c236c43b838221 Stuart Hodgson  2012-09-03  1637  }
7c236c43b838221 Stuart Hodgson  2012-09-03  1638  
7c236c43b838221 Stuart Hodgson  2012-09-03  1639  /* Receive a PTP packet.  Packets are queued until the arrival of
7c236c43b838221 Stuart Hodgson  2012-09-03  1640   * the receive timestamp from the MC - this will probably occur after the
7c236c43b838221 Stuart Hodgson  2012-09-03  1641   * packet arrival because of the processing in the MC.
7c236c43b838221 Stuart Hodgson  2012-09-03  1642   */
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1643  static bool efx_ptp_rx(struct efx_channel *channel, struct sk_buff *skb)
7c236c43b838221 Stuart Hodgson  2012-09-03  1644  {
7c236c43b838221 Stuart Hodgson  2012-09-03  1645  	struct efx_nic *efx = channel->efx;
7c236c43b838221 Stuart Hodgson  2012-09-03  1646  	struct efx_ptp_data *ptp = efx->ptp_data;
7c236c43b838221 Stuart Hodgson  2012-09-03  1647  	struct efx_ptp_match *match = (struct efx_ptp_match *)skb->cb;
c939a316459783e Laurence Evans  2012-11-15  1648  	u8 *match_data_012, *match_data_345;
7c236c43b838221 Stuart Hodgson  2012-09-03  1649  	unsigned int version;
ce320f44d677549 Ben Hutchings   2014-02-12  1650  	u8 *data;
7c236c43b838221 Stuart Hodgson  2012-09-03  1651  
7c236c43b838221 Stuart Hodgson  2012-09-03  1652  	match->expiry = jiffies + msecs_to_jiffies(PKT_EVENT_LIFETIME_MS);
7c236c43b838221 Stuart Hodgson  2012-09-03  1653  
7c236c43b838221 Stuart Hodgson  2012-09-03  1654  	/* Correct version? */
7c236c43b838221 Stuart Hodgson  2012-09-03  1655  	if (ptp->mode == MC_CMD_PTP_MODE_V1) {
97d48a10c670f87 Alexandre Rames 2013-01-11  1656  		if (!pskb_may_pull(skb, PTP_V1_MIN_LENGTH)) {
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1657  			return false;
7c236c43b838221 Stuart Hodgson  2012-09-03  1658  		}
ce320f44d677549 Ben Hutchings   2014-02-12  1659  		data = skb->data;
ce320f44d677549 Ben Hutchings   2014-02-12  1660  		version = ntohs(*(__be16 *)&data[PTP_V1_VERSION_OFFSET]);
7c236c43b838221 Stuart Hodgson  2012-09-03  1661  		if (version != PTP_VERSION_V1) {
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1662  			return false;
7c236c43b838221 Stuart Hodgson  2012-09-03  1663  		}
c939a316459783e Laurence Evans  2012-11-15  1664  
c939a316459783e Laurence Evans  2012-11-15  1665  		/* PTP V1 uses all six bytes of the UUID to match the packet
c939a316459783e Laurence Evans  2012-11-15  1666  		 * to the timestamp
c939a316459783e Laurence Evans  2012-11-15  1667  		 */
ce320f44d677549 Ben Hutchings   2014-02-12  1668  		match_data_012 = data + PTP_V1_UUID_OFFSET;
ce320f44d677549 Ben Hutchings   2014-02-12  1669  		match_data_345 = data + PTP_V1_UUID_OFFSET + 3;
7c236c43b838221 Stuart Hodgson  2012-09-03  1670  	} else {
97d48a10c670f87 Alexandre Rames 2013-01-11  1671  		if (!pskb_may_pull(skb, PTP_V2_MIN_LENGTH)) {
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1672  			return false;
7c236c43b838221 Stuart Hodgson  2012-09-03  1673  		}
ce320f44d677549 Ben Hutchings   2014-02-12  1674  		data = skb->data;
ce320f44d677549 Ben Hutchings   2014-02-12  1675  		version = data[PTP_V2_VERSION_OFFSET];
7c236c43b838221 Stuart Hodgson  2012-09-03  1676  		if ((version & PTP_VERSION_V2_MASK) != PTP_VERSION_V2) {
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1677  			return false;
7c236c43b838221 Stuart Hodgson  2012-09-03  1678  		}
c939a316459783e Laurence Evans  2012-11-15  1679  
c939a316459783e Laurence Evans  2012-11-15  1680  		/* The original V2 implementation uses bytes 2-7 of
c939a316459783e Laurence Evans  2012-11-15  1681  		 * the UUID to match the packet to the timestamp. This
c939a316459783e Laurence Evans  2012-11-15  1682  		 * discards two of the bytes of the MAC address used
c939a316459783e Laurence Evans  2012-11-15  1683  		 * to create the UUID (SF bug 33070).  The PTP V2
c939a316459783e Laurence Evans  2012-11-15  1684  		 * enhanced mode fixes this issue and uses bytes 0-2
c939a316459783e Laurence Evans  2012-11-15  1685  		 * and byte 5-7 of the UUID.
c939a316459783e Laurence Evans  2012-11-15  1686  		 */
ce320f44d677549 Ben Hutchings   2014-02-12  1687  		match_data_345 = data + PTP_V2_UUID_OFFSET + 5;
c939a316459783e Laurence Evans  2012-11-15  1688  		if (ptp->mode == MC_CMD_PTP_MODE_V2) {
ce320f44d677549 Ben Hutchings   2014-02-12  1689  			match_data_012 = data + PTP_V2_UUID_OFFSET + 2;
c939a316459783e Laurence Evans  2012-11-15  1690  		} else {
ce320f44d677549 Ben Hutchings   2014-02-12  1691  			match_data_012 = data + PTP_V2_UUID_OFFSET + 0;
c939a316459783e Laurence Evans  2012-11-15  1692  			BUG_ON(ptp->mode != MC_CMD_PTP_MODE_V2_ENHANCED);
c939a316459783e Laurence Evans  2012-11-15  1693  		}
7c236c43b838221 Stuart Hodgson  2012-09-03  1694  	}
7c236c43b838221 Stuart Hodgson  2012-09-03  1695  
7c236c43b838221 Stuart Hodgson  2012-09-03  1696  	/* Does this packet require timestamping? */
ce320f44d677549 Ben Hutchings   2014-02-12 @1697  	if (ntohs(*(__be16 *)&data[PTP_DPORT_OFFSET]) == PTP_EVENT_PORT) {
7c236c43b838221 Stuart Hodgson  2012-09-03  1698  		match->state = PTP_PACKET_STATE_UNMATCHED;
7c236c43b838221 Stuart Hodgson  2012-09-03  1699  
c939a316459783e Laurence Evans  2012-11-15  1700  		/* We expect the sequence number to be in the same position in
c939a316459783e Laurence Evans  2012-11-15  1701  		 * the packet for PTP V1 and V2
c939a316459783e Laurence Evans  2012-11-15  1702  		 */
c939a316459783e Laurence Evans  2012-11-15  1703  		BUILD_BUG_ON(PTP_V1_SEQUENCE_OFFSET != PTP_V2_SEQUENCE_OFFSET);
c939a316459783e Laurence Evans  2012-11-15  1704  		BUILD_BUG_ON(PTP_V1_SEQUENCE_LENGTH != PTP_V2_SEQUENCE_LENGTH);
c939a316459783e Laurence Evans  2012-11-15  1705  
7c236c43b838221 Stuart Hodgson  2012-09-03  1706  		/* Extract UUID/Sequence information */
c939a316459783e Laurence Evans  2012-11-15  1707  		match->words[0] = (match_data_012[0]         |
c939a316459783e Laurence Evans  2012-11-15  1708  				   (match_data_012[1] << 8)  |
c939a316459783e Laurence Evans  2012-11-15  1709  				   (match_data_012[2] << 16) |
c939a316459783e Laurence Evans  2012-11-15  1710  				   (match_data_345[0] << 24));
c939a316459783e Laurence Evans  2012-11-15  1711  		match->words[1] = (match_data_345[1]         |
c939a316459783e Laurence Evans  2012-11-15  1712  				   (match_data_345[2] << 8)  |
ce320f44d677549 Ben Hutchings   2014-02-12  1713  				   (data[PTP_V1_SEQUENCE_OFFSET +
7c236c43b838221 Stuart Hodgson  2012-09-03  1714  					 PTP_V1_SEQUENCE_LENGTH - 1] <<
7c236c43b838221 Stuart Hodgson  2012-09-03  1715  				    16));
7c236c43b838221 Stuart Hodgson  2012-09-03  1716  	} else {
7c236c43b838221 Stuart Hodgson  2012-09-03  1717  		match->state = PTP_PACKET_STATE_MATCH_UNWANTED;
7c236c43b838221 Stuart Hodgson  2012-09-03  1718  	}
7c236c43b838221 Stuart Hodgson  2012-09-03  1719  
7c236c43b838221 Stuart Hodgson  2012-09-03  1720  	skb_queue_tail(&ptp->rxq, skb);
7c236c43b838221 Stuart Hodgson  2012-09-03  1721  	queue_work(ptp->workwq, &ptp->work);
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1722  
4a74dc65e3ad825 Ben Hutchings   2013-03-05  1723  	return true;
7c236c43b838221 Stuart Hodgson  2012-09-03  1724  }
7c236c43b838221 Stuart Hodgson  2012-09-03  1725
diff mbox series

Patch

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;
 }