Thread (4 messages) 4 messages, 3 authors, 2025-04-18

Re: [PATCH net-next v18 1/1] mctp pcc: Implement MCTP over PCC Transport

From: Jakub Kicinski <kuba@kernel.org>
Date: 2025-02-25 02:11:18
Also in: lkml

On Thu, 20 Feb 2025 13:34:10 -0500 admiyo@os.amperecomputing.com wrote:
quoted hunk ↗ jump to hunk
+MANAGEMENT COMPONENT TRANSPORT PROTOCOL (MCTP) over PCC (MCTP-PCC) Driver
+M:	Adam Young <admiyo@os.amperecomputing.com>
+L:	netdev@vger.kernel.org
You can drop the L:, AFAIK, it's going to be inherited from next layer
of entries.
quoted hunk ↗ jump to hunk
+S:	Maintained
+F:	drivers/net/mctp/mctp-pcc.c
+
quoted hunk ↗ jump to hunk
+static netdev_tx_t mctp_pcc_tx(struct sk_buff *skb, struct net_device *ndev)
+{
+	struct mctp_pcc_ndev *mpnd = netdev_priv(ndev);
+	struct mctp_pcc_hdr  *mctp_pcc_header;
+	void __iomem *buffer;
+	unsigned long flags;
+	int len = skb->len;
+
+	dev_dstats_tx_add(ndev, len);
To be safe you should call:

	if (skb_cow_head(skb, ..

to make sure skb isn't a clone.
quoted hunk ↗ jump to hunk
+	spin_lock_irqsave(&mpnd->lock, flags);
+	mctp_pcc_header = skb_push(skb, sizeof(struct mctp_pcc_hdr));
+	buffer = mpnd->outbox.chan->shmem;
+	mctp_pcc_header->signature = cpu_to_le32(PCC_MAGIC | mpnd->outbox.index);
+	mctp_pcc_header->flags = cpu_to_le32(PCC_HEADER_FLAGS);
+	memcpy(mctp_pcc_header->mctp_signature, MCTP_SIGNATURE,
+	       MCTP_SIGNATURE_LENGTH);
+	mctp_pcc_header->length = cpu_to_le32(len + MCTP_SIGNATURE_LENGTH);
+
+	memcpy_toio(buffer, skb->data, skb->len);
+	mpnd->outbox.chan->mchan->mbox->ops->send_data(mpnd->outbox.chan->mchan,
+						    NULL);
+	spin_unlock_irqrestore(&mpnd->lock, flags);
+
+	dev_consume_skb_any(skb);
+	return NETDEV_TX_OK;
+}
quoted hunk ↗ jump to hunk
+static int mctp_pcc_driver_add(struct acpi_device *acpi_dev)
+{
+	struct mctp_pcc_lookup_context context = {0, 0, 0};
+	struct mctp_pcc_ndev *mctp_pcc_ndev;
+	struct device *dev = &acpi_dev->dev;
+	struct net_device *ndev;
+	acpi_handle dev_handle;
+	acpi_status status;
+	int mctp_pcc_mtu;
+	char name[32];
+	int rc;
+
+	dev_dbg(dev, "Adding mctp_pcc device for HID %s\n",
+		acpi_device_hid(acpi_dev));
+	dev_handle = acpi_device_handle(acpi_dev);
+	status = acpi_walk_resources(dev_handle, "_CRS", lookup_pcct_indices,
+				     &context);
+	if (!ACPI_SUCCESS(status)) {
+		dev_err(dev, "FAILURE to lookup PCC indexes from CRS\n");
+		return -EINVAL;
+	}
+
+	//inbox initialization
Prefer C comments, please.
+	snprintf(name, sizeof(name), "mctpipcc%d", context.inbox_index);
+	ndev = alloc_netdev(sizeof(struct mctp_pcc_ndev), name, NET_NAME_ENUM,
Enum means the kernel assigns the ID, you're fully formatting the name
in the driver based on fixed device attributes, so NET_NAME_PREDICTABLE
quoted hunk ↗ jump to hunk
+			    mctp_pcc_setup);
+	if (!ndev)
+		return -ENOMEM;
+	return devm_add_action_or_reset(dev, mctp_cleanup_netdev, ndev);
+cleanup_netdev:
rename the label to free_netdev, please, to match with the first action
quoted hunk ↗ jump to hunk
+	free_netdev(ndev);
+	return rc;
+}
-- 
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help