From patchwork Mon May 13 17:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: admiyo@os.amperecomputing.com X-Patchwork-Id: 13663576 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2126.outbound.protection.outlook.com [40.107.220.126]) (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 E817520DE8; Mon, 13 May 2024 17:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.126 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621767; cv=fail; b=QYBEgcvO+rSbvUcw4csvDbfZHWKJHDa+T3TOQHvbhtRza0Ic6g47okyFzLcQpblBfSNk5r5LnTosw3reRByjQysU3LeiyCEECki0H2Ci0Na+wva+eyvRem6E0GQ8ctGRNlv62rZEGqhp9KwKbDeoQjRXNzgW3KFH1YI7MdHyavU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621767; c=relaxed/simple; bh=52/H4VhMWsBWCW5HZjL5onvCNziVYG4+OOtNsjYjuwc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bhRw55kmWecMdfRwP1o8VGMgnmcabMpX+GZ+BAikM4Nik1ppsypvkXnOcf0m59+PGoQagDXXkZxXGGEia/WObR7J50pPByS/Pp3pe6X3p4n4PYpXoNHhIEqGqoPp3oGiiqgW+MMEnzhZL2T3X1n5+qjfCNT5wa9Iab2LslkFKpk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=P8/+K7d1; arc=fail smtp.client-ip=40.107.220.126 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="P8/+K7d1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nau9tFpLKFj8JdJy4fgvGWi5CE5xJ41Rd/Wk/45vFkwY++JE15uFKMX8iiyaK0IjOk8xY4ssgyYoUui9qn2Qm9sQKyglrWe851BiIWRxKJGEeWvtHW+WtuBqn12hizxwcqj8sNC6lb4evOklI0eBmm8uWzk5dvkwxFZspcVG1s4LTdCI35oP6H8T7+QRaByTZq0Ldqll4UA/5F693VBD4sPYqDwxINNcqQ8IgRA3YjFbWGyn7HKHLIsIKUPKnrTTb+a+Fhm3cSV9ogivspmMXPCh199q2Qo+qqWAYTWng7u2Mx+5H9GB3qYoJ93KeSF1oEUe6Ui84uj4hkXp7XMGDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fb16iOyU4Z7n4VfqdhsTkXo/XtcuKHNZXhk2vH67qVk=; b=hPAfjoRey6XSJXG3gGpsLsyHojdl1cw9Y7V+0y+CWlCFma39PBYVRfpSJTlBHB8H/eYVS3NZ8u9biUn6VEdqXO/Fjk1Nk8KU7idZNttONR1hdjzNZAk6n8/canUv4WT7Gj1Oe350OwGAeWN46wCW8gBFwagvCJVapxOi6xT1JVWJ6gGy0tL2Y2WHi2//xUL5v5hD/mVFt6kAMGPYfpkuaj2uvoUu3JfVzRd5rwtdzga2OzP5tvjA3AQ3JVQSfT9tChGO91IHg1rW70Pup78MoLQuYrmKUGuS6BtegvoRVXmjxrsIOAMIh2MuX3vP2HPDtK1SnrrjTNTwdQiguaW/QQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Fb16iOyU4Z7n4VfqdhsTkXo/XtcuKHNZXhk2vH67qVk=; b=P8/+K7d1/29T2KziJLYop86ZbDtls4QV+6FcBp1lStfcjbDw/7DNcnHYVhpF2g9UX/fH3b1F+FUaw5kpXlZ7oZ4zERyZh38r02dX40XI2LFpq++zHgQDQoIqqjwU0/G/RJu2VAqVlVDrXDrCjs9B87RZymqQjiG/KmQ+GRFWxOI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SA0PR01MB6171.prod.exchangelabs.com (2603:10b6:806:e5::16) by SJ0PR01MB6191.prod.exchangelabs.com (2603:10b6:a03:296::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Mon, 13 May 2024 17:35:57 +0000 Received: from SA0PR01MB6171.prod.exchangelabs.com ([fe80::b0e5:c494:81a3:5e1d]) by SA0PR01MB6171.prod.exchangelabs.com ([fe80::b0e5:c494:81a3:5e1d%4]) with mapi id 15.20.7544.052; Mon, 13 May 2024 17:35:57 +0000 From: admiyo@os.amperecomputing.com To: Jeremy Kerr , Matt Johnston , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Young Subject: [PATCH 1/3] mctp pcc: Implement MCTP over PCC Transport Date: Mon, 13 May 2024 13:35:44 -0400 Message-Id: <20240513173546.679061-2-admiyo@os.amperecomputing.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513173546.679061-1-admiyo@os.amperecomputing.com> References: <20240513173546.679061-1-admiyo@os.amperecomputing.com> X-ClientProxiedBy: CH0PR13CA0012.namprd13.prod.outlook.com (2603:10b6:610:b1::17) To SA0PR01MB6171.prod.exchangelabs.com (2603:10b6:806:e5::16) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA0PR01MB6171:EE_|SJ0PR01MB6191:EE_ X-MS-Office365-Filtering-Correlation-Id: 73ed9d97-99bb-47cd-c707-08dc737325ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: +gtumCYfUDy5iLMwfkeftH9NS2VkhXNLK2ritKkIj8lgOACwUUdC4X8/DbdYR4pz96om6tnSDPvQMvypEzgcvm7jzadsjb27nX+jstmkxw0kKj1ZdbE96OFMIYwc6nsOCr8DSre299zA/rb7j3i7QN/0/UKWxqV3aLZ1lZLL24ZyYTPd9Hd/L+b0eWw5YGapb68JD3PpyUVHfDIAZUI02RnluSKeND2kmfj59Wp8pAzB8x65bJcohSL7J19f4xyA/ebqbH+b9nWzrOkLwACb5dYGZPf7EXdJ+cCau76JY4HaQo/UEk7ciSfi6quf5xqzCzP8sfYogv6dWO+QIV5RXrHRv1DUvnF5LncXKXWt9Rtls3yAJlxpgxJ5TaiBvzHJ+oC9Wbfmd+7b9GHcNosZ3cNGROFHfej8GZUYf60eD8PRekbi0ncFJg17NyH/K8SuM5b45i6a8kWeQTDAv4Pe/sI2MuuBTWGuGBC/xamKbGTgvgheVeaGB/o1p1ggFIYprzJPPfcLZUuDfYXzpxYn9H4+X7UkVAftcgryr/c6nI3IZOow4Oj2myxVUhY6lKGCTccxFamju4Pt0AgftbAnGlxj7GfHd6kVcuEw4o2VDebUWV93H7AVIpryFjDTELrUGlo26hxxd0Z8Tka+AlqF4bLQYKHF2n9b9eIwhRt/u6QfqUGIqCmMg3Qn1x28aPkC+AERkksJZTeuJ92bjx2g90ySMLzS3jdMvB0SVv+6M8vtpEjPemzGWt2sGruw5agS846OjPJ63U2IcsA166DXbRkaxFb7srpGqrVFxjH9dCBlpT3vLbp4G7m+qMefLyrTeSzmt68e9+ntqYdulCdzHzotbZNLLgvN0CfTds6oYSqryk8iEuYBb7cI/13sGu+l7LV0XxyEEmQcGcS+T9BMpMvcUBVN65UGdGY0GkRuCU5Kn+eQXv4dwE8C0w3CwsO5t1Zw8j1NrlTx+/WY9+gMTfI5E4yZ2C+I5AGlQZ52x/TToxd9wJD3sBxz97HgytYZ8e9OQRgKupYNI9sSt5SwBQooEF/BjMl00gmXrbXTpiLgFx2GLU5IiHuEPqweVvfdDQ9A9wL4TIHhJ9rkEQqQkrq9J2nBHdY2PuvC7GuMlnZ1yZIZznHnZy1GnjrhK0MhPPiB9ReN5BnE4RmNb7byEruYJushW8tKe8eF0Wn7xtlceIXk/evcnff0ljUkuoIME3v6dNbcKYCc2KhpGebH3s+k+hOUfErdT9QPG5NqNKE1wbwso7CbElhCJqkJqG7MVe3dl1FFBDFbc97SsoMHQw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR01MB6171.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(366007)(1800799015)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z61QdDj48keeTFtJ2rmNTb5ozKZ8u7OGdrDvZuTKtJNZQRCQYRaf/jOABn8+4C2lHcxSPYEbkpTmyJvG8NFdCVYa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363H7JV9DjWzireytmgZ8jPIPmCBcoOM0G3WdNpR7xE/K1vkaghYbJthT3se4UcQOXowAM/cuqYTiOawA7m0KcB85yWnTk6d5Xnjrm7ow3KAYc3/S8/dgycuEVylCKH5I+4Rr/6C5wZUsFi1HYtLui/mkCI/tQe7MByTWgBqFxDRoGijuhUchUdYh+pJ6RBWpomMY6EYzDnF8/UgDmRMnbKZQRIca9rfDEnd+W1aAQFy8ypSNSMwUO0rhhCX3ypwHgZsMfWAlucT8D9uOQL2vF5cylcmGs2nq8bQiFOBAY8qcNbr4Bvzkt3kSjy2HqNsPzjq93zdJWp5IKpJUSkfgk0K0+/KWcjb5cOi2/EAGzQ4gMnyfEd8bFcGCfOahNcD4IS6ffEiM9xc4Lyi8v5hiuyEbmsL2/5qnlZ0AqejUoF63BCP91VNS9u6EYRCLdowUWxdO8Kcg8I5BPez8oW98JcYf1NVo6cPYVmLKOn65qSNXG5np52bVxm6sfqGDhZU+tvAL4mQmxV3k3f7gWaWWOlyOlGb9lQRU= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73ed9d97-99bb-47cd-c707-08dc737325ba X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6171.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2024 17:35:57.2315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B2liY5dM0/ziK3mhlcsEej9pWFUD6n8gt8VKZH9lq63wQ0kFJEAS+dIZoDeL5VmQpvWGWajbo6CzmtZNIPQ+31/+yedztakCpiydHKfghPekKyiWpZqN/o09P85O5twL X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6191 X-Patchwork-Delegate: kuba@kernel.org 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. Signed-off-by: Adam Young --- drivers/net/mctp/Kconfig | 12 ++ drivers/net/mctp/Makefile | 1 + drivers/net/mctp/mctp-pcc.c | 368 ++++++++++++++++++++++++++++++++++++ 3 files changed, 381 insertions(+) create mode 100644 drivers/net/mctp/mctp-pcc.c diff --git a/drivers/net/mctp/Kconfig b/drivers/net/mctp/Kconfig index ce9d2d2ccf3b..16bad87c9a6f 100644 --- a/drivers/net/mctp/Kconfig +++ b/drivers/net/mctp/Kconfig @@ -42,6 +42,18 @@ config MCTP_TRANSPORT_I3C A MCTP protocol network device is created for each I3C bus having a "mctp-controller" devicetree property. +config MCTP_TRANSPORT_PCC + tristate "MCTP PCC transport" + select MCTP_FLOWS + help + Provides a driver to access MCTP devices over PCC transport, + A MCTP protocol network device is created for each entry int the DST/SDST + that matches the identifier. The PCC channels are selected from the + corresponding entries in the PCCT. + + Say y here if you need to connect to MCTP endpoints over PCC. To + compile as a module, use m; the module will be called mctp-pcc. + endmenu endif diff --git a/drivers/net/mctp/Makefile b/drivers/net/mctp/Makefile index e1cb99ced54a..492a9e47638f 100644 --- a/drivers/net/mctp/Makefile +++ b/drivers/net/mctp/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_MCTP_TRANSPORT_PCC) += mctp-pcc.o obj-$(CONFIG_MCTP_SERIAL) += mctp-serial.o obj-$(CONFIG_MCTP_TRANSPORT_I2C) += mctp-i2c.o obj-$(CONFIG_MCTP_TRANSPORT_I3C) += mctp-i3c.o diff --git a/drivers/net/mctp/mctp-pcc.c b/drivers/net/mctp/mctp-pcc.c new file mode 100644 index 000000000000..7242eedd2759 --- /dev/null +++ b/drivers/net/mctp/mctp-pcc.c @@ -0,0 +1,368 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * mctp_pcc.c - Driver for MCTP over PCC. + * Copyright (c) 2024, Ampere Computing LLC + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#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 + +struct mctp_pcc_hdr { + u32 signature; + u32 flags; + u32 length; + char mctp_signature[4]; +}; + +struct mctp_pcc_packet { + struct mctp_pcc_hdr pcc_header; + union { + struct mctp_hdr mctp_header; + unsigned char header_data[sizeof(struct mctp_hdr)]; + }; + unsigned char payload[MCTP_PAYLOAD_LENGTH]; +}; + +struct mctp_pcc_hw_addr { + int inbox_index; + int outbox_index; +}; + +/* The netdev structure. One of these per PCC adapter. */ +struct mctp_pcc_ndev { + struct list_head head; + /* spinlock to serialize access from netdev to pcc buffer*/ + spinlock_t lock; + struct mctp_dev mdev; + struct acpi_device *acpi_device; + struct pcc_mbox_chan *in_chan; + struct pcc_mbox_chan *out_chan; + struct mbox_client outbox_client; + struct mbox_client inbox_client; + void __iomem *pcc_comm_inbox_addr; + void __iomem *pcc_comm_outbox_addr; + struct mctp_pcc_hw_addr hw_addr; + void (*cleanup_channel)(struct pcc_mbox_chan *in_chan); +}; + +static struct list_head mctp_pcc_ndevs; + +static struct mctp_pcc_packet *mctp_pcc_extract_data(struct sk_buff *old_skb, + void *buffer, int outbox_index) +{ + struct mctp_pcc_packet *mpp; + + mpp = buffer; + writel(PCC_MAGIC | outbox_index, &mpp->pcc_header.signature); + writel(0x1, &mpp->pcc_header.flags); + memcpy_toio(mpp->pcc_header.mctp_signature, MCTP_SIGNATURE, SIGNATURE_LENGTH); + writel(old_skb->len + SIGNATURE_LENGTH, &mpp->pcc_header.length); + memcpy_toio(mpp->header_data, old_skb->data, old_skb->len); + return mpp; +} + +static void mctp_pcc_client_rx_callback(struct mbox_client *c, void *) +{ + struct sk_buff *skb; + struct mctp_pcc_packet *mpp; + struct mctp_skb_cb *cb; + int data_len; + unsigned long buf_ptr_val; + struct mctp_pcc_ndev *mctp_pcc_dev = container_of(c, struct mctp_pcc_ndev, inbox_client); + void *skb_buf; + + mpp = (struct mctp_pcc_packet *)mctp_pcc_dev->pcc_comm_inbox_addr; + buf_ptr_val = (unsigned long)mpp; + data_len = readl(&mpp->pcc_header.length) + 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; + } + skb->protocol = htons(ETH_P_MCTP); + skb_buf = skb_put(skb, data_len); + memcpy_fromio(skb_buf, mpp, 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; + netif_rx(skb); +} + +static netdev_tx_t mctp_pcc_tx(struct sk_buff *skb, struct net_device *ndev) +{ + unsigned char *buffer; + struct mctp_pcc_ndev *mpnd; + struct mctp_pcc_packet *mpp; + unsigned long flags; + int rc; + + netif_stop_queue(ndev); + ndev->stats.tx_bytes += skb->len; + mpnd = (struct mctp_pcc_ndev *)netdev_priv(ndev); + spin_lock_irqsave(&mpnd->lock, flags); + buffer = mpnd->pcc_comm_outbox_addr; + mpp = mctp_pcc_extract_data(skb, mpnd->pcc_comm_outbox_addr, mpnd->hw_addr.outbox_index); + rc = mpnd->out_chan->mchan->mbox->ops->send_data(mpnd->out_chan->mchan, mpp); + 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 +}; + +static void mctp_pcc_setup(struct net_device *ndev) +{ + ndev->type = ARPHRD_MCTP; + ndev->hard_header_len = 0; + ndev->addr_len = sizeof(struct mctp_pcc_hw_addr); + ndev->tx_queue_len = DEFAULT_TX_QUEUE_LEN; + ndev->flags = IFF_NOARP; + ndev->netdev_ops = &mctp_pcc_netdev_ops; + ndev->needs_free_netdev = true; +} + +static int create_mctp_pcc_netdev(struct acpi_device *acpi_dev, + struct device *dev, int inbox_index, + int outbox_index) +{ + int rc; + int mctp_pcc_mtu; + char name[32]; + struct net_device *ndev; + struct mctp_pcc_ndev *mctp_pcc_dev; + struct mctp_pcc_hw_addr physical_link_addr; + + snprintf(name, sizeof(name), "mctpipcc%x", inbox_index); + ndev = alloc_netdev(sizeof(struct mctp_pcc_ndev), name, NET_NAME_ENUM, mctp_pcc_setup); + if (!ndev) + return -ENOMEM; + mctp_pcc_dev = (struct mctp_pcc_ndev *)netdev_priv(ndev); + INIT_LIST_HEAD(&mctp_pcc_dev->head); + spin_lock_init(&mctp_pcc_dev->lock); + + mctp_pcc_dev->outbox_client.tx_prepare = NULL; + mctp_pcc_dev->outbox_client.tx_done = NULL; + mctp_pcc_dev->hw_addr.inbox_index = inbox_index; + mctp_pcc_dev->hw_addr.outbox_index = outbox_index; + mctp_pcc_dev->inbox_client.rx_callback = mctp_pcc_client_rx_callback; + mctp_pcc_dev->cleanup_channel = pcc_mbox_free_channel; + mctp_pcc_dev->out_chan = + pcc_mbox_request_channel(&mctp_pcc_dev->outbox_client, + outbox_index); + if (IS_ERR(mctp_pcc_dev->out_chan)) { + rc = PTR_ERR(mctp_pcc_dev->out_chan); + goto free_netdev; + } + mctp_pcc_dev->in_chan = + pcc_mbox_request_channel(&mctp_pcc_dev->inbox_client, + inbox_index); + if (IS_ERR(mctp_pcc_dev->in_chan)) { + rc = PTR_ERR(mctp_pcc_dev->in_chan); + goto cleanup_out_channel; + } + mctp_pcc_dev->pcc_comm_inbox_addr = + devm_ioremap(dev, mctp_pcc_dev->in_chan->shmem_base_addr, + mctp_pcc_dev->in_chan->shmem_size); + if (!mctp_pcc_dev->pcc_comm_inbox_addr) { + rc = -EINVAL; + goto cleanup_in_channel; + } + mctp_pcc_dev->pcc_comm_outbox_addr = + devm_ioremap(dev, mctp_pcc_dev->out_chan->shmem_base_addr, + mctp_pcc_dev->out_chan->shmem_size); + if (!mctp_pcc_dev->pcc_comm_outbox_addr) { + rc = -EINVAL; + goto cleanup_in_channel; + } + mctp_pcc_dev->acpi_device = acpi_dev; + mctp_pcc_dev->inbox_client.dev = dev; + mctp_pcc_dev->outbox_client.dev = dev; + mctp_pcc_dev->mdev.dev = ndev; + +/* There is no clean way to pass the MTU to the callback function + * used for registration, so set the values ahead of time. + */ + mctp_pcc_mtu = mctp_pcc_dev->out_chan->shmem_size - + sizeof(struct mctp_pcc_hdr); + ndev->mtu = mctp_pcc_mtu; + ndev->max_mtu = mctp_pcc_mtu; + ndev->min_mtu = MCTP_MIN_MTU; + + physical_link_addr.inbox_index = + htonl(mctp_pcc_dev->hw_addr.inbox_index); + physical_link_addr.outbox_index = + htonl(mctp_pcc_dev->hw_addr.outbox_index); + dev_addr_set(ndev, (const u8 *)&physical_link_addr); + rc = register_netdev(ndev); + if (rc) + goto cleanup_in_channel; + list_add_tail(&mctp_pcc_dev->head, &mctp_pcc_ndevs); + return 0; +cleanup_in_channel: + mctp_pcc_dev->cleanup_channel(mctp_pcc_dev->in_chan); +cleanup_out_channel: + mctp_pcc_dev->cleanup_channel(mctp_pcc_dev->out_chan); +free_netdev: + unregister_netdev(ndev); + free_netdev(ndev); + return rc; +} + +struct lookup_context { + int index; + int inbox_index; + int outbox_index; +}; + +static acpi_status lookup_pcct_indices(struct acpi_resource *ares, void *context) +{ + struct acpi_resource_address32 *addr; + struct lookup_context *luc = context; + + switch (ares->type) { + case 0x0c: + case 0x0a: + break; + default: + return AE_OK; + } + + addr = ACPI_CAST_PTR(struct acpi_resource_address32, &ares->data); + switch (luc->index) { + case 0: + luc->outbox_index = addr[0].address.minimum; + break; + case 1: + luc->inbox_index = addr[0].address.minimum; + break; + } + luc->index++; + return AE_OK; +} + +static int mctp_pcc_driver_add(struct acpi_device *adev) +{ + int inbox_index; + int outbox_index; + acpi_handle dev_handle; + acpi_status status; + struct lookup_context context = {0, 0, 0}; + + dev_info(&adev->dev, "Adding mctp_pcc device for HID %s\n", acpi_device_hid(adev)); + dev_handle = acpi_device_handle(adev); + status = acpi_walk_resources(dev_handle, "_CRS", lookup_pcct_indices, &context); + if (ACPI_SUCCESS(status)) { + inbox_index = context.inbox_index; + outbox_index = context.outbox_index; + return create_mctp_pcc_netdev(adev, &adev->dev, inbox_index, outbox_index); + } + dev_err(&adev->dev, "FAILURE to lookup PCC indexes from CRS"); + return -EINVAL; +}; + +/* pass in adev=NULL to remove all devices + */ +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) { + mctp_pcc_dev = list_entry(ptr, struct mctp_pcc_ndev, head); + if (!adev || mctp_pcc_dev->acpi_device == adev) { + struct net_device *ndev; + + 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; + } + } +}; + +static const struct acpi_device_id mctp_pcc_device_ids[] = { + { "DMT0001", 0}, + { "", 0}, +}; + +static struct acpi_driver mctp_pcc_driver = { + .name = "mctp_pcc", + .class = "Unknown", + .ids = mctp_pcc_device_ids, + .ops = { + .add = mctp_pcc_driver_add, + .remove = mctp_pcc_driver_remove, + .notify = NULL, + }, + .owner = THIS_MODULE, + +}; + +static int __init mctp_pcc_mod_init(void) +{ + int rc; + + pr_info("initializing MCTP over PCC\n"); + INIT_LIST_HEAD(&mctp_pcc_ndevs); + rc = acpi_bus_register_driver(&mctp_pcc_driver); + if (rc < 0) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering driver\n")); + return rc; +} + +static __exit void mctp_pcc_mod_exit(void) +{ + pr_info("Removing MCTP over PCC transport driver\n"); + mctp_pcc_driver_remove(NULL); + acpi_bus_unregister_driver(&mctp_pcc_driver); +} + +module_init(mctp_pcc_mod_init); +module_exit(mctp_pcc_mod_exit); + +MODULE_DEVICE_TABLE(acpi, mctp_pcc_device_ids); + +MODULE_DESCRIPTION("MCTP PCC device"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Adam Young "); From patchwork Mon May 13 17:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: admiyo@os.amperecomputing.com X-Patchwork-Id: 13663577 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2126.outbound.protection.outlook.com [40.107.220.126]) (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 40F012942F; Mon, 13 May 2024 17:36:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.126 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621768; cv=fail; b=pNAaYPORsMoTby6uPshGc2BD1HSP8TEkfr2cbz40SlWDvszZsC6qqkV78RmJUT93GhZ3WiSxHoWd2PVAmVJCxvA2tpT83TK2HabsKHVP1RinNjUqSwafqyNXL/9dxXVc5DSOsn8z95K3gezjjRRSGlt7z3qyoXfBoIVRlw0AcRM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621768; c=relaxed/simple; bh=qVD5OZHBTexxATXqWQf6ppmZ6NhfvbsEd5G7jaJjqSk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=r7vhctt5GqfOMCKiwNb+r4LCUKbUe9nfUvJI7t1528XgvFIm2g5CjgeiKFrZu0JeLqGiWO27t2auYZd5uVASVHpOkRH9MxaPce7/ukDINb9fz82sNfvULZzoCRui7UaM5/ayodJOq+1z5zNE3dtNIchs30zZ0EuF0d/UOyXVLkw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=QLLeO2Bx; arc=fail smtp.client-ip=40.107.220.126 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="QLLeO2Bx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V3bO1p7ACdYY9FcCgdPT2rsCvpvagx/MtkF6jBuE2i7G1uNmANPeLEy90u40c468iNovovm94nqJ9oZu8HyFftDDa1EkfwOKJCxtK59EdhNtJYnpp03xS/Py7kFP6WDxT609NDQYxcg9R2m6lAZfPZZ+BN8NQZWmfstQqIW3D4DKDpP3UI7+hOsbcd961SO6ePtNKOHeeRHIltlIQfZ0WW/w2k36hYfaAvHphIJXbrtAxc6WEk28SFV0abIl2QdxaXuN2Szp2NP9zLbHXEe67gxHKqOaA9fWeVuLPqPMff2e7dUz9RyBpbJhuUbX/S5YyV+GhGkAo0++7q6OxWzi0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=In696VHAypxUe5gZYlP56lwMGEgQ/XhOdsatFb55nGg=; b=Ajy45XVvTyLMN1Z+SiFWidurz1EMZHsJgGiXNWoTaG3cMRpLsQRsmbx/KR5cuwUlIIcjtmGgSZHODr3Zpdim8KKM7+Mp1HtnllihCZB2Pu15+9YIfxu8SJe7l0kxFXCXAjeANJOpDLqSVCrR9/s+KNJ85KXV2VS0W1HUU8Rs6y9mHjWHBeKucMOyctYtQr406ryehxHDNm3dYsoNQi/sXX8TODDC50jLJd7S0KFjO3cn9Lo8u98NsCc+x/mxfu5DqWzMC6MrrhWVCOOJv6i2DD7wwvdnoyBI/XEH5DxiQVXldmothhdUCQxkJeQwtBwafGmKJp+xukzZ8zPwozIZhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=In696VHAypxUe5gZYlP56lwMGEgQ/XhOdsatFb55nGg=; b=QLLeO2Bx+5y2Dc14RgYp4IJfzlROI8K/uAHNUnQlVCf8ZsllxyHxO+WqUGyEDMnbH0pAtzSVkk+J9WrBjlVQ31RMiDdUbF9jzqPb1lBV4uF1AGB8NxEIgi5EuPaYmDCVtJHPizQqh4mAuu6kaCS5B4U6EsQt2jz/CKhni3uJ+HE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SA0PR01MB6171.prod.exchangelabs.com (2603:10b6:806:e5::16) by SJ0PR01MB6191.prod.exchangelabs.com (2603:10b6:a03:296::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Mon, 13 May 2024 17:35:59 +0000 Received: from SA0PR01MB6171.prod.exchangelabs.com ([fe80::b0e5:c494:81a3:5e1d]) by SA0PR01MB6171.prod.exchangelabs.com ([fe80::b0e5:c494:81a3:5e1d%4]) with mapi id 15.20.7544.052; Mon, 13 May 2024 17:35:59 +0000 From: admiyo@os.amperecomputing.com To: Robert Moore , "Rafael J. Wysocki" , Len Brown Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Young Subject: [PATCH 2/3] mctp pcc: Allow PCC Data Type in MCTP resource. Date: Mon, 13 May 2024 13:35:45 -0400 Message-Id: <20240513173546.679061-3-admiyo@os.amperecomputing.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513173546.679061-1-admiyo@os.amperecomputing.com> References: <20240513173546.679061-1-admiyo@os.amperecomputing.com> X-ClientProxiedBy: CH3P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1e8::15) To SA0PR01MB6171.prod.exchangelabs.com (2603:10b6:806:e5::16) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA0PR01MB6171:EE_|SJ0PR01MB6191:EE_ X-MS-Office365-Filtering-Correlation-Id: cda03e03-a636-42df-4118-08dc73732738 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: f6ORLzHicEwiUCz7aH6nL/4yyKLc6RMulmVMskLrcdRK96kgS22rRa22+2rhiY+JDvpetTpIF+Tx1SzOB6NlbVnIXenLbo0SO6o/9tcCgS9cRQm9wlaxbN/2DM0b7kH0B+byChGd9U4FHfdcdmjwWlG0O+/JElaXiDUl0QWn2vyUhYj+ZLJf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ab1xGbPaCzt8yueU3v5bPjIxBhd7fr4G2ddTw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR01MB6171.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(366007)(1800799015)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ajZBdHG5m0vNUVd2tCQBZl6ELNXMRxcXt65vqOmkF4dD3MNsWoYOlCYPhn78HMf0HhZFmTh5JWw4Bi+XL5WgwDC/H0Q8J7ay3Ymzq5R5daR/JQz233jlDvCms5LxQfDyPraJ39tMZC8XZ8+1vedFnrC4AMup6+mzqz/tpzIWN3U/XxE3J0+Rtj+StouB5XlHaxgHd+jE2w1SByFdeg59UHttiRH4kHjtq/bOv3JpZYjmmnZNQ5fa2glUH+CR58Iq8G+mKbHLhi4T23HKvVA8VrribmlQPCIpkaHxc/IPPsscJn/spDlFR/vIYotHq2KsI4HJscZa05olq1Rghfq5alY3VLu2hIXdxp0ipxKGiJeDavuU1TaOOCtD1A/sCFUzLsKHt05COs0FS+ZI7OOg3Rq3CS3ICFnWsKazzTygei4NR6lZBQ67X86aMOxokTIBLZ+pH355I7gM3vwttru9DVLEtxcyBy0h8o/iuvUnYDpWNbxaJXYTm6B2FY9Dgsdc6oIFAaq5QFutHglrdUOpbRRcdFA0GPX5alKL4mHfB7vaym5GZupGns5ucxHiC6GTAyqP10fmzbu5WmoqjLx8fGYyRVo292DeQOp/m2HhBKwFWcx0ryv7ORpuGkbq5ouCaGp7uOUI5A+C/pEz2LX11r21l+wYstGNnX3qsjNzkGpB7bEjoS8+hrlpME9umtBQYhGYd1c4CnRZbbeeZKcSKAUHv9GqFBtFbHDmNxaWmgVfjms0pEQ2n/4dDrspgIz596AYouJQO61LIvKdCpTsrZx0nekTKzltIxYd7SunixoBZRcrktxaYXv4PlJOvYI2NZdmwub3jv/ufqCyMr6vckjvP5bhr3J0l8XUr6pnLFEiFmmcMco90ECxrm9XHV3V+ZvusoSdU1BIYpg901MvesDlc/iAtOJjY4f0gLwXB51jEzt5oL2GHeXhzK4NZxl5ra4nyWOQcQfNcRAAIND9TFeyG71i6GBmcxqUjMMCYvFzUzI52QGMG0RsssNaULIl5l2XypXFzDk29nWGyrazL5fzp7XbWVKx9Inkuu7TqP7Mf8GKtK15+JaJjzOnMApqyM84NIwPR26vwQ1jNFBHyzwAaDUlGHyn2rXhDSYZZLQly2oeugHpFPux+8oxaw09PCc2V0Dh21X88elejEHPQI5NsqPXSNes/on2oJh/lUbzuO6tEjoGFVklxAD+nTEYJtU6DtpZ2ztKU3BcBrdhyvknz+/Vq1p0VhSg2faXskwis8xYgYlAGg4Aq3i8En6eKl+arpDzYe/w1/3/5uz52SJvs5sYWo62BRv2X/Zfd6vw+KbZXHghuQCAofMKcZwJg9ODKZUQ5D3Y5zM8aODSOvUUrt+Ow7sAZ9ZXhVv11Ewy2f1HuJr4lu1lIHLN4j8um/WRJzOD/Et0c2xrTDvv+C8N1f2ycjhGNlqOiUb7OnPdfo+fAQvbjftxYnEQ/1lFuPAMnzthPOv9WzJjm9LsXxJS16L5Tca9JFxAdX3rn2ZLhG2a909u6FcDxEF7Wz/8BW1IZ9z6v9oLf7XtA/sCe6lMXRM+Eqoq0Zm4H2Lnm8hVbZQ2dCthcW7HtMPwZ+uyAJ/vTDkhC/VBtYj/WxcHy8s+XZp0SWetmtg/lO/WHy+qKVO/WI7uCJoOOrqvs/Yh7sbHIo7eulxmGx+gWGd1Tkuq/+foq4ooasvn/lSMCL8= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: cda03e03-a636-42df-4118-08dc73732738 X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6171.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2024 17:35:59.6838 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rIszyxfHe8GNcwFmcCFwXYwl0smcmzFEoZSVqOiHk2qMjT5SSatTKLny99UM43eGvhZfFFgReI6pxZTBrbP9gHilDJIO4mkmR1eA4umXUko9kvW4SgrN/r+KOZZUE7Sd X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6191 From: Adam Young Note that this patch sfor code that will be merged in via ACPICA changes. The corresponding patch in ACPCA has already merged. Signed-off-by: Adam Young --- drivers/acpi/acpica/rsaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c index fff48001d7ef..6bd9704f17b0 100644 --- a/drivers/acpi/acpica/rsaddr.c +++ b/drivers/acpi/acpica/rsaddr.c @@ -282,7 +282,7 @@ acpi_rs_get_address_common(struct acpi_resource *resource, /* Validate the Resource Type */ - if ((address.resource_type > 2) && (address.resource_type < 0xC0)) { + if ((address.resource_type > 2) && (address.resource_type < 0xC0) && (address.resource_type != 10)) { return (FALSE); } From patchwork Mon May 13 17:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: admiyo@os.amperecomputing.com X-Patchwork-Id: 13663578 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2126.outbound.protection.outlook.com [40.107.220.126]) (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 C03C82E642; Mon, 13 May 2024 17:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.126 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621770; cv=fail; b=W1vEu1KvOe6EoPiOKIUe0jBrIiWuB1/RP99CzzOORaU7XB/ErBOnGMjZHwgs8tAcb8a+KAfQznNiP4eXLZHEbw02i27JcWShK0FQNWad5yTsnp8p/6jDGDRitP970g6WVcKUCDmI61ly9yZnjWEo8fGr6GlVQhJFQaZpY8w6uWY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715621770; c=relaxed/simple; bh=8CBJDKs5VcadL2xD+UZfvIkQa2KAqeo0wah+iZ4bxG4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ajl/VELDaQlo1ERVPG5+LrwS8Y7d1gH+C/zANlsVi4+c/nT1hpN8yjjm33G6c/ZXJ3yrz3+iSsVabOS8grFcaVLSHpqFvfTectLdW/RycrQZ+XPQnV9gemxEbCRLydD3LOM81vsAAhQLD93HPWC3DFh3l69LkW1fQn6/GZpxuTM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=BuZ9CbA1; arc=fail smtp.client-ip=40.107.220.126 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="BuZ9CbA1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GmqUJhiPDWry6bY2rHhKSNTd9PU6/7CylGDtAcL+wDImg+tJuiPAGgya64RTxQJDcp2LDMAQESlZ5ecLwpFLMvGwBOQXk5OZivXRXvsTQ9d1kvK1VdDCbEG1aBuswlZQuNSZgeh2fO1QQPc33htJscktuknklNl/yQ8r7ga8BHQ3cqRgABwaRJZzv8OJllSS4wv4AM37VbOatMQo5CV3rMAnfCdXMhNxKBm9gWZZ4/0258anlEsQtmy6F//VXHja8lL1qiUlsh6c2fuEhsKYb+4KRCkHVaCau57q88uMU4fj+wPPEtshmYayk9W7bZaUGC2sojkr4pr0EPsiJgNn+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z1KGNTPhBzpsjkkHGgPTcFc6xWyKWmAWMQ3CQpC8C54=; b=SVpXCXSx0O4Ftzb7ET4RNkBZVghuW/lMCLjVJ9lfYHVxAiH7nuiy+6XDVKdRsqQ+fRlrzM5EoL3l6RMVfH0Kf8UvcPvF6ZK+cF4VOPbAohX7KKl1lQ7hKXjXUrKDRfijWfc5sEJkw+VqbvZ5Le5fm6QdIrUw6TRz7kyInPwjwqZfOfgjM/aO94WLt1bGbwL49jgwm7m1UqKhKFpA7GpjZ4hrDojmPoG7Cskg/al/Vx+nIzsSL6z1gvmM77a9XwlUbA5ScuxjdoJn6BLsCW58aEY3L7Bi+YwUyFPNxYRSuhc/15AEFn0X92MMwbnK0gq4lkZJEytP6EFQe4pjmcpA0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z1KGNTPhBzpsjkkHGgPTcFc6xWyKWmAWMQ3CQpC8C54=; b=BuZ9CbA1FjNa8u01NVPQTke+Qv7o5/lnEfltW44GNh8uJs9s4NHfQVL/Y6CUWY4b3TLefVIif+XlhxMbWv98jDvH9aUNdbo5IclS0Av00tRuqCEMoIXIWaF/mpg9j+AQQssFFDClGYzK3tUcVHHF+xUybdehumF9XPElReL5/GM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SA0PR01MB6171.prod.exchangelabs.com (2603:10b6:806:e5::16) by SJ0PR01MB6191.prod.exchangelabs.com (2603:10b6:a03:296::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Mon, 13 May 2024 17:36:03 +0000 Received: from SA0PR01MB6171.prod.exchangelabs.com ([fe80::b0e5:c494:81a3:5e1d]) by SA0PR01MB6171.prod.exchangelabs.com ([fe80::b0e5:c494:81a3:5e1d%4]) with mapi id 15.20.7544.052; Mon, 13 May 2024 17:36:03 +0000 From: admiyo@os.amperecomputing.com To: Sudeep Holla , Jassi Brar , Jeremy Kerr , Matt Johnston , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Robert Moore , "Rafael J. Wysocki" , Len Brown Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Young Subject: [PATCH 3/3] mctp pcc: RFC Check before sending MCTP PCC response ACK Date: Mon, 13 May 2024 13:35:46 -0400 Message-Id: <20240513173546.679061-4-admiyo@os.amperecomputing.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513173546.679061-1-admiyo@os.amperecomputing.com> References: <20240513173546.679061-1-admiyo@os.amperecomputing.com> X-ClientProxiedBy: CH0PR07CA0013.namprd07.prod.outlook.com (2603:10b6:610:32::18) To SA0PR01MB6171.prod.exchangelabs.com (2603:10b6:806:e5::16) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA0PR01MB6171:EE_|SJ0PR01MB6191:EE_ X-MS-Office365-Filtering-Correlation-Id: e757cf37-75a4-4f1a-f6e1-08dc7373297b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|366007|1800799015|376005|7416005|921011; X-Microsoft-Antispam-Message-Info: afnJk3pl47fftm4hIZcDht6tC7W+ZtZEpZtEcEXh2uFBw3oa3puDzFOiW1X9f0cHIAagcv7Vbud4wBNqDHNdieHPGedk6e8IRDt/DWx0+JWWhraGfSzUBO8NswQahADiSAENwvcoQ3OL0j0fzrGcLWfej2m/MJicqLtEsVZkE/WAXUnQrkx7Js7mxIBTPf9xiwgyLWdW3PXqY/SkRMyrSe1CsDJ64D/IbSW5CIUcczUW66+ALl/hCxTT7D0/JQsHK2SeeycMLP0gofcHuUXG2Z0tVGRf5vKgHWsnZC01uCwXHs3pjSOXUaXGIzAD0jxkC/HyHp+bV47s76htfNA5rMvNEIe+u32+PxtGrXk0vdQ86xZdduO2txuHFSbGjcMldcmsRTDl4QBQzvwDRBLQtXlV7g3jP2galEy1sYH7CyQ72yKVJ73VekQ8jAK6IlFaJkX+GmA6svZdFkuYoBLWL5iyEE5p6E7H06aNMLkU9KnIkSJ1CcdopoKXqsmSOsccsHX8qsK30Gg2z6gevYa2yEyj7X1FfTBtw4ZdW6lKRFtMgSUtPlW+TLwN5CWgaAo5zpzaAUNLNROfKysnp4VD2CyPrMk/mugbIrDc0PVtUo3QK37Row8JiESNX0OpxL79gAcaX4g3oy3+yJpyGBiqtT4VSt6SVfTCEqv7PNk9iKi0WjyxSo/zapU8XxFau3/UYep2oDgpbYpVvRUetFnuX0meFfqAbpETaqwOMUXpaslag26HnY33X9JVctnLo1/zRVxJlwjssS1zGNk21qubsQWwkIhf/f0ZsZN/ysLzLqd+8v5sVuTQ1ZdvCK1q/98BXCjn5GMcI8y8xnogqL0/1pJKxgz8CfyscnBrU8tR8sHq47VOak5RlKGFh3ANZVYo4imscGf0XfnUxBxakoDPVZI0OEf3MjFE66d4d2CxgDleTy/N1OT6Tx2Vbyuty3TjaIIjI1i/CGY996/pRX3CweY3KqhMd7lNE5pTOvbbuLDsCJXzWsVAQYUnWRZc1B02qxwdRV3ovFD6lTyFVw+H04E7AWXxIYAc69fzh4bI/XzmiZhDLUtVJnng3uv8RQRX5E13TLOvikM5zJ1AE66JLbRnDeEfKVstKGb71tmT3veol+jjRUIlMCl0wnjnzQhJtJicFdi9FUTfKFKGBWvhf5O2/lvS8BypvOxXbPoHoIWujOGznTaGaluBZs6ZHZnd3UDuw+Up2MrxNc5E94eTHViwToPiz4gUSYUfyP6sSVicbLZZJkpsjeS3s678Wk/fwHYOvDvFln13BX79nNV7gn2EclKksK1B2K+Qr7KBjSP6Sy29QRskwLDbU78c/sYc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA0PR01MB6171.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(366007)(1800799015)(376005)(7416005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kErUBXLVwIVvACmMPYRwQIEewHzV3N7cfaDA8nFzWv2NK7f9Bd3PfKJqGyD16mUPLN4RiJDB92pAUgZ5IjcAV4GYj1VfFRB0TUsrfHsaF/KydJY99F/BKvsf/yFmBuuTi79D34LefjBTjboNhFoGnVNTpkYhKznh6wNw9Rhss74tePt3oj1ITMsXp5htpMNiU1TjTMyvPdWkNUa6xiB9tp59Jo91lHwDTIbklAzIxMLMNmtFXwQkXMh5G2Fjbcuep9RuXakgA1L5uBEgsw7ne3A3Bv+L7lkDR02ww0oLYsJ01XXOexpwTL6GqvfgKWUe6rc7LgfWyFCsSCwC2jV006d2Pk9Epr3dveqy0/yIeA/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0gK3VqUXZI/VB1ORFB6x6cvfKDxne4LQiVwt3eporbLK5uMWeZbgSz1LYc40G8Qvv9wYGR+nAoiicKE70qf6na0RpblwtLldpBXjtjQlgWk2ep2TVgH6XSEmHbLSp4mSWpgPwyyADY4554eP+X0UcY4sDeRAOQMmjQyQh/8yuDFrqoHcpzEzaHKxghx9Xu7cJezNYCYZ1rUnb/D/jQxHUVOtOWCHdDuS5Ia6Zh4D+SmR+Ie9D78r9dVNtxW91LfvhqCc= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e757cf37-75a4-4f1a-f6e1-08dc7373297b X-MS-Exchange-CrossTenant-AuthSource: SA0PR01MB6171.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2024 17:36:03.4913 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: voYGs8TXDRB7tQnc8f8A+Y2DXCjyL4pGxPa1qgUd7LnvAKnkr1Dy78cEBkkX1ELciBCmsJrmMMQBwNOED9DaVtkLYWu9ARR1xHtFUEka6kpLM/REflMrWk+aH+8iwFXq X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6191 X-Patchwork-Delegate: kuba@kernel.org From: Adam Young Type 4 PCC channels have an option to send back a response to the platform when they are done processing the request. The flag to indicate whether or not to respond is inside the message body, and thus is not available to the pcc mailbox. Since only one message can be processed at once per channel, the value of this flag is checked during message processing and passed back via the channels global structure. Ideally, the mailbox callback function would return a value indicating whether the message requires an ACK, but that would be a change to the mailbox API. That would involve some change to all of the mailbox based drivers. Signed-off-by: Adam Young --- drivers/mailbox/pcc.c | 5 ++++- drivers/net/mctp/mctp-pcc.c | 4 ++++ include/acpi/pcc.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 94885e411085..774727b89693 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -280,6 +280,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) { struct pcc_chan_info *pchan; struct mbox_chan *chan = p; + struct pcc_mbox_chan *pmchan; u64 val; int ret; @@ -304,6 +305,8 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) return IRQ_NONE; + pmchan = &pchan->chan; + pmchan->ack_rx = true; //TODO default to False mbox_chan_received_data(chan, NULL); /* @@ -312,7 +315,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) * * The PCC master subspace channel clears chan_in_use to free channel. */ - if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE) + if ((pchan->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE) && pmchan->ack_rx) pcc_send_data(chan, NULL); pchan->chan_in_use = false; diff --git a/drivers/net/mctp/mctp-pcc.c b/drivers/net/mctp/mctp-pcc.c index 7242eedd2759..3df45b86ea03 100644 --- a/drivers/net/mctp/mctp-pcc.c +++ b/drivers/net/mctp/mctp-pcc.c @@ -96,6 +96,7 @@ static void mctp_pcc_client_rx_callback(struct mbox_client *c, void *) unsigned long buf_ptr_val; struct mctp_pcc_ndev *mctp_pcc_dev = container_of(c, struct mctp_pcc_ndev, inbox_client); void *skb_buf; + u32 flags; mpp = (struct mctp_pcc_packet *)mctp_pcc_dev->pcc_comm_inbox_addr; buf_ptr_val = (unsigned long)mpp; @@ -115,6 +116,9 @@ static void mctp_pcc_client_rx_callback(struct mbox_client *c, void *) cb->halen = 0; skb->dev = mctp_pcc_dev->mdev.dev; netif_rx(skb); + + flags = readl(&mpp->pcc_header.flags); + 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) diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index 9b373d172a77..297913378c2b 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -16,6 +16,7 @@ struct pcc_mbox_chan { u32 latency; u32 max_access_rate; u16 min_turnaround_time; + bool ack_rx; }; /* Generic Communications Channel Shared Memory Region */