usnic_vnic.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. *
  17. */
  18. #ifndef USNIC_VNIC_H_
  19. #define USNIC_VNIC_H_
  20. #include <linux/pci.h>
  21. #include "vnic_dev.h"
  22. /* =USNIC_VNIC_RES_TYPE= =VNIC_RES= =DESC= */
  23. #define USNIC_VNIC_RES_TYPES \
  24. DEFINE_USNIC_VNIC_RES_AT(EOL, RES_TYPE_EOL, "EOL", 0) \
  25. DEFINE_USNIC_VNIC_RES(WQ, RES_TYPE_WQ, "WQ") \
  26. DEFINE_USNIC_VNIC_RES(RQ, RES_TYPE_RQ, "RQ") \
  27. DEFINE_USNIC_VNIC_RES(CQ, RES_TYPE_CQ, "CQ") \
  28. DEFINE_USNIC_VNIC_RES(INTR, RES_TYPE_INTR_CTRL, "INT") \
  29. DEFINE_USNIC_VNIC_RES(MAX, RES_TYPE_MAX, "MAX")\
  30. #define DEFINE_USNIC_VNIC_RES_AT(usnic_vnic_res_t, vnic_res_type, desc, val) \
  31. USNIC_VNIC_RES_TYPE_##usnic_vnic_res_t = val,
  32. #define DEFINE_USNIC_VNIC_RES(usnic_vnic_res_t, vnic_res_type, desc) \
  33. USNIC_VNIC_RES_TYPE_##usnic_vnic_res_t,
  34. enum usnic_vnic_res_type {
  35. USNIC_VNIC_RES_TYPES
  36. };
  37. #undef DEFINE_USNIC_VNIC_RES
  38. #undef DEFINE_USNIC_VNIC_RES_AT
  39. struct usnic_vnic_res {
  40. enum usnic_vnic_res_type type;
  41. unsigned int vnic_idx;
  42. struct usnic_vnic *vnic;
  43. void __iomem *ctrl;
  44. void *owner;
  45. };
  46. struct usnic_vnic_res_chunk {
  47. enum usnic_vnic_res_type type;
  48. int cnt;
  49. int free_cnt;
  50. struct usnic_vnic_res **res;
  51. struct usnic_vnic *vnic;
  52. };
  53. struct usnic_vnic_res_desc {
  54. enum usnic_vnic_res_type type;
  55. uint16_t cnt;
  56. };
  57. struct usnic_vnic_res_spec {
  58. struct usnic_vnic_res_desc resources[USNIC_VNIC_RES_TYPE_MAX];
  59. };
  60. const char *usnic_vnic_res_type_to_str(enum usnic_vnic_res_type res_type);
  61. const char *usnic_vnic_pci_name(struct usnic_vnic *vnic);
  62. int usnic_vnic_dump(struct usnic_vnic *vnic, char *buf, int buf_sz,
  63. void *hdr_obj,
  64. int (*printtitle)(void *, char*, int),
  65. int (*printcols)(char *, int),
  66. int (*printrow)(void *, char *, int));
  67. void usnic_vnic_res_spec_update(struct usnic_vnic_res_spec *spec,
  68. enum usnic_vnic_res_type trgt_type,
  69. u16 cnt);
  70. int usnic_vnic_res_spec_satisfied(const struct usnic_vnic_res_spec *min_spec,
  71. struct usnic_vnic_res_spec *res_spec);
  72. int usnic_vnic_spec_dump(char *buf, int buf_sz,
  73. struct usnic_vnic_res_spec *res_spec);
  74. int usnic_vnic_check_room(struct usnic_vnic *vnic,
  75. struct usnic_vnic_res_spec *res_spec);
  76. int usnic_vnic_res_cnt(struct usnic_vnic *vnic,
  77. enum usnic_vnic_res_type type);
  78. int usnic_vnic_res_free_cnt(struct usnic_vnic *vnic,
  79. enum usnic_vnic_res_type type);
  80. struct usnic_vnic_res_chunk *
  81. usnic_vnic_get_resources(struct usnic_vnic *vnic,
  82. enum usnic_vnic_res_type type,
  83. int cnt,
  84. void *owner);
  85. void usnic_vnic_put_resources(struct usnic_vnic_res_chunk *chunk);
  86. struct pci_dev *usnic_vnic_get_pdev(struct usnic_vnic *vnic);
  87. struct vnic_dev_bar *usnic_vnic_get_bar(struct usnic_vnic *vnic,
  88. int bar_num);
  89. struct usnic_vnic *usnic_vnic_alloc(struct pci_dev *pdev);
  90. void usnic_vnic_free(struct usnic_vnic *vnic);
  91. u16 usnic_vnic_get_index(struct usnic_vnic *vnic);
  92. #endif /*!USNIC_VNIC_H_*/