diff mbox

[net-next,v3,1/2] ethtool: Add helper routines to pass vf to rx_flow_spec

Message ID 20150518153138.2807.96111.stgit@nitbit.x32
State Superseded
Headers show

Commit Message

John Fastabend May 18, 2015, 3:31 p.m. UTC
The ring_cookie is 64 bits wide which is much larger than can be used
for actual queue index values. So provide some helper routines to
pack a VF index into the cookie. This is useful to steer packets to
a VF ring without having to know the queue layout of the device.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
 include/uapi/linux/ethtool.h |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Alexander Duyck May 18, 2015, 3:46 p.m. UTC | #1
On 05/18/2015 08:31 AM, John Fastabend wrote:
> The ring_cookie is 64 bits wide which is much larger than can be used
> for actual queue index values. So provide some helper routines to
> pack a VF index into the cookie. This is useful to steer packets to
> a VF ring without having to know the queue layout of the device.
>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
> ---
>   include/uapi/linux/ethtool.h |   20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>
> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
> index 2e49fc8..ecc658d 100644
> --- a/include/uapi/linux/ethtool.h
> +++ b/include/uapi/linux/ethtool.h
> @@ -796,6 +796,26 @@ struct ethtool_rx_flow_spec {
>   	__u32		location;
>   };
>   
> +/* How rings are layed out when accessing virtual functions or
> + * offloaded queues is device specific. To allow users to flow
> + * steering and specify these queues though break the ring cookie
> + * into a 32bit queue index with an 8 bit virtual function id.
> + * This also leaves the 3bytes for further specifiers.
> + */
> +#define ETHTOOL_RX_FLOW_SPEC_RING	0x00000000FFFFFFFF
> +#define ETHTOOL_RX_FLOW_SPEC_RING_VF	0x000000FF00000000

I still say the VF portion should be more bits.  If not 16 then at least 
12 so that there is room for expansion in the event that somebody comes 
out with a device that supports 256 or more VFs.  An alternative would 
be to document that we may want to leave space for future expansion of 
the VF field.

> +#define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
> +static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie)
> +{
> +	return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie;
> +};
> +
> +static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie)
> +{
> +	return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >>
> +				ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF;
> +};
> +
>   /**
>    * struct ethtool_rxnfc - command to get or set RX flow classification rules
>    * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
>
John Fastabend May 18, 2015, 3:55 p.m. UTC | #2
On 05/18/2015 08:46 AM, Alexander Duyck wrote:
> 
> 
> On 05/18/2015 08:31 AM, John Fastabend wrote:
>> The ring_cookie is 64 bits wide which is much larger than can be used
>> for actual queue index values. So provide some helper routines to
>> pack a VF index into the cookie. This is useful to steer packets to
>> a VF ring without having to know the queue layout of the device.
>>
>> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>> ---
>>   include/uapi/linux/ethtool.h |   20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>
>> diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
>> index 2e49fc8..ecc658d 100644
>> --- a/include/uapi/linux/ethtool.h
>> +++ b/include/uapi/linux/ethtool.h
>> @@ -796,6 +796,26 @@ struct ethtool_rx_flow_spec {
>>       __u32        location;
>>   };
>>   +/* How rings are layed out when accessing virtual functions or
>> + * offloaded queues is device specific. To allow users to flow
>> + * steering and specify these queues though break the ring cookie
>> + * into a 32bit queue index with an 8 bit virtual function id.
>> + * This also leaves the 3bytes for further specifiers.
>> + */
>> +#define ETHTOOL_RX_FLOW_SPEC_RING    0x00000000FFFFFFFF
>> +#define ETHTOOL_RX_FLOW_SPEC_RING_VF    0x000000FF00000000
> 
> I still say the VF portion should be more bits. If not 16 then at
> least 12 so that there is room for expansion in the event that
> somebody comes out with a device that supports 256 or more VFs. An
> alternative would be to document that we may want to leave space for
> future expansion of the VF field.

My argument is we don't have these devices today and we can always
extend these later without breaking API because we have 3 unused bytes
here. If we add it now we can't really revert it if we come up with a
better use for the bytes later. I'll add a comment.

> 
>> +#define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
>> +static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie)
>> +{
>> +    return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie;
>> +};
>> +
>> +static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie)
>> +{
>> +    return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >>
>> +                ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF;
>> +};
>> +
>>   /**
>>    * struct ethtool_rxnfc - command to get or set RX flow classification rules
>>    * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
>>
> 
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@lists.osuosl.org
> http://lists.osuosl.org/mailman/listinfo/intel-wired-lan
diff mbox

Patch

diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 2e49fc8..ecc658d 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -796,6 +796,26 @@  struct ethtool_rx_flow_spec {
 	__u32		location;
 };
 
+/* How rings are layed out when accessing virtual functions or
+ * offloaded queues is device specific. To allow users to flow
+ * steering and specify these queues though break the ring cookie
+ * into a 32bit queue index with an 8 bit virtual function id.
+ * This also leaves the 3bytes for further specifiers.
+ */
+#define ETHTOOL_RX_FLOW_SPEC_RING	0x00000000FFFFFFFF
+#define ETHTOOL_RX_FLOW_SPEC_RING_VF	0x000000FF00000000
+#define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32
+static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie)
+{
+	return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie;
+};
+
+static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie)
+{
+	return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >>
+				ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF;
+};
+
 /**
  * struct ethtool_rxnfc - command to get or set RX flow classification rules
  * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,