Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp498511rdh; Wed, 14 Feb 2024 03:23:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0gaRHuqVkJnULWDQjn+qnKM9FkEMLxrT99ahxS/FsX3TvVWczYDfc/qjdhD82yUvB5sRP9DchoD72WFk7AW3ihsxgxHStzFk6QEB/Ng== X-Google-Smtp-Source: AGHT+IE+l86QOsQGCvffV3/PQS1+vBnu9APjDs2SGLAKUKUMyK+Ii9AtutNVVk8muFJOczPdr+3f X-Received: by 2002:a05:6a20:e68c:b0:19c:8ed6:8bb5 with SMTP id mz12-20020a056a20e68c00b0019c8ed68bb5mr2447331pzb.39.1707909808601; Wed, 14 Feb 2024 03:23:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707909808; cv=pass; d=google.com; s=arc-20160816; b=K4VrZDfeva/tKh49D5Wq+g5HDtaw3eZZExGSCcg2w4ka9Ml1aZkyrcqVjwRYyHPrGX KbYtdQvfuFwSL0FphpAMgckJYtwsycOgpCBuImFAMWmIVyVWA+w57ZXsYEjKKsewkhQ/ pl9rRTCJFg4Q2POfTZbTzNrBo7Qhfcgy/YL+UTlt1Q9jfk7zMhzOLnKbpUvgE9NirbSY 3xplDzft1CxcglDspVzmYZK2pCu01yBjgWl6+De1Eeczb50mchYUp5sRmbBE+s+6/WHh 9P0e1TBcsHdwwlmxxLDr0fzsv4Xw1GG1OrtVPBycVQTFN/mHkRgJFnukwYABHwJK9w2q rdgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=bNyMKCwVt13/eR+EwpIRTRHK69mX0eVQLKEM2trCPPA=; fh=qVKx06tAyKcmPq3sCzCMF9FZF/dRmn1bKDHjQcemWGw=; b=LXuVm/TLar6m0/Gm7BqalEh10sMmA6Agz7aAIiBKHIcd7C5TMwsvG6WJgNIklO4CIr w27+M9I39Hr+IiA7y/9GRRGclzl5Zt7UDkoo4wkXQDWpmkNaod381CNgMSKb2CAOl0XA waDNWTdzxYmCo41tnEM2ifL9ZnXpRU6N5/4DTgtO5Si/rFOhYW1UEMoZ2xU8t5+TX6sT FlXbHNIj1X1nr1C4tb45a6nTX33JYLI2+fXLSB1YDlXZ6gJcSLnEqxV3iOYF/c8pQRnL xCMIAO8QAvLQlsk5jkcP2Aa4KAxGxJVtwAG1ac/bx3L7fjYVkDDVoUz98yyLfrpo46r2 PX3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=RdFfgECC; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=arQXjg4W; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-65118-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65118-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de X-Forwarded-Encrypted: i=2; AJvYcCUSBbbX8Oj+/xqO8uPucYjKphS5b+/zv7c/B6HmohgDPCMj9Jmk/mtQz9n4bYayuTe9vrDFsQxoAGGmUiOmcknC7i6ahNsHSb3NkO0V4A== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b17-20020a056a000cd100b006e0cfe7ad50si6155267pfv.102.2024.02.14.03.23.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:23:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65118-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm3 header.b=RdFfgECC; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=arQXjg4W; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-65118-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65118-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3BBDE281985 for ; Wed, 14 Feb 2024 11:23:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F250199C2; Wed, 14 Feb 2024 11:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="RdFfgECC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="arQXjg4W" Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF26C1946B for ; Wed, 14 Feb 2024 11:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707909799; cv=none; b=QnrqHBy8sxTAUMT75gG3L/sMYGJGlHoKTzbhEskjUExTZXTWlHDSiSf2Q++lwkE0aiY6TuZu8Mg63JJVurMsNpUrEgIL3CBX20nWNvRX4ZoPt8Jrau3lQJDxbGPgAORRRiDC8LXhPBNebh35pmVfd721FeLX18MoaPlEC5Pwha0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707909799; c=relaxed/simple; bh=aNjYCTOTHhRmSRZFRYqfmCVM93esw7nPSRqBG2xTjts=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=Fzf1J5xmpD4Y+5Naq5JRspnjGRcfvZ4hTffPBFa22B/kqUk/dAFzPdAEKNAAUgQrZyviriGU3v6PYpOlz7nYB4GA/u1mTbR4A4t0xqZbKRNUpDdhRw/I9mPXt/dAcmMp0j/W1xs1hPxToshas+S2MvuvhZKCm8wIcbFyWa8BaR8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=RdFfgECC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=arQXjg4W; arc=none smtp.client-ip=64.147.123.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id A8C893200A0A; Wed, 14 Feb 2024 06:23:15 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Wed, 14 Feb 2024 06:23:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1707909795; x=1707996195; bh=bNyMKCwVt1 3/eR+EwpIRTRHK69mX0eVQLKEM2trCPPA=; b=RdFfgECCdp6wlwUXICQNsf5Rb+ ZQ2Oz5IxXDVRtHyV9dlmC/0010T/LMbJWOfHuPq+fPaa3J0S3j9d8Pbn7WURsVRZ SWDKk/7JIiWE+b1Qz6k3N8lono89jxvnWfAxbWsqalMMmHcB7k5/qSFz1E3L6ALP czWrjxLqfvW7Kb4L3ZM1QAvtu8Pstprnhe+dW1Rlwv5Iq1SyUW+dFY0D/g2SEpSR SpuWxy5l8GEiuVx+cwGwLo5XaI9PnrkP5niLE3D+VdtkxjxGplgb3N1JWRboHGJZ fkKsViqi1QOyiE3Jd0BW5b7bV+wXqSCDd6UO7ACt5r8mO7wvGZ8Pt8sCaV3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1707909795; x=1707996195; bh=bNyMKCwVt13/eR+EwpIRTRHK69mX 0eVQLKEM2trCPPA=; b=arQXjg4WnBwUbbnGKQu9ploOH8aLj5cSGhOWocdqhzp1 f3rSf+l+tgTIMInXVhqYdZgMV507SYg9+I1gNodQgL/qvOYfD7sHej0M9+id+hfS uU53s6/XqeYona+xESj0goIpO79T0r4tpT5B78GgxHZCgDP5W8Fu6k3MLCEyO7sl IcU1lUzm01PTmxtfC7tK2eBqNCZFF7ynGvOPEcRSZKqn2UE1A3YEJ9YN25PNpepN 4/vhZNyH1GXrWduckGNU7UdyYG5JI36wy6f5Aa8XACDwZJhy1i+7MSJb2C5yA0bZ sHOPMVF1HcGRn/iPBeT7Vnz+yk6tqo1hWEutlAiIgg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudejgddvjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id C8C21B6008F; Wed, 14 Feb 2024 06:23:14 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-144-ge5821d614e-fm-20240125.002-ge5821d61 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <165cec24-680e-4d3e-883e-56fccbb4d7d9@app.fastmail.com> In-Reply-To: <20240214035524.1245615-1-vattunuru@marvell.com> References: <20240214035524.1245615-1-vattunuru@marvell.com> Date: Wed, 14 Feb 2024 12:22:53 +0100 From: "Arnd Bergmann" To: "Vamsi Attunuru" , "Greg Kroah-Hartman" Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] misc: mrvl-dpi: add octeontx3 dpi driver Content-Type: text/plain On Wed, Feb 14, 2024, at 04:55, Vamsi Attunuru wrote: > Adds PCIe PF driver for OcteonTx3 DPI PF device which initializes DPI > DMA hardware's global configuration and enables PF-VF mbox channels > which can be used by it's VF devices. This DPI PF driver handles only > the resource configuration requests from VFs and it does not have any > data movement functionality. > > Signed-off-by: Vamsi Attunuru This looks incomplete, as there is no apparent interface to actually use the driver from either userspace or kernel. I understand that you want to merge this one step at a time, but please try to at least point out how this is intended to be used, or post it together with an (in-kernel) user if you plan to upstream that. Is this used for anything other than networking? If not, maybe it should be part of drivers/net/ instead of drivers/misc. A few more things that Greg hasn't already commented on: > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > index 4fb291f0bf7c..3142fdb1b4c0 100644 > --- a/drivers/misc/Kconfig > +++ b/drivers/misc/Kconfig > @@ -574,6 +574,16 @@ config NSM > To compile this driver as a module, choose M here. > The module will be called nsm. > > +config MARVELL_OCTEONTX3_DPI > + tristate "OcteonTX3 DPI driver" Is OcteonTX3 an actual product name? I thought the follow-up to OcteonTX2 (cn9[268]xx) was the OCTEON 10 line. Or is this a follow-up to the Marvell Armada (cn91xx) line? > +static void dpi_poll_pfvf_mbox(struct dpipf *dpi) > +{ > + u64 reg; > + u32 vf; > + > + reg = dpi_reg_read(dpi, DPI_MBOX_VF_PF_INT); > + if (reg) { > + for (vf = 0; vf < DPI_MAX_VFS; vf++) { > + if (!(reg & (0x1UL << vf))) > + continue; > + > + if (!dpi->mbox[vf]) { > + dev_err(&dpi->pdev->dev, "bad mbox vf %d\n", vf); > + continue; > + } > + > + schedule_work(&dpi->mbox[vf]->wk.work); > + } > + > + if (reg) > + dpi_reg_write(dpi, DPI_MBOX_VF_PF_INT, reg); > + } > +} > + > +static irqreturn_t dpi_mbox_intr_handler(int irq, void *data) > +{ > + struct dpipf *dpi = data; > + > + dpi_poll_pfvf_mbox(dpi); > + > + return IRQ_HANDLED; > +} Have you considered using the drivers/mailbox framework for the mailbox portion? > +static void dpi_pfvf_mbox_work(struct work_struct *work) > +{ > + struct dpi_pfvf_mbox_wk *wk = container_of(work, struct > dpi_pfvf_mbox_wk, work); > + union dpi_mbox_message_t msg = { 0 }; > + struct dpi_mbox *mbox = NULL; > + struct dpipf_vf *dpivf; > + struct dpipf *dpi; > + int vf_id; > + > + mbox = (struct dpi_mbox *)wk->ctxptr; > + dpi = (struct dpipf *)mbox->pf; Can these pointers be strictly typed instead of casting from a void*? > +static int dpi_pfvf_mbox_setup(struct dpipf *dpi) > +{ > + int vf; > + > + for (vf = 0; vf < DPI_MAX_VFS; vf++) { > + dpi->mbox[vf] = vzalloc(sizeof(*dpi->mbox[vf])); > + dpi->mbox[vf] does not look excessively large, so I think kzalloc() is better than vzalloc() here. > +module_init(dpi_init_module); > +module_exit(dpi_cleanup_module); > +MODULE_DEVICE_TABLE(pci, dpi_id_table); > +MODULE_AUTHOR("Marvell International Ltd."); > +MODULE_DESCRIPTION(DPI_DRV_STRING); > +MODULE_LICENSE("GPL"); > +MODULE_VERSION(DPI_DRV_VERSION); Please remove the DPI_DRV_STRING and DPI_DRV_VERSION macros, they prevent grepping for the strings. > diff --git a/drivers/misc/mrvl-dpi/dpi.h b/drivers/misc/mrvl-dpi/dpi.h > new file mode 100644 > index 000000000000..99ebe6bbe577 > --- /dev/null > +++ b/drivers/misc/mrvl-dpi/dpi.h > @@ -0,0 +1,232 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* Marvell OcteonTx3 DPI driver > + * > + * Copyright (C) 2024 Marvell International Ltd. > + */ > + > +#ifndef __DPI_H__ > +#define __DPI_H__ I see no need for a separate header file if there is no other driver including it, so just merge this all into the .c file. > +union dpi_mbox_message_t { > + uint64_t u[2]; > + struct dpi_mbox_message_s { > + /* VF ID to configure */ > + uint64_t vfid :8; > + /* Command code */ > + uint64_t cmd :4; > + /* Command buffer size in 8-byte words */ > + uint64_t csize :14; > + /* aura of the command buffer */ > + uint64_t aura :20; > + /* SSO PF function */ > + uint64_t sso_pf_func :16; > + /* NPA PF function */ > + uint64_t npa_pf_func :16; > + /* Work queue completion status enable */ > + uint64_t wqecs :1; > + /* Work queue completion status byte offset */ > + uint64_t wqecsoff :7; > + } s __packed; > +}; Is this a hardware structure? If it is, you probably don't want to use bit fields here, even in the best case that is a bug that prevents you from using the driver in big-endian mode. I also see that there are only 86 bits defined, and one field crosses a 64-bit boundary, which feels odd. Arnd