hns_dsaf_ppe.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (c) 2014-2015 Hisilicon Limited.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #ifndef _HNS_DSAF_PPE_H
  10. #define _HNS_DSAF_PPE_H
  11. #include <linux/platform_device.h>
  12. #include "hns_dsaf_main.h"
  13. #include "hns_dsaf_mac.h"
  14. #include "hns_dsaf_rcb.h"
  15. #define HNS_PPE_SERVICE_NW_ENGINE_NUM DSAF_COMM_CHN
  16. #define HNS_PPE_DEBUG_NW_ENGINE_NUM 1
  17. #define HNS_PPE_COM_NUM DSAF_COMM_DEV_NUM
  18. #define PPE_COMMON_REG_OFFSET 0x70000
  19. #define PPE_REG_OFFSET 0x10000
  20. #define ETH_PPE_DUMP_NUM 576
  21. #define ETH_PPE_STATIC_NUM 12
  22. #define HNS_PPEV2_RSS_IND_TBL_SIZE 256
  23. #define HNS_PPEV2_RSS_KEY_SIZE 40 /* in bytes or 320 bits */
  24. #define HNS_PPEV2_RSS_KEY_NUM (HNS_PPEV2_RSS_KEY_SIZE / sizeof(u32))
  25. #define HNS_PPEV2_MAX_FRAME_LEN 0X980
  26. enum ppe_qid_mode {
  27. PPE_QID_MODE0 = 0, /* fixed queue id mode */
  28. PPE_QID_MODE1, /* switch:128VM non switch:6Port/4VM/4TC */
  29. PPE_QID_MODE2, /* switch:32VM/4TC non switch:6Port/16VM */
  30. PPE_QID_MODE3, /* switch:4TC/8RSS non switch:2Port/64VM */
  31. PPE_QID_MODE4, /* switch:8VM/16RSS non switch:2Port/16VM/4TC */
  32. PPE_QID_MODE5, /* switch:16VM/8TC non switch:6Port/16RSS */
  33. PPE_QID_MODE6, /* switch:32VM/4RSS non switch:6Port/2VM/8TC */
  34. PPE_QID_MODE7, /* switch:32RSS non switch:2Port/8VM/8TC */
  35. PPE_QID_MODE8, /* switch:6VM/4TC/4RSS non switch:2Port/16VM/4RSS */
  36. PPE_QID_MODE9, /* non switch:2Port/32VM/2RSS */
  37. PPE_QID_MODE10, /* non switch:2Port/32RSS */
  38. PPE_QID_MODE11, /* non switch:2Port/4TC/16RSS */
  39. };
  40. enum ppe_port_mode {
  41. PPE_MODE_GE = 0,
  42. PPE_MODE_XGE,
  43. };
  44. enum ppe_common_mode {
  45. PPE_COMMON_MODE_DEBUG = 0,
  46. PPE_COMMON_MODE_SERVICE,
  47. PPE_COMMON_MODE_MAX
  48. };
  49. struct hns_ppe_hw_stats {
  50. u64 rx_pkts_from_sw;
  51. u64 rx_pkts;
  52. u64 rx_drop_no_bd;
  53. u64 rx_alloc_buf_fail;
  54. u64 rx_alloc_buf_wait;
  55. u64 rx_drop_no_buf;
  56. u64 rx_err_fifo_full;
  57. u64 tx_bd_form_rcb;
  58. u64 tx_pkts_from_rcb;
  59. u64 tx_pkts;
  60. u64 tx_err_fifo_empty;
  61. u64 tx_err_checksum;
  62. };
  63. struct hns_ppe_cb {
  64. struct device *dev;
  65. struct hns_ppe_cb *next; /* pointer to next ppe device */
  66. struct ppe_common_cb *ppe_common_cb; /* belong to */
  67. struct hns_ppe_hw_stats hw_stats;
  68. u8 index; /* index in a ppe common device */
  69. void __iomem *io_base;
  70. int virq;
  71. u32 rss_indir_table[HNS_PPEV2_RSS_IND_TBL_SIZE]; /*shadow indir tab */
  72. u32 rss_key[HNS_PPEV2_RSS_KEY_NUM]; /* rss hash key */
  73. };
  74. struct ppe_common_cb {
  75. struct device *dev;
  76. struct dsaf_device *dsaf_dev;
  77. void __iomem *io_base;
  78. enum ppe_common_mode ppe_mode;
  79. u8 comm_index; /*ppe_common index*/
  80. u32 ppe_num;
  81. struct hns_ppe_cb ppe_cb[0];
  82. };
  83. int hns_ppe_init(struct dsaf_device *dsaf_dev);
  84. void hns_ppe_uninit(struct dsaf_device *dsaf_dev);
  85. void hns_ppe_reset_common(struct dsaf_device *dsaf_dev, u8 ppe_common_index);
  86. void hns_ppe_update_stats(struct hns_ppe_cb *ppe_cb);
  87. int hns_ppe_get_sset_count(int stringset);
  88. int hns_ppe_get_regs_count(void);
  89. void hns_ppe_get_regs(struct hns_ppe_cb *ppe_cb, void *data);
  90. void hns_ppe_get_strings(struct hns_ppe_cb *ppe_cb, int stringset, u8 *data);
  91. void hns_ppe_get_stats(struct hns_ppe_cb *ppe_cb, u64 *data);
  92. void hns_ppe_set_tso_enable(struct hns_ppe_cb *ppe_cb, u32 value);
  93. void hns_ppe_set_rss_key(struct hns_ppe_cb *ppe_cb,
  94. const u32 rss_key[HNS_PPEV2_RSS_KEY_NUM]);
  95. void hns_ppe_set_indir_table(struct hns_ppe_cb *ppe_cb,
  96. const u32 rss_tab[HNS_PPEV2_RSS_IND_TBL_SIZE]);
  97. #endif /* _HNS_DSAF_PPE_H */