octeon_mailbox.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**********************************************************************
  2. * Author: Cavium, Inc.
  3. *
  4. * Contact: support@cavium.com
  5. * Please include "LiquidIO" in the subject.
  6. *
  7. * Copyright (c) 2003-2016 Cavium, Inc.
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more details.
  17. ***********************************************************************/
  18. #ifndef __MAILBOX_H__
  19. #define __MAILBOX_H__
  20. /* Macros for Mail Box Communication */
  21. #define OCTEON_MBOX_DATA_MAX 32
  22. #define OCTEON_VF_ACTIVE 0x1
  23. #define OCTEON_VF_FLR_REQUEST 0x2
  24. #define OCTEON_PF_CHANGED_VF_MACADDR 0x4
  25. #define OCTEON_GET_VF_STATS 0x8
  26. /*Macro for Read acknowldgement*/
  27. #define OCTEON_PFVFACK 0xffffffffffffffffULL
  28. #define OCTEON_PFVFSIG 0x1122334455667788ULL
  29. #define OCTEON_PFVFERR 0xDEADDEADDEADDEADULL
  30. #define LIO_MBOX_WRITE_WAIT_CNT 1000
  31. #define LIO_MBOX_WRITE_WAIT_TIME msecs_to_jiffies(1)
  32. enum octeon_mbox_cmd_status {
  33. OCTEON_MBOX_STATUS_SUCCESS = 0,
  34. OCTEON_MBOX_STATUS_FAILED = 1,
  35. OCTEON_MBOX_STATUS_BUSY = 2
  36. };
  37. enum octeon_mbox_message_type {
  38. OCTEON_MBOX_REQUEST = 0,
  39. OCTEON_MBOX_RESPONSE = 1
  40. };
  41. union octeon_mbox_message {
  42. u64 u64;
  43. struct {
  44. u16 type : 1;
  45. u16 resp_needed : 1;
  46. u16 cmd : 6;
  47. u16 len : 8;
  48. u8 params[6];
  49. } s;
  50. };
  51. typedef void (*octeon_mbox_callback_t)(void *, void *, void *);
  52. struct octeon_mbox_cmd {
  53. union octeon_mbox_message msg;
  54. u64 data[OCTEON_MBOX_DATA_MAX];
  55. u32 q_no;
  56. u32 recv_len;
  57. u32 recv_status;
  58. octeon_mbox_callback_t fn;
  59. void *fn_arg;
  60. };
  61. enum octeon_mbox_state {
  62. OCTEON_MBOX_STATE_IDLE = 1,
  63. OCTEON_MBOX_STATE_REQUEST_RECEIVING = 2,
  64. OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
  65. OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
  66. OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
  67. OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 32,
  68. OCTEON_MBOX_STATE_ERROR = 64
  69. };
  70. struct octeon_mbox {
  71. /** A spinlock to protect access to this q_mbox. */
  72. spinlock_t lock;
  73. struct octeon_device *oct_dev;
  74. u32 q_no;
  75. enum octeon_mbox_state state;
  76. struct cavium_wk mbox_poll_wk;
  77. /** SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
  78. void *mbox_int_reg;
  79. /** SLI_PKT_PF_VF_MBOX_SIG(0) for PF, SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
  80. */
  81. void *mbox_write_reg;
  82. /** SLI_PKT_PF_VF_MBOX_SIG(1) for PF, SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
  83. */
  84. void *mbox_read_reg;
  85. struct octeon_mbox_cmd mbox_req;
  86. struct octeon_mbox_cmd mbox_resp;
  87. };
  88. struct oct_vf_stats_ctx {
  89. atomic_t status;
  90. struct oct_vf_stats *stats;
  91. };
  92. int octeon_mbox_read(struct octeon_mbox *mbox);
  93. int octeon_mbox_write(struct octeon_device *oct,
  94. struct octeon_mbox_cmd *mbox_cmd);
  95. int octeon_mbox_process_message(struct octeon_mbox *mbox);
  96. int octeon_mbox_cancel(struct octeon_device *oct, int q_no);
  97. #endif