mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yojana Mallik <y-mallik@ti.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <schnelle@linux.ibm.com>, <wsa+renesas@sang-engineering.com>,
	<diogo.ivo@siemens.com>, <rdunlap@infradead.org>,
	<horms@kernel.org>, <vigneshr@ti.com>, <rogerq@ti.com>,
	<danishanwar@ti.com>, <pabeni@redhat.com>, <kuba@kernel.org>,
	<edumazet@google.com>, <davem@davemloft.net>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<srk@ti.com>, <rogerq@kernel.org>, <s-vadapalli@ti.com>
Subject: Re: [PATCH net-next v2 1/3] net: ethernet: ti: RPMsg based shared memory ethernet driver
Date: Mon, 3 Jun 2024 14:26:06 +0530	[thread overview]
Message-ID: <319616d8-533e-48c6-b97e-6285d284ac9e@ti.com> (raw)
In-Reply-To: <389e1f57-1666-4298-a970-74f730740e4c@lunn.ch>

Hi Andrew,

On 6/2/24 21:51, Andrew Lunn wrote:
>> +struct request_message {
>> +	u32 type; /* Request Type */
>> +	u32 id;	  /* Request ID */
>> +} __packed;
>> +
>> +struct response_message {
>> +	u32 type;	/* Response Type */
>> +	u32 id;		/* Response ID */
>> +} __packed;
>> +
>> +struct notify_message {
>> +	u32 type;	/* Notify Type */
>> +	u32 id;		/* Notify ID */
>> +} __packed;
> 
> These are basically identical.
> 

The first patch introduces only the RPMsg-based driver.
The RPMsg driver is registered as a network device in the second patch.
struct icve_mac_addr mac_addr is added as a member to
struct request_message in the second patch. Similarly struct icve_shm shm_info
is added as a member to struct response_message in the second patch. From
second patch onward struct request_message and struct response_message are not
identical. These members are used for the network device driver. As this patch
introduces only RPMsg-based ethernet driver these members were not used in this
patch and hence not mentioned in this patch. I understand this has led to the
confusion of the structures looking similar in this patch. Kindly suggest if I
should add these members in this patch itself instead of introducing them in
the next patch.

> The packed should not be needed, since these structures are naturally
> aligned. The compiler will do the right thing without the
> __packet. And there is a general dislike for __packed. It is better to
> layout your structures correctly so they are not needed.
> 

>> +struct message_header {
>> +	u32 src_id;
>> +	u32 msg_type; /* Do not use enum type, as enum size is compiler dependent */
>> +} __packed;
>> +
>> +struct message {
>> +	struct message_header msg_hdr;
>> +	union {
>> +		struct request_message req_msg;
>> +		struct response_message resp_msg;
>> +		struct notify_message notify_msg;
>> +	};
> 
> Since they are identical, why bother with a union?  It could be argued
> it allows future extensions, but i don't see any sort of protocol
> version here so you can tell if extra fields have been added.
> 

struct icve_mac_addr mac_addr is added as a member to
struct request_message in the second patch. Similarly struct icve_shm shm_info
is added as a member to struct response_message in the second patch. So sizes
of the structures are different. Hence union is used. I had moved those newly
added members to second patch because they are not used in the first patch. I
understand this has led to the confusion of the structures looking identical in
this patch. If you suggest I will move the newly added members of the
structures from the second patch to the first patch and then the structures
will not look identical in this patch.

>> +static int icve_rpmsg_cb(struct rpmsg_device *rpdev, void *data, int len,
>> +			 void *priv, u32 src)
>> +{
>> +	struct icve_common *common = dev_get_drvdata(&rpdev->dev);
>> +	struct message *msg = (struct message *)data;
>> +	u32 msg_type = msg->msg_hdr.msg_type;
>> +	u32 rpmsg_type;
>> +
>> +	switch (msg_type) {
>> +	case ICVE_REQUEST_MSG:
>> +		rpmsg_type = msg->req_msg.type;
>> +		dev_dbg(common->dev, "Msg type = %d; RPMsg type = %d\n",
>> +			msg_type, rpmsg_type);
>> +		break;
>> +	case ICVE_RESPONSE_MSG:
>> +		rpmsg_type = msg->resp_msg.type;
>> +		dev_dbg(common->dev, "Msg type = %d; RPMsg type = %d\n",
>> +			msg_type, rpmsg_type);
>> +		break;
>> +	case ICVE_NOTIFY_MSG:
>> +		rpmsg_type = msg->notify_msg.type;
>> +		dev_dbg(common->dev, "Msg type = %d; RPMsg type = %d\n",
>> +			msg_type, rpmsg_type);
> 
> This can be flattened to:
> 
>> +	case ICVE_REQUEST_MSG:
>> +	case ICVE_RESPONSE_MSG:
>> +	case ICVE_NOTIFY_MSG:
>> +		rpmsg_type = msg->notify_msg.type;
>> +		dev_dbg(common->dev, "Msg type = %d; RPMsg type = %d\n",
>> +			msg_type, rpmsg_type);
> 

New switch case statements have been added in the second patch for rpmsg_type
under under the case ICVE_RESPONSE_MSG. This makes case ICVE_REQUEST_MSG, case
ICVE_RESPONSE_MSG and case ICVE_NOTIFY_MSG different in the second patch. I
have kept icve_rpmsg_cb simple in this patch as it is called by the .callback.
Do you suggest to flatten these switch cases only for this patch?

> which makes me wounder about the value of this. Yes, later patches are
> going to flesh this out, but what value is there in printing the
> numerical value of msg_type, when you could easily have the text
> "Request", "Response", and "Notify". And why not include src_id and id
> in this debug output? If you are going to add debug output, please
> make it complete, otherwise it is often not useful.
> 

I will modify the debug output by including texts like "Request", "Response",
and "Notify" instead of the numerical value of msg_type. I will include src_id
and id and try to make this debug output complete and meaningful.

>> +		break;
>> +	default:
>> +		dev_err(common->dev, "Invalid msg type\n");
>> +		break;

> That is a potential way for the other end to DoS you. It also makes
> changes to the protocol difficult, since you cannot add new messages
> without DoS a machine using the old protocol. It would be better to
> just increment a counter and keep going.
> 

I will modify default case to return -EINVAL.

>> +static void icve_rpmsg_remove(struct rpmsg_device *rpdev)
>> +{
>> +	dev_info(&rpdev->dev, "icve rpmsg client driver is removed\n");
> 
> Please don't spam the logs. dev_dbg(), or nothing at all.
> 
> 	Andrew

I will remove the dev_info from icve_rpmsg_remove.

Thanks for your feedback.

  reply	other threads:[~2024-06-03  8:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  6:40 [PATCH net-next v2 0/3] Introducing Intercore Virtual Ethernet (ICVE) driver Yojana Mallik
2024-05-31  6:40 ` [PATCH net-next v2 1/3] net: ethernet: ti: RPMsg based shared memory ethernet driver Yojana Mallik
2024-05-31 15:30   ` Randy Dunlap
2024-06-03  5:50     ` Yojana Mallik
2024-06-02  7:01   ` Siddharth Vadapalli
2024-06-03  6:16     ` Yojana Mallik
2024-06-02 16:21   ` Andrew Lunn
2024-06-03  8:56     ` Yojana Mallik [this message]
2024-06-03 12:54       ` Andrew Lunn
2024-05-31  6:40 ` [PATCH net-next v2 2/3] net: ethernet: ti: Register the RPMsg driver as network device Yojana Mallik
2024-06-01  3:13   ` kernel test robot
2024-06-03  9:26     ` Yojana Mallik
2024-06-02  7:22   ` Siddharth Vadapalli
2024-06-02 15:54     ` Andrew Lunn
2024-06-02  7:35   ` Siddharth Vadapalli
2024-06-02 16:45   ` Andrew Lunn
2024-06-04  6:23     ` Yojana Mallik
2024-06-04 12:54       ` Andrew Lunn
2024-06-12 12:52         ` Yojana Mallik
2024-06-12 14:59           ` Andrew Lunn
2024-06-14  9:08             ` Yojana Mallik
2024-06-16 16:19               ` Andrew Lunn
2024-06-16 19:03                 ` Andrew Lunn
2024-06-04 13:00       ` Andrew Lunn
2024-06-12 12:49         ` Yojana Mallik
2024-06-12 14:36           ` Andrew Lunn
2024-05-31  6:40 ` [PATCH net-next v2 3/3] net: ethernet: ti: icve: Add support for multicast filtering Yojana Mallik
2024-06-03 21:27   ` kernel test robot
2024-06-02 15:45 ` [PATCH net-next v2 0/3] Introducing Intercore Virtual Ethernet (ICVE) driver Andrew Lunn
2024-06-03 23:54   ` Jakub Kicinski
2024-06-12 12:48   ` Yojana Mallik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=319616d8-533e-48c6-b97e-6285d284ac9e@ti.com \
    --to=y-mallik@ti.com \
    --cc=andrew@lunn.ch \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=diogo.ivo@siemens.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=rogerq@kernel.org \
    --cc=rogerq@ti.com \
    --cc=s-vadapalli@ti.com \
    --cc=schnelle@linux.ibm.com \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®