octeon_mailbox.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. /*Macro for Read acknowldgement*/
  26. #define OCTEON_PFVFACK 0xffffffffffffffff
  27. #define OCTEON_PFVFSIG 0x1122334455667788
  28. #define OCTEON_PFVFERR 0xDEADDEADDEADDEAD
  29. #define LIO_MBOX_WRITE_WAIT_CNT 1000
  30. #define LIO_MBOX_WRITE_WAIT_TIME 10
  31. enum octeon_mbox_cmd_status {
  32. OCTEON_MBOX_STATUS_SUCCESS = 0,
  33. OCTEON_MBOX_STATUS_FAILED = 1,
  34. OCTEON_MBOX_STATUS_BUSY = 2
  35. };
  36. enum octeon_mbox_message_type {
  37. OCTEON_MBOX_REQUEST = 0,
  38. OCTEON_MBOX_RESPONSE = 1
  39. };
  40. union octeon_mbox_message {
  41. u64 u64;
  42. struct {
  43. u16 type : 1;
  44. u16 resp_needed : 1;
  45. u16 cmd : 6;
  46. u16 len : 8;
  47. u8 params[6];
  48. } s;
  49. };
  50. typedef void (*octeon_mbox_callback_t)(void *, void *, void *);
  51. struct octeon_mbox_cmd {
  52. union octeon_mbox_message msg;
  53. u64 data[OCTEON_MBOX_DATA_MAX];
  54. u32 q_no;
  55. u32 recv_len;
  56. u32 recv_status;
  57. octeon_mbox_callback_t fn;
  58. void *fn_arg;
  59. };
  60. enum octeon_mbox_state {
  61. OCTEON_MBOX_STATE_IDLE = 1,
  62. OCTEON_MBOX_STATE_REQUEST_RECEIVING = 2,
  63. OCTEON_MBOX_STATE_REQUEST_RECEIVED = 4,
  64. OCTEON_MBOX_STATE_RESPONSE_PENDING = 8,
  65. OCTEON_MBOX_STATE_RESPONSE_RECEIVING = 16,
  66. OCTEON_MBOX_STATE_RESPONSE_RECEIVED = 16,
  67. OCTEON_MBOX_STATE_ERROR = 32
  68. };
  69. struct octeon_mbox {
  70. /** A spinlock to protect access to this q_mbox. */
  71. spinlock_t lock;
  72. struct octeon_device *oct_dev;
  73. u32 q_no;
  74. enum octeon_mbox_state state;
  75. struct cavium_wk mbox_poll_wk;
  76. /** SLI_MAC_PF_MBOX_INT for PF, SLI_PKT_MBOX_INT for VF. */
  77. void *mbox_int_reg;
  78. /** SLI_PKT_PF_VF_MBOX_SIG(0) for PF, SLI_PKT_PF_VF_MBOX_SIG(1) for VF.
  79. */
  80. void *mbox_write_reg;
  81. /** SLI_PKT_PF_VF_MBOX_SIG(1) for PF, SLI_PKT_PF_VF_MBOX_SIG(0) for VF.
  82. */
  83. void *mbox_read_reg;
  84. struct octeon_mbox_cmd mbox_req;
  85. struct octeon_mbox_cmd mbox_resp;
  86. };
  87. int octeon_mbox_read(struct octeon_mbox *mbox);
  88. int octeon_mbox_write(struct octeon_device *oct,
  89. struct octeon_mbox_cmd *mbox_cmd);
  90. int octeon_mbox_process_message(struct octeon_mbox *mbox);
  91. #endif