RE: [PATCH v11 09/13] virtio-net: Add flow filter capability

Parav Pandit <[email protected]> Wed, 19 Nov 2025 03:31:14 +0000
Newsgroups dev.linux.lists.virtio-comment
Message-ID <CY8PR12MB719573A4D5D931AD362DA449DCD7A@CY8PR12MB7195.namprd12.prod.outlook.com>

> From: Michael S. Tsirkin <[email protected]>
> Sent: 19 November 2025 03:40 AM
> 
> On Tue, Jun 04, 2024 at 04:28:59PM +0300, Parav Pandit wrote:
> > +\begin{lstlisting}
> > +struct virtio_net_ff_cap_data {
> > +        le32 groups_limit;
> > +        le32 selectors_limit;
> > +        le32 rules_limit;
> > +        le32 rules_per_group_limit;
> > +        u8 last_rule_priority;
> > +        u8 selectors_per_classifier_limit; }; \end{lstlisting}
> 
> 
> I don't know how I missed this, but this structure is not aligned properly. In a
> typical compiler there's going to be a 2 byte padding here :(
> 
> 
> It's been a year ... do you think it's too late to fix?
> Parav?
> If it's been out too long then maybe we need a flag to fix it.

Structure not aligned to 8B size is not so good, but it is allowed.

The spec already has text as below.

Many device and driver in-memory structure layouts are documented using the C struct syntax. All structures
are assumed to be without additional padding. To stress this, cases where common C compilers are known
to insert extra padding within structures are tagged using the GNU C __attribute__((packed)) syntax.

Above structure is similar to 
struct virtio_net_config is 28 bytes.
struct virtio_gpu_config is 20 bytes.

Patch-5 should define this struct using packed attribute.