18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is part of the Chelsio FCoE driver for Linux. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2008-2012 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 __CSIO_HW_H__ 368c2ecf20Sopenharmony_ci#define __CSIO_HW_H__ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include <linux/kernel.h> 398c2ecf20Sopenharmony_ci#include <linux/pci.h> 408c2ecf20Sopenharmony_ci#include <linux/device.h> 418c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 428c2ecf20Sopenharmony_ci#include <linux/compiler.h> 438c2ecf20Sopenharmony_ci#include <linux/cdev.h> 448c2ecf20Sopenharmony_ci#include <linux/list.h> 458c2ecf20Sopenharmony_ci#include <linux/mempool.h> 468c2ecf20Sopenharmony_ci#include <linux/io.h> 478c2ecf20Sopenharmony_ci#include <linux/spinlock_types.h> 488c2ecf20Sopenharmony_ci#include <scsi/scsi_device.h> 498c2ecf20Sopenharmony_ci#include <scsi/scsi_transport_fc.h> 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#include "t4_hw.h" 528c2ecf20Sopenharmony_ci#include "csio_hw_chip.h" 538c2ecf20Sopenharmony_ci#include "csio_wr.h" 548c2ecf20Sopenharmony_ci#include "csio_mb.h" 558c2ecf20Sopenharmony_ci#include "csio_scsi.h" 568c2ecf20Sopenharmony_ci#include "csio_defs.h" 578c2ecf20Sopenharmony_ci#include "t4_regs.h" 588c2ecf20Sopenharmony_ci#include "t4_msg.h" 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* 618c2ecf20Sopenharmony_ci * An error value used by host. Should not clash with FW defined return values. 628c2ecf20Sopenharmony_ci */ 638c2ecf20Sopenharmony_ci#define FW_HOSTERROR 255 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define CSIO_HW_NAME "Chelsio FCoE Adapter" 668c2ecf20Sopenharmony_ci#define CSIO_MAX_PFN 8 678c2ecf20Sopenharmony_ci#define CSIO_MAX_PPORTS 4 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define CSIO_MAX_LUN 0xFFFF 708c2ecf20Sopenharmony_ci#define CSIO_MAX_QUEUE 2048 718c2ecf20Sopenharmony_ci#define CSIO_MAX_CMD_PER_LUN 32 728c2ecf20Sopenharmony_ci#define CSIO_MAX_DDP_BUF_SIZE (1024 * 1024) 738c2ecf20Sopenharmony_ci#define CSIO_MAX_SECTOR_SIZE 128 748c2ecf20Sopenharmony_ci#define CSIO_MIN_T6_FW 0x01102D00 /* FW 1.16.45.0 */ 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* Interrupts */ 778c2ecf20Sopenharmony_ci#define CSIO_EXTRA_MSI_IQS 2 /* Extra iqs for INTX/MSI mode 788c2ecf20Sopenharmony_ci * (Forward intr iq + fw iq) */ 798c2ecf20Sopenharmony_ci#define CSIO_EXTRA_VECS 2 /* non-data + FW evt */ 808c2ecf20Sopenharmony_ci#define CSIO_MAX_SCSI_CPU 128 818c2ecf20Sopenharmony_ci#define CSIO_MAX_SCSI_QSETS (CSIO_MAX_SCSI_CPU * CSIO_MAX_PPORTS) 828c2ecf20Sopenharmony_ci#define CSIO_MAX_MSIX_VECS (CSIO_MAX_SCSI_QSETS + CSIO_EXTRA_VECS) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* Queues */ 858c2ecf20Sopenharmony_cienum { 868c2ecf20Sopenharmony_ci CSIO_INTR_WRSIZE = 128, 878c2ecf20Sopenharmony_ci CSIO_INTR_IQSIZE = ((CSIO_MAX_MSIX_VECS + 1) * CSIO_INTR_WRSIZE), 888c2ecf20Sopenharmony_ci CSIO_FWEVT_WRSIZE = 128, 898c2ecf20Sopenharmony_ci CSIO_FWEVT_IQLEN = 128, 908c2ecf20Sopenharmony_ci CSIO_FWEVT_FLBUFS = 64, 918c2ecf20Sopenharmony_ci CSIO_FWEVT_IQSIZE = (CSIO_FWEVT_WRSIZE * CSIO_FWEVT_IQLEN), 928c2ecf20Sopenharmony_ci CSIO_HW_NIQ = 1, 938c2ecf20Sopenharmony_ci CSIO_HW_NFLQ = 1, 948c2ecf20Sopenharmony_ci CSIO_HW_NEQ = 1, 958c2ecf20Sopenharmony_ci CSIO_HW_NINTXQ = 1, 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistruct csio_msix_entries { 998c2ecf20Sopenharmony_ci void *dev_id; /* Priv object associated w/ this msix*/ 1008c2ecf20Sopenharmony_ci char desc[24]; /* Description of this vector */ 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistruct csio_scsi_qset { 1048c2ecf20Sopenharmony_ci int iq_idx; /* Ingress index */ 1058c2ecf20Sopenharmony_ci int eq_idx; /* Egress index */ 1068c2ecf20Sopenharmony_ci uint32_t intr_idx; /* MSIX Vector index */ 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct csio_scsi_cpu_info { 1108c2ecf20Sopenharmony_ci int16_t max_cpus; 1118c2ecf20Sopenharmony_ci}; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciextern int csio_dbg_level; 1148c2ecf20Sopenharmony_ciextern unsigned int csio_port_mask; 1158c2ecf20Sopenharmony_ciextern int csio_msi; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#define CSIO_VENDOR_ID 0x1425 1188c2ecf20Sopenharmony_ci#define CSIO_ASIC_DEVID_PROTO_MASK 0xFF00 1198c2ecf20Sopenharmony_ci#define CSIO_ASIC_DEVID_TYPE_MASK 0x00FF 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci#define CSIO_GLBL_INTR_MASK (CIM_F | MPS_F | PL_F | PCIE_F | MC_F | \ 1228c2ecf20Sopenharmony_ci EDC0_F | EDC1_F | LE_F | TP_F | MA_F | \ 1238c2ecf20Sopenharmony_ci PM_TX_F | PM_RX_F | ULP_RX_F | \ 1248c2ecf20Sopenharmony_ci CPL_SWITCH_F | SGE_F | ULP_TX_F | SF_F) 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci/* 1278c2ecf20Sopenharmony_ci * Hard parameters used to initialize the card in the absence of a 1288c2ecf20Sopenharmony_ci * configuration file. 1298c2ecf20Sopenharmony_ci */ 1308c2ecf20Sopenharmony_cienum { 1318c2ecf20Sopenharmony_ci /* General */ 1328c2ecf20Sopenharmony_ci CSIO_SGE_DBFIFO_INT_THRESH = 10, 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci CSIO_SGE_RX_DMA_OFFSET = 2, 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE1 = 65536, 1378c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE2 = 1536, 1388c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE3 = 9024, 1398c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE4 = 9216, 1408c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE5 = 2048, 1418c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE6 = 128, 1428c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE7 = 8192, 1438c2ecf20Sopenharmony_ci CSIO_SGE_FLBUF_SIZE8 = 16384, 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci CSIO_SGE_TIMER_VAL_0 = 5, 1468c2ecf20Sopenharmony_ci CSIO_SGE_TIMER_VAL_1 = 10, 1478c2ecf20Sopenharmony_ci CSIO_SGE_TIMER_VAL_2 = 20, 1488c2ecf20Sopenharmony_ci CSIO_SGE_TIMER_VAL_3 = 50, 1498c2ecf20Sopenharmony_ci CSIO_SGE_TIMER_VAL_4 = 100, 1508c2ecf20Sopenharmony_ci CSIO_SGE_TIMER_VAL_5 = 200, 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci CSIO_SGE_INT_CNT_VAL_0 = 1, 1538c2ecf20Sopenharmony_ci CSIO_SGE_INT_CNT_VAL_1 = 4, 1548c2ecf20Sopenharmony_ci CSIO_SGE_INT_CNT_VAL_2 = 8, 1558c2ecf20Sopenharmony_ci CSIO_SGE_INT_CNT_VAL_3 = 16, 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci/* Slowpath events */ 1598c2ecf20Sopenharmony_cienum csio_evt { 1608c2ecf20Sopenharmony_ci CSIO_EVT_FW = 0, /* FW event */ 1618c2ecf20Sopenharmony_ci CSIO_EVT_MBX, /* MBX event */ 1628c2ecf20Sopenharmony_ci CSIO_EVT_SCN, /* State change notification */ 1638c2ecf20Sopenharmony_ci CSIO_EVT_DEV_LOSS, /* Device loss event */ 1648c2ecf20Sopenharmony_ci CSIO_EVT_MAX, /* Max supported event */ 1658c2ecf20Sopenharmony_ci}; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#define CSIO_EVT_MSG_SIZE 512 1688c2ecf20Sopenharmony_ci#define CSIO_EVTQ_SIZE 512 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* Event msg */ 1718c2ecf20Sopenharmony_cistruct csio_evt_msg { 1728c2ecf20Sopenharmony_ci struct list_head list; /* evt queue*/ 1738c2ecf20Sopenharmony_ci enum csio_evt type; 1748c2ecf20Sopenharmony_ci uint8_t data[CSIO_EVT_MSG_SIZE]; 1758c2ecf20Sopenharmony_ci}; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_cienum { 1788c2ecf20Sopenharmony_ci SERNUM_LEN = 16, /* Serial # length */ 1798c2ecf20Sopenharmony_ci EC_LEN = 16, /* E/C length */ 1808c2ecf20Sopenharmony_ci ID_LEN = 16, /* ID length */ 1818c2ecf20Sopenharmony_ci}; 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_cienum { 1848c2ecf20Sopenharmony_ci SF_SIZE = SF_SEC_SIZE * 16, /* serial flash size */ 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci/* serial flash and firmware constants */ 1888c2ecf20Sopenharmony_cienum { 1898c2ecf20Sopenharmony_ci SF_ATTEMPTS = 10, /* max retries for SF operations */ 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci /* flash command opcodes */ 1928c2ecf20Sopenharmony_ci SF_PROG_PAGE = 2, /* program page */ 1938c2ecf20Sopenharmony_ci SF_WR_DISABLE = 4, /* disable writes */ 1948c2ecf20Sopenharmony_ci SF_RD_STATUS = 5, /* read status register */ 1958c2ecf20Sopenharmony_ci SF_WR_ENABLE = 6, /* enable writes */ 1968c2ecf20Sopenharmony_ci SF_RD_DATA_FAST = 0xb, /* read flash */ 1978c2ecf20Sopenharmony_ci SF_RD_ID = 0x9f, /* read ID */ 1988c2ecf20Sopenharmony_ci SF_ERASE_SECTOR = 0xd8, /* erase sector */ 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* Management module */ 2028c2ecf20Sopenharmony_cienum { 2038c2ecf20Sopenharmony_ci CSIO_MGMT_EQ_WRSIZE = 512, 2048c2ecf20Sopenharmony_ci CSIO_MGMT_IQ_WRSIZE = 128, 2058c2ecf20Sopenharmony_ci CSIO_MGMT_EQLEN = 64, 2068c2ecf20Sopenharmony_ci CSIO_MGMT_IQLEN = 64, 2078c2ecf20Sopenharmony_ci}; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci#define CSIO_MGMT_EQSIZE (CSIO_MGMT_EQLEN * CSIO_MGMT_EQ_WRSIZE) 2108c2ecf20Sopenharmony_ci#define CSIO_MGMT_IQSIZE (CSIO_MGMT_IQLEN * CSIO_MGMT_IQ_WRSIZE) 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci/* mgmt module stats */ 2138c2ecf20Sopenharmony_cistruct csio_mgmtm_stats { 2148c2ecf20Sopenharmony_ci uint32_t n_abort_req; /* Total abort request */ 2158c2ecf20Sopenharmony_ci uint32_t n_abort_rsp; /* Total abort response */ 2168c2ecf20Sopenharmony_ci uint32_t n_close_req; /* Total close request */ 2178c2ecf20Sopenharmony_ci uint32_t n_close_rsp; /* Total close response */ 2188c2ecf20Sopenharmony_ci uint32_t n_err; /* Total Errors */ 2198c2ecf20Sopenharmony_ci uint32_t n_drop; /* Total request dropped */ 2208c2ecf20Sopenharmony_ci uint32_t n_active; /* Count of active_q */ 2218c2ecf20Sopenharmony_ci uint32_t n_cbfn; /* Count of cbfn_q */ 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci/* MGMT module */ 2258c2ecf20Sopenharmony_cistruct csio_mgmtm { 2268c2ecf20Sopenharmony_ci struct csio_hw *hw; /* Pointer to HW moduel */ 2278c2ecf20Sopenharmony_ci int eq_idx; /* Egress queue index */ 2288c2ecf20Sopenharmony_ci int iq_idx; /* Ingress queue index */ 2298c2ecf20Sopenharmony_ci int msi_vec; /* MSI vector */ 2308c2ecf20Sopenharmony_ci struct list_head active_q; /* Outstanding ELS/CT */ 2318c2ecf20Sopenharmony_ci struct list_head abort_q; /* Outstanding abort req */ 2328c2ecf20Sopenharmony_ci struct list_head cbfn_q; /* Completion queue */ 2338c2ecf20Sopenharmony_ci struct list_head mgmt_req_freelist; /* Free poll of reqs */ 2348c2ecf20Sopenharmony_ci /* ELSCT request freelist*/ 2358c2ecf20Sopenharmony_ci struct timer_list mgmt_timer; /* MGMT timer */ 2368c2ecf20Sopenharmony_ci struct csio_mgmtm_stats stats; /* ELS/CT stats */ 2378c2ecf20Sopenharmony_ci}; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_cistruct csio_adap_desc { 2408c2ecf20Sopenharmony_ci char model_no[16]; 2418c2ecf20Sopenharmony_ci char description[32]; 2428c2ecf20Sopenharmony_ci}; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_cistruct pci_params { 2458c2ecf20Sopenharmony_ci uint16_t vendor_id; 2468c2ecf20Sopenharmony_ci uint16_t device_id; 2478c2ecf20Sopenharmony_ci int vpd_cap_addr; 2488c2ecf20Sopenharmony_ci uint16_t speed; 2498c2ecf20Sopenharmony_ci uint8_t width; 2508c2ecf20Sopenharmony_ci}; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* User configurable hw parameters */ 2538c2ecf20Sopenharmony_cistruct csio_hw_params { 2548c2ecf20Sopenharmony_ci uint32_t sf_size; /* serial flash 2558c2ecf20Sopenharmony_ci * size in bytes 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_ci uint32_t sf_nsec; /* # of flash sectors */ 2588c2ecf20Sopenharmony_ci struct pci_params pci; 2598c2ecf20Sopenharmony_ci uint32_t log_level; /* Module-level for 2608c2ecf20Sopenharmony_ci * debug log. 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cistruct csio_vpd { 2658c2ecf20Sopenharmony_ci uint32_t cclk; 2668c2ecf20Sopenharmony_ci uint8_t ec[EC_LEN + 1]; 2678c2ecf20Sopenharmony_ci uint8_t sn[SERNUM_LEN + 1]; 2688c2ecf20Sopenharmony_ci uint8_t id[ID_LEN + 1]; 2698c2ecf20Sopenharmony_ci}; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci/* Firmware Port Capabilities types. */ 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_citypedef u16 fw_port_cap16_t; /* 16-bit Port Capabilities integral value */ 2748c2ecf20Sopenharmony_citypedef u32 fw_port_cap32_t; /* 32-bit Port Capabilities integral value */ 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_cienum fw_caps { 2778c2ecf20Sopenharmony_ci FW_CAPS_UNKNOWN = 0, /* 0'ed out initial state */ 2788c2ecf20Sopenharmony_ci FW_CAPS16 = 1, /* old Firmware: 16-bit Port Capabilities */ 2798c2ecf20Sopenharmony_ci FW_CAPS32 = 2, /* new Firmware: 32-bit Port Capabilities */ 2808c2ecf20Sopenharmony_ci}; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cienum cc_pause { 2838c2ecf20Sopenharmony_ci PAUSE_RX = 1 << 0, 2848c2ecf20Sopenharmony_ci PAUSE_TX = 1 << 1, 2858c2ecf20Sopenharmony_ci PAUSE_AUTONEG = 1 << 2 2868c2ecf20Sopenharmony_ci}; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_cienum cc_fec { 2898c2ecf20Sopenharmony_ci FEC_AUTO = 1 << 0, /* IEEE 802.3 "automatic" */ 2908c2ecf20Sopenharmony_ci FEC_RS = 1 << 1, /* Reed-Solomon */ 2918c2ecf20Sopenharmony_ci FEC_BASER_RS = 1 << 2 /* BaseR/Reed-Solomon */ 2928c2ecf20Sopenharmony_ci}; 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_cistruct link_config { 2958c2ecf20Sopenharmony_ci fw_port_cap32_t pcaps; /* link capabilities */ 2968c2ecf20Sopenharmony_ci fw_port_cap32_t def_acaps; /* default advertised capabilities */ 2978c2ecf20Sopenharmony_ci fw_port_cap32_t acaps; /* advertised capabilities */ 2988c2ecf20Sopenharmony_ci fw_port_cap32_t lpacaps; /* peer advertised capabilities */ 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci fw_port_cap32_t speed_caps; /* speed(s) user has requested */ 3018c2ecf20Sopenharmony_ci unsigned int speed; /* actual link speed (Mb/s) */ 3028c2ecf20Sopenharmony_ci 3038c2ecf20Sopenharmony_ci enum cc_pause requested_fc; /* flow control user has requested */ 3048c2ecf20Sopenharmony_ci enum cc_pause fc; /* actual link flow control */ 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci enum cc_fec requested_fec; /* Forward Error Correction: */ 3078c2ecf20Sopenharmony_ci enum cc_fec fec; /* requested and actual in use */ 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci unsigned char autoneg; /* autonegotiating? */ 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci unsigned char link_ok; /* link up? */ 3128c2ecf20Sopenharmony_ci unsigned char link_down_rc; /* link down reason */ 3138c2ecf20Sopenharmony_ci}; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16) 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci#define ADVERT_MASK (FW_PORT_CAP32_SPEED_V(FW_PORT_CAP32_SPEED_M) | \ 3188c2ecf20Sopenharmony_ci FW_PORT_CAP32_ANEG) 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci/* Enable or disable autonegotiation. */ 3218c2ecf20Sopenharmony_ci#define AUTONEG_DISABLE 0x00 3228c2ecf20Sopenharmony_ci#define AUTONEG_ENABLE 0x01 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_cistruct csio_pport { 3258c2ecf20Sopenharmony_ci uint16_t pcap; 3268c2ecf20Sopenharmony_ci uint16_t acap; 3278c2ecf20Sopenharmony_ci uint8_t portid; 3288c2ecf20Sopenharmony_ci uint8_t link_status; 3298c2ecf20Sopenharmony_ci uint16_t link_speed; 3308c2ecf20Sopenharmony_ci uint8_t mac[6]; 3318c2ecf20Sopenharmony_ci uint8_t mod_type; 3328c2ecf20Sopenharmony_ci uint8_t rsvd1; 3338c2ecf20Sopenharmony_ci uint8_t rsvd2; 3348c2ecf20Sopenharmony_ci uint8_t rsvd3; 3358c2ecf20Sopenharmony_ci struct link_config link_cfg; 3368c2ecf20Sopenharmony_ci}; 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci/* fcoe resource information */ 3398c2ecf20Sopenharmony_cistruct csio_fcoe_res_info { 3408c2ecf20Sopenharmony_ci uint16_t e_d_tov; 3418c2ecf20Sopenharmony_ci uint16_t r_a_tov_seq; 3428c2ecf20Sopenharmony_ci uint16_t r_a_tov_els; 3438c2ecf20Sopenharmony_ci uint16_t r_r_tov; 3448c2ecf20Sopenharmony_ci uint32_t max_xchgs; 3458c2ecf20Sopenharmony_ci uint32_t max_ssns; 3468c2ecf20Sopenharmony_ci uint32_t used_xchgs; 3478c2ecf20Sopenharmony_ci uint32_t used_ssns; 3488c2ecf20Sopenharmony_ci uint32_t max_fcfs; 3498c2ecf20Sopenharmony_ci uint32_t max_vnps; 3508c2ecf20Sopenharmony_ci uint32_t used_fcfs; 3518c2ecf20Sopenharmony_ci uint32_t used_vnps; 3528c2ecf20Sopenharmony_ci}; 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci/* HW State machine Events */ 3558c2ecf20Sopenharmony_cienum csio_hw_ev { 3568c2ecf20Sopenharmony_ci CSIO_HWE_CFG = (uint32_t)1, /* Starts off the State machine */ 3578c2ecf20Sopenharmony_ci CSIO_HWE_INIT, /* Config done, start Init */ 3588c2ecf20Sopenharmony_ci CSIO_HWE_INIT_DONE, /* Init Mailboxes sent, HW ready */ 3598c2ecf20Sopenharmony_ci CSIO_HWE_FATAL, /* Fatal error during initialization */ 3608c2ecf20Sopenharmony_ci CSIO_HWE_PCIERR_DETECTED,/* PCI error recovery detetced */ 3618c2ecf20Sopenharmony_ci CSIO_HWE_PCIERR_SLOT_RESET, /* Slot reset after PCI recoviery */ 3628c2ecf20Sopenharmony_ci CSIO_HWE_PCIERR_RESUME, /* Resume after PCI error recovery */ 3638c2ecf20Sopenharmony_ci CSIO_HWE_QUIESCED, /* HBA quiesced */ 3648c2ecf20Sopenharmony_ci CSIO_HWE_HBA_RESET, /* HBA reset requested */ 3658c2ecf20Sopenharmony_ci CSIO_HWE_HBA_RESET_DONE, /* HBA reset completed */ 3668c2ecf20Sopenharmony_ci CSIO_HWE_FW_DLOAD, /* FW download requested */ 3678c2ecf20Sopenharmony_ci CSIO_HWE_PCI_REMOVE, /* PCI de-instantiation */ 3688c2ecf20Sopenharmony_ci CSIO_HWE_SUSPEND, /* HW suspend for Online(hot) replacement */ 3698c2ecf20Sopenharmony_ci CSIO_HWE_RESUME, /* HW resume for Online(hot) replacement */ 3708c2ecf20Sopenharmony_ci CSIO_HWE_MAX, /* Max HW event */ 3718c2ecf20Sopenharmony_ci}; 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci/* hw stats */ 3748c2ecf20Sopenharmony_cistruct csio_hw_stats { 3758c2ecf20Sopenharmony_ci uint32_t n_evt_activeq; /* Number of event in active Q */ 3768c2ecf20Sopenharmony_ci uint32_t n_evt_freeq; /* Number of event in free Q */ 3778c2ecf20Sopenharmony_ci uint32_t n_evt_drop; /* Number of event droped */ 3788c2ecf20Sopenharmony_ci uint32_t n_evt_unexp; /* Number of unexpected events */ 3798c2ecf20Sopenharmony_ci uint32_t n_pcich_offline;/* Number of pci channel offline */ 3808c2ecf20Sopenharmony_ci uint32_t n_lnlkup_miss; /* Number of lnode lookup miss */ 3818c2ecf20Sopenharmony_ci uint32_t n_cpl_fw6_msg; /* Number of cpl fw6 message*/ 3828c2ecf20Sopenharmony_ci uint32_t n_cpl_fw6_pld; /* Number of cpl fw6 payload*/ 3838c2ecf20Sopenharmony_ci uint32_t n_cpl_unexp; /* Number of unexpected cpl */ 3848c2ecf20Sopenharmony_ci uint32_t n_mbint_unexp; /* Number of unexpected mbox */ 3858c2ecf20Sopenharmony_ci /* interrupt */ 3868c2ecf20Sopenharmony_ci uint32_t n_plint_unexp; /* Number of unexpected PL */ 3878c2ecf20Sopenharmony_ci /* interrupt */ 3888c2ecf20Sopenharmony_ci uint32_t n_plint_cnt; /* Number of PL interrupt */ 3898c2ecf20Sopenharmony_ci uint32_t n_int_stray; /* Number of stray interrupt */ 3908c2ecf20Sopenharmony_ci uint32_t n_err; /* Number of hw errors */ 3918c2ecf20Sopenharmony_ci uint32_t n_err_fatal; /* Number of fatal errors */ 3928c2ecf20Sopenharmony_ci uint32_t n_err_nomem; /* Number of memory alloc failure */ 3938c2ecf20Sopenharmony_ci uint32_t n_err_io; /* Number of IO failure */ 3948c2ecf20Sopenharmony_ci enum csio_hw_ev n_evt_sm[CSIO_HWE_MAX]; /* Number of sm events */ 3958c2ecf20Sopenharmony_ci uint64_t n_reset_start; /* Start time after the reset */ 3968c2ecf20Sopenharmony_ci uint32_t rsvd1; 3978c2ecf20Sopenharmony_ci}; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci/* Defines for hw->flags */ 4008c2ecf20Sopenharmony_ci#define CSIO_HWF_MASTER 0x00000001 /* This is the Master 4018c2ecf20Sopenharmony_ci * function for the 4028c2ecf20Sopenharmony_ci * card. 4038c2ecf20Sopenharmony_ci */ 4048c2ecf20Sopenharmony_ci#define CSIO_HWF_HW_INTR_ENABLED 0x00000002 /* Are HW Interrupt 4058c2ecf20Sopenharmony_ci * enable bit set? 4068c2ecf20Sopenharmony_ci */ 4078c2ecf20Sopenharmony_ci#define CSIO_HWF_FWEVT_PENDING 0x00000004 /* FW events pending */ 4088c2ecf20Sopenharmony_ci#define CSIO_HWF_Q_MEM_ALLOCED 0x00000008 /* Queues have been 4098c2ecf20Sopenharmony_ci * allocated memory. 4108c2ecf20Sopenharmony_ci */ 4118c2ecf20Sopenharmony_ci#define CSIO_HWF_Q_FW_ALLOCED 0x00000010 /* Queues have been 4128c2ecf20Sopenharmony_ci * allocated in FW. 4138c2ecf20Sopenharmony_ci */ 4148c2ecf20Sopenharmony_ci#define CSIO_HWF_VPD_VALID 0x00000020 /* Valid VPD copied */ 4158c2ecf20Sopenharmony_ci#define CSIO_HWF_DEVID_CACHED 0X00000040 /* PCI vendor & device 4168c2ecf20Sopenharmony_ci * id cached */ 4178c2ecf20Sopenharmony_ci#define CSIO_HWF_FWEVT_STOP 0x00000080 /* Stop processing 4188c2ecf20Sopenharmony_ci * FW events 4198c2ecf20Sopenharmony_ci */ 4208c2ecf20Sopenharmony_ci#define CSIO_HWF_USING_SOFT_PARAMS 0x00000100 /* Using FW config 4218c2ecf20Sopenharmony_ci * params 4228c2ecf20Sopenharmony_ci */ 4238c2ecf20Sopenharmony_ci#define CSIO_HWF_HOST_INTR_ENABLED 0x00000200 /* Are host interrupts 4248c2ecf20Sopenharmony_ci * enabled? 4258c2ecf20Sopenharmony_ci */ 4268c2ecf20Sopenharmony_ci#define CSIO_HWF_ROOT_NO_RELAXED_ORDERING 0x00000400 /* Is PCIe relaxed 4278c2ecf20Sopenharmony_ci * ordering enabled 4288c2ecf20Sopenharmony_ci */ 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci#define csio_is_hw_intr_enabled(__hw) \ 4318c2ecf20Sopenharmony_ci ((__hw)->flags & CSIO_HWF_HW_INTR_ENABLED) 4328c2ecf20Sopenharmony_ci#define csio_is_host_intr_enabled(__hw) \ 4338c2ecf20Sopenharmony_ci ((__hw)->flags & CSIO_HWF_HOST_INTR_ENABLED) 4348c2ecf20Sopenharmony_ci#define csio_is_hw_master(__hw) ((__hw)->flags & CSIO_HWF_MASTER) 4358c2ecf20Sopenharmony_ci#define csio_is_valid_vpd(__hw) ((__hw)->flags & CSIO_HWF_VPD_VALID) 4368c2ecf20Sopenharmony_ci#define csio_is_dev_id_cached(__hw) ((__hw)->flags & CSIO_HWF_DEVID_CACHED) 4378c2ecf20Sopenharmony_ci#define csio_valid_vpd_copied(__hw) ((__hw)->flags |= CSIO_HWF_VPD_VALID) 4388c2ecf20Sopenharmony_ci#define csio_dev_id_cached(__hw) ((__hw)->flags |= CSIO_HWF_DEVID_CACHED) 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci/* Defines for intr_mode */ 4418c2ecf20Sopenharmony_cienum csio_intr_mode { 4428c2ecf20Sopenharmony_ci CSIO_IM_NONE = 0, 4438c2ecf20Sopenharmony_ci CSIO_IM_INTX = 1, 4448c2ecf20Sopenharmony_ci CSIO_IM_MSI = 2, 4458c2ecf20Sopenharmony_ci CSIO_IM_MSIX = 3, 4468c2ecf20Sopenharmony_ci}; 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ci/* Master HW structure: One per function */ 4498c2ecf20Sopenharmony_cistruct csio_hw { 4508c2ecf20Sopenharmony_ci struct csio_sm sm; /* State machine: should 4518c2ecf20Sopenharmony_ci * be the 1st member. 4528c2ecf20Sopenharmony_ci */ 4538c2ecf20Sopenharmony_ci spinlock_t lock; /* Lock for hw */ 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci struct csio_scsim scsim; /* SCSI module*/ 4568c2ecf20Sopenharmony_ci struct csio_wrm wrm; /* Work request module*/ 4578c2ecf20Sopenharmony_ci struct pci_dev *pdev; /* PCI device */ 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci void __iomem *regstart; /* Virtual address of 4608c2ecf20Sopenharmony_ci * register map 4618c2ecf20Sopenharmony_ci */ 4628c2ecf20Sopenharmony_ci /* SCSI queue sets */ 4638c2ecf20Sopenharmony_ci uint32_t num_sqsets; /* Number of SCSI 4648c2ecf20Sopenharmony_ci * queue sets */ 4658c2ecf20Sopenharmony_ci uint32_t num_scsi_msix_cpus; /* Number of CPUs that 4668c2ecf20Sopenharmony_ci * will be used 4678c2ecf20Sopenharmony_ci * for ingress 4688c2ecf20Sopenharmony_ci * processing. 4698c2ecf20Sopenharmony_ci */ 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci struct csio_scsi_qset sqset[CSIO_MAX_PPORTS][CSIO_MAX_SCSI_CPU]; 4728c2ecf20Sopenharmony_ci struct csio_scsi_cpu_info scsi_cpu_info[CSIO_MAX_PPORTS]; 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci uint32_t evtflag; /* Event flag */ 4758c2ecf20Sopenharmony_ci uint32_t flags; /* HW flags */ 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci struct csio_mgmtm mgmtm; /* management module */ 4788c2ecf20Sopenharmony_ci struct csio_mbm mbm; /* Mailbox module */ 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci /* Lnodes */ 4818c2ecf20Sopenharmony_ci uint32_t num_lns; /* Number of lnodes */ 4828c2ecf20Sopenharmony_ci struct csio_lnode *rln; /* Root lnode */ 4838c2ecf20Sopenharmony_ci struct list_head sln_head; /* Sibling node list 4848c2ecf20Sopenharmony_ci * list 4858c2ecf20Sopenharmony_ci */ 4868c2ecf20Sopenharmony_ci int intr_iq_idx; /* Forward interrupt 4878c2ecf20Sopenharmony_ci * queue. 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_ci int fwevt_iq_idx; /* FW evt queue */ 4908c2ecf20Sopenharmony_ci struct work_struct evtq_work; /* Worker thread for 4918c2ecf20Sopenharmony_ci * HW events. 4928c2ecf20Sopenharmony_ci */ 4938c2ecf20Sopenharmony_ci struct list_head evt_free_q; /* freelist of evt 4948c2ecf20Sopenharmony_ci * elements 4958c2ecf20Sopenharmony_ci */ 4968c2ecf20Sopenharmony_ci struct list_head evt_active_q; /* active evt queue*/ 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci /* board related info */ 4998c2ecf20Sopenharmony_ci char name[32]; 5008c2ecf20Sopenharmony_ci char hw_ver[16]; 5018c2ecf20Sopenharmony_ci char model_desc[32]; 5028c2ecf20Sopenharmony_ci char drv_version[32]; 5038c2ecf20Sopenharmony_ci char fwrev_str[32]; 5048c2ecf20Sopenharmony_ci uint32_t optrom_ver; 5058c2ecf20Sopenharmony_ci uint32_t fwrev; 5068c2ecf20Sopenharmony_ci uint32_t tp_vers; 5078c2ecf20Sopenharmony_ci char chip_ver; 5088c2ecf20Sopenharmony_ci uint16_t chip_id; /* Tells T4/T5 chip */ 5098c2ecf20Sopenharmony_ci enum csio_dev_state fw_state; 5108c2ecf20Sopenharmony_ci struct csio_vpd vpd; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci uint8_t pfn; /* Physical Function 5138c2ecf20Sopenharmony_ci * number 5148c2ecf20Sopenharmony_ci */ 5158c2ecf20Sopenharmony_ci uint32_t port_vec; /* Port vector */ 5168c2ecf20Sopenharmony_ci uint8_t num_pports; /* Number of physical 5178c2ecf20Sopenharmony_ci * ports. 5188c2ecf20Sopenharmony_ci */ 5198c2ecf20Sopenharmony_ci uint8_t rst_retries; /* Reset retries */ 5208c2ecf20Sopenharmony_ci uint8_t cur_evt; /* current s/m evt */ 5218c2ecf20Sopenharmony_ci uint8_t prev_evt; /* Previous s/m evt */ 5228c2ecf20Sopenharmony_ci uint32_t dev_num; /* device number */ 5238c2ecf20Sopenharmony_ci struct csio_pport pport[CSIO_MAX_PPORTS]; /* Ports (XGMACs) */ 5248c2ecf20Sopenharmony_ci struct csio_hw_params params; /* Hw parameters */ 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci struct dma_pool *scsi_dma_pool; /* DMA pool for SCSI */ 5278c2ecf20Sopenharmony_ci mempool_t *mb_mempool; /* Mailbox memory pool*/ 5288c2ecf20Sopenharmony_ci mempool_t *rnode_mempool; /* rnode memory pool */ 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci /* Interrupt */ 5318c2ecf20Sopenharmony_ci enum csio_intr_mode intr_mode; /* INTx, MSI, MSIX */ 5328c2ecf20Sopenharmony_ci uint32_t fwevt_intr_idx; /* FW evt MSIX/interrupt 5338c2ecf20Sopenharmony_ci * index 5348c2ecf20Sopenharmony_ci */ 5358c2ecf20Sopenharmony_ci uint32_t nondata_intr_idx; /* nondata MSIX/intr 5368c2ecf20Sopenharmony_ci * idx 5378c2ecf20Sopenharmony_ci */ 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci uint8_t cfg_neq; /* FW configured no of 5408c2ecf20Sopenharmony_ci * egress queues 5418c2ecf20Sopenharmony_ci */ 5428c2ecf20Sopenharmony_ci uint8_t cfg_niq; /* FW configured no of 5438c2ecf20Sopenharmony_ci * iq queues. 5448c2ecf20Sopenharmony_ci */ 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_ci struct csio_fcoe_res_info fres_info; /* Fcoe resource info */ 5478c2ecf20Sopenharmony_ci struct csio_hw_chip_ops *chip_ops; /* T4/T5 Chip specific 5488c2ecf20Sopenharmony_ci * Operations 5498c2ecf20Sopenharmony_ci */ 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci /* MSIX vectors */ 5528c2ecf20Sopenharmony_ci struct csio_msix_entries msix_entries[CSIO_MAX_MSIX_VECS]; 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci struct dentry *debugfs_root; /* Debug FS */ 5558c2ecf20Sopenharmony_ci struct csio_hw_stats stats; /* Hw statistics */ 5568c2ecf20Sopenharmony_ci}; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci/* Register access macros */ 5598c2ecf20Sopenharmony_ci#define csio_reg(_b, _r) ((_b) + (_r)) 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci#define csio_rd_reg8(_h, _r) readb(csio_reg((_h)->regstart, (_r))) 5628c2ecf20Sopenharmony_ci#define csio_rd_reg16(_h, _r) readw(csio_reg((_h)->regstart, (_r))) 5638c2ecf20Sopenharmony_ci#define csio_rd_reg32(_h, _r) readl(csio_reg((_h)->regstart, (_r))) 5648c2ecf20Sopenharmony_ci#define csio_rd_reg64(_h, _r) readq(csio_reg((_h)->regstart, (_r))) 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci#define csio_wr_reg8(_h, _v, _r) writeb((_v), \ 5678c2ecf20Sopenharmony_ci csio_reg((_h)->regstart, (_r))) 5688c2ecf20Sopenharmony_ci#define csio_wr_reg16(_h, _v, _r) writew((_v), \ 5698c2ecf20Sopenharmony_ci csio_reg((_h)->regstart, (_r))) 5708c2ecf20Sopenharmony_ci#define csio_wr_reg32(_h, _v, _r) writel((_v), \ 5718c2ecf20Sopenharmony_ci csio_reg((_h)->regstart, (_r))) 5728c2ecf20Sopenharmony_ci#define csio_wr_reg64(_h, _v, _r) writeq((_v), \ 5738c2ecf20Sopenharmony_ci csio_reg((_h)->regstart, (_r))) 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_civoid csio_set_reg_field(struct csio_hw *, uint32_t, uint32_t, uint32_t); 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci/* Core clocks <==> uSecs */ 5788c2ecf20Sopenharmony_cistatic inline uint32_t 5798c2ecf20Sopenharmony_cicsio_core_ticks_to_us(struct csio_hw *hw, uint32_t ticks) 5808c2ecf20Sopenharmony_ci{ 5818c2ecf20Sopenharmony_ci /* add Core Clock / 2 to round ticks to nearest uS */ 5828c2ecf20Sopenharmony_ci return (ticks * 1000 + hw->vpd.cclk/2) / hw->vpd.cclk; 5838c2ecf20Sopenharmony_ci} 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_cistatic inline uint32_t 5868c2ecf20Sopenharmony_cicsio_us_to_core_ticks(struct csio_hw *hw, uint32_t us) 5878c2ecf20Sopenharmony_ci{ 5888c2ecf20Sopenharmony_ci return (us * hw->vpd.cclk) / 1000; 5898c2ecf20Sopenharmony_ci} 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci/* Easy access macros */ 5928c2ecf20Sopenharmony_ci#define csio_hw_to_wrm(hw) ((struct csio_wrm *)(&(hw)->wrm)) 5938c2ecf20Sopenharmony_ci#define csio_hw_to_mbm(hw) ((struct csio_mbm *)(&(hw)->mbm)) 5948c2ecf20Sopenharmony_ci#define csio_hw_to_scsim(hw) ((struct csio_scsim *)(&(hw)->scsim)) 5958c2ecf20Sopenharmony_ci#define csio_hw_to_mgmtm(hw) ((struct csio_mgmtm *)(&(hw)->mgmtm)) 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_ci#define CSIO_PCI_BUS(hw) ((hw)->pdev->bus->number) 5988c2ecf20Sopenharmony_ci#define CSIO_PCI_DEV(hw) (PCI_SLOT((hw)->pdev->devfn)) 5998c2ecf20Sopenharmony_ci#define CSIO_PCI_FUNC(hw) (PCI_FUNC((hw)->pdev->devfn)) 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ci#define csio_set_fwevt_intr_idx(_h, _i) ((_h)->fwevt_intr_idx = (_i)) 6028c2ecf20Sopenharmony_ci#define csio_get_fwevt_intr_idx(_h) ((_h)->fwevt_intr_idx) 6038c2ecf20Sopenharmony_ci#define csio_set_nondata_intr_idx(_h, _i) ((_h)->nondata_intr_idx = (_i)) 6048c2ecf20Sopenharmony_ci#define csio_get_nondata_intr_idx(_h) ((_h)->nondata_intr_idx) 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci/* Printing/logging */ 6078c2ecf20Sopenharmony_ci#define CSIO_DEVID(__dev) ((__dev)->dev_num) 6088c2ecf20Sopenharmony_ci#define CSIO_DEVID_LO(__dev) (CSIO_DEVID((__dev)) & 0xFFFF) 6098c2ecf20Sopenharmony_ci#define CSIO_DEVID_HI(__dev) ((CSIO_DEVID((__dev)) >> 16) & 0xFFFF) 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci#define csio_info(__hw, __fmt, ...) \ 6128c2ecf20Sopenharmony_ci dev_info(&(__hw)->pdev->dev, __fmt, ##__VA_ARGS__) 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci#define csio_fatal(__hw, __fmt, ...) \ 6158c2ecf20Sopenharmony_ci dev_crit(&(__hw)->pdev->dev, __fmt, ##__VA_ARGS__) 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci#define csio_err(__hw, __fmt, ...) \ 6188c2ecf20Sopenharmony_ci dev_err(&(__hw)->pdev->dev, __fmt, ##__VA_ARGS__) 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci#define csio_warn(__hw, __fmt, ...) \ 6218c2ecf20Sopenharmony_ci dev_warn(&(__hw)->pdev->dev, __fmt, ##__VA_ARGS__) 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci#ifdef __CSIO_DEBUG__ 6248c2ecf20Sopenharmony_ci#define csio_dbg(__hw, __fmt, ...) \ 6258c2ecf20Sopenharmony_ci csio_info((__hw), __fmt, ##__VA_ARGS__); 6268c2ecf20Sopenharmony_ci#else 6278c2ecf20Sopenharmony_ci#define csio_dbg(__hw, __fmt, ...) 6288c2ecf20Sopenharmony_ci#endif 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ciint csio_hw_wait_op_done_val(struct csio_hw *, int, uint32_t, int, 6318c2ecf20Sopenharmony_ci int, int, uint32_t *); 6328c2ecf20Sopenharmony_civoid csio_hw_tp_wr_bits_indirect(struct csio_hw *, unsigned int, 6338c2ecf20Sopenharmony_ci unsigned int, unsigned int); 6348c2ecf20Sopenharmony_ciint csio_mgmt_req_lookup(struct csio_mgmtm *, struct csio_ioreq *); 6358c2ecf20Sopenharmony_civoid csio_hw_intr_disable(struct csio_hw *); 6368c2ecf20Sopenharmony_ciint csio_hw_slow_intr_handler(struct csio_hw *); 6378c2ecf20Sopenharmony_ciint csio_handle_intr_status(struct csio_hw *, unsigned int, 6388c2ecf20Sopenharmony_ci const struct intr_info *); 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_cifw_port_cap32_t fwcap_to_fwspeed(fw_port_cap32_t acaps); 6418c2ecf20Sopenharmony_cifw_port_cap32_t fwcaps16_to_caps32(fw_port_cap16_t caps16); 6428c2ecf20Sopenharmony_cifw_port_cap16_t fwcaps32_to_caps16(fw_port_cap32_t caps32); 6438c2ecf20Sopenharmony_cifw_port_cap32_t lstatus_to_fwcap(u32 lstatus); 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ciint csio_hw_start(struct csio_hw *); 6468c2ecf20Sopenharmony_ciint csio_hw_stop(struct csio_hw *); 6478c2ecf20Sopenharmony_ciint csio_hw_reset(struct csio_hw *); 6488c2ecf20Sopenharmony_ciint csio_is_hw_ready(struct csio_hw *); 6498c2ecf20Sopenharmony_ciint csio_is_hw_removing(struct csio_hw *); 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ciint csio_fwevtq_handler(struct csio_hw *); 6528c2ecf20Sopenharmony_civoid csio_evtq_worker(struct work_struct *); 6538c2ecf20Sopenharmony_ciint csio_enqueue_evt(struct csio_hw *, enum csio_evt, void *, uint16_t); 6548c2ecf20Sopenharmony_civoid csio_evtq_flush(struct csio_hw *hw); 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ciint csio_request_irqs(struct csio_hw *); 6578c2ecf20Sopenharmony_civoid csio_intr_enable(struct csio_hw *); 6588c2ecf20Sopenharmony_civoid csio_intr_disable(struct csio_hw *, bool); 6598c2ecf20Sopenharmony_civoid csio_hw_fatal_err(struct csio_hw *); 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_cistruct csio_lnode *csio_lnode_alloc(struct csio_hw *); 6628c2ecf20Sopenharmony_ciint csio_config_queues(struct csio_hw *); 6638c2ecf20Sopenharmony_ci 6648c2ecf20Sopenharmony_ciint csio_hw_init(struct csio_hw *); 6658c2ecf20Sopenharmony_civoid csio_hw_exit(struct csio_hw *); 6668c2ecf20Sopenharmony_ci#endif /* ifndef __CSIO_HW_H__ */ 667