Re: [PATCH v2 net-next] net: stmmac: Add support for U32 TC filter using Flexible RX Parser

2018-05-07 Thread Jose Abreu
Hi Jakub, David,

On 05-05-2018 02:33, Jakub Kicinski wrote:
> On Fri,  4 May 2018 10:01:38 +0100, Jose Abreu wrote:
>> This adds support for U32 filter by using an HW only feature called
>> Flexible RX Parser. This allow us to match any given packet field with a
>> pattern and accept/reject or even route the packet to a specific DMA
>> channel.
>>
>> Right now we only support acception or rejection of frame and we only
>> support simple rules. Though, the Parser has the flexibility of jumping to
>> specific rules as an if condition so complex rules can be established.
>>
>> This is only supported in GMAC5.10+.
>>
>> The following commands can be used to test this code:
>>
>>  1) Setup an ingress qdisk:
>>  # tc qdisc add dev eth0 handle : ingress
>>
>>  2) Setup a filter (e.g. filter by IP):
>>  # tc filter add dev eth0 parent : protocol ip u32 match ip \
>>  src 192.168.0.3 skip_sw action drop
>>
>> In every tests performed we always used the "skip_sw" flag to make sure
>> only the RX Parser was involved.
>>
>> Signed-off-by: Jose Abreu 
>> Cc: David S. Miller 
>> Cc: Joao Pinto 
>> Cc: Vitor Soares 
>> Cc: Giuseppe Cavallaro 
>> Cc: Alexandre Torgue 
>> Cc: Jakub Kicinski 
>> ---
>> Changes from v1:
>>  - Follow Linux network coding style (David)
>>  - Use tc_cls_can_offload_and_chain0() (Jakub)
> Thanks!
>
>> @@ -4223,6 +4277,11 @@ int stmmac_dvr_probe(struct device *device,
>>  ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
>>  NETIF_F_RXCSUM;
>>  
>> +ret = stmmac_tc_init(priv, priv);
>> +if (!ret) {
>> +ndev->hw_features |= NETIF_F_HW_TC;
>> +}
>> +
>>  if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) {
>>  ndev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
>>  priv->tso = true;
> One more comment, but perhaps not a showstopper, it's considered good
> practice to disallow clearing/disabling this flag while filters are
> installed.  Driver should return -EBUSY from .ndo_set_features if TC
> rules are offloaded and user wants to disable HW_TC feature flag.

I can do that but I saw in Patchwork that patch was already
marked as accepted, David sent me no confirmation though.

David,
Shall I respin or send a follow up patch?

Thanks and Best Regards,
Jose Miguel Abreu


Re: [PATCH v2 net-next] net: stmmac: Add support for U32 TC filter using Flexible RX Parser

2018-05-04 Thread Jakub Kicinski
On Fri,  4 May 2018 10:01:38 +0100, Jose Abreu wrote:
> This adds support for U32 filter by using an HW only feature called
> Flexible RX Parser. This allow us to match any given packet field with a
> pattern and accept/reject or even route the packet to a specific DMA
> channel.
> 
> Right now we only support acception or rejection of frame and we only
> support simple rules. Though, the Parser has the flexibility of jumping to
> specific rules as an if condition so complex rules can be established.
> 
> This is only supported in GMAC5.10+.
> 
> The following commands can be used to test this code:
> 
>   1) Setup an ingress qdisk:
>   # tc qdisc add dev eth0 handle : ingress
> 
>   2) Setup a filter (e.g. filter by IP):
>   # tc filter add dev eth0 parent : protocol ip u32 match ip \
>   src 192.168.0.3 skip_sw action drop
> 
> In every tests performed we always used the "skip_sw" flag to make sure
> only the RX Parser was involved.
> 
> Signed-off-by: Jose Abreu 
> Cc: David S. Miller 
> Cc: Joao Pinto 
> Cc: Vitor Soares 
> Cc: Giuseppe Cavallaro 
> Cc: Alexandre Torgue 
> Cc: Jakub Kicinski 
> ---
> Changes from v1:
>   - Follow Linux network coding style (David)
>   - Use tc_cls_can_offload_and_chain0() (Jakub)

Thanks!

> @@ -4223,6 +4277,11 @@ int stmmac_dvr_probe(struct device *device,
>   ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
>   NETIF_F_RXCSUM;
>  
> + ret = stmmac_tc_init(priv, priv);
> + if (!ret) {
> + ndev->hw_features |= NETIF_F_HW_TC;
> + }
> +
>   if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) {
>   ndev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
>   priv->tso = true;

One more comment, but perhaps not a showstopper, it's considered good
practice to disallow clearing/disabling this flag while filters are
installed.  Driver should return -EBUSY from .ndo_set_features if TC
rules are offloaded and user wants to disable HW_TC feature flag.