hclge_mbx.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /* Copyright (c) 2016-2017 Hisilicon Limited. */
  3. #ifndef __HCLGE_MBX_H
  4. #define __HCLGE_MBX_H
  5. #include <linux/init.h>
  6. #include <linux/mutex.h>
  7. #include <linux/types.h>
  8. #define HCLGE_MBX_VF_MSG_DATA_NUM 16
  9. enum HCLGE_MBX_OPCODE {
  10. HCLGE_MBX_RESET = 0x01, /* (VF -> PF) assert reset */
  11. HCLGE_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset*/
  12. HCLGE_MBX_SET_UNICAST, /* (VF -> PF) set UC addr */
  13. HCLGE_MBX_SET_MULTICAST, /* (VF -> PF) set MC addr */
  14. HCLGE_MBX_SET_VLAN, /* (VF -> PF) set VLAN */
  15. HCLGE_MBX_MAP_RING_TO_VECTOR, /* (VF -> PF) map ring-to-vector */
  16. HCLGE_MBX_UNMAP_RING_TO_VECTOR, /* (VF -> PF) unamp ring-to-vector */
  17. HCLGE_MBX_SET_PROMISC_MODE, /* (VF -> PF) set promiscuous mode */
  18. HCLGE_MBX_SET_MACVLAN, /* (VF -> PF) set unicast filter */
  19. HCLGE_MBX_API_NEGOTIATE, /* (VF -> PF) negotiate API version */
  20. HCLGE_MBX_GET_QINFO, /* (VF -> PF) get queue config */
  21. HCLGE_MBX_GET_TCINFO, /* (VF -> PF) get TC config */
  22. HCLGE_MBX_GET_RETA, /* (VF -> PF) get RETA */
  23. HCLGE_MBX_GET_RSS_KEY, /* (VF -> PF) get RSS key */
  24. HCLGE_MBX_GET_MAC_ADDR, /* (VF -> PF) get MAC addr */
  25. HCLGE_MBX_PF_VF_RESP, /* (PF -> VF) generate respone to VF */
  26. HCLGE_MBX_GET_BDNUM, /* (VF -> PF) get BD num */
  27. HCLGE_MBX_GET_BUFSIZE, /* (VF -> PF) get buffer size */
  28. HCLGE_MBX_GET_STREAMID, /* (VF -> PF) get stream id */
  29. HCLGE_MBX_SET_AESTART, /* (VF -> PF) start ae */
  30. HCLGE_MBX_SET_TSOSTATS, /* (VF -> PF) get tso stats */
  31. HCLGE_MBX_LINK_STAT_CHANGE, /* (PF -> VF) link status has changed */
  32. HCLGE_MBX_GET_BASE_CONFIG, /* (VF -> PF) get config */
  33. HCLGE_MBX_BIND_FUNC_QUEUE, /* (VF -> PF) bind function and queue */
  34. HCLGE_MBX_GET_LINK_STATUS, /* (VF -> PF) get link status */
  35. HCLGE_MBX_QUEUE_RESET, /* (VF -> PF) reset queue */
  36. };
  37. /* below are per-VF mac-vlan subcodes */
  38. enum hclge_mbx_mac_vlan_subcode {
  39. HCLGE_MBX_MAC_VLAN_UC_MODIFY = 0, /* modify UC mac addr */
  40. HCLGE_MBX_MAC_VLAN_UC_ADD, /* add a new UC mac addr */
  41. HCLGE_MBX_MAC_VLAN_UC_REMOVE, /* remove a new UC mac addr */
  42. HCLGE_MBX_MAC_VLAN_MC_MODIFY, /* modify MC mac addr */
  43. HCLGE_MBX_MAC_VLAN_MC_ADD, /* add new MC mac addr */
  44. HCLGE_MBX_MAC_VLAN_MC_REMOVE, /* remove MC mac addr */
  45. HCLGE_MBX_MAC_VLAN_MC_FUNC_MTA_ENABLE, /* config func MTA enable */
  46. HCLGE_MBX_MAC_VLAN_MTA_TYPE_READ, /* read func MTA type */
  47. HCLGE_MBX_MAC_VLAN_MTA_STATUS_UPDATE, /* update MTA status */
  48. };
  49. /* below are per-VF vlan cfg subcodes */
  50. enum hclge_mbx_vlan_cfg_subcode {
  51. HCLGE_MBX_VLAN_FILTER = 0, /* set vlan filter */
  52. HCLGE_MBX_VLAN_TX_OFF_CFG, /* set tx side vlan offload */
  53. HCLGE_MBX_VLAN_RX_OFF_CFG, /* set rx side vlan offload */
  54. };
  55. #define HCLGE_MBX_MAX_MSG_SIZE 16
  56. #define HCLGE_MBX_MAX_RESP_DATA_SIZE 8
  57. #define HCLGE_MBX_RING_MAP_BASIC_MSG_NUM 3
  58. #define HCLGE_MBX_RING_NODE_VARIABLE_NUM 3
  59. struct hclgevf_mbx_resp_status {
  60. struct mutex mbx_mutex; /* protects against contending sync cmd resp */
  61. u32 origin_mbx_msg;
  62. bool received_resp;
  63. int resp_status;
  64. u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
  65. };
  66. struct hclge_mbx_vf_to_pf_cmd {
  67. u8 rsv;
  68. u8 mbx_src_vfid; /* Auto filled by IMP */
  69. u8 rsv1[2];
  70. u8 msg_len;
  71. u8 rsv2[3];
  72. u8 msg[HCLGE_MBX_MAX_MSG_SIZE];
  73. };
  74. struct hclge_mbx_pf_to_vf_cmd {
  75. u8 dest_vfid;
  76. u8 rsv[3];
  77. u8 msg_len;
  78. u8 rsv1[3];
  79. u16 msg[8];
  80. };
  81. /* used by VF to store the received Async responses from PF */
  82. struct hclgevf_mbx_arq_ring {
  83. #define HCLGE_MBX_MAX_ARQ_MSG_SIZE 8
  84. #define HCLGE_MBX_MAX_ARQ_MSG_NUM 1024
  85. struct hclgevf_dev *hdev;
  86. u32 head;
  87. u32 tail;
  88. u32 count;
  89. u16 msg_q[HCLGE_MBX_MAX_ARQ_MSG_NUM][HCLGE_MBX_MAX_ARQ_MSG_SIZE];
  90. };
  91. #define hclge_mbx_ring_ptr_move_crq(crq) \
  92. (crq->next_to_use = (crq->next_to_use + 1) % crq->desc_num)
  93. #define hclge_mbx_tail_ptr_move_arq(arq) \
  94. (arq.tail = (arq.tail + 1) % HCLGE_MBX_MAX_ARQ_MSG_SIZE)
  95. #define hclge_mbx_head_ptr_move_arq(arq) \
  96. (arq.head = (arq.head + 1) % HCLGE_MBX_MAX_ARQ_MSG_SIZE)
  97. #endif