blob: 8d232bf612e709be23cdc04ddc05abea1901356b [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"
Ben Hutchings177dfcd2008-12-12 21:50:08 -080015#include "efx.h"
Ben Hutchings8ceee662008-04-27 12:55:59 +010016
17/*
18 * Falcon hardware control
19 */
20
21enum falcon_revision {
22 FALCON_REV_A0 = 0,
23 FALCON_REV_A1 = 1,
24 FALCON_REV_B0 = 2,
25};
26
Ben Hutchings55668612008-05-16 21:16:10 +010027static inline int falcon_rev(struct efx_nic *efx)
28{
29 return efx->pci_dev->revision;
30}
Ben Hutchings8ceee662008-04-27 12:55:59 +010031
32extern struct efx_nic_type falcon_a_nic_type;
33extern struct efx_nic_type falcon_b_nic_type;
34
35/**************************************************************************
36 *
37 * Externs
38 *
39 **************************************************************************
40 */
41
Ben Hutchings5087b542009-10-23 08:29:51 +000042extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info);
43
Ben Hutchings8ceee662008-04-27 12:55:59 +010044/* TX data path */
45extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010046extern void falcon_init_tx(struct efx_tx_queue *tx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +010047extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
48extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
49extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
50
51/* RX data path */
52extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010053extern void falcon_init_rx(struct efx_rx_queue *rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +010054extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
55extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
56extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
57
58/* Event data path */
59extern int falcon_probe_eventq(struct efx_channel *channel);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010060extern void falcon_init_eventq(struct efx_channel *channel);
Ben Hutchings8ceee662008-04-27 12:55:59 +010061extern void falcon_fini_eventq(struct efx_channel *channel);
62extern void falcon_remove_eventq(struct efx_channel *channel);
Ben Hutchings42cbe2d2008-09-01 12:48:08 +010063extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota);
Ben Hutchings8ceee662008-04-27 12:55:59 +010064extern void falcon_eventq_read_ack(struct efx_channel *channel);
65
66/* Ports */
67extern int falcon_probe_port(struct efx_nic *efx);
68extern void falcon_remove_port(struct efx_nic *efx);
69
70/* MAC/PHY */
Ben Hutchings177dfcd2008-12-12 21:50:08 -080071extern int falcon_switch_mac(struct efx_nic *efx);
Ben Hutchingsdc8cfa52008-09-01 12:46:50 +010072extern bool falcon_xaui_link_ok(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +010073extern int falcon_dma_stats(struct efx_nic *efx,
74 unsigned int done_offset);
75extern void falcon_drain_tx_fifo(struct efx_nic *efx);
76extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
77extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
78
79/* Interrupts and test events */
80extern int falcon_init_interrupt(struct efx_nic *efx);
81extern void falcon_enable_interrupts(struct efx_nic *efx);
82extern void falcon_generate_test_event(struct efx_channel *channel,
83 unsigned int magic);
Ben Hutchings177dfcd2008-12-12 21:50:08 -080084extern void falcon_sim_phy_event(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +010085extern void falcon_generate_interrupt(struct efx_nic *efx);
86extern void falcon_set_int_moderation(struct efx_channel *channel);
87extern void falcon_disable_interrupts(struct efx_nic *efx);
88extern void falcon_fini_interrupt(struct efx_nic *efx);
89
Ben Hutchings6fb70fd2009-03-20 13:30:37 +000090#define FALCON_IRQ_MOD_RESOLUTION 5
91
Ben Hutchings8ceee662008-04-27 12:55:59 +010092/* Global Resources */
93extern int falcon_probe_nic(struct efx_nic *efx);
94extern int falcon_probe_resources(struct efx_nic *efx);
95extern int falcon_init_nic(struct efx_nic *efx);
Ben Hutchings6bc5d3a2008-09-01 12:49:37 +010096extern int falcon_flush_queues(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +010097extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
98extern void falcon_remove_resources(struct efx_nic *efx);
99extern void falcon_remove_nic(struct efx_nic *efx);
100extern void falcon_update_nic_stats(struct efx_nic *efx);
101extern void falcon_set_multicast_hash(struct efx_nic *efx);
102extern int falcon_reset_xaui(struct efx_nic *efx);
103
Ben Hutchings8c8661e2008-09-01 12:49:02 +0100104/* Tests */
105struct falcon_nvconfig;
106extern int falcon_read_nvram(struct efx_nic *efx,
107 struct falcon_nvconfig *nvconfig);
108extern int falcon_test_registers(struct efx_nic *efx);
109
Ben Hutchings8ceee662008-04-27 12:55:59 +0100110/**************************************************************************
111 *
112 * Falcon MAC stats
113 *
114 **************************************************************************
115 */
116
117#define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
118#define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
119
120/* Retrieve statistic from statistics block */
121#define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
122 if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
123 (efx)->mac_stats.efx_stat += le16_to_cpu( \
124 *((__force __le16 *) \
125 (efx->stats_buffer.addr + \
126 FALCON_STAT_OFFSET(falcon_stat)))); \
127 else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
128 (efx)->mac_stats.efx_stat += le32_to_cpu( \
129 *((__force __le32 *) \
130 (efx->stats_buffer.addr + \
131 FALCON_STAT_OFFSET(falcon_stat)))); \
132 else \
133 (efx)->mac_stats.efx_stat += le64_to_cpu( \
134 *((__force __le64 *) \
135 (efx->stats_buffer.addr + \
136 FALCON_STAT_OFFSET(falcon_stat)))); \
137 } while (0)
138
139#define FALCON_MAC_STATS_SIZE 0x100
140
141#define MAC_DATA_LBN 0
142#define MAC_DATA_WIDTH 32
143
144extern void falcon_generate_event(struct efx_channel *channel,
145 efx_qword_t *event);
146
147#endif /* EFX_FALCON_H */