netxen_nic_hw.h
来自「linux 内核源代码」· C头文件 代码 · 共 546 行 · 第 1/2 页
H
546 行
/* * Copyright (C) 2003 - 2006 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * The full GNU General Public License is included in this distribution * in the file called LICENSE. * * Contact Information: * info@netxen.com * NetXen, * 3965 Freedom Circle, Fourth floor, * Santa Clara, CA 95054 * * * Structures, enums, and macros for the MAC * */#ifndef __NETXEN_NIC_HW_H_#define __NETXEN_NIC_HW_H_#include "netxen_nic_hdr.h"/* Hardware memory size of 128 meg */#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)#ifndef readqstatic inline u64 readq(void __iomem * addr){ return readl(addr) | (((u64) readl(addr + 4)) << 32LL);}#endif#ifndef writeqstatic inline void writeq(u64 val, void __iomem * addr){ writel(((u32) (val)), (addr)); writel(((u32) (val >> 32)), (addr + 4));}#endifstatic inline void netxen_nic_hw_block_write64(u64 __iomem * data_ptr, u64 __iomem * addr, int num_words){ int num; for (num = 0; num < num_words; num++) { writeq(readq((void __iomem *)data_ptr), addr); addr++; data_ptr++; }}static inline void netxen_nic_hw_block_read64(u64 __iomem * data_ptr, u64 __iomem * addr, int num_words){ int num; for (num = 0; num < num_words; num++) { writeq(readq((void __iomem *)addr), data_ptr); addr++; data_ptr++; }}struct netxen_adapter;#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \ addr = pci_base_offset(adapter, X); \ *(u32 *)Y = readl((void __iomem*) addr);struct netxen_port;void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);void netxen_nic_flash_print(struct netxen_adapter *adapter);int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, int len);void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off, int data);int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data, int len);typedef u8 netxen_ethernet_macaddr_t[6];/* Nibble or Byte mode for phy interface (GbE mode only) */typedef enum { NETXEN_NIU_10_100_MB = 0, NETXEN_NIU_1000_MB} netxen_niu_gbe_ifmode_t;#define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)/* * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3) * * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream * Bit 2 : enable_rx => 1:enable frame recv, 0:disable * Bit 3 : rx_synced => R/O: recv enable synched to recv stream * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op */#define netxen_gb_enable_tx(config_word) \ ((config_word) |= 1 << 0)#define netxen_gb_enable_rx(config_word) \ ((config_word) |= 1 << 2)#define netxen_gb_tx_flowctl(config_word) \ ((config_word) |= 1 << 4)#define netxen_gb_rx_flowctl(config_word) \ ((config_word) |= 1 << 5)#define netxen_gb_tx_reset_pb(config_word) \ ((config_word) |= 1 << 16)#define netxen_gb_rx_reset_pb(config_word) \ ((config_word) |= 1 << 17)#define netxen_gb_tx_reset_mac(config_word) \ ((config_word) |= 1 << 18)#define netxen_gb_rx_reset_mac(config_word) \ ((config_word) |= 1 << 19)#define netxen_gb_soft_reset(config_word) \ ((config_word) |= 1 << 31)#define netxen_gb_unset_tx_flowctl(config_word) \ ((config_word) &= ~(1 << 4))#define netxen_gb_unset_rx_flowctl(config_word) \ ((config_word) &= ~(1 << 5))#define netxen_gb_get_tx_synced(config_word) \ _netxen_crb_get_bit((config_word), 1)#define netxen_gb_get_rx_synced(config_word) \ _netxen_crb_get_bit((config_word), 3)#define netxen_gb_get_tx_flowctl(config_word) \ _netxen_crb_get_bit((config_word), 4)#define netxen_gb_get_rx_flowctl(config_word) \ _netxen_crb_get_bit((config_word), 5)#define netxen_gb_get_soft_reset(config_word) \ _netxen_crb_get_bit((config_word), 31)/* * NIU GB MAC Config Register 1 (applies to GB0, GB1, GB2, GB3) * * Bit 0 : duplex => 1:full duplex mode, 0:half duplex * Bit 1 : crc_enable => 1:append CRC to xmit frames, 0:dont append * Bit 2 : padshort => 1:pad short frames and add CRC, 0:dont pad * Bit 4 : checklength => 1:check framelen with actual,0:dont check * Bit 5 : hugeframes => 1:allow oversize xmit frames, 0:dont allow * Bits 8-9 : intfmode => 01:nibble (10/100), 10:byte (1000) * Bits 12-15 : preamblelen => preamble field length in bytes, default 7 */#define netxen_gb_set_duplex(config_word) \ ((config_word) |= 1 << 0)#define netxen_gb_set_crc_enable(config_word) \ ((config_word) |= 1 << 1)#define netxen_gb_set_padshort(config_word) \ ((config_word) |= 1 << 2)#define netxen_gb_set_checklength(config_word) \ ((config_word) |= 1 << 4)#define netxen_gb_set_hugeframes(config_word) \ ((config_word) |= 1 << 5)#define netxen_gb_set_preamblelen(config_word, val) \ ((config_word) |= ((val) << 12) & 0xF000)#define netxen_gb_set_intfmode(config_word, val) \ ((config_word) |= ((val) << 8) & 0x300)#define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)#define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \ ((config_word) |= ((val) & 0x07))#define netxen_gb_mii_mgmt_reset(config_word) \ ((config_word) |= 1 << 31)#define netxen_gb_mii_mgmt_unset(config_word) \ ((config_word) &= ~(1 << 31))/* * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3) * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op */#define netxen_gb_mii_mgmt_set_read_cycle(config_word) \ ((config_word) |= 1 << 0)#define netxen_gb_mii_mgmt_reg_addr(config_word, val) \ ((config_word) |= ((val) & 0x1F))#define netxen_gb_mii_mgmt_phy_addr(config_word, val) \ ((config_word) |= (((val) & 0x1F) << 8))/* * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3) * Read-only register. * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle * Bit 1 : scanning => 1:scan operation in progress, 0:idle * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle */#define netxen_get_gb_mii_mgmt_busy(config_word) \ _netxen_crb_get_bit(config_word, 0)#define netxen_get_gb_mii_mgmt_scanning(config_word) \ _netxen_crb_get_bit(config_word, 1)#define netxen_get_gb_mii_mgmt_notvalid(config_word) \ _netxen_crb_get_bit(config_word, 2)/* * NIU XG Pause Ctl Register * * Bit 0 : xg0_mask => 1:disable tx pause frames * Bit 1 : xg0_request => 1:request single pause frame * Bit 2 : xg0_on_off => 1:request is pause on, 0:off * Bit 3 : xg1_mask => 1:disable tx pause frames * Bit 4 : xg1_request => 1:request single pause frame * Bit 5 : xg1_on_off => 1:request is pause on, 0:off */#define netxen_xg_set_xg0_mask(config_word) \ ((config_word) |= 1 << 0)#define netxen_xg_set_xg1_mask(config_word) \ ((config_word) |= 1 << 3) #define netxen_xg_get_xg0_mask(config_word) \ _netxen_crb_get_bit((config_word), 0)#define netxen_xg_get_xg1_mask(config_word) \ _netxen_crb_get_bit((config_word), 3)#define netxen_xg_unset_xg0_mask(config_word) \ ((config_word) &= ~(1 << 0))#define netxen_xg_unset_xg1_mask(config_word) \ ((config_word) &= ~(1 << 3))/* * NIU XG Pause Ctl Register * * Bit 0 : xg0_mask => 1:disable tx pause frames * Bit 1 : xg0_request => 1:request single pause frame * Bit 2 : xg0_on_off => 1:request is pause on, 0:off * Bit 3 : xg1_mask => 1:disable tx pause frames * Bit 4 : xg1_request => 1:request single pause frame * Bit 5 : xg1_on_off => 1:request is pause on, 0:off */#define netxen_gb_set_gb0_mask(config_word) \ ((config_word) |= 1 << 0)#define netxen_gb_set_gb1_mask(config_word) \ ((config_word) |= 1 << 2)#define netxen_gb_set_gb2_mask(config_word) \ ((config_word) |= 1 << 4)#define netxen_gb_set_gb3_mask(config_word) \ ((config_word) |= 1 << 6)#define netxen_gb_get_gb0_mask(config_word) \ _netxen_crb_get_bit((config_word), 0)#define netxen_gb_get_gb1_mask(config_word) \ _netxen_crb_get_bit((config_word), 2)#define netxen_gb_get_gb2_mask(config_word) \ _netxen_crb_get_bit((config_word), 4)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?