154e4ee71SNavdeep Parhar /*-
24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni *
454e4ee71SNavdeep Parhar * Copyright (c) 2011 Chelsio Communications, Inc.
554e4ee71SNavdeep Parhar * All rights reserved.
654e4ee71SNavdeep Parhar *
754e4ee71SNavdeep Parhar * Redistribution and use in source and binary forms, with or without
854e4ee71SNavdeep Parhar * modification, are permitted provided that the following conditions
954e4ee71SNavdeep Parhar * are met:
1054e4ee71SNavdeep Parhar * 1. Redistributions of source code must retain the above copyright
1154e4ee71SNavdeep Parhar * notice, this list of conditions and the following disclaimer.
1254e4ee71SNavdeep Parhar * 2. Redistributions in binary form must reproduce the above copyright
1354e4ee71SNavdeep Parhar * notice, this list of conditions and the following disclaimer in the
1454e4ee71SNavdeep Parhar * documentation and/or other materials provided with the distribution.
1554e4ee71SNavdeep Parhar *
1654e4ee71SNavdeep Parhar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1754e4ee71SNavdeep Parhar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1854e4ee71SNavdeep Parhar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1954e4ee71SNavdeep Parhar * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2054e4ee71SNavdeep Parhar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2154e4ee71SNavdeep Parhar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2254e4ee71SNavdeep Parhar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2354e4ee71SNavdeep Parhar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2454e4ee71SNavdeep Parhar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2554e4ee71SNavdeep Parhar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2654e4ee71SNavdeep Parhar * SUCH DAMAGE.
2754e4ee71SNavdeep Parhar *
2854e4ee71SNavdeep Parhar */
2954e4ee71SNavdeep Parhar
3054e4ee71SNavdeep Parhar #ifndef __CHELSIO_COMMON_H
3154e4ee71SNavdeep Parhar #define __CHELSIO_COMMON_H
3254e4ee71SNavdeep Parhar
3354e4ee71SNavdeep Parhar #include "t4_hw.h"
3454e4ee71SNavdeep Parhar
3554e4ee71SNavdeep Parhar enum {
3654e4ee71SNavdeep Parhar MAX_NPORTS = 4, /* max # of ports */
3754e4ee71SNavdeep Parhar SERNUM_LEN = 24, /* Serial # length */
3854e4ee71SNavdeep Parhar EC_LEN = 16, /* E/C length */
3954e4ee71SNavdeep Parhar ID_LEN = 16, /* ID length */
402a5f6b0eSNavdeep Parhar PN_LEN = 16, /* Part Number length */
41426b6bd5SNavdeep Parhar MD_LEN = 16, /* MFG diags version length */
422a5f6b0eSNavdeep Parhar MACADDR_LEN = 12, /* MAC Address length */
4354e4ee71SNavdeep Parhar };
4454e4ee71SNavdeep Parhar
454f8a1fd8SNavdeep Parhar enum {
464f8a1fd8SNavdeep Parhar T4_REGMAP_SIZE = (160 * 1024),
474f8a1fd8SNavdeep Parhar T5_REGMAP_SIZE = (332 * 1024),
484f8a1fd8SNavdeep Parhar };
494f8a1fd8SNavdeep Parhar
5083a611e0SNavdeep Parhar enum { MEM_EDC0, MEM_EDC1, MEM_MC, MEM_MC0 = MEM_MC, MEM_MC1, MEM_HMA };
5154e4ee71SNavdeep Parhar
5254e4ee71SNavdeep Parhar enum dev_master { MASTER_CANT, MASTER_MAY, MASTER_MUST };
5354e4ee71SNavdeep Parhar
5454e4ee71SNavdeep Parhar enum dev_state { DEV_STATE_UNINIT, DEV_STATE_INIT, DEV_STATE_ERR };
5554e4ee71SNavdeep Parhar
5654e4ee71SNavdeep Parhar enum {
5754e4ee71SNavdeep Parhar PAUSE_RX = 1 << 0,
5854e4ee71SNavdeep Parhar PAUSE_TX = 1 << 1,
5954e4ee71SNavdeep Parhar PAUSE_AUTONEG = 1 << 2
6054e4ee71SNavdeep Parhar };
6154e4ee71SNavdeep Parhar
62358bca3bSNavdeep Parhar enum {
63e3338deeSNavdeep Parhar /*
64e3338deeSNavdeep Parhar * Real FECs. In the same order as the FEC portion of caps32 so that
65e3338deeSNavdeep Parhar * the code can do (fec & M_FW_PORT_CAP32_FEC) to get all the real FECs.
66e3338deeSNavdeep Parhar */
67e3338deeSNavdeep Parhar FEC_RS = 1 << 0, /* Reed-Solomon */
68e3338deeSNavdeep Parhar FEC_BASER_RS = 1 << 1, /* BASE-R, aka Firecode */
69e3338deeSNavdeep Parhar FEC_NONE = 1 << 2, /* no FEC */
70e3338deeSNavdeep Parhar
71e3338deeSNavdeep Parhar /*
72e3338deeSNavdeep Parhar * Pseudo FECs that translate to real FECs. The firmware knows nothing
73e3338deeSNavdeep Parhar * about these and they start at M_FW_PORT_CAP32_FEC + 1. AUTO should
74e3338deeSNavdeep Parhar * be set all by itself.
75e3338deeSNavdeep Parhar */
76e3338deeSNavdeep Parhar FEC_AUTO = 1 << 5,
77e3338deeSNavdeep Parhar FEC_MODULE = 1 << 6, /* FEC suggested by the cable/transceiver. */
78358bca3bSNavdeep Parhar };
79358bca3bSNavdeep Parhar
805c2bacdeSNavdeep Parhar enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
815c2bacdeSNavdeep Parhar
8254e4ee71SNavdeep Parhar struct port_stats {
8354e4ee71SNavdeep Parhar u64 tx_octets; /* total # of octets in good frames */
8454e4ee71SNavdeep Parhar u64 tx_frames; /* all good frames */
8554e4ee71SNavdeep Parhar u64 tx_bcast_frames; /* all broadcast frames */
8654e4ee71SNavdeep Parhar u64 tx_mcast_frames; /* all multicast frames */
8754e4ee71SNavdeep Parhar u64 tx_ucast_frames; /* all unicast frames */
8854e4ee71SNavdeep Parhar u64 tx_error_frames; /* all error frames */
8954e4ee71SNavdeep Parhar
9054e4ee71SNavdeep Parhar u64 tx_frames_64; /* # of Tx frames in a particular range */
9154e4ee71SNavdeep Parhar u64 tx_frames_65_127;
9254e4ee71SNavdeep Parhar u64 tx_frames_128_255;
9354e4ee71SNavdeep Parhar u64 tx_frames_256_511;
9454e4ee71SNavdeep Parhar u64 tx_frames_512_1023;
9554e4ee71SNavdeep Parhar u64 tx_frames_1024_1518;
9654e4ee71SNavdeep Parhar u64 tx_frames_1519_max;
9754e4ee71SNavdeep Parhar
9854e4ee71SNavdeep Parhar u64 tx_drop; /* # of dropped Tx frames */
9954e4ee71SNavdeep Parhar u64 tx_pause; /* # of transmitted pause frames */
10054e4ee71SNavdeep Parhar u64 tx_ppp0; /* # of transmitted PPP prio 0 frames */
10154e4ee71SNavdeep Parhar u64 tx_ppp1; /* # of transmitted PPP prio 1 frames */
10254e4ee71SNavdeep Parhar u64 tx_ppp2; /* # of transmitted PPP prio 2 frames */
10354e4ee71SNavdeep Parhar u64 tx_ppp3; /* # of transmitted PPP prio 3 frames */
10454e4ee71SNavdeep Parhar u64 tx_ppp4; /* # of transmitted PPP prio 4 frames */
10554e4ee71SNavdeep Parhar u64 tx_ppp5; /* # of transmitted PPP prio 5 frames */
10654e4ee71SNavdeep Parhar u64 tx_ppp6; /* # of transmitted PPP prio 6 frames */
10754e4ee71SNavdeep Parhar u64 tx_ppp7; /* # of transmitted PPP prio 7 frames */
10854e4ee71SNavdeep Parhar
10954e4ee71SNavdeep Parhar u64 rx_octets; /* total # of octets in good frames */
11054e4ee71SNavdeep Parhar u64 rx_frames; /* all good frames */
11154e4ee71SNavdeep Parhar u64 rx_bcast_frames; /* all broadcast frames */
11254e4ee71SNavdeep Parhar u64 rx_mcast_frames; /* all multicast frames */
11354e4ee71SNavdeep Parhar u64 rx_ucast_frames; /* all unicast frames */
11454e4ee71SNavdeep Parhar u64 rx_too_long; /* # of frames exceeding MTU */
11554e4ee71SNavdeep Parhar u64 rx_jabber; /* # of jabber frames */
11654e4ee71SNavdeep Parhar u64 rx_fcs_err; /* # of received frames with bad FCS */
11754e4ee71SNavdeep Parhar u64 rx_len_err; /* # of received frames with length error */
11854e4ee71SNavdeep Parhar u64 rx_symbol_err; /* symbol errors */
11954e4ee71SNavdeep Parhar u64 rx_runt; /* # of short frames */
12054e4ee71SNavdeep Parhar
12154e4ee71SNavdeep Parhar u64 rx_frames_64; /* # of Rx frames in a particular range */
12254e4ee71SNavdeep Parhar u64 rx_frames_65_127;
12354e4ee71SNavdeep Parhar u64 rx_frames_128_255;
12454e4ee71SNavdeep Parhar u64 rx_frames_256_511;
12554e4ee71SNavdeep Parhar u64 rx_frames_512_1023;
12654e4ee71SNavdeep Parhar u64 rx_frames_1024_1518;
12754e4ee71SNavdeep Parhar u64 rx_frames_1519_max;
12854e4ee71SNavdeep Parhar
12954e4ee71SNavdeep Parhar u64 rx_pause; /* # of received pause frames */
13054e4ee71SNavdeep Parhar u64 rx_ppp0; /* # of received PPP prio 0 frames */
13154e4ee71SNavdeep Parhar u64 rx_ppp1; /* # of received PPP prio 1 frames */
13254e4ee71SNavdeep Parhar u64 rx_ppp2; /* # of received PPP prio 2 frames */
13354e4ee71SNavdeep Parhar u64 rx_ppp3; /* # of received PPP prio 3 frames */
13454e4ee71SNavdeep Parhar u64 rx_ppp4; /* # of received PPP prio 4 frames */
13554e4ee71SNavdeep Parhar u64 rx_ppp5; /* # of received PPP prio 5 frames */
13654e4ee71SNavdeep Parhar u64 rx_ppp6; /* # of received PPP prio 6 frames */
13754e4ee71SNavdeep Parhar u64 rx_ppp7; /* # of received PPP prio 7 frames */
13854e4ee71SNavdeep Parhar
13954e4ee71SNavdeep Parhar u64 rx_ovflow0; /* drops due to buffer-group 0 overflows */
14054e4ee71SNavdeep Parhar u64 rx_ovflow1; /* drops due to buffer-group 1 overflows */
14154e4ee71SNavdeep Parhar u64 rx_ovflow2; /* drops due to buffer-group 2 overflows */
14254e4ee71SNavdeep Parhar u64 rx_ovflow3; /* drops due to buffer-group 3 overflows */
14354e4ee71SNavdeep Parhar u64 rx_trunc0; /* buffer-group 0 truncated packets */
14454e4ee71SNavdeep Parhar u64 rx_trunc1; /* buffer-group 1 truncated packets */
14554e4ee71SNavdeep Parhar u64 rx_trunc2; /* buffer-group 2 truncated packets */
14654e4ee71SNavdeep Parhar u64 rx_trunc3; /* buffer-group 3 truncated packets */
14754e4ee71SNavdeep Parhar };
14854e4ee71SNavdeep Parhar
14954e4ee71SNavdeep Parhar struct lb_port_stats {
15054e4ee71SNavdeep Parhar u64 octets;
15154e4ee71SNavdeep Parhar u64 frames;
15254e4ee71SNavdeep Parhar u64 bcast_frames;
15354e4ee71SNavdeep Parhar u64 mcast_frames;
15454e4ee71SNavdeep Parhar u64 ucast_frames;
15554e4ee71SNavdeep Parhar u64 error_frames;
15654e4ee71SNavdeep Parhar
15754e4ee71SNavdeep Parhar u64 frames_64;
15854e4ee71SNavdeep Parhar u64 frames_65_127;
15954e4ee71SNavdeep Parhar u64 frames_128_255;
16054e4ee71SNavdeep Parhar u64 frames_256_511;
16154e4ee71SNavdeep Parhar u64 frames_512_1023;
16254e4ee71SNavdeep Parhar u64 frames_1024_1518;
16354e4ee71SNavdeep Parhar u64 frames_1519_max;
16454e4ee71SNavdeep Parhar
16554e4ee71SNavdeep Parhar u64 drop;
16654e4ee71SNavdeep Parhar
16754e4ee71SNavdeep Parhar u64 ovflow0;
16854e4ee71SNavdeep Parhar u64 ovflow1;
16954e4ee71SNavdeep Parhar u64 ovflow2;
17054e4ee71SNavdeep Parhar u64 ovflow3;
17154e4ee71SNavdeep Parhar u64 trunc0;
17254e4ee71SNavdeep Parhar u64 trunc1;
17354e4ee71SNavdeep Parhar u64 trunc2;
17454e4ee71SNavdeep Parhar u64 trunc3;
17554e4ee71SNavdeep Parhar };
17654e4ee71SNavdeep Parhar
17754e4ee71SNavdeep Parhar struct tp_tcp_stats {
178ecdff8faSNavdeep Parhar u32 tcp_out_rsts;
179ecdff8faSNavdeep Parhar u64 tcp_in_segs;
180ecdff8faSNavdeep Parhar u64 tcp_out_segs;
181ecdff8faSNavdeep Parhar u64 tcp_retrans_segs;
18254e4ee71SNavdeep Parhar };
18354e4ee71SNavdeep Parhar
18454e4ee71SNavdeep Parhar struct tp_usm_stats {
18554e4ee71SNavdeep Parhar u32 frames;
18654e4ee71SNavdeep Parhar u32 drops;
18754e4ee71SNavdeep Parhar u64 octets;
18854e4ee71SNavdeep Parhar };
18954e4ee71SNavdeep Parhar
190dbc5c85cSNavdeep Parhar struct tp_tid_stats {
191dbc5c85cSNavdeep Parhar u32 del;
192dbc5c85cSNavdeep Parhar u32 inv;
193dbc5c85cSNavdeep Parhar u32 act;
194dbc5c85cSNavdeep Parhar u32 pas;
195dbc5c85cSNavdeep Parhar };
196dbc5c85cSNavdeep Parhar
19754e4ee71SNavdeep Parhar struct tp_fcoe_stats {
198ecdff8faSNavdeep Parhar u32 frames_ddp;
199ecdff8faSNavdeep Parhar u32 frames_drop;
200ecdff8faSNavdeep Parhar u64 octets_ddp;
20154e4ee71SNavdeep Parhar };
20254e4ee71SNavdeep Parhar
20354e4ee71SNavdeep Parhar struct tp_err_stats {
204d1205d09SNavdeep Parhar u32 mac_in_errs[MAX_NCHAN];
205d1205d09SNavdeep Parhar u32 hdr_in_errs[MAX_NCHAN];
206d1205d09SNavdeep Parhar u32 tcp_in_errs[MAX_NCHAN];
207d1205d09SNavdeep Parhar u32 tnl_cong_drops[MAX_NCHAN];
208d1205d09SNavdeep Parhar u32 ofld_chan_drops[MAX_NCHAN];
209d1205d09SNavdeep Parhar u32 tnl_tx_drops[MAX_NCHAN];
210d1205d09SNavdeep Parhar u32 ofld_vlan_drops[MAX_NCHAN];
211d1205d09SNavdeep Parhar u32 tcp6_in_errs[MAX_NCHAN];
212ecdff8faSNavdeep Parhar u32 ofld_no_neigh;
213ecdff8faSNavdeep Parhar u32 ofld_cong_defer;
21454e4ee71SNavdeep Parhar };
21554e4ee71SNavdeep Parhar
216dbc5c85cSNavdeep Parhar struct tp_tnl_stats {
217dbc5c85cSNavdeep Parhar u32 out_pkt[MAX_NCHAN];
218dbc5c85cSNavdeep Parhar u32 in_pkt[MAX_NCHAN];
219dbc5c85cSNavdeep Parhar };
220dbc5c85cSNavdeep Parhar
22154e4ee71SNavdeep Parhar struct tp_proxy_stats {
222d1205d09SNavdeep Parhar u32 proxy[MAX_NCHAN];
22354e4ee71SNavdeep Parhar };
22454e4ee71SNavdeep Parhar
22554e4ee71SNavdeep Parhar struct tp_cpl_stats {
226d1205d09SNavdeep Parhar u32 req[MAX_NCHAN];
227d1205d09SNavdeep Parhar u32 rsp[MAX_NCHAN];
22854e4ee71SNavdeep Parhar };
22954e4ee71SNavdeep Parhar
23054e4ee71SNavdeep Parhar struct tp_rdma_stats {
23154e4ee71SNavdeep Parhar u32 rqe_dfr_pkt;
232ecdff8faSNavdeep Parhar u32 rqe_dfr_mod;
23354e4ee71SNavdeep Parhar };
23454e4ee71SNavdeep Parhar
23590e7434aSNavdeep Parhar struct sge_params {
236d491f8caSNavdeep Parhar int timer_val[SGE_NTIMERS]; /* final, scaled values */
23790e7434aSNavdeep Parhar int counter_val[SGE_NCOUNTERS];
23890e7434aSNavdeep Parhar int fl_starve_threshold;
23990e7434aSNavdeep Parhar int fl_starve_threshold2;
24090e7434aSNavdeep Parhar int page_shift;
24190e7434aSNavdeep Parhar int eq_s_qpp;
24290e7434aSNavdeep Parhar int iq_s_qpp;
24390e7434aSNavdeep Parhar int spg_len;
24490e7434aSNavdeep Parhar int pad_boundary;
24590e7434aSNavdeep Parhar int pack_boundary;
24690e7434aSNavdeep Parhar int fl_pktshift;
24759c1e950SJohn Baldwin u32 sge_control;
24859c1e950SJohn Baldwin u32 sge_fl_buffer_size[SGE_FLBUF_SIZES];
24990e7434aSNavdeep Parhar };
25090e7434aSNavdeep Parhar
25154e4ee71SNavdeep Parhar struct tp_params {
25254e4ee71SNavdeep Parhar unsigned int tre; /* log2 of core clocks per TP tick */
25354e4ee71SNavdeep Parhar unsigned int dack_re; /* DACK timer resolution */
25454e4ee71SNavdeep Parhar unsigned int la_mask; /* what events are recorded by TP LA */
255700cfba7SNavdeep Parhar
2567ac8040aSNavdeep Parhar uint16_t filter_mode;
2577ac8040aSNavdeep Parhar uint16_t filter_mask; /* Used by TOE and hashfilters */
2587ac8040aSNavdeep Parhar int vnic_mode;
2596a59b994SNavdeep Parhar uint32_t max_rx_pdu;
2606a59b994SNavdeep Parhar uint32_t max_tx_pdu;
261a4a4ad2dSNavdeep Parhar bool rx_pkt_encap;
262700cfba7SNavdeep Parhar
263700cfba7SNavdeep Parhar int8_t fcoe_shift;
264c337fa30SNavdeep Parhar int8_t port_shift;
265700cfba7SNavdeep Parhar int8_t vnic_shift;
266700cfba7SNavdeep Parhar int8_t vlan_shift;
267700cfba7SNavdeep Parhar int8_t tos_shift;
268c337fa30SNavdeep Parhar int8_t protocol_shift;
269700cfba7SNavdeep Parhar int8_t ethertype_shift;
270700cfba7SNavdeep Parhar int8_t macmatch_shift;
271700cfba7SNavdeep Parhar int8_t matchtype_shift;
272700cfba7SNavdeep Parhar int8_t frag_shift;
27354e4ee71SNavdeep Parhar };
27454e4ee71SNavdeep Parhar
275f76effedSNavdeep Parhar /* Use same modulation queue as the tx channel. */
276f76effedSNavdeep Parhar #define TX_MODQ(tx_chan) (tx_chan)
277f76effedSNavdeep Parhar
27854e4ee71SNavdeep Parhar struct vpd_params {
27954e4ee71SNavdeep Parhar unsigned int cclk;
28054e4ee71SNavdeep Parhar u8 ec[EC_LEN + 1];
28154e4ee71SNavdeep Parhar u8 sn[SERNUM_LEN + 1];
28254e4ee71SNavdeep Parhar u8 id[ID_LEN + 1];
2832a5f6b0eSNavdeep Parhar u8 pn[PN_LEN + 1];
2842a5f6b0eSNavdeep Parhar u8 na[MACADDR_LEN + 1];
285426b6bd5SNavdeep Parhar u8 md[MD_LEN + 1];
28654e4ee71SNavdeep Parhar };
28754e4ee71SNavdeep Parhar
28854e4ee71SNavdeep Parhar struct pci_params {
28954e4ee71SNavdeep Parhar unsigned int vpd_cap_addr;
290729fee33SNavdeep Parhar unsigned int mps;
291733b9277SNavdeep Parhar unsigned short speed;
292733b9277SNavdeep Parhar unsigned short width;
29354e4ee71SNavdeep Parhar };
29454e4ee71SNavdeep Parhar
29554e4ee71SNavdeep Parhar /*
29654e4ee71SNavdeep Parhar * Firmware device log.
29754e4ee71SNavdeep Parhar */
29854e4ee71SNavdeep Parhar struct devlog_params {
29948d05478SNavdeep Parhar u32 memtype; /* which memory (FW_MEMTYPE_* ) */
30054e4ee71SNavdeep Parhar u32 start; /* start of log in firmware memory */
30154e4ee71SNavdeep Parhar u32 size; /* size of log */
30298790d33SNavdeep Parhar u32 addr; /* start address in flat addr space */
30354e4ee71SNavdeep Parhar };
30454e4ee71SNavdeep Parhar
305d1205d09SNavdeep Parhar /* Stores chip specific parameters */
306d1205d09SNavdeep Parhar struct chip_params {
307d1205d09SNavdeep Parhar u8 nchan;
308d1205d09SNavdeep Parhar u8 pm_stats_cnt;
309d1205d09SNavdeep Parhar u8 cng_ch_bits_log; /* congestion channel map bits width */
310d1205d09SNavdeep Parhar u8 nsched_cls;
311d1205d09SNavdeep Parhar u8 cim_num_obq;
3120460a450SNavdeep Parhar u8 filter_opt_len;
313d1205d09SNavdeep Parhar u16 mps_rplc_size;
314d1205d09SNavdeep Parhar u16 vfcount;
315d1205d09SNavdeep Parhar u32 sge_fl_db;
316d1205d09SNavdeep Parhar u16 mps_tcam_size;
317a2e160c5SNavdeep Parhar u16 rss_nentries;
3189ea86c8fSNavdeep Parhar u16 cim_la_size;
319d1205d09SNavdeep Parhar };
320d1205d09SNavdeep Parhar
321577422fcSJohn Baldwin /* VF-only parameters. */
322577422fcSJohn Baldwin
323577422fcSJohn Baldwin /*
324577422fcSJohn Baldwin * Global Receive Side Scaling (RSS) parameters in host-native format.
325577422fcSJohn Baldwin */
326577422fcSJohn Baldwin struct rss_params {
327577422fcSJohn Baldwin unsigned int mode; /* RSS mode */
328577422fcSJohn Baldwin union {
329577422fcSJohn Baldwin struct {
330577422fcSJohn Baldwin u_int synmapen:1; /* SYN Map Enable */
331577422fcSJohn Baldwin u_int syn4tupenipv6:1; /* enable hashing 4-tuple IPv6 SYNs */
332577422fcSJohn Baldwin u_int syn2tupenipv6:1; /* enable hashing 2-tuple IPv6 SYNs */
333577422fcSJohn Baldwin u_int syn4tupenipv4:1; /* enable hashing 4-tuple IPv4 SYNs */
334577422fcSJohn Baldwin u_int syn2tupenipv4:1; /* enable hashing 2-tuple IPv4 SYNs */
335577422fcSJohn Baldwin u_int ofdmapen:1; /* Offload Map Enable */
336577422fcSJohn Baldwin u_int tnlmapen:1; /* Tunnel Map Enable */
337577422fcSJohn Baldwin u_int tnlalllookup:1; /* Tunnel All Lookup */
338577422fcSJohn Baldwin u_int hashtoeplitz:1; /* use Toeplitz hash */
339577422fcSJohn Baldwin } basicvirtual;
340577422fcSJohn Baldwin } u;
341577422fcSJohn Baldwin };
342577422fcSJohn Baldwin
343577422fcSJohn Baldwin /*
344577422fcSJohn Baldwin * Maximum resources provisioned for a PCI VF.
345577422fcSJohn Baldwin */
346577422fcSJohn Baldwin struct vf_resources {
347577422fcSJohn Baldwin unsigned int nvi; /* N virtual interfaces */
348577422fcSJohn Baldwin unsigned int neq; /* N egress Qs */
349577422fcSJohn Baldwin unsigned int nethctrl; /* N egress ETH or CTRL Qs */
350577422fcSJohn Baldwin unsigned int niqflint; /* N ingress Qs/w free list(s) & intr */
351577422fcSJohn Baldwin unsigned int niq; /* N ingress Qs */
352577422fcSJohn Baldwin unsigned int tc; /* PCI-E traffic class */
353577422fcSJohn Baldwin unsigned int pmask; /* port access rights mask */
354577422fcSJohn Baldwin unsigned int nexactf; /* N exact MPS filters */
355577422fcSJohn Baldwin unsigned int r_caps; /* read capabilities */
356577422fcSJohn Baldwin unsigned int wx_caps; /* write/execute capabilities */
357577422fcSJohn Baldwin };
358577422fcSJohn Baldwin
35954e4ee71SNavdeep Parhar struct adapter_params {
36090e7434aSNavdeep Parhar struct sge_params sge;
361577422fcSJohn Baldwin struct tp_params tp; /* PF-only */
36254e4ee71SNavdeep Parhar struct vpd_params vpd;
36354e4ee71SNavdeep Parhar struct pci_params pci;
364577422fcSJohn Baldwin struct devlog_params devlog; /* PF-only */
365577422fcSJohn Baldwin struct rss_params rss; /* VF-only */
366577422fcSJohn Baldwin struct vf_resources vfres; /* VF-only */
367879462e9SNavdeep Parhar unsigned int core_vdd;
36854e4ee71SNavdeep Parhar
36954e4ee71SNavdeep Parhar unsigned int sf_size; /* serial flash size in bytes */
37054e4ee71SNavdeep Parhar unsigned int sf_nsec; /* # of flash sectors */
37154e4ee71SNavdeep Parhar
372e25621e5SNavdeep Parhar unsigned int fw_vers; /* firmware version */
373e25621e5SNavdeep Parhar unsigned int bs_vers; /* bootstrap version */
374e25621e5SNavdeep Parhar unsigned int tp_vers; /* TP microcode version */
375e25621e5SNavdeep Parhar unsigned int er_vers; /* expansion ROM version */
376e25621e5SNavdeep Parhar unsigned int scfg_vers; /* Serial Configuration version */
377e25621e5SNavdeep Parhar unsigned int vpd_vers; /* VPD version */
37854e4ee71SNavdeep Parhar
37954e4ee71SNavdeep Parhar unsigned short mtus[NMTUS];
38054e4ee71SNavdeep Parhar unsigned short a_wnd[NCCTRL_WIN];
38154e4ee71SNavdeep Parhar unsigned short b_wnd[NCCTRL_WIN];
38254e4ee71SNavdeep Parhar
38354e4ee71SNavdeep Parhar unsigned int cim_la_size;
38454e4ee71SNavdeep Parhar
385d14b0ac1SNavdeep Parhar uint8_t nports; /* # of ethernet ports */
386d14b0ac1SNavdeep Parhar uint8_t portvec;
387d14b0ac1SNavdeep Parhar unsigned int chipid:4; /* chip ID. T4 = 4, T5 = 5, ... */
388d14b0ac1SNavdeep Parhar unsigned int rev:4; /* chip revision */
389d14b0ac1SNavdeep Parhar unsigned int fpga:1; /* this is an FPGA */
390d14b0ac1SNavdeep Parhar unsigned int offload:1; /* hw is TOE capable, fw has divvied up card
391d14b0ac1SNavdeep Parhar resources for TOE operation. */
392d14b0ac1SNavdeep Parhar unsigned int bypass:1; /* this is a bypass card */
39393e9cae3SNavdeep Parhar unsigned int ethoffload:1;
39489f651e7SNavdeep Parhar unsigned int hash_filter:1;
3955174205dSNavdeep Parhar unsigned int filter2_wr_support:1;
396ea710848SNavdeep Parhar unsigned int port_caps32:1;
397a2e160c5SNavdeep Parhar unsigned int smac_add_support:1;
39854e4ee71SNavdeep Parhar
39954e4ee71SNavdeep Parhar unsigned int ofldq_wr_cred;
40093e9cae3SNavdeep Parhar unsigned int eo_wr_cred;
4010a600b63SNavdeep Parhar
4020a600b63SNavdeep Parhar unsigned int max_ordird_qp;
4030a600b63SNavdeep Parhar unsigned int max_ird_adapter;
4045bcae8ddSNavdeep Parhar
4057f10048fSNavdeep Parhar /* These values are for all ports (8b/port, upto 4 ports) */
4067f10048fSNavdeep Parhar uint32_t mps_bg_map; /* MPS rx buffer group map */
4077f10048fSNavdeep Parhar uint32_t tp_ch_map; /* TPCHMAP from firmware */
408f93039d9SNavdeep Parhar
409f93039d9SNavdeep Parhar bool ulptx_memwrite_dsgl; /* use of T5 DSGL allowed */
410f93039d9SNavdeep Parhar bool fr_nsmr_tpte_wr_support; /* FW support for FR_NSMR_TPTE_WR */
411db15dbf8SNavdeep Parhar bool dev_512sgl_mr; /* FW support for 512 SGL per FR MR */
412edb518f4SNavdeep Parhar bool viid_smt_extn_support; /* FW returns vin, vfvld & smt index? */
413d735920dSNavdeep Parhar unsigned int max_pkts_per_eth_tx_pkts_wr;
4146beb67c7SNavdeep Parhar uint8_t nsched_cls; /* # of usable sched classes per port */
41554e4ee71SNavdeep Parhar };
41654e4ee71SNavdeep Parhar
417d14b0ac1SNavdeep Parhar #define CHELSIO_T4 0x4
418d14b0ac1SNavdeep Parhar #define CHELSIO_T5 0x5
419d1205d09SNavdeep Parhar #define CHELSIO_T6 0x6
42054e4ee71SNavdeep Parhar
421a5eff821SNavdeep Parhar /*
422a5eff821SNavdeep Parhar * State needed to monitor the forward progress of SGE Ingress DMA activities
423a5eff821SNavdeep Parhar * and possible hangs.
424a5eff821SNavdeep Parhar */
425a5eff821SNavdeep Parhar struct sge_idma_monitor_state {
426a5eff821SNavdeep Parhar unsigned int idma_1s_thresh; /* 1s threshold in Core Clock ticks */
427a5eff821SNavdeep Parhar unsigned int idma_stalled[2]; /* synthesized stalled timers in HZ */
428a5eff821SNavdeep Parhar unsigned int idma_state[2]; /* IDMA Hang detect state */
429a5eff821SNavdeep Parhar unsigned int idma_qid[2]; /* IDMA Hung Ingress Queue ID */
430a5eff821SNavdeep Parhar unsigned int idma_warn[2]; /* time to warning in HZ */
431a5eff821SNavdeep Parhar };
432a5eff821SNavdeep Parhar
43354e4ee71SNavdeep Parhar struct trace_params {
43454e4ee71SNavdeep Parhar u32 data[TRACE_LEN / 4];
43554e4ee71SNavdeep Parhar u32 mask[TRACE_LEN / 4];
43654e4ee71SNavdeep Parhar unsigned short snap_len;
43754e4ee71SNavdeep Parhar unsigned short min_len;
43854e4ee71SNavdeep Parhar unsigned char skip_ofst;
43954e4ee71SNavdeep Parhar unsigned char skip_len;
44054e4ee71SNavdeep Parhar unsigned char invert;
44154e4ee71SNavdeep Parhar unsigned char port;
44254e4ee71SNavdeep Parhar };
44354e4ee71SNavdeep Parhar
44454e4ee71SNavdeep Parhar struct link_config {
445ea710848SNavdeep Parhar /* OS-specific code owns all the requested_* fields. */
446ea710848SNavdeep Parhar int8_t requested_aneg; /* link autonegotiation */
447ea710848SNavdeep Parhar int8_t requested_fc; /* flow control */
448ea710848SNavdeep Parhar int8_t requested_fec; /* FEC */
449448bcd01SNavdeep Parhar int8_t force_fec; /* FORCE_FEC in L1_CFG32 command. */
450ea710848SNavdeep Parhar u_int requested_speed; /* speed (Mbps) */
451d99b1d83SNavdeep Parhar uint32_t requested_caps;/* rcap in last l1cfg issued by the driver. */
45201285747SNavdeep Parhar
453448bcd01SNavdeep Parhar /* These are populated with information from the firmware. */
454e3338deeSNavdeep Parhar uint32_t pcaps; /* link capabilities */
455e3338deeSNavdeep Parhar uint32_t acaps; /* advertised capabilities */
456e3338deeSNavdeep Parhar uint32_t lpacaps; /* peer advertised capabilities */
457ea710848SNavdeep Parhar u_int speed; /* actual link speed (Mbps) */
458ea710848SNavdeep Parhar int8_t fc; /* actual link flow control */
459e3338deeSNavdeep Parhar int8_t fec_hint; /* cable/transceiver recommended fec */
460ea710848SNavdeep Parhar int8_t fec; /* actual FEC */
461ea710848SNavdeep Parhar bool link_ok; /* link up? */
462ea710848SNavdeep Parhar uint8_t link_down_rc; /* link down reason */
46354e4ee71SNavdeep Parhar };
46454e4ee71SNavdeep Parhar
46554e4ee71SNavdeep Parhar #include "adapter.h"
46654e4ee71SNavdeep Parhar
46754e4ee71SNavdeep Parhar #ifndef PCI_VENDOR_ID_CHELSIO
46854e4ee71SNavdeep Parhar # define PCI_VENDOR_ID_CHELSIO 0x1425
46954e4ee71SNavdeep Parhar #endif
47054e4ee71SNavdeep Parhar
47154e4ee71SNavdeep Parhar #define for_each_port(adapter, iter) \
47254e4ee71SNavdeep Parhar for (iter = 0; iter < (adapter)->params.nports; ++iter)
47354e4ee71SNavdeep Parhar
is_ftid(const struct adapter * sc,u_int tid)47493e9cae3SNavdeep Parhar static inline int is_ftid(const struct adapter *sc, u_int tid)
47593e9cae3SNavdeep Parhar {
47693e9cae3SNavdeep Parhar
4770c71c9ccSNavdeep Parhar return (sc->tids.nftids > 0 && tid >= sc->tids.ftid_base &&
4780c71c9ccSNavdeep Parhar tid <= sc->tids.ftid_end);
47993e9cae3SNavdeep Parhar }
48093e9cae3SNavdeep Parhar
is_hpftid(const struct adapter * sc,u_int tid)4815fc0f72fSNavdeep Parhar static inline int is_hpftid(const struct adapter *sc, u_int tid)
4825fc0f72fSNavdeep Parhar {
4835fc0f72fSNavdeep Parhar
4845fc0f72fSNavdeep Parhar return (sc->tids.nhpftids > 0 && tid >= sc->tids.hpftid_base &&
4855fc0f72fSNavdeep Parhar tid <= sc->tids.hpftid_end);
4865fc0f72fSNavdeep Parhar }
4875fc0f72fSNavdeep Parhar
is_etid(const struct adapter * sc,u_int tid)48893e9cae3SNavdeep Parhar static inline int is_etid(const struct adapter *sc, u_int tid)
48993e9cae3SNavdeep Parhar {
49093e9cae3SNavdeep Parhar
4910c71c9ccSNavdeep Parhar return (sc->tids.netids > 0 && tid >= sc->tids.etid_base &&
4920c71c9ccSNavdeep Parhar tid <= sc->tids.etid_end);
49393e9cae3SNavdeep Parhar }
49493e9cae3SNavdeep Parhar
is_offload(const struct adapter * adap)49554e4ee71SNavdeep Parhar static inline int is_offload(const struct adapter *adap)
49654e4ee71SNavdeep Parhar {
49754e4ee71SNavdeep Parhar return adap->params.offload;
49854e4ee71SNavdeep Parhar }
49954e4ee71SNavdeep Parhar
is_ethoffload(const struct adapter * adap)50093e9cae3SNavdeep Parhar static inline int is_ethoffload(const struct adapter *adap)
50193e9cae3SNavdeep Parhar {
50293e9cae3SNavdeep Parhar return adap->params.ethoffload;
50393e9cae3SNavdeep Parhar }
50493e9cae3SNavdeep Parhar
is_hashfilter(const struct adapter * adap)50589f651e7SNavdeep Parhar static inline int is_hashfilter(const struct adapter *adap)
50689f651e7SNavdeep Parhar {
50789f651e7SNavdeep Parhar return adap->params.hash_filter;
50889f651e7SNavdeep Parhar }
50989f651e7SNavdeep Parhar
is_ktls(const struct adapter * adap)51015f33555SNavdeep Parhar static inline int is_ktls(const struct adapter *adap)
51115f33555SNavdeep Parhar {
51215f33555SNavdeep Parhar return adap->cryptocaps & FW_CAPS_CONFIG_TLS_HW;
51315f33555SNavdeep Parhar }
51415f33555SNavdeep Parhar
chip_id(struct adapter * adap)515d14b0ac1SNavdeep Parhar static inline int chip_id(struct adapter *adap)
516d14b0ac1SNavdeep Parhar {
517d14b0ac1SNavdeep Parhar return adap->params.chipid;
518d14b0ac1SNavdeep Parhar }
519d14b0ac1SNavdeep Parhar
chip_rev(struct adapter * adap)520d14b0ac1SNavdeep Parhar static inline int chip_rev(struct adapter *adap)
521d14b0ac1SNavdeep Parhar {
522d14b0ac1SNavdeep Parhar return adap->params.rev;
523d14b0ac1SNavdeep Parhar }
524d14b0ac1SNavdeep Parhar
is_t4(struct adapter * adap)525d14b0ac1SNavdeep Parhar static inline int is_t4(struct adapter *adap)
526d14b0ac1SNavdeep Parhar {
527d14b0ac1SNavdeep Parhar return adap->params.chipid == CHELSIO_T4;
528d14b0ac1SNavdeep Parhar }
529d14b0ac1SNavdeep Parhar
is_t5(struct adapter * adap)530d14b0ac1SNavdeep Parhar static inline int is_t5(struct adapter *adap)
531d14b0ac1SNavdeep Parhar {
532d14b0ac1SNavdeep Parhar return adap->params.chipid == CHELSIO_T5;
533d14b0ac1SNavdeep Parhar }
534d14b0ac1SNavdeep Parhar
is_t6(struct adapter * adap)535d1205d09SNavdeep Parhar static inline int is_t6(struct adapter *adap)
536d1205d09SNavdeep Parhar {
537d1205d09SNavdeep Parhar return adap->params.chipid == CHELSIO_T6;
538d1205d09SNavdeep Parhar }
539d1205d09SNavdeep Parhar
is_fpga(struct adapter * adap)540d14b0ac1SNavdeep Parhar static inline int is_fpga(struct adapter *adap)
541d14b0ac1SNavdeep Parhar {
542d14b0ac1SNavdeep Parhar return adap->params.fpga;
543d14b0ac1SNavdeep Parhar }
544d14b0ac1SNavdeep Parhar
core_ticks_per_usec(const struct adapter * adap)54554e4ee71SNavdeep Parhar static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
54654e4ee71SNavdeep Parhar {
54754e4ee71SNavdeep Parhar return adap->params.vpd.cclk / 1000;
54854e4ee71SNavdeep Parhar }
54954e4ee71SNavdeep Parhar
us_to_core_ticks(const struct adapter * adap,unsigned int us)55054e4ee71SNavdeep Parhar static inline unsigned int us_to_core_ticks(const struct adapter *adap,
55154e4ee71SNavdeep Parhar unsigned int us)
55254e4ee71SNavdeep Parhar {
55354e4ee71SNavdeep Parhar return (us * adap->params.vpd.cclk) / 1000;
55454e4ee71SNavdeep Parhar }
55554e4ee71SNavdeep Parhar
core_ticks_to_us(const struct adapter * adapter,unsigned int ticks)55690e7434aSNavdeep Parhar static inline unsigned int core_ticks_to_us(const struct adapter *adapter,
55790e7434aSNavdeep Parhar unsigned int ticks)
55890e7434aSNavdeep Parhar {
55990e7434aSNavdeep Parhar /* add Core Clock / 2 to round ticks to nearest uS */
56090e7434aSNavdeep Parhar return ((ticks * 1000 + adapter->params.vpd.cclk/2) /
56190e7434aSNavdeep Parhar adapter->params.vpd.cclk);
56290e7434aSNavdeep Parhar }
56390e7434aSNavdeep Parhar
dack_ticks_to_usec(const struct adapter * adap,unsigned int ticks)56454e4ee71SNavdeep Parhar static inline unsigned int dack_ticks_to_usec(const struct adapter *adap,
56554e4ee71SNavdeep Parhar unsigned int ticks)
56654e4ee71SNavdeep Parhar {
56754e4ee71SNavdeep Parhar return (ticks << adap->params.tp.dack_re) / core_ticks_per_usec(adap);
56854e4ee71SNavdeep Parhar }
56954e4ee71SNavdeep Parhar
us_to_tcp_ticks(const struct adapter * adap,u_long us)570019c1a01SNavdeep Parhar static inline u_int us_to_tcp_ticks(const struct adapter *adap, u_long us)
571dcbe7056SNavdeep Parhar {
572dcbe7056SNavdeep Parhar
573019c1a01SNavdeep Parhar return (us * adap->params.vpd.cclk / 1000 >> adap->params.tp.tre);
574dcbe7056SNavdeep Parhar }
575dcbe7056SNavdeep Parhar
tcp_ticks_to_us(const struct adapter * adap,u_int ticks)576f8fea0d9SNavdeep Parhar static inline u_int tcp_ticks_to_us(const struct adapter *adap, u_int ticks)
577f8fea0d9SNavdeep Parhar {
578f8fea0d9SNavdeep Parhar return ((uint64_t)ticks << adap->params.tp.tre) /
579f8fea0d9SNavdeep Parhar core_ticks_per_usec(adap);
580f8fea0d9SNavdeep Parhar }
581f8fea0d9SNavdeep Parhar
58254e4ee71SNavdeep Parhar void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, u32 val);
58354e4ee71SNavdeep Parhar
584948d0ec0SNavdeep Parhar int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd,
585948d0ec0SNavdeep Parhar int size, void *rpl, bool sleep_ok, int timeout);
58654e4ee71SNavdeep Parhar int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
58754e4ee71SNavdeep Parhar void *rpl, bool sleep_ok);
588e9e7bc82SNavdeep Parhar void t4_report_fw_error(struct adapter *adap);
58954e4ee71SNavdeep Parhar
t4_wr_mbox_timeout(struct adapter * adap,int mbox,const void * cmd,int size,void * rpl,int timeout)590948d0ec0SNavdeep Parhar static inline int t4_wr_mbox_timeout(struct adapter *adap, int mbox,
591948d0ec0SNavdeep Parhar const void *cmd, int size, void *rpl,
592948d0ec0SNavdeep Parhar int timeout)
593948d0ec0SNavdeep Parhar {
594948d0ec0SNavdeep Parhar return t4_wr_mbox_meat_timeout(adap, mbox, cmd, size, rpl, true,
595948d0ec0SNavdeep Parhar timeout);
596948d0ec0SNavdeep Parhar }
597948d0ec0SNavdeep Parhar
t4_wr_mbox(struct adapter * adap,int mbox,const void * cmd,int size,void * rpl)59854e4ee71SNavdeep Parhar static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
59954e4ee71SNavdeep Parhar int size, void *rpl)
60054e4ee71SNavdeep Parhar {
60154e4ee71SNavdeep Parhar return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
60254e4ee71SNavdeep Parhar }
60354e4ee71SNavdeep Parhar
t4_wr_mbox_ns(struct adapter * adap,int mbox,const void * cmd,int size,void * rpl)60454e4ee71SNavdeep Parhar static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
60554e4ee71SNavdeep Parhar int size, void *rpl)
60654e4ee71SNavdeep Parhar {
60754e4ee71SNavdeep Parhar return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
60854e4ee71SNavdeep Parhar }
60954e4ee71SNavdeep Parhar
61054e4ee71SNavdeep Parhar void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
61154e4ee71SNavdeep Parhar unsigned int data_reg, u32 *vals, unsigned int nregs,
61254e4ee71SNavdeep Parhar unsigned int start_idx);
61354e4ee71SNavdeep Parhar void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
61454e4ee71SNavdeep Parhar unsigned int data_reg, const u32 *vals,
61554e4ee71SNavdeep Parhar unsigned int nregs, unsigned int start_idx);
61654e4ee71SNavdeep Parhar
6172a5f6b0eSNavdeep Parhar u32 t4_hw_pci_read_cfg4(adapter_t *adapter, int reg);
6182a5f6b0eSNavdeep Parhar
61954e4ee71SNavdeep Parhar struct fw_filter_wr;
62054e4ee71SNavdeep Parhar
62154e4ee71SNavdeep Parhar void t4_intr_enable(struct adapter *adapter);
62254e4ee71SNavdeep Parhar void t4_intr_disable(struct adapter *adapter);
623e9e7bc82SNavdeep Parhar bool t4_slow_intr_handler(struct adapter *adapter, bool verbose);
62454e4ee71SNavdeep Parhar
62554e4ee71SNavdeep Parhar int t4_hash_mac_addr(const u8 *addr);
626ecdff8faSNavdeep Parhar int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
62754e4ee71SNavdeep Parhar struct link_config *lc);
62854e4ee71SNavdeep Parhar int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
62954e4ee71SNavdeep Parhar int t4_seeprom_read(struct adapter *adapter, u32 addr, u32 *data);
63054e4ee71SNavdeep Parhar int t4_seeprom_write(struct adapter *adapter, u32 addr, u32 data);
63154e4ee71SNavdeep Parhar int t4_eeprom_ptov(unsigned int phys_addr, unsigned int fn, unsigned int sz);
63254e4ee71SNavdeep Parhar int t4_seeprom_wp(struct adapter *adapter, int enable);
63354e4ee71SNavdeep Parhar int t4_read_flash(struct adapter *adapter, unsigned int addr, unsigned int nwords,
63454e4ee71SNavdeep Parhar u32 *data, int byte_oriented);
635b3500921SNavdeep Parhar int t4_write_flash(struct adapter *adapter, unsigned int addr,
636b3500921SNavdeep Parhar unsigned int n, const u8 *data, int byte_oriented);
63754e4ee71SNavdeep Parhar int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
638a5eff821SNavdeep Parhar int t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op);
639a5eff821SNavdeep Parhar int t5_fw_init_extern_mem(struct adapter *adap);
640b3500921SNavdeep Parhar int t4_load_bootcfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size);
6412a5f6b0eSNavdeep Parhar int t4_load_boot(struct adapter *adap, u8 *boot_data,
642733b9277SNavdeep Parhar unsigned int boot_addr, unsigned int size);
643b3500921SNavdeep Parhar int t4_flash_erase_sectors(struct adapter *adapter, int start, int end);
6443cc9b3e2SNavdeep Parhar int t4_flash_cfg_addr(struct adapter *adapter);
64554e4ee71SNavdeep Parhar int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size);
64654e4ee71SNavdeep Parhar int t4_get_fw_version(struct adapter *adapter, u32 *vers);
647f02cc9b2SNavdeep Parhar int t4_get_fw_hdr(struct adapter *adapter, struct fw_hdr *hdr);
648e25621e5SNavdeep Parhar int t4_get_bs_version(struct adapter *adapter, u32 *vers);
64954e4ee71SNavdeep Parhar int t4_get_tp_version(struct adapter *adapter, u32 *vers);
650a5eff821SNavdeep Parhar int t4_get_exprom_version(struct adapter *adapter, u32 *vers);
651e25621e5SNavdeep Parhar int t4_get_scfg_version(struct adapter *adapter, u32 *vers);
652e25621e5SNavdeep Parhar int t4_get_vpd_version(struct adapter *adapter, u32 *vers);
653e25621e5SNavdeep Parhar int t4_get_version_info(struct adapter *adapter);
65454e4ee71SNavdeep Parhar int t4_init_hw(struct adapter *adapter, u32 fw_params);
6556af45170SJohn Baldwin const struct chip_params *t4_get_chip_params(int chipid);
656426b6bd5SNavdeep Parhar int t4_prep_adapter(struct adapter *adapter, u32 *buf);
657a5eff821SNavdeep Parhar int t4_shutdown_adapter(struct adapter *adapter);
658a5eff821SNavdeep Parhar int t4_init_devlog_params(struct adapter *adapter, int fw_attach);
65990e7434aSNavdeep Parhar int t4_init_sge_params(struct adapter *adapter);
660fae028ddSNavdeep Parhar int t4_init_tp_params(struct adapter *adap);
661c337fa30SNavdeep Parhar int t4_filter_field_shift(const struct adapter *adap, int filter_sel);
662b3500921SNavdeep Parhar int t4_port_init(struct adapter *adap, int mbox, int pf, int vf, int port_id);
663cb7c3f12SNavdeep Parhar void t4_fatal_err(struct adapter *adapter, bool fw_error);
66454e4ee71SNavdeep Parhar int t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
66554e4ee71SNavdeep Parhar int filter_index, int enable);
66654e4ee71SNavdeep Parhar void t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
66754e4ee71SNavdeep Parhar int filter_index, int *enabled);
66854e4ee71SNavdeep Parhar int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
66954e4ee71SNavdeep Parhar int start, int n, const u16 *rspq, unsigned int nrspq);
67054e4ee71SNavdeep Parhar int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
67154e4ee71SNavdeep Parhar unsigned int flags);
67254e4ee71SNavdeep Parhar int t4_config_vi_rss(struct adapter *adapter, int mbox, unsigned int viid,
673a10443e8SNavdeep Parhar unsigned int flags, unsigned int defq, unsigned int skeyidx,
674a10443e8SNavdeep Parhar unsigned int skey);
67554e4ee71SNavdeep Parhar int t4_read_rss(struct adapter *adapter, u16 *entries);
676c45b1868SNavdeep Parhar void t4_read_rss_key(struct adapter *adapter, u32 *key, bool sleep_ok);
677c45b1868SNavdeep Parhar void t4_write_rss_key(struct adapter *adap, const u32 *key, int idx,
678c45b1868SNavdeep Parhar bool sleep_ok);
679c45b1868SNavdeep Parhar void t4_read_rss_pf_config(struct adapter *adapter, unsigned int index,
680c45b1868SNavdeep Parhar u32 *valp, bool sleep_ok);
681c45b1868SNavdeep Parhar void t4_write_rss_pf_config(struct adapter *adapter, unsigned int index,
682c45b1868SNavdeep Parhar u32 val, bool sleep_ok);
68354e4ee71SNavdeep Parhar void t4_read_rss_vf_config(struct adapter *adapter, unsigned int index,
684c45b1868SNavdeep Parhar u32 *vfl, u32 *vfh, bool sleep_ok);
68554e4ee71SNavdeep Parhar void t4_write_rss_vf_config(struct adapter *adapter, unsigned int index,
686c45b1868SNavdeep Parhar u32 vfl, u32 vfh, bool sleep_ok);
687c45b1868SNavdeep Parhar u32 t4_read_rss_pf_map(struct adapter *adapter, bool sleep_ok);
688c45b1868SNavdeep Parhar void t4_write_rss_pf_map(struct adapter *adapter, u32 pfmap, bool sleep_ok);
689c45b1868SNavdeep Parhar u32 t4_read_rss_pf_mask(struct adapter *adapter, bool sleep_ok);
690c45b1868SNavdeep Parhar void t4_write_rss_pf_mask(struct adapter *adapter, u32 pfmask, bool sleep_ok);
69154e4ee71SNavdeep Parhar int t4_mps_set_active_ports(struct adapter *adap, unsigned int port_mask);
69254e4ee71SNavdeep Parhar void t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
69354e4ee71SNavdeep Parhar void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]);
69454e4ee71SNavdeep Parhar void t4_read_cimq_cfg(struct adapter *adap, u16 *base, u16 *size, u16 *thres);
69554e4ee71SNavdeep Parhar int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data, size_t n);
69654e4ee71SNavdeep Parhar int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data, size_t n);
69754e4ee71SNavdeep Parhar int t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
69854e4ee71SNavdeep Parhar unsigned int *valp);
69954e4ee71SNavdeep Parhar int t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n,
70054e4ee71SNavdeep Parhar const unsigned int *valp);
70154e4ee71SNavdeep Parhar int t4_cim_ctl_read(struct adapter *adap, unsigned int addr, unsigned int n,
70254e4ee71SNavdeep Parhar unsigned int *valp);
70354e4ee71SNavdeep Parhar int t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr);
70454e4ee71SNavdeep Parhar void t4_cim_read_pif_la(struct adapter *adap, u32 *pif_req, u32 *pif_rsp,
70554e4ee71SNavdeep Parhar unsigned int *pif_req_wrptr, unsigned int *pif_rsp_wrptr);
70654e4ee71SNavdeep Parhar void t4_cim_read_ma_la(struct adapter *adap, u32 *ma_req, u32 *ma_rsp);
707b3500921SNavdeep Parhar int t4_get_flash_params(struct adapter *adapter);
708a5eff821SNavdeep Parhar
709a5eff821SNavdeep Parhar u32 t4_read_pcie_cfg4(struct adapter *adap, int reg, int drv_fw_attach);
710d14b0ac1SNavdeep Parhar int t4_mc_read(struct adapter *adap, int idx, u32 addr,
711d14b0ac1SNavdeep Parhar __be32 *data, u64 *parity);
71254e4ee71SNavdeep Parhar int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *parity);
71354e4ee71SNavdeep Parhar int t4_mem_read(struct adapter *adap, int mtype, u32 addr, u32 size,
71454e4ee71SNavdeep Parhar __be32 *data);
715a5eff821SNavdeep Parhar void t4_idma_monitor_init(struct adapter *adapter,
716a5eff821SNavdeep Parhar struct sge_idma_monitor_state *idma);
717a5eff821SNavdeep Parhar void t4_idma_monitor(struct adapter *adapter,
718a5eff821SNavdeep Parhar struct sge_idma_monitor_state *idma,
719a5eff821SNavdeep Parhar int hz, int ticks);
720de0a3472SNavdeep Parhar int t4_set_vf_mac(struct adapter *adapter, unsigned int pf, unsigned int vf,
721de0a3472SNavdeep Parhar unsigned int naddr, u8 *addr);
72254e4ee71SNavdeep Parhar
7234f8a1fd8SNavdeep Parhar unsigned int t4_get_regs_len(struct adapter *adapter);
7244f8a1fd8SNavdeep Parhar void t4_get_regs(struct adapter *adap, u8 *buf, size_t buf_size);
7254f8a1fd8SNavdeep Parhar
726b59c5d97SNavdeep Parhar u32 t4_port_reg(struct adapter *adap, u8 port, u32 reg);
727ecdff8faSNavdeep Parhar const char *t4_get_port_type_description(enum fw_port_type port_type);
72854e4ee71SNavdeep Parhar void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
7292a5f6b0eSNavdeep Parhar void t4_get_port_stats_offset(struct adapter *adap, int idx,
7302a5f6b0eSNavdeep Parhar struct port_stats *stats,
7312a5f6b0eSNavdeep Parhar struct port_stats *offset);
73254e4ee71SNavdeep Parhar void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
73354e4ee71SNavdeep Parhar void t4_clr_port_stats(struct adapter *adap, int idx);
73454e4ee71SNavdeep Parhar
73554e4ee71SNavdeep Parhar void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
73654e4ee71SNavdeep Parhar void t4_read_cong_tbl(struct adapter *adap, u16 incr[NMTUS][NCCTRL_WIN]);
73754e4ee71SNavdeep Parhar void t4_read_pace_tbl(struct adapter *adap, unsigned int pace_vals[NTX_SCHED]);
73854e4ee71SNavdeep Parhar void t4_get_tx_sched(struct adapter *adap, unsigned int sched, unsigned int *kbps,
739c45b1868SNavdeep Parhar unsigned int *ipg, bool sleep_ok);
74054e4ee71SNavdeep Parhar void t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr,
74154e4ee71SNavdeep Parhar unsigned int mask, unsigned int val);
74254e4ee71SNavdeep Parhar void t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr);
743c45b1868SNavdeep Parhar void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st,
744c45b1868SNavdeep Parhar bool sleep_ok);
745dbc5c85cSNavdeep Parhar void t4_tp_get_tnl_stats(struct adapter *adap, struct tp_tnl_stats *st,
746dbc5c85cSNavdeep Parhar bool sleep_ok);
747c45b1868SNavdeep Parhar void t4_tp_get_proxy_stats(struct adapter *adap, struct tp_proxy_stats *st,
748c45b1868SNavdeep Parhar bool sleep_ok);
749c45b1868SNavdeep Parhar void t4_tp_get_cpl_stats(struct adapter *adap, struct tp_cpl_stats *st,
750c45b1868SNavdeep Parhar bool sleep_ok);
751c45b1868SNavdeep Parhar void t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st,
752c45b1868SNavdeep Parhar bool sleep_ok);
753c45b1868SNavdeep Parhar void t4_get_usm_stats(struct adapter *adap, struct tp_usm_stats *st,
754c45b1868SNavdeep Parhar bool sleep_ok);
755dbc5c85cSNavdeep Parhar void t4_tp_get_tid_stats(struct adapter *adap, struct tp_tid_stats *st,
756dbc5c85cSNavdeep Parhar bool sleep_ok);
75754e4ee71SNavdeep Parhar void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
758c45b1868SNavdeep Parhar struct tp_tcp_stats *v6, bool sleep_ok);
75954e4ee71SNavdeep Parhar void t4_get_fcoe_stats(struct adapter *adap, unsigned int idx,
760c45b1868SNavdeep Parhar struct tp_fcoe_stats *st, bool sleep_ok);
76154e4ee71SNavdeep Parhar void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
76254e4ee71SNavdeep Parhar const unsigned short *alpha, const unsigned short *beta);
76354e4ee71SNavdeep Parhar
76454e4ee71SNavdeep Parhar void t4_ulprx_read_la(struct adapter *adap, u32 *la_buf);
76554e4ee71SNavdeep Parhar
76654e4ee71SNavdeep Parhar int t4_set_sched_bps(struct adapter *adap, int sched, unsigned int kbps);
76754e4ee71SNavdeep Parhar int t4_set_sched_ipg(struct adapter *adap, int sched, unsigned int ipg);
76854e4ee71SNavdeep Parhar int t4_set_pace_tbl(struct adapter *adap, const unsigned int *pace_vals,
76954e4ee71SNavdeep Parhar unsigned int start, unsigned int n);
77054e4ee71SNavdeep Parhar void t4_get_chan_txrate(struct adapter *adap, u64 *nic_rate, u64 *ofld_rate);
7717ac8040aSNavdeep Parhar int t4_set_filter_cfg(struct adapter *adap, int mode, int mask, int vnic_mode);
77254e4ee71SNavdeep Parhar void t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid);
77354e4ee71SNavdeep Parhar
77454e4ee71SNavdeep Parhar void t4_wol_magic_enable(struct adapter *adap, unsigned int port, const u8 *addr);
77554e4ee71SNavdeep Parhar int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
77654e4ee71SNavdeep Parhar u64 mask0, u64 mask1, unsigned int crc, bool enable);
77754e4ee71SNavdeep Parhar
77854e4ee71SNavdeep Parhar int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
77954e4ee71SNavdeep Parhar enum dev_master master, enum dev_state *state);
78054e4ee71SNavdeep Parhar int t4_fw_bye(struct adapter *adap, unsigned int mbox);
78154e4ee71SNavdeep Parhar int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
7822a5f6b0eSNavdeep Parhar int t4_fw_halt(struct adapter *adap, unsigned int mbox, int force);
783f02cc9b2SNavdeep Parhar int t4_fw_restart(struct adapter *adap, unsigned int mbox);
7842a5f6b0eSNavdeep Parhar int t4_fw_upgrade(struct adapter *adap, unsigned int mbox,
7852a5f6b0eSNavdeep Parhar const u8 *fw_data, unsigned int size, int force);
786733b9277SNavdeep Parhar int t4_fw_initialize(struct adapter *adap, unsigned int mbox);
78754e4ee71SNavdeep Parhar int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
78854e4ee71SNavdeep Parhar unsigned int vf, unsigned int nparams, const u32 *params,
78954e4ee71SNavdeep Parhar u32 *val);
7909b6d39a0SNavdeep Parhar int t4_query_params_rw(struct adapter *adap, unsigned int mbox, unsigned int pf,
7919b6d39a0SNavdeep Parhar unsigned int vf, unsigned int nparams, const u32 *params,
7929b6d39a0SNavdeep Parhar u32 *val, int rw);
7939b6d39a0SNavdeep Parhar int t4_set_params_timeout(struct adapter *adap, unsigned int mbox,
7949b6d39a0SNavdeep Parhar unsigned int pf, unsigned int vf,
7959b6d39a0SNavdeep Parhar unsigned int nparams, const u32 *params,
7969b6d39a0SNavdeep Parhar const u32 *val, int timeout);
79754e4ee71SNavdeep Parhar int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
79854e4ee71SNavdeep Parhar unsigned int vf, unsigned int nparams, const u32 *params,
79954e4ee71SNavdeep Parhar const u32 *val);
80054e4ee71SNavdeep Parhar int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
80154e4ee71SNavdeep Parhar unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
80254e4ee71SNavdeep Parhar unsigned int rxqi, unsigned int rxq, unsigned int tc,
80354e4ee71SNavdeep Parhar unsigned int vi, unsigned int cmask, unsigned int pmask,
80454e4ee71SNavdeep Parhar unsigned int exactf, unsigned int rcaps, unsigned int wxcaps);
8052a5f6b0eSNavdeep Parhar int t4_alloc_vi_func(struct adapter *adap, unsigned int mbox,
8062a5f6b0eSNavdeep Parhar unsigned int port, unsigned int pf, unsigned int vf,
807298d969cSNavdeep Parhar unsigned int nmac, u8 *mac, u16 *rss_size,
808edb518f4SNavdeep Parhar uint8_t *vfvld, uint16_t *vin,
8092a5f6b0eSNavdeep Parhar unsigned int portfunc, unsigned int idstype);
81054e4ee71SNavdeep Parhar int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
81154e4ee71SNavdeep Parhar unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
812edb518f4SNavdeep Parhar u16 *rss_size, uint8_t *vfvld, uint16_t *vin);
81354e4ee71SNavdeep Parhar int t4_free_vi(struct adapter *adap, unsigned int mbox,
81454e4ee71SNavdeep Parhar unsigned int pf, unsigned int vf,
81554e4ee71SNavdeep Parhar unsigned int viid);
81654e4ee71SNavdeep Parhar int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
81754e4ee71SNavdeep Parhar int mtu, int promisc, int all_multi, int bcast, int vlanex,
81854e4ee71SNavdeep Parhar bool sleep_ok);
81954e4ee71SNavdeep Parhar int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox, unsigned int viid,
82054e4ee71SNavdeep Parhar bool free, unsigned int naddr, const u8 **addr, u16 *idx,
82154e4ee71SNavdeep Parhar u64 *hash, bool sleep_ok);
822a2e160c5SNavdeep Parhar int t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
823a2e160c5SNavdeep Parhar unsigned int viid, unsigned int naddr,
824a2e160c5SNavdeep Parhar const u8 **addr, bool sleep_ok);
825a2e160c5SNavdeep Parhar int t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
826a2e160c5SNavdeep Parhar int idx, bool sleep_ok);
827a2e160c5SNavdeep Parhar int t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid,
828a2e160c5SNavdeep Parhar const u8 *addr, const u8 *mask, unsigned int idx,
829a2e160c5SNavdeep Parhar u8 lookup_type, u8 port_id, bool sleep_ok);
830a2e160c5SNavdeep Parhar int t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid,
831a2e160c5SNavdeep Parhar const u8 *addr, const u8 *mask, unsigned int idx,
832a2e160c5SNavdeep Parhar u8 lookup_type, u8 port_id, bool sleep_ok);
833a2e160c5SNavdeep Parhar int t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
834a2e160c5SNavdeep Parhar const u8 *addr, const u8 *mask, unsigned int vni,
835a2e160c5SNavdeep Parhar unsigned int vni_mask, u8 dip_hit, u8 lookup_type,
836a2e160c5SNavdeep Parhar bool sleep_ok);
83754e4ee71SNavdeep Parhar int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
838edb518f4SNavdeep Parhar int idx, const u8 *addr, bool persist, uint16_t *smt_idx);
839a2e160c5SNavdeep Parhar int t4_del_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
840a2e160c5SNavdeep Parhar const u8 *addr, bool smac);
841a2e160c5SNavdeep Parhar int t4_add_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
842a2e160c5SNavdeep Parhar int idx, const u8 *addr, bool persist, u8 *smt_idx, bool smac);
84354e4ee71SNavdeep Parhar int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
84454e4ee71SNavdeep Parhar bool ucast, u64 vec, bool sleep_ok);
8459b6d39a0SNavdeep Parhar int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
8469b6d39a0SNavdeep Parhar unsigned int viid, bool rx_en, bool tx_en, bool dcb_en);
84754e4ee71SNavdeep Parhar int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
84854e4ee71SNavdeep Parhar bool rx_en, bool tx_en);
84954e4ee71SNavdeep Parhar int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
85054e4ee71SNavdeep Parhar unsigned int nblinks);
85154e4ee71SNavdeep Parhar int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
85254e4ee71SNavdeep Parhar unsigned int mmd, unsigned int reg, unsigned int *valp);
85354e4ee71SNavdeep Parhar int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
85454e4ee71SNavdeep Parhar unsigned int mmd, unsigned int reg, unsigned int val);
855a2e160c5SNavdeep Parhar int t4_i2c_io(struct adapter *adap, unsigned int mbox,
856a2e160c5SNavdeep Parhar int port, unsigned int devid,
857a2e160c5SNavdeep Parhar unsigned int offset, unsigned int len,
858a2e160c5SNavdeep Parhar u8 *buf, bool write);
85944eb8936SNavdeep Parhar int t4_i2c_rd(struct adapter *adap, unsigned int mbox,
86044eb8936SNavdeep Parhar int port, unsigned int devid,
86144eb8936SNavdeep Parhar unsigned int offset, unsigned int len,
86244eb8936SNavdeep Parhar u8 *buf);
86344eb8936SNavdeep Parhar int t4_i2c_wr(struct adapter *adap, unsigned int mbox,
86444eb8936SNavdeep Parhar int port, unsigned int devid,
86544eb8936SNavdeep Parhar unsigned int offset, unsigned int len,
86644eb8936SNavdeep Parhar u8 *buf);
867a5eff821SNavdeep Parhar int t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
868a5eff821SNavdeep Parhar unsigned int vf, unsigned int iqtype, unsigned int iqid,
869a5eff821SNavdeep Parhar unsigned int fl0id, unsigned int fl1id);
87054e4ee71SNavdeep Parhar int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
87154e4ee71SNavdeep Parhar unsigned int vf, unsigned int iqtype, unsigned int iqid,
87254e4ee71SNavdeep Parhar unsigned int fl0id, unsigned int fl1id);
8738eba75edSNavdeep Parhar int t4_eth_eq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf,
8748eba75edSNavdeep Parhar unsigned int vf, unsigned int eqid);
87554e4ee71SNavdeep Parhar int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
87654e4ee71SNavdeep Parhar unsigned int vf, unsigned int eqid);
87754e4ee71SNavdeep Parhar int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
87854e4ee71SNavdeep Parhar unsigned int vf, unsigned int eqid);
87954e4ee71SNavdeep Parhar int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
88054e4ee71SNavdeep Parhar unsigned int vf, unsigned int eqid);
88154e4ee71SNavdeep Parhar int t4_sge_ctxt_rd(struct adapter *adap, unsigned int mbox, unsigned int cid,
88254e4ee71SNavdeep Parhar enum ctxt_type ctype, u32 *data);
88354e4ee71SNavdeep Parhar int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type ctype,
88454e4ee71SNavdeep Parhar u32 *data);
885a2e160c5SNavdeep Parhar int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox, int ctxt_type);
886f799998fSNavdeep Parhar const char *t4_link_down_rc_str(unsigned char link_down_rc);
88701285747SNavdeep Parhar int t4_update_port_info(struct port_info *pi);
88854e4ee71SNavdeep Parhar int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
8892a5f6b0eSNavdeep Parhar int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, u32 addr, u32 val);
890bc22dc70SNavdeep Parhar int t4_sched_config(struct adapter *adapter, int type, int minmaxen,
891bc22dc70SNavdeep Parhar int sleep_ok);
89205337b80SNavdeep Parhar int t4_sched_params(struct adapter *adapter, int type, int level, int mode,
89305337b80SNavdeep Parhar int rateunit, int ratemode, int channel, int cl,
894bc22dc70SNavdeep Parhar int minrate, int maxrate, int weight, int pktsize,
89509a7189fSNavdeep Parhar int burstsize, int sleep_ok);
8962204b427SNavdeep Parhar int t4_sched_params_ch_rl(struct adapter *adapter, int channel, int ratemode,
8972204b427SNavdeep Parhar unsigned int maxrate, int sleep_ok);
8982204b427SNavdeep Parhar int t4_sched_params_cl_wrr(struct adapter *adapter, int channel, int cl,
8992204b427SNavdeep Parhar int weight, int sleep_ok);
9002204b427SNavdeep Parhar int t4_sched_params_cl_rl_kbps(struct adapter *adapter, int channel, int cl,
9012204b427SNavdeep Parhar int mode, unsigned int maxrate, int pktsize,
9022204b427SNavdeep Parhar int sleep_ok);
903a5eff821SNavdeep Parhar int t4_config_watchdog(struct adapter *adapter, unsigned int mbox,
904a5eff821SNavdeep Parhar unsigned int pf, unsigned int vf,
905a5eff821SNavdeep Parhar unsigned int timeout, unsigned int action);
906a5eff821SNavdeep Parhar int t4_get_devlog_level(struct adapter *adapter, unsigned int *level);
907a5eff821SNavdeep Parhar int t4_set_devlog_level(struct adapter *adapter, unsigned int level);
908a5eff821SNavdeep Parhar void t4_sge_decode_idma_state(struct adapter *adapter, int state);
9096af45170SJohn Baldwin
910c45b1868SNavdeep Parhar void t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
911c45b1868SNavdeep Parhar u32 start_index, bool sleep_ok);
912c45b1868SNavdeep Parhar void t4_tp_pio_write(struct adapter *adap, const u32 *buff, u32 nregs,
913c45b1868SNavdeep Parhar u32 start_index, bool sleep_ok);
914c45b1868SNavdeep Parhar void t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs,
915c45b1868SNavdeep Parhar u32 start_index, bool sleep_ok);
916c45b1868SNavdeep Parhar void t4_tp_mib_read(struct adapter *adap, u32 *buff, u32 nregs,
917c45b1868SNavdeep Parhar u32 start_index, bool sleep_ok);
918a2e160c5SNavdeep Parhar int t4_configure_ringbb(struct adapter *adap);
919a2e160c5SNavdeep Parhar int t4_configure_add_smac(struct adapter *adap);
920a2e160c5SNavdeep Parhar int t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf,
921a2e160c5SNavdeep Parhar u16 vlan);
922c45b1868SNavdeep Parhar
t4vf_query_params(struct adapter * adapter,unsigned int nparams,const u32 * params,u32 * vals)9236af45170SJohn Baldwin static inline int t4vf_query_params(struct adapter *adapter,
9246af45170SJohn Baldwin unsigned int nparams, const u32 *params,
9256af45170SJohn Baldwin u32 *vals)
9266af45170SJohn Baldwin {
9276af45170SJohn Baldwin return t4_query_params(adapter, 0, 0, 0, nparams, params, vals);
9286af45170SJohn Baldwin }
9296af45170SJohn Baldwin
t4vf_set_params(struct adapter * adapter,unsigned int nparams,const u32 * params,const u32 * vals)9306af45170SJohn Baldwin static inline int t4vf_set_params(struct adapter *adapter,
9316af45170SJohn Baldwin unsigned int nparams, const u32 *params,
9326af45170SJohn Baldwin const u32 *vals)
9336af45170SJohn Baldwin {
9346af45170SJohn Baldwin return t4_set_params(adapter, 0, 0, 0, nparams, params, vals);
9356af45170SJohn Baldwin }
9366af45170SJohn Baldwin
t4vf_wr_mbox(struct adapter * adap,const void * cmd,int size,void * rpl)9376af45170SJohn Baldwin static inline int t4vf_wr_mbox(struct adapter *adap, const void *cmd,
9386af45170SJohn Baldwin int size, void *rpl)
9396af45170SJohn Baldwin {
9406af45170SJohn Baldwin return t4_wr_mbox(adap, adap->mbox, cmd, size, rpl);
9416af45170SJohn Baldwin }
9426af45170SJohn Baldwin
9436af45170SJohn Baldwin int t4vf_wait_dev_ready(struct adapter *adapter);
9446af45170SJohn Baldwin int t4vf_fw_reset(struct adapter *adapter);
9456af45170SJohn Baldwin int t4vf_get_sge_params(struct adapter *adapter);
9466af45170SJohn Baldwin int t4vf_get_rss_glb_config(struct adapter *adapter);
9476af45170SJohn Baldwin int t4vf_get_vfres(struct adapter *adapter);
9486af45170SJohn Baldwin int t4vf_prep_adapter(struct adapter *adapter);
949dc0800a9SNavdeep Parhar int t4vf_get_vf_mac(struct adapter *adapter, unsigned int port,
950dc0800a9SNavdeep Parhar unsigned int *naddr, u8 *addr);
951*4471ff11SNavdeep Parhar int t4vf_get_vf_vlan(struct adapter *adapter);
9525c2bacdeSNavdeep Parhar int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
9535c2bacdeSNavdeep Parhar enum t4_bar2_qtype qtype, int user, u64 *pbar2_qoffset,
9545c2bacdeSNavdeep Parhar unsigned int *pbar2_qid);
955ea710848SNavdeep Parhar unsigned int fwcap_to_speed(uint32_t caps);
956ea710848SNavdeep Parhar uint32_t speed_to_fwcap(unsigned int speed);
957ea710848SNavdeep Parhar uint32_t fwcap_top_speed(uint32_t caps);
958ea710848SNavdeep Parhar
959ea710848SNavdeep Parhar static inline int
port_top_speed(const struct port_info * pi)960ea710848SNavdeep Parhar port_top_speed(const struct port_info *pi)
961ea710848SNavdeep Parhar {
962ea710848SNavdeep Parhar
963ea710848SNavdeep Parhar /* Mbps -> Gbps */
964e3338deeSNavdeep Parhar return (fwcap_to_speed(pi->link_cfg.pcaps) / 1000);
965ea710848SNavdeep Parhar }
9666af45170SJohn Baldwin
96764a00f87SNavdeep Parhar /* SET_TCB_FIELD sent as a ULP command looks like this */
96864a00f87SNavdeep Parhar #define LEN__SET_TCB_FIELD_ULP (sizeof(struct ulp_txpkt) + \
96964a00f87SNavdeep Parhar sizeof(struct ulptx_idata) + sizeof(struct cpl_set_tcb_field_core))
97064a00f87SNavdeep Parhar
97164a00f87SNavdeep Parhar static inline void *
mk_set_tcb_field_ulp(struct adapter * sc,void * cur,int tid,uint16_t word,uint64_t mask,uint64_t val)97264a00f87SNavdeep Parhar mk_set_tcb_field_ulp(struct adapter *sc, void *cur, int tid, uint16_t word,
97364a00f87SNavdeep Parhar uint64_t mask, uint64_t val)
97464a00f87SNavdeep Parhar {
97564a00f87SNavdeep Parhar struct ulp_txpkt *ulpmc;
97664a00f87SNavdeep Parhar struct ulptx_idata *ulpsc;
97764a00f87SNavdeep Parhar struct cpl_set_tcb_field_core *req;
97864a00f87SNavdeep Parhar
97964a00f87SNavdeep Parhar MPASS(((uintptr_t)cur & 7) == 0);
98064a00f87SNavdeep Parhar
98164a00f87SNavdeep Parhar ulpmc = cur;
98264a00f87SNavdeep Parhar ulpmc->cmd_dest = htobe32(V_ULPTX_CMD(ULP_TX_PKT) |
98364a00f87SNavdeep Parhar V_ULP_TXPKT_DEST(ULP_TXPKT_DEST_TP));
98464a00f87SNavdeep Parhar ulpmc->len = htobe32(howmany(LEN__SET_TCB_FIELD_ULP, 16));
98564a00f87SNavdeep Parhar
98664a00f87SNavdeep Parhar ulpsc = (struct ulptx_idata *)(ulpmc + 1);
98764a00f87SNavdeep Parhar ulpsc->cmd_more = htobe32(V_ULPTX_CMD(ULP_TX_SC_IMM));
98864a00f87SNavdeep Parhar ulpsc->len = htobe32(sizeof(*req));
98964a00f87SNavdeep Parhar
99064a00f87SNavdeep Parhar req = (struct cpl_set_tcb_field_core *)(ulpsc + 1);
99164a00f87SNavdeep Parhar OPCODE_TID(req) = htobe32(MK_OPCODE_TID(CPL_SET_TCB_FIELD, tid));
99264a00f87SNavdeep Parhar req->reply_ctrl = htobe16(F_NO_REPLY);
99364a00f87SNavdeep Parhar req->word_cookie = htobe16(V_WORD(word) | V_COOKIE(0));
99464a00f87SNavdeep Parhar req->mask = htobe64(mask);
99564a00f87SNavdeep Parhar req->val = htobe64(val);
99664a00f87SNavdeep Parhar
99764a00f87SNavdeep Parhar /*
99864a00f87SNavdeep Parhar * ULP_TX is an 8B processor but the firmware transfers WRs in 16B
99964a00f87SNavdeep Parhar * chunks. The master command for set_tcb_field does not end at a 16B
100064a00f87SNavdeep Parhar * boundary so it needs to be padded with a no-op.
100164a00f87SNavdeep Parhar */
100264a00f87SNavdeep Parhar MPASS((LEN__SET_TCB_FIELD_ULP & 0xf) != 0);
100364a00f87SNavdeep Parhar ulpsc = (struct ulptx_idata *)(req + 1);
100464a00f87SNavdeep Parhar ulpsc->cmd_more = htobe32(V_ULPTX_CMD(ULP_TX_SC_NOOP));
100564a00f87SNavdeep Parhar ulpsc->len = htobe32(0);
100664a00f87SNavdeep Parhar
100764a00f87SNavdeep Parhar return (ulpsc + 1);
100864a00f87SNavdeep Parhar }
100954e4ee71SNavdeep Parhar #endif /* __CHELSIO_COMMON_H */
1010