bnxt_ulp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Broadcom NetXtreme-C/E network driver.
  2. *
  3. * Copyright (c) 2016-2018 Broadcom Limited
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation.
  8. */
  9. #ifndef BNXT_ULP_H
  10. #define BNXT_ULP_H
  11. #define BNXT_ROCE_ULP 0
  12. #define BNXT_OTHER_ULP 1
  13. #define BNXT_MAX_ULP 2
  14. #define BNXT_MIN_ROCE_CP_RINGS 2
  15. #define BNXT_MIN_ROCE_STAT_CTXS 1
  16. struct hwrm_async_event_cmpl;
  17. struct bnxt;
  18. struct bnxt_msix_entry {
  19. u32 vector;
  20. u32 ring_idx;
  21. u32 db_offset;
  22. };
  23. struct bnxt_ulp_ops {
  24. /* async_notifier() cannot sleep (in BH context) */
  25. void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
  26. void (*ulp_stop)(void *);
  27. void (*ulp_start)(void *);
  28. void (*ulp_sriov_config)(void *, int);
  29. void (*ulp_shutdown)(void *);
  30. void (*ulp_irq_stop)(void *);
  31. void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *);
  32. };
  33. struct bnxt_fw_msg {
  34. void *msg;
  35. int msg_len;
  36. void *resp;
  37. int resp_max_len;
  38. int timeout;
  39. };
  40. struct bnxt_ulp {
  41. void *handle;
  42. struct bnxt_ulp_ops __rcu *ulp_ops;
  43. unsigned long *async_events_bmap;
  44. u16 max_async_event_id;
  45. u16 msix_requested;
  46. u16 msix_base;
  47. atomic_t ref_count;
  48. };
  49. struct bnxt_en_dev {
  50. struct net_device *net;
  51. struct pci_dev *pdev;
  52. u32 flags;
  53. #define BNXT_EN_FLAG_ROCEV1_CAP 0x1
  54. #define BNXT_EN_FLAG_ROCEV2_CAP 0x2
  55. #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \
  56. BNXT_EN_FLAG_ROCEV2_CAP)
  57. #define BNXT_EN_FLAG_MSIX_REQUESTED 0x4
  58. const struct bnxt_en_ops *en_ops;
  59. struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP];
  60. };
  61. struct bnxt_en_ops {
  62. int (*bnxt_register_device)(struct bnxt_en_dev *, int,
  63. struct bnxt_ulp_ops *, void *);
  64. int (*bnxt_unregister_device)(struct bnxt_en_dev *, int);
  65. int (*bnxt_request_msix)(struct bnxt_en_dev *, int,
  66. struct bnxt_msix_entry *, int);
  67. int (*bnxt_free_msix)(struct bnxt_en_dev *, int);
  68. int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, int,
  69. struct bnxt_fw_msg *);
  70. int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, int,
  71. unsigned long *, u16);
  72. };
  73. static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
  74. {
  75. if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops))
  76. return true;
  77. return false;
  78. }
  79. int bnxt_get_ulp_msix_num(struct bnxt *bp);
  80. int bnxt_get_ulp_msix_base(struct bnxt *bp);
  81. void bnxt_ulp_stop(struct bnxt *bp);
  82. void bnxt_ulp_start(struct bnxt *bp);
  83. void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
  84. void bnxt_ulp_shutdown(struct bnxt *bp);
  85. void bnxt_ulp_irq_stop(struct bnxt *bp);
  86. void bnxt_ulp_irq_restart(struct bnxt *bp, int err);
  87. void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
  88. struct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev);
  89. #endif