Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp372158lqb; Tue, 28 May 2024 19:47:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGGFaXA+u/SUCBHFH0ifte1c+5TYC7CKvYod9tbxqV8z52lg8D2Q+MapXaYKPQofRTavnvjgbsWOv5uj4rD2qcPQEORMN9VmXCny/jGg== X-Google-Smtp-Source: AGHT+IFpnKmk9ECQebSJnXC016jHrqcggyQu2YPgds+c5fubULHbT4Yr+k1rjuiajXrQio5Nii+h X-Received: by 2002:a81:a1c9:0:b0:627:8791:5c4 with SMTP id 00721157ae682-62a08d2aab2mr135038007b3.8.1716950833706; Tue, 28 May 2024 19:47:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716950833; cv=pass; d=google.com; s=arc-20160816; b=wnWojYhGVZk/7v91jgt5Hyoffkzq+S9aAm5U/EJ+GRGac43BP94ncouX51ZcdhkfUD 5WApuWAX8ssxCo3rndJEcazEDqWMXE4fo5JlOzONocoEXcT5bioCNRjcwZYHv/uL7jo1 vvW1VXC20zYyYSVpqiNb5EaJ68bfe0o0SHbe7rQdCAe6tmganP6chrLQdydSjuoANb6N OAXLW1MXy9rbV6tzA8ctmgYjmafUNuO8u/5/R2nv2S5UZ93W9CKgtvZ64/QndMu+wBnO IVDAqIMBFefminiRvqRhF0FVkIoCPvghXAo85rNYigY2wiSVRNxInZAUgMd1PvPVjuXB 58OQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=kU0rjq9Y3/vPwOLsm7k/OMiADPQ86g1+gN5BGzDO2FQ=; fh=igSMzE2xcdhoFswFxuIoUHITWLZsk4CBFWwY4PiG3C8=; b=X1jxukX5E32B5og7iYsPi+LYJGOsEYM8QoVaCnpkY5mnwRvSsgCoZI6yhli3QgXyT6 oNRpv7zA43IhrE/FqkwNwI9MzBmomYxk83GbtzfOIUp4KbXtt8jw3FAbY4MULOAypDti 3m0WM5jsLmHRIIa0c1JLSF0cslrs9fJhbVmMnkHGsSXqRw5Laz/9G40bnuVaBofCw7Z+ tyVYhQyYVMg6a9ht79Iwttnd8l8dKv5xDXj+B9Zn5h2reSN68LwNbq+41YkaR9LPUNg5 GZYkk8Ek6p6hvG2j5l6kOV7Aehj6BDubUOniROQ6xBag1vuQNCAh3R8nixJffviYC2qz 5l9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cr7aLzOu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221b757a8si9815475a12.165.2024.05.28.19.47.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 19:47:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cr7aLzOu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193383-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2C566B22643 for ; Wed, 29 May 2024 02:46:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4ADE315B103; Wed, 29 May 2024 02:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cr7aLzOu" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6113228E8; Wed, 29 May 2024 02:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716950759; cv=none; b=PIGcwskIuQ+h3+zLUNK0LUBiXet8mmQZWTlcre8CDzFoqnYxU1KK1F3XeakoXnueXyVh7roaknIOrOzhf/sRJZxM+UNfgNh3XtPILcPYOxXhT+eC7KU0w+D+pcWoF5VA3ZPftHK8so51NqlZHNBDksOwX1QmaBO00D7zOpw6YRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716950759; c=relaxed/simple; bh=YNB+3eDBjI3xG8Rb1/MLEq3QCHjbZGBsVk7x/zHsfRY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xvl44gfpPylBIN6ATVbsTTJ2UZStW+lrWwLihHLFCpahLD4p2SpA+JA4sKvSDoHGYkVfQOE31ER2RZo3HIwqgPA2o4+hjt0BKVlEfGy3OMyTNMRabQS12f47j4VCbjy34zrR6g9xiT/GYEzCYU7LOnBUgUkDw1rEvCi9f2fHuwY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cr7aLzOu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9810FC3277B; Wed, 29 May 2024 02:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716950759; bh=YNB+3eDBjI3xG8Rb1/MLEq3QCHjbZGBsVk7x/zHsfRY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cr7aLzOuZvv9maRdMkD+mou4kKjLCYDyTEGdehFO3Mniifm3DP26fooGwDqSL2FXK wEF03DlOnkkt2iHPG4hK5/qUz/QRc96yd6JXBHYz8Iz7QU6lpNej1sWc8JK70t9IRU kvbW8NW2QK3URk929xOEEzLsgRfnCovq0E4ZOpCtMScSyi/Tyl1A8nxmFed37glRSh lAECehfRSCIu+q7VviTSZOsh7HzHIcZ85xdhjxEgJJ6ukecOOX5VD4XdR/K0zBSs9U Se4r2TIdvHnps8Zv5Ex5IL0GeKuge9Vg35a5kX33z87cGxhGcVf+VaFF+B32ca6rE8 /kFNA90dKdt1A== Date: Tue, 28 May 2024 19:45:57 -0700 From: Jakub Kicinski To: admiyo@os.amperecomputing.com Cc: Jeremy Kerr , Matt Johnston , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] mctp pcc: Implement MCTP over PCC Transport Message-ID: <20240528194557.7a8f522d@kernel.org> In-Reply-To: <20240528191823.17775-4-admiyo@os.amperecomputing.com> References: <20240513173546.679061-1-admiyo@os.amperecomputing.com> <20240528191823.17775-1-admiyo@os.amperecomputing.com> <20240528191823.17775-4-admiyo@os.amperecomputing.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 28 May 2024 15:18:23 -0400 admiyo@os.amperecomputing.com wrote: > From: Adam Young > > Implementation of DMTF DSP:0292 > Management Control Transport Protocol(MCTP) over > Platform Communication Channel(PCC) > > MCTP devices are specified by entries in DSDT/SDST and > reference channels specified in the PCCT. > > Communication with other devices use the PCC based > doorbell mechanism. Missing your SoB, but please wait for more feedback before reposting. > +#include Hm, what do you need this include for? > +#define SPDM_VERSION_OFFSET 1 > +#define SPDM_REQ_RESP_OFFSET 2 > +#define MCTP_PAYLOAD_LENGTH 256 > +#define MCTP_CMD_LENGTH 4 > +#define MCTP_PCC_VERSION 0x1 /* DSP0253 defines a single version: 1 */ > +#define MCTP_SIGNATURE "MCTP" > +#define SIGNATURE_LENGTH 4 > +#define MCTP_HEADER_LENGTH 12 > +#define MCTP_MIN_MTU 68 > +#define PCC_MAGIC 0x50434300 > +#define PCC_DWORD_TYPE 0x0c Could you align the values using tabs? > +static void mctp_pcc_client_rx_callback(struct mbox_client *c, void *buffer) > +{ > + struct mctp_pcc_ndev *mctp_pcc_dev; > + struct mctp_skb_cb *cb; > + struct sk_buff *skb; > + u32 length_offset; > + u32 flags_offset; > + void *skb_buf; > + u32 data_len; > + u32 flags; > + > + mctp_pcc_dev = container_of(c, struct mctp_pcc_ndev, inbox_client); > + length_offset = offsetof(struct mctp_pcc_hdr, length); > + data_len = readl(mctp_pcc_dev->pcc_comm_inbox_addr + length_offset) + > + MCTP_HEADER_LENGTH; > + > + skb = netdev_alloc_skb(mctp_pcc_dev->mdev.dev, data_len); > + if (!skb) { > + mctp_pcc_dev->mdev.dev->stats.rx_dropped++; > + return; > + } > + mctp_pcc_dev->mdev.dev->stats.rx_packets++; > + mctp_pcc_dev->mdev.dev->stats.rx_bytes += data_len; Please implement ndo_get_stats64, use of the core dev stats in drivers is deprecated: * @stats: Statistics struct, which was left as a legacy, use * rtnl_link_stats64 instead > + skb->protocol = htons(ETH_P_MCTP); > + skb_buf = skb_put(skb, data_len); > + memcpy_fromio(skb_buf, mctp_pcc_dev->pcc_comm_inbox_addr, data_len); > + skb_reset_mac_header(skb); > + skb_pull(skb, sizeof(struct mctp_pcc_hdr)); > + skb_reset_network_header(skb); > + cb = __mctp_cb(skb); > + cb->halen = 0; > + skb->dev = mctp_pcc_dev->mdev.dev; netdev_alloc_skb() already sets dev > + netif_rx(skb); > + > + flags_offset = offsetof(struct mctp_pcc_hdr, flags); > + flags = readl(mctp_pcc_dev->pcc_comm_inbox_addr + flags_offset); > + mctp_pcc_dev->in_chan->ack_rx = (flags & 1) > 0; > +} > + > +static netdev_tx_t mctp_pcc_tx(struct sk_buff *skb, struct net_device *ndev) > +{ > + struct mctp_pcc_hdr pcc_header; > + struct mctp_pcc_ndev *mpnd; > + void __iomem *buffer; > + unsigned long flags; > + int rc; > + > + netif_stop_queue(ndev); Why? > + ndev->stats.tx_bytes += skb->len; > + ndev->stats.tx_packets++; > + mpnd = (struct mctp_pcc_ndev *)netdev_priv(ndev); > + > + spin_lock_irqsave(&mpnd->lock, flags); > + buffer = mpnd->pcc_comm_outbox_addr; > + pcc_header.signature = PCC_MAGIC; > + pcc_header.flags = 0x1; > + memcpy(pcc_header.mctp_signature, MCTP_SIGNATURE, SIGNATURE_LENGTH); > + pcc_header.length = skb->len + SIGNATURE_LENGTH; > + memcpy_toio(buffer, &pcc_header, sizeof(struct mctp_pcc_hdr)); > + memcpy_toio(buffer + sizeof(struct mctp_pcc_hdr), skb->data, skb->len); > + rc = mpnd->out_chan->mchan->mbox->ops->send_data(mpnd->out_chan->mchan, > + NULL); > + spin_unlock_irqrestore(&mpnd->lock, flags); > + > + dev_consume_skb_any(skb); > + netif_start_queue(ndev); > + if (!rc) > + return NETDEV_TX_OK; > + return NETDEV_TX_BUSY; > +} > + > +static const struct net_device_ops mctp_pcc_netdev_ops = { > + .ndo_start_xmit = mctp_pcc_tx, > + .ndo_uninit = NULL No need to init things to NULL > +static void mctp_pcc_driver_remove(struct acpi_device *adev) > +{ > + struct mctp_pcc_ndev *mctp_pcc_dev = NULL; > + struct list_head *ptr; > + struct list_head *tmp; > + > + list_for_each_safe(ptr, tmp, &mctp_pcc_ndevs) { > + struct net_device *ndev; > + > + mctp_pcc_dev = list_entry(ptr, struct mctp_pcc_ndev, next); > + if (adev && mctp_pcc_dev->acpi_device == adev) > + continue; > + > + mctp_pcc_dev->cleanup_channel(mctp_pcc_dev->out_chan); > + mctp_pcc_dev->cleanup_channel(mctp_pcc_dev->in_chan); > + ndev = mctp_pcc_dev->mdev.dev; > + if (ndev) > + mctp_unregister_netdev(ndev); > + list_del(ptr); > + if (adev) > + break; > + } > +}; spurious ; > + .owner = THIS_MODULE, > + suprious new line > +}; > + -- pw-bot: cr