All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Antoine Tenart <antoine.tenart@bootlin.com>
Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com,
	hkallweit1@gmail.com, alexandre.belloni@bootlin.com,
	UNGLinuxDriver@microchip.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com,
	allan.nielsen@microchip.com, foss@0leil.net
Subject: Re: [PATCH net-next v3 6/8] net: phy: mscc: timestamping and PHC support
Date: Sat, 20 Jun 2020 08:00:45 -0700	[thread overview]
Message-ID: <20200620150045.GA2054@localhost> (raw)
In-Reply-To: <20200619122300.2510533-7-antoine.tenart@bootlin.com>

On Fri, Jun 19, 2020 at 02:22:58PM +0200, Antoine Tenart wrote:

> +static void vsc85xx_dequeue_skb(struct vsc85xx_ptp *ptp)
> +{
> +	struct skb_shared_hwtstamps shhwtstamps;
> +	struct vsc85xx_ts_fifo fifo;
> +	struct sk_buff *skb;
> +	u8 skb_sig[16], *p;
> +	int i, len;
> +	u32 reg;
> +
> +	memset(&fifo, 0, sizeof(fifo));
> +	p = (u8 *)&fifo;
> +
> +	reg = vsc85xx_ts_read_csr(ptp->phydev, PROCESSOR,
> +				  MSCC_PHY_PTP_EGR_TS_FIFO(0));
> +	if (reg & PTP_EGR_TS_FIFO_EMPTY)
> +		return;
> +
> +	*p++ = reg & 0xff;
> +	*p++ = (reg >> 8) & 0xff;
> +
> +	/* Read the current FIFO item. Reading FIFO6 pops the next one. */
> +	for (i = 1; i < 7; i++) {
> +		reg = vsc85xx_ts_read_csr(ptp->phydev, PROCESSOR,
> +					  MSCC_PHY_PTP_EGR_TS_FIFO(i));
> +		*p++ = reg & 0xff;
> +		*p++ = (reg >> 8) & 0xff;
> +		*p++ = (reg >> 16) & 0xff;
> +		*p++ = (reg >> 24) & 0xff;
> +	}
> +
> +	len = skb_queue_len(&ptp->tx_queue);
> +	if (len < 1)
> +		return;
> +
> +	while (len--) {
> +		skb = __skb_dequeue(&ptp->tx_queue);
> +		if (!skb)
> +			return;
> +
> +		/* Can't get the signature of the packet, won't ever
> +		 * be able to have one so let's dequeue the packet.
> +		 */
> +		if (get_sig(skb, skb_sig) < 0)
> +			continue;

This leaks the skb.

> +		/* Check if we found the signature we were looking for. */
> +		if (!memcmp(skb_sig, fifo.sig, sizeof(fifo.sig))) {
> +			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
> +			shhwtstamps.hwtstamp = ktime_set(fifo.secs, fifo.ns);
> +			skb_complete_tx_timestamp(skb, &shhwtstamps);
> +
> +			return;
> +		}
> +
> +		/* Valid signature but does not match the one of the
> +		 * packet in the FIFO right now, reschedule it for later
> +		 * packets.
> +		 */
> +		__skb_queue_tail(&ptp->tx_queue, skb);
> +	}
> +}

Thanks,
Richard

  reply	other threads:[~2020-06-20 15:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-19 12:22 [PATCH net-next v3 0/8] net: phy: mscc: PHC and timestamping support Antoine Tenart
2020-06-19 12:22 ` [PATCH net-next v3 1/8] net: phy: add support for a common probe between shared PHYs Antoine Tenart
2020-06-20 14:49   ` Andrew Lunn
2020-06-19 12:22 ` [PATCH net-next v3 2/8] net: phy: mscc: fix copyright and author information in MACsec Antoine Tenart
2020-06-20 14:50   ` Andrew Lunn
2020-06-19 12:22 ` [PATCH net-next v3 3/8] net: phy: mscc: remove the TR CLK disable magic value Antoine Tenart
2020-06-20 14:52   ` Andrew Lunn
2020-06-22 12:49     ` Antoine Tenart
2020-06-19 12:22 ` [PATCH net-next v3 4/8] net: phy: mscc: take into account the 1588 block in MACsec init Antoine Tenart
2020-06-21 15:38   ` Quentin Schulz
2020-06-22 14:25     ` Antoine Tenart
2020-06-19 12:22 ` [PATCH net-next v3 5/8] net: phy: mscc: 1588 block initialization Antoine Tenart
2020-06-20 15:10   ` Andrew Lunn
2020-06-22 13:07     ` Antoine Tenart
2020-06-21 16:57   ` Quentin Schulz
2020-06-22 15:26     ` Antoine Tenart
2020-06-19 12:22 ` [PATCH net-next v3 6/8] net: phy: mscc: timestamping and PHC support Antoine Tenart
2020-06-20 15:00   ` Richard Cochran [this message]
2020-06-22 13:09     ` Antoine Tenart
2020-06-20 15:16   ` Andrew Lunn
2020-06-20 15:21   ` Andrew Lunn
2020-06-22 13:31     ` Antoine Tenart
2020-06-20 15:40   ` Andrew Lunn
2020-06-22 13:26     ` Antoine Tenart
2020-06-21 17:35   ` Quentin Schulz
2020-06-22 15:35     ` Antoine Tenart
2020-06-19 12:22 ` [PATCH net-next v3 7/8] dt-bindings: net: phy: vsc8531: document the load/save GPIO Antoine Tenart
2020-06-19 12:23 ` [PATCH net-next v3 8/8] MIPS: dts: ocelot: describe " Antoine Tenart

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=20200620150045.GA2054@localhost \
    --to=richardcochran@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=foss@0leil.net \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.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.