642-net-8021q-support-hardware-flow-table-offload.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Thu, 15 Mar 2018 20:49:58 +0100
  3. Subject: [PATCH] net: 8021q: support hardware flow table offload
  4. Add the VLAN ID and protocol information
  5. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  6. ---
  7. --- a/net/8021q/vlan_dev.c
  8. +++ b/net/8021q/vlan_dev.c
  9. @@ -32,6 +32,10 @@
  10. #include <linux/phy.h>
  11. #include <net/arp.h>
  12. #include <net/switchdev.h>
  13. +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
  14. +#include <linux/netfilter.h>
  15. +#include <net/netfilter/nf_flow_table.h>
  16. +#endif
  17. #include "vlan.h"
  18. #include "vlanproc.h"
  19. @@ -769,6 +773,27 @@ static int vlan_dev_get_iflink(const str
  20. return real_dev->ifindex;
  21. }
  22. +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
  23. +static int vlan_dev_flow_offload_check(struct flow_offload_hw_path *path)
  24. +{
  25. + struct net_device *dev = path->dev;
  26. + struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
  27. +
  28. + if (path->flags & FLOW_OFFLOAD_PATH_VLAN)
  29. + return -EEXIST;
  30. +
  31. + path->flags |= FLOW_OFFLOAD_PATH_VLAN;
  32. + path->vlan_proto = vlan->vlan_proto;
  33. + path->vlan_id = vlan->vlan_id;
  34. + path->dev = vlan->real_dev;
  35. +
  36. + if (vlan->real_dev->netdev_ops->ndo_flow_offload_check)
  37. + return vlan->real_dev->netdev_ops->ndo_flow_offload_check(path);
  38. +
  39. + return 0;
  40. +}
  41. +#endif /* CONFIG_NF_FLOW_TABLE */
  42. +
  43. static const struct ethtool_ops vlan_ethtool_ops = {
  44. .get_link_ksettings = vlan_ethtool_get_link_ksettings,
  45. .get_drvinfo = vlan_ethtool_get_drvinfo,
  46. @@ -806,6 +831,9 @@ static const struct net_device_ops vlan_
  47. .ndo_fix_features = vlan_dev_fix_features,
  48. .ndo_get_lock_subclass = vlan_dev_get_lock_subclass,
  49. .ndo_get_iflink = vlan_dev_get_iflink,
  50. +#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
  51. + .ndo_flow_offload_check = vlan_dev_flow_offload_check,
  52. +#endif
  53. };
  54. static void vlan_dev_free(struct net_device *dev)