2
0

0009-nss-dp-switchdev-fix-FDB-roaming.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. From 25ca3308edb67aa0c6c70b83edf0e22b8ae7533f Mon Sep 17 00:00:00 2001
  2. From: Robert Marko <[email protected]>
  3. Date: Thu, 29 Jun 2023 13:52:58 +0200
  4. Subject: [PATCH] nss-dp: switchdev: fix FDB roaming
  5. Try and solve the roaming issue by trying to replicate what NSS bridge
  6. module is doing, but by utilizing switchdev FDB notifiers instead of
  7. adding new notifiers to the bridge code.
  8. We register a new non-blocking switchdev notifier and simply wait for
  9. notification, and then process the SWITCHDEV_FDB_DEL_TO_DEVICE
  10. notifications.
  11. Those tell us that a certain FDB entry should be removed, then a VSI ID
  12. is fetched for the physical PPE port and using that VSI ID and the
  13. notification provided MAC adress existing FDB entry gets removed.
  14. Signed-off-by: Robert Marko <[email protected]>
  15. ---
  16. nss_dp_switchdev.c | 73 +++++++++++++++++++++++++++++++++++++++++++++-
  17. 1 file changed, 72 insertions(+), 1 deletion(-)
  18. --- a/nss_dp_switchdev.c
  19. +++ b/nss_dp_switchdev.c
  20. @@ -29,6 +29,8 @@
  21. #include "nss_dp_dev.h"
  22. #include "fal/fal_stp.h"
  23. #include "fal/fal_ctrlpkt.h"
  24. +#include "fal/fal_fdb.h"
  25. +#include "ref/ref_vsi.h"
  26. #define NSS_DP_SWITCH_ID 0
  27. #define NSS_DP_SW_ETHTYPE_PID 0 /* PPE ethtype profile ID for slow protocols */
  28. @@ -521,7 +523,76 @@ static struct notifier_block *nss_dp_sw_
  29. #else
  30. -static struct notifier_block *nss_dp_sw_ev_nb;
  31. +/*
  32. + * nss_dp_switchdev_fdb_del_event
  33. + *
  34. + * Used for EDMA v1 to remove old MAC in order to preventing having
  35. + * duplicate MAC entries in FDB thus and avoid roaming issues.
  36. + */
  37. +
  38. +static int nss_dp_switchdev_fdb_del_event(struct net_device *netdev,
  39. + struct switchdev_notifier_fdb_info *fdb_info)
  40. +{
  41. + struct nss_dp_dev *dp_priv = (struct nss_dp_dev *)netdev_priv(netdev);
  42. + fal_fdb_entry_t entry;
  43. + a_uint32_t vsi_id;
  44. + sw_error_t rv;
  45. +
  46. + netdev_dbg(netdev, "FDB DEL %pM port %d\n", fdb_info->addr, dp_priv->macid);
  47. +
  48. + rv = ppe_port_vsi_get(NSS_DP_SWITCH_ID, dp_priv->macid, &vsi_id);
  49. + if (rv) {
  50. + netdev_err(netdev, "cannot get VSI ID for port %d\n", dp_priv->macid);
  51. + return notifier_from_errno(rv);
  52. + }
  53. +
  54. + memset(&entry, 0, sizeof(entry));
  55. + memcpy(&entry.addr, fdb_info->addr, ETH_ALEN);
  56. + entry.fid = vsi_id;
  57. +
  58. + rv = fal_fdb_entry_del_bymac(NSS_DP_SWITCH_ID, &entry);
  59. + if (rv) {
  60. + netdev_err(netdev, "FDB entry delete failed with MAC %pM and fid %d\n",
  61. + &entry.addr, entry.fid);
  62. + return notifier_from_errno(rv);
  63. + }
  64. +
  65. + return notifier_from_errno(rv);
  66. +}
  67. +
  68. +/*
  69. + * nss_dp_switchdev_event_nb
  70. + *
  71. + * Non blocking switchdev event for netdevice.
  72. + * Used for EDMA v1 to remove old MAC and avoid roaming issues.
  73. + */
  74. +static int nss_dp_switchdev_event_nb(struct notifier_block *unused,
  75. + unsigned long event, void *ptr)
  76. +{
  77. + struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
  78. +
  79. + /*
  80. + * Handle switchdev event only for physical devices
  81. + */
  82. + if (!nss_dp_is_phy_dev(dev)) {
  83. + return NOTIFY_DONE;
  84. + }
  85. +
  86. + switch (event) {
  87. + case SWITCHDEV_FDB_DEL_TO_DEVICE:
  88. + return nss_dp_switchdev_fdb_del_event(dev, ptr);
  89. + default:
  90. + netdev_dbg(dev, "Switchdev event %lu is not supported\n", event);
  91. + }
  92. +
  93. + return NOTIFY_DONE;
  94. +}
  95. +
  96. +static struct notifier_block nss_dp_switchdev_notifier_nb = {
  97. + .notifier_call = nss_dp_switchdev_event_nb,
  98. +};
  99. +
  100. +static struct notifier_block *nss_dp_sw_ev_nb = &nss_dp_switchdev_notifier_nb;
  101. /*
  102. * nss_dp_bridge_attr_set()