bnxt_ulp.h 2.4 KB

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