dpaa_eth.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* Copyright 2008 - 2016 Freescale Semiconductor Inc.
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are met:
  5. * * Redistributions of source code must retain the above copyright
  6. * notice, this list of conditions and the following disclaimer.
  7. * * Redistributions in binary form must reproduce the above copyright
  8. * notice, this list of conditions and the following disclaimer in the
  9. * documentation and/or other materials provided with the distribution.
  10. * * Neither the name of Freescale Semiconductor nor the
  11. * names of its contributors may be used to endorse or promote products
  12. * derived from this software without specific prior written permission.
  13. *
  14. * ALTERNATIVELY, this software may be distributed under the terms of the
  15. * GNU General Public License ("GPL") as published by the Free Software
  16. * Foundation, either version 2 of that License or (at your option) any
  17. * later version.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
  20. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
  23. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef __DPAA_H
  31. #define __DPAA_H
  32. #include <linux/netdevice.h>
  33. #include <soc/fsl/qman.h>
  34. #include <soc/fsl/bman.h>
  35. #include "fman.h"
  36. #include "mac.h"
  37. #include "dpaa_eth_trace.h"
  38. #define DPAA_ETH_TXQ_NUM NR_CPUS
  39. #define DPAA_BPS_NUM 3 /* number of bpools per interface */
  40. /* More detailed FQ types - used for fine-grained WQ assignments */
  41. enum dpaa_fq_type {
  42. FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */
  43. FQ_TYPE_RX_ERROR, /* Rx Error FQs */
  44. FQ_TYPE_TX, /* "Real" Tx FQs */
  45. FQ_TYPE_TX_CONFIRM, /* Tx default Conf FQ (actually an Rx FQ) */
  46. FQ_TYPE_TX_CONF_MQ, /* Tx conf FQs (one for each Tx FQ) */
  47. FQ_TYPE_TX_ERROR, /* Tx Error FQs (these are actually Rx FQs) */
  48. };
  49. struct dpaa_fq {
  50. struct qman_fq fq_base;
  51. struct list_head list;
  52. struct net_device *net_dev;
  53. bool init;
  54. u32 fqid;
  55. u32 flags;
  56. u16 channel;
  57. u8 wq;
  58. enum dpaa_fq_type fq_type;
  59. };
  60. struct dpaa_fq_cbs {
  61. struct qman_fq rx_defq;
  62. struct qman_fq tx_defq;
  63. struct qman_fq rx_errq;
  64. struct qman_fq tx_errq;
  65. struct qman_fq egress_ern;
  66. };
  67. struct dpaa_bp {
  68. /* device used in the DMA mapping operations */
  69. struct device *dev;
  70. /* current number of buffers in the buffer pool alloted to each CPU */
  71. int __percpu *percpu_count;
  72. /* all buffers allocated for this pool have this raw size */
  73. size_t raw_size;
  74. /* all buffers in this pool have this same usable size */
  75. size_t size;
  76. /* the buffer pools are initialized with config_count buffers for each
  77. * CPU; at runtime the number of buffers per CPU is constantly brought
  78. * back to this level
  79. */
  80. u16 config_count;
  81. u8 bpid;
  82. struct bman_pool *pool;
  83. /* bpool can be seeded before use by this cb */
  84. int (*seed_cb)(struct dpaa_bp *);
  85. /* bpool can be emptied before freeing by this cb */
  86. void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *);
  87. atomic_t refs;
  88. };
  89. struct dpaa_rx_errors {
  90. u64 dme; /* DMA Error */
  91. u64 fpe; /* Frame Physical Error */
  92. u64 fse; /* Frame Size Error */
  93. u64 phe; /* Header Error */
  94. };
  95. /* Counters for QMan ERN frames - one counter per rejection code */
  96. struct dpaa_ern_cnt {
  97. u64 cg_tdrop; /* Congestion group taildrop */
  98. u64 wred; /* WRED congestion */
  99. u64 err_cond; /* Error condition */
  100. u64 early_window; /* Order restoration, frame too early */
  101. u64 late_window; /* Order restoration, frame too late */
  102. u64 fq_tdrop; /* FQ taildrop */
  103. u64 fq_retired; /* FQ is retired */
  104. u64 orp_zero; /* ORP disabled */
  105. };
  106. struct dpaa_napi_portal {
  107. struct napi_struct napi;
  108. struct qman_portal *p;
  109. bool down;
  110. };
  111. struct dpaa_percpu_priv {
  112. struct net_device *net_dev;
  113. struct dpaa_napi_portal np;
  114. u64 in_interrupt;
  115. u64 tx_confirm;
  116. /* fragmented (non-linear) skbuffs received from the stack */
  117. u64 tx_frag_skbuffs;
  118. struct rtnl_link_stats64 stats;
  119. struct dpaa_rx_errors rx_errors;
  120. struct dpaa_ern_cnt ern_cnt;
  121. };
  122. struct dpaa_buffer_layout {
  123. u16 priv_data_size;
  124. };
  125. struct dpaa_priv {
  126. struct dpaa_percpu_priv __percpu *percpu_priv;
  127. struct dpaa_bp *dpaa_bps[DPAA_BPS_NUM];
  128. /* Store here the needed Tx headroom for convenience and speed
  129. * (even though it can be computed based on the fields of buf_layout)
  130. */
  131. u16 tx_headroom;
  132. struct net_device *net_dev;
  133. struct mac_device *mac_dev;
  134. struct qman_fq *egress_fqs[DPAA_ETH_TXQ_NUM];
  135. struct qman_fq *conf_fqs[DPAA_ETH_TXQ_NUM];
  136. u16 channel;
  137. struct list_head dpaa_fq_list;
  138. u32 msg_enable; /* net_device message level */
  139. struct {
  140. /* All egress queues to a given net device belong to one
  141. * (and the same) congestion group.
  142. */
  143. struct qman_cgr cgr;
  144. /* If congested, when it began. Used for performance stats. */
  145. u32 congestion_start_jiffies;
  146. /* Number of jiffies the Tx port was congested. */
  147. u32 congested_jiffies;
  148. /* Counter for the number of times the CGR
  149. * entered congestion state
  150. */
  151. u32 cgr_congested_count;
  152. } cgr_data;
  153. /* Use a per-port CGR for ingress traffic. */
  154. bool use_ingress_cgr;
  155. struct qman_cgr ingress_cgr;
  156. struct dpaa_buffer_layout buf_layout[2];
  157. u16 rx_headroom;
  158. };
  159. /* from dpaa_ethtool.c */
  160. extern const struct ethtool_ops dpaa_ethtool_ops;
  161. /* from dpaa_eth_sysfs.c */
  162. void dpaa_eth_sysfs_remove(struct device *dev);
  163. void dpaa_eth_sysfs_init(struct device *dev);
  164. #endif /* __DPAA_H */