Received: by 10.192.165.148 with SMTP id m20csp495594imm; Wed, 25 Apr 2018 03:05:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqeOIs+dznU1pfxRc04KRH9h2l9p0ruOU9bvQqEqm/GnbApjBdIluDykiSDf8G4D4WEbvyc X-Received: by 2002:a17:902:ab83:: with SMTP id f3-v6mr7599380plr.344.1524650741812; Wed, 25 Apr 2018 03:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524650741; cv=none; d=google.com; s=arc-20160816; b=tgxMWyO7qR0BtBgKNrJv1uxX8qkr5SXTBdU1y8fRhs9Gw2JBXkLmQY9U2XKz4X+IkE z4HHdNcQegHnxtgh4JeaaCI7RBl7yqxgvnZiqCUY4Intw3Ju0uUALwmA9vt8zUvNlQ0E odAYtLhcN+XRuYbA/7cPWsMUPdy9dfU0o/iIFl2puJjHt7bPRoHSEfH1IuefZYIqGae9 ajxNbHdXCPzlIxsSz/ylzHh8nP4vGkcunURKHGpVDDKqAPxnjT88gFC0ipy0Q0a6aA0v xtJzMT5l4ZGu7y04l+o8xKqrch20Y1iOlbvWbp6uZ1imUlK7e2OOo89MEYY7QnLFYvHN 6CtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=GR3IxuUcjIgOpVQuwMVNZEFlHOwgYuEA2Bbg19BRVvA=; b=FwA+V5OcEN+6KU+j3TkjojtXgwu71DHQfLXLLe4vW/f7mDCMbEGSDjNBh2PoUwmiTv XOsVsdTVxCb2uoSpKrCokGpi6jorGO8zFLefh/4agwkwUzG9jREFu1zlHJcvRUbI3aMY bqSjzX3UpzwhtkKdcK+3miTQRCL0QJutgivJmPRFogKGj0L3S9fuIpNOlc9vb09JcZWd WSzlHOixLoLD8uXLkPmNV55IeHO9mPJUeVoC7vNsD+DYcLN+ckzTyVIJA/2apEncUpYZ 4shSqEc5R4oeDrS6LJgGhqRp44p2Ao6Rt6yCWjpQY44i2ztg6olUdfaTwtjq9i/RwGpM 282g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=l5LV8oOW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si347138pgw.578.2018.04.25.03.05.27; Wed, 25 Apr 2018 03:05:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=l5LV8oOW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751696AbeDYKEH (ORCPT + 99 others); Wed, 25 Apr 2018 06:04:07 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49470 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbeDYKED (ORCPT ); Wed, 25 Apr 2018 06:04:03 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3PA1U1T094848; Wed, 25 Apr 2018 10:03:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=GR3IxuUcjIgOpVQuwMVNZEFlHOwgYuEA2Bbg19BRVvA=; b=l5LV8oOWTXcZJHkBKp3dxEtp6DEsZsu65HZr/+ejFxxozbjIUCvvnpifkSJywG0Hlie0 7ax3wAayTBisP2RO29AEue0U/gxyiCZm4uluQZrlEtW3+rRh1r0El/Igoa2TgqsUThfN vu0WtsqQ9/sTY+w9WPtgkIFBGTDZp49lzm2wR+zPwp09bKTJRaPk9bQXkiesgJaI+XOn 99D/WMOYFEfJnTrbIZiAJhfYCOm/uV6GkGe7Gp2Qewxgk0jHqkkTLFYSH64ZK8Ep1rCw 3P+q5XcdcEfH3rTS70Py927XM7aCOSut5huRybxUy9dn1w5h0UdT8SIwmG2mIjykg8q2 3A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2hfw9adsyw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Apr 2018 10:03:54 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3PA3rWx013719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Apr 2018 10:03:53 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3PA3q1C007143; Wed, 25 Apr 2018 10:03:53 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Apr 2018 03:03:52 -0700 Date: Wed, 25 Apr 2018 13:03:45 +0300 From: Dan Carpenter To: Yangbo Lu Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Richard Cochran , Ioana Radulescu Subject: Re: [PATCH] staging: fsl-dpaa2/eth: Add support for hardware timestamping Message-ID: <20180425100345.b5oxgdjyud7t6kzc@mwanda> References: <20180425091749.46841-1-yangbo.lu@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180425091749.46841-1-yangbo.lu@nxp.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8873 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804250093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > + 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. > + } > + > /* 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). > + > 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. > + > u16 tx_qdid; > u16 rx_buf_align; > struct fsl_mc_io *mc_io; regards, dan carpenter