dpaa_eth.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
  2. /*
  3. * Copyright 2008 - 2016 Freescale Semiconductor Inc.
  4. */
  5. #ifndef __DPAA_H
  6. #define __DPAA_H
  7. #include <linux/netdevice.h>
  8. #include <linux/refcount.h>
  9. #include <net/xdp.h>
  10. #include <soc/fsl/qman.h>
  11. #include <soc/fsl/bman.h>
  12. #include "fman.h"
  13. #include "mac.h"
  14. #include "dpaa_eth_trace.h"
  15. /* Number of prioritised traffic classes */
  16. #define DPAA_TC_NUM 4
  17. /* More detailed FQ types - used for fine-grained WQ assignments */
  18. enum dpaa_fq_type {
  19. FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */
  20. FQ_TYPE_RX_ERROR, /* Rx Error FQs */
  21. FQ_TYPE_RX_PCD, /* Rx Parse Classify Distribute FQs */
  22. FQ_TYPE_TX, /* "Real" Tx FQs */
  23. FQ_TYPE_TX_CONFIRM, /* Tx default Conf FQ (actually an Rx FQ) */
  24. FQ_TYPE_TX_CONF_MQ, /* Tx conf FQs (one for each Tx FQ) */
  25. FQ_TYPE_TX_ERROR, /* Tx Error FQs (these are actually Rx FQs) */
  26. };
  27. struct dpaa_fq {
  28. struct qman_fq fq_base;
  29. struct list_head list;
  30. struct net_device *net_dev;
  31. bool init;
  32. u32 fqid;
  33. u32 flags;
  34. u16 channel;
  35. u8 wq;
  36. enum dpaa_fq_type fq_type;
  37. struct xdp_rxq_info xdp_rxq;
  38. };
  39. struct dpaa_fq_cbs {
  40. struct qman_fq rx_defq;
  41. struct qman_fq tx_defq;
  42. struct qman_fq rx_errq;
  43. struct qman_fq tx_errq;
  44. struct qman_fq egress_ern;
  45. };
  46. struct dpaa_priv;
  47. struct dpaa_bp {
  48. /* used in the DMA mapping operations */
  49. struct dpaa_priv *priv;
  50. /* current number of buffers in the buffer pool alloted to each CPU */
  51. int __percpu *percpu_count;
  52. /* all buffers allocated for this pool have this raw size */
  53. size_t raw_size;
  54. /* all buffers in this pool have this same usable size */
  55. size_t size;
  56. /* the buffer pools are initialized with config_count buffers for each
  57. * CPU; at runtime the number of buffers per CPU is constantly brought
  58. * back to this level
  59. */
  60. u16 config_count;
  61. u8 bpid;
  62. struct bman_pool *pool;
  63. /* bpool can be seeded before use by this cb */
  64. int (*seed_cb)(struct dpaa_bp *);
  65. /* bpool can be emptied before freeing by this cb */
  66. void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *);
  67. refcount_t refs;
  68. };
  69. struct dpaa_rx_errors {
  70. u64 dme; /* DMA Error */
  71. u64 fpe; /* Frame Physical Error */
  72. u64 fse; /* Frame Size Error */
  73. u64 phe; /* Header Error */
  74. };
  75. /* Counters for QMan ERN frames - one counter per rejection code */
  76. struct dpaa_ern_cnt {
  77. u64 cg_tdrop; /* Congestion group taildrop */
  78. u64 wred; /* WRED congestion */
  79. u64 err_cond; /* Error condition */
  80. u64 early_window; /* Order restoration, frame too early */
  81. u64 late_window; /* Order restoration, frame too late */
  82. u64 fq_tdrop; /* FQ taildrop */
  83. u64 fq_retired; /* FQ is retired */
  84. u64 orp_zero; /* ORP disabled */
  85. };
  86. struct dpaa_napi_portal {
  87. struct napi_struct napi;
  88. struct qman_portal *p;
  89. bool down;
  90. int xdp_act;
  91. };
  92. struct dpaa_percpu_priv {
  93. struct net_device *net_dev;
  94. struct dpaa_napi_portal np;
  95. u64 in_interrupt;
  96. u64 tx_confirm;
  97. /* fragmented (non-linear) skbuffs received from the stack */
  98. u64 tx_frag_skbuffs;
  99. struct rtnl_link_stats64 stats;
  100. struct dpaa_rx_errors rx_errors;
  101. struct dpaa_ern_cnt ern_cnt;
  102. };
  103. struct dpaa_buffer_layout {
  104. u16 priv_data_size;
  105. };
  106. /* Information to be used on the Tx confirmation path. Stored just
  107. * before the start of the transmit buffer. Maximum size allowed
  108. * is DPAA_TX_PRIV_DATA_SIZE bytes.
  109. */
  110. struct dpaa_eth_swbp {
  111. struct sk_buff *skb;
  112. struct xdp_frame *xdpf;
  113. };
  114. struct dpaa_priv {
  115. struct dpaa_percpu_priv __percpu *percpu_priv;
  116. struct dpaa_bp *dpaa_bp;
  117. /* Store here the needed Tx headroom for convenience and speed
  118. * (even though it can be computed based on the fields of buf_layout)
  119. */
  120. u16 tx_headroom;
  121. struct net_device *net_dev;
  122. struct mac_device *mac_dev;
  123. struct device *rx_dma_dev;
  124. struct device *tx_dma_dev;
  125. struct qman_fq **egress_fqs;
  126. struct qman_fq **conf_fqs;
  127. u16 channel;
  128. struct list_head dpaa_fq_list;
  129. u8 num_tc;
  130. bool keygen_in_use;
  131. u32 msg_enable; /* net_device message level */
  132. struct {
  133. /* All egress queues to a given net device belong to one
  134. * (and the same) congestion group.
  135. */
  136. struct qman_cgr cgr;
  137. /* If congested, when it began. Used for performance stats. */
  138. u32 congestion_start_jiffies;
  139. /* Number of jiffies the Tx port was congested. */
  140. u32 congested_jiffies;
  141. /* Counter for the number of times the CGR
  142. * entered congestion state
  143. */
  144. u32 cgr_congested_count;
  145. } cgr_data;
  146. /* Use a per-port CGR for ingress traffic. */
  147. bool use_ingress_cgr;
  148. struct qman_cgr ingress_cgr;
  149. struct dpaa_buffer_layout buf_layout[2];
  150. u16 rx_headroom;
  151. bool tx_tstamp; /* Tx timestamping enabled */
  152. bool rx_tstamp; /* Rx timestamping enabled */
  153. struct bpf_prog *xdp_prog;
  154. };
  155. /* from dpaa_ethtool.c */
  156. extern const struct ethtool_ops dpaa_ethtool_ops;
  157. /* from dpaa_eth_sysfs.c */
  158. void dpaa_eth_sysfs_remove(struct device *dev);
  159. void dpaa_eth_sysfs_init(struct device *dev);
  160. static inline size_t dpaa_num_txqs_per_tc(void)
  161. {
  162. return num_possible_cpus();
  163. }
  164. /* Total number of Tx queues */
  165. static inline size_t dpaa_max_num_txqs(void)
  166. {
  167. return DPAA_TC_NUM * dpaa_num_txqs_per_tc();
  168. }
  169. #endif /* __DPAA_H */