Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
0002 /*
0003  * Copyright 2008 - 2016 Freescale Semiconductor Inc.
0004  */
0005 
0006 #ifndef __DPAA_H
0007 #define __DPAA_H
0008 
0009 #include <linux/netdevice.h>
0010 #include <linux/refcount.h>
0011 #include <soc/fsl/qman.h>
0012 #include <soc/fsl/bman.h>
0013 
0014 #include "fman.h"
0015 #include "mac.h"
0016 #include "dpaa_eth_trace.h"
0017 
0018 /* Number of prioritised traffic classes */
0019 #define DPAA_TC_NUM     4
0020 /* Number of Tx queues per traffic class */
0021 #define DPAA_TC_TXQ_NUM     NR_CPUS
0022 /* Total number of Tx queues */
0023 #define DPAA_ETH_TXQ_NUM    (DPAA_TC_NUM * DPAA_TC_TXQ_NUM)
0024 
0025 /* More detailed FQ types - used for fine-grained WQ assignments */
0026 enum dpaa_fq_type {
0027     FQ_TYPE_RX_DEFAULT = 1, /* Rx Default FQs */
0028     FQ_TYPE_RX_ERROR,   /* Rx Error FQs */
0029     FQ_TYPE_RX_PCD,     /* Rx Parse Classify Distribute FQs */
0030     FQ_TYPE_TX,     /* "Real" Tx FQs */
0031     FQ_TYPE_TX_CONFIRM, /* Tx default Conf FQ (actually an Rx FQ) */
0032     FQ_TYPE_TX_CONF_MQ, /* Tx conf FQs (one for each Tx FQ) */
0033     FQ_TYPE_TX_ERROR,   /* Tx Error FQs (these are actually Rx FQs) */
0034 };
0035 
0036 struct dpaa_fq {
0037     struct qman_fq fq_base;
0038     struct list_head list;
0039     struct net_device *net_dev;
0040     bool init;
0041     u32 fqid;
0042     u32 flags;
0043     u16 channel;
0044     u8 wq;
0045     enum dpaa_fq_type fq_type;
0046     struct xdp_rxq_info xdp_rxq;
0047 };
0048 
0049 struct dpaa_fq_cbs {
0050     struct qman_fq rx_defq;
0051     struct qman_fq tx_defq;
0052     struct qman_fq rx_errq;
0053     struct qman_fq tx_errq;
0054     struct qman_fq egress_ern;
0055 };
0056 
0057 struct dpaa_priv;
0058 
0059 struct dpaa_bp {
0060     /* used in the DMA mapping operations */
0061     struct dpaa_priv *priv;
0062     /* current number of buffers in the buffer pool alloted to each CPU */
0063     int __percpu *percpu_count;
0064     /* all buffers allocated for this pool have this raw size */
0065     size_t raw_size;
0066     /* all buffers in this pool have this same usable size */
0067     size_t size;
0068     /* the buffer pools are initialized with config_count buffers for each
0069      * CPU; at runtime the number of buffers per CPU is constantly brought
0070      * back to this level
0071      */
0072     u16 config_count;
0073     u8 bpid;
0074     struct bman_pool *pool;
0075     /* bpool can be seeded before use by this cb */
0076     int (*seed_cb)(struct dpaa_bp *);
0077     /* bpool can be emptied before freeing by this cb */
0078     void (*free_buf_cb)(const struct dpaa_bp *, struct bm_buffer *);
0079     refcount_t refs;
0080 };
0081 
0082 struct dpaa_rx_errors {
0083     u64 dme;        /* DMA Error */
0084     u64 fpe;        /* Frame Physical Error */
0085     u64 fse;        /* Frame Size Error */
0086     u64 phe;        /* Header Error */
0087 };
0088 
0089 /* Counters for QMan ERN frames - one counter per rejection code */
0090 struct dpaa_ern_cnt {
0091     u64 cg_tdrop;       /* Congestion group taildrop */
0092     u64 wred;       /* WRED congestion */
0093     u64 err_cond;       /* Error condition */
0094     u64 early_window;   /* Order restoration, frame too early */
0095     u64 late_window;    /* Order restoration, frame too late */
0096     u64 fq_tdrop;       /* FQ taildrop */
0097     u64 fq_retired;     /* FQ is retired */
0098     u64 orp_zero;       /* ORP disabled */
0099 };
0100 
0101 struct dpaa_napi_portal {
0102     struct napi_struct napi;
0103     struct qman_portal *p;
0104     bool down;
0105     int xdp_act;
0106 };
0107 
0108 struct dpaa_percpu_priv {
0109     struct net_device *net_dev;
0110     struct dpaa_napi_portal np;
0111     u64 in_interrupt;
0112     u64 tx_confirm;
0113     /* fragmented (non-linear) skbuffs received from the stack */
0114     u64 tx_frag_skbuffs;
0115     struct rtnl_link_stats64 stats;
0116     struct dpaa_rx_errors rx_errors;
0117     struct dpaa_ern_cnt ern_cnt;
0118 };
0119 
0120 struct dpaa_buffer_layout {
0121     u16 priv_data_size;
0122 };
0123 
0124 /* Information to be used on the Tx confirmation path. Stored just
0125  * before the start of the transmit buffer. Maximum size allowed
0126  * is DPAA_TX_PRIV_DATA_SIZE bytes.
0127  */
0128 struct dpaa_eth_swbp {
0129     struct sk_buff *skb;
0130     struct xdp_frame *xdpf;
0131 };
0132 
0133 struct dpaa_priv {
0134     struct dpaa_percpu_priv __percpu *percpu_priv;
0135     struct dpaa_bp *dpaa_bp;
0136     /* Store here the needed Tx headroom for convenience and speed
0137      * (even though it can be computed based on the fields of buf_layout)
0138      */
0139     u16 tx_headroom;
0140     struct net_device *net_dev;
0141     struct mac_device *mac_dev;
0142     struct device *rx_dma_dev;
0143     struct device *tx_dma_dev;
0144     struct qman_fq *egress_fqs[DPAA_ETH_TXQ_NUM];
0145     struct qman_fq *conf_fqs[DPAA_ETH_TXQ_NUM];
0146 
0147     u16 channel;
0148     struct list_head dpaa_fq_list;
0149 
0150     u8 num_tc;
0151     bool keygen_in_use;
0152     u32 msg_enable; /* net_device message level */
0153 
0154     struct {
0155         /* All egress queues to a given net device belong to one
0156          * (and the same) congestion group.
0157          */
0158         struct qman_cgr cgr;
0159         /* If congested, when it began. Used for performance stats. */
0160         u32 congestion_start_jiffies;
0161         /* Number of jiffies the Tx port was congested. */
0162         u32 congested_jiffies;
0163         /* Counter for the number of times the CGR
0164          * entered congestion state
0165          */
0166         u32 cgr_congested_count;
0167     } cgr_data;
0168     /* Use a per-port CGR for ingress traffic. */
0169     bool use_ingress_cgr;
0170     struct qman_cgr ingress_cgr;
0171 
0172     struct dpaa_buffer_layout buf_layout[2];
0173     u16 rx_headroom;
0174 
0175     bool tx_tstamp; /* Tx timestamping enabled */
0176     bool rx_tstamp; /* Rx timestamping enabled */
0177 
0178     struct bpf_prog *xdp_prog;
0179 };
0180 
0181 /* from dpaa_ethtool.c */
0182 extern const struct ethtool_ops dpaa_ethtool_ops;
0183 
0184 /* from dpaa_eth_sysfs.c */
0185 void dpaa_eth_sysfs_remove(struct device *dev);
0186 void dpaa_eth_sysfs_init(struct device *dev);
0187 #endif  /* __DPAA_H */