18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is part of the Chelsio T4 Ethernet driver for Linux. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2003-2016 Chelsio Communications, Inc. All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 78c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 138c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 148c2ecf20Sopenharmony_ci * conditions are met: 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 178c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 188c2ecf20Sopenharmony_ci * disclaimer. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 218c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 228c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 238c2ecf20Sopenharmony_ci * provided with the distribution. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 328c2ecf20Sopenharmony_ci * SOFTWARE. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#ifndef __CXGB4_H__ 368c2ecf20Sopenharmony_ci#define __CXGB4_H__ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include "t4_hw.h" 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#include <linux/bitops.h> 418c2ecf20Sopenharmony_ci#include <linux/cache.h> 428c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 438c2ecf20Sopenharmony_ci#include <linux/list.h> 448c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 458c2ecf20Sopenharmony_ci#include <linux/pci.h> 468c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 478c2ecf20Sopenharmony_ci#include <linux/timer.h> 488c2ecf20Sopenharmony_ci#include <linux/vmalloc.h> 498c2ecf20Sopenharmony_ci#include <linux/rhashtable.h> 508c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 518c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h> 528c2ecf20Sopenharmony_ci#include <linux/ptp_clock_kernel.h> 538c2ecf20Sopenharmony_ci#include <linux/ptp_classify.h> 548c2ecf20Sopenharmony_ci#include <linux/crash_dump.h> 558c2ecf20Sopenharmony_ci#include <linux/thermal.h> 568c2ecf20Sopenharmony_ci#include <asm/io.h> 578c2ecf20Sopenharmony_ci#include "t4_chip_type.h" 588c2ecf20Sopenharmony_ci#include "cxgb4_uld.h" 598c2ecf20Sopenharmony_ci#include "t4fw_api.h" 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__) 628c2ecf20Sopenharmony_ciextern struct list_head adapter_list; 638c2ecf20Sopenharmony_ciextern struct list_head uld_list; 648c2ecf20Sopenharmony_ciextern struct mutex uld_mutex; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* Suspend an Ethernet Tx queue with fewer available descriptors than this. 678c2ecf20Sopenharmony_ci * This is the same as calc_tx_descs() for a TSO packet with 688c2ecf20Sopenharmony_ci * nr_frags == MAX_SKB_FRAGS. 698c2ecf20Sopenharmony_ci */ 708c2ecf20Sopenharmony_ci#define ETHTXQ_STOP_THRES \ 718c2ecf20Sopenharmony_ci (1 + DIV_ROUND_UP((3 * MAX_SKB_FRAGS) / 2 + (MAX_SKB_FRAGS & 1), 8)) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#define FW_PARAM_DEV(param) \ 748c2ecf20Sopenharmony_ci (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) | \ 758c2ecf20Sopenharmony_ci FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_##param)) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define FW_PARAM_PFVF(param) \ 788c2ecf20Sopenharmony_ci (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \ 798c2ecf20Sopenharmony_ci FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param) | \ 808c2ecf20Sopenharmony_ci FW_PARAMS_PARAM_Y_V(0) | \ 818c2ecf20Sopenharmony_ci FW_PARAMS_PARAM_Z_V(0)) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cienum { 848c2ecf20Sopenharmony_ci MAX_NPORTS = 4, /* max # of ports */ 858c2ecf20Sopenharmony_ci SERNUM_LEN = 24, /* Serial # length */ 868c2ecf20Sopenharmony_ci EC_LEN = 16, /* E/C length */ 878c2ecf20Sopenharmony_ci ID_LEN = 16, /* ID length */ 888c2ecf20Sopenharmony_ci PN_LEN = 16, /* Part Number length */ 898c2ecf20Sopenharmony_ci MACADDR_LEN = 12, /* MAC Address length */ 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cienum { 938c2ecf20Sopenharmony_ci T4_REGMAP_SIZE = (160 * 1024), 948c2ecf20Sopenharmony_ci T5_REGMAP_SIZE = (332 * 1024), 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cienum { 988c2ecf20Sopenharmony_ci MEM_EDC0, 998c2ecf20Sopenharmony_ci MEM_EDC1, 1008c2ecf20Sopenharmony_ci MEM_MC, 1018c2ecf20Sopenharmony_ci MEM_MC0 = MEM_MC, 1028c2ecf20Sopenharmony_ci MEM_MC1, 1038c2ecf20Sopenharmony_ci MEM_HMA, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cienum { 1078c2ecf20Sopenharmony_ci MEMWIN0_APERTURE = 2048, 1088c2ecf20Sopenharmony_ci MEMWIN0_BASE = 0x1b800, 1098c2ecf20Sopenharmony_ci MEMWIN1_APERTURE = 32768, 1108c2ecf20Sopenharmony_ci MEMWIN1_BASE = 0x28000, 1118c2ecf20Sopenharmony_ci MEMWIN1_BASE_T5 = 0x52000, 1128c2ecf20Sopenharmony_ci MEMWIN2_APERTURE = 65536, 1138c2ecf20Sopenharmony_ci MEMWIN2_BASE = 0x30000, 1148c2ecf20Sopenharmony_ci MEMWIN2_APERTURE_T5 = 131072, 1158c2ecf20Sopenharmony_ci MEMWIN2_BASE_T5 = 0x60000, 1168c2ecf20Sopenharmony_ci}; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_cienum dev_master { 1198c2ecf20Sopenharmony_ci MASTER_CANT, 1208c2ecf20Sopenharmony_ci MASTER_MAY, 1218c2ecf20Sopenharmony_ci MASTER_MUST 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cienum dev_state { 1258c2ecf20Sopenharmony_ci DEV_STATE_UNINIT, 1268c2ecf20Sopenharmony_ci DEV_STATE_INIT, 1278c2ecf20Sopenharmony_ci DEV_STATE_ERR 1288c2ecf20Sopenharmony_ci}; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cienum cc_pause { 1318c2ecf20Sopenharmony_ci PAUSE_RX = 1 << 0, 1328c2ecf20Sopenharmony_ci PAUSE_TX = 1 << 1, 1338c2ecf20Sopenharmony_ci PAUSE_AUTONEG = 1 << 2 1348c2ecf20Sopenharmony_ci}; 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_cienum cc_fec { 1378c2ecf20Sopenharmony_ci FEC_AUTO = 1 << 0, /* IEEE 802.3 "automatic" */ 1388c2ecf20Sopenharmony_ci FEC_RS = 1 << 1, /* Reed-Solomon */ 1398c2ecf20Sopenharmony_ci FEC_BASER_RS = 1 << 2 /* BaseR/Reed-Solomon */ 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cienum { 1438c2ecf20Sopenharmony_ci CXGB4_ETHTOOL_FLASH_FW = 1, 1448c2ecf20Sopenharmony_ci CXGB4_ETHTOOL_FLASH_PHY = 2, 1458c2ecf20Sopenharmony_ci CXGB4_ETHTOOL_FLASH_BOOT = 3, 1468c2ecf20Sopenharmony_ci CXGB4_ETHTOOL_FLASH_BOOTCFG = 4 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cienum cxgb4_netdev_tls_ops { 1508c2ecf20Sopenharmony_ci CXGB4_TLSDEV_OPS = 1, 1518c2ecf20Sopenharmony_ci CXGB4_XFRMDEV_OPS 1528c2ecf20Sopenharmony_ci}; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_cistruct cxgb4_bootcfg_data { 1558c2ecf20Sopenharmony_ci __le16 signature; 1568c2ecf20Sopenharmony_ci __u8 reserved[2]; 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistruct cxgb4_pcir_data { 1608c2ecf20Sopenharmony_ci __le32 signature; /* Signature. The string "PCIR" */ 1618c2ecf20Sopenharmony_ci __le16 vendor_id; /* Vendor Identification */ 1628c2ecf20Sopenharmony_ci __le16 device_id; /* Device Identification */ 1638c2ecf20Sopenharmony_ci __u8 vital_product[2]; /* Pointer to Vital Product Data */ 1648c2ecf20Sopenharmony_ci __u8 length[2]; /* PCIR Data Structure Length */ 1658c2ecf20Sopenharmony_ci __u8 revision; /* PCIR Data Structure Revision */ 1668c2ecf20Sopenharmony_ci __u8 class_code[3]; /* Class Code */ 1678c2ecf20Sopenharmony_ci __u8 image_length[2]; /* Image Length. Multiple of 512B */ 1688c2ecf20Sopenharmony_ci __u8 code_revision[2]; /* Revision Level of Code/Data */ 1698c2ecf20Sopenharmony_ci __u8 code_type; 1708c2ecf20Sopenharmony_ci __u8 indicator; 1718c2ecf20Sopenharmony_ci __u8 reserved[2]; 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* BIOS boot headers */ 1758c2ecf20Sopenharmony_cistruct cxgb4_pci_exp_rom_header { 1768c2ecf20Sopenharmony_ci __le16 signature; /* ROM Signature. Should be 0xaa55 */ 1778c2ecf20Sopenharmony_ci __u8 reserved[22]; /* Reserved per processor Architecture data */ 1788c2ecf20Sopenharmony_ci __le16 pcir_offset; /* Offset to PCI Data Structure */ 1798c2ecf20Sopenharmony_ci}; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci/* Legacy PCI Expansion ROM Header */ 1828c2ecf20Sopenharmony_cistruct legacy_pci_rom_hdr { 1838c2ecf20Sopenharmony_ci __u8 signature[2]; /* ROM Signature. Should be 0xaa55 */ 1848c2ecf20Sopenharmony_ci __u8 size512; /* Current Image Size in units of 512 bytes */ 1858c2ecf20Sopenharmony_ci __u8 initentry_point[4]; 1868c2ecf20Sopenharmony_ci __u8 cksum; /* Checksum computed on the entire Image */ 1878c2ecf20Sopenharmony_ci __u8 reserved[16]; /* Reserved */ 1888c2ecf20Sopenharmony_ci __le16 pcir_offset; /* Offset to PCI Data Struture */ 1898c2ecf20Sopenharmony_ci}; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define CXGB4_HDR_CODE1 0x00 1928c2ecf20Sopenharmony_ci#define CXGB4_HDR_CODE2 0x03 1938c2ecf20Sopenharmony_ci#define CXGB4_HDR_INDI 0x80 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/* BOOT constants */ 1968c2ecf20Sopenharmony_cienum { 1978c2ecf20Sopenharmony_ci BOOT_CFG_SIG = 0x4243, 1988c2ecf20Sopenharmony_ci BOOT_SIZE_INC = 512, 1998c2ecf20Sopenharmony_ci BOOT_SIGNATURE = 0xaa55, 2008c2ecf20Sopenharmony_ci BOOT_MIN_SIZE = sizeof(struct cxgb4_pci_exp_rom_header), 2018c2ecf20Sopenharmony_ci BOOT_MAX_SIZE = 1024 * BOOT_SIZE_INC, 2028c2ecf20Sopenharmony_ci PCIR_SIGNATURE = 0x52494350 2038c2ecf20Sopenharmony_ci}; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_cistruct port_stats { 2068c2ecf20Sopenharmony_ci u64 tx_octets; /* total # of octets in good frames */ 2078c2ecf20Sopenharmony_ci u64 tx_frames; /* all good frames */ 2088c2ecf20Sopenharmony_ci u64 tx_bcast_frames; /* all broadcast frames */ 2098c2ecf20Sopenharmony_ci u64 tx_mcast_frames; /* all multicast frames */ 2108c2ecf20Sopenharmony_ci u64 tx_ucast_frames; /* all unicast frames */ 2118c2ecf20Sopenharmony_ci u64 tx_error_frames; /* all error frames */ 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci u64 tx_frames_64; /* # of Tx frames in a particular range */ 2148c2ecf20Sopenharmony_ci u64 tx_frames_65_127; 2158c2ecf20Sopenharmony_ci u64 tx_frames_128_255; 2168c2ecf20Sopenharmony_ci u64 tx_frames_256_511; 2178c2ecf20Sopenharmony_ci u64 tx_frames_512_1023; 2188c2ecf20Sopenharmony_ci u64 tx_frames_1024_1518; 2198c2ecf20Sopenharmony_ci u64 tx_frames_1519_max; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci u64 tx_drop; /* # of dropped Tx frames */ 2228c2ecf20Sopenharmony_ci u64 tx_pause; /* # of transmitted pause frames */ 2238c2ecf20Sopenharmony_ci u64 tx_ppp0; /* # of transmitted PPP prio 0 frames */ 2248c2ecf20Sopenharmony_ci u64 tx_ppp1; /* # of transmitted PPP prio 1 frames */ 2258c2ecf20Sopenharmony_ci u64 tx_ppp2; /* # of transmitted PPP prio 2 frames */ 2268c2ecf20Sopenharmony_ci u64 tx_ppp3; /* # of transmitted PPP prio 3 frames */ 2278c2ecf20Sopenharmony_ci u64 tx_ppp4; /* # of transmitted PPP prio 4 frames */ 2288c2ecf20Sopenharmony_ci u64 tx_ppp5; /* # of transmitted PPP prio 5 frames */ 2298c2ecf20Sopenharmony_ci u64 tx_ppp6; /* # of transmitted PPP prio 6 frames */ 2308c2ecf20Sopenharmony_ci u64 tx_ppp7; /* # of transmitted PPP prio 7 frames */ 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci u64 rx_octets; /* total # of octets in good frames */ 2338c2ecf20Sopenharmony_ci u64 rx_frames; /* all good frames */ 2348c2ecf20Sopenharmony_ci u64 rx_bcast_frames; /* all broadcast frames */ 2358c2ecf20Sopenharmony_ci u64 rx_mcast_frames; /* all multicast frames */ 2368c2ecf20Sopenharmony_ci u64 rx_ucast_frames; /* all unicast frames */ 2378c2ecf20Sopenharmony_ci u64 rx_too_long; /* # of frames exceeding MTU */ 2388c2ecf20Sopenharmony_ci u64 rx_jabber; /* # of jabber frames */ 2398c2ecf20Sopenharmony_ci u64 rx_fcs_err; /* # of received frames with bad FCS */ 2408c2ecf20Sopenharmony_ci u64 rx_len_err; /* # of received frames with length error */ 2418c2ecf20Sopenharmony_ci u64 rx_symbol_err; /* symbol errors */ 2428c2ecf20Sopenharmony_ci u64 rx_runt; /* # of short frames */ 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci u64 rx_frames_64; /* # of Rx frames in a particular range */ 2458c2ecf20Sopenharmony_ci u64 rx_frames_65_127; 2468c2ecf20Sopenharmony_ci u64 rx_frames_128_255; 2478c2ecf20Sopenharmony_ci u64 rx_frames_256_511; 2488c2ecf20Sopenharmony_ci u64 rx_frames_512_1023; 2498c2ecf20Sopenharmony_ci u64 rx_frames_1024_1518; 2508c2ecf20Sopenharmony_ci u64 rx_frames_1519_max; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci u64 rx_pause; /* # of received pause frames */ 2538c2ecf20Sopenharmony_ci u64 rx_ppp0; /* # of received PPP prio 0 frames */ 2548c2ecf20Sopenharmony_ci u64 rx_ppp1; /* # of received PPP prio 1 frames */ 2558c2ecf20Sopenharmony_ci u64 rx_ppp2; /* # of received PPP prio 2 frames */ 2568c2ecf20Sopenharmony_ci u64 rx_ppp3; /* # of received PPP prio 3 frames */ 2578c2ecf20Sopenharmony_ci u64 rx_ppp4; /* # of received PPP prio 4 frames */ 2588c2ecf20Sopenharmony_ci u64 rx_ppp5; /* # of received PPP prio 5 frames */ 2598c2ecf20Sopenharmony_ci u64 rx_ppp6; /* # of received PPP prio 6 frames */ 2608c2ecf20Sopenharmony_ci u64 rx_ppp7; /* # of received PPP prio 7 frames */ 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci u64 rx_ovflow0; /* drops due to buffer-group 0 overflows */ 2638c2ecf20Sopenharmony_ci u64 rx_ovflow1; /* drops due to buffer-group 1 overflows */ 2648c2ecf20Sopenharmony_ci u64 rx_ovflow2; /* drops due to buffer-group 2 overflows */ 2658c2ecf20Sopenharmony_ci u64 rx_ovflow3; /* drops due to buffer-group 3 overflows */ 2668c2ecf20Sopenharmony_ci u64 rx_trunc0; /* buffer-group 0 truncated packets */ 2678c2ecf20Sopenharmony_ci u64 rx_trunc1; /* buffer-group 1 truncated packets */ 2688c2ecf20Sopenharmony_ci u64 rx_trunc2; /* buffer-group 2 truncated packets */ 2698c2ecf20Sopenharmony_ci u64 rx_trunc3; /* buffer-group 3 truncated packets */ 2708c2ecf20Sopenharmony_ci}; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cistruct lb_port_stats { 2738c2ecf20Sopenharmony_ci u64 octets; 2748c2ecf20Sopenharmony_ci u64 frames; 2758c2ecf20Sopenharmony_ci u64 bcast_frames; 2768c2ecf20Sopenharmony_ci u64 mcast_frames; 2778c2ecf20Sopenharmony_ci u64 ucast_frames; 2788c2ecf20Sopenharmony_ci u64 error_frames; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci u64 frames_64; 2818c2ecf20Sopenharmony_ci u64 frames_65_127; 2828c2ecf20Sopenharmony_ci u64 frames_128_255; 2838c2ecf20Sopenharmony_ci u64 frames_256_511; 2848c2ecf20Sopenharmony_ci u64 frames_512_1023; 2858c2ecf20Sopenharmony_ci u64 frames_1024_1518; 2868c2ecf20Sopenharmony_ci u64 frames_1519_max; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci u64 drop; 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci u64 ovflow0; 2918c2ecf20Sopenharmony_ci u64 ovflow1; 2928c2ecf20Sopenharmony_ci u64 ovflow2; 2938c2ecf20Sopenharmony_ci u64 ovflow3; 2948c2ecf20Sopenharmony_ci u64 trunc0; 2958c2ecf20Sopenharmony_ci u64 trunc1; 2968c2ecf20Sopenharmony_ci u64 trunc2; 2978c2ecf20Sopenharmony_ci u64 trunc3; 2988c2ecf20Sopenharmony_ci}; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_cistruct tp_tcp_stats { 3018c2ecf20Sopenharmony_ci u32 tcp_out_rsts; 3028c2ecf20Sopenharmony_ci u64 tcp_in_segs; 3038c2ecf20Sopenharmony_ci u64 tcp_out_segs; 3048c2ecf20Sopenharmony_ci u64 tcp_retrans_segs; 3058c2ecf20Sopenharmony_ci}; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cistruct tp_usm_stats { 3088c2ecf20Sopenharmony_ci u32 frames; 3098c2ecf20Sopenharmony_ci u32 drops; 3108c2ecf20Sopenharmony_ci u64 octets; 3118c2ecf20Sopenharmony_ci}; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistruct tp_fcoe_stats { 3148c2ecf20Sopenharmony_ci u32 frames_ddp; 3158c2ecf20Sopenharmony_ci u32 frames_drop; 3168c2ecf20Sopenharmony_ci u64 octets_ddp; 3178c2ecf20Sopenharmony_ci}; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistruct tp_err_stats { 3208c2ecf20Sopenharmony_ci u32 mac_in_errs[4]; 3218c2ecf20Sopenharmony_ci u32 hdr_in_errs[4]; 3228c2ecf20Sopenharmony_ci u32 tcp_in_errs[4]; 3238c2ecf20Sopenharmony_ci u32 tnl_cong_drops[4]; 3248c2ecf20Sopenharmony_ci u32 ofld_chan_drops[4]; 3258c2ecf20Sopenharmony_ci u32 tnl_tx_drops[4]; 3268c2ecf20Sopenharmony_ci u32 ofld_vlan_drops[4]; 3278c2ecf20Sopenharmony_ci u32 tcp6_in_errs[4]; 3288c2ecf20Sopenharmony_ci u32 ofld_no_neigh; 3298c2ecf20Sopenharmony_ci u32 ofld_cong_defer; 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cistruct tp_cpl_stats { 3338c2ecf20Sopenharmony_ci u32 req[4]; 3348c2ecf20Sopenharmony_ci u32 rsp[4]; 3358c2ecf20Sopenharmony_ci}; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_cistruct tp_rdma_stats { 3388c2ecf20Sopenharmony_ci u32 rqe_dfr_pkt; 3398c2ecf20Sopenharmony_ci u32 rqe_dfr_mod; 3408c2ecf20Sopenharmony_ci}; 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_cistruct sge_params { 3438c2ecf20Sopenharmony_ci u32 hps; /* host page size for our PF/VF */ 3448c2ecf20Sopenharmony_ci u32 eq_qpp; /* egress queues/page for our PF/VF */ 3458c2ecf20Sopenharmony_ci u32 iq_qpp; /* egress queues/page for our PF/VF */ 3468c2ecf20Sopenharmony_ci}; 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_cistruct tp_params { 3498c2ecf20Sopenharmony_ci unsigned int tre; /* log2 of core clocks per TP tick */ 3508c2ecf20Sopenharmony_ci unsigned int la_mask; /* what events are recorded by TP LA */ 3518c2ecf20Sopenharmony_ci unsigned short tx_modq_map; /* TX modulation scheduler queue to */ 3528c2ecf20Sopenharmony_ci /* channel map */ 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci uint32_t dack_re; /* DACK timer resolution */ 3558c2ecf20Sopenharmony_ci unsigned short tx_modq[NCHAN]; /* channel to modulation queue map */ 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci u32 vlan_pri_map; /* cached TP_VLAN_PRI_MAP */ 3588c2ecf20Sopenharmony_ci u32 filter_mask; 3598c2ecf20Sopenharmony_ci u32 ingress_config; /* cached TP_INGRESS_CONFIG */ 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci /* cached TP_OUT_CONFIG compressed error vector 3628c2ecf20Sopenharmony_ci * and passing outer header info for encapsulated packets. 3638c2ecf20Sopenharmony_ci */ 3648c2ecf20Sopenharmony_ci int rx_pkt_encap; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci /* TP_VLAN_PRI_MAP Compressed Filter Tuple field offsets. This is a 3678c2ecf20Sopenharmony_ci * subset of the set of fields which may be present in the Compressed 3688c2ecf20Sopenharmony_ci * Filter Tuple portion of filters and TCP TCB connections. The 3698c2ecf20Sopenharmony_ci * fields which are present are controlled by the TP_VLAN_PRI_MAP. 3708c2ecf20Sopenharmony_ci * Since a variable number of fields may or may not be present, their 3718c2ecf20Sopenharmony_ci * shifted field positions within the Compressed Filter Tuple may 3728c2ecf20Sopenharmony_ci * vary, or not even be present if the field isn't selected in 3738c2ecf20Sopenharmony_ci * TP_VLAN_PRI_MAP. Since some of these fields are needed in various 3748c2ecf20Sopenharmony_ci * places we store their offsets here, or a -1 if the field isn't 3758c2ecf20Sopenharmony_ci * present. 3768c2ecf20Sopenharmony_ci */ 3778c2ecf20Sopenharmony_ci int fcoe_shift; 3788c2ecf20Sopenharmony_ci int port_shift; 3798c2ecf20Sopenharmony_ci int vnic_shift; 3808c2ecf20Sopenharmony_ci int vlan_shift; 3818c2ecf20Sopenharmony_ci int tos_shift; 3828c2ecf20Sopenharmony_ci int protocol_shift; 3838c2ecf20Sopenharmony_ci int ethertype_shift; 3848c2ecf20Sopenharmony_ci int macmatch_shift; 3858c2ecf20Sopenharmony_ci int matchtype_shift; 3868c2ecf20Sopenharmony_ci int frag_shift; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci u64 hash_filter_mask; 3898c2ecf20Sopenharmony_ci}; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_cistruct vpd_params { 3928c2ecf20Sopenharmony_ci unsigned int cclk; 3938c2ecf20Sopenharmony_ci u8 ec[EC_LEN + 1]; 3948c2ecf20Sopenharmony_ci u8 sn[SERNUM_LEN + 1]; 3958c2ecf20Sopenharmony_ci u8 id[ID_LEN + 1]; 3968c2ecf20Sopenharmony_ci u8 pn[PN_LEN + 1]; 3978c2ecf20Sopenharmony_ci u8 na[MACADDR_LEN + 1]; 3988c2ecf20Sopenharmony_ci}; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci/* Maximum resources provisioned for a PCI PF. 4018c2ecf20Sopenharmony_ci */ 4028c2ecf20Sopenharmony_cistruct pf_resources { 4038c2ecf20Sopenharmony_ci unsigned int nvi; /* N virtual interfaces */ 4048c2ecf20Sopenharmony_ci unsigned int neq; /* N egress Qs */ 4058c2ecf20Sopenharmony_ci unsigned int nethctrl; /* N egress ETH or CTRL Qs */ 4068c2ecf20Sopenharmony_ci unsigned int niqflint; /* N ingress Qs/w free list(s) & intr */ 4078c2ecf20Sopenharmony_ci unsigned int niq; /* N ingress Qs */ 4088c2ecf20Sopenharmony_ci unsigned int tc; /* PCI-E traffic class */ 4098c2ecf20Sopenharmony_ci unsigned int pmask; /* port access rights mask */ 4108c2ecf20Sopenharmony_ci unsigned int nexactf; /* N exact MPS filters */ 4118c2ecf20Sopenharmony_ci unsigned int r_caps; /* read capabilities */ 4128c2ecf20Sopenharmony_ci unsigned int wx_caps; /* write/execute capabilities */ 4138c2ecf20Sopenharmony_ci}; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_cistruct pci_params { 4168c2ecf20Sopenharmony_ci unsigned int vpd_cap_addr; 4178c2ecf20Sopenharmony_ci unsigned char speed; 4188c2ecf20Sopenharmony_ci unsigned char width; 4198c2ecf20Sopenharmony_ci}; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_cistruct devlog_params { 4228c2ecf20Sopenharmony_ci u32 memtype; /* which memory (EDC0, EDC1, MC) */ 4238c2ecf20Sopenharmony_ci u32 start; /* start of log in firmware memory */ 4248c2ecf20Sopenharmony_ci u32 size; /* size of log */ 4258c2ecf20Sopenharmony_ci}; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci/* Stores chip specific parameters */ 4288c2ecf20Sopenharmony_cistruct arch_specific_params { 4298c2ecf20Sopenharmony_ci u8 nchan; 4308c2ecf20Sopenharmony_ci u8 pm_stats_cnt; 4318c2ecf20Sopenharmony_ci u8 cng_ch_bits_log; /* congestion channel map bits width */ 4328c2ecf20Sopenharmony_ci u16 mps_rplc_size; 4338c2ecf20Sopenharmony_ci u16 vfcount; 4348c2ecf20Sopenharmony_ci u32 sge_fl_db; 4358c2ecf20Sopenharmony_ci u16 mps_tcam_size; 4368c2ecf20Sopenharmony_ci}; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_cistruct adapter_params { 4398c2ecf20Sopenharmony_ci struct sge_params sge; 4408c2ecf20Sopenharmony_ci struct tp_params tp; 4418c2ecf20Sopenharmony_ci struct vpd_params vpd; 4428c2ecf20Sopenharmony_ci struct pf_resources pfres; 4438c2ecf20Sopenharmony_ci struct pci_params pci; 4448c2ecf20Sopenharmony_ci struct devlog_params devlog; 4458c2ecf20Sopenharmony_ci enum pcie_memwin drv_memwin; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci unsigned int cim_la_size; 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci unsigned int sf_size; /* serial flash size in bytes */ 4508c2ecf20Sopenharmony_ci unsigned int sf_nsec; /* # of flash sectors */ 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci unsigned int fw_vers; /* firmware version */ 4538c2ecf20Sopenharmony_ci unsigned int bs_vers; /* bootstrap version */ 4548c2ecf20Sopenharmony_ci unsigned int tp_vers; /* TP microcode version */ 4558c2ecf20Sopenharmony_ci unsigned int er_vers; /* expansion ROM version */ 4568c2ecf20Sopenharmony_ci unsigned int scfg_vers; /* Serial Configuration version */ 4578c2ecf20Sopenharmony_ci unsigned int vpd_vers; /* VPD Version */ 4588c2ecf20Sopenharmony_ci u8 api_vers[7]; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci unsigned short mtus[NMTUS]; 4618c2ecf20Sopenharmony_ci unsigned short a_wnd[NCCTRL_WIN]; 4628c2ecf20Sopenharmony_ci unsigned short b_wnd[NCCTRL_WIN]; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci unsigned char nports; /* # of ethernet ports */ 4658c2ecf20Sopenharmony_ci unsigned char portvec; 4668c2ecf20Sopenharmony_ci enum chip_type chip; /* chip code */ 4678c2ecf20Sopenharmony_ci struct arch_specific_params arch; /* chip specific params */ 4688c2ecf20Sopenharmony_ci unsigned char offload; 4698c2ecf20Sopenharmony_ci unsigned char crypto; /* HW capability for crypto */ 4708c2ecf20Sopenharmony_ci unsigned char ethofld; /* QoS support */ 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci unsigned char bypass; 4738c2ecf20Sopenharmony_ci unsigned char hash_filter; 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci unsigned int ofldq_wr_cred; 4768c2ecf20Sopenharmony_ci bool ulptx_memwrite_dsgl; /* use of T5 DSGL allowed */ 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci unsigned int nsched_cls; /* number of traffic classes */ 4798c2ecf20Sopenharmony_ci unsigned int max_ordird_qp; /* Max read depth per RDMA QP */ 4808c2ecf20Sopenharmony_ci unsigned int max_ird_adapter; /* Max read depth per adapter */ 4818c2ecf20Sopenharmony_ci bool fr_nsmr_tpte_wr_support; /* FW support for FR_NSMR_TPTE_WR */ 4828c2ecf20Sopenharmony_ci u8 fw_caps_support; /* 32-bit Port Capabilities */ 4838c2ecf20Sopenharmony_ci bool filter2_wr_support; /* FW support for FILTER2_WR */ 4848c2ecf20Sopenharmony_ci unsigned int viid_smt_extn_support:1; /* FW returns vin and smt index */ 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci /* MPS Buffer Group Map[per Port]. Bit i is set if buffer group i is 4878c2ecf20Sopenharmony_ci * used by the Port 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_ci u8 mps_bg_map[MAX_NPORTS]; /* MPS Buffer Group Map */ 4908c2ecf20Sopenharmony_ci bool write_w_imm_support; /* FW supports WRITE_WITH_IMMEDIATE */ 4918c2ecf20Sopenharmony_ci bool write_cmpl_support; /* FW supports WRITE_CMPL */ 4928c2ecf20Sopenharmony_ci}; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci/* State needed to monitor the forward progress of SGE Ingress DMA activities 4958c2ecf20Sopenharmony_ci * and possible hangs. 4968c2ecf20Sopenharmony_ci */ 4978c2ecf20Sopenharmony_cistruct sge_idma_monitor_state { 4988c2ecf20Sopenharmony_ci unsigned int idma_1s_thresh; /* 1s threshold in Core Clock ticks */ 4998c2ecf20Sopenharmony_ci unsigned int idma_stalled[2]; /* synthesized stalled timers in HZ */ 5008c2ecf20Sopenharmony_ci unsigned int idma_state[2]; /* IDMA Hang detect state */ 5018c2ecf20Sopenharmony_ci unsigned int idma_qid[2]; /* IDMA Hung Ingress Queue ID */ 5028c2ecf20Sopenharmony_ci unsigned int idma_warn[2]; /* time to warning in HZ */ 5038c2ecf20Sopenharmony_ci}; 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci/* Firmware Mailbox Command/Reply log. All values are in Host-Endian format. 5068c2ecf20Sopenharmony_ci * The access and execute times are signed in order to accommodate negative 5078c2ecf20Sopenharmony_ci * error returns. 5088c2ecf20Sopenharmony_ci */ 5098c2ecf20Sopenharmony_cistruct mbox_cmd { 5108c2ecf20Sopenharmony_ci u64 cmd[MBOX_LEN / 8]; /* a Firmware Mailbox Command/Reply */ 5118c2ecf20Sopenharmony_ci u64 timestamp; /* OS-dependent timestamp */ 5128c2ecf20Sopenharmony_ci u32 seqno; /* sequence number */ 5138c2ecf20Sopenharmony_ci s16 access; /* time (ms) to access mailbox */ 5148c2ecf20Sopenharmony_ci s16 execute; /* time (ms) to execute */ 5158c2ecf20Sopenharmony_ci}; 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_cistruct mbox_cmd_log { 5188c2ecf20Sopenharmony_ci unsigned int size; /* number of entries in the log */ 5198c2ecf20Sopenharmony_ci unsigned int cursor; /* next position in the log to write */ 5208c2ecf20Sopenharmony_ci u32 seqno; /* next sequence number */ 5218c2ecf20Sopenharmony_ci /* variable length mailbox command log starts here */ 5228c2ecf20Sopenharmony_ci}; 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci/* Given a pointer to a Firmware Mailbox Command Log and a log entry index, 5258c2ecf20Sopenharmony_ci * return a pointer to the specified entry. 5268c2ecf20Sopenharmony_ci */ 5278c2ecf20Sopenharmony_cistatic inline struct mbox_cmd *mbox_cmd_log_entry(struct mbox_cmd_log *log, 5288c2ecf20Sopenharmony_ci unsigned int entry_idx) 5298c2ecf20Sopenharmony_ci{ 5308c2ecf20Sopenharmony_ci return &((struct mbox_cmd *)&(log)[1])[entry_idx]; 5318c2ecf20Sopenharmony_ci} 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci#define FW_VERSION(chip) ( \ 5348c2ecf20Sopenharmony_ci FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \ 5358c2ecf20Sopenharmony_ci FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \ 5368c2ecf20Sopenharmony_ci FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \ 5378c2ecf20Sopenharmony_ci FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD)) 5388c2ecf20Sopenharmony_ci#define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf) 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_cistruct cxgb4_ethtool_lb_test { 5418c2ecf20Sopenharmony_ci struct completion completion; 5428c2ecf20Sopenharmony_ci int result; 5438c2ecf20Sopenharmony_ci int loopback; 5448c2ecf20Sopenharmony_ci}; 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_cistruct fw_info { 5478c2ecf20Sopenharmony_ci u8 chip; 5488c2ecf20Sopenharmony_ci char *fs_name; 5498c2ecf20Sopenharmony_ci char *fw_mod_name; 5508c2ecf20Sopenharmony_ci struct fw_hdr fw_hdr; 5518c2ecf20Sopenharmony_ci}; 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_cistruct trace_params { 5548c2ecf20Sopenharmony_ci u32 data[TRACE_LEN / 4]; 5558c2ecf20Sopenharmony_ci u32 mask[TRACE_LEN / 4]; 5568c2ecf20Sopenharmony_ci unsigned short snap_len; 5578c2ecf20Sopenharmony_ci unsigned short min_len; 5588c2ecf20Sopenharmony_ci unsigned char skip_ofst; 5598c2ecf20Sopenharmony_ci unsigned char skip_len; 5608c2ecf20Sopenharmony_ci unsigned char invert; 5618c2ecf20Sopenharmony_ci unsigned char port; 5628c2ecf20Sopenharmony_ci}; 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_cistruct cxgb4_fw_data { 5658c2ecf20Sopenharmony_ci __be32 signature; 5668c2ecf20Sopenharmony_ci __u8 reserved[4]; 5678c2ecf20Sopenharmony_ci}; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci/* Firmware Port Capabilities types. */ 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_citypedef u16 fw_port_cap16_t; /* 16-bit Port Capabilities integral value */ 5728c2ecf20Sopenharmony_citypedef u32 fw_port_cap32_t; /* 32-bit Port Capabilities integral value */ 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_cienum fw_caps { 5758c2ecf20Sopenharmony_ci FW_CAPS_UNKNOWN = 0, /* 0'ed out initial state */ 5768c2ecf20Sopenharmony_ci FW_CAPS16 = 1, /* old Firmware: 16-bit Port Capabilities */ 5778c2ecf20Sopenharmony_ci FW_CAPS32 = 2, /* new Firmware: 32-bit Port Capabilities */ 5788c2ecf20Sopenharmony_ci}; 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_cistruct link_config { 5818c2ecf20Sopenharmony_ci fw_port_cap32_t pcaps; /* link capabilities */ 5828c2ecf20Sopenharmony_ci fw_port_cap32_t def_acaps; /* default advertised capabilities */ 5838c2ecf20Sopenharmony_ci fw_port_cap32_t acaps; /* advertised capabilities */ 5848c2ecf20Sopenharmony_ci fw_port_cap32_t lpacaps; /* peer advertised capabilities */ 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci fw_port_cap32_t speed_caps; /* speed(s) user has requested */ 5878c2ecf20Sopenharmony_ci unsigned int speed; /* actual link speed (Mb/s) */ 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ci enum cc_pause requested_fc; /* flow control user has requested */ 5908c2ecf20Sopenharmony_ci enum cc_pause fc; /* actual link flow control */ 5918c2ecf20Sopenharmony_ci enum cc_pause advertised_fc; /* actual advertised flow control */ 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci enum cc_fec requested_fec; /* Forward Error Correction: */ 5948c2ecf20Sopenharmony_ci enum cc_fec fec; /* requested and actual in use */ 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci unsigned char autoneg; /* autonegotiating? */ 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci unsigned char link_ok; /* link up? */ 5998c2ecf20Sopenharmony_ci unsigned char link_down_rc; /* link down reason */ 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci bool new_module; /* ->OS Transceiver Module inserted */ 6028c2ecf20Sopenharmony_ci bool redo_l1cfg; /* ->CC redo current "sticky" L1 CFG */ 6038c2ecf20Sopenharmony_ci}; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16) 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_cienum { 6088c2ecf20Sopenharmony_ci MAX_ETH_QSETS = 32, /* # of Ethernet Tx/Rx queue sets */ 6098c2ecf20Sopenharmony_ci MAX_OFLD_QSETS = 16, /* # of offload Tx, iscsi Rx queue sets */ 6108c2ecf20Sopenharmony_ci MAX_CTRL_QUEUES = NCHAN, /* # of control Tx queues */ 6118c2ecf20Sopenharmony_ci}; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_cienum { 6148c2ecf20Sopenharmony_ci MAX_TXQ_ENTRIES = 16384, 6158c2ecf20Sopenharmony_ci MAX_CTRL_TXQ_ENTRIES = 1024, 6168c2ecf20Sopenharmony_ci MAX_RSPQ_ENTRIES = 16384, 6178c2ecf20Sopenharmony_ci MAX_RX_BUFFERS = 16384, 6188c2ecf20Sopenharmony_ci MIN_TXQ_ENTRIES = 32, 6198c2ecf20Sopenharmony_ci MIN_CTRL_TXQ_ENTRIES = 32, 6208c2ecf20Sopenharmony_ci MIN_RSPQ_ENTRIES = 128, 6218c2ecf20Sopenharmony_ci MIN_FL_ENTRIES = 16 6228c2ecf20Sopenharmony_ci}; 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_cienum { 6258c2ecf20Sopenharmony_ci MAX_TXQ_DESC_SIZE = 64, 6268c2ecf20Sopenharmony_ci MAX_RXQ_DESC_SIZE = 128, 6278c2ecf20Sopenharmony_ci MAX_FL_DESC_SIZE = 8, 6288c2ecf20Sopenharmony_ci MAX_CTRL_TXQ_DESC_SIZE = 64, 6298c2ecf20Sopenharmony_ci}; 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_cienum { 6328c2ecf20Sopenharmony_ci INGQ_EXTRAS = 2, /* firmware event queue and */ 6338c2ecf20Sopenharmony_ci /* forwarded interrupts */ 6348c2ecf20Sopenharmony_ci MAX_INGQ = MAX_ETH_QSETS + INGQ_EXTRAS, 6358c2ecf20Sopenharmony_ci}; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cienum { 6388c2ecf20Sopenharmony_ci PRIV_FLAG_PORT_TX_VM_BIT, 6398c2ecf20Sopenharmony_ci}; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci#define PRIV_FLAG_PORT_TX_VM BIT(PRIV_FLAG_PORT_TX_VM_BIT) 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci#define PRIV_FLAGS_ADAP 0 6448c2ecf20Sopenharmony_ci#define PRIV_FLAGS_PORT PRIV_FLAG_PORT_TX_VM 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_cistruct adapter; 6478c2ecf20Sopenharmony_cistruct sge_rspq; 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci#include "cxgb4_dcb.h" 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_FCOE 6528c2ecf20Sopenharmony_ci#include "cxgb4_fcoe.h" 6538c2ecf20Sopenharmony_ci#endif /* CONFIG_CHELSIO_T4_FCOE */ 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_cistruct port_info { 6568c2ecf20Sopenharmony_ci struct adapter *adapter; 6578c2ecf20Sopenharmony_ci u16 viid; 6588c2ecf20Sopenharmony_ci int xact_addr_filt; /* index of exact MAC address filter */ 6598c2ecf20Sopenharmony_ci u16 rss_size; /* size of VI's RSS table slice */ 6608c2ecf20Sopenharmony_ci s8 mdio_addr; 6618c2ecf20Sopenharmony_ci enum fw_port_type port_type; 6628c2ecf20Sopenharmony_ci u8 mod_type; 6638c2ecf20Sopenharmony_ci u8 port_id; 6648c2ecf20Sopenharmony_ci u8 tx_chan; 6658c2ecf20Sopenharmony_ci u8 lport; /* associated offload logical port */ 6668c2ecf20Sopenharmony_ci u8 nqsets; /* # of qsets */ 6678c2ecf20Sopenharmony_ci u8 first_qset; /* index of first qset */ 6688c2ecf20Sopenharmony_ci u8 rss_mode; 6698c2ecf20Sopenharmony_ci struct link_config link_cfg; 6708c2ecf20Sopenharmony_ci u16 *rss; 6718c2ecf20Sopenharmony_ci struct port_stats stats_base; 6728c2ecf20Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_DCB 6738c2ecf20Sopenharmony_ci struct port_dcb_info dcb; /* Data Center Bridging support */ 6748c2ecf20Sopenharmony_ci#endif 6758c2ecf20Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_FCOE 6768c2ecf20Sopenharmony_ci struct cxgb_fcoe fcoe; 6778c2ecf20Sopenharmony_ci#endif /* CONFIG_CHELSIO_T4_FCOE */ 6788c2ecf20Sopenharmony_ci bool rxtstamp; /* Enable TS */ 6798c2ecf20Sopenharmony_ci struct hwtstamp_config tstamp_config; 6808c2ecf20Sopenharmony_ci bool ptp_enable; 6818c2ecf20Sopenharmony_ci struct sched_table *sched_tbl; 6828c2ecf20Sopenharmony_ci u32 eth_flags; 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci /* viid and smt fields either returned by fw 6858c2ecf20Sopenharmony_ci * or decoded by parsing viid by driver. 6868c2ecf20Sopenharmony_ci */ 6878c2ecf20Sopenharmony_ci u8 vin; 6888c2ecf20Sopenharmony_ci u8 vivld; 6898c2ecf20Sopenharmony_ci u8 smt_idx; 6908c2ecf20Sopenharmony_ci u8 rx_cchan; 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ci bool tc_block_shared; 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci /* Mirror VI information */ 6958c2ecf20Sopenharmony_ci u16 viid_mirror; 6968c2ecf20Sopenharmony_ci u16 nmirrorqsets; 6978c2ecf20Sopenharmony_ci u32 vi_mirror_count; 6988c2ecf20Sopenharmony_ci struct mutex vi_mirror_mutex; /* Sync access to Mirror VI info */ 6998c2ecf20Sopenharmony_ci struct cxgb4_ethtool_lb_test ethtool_lb; 7008c2ecf20Sopenharmony_ci}; 7018c2ecf20Sopenharmony_ci 7028c2ecf20Sopenharmony_cistruct dentry; 7038c2ecf20Sopenharmony_cistruct work_struct; 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_cienum { /* adapter flags */ 7068c2ecf20Sopenharmony_ci CXGB4_FULL_INIT_DONE = (1 << 0), 7078c2ecf20Sopenharmony_ci CXGB4_DEV_ENABLED = (1 << 1), 7088c2ecf20Sopenharmony_ci CXGB4_USING_MSI = (1 << 2), 7098c2ecf20Sopenharmony_ci CXGB4_USING_MSIX = (1 << 3), 7108c2ecf20Sopenharmony_ci CXGB4_FW_OK = (1 << 4), 7118c2ecf20Sopenharmony_ci CXGB4_RSS_TNLALLLOOKUP = (1 << 5), 7128c2ecf20Sopenharmony_ci CXGB4_USING_SOFT_PARAMS = (1 << 6), 7138c2ecf20Sopenharmony_ci CXGB4_MASTER_PF = (1 << 7), 7148c2ecf20Sopenharmony_ci CXGB4_FW_OFLD_CONN = (1 << 9), 7158c2ecf20Sopenharmony_ci CXGB4_ROOT_NO_RELAXED_ORDERING = (1 << 10), 7168c2ecf20Sopenharmony_ci CXGB4_SHUTTING_DOWN = (1 << 11), 7178c2ecf20Sopenharmony_ci CXGB4_SGE_DBQ_TIMER = (1 << 12), 7188c2ecf20Sopenharmony_ci}; 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_cienum { 7218c2ecf20Sopenharmony_ci ULP_CRYPTO_LOOKASIDE = 1 << 0, 7228c2ecf20Sopenharmony_ci ULP_CRYPTO_IPSEC_INLINE = 1 << 1, 7238c2ecf20Sopenharmony_ci ULP_CRYPTO_KTLS_INLINE = 1 << 3, 7248c2ecf20Sopenharmony_ci}; 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_DESC_NUM 1024 7278c2ecf20Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_DESC_SIZE 64 7288c2ecf20Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_INTR_USEC 5 7298c2ecf20Sopenharmony_ci#define CXGB4_MIRROR_RXQ_DEFAULT_PKT_CNT 8 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci#define CXGB4_MIRROR_FLQ_DEFAULT_DESC_NUM 72 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_cistruct rx_sw_desc; 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_cistruct sge_fl { /* SGE free-buffer queue state */ 7368c2ecf20Sopenharmony_ci unsigned int avail; /* # of available Rx buffers */ 7378c2ecf20Sopenharmony_ci unsigned int pend_cred; /* new buffers since last FL DB ring */ 7388c2ecf20Sopenharmony_ci unsigned int cidx; /* consumer index */ 7398c2ecf20Sopenharmony_ci unsigned int pidx; /* producer index */ 7408c2ecf20Sopenharmony_ci unsigned long alloc_failed; /* # of times buffer allocation failed */ 7418c2ecf20Sopenharmony_ci unsigned long large_alloc_failed; 7428c2ecf20Sopenharmony_ci unsigned long mapping_err; /* # of RX Buffer DMA Mapping failures */ 7438c2ecf20Sopenharmony_ci unsigned long low; /* # of times momentarily starving */ 7448c2ecf20Sopenharmony_ci unsigned long starving; 7458c2ecf20Sopenharmony_ci /* RO fields */ 7468c2ecf20Sopenharmony_ci unsigned int cntxt_id; /* SGE context id for the free list */ 7478c2ecf20Sopenharmony_ci unsigned int size; /* capacity of free list */ 7488c2ecf20Sopenharmony_ci struct rx_sw_desc *sdesc; /* address of SW Rx descriptor ring */ 7498c2ecf20Sopenharmony_ci __be64 *desc; /* address of HW Rx descriptor ring */ 7508c2ecf20Sopenharmony_ci dma_addr_t addr; /* bus address of HW ring start */ 7518c2ecf20Sopenharmony_ci void __iomem *bar2_addr; /* address of BAR2 Queue registers */ 7528c2ecf20Sopenharmony_ci unsigned int bar2_qid; /* Queue ID for BAR2 Queue registers */ 7538c2ecf20Sopenharmony_ci}; 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci/* A packet gather list */ 7568c2ecf20Sopenharmony_cistruct pkt_gl { 7578c2ecf20Sopenharmony_ci u64 sgetstamp; /* SGE Time Stamp for Ingress Packet */ 7588c2ecf20Sopenharmony_ci struct page_frag frags[MAX_SKB_FRAGS]; 7598c2ecf20Sopenharmony_ci void *va; /* virtual address of first byte */ 7608c2ecf20Sopenharmony_ci unsigned int nfrags; /* # of fragments */ 7618c2ecf20Sopenharmony_ci unsigned int tot_len; /* total length of fragments */ 7628c2ecf20Sopenharmony_ci}; 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_citypedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp, 7658c2ecf20Sopenharmony_ci const struct pkt_gl *gl); 7668c2ecf20Sopenharmony_citypedef void (*rspq_flush_handler_t)(struct sge_rspq *q); 7678c2ecf20Sopenharmony_ci/* LRO related declarations for ULD */ 7688c2ecf20Sopenharmony_cistruct t4_lro_mgr { 7698c2ecf20Sopenharmony_ci#define MAX_LRO_SESSIONS 64 7708c2ecf20Sopenharmony_ci u8 lro_session_cnt; /* # of sessions to aggregate */ 7718c2ecf20Sopenharmony_ci unsigned long lro_pkts; /* # of LRO super packets */ 7728c2ecf20Sopenharmony_ci unsigned long lro_merged; /* # of wire packets merged by LRO */ 7738c2ecf20Sopenharmony_ci struct sk_buff_head lroq; /* list of aggregated sessions */ 7748c2ecf20Sopenharmony_ci}; 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_cistruct sge_rspq { /* state for an SGE response queue */ 7778c2ecf20Sopenharmony_ci struct napi_struct napi; 7788c2ecf20Sopenharmony_ci const __be64 *cur_desc; /* current descriptor in queue */ 7798c2ecf20Sopenharmony_ci unsigned int cidx; /* consumer index */ 7808c2ecf20Sopenharmony_ci u8 gen; /* current generation bit */ 7818c2ecf20Sopenharmony_ci u8 intr_params; /* interrupt holdoff parameters */ 7828c2ecf20Sopenharmony_ci u8 next_intr_params; /* holdoff params for next interrupt */ 7838c2ecf20Sopenharmony_ci u8 adaptive_rx; 7848c2ecf20Sopenharmony_ci u8 pktcnt_idx; /* interrupt packet threshold */ 7858c2ecf20Sopenharmony_ci u8 uld; /* ULD handling this queue */ 7868c2ecf20Sopenharmony_ci u8 idx; /* queue index within its group */ 7878c2ecf20Sopenharmony_ci int offset; /* offset into current Rx buffer */ 7888c2ecf20Sopenharmony_ci u16 cntxt_id; /* SGE context id for the response q */ 7898c2ecf20Sopenharmony_ci u16 abs_id; /* absolute SGE id for the response q */ 7908c2ecf20Sopenharmony_ci __be64 *desc; /* address of HW response ring */ 7918c2ecf20Sopenharmony_ci dma_addr_t phys_addr; /* physical address of the ring */ 7928c2ecf20Sopenharmony_ci void __iomem *bar2_addr; /* address of BAR2 Queue registers */ 7938c2ecf20Sopenharmony_ci unsigned int bar2_qid; /* Queue ID for BAR2 Queue registers */ 7948c2ecf20Sopenharmony_ci unsigned int iqe_len; /* entry size */ 7958c2ecf20Sopenharmony_ci unsigned int size; /* capacity of response queue */ 7968c2ecf20Sopenharmony_ci struct adapter *adap; 7978c2ecf20Sopenharmony_ci struct net_device *netdev; /* associated net device */ 7988c2ecf20Sopenharmony_ci rspq_handler_t handler; 7998c2ecf20Sopenharmony_ci rspq_flush_handler_t flush_handler; 8008c2ecf20Sopenharmony_ci struct t4_lro_mgr lro_mgr; 8018c2ecf20Sopenharmony_ci}; 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_cistruct sge_eth_stats { /* Ethernet queue statistics */ 8048c2ecf20Sopenharmony_ci unsigned long pkts; /* # of ethernet packets */ 8058c2ecf20Sopenharmony_ci unsigned long lro_pkts; /* # of LRO super packets */ 8068c2ecf20Sopenharmony_ci unsigned long lro_merged; /* # of wire packets merged by LRO */ 8078c2ecf20Sopenharmony_ci unsigned long rx_cso; /* # of Rx checksum offloads */ 8088c2ecf20Sopenharmony_ci unsigned long vlan_ex; /* # of Rx VLAN extractions */ 8098c2ecf20Sopenharmony_ci unsigned long rx_drops; /* # of packets dropped due to no mem */ 8108c2ecf20Sopenharmony_ci unsigned long bad_rx_pkts; /* # of packets with err_vec!=0 */ 8118c2ecf20Sopenharmony_ci}; 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_cistruct sge_eth_rxq { /* SW Ethernet Rx queue */ 8148c2ecf20Sopenharmony_ci struct sge_rspq rspq; 8158c2ecf20Sopenharmony_ci struct sge_fl fl; 8168c2ecf20Sopenharmony_ci struct sge_eth_stats stats; 8178c2ecf20Sopenharmony_ci struct msix_info *msix; 8188c2ecf20Sopenharmony_ci} ____cacheline_aligned_in_smp; 8198c2ecf20Sopenharmony_ci 8208c2ecf20Sopenharmony_cistruct sge_ofld_stats { /* offload queue statistics */ 8218c2ecf20Sopenharmony_ci unsigned long pkts; /* # of packets */ 8228c2ecf20Sopenharmony_ci unsigned long imm; /* # of immediate-data packets */ 8238c2ecf20Sopenharmony_ci unsigned long an; /* # of asynchronous notifications */ 8248c2ecf20Sopenharmony_ci unsigned long nomem; /* # of responses deferred due to no mem */ 8258c2ecf20Sopenharmony_ci}; 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_cistruct sge_ofld_rxq { /* SW offload Rx queue */ 8288c2ecf20Sopenharmony_ci struct sge_rspq rspq; 8298c2ecf20Sopenharmony_ci struct sge_fl fl; 8308c2ecf20Sopenharmony_ci struct sge_ofld_stats stats; 8318c2ecf20Sopenharmony_ci struct msix_info *msix; 8328c2ecf20Sopenharmony_ci} ____cacheline_aligned_in_smp; 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_cistruct tx_desc { 8358c2ecf20Sopenharmony_ci __be64 flit[8]; 8368c2ecf20Sopenharmony_ci}; 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_cistruct ulptx_sgl; 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_cistruct tx_sw_desc { 8418c2ecf20Sopenharmony_ci struct sk_buff *skb; /* SKB to free after getting completion */ 8428c2ecf20Sopenharmony_ci dma_addr_t addr[MAX_SKB_FRAGS + 1]; /* DMA mapped addresses */ 8438c2ecf20Sopenharmony_ci}; 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_cistruct sge_txq { 8468c2ecf20Sopenharmony_ci unsigned int in_use; /* # of in-use Tx descriptors */ 8478c2ecf20Sopenharmony_ci unsigned int q_type; /* Q type Eth/Ctrl/Ofld */ 8488c2ecf20Sopenharmony_ci unsigned int size; /* # of descriptors */ 8498c2ecf20Sopenharmony_ci unsigned int cidx; /* SW consumer index */ 8508c2ecf20Sopenharmony_ci unsigned int pidx; /* producer index */ 8518c2ecf20Sopenharmony_ci unsigned long stops; /* # of times q has been stopped */ 8528c2ecf20Sopenharmony_ci unsigned long restarts; /* # of queue restarts */ 8538c2ecf20Sopenharmony_ci unsigned int cntxt_id; /* SGE context id for the Tx q */ 8548c2ecf20Sopenharmony_ci struct tx_desc *desc; /* address of HW Tx descriptor ring */ 8558c2ecf20Sopenharmony_ci struct tx_sw_desc *sdesc; /* address of SW Tx descriptor ring */ 8568c2ecf20Sopenharmony_ci struct sge_qstat *stat; /* queue status entry */ 8578c2ecf20Sopenharmony_ci dma_addr_t phys_addr; /* physical address of the ring */ 8588c2ecf20Sopenharmony_ci spinlock_t db_lock; 8598c2ecf20Sopenharmony_ci int db_disabled; 8608c2ecf20Sopenharmony_ci unsigned short db_pidx; 8618c2ecf20Sopenharmony_ci unsigned short db_pidx_inc; 8628c2ecf20Sopenharmony_ci void __iomem *bar2_addr; /* address of BAR2 Queue registers */ 8638c2ecf20Sopenharmony_ci unsigned int bar2_qid; /* Queue ID for BAR2 Queue registers */ 8648c2ecf20Sopenharmony_ci}; 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_cistruct sge_eth_txq { /* state for an SGE Ethernet Tx queue */ 8678c2ecf20Sopenharmony_ci struct sge_txq q; 8688c2ecf20Sopenharmony_ci struct netdev_queue *txq; /* associated netdev TX queue */ 8698c2ecf20Sopenharmony_ci#ifdef CONFIG_CHELSIO_T4_DCB 8708c2ecf20Sopenharmony_ci u8 dcb_prio; /* DCB Priority bound to queue */ 8718c2ecf20Sopenharmony_ci#endif 8728c2ecf20Sopenharmony_ci u8 dbqt; /* SGE Doorbell Queue Timer in use */ 8738c2ecf20Sopenharmony_ci unsigned int dbqtimerix; /* SGE Doorbell Queue Timer Index */ 8748c2ecf20Sopenharmony_ci unsigned long tso; /* # of TSO requests */ 8758c2ecf20Sopenharmony_ci unsigned long uso; /* # of USO requests */ 8768c2ecf20Sopenharmony_ci unsigned long tx_cso; /* # of Tx checksum offloads */ 8778c2ecf20Sopenharmony_ci unsigned long vlan_ins; /* # of Tx VLAN insertions */ 8788c2ecf20Sopenharmony_ci unsigned long mapping_err; /* # of I/O MMU packet mapping errors */ 8798c2ecf20Sopenharmony_ci} ____cacheline_aligned_in_smp; 8808c2ecf20Sopenharmony_ci 8818c2ecf20Sopenharmony_cistruct sge_uld_txq { /* state for an SGE offload Tx queue */ 8828c2ecf20Sopenharmony_ci struct sge_txq q; 8838c2ecf20Sopenharmony_ci struct adapter *adap; 8848c2ecf20Sopenharmony_ci struct sk_buff_head sendq; /* list of backpressured packets */ 8858c2ecf20Sopenharmony_ci struct tasklet_struct qresume_tsk; /* restarts the queue */ 8868c2ecf20Sopenharmony_ci bool service_ofldq_running; /* service_ofldq() is processing sendq */ 8878c2ecf20Sopenharmony_ci u8 full; /* the Tx ring is full */ 8888c2ecf20Sopenharmony_ci unsigned long mapping_err; /* # of I/O MMU packet mapping errors */ 8898c2ecf20Sopenharmony_ci} ____cacheline_aligned_in_smp; 8908c2ecf20Sopenharmony_ci 8918c2ecf20Sopenharmony_cistruct sge_ctrl_txq { /* state for an SGE control Tx queue */ 8928c2ecf20Sopenharmony_ci struct sge_txq q; 8938c2ecf20Sopenharmony_ci struct adapter *adap; 8948c2ecf20Sopenharmony_ci struct sk_buff_head sendq; /* list of backpressured packets */ 8958c2ecf20Sopenharmony_ci struct tasklet_struct qresume_tsk; /* restarts the queue */ 8968c2ecf20Sopenharmony_ci u8 full; /* the Tx ring is full */ 8978c2ecf20Sopenharmony_ci} ____cacheline_aligned_in_smp; 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_cistruct sge_uld_rxq_info { 9008c2ecf20Sopenharmony_ci char name[IFNAMSIZ]; /* name of ULD driver */ 9018c2ecf20Sopenharmony_ci struct sge_ofld_rxq *uldrxq; /* Rxq's for ULD */ 9028c2ecf20Sopenharmony_ci u16 *rspq_id; /* response queue id's of rxq */ 9038c2ecf20Sopenharmony_ci u16 nrxq; /* # of ingress uld queues */ 9048c2ecf20Sopenharmony_ci u16 nciq; /* # of completion queues */ 9058c2ecf20Sopenharmony_ci u8 uld; /* uld type */ 9068c2ecf20Sopenharmony_ci}; 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_cistruct sge_uld_txq_info { 9098c2ecf20Sopenharmony_ci struct sge_uld_txq *uldtxq; /* Txq's for ULD */ 9108c2ecf20Sopenharmony_ci atomic_t users; /* num users */ 9118c2ecf20Sopenharmony_ci u16 ntxq; /* # of egress uld queues */ 9128c2ecf20Sopenharmony_ci}; 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci/* struct to maintain ULD list to reallocate ULD resources on hotplug */ 9158c2ecf20Sopenharmony_cistruct cxgb4_uld_list { 9168c2ecf20Sopenharmony_ci struct cxgb4_uld_info uld_info; 9178c2ecf20Sopenharmony_ci struct list_head list_node; 9188c2ecf20Sopenharmony_ci enum cxgb4_uld uld_type; 9198c2ecf20Sopenharmony_ci}; 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_cienum sge_eosw_state { 9228c2ecf20Sopenharmony_ci CXGB4_EO_STATE_CLOSED = 0, /* Not ready to accept traffic */ 9238c2ecf20Sopenharmony_ci CXGB4_EO_STATE_FLOWC_OPEN_SEND, /* Send FLOWC open request */ 9248c2ecf20Sopenharmony_ci CXGB4_EO_STATE_FLOWC_OPEN_REPLY, /* Waiting for FLOWC open reply */ 9258c2ecf20Sopenharmony_ci CXGB4_EO_STATE_ACTIVE, /* Ready to accept traffic */ 9268c2ecf20Sopenharmony_ci CXGB4_EO_STATE_FLOWC_CLOSE_SEND, /* Send FLOWC close request */ 9278c2ecf20Sopenharmony_ci CXGB4_EO_STATE_FLOWC_CLOSE_REPLY, /* Waiting for FLOWC close reply */ 9288c2ecf20Sopenharmony_ci}; 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_cistruct sge_eosw_txq { 9318c2ecf20Sopenharmony_ci spinlock_t lock; /* Per queue lock to synchronize completions */ 9328c2ecf20Sopenharmony_ci enum sge_eosw_state state; /* Current ETHOFLD State */ 9338c2ecf20Sopenharmony_ci struct tx_sw_desc *desc; /* Descriptor ring to hold packets */ 9348c2ecf20Sopenharmony_ci u32 ndesc; /* Number of descriptors */ 9358c2ecf20Sopenharmony_ci u32 pidx; /* Current Producer Index */ 9368c2ecf20Sopenharmony_ci u32 last_pidx; /* Last successfully transmitted Producer Index */ 9378c2ecf20Sopenharmony_ci u32 cidx; /* Current Consumer Index */ 9388c2ecf20Sopenharmony_ci u32 last_cidx; /* Last successfully reclaimed Consumer Index */ 9398c2ecf20Sopenharmony_ci u32 flowc_idx; /* Descriptor containing a FLOWC request */ 9408c2ecf20Sopenharmony_ci u32 inuse; /* Number of packets held in ring */ 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci u32 cred; /* Current available credits */ 9438c2ecf20Sopenharmony_ci u32 ncompl; /* # of completions posted */ 9448c2ecf20Sopenharmony_ci u32 last_compl; /* # of credits consumed since last completion req */ 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ci u32 eotid; /* Index into EOTID table in software */ 9478c2ecf20Sopenharmony_ci u32 hwtid; /* Hardware EOTID index */ 9488c2ecf20Sopenharmony_ci 9498c2ecf20Sopenharmony_ci u32 hwqid; /* Underlying hardware queue index */ 9508c2ecf20Sopenharmony_ci struct net_device *netdev; /* Pointer to netdevice */ 9518c2ecf20Sopenharmony_ci struct tasklet_struct qresume_tsk; /* Restarts the queue */ 9528c2ecf20Sopenharmony_ci struct completion completion; /* completion for FLOWC rendezvous */ 9538c2ecf20Sopenharmony_ci}; 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_cistruct sge_eohw_txq { 9568c2ecf20Sopenharmony_ci spinlock_t lock; /* Per queue lock */ 9578c2ecf20Sopenharmony_ci struct sge_txq q; /* HW Txq */ 9588c2ecf20Sopenharmony_ci struct adapter *adap; /* Backpointer to adapter */ 9598c2ecf20Sopenharmony_ci unsigned long tso; /* # of TSO requests */ 9608c2ecf20Sopenharmony_ci unsigned long uso; /* # of USO requests */ 9618c2ecf20Sopenharmony_ci unsigned long tx_cso; /* # of Tx checksum offloads */ 9628c2ecf20Sopenharmony_ci unsigned long vlan_ins; /* # of Tx VLAN insertions */ 9638c2ecf20Sopenharmony_ci unsigned long mapping_err; /* # of I/O MMU packet mapping errors */ 9648c2ecf20Sopenharmony_ci}; 9658c2ecf20Sopenharmony_ci 9668c2ecf20Sopenharmony_cistruct sge { 9678c2ecf20Sopenharmony_ci struct sge_eth_txq ethtxq[MAX_ETH_QSETS]; 9688c2ecf20Sopenharmony_ci struct sge_eth_txq ptptxq; 9698c2ecf20Sopenharmony_ci struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES]; 9708c2ecf20Sopenharmony_ci 9718c2ecf20Sopenharmony_ci struct sge_eth_rxq ethrxq[MAX_ETH_QSETS]; 9728c2ecf20Sopenharmony_ci struct sge_rspq fw_evtq ____cacheline_aligned_in_smp; 9738c2ecf20Sopenharmony_ci struct sge_uld_rxq_info **uld_rxq_info; 9748c2ecf20Sopenharmony_ci struct sge_uld_txq_info **uld_txq_info; 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci struct sge_rspq intrq ____cacheline_aligned_in_smp; 9778c2ecf20Sopenharmony_ci spinlock_t intrq_lock; 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_ci struct sge_eohw_txq *eohw_txq; 9808c2ecf20Sopenharmony_ci struct sge_ofld_rxq *eohw_rxq; 9818c2ecf20Sopenharmony_ci 9828c2ecf20Sopenharmony_ci struct sge_eth_rxq *mirror_rxq[NCHAN]; 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci u16 max_ethqsets; /* # of available Ethernet queue sets */ 9858c2ecf20Sopenharmony_ci u16 ethqsets; /* # of active Ethernet queue sets */ 9868c2ecf20Sopenharmony_ci u16 ethtxq_rover; /* Tx queue to clean up next */ 9878c2ecf20Sopenharmony_ci u16 ofldqsets; /* # of active ofld queue sets */ 9888c2ecf20Sopenharmony_ci u16 nqs_per_uld; /* # of Rx queues per ULD */ 9898c2ecf20Sopenharmony_ci u16 eoqsets; /* # of ETHOFLD queues */ 9908c2ecf20Sopenharmony_ci u16 mirrorqsets; /* # of Mirror queues */ 9918c2ecf20Sopenharmony_ci 9928c2ecf20Sopenharmony_ci u16 timer_val[SGE_NTIMERS]; 9938c2ecf20Sopenharmony_ci u8 counter_val[SGE_NCOUNTERS]; 9948c2ecf20Sopenharmony_ci u16 dbqtimer_tick; 9958c2ecf20Sopenharmony_ci u16 dbqtimer_val[SGE_NDBQTIMERS]; 9968c2ecf20Sopenharmony_ci u32 fl_pg_order; /* large page allocation size */ 9978c2ecf20Sopenharmony_ci u32 stat_len; /* length of status page at ring end */ 9988c2ecf20Sopenharmony_ci u32 pktshift; /* padding between CPL & packet data */ 9998c2ecf20Sopenharmony_ci u32 fl_align; /* response queue message alignment */ 10008c2ecf20Sopenharmony_ci u32 fl_starve_thres; /* Free List starvation threshold */ 10018c2ecf20Sopenharmony_ci 10028c2ecf20Sopenharmony_ci struct sge_idma_monitor_state idma_monitor; 10038c2ecf20Sopenharmony_ci unsigned int egr_start; 10048c2ecf20Sopenharmony_ci unsigned int egr_sz; 10058c2ecf20Sopenharmony_ci unsigned int ingr_start; 10068c2ecf20Sopenharmony_ci unsigned int ingr_sz; 10078c2ecf20Sopenharmony_ci void **egr_map; /* qid->queue egress queue map */ 10088c2ecf20Sopenharmony_ci struct sge_rspq **ingr_map; /* qid->queue ingress queue map */ 10098c2ecf20Sopenharmony_ci unsigned long *starving_fl; 10108c2ecf20Sopenharmony_ci unsigned long *txq_maperr; 10118c2ecf20Sopenharmony_ci unsigned long *blocked_fl; 10128c2ecf20Sopenharmony_ci struct timer_list rx_timer; /* refills starving FLs */ 10138c2ecf20Sopenharmony_ci struct timer_list tx_timer; /* checks Tx queues */ 10148c2ecf20Sopenharmony_ci 10158c2ecf20Sopenharmony_ci int fwevtq_msix_idx; /* Index to firmware event queue MSI-X info */ 10168c2ecf20Sopenharmony_ci int nd_msix_idx; /* Index to non-data interrupts MSI-X info */ 10178c2ecf20Sopenharmony_ci}; 10188c2ecf20Sopenharmony_ci 10198c2ecf20Sopenharmony_ci#define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++) 10208c2ecf20Sopenharmony_ci#define for_each_ofldtxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++) 10218c2ecf20Sopenharmony_ci 10228c2ecf20Sopenharmony_cistruct l2t_data; 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_IOV 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci/* T4 supports SRIOV on PF0-3 and T5 on PF0-7. However, the Serial 10278c2ecf20Sopenharmony_ci * Configuration initialization for T5 only has SR-IOV functionality enabled 10288c2ecf20Sopenharmony_ci * on PF0-3 in order to simplify everything. 10298c2ecf20Sopenharmony_ci */ 10308c2ecf20Sopenharmony_ci#define NUM_OF_PF_WITH_SRIOV 4 10318c2ecf20Sopenharmony_ci 10328c2ecf20Sopenharmony_ci#endif 10338c2ecf20Sopenharmony_ci 10348c2ecf20Sopenharmony_cistruct doorbell_stats { 10358c2ecf20Sopenharmony_ci u32 db_drop; 10368c2ecf20Sopenharmony_ci u32 db_empty; 10378c2ecf20Sopenharmony_ci u32 db_full; 10388c2ecf20Sopenharmony_ci}; 10398c2ecf20Sopenharmony_ci 10408c2ecf20Sopenharmony_cistruct hash_mac_addr { 10418c2ecf20Sopenharmony_ci struct list_head list; 10428c2ecf20Sopenharmony_ci u8 addr[ETH_ALEN]; 10438c2ecf20Sopenharmony_ci unsigned int iface_mac; 10448c2ecf20Sopenharmony_ci}; 10458c2ecf20Sopenharmony_ci 10468c2ecf20Sopenharmony_cistruct msix_bmap { 10478c2ecf20Sopenharmony_ci unsigned long *msix_bmap; 10488c2ecf20Sopenharmony_ci unsigned int mapsize; 10498c2ecf20Sopenharmony_ci spinlock_t lock; /* lock for acquiring bitmap */ 10508c2ecf20Sopenharmony_ci}; 10518c2ecf20Sopenharmony_ci 10528c2ecf20Sopenharmony_cistruct msix_info { 10538c2ecf20Sopenharmony_ci unsigned short vec; 10548c2ecf20Sopenharmony_ci char desc[IFNAMSIZ + 10]; 10558c2ecf20Sopenharmony_ci unsigned int idx; 10568c2ecf20Sopenharmony_ci cpumask_var_t aff_mask; 10578c2ecf20Sopenharmony_ci}; 10588c2ecf20Sopenharmony_ci 10598c2ecf20Sopenharmony_cistruct vf_info { 10608c2ecf20Sopenharmony_ci unsigned char vf_mac_addr[ETH_ALEN]; 10618c2ecf20Sopenharmony_ci unsigned int tx_rate; 10628c2ecf20Sopenharmony_ci bool pf_set_mac; 10638c2ecf20Sopenharmony_ci u16 vlan; 10648c2ecf20Sopenharmony_ci int link_state; 10658c2ecf20Sopenharmony_ci}; 10668c2ecf20Sopenharmony_ci 10678c2ecf20Sopenharmony_cienum { 10688c2ecf20Sopenharmony_ci HMA_DMA_MAPPED_FLAG = 1 10698c2ecf20Sopenharmony_ci}; 10708c2ecf20Sopenharmony_ci 10718c2ecf20Sopenharmony_cistruct hma_data { 10728c2ecf20Sopenharmony_ci unsigned char flags; 10738c2ecf20Sopenharmony_ci struct sg_table *sgt; 10748c2ecf20Sopenharmony_ci dma_addr_t *phy_addr; /* physical address of the page */ 10758c2ecf20Sopenharmony_ci}; 10768c2ecf20Sopenharmony_ci 10778c2ecf20Sopenharmony_cistruct mbox_list { 10788c2ecf20Sopenharmony_ci struct list_head list; 10798c2ecf20Sopenharmony_ci}; 10808c2ecf20Sopenharmony_ci 10818c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_THERMAL) 10828c2ecf20Sopenharmony_cistruct ch_thermal { 10838c2ecf20Sopenharmony_ci struct thermal_zone_device *tzdev; 10848c2ecf20Sopenharmony_ci int trip_temp; 10858c2ecf20Sopenharmony_ci int trip_type; 10868c2ecf20Sopenharmony_ci}; 10878c2ecf20Sopenharmony_ci#endif 10888c2ecf20Sopenharmony_ci 10898c2ecf20Sopenharmony_cistruct mps_entries_ref { 10908c2ecf20Sopenharmony_ci struct list_head list; 10918c2ecf20Sopenharmony_ci u8 addr[ETH_ALEN]; 10928c2ecf20Sopenharmony_ci u8 mask[ETH_ALEN]; 10938c2ecf20Sopenharmony_ci u16 idx; 10948c2ecf20Sopenharmony_ci refcount_t refcnt; 10958c2ecf20Sopenharmony_ci}; 10968c2ecf20Sopenharmony_ci 10978c2ecf20Sopenharmony_cistruct cxgb4_ethtool_filter_info { 10988c2ecf20Sopenharmony_ci u32 *loc_array; /* Array holding the actual TIDs set to filters */ 10998c2ecf20Sopenharmony_ci unsigned long *bmap; /* Bitmap for managing filters in use */ 11008c2ecf20Sopenharmony_ci u32 in_use; /* # of filters in use */ 11018c2ecf20Sopenharmony_ci}; 11028c2ecf20Sopenharmony_ci 11038c2ecf20Sopenharmony_cistruct cxgb4_ethtool_filter { 11048c2ecf20Sopenharmony_ci u32 nentries; /* Adapter wide number of supported filters */ 11058c2ecf20Sopenharmony_ci struct cxgb4_ethtool_filter_info *port; /* Per port entry */ 11068c2ecf20Sopenharmony_ci}; 11078c2ecf20Sopenharmony_ci 11088c2ecf20Sopenharmony_cistruct adapter { 11098c2ecf20Sopenharmony_ci void __iomem *regs; 11108c2ecf20Sopenharmony_ci void __iomem *bar2; 11118c2ecf20Sopenharmony_ci u32 t4_bar0; 11128c2ecf20Sopenharmony_ci struct pci_dev *pdev; 11138c2ecf20Sopenharmony_ci struct device *pdev_dev; 11148c2ecf20Sopenharmony_ci const char *name; 11158c2ecf20Sopenharmony_ci unsigned int mbox; 11168c2ecf20Sopenharmony_ci unsigned int pf; 11178c2ecf20Sopenharmony_ci unsigned int flags; 11188c2ecf20Sopenharmony_ci unsigned int adap_idx; 11198c2ecf20Sopenharmony_ci enum chip_type chip; 11208c2ecf20Sopenharmony_ci u32 eth_flags; 11218c2ecf20Sopenharmony_ci 11228c2ecf20Sopenharmony_ci int msg_enable; 11238c2ecf20Sopenharmony_ci __be16 vxlan_port; 11248c2ecf20Sopenharmony_ci __be16 geneve_port; 11258c2ecf20Sopenharmony_ci 11268c2ecf20Sopenharmony_ci struct adapter_params params; 11278c2ecf20Sopenharmony_ci struct cxgb4_virt_res vres; 11288c2ecf20Sopenharmony_ci unsigned int swintr; 11298c2ecf20Sopenharmony_ci 11308c2ecf20Sopenharmony_ci /* MSI-X Info for NIC and OFLD queues */ 11318c2ecf20Sopenharmony_ci struct msix_info *msix_info; 11328c2ecf20Sopenharmony_ci struct msix_bmap msix_bmap; 11338c2ecf20Sopenharmony_ci 11348c2ecf20Sopenharmony_ci struct doorbell_stats db_stats; 11358c2ecf20Sopenharmony_ci struct sge sge; 11368c2ecf20Sopenharmony_ci 11378c2ecf20Sopenharmony_ci struct net_device *port[MAX_NPORTS]; 11388c2ecf20Sopenharmony_ci u8 chan_map[NCHAN]; /* channel -> port map */ 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_ci struct vf_info *vfinfo; 11418c2ecf20Sopenharmony_ci u8 num_vfs; 11428c2ecf20Sopenharmony_ci 11438c2ecf20Sopenharmony_ci u32 filter_mode; 11448c2ecf20Sopenharmony_ci unsigned int l2t_start; 11458c2ecf20Sopenharmony_ci unsigned int l2t_end; 11468c2ecf20Sopenharmony_ci struct l2t_data *l2t; 11478c2ecf20Sopenharmony_ci unsigned int clipt_start; 11488c2ecf20Sopenharmony_ci unsigned int clipt_end; 11498c2ecf20Sopenharmony_ci struct clip_tbl *clipt; 11508c2ecf20Sopenharmony_ci unsigned int rawf_start; 11518c2ecf20Sopenharmony_ci unsigned int rawf_cnt; 11528c2ecf20Sopenharmony_ci struct smt_data *smt; 11538c2ecf20Sopenharmony_ci struct cxgb4_uld_info *uld; 11548c2ecf20Sopenharmony_ci void *uld_handle[CXGB4_ULD_MAX]; 11558c2ecf20Sopenharmony_ci unsigned int num_uld; 11568c2ecf20Sopenharmony_ci unsigned int num_ofld_uld; 11578c2ecf20Sopenharmony_ci struct list_head list_node; 11588c2ecf20Sopenharmony_ci struct list_head rcu_node; 11598c2ecf20Sopenharmony_ci struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */ 11608c2ecf20Sopenharmony_ci struct list_head mps_ref; 11618c2ecf20Sopenharmony_ci spinlock_t mps_ref_lock; /* lock for syncing mps ref/def activities */ 11628c2ecf20Sopenharmony_ci 11638c2ecf20Sopenharmony_ci void *iscsi_ppm; 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_ci struct tid_info tids; 11668c2ecf20Sopenharmony_ci void **tid_release_head; 11678c2ecf20Sopenharmony_ci spinlock_t tid_release_lock; 11688c2ecf20Sopenharmony_ci struct workqueue_struct *workq; 11698c2ecf20Sopenharmony_ci struct work_struct tid_release_task; 11708c2ecf20Sopenharmony_ci struct work_struct db_full_task; 11718c2ecf20Sopenharmony_ci struct work_struct db_drop_task; 11728c2ecf20Sopenharmony_ci struct work_struct fatal_err_notify_task; 11738c2ecf20Sopenharmony_ci bool tid_release_task_busy; 11748c2ecf20Sopenharmony_ci 11758c2ecf20Sopenharmony_ci /* lock for mailbox cmd list */ 11768c2ecf20Sopenharmony_ci spinlock_t mbox_lock; 11778c2ecf20Sopenharmony_ci struct mbox_list mlist; 11788c2ecf20Sopenharmony_ci 11798c2ecf20Sopenharmony_ci /* support for mailbox command/reply logging */ 11808c2ecf20Sopenharmony_ci#define T4_OS_LOG_MBOX_CMDS 256 11818c2ecf20Sopenharmony_ci struct mbox_cmd_log *mbox_log; 11828c2ecf20Sopenharmony_ci 11838c2ecf20Sopenharmony_ci struct mutex uld_mutex; 11848c2ecf20Sopenharmony_ci 11858c2ecf20Sopenharmony_ci struct dentry *debugfs_root; 11868c2ecf20Sopenharmony_ci bool use_bd; /* Use SGE Back Door intfc for reading SGE Contexts */ 11878c2ecf20Sopenharmony_ci bool trace_rss; /* 1 implies that different RSS flit per filter is 11888c2ecf20Sopenharmony_ci * used per filter else if 0 default RSS flit is 11898c2ecf20Sopenharmony_ci * used for all 4 filters. 11908c2ecf20Sopenharmony_ci */ 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci struct ptp_clock *ptp_clock; 11938c2ecf20Sopenharmony_ci struct ptp_clock_info ptp_clock_info; 11948c2ecf20Sopenharmony_ci struct sk_buff *ptp_tx_skb; 11958c2ecf20Sopenharmony_ci /* ptp lock */ 11968c2ecf20Sopenharmony_ci spinlock_t ptp_lock; 11978c2ecf20Sopenharmony_ci spinlock_t stats_lock; 11988c2ecf20Sopenharmony_ci spinlock_t win0_lock ____cacheline_aligned_in_smp; 11998c2ecf20Sopenharmony_ci 12008c2ecf20Sopenharmony_ci /* TC u32 offload */ 12018c2ecf20Sopenharmony_ci struct cxgb4_tc_u32_table *tc_u32; 12028c2ecf20Sopenharmony_ci struct chcr_ktls chcr_ktls; 12038c2ecf20Sopenharmony_ci struct chcr_stats_debug chcr_stats; 12048c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE) 12058c2ecf20Sopenharmony_ci struct ch_ktls_stats_debug ch_ktls_stats; 12068c2ecf20Sopenharmony_ci#endif 12078c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_CHELSIO_IPSEC_INLINE) 12088c2ecf20Sopenharmony_ci struct ch_ipsec_stats_debug ch_ipsec_stats; 12098c2ecf20Sopenharmony_ci#endif 12108c2ecf20Sopenharmony_ci 12118c2ecf20Sopenharmony_ci /* TC flower offload */ 12128c2ecf20Sopenharmony_ci bool tc_flower_initialized; 12138c2ecf20Sopenharmony_ci struct rhashtable flower_tbl; 12148c2ecf20Sopenharmony_ci struct rhashtable_params flower_ht_params; 12158c2ecf20Sopenharmony_ci struct timer_list flower_stats_timer; 12168c2ecf20Sopenharmony_ci struct work_struct flower_stats_work; 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_ci /* Ethtool Dump */ 12198c2ecf20Sopenharmony_ci struct ethtool_dump eth_dump; 12208c2ecf20Sopenharmony_ci 12218c2ecf20Sopenharmony_ci /* HMA */ 12228c2ecf20Sopenharmony_ci struct hma_data hma; 12238c2ecf20Sopenharmony_ci 12248c2ecf20Sopenharmony_ci struct srq_data *srq; 12258c2ecf20Sopenharmony_ci 12268c2ecf20Sopenharmony_ci /* Dump buffer for collecting logs in kdump kernel */ 12278c2ecf20Sopenharmony_ci struct vmcoredd_data vmcoredd; 12288c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_THERMAL) 12298c2ecf20Sopenharmony_ci struct ch_thermal ch_thermal; 12308c2ecf20Sopenharmony_ci#endif 12318c2ecf20Sopenharmony_ci 12328c2ecf20Sopenharmony_ci /* TC MQPRIO offload */ 12338c2ecf20Sopenharmony_ci struct cxgb4_tc_mqprio *tc_mqprio; 12348c2ecf20Sopenharmony_ci 12358c2ecf20Sopenharmony_ci /* TC MATCHALL classifier offload */ 12368c2ecf20Sopenharmony_ci struct cxgb4_tc_matchall *tc_matchall; 12378c2ecf20Sopenharmony_ci 12388c2ecf20Sopenharmony_ci /* Ethtool n-tuple */ 12398c2ecf20Sopenharmony_ci struct cxgb4_ethtool_filter *ethtool_filters; 12408c2ecf20Sopenharmony_ci}; 12418c2ecf20Sopenharmony_ci 12428c2ecf20Sopenharmony_ci/* Support for "sched-class" command to allow a TX Scheduling Class to be 12438c2ecf20Sopenharmony_ci * programmed with various parameters. 12448c2ecf20Sopenharmony_ci */ 12458c2ecf20Sopenharmony_cistruct ch_sched_params { 12468c2ecf20Sopenharmony_ci u8 type; /* packet or flow */ 12478c2ecf20Sopenharmony_ci union { 12488c2ecf20Sopenharmony_ci struct { 12498c2ecf20Sopenharmony_ci u8 level; /* scheduler hierarchy level */ 12508c2ecf20Sopenharmony_ci u8 mode; /* per-class or per-flow */ 12518c2ecf20Sopenharmony_ci u8 rateunit; /* bit or packet rate */ 12528c2ecf20Sopenharmony_ci u8 ratemode; /* %port relative or kbps absolute */ 12538c2ecf20Sopenharmony_ci u8 channel; /* scheduler channel [0..N] */ 12548c2ecf20Sopenharmony_ci u8 class; /* scheduler class [0..N] */ 12558c2ecf20Sopenharmony_ci u32 minrate; /* minimum rate */ 12568c2ecf20Sopenharmony_ci u32 maxrate; /* maximum rate */ 12578c2ecf20Sopenharmony_ci u16 weight; /* percent weight */ 12588c2ecf20Sopenharmony_ci u16 pktsize; /* average packet size */ 12598c2ecf20Sopenharmony_ci u16 burstsize; /* burst buffer size */ 12608c2ecf20Sopenharmony_ci } params; 12618c2ecf20Sopenharmony_ci } u; 12628c2ecf20Sopenharmony_ci}; 12638c2ecf20Sopenharmony_ci 12648c2ecf20Sopenharmony_cienum { 12658c2ecf20Sopenharmony_ci SCHED_CLASS_TYPE_PACKET = 0, /* class type */ 12668c2ecf20Sopenharmony_ci}; 12678c2ecf20Sopenharmony_ci 12688c2ecf20Sopenharmony_cienum { 12698c2ecf20Sopenharmony_ci SCHED_CLASS_LEVEL_CL_RL = 0, /* class rate limiter */ 12708c2ecf20Sopenharmony_ci SCHED_CLASS_LEVEL_CH_RL = 2, /* channel rate limiter */ 12718c2ecf20Sopenharmony_ci}; 12728c2ecf20Sopenharmony_ci 12738c2ecf20Sopenharmony_cienum { 12748c2ecf20Sopenharmony_ci SCHED_CLASS_MODE_CLASS = 0, /* per-class scheduling */ 12758c2ecf20Sopenharmony_ci SCHED_CLASS_MODE_FLOW, /* per-flow scheduling */ 12768c2ecf20Sopenharmony_ci}; 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_cienum { 12798c2ecf20Sopenharmony_ci SCHED_CLASS_RATEUNIT_BITS = 0, /* bit rate scheduling */ 12808c2ecf20Sopenharmony_ci}; 12818c2ecf20Sopenharmony_ci 12828c2ecf20Sopenharmony_cienum { 12838c2ecf20Sopenharmony_ci SCHED_CLASS_RATEMODE_ABS = 1, /* Kb/s */ 12848c2ecf20Sopenharmony_ci}; 12858c2ecf20Sopenharmony_ci 12868c2ecf20Sopenharmony_ci/* Support for "sched_queue" command to allow one or more NIC TX Queues 12878c2ecf20Sopenharmony_ci * to be bound to a TX Scheduling Class. 12888c2ecf20Sopenharmony_ci */ 12898c2ecf20Sopenharmony_cistruct ch_sched_queue { 12908c2ecf20Sopenharmony_ci s8 queue; /* queue index */ 12918c2ecf20Sopenharmony_ci s8 class; /* class index */ 12928c2ecf20Sopenharmony_ci}; 12938c2ecf20Sopenharmony_ci 12948c2ecf20Sopenharmony_ci/* Support for "sched_flowc" command to allow one or more FLOWC 12958c2ecf20Sopenharmony_ci * to be bound to a TX Scheduling Class. 12968c2ecf20Sopenharmony_ci */ 12978c2ecf20Sopenharmony_cistruct ch_sched_flowc { 12988c2ecf20Sopenharmony_ci s32 tid; /* TID to bind */ 12998c2ecf20Sopenharmony_ci s8 class; /* class index */ 13008c2ecf20Sopenharmony_ci}; 13018c2ecf20Sopenharmony_ci 13028c2ecf20Sopenharmony_ci/* Defined bit width of user definable filter tuples 13038c2ecf20Sopenharmony_ci */ 13048c2ecf20Sopenharmony_ci#define ETHTYPE_BITWIDTH 16 13058c2ecf20Sopenharmony_ci#define FRAG_BITWIDTH 1 13068c2ecf20Sopenharmony_ci#define MACIDX_BITWIDTH 9 13078c2ecf20Sopenharmony_ci#define FCOE_BITWIDTH 1 13088c2ecf20Sopenharmony_ci#define IPORT_BITWIDTH 3 13098c2ecf20Sopenharmony_ci#define MATCHTYPE_BITWIDTH 3 13108c2ecf20Sopenharmony_ci#define PROTO_BITWIDTH 8 13118c2ecf20Sopenharmony_ci#define TOS_BITWIDTH 8 13128c2ecf20Sopenharmony_ci#define PF_BITWIDTH 8 13138c2ecf20Sopenharmony_ci#define VF_BITWIDTH 8 13148c2ecf20Sopenharmony_ci#define IVLAN_BITWIDTH 16 13158c2ecf20Sopenharmony_ci#define OVLAN_BITWIDTH 16 13168c2ecf20Sopenharmony_ci#define ENCAP_VNI_BITWIDTH 24 13178c2ecf20Sopenharmony_ci 13188c2ecf20Sopenharmony_ci/* Filter matching rules. These consist of a set of ingress packet field 13198c2ecf20Sopenharmony_ci * (value, mask) tuples. The associated ingress packet field matches the 13208c2ecf20Sopenharmony_ci * tuple when ((field & mask) == value). (Thus a wildcard "don't care" field 13218c2ecf20Sopenharmony_ci * rule can be constructed by specifying a tuple of (0, 0).) A filter rule 13228c2ecf20Sopenharmony_ci * matches an ingress packet when all of the individual individual field 13238c2ecf20Sopenharmony_ci * matching rules are true. 13248c2ecf20Sopenharmony_ci * 13258c2ecf20Sopenharmony_ci * Partial field masks are always valid, however, while it may be easy to 13268c2ecf20Sopenharmony_ci * understand their meanings for some fields (e.g. IP address to match a 13278c2ecf20Sopenharmony_ci * subnet), for others making sensible partial masks is less intuitive (e.g. 13288c2ecf20Sopenharmony_ci * MPS match type) ... 13298c2ecf20Sopenharmony_ci * 13308c2ecf20Sopenharmony_ci * Most of the following data structures are modeled on T4 capabilities. 13318c2ecf20Sopenharmony_ci * Drivers for earlier chips use the subsets which make sense for those chips. 13328c2ecf20Sopenharmony_ci * We really need to come up with a hardware-independent mechanism to 13338c2ecf20Sopenharmony_ci * represent hardware filter capabilities ... 13348c2ecf20Sopenharmony_ci */ 13358c2ecf20Sopenharmony_cistruct ch_filter_tuple { 13368c2ecf20Sopenharmony_ci /* Compressed header matching field rules. The TP_VLAN_PRI_MAP 13378c2ecf20Sopenharmony_ci * register selects which of these fields will participate in the 13388c2ecf20Sopenharmony_ci * filter match rules -- up to a maximum of 36 bits. Because 13398c2ecf20Sopenharmony_ci * TP_VLAN_PRI_MAP is a global register, all filters must use the same 13408c2ecf20Sopenharmony_ci * set of fields. 13418c2ecf20Sopenharmony_ci */ 13428c2ecf20Sopenharmony_ci uint32_t ethtype:ETHTYPE_BITWIDTH; /* Ethernet type */ 13438c2ecf20Sopenharmony_ci uint32_t frag:FRAG_BITWIDTH; /* IP fragmentation header */ 13448c2ecf20Sopenharmony_ci uint32_t ivlan_vld:1; /* inner VLAN valid */ 13458c2ecf20Sopenharmony_ci uint32_t ovlan_vld:1; /* outer VLAN valid */ 13468c2ecf20Sopenharmony_ci uint32_t pfvf_vld:1; /* PF/VF valid */ 13478c2ecf20Sopenharmony_ci uint32_t encap_vld:1; /* Encapsulation valid */ 13488c2ecf20Sopenharmony_ci uint32_t macidx:MACIDX_BITWIDTH; /* exact match MAC index */ 13498c2ecf20Sopenharmony_ci uint32_t fcoe:FCOE_BITWIDTH; /* FCoE packet */ 13508c2ecf20Sopenharmony_ci uint32_t iport:IPORT_BITWIDTH; /* ingress port */ 13518c2ecf20Sopenharmony_ci uint32_t matchtype:MATCHTYPE_BITWIDTH; /* MPS match type */ 13528c2ecf20Sopenharmony_ci uint32_t proto:PROTO_BITWIDTH; /* protocol type */ 13538c2ecf20Sopenharmony_ci uint32_t tos:TOS_BITWIDTH; /* TOS/Traffic Type */ 13548c2ecf20Sopenharmony_ci uint32_t pf:PF_BITWIDTH; /* PCI-E PF ID */ 13558c2ecf20Sopenharmony_ci uint32_t vf:VF_BITWIDTH; /* PCI-E VF ID */ 13568c2ecf20Sopenharmony_ci uint32_t ivlan:IVLAN_BITWIDTH; /* inner VLAN */ 13578c2ecf20Sopenharmony_ci uint32_t ovlan:OVLAN_BITWIDTH; /* outer VLAN */ 13588c2ecf20Sopenharmony_ci uint32_t vni:ENCAP_VNI_BITWIDTH; /* VNI of tunnel */ 13598c2ecf20Sopenharmony_ci 13608c2ecf20Sopenharmony_ci /* Uncompressed header matching field rules. These are always 13618c2ecf20Sopenharmony_ci * available for field rules. 13628c2ecf20Sopenharmony_ci */ 13638c2ecf20Sopenharmony_ci uint8_t lip[16]; /* local IP address (IPv4 in [3:0]) */ 13648c2ecf20Sopenharmony_ci uint8_t fip[16]; /* foreign IP address (IPv4 in [3:0]) */ 13658c2ecf20Sopenharmony_ci uint16_t lport; /* local port */ 13668c2ecf20Sopenharmony_ci uint16_t fport; /* foreign port */ 13678c2ecf20Sopenharmony_ci}; 13688c2ecf20Sopenharmony_ci 13698c2ecf20Sopenharmony_ci/* A filter ioctl command. 13708c2ecf20Sopenharmony_ci */ 13718c2ecf20Sopenharmony_cistruct ch_filter_specification { 13728c2ecf20Sopenharmony_ci /* Administrative fields for filter. 13738c2ecf20Sopenharmony_ci */ 13748c2ecf20Sopenharmony_ci uint32_t hitcnts:1; /* count filter hits in TCB */ 13758c2ecf20Sopenharmony_ci uint32_t prio:1; /* filter has priority over active/server */ 13768c2ecf20Sopenharmony_ci 13778c2ecf20Sopenharmony_ci /* Fundamental filter typing. This is the one element of filter 13788c2ecf20Sopenharmony_ci * matching that doesn't exist as a (value, mask) tuple. 13798c2ecf20Sopenharmony_ci */ 13808c2ecf20Sopenharmony_ci uint32_t type:1; /* 0 => IPv4, 1 => IPv6 */ 13818c2ecf20Sopenharmony_ci u32 hash:1; /* 0 => wild-card, 1 => exact-match */ 13828c2ecf20Sopenharmony_ci 13838c2ecf20Sopenharmony_ci /* Packet dispatch information. Ingress packets which match the 13848c2ecf20Sopenharmony_ci * filter rules will be dropped, passed to the host or switched back 13858c2ecf20Sopenharmony_ci * out as egress packets. 13868c2ecf20Sopenharmony_ci */ 13878c2ecf20Sopenharmony_ci uint32_t action:2; /* drop, pass, switch */ 13888c2ecf20Sopenharmony_ci 13898c2ecf20Sopenharmony_ci uint32_t rpttid:1; /* report TID in RSS hash field */ 13908c2ecf20Sopenharmony_ci 13918c2ecf20Sopenharmony_ci uint32_t dirsteer:1; /* 0 => RSS, 1 => steer to iq */ 13928c2ecf20Sopenharmony_ci uint32_t iq:10; /* ingress queue */ 13938c2ecf20Sopenharmony_ci 13948c2ecf20Sopenharmony_ci uint32_t maskhash:1; /* dirsteer=0: store RSS hash in TCB */ 13958c2ecf20Sopenharmony_ci uint32_t dirsteerhash:1;/* dirsteer=1: 0 => TCB contains RSS hash */ 13968c2ecf20Sopenharmony_ci /* 1 => TCB contains IQ ID */ 13978c2ecf20Sopenharmony_ci 13988c2ecf20Sopenharmony_ci /* Switch proxy/rewrite fields. An ingress packet which matches a 13998c2ecf20Sopenharmony_ci * filter with "switch" set will be looped back out as an egress 14008c2ecf20Sopenharmony_ci * packet -- potentially with some Ethernet header rewriting. 14018c2ecf20Sopenharmony_ci */ 14028c2ecf20Sopenharmony_ci uint32_t eport:2; /* egress port to switch packet out */ 14038c2ecf20Sopenharmony_ci uint32_t newdmac:1; /* rewrite destination MAC address */ 14048c2ecf20Sopenharmony_ci uint32_t newsmac:1; /* rewrite source MAC address */ 14058c2ecf20Sopenharmony_ci uint32_t newvlan:2; /* rewrite VLAN Tag */ 14068c2ecf20Sopenharmony_ci uint32_t nat_mode:3; /* specify NAT operation mode */ 14078c2ecf20Sopenharmony_ci uint8_t dmac[ETH_ALEN]; /* new destination MAC address */ 14088c2ecf20Sopenharmony_ci uint8_t smac[ETH_ALEN]; /* new source MAC address */ 14098c2ecf20Sopenharmony_ci uint16_t vlan; /* VLAN Tag to insert */ 14108c2ecf20Sopenharmony_ci 14118c2ecf20Sopenharmony_ci u8 nat_lip[16]; /* local IP to use after NAT'ing */ 14128c2ecf20Sopenharmony_ci u8 nat_fip[16]; /* foreign IP to use after NAT'ing */ 14138c2ecf20Sopenharmony_ci u16 nat_lport; /* local port to use after NAT'ing */ 14148c2ecf20Sopenharmony_ci u16 nat_fport; /* foreign port to use after NAT'ing */ 14158c2ecf20Sopenharmony_ci 14168c2ecf20Sopenharmony_ci u32 tc_prio; /* TC's filter priority index */ 14178c2ecf20Sopenharmony_ci u64 tc_cookie; /* Unique cookie identifying TC rules */ 14188c2ecf20Sopenharmony_ci 14198c2ecf20Sopenharmony_ci /* reservation for future additions */ 14208c2ecf20Sopenharmony_ci u8 rsvd[12]; 14218c2ecf20Sopenharmony_ci 14228c2ecf20Sopenharmony_ci /* Filter rule value/mask pairs. 14238c2ecf20Sopenharmony_ci */ 14248c2ecf20Sopenharmony_ci struct ch_filter_tuple val; 14258c2ecf20Sopenharmony_ci struct ch_filter_tuple mask; 14268c2ecf20Sopenharmony_ci}; 14278c2ecf20Sopenharmony_ci 14288c2ecf20Sopenharmony_cienum { 14298c2ecf20Sopenharmony_ci FILTER_PASS = 0, /* default */ 14308c2ecf20Sopenharmony_ci FILTER_DROP, 14318c2ecf20Sopenharmony_ci FILTER_SWITCH 14328c2ecf20Sopenharmony_ci}; 14338c2ecf20Sopenharmony_ci 14348c2ecf20Sopenharmony_cienum { 14358c2ecf20Sopenharmony_ci VLAN_NOCHANGE = 0, /* default */ 14368c2ecf20Sopenharmony_ci VLAN_REMOVE, 14378c2ecf20Sopenharmony_ci VLAN_INSERT, 14388c2ecf20Sopenharmony_ci VLAN_REWRITE 14398c2ecf20Sopenharmony_ci}; 14408c2ecf20Sopenharmony_ci 14418c2ecf20Sopenharmony_cienum { 14428c2ecf20Sopenharmony_ci NAT_MODE_NONE = 0, /* No NAT performed */ 14438c2ecf20Sopenharmony_ci NAT_MODE_DIP, /* NAT on Dst IP */ 14448c2ecf20Sopenharmony_ci NAT_MODE_DIP_DP, /* NAT on Dst IP, Dst Port */ 14458c2ecf20Sopenharmony_ci NAT_MODE_DIP_DP_SIP, /* NAT on Dst IP, Dst Port and Src IP */ 14468c2ecf20Sopenharmony_ci NAT_MODE_DIP_DP_SP, /* NAT on Dst IP, Dst Port and Src Port */ 14478c2ecf20Sopenharmony_ci NAT_MODE_SIP_SP, /* NAT on Src IP and Src Port */ 14488c2ecf20Sopenharmony_ci NAT_MODE_DIP_SIP_SP, /* NAT on Dst IP, Src IP and Src Port */ 14498c2ecf20Sopenharmony_ci NAT_MODE_ALL /* NAT on entire 4-tuple */ 14508c2ecf20Sopenharmony_ci}; 14518c2ecf20Sopenharmony_ci 14528c2ecf20Sopenharmony_ci#define CXGB4_FILTER_TYPE_MAX 2 14538c2ecf20Sopenharmony_ci 14548c2ecf20Sopenharmony_ci/* Host shadow copy of ingress filter entry. This is in host native format 14558c2ecf20Sopenharmony_ci * and doesn't match the ordering or bit order, etc. of the hardware of the 14568c2ecf20Sopenharmony_ci * firmware command. The use of bit-field structure elements is purely to 14578c2ecf20Sopenharmony_ci * remind ourselves of the field size limitations and save memory in the case 14588c2ecf20Sopenharmony_ci * where the filter table is large. 14598c2ecf20Sopenharmony_ci */ 14608c2ecf20Sopenharmony_cistruct filter_entry { 14618c2ecf20Sopenharmony_ci /* Administrative fields for filter. */ 14628c2ecf20Sopenharmony_ci u32 valid:1; /* filter allocated and valid */ 14638c2ecf20Sopenharmony_ci u32 locked:1; /* filter is administratively locked */ 14648c2ecf20Sopenharmony_ci 14658c2ecf20Sopenharmony_ci u32 pending:1; /* filter action is pending firmware reply */ 14668c2ecf20Sopenharmony_ci struct filter_ctx *ctx; /* Caller's completion hook */ 14678c2ecf20Sopenharmony_ci struct l2t_entry *l2t; /* Layer Two Table entry for dmac */ 14688c2ecf20Sopenharmony_ci struct smt_entry *smt; /* Source Mac Table entry for smac */ 14698c2ecf20Sopenharmony_ci struct net_device *dev; /* Associated net device */ 14708c2ecf20Sopenharmony_ci u32 tid; /* This will store the actual tid */ 14718c2ecf20Sopenharmony_ci 14728c2ecf20Sopenharmony_ci /* The filter itself. Most of this is a straight copy of information 14738c2ecf20Sopenharmony_ci * provided by the extended ioctl(). Some fields are translated to 14748c2ecf20Sopenharmony_ci * internal forms -- for instance the Ingress Queue ID passed in from 14758c2ecf20Sopenharmony_ci * the ioctl() is translated into the Absolute Ingress Queue ID. 14768c2ecf20Sopenharmony_ci */ 14778c2ecf20Sopenharmony_ci struct ch_filter_specification fs; 14788c2ecf20Sopenharmony_ci}; 14798c2ecf20Sopenharmony_ci 14808c2ecf20Sopenharmony_cistatic inline int is_offload(const struct adapter *adap) 14818c2ecf20Sopenharmony_ci{ 14828c2ecf20Sopenharmony_ci return adap->params.offload; 14838c2ecf20Sopenharmony_ci} 14848c2ecf20Sopenharmony_ci 14858c2ecf20Sopenharmony_cistatic inline int is_hashfilter(const struct adapter *adap) 14868c2ecf20Sopenharmony_ci{ 14878c2ecf20Sopenharmony_ci return adap->params.hash_filter; 14888c2ecf20Sopenharmony_ci} 14898c2ecf20Sopenharmony_ci 14908c2ecf20Sopenharmony_cistatic inline int is_pci_uld(const struct adapter *adap) 14918c2ecf20Sopenharmony_ci{ 14928c2ecf20Sopenharmony_ci return adap->params.crypto; 14938c2ecf20Sopenharmony_ci} 14948c2ecf20Sopenharmony_ci 14958c2ecf20Sopenharmony_cistatic inline int is_uld(const struct adapter *adap) 14968c2ecf20Sopenharmony_ci{ 14978c2ecf20Sopenharmony_ci return (adap->params.offload || adap->params.crypto); 14988c2ecf20Sopenharmony_ci} 14998c2ecf20Sopenharmony_ci 15008c2ecf20Sopenharmony_cistatic inline int is_ethofld(const struct adapter *adap) 15018c2ecf20Sopenharmony_ci{ 15028c2ecf20Sopenharmony_ci return adap->params.ethofld; 15038c2ecf20Sopenharmony_ci} 15048c2ecf20Sopenharmony_ci 15058c2ecf20Sopenharmony_cistatic inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr) 15068c2ecf20Sopenharmony_ci{ 15078c2ecf20Sopenharmony_ci return readl(adap->regs + reg_addr); 15088c2ecf20Sopenharmony_ci} 15098c2ecf20Sopenharmony_ci 15108c2ecf20Sopenharmony_cistatic inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val) 15118c2ecf20Sopenharmony_ci{ 15128c2ecf20Sopenharmony_ci writel(val, adap->regs + reg_addr); 15138c2ecf20Sopenharmony_ci} 15148c2ecf20Sopenharmony_ci 15158c2ecf20Sopenharmony_ci#ifndef readq 15168c2ecf20Sopenharmony_cistatic inline u64 readq(const volatile void __iomem *addr) 15178c2ecf20Sopenharmony_ci{ 15188c2ecf20Sopenharmony_ci return readl(addr) + ((u64)readl(addr + 4) << 32); 15198c2ecf20Sopenharmony_ci} 15208c2ecf20Sopenharmony_ci 15218c2ecf20Sopenharmony_cistatic inline void writeq(u64 val, volatile void __iomem *addr) 15228c2ecf20Sopenharmony_ci{ 15238c2ecf20Sopenharmony_ci writel(val, addr); 15248c2ecf20Sopenharmony_ci writel(val >> 32, addr + 4); 15258c2ecf20Sopenharmony_ci} 15268c2ecf20Sopenharmony_ci#endif 15278c2ecf20Sopenharmony_ci 15288c2ecf20Sopenharmony_cistatic inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr) 15298c2ecf20Sopenharmony_ci{ 15308c2ecf20Sopenharmony_ci return readq(adap->regs + reg_addr); 15318c2ecf20Sopenharmony_ci} 15328c2ecf20Sopenharmony_ci 15338c2ecf20Sopenharmony_cistatic inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val) 15348c2ecf20Sopenharmony_ci{ 15358c2ecf20Sopenharmony_ci writeq(val, adap->regs + reg_addr); 15368c2ecf20Sopenharmony_ci} 15378c2ecf20Sopenharmony_ci 15388c2ecf20Sopenharmony_ci/** 15398c2ecf20Sopenharmony_ci * t4_set_hw_addr - store a port's MAC address in SW 15408c2ecf20Sopenharmony_ci * @adapter: the adapter 15418c2ecf20Sopenharmony_ci * @port_idx: the port index 15428c2ecf20Sopenharmony_ci * @hw_addr: the Ethernet address 15438c2ecf20Sopenharmony_ci * 15448c2ecf20Sopenharmony_ci * Store the Ethernet address of the given port in SW. Called by the common 15458c2ecf20Sopenharmony_ci * code when it retrieves a port's Ethernet address from EEPROM. 15468c2ecf20Sopenharmony_ci */ 15478c2ecf20Sopenharmony_cistatic inline void t4_set_hw_addr(struct adapter *adapter, int port_idx, 15488c2ecf20Sopenharmony_ci u8 hw_addr[]) 15498c2ecf20Sopenharmony_ci{ 15508c2ecf20Sopenharmony_ci ether_addr_copy(adapter->port[port_idx]->dev_addr, hw_addr); 15518c2ecf20Sopenharmony_ci ether_addr_copy(adapter->port[port_idx]->perm_addr, hw_addr); 15528c2ecf20Sopenharmony_ci} 15538c2ecf20Sopenharmony_ci 15548c2ecf20Sopenharmony_ci/** 15558c2ecf20Sopenharmony_ci * netdev2pinfo - return the port_info structure associated with a net_device 15568c2ecf20Sopenharmony_ci * @dev: the netdev 15578c2ecf20Sopenharmony_ci * 15588c2ecf20Sopenharmony_ci * Return the struct port_info associated with a net_device 15598c2ecf20Sopenharmony_ci */ 15608c2ecf20Sopenharmony_cistatic inline struct port_info *netdev2pinfo(const struct net_device *dev) 15618c2ecf20Sopenharmony_ci{ 15628c2ecf20Sopenharmony_ci return netdev_priv(dev); 15638c2ecf20Sopenharmony_ci} 15648c2ecf20Sopenharmony_ci 15658c2ecf20Sopenharmony_ci/** 15668c2ecf20Sopenharmony_ci * adap2pinfo - return the port_info of a port 15678c2ecf20Sopenharmony_ci * @adap: the adapter 15688c2ecf20Sopenharmony_ci * @idx: the port index 15698c2ecf20Sopenharmony_ci * 15708c2ecf20Sopenharmony_ci * Return the port_info structure for the port of the given index. 15718c2ecf20Sopenharmony_ci */ 15728c2ecf20Sopenharmony_cistatic inline struct port_info *adap2pinfo(struct adapter *adap, int idx) 15738c2ecf20Sopenharmony_ci{ 15748c2ecf20Sopenharmony_ci return netdev_priv(adap->port[idx]); 15758c2ecf20Sopenharmony_ci} 15768c2ecf20Sopenharmony_ci 15778c2ecf20Sopenharmony_ci/** 15788c2ecf20Sopenharmony_ci * netdev2adap - return the adapter structure associated with a net_device 15798c2ecf20Sopenharmony_ci * @dev: the netdev 15808c2ecf20Sopenharmony_ci * 15818c2ecf20Sopenharmony_ci * Return the struct adapter associated with a net_device 15828c2ecf20Sopenharmony_ci */ 15838c2ecf20Sopenharmony_cistatic inline struct adapter *netdev2adap(const struct net_device *dev) 15848c2ecf20Sopenharmony_ci{ 15858c2ecf20Sopenharmony_ci return netdev2pinfo(dev)->adapter; 15868c2ecf20Sopenharmony_ci} 15878c2ecf20Sopenharmony_ci 15888c2ecf20Sopenharmony_ci/* Return a version number to identify the type of adapter. The scheme is: 15898c2ecf20Sopenharmony_ci * - bits 0..9: chip version 15908c2ecf20Sopenharmony_ci * - bits 10..15: chip revision 15918c2ecf20Sopenharmony_ci * - bits 16..23: register dump version 15928c2ecf20Sopenharmony_ci */ 15938c2ecf20Sopenharmony_cistatic inline unsigned int mk_adap_vers(struct adapter *ap) 15948c2ecf20Sopenharmony_ci{ 15958c2ecf20Sopenharmony_ci return CHELSIO_CHIP_VERSION(ap->params.chip) | 15968c2ecf20Sopenharmony_ci (CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16); 15978c2ecf20Sopenharmony_ci} 15988c2ecf20Sopenharmony_ci 15998c2ecf20Sopenharmony_ci/* Return a queue's interrupt hold-off time in us. 0 means no timer. */ 16008c2ecf20Sopenharmony_cistatic inline unsigned int qtimer_val(const struct adapter *adap, 16018c2ecf20Sopenharmony_ci const struct sge_rspq *q) 16028c2ecf20Sopenharmony_ci{ 16038c2ecf20Sopenharmony_ci unsigned int idx = q->intr_params >> 1; 16048c2ecf20Sopenharmony_ci 16058c2ecf20Sopenharmony_ci return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0; 16068c2ecf20Sopenharmony_ci} 16078c2ecf20Sopenharmony_ci 16088c2ecf20Sopenharmony_ci/* driver name used for ethtool_drvinfo */ 16098c2ecf20Sopenharmony_ciextern char cxgb4_driver_name[]; 16108c2ecf20Sopenharmony_ci 16118c2ecf20Sopenharmony_civoid t4_os_portmod_changed(struct adapter *adap, int port_id); 16128c2ecf20Sopenharmony_civoid t4_os_link_changed(struct adapter *adap, int port_id, int link_stat); 16138c2ecf20Sopenharmony_ci 16148c2ecf20Sopenharmony_civoid t4_free_sge_resources(struct adapter *adap); 16158c2ecf20Sopenharmony_civoid t4_free_ofld_rxqs(struct adapter *adap, int n, struct sge_ofld_rxq *q); 16168c2ecf20Sopenharmony_ciirq_handler_t t4_intr_handler(struct adapter *adap); 16178c2ecf20Sopenharmony_cinetdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev); 16188c2ecf20Sopenharmony_ciint cxgb4_selftest_lb_pkt(struct net_device *netdev); 16198c2ecf20Sopenharmony_ciint t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp, 16208c2ecf20Sopenharmony_ci const struct pkt_gl *gl); 16218c2ecf20Sopenharmony_ciint t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb); 16228c2ecf20Sopenharmony_ciint t4_ofld_send(struct adapter *adap, struct sk_buff *skb); 16238c2ecf20Sopenharmony_ciint t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, 16248c2ecf20Sopenharmony_ci struct net_device *dev, int intr_idx, 16258c2ecf20Sopenharmony_ci struct sge_fl *fl, rspq_handler_t hnd, 16268c2ecf20Sopenharmony_ci rspq_flush_handler_t flush_handler, int cong); 16278c2ecf20Sopenharmony_ciint t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq, 16288c2ecf20Sopenharmony_ci struct net_device *dev, struct netdev_queue *netdevq, 16298c2ecf20Sopenharmony_ci unsigned int iqid, u8 dbqt); 16308c2ecf20Sopenharmony_ciint t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq, 16318c2ecf20Sopenharmony_ci struct net_device *dev, unsigned int iqid, 16328c2ecf20Sopenharmony_ci unsigned int cmplqid); 16338c2ecf20Sopenharmony_ciint t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid, 16348c2ecf20Sopenharmony_ci unsigned int cmplqid); 16358c2ecf20Sopenharmony_ciint t4_sge_alloc_uld_txq(struct adapter *adap, struct sge_uld_txq *txq, 16368c2ecf20Sopenharmony_ci struct net_device *dev, unsigned int iqid, 16378c2ecf20Sopenharmony_ci unsigned int uld_type); 16388c2ecf20Sopenharmony_ciint t4_sge_alloc_ethofld_txq(struct adapter *adap, struct sge_eohw_txq *txq, 16398c2ecf20Sopenharmony_ci struct net_device *dev, u32 iqid); 16408c2ecf20Sopenharmony_civoid t4_sge_free_ethofld_txq(struct adapter *adap, struct sge_eohw_txq *txq); 16418c2ecf20Sopenharmony_ciirqreturn_t t4_sge_intr_msix(int irq, void *cookie); 16428c2ecf20Sopenharmony_ciint t4_sge_init(struct adapter *adap); 16438c2ecf20Sopenharmony_civoid t4_sge_start(struct adapter *adap); 16448c2ecf20Sopenharmony_civoid t4_sge_stop(struct adapter *adap); 16458c2ecf20Sopenharmony_ciint t4_sge_eth_txq_egress_update(struct adapter *adap, struct sge_eth_txq *q, 16468c2ecf20Sopenharmony_ci int maxreclaim); 16478c2ecf20Sopenharmony_civoid cxgb4_set_ethtool_ops(struct net_device *netdev); 16488c2ecf20Sopenharmony_ciint cxgb4_write_rss(const struct port_info *pi, const u16 *queues); 16498c2ecf20Sopenharmony_cienum cpl_tx_tnl_lso_type cxgb_encap_offload_supported(struct sk_buff *skb); 16508c2ecf20Sopenharmony_ciextern int dbfifo_int_thresh; 16518c2ecf20Sopenharmony_ci 16528c2ecf20Sopenharmony_ci#define for_each_port(adapter, iter) \ 16538c2ecf20Sopenharmony_ci for (iter = 0; iter < (adapter)->params.nports; ++iter) 16548c2ecf20Sopenharmony_ci 16558c2ecf20Sopenharmony_cistatic inline int is_bypass(struct adapter *adap) 16568c2ecf20Sopenharmony_ci{ 16578c2ecf20Sopenharmony_ci return adap->params.bypass; 16588c2ecf20Sopenharmony_ci} 16598c2ecf20Sopenharmony_ci 16608c2ecf20Sopenharmony_cistatic inline int is_bypass_device(int device) 16618c2ecf20Sopenharmony_ci{ 16628c2ecf20Sopenharmony_ci /* this should be set based upon device capabilities */ 16638c2ecf20Sopenharmony_ci switch (device) { 16648c2ecf20Sopenharmony_ci case 0x440b: 16658c2ecf20Sopenharmony_ci case 0x440c: 16668c2ecf20Sopenharmony_ci return 1; 16678c2ecf20Sopenharmony_ci default: 16688c2ecf20Sopenharmony_ci return 0; 16698c2ecf20Sopenharmony_ci } 16708c2ecf20Sopenharmony_ci} 16718c2ecf20Sopenharmony_ci 16728c2ecf20Sopenharmony_cistatic inline int is_10gbt_device(int device) 16738c2ecf20Sopenharmony_ci{ 16748c2ecf20Sopenharmony_ci /* this should be set based upon device capabilities */ 16758c2ecf20Sopenharmony_ci switch (device) { 16768c2ecf20Sopenharmony_ci case 0x4409: 16778c2ecf20Sopenharmony_ci case 0x4486: 16788c2ecf20Sopenharmony_ci return 1; 16798c2ecf20Sopenharmony_ci 16808c2ecf20Sopenharmony_ci default: 16818c2ecf20Sopenharmony_ci return 0; 16828c2ecf20Sopenharmony_ci } 16838c2ecf20Sopenharmony_ci} 16848c2ecf20Sopenharmony_ci 16858c2ecf20Sopenharmony_cistatic inline unsigned int core_ticks_per_usec(const struct adapter *adap) 16868c2ecf20Sopenharmony_ci{ 16878c2ecf20Sopenharmony_ci return adap->params.vpd.cclk / 1000; 16888c2ecf20Sopenharmony_ci} 16898c2ecf20Sopenharmony_ci 16908c2ecf20Sopenharmony_cistatic inline unsigned int us_to_core_ticks(const struct adapter *adap, 16918c2ecf20Sopenharmony_ci unsigned int us) 16928c2ecf20Sopenharmony_ci{ 16938c2ecf20Sopenharmony_ci return (us * adap->params.vpd.cclk) / 1000; 16948c2ecf20Sopenharmony_ci} 16958c2ecf20Sopenharmony_ci 16968c2ecf20Sopenharmony_cistatic inline unsigned int core_ticks_to_us(const struct adapter *adapter, 16978c2ecf20Sopenharmony_ci unsigned int ticks) 16988c2ecf20Sopenharmony_ci{ 16998c2ecf20Sopenharmony_ci /* add Core Clock / 2 to round ticks to nearest uS */ 17008c2ecf20Sopenharmony_ci return ((ticks * 1000 + adapter->params.vpd.cclk/2) / 17018c2ecf20Sopenharmony_ci adapter->params.vpd.cclk); 17028c2ecf20Sopenharmony_ci} 17038c2ecf20Sopenharmony_ci 17048c2ecf20Sopenharmony_cistatic inline unsigned int dack_ticks_to_usec(const struct adapter *adap, 17058c2ecf20Sopenharmony_ci unsigned int ticks) 17068c2ecf20Sopenharmony_ci{ 17078c2ecf20Sopenharmony_ci return (ticks << adap->params.tp.dack_re) / core_ticks_per_usec(adap); 17088c2ecf20Sopenharmony_ci} 17098c2ecf20Sopenharmony_ci 17108c2ecf20Sopenharmony_civoid t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask, 17118c2ecf20Sopenharmony_ci u32 val); 17128c2ecf20Sopenharmony_ci 17138c2ecf20Sopenharmony_ciint t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd, 17148c2ecf20Sopenharmony_ci int size, void *rpl, bool sleep_ok, int timeout); 17158c2ecf20Sopenharmony_ciint t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size, 17168c2ecf20Sopenharmony_ci void *rpl, bool sleep_ok); 17178c2ecf20Sopenharmony_ci 17188c2ecf20Sopenharmony_cistatic inline int t4_wr_mbox_timeout(struct adapter *adap, int mbox, 17198c2ecf20Sopenharmony_ci const void *cmd, int size, void *rpl, 17208c2ecf20Sopenharmony_ci int timeout) 17218c2ecf20Sopenharmony_ci{ 17228c2ecf20Sopenharmony_ci return t4_wr_mbox_meat_timeout(adap, mbox, cmd, size, rpl, true, 17238c2ecf20Sopenharmony_ci timeout); 17248c2ecf20Sopenharmony_ci} 17258c2ecf20Sopenharmony_ci 17268c2ecf20Sopenharmony_cistatic inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd, 17278c2ecf20Sopenharmony_ci int size, void *rpl) 17288c2ecf20Sopenharmony_ci{ 17298c2ecf20Sopenharmony_ci return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true); 17308c2ecf20Sopenharmony_ci} 17318c2ecf20Sopenharmony_ci 17328c2ecf20Sopenharmony_cistatic inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd, 17338c2ecf20Sopenharmony_ci int size, void *rpl) 17348c2ecf20Sopenharmony_ci{ 17358c2ecf20Sopenharmony_ci return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false); 17368c2ecf20Sopenharmony_ci} 17378c2ecf20Sopenharmony_ci 17388c2ecf20Sopenharmony_ci/** 17398c2ecf20Sopenharmony_ci * hash_mac_addr - return the hash value of a MAC address 17408c2ecf20Sopenharmony_ci * @addr: the 48-bit Ethernet MAC address 17418c2ecf20Sopenharmony_ci * 17428c2ecf20Sopenharmony_ci * Hashes a MAC address according to the hash function used by HW inexact 17438c2ecf20Sopenharmony_ci * (hash) address matching. 17448c2ecf20Sopenharmony_ci */ 17458c2ecf20Sopenharmony_cistatic inline int hash_mac_addr(const u8 *addr) 17468c2ecf20Sopenharmony_ci{ 17478c2ecf20Sopenharmony_ci u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2]; 17488c2ecf20Sopenharmony_ci u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5]; 17498c2ecf20Sopenharmony_ci 17508c2ecf20Sopenharmony_ci a ^= b; 17518c2ecf20Sopenharmony_ci a ^= (a >> 12); 17528c2ecf20Sopenharmony_ci a ^= (a >> 6); 17538c2ecf20Sopenharmony_ci return a & 0x3f; 17548c2ecf20Sopenharmony_ci} 17558c2ecf20Sopenharmony_ci 17568c2ecf20Sopenharmony_ciint cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us, 17578c2ecf20Sopenharmony_ci unsigned int cnt); 17588c2ecf20Sopenharmony_cistatic inline void init_rspq(struct adapter *adap, struct sge_rspq *q, 17598c2ecf20Sopenharmony_ci unsigned int us, unsigned int cnt, 17608c2ecf20Sopenharmony_ci unsigned int size, unsigned int iqe_size) 17618c2ecf20Sopenharmony_ci{ 17628c2ecf20Sopenharmony_ci q->adap = adap; 17638c2ecf20Sopenharmony_ci cxgb4_set_rspq_intr_params(q, us, cnt); 17648c2ecf20Sopenharmony_ci q->iqe_len = iqe_size; 17658c2ecf20Sopenharmony_ci q->size = size; 17668c2ecf20Sopenharmony_ci} 17678c2ecf20Sopenharmony_ci 17688c2ecf20Sopenharmony_ci/** 17698c2ecf20Sopenharmony_ci * t4_is_inserted_mod_type - is a plugged in Firmware Module Type 17708c2ecf20Sopenharmony_ci * @fw_mod_type: the Firmware Mofule Type 17718c2ecf20Sopenharmony_ci * 17728c2ecf20Sopenharmony_ci * Return whether the Firmware Module Type represents a real Transceiver 17738c2ecf20Sopenharmony_ci * Module/Cable Module Type which has been inserted. 17748c2ecf20Sopenharmony_ci */ 17758c2ecf20Sopenharmony_cistatic inline bool t4_is_inserted_mod_type(unsigned int fw_mod_type) 17768c2ecf20Sopenharmony_ci{ 17778c2ecf20Sopenharmony_ci return (fw_mod_type != FW_PORT_MOD_TYPE_NONE && 17788c2ecf20Sopenharmony_ci fw_mod_type != FW_PORT_MOD_TYPE_NOTSUPPORTED && 17798c2ecf20Sopenharmony_ci fw_mod_type != FW_PORT_MOD_TYPE_UNKNOWN && 17808c2ecf20Sopenharmony_ci fw_mod_type != FW_PORT_MOD_TYPE_ERROR); 17818c2ecf20Sopenharmony_ci} 17828c2ecf20Sopenharmony_ci 17838c2ecf20Sopenharmony_civoid t4_write_indirect(struct adapter *adap, unsigned int addr_reg, 17848c2ecf20Sopenharmony_ci unsigned int data_reg, const u32 *vals, 17858c2ecf20Sopenharmony_ci unsigned int nregs, unsigned int start_idx); 17868c2ecf20Sopenharmony_civoid t4_read_indirect(struct adapter *adap, unsigned int addr_reg, 17878c2ecf20Sopenharmony_ci unsigned int data_reg, u32 *vals, unsigned int nregs, 17888c2ecf20Sopenharmony_ci unsigned int start_idx); 17898c2ecf20Sopenharmony_civoid t4_hw_pci_read_cfg4(struct adapter *adapter, int reg, u32 *val); 17908c2ecf20Sopenharmony_ci 17918c2ecf20Sopenharmony_cistruct fw_filter_wr; 17928c2ecf20Sopenharmony_ci 17938c2ecf20Sopenharmony_civoid t4_intr_enable(struct adapter *adapter); 17948c2ecf20Sopenharmony_civoid t4_intr_disable(struct adapter *adapter); 17958c2ecf20Sopenharmony_ciint t4_slow_intr_handler(struct adapter *adapter); 17968c2ecf20Sopenharmony_ci 17978c2ecf20Sopenharmony_ciint t4_wait_dev_ready(void __iomem *regs); 17988c2ecf20Sopenharmony_ci 17998c2ecf20Sopenharmony_cifw_port_cap32_t t4_link_acaps(struct adapter *adapter, unsigned int port, 18008c2ecf20Sopenharmony_ci struct link_config *lc); 18018c2ecf20Sopenharmony_ciint t4_link_l1cfg_core(struct adapter *adap, unsigned int mbox, 18028c2ecf20Sopenharmony_ci unsigned int port, struct link_config *lc, 18038c2ecf20Sopenharmony_ci u8 sleep_ok, int timeout); 18048c2ecf20Sopenharmony_ci 18058c2ecf20Sopenharmony_cistatic inline int t4_link_l1cfg(struct adapter *adapter, unsigned int mbox, 18068c2ecf20Sopenharmony_ci unsigned int port, struct link_config *lc) 18078c2ecf20Sopenharmony_ci{ 18088c2ecf20Sopenharmony_ci return t4_link_l1cfg_core(adapter, mbox, port, lc, 18098c2ecf20Sopenharmony_ci true, FW_CMD_MAX_TIMEOUT); 18108c2ecf20Sopenharmony_ci} 18118c2ecf20Sopenharmony_ci 18128c2ecf20Sopenharmony_cistatic inline int t4_link_l1cfg_ns(struct adapter *adapter, unsigned int mbox, 18138c2ecf20Sopenharmony_ci unsigned int port, struct link_config *lc) 18148c2ecf20Sopenharmony_ci{ 18158c2ecf20Sopenharmony_ci return t4_link_l1cfg_core(adapter, mbox, port, lc, 18168c2ecf20Sopenharmony_ci false, FW_CMD_MAX_TIMEOUT); 18178c2ecf20Sopenharmony_ci} 18188c2ecf20Sopenharmony_ci 18198c2ecf20Sopenharmony_ciint t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port); 18208c2ecf20Sopenharmony_ci 18218c2ecf20Sopenharmony_ciu32 t4_read_pcie_cfg4(struct adapter *adap, int reg); 18228c2ecf20Sopenharmony_ciu32 t4_get_util_window(struct adapter *adap); 18238c2ecf20Sopenharmony_civoid t4_setup_memwin(struct adapter *adap, u32 memwin_base, u32 window); 18248c2ecf20Sopenharmony_ci 18258c2ecf20Sopenharmony_ciint t4_memory_rw_init(struct adapter *adap, int win, int mtype, u32 *mem_off, 18268c2ecf20Sopenharmony_ci u32 *mem_base, u32 *mem_aperture); 18278c2ecf20Sopenharmony_civoid t4_memory_update_win(struct adapter *adap, int win, u32 addr); 18288c2ecf20Sopenharmony_civoid t4_memory_rw_residual(struct adapter *adap, u32 off, u32 addr, u8 *buf, 18298c2ecf20Sopenharmony_ci int dir); 18308c2ecf20Sopenharmony_ci#define T4_MEMORY_WRITE 0 18318c2ecf20Sopenharmony_ci#define T4_MEMORY_READ 1 18328c2ecf20Sopenharmony_ciint t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len, 18338c2ecf20Sopenharmony_ci void *buf, int dir); 18348c2ecf20Sopenharmony_cistatic inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr, 18358c2ecf20Sopenharmony_ci u32 len, __be32 *buf) 18368c2ecf20Sopenharmony_ci{ 18378c2ecf20Sopenharmony_ci return t4_memory_rw(adap, 0, mtype, addr, len, buf, 0); 18388c2ecf20Sopenharmony_ci} 18398c2ecf20Sopenharmony_ci 18408c2ecf20Sopenharmony_ciunsigned int t4_get_regs_len(struct adapter *adapter); 18418c2ecf20Sopenharmony_civoid t4_get_regs(struct adapter *adap, void *buf, size_t buf_size); 18428c2ecf20Sopenharmony_ci 18438c2ecf20Sopenharmony_ciint t4_eeprom_ptov(unsigned int phys_addr, unsigned int fn, unsigned int sz); 18448c2ecf20Sopenharmony_ciint t4_seeprom_wp(struct adapter *adapter, bool enable); 18458c2ecf20Sopenharmony_ciint t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p); 18468c2ecf20Sopenharmony_ciint t4_get_vpd_params(struct adapter *adapter, struct vpd_params *p); 18478c2ecf20Sopenharmony_ciint t4_get_pfres(struct adapter *adapter); 18488c2ecf20Sopenharmony_ciint t4_read_flash(struct adapter *adapter, unsigned int addr, 18498c2ecf20Sopenharmony_ci unsigned int nwords, u32 *data, int byte_oriented); 18508c2ecf20Sopenharmony_ciint t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size); 18518c2ecf20Sopenharmony_ciint t4_load_phy_fw(struct adapter *adap, int win, 18528c2ecf20Sopenharmony_ci int (*phy_fw_version)(const u8 *, size_t), 18538c2ecf20Sopenharmony_ci const u8 *phy_fw_data, size_t phy_fw_size); 18548c2ecf20Sopenharmony_ciint t4_phy_fw_ver(struct adapter *adap, int *phy_fw_ver); 18558c2ecf20Sopenharmony_ciint t4_fwcache(struct adapter *adap, enum fw_params_param_dev_fwcache op); 18568c2ecf20Sopenharmony_ciint t4_fw_upgrade(struct adapter *adap, unsigned int mbox, 18578c2ecf20Sopenharmony_ci const u8 *fw_data, unsigned int size, int force); 18588c2ecf20Sopenharmony_ciint t4_fl_pkt_align(struct adapter *adap); 18598c2ecf20Sopenharmony_ciunsigned int t4_flash_cfg_addr(struct adapter *adapter); 18608c2ecf20Sopenharmony_ciint t4_check_fw_version(struct adapter *adap); 18618c2ecf20Sopenharmony_ciint t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size); 18628c2ecf20Sopenharmony_ciint t4_get_fw_version(struct adapter *adapter, u32 *vers); 18638c2ecf20Sopenharmony_ciint t4_get_bs_version(struct adapter *adapter, u32 *vers); 18648c2ecf20Sopenharmony_ciint t4_get_tp_version(struct adapter *adapter, u32 *vers); 18658c2ecf20Sopenharmony_ciint t4_get_exprom_version(struct adapter *adapter, u32 *vers); 18668c2ecf20Sopenharmony_ciint t4_get_scfg_version(struct adapter *adapter, u32 *vers); 18678c2ecf20Sopenharmony_ciint t4_get_vpd_version(struct adapter *adapter, u32 *vers); 18688c2ecf20Sopenharmony_ciint t4_get_version_info(struct adapter *adapter); 18698c2ecf20Sopenharmony_civoid t4_dump_version_info(struct adapter *adapter); 18708c2ecf20Sopenharmony_ciint t4_prep_fw(struct adapter *adap, struct fw_info *fw_info, 18718c2ecf20Sopenharmony_ci const u8 *fw_data, unsigned int fw_size, 18728c2ecf20Sopenharmony_ci struct fw_hdr *card_fw, enum dev_state state, int *reset); 18738c2ecf20Sopenharmony_ciint t4_prep_adapter(struct adapter *adapter); 18748c2ecf20Sopenharmony_ciint t4_shutdown_adapter(struct adapter *adapter); 18758c2ecf20Sopenharmony_ci 18768c2ecf20Sopenharmony_cienum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS }; 18778c2ecf20Sopenharmony_ciint t4_bar2_sge_qregs(struct adapter *adapter, 18788c2ecf20Sopenharmony_ci unsigned int qid, 18798c2ecf20Sopenharmony_ci enum t4_bar2_qtype qtype, 18808c2ecf20Sopenharmony_ci int user, 18818c2ecf20Sopenharmony_ci u64 *pbar2_qoffset, 18828c2ecf20Sopenharmony_ci unsigned int *pbar2_qid); 18838c2ecf20Sopenharmony_ci 18848c2ecf20Sopenharmony_ciunsigned int qtimer_val(const struct adapter *adap, 18858c2ecf20Sopenharmony_ci const struct sge_rspq *q); 18868c2ecf20Sopenharmony_ci 18878c2ecf20Sopenharmony_ciint t4_init_devlog_params(struct adapter *adapter); 18888c2ecf20Sopenharmony_ciint t4_init_sge_params(struct adapter *adapter); 18898c2ecf20Sopenharmony_ciint t4_init_tp_params(struct adapter *adap, bool sleep_ok); 18908c2ecf20Sopenharmony_ciint t4_filter_field_shift(const struct adapter *adap, int filter_sel); 18918c2ecf20Sopenharmony_ciint t4_init_rss_mode(struct adapter *adap, int mbox); 18928c2ecf20Sopenharmony_ciint t4_init_portinfo(struct port_info *pi, int mbox, 18938c2ecf20Sopenharmony_ci int port, int pf, int vf, u8 mac[]); 18948c2ecf20Sopenharmony_ciint t4_port_init(struct adapter *adap, int mbox, int pf, int vf); 18958c2ecf20Sopenharmony_ciint t4_init_port_mirror(struct port_info *pi, u8 mbox, u8 port, u8 pf, u8 vf, 18968c2ecf20Sopenharmony_ci u16 *mirror_viid); 18978c2ecf20Sopenharmony_civoid t4_fatal_err(struct adapter *adapter); 18988c2ecf20Sopenharmony_ciunsigned int t4_chip_rss_size(struct adapter *adapter); 18998c2ecf20Sopenharmony_ciint t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid, 19008c2ecf20Sopenharmony_ci int start, int n, const u16 *rspq, unsigned int nrspq); 19018c2ecf20Sopenharmony_ciint t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode, 19028c2ecf20Sopenharmony_ci unsigned int flags); 19038c2ecf20Sopenharmony_ciint t4_config_vi_rss(struct adapter *adapter, int mbox, unsigned int viid, 19048c2ecf20Sopenharmony_ci unsigned int flags, unsigned int defq); 19058c2ecf20Sopenharmony_ciint t4_read_rss(struct adapter *adapter, u16 *entries); 19068c2ecf20Sopenharmony_civoid t4_read_rss_key(struct adapter *adapter, u32 *key, bool sleep_ok); 19078c2ecf20Sopenharmony_civoid t4_write_rss_key(struct adapter *adap, const u32 *key, int idx, 19088c2ecf20Sopenharmony_ci bool sleep_ok); 19098c2ecf20Sopenharmony_civoid t4_read_rss_pf_config(struct adapter *adapter, unsigned int index, 19108c2ecf20Sopenharmony_ci u32 *valp, bool sleep_ok); 19118c2ecf20Sopenharmony_civoid t4_read_rss_vf_config(struct adapter *adapter, unsigned int index, 19128c2ecf20Sopenharmony_ci u32 *vfl, u32 *vfh, bool sleep_ok); 19138c2ecf20Sopenharmony_ciu32 t4_read_rss_pf_map(struct adapter *adapter, bool sleep_ok); 19148c2ecf20Sopenharmony_ciu32 t4_read_rss_pf_mask(struct adapter *adapter, bool sleep_ok); 19158c2ecf20Sopenharmony_ci 19168c2ecf20Sopenharmony_ciunsigned int t4_get_mps_bg_map(struct adapter *adapter, int pidx); 19178c2ecf20Sopenharmony_ciunsigned int t4_get_tp_ch_map(struct adapter *adapter, int pidx); 19188c2ecf20Sopenharmony_civoid t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]); 19198c2ecf20Sopenharmony_civoid t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]); 19208c2ecf20Sopenharmony_ciint t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data, 19218c2ecf20Sopenharmony_ci size_t n); 19228c2ecf20Sopenharmony_ciint t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data, 19238c2ecf20Sopenharmony_ci size_t n); 19248c2ecf20Sopenharmony_ciint t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n, 19258c2ecf20Sopenharmony_ci unsigned int *valp); 19268c2ecf20Sopenharmony_ciint t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n, 19278c2ecf20Sopenharmony_ci const unsigned int *valp); 19288c2ecf20Sopenharmony_ciint t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr); 19298c2ecf20Sopenharmony_civoid t4_cim_read_pif_la(struct adapter *adap, u32 *pif_req, u32 *pif_rsp, 19308c2ecf20Sopenharmony_ci unsigned int *pif_req_wrptr, 19318c2ecf20Sopenharmony_ci unsigned int *pif_rsp_wrptr); 19328c2ecf20Sopenharmony_civoid t4_cim_read_ma_la(struct adapter *adap, u32 *ma_req, u32 *ma_rsp); 19338c2ecf20Sopenharmony_civoid t4_read_cimq_cfg(struct adapter *adap, u16 *base, u16 *size, u16 *thres); 19348c2ecf20Sopenharmony_ciconst char *t4_get_port_type_description(enum fw_port_type port_type); 19358c2ecf20Sopenharmony_civoid t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p); 19368c2ecf20Sopenharmony_civoid t4_get_port_stats_offset(struct adapter *adap, int idx, 19378c2ecf20Sopenharmony_ci struct port_stats *stats, 19388c2ecf20Sopenharmony_ci struct port_stats *offset); 19398c2ecf20Sopenharmony_civoid t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p); 19408c2ecf20Sopenharmony_civoid t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log); 19418c2ecf20Sopenharmony_civoid t4_read_cong_tbl(struct adapter *adap, u16 incr[NMTUS][NCCTRL_WIN]); 19428c2ecf20Sopenharmony_civoid t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr, 19438c2ecf20Sopenharmony_ci unsigned int mask, unsigned int val); 19448c2ecf20Sopenharmony_civoid t4_tp_read_la(struct adapter *adap, u64 *la_buf, unsigned int *wrptr); 19458c2ecf20Sopenharmony_civoid t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st, 19468c2ecf20Sopenharmony_ci bool sleep_ok); 19478c2ecf20Sopenharmony_civoid t4_tp_get_cpl_stats(struct adapter *adap, struct tp_cpl_stats *st, 19488c2ecf20Sopenharmony_ci bool sleep_ok); 19498c2ecf20Sopenharmony_civoid t4_tp_get_rdma_stats(struct adapter *adap, struct tp_rdma_stats *st, 19508c2ecf20Sopenharmony_ci bool sleep_ok); 19518c2ecf20Sopenharmony_civoid t4_get_usm_stats(struct adapter *adap, struct tp_usm_stats *st, 19528c2ecf20Sopenharmony_ci bool sleep_ok); 19538c2ecf20Sopenharmony_civoid t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4, 19548c2ecf20Sopenharmony_ci struct tp_tcp_stats *v6, bool sleep_ok); 19558c2ecf20Sopenharmony_civoid t4_get_fcoe_stats(struct adapter *adap, unsigned int idx, 19568c2ecf20Sopenharmony_ci struct tp_fcoe_stats *st, bool sleep_ok); 19578c2ecf20Sopenharmony_civoid t4_load_mtus(struct adapter *adap, const unsigned short *mtus, 19588c2ecf20Sopenharmony_ci const unsigned short *alpha, const unsigned short *beta); 19598c2ecf20Sopenharmony_ci 19608c2ecf20Sopenharmony_civoid t4_ulprx_read_la(struct adapter *adap, u32 *la_buf); 19618c2ecf20Sopenharmony_ci 19628c2ecf20Sopenharmony_civoid t4_get_chan_txrate(struct adapter *adap, u64 *nic_rate, u64 *ofld_rate); 19638c2ecf20Sopenharmony_civoid t4_mk_filtdelwr(unsigned int ftid, struct fw_filter_wr *wr, int qid); 19648c2ecf20Sopenharmony_ci 19658c2ecf20Sopenharmony_civoid t4_wol_magic_enable(struct adapter *adap, unsigned int port, 19668c2ecf20Sopenharmony_ci const u8 *addr); 19678c2ecf20Sopenharmony_ciint t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map, 19688c2ecf20Sopenharmony_ci u64 mask0, u64 mask1, unsigned int crc, bool enable); 19698c2ecf20Sopenharmony_ci 19708c2ecf20Sopenharmony_ciint t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox, 19718c2ecf20Sopenharmony_ci enum dev_master master, enum dev_state *state); 19728c2ecf20Sopenharmony_ciint t4_fw_bye(struct adapter *adap, unsigned int mbox); 19738c2ecf20Sopenharmony_ciint t4_early_init(struct adapter *adap, unsigned int mbox); 19748c2ecf20Sopenharmony_ciint t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset); 19758c2ecf20Sopenharmony_ciint t4_fixup_host_params(struct adapter *adap, unsigned int page_size, 19768c2ecf20Sopenharmony_ci unsigned int cache_line_size); 19778c2ecf20Sopenharmony_ciint t4_fw_initialize(struct adapter *adap, unsigned int mbox); 19788c2ecf20Sopenharmony_ciint t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf, 19798c2ecf20Sopenharmony_ci unsigned int vf, unsigned int nparams, const u32 *params, 19808c2ecf20Sopenharmony_ci u32 *val); 19818c2ecf20Sopenharmony_ciint t4_query_params_ns(struct adapter *adap, unsigned int mbox, unsigned int pf, 19828c2ecf20Sopenharmony_ci unsigned int vf, unsigned int nparams, const u32 *params, 19838c2ecf20Sopenharmony_ci u32 *val); 19848c2ecf20Sopenharmony_ciint t4_query_params_rw(struct adapter *adap, unsigned int mbox, unsigned int pf, 19858c2ecf20Sopenharmony_ci unsigned int vf, unsigned int nparams, const u32 *params, 19868c2ecf20Sopenharmony_ci u32 *val, int rw, bool sleep_ok); 19878c2ecf20Sopenharmony_ciint t4_set_params_timeout(struct adapter *adap, unsigned int mbox, 19888c2ecf20Sopenharmony_ci unsigned int pf, unsigned int vf, 19898c2ecf20Sopenharmony_ci unsigned int nparams, const u32 *params, 19908c2ecf20Sopenharmony_ci const u32 *val, int timeout); 19918c2ecf20Sopenharmony_ciint t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf, 19928c2ecf20Sopenharmony_ci unsigned int vf, unsigned int nparams, const u32 *params, 19938c2ecf20Sopenharmony_ci const u32 *val); 19948c2ecf20Sopenharmony_ciint t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf, 19958c2ecf20Sopenharmony_ci unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl, 19968c2ecf20Sopenharmony_ci unsigned int rxqi, unsigned int rxq, unsigned int tc, 19978c2ecf20Sopenharmony_ci unsigned int vi, unsigned int cmask, unsigned int pmask, 19988c2ecf20Sopenharmony_ci unsigned int nexact, unsigned int rcaps, unsigned int wxcaps); 19998c2ecf20Sopenharmony_ciint t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port, 20008c2ecf20Sopenharmony_ci unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac, 20018c2ecf20Sopenharmony_ci unsigned int *rss_size, u8 *vivld, u8 *vin); 20028c2ecf20Sopenharmony_ciint t4_free_vi(struct adapter *adap, unsigned int mbox, 20038c2ecf20Sopenharmony_ci unsigned int pf, unsigned int vf, 20048c2ecf20Sopenharmony_ci unsigned int viid); 20058c2ecf20Sopenharmony_ciint t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid, 20068c2ecf20Sopenharmony_ci unsigned int viid_mirror, int mtu, int promisc, int all_multi, 20078c2ecf20Sopenharmony_ci int bcast, int vlanex, bool sleep_ok); 20088c2ecf20Sopenharmony_ciint t4_free_raw_mac_filt(struct adapter *adap, unsigned int viid, 20098c2ecf20Sopenharmony_ci const u8 *addr, const u8 *mask, unsigned int idx, 20108c2ecf20Sopenharmony_ci u8 lookup_type, u8 port_id, bool sleep_ok); 20118c2ecf20Sopenharmony_ciint t4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, int idx, 20128c2ecf20Sopenharmony_ci bool sleep_ok); 20138c2ecf20Sopenharmony_ciint t4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid, 20148c2ecf20Sopenharmony_ci const u8 *addr, const u8 *mask, unsigned int vni, 20158c2ecf20Sopenharmony_ci unsigned int vni_mask, u8 dip_hit, u8 lookup_type, 20168c2ecf20Sopenharmony_ci bool sleep_ok); 20178c2ecf20Sopenharmony_ciint t4_alloc_raw_mac_filt(struct adapter *adap, unsigned int viid, 20188c2ecf20Sopenharmony_ci const u8 *addr, const u8 *mask, unsigned int idx, 20198c2ecf20Sopenharmony_ci u8 lookup_type, u8 port_id, bool sleep_ok); 20208c2ecf20Sopenharmony_ciint t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox, 20218c2ecf20Sopenharmony_ci unsigned int viid, bool free, unsigned int naddr, 20228c2ecf20Sopenharmony_ci const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok); 20238c2ecf20Sopenharmony_ciint t4_free_mac_filt(struct adapter *adap, unsigned int mbox, 20248c2ecf20Sopenharmony_ci unsigned int viid, unsigned int naddr, 20258c2ecf20Sopenharmony_ci const u8 **addr, bool sleep_ok); 20268c2ecf20Sopenharmony_ciint t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid, 20278c2ecf20Sopenharmony_ci int idx, const u8 *addr, bool persist, u8 *smt_idx); 20288c2ecf20Sopenharmony_ciint t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid, 20298c2ecf20Sopenharmony_ci bool ucast, u64 vec, bool sleep_ok); 20308c2ecf20Sopenharmony_ciint t4_enable_vi_params(struct adapter *adap, unsigned int mbox, 20318c2ecf20Sopenharmony_ci unsigned int viid, bool rx_en, bool tx_en, bool dcb_en); 20328c2ecf20Sopenharmony_ciint t4_enable_pi_params(struct adapter *adap, unsigned int mbox, 20338c2ecf20Sopenharmony_ci struct port_info *pi, 20348c2ecf20Sopenharmony_ci bool rx_en, bool tx_en, bool dcb_en); 20358c2ecf20Sopenharmony_ciint t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid, 20368c2ecf20Sopenharmony_ci bool rx_en, bool tx_en); 20378c2ecf20Sopenharmony_ciint t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid, 20388c2ecf20Sopenharmony_ci unsigned int nblinks); 20398c2ecf20Sopenharmony_ciint t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr, 20408c2ecf20Sopenharmony_ci unsigned int mmd, unsigned int reg, u16 *valp); 20418c2ecf20Sopenharmony_ciint t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr, 20428c2ecf20Sopenharmony_ci unsigned int mmd, unsigned int reg, u16 val); 20438c2ecf20Sopenharmony_ciint t4_iq_stop(struct adapter *adap, unsigned int mbox, unsigned int pf, 20448c2ecf20Sopenharmony_ci unsigned int vf, unsigned int iqtype, unsigned int iqid, 20458c2ecf20Sopenharmony_ci unsigned int fl0id, unsigned int fl1id); 20468c2ecf20Sopenharmony_ciint t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, 20478c2ecf20Sopenharmony_ci unsigned int vf, unsigned int iqtype, unsigned int iqid, 20488c2ecf20Sopenharmony_ci unsigned int fl0id, unsigned int fl1id); 20498c2ecf20Sopenharmony_ciint t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, 20508c2ecf20Sopenharmony_ci unsigned int vf, unsigned int eqid); 20518c2ecf20Sopenharmony_ciint t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, 20528c2ecf20Sopenharmony_ci unsigned int vf, unsigned int eqid); 20538c2ecf20Sopenharmony_ciint t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf, 20548c2ecf20Sopenharmony_ci unsigned int vf, unsigned int eqid); 20558c2ecf20Sopenharmony_ciint t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox, int ctxt_type); 20568c2ecf20Sopenharmony_ciint t4_read_sge_dbqtimers(struct adapter *adap, unsigned int ndbqtimers, 20578c2ecf20Sopenharmony_ci u16 *dbqtimers); 20588c2ecf20Sopenharmony_civoid t4_handle_get_port_info(struct port_info *pi, const __be64 *rpl); 20598c2ecf20Sopenharmony_ciint t4_update_port_info(struct port_info *pi); 20608c2ecf20Sopenharmony_ciint t4_get_link_params(struct port_info *pi, unsigned int *link_okp, 20618c2ecf20Sopenharmony_ci unsigned int *speedp, unsigned int *mtup); 20628c2ecf20Sopenharmony_ciint t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl); 20638c2ecf20Sopenharmony_civoid t4_db_full(struct adapter *adapter); 20648c2ecf20Sopenharmony_civoid t4_db_dropped(struct adapter *adapter); 20658c2ecf20Sopenharmony_ciint t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp, 20668c2ecf20Sopenharmony_ci int filter_index, int enable); 20678c2ecf20Sopenharmony_civoid t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp, 20688c2ecf20Sopenharmony_ci int filter_index, int *enabled); 20698c2ecf20Sopenharmony_ciint t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, 20708c2ecf20Sopenharmony_ci u32 addr, u32 val); 20718c2ecf20Sopenharmony_civoid t4_read_pace_tbl(struct adapter *adap, unsigned int pace_vals[NTX_SCHED]); 20728c2ecf20Sopenharmony_civoid t4_get_tx_sched(struct adapter *adap, unsigned int sched, 20738c2ecf20Sopenharmony_ci unsigned int *kbps, unsigned int *ipg, bool sleep_ok); 20748c2ecf20Sopenharmony_ciint t4_sge_ctxt_rd(struct adapter *adap, unsigned int mbox, unsigned int cid, 20758c2ecf20Sopenharmony_ci enum ctxt_type ctype, u32 *data); 20768c2ecf20Sopenharmony_ciint t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, 20778c2ecf20Sopenharmony_ci enum ctxt_type ctype, u32 *data); 20788c2ecf20Sopenharmony_ciint t4_sched_params(struct adapter *adapter, u8 type, u8 level, u8 mode, 20798c2ecf20Sopenharmony_ci u8 rateunit, u8 ratemode, u8 channel, u8 class, 20808c2ecf20Sopenharmony_ci u32 minrate, u32 maxrate, u16 weight, u16 pktsize, 20818c2ecf20Sopenharmony_ci u16 burstsize); 20828c2ecf20Sopenharmony_civoid t4_sge_decode_idma_state(struct adapter *adapter, int state); 20838c2ecf20Sopenharmony_civoid t4_idma_monitor_init(struct adapter *adapter, 20848c2ecf20Sopenharmony_ci struct sge_idma_monitor_state *idma); 20858c2ecf20Sopenharmony_civoid t4_idma_monitor(struct adapter *adapter, 20868c2ecf20Sopenharmony_ci struct sge_idma_monitor_state *idma, 20878c2ecf20Sopenharmony_ci int hz, int ticks); 20888c2ecf20Sopenharmony_ciint t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf, 20898c2ecf20Sopenharmony_ci unsigned int naddr, u8 *addr); 20908c2ecf20Sopenharmony_civoid t4_tp_pio_read(struct adapter *adap, u32 *buff, u32 nregs, 20918c2ecf20Sopenharmony_ci u32 start_index, bool sleep_ok); 20928c2ecf20Sopenharmony_civoid t4_tp_tm_pio_read(struct adapter *adap, u32 *buff, u32 nregs, 20938c2ecf20Sopenharmony_ci u32 start_index, bool sleep_ok); 20948c2ecf20Sopenharmony_civoid t4_tp_mib_read(struct adapter *adap, u32 *buff, u32 nregs, 20958c2ecf20Sopenharmony_ci u32 start_index, bool sleep_ok); 20968c2ecf20Sopenharmony_ci 20978c2ecf20Sopenharmony_civoid t4_uld_mem_free(struct adapter *adap); 20988c2ecf20Sopenharmony_ciint t4_uld_mem_alloc(struct adapter *adap); 20998c2ecf20Sopenharmony_civoid t4_uld_clean_up(struct adapter *adap); 21008c2ecf20Sopenharmony_civoid t4_register_netevent_notifier(void); 21018c2ecf20Sopenharmony_ciint t4_i2c_rd(struct adapter *adap, unsigned int mbox, int port, 21028c2ecf20Sopenharmony_ci unsigned int devid, unsigned int offset, 21038c2ecf20Sopenharmony_ci unsigned int len, u8 *buf); 21048c2ecf20Sopenharmony_ciint t4_load_boot(struct adapter *adap, u8 *boot_data, 21058c2ecf20Sopenharmony_ci unsigned int boot_addr, unsigned int size); 21068c2ecf20Sopenharmony_ciint t4_load_bootcfg(struct adapter *adap, 21078c2ecf20Sopenharmony_ci const u8 *cfg_data, unsigned int size); 21088c2ecf20Sopenharmony_civoid free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl); 21098c2ecf20Sopenharmony_civoid free_tx_desc(struct adapter *adap, struct sge_txq *q, 21108c2ecf20Sopenharmony_ci unsigned int n, bool unmap); 21118c2ecf20Sopenharmony_civoid cxgb4_eosw_txq_free_desc(struct adapter *adap, struct sge_eosw_txq *txq, 21128c2ecf20Sopenharmony_ci u32 ndesc); 21138c2ecf20Sopenharmony_ciint cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc); 21148c2ecf20Sopenharmony_civoid cxgb4_ethofld_restart(struct tasklet_struct *t); 21158c2ecf20Sopenharmony_ciint cxgb4_ethofld_rx_handler(struct sge_rspq *q, const __be64 *rsp, 21168c2ecf20Sopenharmony_ci const struct pkt_gl *si); 21178c2ecf20Sopenharmony_civoid free_txq(struct adapter *adap, struct sge_txq *q); 21188c2ecf20Sopenharmony_civoid cxgb4_reclaim_completed_tx(struct adapter *adap, 21198c2ecf20Sopenharmony_ci struct sge_txq *q, bool unmap); 21208c2ecf20Sopenharmony_ciint cxgb4_map_skb(struct device *dev, const struct sk_buff *skb, 21218c2ecf20Sopenharmony_ci dma_addr_t *addr); 21228c2ecf20Sopenharmony_civoid cxgb4_inline_tx_skb(const struct sk_buff *skb, const struct sge_txq *q, 21238c2ecf20Sopenharmony_ci void *pos); 21248c2ecf20Sopenharmony_civoid cxgb4_write_sgl(const struct sk_buff *skb, struct sge_txq *q, 21258c2ecf20Sopenharmony_ci struct ulptx_sgl *sgl, u64 *end, unsigned int start, 21268c2ecf20Sopenharmony_ci const dma_addr_t *addr); 21278c2ecf20Sopenharmony_civoid cxgb4_write_partial_sgl(const struct sk_buff *skb, struct sge_txq *q, 21288c2ecf20Sopenharmony_ci struct ulptx_sgl *sgl, u64 *end, 21298c2ecf20Sopenharmony_ci const dma_addr_t *addr, u32 start, u32 send_len); 21308c2ecf20Sopenharmony_civoid cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int n); 21318c2ecf20Sopenharmony_ciint t4_set_vlan_acl(struct adapter *adap, unsigned int mbox, unsigned int vf, 21328c2ecf20Sopenharmony_ci u16 vlan); 21338c2ecf20Sopenharmony_ciint cxgb4_dcb_enabled(const struct net_device *dev); 21348c2ecf20Sopenharmony_ci 21358c2ecf20Sopenharmony_ciint cxgb4_thermal_init(struct adapter *adap); 21368c2ecf20Sopenharmony_ciint cxgb4_thermal_remove(struct adapter *adap); 21378c2ecf20Sopenharmony_ciint cxgb4_set_msix_aff(struct adapter *adap, unsigned short vec, 21388c2ecf20Sopenharmony_ci cpumask_var_t *aff_mask, int idx); 21398c2ecf20Sopenharmony_civoid cxgb4_clear_msix_aff(unsigned short vec, cpumask_var_t aff_mask); 21408c2ecf20Sopenharmony_ci 21418c2ecf20Sopenharmony_ciint cxgb4_change_mac(struct port_info *pi, unsigned int viid, 21428c2ecf20Sopenharmony_ci int *tcam_idx, const u8 *addr, 21438c2ecf20Sopenharmony_ci bool persistent, u8 *smt_idx); 21448c2ecf20Sopenharmony_ci 21458c2ecf20Sopenharmony_ciint cxgb4_alloc_mac_filt(struct adapter *adap, unsigned int viid, 21468c2ecf20Sopenharmony_ci bool free, unsigned int naddr, 21478c2ecf20Sopenharmony_ci const u8 **addr, u16 *idx, 21488c2ecf20Sopenharmony_ci u64 *hash, bool sleep_ok); 21498c2ecf20Sopenharmony_ciint cxgb4_free_mac_filt(struct adapter *adap, unsigned int viid, 21508c2ecf20Sopenharmony_ci unsigned int naddr, const u8 **addr, bool sleep_ok); 21518c2ecf20Sopenharmony_ciint cxgb4_init_mps_ref_entries(struct adapter *adap); 21528c2ecf20Sopenharmony_civoid cxgb4_free_mps_ref_entries(struct adapter *adap); 21538c2ecf20Sopenharmony_ciint cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid, 21548c2ecf20Sopenharmony_ci const u8 *addr, const u8 *mask, 21558c2ecf20Sopenharmony_ci unsigned int vni, unsigned int vni_mask, 21568c2ecf20Sopenharmony_ci u8 dip_hit, u8 lookup_type, bool sleep_ok); 21578c2ecf20Sopenharmony_ciint cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, 21588c2ecf20Sopenharmony_ci int idx, bool sleep_ok); 21598c2ecf20Sopenharmony_ciint cxgb4_free_raw_mac_filt(struct adapter *adap, 21608c2ecf20Sopenharmony_ci unsigned int viid, 21618c2ecf20Sopenharmony_ci const u8 *addr, 21628c2ecf20Sopenharmony_ci const u8 *mask, 21638c2ecf20Sopenharmony_ci unsigned int idx, 21648c2ecf20Sopenharmony_ci u8 lookup_type, 21658c2ecf20Sopenharmony_ci u8 port_id, 21668c2ecf20Sopenharmony_ci bool sleep_ok); 21678c2ecf20Sopenharmony_ciint cxgb4_alloc_raw_mac_filt(struct adapter *adap, 21688c2ecf20Sopenharmony_ci unsigned int viid, 21698c2ecf20Sopenharmony_ci const u8 *addr, 21708c2ecf20Sopenharmony_ci const u8 *mask, 21718c2ecf20Sopenharmony_ci unsigned int idx, 21728c2ecf20Sopenharmony_ci u8 lookup_type, 21738c2ecf20Sopenharmony_ci u8 port_id, 21748c2ecf20Sopenharmony_ci bool sleep_ok); 21758c2ecf20Sopenharmony_ciint cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid, 21768c2ecf20Sopenharmony_ci int *tcam_idx, const u8 *addr, 21778c2ecf20Sopenharmony_ci bool persistent, u8 *smt_idx); 21788c2ecf20Sopenharmony_ciint cxgb4_get_msix_idx_from_bmap(struct adapter *adap); 21798c2ecf20Sopenharmony_civoid cxgb4_free_msix_idx_in_bmap(struct adapter *adap, u32 msix_idx); 21808c2ecf20Sopenharmony_civoid cxgb4_enable_rx(struct adapter *adap, struct sge_rspq *q); 21818c2ecf20Sopenharmony_civoid cxgb4_quiesce_rx(struct sge_rspq *q); 21828c2ecf20Sopenharmony_ciint cxgb4_port_mirror_alloc(struct net_device *dev); 21838c2ecf20Sopenharmony_civoid cxgb4_port_mirror_free(struct net_device *dev); 21848c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_CHELSIO_TLS_DEVICE) 21858c2ecf20Sopenharmony_ciint cxgb4_set_ktls_feature(struct adapter *adap, bool enable); 21868c2ecf20Sopenharmony_ci#endif 21878c2ecf20Sopenharmony_ci#endif /* __CXGB4_H__ */ 2188