0001
0002
0003 #ifndef _FUNETH_H
0004 #define _FUNETH_H
0005
0006 #include <uapi/linux/if_ether.h>
0007 #include <uapi/linux/net_tstamp.h>
0008 #include <linux/mutex.h>
0009 #include <linux/seqlock.h>
0010 #include <linux/xarray.h>
0011 #include <net/devlink.h>
0012 #include "fun_dev.h"
0013
0014 #define ADMIN_SQE_SIZE SZ_128
0015 #define ADMIN_CQE_SIZE SZ_64
0016 #define ADMIN_RSP_MAX_LEN (ADMIN_CQE_SIZE - sizeof(struct fun_cqe_info))
0017
0018 #define FUN_MAX_MTU 9024
0019
0020 #define SQ_DEPTH 512U
0021 #define CQ_DEPTH 1024U
0022 #define RQ_DEPTH (512U / (PAGE_SIZE / 4096))
0023
0024 #define CQ_INTCOAL_USEC 10
0025 #define CQ_INTCOAL_NPKT 16
0026 #define SQ_INTCOAL_USEC 10
0027 #define SQ_INTCOAL_NPKT 16
0028
0029 #define INVALID_LPORT 0xffff
0030
0031 #define FUN_PORT_CAP_PAUSE_MASK (FUN_PORT_CAP_TX_PAUSE | FUN_PORT_CAP_RX_PAUSE)
0032
0033 struct fun_vport_info {
0034 u8 mac[ETH_ALEN];
0035 u16 vlan;
0036 __be16 vlan_proto;
0037 u8 qos;
0038 u8 spoofchk:1;
0039 u8 trusted:1;
0040 unsigned int max_rate;
0041 };
0042
0043
0044 struct fun_ethdev {
0045 struct fun_dev fdev;
0046
0047
0048 struct net_device **netdevs;
0049 unsigned int num_ports;
0050
0051
0052 unsigned int num_vports;
0053 struct fun_vport_info *vport_info;
0054
0055 struct mutex state_mutex;
0056
0057 unsigned int nsqs_per_port;
0058 };
0059
0060 static inline struct fun_ethdev *to_fun_ethdev(struct fun_dev *p)
0061 {
0062 return container_of(p, struct fun_ethdev, fdev);
0063 }
0064
0065 struct fun_qset {
0066 struct funeth_rxq **rxqs;
0067 struct funeth_txq **txqs;
0068 struct funeth_txq **xdpqs;
0069 unsigned int nrxqs;
0070 unsigned int ntxqs;
0071 unsigned int nxdpqs;
0072 unsigned int rxq_start;
0073 unsigned int txq_start;
0074 unsigned int xdpq_start;
0075 unsigned int cq_depth;
0076 unsigned int rq_depth;
0077 unsigned int sq_depth;
0078 int state;
0079 };
0080
0081
0082 struct funeth_priv {
0083 struct fun_dev *fdev;
0084 struct pci_dev *pdev;
0085 struct net_device *netdev;
0086
0087 struct funeth_rxq * __rcu *rxqs;
0088 struct funeth_txq **txqs;
0089 struct funeth_txq * __rcu *xdpqs;
0090
0091 struct xarray irqs;
0092 unsigned int num_tx_irqs;
0093 unsigned int num_rx_irqs;
0094 unsigned int rx_irq_ofst;
0095
0096 unsigned int lane_attrs;
0097 u16 lport;
0098
0099
0100 u64 port_caps;
0101 u64 advertising;
0102 u64 lp_advertising;
0103 unsigned int link_speed;
0104 u8 xcvr_type;
0105 u8 active_fc;
0106 u8 active_fec;
0107 u8 link_down_reason;
0108 seqcount_t link_seq;
0109
0110 u32 msg_enable;
0111
0112 unsigned int num_xdpqs;
0113
0114
0115 unsigned int sq_depth;
0116 unsigned int rq_depth;
0117 unsigned int cq_depth;
0118 unsigned int cq_irq_db;
0119 u8 tx_coal_usec;
0120 u8 tx_coal_count;
0121 u8 rx_coal_usec;
0122 u8 rx_coal_count;
0123
0124 struct hwtstamp_config hwtstamp_cfg;
0125
0126
0127 u64 tx_packets;
0128 u64 tx_bytes;
0129 u64 tx_dropped;
0130 u64 rx_packets;
0131 u64 rx_bytes;
0132 u64 rx_dropped;
0133
0134
0135 unsigned int rss_hw_id;
0136 enum fun_eth_hash_alg hash_algo;
0137 u8 rss_key[FUN_ETH_RSS_MAX_KEY_SIZE];
0138 unsigned int indir_table_nentries;
0139 u32 indir_table[FUN_ETH_RSS_MAX_INDIR_ENT];
0140 dma_addr_t rss_dma_addr;
0141 void *rss_cfg;
0142
0143
0144 dma_addr_t stats_dma_addr;
0145 __be64 *stats;
0146
0147 struct bpf_prog *xdp_prog;
0148
0149 struct devlink_port dl_port;
0150
0151
0152 unsigned int ktls_id;
0153 atomic64_t tx_tls_add;
0154 atomic64_t tx_tls_del;
0155 atomic64_t tx_tls_resync;
0156 };
0157
0158 void fun_set_ethtool_ops(struct net_device *netdev);
0159 int fun_port_write_cmd(struct funeth_priv *fp, int key, u64 data);
0160 int fun_port_read_cmd(struct funeth_priv *fp, int key, u64 *data);
0161 int fun_create_and_bind_tx(struct funeth_priv *fp, u32 sqid);
0162 int fun_replace_queues(struct net_device *dev, struct fun_qset *newqs,
0163 struct netlink_ext_ack *extack);
0164 int fun_change_num_queues(struct net_device *dev, unsigned int ntx,
0165 unsigned int nrx);
0166 void fun_set_ring_count(struct net_device *netdev, unsigned int ntx,
0167 unsigned int nrx);
0168 int fun_config_rss(struct net_device *dev, int algo, const u8 *key,
0169 const u32 *qtable, u8 op);
0170
0171 #endif