Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3004571pxb; Fri, 5 Nov 2021 08:13:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWqj4NAiZPy5FDbUN6zvrUX7pv7etZlgSyL8qJMiV6P69Bxqyy3jM8QLG3sZRx432NCk0e X-Received: by 2002:a05:6402:3546:: with SMTP id f6mr7543203edd.310.1636125221656; Fri, 05 Nov 2021 08:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636125221; cv=none; d=google.com; s=arc-20160816; b=wlz5MtnCaG4vy7an86rrSnPFxnCUGxmsH/ctn455yNz02E7Dwv5amti8ssbMYFk6aq 6mx2f/XAf9geSj1zEAv7/wDIYDKpQyZGG0rC/+pv7g5fR4gfNDJnwztoOH3/68R9DLBq 4LvNPFeEzMQTCuTUH1pG52Y3mnO4WnSMWsFu0XbXCpFPhrjfaIpJi/8vDTeStrBlnM3F ALJQtokywrsIjKgfosCv/7Z5b2cGjEPAOWfHEy+p26cHQWCTdGm4XPeL/XLBHrEP9QIs FmL54p5a71nZIsaweC+TN/qZ2snJu5j3aaWba/wWwaObg8+7JuOXgxtPq0+uChWe9yCI HL9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=FDjEvpbxXBuzF+yWYWfX00V+Mpta9Rblx/cVdifnups=; b=FdVscA/yoNwRSadDhXrlwUBGPj8nfEl1eXUrtzFwBBZl30JYzQk0efvARrjR02spFs Ia/mXAxLydzkhz3j4zzYpHnK1u2TUSTz7SmN5Tjmw0gefdQZ/09rD/272ikmWAMGSW3Q CJGsi/PtH2sIRDZtf1iHiMEy3SIAQq0l74iFNqj/UlD7ddw7/5KEc8yjyh3uHSc+wy90 aEvHaCVPaKFZPeMAPqTkeqL4MZktXJ+u66IgHoonyxD51oahRfPtBS8GE1Przzt9njEn 4Mjf951F6sUWZuZhXwqASYNS2eqf21+8S1R1EqaYXU3tgbIyhByc4y4fO+mM294OrcS5 LgpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ryd+zHE7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hw9si16436673ejc.475.2021.11.05.08.13.13; Fri, 05 Nov 2021 08:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ryd+zHE7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233393AbhKEPMU (ORCPT + 99 others); Fri, 5 Nov 2021 11:12:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:59444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbhKEPMU (ORCPT ); Fri, 5 Nov 2021 11:12:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A3E660F36; Fri, 5 Nov 2021 15:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636124980; bh=y22Owe3WsOyK/XyUDi4v5MjW8f8Cqs3vQzTjwWumqwA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ryd+zHE7ncWjFfazijXbytqlPP7euhlaAXbEN8UU+CvwAcwQ1UbN/1W33jZhPOmxJ bW9/jwjaVMqXW+bodI1nMZioXnSuawGLlyaWyJlWcq1E6VKd/APgCFk2M/Xh6A/ME1 EsaTuUeXBoh8ak2zTgD4EeB1D/V5OoGIkX7pTnKb7b4LpfrFzFIJwcTte5jhccit30 a+ToWYFsFzMxxsm4MMSia1YtE3PlR6p+NwrBdASu6sH2fydwXYWQ2evLGJABbK5m+v 94KGNXvfT9kSgaP2uzrO7WmsiZvo41pPSLXaNLSqHkZUU8owI+laLJGzIdiFHN7eqm w4pAWO6qZMpcg== Date: Fri, 5 Nov 2021 08:09:39 -0700 From: Jakub Kicinski To: Vladimir Oltean Cc: Richard Cochran , Martin Kaistra , Florian Fainelli , Andrew Lunn , Vivien Didelot , Kurt Kanzenbach , "David S. Miller" , John Stultz , Thomas Gleixner , Stephen Boyd , Russell King , Marc Kleine-Budde , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 7/7] net: dsa: b53: Expose PTP timestamping ioctls to userspace Message-ID: <20211105080939.2508a51e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20211105142833.nv56zd5bqrkyjepd@skbuf> References: <20211104133204.19757-1-martin.kaistra@linutronix.de> <20211104133204.19757-8-martin.kaistra@linutronix.de> <20211104174251.GB32548@hoboy.vegasvil.org> <20211105141319.GA16456@hoboy.vegasvil.org> <20211105142833.nv56zd5bqrkyjepd@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 Nov 2021 16:28:33 +0200 Vladimir Oltean wrote: > On Fri, Nov 05, 2021 at 07:13:19AM -0700, Richard Cochran wrote: > > On Fri, Nov 05, 2021 at 02:38:01PM +0100, Martin Kaistra wrote: > > > Ok, then I will remove HWTSTAMP_FILTER_PTP_V2_(EVENT|SYNC|DELAY_REQ) from > > > this list, what about HWTSTAMP_FILTER_ALL? > > > > AKK means time stamp every received frame, so your driver should > > return an error in this case as well. > > What is the expected convention exactly? There are other drivers that > downgrade the user application's request to what they support, and at > least ptp4l does not error out, it just prints a warning. Which is sad because that's one of the best documented parts of our API: Desired behavior is passed into the kernel and to a specific device by calling ioctl(SIOCSHWTSTAMP) with a pointer to a struct ifreq whose ifr_data points to a struct hwtstamp_config. The tx_type and rx_filter are hints to the driver what it is expected to do. If the requested fine-grained filtering for incoming packets is not supported, the driver may time stamp more than just the requested types of packets. Drivers are free to use a more permissive configuration than the requested configuration. It is expected that drivers should only implement directly the most generic mode that can be supported. For example if the hardware can support HWTSTAMP_FILTER_V2_EVENT, then it should generally always upscale HWTSTAMP_FILTER_V2_L2_SYNC_MESSAGE, and so forth, as HWTSTAMP_FILTER_V2_EVENT is more generic (and more useful to applications). A driver which supports hardware time stamping shall update the struct with the actual, possibly more permissive configuration. If the requested packets cannot be time stamped, then nothing should be changed and ERANGE shall be returned (in contrast to EINVAL, which indicates that SIOCSHWTSTAMP is not supported at all). https://www.kernel.org/doc/html/latest/networking/timestamping.html#hardware-timestamping-configuration-siocshwtstamp-and-siocghwtstamp