29 #define TX_DESC_COUNT 32 30 #define RX_MEM_SIZE 8192 31 #define MAX_FRAME_SIZE 1500 34 #define PREAMBLE_LEN 7 35 #define RX_JUMBO_THRESH ((MAX_FRAME_SIZE + ETH_HLEN + \ 36 VLAN_HLEN + ETH_FCS_LEN + 7) >> 3) 39 #define SMB_TIMER 200000 42 #define TPD_THRESH (TX_DESC_COUNT / 2) 43 #define RX_COUNT_DOWN 4 44 #define TX_COUNT_DOWN (IMT_VAL * 4 / 3) 45 #define DMAR_DLY_CNT 15 46 #define DMAW_DLY_CNT 4 48 #define PCI_DEVICE_ID_ATTANSIC_L1E 0x1026 60 PCI_ROM(0x1969, 0x1026,
"atl1e_26",
"Attansic L1E 0x1026", 0),
61 PCI_ROM(0x1969, 0x1066,
"atl1e_66",
"Attansic L1E 0x1066", 0),
85 128, 256, 512, 1024, 2048, 4096,
163 DBG(
"atl1e: %s link is up, %d Mbps, %s duplex\n",
184 int reg_num,
int val)
220 u32 phy_status_data = 0;
231 if (rev_id >= 0xF0) {
244 hw->phy_configured = 0;
348 rx_page_desc = &
rx_ring->rx_page_desc;
411 DBG(
"atl1e: out of memory allocating %d bytes for %s ring\n",
419 rx_page_desc = &
rx_ring->rx_page_desc;
429 DBG(
"atl1e: out of memory allocating %d bytes for %s txbuf\n",
461 DBG(
"atl1e: ring miscalculation! need %d > %d bytes\n",
489 rx_page_desc = &
rx_ring->rx_page_desc;
498 page_phy_addr = rx_page_desc->rx_page[j].dma;
499 offset_phy_addr = rx_page_desc->rx_page[j].write_offset_dma;
518 u32 dev_ctrl_data = 0;
519 u32 max_pay_load = 0;
520 u32 jumbo_thresh = 0;
535 hw->dmaw_block = max_pay_load;
540 hw->dmar_block = max_pay_load;
559 u32 rxf_thresh_data = 0;
560 u32 rxq_ctrl_data = 0;
570 rxf_high = rxf_len * 4 / 5;
571 rxf_low = rxf_len / 5;
594 u32 dma_ctrl_data = 0;
646 u32 intr_status_data = 0;
699 DBG(
"atl1e: configure failed, PCIE phy link down\n");
758 u32 packet_size, write_offset;
770 if (prrs->
seq_num != rx_page_desc->rx_nxseq) {
771 DBG(
"atl1e %s: RX sequence number error (%d != %d)\n",
773 rx_page_desc->rx_nxseq);
774 rx_page_desc->rx_nxseq++;
778 rx_page_desc->rx_nxseq++;
796 DBG(
"atl1e %s: dropping packet under memory pressure\n",
821 rx_using = rx_page_desc->rx_using;
825 rx_page_desc->rx_using ^= 1;
862 DBG(
"atl1e: PCI-E PHY link down: %x\n",
status);
873 DBG(
"atl1e: PCI-E DMA RW error: %x\n",
status);
891 }
while (--max_ints > 0);
947 tx_buffer->
length = buf_len;
1126 static int cards_found;
1135 DBG(
"atl1e: out of memory allocating net_device\n");
1148 DBG(
"atl1e: cannot map device registers\n");
1149 goto err_free_netdev;
1169 DBG(
"atl1e: private data init failed\n");
1170 goto err_free_netdev;
1181 goto err_free_netdev;
1189 DBG(
"atl1e: cannot read MAC address from EEPROM\n");
1191 goto err_free_netdev;
1196 DBG(
"atl1e: Attansic L1E Ethernet controller on %s, " 1197 "%02x:%02x:%02x:%02x:%02x:%02x\n", adapter->
netdev->
name,
1204 DBG(
"atl1e: cannot register network device\n");
1205 goto err_free_netdev;
1262 return ((
value & 0xFF00) == 0x6C00) ? 0 : 1;
1274 (((
u32)
hw->mac_addr[3]) << 16) |
1275 (((
u32)
hw->mac_addr[4]) << 8) |
1276 (((
u32)
hw->mac_addr[5])) ;
1280 (((
u32)
hw->mac_addr[1])) ;
1317 eth_addr[
ETH_ALEN - i - 1] = hw_addr.byte[i];
1342 memcpy(
hw->mac_addr,
hw->perm_mac_addr,
sizeof(
hw->perm_mac_addr));
1437 u16 mii_autoneg_adv_reg;
1438 u16 mii_1000t_ctrl_reg;
1440 if (0 !=
hw->mii_autoneg_adv_reg)
1466 hw->mii_autoneg_adv_reg = mii_autoneg_adv_reg;
1467 hw->mii_1000t_ctrl_reg = mii_1000t_ctrl_reg;
1475 mii_1000t_ctrl_reg);
1505 for (i = 0; i < 25; i++) {
1513 DBG(
"atl1e: PCI-E link down for at least 25ms\n");
1517 DBG(
"atl1e: PCI-E link up after %d ms\n", i);
1527 if (
hw->phy_configured) {
1528 if (
hw->re_autoneg) {
1587 DBG(
"atl1e: Error enable PHY linkChange Interrupt\n");
1593 DBG(
"atl1e: Error Setting up Auto-Negotiation\n");
1597 DBG(
"atl1e: Restarting Auto-Neg");
1600 DBG(
"atl1e: Error Resetting the phy");
1604 hw->phy_configured = 1;
1619 u32 idle_status_data = 0;
1620 u16 pci_cfg_cmd_word = 0;
1647 if (idle_status_data == 0)
1653 DBG(
"atl1e: MAC reset timeout\n");
1739 hw->mii_1000t_ctrl_reg);
static void atl1e_irq_reset(struct atl1e_adapter *adapter)
#define REG_IRQ_MODU_TIMER2_INIT
#define EINVAL
Invalid argument.
static const u16 atl1e_rx_page_vld_regs[AT_PAGE_NUM_PER_QUEUE]
#define DEVICE_CTRL_MAX_RREQ_SZ_SHIFT
unsigned long membase
Memory base.
#define REG_MB_TPD_PROD_IDX
#define MII_CR_RESTART_AUTO_NEG
#define RXQ_JMBO_LKAH_MASK
static void atl1e_configure_des_ring(const struct atl1e_adapter *adapter)
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
#define MAC_CTRL_MC_ALL_EN
int atl1e_write_phy_reg(struct atl1e_hw *hw, u32 reg_addr, u16 phy_data)
#define MII_AT001_PSSR_DPLX
#define iob_put(iobuf, len)
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
static int atl1e_check_link(struct atl1e_adapter *adapter)
#define GPHY_CTRL_EXT_RESET
#define MDIO_REG_ADDR_SHIFT
#define EBUSY
Device or resource busy.
struct atl1e_rx_ring rx_ring
#define AT_READ_REGW(a, reg)
u8 perm_mac_addr[ETH_ALEN]
#define MII_AR_DEFAULT_CAP_MASK
static void atl1e_clean_rx_irq(struct atl1e_adapter *adapter)
int(* open)(struct net_device *netdev)
Open network device.
static void atl1e_irq_enable(struct atl1e_adapter *adapter)
#define REG_CMBDISDMA_TIMER
#define MAC_CTRL_SPEED_1000
#define MAC_CTRL_PRMLEN_SHIFT
enum atl1e_dma_req_block dmar_block
int(* mdio_read)(struct net_device *dev, int phy_id, int location)
#define REG_HOST_RXF0_MB1_LO
static void atl1e_setup_mac_ctrl(struct atl1e_adapter *adapter)
#define REG_HOST_RXF0_PAGE0_LO
static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
void atl1e_force_ps(struct atl1e_hw *hw)
struct pci_device_id * ids
PCI ID table.
#define TWSI_CTRL_SW_LDSTART
#define AT_WRITE_REGW(a, reg, value)
FILE_LICENCE(GPL2_OR_LATER)
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
uint8_t size
Entry size (in 32-bit words)
#define REG_DESC_BASE_ADDR_HI
#define REG_IRQ_MODU_TIMER_INIT
void atl1e_irq(struct net_device *netdev, int enable)
#define MII_AT001_CR_1000T_FD_CAPS
enum atl1e_dma_req_block dmaw_block
#define GPHY_CTRL_PW_WOL_DIS
static const u16 atl1e_pay_load_size[]
#define MII_AR_100TX_FD_CAPS
struct atl1e_rx_page_desc rx_page_desc
#define DMA_CTRL_DMAW_BURST_LEN_MASK
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
static int atl1e_open(struct net_device *netdev)
#define cpu_to_le64(value)
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
int atl1e_get_speed_and_duplex(struct atl1e_hw *hw, u16 *speed, u16 *duplex)
#define RXQ_RXF_PAUSE_TH_HI_SHIFT
#define PCI_COMMAND
PCI command.
static void atl1e_configure_dma(struct atl1e_adapter *adapter)
int atl1e_phy_commit(struct atl1e_hw *hw)
int atl1e_read_mac_addr(struct atl1e_hw *hw)
#define MDIO_SUP_PREAMBLE
static int atl1e_mdio_read(struct net_device *netdev, int phy_id __unused, int reg_num)
#define DMA_CTRL_DMAW_DLY_CNT_SHIFT
#define REG_TRIG_TPD_THRESH
static struct pci_device_id atl1e_pci_tbl[]
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
struct device dev
Generic device.
#define AT_TWSI_EEPROM_TIMEOUT
static int atl1e_clean_tx_irq(struct atl1e_adapter *adapter)
static void atl1e_configure_rx(struct atl1e_adapter *adapter)
static __always_inline void * bus_to_virt(unsigned long bus_addr)
Convert bus address to a virtual address.
#define DMA_CTRL_DMAR_OUT_ORDER
#define REG_PCIE_CAP_LIST
#define MASTER_CTRL_ITIMER_EN
#define MII_AT001_CR_1000T_SPEED_MASK
static int atl1e_phy_setup_autoneg_adv(struct atl1e_hw *hw)
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
#define MDIO_REG_ADDR_MASK
#define TXQ_CTRL_NUM_TPD_BURST_MASK
#define PCI_COMMAND_MASTER
Bus master.
#define MII_AR_SPEED_MASK
static void atl1e_init_netdev(struct net_device *netdev, struct pci_device *pdev)
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
#define MASTER_CTRL_ITIMER2_EN
#define AT_WRITE_REG(a, reg, value)
#define ENOMEM
Not enough space.
#define PCI_COMMAND_IO
I/O space.
void atl1e_hw_set_mac_addr(struct atl1e_hw *hw)
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int atl1e_check_eeprom_exist(struct atl1e_hw *hw)
#define MAC_CTRL_PRMLEN_MASK
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
static void atl1e_poll(struct net_device *netdev)
static void atl1e_init_ring_ptrs(struct atl1e_adapter *adapter)
#define TXQ_CTRL_NUM_TPD_BURST_SHIFT
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
static int atl1e_get_permanent_address(struct atl1e_hw *hw)
static int atl1e_configure(struct atl1e_adapter *adapter)
#define REG_RXQ_JMBOSZ_RRDTIM
void * priv
Driver private data.
pseudo_bit_t value[0x00020]
struct atl1e_rx_page rx_page[AT_PAGE_NUM_PER_QUEUE]
#define DMA_CTRL_RXCMB_EN
#define __unused
Declare a variable or data structure as unused.
#define GPHY_CTRL_DEFAULT
#define AT_WRITE_REGB(a, reg, value)
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
static int atl1e_sw_init(struct atl1e_adapter *adapter)
#define DEVICE_CTRL_MAX_PAYLOAD_MASK
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
#define REG_BASE_CPU_NUMBER
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
static void atl1e_clean_tx_ring(struct atl1e_adapter *adapter)
static struct net_device * netdev
uint16_t count
Number of entries.
static const u16 atl1e_rx_page_lo_addr_regs[AT_PAGE_NUM_PER_QUEUE]
#define MASTER_CTRL_MANUAL_INT
static void atl1e_cal_ring_size(struct atl1e_adapter *adapter, u32 *ring_size)
void unregister_netdev(struct net_device *netdev)
Unregister network device.
struct atl1e_tx_ring tx_ring
#define cpu_to_le32(value)
struct atl1e_adapter * adapter
int atl1e_reset_hw(struct atl1e_hw *hw)
int atl1e_init_hw(struct atl1e_hw *hw)
struct atl1e_tx_buffer * tx_buffer
static void atl1e_tx_queue(struct atl1e_adapter *adapter, u16 count __unused, struct atl1e_tpd_desc *tpd __unused)
#define MII_AT001_PSSR_1000MBS
static void(* free)(struct refcnt *refcnt))
#define DMA_CTRL_DMAR_REQ_PRI
void * zalloc(size_t size)
Allocate cleared memory.
static int atl1e_probe(struct pci_device *pdev)
#define MAC_CTRL_SPEED_10_100
static struct atl1e_tx_buffer * atl1e_get_tx_buffer(struct atl1e_adapter *adapter, struct atl1e_tpd_desc *tpd)
static void atl1e_close(struct net_device *netdev)
int register_netdev(struct net_device *netdev)
Register network device.
#define MASTER_CTRL_SOFT_RST
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
static void atl1e_irq_disable(struct atl1e_adapter *adapter)
#define MII_AT001_PSSR_100MBS
#define REG_HOST_RXF0_MB0_LO
#define AT_HW_MAX_IDLE_DELAY
#define REG_RXF0_BASE_ADDR_HI
void(* mdio_write)(struct net_device *dev, int phy_id, int location, int val)
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static struct atl1e_rx_page * atl1e_get_rx_page(struct atl1e_adapter *adapter)
static void atl1e_clean_rx_ring(struct atl1e_adapter *adapter)
static struct net_device_operations atl1e_netdev_ops
#define REG_SMB_STAT_TIMER
#define RXQ_RXF_PAUSE_TH_LO_SHIFT
#define MII_AR_100TX_HD_CAPS
A PCI device ID list entry.
#define REG_TRIG_RRD_THRESH
#define DEVICE_CTRL_MAX_PAYLOAD_SHIFT
int atl1e_phy_init(struct atl1e_hw *hw)
#define RXQ_RXF_PAUSE_TH_LO_MASK
#define DEVICE_CTRL_MAX_RREQ_SZ_MASK
static struct xen_remove_from_physmap * remove
#define DMA_CTRL_DMAR_DLY_CNT_MASK
#define AT_WRITE_REG_ARRAY(a, reg, offset, value)
Network device operations.
static void atl1e_init_ring_resources(struct atl1e_adapter *adapter)
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
void atl1e_down(struct atl1e_adapter *adapter)
static void atl1e_reset(struct atl1e_adapter *adapter)
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
int atl1e_read_phy_reg(struct atl1e_hw *hw, u16 reg_addr, u16 *phy_data)
static void atl1e_mdio_write(struct net_device *netdev, int phy_id __unused, int reg_num, int val)
#define MII_AR_10T_HD_CAPS
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
#define iob_reserve(iobuf, len)
#define REG_RX_HASH_TABLE
#define RXQ_RXF_PAUSE_TH_HI_MASK
#define MASTER_CTRL_LED_MODE
struct pci_driver atl1e_driver __pci_driver
char name[NETDEV_NAME_LEN]
Name of this network device.
#define MII_AT001_CR_1000T_DEFAULT_CAP_MASK
#define DMA_CTRL_DMAW_DLY_CNT_MASK
#define RRS_PKT_SIZE_SHIFT
struct net_device * netdev
#define RRS_PKT_SIZE_MASK
#define MII_AR_10T_FD_CAPS
#define AT_WRITE_FLUSH(a)
#define REG_TPD_BASE_ADDR_LO
int(* probe)(struct pci_device *pci)
Probe device.
static void atl1e_configure_tx(struct atl1e_adapter *adapter)
void * data
Start of data.
#define EIO
Input/output error.
#define RXQ_CTRL_CUT_THRU_EN
#define REG_HOST_RXF0_PAGE1_VLD
#define MII_CR_AUTO_NEG_EN
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
static int atl1e_xmit_frame(struct net_device *netdev, struct io_buffer *iob)
#define PCI_REVISION
PCI revision.
#define RXQ_JMBO_LKAH_SHIFT
int atl1e_restart_autoneg(struct atl1e_hw *hw)
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
#define REG_HOST_TX_CMB_LO
uint16_t offset
Offset to command line.
#define MDIO_CLK_SEL_SHIFT
#define PCI_COMMAND_MEM
Memory space.
#define AT_PAGE_NUM_PER_QUEUE
#define REG_SPI_FLASH_CTRL
#define MAC_CTRL_SPEED_SHIFT
static void atl1e_setup_pcicmd(struct pci_device *pdev)
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
#define DMA_CTRL_DMAR_DLY_CNT_SHIFT
static void atl1e_remove(struct pci_device *pdev)
#define RXQ_JMBOSZ_TH_SHIFT
#define REG_HOST_RXF0_PAGE0_VLD
#define SPI_FLASH_CTRL_EN_VPD
static u16 atl1e_tpd_avail(struct atl1e_adapter *adapter)
#define DBG(...)
Print a debugging message.
static const u16 atl1e_rx_page_write_offset_regs[AT_PAGE_NUM_PER_QUEUE]
static struct atl1e_tpd_desc * atl1e_get_tpd(struct atl1e_adapter *adapter)
#define REG_HOST_RXF0_PAGE1_LO
int atl1e_up(struct atl1e_adapter *adapter)
static void atl1e_tx_map(struct atl1e_adapter *adapter, struct io_buffer *iob, struct atl1e_tpd_desc *tpd)
static void atl1e_clear_phy_int(struct atl1e_adapter *adapter)
#define RXQ_JMBOSZ_TH_MASK
#define MII_AT001_PSSR_SPEED
static void atl1e_free_ring_resources(struct atl1e_adapter *adapter)
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
#define PCI_ROM(_vendor, _device, _name, _description, _data)
#define MII_AT001_PSSR_SPD_DPLX_RESOLVED
#define MII_AT001_PSSR_10MBS
#define PHY_STATUS_EMI_CA
#define REG_TPD_RING_SIZE
#define DMA_CTRL_DMAW_BURST_LEN_SHIFT
#define TXQ_CTRL_ENH_MODE
if(natsemi->flags &NATSEMI_64BIT) return 1
void * memset(void *dest, int character, size_t len) __nonnull
#define REG_RXQ_RXF_PAUSE_THRESH
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define RXQ_CTRL_PBA_ALIGN_32
#define DMA_CTRL_DMAR_BURST_LEN_SHIFT
#define REG_HOST_RXFPAGE_SIZE
#define DMA_CTRL_DMAR_BURST_LEN_MASK
static void atl1e_init_pcie(struct atl1e_hw *hw)
#define AT_READ_REG(a, reg)