[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4d74b2dc-6c9a-4a45-9fc7-49f043120e6b@amperemail.onmicrosoft.com>
Date: Fri, 18 Apr 2025 16:39:39 -0400
From: Adam Young <admiyo@...eremail.onmicrosoft.com>
To: Jakub Kicinski <kuba@...nel.org>, admiyo@...amperecomputing.com
Cc: Jeremy Kerr <jk@...econstruct.com.au>,
Matt Johnston <matt@...econstruct.com.au>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Sudeep Holla <sudeep.holla@....com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Huisong Li <lihuisong@...wei.com>
Subject: Re: [PATCH net-next v18 1/1] mctp pcc: Implement MCTP over PCC
Transport
On 2/24/25 21:11, Jakub Kicinski wrote:
>> +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.
>
>> + 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;
>> +}
Is the skb_cow_head function called in place of the push, or does it
make it safe to do the push? Is there a case where we would need an
additional early return from the function for an error condition? What
would cause the skb to be a clone?
Powered by blists - more mailing lists