blob: 30d61e48ac6088219c254dc2d1f42bb936438788 [file] [log] [blame]
Ben Hutchings8ceee662008-04-27 12:55:59 +01001/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_FALCON_H
12#define EFX_FALCON_H
13
14#include "net_driver.h"
15
16/*
17 * Falcon hardware control
18 */
19
20enum falcon_revision {
21 FALCON_REV_A0 = 0,
22 FALCON_REV_A1 = 1,
23 FALCON_REV_B0 = 2,
24};
25
Ben Hutchings55668612008-05-16 21:16:10 +010026static inline int falcon_rev(struct efx_nic *efx)
27{
28 return efx->pci_dev->revision;
29}
Ben Hutchings8ceee662008-04-27 12:55:59 +010030
31extern struct efx_nic_type falcon_a_nic_type;
32extern struct efx_nic_type falcon_b_nic_type;
33
34/**************************************************************************
35 *
36 * Externs
37 *
38 **************************************************************************
39 */
40
41/* TX data path */
42extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010043extern void falcon_init_tx(struct efx_tx_queue *tx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +010044extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
45extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
46extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
47
48/* RX data path */
49extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010050extern void falcon_init_rx(struct efx_rx_queue *rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +010051extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
52extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
53extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
54
55/* Event data path */
56extern int falcon_probe_eventq(struct efx_channel *channel);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010057extern void falcon_init_eventq(struct efx_channel *channel);
Ben Hutchings8ceee662008-04-27 12:55:59 +010058extern void falcon_fini_eventq(struct efx_channel *channel);
59extern void falcon_remove_eventq(struct efx_channel *channel);
Ben Hutchings42cbe2d2008-09-01 12:48:08 +010060extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota);
Ben Hutchings8ceee662008-04-27 12:55:59 +010061extern void falcon_eventq_read_ack(struct efx_channel *channel);
62
63/* Ports */
64extern int falcon_probe_port(struct efx_nic *efx);
65extern void falcon_remove_port(struct efx_nic *efx);
66
67/* MAC/PHY */
Ben Hutchingsdc8cfa52008-09-01 12:46:50 +010068extern bool falcon_xaui_link_ok(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +010069extern int falcon_dma_stats(struct efx_nic *efx,
70 unsigned int done_offset);
71extern void falcon_drain_tx_fifo(struct efx_nic *efx);
72extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
73extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
74
75/* Interrupts and test events */
76extern int falcon_init_interrupt(struct efx_nic *efx);
77extern void falcon_enable_interrupts(struct efx_nic *efx);
78extern void falcon_generate_test_event(struct efx_channel *channel,
79 unsigned int magic);
80extern void falcon_generate_interrupt(struct efx_nic *efx);
81extern void falcon_set_int_moderation(struct efx_channel *channel);
82extern void falcon_disable_interrupts(struct efx_nic *efx);
83extern void falcon_fini_interrupt(struct efx_nic *efx);
84
85/* Global Resources */
86extern int falcon_probe_nic(struct efx_nic *efx);
87extern int falcon_probe_resources(struct efx_nic *efx);
88extern int falcon_init_nic(struct efx_nic *efx);
89extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
90extern void falcon_remove_resources(struct efx_nic *efx);
91extern void falcon_remove_nic(struct efx_nic *efx);
92extern void falcon_update_nic_stats(struct efx_nic *efx);
93extern void falcon_set_multicast_hash(struct efx_nic *efx);
94extern int falcon_reset_xaui(struct efx_nic *efx);
95
Ben Hutchings8c8661e2008-09-01 12:49:02 +010096/* Tests */
97struct falcon_nvconfig;
98extern int falcon_read_nvram(struct efx_nic *efx,
99 struct falcon_nvconfig *nvconfig);
100extern int falcon_test_registers(struct efx_nic *efx);
101
Ben Hutchings8ceee662008-04-27 12:55:59 +0100102/**************************************************************************
103 *
104 * Falcon MAC stats
105 *
106 **************************************************************************
107 */
108
109#define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
110#define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
111
112/* Retrieve statistic from statistics block */
113#define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
114 if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
115 (efx)->mac_stats.efx_stat += le16_to_cpu( \
116 *((__force __le16 *) \
117 (efx->stats_buffer.addr + \
118 FALCON_STAT_OFFSET(falcon_stat)))); \
119 else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
120 (efx)->mac_stats.efx_stat += le32_to_cpu( \
121 *((__force __le32 *) \
122 (efx->stats_buffer.addr + \
123 FALCON_STAT_OFFSET(falcon_stat)))); \
124 else \
125 (efx)->mac_stats.efx_stat += le64_to_cpu( \
126 *((__force __le64 *) \
127 (efx->stats_buffer.addr + \
128 FALCON_STAT_OFFSET(falcon_stat)))); \
129 } while (0)
130
131#define FALCON_MAC_STATS_SIZE 0x100
132
133#define MAC_DATA_LBN 0
134#define MAC_DATA_WIDTH 32
135
136extern void falcon_generate_event(struct efx_channel *channel,
137 efx_qword_t *event);
138
139#endif /* EFX_FALCON_H */