From patchwork Thu Nov 14 18:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Yhgj/vq+"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVlx2PvJz9sQp for ; Fri, 15 Nov 2019 05:45:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E3020882C7; Thu, 14 Nov 2019 18:45:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9Sv-_6Ai9ALe; Thu, 14 Nov 2019 18:45:13 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 59639882BE; Thu, 14 Nov 2019 18:45:13 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 6C6F51BF289 for ; Thu, 14 Nov 2019 18:45:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6902022849 for ; Thu, 14 Nov 2019 18:45:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YldmQdiin-hs for ; Thu, 14 Nov 2019 18:45:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by silver.osuosl.org (Postfix) with ESMTPS id 78F81204C8 for ; Thu, 14 Nov 2019 18:45:11 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id z24so4352430pgu.4 for ; Thu, 14 Nov 2019 10:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8TxLlnJ4BoD9B2pwZqmboySs4KscSO6XXXhYyisKwIU=; b=Yhgj/vq+K/+BgF6v37h/l60TDGEItYnX6OCRofzkA61wbx49rVsGKH+4YsuHT2Uhnp 4QpbcgT1wxH4xljcubgW+/bugWjNhDnNs+2gkJ2KTbc+Ei0sZYtYF4c8FK5Yl8U+uJaB G4KL+ATeMI5EFBbLr1HIFt0bE3yEfFN6BQkwQQZ30ww9FSJFrVx/o/+Nqoz7E9kQNQjK g7t4PFtSI2VgBFCmolQFS9rWrcy8bwypgG63oBwvE70CJ4greNJgg0fpu9XJuH7Bh8AB BzPosknm+rZTNH475+KpvoRmLpmDbrHeqqoixq0Lv0LkSnZy0KZRPHIYr83AXVB2IRk/ N4vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8TxLlnJ4BoD9B2pwZqmboySs4KscSO6XXXhYyisKwIU=; b=G/Tyvkb3vpsRnX6juEL2bqvnNdUHkB61i9QEGfxqMLIzkF0pkMkommvnJ7xbRkJvAK DjYoMAJY3/06LURmOcctm2eDMDrTqRyWIz3psDV4dEexC9EEuvOKwh4s87+XjR5JK6L6 klohCwMSaxCMco2P5iKKbdbNcX/uciqyVEiXG6DFCdDpeRc51TdzmLAK77RCPaX1nMTV HFQrHFXUgWwSyblkIP0JAeIhIB3tBEs6dx8wzIfS9b50As7H6Y06G4WYUvu52gveRBog /U/92+7Ttz4HZ8IQVRsg0048iIzPaCD0dnH0f0eymHHKZ2CtXwasWqMS75WH07zdwysk aSAQ== X-Gm-Message-State: APjAAAWLhThVojxKFJDCLsY8clj94lq3SostwMTaDqed6Xx2/2RP/4mW eMqJoleoNnYsoMrki472JeI= X-Google-Smtp-Source: APXvYqwdUBwNxm3Oy7UhcAMIgUJqoM+tDDV+OBw4iaOzMUqv+8BqU++lw7P+Laz3rFiRtH1VW7yWXw== X-Received: by 2002:a63:4d12:: with SMTP id a18mr11506093pgb.451.1573757110991; Thu, 14 Nov 2019 10:45:10 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:10 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:44:55 -0800 Message-Id: <20191114184507.18937-2-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 01/13] ptp: Validate requests to enable time stamping of external signals. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Commit 415606588c61 ("PTP: introduce new versions of IOCTLs") introduced a new external time stamp ioctl that validates the flags. This patch extends the validation to ensure that at least one rising or falling edge flag is set when enabling external time stamps. Signed-off-by: Richard Cochran --- drivers/ptp/ptp_chardev.c | 18 +++++++++++++----- include/uapi/linux/ptp_clock.h | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index 67d0199840fd..cbbe1237ff8d 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -149,11 +149,19 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) err = -EFAULT; break; } - if (((req.extts.flags & ~PTP_EXTTS_VALID_FLAGS) || - req.extts.rsv[0] || req.extts.rsv[1]) && - cmd == PTP_EXTTS_REQUEST2) { - err = -EINVAL; - break; + if (cmd == PTP_EXTTS_REQUEST2) { + /* Make sure no reserved bit is set. */ + if ((req.extts.flags & ~PTP_EXTTS_VALID_FLAGS) || + req.extts.rsv[0] || req.extts.rsv[1]) { + err = -EINVAL; + break; + } + /* Ensure one of the rising/falling edge bits is set. */ + if ((req.extts.flags & PTP_ENABLE_FEATURE) && + (req.extts.flags & PTP_EXTTS_EDGES) == 0) { + err = -EINVAL; + break; + } } else if (cmd == PTP_EXTTS_REQUEST) { req.extts.flags &= PTP_EXTTS_V1_VALID_FLAGS; req.extts.rsv[0] = 0; diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h index 59e89a1bc3bb..304059b1609d 100644 --- a/include/uapi/linux/ptp_clock.h +++ b/include/uapi/linux/ptp_clock.h @@ -31,6 +31,7 @@ #define PTP_ENABLE_FEATURE (1<<0) #define PTP_RISING_EDGE (1<<1) #define PTP_FALLING_EDGE (1<<2) +#define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE) /* * flag fields valid for the new PTP_EXTTS_REQUEST2 ioctl. From patchwork Thu Nov 14 18:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PR+007x9"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVlz40f9z9sR5 for ; Fri, 15 Nov 2019 05:45:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id CEB2A204F5; Thu, 14 Nov 2019 18:45:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SuWEZezsApKO; Thu, 14 Nov 2019 18:45:15 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 9ECB321543; Thu, 14 Nov 2019 18:45:15 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 5D7DC1BF289 for ; Thu, 14 Nov 2019 18:45:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5955C21543 for ; Thu, 14 Nov 2019 18:45:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J+43p09DR6nE for ; Thu, 14 Nov 2019 18:45:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by silver.osuosl.org (Postfix) with ESMTPS id F0353204C8 for ; Thu, 14 Nov 2019 18:45:12 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id 15so4339944pgt.7 for ; Thu, 14 Nov 2019 10:45:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z+UNW9RTqPu3T1gTax5uZNwqLIoODkDfS7V+zmu+zvg=; b=PR+007x9ZRbsMnCbY0Pqm9sa4glZfBmTZjjAcWxuqaiJoF1Fa6hgSi/KxVJQ77q9vL XlGd91pcpcPBY1SdFMmTO5Bbr6hxpJMhIIoW7SF4dPGlLjwVLkowsKWz9XBrjHvv+n/7 Bkq9bDI+k8nHo0p2bIGAC+0qYeVakGEYBr6gdPC9CJcOhtFEwq3HtRdd+lc1qytyACe7 Vh3s4XCKF2+caDp1lV41w8p0qhbv5fXRtJACg20KJspHUs9PqF1qloDkQjOr2eX4IdaU lM43nnaTZ9wrxvUdx8HuG/0Fh8gcH/pVWFzO4ye3KNptd5MzmwMBJr24fVmEav5Ae9qq qXWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z+UNW9RTqPu3T1gTax5uZNwqLIoODkDfS7V+zmu+zvg=; b=dq1phBqo7sEs1H9v7vIkTy7cNQ0MZr8gDQ+eNZQSd1CQxQJdu01BZDVh36uHnpNvMj 0k3Ji8vcHAsOxfA38NpXcaWVnJyhX1l2WhSFIaE1Oz/zfkT/YRrTMWFwgDrKbxkegy8j 4Cp04O3jaED6whbRFux7rlLiaS5SyweSk1OOWwGBBJ8KyTLnQRzmS5QhKSHOxy9P93Nw Lxcho50bysvsT3UDZeod+o32Q/guTC+bPOb0RQex6CRex3x8DIAd2mPGamslAA7K54vd OR+XhORb7E4NSiVoIhh30UJxmyjrKPn6xW3OWUKx99XhGKUGE43Ae827a51v/Z1ulfVc BRDw== X-Gm-Message-State: APjAAAXNNyZR0IHa4PlMwRBIDEfWdvXOKBmgBbdkyTj31YwMkgmhqI5r PZ8whlwvNMVp7j/itDUkRXCbqBlI X-Google-Smtp-Source: APXvYqxGwNcbi0fDj61FGKMWWQ86GkM6Yuwf37wlDl54Jq8YFICgenQ23oVxP91PXyvf3ZUhArluPA== X-Received: by 2002:a63:e84f:: with SMTP id a15mr11789853pgk.309.1573757112515; Thu, 14 Nov 2019 10:45:12 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:11 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:44:56 -0800 Message-Id: <20191114184507.18937-3-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 02/13] net: reject PTP periodic output requests with unsupported flags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Commit 823eb2a3c4c7 ("PTP: add support for one-shot output") introduced a new flag for the PTP periodic output request ioctl. This flag is not currently supported by any driver. Fix all drivers which implement the periodic output request ioctl to explicitly reject any request with flags they do not understand. This ensures that the driver does not accidentally misinterpret the PTP_PEROUT_ONE_SHOT flag, or any new flag introduced in the future. This is important for forward compatibility: if a new flag is introduced, the driver should reject requests to enable the flag until the driver has actually been modified to support the flag in question. Cc: Felipe Balbi Cc: David S. Miller Cc: Christopher Hall Signed-off-by: Jacob Keller Signed-off-by: Richard Cochran Tested-by: Aaron Brown Reviewed-by: Saeed Mahameed --- drivers/net/ethernet/broadcom/tg3.c | 4 ++++ drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 4 ++++ drivers/net/ethernet/microchip/lan743x_ptp.c | 4 ++++ drivers/net/ethernet/renesas/ravb_ptp.c | 4 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 4 ++++ drivers/net/phy/dp83640.c | 3 +++ 7 files changed, 27 insertions(+) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 77f3511b97de..ca3aa1250dd1 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -6280,6 +6280,10 @@ static int tg3_ptp_enable(struct ptp_clock_info *ptp, switch (rq->type) { case PTP_CLK_REQ_PEROUT: + /* Reject requests with unsupported flags */ + if (rq->perout.flags) + return -EOPNOTSUPP; + if (rq->perout.index != 0) return -EINVAL; diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index fd3071f55bd3..4997963149f6 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -551,6 +551,10 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp, return 0; case PTP_CLK_REQ_PEROUT: + /* Reject requests with unsupported flags */ + if (rq->perout.flags) + return -EOPNOTSUPP; + if (on) { pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT, rq->perout.index); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 0059b290e095..cff6b60de304 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -290,6 +290,10 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp, if (!MLX5_PPS_CAP(mdev)) return -EOPNOTSUPP; + /* Reject requests with unsupported flags */ + if (rq->perout.flags) + return -EOPNOTSUPP; + if (rq->perout.index >= clock->ptp_info.n_pins) return -EINVAL; diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c index 57b26c2acf87..e8fe9a90fe4f 100644 --- a/drivers/net/ethernet/microchip/lan743x_ptp.c +++ b/drivers/net/ethernet/microchip/lan743x_ptp.c @@ -429,6 +429,10 @@ static int lan743x_ptp_perout(struct lan743x_adapter *adapter, int on, int pulse_width = 0; int perout_bit = 0; + /* Reject requests with unsupported flags */ + if (perout->flags) + return -EOPNOTSUPP; + if (!on) { lan743x_ptp_perout_off(adapter); return 0; diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c index 9a42580693cb..638f1fc2166f 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -211,6 +211,10 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp, unsigned long flags; int error = 0; + /* Reject requests with unsupported flags */ + if (req->flags) + return -EOPNOTSUPP; + if (req->index) return -EINVAL; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index df638b18b72c..0989e2bb6ee3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -140,6 +140,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp, switch (rq->type) { case PTP_CLK_REQ_PEROUT: + /* Reject requests with unsupported flags */ + if (rq->perout.flags) + return -EOPNOTSUPP; + cfg = &priv->pps[rq->perout.index]; cfg->start.tv_sec = rq->perout.start.sec; diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 6580094161a9..04ad77758920 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -491,6 +491,9 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp, return 0; case PTP_CLK_REQ_PEROUT: + /* Reject requests with unsupported flags */ + if (rq->perout.flags) + return -EOPNOTSUPP; if (rq->perout.index >= N_PER_OUT) return -EINVAL; return periodic_output(clock, rq, on, rq->perout.index); From patchwork Thu Nov 14 18:44:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HmCxMPjY"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVly2N27z9sQy for ; Fri, 15 Nov 2019 05:45:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A2801882BC; Thu, 14 Nov 2019 18:45:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C5Z3sTllW8Am; Thu, 14 Nov 2019 18:45:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1CAAD882CE; Thu, 14 Nov 2019 18:45:16 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id ED7AC1BF289 for ; Thu, 14 Nov 2019 18:45:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E9DD689168 for ; Thu, 14 Nov 2019 18:45:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AAdO2o1E6YHf for ; Thu, 14 Nov 2019 18:45:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5787B89153 for ; Thu, 14 Nov 2019 18:45:14 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id k13so4350095pgh.3 for ; Thu, 14 Nov 2019 10:45:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UJweYauEUzN1el5H7+jNKGxHUTrlFVlLLYMrPDFTPrw=; b=HmCxMPjYWo4iAoeAvkA0YrUNRCfDp1kQAfnh91Fp3uRWxaBE8edhI5L0TDjakPMYzV BrPSnGSnpa3jJwgggdbsPyazW2K26o2sJNohfKsVpf5zzr5ljGrOfaTNzonfZ7/oK/bs QuEdvxPcckNhDFqVg/yFdW4oTyA1V+6NLziwdH40RObMg/CDDFiZYLTCHvo8A7ZHQ0P1 ULIScUZc89s9Z/ial9FcSnpjLnRVcV2vOsVoJaLaOo5ALiRcuv0K+dUcD6dUkcBZiIST kf25itJeHboIZnhkHRDHzcA7W1KCXMMh4Sj6s8SQFdCPiDbSfHz+MXOQkbXaXUXcmgB7 rwSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UJweYauEUzN1el5H7+jNKGxHUTrlFVlLLYMrPDFTPrw=; b=fG/VeY5IF2XztyKMZtelKfIjecYJrms5pTKsxDpGes5n2gQA89QIpjfcIH65WmKexV /ch8AK4PRKoHb30sGL59ezwUSAjHZ0qxf9bznV2GsEz2UohxKJAjwGLVMqqcvO/3hiUl b7ViAYdyQW3aabunbGqsMYdTDx19O1kiJV+buSvcKkIUCneMy35XUA14IykBusinNucw wOtsB3iHS3VjmfYPzq7AWlnpdpnCmXlgwfyuU2DKlRYdN/xqODYtzMEMuvghyH4oiTRX 30KG3BVHR8Q3Q/3SLiVGuIXXUfVxckV26b59JyIg7QnMI7ex9lRy7ynN3QDnvXgjyBfw 2u2g== X-Gm-Message-State: APjAAAVV8FNiBYLmDh2iHBaxVXcX6Xw/3xWPh4JSoF4BS5yBY7nx5QH2 rhyDMsS1lQdaMjDQNg1gXHM= X-Google-Smtp-Source: APXvYqzS8fKT7yamtldHOoBnAh+S2ZqlWam+5y5daaHTtrUwTXblAXw1esOngPaDfBJCQHEfoTdLFQ== X-Received: by 2002:a65:678a:: with SMTP id e10mr11686445pgr.258.1573757113982; Thu, 14 Nov 2019 10:45:13 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:13 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:44:57 -0800 Message-Id: <20191114184507.18937-4-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 03/13] mv88e6xxx: reject unsupported external timestamp flags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Fix the mv88e6xxx PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl. In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently. For the record, the semantics of this driver are: flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp rising edge Cc: Brandon Streiff Signed-off-by: Jacob Keller Reviewed-by: Richard Cochran --- drivers/net/dsa/mv88e6xxx/ptp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/ptp.c b/drivers/net/dsa/mv88e6xxx/ptp.c index 073cbd0bb91b..076e622a64d6 100644 --- a/drivers/net/dsa/mv88e6xxx/ptp.c +++ b/drivers/net/dsa/mv88e6xxx/ptp.c @@ -273,6 +273,12 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip, int pin; int err; + /* Reject requests with unsupported flags */ + if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE)) + return -EOPNOTSUPP; + pin = ptp_find_pin(chip->ptp_clock, PTP_PF_EXTTS, rq->extts.index); if (pin < 0) From patchwork Thu Nov 14 18:44:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cPhBmbId"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVm03r2vz9sQw for ; Fri, 15 Nov 2019 05:45:20 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1AD4689C95; Thu, 14 Nov 2019 18:45:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yQa2rOnfCDTM; Thu, 14 Nov 2019 18:45:18 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 7214589C8B; Thu, 14 Nov 2019 18:45:18 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 9911F1BF289 for ; Thu, 14 Nov 2019 18:45:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8F6CA882E0 for ; Thu, 14 Nov 2019 18:45:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1e3OU3LievgE for ; Thu, 14 Nov 2019 18:45:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by fraxinus.osuosl.org (Postfix) with ESMTPS id E1A56882BC for ; Thu, 14 Nov 2019 18:45:15 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id j12so3019737plt.9 for ; Thu, 14 Nov 2019 10:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=y5PpCROqLUVCSPUX0tvoqkWmvSCrAux1rzZqUUXzDoo=; b=cPhBmbIdmtQyfQF5AzbqYAvH2xoRj/40g6d2qV5pdY0c1+x9QJjtVhWv32MQqPBmNc Sk6GtuGCYW8VDpn/EN2UxzavB3UQ97D36VdcOf+oVrOKj8VG6hJUtXZo7kYhh/Y8TFKn E2uKmuVao6l+yWztnczXHEXRQt/NKrdxorFH7K+nk19Obb34h7PhMpC2hk6ewz8CAMxW Oc1q41H87UAMM/EpVkDyJAbTMcE1/bIjmru0tVvXGVBnd/vbvQwcp4UR+DE4Os4Rfq37 fStGwklceIwevHB10wpqPsz8vj6wfNcplYtGBWKOGQiowq1zh9MttEduJM2LX+jcC9Lw 7VUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=y5PpCROqLUVCSPUX0tvoqkWmvSCrAux1rzZqUUXzDoo=; b=FA2c7gqqKZYoPq2QS7mj48LSRDU7M6eGFXGrYn4IUzBP8h7ONA3kuXZV9EKYrJ7aPG iXqbnEo2doEJgJvM9uU6JPkv0IQK5zyNTKxaRWXtDTnBjHg/2A3OX14+rQnYMbFvMIfu eoOBBq4AUxnZ0Hv8JPfpIVwKXWKFvdM8oGGrY/F9VZbV7qlDdE8mQ3WovuSasJ95hvhX H38+g6ML9pQUjgLSj9Ff0/bV6du6Cljw8W8lo4CWx4Pzq0Ctoh4M786QYNfTaRZXg0li CRjgPaS9GtJmM1f90JTQwhtQ8Y/zFpnbuIMogCxX9bae+ebjYeUpB3SbzJ5U9c0l+dEw 8w0w== X-Gm-Message-State: APjAAAXf8agxhvE0W5MDMwAQGFRlweG0Is1L8uwg/37zesDoWrjlJfNs iYzL1EnNoHJAJ576jVjdxFE= X-Google-Smtp-Source: APXvYqxwXzvhDmITW4QOWmuk5/jUBwai9RuM5ACXa/w6RYjVf9/qTI18CLm1V501Va+erWE2fXAFHA== X-Received: by 2002:a17:902:6a88:: with SMTP id n8mr637917plk.226.1573757115373; Thu, 14 Nov 2019 10:45:15 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:14 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:44:58 -0800 Message-Id: <20191114184507.18937-5-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 04/13] dp83640: reject unsupported external timestamp flags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Fix the dp83640 PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl. In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently. For the record, the semantics of this driver are: flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp falling edge Cc: Stefan Sørensen Cc: Richard Cochran Signed-off-by: Jacob Keller Reviewed-by: Richard Cochran --- drivers/net/phy/dp83640.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 04ad77758920..2781b0e2d947 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -469,6 +469,11 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp, switch (rq->type) { case PTP_CLK_REQ_EXTTS: + /* Reject requests with unsupported flags */ + if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE)) + return -EOPNOTSUPP; index = rq->extts.index; if (index >= N_EXT_TS) return -EINVAL; From patchwork Thu Nov 14 18:44:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Jx6Bgr7O"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVm128p6z9sR6 for ; Fri, 15 Nov 2019 05:45:21 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D501F89C92; Thu, 14 Nov 2019 18:45:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RACOPSXg9WjG; Thu, 14 Nov 2019 18:45:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 1A5D789C94; Thu, 14 Nov 2019 18:45:19 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id CB2411BF289 for ; Thu, 14 Nov 2019 18:45:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B942B89C8B for ; Thu, 14 Nov 2019 18:45:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U+FB9nDMkxi3 for ; Thu, 14 Nov 2019 18:45:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by hemlock.osuosl.org (Postfix) with ESMTPS id 3E7B889C87 for ; Thu, 14 Nov 2019 18:45:17 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id 193so4841392pfc.13 for ; Thu, 14 Nov 2019 10:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=v+ExKxfOT/Th93uAzKkGBPLkIVwaHS47X1LnIewKNKg=; b=Jx6Bgr7OwiyBrv9XwlgAsSg8fB3hGAJCkT+4nsx1I465GEmLhT1sx5CIbDJSvTaIuB rV40GkylC3E799Myh/jc1xnkP1is3JgGj9nx3thE8NwTfrLMn9lhNpPgYhi0HtUeTZ8o E31SPEoKaDSdlNTsTx+WO5Ya7twx45q1Nv+avQHMWf2B1zFViED/aQqpSqqWgLe79iTu fOTUxXSwEGLJbtLucVMN97twZZ3Myl47Fee4wdAK8bKph9Da8wDlf7odPiLEUCWTZfKN PboF1q2ZtOyGE9R1TvXvJ2EdR+otMhYBLM9D1LXZZ9T4544e8JJEoidmEVdxBKoEXacp q7dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=v+ExKxfOT/Th93uAzKkGBPLkIVwaHS47X1LnIewKNKg=; b=j089wMxok8k37H+Mx+AhCELxE/0MK9qs1x+HXx/TxnUBnOT7lTuvdavI3SUOxbvHpV srUUWMN+6emlTR1begdE/RHvOkrNozPELN5pGhjDa4BYasRMauNMetVV2ycBmGmuRkyT JTE9sMhJ7ohrNu6xYQeL0b+KNsLQhrliqgQx0QeOKlSR0auF3Rd+kERJCgu+OBDuK3EW 0ABjGiyh7bP13vTPLRLFJYNT/CwDdm6Fj1QsSOA945j3UwtYvA+suNa+8mubRN0j78LP ljBMtc1Rdu3oMTVRPsYD4oIL6TedCv+c+C3z4GbPqyRBmeyatIgNUTjKWKzlh0hbBtAj ooew== X-Gm-Message-State: APjAAAVVYZZNvzpSuzK11qbi6zjSmORtE5ZhSQYEWHuYusalSld4b+rv F0B37/B16WMEjAw7E2IYgNP0eiO5 X-Google-Smtp-Source: APXvYqx3b14oHrv5YzdxYBi25JaKUfo00uMLj9uVDs6L3mpvlGNoXso0STPsIC//nadxvp49vaY45w== X-Received: by 2002:a63:d901:: with SMTP id r1mr11706173pgg.328.1573757116811; Thu, 14 Nov 2019 10:45:16 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:16 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:44:59 -0800 Message-Id: <20191114184507.18937-6-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 05/13] igb: reject unsupported external timestamp flags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Fix the igb PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl. In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently. This HW always time stamps both edges: flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp both edges PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp both edges PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp both edges PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp both edges Signed-off-by: Jacob Keller Tested-by: Aaron Brown --- drivers/net/ethernet/intel/igb/igb_ptp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 4997963149f6..0bce3e0f1af0 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -521,6 +521,12 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp, switch (rq->type) { case PTP_CLK_REQ_EXTTS: + /* Reject requests with unsupported flags */ + if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE)) + return -EOPNOTSUPP; + if (on) { pin = ptp_find_pin(igb->ptp_clock, PTP_PF_EXTTS, rq->extts.index); From patchwork Thu Nov 14 18:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UF7sT9Hu"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVm35gD1z9sPk for ; Fri, 15 Nov 2019 05:45:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C8851882CC; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nXXu_E_vBaVG; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 44DAB882BE; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 97D611BF289 for ; Thu, 14 Nov 2019 18:45:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8B8492326C for ; Thu, 14 Nov 2019 18:45:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IsKg73r+3Rsx for ; Thu, 14 Nov 2019 18:45:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by silver.osuosl.org (Postfix) with ESMTPS id DA318204C8 for ; Thu, 14 Nov 2019 18:45:18 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id bb5so3032059plb.4 for ; Thu, 14 Nov 2019 10:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vsKoGi0FAC/KrsCxzqHSC+UAZbZLyyk3Sb9n5a/c8+M=; b=UF7sT9Huk8CwaoJ/o40DDCTT/XQXjkRS/Kkm9BTkDPq++KwOvvi7SjA3kI4g1gV//E 8zyDRdmJcBKoEwbeZFLPX+ZWyeMO9Cgn7ASWB8f8qTEGJB/MR4xc8JfTbqhu/u71ydRo bMrjIqT4CQ7a7pwFX0QyUXEyWeC/RQg7200s9OY7X4zPlnMqMLPKxABcttFK1hOL5NnC KiodeB6VYv4LEiBiDk+KbKpy45MPT5G+PzU/rXv18b+75ZGmvhyJKjEsJtIKRRJSzm5+ l2IdXNpUvOs2ig0EuIcNIcvjn8mKWySh3g7VQ+MAkWyZsx8AVe/UTtbieL3eLjtS/5yN AjGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vsKoGi0FAC/KrsCxzqHSC+UAZbZLyyk3Sb9n5a/c8+M=; b=LIQ3Fx1Z3iX9swd+0QrLeMMPkRv3YLfrxk24ku4IFvCrrDVBP35QLRlmDP0bB71D4a cziQH27A6Oh2Hi0pBnwHG3Z4ksJ/PmVPJk8/oktTQ5hY4eljak6SxruvwmEnEw5FJdLW L3QDoWZZydha9Y0xg0pw7UW/M1M4a7t7XU89hMzQUhbk0/P86G9FZpqbPioQvSwVa2Ve F+mLD6FYJ5SiYE1YIxSg6YGcDRMNwv2UjCLVVUhCS1437BZ5+O9IdCO791yptD8pbMol dRKq4CUmPiSRCltfvP7o4lB5DiEySiSrD3ZbsynkvaOSbspnQZwQ8ueFjxnvIz6lhFTl sEUg== X-Gm-Message-State: APjAAAVOJQW/Mdqg/YemV7pBelGMJQohIHAyOybFGhetWgv/1CrGfi4I CVnoyi5R2rW/axlS0Xp3uOc= X-Google-Smtp-Source: APXvYqwhciTpKJzbRyHRYFGGedeC3yTKw8ODZa10zfyFovb9ZxO8M1O59zcAlG4HNhdnokF2i5QCYg== X-Received: by 2002:a17:902:b702:: with SMTP id d2mr11057777pls.104.1573757118249; Thu, 14 Nov 2019 10:45:18 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:17 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:00 -0800 Message-Id: <20191114184507.18937-7-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 06/13] mlx5: reject unsupported external timestamp flags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Fix the mlx5 core PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl. In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently. [ RC: I'm not 100% sure what this driver does, but if I'm not wrong it follows the dp83640: flags Meaning ---------------------------------------------------- -------------------------- PTP_ENABLE_FEATURE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE Time stamp rising edge PTP_ENABLE_FEATURE|PTP_FALLING_EDGE Time stamp falling edge PTP_ENABLE_FEATURE|PTP_RISING_EDGE|PTP_FALLING_EDGE Time stamp falling edge ] Cc: Feras Daoud Cc: Eugenia Emantayev Signed-off-by: Jacob Keller Reviewed-by: Richard Cochran Reviewed-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index cff6b60de304..9a40f24e3193 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -236,6 +236,12 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp, if (!MLX5_PPS_CAP(mdev)) return -EOPNOTSUPP; + /* Reject requests with unsupported flags */ + if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE)) + return -EOPNOTSUPP; + if (rq->extts.index >= clock->ptp_info.n_pins) return -EINVAL; From patchwork Thu Nov 14 18:45:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AlEKTmOx"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVm40hw2z9sQp for ; Fri, 15 Nov 2019 05:45:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 86E8F20520; Thu, 14 Nov 2019 18:45:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sRT1B9Z3K1W9; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 899B522849; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 8F7831BF289 for ; Thu, 14 Nov 2019 18:45:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8B088882C2 for ; Thu, 14 Nov 2019 18:45:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q54mH3A0FOny for ; Thu, 14 Nov 2019 18:45:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 0DCCE882BE for ; Thu, 14 Nov 2019 18:45:20 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id z4so4847427pfn.12 for ; Thu, 14 Nov 2019 10:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xN6Ff/rEmda33ktJVzl9KCXqa8Sx0iaIjbPXMuf+NBQ=; b=AlEKTmOxNzExN9wdwBJvmv0HnbxXq1IGPPAOjrul0f//SeZAyapcuM+wRs24y3ZSfJ N146GR1cZ5+UBaUA2yGMWpQZ4x3dD31x4WG93L34XXvtjSng4ZWYZVitWj53MvFlSCml NYVbAHg6RkS6z2BOwCv/hUA5fGn0JOFY8tvv/VDBdhHFRJPeZxVyJzpD7kZF1LlCt/F4 uIL2Z8Uo+geC/x/dUQdwJ8lB23Wqypbn2AEXSCnlulaZp8sJ6bJVcd9FHFZ27IglZH32 lyholkefIYZEkqBz56FfeRjNL+UsNakB+6klomVEldPPZumS3tyvQH4W321erYo3iH4T 1xgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xN6Ff/rEmda33ktJVzl9KCXqa8Sx0iaIjbPXMuf+NBQ=; b=G9spCJwDG65IGGEgB911pFcOPxmn2M7KoTUIIDDMYDl9l73SkT8/RZXqD2qBFRgjvh xRbVXwKsaELJwV8wOrWXJkCWL1ioYbKv4w9iqXq5asdtV88nEm8mAmuJk78yjQvPVRQy 1qnYy21oN2jcj1zinDhtnjqkUdiI++A4KG8Jcyt7NAxgzaLR2R1aV/763xf+TUr4vS9+ zM1slq/Qbyf4djn6SPbrpWvRPNM+HDJpRlYofHvOjZHsG9FgV3rNlGPA3jVh1VF4tv/7 qnPplxVPdIvxJi3dl4A39/QVjKyQ/EYWqb3BdroFaxRqPwGp/dalb5akFyV8BL8HaTtI hq/Q== X-Gm-Message-State: APjAAAUaydJ6ZuOzKB6oBdV193kkWDSot+z2ndFgfHB1bTTKZlZnO+V1 oGkT9ORHk0o4BjrAInN1+hzVM01N X-Google-Smtp-Source: APXvYqyDM6CBaERu9pdWS5TIezYmH40TxWm+Pok5B/6Lxu+q5I4mi1XpJkzUaRDheD35nYOcra1FHg== X-Received: by 2002:aa7:9432:: with SMTP id y18mr913814pfo.250.1573757119716; Thu, 14 Nov 2019 10:45:19 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:19 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:01 -0800 Message-Id: <20191114184507.18937-8-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 07/13] renesas: reject unsupported external timestamp flags X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Jacob Keller Fix the renesas PTP support to explicitly reject any future flags that get added to the external timestamp request ioctl. In order to maintain currently functioning code, this patch accepts all three current flags. This is because the PTP_RISING_EDGE and PTP_FALLING_EDGE flags have unclear semantics and each driver seems to have interpreted them slightly differently. Cc: Sergei Shtylyov Signed-off-by: Jacob Keller Reviewed-by: Richard Cochran Reviewed-by: Sergei Shtylyov --- drivers/net/ethernet/renesas/ravb_ptp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c index 638f1fc2166f..666dbee48097 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -182,6 +182,12 @@ static int ravb_ptp_extts(struct ptp_clock_info *ptp, struct net_device *ndev = priv->ndev; unsigned long flags; + /* Reject requests with unsupported flags */ + if (req->flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE)) + return -EOPNOTSUPP; + if (req->index) return -EINVAL; From patchwork Thu Nov 14 18:45:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="j2tGtcfx"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVm575n6z9sQw for ; Fri, 15 Nov 2019 05:45:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 36155882EB; Thu, 14 Nov 2019 18:45:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sa9p_oVteBUB; Thu, 14 Nov 2019 18:45:23 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 134D3882EA; Thu, 14 Nov 2019 18:45:23 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 022271BF289 for ; Thu, 14 Nov 2019 18:45:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id F236189174 for ; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ct7DkIK5tkQu for ; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5CC2C89153 for ; Thu, 14 Nov 2019 18:45:21 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id s5so4853683pfh.9 for ; Thu, 14 Nov 2019 10:45:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OffYFMf+ZOaY8ZSWvKSHW83/Ze95I/wpNSGexu7BXxI=; b=j2tGtcfxj1ga7Tqd36W0X/V5RQZLx6EpTYpyTuM5tdkGy7JuSR7UXcdQzREdkM3A3e e+AGxHhQ9ECeD/gxqV97/etfJVzIFKGByvmlowBdPPrnWLsE4mb+XXDXZp9b+rOZ4Pmb R9q64AQNdVb5At/1pqTK0MPTxGrO3dfhnxhwK18DxWeT1KObRlNYn2CSwyUnOFwr7TcR xihGKPNTSxfCbug7VjCtfD8WTnahq87qSzPYZTu2MoyPd7/HauyziE6sNN204u1CsxS/ TBnswY0TspaL87u0pnxyNT08OV1lDrJIE4greHudGDQ9lmTZGkgkQvD9yBrU5kIAgzLB B7Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OffYFMf+ZOaY8ZSWvKSHW83/Ze95I/wpNSGexu7BXxI=; b=VLknM1Sdnr0szzcAgENPQLRbvO07xq1oEGjElO5wT/lm7ekdk6d67hBd6/Y8m41aed S2TuSkpcYTCgisaKiHB3JefYh6CsJZMbmC3jAHesl3k+MiJlQQybbpAo7XR675ZlyBCQ ac19aOLYlTAa5d9kjkBiPpKYIyPei7DIUFxrCnd20Q7oNm5u4AytnANcO4ZHB3DeBsdx Bf83aL59ov+0Ov9iBDNtbWzeDw3E8CCZabHfotxZ2iAPj2tBgsbFPjPbWmPm/3P6H0hI aTxBGNdLYx5fJc6DwoTNMWDYm5n/phXyWKDqcYcnb30JUbjMOmzTRPfHeViUBwoJ8YuR aFJQ== X-Gm-Message-State: APjAAAWNpfd/utCrEB8Qx+AX1/FXiBMuTZx1PmITtgd/hw7ajOReWr4D y3eVzzsOuDGx1NK/atRGPiA= X-Google-Smtp-Source: APXvYqyRG6OMoXdvstk6lQ4vX+oJ+6MB6GqKUl+zWiqYwW99r1BlXyeVdDrRK+hCRjWeoYMefinvrw== X-Received: by 2002:a17:90b:d88:: with SMTP id bg8mr14417315pjb.78.1573757121030; Thu, 14 Nov 2019 10:45:21 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:20 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:02 -0800 Message-Id: <20191114184507.18937-9-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 08/13] ptp: Introduce strict checking of external time stamp options. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" User space may request time stamps on rising edges, falling edges, or both. However, the particular mode may or may not be supported in the hardware or in the driver. This patch adds a "strict" flag that tells drivers to ensure that the requested mode will be honored. Signed-off-by: Richard Cochran --- drivers/net/dsa/mv88e6xxx/ptp.c | 3 ++- drivers/net/ethernet/intel/igb/igb_ptp.c | 3 ++- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 3 ++- drivers/net/ethernet/renesas/ravb_ptp.c | 3 ++- drivers/net/phy/dp83640.c | 3 ++- drivers/ptp/ptp_chardev.c | 2 ++ include/uapi/linux/ptp_clock.h | 4 +++- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/ptp.c b/drivers/net/dsa/mv88e6xxx/ptp.c index 076e622a64d6..3b1985902f95 100644 --- a/drivers/net/dsa/mv88e6xxx/ptp.c +++ b/drivers/net/dsa/mv88e6xxx/ptp.c @@ -276,7 +276,8 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip, /* Reject requests with unsupported flags */ if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | PTP_RISING_EDGE | - PTP_FALLING_EDGE)) + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) return -EOPNOTSUPP; pin = ptp_find_pin(chip->ptp_clock, PTP_PF_EXTTS, rq->extts.index); diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 0bce3e0f1af0..3fd60715bca7 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -524,7 +524,8 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp, /* Reject requests with unsupported flags */ if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | PTP_RISING_EDGE | - PTP_FALLING_EDGE)) + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) return -EOPNOTSUPP; if (on) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 9a40f24e3193..819097d9b583 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -239,7 +239,8 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp, /* Reject requests with unsupported flags */ if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | PTP_RISING_EDGE | - PTP_FALLING_EDGE)) + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) return -EOPNOTSUPP; if (rq->extts.index >= clock->ptp_info.n_pins) diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c index 666dbee48097..6984bd5b7da9 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c @@ -185,7 +185,8 @@ static int ravb_ptp_extts(struct ptp_clock_info *ptp, /* Reject requests with unsupported flags */ if (req->flags & ~(PTP_ENABLE_FEATURE | PTP_RISING_EDGE | - PTP_FALLING_EDGE)) + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) return -EOPNOTSUPP; if (req->index) diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 2781b0e2d947..3bba2bea3a88 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -472,7 +472,8 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp, /* Reject requests with unsupported flags */ if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | PTP_RISING_EDGE | - PTP_FALLING_EDGE)) + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) return -EOPNOTSUPP; index = rq->extts.index; if (index >= N_EXT_TS) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index cbbe1237ff8d..9d72ab593f13 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -150,6 +150,8 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) break; } if (cmd == PTP_EXTTS_REQUEST2) { + /* Tell the drivers to check the flags carefully. */ + req.extts.flags |= PTP_STRICT_FLAGS; /* Make sure no reserved bit is set. */ if ((req.extts.flags & ~PTP_EXTTS_VALID_FLAGS) || req.extts.rsv[0] || req.extts.rsv[1]) { diff --git a/include/uapi/linux/ptp_clock.h b/include/uapi/linux/ptp_clock.h index 304059b1609d..9dc9d0079e98 100644 --- a/include/uapi/linux/ptp_clock.h +++ b/include/uapi/linux/ptp_clock.h @@ -31,6 +31,7 @@ #define PTP_ENABLE_FEATURE (1<<0) #define PTP_RISING_EDGE (1<<1) #define PTP_FALLING_EDGE (1<<2) +#define PTP_STRICT_FLAGS (1<<3) #define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE) /* @@ -38,7 +39,8 @@ */ #define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | \ PTP_RISING_EDGE | \ - PTP_FALLING_EDGE) + PTP_FALLING_EDGE | \ + PTP_STRICT_FLAGS) /* * flag fields valid for the original PTP_EXTTS_REQUEST ioctl. From patchwork Thu Nov 14 18:45:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sL6ewae8"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVmF4VCxz9sPc for ; Fri, 15 Nov 2019 05:45:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id ECAF389C94; Thu, 14 Nov 2019 18:45:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SMPq0g93gmFf; Thu, 14 Nov 2019 18:45:31 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 6D8F889C8C; Thu, 14 Nov 2019 18:45:31 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 31F031BF289 for ; Thu, 14 Nov 2019 18:45:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 26FD889C8C for ; Thu, 14 Nov 2019 18:45:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S2bdeBAqO452 for ; Thu, 14 Nov 2019 18:45:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by hemlock.osuosl.org (Postfix) with ESMTPS id AF1D389C8B for ; Thu, 14 Nov 2019 18:45:22 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id x28so4873226pfo.6 for ; Thu, 14 Nov 2019 10:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FM0Xa5CiudMEuYb8SLKHiBcKyURm3GM8uH2aZPmH6I0=; b=sL6ewae8cqR2iO+Y3fQIcpw/lBi9VN+TvYmQIPf8SdGeqK1yvGsXEIOikxFGOthKP5 Qi8JCFRJe0p3e6SDGszPrH3vPeZVbP/yxyiEt9uBvrwbVVclBrcbdNRKwFQ+3lkg7oli 6eY1iAqbSnxGH4wbYockkaV+J9k0c99OR2u8D90WuGOt+/83fI6+y5X9Q0EM1puHm0uy CFSQG3v+cNFym/crT0bTl8nR/LQCrsIWqVWeCR/yVNLI/PhR/t5oE5Ptc9ctWa+jWWNG StO+vPb4gtiXltQZb/QnFGlepkR06X8Hq89Myn+iTaDGtW0IPfjdgeGo54WPWsiXo91s dnkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FM0Xa5CiudMEuYb8SLKHiBcKyURm3GM8uH2aZPmH6I0=; b=OXZ0d0swT9IHepals3vaUT1s1eH0xE2K3kMx1cV2nI9dxPhQxq5vmWj8BQzQ144TGX 5E6XAAIQJmI6QBZ0KMvL4Dd6XgDKgcU2UV+9Sri7c0GbjxvTP6CPXsUjxW1ErLl0ISd1 qoiITjV9hyNkQtaa5yOnTFYJsCK3gdIGkcrxracwyS97XIsLiAIFWFuEMSM9tUSYfw2l ywNSUSbNJ62M5gl0QBbh37xhKXCKDbydtta6zbxPdlblW7RJUdvKfDOlujTDYU+Xv9ka 3Sjq8aeBdFs1BeahV7C77LN0ZVH07x5HyzaFyPa+ZCbdnBbERHLc8imtBnbMcsF4xCRz xKqw== X-Gm-Message-State: APjAAAVa5DyzhvrbYxwgefWW7o+6eO70aeCu7AEZ2qTc90xhEhvxETJj Sv3FYdsVNmTb2IZky0CRYaE= X-Google-Smtp-Source: APXvYqyBqA+/yf0s54xrqKe3oPWTtSleHncUSgQ1wUUX2iDg3/6htOF9EV3okmf551jJuYXw92P00Q== X-Received: by 2002:a63:7210:: with SMTP id n16mr11119972pgc.397.1573757122328; Thu, 14 Nov 2019 10:45:22 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:21 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:03 -0800 Message-Id: <20191114184507.18937-10-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 09/13] mv88e6xxx: Reject requests to enable time stamping on both edges. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This driver enables rising edge or falling edge, but not both, and so this patch validates that the request contains only one of the two edges. Signed-off-by: Richard Cochran --- drivers/net/dsa/mv88e6xxx/ptp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/ptp.c b/drivers/net/dsa/mv88e6xxx/ptp.c index 3b1985902f95..d838c174dc0d 100644 --- a/drivers/net/dsa/mv88e6xxx/ptp.c +++ b/drivers/net/dsa/mv88e6xxx/ptp.c @@ -280,6 +280,12 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip, PTP_STRICT_FLAGS)) return -EOPNOTSUPP; + /* Reject requests to enable time stamping on both edges. */ + if ((rq->extts.flags & PTP_STRICT_FLAGS) && + (rq->extts.flags & PTP_ENABLE_FEATURE) && + (rq->extts.flags & PTP_EXTTS_EDGES) == PTP_EXTTS_EDGES) + return -EOPNOTSUPP; + pin = ptp_find_pin(chip->ptp_clock, PTP_PF_EXTTS, rq->extts.index); if (pin < 0) From patchwork Thu Nov 14 18:45:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="miDGPt32"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVmH0CsJz9s4Y for ; Fri, 15 Nov 2019 05:45:34 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5F7CA882C8; Thu, 14 Nov 2019 18:45:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HUp0tdGce0L4; Thu, 14 Nov 2019 18:45:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id EC070882CC; Thu, 14 Nov 2019 18:45:32 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 0037D1BF289 for ; Thu, 14 Nov 2019 18:45:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id DA68E89C8C for ; Thu, 14 Nov 2019 18:45:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tB24dmqFKwOq for ; Thu, 14 Nov 2019 18:45:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by hemlock.osuosl.org (Postfix) with ESMTPS id 4221289C8B for ; Thu, 14 Nov 2019 18:45:24 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id q22so4358183pgk.2 for ; Thu, 14 Nov 2019 10:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=o0poRh66g/qqcAtxprleBKed73eICCEv6L8Oqc9jcrg=; b=miDGPt321IibkYm9srsINKjfZCosucoHt8gtkG+k7OX4GrhuTKA/j4l/Q6pXyiYoEU vnEcMx3/OqTBHAYzh/BEGEcBKyAUg/rpcivOFRCwbz+IphJg5lWYZR8rmGFAAAb27RlJ ku5qrWNtmE66LzaKsugPW8ZOZ7ChP3RbN0XaVlIjnmHhKiTJwOCgbbHtn8oqEeLKjcMW MHi4wQbrWuSE9qTcieRUDv2cB7E3O+7br0wbfhy//xEg7xbTi4yx7sjH4gK0FonNRDTW kvqlOX6FZD4+La2fO4iBYZ1CCxemvk502Qgz4/l7H0MYuTrwqZPkaLPwMZM6stcK+c70 vBDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=o0poRh66g/qqcAtxprleBKed73eICCEv6L8Oqc9jcrg=; b=Jr6zh84IEU7zoBPEvLpDYA52HP6Acj4aiSkTskxn55yx+1+OVDn+zbhY6WtLPV34fM urpmSWxws46OikHA6nw25MaOD+Sxon0dbomul4t5agRTfTN7HrwncVRgLQJgv1Rt9S90 NTe5mmEPbSa8y7l4GGSJI5LvETAkHEeyUP8ffWWSp9qgqdFbWedRHaoJ6pyMU63DnlTM kj76HvG8eukgJFynJbB4S2AEhMNpfhYZHOTM89U1bQJTdiVbzj2H6ExXPMRZHztuiMu6 ePa8YVBnlFarRoVfB10yRZW62dkhx8Z20Xz6kBJXscUxEDrW1YuNELuQeafjALFMEMg6 UtLg== X-Gm-Message-State: APjAAAWVmuc/jZyhC63mM1okU1Qte0ZC5echnMdcc/0shezmGQ1rhcIh gNbyOHeafyAJyKAcUuRYeWk= X-Google-Smtp-Source: APXvYqyt+sDREmYpkh+77thPoRhBNaWyB0Ipzg5X3TtSKyogbAMclFXkc3Z+1wclRekRUL8UnSfYsg== X-Received: by 2002:a65:6482:: with SMTP id e2mr8679115pgv.20.1573757123822; Thu, 14 Nov 2019 10:45:23 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:23 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:04 -0800 Message-Id: <20191114184507.18937-11-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 10/13] dp83640: Reject requests to enable time stamping on both edges. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This driver enables rising edge or falling edge, but not both, and so this patch validates that the request contains only one of the two edges. Signed-off-by: Richard Cochran --- drivers/net/phy/dp83640.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 3bba2bea3a88..8f241b57fcf6 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -475,6 +475,13 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp, PTP_FALLING_EDGE | PTP_STRICT_FLAGS)) return -EOPNOTSUPP; + + /* Reject requests to enable time stamping on both edges. */ + if ((rq->extts.flags & PTP_STRICT_FLAGS) && + (rq->extts.flags & PTP_ENABLE_FEATURE) && + (rq->extts.flags & PTP_EXTTS_EDGES) == PTP_EXTTS_EDGES) + return -EOPNOTSUPP; + index = rq->extts.index; if (index >= N_EXT_TS) return -EINVAL; From patchwork Thu Nov 14 18:45:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QKP/0O4P"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVmN1LkGz9sPc for ; Fri, 15 Nov 2019 05:45:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 820358917C; Thu, 14 Nov 2019 18:45:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XyA7R7JJ9HKJ; Thu, 14 Nov 2019 18:45:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 0B2F389174; Thu, 14 Nov 2019 18:45:34 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 3DFB91BF289 for ; Thu, 14 Nov 2019 18:45:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 31621882C8 for ; Thu, 14 Nov 2019 18:45:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tIf_wABl86qr for ; Thu, 14 Nov 2019 18:45:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id C0691882C7 for ; Thu, 14 Nov 2019 18:45:25 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id s5so4853827pfh.9 for ; Thu, 14 Nov 2019 10:45:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EgZP9Qg8jKjpYCoDh3oNRwu6jLyNFPvdVGbrs0P5gb0=; b=QKP/0O4PMONo3xuGbZDoiCP+GoyoTIvuu+fdiqkeYkxppDvBf5cHolmMn0r6KzxOwz KIojTVA54ky42bwHGtf7NSOZ9nVRu0zOkf+u3y7KbvOfERfoN+kZl+7UH0E3KU3MNgG7 IiFOOPXKGxjscRIkF2pYkeGRmth5ABZK3mbXftYCS0dZDXfHXoKdVSPSc6T3HywHoMgW 8jfTe4uNr/iWdPiz6XzKj6BRzVRqLd1end1+M5Aicszem0FHIkAWs3rTQLlQQcPUMgms zql7sulv+U9j50eYWjH5iyRVbdE1cMoj/wZi03mVkM/HmAjIo2sS/VPCqBEF4tbct521 izQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EgZP9Qg8jKjpYCoDh3oNRwu6jLyNFPvdVGbrs0P5gb0=; b=LGVaQKgdr2lvKss6kvLlaJBxqiAI657O/MMp/GSJQVaMfOJlX3PYKK/yxSO7Lf0VR9 bENd14r/KS3JmtpYZmSacAlfNDuVcijCB7Gv1kRdzWlYBwp/RLuOfFEuzUk6seQW+3Oq bAunfHjFicaQHXyPuyi42t2ZUJ0oGvbv0q2gfFdVUYZfmLnCqwFiaJuG7XvjQ9sNSK4+ FlVgHLQIDOe8NRsalDg6TWyFIiT5rU6CfImPyyrflJcdU/Dlr28SWZBe0r6JUTB8y99w MrEqJh5rVgFX+r4N0tP8McOy4g3797cXcSqymZsyMUlwFIloKZbQYSJzxSXpLhECArOb O9mg== X-Gm-Message-State: APjAAAU9f73YzFy6kNW3MRHqs2BOMthrC08fT8AtZPs2glLolUdV5D9e E5rArL8ov0st2e+tW65Lb9I= X-Google-Smtp-Source: APXvYqwbWZHVJXyM6LwZqG93BFEVswnKFIib/1vA31agwuV1XgvHF/y2aw+qgyQO4OxTpj8+2SWDzA== X-Received: by 2002:a17:90a:b109:: with SMTP id z9mr13948112pjq.108.1573757125454; Thu, 14 Nov 2019 10:45:25 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:24 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:05 -0800 Message-Id: <20191114184507.18937-12-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 11/13] igb: Reject requests that fail to enable time stamping on both edges. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This hardware always time stamps rising and falling edges, and so this patch validates that the request does contains both edges. Signed-off-by: Richard Cochran --- drivers/net/ethernet/intel/igb/igb_ptp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 3fd60715bca7..c39e921757ba 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -528,6 +528,12 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp, PTP_STRICT_FLAGS)) return -EOPNOTSUPP; + /* Reject requests failing to enable both edges. */ + if ((rq->extts.flags & PTP_STRICT_FLAGS) && + (rq->extts.flags & PTP_ENABLE_FEATURE) && + (rq->extts.flags & PTP_EXTTS_EDGES) != PTP_EXTTS_EDGES) + return -EOPNOTSUPP; + if (on) { pin = ptp_find_pin(igb->ptp_clock, PTP_PF_EXTTS, rq->extts.index); From patchwork Thu Nov 14 18:45:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lzBnyKi+"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVmJ4hZNz9sQw for ; Fri, 15 Nov 2019 05:45:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 32BB389C94; Thu, 14 Nov 2019 18:45:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id abSIjIm8w8Ks; Thu, 14 Nov 2019 18:45:34 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 86EFC89CA1; Thu, 14 Nov 2019 18:45:34 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id ACB7D1BF289 for ; Thu, 14 Nov 2019 18:45:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A604D89C8C for ; Thu, 14 Nov 2019 18:45:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K0j-4TyuuJUB for ; Thu, 14 Nov 2019 18:45:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by hemlock.osuosl.org (Postfix) with ESMTPS id 32A6389C8B for ; Thu, 14 Nov 2019 18:45:27 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id k1so3027739pgg.12 for ; Thu, 14 Nov 2019 10:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FM3VhSbSiafPaH1zDTjChkDXYC3HNrrA8QbibO1hxSM=; b=lzBnyKi+bZrh9wnaaq2maczx3IdNblvCteLtfehTKx3USUsi/YgVJfiyYCoJ8FwIMx jOszlkQOPBv7oUwdNL8Ma5NbuZ+bjI3QDV6px/IrnsL5e6RCuFx3oOsdfp6j1U9CDcR8 h/YeE5zFtvUhJ0VEzErb5aB1q9OoT5cNtWfgII8Y9T8svrTQFXe986Y8VkFnSeALS4Yw lQ6mVbFnm0M0RAwSzmgpheESK+M5m3Umdj90RlC5g40WdFfY23+aM4LzX9upCNousnQB rqiVruVT2CFyYElyNfOqGEjgwV4L3MonyDqs6OSUpLd/Kc4UCnLlshKb05zqAVsUDILM ir/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FM3VhSbSiafPaH1zDTjChkDXYC3HNrrA8QbibO1hxSM=; b=Juwh7vgF+q8xlrBYKQP8WEhPATQoelUKd1yzdcVEoTKJFXCct9DDlOMnUpZrmSexWL FV4/hkM0JWDNbl90/V3jqVGC3JwICz78jBI1VRkY1nWSt4H34gRd6S0z4dvRmKNvmFGC IyKoTMy0xzjaa2tIWnZW2F1tM9OdHS6g7P02Q5oBb3Nv4Eh9TGhPFlgKhI7mKvdIXlNG ZyFleGWw+AYBG3BUZZTgOWj05qhdo+toJC47MFYGmdsaaCMoPiRttoKdnfyD+Pq3lTSd GXJ2xqci+sQTZSHFsvXSaNtp2X4SErtaRpNyu42oDRgPkUsVsAPTGUPTd/TNh25ktS7h +0Tw== X-Gm-Message-State: APjAAAXV27Zz1j7fAmzkTZAkapszXIVHdVU8/ez0amaI0ivP66mRtP24 1C4Nr/tl/ep50Xt6JUh0EtY= X-Google-Smtp-Source: APXvYqziilQvp1gfUwYWyoR6VkMNhcHXbr/HTWJJBPcj/7VRsUUQYaXZldCvOUmsEfrY2kMf0OUFnw== X-Received: by 2002:a17:90a:9dca:: with SMTP id x10mr13996788pjv.139.1573757126814; Thu, 14 Nov 2019 10:45:26 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:26 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:06 -0800 Message-Id: <20191114184507.18937-13-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 12/13] mlx5: Reject requests to enable time stamping on both edges. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" This driver enables rising edge or falling edge, but not both, and so this patch validates that the request contains only one of the two edges. Signed-off-by: Richard Cochran Reviewed-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 819097d9b583..43f97601b500 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -243,6 +243,12 @@ static int mlx5_extts_configure(struct ptp_clock_info *ptp, PTP_STRICT_FLAGS)) return -EOPNOTSUPP; + /* Reject requests to enable time stamping on both edges. */ + if ((rq->extts.flags & PTP_STRICT_FLAGS) && + (rq->extts.flags & PTP_ENABLE_FEATURE) && + (rq->extts.flags & PTP_EXTTS_EDGES) == PTP_EXTTS_EDGES) + return -EOPNOTSUPP; + if (rq->extts.index >= clock->ptp_info.n_pins) return -EINVAL; From patchwork Thu Nov 14 18:45:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1195069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Vl9798Ap"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DVmM2dtdz9s4Y for ; Fri, 15 Nov 2019 05:45:39 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B22B7227AD; Thu, 14 Nov 2019 18:45:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m46y6lMbLwB8; Thu, 14 Nov 2019 18:45:36 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 534D9204F5; Thu, 14 Nov 2019 18:45:36 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 7142C1BF289 for ; Thu, 14 Nov 2019 18:45:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 68E6E20520 for ; Thu, 14 Nov 2019 18:45:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xJlK9FIKVens for ; Thu, 14 Nov 2019 18:45:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by silver.osuosl.org (Postfix) with ESMTPS id A0BA6204F5 for ; Thu, 14 Nov 2019 18:45:28 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id s10so3036536plp.2 for ; Thu, 14 Nov 2019 10:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AHCtOmZ2GTslOfW4Um0mVrFAtc3tK3f23TYhKGTJCmE=; b=Vl9798Ap678R+AQutazdpde2HDDM5L2YwL4kGCKMSBGWGHRI0eoXrWxYgQ1CZ6wxYB hfVmR4cxyH+y+fPcFGomu8lp7zViUi+rBAS+XCnqUamo9I3XRDPL3L7hDIoARcCk4EYO cjO3NOA0pq6TgYzRDnS4azdKZ9+CT910y1NHUDMOm+9batpVk3oqVEhzMDsN81+GvMu5 CiZ1isZEA5aqqfIqs9h32DN0qXBmXg8JOFD+vdHeRFShpupiTJoTuzOov7jaMVVcf3Cz HJlUzgZxk2jEO1/Ti1WHlqXzJjVjZceqfbQIv7m/OvCa4947w7l3eldm27WjpoqNL4E1 oJKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AHCtOmZ2GTslOfW4Um0mVrFAtc3tK3f23TYhKGTJCmE=; b=R2nCHJ9hwblFz8ydYi88ZuYrbn6U7DQxTpEvBGJL6rgHcy4YeQ5xUK/72r5h82rcFo 0B84i+wBY2mZO3Ymni3xhd8yyLYW4bRP6lWpkjIyUHWow9qZRwFa8KYa/v8aqWXL8Knz g8Ozn8zbeVjGX2LJI0jIFuqr1IPbcfYdWhHo1R2r9ooIolC2VZEbx6ZkC3q9Zz0v+R4K 8hsaDvytqMvx6p8Mc4Ym7wahfah7JsTWQYcnJOXgdDlnyJ6tnGEXtkdWUqksqzAcc9y5 EyPRT240nQTZN2DQOdOLOkgPfuw3+tjVUVkR40nZ9q0SxDQbdVtk4RXBAXVfS+RUbojx HdAw== X-Gm-Message-State: APjAAAWlPN1HjEpu+M00Pav/Zic3/MELpoEsQfonOJcyNaCy6CXTJxEM locN7P1YuMmWyu2QRiBOiVM= X-Google-Smtp-Source: APXvYqy3ALZfMdDzUs65O3O63qtslh17W7iZe49ML6Rpvfk3n1M3R4zU5I9Yl97hQoXKJEHZuOSt4Q== X-Received: by 2002:a17:902:b693:: with SMTP id c19mr10960511pls.89.1573757128105; Thu, 14 Nov 2019 10:45:28 -0800 (PST) Received: from localhost.localdomain (c-73-241-114-122.hsd1.ca.comcast.net. [73.241.114.122]) by smtp.gmail.com with ESMTPSA id 23sm6819507pgw.8.2019.11.14.10.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 10:45:27 -0800 (PST) From: Richard Cochran To: netdev@vger.kernel.org Date: Thu, 14 Nov 2019 10:45:07 -0800 Message-Id: <20191114184507.18937-14-richardcochran@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH net 13/13] ptp: Extend the test program to check the external time stamp flags. X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher Hall , Brandon Streiff , Sergei Shtylyov , Felipe Balbi , Eugenia Emantayev , Feras Daoud , intel-wired-lan@lists.osuosl.org, David Miller , Stefan Sorensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Because each driver and hardware has different capabilities, the test cannot provide a simple pass/fail result, but it can at least show what combinations of flags are supported. Signed-off-by: Richard Cochran --- tools/testing/selftests/ptp/testptp.c | 53 ++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c index bd4a7247b44f..c0dd10257df5 100644 --- a/tools/testing/selftests/ptp/testptp.c +++ b/tools/testing/selftests/ptp/testptp.c @@ -44,6 +44,46 @@ static int clock_adjtime(clockid_t id, struct timex *tx) } #endif +static void show_flag_test(int rq_index, unsigned int flags, int err) +{ + printf("PTP_EXTTS_REQUEST%c flags 0x%08x : (%d) %s\n", + rq_index ? '1' + rq_index : ' ', + flags, err, strerror(errno)); + /* sigh, uClibc ... */ + errno = 0; +} + +static void do_flag_test(int fd, unsigned int index) +{ + struct ptp_extts_request extts_request; + unsigned long request[2] = { + PTP_EXTTS_REQUEST, + PTP_EXTTS_REQUEST2, + }; + unsigned int enable_flags[5] = { + PTP_ENABLE_FEATURE, + PTP_ENABLE_FEATURE | PTP_RISING_EDGE, + PTP_ENABLE_FEATURE | PTP_FALLING_EDGE, + PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE, + PTP_ENABLE_FEATURE | (PTP_EXTTS_VALID_FLAGS + 1), + }; + int err, i, j; + + memset(&extts_request, 0, sizeof(extts_request)); + extts_request.index = index; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 5; j++) { + extts_request.flags = enable_flags[j]; + err = ioctl(fd, request[i], &extts_request); + show_flag_test(i, extts_request.flags, err); + + extts_request.flags = 0; + err = ioctl(fd, request[i], &extts_request); + } + } +} + static clockid_t get_clockid(int fd) { #define CLOCKFD 3 @@ -96,7 +136,8 @@ static void usage(char *progname) " -s set the ptp clock time from the system time\n" " -S set the system time from the ptp clock time\n" " -t val shift the ptp clock time by 'val' seconds\n" - " -T val set the ptp clock time to 'val' seconds\n", + " -T val set the ptp clock time to 'val' seconds\n" + " -z test combinations of rising/falling external time stamp flags\n", progname); } @@ -122,6 +163,7 @@ int main(int argc, char *argv[]) int adjtime = 0; int capabilities = 0; int extts = 0; + int flagtest = 0; int gettime = 0; int index = 0; int list_pins = 0; @@ -138,7 +180,7 @@ int main(int argc, char *argv[]) progname = strrchr(argv[0], '/'); progname = progname ? 1+progname : argv[0]; - while (EOF != (c = getopt(argc, argv, "cd:e:f:ghi:k:lL:p:P:sSt:T:v"))) { + while (EOF != (c = getopt(argc, argv, "cd:e:f:ghi:k:lL:p:P:sSt:T:z"))) { switch (c) { case 'c': capabilities = 1; @@ -191,6 +233,9 @@ int main(int argc, char *argv[]) settime = 3; seconds = atoi(optarg); break; + case 'z': + flagtest = 1; + break; case 'h': usage(progname); return 0; @@ -322,6 +367,10 @@ int main(int argc, char *argv[]) } } + if (flagtest) { + do_flag_test(fd, index); + } + if (list_pins) { int n_pins = 0; if (ioctl(fd, PTP_CLOCK_GETCAPS, &caps)) {