bnxt_ulp.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Broadcom NetXtreme-C/E network driver.
  2. *
  3. * Copyright (c) 2016 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_ulp_ops {
  19. /* async_notifier() cannot sleep (in BH context) */
  20. void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *);
  21. void (*ulp_stop)(void *);
  22. void (*ulp_start)(void *);
  23. void (*ulp_sriov_config)(void *, int);
  24. };
  25. struct bnxt_msix_entry {
  26. u32 vector;
  27. u32 ring_idx;
  28. u32 db_offset;
  29. };
  30. struct bnxt_fw_msg {
  31. void *msg;
  32. int msg_len;
  33. void *resp;
  34. int resp_max_len;
  35. int timeout;
  36. };
  37. struct bnxt_ulp {
  38. void *handle;
  39. struct bnxt_ulp_ops __rcu *ulp_ops;
  40. unsigned long *async_events_bmap;
  41. u16 max_async_event_id;
  42. u16 msix_requested;
  43. atomic_t ref_count;
  44. };
  45. struct bnxt_en_dev {
  46. struct net_device *net;
  47. struct pci_dev *pdev;
  48. u32 flags;
  49. #define BNXT_EN_FLAG_ROCEV1_CAP 0x1
  50. #define BNXT_EN_FLAG_ROCEV2_CAP 0x2
  51. #define BNXT_EN_FLAG_ROCE_CAP (BNXT_EN_FLAG_ROCEV1_CAP | \
  52. BNXT_EN_FLAG_ROCEV2_CAP)
  53. const struct bnxt_en_ops *en_ops;
  54. struct bnxt_ulp ulp_tbl[BNXT_MAX_ULP];
  55. };
  56. struct bnxt_en_ops {
  57. int (*bnxt_register_device)(struct bnxt_en_dev *, int,
  58. struct bnxt_ulp_ops *, void *);
  59. int (*bnxt_unregister_device)(struct bnxt_en_dev *, int);
  60. int (*bnxt_request_msix)(struct bnxt_en_dev *, int,
  61. struct bnxt_msix_entry *, int);
  62. int (*bnxt_free_msix)(struct bnxt_en_dev *, int);
  63. int (*bnxt_send_fw_msg)(struct bnxt_en_dev *, int,
  64. struct bnxt_fw_msg *);
  65. int (*bnxt_register_fw_async_events)(struct bnxt_en_dev *, int,
  66. unsigned long *, u16);
  67. };
  68. static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev, int ulp_id)
  69. {
  70. if (edev && rcu_access_pointer(edev->ulp_tbl[ulp_id].ulp_ops))
  71. return true;
  72. return false;
  73. }
  74. void bnxt_subtract_ulp_resources(struct bnxt *bp, int ulp_id);
  75. void bnxt_ulp_stop(struct bnxt *bp);
  76. void bnxt_ulp_start(struct bnxt *bp);
  77. void bnxt_ulp_sriov_cfg(struct bnxt *bp, int num_vfs);
  78. void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl);
  79. struct bnxt_en_dev *bnxt_ulp_probe(struct net_device *dev);
  80. #endif