dp_mscs.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include "dp_peer.h"
  19. #include "qdf_nbuf.h"
  20. #include "dp_types.h"
  21. #include "dp_internal.h"
  22. #include "dp_tx.h"
  23. #include "dp_mscs.h"
  24. #define DP_MSCS_INVALID_TID 0xFF
  25. #define DP_MSCS_VALID_TID_MASK 0x7
  26. /**
  27. * dp_mscs_peer_lookup_n_get_priority() - Get priority for MSCS peer
  28. * @soc_hdl - soc handle
  29. * @src_mac_addr - src mac address from connection
  30. * @nbuf - network buffer
  31. *
  32. * Return: 0 when peer has active mscs session and valid user priority
  33. */
  34. int dp_mscs_peer_lookup_n_get_priority(struct cdp_soc_t *soc_hdl,
  35. uint8_t *src_mac_addr, qdf_nbuf_t nbuf)
  36. {
  37. struct dp_peer *peer;
  38. uint8_t user_prio_bitmap;
  39. uint8_t user_prio_limit;
  40. uint8_t user_prio;
  41. int status = 0;
  42. struct dp_soc *dpsoc = cdp_soc_t_to_dp_soc(soc_hdl);
  43. if (!dpsoc) {
  44. QDF_TRACE(QDF_MODULE_ID_MSCS, QDF_TRACE_LEVEL_ERROR,
  45. "%s: Invalid soc\n", __func__);
  46. return -1;
  47. }
  48. /*
  49. * Find the MSCS peer from global soc
  50. */
  51. peer = dp_peer_find_hash_find(dpsoc, src_mac_addr, 0,
  52. DP_VDEV_ALL, DP_MOD_ID_MSCS);
  53. if (!peer) {
  54. /*
  55. * No WLAN client peer found with this peer mac
  56. */
  57. return -1;
  58. }
  59. /*
  60. * check if there is any active MSCS session for this peer
  61. */
  62. if (!peer->mscs_active) {
  63. QDF_TRACE(QDF_MODULE_ID_MSCS, QDF_TRACE_LEVEL_DEBUG,
  64. "%s: MSCS session not active on peer or peer delete in progress\n", __func__);
  65. status = 1;
  66. goto fail;
  67. }
  68. /*
  69. * Get user priority bitmap for this peer MSCS active session
  70. */
  71. user_prio_bitmap = peer->mscs_ipv4_parameter.user_priority_bitmap;
  72. user_prio_limit = peer->mscs_ipv4_parameter.user_priority_limit;
  73. user_prio = qdf_nbuf_get_priority(nbuf) & DP_MSCS_VALID_TID_MASK;
  74. /*
  75. * check if nbuf priority is matching with any of the valid priority value
  76. */
  77. if (!((1 << user_prio) & user_prio_bitmap)) {
  78. QDF_TRACE(QDF_MODULE_ID_MSCS, QDF_TRACE_LEVEL_DEBUG,
  79. "%s: Nbuf TID is not valid, no match in user prioroty bitmap\n", __func__);
  80. status = 1;
  81. goto fail;
  82. }
  83. user_prio = QDF_MIN(user_prio, user_prio_limit);
  84. /*
  85. * Update skb priority
  86. */
  87. qdf_nbuf_set_priority(nbuf, user_prio);
  88. QDF_TRACE(QDF_MODULE_ID_MSCS, QDF_TRACE_LEVEL_DEBUG,
  89. "%s: User priority for this MSCS session %d\n", __func__, user_prio);
  90. status = 0;
  91. fail:
  92. if (peer)
  93. dp_peer_unref_delete(peer, DP_MOD_ID_MSCS);
  94. return status;
  95. }
  96. qdf_export_symbol(dp_mscs_peer_lookup_n_get_priority);