1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
6 #include <uapi/linux/if_ether.h>
7 #include <uapi/linux/net_tstamp.h>
8 #include <linux/mutex.h>
9 #include <linux/seqlock.h>
10 #include <linux/xarray.h>
11 #include <net/devlink.h>
14 #define ADMIN_SQE_SIZE SZ_128
15 #define ADMIN_CQE_SIZE SZ_64
16 #define ADMIN_RSP_MAX_LEN (ADMIN_CQE_SIZE - sizeof(struct fun_cqe_info))
18 #define FUN_MAX_MTU 9024
21 #define CQ_DEPTH 1024U
22 #define RQ_DEPTH (512U / (PAGE_SIZE / 4096))
24 #define CQ_INTCOAL_USEC 10
25 #define CQ_INTCOAL_NPKT 16
26 #define SQ_INTCOAL_USEC 10
27 #define SQ_INTCOAL_NPKT 16
29 #define INVALID_LPORT 0xffff
31 #define FUN_PORT_CAP_PAUSE_MASK (FUN_PORT_CAP_TX_PAUSE | FUN_PORT_CAP_RX_PAUSE)
33 struct fun_vport_info
{
40 unsigned int max_rate
;
43 /* "subclass" of fun_dev for Ethernet functions */
47 /* the function's network ports */
48 struct net_device
**netdevs
;
49 unsigned int num_ports
;
51 /* configuration for the function's virtual ports */
52 unsigned int num_vports
;
53 struct fun_vport_info
*vport_info
;
55 struct mutex state_mutex
; /* nests inside RTNL if both taken */
57 unsigned int nsqs_per_port
;
60 static inline struct fun_ethdev
*to_fun_ethdev(struct fun_dev
*p
)
62 return container_of(p
, struct fun_ethdev
, fdev
);
66 struct funeth_rxq
**rxqs
;
67 struct funeth_txq
**txqs
;
68 struct funeth_txq
**xdpqs
;
72 unsigned int rxq_start
;
73 unsigned int txq_start
;
74 unsigned int xdpq_start
;
75 unsigned int cq_depth
;
76 unsigned int rq_depth
;
77 unsigned int sq_depth
;
81 /* Per netdevice driver state, i.e., netdev_priv. */
85 struct net_device
*netdev
;
87 struct funeth_rxq
* __rcu
*rxqs
;
88 struct funeth_txq
**txqs
;
89 struct funeth_txq
* __rcu
*xdpqs
;
92 unsigned int num_tx_irqs
;
93 unsigned int num_rx_irqs
;
94 unsigned int rx_irq_ofst
;
96 unsigned int lane_attrs
;
103 unsigned int link_speed
;
112 unsigned int num_xdpqs
;
114 /* ethtool, etc. config parameters */
115 unsigned int sq_depth
;
116 unsigned int rq_depth
;
117 unsigned int cq_depth
;
118 unsigned int cq_irq_db
;
124 struct hwtstamp_config hwtstamp_cfg
;
126 /* cumulative queue stats from earlier queue instances */
135 unsigned int rss_hw_id
;
136 enum fun_eth_hash_alg hash_algo
;
137 u8 rss_key
[FUN_ETH_RSS_MAX_KEY_SIZE
];
138 unsigned int indir_table_nentries
;
139 u32 indir_table
[FUN_ETH_RSS_MAX_INDIR_ENT
];
140 dma_addr_t rss_dma_addr
;
143 /* DMA area for port stats */
144 dma_addr_t stats_dma_addr
;
147 struct bpf_prog
*xdp_prog
;
149 struct devlink_port dl_port
;
152 unsigned int ktls_id
;
153 atomic64_t tx_tls_add
;
154 atomic64_t tx_tls_del
;
155 atomic64_t tx_tls_resync
;
158 void fun_set_ethtool_ops(struct net_device
*netdev
);
159 int fun_port_write_cmd(struct funeth_priv
*fp
, int key
, u64 data
);
160 int fun_port_read_cmd(struct funeth_priv
*fp
, int key
, u64
*data
);
161 int fun_create_and_bind_tx(struct funeth_priv
*fp
, u32 sqid
);
162 int fun_replace_queues(struct net_device
*dev
, struct fun_qset
*newqs
,
163 struct netlink_ext_ack
*extack
);
164 int fun_change_num_queues(struct net_device
*dev
, unsigned int ntx
,
166 void fun_set_ring_count(struct net_device
*netdev
, unsigned int ntx
,
168 int fun_config_rss(struct net_device
*dev
, int algo
, const u8
*key
,
169 const u32
*qtable
, u8 op
);
171 #endif /* _FUNETH_H */