LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: "Y.b. Lu" <yangbo.lu@nxp.com> To: Dan Carpenter <dan.carpenter@oracle.com> Cc: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Richard Cochran <richardcochran@gmail.com>, Ruxandra Ioana Ciocoi Radulescu <ruxandra.radulescu@nxp.com> Subject: RE: [PATCH] staging: fsl-dpaa2/eth: Add support for hardware timestamping Date: Thu, 26 Apr 2018 10:17:38 +0000 [thread overview] Message-ID: <DB6PR0401MB25361EE5633F24AA34F0063CF88E0@DB6PR0401MB2536.eurprd04.prod.outlook.com> (raw) In-Reply-To: <20180425100345.b5oxgdjyud7t6kzc@mwanda> Hi Dan, > -----Original Message----- > From: Dan Carpenter [mailto:dan.carpenter@oracle.com] > Sent: Wednesday, April 25, 2018 6:04 PM > To: Y.b. Lu <yangbo.lu@nxp.com> > Cc: devel@driverdev.osuosl.org; linux-kernel@vger.kernel.org; Greg > Kroah-Hartman <gregkh@linuxfoundation.org>; Richard Cochran > <richardcochran@gmail.com>; Ruxandra Ioana Ciocoi Radulescu > <ruxandra.radulescu@nxp.com> > Subject: Re: [PATCH] staging: fsl-dpaa2/eth: Add support for hardware > timestamping > > On Wed, Apr 25, 2018 at 05:17:49PM +0800, Yangbo Lu wrote: > > @@ -275,6 +278,16 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv > > *priv, > > > > prefetch(skb->data); > > > > + /* Get the timestamp value */ > > + if (priv->ts_rx_en) { > > + struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); > > + u64 *ns = dpaa2_get_ts(vaddr, false); > > + > > + *ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(ns); > > This will cause Sparse endianess warnings. > > I don't totally understand why we're writing to *ns. Do we access *ns again > or not? Either way, this doesn't seem right. In other words, why don't we > do this: > > __le64 *period = dpaa2_get_ts(vaddr, false); > u64 ns; > > ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * > le64_to_cpup(period); > memset(shhwtstamps, 0, sizeof(*shhwtstamps)); > shhwtstamps->hwtstamp = ns_to_ktime(ns); > > Then if we need to save a munged *ns then we can do this at the end: > > /* we need this because blah blah blah */ > *period = (__le64)ns; > [Y.b. Lu] You're right. I will modify the code according to your suggestion. > > > + memset(shhwtstamps, 0, sizeof(*shhwtstamps)); > > + shhwtstamps->hwtstamp = ns_to_ktime(*ns); > > + } > > + > > /* Check if we need to validate the L4 csum */ > > if (likely(dpaa2_fd_get_frc(fd) & DPAA2_FD_FRC_FASV)) { > > status = le32_to_cpu(fas->status); > > [ snip ] > > > @@ -520,6 +561,19 @@ static void free_tx_fd(const struct dpaa2_eth_priv > *priv, > > return; > > } > > > > + /* Get the timestamp value */ > > + if (priv->ts_tx_en && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) { > > + struct skb_shared_hwtstamps shhwtstamps; > > + u64 *ns; > > + > > + memset(&shhwtstamps, 0, sizeof(shhwtstamps)); > > + > > + ns = dpaa2_get_ts(skbh, true); > > + *ns = DPAA2_PTP_NOMINAL_FREQ_PERIOD_NS * le64_to_cpup(ns); > > + shhwtstamps.hwtstamp = ns_to_ktime(*ns); > > + skb_tstamp_tx(skb, &shhwtstamps); > > Sparse issues here also. [Y.b. Lu] Will modify the code according to your suggestion. > > > + } > > + > > /* Free SGT buffer allocated on tx */ > > if (fd_format != dpaa2_fd_single) > > skb_free_frag(skbh); > > @@ -552,6 +606,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff > *skb, struct net_device *net_dev) > > goto err_alloc_headroom; > > } > > percpu_extras->tx_reallocs++; > > + > > + if (skb->sk) > > + skb_set_owner_w(ns, skb->sk); > > Is this really related? (I have not looked at this code). [Y.b. Lu] Yes. The skb_tstamp_tx() function will check that. > > > + > > dev_kfree_skb(skb); > > skb = ns; > > } > > [ snip ] > > > @@ -319,6 +351,9 @@ struct dpaa2_eth_priv { > > u16 bpid; > > struct iommu_domain *iommu_domain; > > > > + bool ts_tx_en; /* Tx timestamping enabled */ > > + bool ts_rx_en; /* Rx timestamping enabled */ > > These variable names are not great. I wouldn't have understood "ts_" > without the comment. "tx_" is good. "en" is confusing until you read the > comment. But really it should just be left out because "enable" is assumed, > generally. Last week I asked someone to rewrite a patch that had a _disable > variable because negative variables lead to double negatives which screw with > my tiny head. > > if (blah_disable != 0) { > > OH MY BLASTED WORD MY BRIAN ESPLODED!!!1! > > So let's just name these "tx_timestamps" or something. [Y.b. Lu] Ok. Let me use tx_tstamp/rx_tstamp instead. The tstamp is common used in driver. > > > > + > > u16 tx_qdid; > > u16 rx_buf_align; > > struct fsl_mc_io *mc_io; > > regards, > dan carpenter
next prev parent reply other threads:[~2018-04-26 10:17 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-04-25 9:17 [PATCH] staging: fsl-dpaa2/eth: Add support for hardware timestamping Yangbo Lu 2018-04-25 10:03 ` Dan Carpenter 2018-04-26 10:17 ` Y.b. Lu [this message] 2018-04-26 2:33 ` Richard Cochran 2018-04-26 10:22 ` Y.b. Lu
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=DB6PR0401MB25361EE5633F24AA34F0063CF88E0@DB6PR0401MB2536.eurprd04.prod.outlook.com \ --to=yangbo.lu@nxp.com \ --cc=dan.carpenter@oracle.com \ --cc=devel@driverdev.osuosl.org \ --cc=gregkh@linuxfoundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=richardcochran@gmail.com \ --cc=ruxandra.radulescu@nxp.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: linkBe 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).