acenic.h
来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 806 行 · 第 1/2 页
H
806 行
#define C_SET_MULTICAST_MODE 0x0e#define C_C_MCAST_ENABLE 0x01#define C_C_MCAST_DISABLE 0x02#define C_CLEAR_STATS 0x0f#define C_SET_RX_JUMBO_PRD_IDX 0x10#define C_REFRESH_STATS 0x11/* * Descriptor flags */#define BD_FLG_TCP_UDP_SUM 0x01#define BD_FLG_IP_SUM 0x02#define BD_FLG_END 0x04#define BD_FLG_MORE 0x08#define BD_FLG_JUMBO 0x10#define BD_FLG_UCAST 0x20#define BD_FLG_MCAST 0x40#define BD_FLG_BCAST 0x60#define BD_FLG_TYP_MASK 0x60#define BD_FLG_IP_FRAG 0x80#define BD_FLG_IP_FRAG_END 0x100#define BD_FLG_VLAN_TAG 0x200#define BD_FLG_FRAME_ERROR 0x400#define BD_FLG_COAL_NOW 0x800#define BD_FLG_MINI 0x1000/* * Ring Control block flags */#define RCB_FLG_TCP_UDP_SUM 0x01#define RCB_FLG_IP_SUM 0x02#define RCB_FLG_NO_PSEUDO_HDR 0x08#define RCB_FLG_VLAN_ASSIST 0x10#define RCB_FLG_COAL_INT_ONLY 0x20#define RCB_FLG_TX_HOST_RING 0x40#define RCB_FLG_IEEE_SNAP_SUM 0x80#define RCB_FLG_EXT_RX_BD 0x100#define RCB_FLG_RNG_DISABLE 0x200/* * TX ring - maximum TX ring entries for Tigon I's is 128 */#define MAX_TX_RING_ENTRIES 256#define TIGON_I_TX_RING_ENTRIES 128#define TX_RING_SIZE (MAX_TX_RING_ENTRIES * sizeof(struct tx_desc))#define TX_RING_BASE 0x3800struct tx_desc{ aceaddr addr; u32 flagsize; #if 0/* * This is in PCI shared mem and must be accessed with readl/writel * real layout is: */#if __LITTLE_ENDIAN u16 flags; u16 size; u16 vlan; u16 reserved;#else u16 size; u16 flags; u16 reserved; u16 vlan;#endif#endif u32 vlanres;};#define RX_STD_RING_ENTRIES 512#define RX_STD_RING_SIZE (RX_STD_RING_ENTRIES * sizeof(struct rx_desc))#define RX_JUMBO_RING_ENTRIES 256#define RX_JUMBO_RING_SIZE (RX_JUMBO_RING_ENTRIES *sizeof(struct rx_desc))#define RX_MINI_RING_ENTRIES 1024#define RX_MINI_RING_SIZE (RX_MINI_RING_ENTRIES *sizeof(struct rx_desc))#define RX_RETURN_RING_ENTRIES 2048#define RX_RETURN_RING_SIZE (RX_MAX_RETURN_RING_ENTRIES * \ sizeof(struct rx_desc))struct rx_desc{ aceaddr addr;#ifdef __LITTLE_ENDIAN u16 size; u16 idx;#else u16 idx; u16 size;#endif#ifdef __LITTLE_ENDIAN u16 flags; u16 type;#else u16 type; u16 flags;#endif#ifdef __LITTLE_ENDIAN u16 tcp_udp_csum; u16 ip_csum;#else u16 ip_csum; u16 tcp_udp_csum;#endif#ifdef __LITTLE_ENDIAN u16 vlan; u16 err_flags;#else u16 err_flags; u16 vlan;#endif u32 reserved; u32 opague;};/* * This struct is shared with the NIC firmware. */struct ring_ctrl { aceaddr rngptr;#ifdef __LITTLE_ENDIAN u16 flags; u16 max_len;#else u16 max_len; u16 flags;#endif u32 pad;};struct ace_mac_stats { u32 excess_colls; u32 coll_1; u32 coll_2; u32 coll_3; u32 coll_4; u32 coll_5; u32 coll_6; u32 coll_7; u32 coll_8; u32 coll_9; u32 coll_10; u32 coll_11; u32 coll_12; u32 coll_13; u32 coll_14; u32 coll_15; u32 late_coll; u32 defers; u32 crc_err; u32 underrun; u32 crs_err; u32 pad[3]; u32 drop_ula; u32 drop_mc; u32 drop_fc; u32 drop_space; u32 coll; u32 kept_bc; u32 kept_mc; u32 kept_uc;};struct ace_info { union { u32 stats[256]; } s; struct ring_ctrl evt_ctrl; struct ring_ctrl cmd_ctrl; struct ring_ctrl tx_ctrl; struct ring_ctrl rx_std_ctrl; struct ring_ctrl rx_jumbo_ctrl; struct ring_ctrl rx_mini_ctrl; struct ring_ctrl rx_return_ctrl; aceaddr evt_prd_ptr; aceaddr rx_ret_prd_ptr; aceaddr tx_csm_ptr; aceaddr stats2_ptr;};struct ring_info { struct sk_buff *skb; DECLARE_PCI_UNMAP_ADDR(mapping)};/* * Funny... As soon as we add maplen on alpha, it starts to work * much slower. Hmm... is it because struct does not fit to one cacheline? * So, split tx_ring_info. */struct tx_ring_info { struct sk_buff *skb; DECLARE_PCI_UNMAP_ADDR(mapping) DECLARE_PCI_UNMAP_LEN(maplen)};/* * struct ace_skb holding the rings of skb's. This is an awful lot of * pointers, but I don't see any other smart mode to do this in an * efficient manner ;-( */struct ace_skb{ struct tx_ring_info tx_skbuff[MAX_TX_RING_ENTRIES]; struct ring_info rx_std_skbuff[RX_STD_RING_ENTRIES]; struct ring_info rx_mini_skbuff[RX_MINI_RING_ENTRIES]; struct ring_info rx_jumbo_skbuff[RX_JUMBO_RING_ENTRIES];};/* * Struct private for the AceNIC. * * Elements are grouped so variables used by the tx handling goes * together, and will go into the same cache lines etc. in order to * avoid cache line contention between the rx and tx handling on SMP. * * Frequently accessed variables are put at the beginning of the * struct to help the compiler generate better/shorter code. */struct ace_private{ struct ace_info *info; struct ace_regs *regs; /* register base */ struct ace_skb *skb; dma_addr_t info_dma; /* 32/64 bit */ int version, link; int promisc, mcast_all; /* * TX elements */ struct tx_desc *tx_ring; u32 tx_prd; volatile u32 tx_ret_csm; int tx_ring_entries; /* * RX elements */ unsigned long std_refill_busy __attribute__ ((aligned (SMP_CACHE_BYTES))); unsigned long mini_refill_busy, jumbo_refill_busy; atomic_t cur_rx_bufs; atomic_t cur_mini_bufs; atomic_t cur_jumbo_bufs; u32 rx_std_skbprd, rx_mini_skbprd, rx_jumbo_skbprd; u32 cur_rx; struct rx_desc *rx_std_ring; struct rx_desc *rx_jumbo_ring; struct rx_desc *rx_mini_ring; struct rx_desc *rx_return_ring;#if ACENIC_DO_VLAN struct vlan_group *vlgrp;#endif int tasklet_pending, jumbo; struct tasklet_struct ace_tasklet; struct event *evt_ring; volatile u32 *evt_prd, *rx_ret_prd, *tx_csm; dma_addr_t tx_ring_dma; /* 32/64 bit */ dma_addr_t rx_ring_base_dma; dma_addr_t evt_ring_dma; dma_addr_t evt_prd_dma, rx_ret_prd_dma, tx_csm_dma; unsigned char *trace_buf; struct pci_dev *pdev; struct net_device *next; volatile int fw_running; int board_idx; u16 pci_command; u8 pci_latency; const char *name;#ifdef INDEX_DEBUG spinlock_t debug_lock __attribute__ ((aligned (SMP_CACHE_BYTES))); u32 last_tx, last_std_rx, last_mini_rx;#endif struct net_device_stats stats; int pci_using_dac;};#define TX_RESERVED MAX_SKB_FRAGSstatic inline int tx_space (struct ace_private *ap, u32 csm, u32 prd){ return (csm - prd - 1) & (ACE_TX_RING_ENTRIES(ap) - 1);}#define tx_free(ap) tx_space((ap)->tx_ret_csm, (ap)->tx_prd, ap)#if MAX_SKB_FRAGS#define tx_ring_full(ap, csm, prd) (tx_space(ap, csm, prd) <= TX_RESERVED)#else#define tx_ring_full 0#endifstatic inline void set_aceaddr(aceaddr *aa, dma_addr_t addr){ u64 baddr = (u64) addr; aa->addrlo = baddr & 0xffffffff; aa->addrhi = baddr >> 32; wmb();}static inline void ace_set_txprd(struct ace_regs *regs, struct ace_private *ap, u32 value){#ifdef INDEX_DEBUG unsigned long flags; spin_lock_irqsave(&ap->debug_lock, flags); writel(value, ®s->TxPrd); if (value == ap->last_tx) printk(KERN_ERR "AceNIC RACE ALERT! writing identical value " "to tx producer (%i)\n", value); ap->last_tx = value; spin_unlock_irqrestore(&ap->debug_lock, flags);#else writel(value, ®s->TxPrd);#endif wmb();}static inline void ace_mask_irq(struct net_device *dev){ struct ace_private *ap = dev->priv; struct ace_regs *regs = ap->regs; if (ACE_IS_TIGON_I(ap)) writel(1, ®s->MaskInt); else writel(readl(®s->HostCtrl) | MASK_INTS, ®s->HostCtrl); ace_sync_irq(dev->irq);}static inline void ace_unmask_irq(struct net_device *dev){ struct ace_private *ap = dev->priv; struct ace_regs *regs = ap->regs; if (ACE_IS_TIGON_I(ap)) writel(0, ®s->MaskInt); else writel(readl(®s->HostCtrl) & ~MASK_INTS, ®s->HostCtrl);}/* * Prototypes */static int ace_init(struct net_device *dev);static void ace_load_std_rx_ring(struct ace_private *ap, int nr_bufs);static void ace_load_mini_rx_ring(struct ace_private *ap, int nr_bufs);static void ace_load_jumbo_rx_ring(struct ace_private *ap, int nr_bufs);static irqreturn_t ace_interrupt(int irq, void *dev_id, struct pt_regs *regs);static int ace_load_firmware(struct net_device *dev);static int ace_open(struct net_device *dev);static int ace_start_xmit(struct sk_buff *skb, struct net_device *dev);static int ace_close(struct net_device *dev);static void ace_tasklet(unsigned long dev);static void ace_dump_trace(struct ace_private *ap);static void ace_set_multicast_list(struct net_device *dev);static int ace_change_mtu(struct net_device *dev, int new_mtu);static int ace_set_mac_addr(struct net_device *dev, void *p);static void ace_set_rxtx_parms(struct net_device *dev, int jumbo);static int ace_allocate_descriptors(struct net_device *dev);static void ace_free_descriptors(struct net_device *dev);static void ace_init_cleanup(struct net_device *dev);static struct net_device_stats *ace_get_stats(struct net_device *dev);static int read_eeprom_byte(struct net_device *dev, unsigned long offset);#if ACENIC_DO_VLANstatic void ace_vlan_rx_register(struct net_device *dev, struct vlan_group *grp);static void ace_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid);#endif#endif /* _ACENIC_H_ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?