610-v5.13-16-net-dsa-resolve-forwarding-path-for-dsa-slave-ports.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From: Felix Fietkau <[email protected]>
  2. Date: Wed, 24 Mar 2021 02:30:37 +0100
  3. Subject: [PATCH] net: dsa: resolve forwarding path for dsa slave ports
  4. Add .ndo_fill_forward_path for dsa slave port devices
  5. Signed-off-by: Felix Fietkau <[email protected]>
  6. Signed-off-by: Pablo Neira Ayuso <[email protected]>
  7. ---
  8. --- a/include/linux/netdevice.h
  9. +++ b/include/linux/netdevice.h
  10. @@ -832,6 +832,7 @@ enum net_device_path_type {
  11. DEV_PATH_VLAN,
  12. DEV_PATH_BRIDGE,
  13. DEV_PATH_PPPOE,
  14. + DEV_PATH_DSA,
  15. };
  16. struct net_device_path {
  17. @@ -852,6 +853,10 @@ struct net_device_path {
  18. u16 vlan_id;
  19. __be16 vlan_proto;
  20. } bridge;
  21. + struct {
  22. + int port;
  23. + u16 proto;
  24. + } dsa;
  25. };
  26. };
  27. --- a/net/dsa/slave.c
  28. +++ b/net/dsa/slave.c
  29. @@ -1619,6 +1619,21 @@ static struct devlink_port *dsa_slave_ge
  30. return dp->ds->devlink ? &dp->devlink_port : NULL;
  31. }
  32. +static int dsa_slave_fill_forward_path(struct net_device_path_ctx *ctx,
  33. + struct net_device_path *path)
  34. +{
  35. + struct dsa_port *dp = dsa_slave_to_port(ctx->dev);
  36. + struct dsa_port *cpu_dp = dp->cpu_dp;
  37. +
  38. + path->dev = ctx->dev;
  39. + path->type = DEV_PATH_DSA;
  40. + path->dsa.proto = cpu_dp->tag_ops->proto;
  41. + path->dsa.port = dp->index;
  42. + ctx->dev = cpu_dp->master;
  43. +
  44. + return 0;
  45. +}
  46. +
  47. static const struct net_device_ops dsa_slave_netdev_ops = {
  48. .ndo_open = dsa_slave_open,
  49. .ndo_stop = dsa_slave_close,
  50. @@ -1644,6 +1659,7 @@ static const struct net_device_ops dsa_s
  51. .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
  52. .ndo_get_devlink_port = dsa_slave_get_devlink_port,
  53. .ndo_change_mtu = dsa_slave_change_mtu,
  54. + .ndo_fill_forward_path = dsa_slave_fill_forward_path,
  55. };
  56. static struct device_type dsa_type = {