⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 at.h

📁 Linux* Base Driver for the Attansic(R) L1 Gigabit Ethernet Adapter
💻 H
字号:
/*
Linux Attansic 1 Gigabit Ethernet Driver main header file  
*/

#ifndef _ATTANSIC_H__
#define _ATTANSIC_H__


#include <linux/stddef.h>
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <asm/byteorder.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/string.h>
#include <linux/pagemap.h>
#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <linux/capability.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <net/pkt_sched.h>
#include <linux/list.h>
#include <linux/reboot.h>
#ifdef NETIF_F_TSO
#include <net/checksum.h>
#endif
#ifdef SIOCGMIIPHY
#include <linux/mii.h>
#endif
#ifdef SIOCETHTOOL
#include <linux/ethtool.h>
#endif
#ifdef NETIF_F_HW_VLAN_TX
#include <linux/if_vlan.h>
#endif

#define BAR_0	0
#define BAR_1	1
#define BAR_5	5
#define PCI_DMA_64BIT	0xffffffffffffffffULL
#define PCI_DMA_32BIT	0x00000000ffffffffULL

#define	LBYTESWAP( a )  ( ( ( (a) & 0x00ff00ff ) << 8 ) | ( ( (a) & 0xff00ff00 ) >> 8 ) )
#define	LONGSWAP( a )	( ( LBYTESWAP( a ) << 16 ) | ( LBYTESWAP( a ) >> 16 ) )
#define	SHORTSWAP( a )	( ( (a) << 8 ) | ( (a) >> 8 ) )

#include "kcompat.h"


#define ATTANSIC_ETHERNET_DEVICE(device_id) {\
	PCI_DEVICE(0x1969, device_id)}
	
	
struct at_adapter;

#include "at_hw.h"

#if DBG
#define AT_DBG(args...)	printk(KERN_DEBUG "attansic: " args)
#else
#define AT_DBG(args...)
#endif

#define AT_ERR(args...)	printk(KERN_ERR "attansic: " args)

#define AT_MAX_INTR         3

#define AT_DEFAULT_TPD		    256
#define AT_MAX_TPD		    1023
#define AT_MIN_TPD		    64
#define AT_DEFAULT_RFD		    512
#define AT_MIN_RFD		    128
#define AT_MAX_RFD		    2047





#define AT_DESC_UNUSED(R) \
	((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
	(R)->next_to_clean - (R)->next_to_use - 1)
	
#define AT_DESC_USED(R) \
	(((R)->next_to_clean > (R)->next_to_use) ? 	\
			((R)->count+(R)->next_to_use-(R)->next_to_clean+1) : \
			((R)->next_to_use-(R)->next_to_clean+1))
	

#define AT_GET_DESC(R, i, type)		(&(((type *)((R)->desc))[i]))
#define AT_RFD_DESC(R, i)		AT_GET_DESC(R, i, rx_free_desc_t)
#define AT_TPD_DESC(R, i)		AT_GET_DESC(R, i, tx_packet_desc_t)
#define AT_RRD_DESC(R, i)		AT_GET_DESC(R, i, rx_return_desc_t)

/* wrapper around a pointer to a socket buffer,
 * so a DMA handle can be stored along with the buffer */
struct at_buffer {
	struct sk_buff *skb;
	uint16_t length;
	uint16_t alloced;
	dma_addr_t dma;
};

#define MAX_TX_BUF_LEN		0x3000 /* 12KB */

struct at_tpd_ring {
    void *desc;         /* pointer to the descriptor ring memory */
    dma_addr_t dma;     /* physical adress of the descriptor ring */
    uint16_t size;      /* length of descriptor ring in bytes */
    uint16_t count;     /* number of descriptors in the ring */
    
    uint16_t hw_idx;    /* hardware index */
    atomic_t next_to_clean;
    atomic_t next_to_use;
    struct at_buffer *buffer_info;
};

struct at_rfd_ring {
    void *desc;
    dma_addr_t dma;
    uint16_t size;
    uint16_t count;
    atomic_t next_to_use;
    uint16_t next_to_clean;
    struct at_buffer *buffer_info;
};

struct at_rrd_ring {
	void *desc;
	dma_addr_t dma;
	unsigned int size;
	uint16_t count;
	uint16_t next_to_use; 
	atomic_t next_to_clean;
};

struct at_ring_header {
	/* pointer to the descriptor ring memory */
	void *desc;
	/* physical adress of the descriptor ring */
	dma_addr_t dma;
	/* length of descriptor ring in bytes */
	unsigned int size;
};

struct at_cmb {
	coals_msg_block_t* cmb;
	dma_addr_t dma;
};
struct at_smb {
	stats_msg_block_t* smb;
	dma_addr_t dma;
};

/* Statistics counters */
struct at_sft_stats {
	uint64_t rx_packets;
	uint64_t tx_packets;
	uint64_t rx_bytes;
	uint64_t tx_bytes;
	uint64_t multicast;
	uint64_t collisions;
	uint64_t rx_errors;
	uint64_t rx_length_errors;
	uint64_t rx_crc_errors;
	uint64_t rx_frame_errors;
	uint64_t rx_fifo_errors;
	uint64_t rx_missed_errors;
	uint64_t tx_errors;
    uint64_t tx_fifo_errors;
    uint64_t tx_aborted_errors;
    uint64_t tx_window_errors; 
    uint64_t tx_carrier_errors;
    
    uint64_t tx_pause;      // The number of Pause packet transmitted.
    uint64_t excecol;       // The number of transmit packets aborted due to excessive collisions.
    uint64_t deffer;        // The number of packets transmitted that is deferred.
    uint64_t scc;           // The number of packets subsequently transmitted successfully with a single prior collision.
    uint64_t mcc;           // The number of packets subsequently transmitted successfully with multiple prior collisions.
    uint64_t latecol;       // The number of packets transmitted with late collisions.
    uint64_t tx_underun;    // The number of transmit packets aborted due to transmit FIFO underrun, or TRD FIFO underrun
    uint64_t tx_trunc;      // The number of transmit packets truncated due to size exceeding MTU, regardless if it is truncated by Selene or not. 
                            // (The name is not really reflects the meaning in this case here.)
    
    uint64_t rx_pause;      // The number of Pause packet received.
    uint64_t rx_rrd_ov;
    uint64_t rx_trunc;
};


/* board specific private data structure */
          
#define AT_REGS_LEN	8
struct at_adapter {
	/* OS defined structs */
	struct net_device *netdev;
	struct pci_dev *pdev;
	struct net_device_stats net_stats;
	struct at_sft_stats soft_stats;
	
#ifdef NETIF_F_HW_VLAN_TX
	struct vlan_group *vlgrp;//
#endif
	uint32_t rx_buffer_len;
	uint32_t wol;
	uint16_t link_speed;
	uint16_t link_duplex;
	spinlock_t stats_lock;
	spinlock_t tx_lock;
	atomic_t irq_sem;//
	struct work_struct tx_timeout_task;//
	struct work_struct link_chg_task;//
    struct work_struct pcie_dma_to_rst_task;
    struct timer_list watchdog_timer;
    struct timer_list phy_config_timer;
    boolean_t phy_timer_pending;

    boolean_t mac_disabled;


	// All descriptor rings' memory
	struct at_ring_header ring_header;
	
	/* TX */
	
	struct at_tpd_ring tpd_ring;
	spinlock_t mb_lock;
	

	/* RX */
	struct at_rfd_ring rfd_ring;
	struct at_rrd_ring rrd_ring;
	uint64_t hw_csum_err;
	uint64_t hw_csum_good;

	uint32_t gorcl;
	uint64_t gorcl_old;

	/* Interrupt Moderator timer ( 2us resolution) */
	uint16_t imt;
	/* Interrupt Clear timer (2us resolution) */
	uint16_t ict;
	

	/* structs defined in at_hw.h */
	uint32_t bd_number;     // board number;
	boolean_t pci_using_64;
	struct at_hw hw;
	struct at_smb smb;
	struct at_cmb cmb;

#ifdef ETHTOOL_TEST
	uint32_t test_icr;
	struct at_ring_header   test_ring_header;
	struct at_tpd_ring     test_tpd_ring;
	struct at_rfd_ring     test_rfd_ring;
	struct at_rrd_ring test_rrd_ring;
#endif
	uint32_t pci_state[16];
};




#endif//_ATTANSIC_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -