fw.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright (C) 2017 Netronome Systems, Inc.
  3. *
  4. * This software is dual licensed under the GNU General License Version 2,
  5. * June 1991 as shown in the file COPYING in the top-level directory of this
  6. * source tree or the BSD 2-Clause License provided below. You have the
  7. * option to license this software under the complete terms of either license.
  8. *
  9. * The BSD 2-Clause License:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #ifndef NFP_BPF_FW_H
  34. #define NFP_BPF_FW_H 1
  35. #include <linux/bitops.h>
  36. #include <linux/types.h>
  37. enum bpf_cap_tlv_type {
  38. NFP_BPF_CAP_TYPE_FUNC = 1,
  39. NFP_BPF_CAP_TYPE_ADJUST_HEAD = 2,
  40. NFP_BPF_CAP_TYPE_MAPS = 3,
  41. NFP_BPF_CAP_TYPE_RANDOM = 4,
  42. };
  43. struct nfp_bpf_cap_tlv_func {
  44. __le32 func_id;
  45. __le32 func_addr;
  46. };
  47. struct nfp_bpf_cap_tlv_adjust_head {
  48. __le32 flags;
  49. __le32 off_min;
  50. __le32 off_max;
  51. __le32 guaranteed_sub;
  52. __le32 guaranteed_add;
  53. };
  54. #define NFP_BPF_ADJUST_HEAD_NO_META BIT(0)
  55. struct nfp_bpf_cap_tlv_maps {
  56. __le32 types;
  57. __le32 max_maps;
  58. __le32 max_elems;
  59. __le32 max_key_sz;
  60. __le32 max_val_sz;
  61. __le32 max_elem_sz;
  62. };
  63. /*
  64. * Types defined for map related control messages
  65. */
  66. #define CMSG_MAP_ABI_VERSION 1
  67. enum nfp_bpf_cmsg_type {
  68. CMSG_TYPE_MAP_ALLOC = 1,
  69. CMSG_TYPE_MAP_FREE = 2,
  70. CMSG_TYPE_MAP_LOOKUP = 3,
  71. CMSG_TYPE_MAP_UPDATE = 4,
  72. CMSG_TYPE_MAP_DELETE = 5,
  73. CMSG_TYPE_MAP_GETNEXT = 6,
  74. CMSG_TYPE_MAP_GETFIRST = 7,
  75. __CMSG_TYPE_MAP_MAX,
  76. };
  77. #define CMSG_TYPE_MAP_REPLY_BIT 7
  78. #define __CMSG_REPLY(req) (BIT(CMSG_TYPE_MAP_REPLY_BIT) | (req))
  79. #define CMSG_MAP_KEY_LW 16
  80. #define CMSG_MAP_VALUE_LW 16
  81. enum nfp_bpf_cmsg_status {
  82. CMSG_RC_SUCCESS = 0,
  83. CMSG_RC_ERR_MAP_FD = 1,
  84. CMSG_RC_ERR_MAP_NOENT = 2,
  85. CMSG_RC_ERR_MAP_ERR = 3,
  86. CMSG_RC_ERR_MAP_PARSE = 4,
  87. CMSG_RC_ERR_MAP_EXIST = 5,
  88. CMSG_RC_ERR_MAP_NOMEM = 6,
  89. CMSG_RC_ERR_MAP_E2BIG = 7,
  90. };
  91. struct cmsg_hdr {
  92. u8 type;
  93. u8 ver;
  94. __be16 tag;
  95. };
  96. struct cmsg_reply_map_simple {
  97. struct cmsg_hdr hdr;
  98. __be32 rc;
  99. };
  100. struct cmsg_req_map_alloc_tbl {
  101. struct cmsg_hdr hdr;
  102. __be32 key_size; /* in bytes */
  103. __be32 value_size; /* in bytes */
  104. __be32 max_entries;
  105. __be32 map_type;
  106. __be32 map_flags; /* reserved */
  107. };
  108. struct cmsg_reply_map_alloc_tbl {
  109. struct cmsg_reply_map_simple reply_hdr;
  110. __be32 tid;
  111. };
  112. struct cmsg_req_map_free_tbl {
  113. struct cmsg_hdr hdr;
  114. __be32 tid;
  115. };
  116. struct cmsg_reply_map_free_tbl {
  117. struct cmsg_reply_map_simple reply_hdr;
  118. __be32 count;
  119. };
  120. struct cmsg_key_value_pair {
  121. __be32 key[CMSG_MAP_KEY_LW];
  122. __be32 value[CMSG_MAP_VALUE_LW];
  123. };
  124. struct cmsg_req_map_op {
  125. struct cmsg_hdr hdr;
  126. __be32 tid;
  127. __be32 count;
  128. __be32 flags;
  129. struct cmsg_key_value_pair elem[0];
  130. };
  131. struct cmsg_reply_map_op {
  132. struct cmsg_reply_map_simple reply_hdr;
  133. __be32 count;
  134. __be32 resv;
  135. struct cmsg_key_value_pair elem[0];
  136. };
  137. #endif