common.h
来自「linux 内核源代码」· C头文件 代码 · 共 785 行 · 第 1/2 页
H
785 行
/* * Copyright (c) 2005-2007 Chelsio, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */#ifndef __CHELSIO_COMMON_H#define __CHELSIO_COMMON_H#include <linux/kernel.h>#include <linux/types.h>#include <linux/ctype.h>#include <linux/delay.h>#include <linux/init.h>#include <linux/netdevice.h>#include <linux/ethtool.h>#include <linux/mii.h>#include "version.h"#define CH_ERR(adap, fmt, ...) dev_err(&adap->pdev->dev, fmt, ## __VA_ARGS__)#define CH_WARN(adap, fmt, ...) dev_warn(&adap->pdev->dev, fmt, ## __VA_ARGS__)#define CH_ALERT(adap, fmt, ...) \ dev_printk(KERN_ALERT, &adap->pdev->dev, fmt, ## __VA_ARGS__)/* * More powerful macro that selectively prints messages based on msg_enable. * For info and debugging messages. */#define CH_MSG(adapter, level, category, fmt, ...) do { \ if ((adapter)->msg_enable & NETIF_MSG_##category) \ dev_printk(KERN_##level, &adapter->pdev->dev, fmt, \ ## __VA_ARGS__); \} while (0)#ifdef DEBUG# define CH_DBG(adapter, category, fmt, ...) \ CH_MSG(adapter, DEBUG, category, fmt, ## __VA_ARGS__)#else# define CH_DBG(adapter, category, fmt, ...)#endif/* Additional NETIF_MSG_* categories */#define NETIF_MSG_MMIO 0x8000000struct t3_rx_mode { struct net_device *dev; struct dev_mc_list *mclist; unsigned int idx;};static inline void init_rx_mode(struct t3_rx_mode *p, struct net_device *dev, struct dev_mc_list *mclist){ p->dev = dev; p->mclist = mclist; p->idx = 0;}static inline u8 *t3_get_next_mcaddr(struct t3_rx_mode *rm){ u8 *addr = NULL; if (rm->mclist && rm->idx < rm->dev->mc_count) { addr = rm->mclist->dmi_addr; rm->mclist = rm->mclist->next; rm->idx++; } return addr;}enum { MAX_NPORTS = 2, /* max # of ports */ MAX_FRAME_SIZE = 10240, /* max MAC frame size, including header + FCS */ EEPROMSIZE = 8192, /* Serial EEPROM size */ SERNUM_LEN = 16, /* Serial # length */ RSS_TABLE_SIZE = 64, /* size of RSS lookup and mapping tables */ TCB_SIZE = 128, /* TCB size */ NMTUS = 16, /* size of MTU table */ NCCTRL_WIN = 32, /* # of congestion control windows */ PROTO_SRAM_LINES = 128, /* size of TP sram */};#define MAX_RX_COALESCING_LEN 12288Uenum { PAUSE_RX = 1 << 0, PAUSE_TX = 1 << 1, PAUSE_AUTONEG = 1 << 2};enum { SUPPORTED_IRQ = 1 << 24};enum { /* adapter interrupt-maintained statistics */ STAT_ULP_CH0_PBL_OOB, STAT_ULP_CH1_PBL_OOB, STAT_PCI_CORR_ECC, IRQ_NUM_STATS /* keep last */};enum { TP_VERSION_MAJOR = 1, TP_VERSION_MINOR = 1, TP_VERSION_MICRO = 0};#define S_TP_VERSION_MAJOR 16#define M_TP_VERSION_MAJOR 0xFF#define V_TP_VERSION_MAJOR(x) ((x) << S_TP_VERSION_MAJOR)#define G_TP_VERSION_MAJOR(x) \ (((x) >> S_TP_VERSION_MAJOR) & M_TP_VERSION_MAJOR)#define S_TP_VERSION_MINOR 8#define M_TP_VERSION_MINOR 0xFF#define V_TP_VERSION_MINOR(x) ((x) << S_TP_VERSION_MINOR)#define G_TP_VERSION_MINOR(x) \ (((x) >> S_TP_VERSION_MINOR) & M_TP_VERSION_MINOR)#define S_TP_VERSION_MICRO 0#define M_TP_VERSION_MICRO 0xFF#define V_TP_VERSION_MICRO(x) ((x) << S_TP_VERSION_MICRO)#define G_TP_VERSION_MICRO(x) \ (((x) >> S_TP_VERSION_MICRO) & M_TP_VERSION_MICRO)enum { SGE_QSETS = 8, /* # of SGE Tx/Rx/RspQ sets */ SGE_RXQ_PER_SET = 2, /* # of Rx queues per set */ SGE_TXQ_PER_SET = 3 /* # of Tx queues per set */};enum sge_context_type { /* SGE egress context types */ SGE_CNTXT_RDMA = 0, SGE_CNTXT_ETH = 2, SGE_CNTXT_OFLD = 4, SGE_CNTXT_CTRL = 5};enum { AN_PKT_SIZE = 32, /* async notification packet size */ IMMED_PKT_SIZE = 48 /* packet size for immediate data */};struct sg_ent { /* SGE scatter/gather entry */ __be32 len[2]; __be64 addr[2];};#ifndef SGE_NUM_GENBITS/* Must be 1 or 2 */# define SGE_NUM_GENBITS 2#endif#define TX_DESC_FLITS 16U#define WR_FLITS (TX_DESC_FLITS + 1 - SGE_NUM_GENBITS)struct cphy;struct adapter;struct mdio_ops { int (*read)(struct adapter *adapter, int phy_addr, int mmd_addr, int reg_addr, unsigned int *val); int (*write)(struct adapter *adapter, int phy_addr, int mmd_addr, int reg_addr, unsigned int val);};struct adapter_info { unsigned char nports; /* # of ports */ unsigned char phy_base_addr; /* MDIO PHY base address */ unsigned char mdien; unsigned char mdiinv; unsigned int gpio_out; /* GPIO output settings */ unsigned int gpio_intr; /* GPIO IRQ enable mask */ unsigned long caps; /* adapter capabilities */ const struct mdio_ops *mdio_ops; /* MDIO operations */ const char *desc; /* product description */};struct port_type_info { void (*phy_prep)(struct cphy *phy, struct adapter *adapter, int phy_addr, const struct mdio_ops *ops); unsigned int caps; const char *desc;};struct mc5_stats { unsigned long parity_err; unsigned long active_rgn_full; unsigned long nfa_srch_err; unsigned long unknown_cmd; unsigned long reqq_parity_err; unsigned long dispq_parity_err; unsigned long del_act_empty;};struct mc7_stats { unsigned long corr_err; unsigned long uncorr_err; unsigned long parity_err; unsigned long addr_err;};struct mac_stats { u64 tx_octets; /* total # of octets in good frames */ u64 tx_octets_bad; /* total # of octets in error frames */ u64 tx_frames; /* all good frames */ u64 tx_mcast_frames; /* good multicast frames */ u64 tx_bcast_frames; /* good broadcast frames */ u64 tx_pause; /* # of transmitted pause frames */ u64 tx_deferred; /* frames with deferred transmissions */ u64 tx_late_collisions; /* # of late collisions */ u64 tx_total_collisions; /* # of total collisions */ u64 tx_excess_collisions; /* frame errors from excessive collissions */ u64 tx_underrun; /* # of Tx FIFO underruns */ u64 tx_len_errs; /* # of Tx length errors */ u64 tx_mac_internal_errs; /* # of internal MAC errors on Tx */ u64 tx_excess_deferral; /* # of frames with excessive deferral */ u64 tx_fcs_errs; /* # of frames with bad FCS */ u64 tx_frames_64; /* # of Tx frames in a particular range */ u64 tx_frames_65_127; u64 tx_frames_128_255; u64 tx_frames_256_511; u64 tx_frames_512_1023; u64 tx_frames_1024_1518; u64 tx_frames_1519_max; u64 rx_octets; /* total # of octets in good frames */ u64 rx_octets_bad; /* total # of octets in error frames */ u64 rx_frames; /* all good frames */ u64 rx_mcast_frames; /* good multicast frames */ u64 rx_bcast_frames; /* good broadcast frames */ u64 rx_pause; /* # of received pause frames */ u64 rx_fcs_errs; /* # of received frames with bad FCS */ u64 rx_align_errs; /* alignment errors */ u64 rx_symbol_errs; /* symbol errors */ u64 rx_data_errs; /* data errors */ u64 rx_sequence_errs; /* sequence errors */ u64 rx_runt; /* # of runt frames */ u64 rx_jabber; /* # of jabber frames */ u64 rx_short; /* # of short frames */ u64 rx_too_long; /* # of oversized frames */ u64 rx_mac_internal_errs; /* # of internal MAC errors on Rx */ u64 rx_frames_64; /* # of Rx frames in a particular range */ u64 rx_frames_65_127; u64 rx_frames_128_255; u64 rx_frames_256_511; u64 rx_frames_512_1023; u64 rx_frames_1024_1518; u64 rx_frames_1519_max; u64 rx_cong_drops; /* # of Rx drops due to SGE congestion */ unsigned long tx_fifo_parity_err; unsigned long rx_fifo_parity_err; unsigned long tx_fifo_urun; unsigned long rx_fifo_ovfl; unsigned long serdes_signal_loss; unsigned long xaui_pcs_ctc_err; unsigned long xaui_pcs_align_change; unsigned long num_toggled; /* # times toggled TxEn due to stuck TX */ unsigned long num_resets; /* # times reset due to stuck TX */};struct tp_mib_stats { u32 ipInReceive_hi; u32 ipInReceive_lo; u32 ipInHdrErrors_hi; u32 ipInHdrErrors_lo; u32 ipInAddrErrors_hi; u32 ipInAddrErrors_lo; u32 ipInUnknownProtos_hi; u32 ipInUnknownProtos_lo; u32 ipInDiscards_hi; u32 ipInDiscards_lo; u32 ipInDelivers_hi; u32 ipInDelivers_lo; u32 ipOutRequests_hi; u32 ipOutRequests_lo; u32 ipOutDiscards_hi; u32 ipOutDiscards_lo; u32 ipOutNoRoutes_hi; u32 ipOutNoRoutes_lo; u32 ipReasmTimeout; u32 ipReasmReqds; u32 ipReasmOKs; u32 ipReasmFails; u32 reserved[8]; u32 tcpActiveOpens; u32 tcpPassiveOpens; u32 tcpAttemptFails; u32 tcpEstabResets; u32 tcpOutRsts; u32 tcpCurrEstab; u32 tcpInSegs_hi; u32 tcpInSegs_lo; u32 tcpOutSegs_hi; u32 tcpOutSegs_lo; u32 tcpRetransSeg_hi; u32 tcpRetransSeg_lo; u32 tcpInErrs_hi; u32 tcpInErrs_lo; u32 tcpRtoMin; u32 tcpRtoMax;};struct tp_params { unsigned int nchan; /* # of channels */ unsigned int pmrx_size; /* total PMRX capacity */ unsigned int pmtx_size; /* total PMTX capacity */ unsigned int cm_size; /* total CM capacity */ unsigned int chan_rx_size; /* per channel Rx size */ unsigned int chan_tx_size; /* per channel Tx size */ unsigned int rx_pg_size; /* Rx page size */ unsigned int tx_pg_size; /* Tx page size */ unsigned int rx_num_pgs; /* # of Rx pages */ unsigned int tx_num_pgs; /* # of Tx pages */ unsigned int ntimer_qs; /* # of timer queues */};struct qset_params { /* SGE queue set parameters */ unsigned int polling; /* polling/interrupt service for rspq */ unsigned int coalesce_usecs; /* irq coalescing timer */ unsigned int rspq_size; /* # of entries in response queue */ unsigned int fl_size; /* # of entries in regular free list */ unsigned int jumbo_size; /* # of entries in jumbo free list */ unsigned int txq_size[SGE_TXQ_PER_SET]; /* Tx queue sizes */ unsigned int cong_thres; /* FL congestion threshold */};struct sge_params { unsigned int max_pkt_size; /* max offload pkt size */ struct qset_params qset[SGE_QSETS];};struct mc5_params { unsigned int mode; /* selects MC5 width */ unsigned int nservers; /* size of server region */ unsigned int nfilters; /* size of filter region */ unsigned int nroutes; /* size of routing region */};/* Default MC5 region sizes */enum { DEFAULT_NSERVERS = 512, DEFAULT_NFILTERS = 128};/* MC5 modes, these must be non-0 */enum { MC5_MODE_144_BIT = 1, MC5_MODE_72_BIT = 2};/* MC5 min active region size */enum { MC5_MIN_TIDS = 16 };struct vpd_params { unsigned int cclk; unsigned int mclk; unsigned int uclk; unsigned int mdc;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?