DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] How to use .last and .spec fields in the Generic Flow API?
@ 2019-03-06 15:30 Andrew Bainbridge
  2019-03-07  8:51 ` Raslan Darawsheh
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Bainbridge @ 2019-03-06 15:30 UTC (permalink / raw)
  To: users

Hi

How should I specify a range of UDP ports in the generic flow API? Here's what I've tried...

I'm trying to create a flow to move packets with UDP dest ports from 1234 to 1244 into a specified queue. It works fine if I specify a single port of 1234, instead of the range. Here's how I set the flow item for that:

    struct rte_flow_item_udp udp_spec = { 0 };
    struct rte_flow_item_udp udp_mask = { 0 };
    udp_spec.hdr.dst_port = htons(udp_dst_port);
    udp_mask.hdr.dst_port = 0xffff;
    pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
    pattern[2].spec = &udp_spec;
    pattern[2].mask = &udp_mask;

But if I attempt to specify the range, I believe I have to use the .last field. When I do that, I get this error, 'range between "spec" and "last" is larger than "mask"'. Here's how I set that flow item:

    struct rte_flow_item_udp udp_spec = { 0 };
    struct rte_flow_item_udp udp_last = { 0 };
    struct rte_flow_item_udp udp_mask = { 0 };
    udp_spec.hdr.dst_port = htons(1234);
    udp_last.hdr.dst_port = htons(1244);
    udp_mask.hdr.dst_port = 0xffff;
    pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
    pattern[2].spec = &udp_spec;
    pattern[2].last = &udp_last;
    pattern[2].mask = &udp_mask;

I don't understand the error message. The range between spec and last is 10. The mask is 0xffff. The error message seems wrong. But probably I just misunderstood something.

More details:

I'm using the mlx4 PMD. The source of the error message is in mlx4_flow_item_check(), where the code appears goes through each byte of the spec and last and checks that:

    (((const uint8_t *)item->spec)[i] & mask[i]) != (((const uint8_t *)item->last)[i] & mask[i]))

Which makes no sense to me. That appears to require that spec and last are equal wherever mask is not zero.

Any ideas?

Thanks,
Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] How to use .last and .spec fields in the Generic Flow API?
  2019-03-06 15:30 [dpdk-users] How to use .last and .spec fields in the Generic Flow API? Andrew Bainbridge
@ 2019-03-07  8:51 ` Raslan Darawsheh
  2019-03-07 11:10   ` Andrew Bainbridge
  0 siblings, 1 reply; 4+ messages in thread
From: Raslan Darawsheh @ 2019-03-07  8:51 UTC (permalink / raw)
  To: Andrew Bainbridge, users

Hi Andrew,

You are specifying a mask and the last for the item.
Based on the mask that you specified it means that match only the udp_dst_port that was specified since the mask is 0xffff
Which is causing conflicts with the range.
Try it without setting the mask or set the mask to be 0x0

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: users <users-bounces@dpdk.org> On Behalf Of Andrew Bainbridge
> Sent: Wednesday, March 6, 2019 5:30 PM
> To: users <users@dpdk.org>
> Subject: [dpdk-users] How to use .last and .spec fields in the Generic Flow
> API?
> 
> Hi
> 
> How should I specify a range of UDP ports in the generic flow API? Here's
> what I've tried...
> 
> I'm trying to create a flow to move packets with UDP dest ports from 1234 to
> 1244 into a specified queue. It works fine if I specify a single port of 1234,
> instead of the range. Here's how I set the flow item for that:
> 
>     struct rte_flow_item_udp udp_spec = { 0 };
>     struct rte_flow_item_udp udp_mask = { 0 };
>     udp_spec.hdr.dst_port = htons(udp_dst_port);
>     udp_mask.hdr.dst_port = 0xffff;
>     pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
>     pattern[2].spec = &udp_spec;
>     pattern[2].mask = &udp_mask;
> 
> But if I attempt to specify the range, I believe I have to use the .last field.
> When I do that, I get this error, 'range between "spec" and "last" is larger
> than "mask"'. Here's how I set that flow item:
> 
>     struct rte_flow_item_udp udp_spec = { 0 };
>     struct rte_flow_item_udp udp_last = { 0 };
>     struct rte_flow_item_udp udp_mask = { 0 };
>     udp_spec.hdr.dst_port = htons(1234);
>     udp_last.hdr.dst_port = htons(1244);
>     udp_mask.hdr.dst_port = 0xffff;
>     pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
>     pattern[2].spec = &udp_spec;
>     pattern[2].last = &udp_last;
>     pattern[2].mask = &udp_mask;
> 
> I don't understand the error message. The range between spec and last is 10.
> The mask is 0xffff. The error message seems wrong. But probably I just
> misunderstood something.
> 
> More details:
> 
> I'm using the mlx4 PMD. The source of the error message is in
> mlx4_flow_item_check(), where the code appears goes through each byte
> of the spec and last and checks that:
> 
>     (((const uint8_t *)item->spec)[i] & mask[i]) != (((const uint8_t *)item-
> >last)[i] & mask[i]))
> 
> Which makes no sense to me. That appears to require that spec and last are
> equal wherever mask is not zero.
> 
> Any ideas?
> 
> Thanks,
> Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] How to use .last and .spec fields in the Generic Flow API?
  2019-03-07  8:51 ` Raslan Darawsheh
@ 2019-03-07 11:10   ` Andrew Bainbridge
  2019-03-07 11:31     ` Raslan Darawsheh
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Bainbridge @ 2019-03-07 11:10 UTC (permalink / raw)
  To: Raslan Darawsheh, users

Hi Raslan

Thanks for the reply. It sounds very sensible. Unfortunately I can't get it to work.

If I do not set the mask, I get the "range between spec and last is larger than mask" error again.

If I set the mask to 0, then all udp dst port numbers are accepted.

If I set the mask to 0xff, I get, "mlx4 does not support matching partial UDP fields".

Do any of these work on the PMD you use? The generic flow docs (https://doc.dpdk.org/guides/prog_guide/rte_flow.html section 9.2.3) say, "mask is a simple bit-mask applied before interpreting the contents of spec and last", which sort-of implies I need to set the mask to non-zero even when using "last".

I can't find any other relevant documentation or example code.

Thanks,
Andrew

-----Original Message-----
From: Raslan Darawsheh <rasland@mellanox.com> 
Sent: 07 March 2019 08:52
To: Andrew Bainbridge <andbain@microsoft.com>; users <users@dpdk.org>
Subject: RE: [dpdk-users] How to use .last and .spec fields in the Generic Flow API?

Hi Andrew,

You are specifying a mask and the last for the item.
Based on the mask that you specified it means that match only the udp_dst_port that was specified since the mask is 0xffff Which is causing conflicts with the range.
Try it without setting the mask or set the mask to be 0x0

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: users <users-bounces@dpdk.org> On Behalf Of Andrew Bainbridge
> Sent: Wednesday, March 6, 2019 5:30 PM
> To: users <users@dpdk.org>
> Subject: [dpdk-users] How to use .last and .spec fields in the Generic 
> Flow API?
> 
> Hi
> 
> How should I specify a range of UDP ports in the generic flow API? 
> Here's what I've tried...
> 
> I'm trying to create a flow to move packets with UDP dest ports from 
> 1234 to
> 1244 into a specified queue. It works fine if I specify a single port 
> of 1234, instead of the range. Here's how I set the flow item for that:
> 
>     struct rte_flow_item_udp udp_spec = { 0 };
>     struct rte_flow_item_udp udp_mask = { 0 };
>     udp_spec.hdr.dst_port = htons(udp_dst_port);
>     udp_mask.hdr.dst_port = 0xffff;
>     pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
>     pattern[2].spec = &udp_spec;
>     pattern[2].mask = &udp_mask;
> 
> But if I attempt to specify the range, I believe I have to use the .last field.
> When I do that, I get this error, 'range between "spec" and "last" is 
> larger than "mask"'. Here's how I set that flow item:
> 
>     struct rte_flow_item_udp udp_spec = { 0 };
>     struct rte_flow_item_udp udp_last = { 0 };
>     struct rte_flow_item_udp udp_mask = { 0 };
>     udp_spec.hdr.dst_port = htons(1234);
>     udp_last.hdr.dst_port = htons(1244);
>     udp_mask.hdr.dst_port = 0xffff;
>     pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
>     pattern[2].spec = &udp_spec;
>     pattern[2].last = &udp_last;
>     pattern[2].mask = &udp_mask;
> 
> I don't understand the error message. The range between spec and last is 10.
> The mask is 0xffff. The error message seems wrong. But probably I just 
> misunderstood something.
> 
> More details:
> 
> I'm using the mlx4 PMD. The source of the error message is in 
> mlx4_flow_item_check(), where the code appears goes through each byte 
> of the spec and last and checks that:
> 
>     (((const uint8_t *)item->spec)[i] & mask[i]) != (((const uint8_t 
> *)item-
> >last)[i] & mask[i]))
> 
> Which makes no sense to me. That appears to require that spec and last 
> are equal wherever mask is not zero.
> 
> Any ideas?
> 
> Thanks,
> Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] How to use .last and .spec fields in the Generic Flow API?
  2019-03-07 11:10   ` Andrew Bainbridge
@ 2019-03-07 11:31     ` Raslan Darawsheh
  0 siblings, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2019-03-07 11:31 UTC (permalink / raw)
  To: Andrew Bainbridge, users

Hi Andrew,

I tried to explain it in general for last and mask.
But, for MLX4 in general it can have support only for 0xffff mask or 0x0 mask which mean that you can only do it for one port or any.
This also applies for IPv4 and TCP items.

So for the range you need to explicitly add a separate rule for each port that you want.

Kindest regards,
Raslan Darawsheh

> -----Original Message-----
> From: Andrew Bainbridge <andbain@microsoft.com>
> Sent: Thursday, March 7, 2019 1:10 PM
> To: Raslan Darawsheh <rasland@mellanox.com>; users <users@dpdk.org>
> Subject: RE: [dpdk-users] How to use .last and .spec fields in the Generic
> Flow API?
> 
> Hi Raslan
> 
> Thanks for the reply. It sounds very sensible. Unfortunately I can't get it to
> work.
> 
> If I do not set the mask, I get the "range between spec and last is larger than
> mask" error again.
> 
> If I set the mask to 0, then all udp dst port numbers are accepted.
> 
> If I set the mask to 0xff, I get, "mlx4 does not support matching partial UDP
> fields".
> 
> Do any of these work on the PMD you use? The generic flow docs
> (https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdo
> c.dpdk.org%2Fguides%2Fprog_guide%2Frte_flow.html&amp;data=02%7C01
> %7Crasland%40mellanox.com%7Cb79d945b1a8d4597044f08d6a2ed8282%7Ca
> 652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636875538317844006&am
> p;sdata=Jk3US8esY0vlWXyWyDqyjWlYG4DzpQFERN7L864Xdo0%3D&amp;res
> erved=0 section 9.2.3) say, "mask is a simple bit-mask applied before
> interpreting the contents of spec and last", which sort-of implies I need to
> set the mask to non-zero even when using "last".
> 
> I can't find any other relevant documentation or example code.
> 
> Thanks,
> Andrew
> 
> -----Original Message-----
> From: Raslan Darawsheh <rasland@mellanox.com>
> Sent: 07 March 2019 08:52
> To: Andrew Bainbridge <andbain@microsoft.com>; users <users@dpdk.org>
> Subject: RE: [dpdk-users] How to use .last and .spec fields in the Generic
> Flow API?
> 
> Hi Andrew,
> 
> You are specifying a mask and the last for the item.
> Based on the mask that you specified it means that match only the
> udp_dst_port that was specified since the mask is 0xffff Which is causing
> conflicts with the range.
> Try it without setting the mask or set the mask to be 0x0
> 
> Kindest regards,
> Raslan Darawsheh
> 
> > -----Original Message-----
> > From: users <users-bounces@dpdk.org> On Behalf Of Andrew Bainbridge
> > Sent: Wednesday, March 6, 2019 5:30 PM
> > To: users <users@dpdk.org>
> > Subject: [dpdk-users] How to use .last and .spec fields in the Generic
> > Flow API?
> >
> > Hi
> >
> > How should I specify a range of UDP ports in the generic flow API?
> > Here's what I've tried...
> >
> > I'm trying to create a flow to move packets with UDP dest ports from
> > 1234 to
> > 1244 into a specified queue. It works fine if I specify a single port
> > of 1234, instead of the range. Here's how I set the flow item for that:
> >
> >     struct rte_flow_item_udp udp_spec = { 0 };
> >     struct rte_flow_item_udp udp_mask = { 0 };
> >     udp_spec.hdr.dst_port = htons(udp_dst_port);
> >     udp_mask.hdr.dst_port = 0xffff;
> >     pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
> >     pattern[2].spec = &udp_spec;
> >     pattern[2].mask = &udp_mask;
> >
> > But if I attempt to specify the range, I believe I have to use the .last field.
> > When I do that, I get this error, 'range between "spec" and "last" is
> > larger than "mask"'. Here's how I set that flow item:
> >
> >     struct rte_flow_item_udp udp_spec = { 0 };
> >     struct rte_flow_item_udp udp_last = { 0 };
> >     struct rte_flow_item_udp udp_mask = { 0 };
> >     udp_spec.hdr.dst_port = htons(1234);
> >     udp_last.hdr.dst_port = htons(1244);
> >     udp_mask.hdr.dst_port = 0xffff;
> >     pattern[2].type = RTE_FLOW_ITEM_TYPE_UDP;
> >     pattern[2].spec = &udp_spec;
> >     pattern[2].last = &udp_last;
> >     pattern[2].mask = &udp_mask;
> >
> > I don't understand the error message. The range between spec and last is
> 10.
> > The mask is 0xffff. The error message seems wrong. But probably I just
> > misunderstood something.
> >
> > More details:
> >
> > I'm using the mlx4 PMD. The source of the error message is in
> > mlx4_flow_item_check(), where the code appears goes through each byte
> > of the spec and last and checks that:
> >
> >     (((const uint8_t *)item->spec)[i] & mask[i]) != (((const uint8_t
> > *)item-
> > >last)[i] & mask[i]))
> >
> > Which makes no sense to me. That appears to require that spec and last
> > are equal wherever mask is not zero.
> >
> > Any ideas?
> >
> > Thanks,
> > Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-07 11:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-06 15:30 [dpdk-users] How to use .last and .spec fields in the Generic Flow API? Andrew Bainbridge
2019-03-07  8:51 ` Raslan Darawsheh
2019-03-07 11:10   ` Andrew Bainbridge
2019-03-07 11:31     ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).